diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-10-17 23:52:07 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-10-17 23:52:07 +0000 |
commit | 6f3d435c5a7e70c2470121474ae7c0a3f60fdc4f (patch) | |
tree | 303e84928b088df7b68222dea8572014e37d05ad /clang/lib/AST/ExprConstant.cpp | |
parent | 3ac8201ea41e9b894224f0f5d5b993ad44ed3adf (diff) | |
download | bcm5719-llvm-6f3d435c5a7e70c2470121474ae7c0a3f60fdc4f.tar.gz bcm5719-llvm-6f3d435c5a7e70c2470121474ae7c0a3f60fdc4f.zip |
DR1535: only potentially-evaluated typeid expressions are disallowed in constant
expressions, not *any* typeid on a polymorphic class type.
llvm-svn: 166156
Diffstat (limited to 'clang/lib/AST/ExprConstant.cpp')
-rw-r--r-- | clang/lib/AST/ExprConstant.cpp | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index 323a1746bfb..6e0b5fca60c 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -2886,19 +2886,13 @@ LValueExprEvaluator::VisitCompoundLiteralExpr(const CompoundLiteralExpr *E) { } bool LValueExprEvaluator::VisitCXXTypeidExpr(const CXXTypeidExpr *E) { - if (E->isTypeOperand()) + if (!E->isPotentiallyEvaluated()) return Success(E); - CXXRecordDecl *RD = E->getExprOperand()->getType()->getAsCXXRecordDecl(); - // FIXME: The standard says "a typeid expression whose operand is of a - // polymorphic class type" is not a constant expression, but it probably - // means "a typeid expression whose operand is potentially evaluated". - if (RD && RD->isPolymorphic()) { - Info.Diag(E, diag::note_constexpr_typeid_polymorphic) - << E->getExprOperand()->getType() - << E->getExprOperand()->getSourceRange(); - return false; - } - return Success(E); + + Info.Diag(E, diag::note_constexpr_typeid_polymorphic) + << E->getExprOperand()->getType() + << E->getExprOperand()->getSourceRange(); + return false; } bool LValueExprEvaluator::VisitCXXUuidofExpr(const CXXUuidofExpr *E) { |