[cfe-commits] r41500 - in /cfe/trunk: AST/ASTContext.cpp include/clang/AST/ASTContext.h
Chris Lattner
clattner at apple.com
Mon Aug 27 17:55:02 PDT 2007
On Aug 27, 2007, at 3:18 PM, Neil Booth wrote:
> Chris Lattner wrote:-
>
>> +/// getEnumDeclIntegerType - returns the integer type compatible
>> with the
>> +/// given enum type.
>> +QualType ASTContext::getEnumDeclIntegerType(EnumDecl *ED) const {
>> + if (EnumConstantDecl *C = ED->getEnumConstantList())
>> + return C->getType();
>
> 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.
4. The code we have now isn't done yet.
The enum decl integer type (returned by getEnumDeclIntegerType) is
only used for code generation: determining sizeof(enum foo), figuring
out how much space to allocate for "enum foo X;" etc.
Are my assumptions above incorrect? Note that I want to be ABI
compatible with GCC and its extensions as well as fully supporting
pedantic C.
-Chris
More information about the cfe-commits
mailing list