diff options
| author | Douglas Gregor <dgregor@apple.com> | 2010-10-08 23:50:27 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2010-10-08 23:50:27 +0000 |
| commit | 0bf3140424a0a13a928a4e6bf0f112e6167a5636 (patch) | |
| tree | aef7f4fa057fc4672999ce4ec62b01064035c242 /clang/lib/Sema/SemaExpr.cpp | |
| parent | 959fcc6c634cb4d4fd8bd8c8b4bc3e6b99ebc228 (diff) | |
| download | bcm5719-llvm-0bf3140424a0a13a928a4e6bf0f112e6167a5636.tar.gz bcm5719-llvm-0bf3140424a0a13a928a4e6bf0f112e6167a5636.zip | |
Implement C++0x scoped enumerations, from Daniel Wallin! (and tweaked a
bit by me).
llvm-svn: 116122
Diffstat (limited to 'clang/lib/Sema/SemaExpr.cpp')
| -rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index fec8cb91663..e35b6c24551 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -5420,6 +5420,12 @@ QualType Sema::CheckSubtractionOperands(Expr *&lex, Expr *&rex, return InvalidOperands(Loc, lex, rex); } +static bool isScopedEnumerationType(QualType T) { + if (const EnumType *ET = dyn_cast<EnumType>(T)) + return ET->getDecl()->isScoped(); + return false; +} + // C99 6.5.7 QualType Sema::CheckShiftOperands(Expr *&lex, Expr *&rex, SourceLocation Loc, bool isCompAssign) { @@ -5428,6 +5434,13 @@ QualType Sema::CheckShiftOperands(Expr *&lex, Expr *&rex, SourceLocation Loc, !rex->getType()->hasIntegerRepresentation()) return InvalidOperands(Loc, lex, rex); + // C++0x: Don't allow scoped enums. FIXME: Use something better than + // hasIntegerRepresentation() above instead of this. + if (isScopedEnumerationType(lex->getType()) || + isScopedEnumerationType(rex->getType())) { + return InvalidOperands(Loc, lex, rex); + } + // Vector shifts promote their scalar inputs to vector type. if (lex->getType()->isVectorType() || rex->getType()->isVectorType()) return CheckVectorOperands(Loc, lex, rex); @@ -5914,7 +5927,8 @@ inline QualType Sema::CheckBitwiseOperands( QualType compType = UsualArithmeticConversions(lex, rex, isCompAssign); - if (lex->getType()->isIntegerType() && rex->getType()->isIntegerType()) + if (lex->getType()->isIntegralOrUnscopedEnumerationType() && + rex->getType()->isIntegralOrUnscopedEnumerationType()) return compType; return InvalidOperands(Loc, lex, rex); } |

