[cfe-commits] r148679 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaStmt.cpp test/Sema/switch-enum.c

David Blaikie dblaikie at gmail.com
Mon Jan 23 21:01:11 PST 2012


On Mon, Jan 23, 2012 at 7:15 PM, Richard Smith <richard at metafoo.co.uk> wrote:
> On Mon, January 23, 2012 04:46, David Blaikie wrote:
>> Author: dblaikie
>> Date: Sun Jan 22 22:46:12 2012
>> New Revision: 148679
>>
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=148679&view=rev
>> Log:
>> Implement -Wswitch-enum correctly.
>>
>>
>> Clang previously implemented -Wswitch-enum the same as -Wswitch. This patch
>> corrects the behavior to match GCC's. The critical/only difference being that
>> -Wswitch-enum is not silenced by the presence of a default case in the
>> switch.
>>
>> Added:
>> cfe/trunk/test/Sema/switch-enum.c Modified:
>> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> cfe/trunk/lib/Sema/SemaStmt.cpp
>>
>> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticS
>> emaKinds.td?rev=148679&r1=148678&r2=148679&view=diff
>> =============================================================================
>> =
>> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
>> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Sun Jan 22 22:46:12
>> 2012
>> @@ -4945,6 +4945,20 @@
>> def warn_case_empty_range : Warning<"empty case range specified">; def
>> warn_missing_case_for_condition : Warning<"no case matching constant switch
>> condition '%0'">; +
>> +def warn_def_missing_case1 : Warning<
>> +  "enumeration value %0 not handled in switch">,
>> +  InGroup<SwitchEnum>, DefaultIgnore;
>> +def warn_def_missing_case2 : Warning<
>> +  "enumeration values %0 and %1 not handled in switch">,
>> +  InGroup<SwitchEnum>, DefaultIgnore;
>> +def warn_def_missing_case3 : Warning<
>> +  "enumeration values %0, %1, and %2 not handled in switch">,
>> +  InGroup<SwitchEnum>, DefaultIgnore;
>> +def warn_def_missing_cases : Warning<
>> +  "%0 enumeration values not handled in switch: %1, %2, %3...">,
>> +  InGroup<SwitchEnum>, DefaultIgnore;
>
> This diagnostic text isn't technically correct. What do you think about
> 'enumeration value[...] not explicitly handled in switch'?

Agreed (I'd just done the "simple" thing & preserved GCC's behavior
without giving it much thought). Committed the suggested rewording as
r148781 (& also simplified the test cases a bit).

Thanks,
- David




More information about the cfe-commits mailing list