parameters with default arguments. Directly follow the wording by relaxing the AST invariant that all parameters after one with a default arguemnt also have default arguments, and removing the diagnostic on missing default arguments on a pack-expanded parameter following a parameter with a default argument. Testing also revealed that we need to special-case explicit specializations of templates with a pack following a parameter with a default argument, as such explicit specializations are otherwise impossible to write. The standard wording doesn't address this case; a issue has been filed. This exposed a bug where we would briefly consider a parameter to have no default argument while we parse a delay-parsed default argument for that parameter, which is also fixed. Partially incorporates a patch by Raul Tambre.
23 lines
762 B
C++
23 lines
762 B
C++
// RUN: %clang_cc1 -verify %s
|
|
|
|
void a(int x = 0, int y); // #1 expected-error {{missing default argument on parameter 'y'}}
|
|
void b() {
|
|
a(); // expected-error {{no matching function}} expected-note@#1 {{requires 2 arguments, but 0 were provided}}
|
|
a(0); // expected-error {{no matching function}} expected-note@#1 {{requires 2 arguments, but 1 was provided}}
|
|
a(0, 0);
|
|
}
|
|
|
|
void a(int x, int y = 0);
|
|
void c() {
|
|
a();
|
|
a(0);
|
|
a(0, 0);
|
|
}
|
|
|
|
template<typename ...T> void f(int x = 0, T ...); // #2
|
|
void g() {
|
|
f<int>(); // expected-error {{no matching function}} expected-note@#2 {{requires 2 arguments, but 0 were provided}}
|
|
f<int>(0); // expected-error {{no matching function}} expected-note@#2 {{requires 2 arguments, but 1 was provided}}
|
|
f<int>(0, 0);
|
|
}
|