From 9af804750efecf2ab2a1c3e230f7cd41c68be81f Mon Sep 17 00:00:00 2001 From: Richard Smith <richard-llvm@metafoo.co.uk> Date: Mon, 12 Oct 2015 21:05:54 +0000 Subject: [PATCH] Add warning flags for #include_next and some nearby warnings. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@250105 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Basic/DiagnosticGroups.td | 4 +++- include/clang/Basic/DiagnosticLexKinds.td | 15 ++++++++++----- test/Misc/warning-flags.c | 8 ++------ 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/include/clang/Basic/DiagnosticGroups.td b/include/clang/Basic/DiagnosticGroups.td index bf655cc3aa5..39ed1318cd7 100644 --- a/include/clang/Basic/DiagnosticGroups.td +++ b/include/clang/Basic/DiagnosticGroups.td @@ -202,6 +202,7 @@ def InfiniteRecursion : DiagGroup<"infinite-recursion">; def GNUImaginaryConstant : DiagGroup<"gnu-imaginary-constant">; def IgnoredQualifiers : DiagGroup<"ignored-qualifiers">; def : DiagGroup<"import">; +def GNUIncludeNext : DiagGroup<"gnu-include-next">; def IncompatibleMSStruct : DiagGroup<"incompatible-ms-struct">; def IncompatiblePointerTypesDiscardsQualifiers : DiagGroup<"incompatible-pointer-types-discards-qualifiers">; @@ -708,7 +709,8 @@ def GNU : DiagGroup<"gnu", [GNUAlignofExpression, GNUAnonymousStruct, GNUEmptyInitializer, GNUEmptyStruct, VLAExtension, GNUFlexibleArrayInitializer, GNUFlexibleArrayUnionMember, GNUFoldingConstant, - GNUImaginaryConstant, GNULabelsAsValue, + GNUImaginaryConstant, GNUIncludeNext, + GNULabelsAsValue, RedeclaredClassMember, GNURedeclaredEnum, GNUStatementExpression, GNUStaticFloatInit, GNUStringLiteralOperatorTemplate, diff --git a/include/clang/Basic/DiagnosticLexKinds.td b/include/clang/Basic/DiagnosticLexKinds.td index 3384a34d61a..77090e92929 100644 --- a/include/clang/Basic/DiagnosticLexKinds.td +++ b/include/clang/Basic/DiagnosticLexKinds.td @@ -256,10 +256,13 @@ def err_pp_hash_error : Error<"%0">; } def pp_include_next_in_primary : Warning< - "#include_next in primary source file">; + "#include_next in primary source file">, + InGroup<DiagGroup<"include-next-outside-header">>; def pp_include_macros_out_of_predefines : Error< "the #__include_macros directive is only for internal use by -imacros">; -def pp_include_next_absolute_path : Warning<"#include_next with absolute path">; +def pp_include_next_absolute_path : Warning< + "#include_next with absolute path">, + InGroup<DiagGroup<"include-next-absolute-path">>; def ext_c99_whitespace_required_after_macro_name : ExtWarn< "ISO C99 requires whitespace after the macro name">, InGroup<C99>; def ext_missing_whitespace_after_macro_name : ExtWarn< @@ -267,9 +270,11 @@ def ext_missing_whitespace_after_macro_name : ExtWarn< def warn_missing_whitespace_after_macro_name : Warning< "whitespace recommended after macro name">; -def pp_pragma_once_in_main_file : Warning<"#pragma once in main file">; +def pp_pragma_once_in_main_file : Warning<"#pragma once in main file">, + InGroup<DiagGroup<"pragma-once-outside-header">>; def pp_pragma_sysheader_in_main_file : Warning< - "#pragma system_header ignored in main file">; + "#pragma system_header ignored in main file">, + InGroup<DiagGroup<"pragma-system-header-outside-header">>; def pp_poisoning_existing_macro : Warning<"poisoning existing macro">; def pp_out_of_date_dependency : Warning< "current file is older than dependency %0">; @@ -316,7 +321,7 @@ def ext_pp_include_search_ms : ExtWarn< def ext_pp_ident_directive : Extension<"#ident is a language extension">; def ext_pp_include_next_directive : Extension< - "#include_next is a language extension">; + "#include_next is a language extension">, InGroup<GNUIncludeNext>; def ext_pp_warning_directive : Extension<"#warning is a language extension">; def ext_pp_extra_tokens_at_eol : ExtWarn< diff --git a/test/Misc/warning-flags.c b/test/Misc/warning-flags.c index bd97c4ae808..5cc769faad9 100644 --- a/test/Misc/warning-flags.c +++ b/test/Misc/warning-flags.c @@ -18,7 +18,7 @@ This test serves two purposes: The list of warnings below should NEVER grow. It should gradually shrink to 0. -CHECK: Warnings without flags (89): +CHECK: Warnings without flags (85): CHECK-NEXT: ext_excess_initializers CHECK-NEXT: ext_excess_initializers_in_char_array_initializer CHECK-NEXT: ext_expected_semi_decl_list @@ -35,13 +35,9 @@ CHECK-NEXT: ext_typecheck_cond_incompatible_operands_nonstandard CHECK-NEXT: ext_typecheck_ordered_comparison_of_function_pointers CHECK-NEXT: ext_typecheck_ordered_comparison_of_pointer_integer CHECK-NEXT: ext_using_undefined_std -CHECK-NEXT: pp_include_next_absolute_path -CHECK-NEXT: pp_include_next_in_primary CHECK-NEXT: pp_invalid_string_literal CHECK-NEXT: pp_out_of_date_dependency CHECK-NEXT: pp_poisoning_existing_macro -CHECK-NEXT: pp_pragma_once_in_main_file -CHECK-NEXT: pp_pragma_sysheader_in_main_file CHECK-NEXT: w_asm_qualifier_ignored CHECK-NEXT: warn_accessor_property_type_mismatch CHECK-NEXT: warn_arcmt_nsalloc_realloc @@ -111,4 +107,4 @@ CHECK-NEXT: warn_weak_import The list of warnings in -Wpedantic should NEVER grow. -CHECK: Number in -Wpedantic (not covered by other -W flags): 28 +CHECK: Number in -Wpedantic (not covered by other -W flags): 27 -- GitLab