Skip to content

Commit f01b56f

Browse files
authored
[Clang] [NFC] Introduce helpers for defining compatibilty warnings (llvm#132129)
This introduces some tablegen helpers for defining compatibility warnings. The main aim of this is to both simplify adding new compatibility warnings as well as to unify the naming of compatibility warnings. I’ve refactored ~half of the compatiblity warnings (that follow the usual scheme) in `DiagnosticSemaKinds.td` for illustration purposes and also to simplify/unify the wording of some of them (I also corrected a typo in one of them as a drive-by fix). I haven’t (yet) migrated *all* warnings even in that one file, and there are some more specialised ones for which the scheme I’ve established here doesn’t work (e.g. because they’re warning+error instead of warning+extwarn; however, warning+extension *is* supported), but the point of this isn’t to implement *all* compatibility-related warnings this way, only to make the common case a bit easier to handle. This currently also only handles C++ compatibility warnings, but it should be fairly straight-forward to extend the tablegen code so it can also be used for C compatibility warnings (if this gets merged, I’m planning to do that in a follow-up pr). The vast majority of compatibility warnings are emitted by writing ```c++ Diag(Loc, getLangOpts().CPlusPlusYZ ? diag::ext_... : diag::warn_...) ``` in accordance with which I’ve chosen the following naming scheme: ```c++ Diag(Loc, getLangOpts().CPlusPlusYZ ? diag::compat_cxxyz_foo : diag::compat_pre_cxxyz_foo) ``` That is, for a warning about a C++20 feature—i.e. C++≤17 compatibility—we get: ```c++ Diag(Loc, getLangOpts().CPlusPlus20 ? diag::compat_cxx20_foo : diag::compat_pre_cxx20_foo) ``` While there is an argument to be made against writing ‘`compat_cxx20`’ here since is technically a case of ‘C++17 compatibility’ and not ‘C++20 compatibility’, I at least find this easier to reason about, because I can just write the same number 3 times instead of having to use `ext_cxx20_foo` but `warn_cxx17_foo`. Instead, I like to read this as a warning about the ‘compatibility *of* a C++20 feature’ rather than ‘*with* C++17’. I also experimented with moving all compatibility warnings to a separate file, but 1. I don’t think it’s worth the effort, and 2. I think it hurts compile times a bit because at least in my testing I felt that I had to recompile more code than if we just keep e.g. Sema-specific compat warnings in the Sema diagnostics file. Instead, I’ve opted to put them all in the same place within any one file; currently this is a the very top but I don’t really have strong opinions about this.
1 parent 8d825cb commit f01b56f

19 files changed

+211
-254
lines changed

clang/include/clang/Basic/Diagnostic.td

+49
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,55 @@ class DefaultWarnNoWerror {
155155
}
156156
class DefaultRemark { Severity DefaultSeverity = SEV_Remark; }
157157

158+
// C++ compatibility warnings.
159+
multiclass CXXCompat<
160+
string message,
161+
int std_ver,
162+
bit ext_warn = true,
163+
string std_ver_override = ""#std_ver> {
164+
// 'X is a C++YZ extension'.
165+
def compat_pre_cxx#std_ver#_#NAME :
166+
Diagnostic<!strconcat(message, " a C++", std_ver_override, " extension"),
167+
CLASS_EXTENSION,
168+
!if(ext_warn, SEV_Warning, SEV_Ignored)>,
169+
InGroup<!cast<DiagGroup>("CXX"#std_ver)>;
170+
171+
// 'X is incompatible with C++98' (if std_ver == 11).
172+
// 'X is incompatible with C++ standards before C++YZ' (otherwise).
173+
def compat_cxx#std_ver#_#NAME :
174+
Warning<!if(!eq(std_ver, 11),
175+
!strconcat(message, " incompatible with C++98"),
176+
!strconcat(message, " incompatible with C++ standards before C++", std_ver_override))>,
177+
InGroup<!cast<DiagGroup>(!if(!eq(std_ver, 11),
178+
"CXX98Compat",
179+
"CXXPre"#std_ver#"Compat"))>,
180+
DefaultIgnore;
181+
}
182+
183+
// These generate pairs of C++ compatibility warnings of the form:
184+
//
185+
// - compat_cxx<std>_<name>
186+
// - compat_pre_cxx<std>_<name>
187+
//
188+
// The 'compat_cxx...' warning is intended to be issued in C++<std> mode,
189+
// and the 'compat_pre_cxx...' warning in C++ modes before C++<std>.
190+
//
191+
// Example:
192+
//
193+
// defm inline_variable : CXX17Compat<"inline variables are">;
194+
//
195+
// This generates two warnings:
196+
//
197+
// - compat_cxx17_inline_variable: 'inline variables are incompatible with C++ standards before C++17'
198+
// - compat_pre_cxx17_inline_variable: 'inline variables are a C++17 extension'
199+
//
200+
multiclass CXX11Compat<string message, bit ext_warn = true> : CXXCompat<message, 11, ext_warn>;
201+
multiclass CXX14Compat<string message, bit ext_warn = true> : CXXCompat<message, 14, ext_warn>;
202+
multiclass CXX17Compat<string message, bit ext_warn = true> : CXXCompat<message, 17, ext_warn>;
203+
multiclass CXX20Compat<string message, bit ext_warn = true> : CXXCompat<message, 20, ext_warn>;
204+
multiclass CXX23Compat<string message, bit ext_warn = true> : CXXCompat<message, 23, ext_warn>;
205+
multiclass CXX26Compat<string message, bit ext_warn = true> : CXXCompat<message, 26, ext_warn, "2c">;
206+
158207
// Definitions for Diagnostics.
159208
include "DiagnosticASTKinds.td"
160209
include "DiagnosticCommentKinds.td"

clang/include/clang/Basic/DiagnosticSemaKinds.td

+55-145
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,59 @@
1212

1313
let Component = "Sema" in {
1414
let CategoryName = "Semantic Issue" in {
15+
// C++11 compatibility with C++98.
16+
defm nonclass_type_friend : CXX11Compat<"non-class friend type %0 is">;
17+
defm static_data_member_in_union : CXX11Compat<"static data member %0 in union is">;
18+
defm templ_default_in_function_templ : CXX11Compat<
19+
"default template arguments for a function template are">;
20+
defm template_arg_extra_parens : CXX11Compat<
21+
"parentheses around address non-type template argument are">;
22+
defm typename_outside_of_template : CXX11Compat<"'typename' outside of a template is">;
23+
24+
// C++14 compatibility with C++11 and earlier.
25+
defm constexpr_type_definition : CXX14Compat<
26+
"type definition in a constexpr %select{function|constructor}0 is">;
27+
defm constexpr_local_var : CXX14Compat<
28+
"variable declaration in a constexpr %select{function|constructor}0 is">;
29+
defm constexpr_body_multiple_return : CXX14Compat<
30+
"multiple return statements in constexpr function is">;
31+
defm variable_template : CXX14Compat<"variable templates are">;
32+
33+
// C++17 compatibility with C++14 and earlier.
34+
defm decomp_decl : CXX17Compat<"decomposition declarations are">;
35+
defm inline_variable : CXX17Compat<"inline variables are">;
36+
37+
// C++20 compatibility with C++17 and earlier.
38+
defm decomp_decl_spec : CXX20Compat<
39+
"decomposition declaration declared "
40+
"%plural{1:'%1'|:with '%1' specifiers}0 is">;
41+
defm constexpr_local_var_no_init : CXX20Compat<
42+
"uninitialized variable in a constexpr %select{function|constructor}0 is">;
43+
defm constexpr_function_try_block : CXX20Compat<
44+
"function try block in constexpr %select{function|constructor}0 is">;
45+
defm constexpr_union_ctor_no_init : CXX20Compat<
46+
"constexpr union constructor that does not initialize any member is">;
47+
defm constexpr_ctor_missing_init : CXX20Compat<
48+
"constexpr constructor that does not initialize all members is">;
49+
defm adl_only_template_id : CXX20Compat<
50+
"use of function template name with no prior declaration in function call "
51+
"with explicit template arguments is">;
52+
53+
// C++23 compatibility with C++20 and earlier.
54+
defm constexpr_static_var : CXX23Compat<
55+
"definition of a %select{static|thread_local}1 variable "
56+
"in a constexpr %select{function|constructor}0 "
57+
"is">;
58+
59+
// C++26 compatibility with C++23 and earlier.
60+
defm decomp_decl_cond : CXX26Compat<"structured binding declaration in a condition is">;
61+
62+
// Compatibility warnings duplicated across multiple language versions.
63+
foreach std = [14, 20, 23] in {
64+
defm constexpr_body_invalid_stmt : CXXCompat<
65+
"use of this statement in a constexpr %select{function|constructor}0 is", std>;
66+
}
67+
1568
def note_previous_decl : Note<"%0 declared here">;
1669
def note_entity_declared_at : Note<"%0 declared here">;
1770
def note_callee_decl : Note<"%0 declared here">;
@@ -523,30 +576,9 @@ def warn_modifying_shadowing_decl :
523576
// C++ decomposition declarations
524577
def err_decomp_decl_context : Error<
525578
"decomposition declaration not permitted in this context">;
526-
def warn_cxx14_compat_decomp_decl : Warning<
527-
"decomposition declarations are incompatible with "
528-
"C++ standards before C++17">, DefaultIgnore, InGroup<CXXPre17Compat>;
529-
def ext_decomp_decl : ExtWarn<
530-
"decomposition declarations are a C++17 extension">, InGroup<CXX17>;
531-
def ext_decomp_decl_cond : ExtWarn<
532-
"structured binding declaration in a condition is a C++2c extenstion">,
533-
InGroup<CXX26>;
534-
def warn_cxx26_decomp_decl_cond : Warning<
535-
"structured binding declaration in a condition is incompatible with "
536-
"C++ standards before C++2c">,
537-
InGroup<CXXPre26Compat>, DefaultIgnore;
538579
def err_decomp_decl_spec : Error<
539580
"decomposition declaration cannot be declared "
540581
"%plural{1:'%1'|:with '%1' specifiers}0">;
541-
def ext_decomp_decl_spec : ExtWarn<
542-
"decomposition declaration declared "
543-
"%plural{1:'%1'|:with '%1' specifiers}0 is a C++20 extension">,
544-
InGroup<CXX20>;
545-
def warn_cxx17_compat_decomp_decl_spec : Warning<
546-
"decomposition declaration declared "
547-
"%plural{1:'%1'|:with '%1' specifiers}0 "
548-
"is incompatible with C++ standards before C++20">,
549-
InGroup<CXXPre20Compat>, DefaultIgnore;
550582
def err_decomp_decl_type : Error<
551583
"decomposition declaration cannot be declared with type %0; "
552584
"declared type must be 'auto' or reference to 'auto'">;
@@ -1695,12 +1727,6 @@ def warn_consteval_if_always_true : Warning<
16951727
"consteval if is always true in an %select{unevaluated|immediate}0 context">,
16961728
InGroup<DiagGroup<"redundant-consteval-if">>;
16971729

1698-
def ext_inline_variable : ExtWarn<
1699-
"inline variables are a C++17 extension">, InGroup<CXX17>;
1700-
def warn_cxx14_compat_inline_variable : Warning<
1701-
"inline variables are incompatible with C++ standards before C++17">,
1702-
DefaultIgnore, InGroup<CXXPre17Compat>;
1703-
17041730
def warn_inline_namespace_reopened_noninline : Warning<
17051731
"inline namespace reopened as a non-inline namespace">,
17061732
InGroup<InlineNamespaceReopenedNoninline>;
@@ -1716,11 +1742,6 @@ def ext_enum_friend : ExtWarn<
17161742
InGroup<DiagGroup<"friend-enum">>;
17171743
def note_enum_friend : Note<
17181744
"remove 'enum%select{| struct| class}0' to befriend an enum">;
1719-
def ext_nonclass_type_friend : ExtWarn<
1720-
"non-class friend type %0 is a C++11 extension">, InGroup<CXX11>;
1721-
def warn_cxx98_compat_nonclass_type_friend : Warning<
1722-
"non-class friend type %0 is incompatible with C++98">,
1723-
InGroup<CXX98Compat>, DefaultIgnore;
17241745
def err_friend_is_member : Error<
17251746
"friends cannot be members of the declaring class">;
17261747
def warn_cxx98_compat_friend_is_member : Warning<
@@ -2152,11 +2173,6 @@ def select_tag_type_kind : TextSubstitution<
21522173
def err_static_data_member_not_allowed_in_anon_struct : Error<
21532174
"static data member %0 not allowed in anonymous "
21542175
"%sub{select_tag_type_kind}1">;
2155-
def ext_static_data_member_in_union : ExtWarn<
2156-
"static data member %0 in union is a C++11 extension">, InGroup<CXX11>;
2157-
def warn_cxx98_compat_static_data_member_in_union : Warning<
2158-
"static data member %0 in union is incompatible with C++98">,
2159-
InGroup<CXX98Compat>, DefaultIgnore;
21602176
def ext_union_member_of_reference_type : ExtWarn<
21612177
"union member %0 has reference type %1, which is a Microsoft extension">,
21622178
InGroup<MicrosoftUnionMemberReference>;
@@ -2904,63 +2920,17 @@ def err_constexpr_non_literal_param : Error<
29042920
"not a literal type">;
29052921
def err_constexpr_body_invalid_stmt : Error<
29062922
"statement not allowed in %select{constexpr|consteval}1 %select{function|constructor}0">;
2907-
def ext_constexpr_body_invalid_stmt : ExtWarn<
2908-
"use of this statement in a constexpr %select{function|constructor}0 "
2909-
"is a C++14 extension">, InGroup<CXX14>;
2910-
def warn_cxx11_compat_constexpr_body_invalid_stmt : Warning<
2911-
"use of this statement in a constexpr %select{function|constructor}0 "
2912-
"is incompatible with C++ standards before C++14">,
2913-
InGroup<CXXPre14Compat>, DefaultIgnore;
2914-
def ext_constexpr_body_invalid_stmt_cxx20 : ExtWarn<
2915-
"use of this statement in a constexpr %select{function|constructor}0 "
2916-
"is a C++20 extension">, InGroup<CXX20>;
2917-
def warn_cxx17_compat_constexpr_body_invalid_stmt : Warning<
2918-
"use of this statement in a constexpr %select{function|constructor}0 "
2919-
"is incompatible with C++ standards before C++20">,
2920-
InGroup<CXXPre20Compat>, DefaultIgnore;
2921-
def ext_constexpr_body_invalid_stmt_cxx23 : ExtWarn<
2922-
"use of this statement in a constexpr %select{function|constructor}0 "
2923-
"is a C++23 extension">, InGroup<CXX23>;
2924-
def warn_cxx20_compat_constexpr_body_invalid_stmt : Warning<
2925-
"use of this statement in a constexpr %select{function|constructor}0 "
2926-
"is incompatible with C++ standards before C++23">,
2927-
InGroup<CXXPre23Compat>, DefaultIgnore;
2928-
def ext_constexpr_type_definition : ExtWarn<
2929-
"type definition in a constexpr %select{function|constructor}0 "
2930-
"is a C++14 extension">, InGroup<CXX14>;
2931-
def warn_cxx11_compat_constexpr_type_definition : Warning<
2932-
"type definition in a constexpr %select{function|constructor}0 "
2933-
"is incompatible with C++ standards before C++14">,
2934-
InGroup<CXXPre14Compat>, DefaultIgnore;
29352923
def err_constexpr_vla : Error<
29362924
"variably-modified type %0 cannot be used in a constexpr "
29372925
"%select{function|constructor}1">;
2938-
def ext_constexpr_local_var : ExtWarn<
2939-
"variable declaration in a constexpr %select{function|constructor}0 "
2940-
"is a C++14 extension">, InGroup<CXX14>;
2941-
def warn_cxx11_compat_constexpr_local_var : Warning<
2942-
"variable declaration in a constexpr %select{function|constructor}0 "
2943-
"is incompatible with C++ standards before C++14">,
2944-
InGroup<CXXPre14Compat>, DefaultIgnore;
2945-
def ext_constexpr_static_var : ExtWarn<
2946-
"definition of a %select{static|thread_local}1 variable "
2947-
"in a constexpr %select{function|constructor}0 "
2948-
"is a C++23 extension">, InGroup<CXX23>;
29492926
def warn_cxx20_compat_constexpr_var : Warning<
2950-
"definition of a %select{static variable|thread_local variable|variable "
2951-
"of non-literal type}1 in a constexpr %select{function|constructor}0 "
2927+
"definition of a variable of non-literal type in a constexpr "
2928+
"%select{function|constructor}0 "
29522929
"is incompatible with C++ standards before C++23">,
29532930
InGroup<CXXPre23Compat>, DefaultIgnore;
29542931
def err_constexpr_local_var_non_literal_type : Error<
29552932
"variable of non-literal type %1 cannot be defined in a constexpr "
29562933
"%select{function|constructor}0 before C++23">;
2957-
def ext_constexpr_local_var_no_init : ExtWarn<
2958-
"uninitialized variable in a constexpr %select{function|constructor}0 "
2959-
"is a C++20 extension">, InGroup<CXX20>;
2960-
def warn_cxx17_compat_constexpr_local_var_no_init : Warning<
2961-
"uninitialized variable in a constexpr %select{function|constructor}0 "
2962-
"is incompatible with C++ standards before C++20">,
2963-
InGroup<CXXPre20Compat>, DefaultIgnore;
29642934
def ext_constexpr_function_never_constant_expr : ExtWarn<
29652935
"%select{constexpr|consteval}1 %select{function|constructor}0 never produces a "
29662936
"constant expression">, InGroup<DiagGroup<"invalid-constexpr">>, DefaultError;
@@ -2982,41 +2952,11 @@ def err_constexpr_return_missing_expr : Error<
29822952
def warn_cxx11_compat_constexpr_body_no_return : Warning<
29832953
"constexpr function with no return statements is incompatible with C++ "
29842954
"standards before C++14">, InGroup<CXXPre14Compat>, DefaultIgnore;
2985-
def ext_constexpr_body_multiple_return : ExtWarn<
2986-
"multiple return statements in constexpr function is a C++14 extension">,
2987-
InGroup<CXX14>;
2988-
def warn_cxx11_compat_constexpr_body_multiple_return : Warning<
2989-
"multiple return statements in constexpr function "
2990-
"is incompatible with C++ standards before C++14">,
2991-
InGroup<CXXPre14Compat>, DefaultIgnore;
29922955
def note_constexpr_body_previous_return : Note<
29932956
"previous return statement is here">;
29942957
def err_ms_constexpr_cannot_be_applied : Error<
29952958
"attribute 'msvc::constexpr' cannot be applied to the %select{constexpr|consteval|virtual}0 function %1">;
29962959

2997-
// C++20 function try blocks in constexpr
2998-
def ext_constexpr_function_try_block_cxx20 : ExtWarn<
2999-
"function try block in constexpr %select{function|constructor}0 is "
3000-
"a C++20 extension">, InGroup<CXX20>;
3001-
def warn_cxx17_compat_constexpr_function_try_block : Warning<
3002-
"function try block in constexpr %select{function|constructor}0 is "
3003-
"incompatible with C++ standards before C++20">,
3004-
InGroup<CXXPre20Compat>, DefaultIgnore;
3005-
3006-
def ext_constexpr_union_ctor_no_init : ExtWarn<
3007-
"constexpr union constructor that does not initialize any member "
3008-
"is a C++20 extension">, InGroup<CXX20>;
3009-
def warn_cxx17_compat_constexpr_union_ctor_no_init : Warning<
3010-
"constexpr union constructor that does not initialize any member "
3011-
"is incompatible with C++ standards before C++20">,
3012-
InGroup<CXXPre20Compat>, DefaultIgnore;
3013-
def ext_constexpr_ctor_missing_init : ExtWarn<
3014-
"constexpr constructor that does not initialize all members "
3015-
"is a C++20 extension">, InGroup<CXX20>;
3016-
def warn_cxx17_compat_constexpr_ctor_missing_init : Warning<
3017-
"constexpr constructor that does not initialize all members "
3018-
"is incompatible with C++ standards before C++20">,
3019-
InGroup<CXXPre20Compat>, DefaultIgnore;
30202960
def note_constexpr_ctor_missing_init : Note<
30212961
"member not initialized by constructor">;
30222962
def note_non_literal_no_constexpr_ctors : Note<
@@ -5293,12 +5233,6 @@ def note_template_param_prev_default_arg_in_other_module : Note<
52935233
"previous default template argument defined in module %0">;
52945234
def err_template_param_default_arg_missing : Error<
52955235
"template parameter missing a default argument">;
5296-
def ext_template_parameter_default_in_function_template : ExtWarn<
5297-
"default template arguments for a function template are a C++11 extension">,
5298-
InGroup<CXX11>;
5299-
def warn_cxx98_compat_template_parameter_default_in_function_template : Warning<
5300-
"default template arguments for a function template are incompatible with C++98">,
5301-
InGroup<CXX98Compat>, DefaultIgnore;
53025236
def err_template_parameter_default_template_member : Error<
53035237
"cannot add a default template argument to the definition of a member of a "
53045238
"class template">;
@@ -5307,11 +5241,6 @@ def err_template_parameter_default_friend_template : Error<
53075241
def err_template_template_parm_no_parms : Error<
53085242
"template template parameter must have its own template parameters">;
53095243

5310-
def ext_variable_template : ExtWarn<"variable templates are a C++14 extension">,
5311-
InGroup<CXX14>;
5312-
def warn_cxx11_compat_variable_template : Warning<
5313-
"variable templates are incompatible with C++ standards before C++14">,
5314-
InGroup<CXXPre14Compat>, DefaultIgnore;
53155244
def err_template_variable_noparams : Error<
53165245
"extraneous 'template<>' in declaration of variable %0">;
53175246
def err_template_member : Error<"non-static data member %0 cannot be declared as a template">;
@@ -5321,15 +5250,6 @@ def err_template_member_noparams : Error<
53215250
def err_template_tag_noparams : Error<
53225251
"extraneous 'template<>' in declaration of %0 %1">;
53235252

5324-
def warn_cxx17_compat_adl_only_template_id : Warning<
5325-
"use of function template name with no prior function template "
5326-
"declaration in function call with explicit template arguments "
5327-
"is incompatible with C++ standards before C++20">,
5328-
InGroup<CXXPre20Compat>, DefaultIgnore;
5329-
def ext_adl_only_template_id : ExtWarn<
5330-
"use of function template name with no prior declaration in function call "
5331-
"with explicit template arguments is a C++20 extension">, InGroup<CXX20>;
5332-
53335253
def warn_unqualified_call_to_std_cast_function : Warning<
53345254
"unqualified call to '%0'">, InGroup<DiagGroup<"unqualified-std-cast-call">>;
53355255

@@ -5468,11 +5388,6 @@ def err_template_arg_not_pointer_to_member_form : Error<
54685388
"non-type template argument is not a pointer to member constant">;
54695389
def err_template_arg_invalid : Error<
54705390
"non-type template argument '%0' is invalid">;
5471-
def ext_template_arg_extra_parens : ExtWarn<
5472-
"address non-type template argument cannot be surrounded by parentheses">;
5473-
def warn_cxx98_compat_template_arg_extra_parens : Warning<
5474-
"redundant parentheses surrounding address non-type template argument are "
5475-
"incompatible with C++98">, InGroup<CXX98Compat>, DefaultIgnore;
54765391
def err_pointer_to_member_type : Error<
54775392
"invalid use of pointer to member type after %select{.*|->*}0">;
54785393
def err_pointer_to_member_call_drops_quals : Error<
@@ -5887,11 +5802,6 @@ def err_typename_missing_template
58875802
def ext_typename_missing
58885803
: ExtWarn<"missing 'typename' prior to dependent type name %0">,
58895804
InGroup<DiagGroup<"typename-missing">>;
5890-
def ext_typename_outside_of_template : ExtWarn<
5891-
"'typename' occurs outside of a template">, InGroup<CXX11>;
5892-
def warn_cxx98_compat_typename_outside_of_template : Warning<
5893-
"use of 'typename' outside of a template is incompatible with C++98">,
5894-
InGroup<CXX98Compat>, DefaultIgnore;
58955805
def err_typename_refers_to_using_value_decl : Error<
58965806
"typename specifier refers to a dependent using declaration for a value "
58975807
"%0 in %1">;

clang/lib/Sema/SemaDecl.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -7649,8 +7649,8 @@ NamedDecl *Sema::ActOnVariableDeclarator(
76497649
// Only C++1y supports variable templates (N3651).
76507650
Diag(D.getIdentifierLoc(),
76517651
getLangOpts().CPlusPlus14
7652-
? diag::warn_cxx11_compat_variable_template
7653-
: diag::ext_variable_template);
7652+
? diag::compat_cxx14_variable_template
7653+
: diag::compat_pre_cxx14_variable_template);
76547654
}
76557655
}
76567656
} else {
@@ -7718,8 +7718,8 @@ NamedDecl *Sema::ActOnVariableDeclarator(
77187718
// the program is ill-formed. C++11 drops this restriction.
77197719
Diag(D.getIdentifierLoc(),
77207720
getLangOpts().CPlusPlus11
7721-
? diag::warn_cxx98_compat_static_data_member_in_union
7722-
: diag::ext_static_data_member_in_union)
7721+
? diag::compat_cxx11_static_data_member_in_union
7722+
: diag::compat_pre_cxx11_static_data_member_in_union)
77237723
<< Name;
77247724
}
77257725
}
@@ -7822,8 +7822,8 @@ NamedDecl *Sema::ActOnVariableDeclarator(
78227822
<< FixItHint::CreateRemoval(D.getDeclSpec().getInlineSpecLoc());
78237823
} else {
78247824
Diag(D.getDeclSpec().getInlineSpecLoc(),
7825-
getLangOpts().CPlusPlus17 ? diag::warn_cxx14_compat_inline_variable
7826-
: diag::ext_inline_variable);
7825+
getLangOpts().CPlusPlus17 ? diag::compat_cxx17_inline_variable
7826+
: diag::compat_pre_cxx17_inline_variable);
78277827
NewVD->setInlineSpecified();
78287828
}
78297829
}

0 commit comments

Comments
 (0)