42 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only -verify=expected,spec %s2// RUN: %clang_cc1 -fsyntax-only -verify -Wno-explicit-specialization-storage-class %s3 4// A storage-class-specifier shall not be specified in an explicit5// specialization (14.7.3) or an explicit instantiation (14.7.2)6// directive.7template<typename T> void f(T) {}8template<typename T> static void g(T) {}9 10 11template<> static void f<int>(int); // spec-warning{{explicit specialization cannot have a storage class}}12template static void f<float>(float); // expected-error{{explicit instantiation cannot have a storage class}}13 14template<> void f<double>(double);15template void f<long>(long);16 17template<> static void g<int>(int); // spec-warning{{explicit specialization cannot have a storage class}}18template static void g<float>(float); // expected-error{{explicit instantiation cannot have a storage class}}19 20template<> void g<double>(double);21template void g<long>(long);22 23template<typename T>24struct X {25 static int value;26};27 28template<typename T>29int X<T>::value = 17;30 31template static int X<int>::value; // expected-error{{explicit instantiation cannot have a storage class}}32 33template<> static int X<float>::value; // spec-warning{{explicit specialization cannot have a storage class}}34 // expected-error@-1{{'static' can only be specified inside the class definition}}35 36struct t1 {37 template<typename>38 static void f1();39 template<>40 static void f1<int>(); // spec-warning{{explicit specialization cannot have a storage class}}41};42