Skip to content

Commit b3facc9

Browse files
committed
Add test
1 parent a539afc commit b3facc9

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

clang/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p1.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// RUN: %clang_cc1 -fsyntax-only -verify %s
1+
// RUN: %clang_cc1 -fsyntax-only -verify=expected,spec %s
2+
// RUN: %clang_cc1 -fsyntax-only -verify -Wno-explicit-specialization-storage-class %s
23

34
// A storage-class-specifier shall not be specified in an explicit
45
// specialization (14.7.3) or an explicit instantiation (14.7.2)
@@ -7,13 +8,13 @@ template<typename T> void f(T) {}
78
template<typename T> static void g(T) {}
89

910

10-
template<> static void f<int>(int); // expected-warning{{explicit specialization cannot have a storage class}}
11+
template<> static void f<int>(int); // spec-warning{{explicit specialization cannot have a storage class}}
1112
template static void f<float>(float); // expected-error{{explicit instantiation cannot have a storage class}}
1213

1314
template<> void f<double>(double);
1415
template void f<long>(long);
1516

16-
template<> static void g<int>(int); // expected-warning{{explicit specialization cannot have a storage class}}
17+
template<> static void g<int>(int); // spec-warning{{explicit specialization cannot have a storage class}}
1718
template static void g<float>(float); // expected-error{{explicit instantiation cannot have a storage class}}
1819

1920
template<> void g<double>(double);
@@ -29,5 +30,12 @@ int X<T>::value = 17;
2930

3031
template static int X<int>::value; // expected-error{{explicit instantiation cannot have a storage class}}
3132

32-
template<> static int X<float>::value; // expected-warning{{explicit specialization cannot have a storage class}}
33+
template<> static int X<float>::value; // spec-warning{{explicit specialization cannot have a storage class}}
3334
// expected-error@-1{{'static' can only be specified inside the class definition}}
35+
36+
struct 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+
};
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -verify %s
2+
// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -Wno-explicit-specialization-storage-class -verify=expnone %s
3+
4+
// expnone-no-diagnostics
5+
6+
struct A {
7+
template<typename T>
8+
static constexpr int x = 0;
9+
10+
template<>
11+
static constexpr int x<void> = 1; // expected-warning{{explicit specialization cannot have a storage class}}
12+
};
13+
14+
template<typename T>
15+
static constexpr int x = 0;
16+
17+
template<>
18+
static constexpr int x<void> = 1; // expected-warning{{explicit specialization cannot have a storage class}}

0 commit comments

Comments
 (0)