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

            Bug ID: 18392
           Summary: False positive: Clang warns about unhanded switch
                    values even if they are handled elsewhere
           Product: clang
           Version: unspecified
          Hardware: Macintosh
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    Classification: Unclassified

Clang warns that a switch statement does not handle all enumeration values even
if the values not handled are actually handled elsewhere before the switch
statement.

e.g:

typedef NS_ENUM( NSUInteger, AnEnum ) {
    AnEnumA,
    AnEnumB,
    AnEnumC
};

- (void)doSomething: (AnEnum)value {

    if( AnEnumA == value )
    {
        // Do something special.
    }
    else
    {
        NSUInteger aParam;

        switch( value )
        {
            case AnEnumB: aParam = 1; break;
            case AnEnumC: aParam = 2; break;
        }

        [self doSomethingElse: aParam];
    }
}

Clang warns that the switch statement does not cover 'AnEnumA', even though it
is not possible that value could possibly be 'AnEnumA' at that point.

As you can see, I've stuck AnEnumB and AnEnumC inside a switch statement
because all of those cases are handled the same way (save for a single
parameter value). AnEnumA requires some special treatment, which is why I have
handled it before reaching the switch statement.

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