Skip to content

Commit 107f8f7

Browse files
committed
[FOLD] update tests
1 parent 4372df3 commit 107f8f7

File tree

13 files changed

+100
-82
lines changed

13 files changed

+100
-82
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ template<typename T> void f(T) {}
77
template<typename T> static void g(T) {}
88

99

10-
template<> static void f<int>(int); // expected-error{{explicit specialization has extraneous, inconsistent storage class 'static'}}
10+
template<> static void f<int>(int); // expected-warning{{explicit specialization cannot have a storage class}}
1111
template static void f<float>(float); // expected-error{{explicit instantiation cannot have a storage class}}
1212

1313
template<> void f<double>(double);
@@ -29,4 +29,5 @@ int X<T>::value = 17;
2929

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

32-
template<> static int X<float>::value; // expected-error{{'static' can only be specified inside the class definition}}
32+
template<> static int X<float>::value; // expected-warning{{explicit specialization cannot have a storage class}}
33+
// expected-error@-1{{'static' can only be specified inside the class definition}}

clang/test/CXX/drs/cwg7xx.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ namespace cwg727 { // cwg727: partial
8080

8181
template<> struct C<int>;
8282
template<> void f<int>();
83-
template<> static int N<int>;
83+
template<> int N<int>;
8484

8585
template<typename T> struct C<T*>;
8686
template<typename T> static int N<T*>;
@@ -91,7 +91,7 @@ namespace cwg727 { // cwg727: partial
9191
// expected-note@#cwg727-C {{explicitly specialized declaration is here}}
9292
template<> void f<float>();
9393
// expected-error@-1 {{no function template matches function template specialization 'f'}}
94-
template<> static int N<float>;
94+
template<> int N<float>;
9595
// expected-error@-1 {{variable template specialization of 'N' not in class 'A' or an enclosing namespace}}
9696
// expected-note@#cwg727-N {{explicitly specialized declaration is here}}
9797

@@ -109,7 +109,7 @@ namespace cwg727 { // cwg727: partial
109109
template<> void A::f<double>();
110110
// expected-error@-1 {{o function template matches function template specialization 'f'}}
111111
// expected-error@-2 {{non-friend class member 'f' cannot have a qualified name}}
112-
template<> static int A::N<double>;
112+
template<> int A::N<double>;
113113
// expected-error@-1 {{non-friend class member 'N' cannot have a qualified name}}
114114
// expected-error@-2 {{variable template specialization of 'N' not in class 'A' or an enclosing namespace}}
115115
// expected-note@#cwg727-N {{explicitly specialized declaration is here}}
@@ -166,7 +166,7 @@ namespace cwg727 { // cwg727: partial
166166

167167
template<> struct C<int> {};
168168
template<> void f<int>() {}
169-
template<> static const int N<int>;
169+
template<> const int N<int>;
170170

171171
template<typename T> struct C<T*> {};
172172
template<typename T> static const int N<T*>;
@@ -208,18 +208,18 @@ namespace cwg727 { // cwg727: partial
208208
#if __cplusplus >= 201402L
209209
template<int> struct B {
210210
template<int> static const int u = 1;
211-
template<> static const int u<0> = 2; // #cwg727-u0
211+
template<> const int u<0> = 2; // #cwg727-u0
212212

213213
// Note that in C++17 onwards, these are implicitly inline, and so the
214214
// initializer of v<0> is not instantiated with the declaration. In
215215
// C++14, v<0> is a non-defining declaration and its initializer is
216216
// instantiated with the class.
217217
template<int> static constexpr int v = 1;
218-
template<> static constexpr int v<0> = 2; // #cwg727-v0
218+
template<> constexpr int v<0> = 2; // #cwg727-v0
219219

220220
template<int> static const inline int w = 1;
221221
// cxx14-error@-1 {{inline variables are a C++17 extension}}
222-
template<> static const inline int w<0> = 2;
222+
template<> const inline int w<0> = 2;
223223
// cxx14-error@-1 {{inline variables are a C++17 extension}}
224224
};
225225

@@ -267,18 +267,18 @@ namespace cwg727 { // cwg727: partial
267267

268268
template<typename> static int v1;
269269
// cxx98-11-error@-1 {{variable templates are a C++14 extension}}
270-
template<> static int v1<T>; // #cwg727-v1-T
271-
template<> static int v1<U>;
270+
template<> int v1<T>; // #cwg727-v1-T
271+
template<> int v1<U>;
272272
// expected-error@-1 {{duplicate member 'v1'}}
273273
// expected-note@#cwg727-Collision-int-int {{in instantiation of template class 'cwg727::Collision<int, int>' requested here}}
274274
// expected-note@#cwg727-v1-T {{previous}}
275275

276276
template<typename> static inline int v2;
277277
// cxx98-11-error@-1 {{variable templates are a C++14 extension}}
278278
// cxx98-14-error@-2 {{inline variables are a C++17 extension}}
279-
template<> static inline int v2<T>; // #cwg727-v2-T
279+
template<> inline int v2<T>; // #cwg727-v2-T
280280
// cxx98-14-error@-1 {{inline variables are a C++17 extension}}
281-
template<> static inline int v2<U>;
281+
template<> inline int v2<U>;
282282
// cxx98-14-error@-1 {{inline variables are a C++17 extension}}
283283
// expected-error@-2 {{duplicate member 'v2'}}
284284
// expected-note@#cwg727-v2-T {{previous declaration is here}}

clang/test/CXX/temp/temp.decls/temp.mem/p2.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ void fun() {
99
template <typename> void baz() {} // expected-error{{templates cannot be declared inside of a local class}}
1010
template <typename> void qux(); // expected-error{{templates cannot be declared inside of a local class}}
1111
template <typename> using corge = int; // expected-error{{templates cannot be declared inside of a local class}}
12-
template <typename T> static T grault; // expected-error{{static data member}} expected-error{{templates cannot be declared inside of a local class}}
12+
template <typename T> static T grault; // expected-error{{templates cannot be declared inside of a local class}}
1313
};
1414
}

clang/test/CXX/temp/temp.decls/temp.variadic/p5.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ namespace Specializations {
408408
template<typename... Us>
409409
constexpr static int InnerVar = 0;
410410
template<>
411-
constexpr static int InnerVar<Ts> = 0; // expected-error{{explicit specialization contains unexpanded parameter pack 'Ts'}}
411+
constexpr int InnerVar<Ts> = 0; // expected-error{{explicit specialization contains unexpanded parameter pack 'Ts'}}
412412
template<typename U>
413413
constexpr static int InnerVar<U, Ts> = 0; // expected-error{{partial specialization contains unexpanded parameter pack 'Ts'}}
414414
#endif

clang/test/CXX/temp/temp.spec/temp.expl.spec/p17.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ struct S {
4040
int j<int>; // expected-error {{member 'j' cannot have template arguments}}
4141

4242
static int k<12>; // expected-error {{template specialization requires 'template<>'}} \
43-
expected-error{{no variable template matches specialization}}
43+
expected-error {{no variable template matches specialization}} \
44+
expected-warning {{explicit specialization cannot have a storage class}}
4445
void f<12>(); // expected-error {{template specialization requires 'template<>'}} \
4546
// expected-error {{no function template matches function template specialization 'f'}}
4647
};

clang/test/CXX/temp/temp.spec/temp.expl.spec/p2-0x.cpp

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace N0 {
2424
void test_f0(NonDefaultConstructible NDC) {
2525
f0(NDC);
2626
}
27-
27+
2828
template<> void f0(int);
2929
template<> void f0(long);
3030
}
@@ -39,34 +39,34 @@ template<> void N0::f0(double) { }
3939

4040
struct X1 {
4141
template<typename T> void f(T);
42-
42+
4343
template<> void f(int); // OK (DR727)
4444
};
4545

4646
// -- class template
4747
namespace N0 {
48-
48+
4949
template<typename T>
5050
struct X0 { // expected-note {{here}}
5151
static T member;
52-
52+
5353
void f1(T t) {
5454
t = 17;
5555
}
56-
56+
5757
struct Inner : public T { }; // expected-note 2{{here}}
58-
58+
5959
template<typename U>
6060
struct InnerTemplate : public T { }; // expected-note 1{{explicitly specialized}} \
6161
// expected-error{{base specifier}}
62-
62+
6363
template<typename U>
6464
void ft1(T t, U u);
6565
};
6666

6767
}
6868

69-
template<typename T>
69+
template<typename T>
7070
template<typename U>
7171
void N0::X0<T>::ft1(T t, U u) {
7272
t = u;
@@ -85,35 +85,36 @@ namespace N0 {
8585
template<> struct X0<volatile void>;
8686
}
8787

88-
template<> struct N0::X0<volatile void> {
88+
template<> struct N0::X0<volatile void> {
8989
void f1(void *);
9090
};
9191

9292
// -- variable template [C++1y]
9393
namespace N0 {
9494
template<typename T> int v0; // expected-note 4{{explicitly specialized declaration is here}}
95-
template<> extern int v0<char[1]>;
96-
template<> extern int v0<char[2]>;
97-
template<> extern int v0<char[5]>;
98-
template<> extern int v0<char[6]>;
95+
template<> int v0<char[1]>; // expected-note {{previous definition is here}}
96+
template<> int v0<char[2]>;
97+
template<> int v0<char[5]>; // expected-note {{previous definition is here}}
98+
template<> int v0<char[6]>;
9999
}
100100
using N0::v0;
101101

102102
template<typename T> int v1; // expected-note 4{{explicitly specialized declaration is here}}
103-
template<> extern int v1<char[3]>;
104-
template<> extern int v1<char[4]>;
105-
template<> extern int v1<char[7]>;
106-
template<> extern int v1<char[8]>;
103+
template<> int v1<char[3]>; // expected-note {{previous definition is here}}
104+
template<> int v1<char[4]>; // expected-note {{previous definition is here}}
105+
template<> int v1<char[7]>; // expected-note {{previous definition is here}}
106+
template<> int v1<char[8]>;
107107

108108
template<> int N0::v0<int[1]>;
109109
template<> int v0<int[2]>;
110110
template<> int ::v1<int[3]>; // expected-warning {{extra qualification}}
111111
template<> int v1<int[4]>;
112112

113-
template<> int N0::v0<char[1]>;
113+
template<> int N0::v0<char[1]>; // expected-error {{redefinition of 'v0<char[1]>'}}
114114
template<> int v0<char[2]>;
115115
template<> int ::v1<char[3]>; // expected-warning {{extra qualification}}
116-
template<> int v1<char[4]>;
116+
// expected-error@-1 {{redefinition of 'v1<char[3]>'}}
117+
template<> int v1<char[4]>; // expected-error {{redefinition of 'v1<char[4]>'}}
117118

118119
namespace N1 {
119120
template<> int N0::v0<int[5]>; // expected-error {{not in a namespace enclosing 'N0'}}
@@ -122,8 +123,10 @@ template<> int ::v1<int[7]>; // expected-error {{must occur at global scope}}
122123
template<> int v1<int[8]>; // expected-error {{must occur at global scope}}
123124

124125
template<> int N0::v0<char[5]>; // expected-error {{not in a namespace enclosing 'N0'}}
126+
// expected-error@-1 {{redefinition of 'v0<char[5]>'}}
125127
template<> int v0<char[6]>; // expected-error {{not in a namespace enclosing 'N0'}}
126128
template<> int ::v1<char[7]>; // expected-error {{must occur at global scope}}
129+
// expected-error@-1 {{redefinition of 'v1<char[7]>'}}
127130
template<> int v1<char[8]>; // expected-error {{must occur at global scope}}
128131
}
129132

@@ -147,13 +150,13 @@ void test_x0_cvvoid(N0::X0<const volatile void*> x0, const volatile void *cvp) {
147150
// -- static data member of a class template
148151
namespace N0 {
149152
// This actually tests p15; the following is a declaration, not a definition.
150-
template<>
153+
template<>
151154
NonDefaultConstructible X0<NonDefaultConstructible>::member;
152-
155+
153156
template<> long X0<long>::member = 17;
154157

155158
template<> float X0<float>::member;
156-
159+
157160
template<> double X0<double>::member;
158161
}
159162

@@ -171,7 +174,7 @@ namespace N1 {
171174

172175
// -- member class of a class template
173176
namespace N0 {
174-
177+
175178
template<>
176179
struct X0<void*>::Inner { };
177180

@@ -213,7 +216,7 @@ namespace N0 {
213216
template<>
214217
template<>
215218
struct X0<void*>::InnerTemplate<int> { };
216-
219+
217220
template<> template<>
218221
struct X0<int>::InnerTemplate<int>; // expected-note{{forward declaration}}
219222

@@ -245,7 +248,7 @@ namespace N0 {
245248
template<>
246249
template<>
247250
void X0<void*>::ft1(void*, const void*) { }
248-
251+
249252
template<> template<>
250253
void X0<void*>::ft1(void *, int);
251254

@@ -279,7 +282,7 @@ namespace has_inline_namespaces {
279282
inline namespace inner {
280283
template<class T> void f(T&);
281284

282-
template<class T>
285+
template<class T>
283286
struct X0 {
284287
struct MemberClass;
285288

@@ -330,10 +333,10 @@ template<> struct has_inline_namespaces::X0<X4>::MemberClass { };
330333

331334
template<> void has_inline_namespaces::X0<X4>::mem_func();
332335

333-
template<> template<typename T>
336+
template<> template<typename T>
334337
struct has_inline_namespaces::X0<X4>::MemberClassTemplate { };
335338

336-
template<> template<typename T>
339+
template<> template<typename T>
337340
void has_inline_namespaces::X0<X4>::mem_func_template(T&) { }
338341

339342
template<> int has_inline_namespaces::X0<X4>::value = 13;

clang/test/Modules/Inputs/redecl-templates/a.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ template<int N> constexpr void f();
55
template<> constexpr void f<1>();
66

77
template<int N> extern int v;
8-
template<> extern int v<1>;
8+
template<> int v<1>;

clang/test/Modules/redecl-templates.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// RUN: rm -rf %t
22
// RUN: %clang_cc1 -x c++ -I %S/Inputs/redecl-templates %s -verify -std=c++14
33
// RUN: %clang_cc1 -x c++ -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs/redecl-templates %s -verify -std=c++14
4-
// expected-no-diagnostics
54

65
template<int N> struct A {};
76
template<int N> using X = A<N>;
@@ -29,4 +28,4 @@ int &x = w<1>;
2928
// instantiation of this specialization.
3029
template<> struct A<1> {};
3130
template<> constexpr void f<1>() {}
32-
template<> int v<1>;
31+
template<> int v<1>; // expected-error{{redefinition of 'v<1>'}}

clang/test/PCH/cxx-templates.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ struct Dep {
4949
int y = T::template my_templf<int>(0);
5050
ovl(y);
5151
}
52-
52+
5353
void ovl(int);
5454
void ovl(float);
5555
};
@@ -67,7 +67,7 @@ template <class T> class UseBase {
6767

6868
template <class T> class UseA : public UseBase<T> {
6969
using UseBase<T>::foo;
70-
using typename UseBase<T>::bar;
70+
using typename UseBase<T>::bar;
7171
};
7272

7373
template <class T> class Sub : public UseBase<int> { };
@@ -95,7 +95,7 @@ template<> bool isInt<8>(int x) {
9595
template<typename _CharT>
9696
int __copy_streambufs_eof(_CharT);
9797

98-
class basic_streambuf
98+
class basic_streambuf
9999
{
100100
void m() { }
101101
friend int __copy_streambufs_eof<>(int);
@@ -174,7 +174,7 @@ struct S7<int[N]> : S6<const int[N]> { };
174174
namespace ZeroLengthExplicitTemplateArgs {
175175
template<typename T> void h();
176176

177-
struct Y {
177+
struct Y {
178178
template<typename T> void f();
179179
};
180180

@@ -417,11 +417,11 @@ namespace ClassScopeExplicitSpecializations {
417417
template<int> struct B {
418418
template<typename> static const int v = 1;
419419
template<typename T> static const int v<T*> = 2;
420-
template<> static const int v<int> = 3;
420+
template<> const int v<int> = 3;
421421

422422
template<typename> static constexpr int w = 1;
423423
template<typename T> static constexpr int w<T*> = 2;
424-
template<> static constexpr int w<int> = 3;
424+
template<> constexpr int w<int> = 3;
425425
};
426426

427427
template<> template<typename> constexpr int B<0>::v = 4;

0 commit comments

Comments
 (0)