Skip to content

Commit a539afc

Browse files
committed
Clang: Add warning flag for storage class specifiers on explicit specializations
With the recent fix for this situation in class members (#93873) (for which the fixed code is invalid prior to this patch - making migrating code difficult as it must be in lock-step with the compiler migration, if building with -Werror) it'd be really useful to be able to disable this warning during the compiler migration/decouple the compiler migration from the source fixes. In theory this approach will regress the codebase to the previous non-member cases of this issue that were already being held back by the warning (as opposed to if we carved out the new cases into a separate warning from the existing cases) but I think this'll be so rare and the cleanup so simple, that the extra regressions of disabling the warning broadly won't be too much of a problem. (but if folks disagree, I'm open to making the warning more fine-grained)
1 parent 6621505 commit a539afc

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

clang/include/clang/Basic/DiagnosticGroups.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1535,3 +1535,7 @@ def BitIntExtension : DiagGroup<"bit-int-extension">;
15351535

15361536
// Warnings about misuse of ExtractAPI options.
15371537
def ExtractAPIMisuse : DiagGroup<"extractapi-misuse">;
1538+
1539+
// Warnings about using the non-standard extension having an explicit specialization
1540+
// with a storage class specifier.
1541+
def ExplicitSpecializationStorageClass : DiagGroup<"explicit-specialization-storage-class">;

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5366,7 +5366,7 @@ def err_not_class_template_specialization : Error<
53665366
"cannot specialize a %select{dependent template|template template "
53675367
"parameter}0">;
53685368
def ext_explicit_specialization_storage_class : ExtWarn<
5369-
"explicit specialization cannot have a storage class">;
5369+
"explicit specialization cannot have a storage class">, InGroup<ExplicitSpecializationStorageClass>;
53705370
def err_dependent_function_template_spec_no_match : Error<
53715371
"no candidate function template was found for dependent"
53725372
" %select{member|friend}0 function template specialization">;

clang/test/Misc/warning-flags.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@ This test serves two purposes:
1818

1919
The list of warnings below should NEVER grow. It should gradually shrink to 0.
2020

21-
CHECK: Warnings without flags (66):
21+
CHECK: Warnings without flags (65):
2222

2323
CHECK-NEXT: ext_expected_semi_decl_list
24-
CHECK-NEXT: ext_explicit_specialization_storage_class
2524
CHECK-NEXT: ext_missing_whitespace_after_macro_name
2625
CHECK-NEXT: ext_new_paren_array_nonconst
2726
CHECK-NEXT: ext_plain_complex

0 commit comments

Comments
 (0)