r201102 - Basic: Clean up malformed pragma diagnostics
David Majnemer
david.majnemer at gmail.com
Mon Feb 10 11:06:37 PST 2014
Author: majnemer
Date: Mon Feb 10 13:06:37 2014
New Revision: 201102
URL: http://llvm.org/viewvc/llvm-project?rev=201102&view=rev
Log:
Basic: Clean up malformed pragma diagnostics
Create a new diagnostic, -Wignored-pragmas and use it to handle any
case where a pragma would have a side effect but is ignored.
Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Parse/ParseOpenMP.cpp
cfe/trunk/lib/Parse/ParsePragma.cpp
cfe/trunk/test/Misc/warning-flags.c
Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=201102&r1=201101&r2=201102&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Mon Feb 10 13:06:37 2014
@@ -339,6 +339,8 @@ def UninitializedStaticSelfInit : DiagGr
def Uninitialized : DiagGroup<"uninitialized", [UninitializedSometimes,
UninitializedStaticSelfInit]>;
def UnknownPragmas : DiagGroup<"unknown-pragmas">;
+def IgnoredPragmas : DiagGroup<"ignored-pragmas">;
+def Pragmas : DiagGroup<"pragmas", [UnknownPragmas, IgnoredPragmas]>;
def UnknownWarningOption : DiagGroup<"unknown-warning-option">;
def NSobjectAttribute : DiagGroup<"NSObject-attribute">;
def UnknownAttributes : DiagGroup<"unknown-attributes">;
Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=201102&r1=201101&r2=201102&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Mon Feb 10 13:06:37 2014
@@ -437,7 +437,8 @@ def err_pragma_message_malformed : Error
def err_pragma_push_pop_macro_malformed : Error<
"pragma %0 requires a parenthesized string">;
def warn_pragma_pop_macro_no_push : Warning<
- "pragma pop_macro could not pop '%0', no matching push_macro">;
+ "pragma pop_macro could not pop '%0', no matching push_macro">,
+ InGroup<IgnoredPragmas>;
def warn_pragma_message : Warning<"%0">,
InGroup<PoundPragmaMessage>, DefaultWarnNoWerror;
def err_pragma_message : Error<"%0">;
@@ -472,7 +473,7 @@ def warn_pragma_diagnostic_unknown_warni
InGroup<UnknownPragmas>;
// - #pragma __debug
def warn_pragma_debug_unexpected_command : Warning<
- "unexpected debug command '%0'">;
+ "unexpected debug command '%0'">, InGroup<IgnoredPragmas>;
def err_defined_macro_name : Error<"'defined' cannot be used as a macro name">;
def err_paste_at_start : Error<
Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=201102&r1=201101&r2=201102&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Mon Feb 10 13:06:37 2014
@@ -763,32 +763,40 @@ def err_type_trait_arity : Error<
// Language specific pragmas
// - Generic warnings
def warn_pragma_expected_lparen : Warning<
- "missing '(' after '#pragma %0' - ignoring">;
+ "missing '(' after '#pragma %0' - ignoring">, InGroup<IgnoredPragmas>;
def warn_pragma_expected_rparen : Warning<
- "missing ')' after '#pragma %0' - ignoring">;
+ "missing ')' after '#pragma %0' - ignoring">, InGroup<IgnoredPragmas>;
def warn_pragma_expected_identifier : Warning<
- "expected identifier in '#pragma %0' - ignored">;
+ "expected identifier in '#pragma %0' - ignored">, InGroup<IgnoredPragmas>;
def warn_pragma_ms_struct : Warning<
- "incorrect use of '#pragma ms_struct on|off' - ignored">;
+ "incorrect use of '#pragma ms_struct on|off' - ignored">,
+ InGroup<IgnoredPragmas>;
def warn_pragma_extra_tokens_at_eol : Warning<
- "extra tokens at end of '#pragma %0' - ignored">;
+ "extra tokens at end of '#pragma %0' - ignored">,
+ InGroup<IgnoredPragmas>;
+def warn_pragma_expected_punc : Warning<
+ "expected ')' or ',' in '#pragma %0'">, InGroup<IgnoredPragmas>;
// - #pragma options
def warn_pragma_options_expected_align : Warning<
- "expected 'align' following '#pragma options' - ignored">;
+ "expected 'align' following '#pragma options' - ignored">,
+ InGroup<IgnoredPragmas>;
def warn_pragma_align_expected_equal : Warning<
- "expected '=' following '#pragma %select{align|options align}0' - ignored">;
+ "expected '=' following '#pragma %select{align|options align}0' - ignored">,
+ InGroup<IgnoredPragmas>;
def warn_pragma_align_invalid_option : Warning<
- "invalid alignment option in '#pragma %select{align|options align}0' - ignored">;
+ "invalid alignment option in '#pragma %select{align|options align}0' - ignored">,
+ InGroup<IgnoredPragmas>;
// - #pragma pack
def warn_pragma_pack_invalid_action : Warning<
- "unknown action for '#pragma pack' - ignored">;
+ "unknown action for '#pragma pack' - ignored">,
+ InGroup<IgnoredPragmas>;
def warn_pragma_pack_malformed : Warning<
- "expected integer or identifier in '#pragma pack' - ignored">;
+ "expected integer or identifier in '#pragma pack' - ignored">,
+ InGroup<IgnoredPragmas>;
// - #pragma unused
def warn_pragma_unused_expected_var : Warning<
- "expected '#pragma unused' argument to be a variable name">;
-def warn_pragma_unused_expected_punc : Warning<
- "expected ')' or ',' in '#pragma unused'">;
+ "expected '#pragma unused' argument to be a variable name">,
+ InGroup<IgnoredPragmas>;
// - #pragma fp_contract
def err_pragma_fp_contract_scope : Error<
"'#pragma fp_contract' can only appear at file scope or at the start of a "
@@ -808,11 +816,11 @@ def err_not_opencl_storage_class_specifi
// OpenCL EXTENSION pragma (OpenCL 1.1 [9.1])
def warn_pragma_expected_colon : Warning<
- "missing ':' after %0 - ignoring">;
+ "missing ':' after %0 - ignoring">, InGroup<IgnoredPragmas>;
def warn_pragma_expected_enable_disable : Warning<
- "expected 'enable' or 'disable' - ignoring">;
+ "expected 'enable' or 'disable' - ignoring">, InGroup<IgnoredPragmas>;
def warn_pragma_unknown_extension : Warning<
- "unknown OpenCL extension %0 - ignoring">;
+ "unknown OpenCL extension %0 - ignoring">, InGroup<IgnoredPragmas>;
def err_seh_expected_handler : Error<
"expected '__except' or '__finally' block">;
@@ -837,7 +845,7 @@ def err_omp_unknown_directive : Error <
def err_omp_unexpected_directive : Error <
"unexpected OpenMP directive '#pragma omp %0'">;
def err_omp_expected_punc : Error <
- "expected ',' or ')' in %select{'#pragma omp %1'|'%1' clause}0">;
+ "expected ',' or ')' in '%0' clause">;
def err_omp_unexpected_clause : Error <
"unexpected OpenMP clause '%0' in directive '#pragma omp %1'">;
def err_omp_more_one_clause : Error <
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=201102&r1=201101&r2=201102&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Feb 10 13:06:37 2014
@@ -469,22 +469,28 @@ def err_opencl_half_return : Error<
"declaring function return value of type %0 is not allowed; did you forget * ?">;
def warn_enum_value_overflow : Warning<"overflow in enumeration value">;
def warn_pragma_options_align_reset_failed : Warning<
- "#pragma options align=reset failed: %0">;
+ "#pragma options align=reset failed: %0">,
+ InGroup<IgnoredPragmas>;
def err_pragma_options_align_mac68k_target_unsupported : Error<
"mac68k alignment pragma is not supported on this target">;
def warn_pragma_pack_invalid_alignment : Warning<
- "expected #pragma pack parameter to be '1', '2', '4', '8', or '16'">;
+ "expected #pragma pack parameter to be '1', '2', '4', '8', or '16'">,
+ InGroup<IgnoredPragmas>;
// Follow the MSVC implementation.
def warn_pragma_pack_show : Warning<"value of #pragma pack(show) == %0">;
def warn_pragma_pack_pop_identifer_and_alignment : Warning<
"specifying both a name and alignment to 'pop' is undefined">;
-def warn_pragma_pack_pop_failed : Warning<"#pragma pack(pop, ...) failed: %0">;
-def warn_pragma_ms_struct_failed : Warning<"#pramga ms_struct can not be used with dynamic classes or structures">, InGroup<IgnoredAttributes>;
+def warn_pragma_pack_pop_failed : Warning<"#pragma pack(pop, ...) failed: %0">,
+ InGroup<IgnoredPragmas>;
+def warn_pragma_ms_struct_failed : Warning<"#pramga ms_struct can not be used with dynamic classes or structures">,
+ InGroup<IgnoredPragmas>;
def warn_pragma_unused_undeclared_var : Warning<
- "undeclared variable %0 used as an argument for '#pragma unused'">;
+ "undeclared variable %0 used as an argument for '#pragma unused'">,
+ InGroup<IgnoredPragmas>;
def warn_pragma_unused_expected_var_arg : Warning<
- "only variables can be arguments to '#pragma unused'">;
+ "only variables can be arguments to '#pragma unused'">,
+ InGroup<IgnoredPragmas>;
def err_pragma_push_visibility_mismatch : Error<
"#pragma visibility push with no matching #pragma visibility pop">;
def note_surrounding_namespace_ends_here : Note<
Modified: cfe/trunk/lib/Parse/ParseOpenMP.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseOpenMP.cpp?rev=201102&r1=201101&r2=201102&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseOpenMP.cpp (original)
+++ cfe/trunk/lib/Parse/ParseOpenMP.cpp Mon Feb 10 13:06:37 2014
@@ -367,7 +367,7 @@ OMPClause *Parser::ParseOpenMPVarListCla
} else if (Tok.isNot(tok::r_paren) &&
Tok.isNot(tok::annot_pragma_openmp_end)) {
Diag(Tok, diag::err_omp_expected_punc)
- << 1 << getOpenMPClauseName(Kind);
+ << getOpenMPClauseName(Kind);
}
}
Modified: cfe/trunk/lib/Parse/ParsePragma.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParsePragma.cpp?rev=201102&r1=201101&r2=201102&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParsePragma.cpp (original)
+++ cfe/trunk/lib/Parse/ParsePragma.cpp Mon Feb 10 13:06:37 2014
@@ -530,7 +530,7 @@ void PragmaUnusedHandler::HandlePragma(P
}
// Illegal token!
- PP.Diag(Tok.getLocation(), diag::warn_pragma_unused_expected_punc);
+ PP.Diag(Tok.getLocation(), diag::warn_pragma_expected_punc) << "unused";
return;
}
Modified: cfe/trunk/test/Misc/warning-flags.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/warning-flags.c?rev=201102&r1=201101&r2=201102&view=diff
==============================================================================
--- cfe/trunk/test/Misc/warning-flags.c (original)
+++ cfe/trunk/test/Misc/warning-flags.c Mon Feb 10 13:06:37 2014
@@ -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 (133):
+CHECK: Warnings without flags (111):
CHECK-NEXT: ext_delete_void_ptr_operand
CHECK-NEXT: ext_expected_semi_decl_list
CHECK-NEXT: ext_explicit_specialization_storage_class
@@ -108,30 +108,8 @@ CHECK-NEXT: warn_pp_convert_lhs_to_pos
CHECK-NEXT: warn_pp_convert_rhs_to_positive
CHECK-NEXT: warn_pp_expr_overflow
CHECK-NEXT: warn_pp_line_decimal
-CHECK-NEXT: warn_pragma_align_expected_equal
-CHECK-NEXT: warn_pragma_align_invalid_option
-CHECK-NEXT: warn_pragma_debug_unexpected_command
-CHECK-NEXT: warn_pragma_expected_colon
-CHECK-NEXT: warn_pragma_expected_enable_disable
-CHECK-NEXT: warn_pragma_expected_identifier
-CHECK-NEXT: warn_pragma_expected_lparen
-CHECK-NEXT: warn_pragma_expected_rparen
-CHECK-NEXT: warn_pragma_extra_tokens_at_eol
-CHECK-NEXT: warn_pragma_ms_struct
-CHECK-NEXT: warn_pragma_options_align_reset_failed
-CHECK-NEXT: warn_pragma_options_expected_align
-CHECK-NEXT: warn_pragma_pack_invalid_action
-CHECK-NEXT: warn_pragma_pack_invalid_alignment
-CHECK-NEXT: warn_pragma_pack_malformed
-CHECK-NEXT: warn_pragma_pack_pop_failed
CHECK-NEXT: warn_pragma_pack_pop_identifer_and_alignment
CHECK-NEXT: warn_pragma_pack_show
-CHECK-NEXT: warn_pragma_pop_macro_no_push
-CHECK-NEXT: warn_pragma_unknown_extension
-CHECK-NEXT: warn_pragma_unused_expected_punc
-CHECK-NEXT: warn_pragma_unused_expected_var
-CHECK-NEXT: warn_pragma_unused_expected_var_arg
-CHECK-NEXT: warn_pragma_unused_undeclared_var
CHECK-NEXT: warn_property_attr_mismatch
CHECK-NEXT: warn_property_attribute
CHECK-NEXT: warn_property_getter_owning_mismatch
More information about the cfe-commits
mailing list