From: Nico Weber Date: Tue, 28 Jul 2015 02:37:37 +0000 (+0000) Subject: Split -Wmicrosoft into many specific warnings. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cadcba37e290428e07dd7eccc99b6b6a05c95b81;p=clang Split -Wmicrosoft into many specific warnings. Also move "pragma comment" warning from -Wmicrosoft to -Wignored-pragmas. -Wmicrosoft currently covers many different areas, some more useful than others. Split it into many targeted flags, so that projects can choose to enable only a subset of these warnings. This is also useful for incrementally fixing and turning on these warnings. -Wno-microsoft still disables all these warnings, and -Wmicrosoft still enables them all. After this change, it's possible to pass `-Wno-microsoft -Wmicrosoft-unqualified-friend` to only enable -Wmicrosoft-unqualified-friend, and `-Wmicrosoft -Wno-microsoft-unqualified-friend` to enable all other Microsoft warnings. I put all the template-related warnings behind -Wmicrosoft-template; if that turns out to be too coarse we can make that finer later on. (In practice, I haven't seen the template-related warnings fire frequently.) Reviewed at http://reviews.llvm.org/D11504 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@243371 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/DiagnosticGroups.td b/include/clang/Basic/DiagnosticGroups.td index 4ecd5d5e18..a751da0fbb 100644 --- a/include/clang/Basic/DiagnosticGroups.td +++ b/include/clang/Basic/DiagnosticGroups.td @@ -715,8 +715,45 @@ def GNU : DiagGroup<"gnu", [GNUAlignofExpression, GNUAnonymousStruct, // A warning group for warnings about code that clang accepts but gcc doesn't. def GccCompat : DiagGroup<"gcc-compat">; -// A warning group for warnings about Microsoft extensions. -def Microsoft : DiagGroup<"microsoft">; +// Warnings for Microsoft extensions. +def MicrosoftCharize : DiagGroup<"microsoft-charize">; +def MicrosoftCppMacro : DiagGroup<"microsoft-cpp-macro">; +def MicrosoftFixedEnum : DiagGroup<"microsoft-fixed-enum">; +def MicrosoftSealed : DiagGroup<"microsoft-sealed">; +def MicrosoftUnqualifiedFriend : DiagGroup<"microsoft-unqualified-friend">; +def MicrosoftExceptionSpec : DiagGroup<"microsoft-exception-spec">; +def MicrosoftUsingDecl : DiagGroup<"microsoft-using-decl">; +def MicrosoftMutableReference : DiagGroup<"microsoft-mutable-reference">; +def MicrosoftPureDefinition : DiagGroup<"microsoft-pure-definition">; +def MicrosoftUnionMemberReference : DiagGroup< + "microsoft-union-member-reference">; +def MicrosoftExplicitConstructorCall : DiagGroup< + "microsoft-explicit-constructor-call">; +def MicrosoftEnumValue : DiagGroup<"microsoft-enum-value">; +def MicrosoftDefaultArgRedefinition : + DiagGroup<"microsoft-default-arg-redefinition">; +def MicrosoftTemplate : DiagGroup<"microsoft-template">; +def MicrosoftRedeclareStatic : DiagGroup<"microsoft-redeclare-static">; +def MicrosoftEnumForwardReference : + DiagGroup<"microsoft-enum-forward-reference">; +def MicrosoftGoto : DiagGroup<"microsoft-goto">; +def MicrosoftFlexibleArray : DiagGroup<"microsoft-flexible-array">; +def MicrosoftExtraQualification : DiagGroup<"microsoft-extra-qualification">; +def MicrosoftCast : DiagGroup<"microsoft-cast">; +def MicrosoftConstInit : DiagGroup<"microsoft-const-init">; +def MicrosoftVoidPseudoDtor : DiagGroup<"microsoft-void-pseudo-dtor">; +def MicrosoftAnonTag : DiagGroup<"microsoft-anon-tag">; + +// Warnings group for warnings about Microsoft extensions. +def Microsoft : DiagGroup<"microsoft", + [MicrosoftCharize, MicrosoftCppMacro, MicrosoftFixedEnum, MicrosoftSealed, + MicrosoftUnqualifiedFriend, MicrosoftExceptionSpec, MicrosoftUsingDecl, + MicrosoftMutableReference, MicrosoftPureDefinition, + MicrosoftUnionMemberReference, MicrosoftExplicitConstructorCall, + MicrosoftEnumValue, MicrosoftDefaultArgRedefinition, MicrosoftTemplate, + MicrosoftRedeclareStatic, MicrosoftEnumForwardReference, MicrosoftGoto, + MicrosoftFlexibleArray, MicrosoftExtraQualification, MicrosoftCast, + MicrosoftConstInit, MicrosoftVoidPseudoDtor, MicrosoftAnonTag]>; def ObjCNonUnifiedException : DiagGroup<"objc-nonunified-exceptions">; diff --git a/include/clang/Basic/DiagnosticLexKinds.td b/include/clang/Basic/DiagnosticLexKinds.td index 5dd4ae0ac7..6e7a50d7c0 100644 --- a/include/clang/Basic/DiagnosticLexKinds.td +++ b/include/clang/Basic/DiagnosticLexKinds.td @@ -57,8 +57,9 @@ def warn_cxx98_compat_no_newline_eof : Warning< def ext_dollar_in_identifier : Extension<"'$' in identifier">, InGroup>; -def ext_charize_microsoft : Extension<"charizing operator #@ is a Microsoft extension">, - InGroup; +def ext_charize_microsoft : Extension< + "charizing operator #@ is a Microsoft extension">, + InGroup; def ext_token_used : Extension<"extension used">, InGroup>; @@ -510,7 +511,7 @@ def ext_pp_bad_paste_ms : ExtWarn< def err_pp_operator_used_as_macro_name : Error< "C++ operator %0 (aka %1) used as a macro name">; def ext_pp_operator_used_as_macro_name : Extension< - "C++ operator %0 (aka %1) used as a macro name">, InGroup; + err_pp_operator_used_as_macro_name.Text>, InGroup; def err_pp_illegal_floating_literal : Error< "floating point literal in preprocessor expression">; def err_pp_line_requires_integer : Error< diff --git a/include/clang/Basic/DiagnosticParseKinds.td b/include/clang/Basic/DiagnosticParseKinds.td index 1364b982ec..a85b5ac070 100644 --- a/include/clang/Basic/DiagnosticParseKinds.td +++ b/include/clang/Basic/DiagnosticParseKinds.td @@ -101,7 +101,7 @@ def ext_cxx11_enum_fixed_underlying_type : Extension< InGroup; def ext_c_enum_fixed_underlying_type : Extension< "enumeration types with a fixed underlying type are a Microsoft extension">, - InGroup; + InGroup; def warn_cxx98_compat_enum_fixed_underlying_type : Warning< "enumeration types with a fixed underlying type are incompatible with C++98">, InGroup, DefaultIgnore; @@ -508,7 +508,7 @@ def note_missing_end_of_definition_before : Note< "still within definition of %q0 here">; def ext_ellipsis_exception_spec : Extension< "exception specification of '...' is a Microsoft extension">, - InGroup; + InGroup; def err_dynamic_and_noexcept_specification : Error< "cannot have both throw() and noexcept() clause on the same function">; def err_except_spec_unparsed : Error< @@ -780,7 +780,7 @@ def err_override_control_interface : Error< "'%0' keyword not permitted with interface types">; def ext_ms_sealed_keyword : ExtWarn< "'sealed' keyword is a Microsoft extension">, - InGroup; + InGroup; def err_access_specifier_interface : Error< "interface types cannot specify '%select{private|protected}0' access">; @@ -941,7 +941,7 @@ def err_pragma_comment_malformed : Error< def err_pragma_comment_unknown_kind : Error<"unknown kind of pragma comment">; // PS4 recognizes only #pragma comment(lib) def warn_pragma_comment_ignored : Warning<"'#pragma comment %0' ignored">, - InGroup; + InGroup; // - #pragma detect_mismatch def err_pragma_detect_mismatch_malformed : Error< "pragma detect_mismatch is malformed; it requires two comma-separated " diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index f118600e8d..5847c0fd8b 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -1058,7 +1058,7 @@ def warn_template_qualified_friend_ignored : Warning< def ext_friend_tag_redecl_outside_namespace : ExtWarn< "unqualified friend declaration referring to type outside of the nearest " "enclosing namespace is a Microsoft extension; add a nested name specifier">, - InGroup; + InGroup; def err_pure_friend : Error<"friend declaration cannot have a pure-specifier">; def err_invalid_member_in_interface : Error< @@ -1138,12 +1138,12 @@ def err_rref_in_exception_spec : Error< def err_mismatched_exception_spec : Error< "exception specification in declaration does not match previous declaration">; def ext_mismatched_exception_spec : ExtWarn, - InGroup; + InGroup; def err_override_exception_spec : Error< "exception specification of overriding function is more lax than " "base version">; def ext_override_exception_spec : ExtWarn, - InGroup; + InGroup; def err_incompatible_exception_specs : Error< "target exception specification is not superset of source">; def err_deep_exception_specs_differ : Error< @@ -1163,7 +1163,7 @@ def err_access : Error< def ext_ms_using_declaration_inaccessible : ExtWarn< "using declaration referring to inaccessible member '%0' (which refers " "to accessible member '%1') is a Microsoft compatibility extension">, - AccessControl, InGroup; + AccessControl, InGroup; def err_access_ctor : Error< "calling a %select{private|protected}0 constructor of class %2">, AccessControl; @@ -1269,7 +1269,7 @@ def err_mutable_function : Error<"'mutable' cannot be applied to functions">; def err_mutable_reference : Error<"'mutable' cannot be applied to references">; def ext_mutable_reference : ExtWarn< "'mutable' on a reference type is a Microsoft extension">, - InGroup; + InGroup; def err_mutable_const : Error<"'mutable' and 'const' cannot be mixed">; def err_mutable_nonmember : Error< "'mutable' can only be applied to member variables">; @@ -1305,7 +1305,7 @@ def err_non_virtual_pure : Error< "%0 is not virtual and cannot be declared pure">; def ext_pure_function_definition : ExtWarn< "function definition with pure-specifier is a Microsoft extension">, - InGroup; + InGroup; def err_implicit_object_parameter_init : Error< "cannot initialize object parameter of type %0 with an expression " "of type %1">; @@ -1384,7 +1384,7 @@ def warn_cxx98_compat_static_data_member_in_union : Warning< InGroup, DefaultIgnore; def ext_union_member_of_reference_type : ExtWarn< "union member %0 has reference type %1, which is a Microsoft extension">, - InGroup; + InGroup; def err_union_member_of_reference_type : Error< "union member %0 has reference type %1">; def ext_anonymous_struct_union_qualified : Extension< @@ -1439,7 +1439,8 @@ def warn_no_constructor_for_refconst : Warning< def note_refconst_member_not_initialized : Note< "%select{const|reference}0 member %1 will never be initialized">; def ext_ms_explicit_constructor_call : ExtWarn< - "explicit constructor calls are a Microsoft extension">, InGroup; + "explicit constructor calls are a Microsoft extension">, + InGroup; // C++ destructors def err_destructor_not_member : Error< @@ -1770,7 +1771,7 @@ def err_enumerator_too_large : Error< "enumerator value is not representable in the underlying type %0">; def ext_enumerator_too_large : ExtWarn< "enumerator value is not representable in the underlying type %0">, - InGroup; + InGroup; def err_enumerator_wrapped : Error< "enumerator value %0 is not representable in the underlying type %1">; def err_enum_redeclare_type_mismatch : Error< @@ -2853,7 +2854,8 @@ def err_param_default_argument : Error< def err_param_default_argument_redefinition : Error< "redefinition of default argument">; def ext_param_default_argument_redefinition : ExtWarn< - "redefinition of default argument">, InGroup; + err_param_default_argument_redefinition.Text>, + InGroup; def err_param_default_argument_missing : Error< "missing default argument on parameter">; def err_param_default_argument_missing_name : Error< @@ -3345,11 +3347,12 @@ def note_template_decl_here : Note<"template is declared here">; def err_template_arg_must_be_type : Error< "template argument for template type parameter must be a type">; def err_template_arg_must_be_type_suggest : Error< - "template argument for template type parameter must be a type; did you forget 'typename'?">; + "template argument for template type parameter must be a type; " + "did you forget 'typename'?">; def ext_ms_template_type_arg_missing_typename : ExtWarn< "template argument for template type parameter must be a type; " "omitted 'typename' is a Microsoft extension">, - InGroup; + InGroup; def err_template_arg_must_be_expr : Error< "template argument for non-type template parameter must be an expression">; def err_template_arg_nontype_ambig : Error< @@ -3469,10 +3472,10 @@ def err_pointer_to_member_oper_value_classify: Error< "%select{rvalue|lvalue}1">; def ext_ms_deref_template_argument: ExtWarn< "non-type template argument containing a dereference operation is a " - "Microsoft extension">, InGroup; + "Microsoft extension">, InGroup; def ext_ms_delayed_template_argument: ExtWarn< "using the undeclared type %0 as a default template argument is a " - "Microsoft extension">, InGroup; + "Microsoft extension">, InGroup; // C++ template specialization def err_template_spec_unknown_kind : Error< @@ -3520,7 +3523,7 @@ def ext_ms_template_spec_redecl_out_of_scope: ExtWarn< "variable template partial|function template|member " "function|static data member|member class|member enumeration}0 " "specialization of %1 outside namespace enclosing %2 " - "is a Microsoft extension">, InGroup; + "is a Microsoft extension">, InGroup; def err_template_spec_redecl_global_scope : Error< "%select{class template|class template partial|variable template|" "variable template partial|function template|member " @@ -3545,7 +3548,7 @@ def err_function_specialization_in_class : Error< "cannot specialize a function %0 within class scope">; def ext_function_specialization_in_class : ExtWarn< "explicit specialization of %0 within class scope is a Microsoft extension">, - InGroup; + InGroup; def ext_explicit_specialization_storage_class : ExtWarn< "explicit specialization cannot have a storage class">; def err_explicit_specialization_inconsistent_storage_class : Error< @@ -3706,7 +3709,7 @@ def err_explicit_instantiation_duplicate : Error< "duplicate explicit instantiation of %0">; def ext_explicit_instantiation_duplicate : ExtWarn< "duplicate explicit instantiation of %0 ignored as a Microsoft extension">, - InGroup; + InGroup; def note_previous_explicit_instantiation : Note< "previous explicit instantiation is here">; def ext_explicit_instantiation_after_specialization : Extension< @@ -3791,10 +3794,11 @@ def err_invalid_var_template_spec_type : Error<"type %2 " "partial specialization|redeclaration}0 of %1 does not match" " expected type %3">; def err_mismatched_exception_spec_explicit_instantiation : Error< - "exception specification in explicit instantiation does not match instantiated one">; + "exception specification in explicit instantiation does not match " + "instantiated one">; def ext_mismatched_exception_spec_explicit_instantiation : ExtWarn< - "exception specification in explicit instantiation does not match instantiated one">, - InGroup; + err_mismatched_exception_spec_explicit_instantiation.Text>, + InGroup; // C++ typename-specifiers def err_typename_nested_not_found : Error<"no type named %0 in %1">; @@ -3912,10 +3916,10 @@ def err_undeclared_var_use : Error<"use of undeclared identifier %0">; def ext_undeclared_unqual_id_with_dependent_base : ExtWarn< "use of undeclared identifier %0; " "unqualified lookup into dependent bases of class template %1 is a Microsoft extension">, - InGroup; + InGroup; def ext_found_via_dependent_bases_lookup : ExtWarn<"use of identifier %0 " "found via unqualified lookup into dependent bases of class templates is a " - "Microsoft extension">, InGroup; + "Microsoft extension">, InGroup; def note_dependent_var_use : Note<"must qualify identifier to find this " "declaration in dependent base class">; def err_not_found_by_two_phase_lookup : Error<"call to function %0 that is neither " @@ -4072,7 +4076,8 @@ def note_extern_c_global_conflict : Note< def warn_weak_import : Warning < "an already-declared variable is made a weak_import declaration %0">; def ext_static_non_static : Extension< - "redeclaring non-static %0 as static is a Microsoft extension">, InGroup; + "redeclaring non-static %0 as static is a Microsoft extension">, + InGroup; def err_non_static_static : Error< "non-static declaration of %0 follows static declaration">; def err_extern_non_extern : Error< @@ -4130,9 +4135,11 @@ def ext_forward_ref_enum : Extension< def err_forward_ref_enum : Error< "ISO C++ forbids forward references to 'enum' types">; def ext_ms_forward_ref_enum : Extension< - "forward references to 'enum' types are a Microsoft extension">, InGroup; + "forward references to 'enum' types are a Microsoft extension">, + InGroup; def ext_forward_ref_enum_def : Extension< - "redeclaration of already-defined enum %0 is a GNU extension">, InGroup; + "redeclaration of already-defined enum %0 is a GNU extension">, + InGroup; def err_redefinition_of_enumerator : Error<"redefinition of enumerator %0">; def err_duplicate_member : Error<"duplicate member %0">; @@ -4325,7 +4332,7 @@ def err_goto_into_protected_scope : Error< "cannot jump from this goto statement to its label">; def ext_goto_into_protected_scope : ExtWarn< "jump from this goto statement to its label is a Microsoft extension">, - InGroup; + InGroup; def warn_cxx98_compat_goto_into_protected_scope : Warning< "jump from this goto statement to its label is incompatible with C++98">, InGroup, DefaultIgnore; @@ -4458,12 +4465,12 @@ def err_flexible_array_init : Error< def ext_flexible_array_empty_aggregate_ms : Extension< "flexible array member %0 in otherwise empty " "%select{struct|interface|union|class|enum}1 is a Microsoft extension">, - InGroup; + InGroup; def err_flexible_array_union : Error< "flexible array member %0 in a union is not allowed">; def ext_flexible_array_union_ms : Extension< "flexible array member %0 in a union is a Microsoft extension">, - InGroup; + InGroup; def ext_flexible_array_empty_aggregate_gnu : Extension< "flexible array member %0 in otherwise empty " "%select{struct|interface|union|class|enum}1 is a GNU extension">, @@ -4946,10 +4953,10 @@ def err_qualified_param_declarator : Error< def ext_out_of_line_declaration : ExtWarn< "out-of-line declaration of a member must be a definition">, InGroup, DefaultError; -def warn_member_extra_qualification : Warning< - "extra qualification on member %0">, InGroup; def err_member_extra_qualification : Error< "extra qualification on member %0">; +def warn_member_extra_qualification : Warning< + err_member_extra_qualification.Text>, InGroup; def warn_namespace_member_extra_qualification : Warning< "extra qualification on member %0">, InGroup>; @@ -5425,7 +5432,7 @@ def ext_cast_fn_obj : Extension< def ext_ms_cast_fn_obj : ExtWarn< "static_cast between pointer-to-function and pointer-to-object is a " "Microsoft extension">, - InGroup; + InGroup; def warn_cxx98_compat_cast_fn_obj : Warning< "cast between pointer-to-function and pointer-to-object is incompatible with C++98">, InGroup, DefaultIgnore; @@ -5535,7 +5542,7 @@ def ext_default_init_const : ExtWarn< "default initialization of an object of const type %0" "%select{| without a user-provided default constructor}1 " "is a Microsoft extension">, - InGroup; + InGroup; def err_delete_operand : Error<"cannot delete expression of type %0">; def ext_delete_void_ptr_operand : ExtWarn< "cannot delete expression with pointer-to-'void' type %0">, @@ -5753,7 +5760,7 @@ def err_pseudo_dtor_base_not_scalar : Error< "pseudo-destructor expression">; def ext_pseudo_dtor_on_void : ExtWarn< "pseudo-destructors on type void are a Microsoft extension">, - InGroup; + InGroup; def err_pseudo_dtor_type_mismatch : Error< "the type of object expression " "%diff{($) does not match the type being destroyed ($)|" @@ -6503,7 +6510,7 @@ def err_anonymous_record_with_type : Error< "types cannot be declared in an anonymous %select{struct|union}0">; def ext_anonymous_record_with_type : Extension< "types declared in an anonymous %select{struct|union}0 are a Microsoft " - "extension">, InGroup; + "extension">, InGroup; def ext_anonymous_record_with_anonymous_type : Extension< "anonymous types declared in an anonymous %select{struct|union}0 " "are an extension">, InGroup>; @@ -6518,7 +6525,7 @@ def err_anonymous_record_nonpublic_member : Error< "%select{private|protected}1 data member">; def ext_ms_anonymous_record : ExtWarn< "anonymous %select{structs|unions}0 are a Microsoft extension">, - InGroup; + InGroup; // C++ local classes def err_reference_to_local_var_in_enclosing_function : Error<