[cfe-dev] Enum identifier hiding in function prototype scope

Douglas Gregor dgregor at apple.com
Tue Sep 14 08:10:33 PDT 2010


On Sep 14, 2010, at 6:04 AM, Ken Dyck wrote:

> I have access to the Plum Hall Validation Suite for C [1], which I have
> been using to test a Clang/LLVM backend that I'm developing. 
> 
> One of the test cases in the suite exercises the identifier scoping
> rules set out in section 6.1.2.1 in C90 and 6.2.1 in C99. The tests case
> is intended to be conforming code, but Clang rejects it with error
> messages. 
> 
> The code for the test is:
> 
>  // test.c
>  int iequals(int, int, int);
>  int do_nothing1(const volatile void *);
> 
>  enum eAABB {AA, BB};
> 
>  static int f(enum {BB, AA} n)
>  { iequals(__LINE__, BB, 0); do_nothing1(&n); return BB; }
> 
> 
> This is the reported error:
> 
>> clang -S -x c -std=iso9899:1990 -o - test.c
>  test.c:6:20: error: redefinition of enumerator 'BB'
>  static int f(enum {BB, AA} n)
>                     ^
>  test.c:4:17: note: previous definition is here
>  enum eAABB {AA, BB};
>                  ^
>  test.c:6:24: error: redefinition of enumerator 'AA'
>  static int f(enum {BB, AA} n)
>                         ^
>  test.c:4:13: note: previous definition is here
>  enum eAABB {AA, BB};
>              ^
>  2 errors generated.
> 
> 
> Can any language lawyers comment on whether this is really a
> non-conformance against the standards?

Yes, it's a Clang bug. We have numerous problems with definitions in prototype scope. This one is essentially captured by:

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

	- Doug



More information about the cfe-dev mailing list