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