Daniel Dunbar | d7d5f02 | 2009-03-24 02:24:46 +0000 | [diff] [blame] | 1 | // RUN: clang-cc -fsyntax-only -verify %s |
Chris Lattner | 0442108 | 2008-04-08 04:40:51 +0000 | [diff] [blame] | 2 | void f(int i); |
Chris Lattner | 5f4a682 | 2008-11-23 23:12:31 +0000 | [diff] [blame] | 3 | void f(int i = 0); // expected-note {{previous definition is here}} |
Chris Lattner | 0442108 | 2008-04-08 04:40:51 +0000 | [diff] [blame] | 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; |
| 17 | void i(int = s) { } // expected-error {{incompatible type}} |
Douglas Gregor | eb704f2 | 2008-11-04 13:57:51 +0000 | [diff] [blame] | 18 | |
| 19 | struct X { |
| 20 | X(int); |
| 21 | }; |
| 22 | |
| 23 | void j(X x = 17); |
| 24 | |
| 25 | struct Y { |
| 26 | explicit Y(int); |
| 27 | }; |
| 28 | |
Douglas Gregor | 61366e9 | 2008-12-24 00:01:03 +0000 | [diff] [blame] | 29 | void k(Y y = 17); // expected-error{{cannot initialize 'y' with an rvalue of type 'int'}} |
| 30 | |
| 31 | void kk(Y = 17); // expected-error{{cannot initialize a value of type 'struct Y' with an rvalue of type 'int'}} |