aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--clang/docs/ReleaseNotes.rst9
-rw-r--r--clang/include/clang/Basic/DiagnosticSemaKinds.td3
-rw-r--r--clang/test/Misc/warning-flags.c3
-rw-r--r--clang/test/SemaTemplate/temp_explicit.cpp7
4 files changed, 18 insertions, 4 deletions
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 1541b0c..7c4451d 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -65,6 +65,15 @@ C++ Specific Potentially Breaking Changes
`-Wno-enum-constexpr-conversion`, to allow for a transition period for users.
Now, in Clang 20, **it is no longer possible to suppress the diagnostic**.
+- Extraneous template headers are now ill-formed by default.
+ This error can be disable with ``-Wno-error=extraneous-template-head``.
+
+ .. code-block:: c++
+
+ template <> // error: extraneous template head
+ template <typename T>
+ void f();
+
ABI Changes in This Version
---------------------------
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index c710c33..da2f939 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -5428,7 +5428,8 @@ def err_template_spec_extra_headers : Error<
"extraneous template parameter list in template specialization or "
"out-of-line template definition">;
def ext_template_spec_extra_headers : ExtWarn<
- "extraneous template parameter list in template specialization">;
+ "extraneous template parameter list in template specialization">,
+ InGroup<DiagGroup<"extraneous-template-head">>, DefaultError;
def note_explicit_template_spec_does_not_need_header : Note<
"'template<>' header not required for explicitly-specialized class %0 "
"declared here">;
diff --git a/clang/test/Misc/warning-flags.c b/clang/test/Misc/warning-flags.c
index cdbe1e9..35543e6 100644
--- a/clang/test/Misc/warning-flags.c
+++ b/clang/test/Misc/warning-flags.c
@@ -18,14 +18,13 @@ This test serves two purposes:
The list of warnings below should NEVER grow. It should gradually shrink to 0.
-CHECK: Warnings without flags (65):
+CHECK: Warnings without flags (64):
CHECK-NEXT: ext_expected_semi_decl_list
CHECK-NEXT: ext_missing_whitespace_after_macro_name
CHECK-NEXT: ext_new_paren_array_nonconst
CHECK-NEXT: ext_plain_complex
CHECK-NEXT: ext_template_arg_extra_parens
-CHECK-NEXT: ext_template_spec_extra_headers
CHECK-NEXT: ext_typecheck_cond_incompatible_operands
CHECK-NEXT: ext_typecheck_ordered_comparison_of_pointer_integer
CHECK-NEXT: ext_using_undefined_std
diff --git a/clang/test/SemaTemplate/temp_explicit.cpp b/clang/test/SemaTemplate/temp_explicit.cpp
index 0bb0cfa..4612e4a 100644
--- a/clang/test/SemaTemplate/temp_explicit.cpp
+++ b/clang/test/SemaTemplate/temp_explicit.cpp
@@ -1,6 +1,7 @@
// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -Wc++11-compat %s
// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -Wc++11-compat -std=c++98 %s
// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -std=c++20 %s
//
// Tests explicit instantiation of templates.
template<typename T, typename U = T> class X0 { };
@@ -128,11 +129,15 @@ struct Foo<int> // expected-note{{header not required for explicitly-specialized
{};
};
-template <> // expected-warning{{extraneous template parameter list}}
+template <> // expected-error{{extraneous template parameter list}}
template <>
struct Foo<int>::Bar<void>
{};
+#if __cplusplus >= 202002L
+template<> void f(auto); // expected-error{{extraneous template parameter list}}
+#endif
+
namespace N1 {
template<typename T> struct X7 { }; // expected-note{{here}}