Hi here is an updated patch On Fri, Oct 1, 2010 at 10:29 AM, Douglas Gregor <[email protected]> wrote: > + > + // Make enum type a complete definition on Tag declaration in Microsoft > + //mode. Default to int type. Needed for enum forward declaration. > + if (getLangOptions().Microsoft) { > + EnumDecl *NewEnum = cast<EnumDecl>(New); > + NewEnum->completeDefinition(Context.IntTy, Context.IntTy, 0, 0); > + } > + > > 0, 0 seems a bit strange... I suggest we use the number of negative/positive > bits in an int. > I did NewEnum->completeDefinition(Context.IntTy, Context.IntTy, Context.Target.getIntWidth() - 1, Context.Target.getIntWidth()); which is equivalent to this enum: enum E { e1 = INT_MAX, INT_MIN };
>
> - Enum->completeDefinition(BestType, BestPromotionType,
> - NumPositiveBits, NumNegativeBits);
> + // In Microsoft mode, enums are already complete type in ActOnTag.
> + if (getLangOptions().Microsoft) {
> + Enum->setNumPositiveBits(NumPositiveBits);
> + Enum->setNumNegativeBits(NumNegativeBits);
> + } else
> + Enum->completeDefinition(BestType, BestPromotionType,
> + NumPositiveBits, NumNegativeBits);
> }
>
> We're missing semantic validation here; we've completed the enum with an
> underlying type of "int", but we haven't converted all of the enumerator
> types to "int" and we haven't verified that all of the enumerator values fall
> into the range of an int, e.g.,
>
> enum E { e1 = INT_MAX + 1 };
>
> seems like it should be an error in Microsoft mode, and we should truncate
> the value to the size of an int, but it depends on how the Microsoft compiler
> deals with large enumerators.
Ok, I skipped the part where sema selects the underlying type in
Microsoft mode. Microsoft enums are always int and will silently
convert any enumerator value to int. I believe this is what clang will
do also.
Then there is the enum E : unsigned short {e}; syntax supported since
VS 2005. But I'll keep that for later since I think someone is already
working on adding this to clang.
enum_complete_type_tag.patch
Description: Binary data
_______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
