blob: ae6ef9791c2a09f99f573668a5a61ea3e211c9f6 [file] [log] [blame]
Daniel Dunbar8fbe78f2009-12-15 20:14:24 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
Chris Lattneraa9c7ae2008-04-08 04:40:51 +00002void f(int i);
Chris Lattner0369c572008-11-23 23:12:31 +00003void f(int i = 0); // expected-note {{previous definition is here}}
Chris Lattneraa9c7ae2008-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 Gregor4f4946a2010-04-22 00:20:18 +000017void i(int = s) { } // expected-error {{no viable conversion}} \
18// expected-note{{passing argument to parameter here}}
Douglas Gregor5496d4c2008-11-04 13:57:51 +000019
20struct X {
21 X(int);
22};
23
24void j(X x = 17);
25
Douglas Gregora4b592a2009-12-19 03:01:41 +000026struct Y { // expected-note 2{{candidate}}
Douglas Gregor5496d4c2008-11-04 13:57:51 +000027 explicit Y(int);
28};
29
Douglas Gregor4f4946a2010-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 Gregor58354032008-12-24 00:01:03 +000032
Douglas Gregor4f4946a2010-04-22 00:20:18 +000033void kk(Y = 17); // expected-error{{no viable conversion}} \
34// expected-note{{passing argument to parameter here}}
James Molloye9430032012-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}}
50 j(); // expected-error{{too few arguments to function call, expected 1, have 0}}
51 }
52}