[cfe-commits] r148640 - in /cfe/trunk: include/clang/Basic/DiagnosticGroups.td include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaStmt.cpp test/Sema/switch.c test/Sema/warn-unreachable.c test/SemaCXX/gnu-case-ranges.cpp test/SemaCXX/return-n

David Blaikie dblaikie at gmail.com
Sun Jan 22 21:17:32 PST 2012


Implemented by:
r148648 - move existing -Wswitch-enum behavior to -Wswitch
[r148649 - related bugfix since I came across it: Fix -Wswitch to warn
about out of bounds enum cases even when there's a default]
r148679 - implement correct -Wswitch-enum behavior
r148680 - Rename -Wswitch-enum-redundant-default to
-Wswitch-redundant-default for consistency.

Thanks Fariborz & Chandler,

- David

On Sat, Jan 21, 2012 at 2:38 PM, David Blaikie <dblaikie at gmail.com> wrote:
> Yeah, but that's fine - I'll:
> • move current clang switch enum behavior under -Wswitch, including my new
> warning
> • remove the, now empty -Wswitch-enum group from -Wswitch so it's off by
> default as it is in gcc
> • implement gcc's switch-enum behavior under that group
>
> It's. A bit breaking for clang only users, but bring things in line with gcc
> (with the bonus of my new warning where it's most valuable)
> ________________________________
> From: Chandler Carruth
> Sent: 1/21/2012 2:02 PM
> To: Fariborz Jahanian
> Cc: David Blaikie; cfe-commits at cs.uiuc.edu
> Subject: Re: [cfe-commits] r148640 - in /cfe/trunk:
> include/clang/Basic/DiagnosticGroups.td
> include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaStmt.cpp
> test/Sema/switch.c test/Sema/warn-unreachable.c
> test/SemaCXX/gnu-case-ranges.cpp test/SemaCXX/return-n
>
> On Sat, Jan 21, 2012 at 11:43 AM, Fariborz Jahanian <fjahanian at apple.com>
> wrote:
>>
>> Yes, clang currently treats -Wswitch-enum same as -Wswitch. Maybe, while
>> you
>> are at it you can address this too. Once -Wswitch-enum is corrected, a
>> "default' can no
>> longer hide missing case labels.
>
>
> I worry that fixing -Wswitch-enum will simply cause everyone to turn it off,
> and only turn on -Wswitch. I certainly wouldn't be interested in the
> behavior described by -Wswitch-enum. It's important to be able to write a
> compact switch that wants to handle exactly two cases from an enumeration,
> and default the rest. The nice thing about David's patch is that when the
> default becomes unnecessary, we notice it, remove it, and start benefitting
> from -Wswitch warnings. So i think David's warning is likely to be valuable
> even with a fixed -Wswitch-enum, and fixing -Wswitch-enum will just make
> -Wswitch-enum essentially unused. =/




More information about the cfe-commits mailing list