blob: d689cc86e6b16c729b1798a7df5b66f6278c6d80 [file] [log] [blame]
Anders Carlsson9351c172009-08-25 03:18:48 +00001// RUN: clang-cc -fsyntax-only -verify %s
2
3struct S { };
4
5template<typename T> void f1(T a, T b = 10) { } // expected-error{{cannot initialize 'b' with an rvalue of type 'int'}}
6
7template<typename T> void f2(T a, T b = T()) { }
8
9template<typename T> void f3(T a, T b = T() + T()); // expected-error{{invalid operands to binary expression ('struct S' and 'struct S')}}
10
11void g() {
12 f1(10);
Anders Carlsson25cae7f2009-09-05 05:14:19 +000013 f1(S()); // expected-note{{in instantiation of default function argument expression for 'f1<struct S>' required here}}
Anders Carlsson9351c172009-08-25 03:18:48 +000014
15 f2(10);
16 f2(S());
17
18 f3(10);
Anders Carlsson25cae7f2009-09-05 05:14:19 +000019 f3(S()); // expected-note{{in instantiation of default function argument expression for 'f3<struct S>' required here}}
Anders Carlsson9351c172009-08-25 03:18:48 +000020}
Anders Carlsson8644aec2009-08-25 13:07:08 +000021
22template<typename T> struct F {
Anders Carlsson21e1c4e2009-09-06 16:54:02 +000023 F(T t = 10); // expected-error{{cannot initialize 't' with an rvalue of type 'int'}}
Anders Carlsson6bc107b2009-09-05 05:38:54 +000024 void f(T t = 10); // expected-error{{cannot initialize 't' with an rvalue of type 'int'}}
Anders Carlsson8644aec2009-08-25 13:07:08 +000025};
26
Douglas Gregor0b84a532009-08-25 15:24:38 +000027struct FD : F<int> { };
28
Anders Carlsson8644aec2009-08-25 13:07:08 +000029void g2() {
Anders Carlsson25cae7f2009-09-05 05:14:19 +000030 F<int> f;
Douglas Gregor0b84a532009-08-25 15:24:38 +000031 FD fd;
Anders Carlsson8644aec2009-08-25 13:07:08 +000032}
Anders Carlsson5653ca52009-08-25 13:46:13 +000033
Anders Carlsson6bc107b2009-09-05 05:38:54 +000034void g3(F<int> f, F<struct S> s) {
35 f.f();
36 s.f(); // expected-note{{in instantiation of default function argument expression for 'f<struct S>' required here}}
Anders Carlsson21e1c4e2009-09-06 16:54:02 +000037
38 F<int> f2;
39 F<S> s2; // expected-note{{in instantiation of default function argument expression for 'F<struct S>' required here}}
Anders Carlsson6bc107b2009-09-05 05:38:54 +000040}
41
Anders Carlsson5653ca52009-08-25 13:46:13 +000042template<typename T> struct G {
Anders Carlsson25cae7f2009-09-05 05:14:19 +000043 G(T) {}
Anders Carlsson5653ca52009-08-25 13:46:13 +000044};
45
46void s(G<int> flags = 10) { }
47
48
Anders Carlsson6bc107b2009-09-05 05:38:54 +000049