Anders Carlsson | 9351c17 | 2009-08-25 03:18:48 +0000 | [diff] [blame] | 1 | // RUN: clang-cc -fsyntax-only -verify %s |
| 2 | |
| 3 | struct S { }; |
| 4 | |
| 5 | template<typename T> void f1(T a, T b = 10) { } // expected-error{{cannot initialize 'b' with an rvalue of type 'int'}} |
| 6 | |
| 7 | template<typename T> void f2(T a, T b = T()) { } |
| 8 | |
| 9 | template<typename T> void f3(T a, T b = T() + T()); // expected-error{{invalid operands to binary expression ('struct S' and 'struct S')}} |
| 10 | |
| 11 | void 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 Carlsson | 8644aec | 2009-08-25 13:07:08 +0000 | [diff] [blame] | 21 | |
| 22 | template<typename T> struct F { |
| 23 | F(T t = 10); |
| 24 | }; |
| 25 | |
| 26 | void g2() { |
| 27 | F<int> f; |
| 28 | } |
Anders Carlsson | 5653ca5 | 2009-08-25 13:46:13 +0000 | [diff] [blame^] | 29 | |
| 30 | template<typename T> struct G { |
| 31 | G(T) {} |
| 32 | }; |
| 33 | |
| 34 | void s(G<int> flags = 10) { } |
| 35 | |
| 36 | |