Hi Alexander, > > While clang issues a warns about a possibly incomplete switch statement > > when switching over an enum variable and failing to cover all enum > > values (either explicitly or with a default case), no such warning is > > emitted if a plain integer variable is used as switch variable. > > > > If we consider this diagnostic useful, then we should implement > -Wswitch-default in Clang (GCC has it, Clang doesn't).
This is intended to catch different problems than -Wswitch-default, and a default case is even discouraged in some style guides since it masks unhandled values when using -Wswitch (explicitly in GCC or implicitly in clang). The problem this tries to catch is switching on ints w/o an existing default. If the switch labels are enum values both GCC and clang will check for full coverage if one uses -Wswitch; however since the switch condition won't be of that enum type no full coverage can be guaranteed. The same problem also exists were the switch labels plain ints, but then even -Wswitch won't help. It might be a good idea to add a compiler warning proper for that, but I have even less experience with that than with writing AST matchers for clang-tidy. Btw, I am working on comments in http://reviews.llvm.org/D4784. Cheers, Benjamin -- "Good judgment comes from experience. Experience comes from bad judgment."
signature.asc
Description: Digital signature
_______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
