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 | 9be36ab27b874b404099650e0c29bc92f3c7662d (patch) | |
tree | 802a751c7a857e5785bfdc1c3e148375512ba71a /lib/AST/ExprConstant.cpp | |
parent | 76398e5ad39ae719dcc650c7cddeb25379c02c34 (diff) |
DR1535: only potentially-evaluated typeid expressions are disallowed in constant
expressions, not *any* typeid on a polymorphic class type.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166156 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/ExprConstant.cpp')
-rw-r--r-- | lib/AST/ExprConstant.cpp | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp index 323a1746bf..6e0b5fca60 100644 --- a/lib/AST/ExprConstant.cpp +++ b/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) { |