[cfe-commits] r41500 - in /cfe/trunk: AST/ASTContext.cpp include/clang/AST/ASTContext.h

Neil Booth neil at daikokuya.co.uk
Tue Aug 28 08:37:38 PDT 2007


Chris Lattner wrote:-

> >Is this saying the type of the enum is the type of the enumerator?
> >If so, it's probably not what you want.
> >
> >In C enumerators always have type "int".
> 
> I'm not fully done with the enum-related code.  What I think I know:
> 
> 1. GCC has a bunch of extensions in this area.  Among other amusing  
> things, -pedantic changes the code that GCC generates in some enum  
> cases.  The most significant one is that GCC allows long, long long,  
> ull, etc enum types.
> 2. All enum constants have to have the same type.
> 3. The enum decl itself, when code generated, has the same type as  
> the enum constants.

This doesn't seem to be the case:

enum { foo } z;

int main (void)
{
  int r = 0;

  if (foo - 1 < 0)
    r += 2;
  if (z - 1 < 0)
    r++;

  return r;
}

$ gcc test.c && ./a.out; echo $?
2

Neil.



More information about the cfe-commits mailing list