Skip to content

Commit e2d0e6a

Browse files
committed
[FOLD]
1 parent c31ab16 commit e2d0e6a

File tree

2 files changed

+81
-1
lines changed

2 files changed

+81
-1
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,8 @@ Improvements to Clang's diagnostics
201201
- Added diagnostics for C11 keywords being incompatible with language standards
202202
before C11, under a new warning group: ``-Wpre-c11-compat``.
203203

204+
- Clang now diagnoses extraneous template parameter lists as a language extension.
205+
204206
Improvements to Clang's time-trace
205207
----------------------------------
206208

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

Lines changed: 79 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clang_cc1 -fsyntax-only -verify %s
1+
// RUN: %clang_cc1 -fsyntax-only -pedantic-errors -verify %s
22
template<class T> struct A {
33
void f(T);
44
template<class X1> void g1(T, X1);
@@ -36,3 +36,81 @@ namespace PR10024 {
3636
template <>
3737
void Test<T>::get<double>(double i) {} // expected-error{{cannot specialize (with 'template<>') a member of an unspecialized template}}
3838
}
39+
40+
namespace extraneous {
41+
template<typename T> struct A;
42+
template<typename T> int x;
43+
template<typename T> void f();
44+
45+
template<> // expected-error{{extraneous template parameter list in template specialization}}
46+
template<>
47+
struct A<int>;
48+
49+
template<> // expected-error{{extraneous template parameter list in template specialization}}
50+
template<>
51+
int x<int>;
52+
53+
template<> // expected-error{{extraneous template parameter list in template specialization}}
54+
template<>
55+
void f<int>();
56+
57+
template<typename T>
58+
struct B {
59+
struct C;
60+
61+
template<typename U>
62+
struct D;
63+
64+
static int y;
65+
66+
template<typename U>
67+
static int z;
68+
69+
void g();
70+
71+
template<typename U>
72+
void h();
73+
};
74+
75+
template<>
76+
template<> // expected-error{{extraneous 'template<>' in declaration of struct 'C'}}
77+
struct B<int>::C;
78+
79+
template<>
80+
template<> // expected-error{{extraneous template parameter list in template specialization}}
81+
template<>
82+
struct B<int>::D<int>;
83+
84+
template<>
85+
template<> // expected-error{{extraneous template parameter list in template specialization}}
86+
template<typename U>
87+
struct B<int>::D;
88+
89+
template<>
90+
template<> // expected-error{{extraneous 'template<>' in declaration of variable 'y'}}
91+
int B<int>::y;
92+
93+
template<>
94+
template<> // expected-error{{extraneous template parameter list in template specialization}}
95+
template<>
96+
int B<int>::z<int>;
97+
98+
template<>
99+
template<> // expected-error{{extraneous template parameter list in template specialization}}
100+
template<typename U>
101+
int B<int>::z;
102+
103+
template<>
104+
template<>
105+
void B<int>::g(); // expected-error{{no function template matches function template specialization 'g'}}
106+
107+
template<>
108+
template<> // expected-error{{extraneous template parameter list in template specialization}}
109+
template<>
110+
void B<int>::h<int>();
111+
112+
template<>
113+
template<> // expected-error{{extraneous template parameter list in template specialization}}
114+
template<typename U>
115+
void B<int>::h<int>(); // expected-error{{function template partial specialization is not allowed}}
116+
}

0 commit comments

Comments
 (0)