Douglas Gregor | cc63668 | 2009-02-17 23:15:12 +0000 | [diff] [blame] | 1 | // RUN: clang -fsyntax-only -verify %s |
| 2 | template<typename T, typename U = int> class A; |
| 3 | |
| 4 | template<> class A<double, double>; // expected-note{{forward declaration}} |
| 5 | |
| 6 | template<> class A<float, float> { // expected-note{{previous definition}} |
| 7 | int x; |
| 8 | }; |
| 9 | |
| 10 | template<> class A<float> { // expected-note{{previous definition}} |
| 11 | int y; |
| 12 | }; |
| 13 | |
| 14 | int test_specs(A<float, float> *a1, A<float, int> *a2) { |
| 15 | return a1->x + a2->y; |
| 16 | } |
| 17 | |
| 18 | int test_incomplete_specs(A<double, double> *a1, |
| 19 | A<double> *a2) // FIXME: expected-note{{forward declaration}} |
| 20 | { |
| 21 | (void)a1->x; // expected-error{{incomplete definition of type 'A<double, double>'}} |
| 22 | (void)a2->x; // expected-error{{incomplete definition of type 'A<double>'}} |
| 23 | } |
| 24 | |
| 25 | typedef float FLOAT; |
| 26 | |
| 27 | template<> class A<float, FLOAT>; |
| 28 | |
| 29 | template<> class A<FLOAT, float> { }; // expected-error{{redefinition}} |
| 30 | |
| 31 | template<> class A<float, int> { }; // expected-error{{redefinition}} |
Douglas Gregor | 611a8c4 | 2009-02-19 00:52:42 +0000 | [diff] [blame] | 32 | |
| 33 | template<typename T, typename U = int> class X; |
| 34 | |
| 35 | template <> class X<int, int> { int foo(); }; // #1 |
| 36 | template <> class X<float> { int bar(); }; // #2 |
| 37 | |
| 38 | typedef int int_type; |
| 39 | void testme(X<int_type> *x1, X<float, int> *x2) { |
| 40 | x1->foo(); // okay: refers to #1 |
| 41 | x2->bar(); // okay: refers to #2 |
| 42 | } |