http://llvm.org/bugs/show_bug.cgi?id=13815

             Bug #: 13815
           Summary: -Wunreachable-code cannot be silenced for default
                    cases in switches
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
        AssignedTo: [email protected]
        ReportedBy: [email protected]
                CC: [email protected]
    Classification: Unclassified


The flag -Wcovered-switch-default enables warnings for default cases in
switches that cannot be reached, e.g. because all possible enum values have
been listed. For code where the defaults are added intentionally, the
-Wno-covered-switch-default can be used to silence the warning. However,
-Wunreachable-code also enables warnings for the same cases, but they cannot be
silenced without -Wno-unreachable-code, which disables all unreachable code
warnings.

Code snipped illustrating the behaviour follows.

#include <stdlib.h>

enum e {E1, E2};

int main(int argc, char* argv[])
{
        enum e e = atoi(argv[argc-1]);
        switch(e)
        {
                case E1: return 1;
                case E2: return 2;
/* Both -Wcovered-switch-default and -Wunreachable-code trigger below */
                default: return 3; 
        }
}

-- 
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

Reply via email to