Douglas Gregor | e704c9d | 2009-08-27 16:57:43 +0000 | [diff] [blame] | 1 | // RUN: clang-cc -fsyntax-only -verify %s |
| 2 | |
| 3 | template<typename T> |
| 4 | struct X0 { |
| 5 | template<typename U> T f0(U); |
| 6 | template<typename U> U& f1(T*, U); // expected-error{{pointer to a reference}} \ |
| 7 | // expected-note{{candidate}} |
| 8 | }; |
| 9 | |
| 10 | X0<int> x0i; |
| 11 | X0<void> x0v; |
| 12 | X0<int&> x0ir; // expected-note{{instantiation}} |
| 13 | |
| 14 | void test_X0(int *ip, double *dp) { |
| 15 | X0<int> xi; |
| 16 | int i1 = xi.f0(ip); |
| 17 | double *&dpr = xi.f1(ip, dp); |
| 18 | xi.f1(dp, dp); // expected-error{{no matching}} |
| 19 | |
| 20 | X0<void> xv; |
| 21 | double *&dpr2 = xv.f1(ip, dp); |
| 22 | } |
Douglas Gregor | a654dd8 | 2009-08-28 17:37:35 +0000 | [diff] [blame] | 23 | |
Douglas Gregor | 01afeef | 2009-08-28 20:31:08 +0000 | [diff] [blame] | 24 | template<typename T> |
| 25 | struct X1 { |
| 26 | template<typename U> |
| 27 | struct Inner0 { |
| 28 | U x; |
| 29 | T y; // expected-error{{void}} |
| 30 | }; |
| 31 | |
| 32 | template<typename U> |
| 33 | struct Inner1 { |
| 34 | U x; // expected-error{{void}} |
Douglas Gregor | 39cacdb | 2009-08-28 20:50:45 +0000 | [diff] [blame] | 35 | T y; |
| 36 | }; |
| 37 | |
| 38 | template<typename U> |
| 39 | struct Inner2 { |
| 40 | struct SuperInner { |
| 41 | U z; // expected-error{{void}} |
| 42 | }; |
Douglas Gregor | 01afeef | 2009-08-28 20:31:08 +0000 | [diff] [blame] | 43 | }; |
Douglas Gregor | d99bb43 | 2009-08-28 21:09:48 +0000 | [diff] [blame^] | 44 | |
| 45 | template<typename U> |
| 46 | struct Inner3 { |
| 47 | void f0(T t, U u) { |
| 48 | (void)(t + u); // expected-error{{invalid operands}} |
| 49 | } |
| 50 | |
| 51 | template<typename V> |
| 52 | V f1(T t, U u, V) { |
| 53 | return t + u; // expected-error{{incompatible type}} |
| 54 | } |
| 55 | }; |
| 56 | |
Douglas Gregor | 01afeef | 2009-08-28 20:31:08 +0000 | [diff] [blame] | 57 | }; |
| 58 | |
Douglas Gregor | d99bb43 | 2009-08-28 21:09:48 +0000 | [diff] [blame^] | 59 | void test_X1(int *ip, int i, double *dp) { |
Douglas Gregor | 01afeef | 2009-08-28 20:31:08 +0000 | [diff] [blame] | 60 | X1<void>::Inner0<int> *xvip; // okay |
| 61 | X1<void>::Inner0<int> xvi; // expected-note{{instantiation}} |
| 62 | |
| 63 | X1<int>::Inner1<void> *xivp; // okay |
| 64 | X1<int>::Inner1<void> xiv; // expected-note{{instantiation}} |
Douglas Gregor | 39cacdb | 2009-08-28 20:50:45 +0000 | [diff] [blame] | 65 | |
| 66 | X1<int>::Inner2<void>::SuperInner *xisivp; // okay |
| 67 | X1<int>::Inner2<void>::SuperInner xisiv; // expected-note{{instantiation}} |
Douglas Gregor | d99bb43 | 2009-08-28 21:09:48 +0000 | [diff] [blame^] | 68 | |
| 69 | X1<int*>::Inner3<int> id3; |
| 70 | id3.f0(ip, i); |
| 71 | id3.f0(dp, i); // expected-error{{incompatible type}} |
| 72 | id3.f1(ip, i, ip); |
| 73 | id3.f1(ip, i, dp); // expected-note{{instantiation}} |
| 74 | |
| 75 | X1<int*>::Inner3<double*> id3b; |
| 76 | id3b.f0(ip, dp); // expected-note{{instantiation}} |
Douglas Gregor | 01afeef | 2009-08-28 20:31:08 +0000 | [diff] [blame] | 77 | } |