1. Clang should warn on a case value that exceeds the range of the type in switch. int test1(const char *foo) { int success = 0; switch(foo[0]) { case 1234: /* XXX */ success = 1; break; default: break; } return success; } 2. Clang should warn on switch(bool) since it's almost certainly wrong (developers seem okay with using if-statements instead). int test2(const char *foo) { int success = 0; switch (foo && foo[0]) { /* XXX */ case 0: success = 1; break; case 1: break; } return success; }
This report contains two separate issues. I created http://llvm.org/bugs/show_bug.cgi?id=5190 to track the second one. Let's track the first one only here.
Proposed patch uploaded to http://codereview.appspot.com/130078 for review.
Patch sent to cfe-commits for review.
Fixed in r84259.