blob: 7e705b034d4556c4411cafeb6c33a6bb4d4bd7a8 [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);
13 f1(S()); // expected-note{{in instantiation of default argument for 'f1<struct S>' required here}}
14
15 f2(10);
16 f2(S());
17
18 f3(10);
19 f3(S()); // expected-note{{in instantiation of default argument for 'f3<struct S>' required here}}
20}
Anders Carlsson8644aec2009-08-25 13:07:08 +000021
22template<typename T> struct F {
23 F(T t = 10);
24};
25
Douglas Gregor0b84a532009-08-25 15:24:38 +000026struct FD : F<int> { };
27
Anders Carlsson8644aec2009-08-25 13:07:08 +000028void g2() {
29 F<int> f;
Douglas Gregor0b84a532009-08-25 15:24:38 +000030 FD fd;
Anders Carlsson8644aec2009-08-25 13:07:08 +000031}
Anders Carlsson5653ca52009-08-25 13:46:13 +000032
33template<typename T> struct G {
34 G(T) {}
35};
36
37void s(G<int> flags = 10) { }
38
39