diff --git a/clang/include/clang/Basic/Diagnostic.td b/clang/include/clang/Basic/Diagnostic.td index 0b8b3af939ba..b31d846210a8 100644 --- a/clang/include/clang/Basic/Diagnostic.td +++ b/clang/include/clang/Basic/Diagnostic.td @@ -155,6 +155,55 @@ class DefaultWarnNoWerror { } class DefaultRemark { Severity DefaultSeverity = SEV_Remark; } +// C++ compatibility warnings. +multiclass CXXCompat< + string message, + int std_ver, + bit ext_warn = true, + string std_ver_override = ""#std_ver> { + // 'X is a C++YZ extension'. + def compat_pre_cxx#std_ver#_#NAME : + Diagnostic, + InGroup("CXX"#std_ver)>; + + // 'X is incompatible with C++98' (if std_ver == 11). + // 'X is incompatible with C++ standards before C++YZ' (otherwise). + def compat_cxx#std_ver#_#NAME : + Warning, + InGroup(!if(!eq(std_ver, 11), + "CXX98Compat", + "CXXPre"#std_ver#"Compat"))>, + DefaultIgnore; +} + +// These generate pairs of C++ compatibility warnings of the form: +// +// - compat_cxx_ +// - compat_pre_cxx_ +// +// The 'compat_cxx...' warning is intended to be issued in C++ mode, +// and the 'compat_pre_cxx...' warning in C++ modes before C++. +// +// Example: +// +// defm inline_variable : CXX17Compat<"inline variables are">; +// +// This generates two warnings: +// +// - compat_cxx17_inline_variable: 'inline variables are incompatible with C++ standards before C++17' +// - compat_pre_cxx17_inline_variable: 'inline variables are a C++17 extension' +// +multiclass CXX11Compat : CXXCompat; +multiclass CXX14Compat : CXXCompat; +multiclass CXX17Compat : CXXCompat; +multiclass CXX20Compat : CXXCompat; +multiclass CXX23Compat : CXXCompat; +multiclass CXX26Compat : CXXCompat; + // Definitions for Diagnostics. include "DiagnosticASTKinds.td" include "DiagnosticCommentKinds.td" diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 1536a3b8c920..eed06657536f 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -12,6 +12,59 @@ let Component = "Sema" in { let CategoryName = "Semantic Issue" in { +// C++11 compatibility with C++98. +defm nonclass_type_friend : CXX11Compat<"non-class friend type %0 is">; +defm static_data_member_in_union : CXX11Compat<"static data member %0 in union is">; +defm templ_default_in_function_templ : CXX11Compat< + "default template arguments for a function template are">; +defm template_arg_extra_parens : CXX11Compat< + "parentheses around address non-type template argument are">; +defm typename_outside_of_template : CXX11Compat<"'typename' outside of a template is">; + +// C++14 compatibility with C++11 and earlier. +defm constexpr_type_definition : CXX14Compat< + "type definition in a constexpr %select{function|constructor}0 is">; +defm constexpr_local_var : CXX14Compat< + "variable declaration in a constexpr %select{function|constructor}0 is">; +defm constexpr_body_multiple_return : CXX14Compat< + "multiple return statements in constexpr function is">; +defm variable_template : CXX14Compat<"variable templates are">; + +// C++17 compatibility with C++14 and earlier. +defm decomp_decl : CXX17Compat<"decomposition declarations are">; +defm inline_variable : CXX17Compat<"inline variables are">; + +// C++20 compatibility with C++17 and earlier. +defm decomp_decl_spec : CXX20Compat< + "decomposition declaration declared " + "%plural{1:'%1'|:with '%1' specifiers}0 is">; +defm constexpr_local_var_no_init : CXX20Compat< + "uninitialized variable in a constexpr %select{function|constructor}0 is">; +defm constexpr_function_try_block : CXX20Compat< + "function try block in constexpr %select{function|constructor}0 is">; +defm constexpr_union_ctor_no_init : CXX20Compat< + "constexpr union constructor that does not initialize any member is">; +defm constexpr_ctor_missing_init : CXX20Compat< + "constexpr constructor that does not initialize all members is">; +defm adl_only_template_id : CXX20Compat< + "use of function template name with no prior declaration in function call " + "with explicit template arguments is">; + +// C++23 compatibility with C++20 and earlier. +defm constexpr_static_var : CXX23Compat< + "definition of a %select{static|thread_local}1 variable " + "in a constexpr %select{function|constructor}0 " + "is">; + +// C++26 compatibility with C++23 and earlier. +defm decomp_decl_cond : CXX26Compat<"structured binding declaration in a condition is">; + +// Compatibility warnings duplicated across multiple language versions. +foreach std = [14, 20, 23] in { + defm constexpr_body_invalid_stmt : CXXCompat< + "use of this statement in a constexpr %select{function|constructor}0 is", std>; +} + def note_previous_decl : Note<"%0 declared here">; def note_entity_declared_at : Note<"%0 declared here">; def note_callee_decl : Note<"%0 declared here">; @@ -523,30 +576,9 @@ def warn_modifying_shadowing_decl : // C++ decomposition declarations def err_decomp_decl_context : Error< "decomposition declaration not permitted in this context">; -def warn_cxx14_compat_decomp_decl : Warning< - "decomposition declarations are incompatible with " - "C++ standards before C++17">, DefaultIgnore, InGroup; -def ext_decomp_decl : ExtWarn< - "decomposition declarations are a C++17 extension">, InGroup; -def ext_decomp_decl_cond : ExtWarn< - "structured binding declaration in a condition is a C++2c extenstion">, - InGroup; -def warn_cxx26_decomp_decl_cond : Warning< - "structured binding declaration in a condition is incompatible with " - "C++ standards before C++2c">, - InGroup, DefaultIgnore; def err_decomp_decl_spec : Error< "decomposition declaration cannot be declared " "%plural{1:'%1'|:with '%1' specifiers}0">; -def ext_decomp_decl_spec : ExtWarn< - "decomposition declaration declared " - "%plural{1:'%1'|:with '%1' specifiers}0 is a C++20 extension">, - InGroup; -def warn_cxx17_compat_decomp_decl_spec : Warning< - "decomposition declaration declared " - "%plural{1:'%1'|:with '%1' specifiers}0 " - "is incompatible with C++ standards before C++20">, - InGroup, DefaultIgnore; def err_decomp_decl_type : Error< "decomposition declaration cannot be declared with type %0; " "declared type must be 'auto' or reference to 'auto'">; @@ -1695,12 +1727,6 @@ def warn_consteval_if_always_true : Warning< "consteval if is always true in an %select{unevaluated|immediate}0 context">, InGroup>; -def ext_inline_variable : ExtWarn< - "inline variables are a C++17 extension">, InGroup; -def warn_cxx14_compat_inline_variable : Warning< - "inline variables are incompatible with C++ standards before C++17">, - DefaultIgnore, InGroup; - def warn_inline_namespace_reopened_noninline : Warning< "inline namespace reopened as a non-inline namespace">, InGroup; @@ -1716,11 +1742,6 @@ def ext_enum_friend : ExtWarn< InGroup>; def note_enum_friend : Note< "remove 'enum%select{| struct| class}0' to befriend an enum">; -def ext_nonclass_type_friend : ExtWarn< - "non-class friend type %0 is a C++11 extension">, InGroup; -def warn_cxx98_compat_nonclass_type_friend : Warning< - "non-class friend type %0 is incompatible with C++98">, - InGroup, DefaultIgnore; def err_friend_is_member : Error< "friends cannot be members of the declaring class">; def warn_cxx98_compat_friend_is_member : Warning< @@ -2152,11 +2173,6 @@ def select_tag_type_kind : TextSubstitution< def err_static_data_member_not_allowed_in_anon_struct : Error< "static data member %0 not allowed in anonymous " "%sub{select_tag_type_kind}1">; -def ext_static_data_member_in_union : ExtWarn< - "static data member %0 in union is a C++11 extension">, InGroup; -def warn_cxx98_compat_static_data_member_in_union : Warning< - "static data member %0 in union is incompatible with C++98">, - InGroup, DefaultIgnore; def ext_union_member_of_reference_type : ExtWarn< "union member %0 has reference type %1, which is a Microsoft extension">, InGroup; @@ -2904,63 +2920,17 @@ def err_constexpr_non_literal_param : Error< "not a literal type">; def err_constexpr_body_invalid_stmt : Error< "statement not allowed in %select{constexpr|consteval}1 %select{function|constructor}0">; -def ext_constexpr_body_invalid_stmt : ExtWarn< - "use of this statement in a constexpr %select{function|constructor}0 " - "is a C++14 extension">, InGroup; -def warn_cxx11_compat_constexpr_body_invalid_stmt : Warning< - "use of this statement in a constexpr %select{function|constructor}0 " - "is incompatible with C++ standards before C++14">, - InGroup, DefaultIgnore; -def ext_constexpr_body_invalid_stmt_cxx20 : ExtWarn< - "use of this statement in a constexpr %select{function|constructor}0 " - "is a C++20 extension">, InGroup; -def warn_cxx17_compat_constexpr_body_invalid_stmt : Warning< - "use of this statement in a constexpr %select{function|constructor}0 " - "is incompatible with C++ standards before C++20">, - InGroup, DefaultIgnore; -def ext_constexpr_body_invalid_stmt_cxx23 : ExtWarn< - "use of this statement in a constexpr %select{function|constructor}0 " - "is a C++23 extension">, InGroup; -def warn_cxx20_compat_constexpr_body_invalid_stmt : Warning< - "use of this statement in a constexpr %select{function|constructor}0 " - "is incompatible with C++ standards before C++23">, - InGroup, DefaultIgnore; -def ext_constexpr_type_definition : ExtWarn< - "type definition in a constexpr %select{function|constructor}0 " - "is a C++14 extension">, InGroup; -def warn_cxx11_compat_constexpr_type_definition : Warning< - "type definition in a constexpr %select{function|constructor}0 " - "is incompatible with C++ standards before C++14">, - InGroup, DefaultIgnore; def err_constexpr_vla : Error< "variably-modified type %0 cannot be used in a constexpr " "%select{function|constructor}1">; -def ext_constexpr_local_var : ExtWarn< - "variable declaration in a constexpr %select{function|constructor}0 " - "is a C++14 extension">, InGroup; -def warn_cxx11_compat_constexpr_local_var : Warning< - "variable declaration in a constexpr %select{function|constructor}0 " - "is incompatible with C++ standards before C++14">, - InGroup, DefaultIgnore; -def ext_constexpr_static_var : ExtWarn< - "definition of a %select{static|thread_local}1 variable " - "in a constexpr %select{function|constructor}0 " - "is a C++23 extension">, InGroup; def warn_cxx20_compat_constexpr_var : Warning< - "definition of a %select{static variable|thread_local variable|variable " - "of non-literal type}1 in a constexpr %select{function|constructor}0 " + "definition of a variable of non-literal type in a constexpr " + "%select{function|constructor}0 " "is incompatible with C++ standards before C++23">, InGroup, DefaultIgnore; def err_constexpr_local_var_non_literal_type : Error< "variable of non-literal type %1 cannot be defined in a constexpr " "%select{function|constructor}0 before C++23">; -def ext_constexpr_local_var_no_init : ExtWarn< - "uninitialized variable in a constexpr %select{function|constructor}0 " - "is a C++20 extension">, InGroup; -def warn_cxx17_compat_constexpr_local_var_no_init : Warning< - "uninitialized variable in a constexpr %select{function|constructor}0 " - "is incompatible with C++ standards before C++20">, - InGroup, DefaultIgnore; def ext_constexpr_function_never_constant_expr : ExtWarn< "%select{constexpr|consteval}1 %select{function|constructor}0 never produces a " "constant expression">, InGroup>, DefaultError; @@ -2982,41 +2952,11 @@ def err_constexpr_return_missing_expr : Error< def warn_cxx11_compat_constexpr_body_no_return : Warning< "constexpr function with no return statements is incompatible with C++ " "standards before C++14">, InGroup, DefaultIgnore; -def ext_constexpr_body_multiple_return : ExtWarn< - "multiple return statements in constexpr function is a C++14 extension">, - InGroup; -def warn_cxx11_compat_constexpr_body_multiple_return : Warning< - "multiple return statements in constexpr function " - "is incompatible with C++ standards before C++14">, - InGroup, DefaultIgnore; def note_constexpr_body_previous_return : Note< "previous return statement is here">; def err_ms_constexpr_cannot_be_applied : Error< "attribute 'msvc::constexpr' cannot be applied to the %select{constexpr|consteval|virtual}0 function %1">; -// C++20 function try blocks in constexpr -def ext_constexpr_function_try_block_cxx20 : ExtWarn< - "function try block in constexpr %select{function|constructor}0 is " - "a C++20 extension">, InGroup; -def warn_cxx17_compat_constexpr_function_try_block : Warning< - "function try block in constexpr %select{function|constructor}0 is " - "incompatible with C++ standards before C++20">, - InGroup, DefaultIgnore; - -def ext_constexpr_union_ctor_no_init : ExtWarn< - "constexpr union constructor that does not initialize any member " - "is a C++20 extension">, InGroup; -def warn_cxx17_compat_constexpr_union_ctor_no_init : Warning< - "constexpr union constructor that does not initialize any member " - "is incompatible with C++ standards before C++20">, - InGroup, DefaultIgnore; -def ext_constexpr_ctor_missing_init : ExtWarn< - "constexpr constructor that does not initialize all members " - "is a C++20 extension">, InGroup; -def warn_cxx17_compat_constexpr_ctor_missing_init : Warning< - "constexpr constructor that does not initialize all members " - "is incompatible with C++ standards before C++20">, - InGroup, DefaultIgnore; def note_constexpr_ctor_missing_init : Note< "member not initialized by constructor">; def note_non_literal_no_constexpr_ctors : Note< @@ -5293,12 +5233,6 @@ def note_template_param_prev_default_arg_in_other_module : Note< "previous default template argument defined in module %0">; def err_template_param_default_arg_missing : Error< "template parameter missing a default argument">; -def ext_template_parameter_default_in_function_template : ExtWarn< - "default template arguments for a function template are a C++11 extension">, - InGroup; -def warn_cxx98_compat_template_parameter_default_in_function_template : Warning< - "default template arguments for a function template are incompatible with C++98">, - InGroup, DefaultIgnore; def err_template_parameter_default_template_member : Error< "cannot add a default template argument to the definition of a member of a " "class template">; @@ -5307,11 +5241,6 @@ def err_template_parameter_default_friend_template : Error< def err_template_template_parm_no_parms : Error< "template template parameter must have its own template parameters">; -def ext_variable_template : ExtWarn<"variable templates are a C++14 extension">, - InGroup; -def warn_cxx11_compat_variable_template : Warning< - "variable templates are incompatible with C++ standards before C++14">, - InGroup, DefaultIgnore; def err_template_variable_noparams : Error< "extraneous 'template<>' in declaration of variable %0">; 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< def err_template_tag_noparams : Error< "extraneous 'template<>' in declaration of %0 %1">; -def warn_cxx17_compat_adl_only_template_id : Warning< - "use of function template name with no prior function template " - "declaration in function call with explicit template arguments " - "is incompatible with C++ standards before C++20">, - InGroup, DefaultIgnore; -def ext_adl_only_template_id : ExtWarn< - "use of function template name with no prior declaration in function call " - "with explicit template arguments is a C++20 extension">, InGroup; - def warn_unqualified_call_to_std_cast_function : Warning< "unqualified call to '%0'">, InGroup>; @@ -5468,11 +5388,6 @@ def err_template_arg_not_pointer_to_member_form : Error< "non-type template argument is not a pointer to member constant">; def err_template_arg_invalid : Error< "non-type template argument '%0' is invalid">; -def ext_template_arg_extra_parens : ExtWarn< - "address non-type template argument cannot be surrounded by parentheses">; -def warn_cxx98_compat_template_arg_extra_parens : Warning< - "redundant parentheses surrounding address non-type template argument are " - "incompatible with C++98">, InGroup, DefaultIgnore; def err_pointer_to_member_type : Error< "invalid use of pointer to member type after %select{.*|->*}0">; def err_pointer_to_member_call_drops_quals : Error< @@ -5887,11 +5802,6 @@ def err_typename_missing_template def ext_typename_missing : ExtWarn<"missing 'typename' prior to dependent type name %0">, InGroup>; -def ext_typename_outside_of_template : ExtWarn< - "'typename' occurs outside of a template">, InGroup; -def warn_cxx98_compat_typename_outside_of_template : Warning< - "use of 'typename' outside of a template is incompatible with C++98">, - InGroup, DefaultIgnore; def err_typename_refers_to_using_value_decl : Error< "typename specifier refers to a dependent using declaration for a value " "%0 in %1">; diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index fdfba48ab4b1..9042655dc1b8 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -7649,8 +7649,8 @@ NamedDecl *Sema::ActOnVariableDeclarator( // Only C++1y supports variable templates (N3651). Diag(D.getIdentifierLoc(), getLangOpts().CPlusPlus14 - ? diag::warn_cxx11_compat_variable_template - : diag::ext_variable_template); + ? diag::compat_cxx14_variable_template + : diag::compat_pre_cxx14_variable_template); } } } else { @@ -7718,8 +7718,8 @@ NamedDecl *Sema::ActOnVariableDeclarator( // the program is ill-formed. C++11 drops this restriction. Diag(D.getIdentifierLoc(), getLangOpts().CPlusPlus11 - ? diag::warn_cxx98_compat_static_data_member_in_union - : diag::ext_static_data_member_in_union) + ? diag::compat_cxx11_static_data_member_in_union + : diag::compat_pre_cxx11_static_data_member_in_union) << Name; } } @@ -7822,8 +7822,8 @@ NamedDecl *Sema::ActOnVariableDeclarator( << FixItHint::CreateRemoval(D.getDeclSpec().getInlineSpecLoc()); } else { Diag(D.getDeclSpec().getInlineSpecLoc(), - getLangOpts().CPlusPlus17 ? diag::warn_cxx14_compat_inline_variable - : diag::ext_inline_variable); + getLangOpts().CPlusPlus17 ? diag::compat_cxx17_inline_variable + : diag::compat_pre_cxx17_inline_variable); NewVD->setInlineSpecified(); } } diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index a1551e8027cd..8ea24deecd53 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -745,12 +745,13 @@ Sema::ActOnDecompositionDeclarator(Scope *S, Declarator &D, unsigned DiagID; if (!getLangOpts().CPlusPlus17) - DiagID = diag::ext_decomp_decl; + DiagID = diag::compat_pre_cxx17_decomp_decl; else if (D.getContext() == DeclaratorContext::Condition) - DiagID = getLangOpts().CPlusPlus26 ? diag::warn_cxx26_decomp_decl_cond - : diag::ext_decomp_decl_cond; + DiagID = getLangOpts().CPlusPlus26 + ? diag::compat_cxx26_decomp_decl_cond + : diag::compat_pre_cxx26_decomp_decl_cond; else - DiagID = diag::warn_cxx14_compat_decomp_decl; + DiagID = diag::compat_cxx17_decomp_decl; Diag(Decomp.getLSquareLoc(), DiagID) << Decomp.getSourceRange(); @@ -808,8 +809,8 @@ Sema::ActOnDecompositionDeclarator(Scope *S, Declarator &D, } else if (!CPlusPlus20Specifiers.empty()) { auto &&Warn = Diag(CPlusPlus20SpecifierLocs.front(), getLangOpts().CPlusPlus20 - ? diag::warn_cxx17_compat_decomp_decl_spec - : diag::ext_decomp_decl_spec); + ? diag::compat_cxx20_decomp_decl_spec + : diag::compat_pre_cxx20_decomp_decl_spec); Warn << (int)CPlusPlus20Specifiers.size() << llvm::join(CPlusPlus20Specifiers.begin(), CPlusPlus20Specifiers.end(), " "); @@ -2041,8 +2042,8 @@ static bool CheckConstexprDeclStmt(Sema &SemaRef, const FunctionDecl *Dcl, if (Kind == Sema::CheckConstexprKind::Diagnose) { SemaRef.Diag(DS->getBeginLoc(), SemaRef.getLangOpts().CPlusPlus14 - ? diag::warn_cxx11_compat_constexpr_type_definition - : diag::ext_constexpr_type_definition) + ? diag::compat_cxx14_constexpr_type_definition + : diag::compat_pre_cxx14_constexpr_type_definition) << isa(Dcl); } else if (!SemaRef.getLangOpts().CPlusPlus14) { return false; @@ -2069,8 +2070,8 @@ static bool CheckConstexprDeclStmt(Sema &SemaRef, const FunctionDecl *Dcl, if (Kind == Sema::CheckConstexprKind::Diagnose) { SemaRef.Diag(VD->getLocation(), SemaRef.getLangOpts().CPlusPlus23 - ? diag::warn_cxx20_compat_constexpr_var - : diag::ext_constexpr_static_var) + ? diag::compat_cxx23_constexpr_static_var + : diag::compat_pre_cxx23_constexpr_static_var) << isa(Dcl) << (VD->getTLSKind() == VarDecl::TLS_Dynamic); } else if (!SemaRef.getLangOpts().CPlusPlus23) { @@ -2080,8 +2081,7 @@ static bool CheckConstexprDeclStmt(Sema &SemaRef, const FunctionDecl *Dcl, if (SemaRef.LangOpts.CPlusPlus23) { CheckLiteralType(SemaRef, Kind, VD->getLocation(), VD->getType(), diag::warn_cxx20_compat_constexpr_var, - isa(Dcl), - /*variable of non-literal type*/ 2); + isa(Dcl)); } else if (CheckLiteralType( SemaRef, Kind, VD->getLocation(), VD->getType(), diag::err_constexpr_local_var_non_literal_type, @@ -2094,8 +2094,8 @@ static bool CheckConstexprDeclStmt(Sema &SemaRef, const FunctionDecl *Dcl, SemaRef.Diag( VD->getLocation(), SemaRef.getLangOpts().CPlusPlus20 - ? diag::warn_cxx17_compat_constexpr_local_var_no_init - : diag::ext_constexpr_local_var_no_init) + ? diag::compat_cxx20_constexpr_local_var_no_init + : diag::compat_pre_cxx20_constexpr_local_var_no_init) << isa(Dcl); } else if (!SemaRef.getLangOpts().CPlusPlus20) { return false; @@ -2106,9 +2106,9 @@ static bool CheckConstexprDeclStmt(Sema &SemaRef, const FunctionDecl *Dcl, if (Kind == Sema::CheckConstexprKind::Diagnose) { SemaRef.Diag(VD->getLocation(), SemaRef.getLangOpts().CPlusPlus14 - ? diag::warn_cxx11_compat_constexpr_local_var - : diag::ext_constexpr_local_var) - << isa(Dcl); + ? diag::compat_cxx14_constexpr_local_var + : diag::compat_pre_cxx14_constexpr_local_var) + << isa(Dcl); } else if (!SemaRef.getLangOpts().CPlusPlus14) { return false; } @@ -2179,8 +2179,8 @@ static bool CheckConstexprCtorInitializer(Sema &SemaRef, if (!Diagnosed) { SemaRef.Diag(Dcl->getLocation(), SemaRef.getLangOpts().CPlusPlus20 - ? diag::warn_cxx17_compat_constexpr_ctor_missing_init - : diag::ext_constexpr_ctor_missing_init); + ? diag::compat_cxx20_constexpr_ctor_missing_init + : diag::compat_pre_cxx20_constexpr_ctor_missing_init); Diagnosed = true; } SemaRef.Diag(Field->getLocation(), @@ -2392,9 +2392,9 @@ static bool CheckConstexprFunctionBody(Sema &SemaRef, const FunctionDecl *Dcl, case Sema::CheckConstexprKind::Diagnose: SemaRef.Diag(Body->getBeginLoc(), - !SemaRef.getLangOpts().CPlusPlus20 - ? diag::ext_constexpr_function_try_block_cxx20 - : diag::warn_cxx17_compat_constexpr_function_try_block) + SemaRef.getLangOpts().CPlusPlus20 + ? diag::compat_cxx20_constexpr_function_try_block + : diag::compat_pre_cxx20_constexpr_function_try_block) << isa(Dcl); break; } @@ -2423,21 +2423,21 @@ static bool CheckConstexprFunctionBody(Sema &SemaRef, const FunctionDecl *Dcl, } else if (Cxx2bLoc.isValid()) { SemaRef.Diag(Cxx2bLoc, SemaRef.getLangOpts().CPlusPlus23 - ? diag::warn_cxx20_compat_constexpr_body_invalid_stmt - : diag::ext_constexpr_body_invalid_stmt_cxx23) + ? diag::compat_cxx23_constexpr_body_invalid_stmt + : diag::compat_pre_cxx23_constexpr_body_invalid_stmt) << isa(Dcl); } else if (Cxx2aLoc.isValid()) { SemaRef.Diag(Cxx2aLoc, - SemaRef.getLangOpts().CPlusPlus20 - ? diag::warn_cxx17_compat_constexpr_body_invalid_stmt - : diag::ext_constexpr_body_invalid_stmt_cxx20) - << isa(Dcl); + SemaRef.getLangOpts().CPlusPlus20 + ? diag::compat_cxx20_constexpr_body_invalid_stmt + : diag::compat_pre_cxx20_constexpr_body_invalid_stmt) + << isa(Dcl); } else if (Cxx1yLoc.isValid()) { SemaRef.Diag(Cxx1yLoc, - SemaRef.getLangOpts().CPlusPlus14 - ? diag::warn_cxx11_compat_constexpr_body_invalid_stmt - : diag::ext_constexpr_body_invalid_stmt) - << isa(Dcl); + SemaRef.getLangOpts().CPlusPlus14 + ? diag::compat_cxx14_constexpr_body_invalid_stmt + : diag::compat_pre_cxx14_constexpr_body_invalid_stmt) + << isa(Dcl); } if (const CXXConstructorDecl *Constructor @@ -2456,8 +2456,8 @@ static bool CheckConstexprFunctionBody(Sema &SemaRef, const FunctionDecl *Dcl, SemaRef.Diag( Dcl->getLocation(), SemaRef.getLangOpts().CPlusPlus20 - ? diag::warn_cxx17_compat_constexpr_union_ctor_no_init - : diag::ext_constexpr_union_ctor_no_init); + ? diag::compat_cxx20_constexpr_union_ctor_no_init + : diag::compat_pre_cxx20_constexpr_union_ctor_no_init); } else if (!SemaRef.getLangOpts().CPlusPlus20) { return false; } @@ -2523,8 +2523,8 @@ static bool CheckConstexprFunctionBody(Sema &SemaRef, const FunctionDecl *Dcl, SemaRef.Diag( ReturnStmts.back(), SemaRef.getLangOpts().CPlusPlus14 - ? diag::warn_cxx11_compat_constexpr_body_multiple_return - : diag::ext_constexpr_body_multiple_return); + ? diag::compat_cxx14_constexpr_body_multiple_return + : diag::compat_pre_cxx14_constexpr_body_multiple_return); for (unsigned I = 0; I < ReturnStmts.size() - 1; ++I) SemaRef.Diag(ReturnStmts[I], diag::note_constexpr_body_previous_return); @@ -17825,8 +17825,8 @@ Decl *Sema::ActOnFriendTypeDecl(Scope *S, const DeclSpec &DS, InsertionText); } else { Diag(FriendLoc, getLangOpts().CPlusPlus11 - ? diag::warn_cxx98_compat_nonclass_type_friend - : diag::ext_nonclass_type_friend) + ? diag::compat_cxx11_nonclass_type_friend + : diag::compat_pre_cxx11_nonclass_type_friend) << T << DS.getSourceRange(); } } diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 42f0acb62ee5..7d4f95943479 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -6484,8 +6484,8 @@ ExprResult Sema::ActOnCallExpr(Scope *Scope, Expr *Fn, SourceLocation LParenLoc, ULE && ULE->hasExplicitTemplateArgs() && ULE->decls_begin() == ULE->decls_end()) { Diag(Fn->getExprLoc(), getLangOpts().CPlusPlus20 - ? diag::warn_cxx17_compat_adl_only_template_id - : diag::ext_adl_only_template_id) + ? diag::compat_cxx20_adl_only_template_id + : diag::compat_pre_cxx20_adl_only_template_id) << ULE->getName(); } diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index c3c993d51b79..97da433b8ddb 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -2235,10 +2235,11 @@ static bool DiagnoseDefaultTemplateArgument(Sema &S, // template-argument, that declaration shall be a definition and shall be // the only declaration of the function template in the translation unit. // (C++98/03 doesn't have this wording; see DR226). - S.Diag(ParamLoc, S.getLangOpts().CPlusPlus11 ? - diag::warn_cxx98_compat_template_parameter_default_in_function_template - : diag::ext_template_parameter_default_in_function_template) - << DefArgRange; + S.Diag(ParamLoc, + S.getLangOpts().CPlusPlus11 + ? diag::compat_cxx11_templ_default_in_function_templ + : diag::compat_pre_cxx11_templ_default_in_function_templ) + << DefArgRange; return false; case Sema::TPC_ClassTemplateMember: @@ -6428,8 +6429,8 @@ static bool CheckTemplateArgumentAddressOfObjectOrFunction( if (!Invalid && !ExtraParens) { S.Diag(Arg->getBeginLoc(), S.getLangOpts().CPlusPlus11 - ? diag::warn_cxx98_compat_template_arg_extra_parens - : diag::ext_template_arg_extra_parens) + ? diag::compat_cxx11_template_arg_extra_parens + : diag::compat_pre_cxx11_template_arg_extra_parens) << Arg->getSourceRange(); ExtraParens = true; } @@ -6651,8 +6652,8 @@ CheckTemplateArgumentPointerToMember(Sema &S, NonTypeTemplateParmDecl *Param, if (!Invalid && !ExtraParens) { S.Diag(Arg->getBeginLoc(), S.getLangOpts().CPlusPlus11 - ? diag::warn_cxx98_compat_template_arg_extra_parens - : diag::ext_template_arg_extra_parens) + ? diag::compat_cxx11_template_arg_extra_parens + : diag::compat_pre_cxx11_template_arg_extra_parens) << Arg->getSourceRange(); ExtraParens = true; } @@ -10634,11 +10635,10 @@ TypeResult Sema::ActOnTypenameType(Scope *S, SourceLocation TypenameLoc, return true; if (TypenameLoc.isValid() && S && !S->getTemplateParamParent()) - Diag(TypenameLoc, - getLangOpts().CPlusPlus11 ? - diag::warn_cxx98_compat_typename_outside_of_template : - diag::ext_typename_outside_of_template) - << FixItHint::CreateRemoval(TypenameLoc); + Diag(TypenameLoc, getLangOpts().CPlusPlus11 + ? diag::compat_cxx11_typename_outside_of_template + : diag::compat_pre_cxx11_typename_outside_of_template) + << FixItHint::CreateRemoval(TypenameLoc); NestedNameSpecifierLoc QualifierLoc = SS.getWithLocInContext(Context); TypeSourceInfo *TSI = nullptr; @@ -10662,11 +10662,10 @@ Sema::ActOnTypenameType(Scope *S, SourceLocation TypenameLoc, ASTTemplateArgsPtr TemplateArgsIn, SourceLocation RAngleLoc) { if (TypenameLoc.isValid() && S && !S->getTemplateParamParent()) - Diag(TypenameLoc, - getLangOpts().CPlusPlus11 ? - diag::warn_cxx98_compat_typename_outside_of_template : - diag::ext_typename_outside_of_template) - << FixItHint::CreateRemoval(TypenameLoc); + Diag(TypenameLoc, getLangOpts().CPlusPlus11 + ? diag::compat_cxx11_typename_outside_of_template + : diag::compat_pre_cxx11_typename_outside_of_template) + << FixItHint::CreateRemoval(TypenameLoc); // Strangely, non-type results are not ignored by this lookup, so the // program is ill-formed if it finds an injected-class-name. diff --git a/clang/test/AST/ByteCode/if.cpp b/clang/test/AST/ByteCode/if.cpp index 909e08a22a28..ad87b64fec46 100644 --- a/clang/test/AST/ByteCode/if.cpp +++ b/clang/test/AST/ByteCode/if.cpp @@ -54,7 +54,7 @@ namespace InitDecl { constexpr char g(char const (&x)[2]) { return 'x'; if (auto [a, b] = x) // both-error {{an array type is not allowed here}} \ - // both-warning {{structured binding declaration in a condition is a C++2c extenstion}} + // both-warning {{structured binding declaration in a condition is a C++2c extension}} ; } static_assert(g("x") == 'x'); diff --git a/clang/test/CXX/drs/cwg13xx.cpp b/clang/test/CXX/drs/cwg13xx.cpp index 9c72fefb5b65..2501a1084612 100644 --- a/clang/test/CXX/drs/cwg13xx.cpp +++ b/clang/test/CXX/drs/cwg13xx.cpp @@ -81,14 +81,14 @@ namespace cwg1310 { // cwg1310: 5 W::W::X w1bx; typename W::W w2a; // expected-error@-1 {{ISO C++ specifies that qualified reference to 'W' is a constructor name rather than a type in this context, despite preceding 'typename' keyword}} - // cxx98-error@-2 {{'typename' occurs outside of a template}} + // cxx98-error@-2 {{'typename' outside of a template is a C++11 extension}} typename W::W::X w2ax; - // cxx98-error@-1 {{'typename' occurs outside of a template}} + // cxx98-error@-1 {{'typename' outside of a template is a C++11 extension}} typename W::W w2b; // expected-error@-1 {{ISO C++ specifies that qualified reference to 'W' is a constructor name rather than a template name in this context, despite preceding 'typename' keyword}} - // cxx98-error@-2 {{'typename' occurs outside of a template}} + // cxx98-error@-2 {{'typename' outside of a template is a C++11 extension}} typename W::W::X w2bx; - // cxx98-error@-1 {{'typename' occurs outside of a template}} + // cxx98-error@-1 {{'typename' outside of a template is a C++11 extension}} W::template W w3; // expected-error@-1 {{ISO C++ specifies that qualified reference to 'W' is a constructor name rather than a template name in this context, despite preceding 'template' keyword}} // cxx98-error@-2 {{'template' keyword outside of a template}} @@ -97,10 +97,10 @@ namespace cwg1310 { // cwg1310: 5 typename W::template W w4; // expected-error@-1 {{ISO C++ specifies that qualified reference to 'W' is a constructor name rather than a template name in this context, despite preceding 'template' keyword}} // cxx98-error@-2 {{'template' keyword outside of a template}} - // cxx98-error@-3 {{'typename' occurs outside of a template}} + // cxx98-error@-3 {{'typename' outside of a template is a C++11 extension}} typename W::template W::X w4x; // cxx98-error@-1 {{'template' keyword outside of a template}} - // cxx98-error@-2 {{'typename' occurs outside of a template}} + // cxx98-error@-2 {{'typename' outside of a template is a C++11 extension}} TT::W> tt1; // expected-error@-1 {{qualified reference to 'W' is a constructor name rather than a type in this context}} diff --git a/clang/test/CXX/drs/cwg1xx.cpp b/clang/test/CXX/drs/cwg1xx.cpp index 4a5394be146b..6b9ad31bffbc 100644 --- a/clang/test/CXX/drs/cwg1xx.cpp +++ b/clang/test/CXX/drs/cwg1xx.cpp @@ -1295,7 +1295,7 @@ namespace cwg183 { // cwg183: sup 382 }; template<> struct A { typename B::X x; - // cxx98-error@-1 {{'typename' occurs outside of a template}} + // cxx98-error@-1 {{'typename' outside of a template is a C++11 extension}} }; } // namespace cwg183 diff --git a/clang/test/CXX/drs/cwg3xx.cpp b/clang/test/CXX/drs/cwg3xx.cpp index 164cc26ae585..8b035cf6f237 100644 --- a/clang/test/CXX/drs/cwg3xx.cpp +++ b/clang/test/CXX/drs/cwg3xx.cpp @@ -1333,9 +1333,9 @@ namespace cwg382 { // cwg382: 2.7 c++11 // FIXME: Should we allow this in C++98 mode? struct A { typedef int T; }; typename A::T t; - // cxx98-error@-1 {{'typename' occurs outside of a template}} + // cxx98-error@-1 {{'typename' outside of a template is a C++11 extension}} typename cwg382::A a; - // cxx98-error@-1 {{'typename' occurs outside of a template}} + // cxx98-error@-1 {{'typename' outside of a template is a C++11 extension}} typename A b; // expected-error@-1 {{expected a qualified name after 'typename'}} } // namespace cwg382 diff --git a/clang/test/CXX/temp/temp.arg/temp.arg.nontype/p5.cpp b/clang/test/CXX/temp/temp.arg/temp.arg.nontype/p5.cpp index 034ad49d0715..15b7a40654cd 100644 --- a/clang/test/CXX/temp/temp.arg/temp.arg.nontype/p5.cpp +++ b/clang/test/CXX/temp/temp.arg/temp.arg.nontype/p5.cpp @@ -64,7 +64,7 @@ namespace pointer_to_object_parameters { A2<&an_X> *a13_2; A2<(&an_X)> *a13_3; #if __cplusplus < 201103L - // expected-warning@-2 {{address non-type template argument cannot be surrounded by parentheses}} + // expected-warning@-2 {{parentheses around address non-type template argument are a C++11 extension}} #endif // PR6244 diff --git a/clang/test/Misc/warning-flags.c b/clang/test/Misc/warning-flags.c index 46b4e5a064c3..a978835a4101 100644 --- a/clang/test/Misc/warning-flags.c +++ b/clang/test/Misc/warning-flags.c @@ -18,13 +18,12 @@ This test serves two purposes: The list of warnings below should NEVER grow. It should gradually shrink to 0. -CHECK: Warnings without flags (59): +CHECK: Warnings without flags (58): 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_typecheck_cond_incompatible_operands CHECK-NEXT: ext_typecheck_ordered_comparison_of_pointer_integer CHECK-NEXT: ext_using_undefined_std diff --git a/clang/test/Parser/cxx1z-decomposition.cpp b/clang/test/Parser/cxx1z-decomposition.cpp index a6ca642269ee..3e2526979be8 100644 --- a/clang/test/Parser/cxx1z-decomposition.cpp +++ b/clang/test/Parser/cxx1z-decomposition.cpp @@ -37,12 +37,12 @@ namespace OtherDecl { void g() { // A condition is allowed as a Clang extension. // See commentary in test/Parser/decomposed-condition.cpp - for (; auto [a, b, c] = S(); ) {} // pre2c-warning {{structured binding declaration in a condition is a C++2c extenstion}} expected-error {{value of type 'S' is not contextually convertible to 'bool'}} - if (auto [a, b, c] = S()) {} // pre2c-warning {{structured binding declaration in a condition is a C++2c extenstion}} expected-error {{value of type 'S' is not contextually convertible to 'bool'}} - if (int n; auto [a, b, c] = S()) {} // pre2c-warning {{structured binding declaration in a condition is a C++2c extenstion}} expected-error {{value of type 'S' is not contextually convertible to 'bool'}} - switch (auto [a, b, c] = S()) {} // pre2c-warning {{structured binding declaration in a condition is a C++2c extenstion}} expected-error {{statement requires expression of integer type ('S' invalid)}} - switch (int n; auto [a, b, c] = S()) {} // pre2c-warning {{structured binding declaration in a condition is a C++2c extenstion}} expected-error {{statement requires expression of integer type ('S' invalid)}} - while (auto [a, b, c] = S()) {} // pre2c-warning {{structured binding declaration in a condition is a C++2c extenstion}} expected-error {{value of type 'S' is not contextually convertible to 'bool'}} + for (; auto [a, b, c] = S(); ) {} // pre2c-warning {{structured binding declaration in a condition is a C++2c extension}} expected-error {{value of type 'S' is not contextually convertible to 'bool'}} + if (auto [a, b, c] = S()) {} // pre2c-warning {{structured binding declaration in a condition is a C++2c extension}} expected-error {{value of type 'S' is not contextually convertible to 'bool'}} + if (int n; auto [a, b, c] = S()) {} // pre2c-warning {{structured binding declaration in a condition is a C++2c extension}} expected-error {{value of type 'S' is not contextually convertible to 'bool'}} + switch (auto [a, b, c] = S()) {} // pre2c-warning {{structured binding declaration in a condition is a C++2c extension}} expected-error {{statement requires expression of integer type ('S' invalid)}} + switch (int n; auto [a, b, c] = S()) {} // pre2c-warning {{structured binding declaration in a condition is a C++2c extension}} expected-error {{statement requires expression of integer type ('S' invalid)}} + while (auto [a, b, c] = S()) {} // pre2c-warning {{structured binding declaration in a condition is a C++2c extension}} expected-error {{value of type 'S' is not contextually convertible to 'bool'}} // An exception-declaration is not a simple-declaration. try {} diff --git a/clang/test/Parser/decomposed-condition.cpp b/clang/test/Parser/decomposed-condition.cpp index 37a24f8f9509..15a9da7d3200 100644 --- a/clang/test/Parser/decomposed-condition.cpp +++ b/clang/test/Parser/decomposed-condition.cpp @@ -33,33 +33,33 @@ Na g(); namespace CondInIf { int h() { - if (auto [ok, d] = f()) // expected-warning {{structured binding declaration in a condition is a C++2c extenstion}} + if (auto [ok, d] = f()) // expected-warning {{structured binding declaration in a condition is a C++2c extension}} ; - if (auto [ok, d] = g()) // expected-warning {{structured binding declaration in a condition is a C++2c extenstion}} expected-error {{value of type 'Na' is not contextually convertible to 'bool'}} + if (auto [ok, d] = g()) // expected-warning {{structured binding declaration in a condition is a C++2c extension}} expected-error {{value of type 'Na' is not contextually convertible to 'bool'}} ; - if (auto [value] = Get()) // expected-warning {{structured binding declaration in a condition is a C++2c extenstion}} + if (auto [value] = Get()) // expected-warning {{structured binding declaration in a condition is a C++2c extension}} return value; } } // namespace CondInIf namespace CondInWhile { int h() { - while (auto [ok, d] = f()) // expected-warning {{structured binding declaration in a condition is a C++2c extenstion}} + while (auto [ok, d] = f()) // expected-warning {{structured binding declaration in a condition is a C++2c extension}} ; - while (auto [ok, d] = g()) // expected-warning {{structured binding declaration in a condition is a C++2c extenstion}} expected-error {{value of type 'Na' is not contextually convertible to 'bool'}} + while (auto [ok, d] = g()) // expected-warning {{structured binding declaration in a condition is a C++2c extension}} expected-error {{value of type 'Na' is not contextually convertible to 'bool'}} ; - while (auto [value] = Get()) // expected-warning{{structured binding declaration in a condition is a C++2c extenstion}} + while (auto [value] = Get()) // expected-warning{{structured binding declaration in a condition is a C++2c extension}} return value; } } // namespace CondInWhile namespace CondInFor { int h() { - for (; auto [ok, d] = f();) // expected-warning {{structured binding declaration in a condition is a C++2c extenstion}} + for (; auto [ok, d] = f();) // expected-warning {{structured binding declaration in a condition is a C++2c extension}} ; - for (; auto [ok, d] = g();) // expected-warning {{structured binding declaration in a condition is a C++2c extenstion}} expected-error {{value of type 'Na' is not contextually convertible to 'bool'}} + for (; auto [ok, d] = g();) // expected-warning {{structured binding declaration in a condition is a C++2c extension}} expected-error {{value of type 'Na' is not contextually convertible to 'bool'}} ; - for (; auto [value] = Get();) // expected-warning {{structured binding declaration in a condition is a C++2c extenstion}} + for (; auto [value] = Get();) // expected-warning {{structured binding declaration in a condition is a C++2c extension}} return value; } } // namespace CondInFor @@ -74,11 +74,11 @@ struct IntegerLike { namespace CondInSwitch { int h(IntegerLike x) { - switch (auto [ok, d] = x) // expected-warning {{structured binding declaration in a condition is a C++2c extenstion}} + switch (auto [ok, d] = x) // expected-warning {{structured binding declaration in a condition is a C++2c extension}} ; - switch (auto [ok, d] = g()) // expected-warning {{structured binding declaration in a condition is a C++2c extenstion}} expected-error {{statement requires expression of integer type ('Na' invalid)}} + switch (auto [ok, d] = g()) // expected-warning {{structured binding declaration in a condition is a C++2c extension}} expected-error {{statement requires expression of integer type ('Na' invalid)}} ; - switch (auto [value] = Get()) {// expected-warning {{structured binding declaration in a condition is a C++2c extenstion}} + switch (auto [value] = Get()) {// expected-warning {{structured binding declaration in a condition is a C++2c extension}} // expected-warning@-1{{switch condition has boolean value}} case 1: return value; diff --git a/clang/test/SemaCXX/cxx98-compat.cpp b/clang/test/SemaCXX/cxx98-compat.cpp index d31d95a9995f..43ba208d375c 100644 --- a/clang/test/SemaCXX/cxx98-compat.cpp +++ b/clang/test/SemaCXX/cxx98-compat.cpp @@ -189,8 +189,8 @@ int UnnamedTemplateArg = TemplateFn(obj_of_unnamed_type); // expected-warning {{ namespace RedundantParensInAddressTemplateParam { int n; template struct S {}; - S<(&n)> s; // expected-warning {{redundant parentheses surrounding address non-type template argument are incompatible with C++98}} - S<(((&n)))> t; // expected-warning {{redundant parentheses surrounding address non-type template argument are incompatible with C++98}} + S<(&n)> s; // expected-warning {{parentheses around address non-type template argument are incompatible with C++98}} + S<(((&n)))> t; // expected-warning {{parentheses around address non-type template argument are incompatible with C++98}} } #endif @@ -202,7 +202,7 @@ template<> struct TemplateSpecOutOfScopeNs::S {}; struct Typename { template struct Inner {}; }; -typename ::Typename TypenameOutsideTemplate(); // expected-warning {{use of 'typename' outside of a template is incompatible with C++98}} +typename ::Typename TypenameOutsideTemplate(); // expected-warning {{'typename' outside of a template is incompatible with C++98}} Typename::template Inner TemplateOutsideTemplate(); // expected-warning {{use of 'template' keyword outside of a template is incompatible with C++98}} struct TrivialButNonPOD { diff --git a/clang/test/SemaObjCXX/message.mm b/clang/test/SemaObjCXX/message.mm index ec82d63ea908..5c37135f1a59 100644 --- a/clang/test/SemaObjCXX/message.mm +++ b/clang/test/SemaObjCXX/message.mm @@ -67,7 +67,7 @@ struct identity { if (true) return [typename identity::type method]; #if __cplusplus <= 199711L - // expected-warning@-2 {{'typename' occurs outside of a template}} + // expected-warning@-2 {{'typename' outside of a template is a C++11 extension}} #endif return [::I3 method]; @@ -77,12 +77,12 @@ struct identity { int* ip2 = {[::I3 method]}; int* ip3 = {[typename identity::type method]}; #if __cplusplus <= 199711L - // expected-warning@-2 {{'typename' occurs outside of a template}} + // expected-warning@-2 {{'typename' outside of a template is a C++11 extension}} #endif int* ip4 = {[typename identity::type().get() method]}; #if __cplusplus <= 199711L - // expected-warning@-2 {{'typename' occurs outside of a template}} + // expected-warning@-2 {{'typename' outside of a template is a C++11 extension}} #endif int array[5] = {[3] = 2}; // expected-warning {{C99 extension}} return [super method]; diff --git a/clang/test/SemaTemplate/temp_arg_nontype.cpp b/clang/test/SemaTemplate/temp_arg_nontype.cpp index 2a1c059df002..e989e45efb68 100644 --- a/clang/test/SemaTemplate/temp_arg_nontype.cpp +++ b/clang/test/SemaTemplate/temp_arg_nontype.cpp @@ -90,7 +90,7 @@ template struct A7c; A7<&Z::int_member> *a18_1; A7c<&Z::int_member> *a18_2; A7<&Z::float_member> *a18_3; // expected-error{{non-type template argument of type 'float Z::*' cannot be converted to a value of type 'int Z::*'}} -A7c<(&Z::int_member)> *a18_4; // expected-warning{{address non-type template argument cannot be surrounded by parentheses}} +A7c<(&Z::int_member)> *a18_4; // expected-warning{{parentheses around address non-type template argument are a C++11 extension}} A7c<&Z::union_member> *a18_5; template struct Overflow; // expected-note{{template parameter is declared here}} diff --git a/clang/test/SemaTemplate/typename-specifier-4.cpp b/clang/test/SemaTemplate/typename-specifier-4.cpp index 7aa2b8da5108..4853e610e2ba 100644 --- a/clang/test/SemaTemplate/typename-specifier-4.cpp +++ b/clang/test/SemaTemplate/typename-specifier-4.cpp @@ -32,7 +32,7 @@ int a1[is_same< typename make_pair::template apply, #if __cplusplus <= 199711L // C++03 and earlier modes // expected-warning@-2 {{'template' keyword outside of a template}} - // expected-warning@-3 {{'typename' occurs outside of a template}} + // expected-warning@-3 {{'typename' outside of a template is a C++11 extension}} #endif make_pair::apply >::value? 1 : -1]; diff --git a/clang/test/SemaTemplate/typename-specifier.cpp b/clang/test/SemaTemplate/typename-specifier.cpp index 99326f6a400a..01acc34f3bb3 100644 --- a/clang/test/SemaTemplate/typename-specifier.cpp +++ b/clang/test/SemaTemplate/typename-specifier.cpp @@ -22,35 +22,35 @@ int i; typename N::A::type *ip1 = &i; #if __cplusplus <= 199711L // C++03 or earlier modes -// expected-warning@-2 {{'typename' occurs outside of a template}} +// expected-warning@-2 {{'typename' outside of a template is a C++11 extension}} #endif typename N::B::type *ip2 = &i; // expected-error{{no type named 'type' in 'N::B'}} #if __cplusplus <= 199711L -// expected-warning@-2 {{'typename' occurs outside of a template}} +// expected-warning@-2 {{'typename' outside of a template is a C++11 extension}} #endif typename N::C::type *ip3 = &i; // expected-error{{typename specifier refers to non-type member 'type'}} #if __cplusplus <= 199711L -// expected-warning@-2 {{'typename' occurs outside of a template}} +// expected-warning@-2 {{'typename' outside of a template is a C++11 extension}} #endif void test(double d) { typename N::A::type f(typename N::A::type(a)); // expected-warning{{disambiguated as a function declaration}} // expected-note@-1 {{add a pair of parentheses}} #if __cplusplus <= 199711L - // expected-warning@-3 2{{'typename' occurs outside of a template}} + // expected-warning@-3 2{{'typename' outside of a template is a C++11 extension}} #endif int five = f(5); using namespace N; for (typename A::type i = 0; i < 10; ++i) #if __cplusplus <= 199711L -// expected-warning@-2 {{'typename' occurs outside of a template}} +// expected-warning@-2 {{'typename' outside of a template is a C++11 extension}} #endif five += 1; const typename N::A::type f2(d); #if __cplusplus <= 199711L -// expected-warning@-2 {{'typename' occurs outside of a template}} +// expected-warning@-2 {{'typename' outside of a template is a C++11 extension}} #endif }