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

Chris Lattner clattner at apple.com
Tue Aug 28 10:57:35 PDT 2007


On Aug 28, 2007, at 8:37 AM, Neil Booth wrote:

> 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

Yep, you're right.  Unbelievable :).  I'll make it work, thanks Neil!

-Chris



More information about the cfe-commits mailing list