| 1 |
// RUN: %clang_cc1 -fsyntax-only -std=c++17 -verify %s -fcxx-exceptions |
| 2 |
template<typename T> |
| 3 |
struct X0 { |
| 4 |
typedef T* type; |
| 5 |
|
| 6 |
void f0(T); |
| 7 |
void f1(type); |
| 8 |
}; |
| 9 |
|
| 10 |
template<> void X0<char>::f0(char); |
| 11 |
template<> void X0<char>::f1(type); |
| 12 |
|
| 13 |
namespace PR6161 { |
| 14 |
template<typename _CharT> |
| 15 |
class numpunct : public locale::facet // expected-error{{use of undeclared identifier 'locale'}} \ |
| 16 |
// expected-error{{expected class name}} |
| 17 |
{ |
| 18 |
static locale::id id; // expected-error{{use of undeclared identifier}} |
| 19 |
}; |
| 20 |
numpunct<char>::~numpunct(); |
| 21 |
} |
| 22 |
|
| 23 |
namespace PR12331 { |
| 24 |
template<typename T> struct S { |
| 25 |
struct U { static const int n = 5; }; |
| 26 |
enum E { e = U::n }; // expected-note {{implicit instantiation first required here}} |
| 27 |
int arr[e]; |
| 28 |
}; |
| 29 |
template<> struct S<int>::U { static const int n = sizeof(int); }; // expected-error {{explicit specialization of 'U' after instantiation}} |
| 30 |
} |
| 31 |
|
| 32 |
namespace PR18246 { |
| 33 |
template<typename T> |
| 34 |
class Baz { |
| 35 |
public: |
| 36 |
template<int N> void bar(); |
| 37 |
}; |
| 38 |
|
| 39 |
template<typename T> |
| 40 |
template<int N> |
| 41 |
void Baz<T>::bar() { |
| 42 |
} |
| 43 |
|
| 44 |
template<typename T> |
| 45 |
void Baz<T>::bar<0>() { // expected-error {{cannot specialize a member of an unspecialized template}} |
| 46 |
} |
| 47 |
} |
| 48 |
|
| 49 |
namespace PR19340 { |
| 50 |
template<typename T> struct Helper { |
| 51 |
template<int N> static void func(const T *m) {} |
| 52 |
}; |
| 53 |
|
| 54 |
template<typename T> void Helper<T>::func<2>() {} // expected-error {{cannot specialize a member}} |
| 55 |
} |
| 56 |
|
| 57 |
namespace SpecLoc { |
| 58 |
template <typename T> struct A { |
| 59 |
static int n; // expected-note {{previous}} |
| 60 |
static void f(); // expected-note {{previous}} |
| 61 |
}; |
| 62 |
template<> float A<int>::n; // expected-error {{different type}} |
| 63 |
template<> void A<int>::f() throw(); // expected-error {{does not match}} |
| 64 |
} |
| 65 |
|
| 66 |
namespace PR41607 { |
| 67 |
template<int N> struct Outer { |
| 68 |
template<typename...> struct Inner; |
| 69 |
template<> struct Inner<> { |
| 70 |
static constexpr int f() { return N; } |
| 71 |
}; |
| 72 |
|
| 73 |
template<typename...> static int a; |
| 74 |
template<> constexpr int a<> = N; |
| 75 |
|
| 76 |
template<typename...> static inline int b; |
| 77 |
template<> inline constexpr int b<> = N; |
| 78 |
|
| 79 |
template<typename...> static constexpr int f(); |
| 80 |
template<> constexpr int f() { |
| 81 |
return N; |
| 82 |
} |
| 83 |
}; |
| 84 |
static_assert(Outer<123>::Inner<>::f() == 123, ""); |
| 85 |
static_assert(Outer<123>::Inner<>::f() != 125, ""); |
| 86 |
|
| 87 |
static_assert(Outer<123>::a<> == 123, ""); |
| 88 |
static_assert(Outer<123>::a<> != 125, ""); |
| 89 |
|
| 90 |
static_assert(Outer<123>::b<> == 123, ""); |
| 91 |
static_assert(Outer<123>::b<> != 125, ""); |
| 92 |
|
| 93 |
static_assert(Outer<123>::f<>() == 123, ""); |
| 94 |
static_assert(Outer<123>::f<>() != 125, ""); |
| 95 |
} |