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