| 1 |
// RUN: %clang_cc1 -fsyntax-only -verify %s |
| 2 |
|
| 3 |
struct IntHolder { |
| 4 |
IntHolder(int); |
| 5 |
}; |
| 6 |
|
| 7 |
template<typename T, typename U> |
| 8 |
struct X { |
| 9 |
void f() { |
| 10 |
T t; |
| 11 |
} |
| 12 |
|
| 13 |
void g() { } |
| 14 |
|
| 15 |
struct Inner { |
| 16 |
T value; |
| 17 |
}; |
| 18 |
|
| 19 |
static T value; |
| 20 |
}; |
| 21 |
|
| 22 |
template<typename T, typename U> |
| 23 |
T X<T, U>::value; |
| 24 |
|
| 25 |
// Explicitly specialize the members of X<IntHolder, long> to not cause |
| 26 |
// problems with instantiation, but only provide declarations (not definitions). |
| 27 |
template<> |
| 28 |
void X<IntHolder, long>::f(); |
| 29 |
|
| 30 |
template<> |
| 31 |
struct X<IntHolder, long>::Inner; // expected-note{{forward declaration}} |
| 32 |
|
| 33 |
template<> |
| 34 |
IntHolder X<IntHolder, long>::value; |
| 35 |
|
| 36 |
IntHolder &test_X_IntHolderInt(X<IntHolder, long> xih) { |
| 37 |
xih.g(); // okay |
| 38 |
xih.f(); // okay, uses specialization |
| 39 |
|
| 40 |
X<IntHolder, long>::Inner inner; // expected-error {{incomplete}} |
| 41 |
|
| 42 |
return X<IntHolder, long>::value; // okay, uses specialization |
| 43 |
} |
| 44 |
|
| 45 |
|
| 46 |
template<class T> struct A { |
| 47 |
void f(T) { /* ... */ } |
| 48 |
}; |
| 49 |
|
| 50 |
template<> struct A<int> { |
| 51 |
void f(int); |
| 52 |
}; |
| 53 |
|
| 54 |
void h() { |
| 55 |
A<int> a; |
| 56 |
a.f(16); // A<int>::f must be defined somewhere |
| 57 |
} |
| 58 |
|
| 59 |
// explicit specialization syntax not used for a member of |
| 60 |
// explicitly specialized class template specialization |
| 61 |
void A<int>::f(int) { /* ... */ } |