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

Ken Dyck Ken.Dyck at onsemi.com
Tue Sep 14 06:04:56 PDT 2010


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?

-Ken

[1] http://www.plumhall.com/stec.html




More information about the cfe-dev mailing list