blob: be264ad62b130790fa25912c0a6583a4443fbc37 [file] [log] [blame]
Daniel Dunbard7d5f022009-03-24 02:24:46 +00001// RUN: clang-cc -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;
17void i(int = s) { } // expected-error {{incompatible type}}
Douglas Gregoreb704f22008-11-04 13:57:51 +000018
19struct X {
20 X(int);
21};
22
23void j(X x = 17);
24
25struct Y {
26 explicit Y(int);
27};
28
Douglas Gregor61366e92008-12-24 00:01:03 +000029void k(Y y = 17); // expected-error{{cannot initialize 'y' with an rvalue of type 'int'}}
30
31void kk(Y = 17); // expected-error{{cannot initialize a value of type 'struct Y' with an rvalue of type 'int'}}