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

             Bug #: 15071
           Summary: redefinition of enumerator in enum not issuing an
                    error
           Product: clang
           Version: 3.1
          Platform: Macintosh
        OS/Version: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
        AssignedTo: [email protected]
        ReportedBy: [email protected]
                CC: [email protected]
    Classification: Unclassified


clang is not catching a redefinition of an enumerator in C if, for example, one
of them is inside of a struct.  Example code:

#include <stdio.h>

struct q {
    enum {
        A,
        B
    } foo;
};

enum p {
    B,
    C
};

int main(void)
{
    printf("B = %d\n", B);
    return 0;
}

Compiling this with clang results in no error.  It will print that B is either
zero or one, depending on which definition appears last in the source file.

If I remove the struct from around the first enum, then I get the expected:

clang-enum-bug.c:11:5: error: redefinition of enumerator 'B'

This had me going for while hunting down a bug where I had inadvertently used
the same enumerator in two different places, but the compiler didn't catch it.

I am using:
Apple clang version 4.1 (tags/Apple/clang-421.11.66) (based on LLVM 3.1svn)
Target: x86_64-apple-darwin12.2.1

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