2009-12-16 04:14:24 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
|
2008-04-08 12:40:51 +08:00
|
|
|
void f(int i);
|
2008-11-24 07:12:31 +08:00
|
|
|
void f(int i = 0); // expected-note {{previous definition is here}}
|
2008-04-08 12:40:51 +08:00
|
|
|
void f(int i = 17); // expected-error {{redefinition of default argument}}
|
|
|
|
|
|
|
|
|
|
|
|
void g(int i, int j, int k = 3);
|
|
|
|
void g(int i, int j = 2, int k);
|
|
|
|
void g(int i = 1, int j, int k);
|
|
|
|
|
|
|
|
void h(int i, int j = 2, int k = 3,
|
|
|
|
int l, // expected-error {{missing default argument on parameter 'l'}}
|
|
|
|
int, // expected-error {{missing default argument on parameter}}
|
|
|
|
int n);// expected-error {{missing default argument on parameter 'n'}}
|
|
|
|
|
|
|
|
struct S { } s;
|
2010-04-22 08:20:18 +08:00
|
|
|
void i(int = s) { } // expected-error {{no viable conversion}} \
|
|
|
|
// expected-note{{passing argument to parameter here}}
|
2008-11-04 21:57:51 +08:00
|
|
|
|
|
|
|
struct X {
|
|
|
|
X(int);
|
|
|
|
};
|
|
|
|
|
2013-07-09 07:13:44 +08:00
|
|
|
void j(X x = 17); // expected-note{{'::j' declared here}}
|
2008-11-04 21:57:51 +08:00
|
|
|
|
2009-12-19 11:01:41 +08:00
|
|
|
struct Y { // expected-note 2{{candidate}}
|
2008-11-04 21:57:51 +08:00
|
|
|
explicit Y(int);
|
|
|
|
};
|
|
|
|
|
2010-04-22 08:20:18 +08:00
|
|
|
void k(Y y = 17); // expected-error{{no viable conversion}} \
|
|
|
|
// expected-note{{passing argument to parameter 'y' here}}
|
2008-12-24 08:01:03 +08:00
|
|
|
|
2010-04-22 08:20:18 +08:00
|
|
|
void kk(Y = 17); // expected-error{{no viable conversion}} \
|
|
|
|
// expected-note{{passing argument to parameter here}}
|
2012-03-13 16:55:35 +08:00
|
|
|
|
|
|
|
int l () {
|
|
|
|
int m(int i, int j, int k = 3);
|
|
|
|
if (1)
|
|
|
|
{
|
|
|
|
int m(int i, int j = 2, int k = 4);
|
|
|
|
m(8);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int i () {
|
|
|
|
void j (int f = 4);
|
|
|
|
{
|
2013-07-09 07:13:44 +08:00
|
|
|
void j (int f);
|
|
|
|
j(); // expected-error{{too few arguments to function call, expected 1, have 0; did you mean '::j'?}}
|
|
|
|
}
|
|
|
|
void jj (int f = 4);
|
|
|
|
{
|
|
|
|
void jj (int f); // expected-note{{'jj' declared here}}
|
|
|
|
jj(); // expected-error{{too few arguments to function call, single argument 'f' was not specified}}
|
2012-05-15 14:21:54 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int i2() {
|
|
|
|
void j(int f = 4); // expected-note{{'j' declared here}}
|
|
|
|
{
|
|
|
|
j(2, 3); // expected-error{{too many arguments to function call, expected at most single argument 'f', have 2}}
|
2012-03-13 16:55:35 +08:00
|
|
|
}
|
|
|
|
}
|
2014-07-22 09:54:49 +08:00
|
|
|
|
|
|
|
int pr20055_f(int x = 0, int y = UNDEFINED); // expected-error{{use of undeclared identifier}}
|
|
|
|
int pr20055_v = pr20055_f(0);
|
2014-08-28 06:31:34 +08:00
|
|
|
|
|
|
|
void PR20769() { void PR20769(int = 1); }
|
|
|
|
void PR20769(int = 2);
|
|
|
|
|
|
|
|
void PR20769_b(int = 1);
|
|
|
|
void PR20769_b() { void PR20769_b(int = 2); }
|