1 // RUN: %clang_cc1 -fsyntax-only -verify %s
2 void f(int i);
3 void f(int i = 0); // expected-note {{previous definition is here}}
4 void f(int i = 17); // expected-error {{redefinition of default argument}}
5
6
7 void g(int i, int j, int k = 3);
8 void g(int i, int j = 2, int k);
9 void g(int i = 1, int j, int k);
10
11 void h(int i, int j = 2, int k = 3,
12 int l, // expected-error {{missing default argument on parameter 'l'}}
13 int, // expected-error {{missing default argument on parameter}}
14 int n);// expected-error {{missing default argument on parameter 'n'}}
15
16 struct S { } s;
i(int=s)17 void i(int = s) { } // expected-error {{no viable conversion}} \
18 // expected-note{{passing argument to parameter here}}
19
20 struct X {
21 X(int);
22 };
23
24 void j(X x = 17); // expected-note{{'::j' declared here}}
25
26 struct Y { // expected-note 2{{candidate}}
27 explicit Y(int);
28 };
29
30 void k(Y y = 17); // expected-error{{no viable conversion}} \
31 // expected-note{{passing argument to parameter 'y' here}}
32
33 void kk(Y = 17); // expected-error{{no viable conversion}} \
34 // expected-note{{passing argument to parameter here}}
35
l()36 int l () {
37 int m(int i, int j, int k = 3);
38 if (1)
39 {
40 int m(int i, int j = 2, int k = 4);
41 m(8);
42 }
43 return 0;
44 }
45
i()46 int i () {
47 void j (int f = 4);
48 {
49 void j (int f);
50 j(); // expected-error{{too few arguments to function call, expected 1, have 0; did you mean '::j'?}}
51 }
52 void jj (int f = 4);
53 {
54 void jj (int f); // expected-note{{'jj' declared here}}
55 jj(); // expected-error{{too few arguments to function call, single argument 'f' was not specified}}
56 }
57 }
58
i2()59 int i2() {
60 void j(int f = 4); // expected-note{{'j' declared here}}
61 {
62 j(2, 3); // expected-error{{too many arguments to function call, expected at most single argument 'f', have 2}}
63 }
64 }
65
66 int pr20055_f(int x = 0, int y = UNDEFINED); // expected-error{{use of undeclared identifier}}
67 int pr20055_v = pr20055_f(0);
68
PR20769()69 void PR20769() { void PR20769(int = 1); }
70 void PR20769(int = 2);
71
72 void PR20769_b(int = 1);
PR20769_b()73 void PR20769_b() { void PR20769_b(int = 2); }
74