diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-02-24 22:12:32 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-02-24 22:12:32 +0000 |
commit | 359c89df5479810c9d4784fc0b6ab592eb136777 (patch) | |
tree | d8904c4794928f823197cac4abce2e1c1b6d42d5 /lib/AST/ExprConstant.cpp | |
parent | f329527bbeae86c8eac6eea6efaa20e807c16679 (diff) |
When checking whether a reference to a variable is an ICE, look at the type of
the declaration, not at the type of the DeclRefExpr, since within a lambda the
DeclRefExpr can be more const than the declaration is.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151399 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/ExprConstant.cpp')
-rw-r--r-- | lib/AST/ExprConstant.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp index b69a805f78..44e41864f0 100644 --- a/lib/AST/ExprConstant.cpp +++ b/lib/AST/ExprConstant.cpp @@ -6379,12 +6379,12 @@ static ICEDiag CheckICE(const Expr* E, ASTContext &Ctx) { return CheckEvalInICE(E, Ctx); return ICEDiag(2, E->getLocStart()); } - case Expr::DeclRefExprClass: + case Expr::DeclRefExprClass: { if (isa<EnumConstantDecl>(cast<DeclRefExpr>(E)->getDecl())) return NoDiag(); - if (Ctx.getLangOptions().CPlusPlus && IsConstNonVolatile(E->getType())) { - const NamedDecl *D = cast<DeclRefExpr>(E)->getDecl(); - + const ValueDecl *D = dyn_cast<ValueDecl>(cast<DeclRefExpr>(E)->getDecl()); + if (Ctx.getLangOptions().CPlusPlus && + D && IsConstNonVolatile(D->getType())) { // Parameter variables are never constants. Without this check, // getAnyInitializer() can find a default argument, which leads // to chaos. @@ -6408,6 +6408,7 @@ static ICEDiag CheckICE(const Expr* E, ASTContext &Ctx) { } } return ICEDiag(2, E->getLocStart()); + } case Expr::UnaryOperatorClass: { const UnaryOperator *Exp = cast<UnaryOperator>(E); switch (Exp->getOpcode()) { |