blob: 4de220a77cb58b327561e96ae3abe78f2618fce7 [file] [log] [blame]
Douglas Gregorcc636682009-02-17 23:15:12 +00001// RUN: clang -fsyntax-only -verify %s
2template<typename T, typename U = int> class A;
3
4template<> class A<double, double>; // expected-note{{forward declaration}}
5
6template<> class A<float, float> { // expected-note{{previous definition}}
7 int x;
8};
9
10template<> class A<float> { // expected-note{{previous definition}}
11 int y;
12};
13
14int test_specs(A<float, float> *a1, A<float, int> *a2) {
15 return a1->x + a2->y;
16}
17
18int 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
25typedef float FLOAT;
26
27template<> class A<float, FLOAT>;
28
29template<> class A<FLOAT, float> { }; // expected-error{{redefinition}}
30
31template<> class A<float, int> { }; // expected-error{{redefinition}}
Douglas Gregor611a8c42009-02-19 00:52:42 +000032
33template<typename T, typename U = int> class X;
34
35template <> class X<int, int> { int foo(); }; // #1
36template <> class X<float> { int bar(); }; // #2
37
38typedef int int_type;
39void testme(X<int_type> *x1, X<float, int> *x2) {
40 x1->foo(); // okay: refers to #1
41 x2->bar(); // okay: refers to #2
42}
Douglas Gregor39a8de12009-02-25 19:37:18 +000043
Douglas Gregorac1afdc2009-02-25 19:48:02 +000044// Diagnose specializations in a different namespace
45class A<double> { };