Clang Project

clang_source_code/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p1.cpp
1// RUN: %clang_cc1 -fsyntax-only -verify %s
2
3// A storage-class-specifier shall not be specified in an explicit
4// specialization (14.7.3) or an explicit instantiation (14.7.2)
5// directive.
6template<typename T> void f(T) {}
7template<typename T> static void g(T) {}
8
9
10template<> static void f<int>(int); // expected-error{{explicit specialization has extraneous, inconsistent storage class 'static'}}
11template static void f<float>(float); // expected-error{{explicit instantiation cannot have a storage class}}
12
13template<> void f<double>(double);
14template void f<long>(long);
15
16template<> static void g<int>(int); // expected-warning{{explicit specialization cannot have a storage class}}
17template static void g<float>(float); // expected-error{{explicit instantiation cannot have a storage class}}
18
19template<> void g<double>(double);
20template void g<long>(long);
21
22template<typename T>
23struct X {
24  static int value;
25};
26
27template<typename T>
28int X<T>::value = 17;
29
30template static int X<int>::value; // expected-error{{explicit instantiation cannot have a storage class}}
31
32template<> static int X<float>::value; // expected-error{{'static' can only be specified inside the class definition}}
33