From: David Majnemer Date: Tue, 11 Mar 2014 00:26:28 +0000 (+0000) Subject: Basic: Add -Wswitch-bool to control warn_bool_switch_condition X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c78427d26bca8583da91b83dc6e8ee76fba495f2;p=clang Basic: Add -Wswitch-bool to control warn_bool_switch_condition This warning was missing a flag, add one. test/Misc/warning-flags.c has one fewer entry. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203522 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/DiagnosticGroups.td b/include/clang/Basic/DiagnosticGroups.td index ca12e4b73f..97f0b3ed61 100644 --- a/include/clang/Basic/DiagnosticGroups.td +++ b/include/clang/Basic/DiagnosticGroups.td @@ -326,6 +326,7 @@ def : DiagGroup<"strict-prototypes">; def StrictSelector : DiagGroup<"strict-selector-match">; def MethodDuplicate : DiagGroup<"duplicate-method-match">; def CoveredSwitchDefault : DiagGroup<"covered-switch-default">; +def SwitchBool : DiagGroup<"switch-bool">; def SwitchEnum : DiagGroup<"switch-enum">; def Switch : DiagGroup<"switch">; def ImplicitFallthroughPerFunction : @@ -541,7 +542,7 @@ def Consumed : DiagGroup<"consumed">; // Note that putting warnings in -Wall will not disable them by default. If a // warning should be active _only_ when -Wall is passed in, mark it as // DefaultIgnore in addition to putting it here. -def : DiagGroup<"all", [Most, Parentheses, Switch]>; +def : DiagGroup<"all", [Most, Parentheses, Switch, SwitchBool]>; // Warnings enabled by -pedantic. This is magically filled in by TableGen. def Pedantic : DiagGroup<"pedantic">; diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index e2f7e3c1b9..7f2abe6452 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -6425,7 +6425,7 @@ def err_default_not_in_switch : Error< "'default' statement not in switch statement">; def err_case_not_in_switch : Error<"'case' statement not in switch statement">; def warn_bool_switch_condition : Warning< - "switch condition has boolean value">; + "switch condition has boolean value">, InGroup; def warn_case_value_overflow : Warning< "overflow converting case value to switch condition type (%0 to %1)">, InGroup; diff --git a/test/Misc/warning-flags.c b/test/Misc/warning-flags.c index 7044a7828b..d1653b4c05 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 (109): +CHECK: Warnings without flags (108): CHECK-NEXT: ext_delete_void_ptr_operand CHECK-NEXT: ext_expected_semi_decl_list CHECK-NEXT: ext_explicit_specialization_storage_class @@ -49,7 +49,6 @@ CHECK-NEXT: warn_accessor_property_type_mismatch CHECK-NEXT: warn_anon_bitfield_width_exceeds_type_size CHECK-NEXT: warn_asm_label_on_auto_decl CHECK-NEXT: warn_bitfield_width_exceeds_type_size -CHECK-NEXT: warn_bool_switch_condition CHECK-NEXT: warn_braces_around_scalar_init CHECK-NEXT: warn_c_kext CHECK-NEXT: warn_call_to_pure_virtual_member_function_from_ctor_dtor