blob: c8c197e153d4f4f2facabd69ad279604e6c77214 [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
Chris Lattner04421082008-04-08 04:40:51 +00002void f(int i);
Chris Lattner5f4a6822008-11-23 23:12:31 +00003void f(int i = 0); // expected-note {{previous definition is here}}
Chris Lattner04421082008-04-08 04:40:51 +00004void f(int i = 17); // expected-error {{redefinition of default argument}}
5
6
7void g(int i, int j, int k = 3);
8void g(int i, int j = 2, int k);
9void g(int i = 1, int j, int k);
10
11void 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
16struct S { } s;
Douglas Gregora41a8c52010-04-22 00:20:18 +000017void i(int = s) { } // expected-error {{no viable conversion}} \
18// expected-note{{passing argument to parameter here}}
Douglas Gregoreb704f22008-11-04 13:57:51 +000019
20struct X {
21 X(int);
22};
23
24void j(X x = 17);
25
Douglas Gregor7abfbdb2009-12-19 03:01:41 +000026struct Y { // expected-note 2{{candidate}}
Douglas Gregoreb704f22008-11-04 13:57:51 +000027 explicit Y(int);
28};
29
Douglas Gregora41a8c52010-04-22 00:20:18 +000030void k(Y y = 17); // expected-error{{no viable conversion}} \
31// expected-note{{passing argument to parameter 'y' here}}
Douglas Gregor61366e92008-12-24 00:01:03 +000032
Douglas Gregora41a8c52010-04-22 00:20:18 +000033void kk(Y = 17); // expected-error{{no viable conversion}} \
34// expected-note{{passing argument to parameter here}}
James Molloy9cda03f2012-03-13 08:55:35 +000035
36int 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
46int i () {
47 void j (int f = 4);
48 {
49 void j (int f); // expected-note{{'j' declared here}}
Richard Smithc608c3c2012-05-15 06:21:54 +000050 j(); // expected-error{{too few arguments to function call, single argument 'f' was not specified}}
51 }
52}
53
54int i2() {
55 void j(int f = 4); // expected-note{{'j' declared here}}
56 {
57 j(2, 3); // expected-error{{too many arguments to function call, expected at most single argument 'f', have 2}}
James Molloy9cda03f2012-03-13 08:55:35 +000058 }
59}