Douglas Gregor | 5f62c5e | 2009-05-14 23:26:13 +0000 | [diff] [blame] | 1 | // RUN: clang-cc -fsyntax-only -verify %s |
| 2 | |
| 3 | template<typename T, typename U> |
| 4 | struct X0 { |
| 5 | void f(T x, U y) { |
| 6 | x + y; // expected-error{{invalid operands}} |
| 7 | } |
| 8 | }; |
| 9 | |
| 10 | struct X1 { }; |
| 11 | |
| 12 | template struct X0<int, float>; |
| 13 | template struct X0<int*, int>; |
| 14 | template struct X0<int X1::*, int>; // expected-note{{instantiation of}} |
Douglas Gregor | bd5c81c | 2009-05-14 23:40:54 +0000 | [diff] [blame] | 15 | |
| 16 | template<typename T> |
| 17 | struct X2 { |
| 18 | void f(T); |
| 19 | |
| 20 | T g(T x, T y) { |
Douglas Gregor | b06585a | 2009-05-15 00:01:03 +0000 | [diff] [blame] | 21 | /* DeclStmt */; |
| 22 | T *xp = &x, &yr = y; // expected-error{{pointer to a reference}} |
Douglas Gregor | bd5c81c | 2009-05-14 23:40:54 +0000 | [diff] [blame] | 23 | /* NullStmt */; |
| 24 | } |
| 25 | }; |
| 26 | |
| 27 | template struct X2<int>; |
Douglas Gregor | b06585a | 2009-05-15 00:01:03 +0000 | [diff] [blame] | 28 | template struct X2<int&>; // expected-note{{instantiation of}} |
Anders Carlsson | 23daf41 | 2009-05-15 00:15:26 +0000 | [diff] [blame] | 29 | |
| 30 | template<typename T> |
| 31 | struct X3 { |
| 32 | void f(T) { |
| 33 | Label: |
| 34 | T x; |
| 35 | goto Label; |
| 36 | } |
| 37 | }; |
| 38 | |
| 39 | template struct X3<int>; |
Anders Carlsson | 92358ae | 2009-05-15 00:48:27 +0000 | [diff] [blame^] | 40 | |
| 41 | template <typename T> struct X4 { |
| 42 | T f() const { |
| 43 | return; // expected-warning{{non-void function 'f' should return a value}} |
| 44 | } |
| 45 | |
| 46 | T g() const { |
| 47 | return 1; // expected-warning{{void function 'g' should not return a value}} |
| 48 | } |
| 49 | }; |
| 50 | |
| 51 | template struct X4<void>; // expected-note{{in instantiation of template class 'X4<void>' requested here}} |
| 52 | template struct X4<int>; // expected-note{{in instantiation of template class 'X4<int>' requested here}} |