[cfe-dev] clang++: '-Wswitch-enum' turned on by default

Sean McBride sean at rogue-research.com
Thu Sep 16 10:15:20 PDT 2010


On Thu, 16 Sep 2010 09:12:09 -0700, Chris Lattner said:

>we produce:
>
>t.c:4:11: warning: enumeration value 'a' not handled in switch [-
Wswitch-enum]
>  switch (a) {
>          ^
>t.c:4:11: warning: enumeration value 'd' not handled in switch [-
Wswitch-enum]
>t.c:4:11: warning: enumeration value 'e' not handled in switch [-
Wswitch-enum]
>t.c:4:11: warning: enumeration value 'f' not handled in switch [-
Wswitch-enum]
>t.c:4:11: warning: enumeration value 'g' not handled in switch [-
Wswitch-enum]
>5 warnings generated.
>
>In this case, I think it would be better to emit one warning say:
>
>t.c:4:11: warning: 5 enumeration values not handled in switch: 'a', 'd',
>'e' ... [-Wswitch-enum]
>
>or something like that.  What do you think?

That would be sweet IMHO.  Many of the open source libs I use generate
tonnes of noise with this warning, and your proposed change would force
attention on the switch itself and not each little missing case.

-- 
____________________________________________________________
Sean McBride, B. Eng                 sean at rogue-research.com
Rogue Research                        www.rogue-research.com 
Mac Software Developer              Montréal, Québec, Canada






More information about the cfe-dev mailing list