http://llvm.org/bugs/show_bug.cgi?id=11986
David Blaikie <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |INVALID --- Comment #1 from David Blaikie <[email protected]> 2012-02-11 23:06:01 CST --- Eli - thanks for the heads up on this. John - I think you /might/ be misunderstanding the behavior of -Wswitch-enum. To quote the GCC documentation ( http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html ): -Wswitch Warn whenever a switch statement has an index of enumerated type and lacks a case for one or more of the named codes of that enumeration. (The presence of a default label prevents this warning.) case labels outside the enumeration range also provoke warnings when this option is used (even if there is a default label). This warning is enabled by -Wall. -Wswitch-enum Warn whenever a switch statement has an index of enumerated type and lacks a case for one or more of the named codes of that enumeration. case labels outside the enumeration range also provoke warnings when this option is used. >>>The only difference between -Wswitch and this option is that this option gives a warning about an omitted enumeration code even if there is a default label.<<< To demonstrate this behavior (& Clang's consistency with GCC 4.6.1): $ cat switch.cpp enum E { a, b }; int func(E e) { switch (e) { case a: return 1; } return 2; } $ clang++ switch.cpp -Wswitch switch.cpp:3:11: warning: enumeration value 'b' not handled in switch [-Wswitch] switch (e) { ^ $ g++ switch.cpp -Wswitch switch.cpp: In function 'int func(E)': switch.cpp:3:10: warning: enumeration value 'b' not handled in switch [-Wswitch] $ cat switch.cpp enum E { a, b }; int func(E e) { switch (e) { case a: return 1; default: return 2; } } $ clang++ switch.cpp -Wswitch-enum switch.cpp:3:11: warning: enumeration value 'b' not explicitly handled in switch [-Wswitch-enum] switch (e) { ^ $ g++ switch.cpp -Wswitch-enum switch.cpp: In function âint func(E)â: switch.cpp:3:10: warning: enumeration value âbâ not handled in switch [-Wswitch-enum] (please reopen if I've misunderstood your bug/haven't adequately explained the behavior/consistency here) -- Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug. _______________________________________________ LLVMbugs mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs
