1 // RUN: clang-cc -fsyntax-only -verify %s
4 class C { C(int a0 = 0); };
11 template<typename T> void f1(T a, T b = 10) { } // expected-error{{cannot initialize 'b' with an rvalue of type 'int'}}
13 template<typename T> void f2(T a, T b = T()) { }
15 template<typename T> void f3(T a, T b = T() + T()); // expected-error{{invalid operands to binary expression ('struct S' and 'struct S')}}
19 f1(S()); // expected-note{{in instantiation of default function argument expression for 'f1<struct S>' required here}}
25 f3(S()); // expected-note{{in instantiation of default function argument expression for 'f3<struct S>' required here}}
28 template<typename T> struct F {
29 F(T t = 10); // expected-error{{cannot initialize 't' with an rvalue of type 'int'}}
30 void f(T t = 10); // expected-error{{cannot initialize 't' with an rvalue of type 'int'}}
33 struct FD : F<int> { };
40 void g3(F<int> f, F<struct S> s) {
42 s.f(); // expected-note{{in instantiation of default function argument expression for 'f<struct S>' required here}}
45 F<S> s2; // expected-note{{in instantiation of default function argument expression for 'F<struct S>' required here}}
48 template<typename T> struct G {
52 void s(G<int> flags = 10) { }
54 // Test default arguments
57 void f(T = T()); // expected-error{{no matching}}
63 void test_x0(X0<int> xi) {
68 struct NotDefaultConstructible { // expected-note{{candidate}}
69 NotDefaultConstructible(int); // expected-note{{candidate}}
72 void test_x0_not_default_constructible(X0<NotDefaultConstructible> xn) {
73 xn.f(NotDefaultConstructible(17));
75 xn.f(); // expected-note{{in instantiation of default function argument}}
81 X1(const value_type& value = value_type());
90 template<typename T> struct A {
91 A(T = 1); // expected-error 3 {{incompatible type initializing 'int', expected 'int *'}}
97 B::B() { } // expected-note {{in instantiation of default function argument expression for 'A<int *>' required he}}
99 struct C : virtual A<int*> {
102 C::C() { } // expected-note {{in instantiation of default function argument expression for 'A<int *>' required he}}
109 D::D() { } // expected-note {{in instantiation of default function argument expression for 'A<int *>' required he}}