| 1 |
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++20 %s |
| 2 |
|
| 3 |
template<typename T> |
| 4 |
int x; |
| 5 |
|
| 6 |
template<typename T> |
| 7 |
static int x<T*>; |
| 8 |
|
| 9 |
template<> |
| 10 |
static int x<int>; // expected-warning {{explicit specialization cannot have a storage class}} |
| 11 |
|
| 12 |
template<typename T> |
| 13 |
extern int y; |
| 14 |
|
| 15 |
template<typename T> |
| 16 |
static int y<T*>; |
| 17 |
|
| 18 |
template<> |
| 19 |
static int y<int>; // expected-warning {{explicit specialization cannot have a storage class}} |
| 20 |
|
| 21 |
template<typename T> |
| 22 |
void f(); |
| 23 |
|
| 24 |
template<> |
| 25 |
static void f<int>(); // expected-warning {{explicit specialization cannot have a storage class}} |
| 26 |
|
| 27 |
template<typename T> |
| 28 |
extern void g(); |
| 29 |
|
| 30 |
template<> |
| 31 |
static void g<int>(); // expected-warning {{explicit specialization cannot have a storage class}} |
| 32 |
|
| 33 |
struct A { |
| 34 |
static int x; |
| 35 |
|
| 36 |
static int y; |
| 37 |
|
| 38 |
static void f(); |
| 39 |
|
| 40 |
static void g(); |
| 41 |
}; |
| 42 |
|
| 43 |
int A::x = 0; |
| 44 |
|
| 45 |
static int A::y = 0; // expected-error {{'static' can only be specified inside the class definition}} |
| 46 |
|
| 47 |
void A::f() { } |
| 48 |
|
| 49 |
static void A::g() { } // expected-error {{'static' can only be specified inside the class definition}} |
| 50 |
|
| 51 |
struct B { |
| 52 |
template<typename T> |
| 53 |
static int x; |
| 54 |
|
| 55 |
template<typename T> |
| 56 |
static int y; |
| 57 |
|
| 58 |
template<typename T> |
| 59 |
int z; // expected-error {{non-static data member 'z' cannot be declared as a template}} |
| 60 |
|
| 61 |
template<typename T> |
| 62 |
static int x<T*>; |
| 63 |
|
| 64 |
template<typename T> |
| 65 |
static int y<T*>; |
| 66 |
|
| 67 |
template<typename T> |
| 68 |
int x<T**>; // expected-error {{non-static data member 'x' cannot be declared as a template}} |
| 69 |
|
| 70 |
template<> |
| 71 |
int x<short>; |
| 72 |
|
| 73 |
template<> |
| 74 |
static int x<long>; // expected-warning {{explicit specialization cannot have a storage class}} |
| 75 |
|
| 76 |
template<typename T> |
| 77 |
static void f(); |
| 78 |
|
| 79 |
template<typename T> |
| 80 |
static void g(); |
| 81 |
|
| 82 |
template<> |
| 83 |
void f<short>(); |
| 84 |
|
| 85 |
template<> |
| 86 |
static void f<long>(); // expected-warning {{explicit specialization cannot have a storage class}} |
| 87 |
}; |
| 88 |
|
| 89 |
template<typename T> |
| 90 |
int B::x = 0; |
| 91 |
|
| 92 |
template<typename T> |
| 93 |
static int B::y = 0; // expected-error {{'static' can only be specified inside the class definition}} |
| 94 |
|
| 95 |
template<typename T> |
| 96 |
int B::x<T*> = 0; |
| 97 |
|
| 98 |
template<typename T> |
| 99 |
static int B::y<T*> = 0; // expected-error {{'static' can only be specified inside the class definition}} |
| 100 |
|
| 101 |
template<typename T> |
| 102 |
int B::x<T***>; |
| 103 |
|
| 104 |
template<typename T> |
| 105 |
static int B::y<T***>; // expected-error {{'static' can only be specified inside the class definition}} |
| 106 |
|
| 107 |
template<> |
| 108 |
int B::x<unsigned>; |
| 109 |
|
| 110 |
template<> |
| 111 |
static int B::y<unsigned>; // expected-warning {{explicit specialization cannot have a storage class}} |
| 112 |
// expected-error@-1 {{'static' can only be specified inside the class definition}} |
| 113 |
|
| 114 |
template<typename T> |
| 115 |
void B::f() { } |
| 116 |
|
| 117 |
template<typename T> |
| 118 |
static void B::g() { } // expected-error {{'static' can only be specified inside the class definition}} |
| 119 |
|
| 120 |
template<> |
| 121 |
void B::f<unsigned>(); |
| 122 |
|
| 123 |
template<> |
| 124 |
static void B::g<unsigned>(); // expected-warning {{explicit specialization cannot have a storage class}} |
| 125 |
// expected-error@-1 {{'static' can only be specified inside the class definition}} |
| 126 |
|
| 127 |
template<typename T> |
| 128 |
struct C { |
| 129 |
static int x; |
| 130 |
|
| 131 |
static int y; |
| 132 |
|
| 133 |
static void f(); |
| 134 |
|
| 135 |
static void g(); |
| 136 |
}; |
| 137 |
|
| 138 |
template<typename T> |
| 139 |
int C<T>::x = 0; |
| 140 |
|
| 141 |
template<typename T> |
| 142 |
static int C<T>::y = 0; // expected-error {{'static' can only be specified inside the class definition}} |
| 143 |
|
| 144 |
template<typename T> |
| 145 |
void C<T>::f() { } |
| 146 |
|
| 147 |
template<typename T> |
| 148 |
static void C<T>::g() { } // expected-warning {{'static' can only be specified inside the class definition}} |
| 149 |
|
| 150 |
template<> |
| 151 |
int C<int>::x = 0; |
| 152 |
|
| 153 |
template<> |
| 154 |
static int C<int>::y = 0; // expected-warning {{explicit specialization cannot have a storage class}} |
| 155 |
// expected-error@-1 {{'static' can only be specified inside the class definition}} |
| 156 |
|
| 157 |
template<> |
| 158 |
void C<int>::f(); |
| 159 |
|
| 160 |
template<> |
| 161 |
static void C<int>::g(); // expected-warning {{explicit specialization cannot have a storage class}} |
| 162 |
// expected-error@-1 {{'static' can only be specified inside the class definition}} |
| 163 |
template<typename T> |
| 164 |
struct D { |
| 165 |
template<typename U> |
| 166 |
static int x; |
| 167 |
|
| 168 |
template<typename U> |
| 169 |
static int y; |
| 170 |
|
| 171 |
template<typename U> |
| 172 |
int z; // expected-error {{non-static data member 'z' cannot be declared as a template}} |
| 173 |
|
| 174 |
template<typename U> |
| 175 |
static int x<U*>; |
| 176 |
|
| 177 |
template<typename U> |
| 178 |
static int y<U*>; |
| 179 |
|
| 180 |
template<typename U> |
| 181 |
int x<U**>; // expected-error {{non-static data member 'x' cannot be declared as a template}} |
| 182 |
|
| 183 |
template<> |
| 184 |
int x<short>; |
| 185 |
|
| 186 |
template<> |
| 187 |
static int x<long>; // expected-warning {{explicit specialization cannot have a storage class}} |
| 188 |
|
| 189 |
template<typename U> |
| 190 |
static void f(); |
| 191 |
|
| 192 |
template<typename U> |
| 193 |
static void g(); |
| 194 |
|
| 195 |
template<> |
| 196 |
void f<short>(); |
| 197 |
|
| 198 |
template<> |
| 199 |
static void f<long>(); // expected-warning {{explicit specialization cannot have a storage class}} |
| 200 |
}; |
| 201 |
|
| 202 |
template<typename T> |
| 203 |
template<typename U> |
| 204 |
int D<T>::x = 0; |
| 205 |
|
| 206 |
template<typename T> |
| 207 |
template<typename U> |
| 208 |
static int D<T>::y = 0; // expected-error {{'static' can only be specified inside the class definition}} |
| 209 |
|
| 210 |
template<typename T> |
| 211 |
template<typename U> |
| 212 |
int D<T>::x<U*> = 0; |
| 213 |
|
| 214 |
template<typename T> |
| 215 |
template<typename U> |
| 216 |
static int D<T>::y<U*> = 0; // expected-error {{'static' can only be specified inside the class definition}} |
| 217 |
|
| 218 |
template<typename T> |
| 219 |
template<typename U> |
| 220 |
int D<T>::x<U***>; |
| 221 |
|
| 222 |
template<typename T> |
| 223 |
template<typename U> |
| 224 |
static int D<T>::y<U***>; // expected-error {{'static' can only be specified inside the class definition}} |
| 225 |
|
| 226 |
template<> |
| 227 |
template<typename U> |
| 228 |
int D<int>::x; |
| 229 |
|
| 230 |
template<> |
| 231 |
template<typename U> |
| 232 |
static int D<int>::y; // expected-warning {{explicit specialization cannot have a storage class}} |
| 233 |
// expected-error@-1 {{'static' can only be specified inside the class definition}} |
| 234 |
template<> |
| 235 |
template<typename U> |
| 236 |
int D<int>::x<U****>; |
| 237 |
|
| 238 |
template<> |
| 239 |
template<typename U> |
| 240 |
static int D<int>::y<U****>; // expected-warning {{explicit specialization cannot have a storage class}} |
| 241 |
// expected-error@-1 {{'static' can only be specified inside the class definition}} |
| 242 |
template<> |
| 243 |
template<> |
| 244 |
int D<int>::x<unsigned>; |
| 245 |
|
| 246 |
template<> |
| 247 |
template<> |
| 248 |
static int D<int>::y<unsigned>; // expected-warning {{explicit specialization cannot have a storage class}} |
| 249 |
// expected-error@-1 {{'static' can only be specified inside the class definition}} |
| 250 |
|
| 251 |
template<typename T> |
| 252 |
template<typename U> |
| 253 |
void D<T>::f() { } |
| 254 |
|
| 255 |
template<typename T> |
| 256 |
template<typename U> |
| 257 |
static void D<T>::g() { } // expected-warning {{'static' can only be specified inside the class definition}} |
| 258 |
|
| 259 |
template<> |
| 260 |
template<typename U> |
| 261 |
void D<int>::f(); |
| 262 |
|
| 263 |
template<> |
| 264 |
template<typename U> |
| 265 |
static void D<int>::g(); // expected-warning {{explicit specialization cannot have a storage class}} |
| 266 |
// expected-error@-1 {{'static' can only be specified inside the class definition}} |
| 267 |
template<> |
| 268 |
template<> |
| 269 |
void D<int>::f<unsigned>(); |
| 270 |
|
| 271 |
template<> |
| 272 |
template<> |
| 273 |
static void D<int>::g<unsigned>(); // expected-warning {{explicit specialization cannot have a storage class}} |
| 274 |
// expected-error@-1 {{'static' can only be specified inside the class definition}} |