diff options
author | Francois Pichet <pichet2000@gmail.com> | 2010-10-18 15:01:13 +0000 |
---|---|---|
committer | Francois Pichet <pichet2000@gmail.com> | 2010-10-18 15:01:13 +0000 |
commit | 842e7a22c6a0fbf0ccdb4bb9308d92ca9e9621f6 (patch) | |
tree | 6903b9f80c9bb472e91b2b8f19a9737ff7bb0332 /lib/Sema/SemaDecl.cpp | |
parent | 6f2d1b111ed6d3c686303746e3949e3cbc9f3870 (diff) |
Microsoft enum extensions. 2 things will change on -fms-extensions:
1. enum underlying type is int by default.
2. Error "enumerator value is not representable in the underlying type"is a ExtWarning
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116704 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index c727c64370..a65c69ddd5 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -5526,7 +5526,9 @@ Decl *Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, // Recover by falling back to int. EnumUnderlying = Context.IntTy.getTypePtr(); } - } + } else if (getLangOptions().Microsoft) + // Microsoft enums are always of int type. + EnumUnderlying = Context.IntTy.getTypePtr(); } DeclContext *SearchDC = CurContext; @@ -7080,10 +7082,14 @@ EnumConstantDecl *Sema::CheckEnumConstant(EnumDecl *Enum, // C++0x [dcl.enum]p5: // ... if the initializing value of an enumerator cannot be // represented by the underlying type, the program is ill-formed. - if (!isRepresentableIntegerValue(Context, EnumVal, EltTy)) - Diag(IdLoc, diag::err_enumerator_too_large) - << EltTy; - else + if (!isRepresentableIntegerValue(Context, EnumVal, EltTy)) { + if (getLangOptions().Microsoft) { + Diag(IdLoc, diag::ext_enumerator_too_large) << EltTy; + ImpCastExprToType(Val, EltTy, CK_IntegralCast); + } else + Diag(IdLoc, diag::err_enumerator_too_large) + << EltTy; + } else ImpCastExprToType(Val, EltTy, CK_IntegralCast); } else { |