summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2012-02-24 22:12:32 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2012-02-24 22:12:32 +0000
commit6365c9138e26add7d5ee99b74ad4edd309024c3c (patch)
tree12cf6da28b78c96389bd668c2c5e732a9edc3bf3 /clang/lib
parent9fceb90175f1fd40ab69015e18804d5d78781ffd (diff)
downloadbcm5719-llvm-6365c9138e26add7d5ee99b74ad4edd309024c3c.tar.gz
bcm5719-llvm-6365c9138e26add7d5ee99b74ad4edd309024c3c.zip
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. llvm-svn: 151399
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/AST/ExprConstant.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index b69a805f785..44e41864f0b 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/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()) {
OpenPOWER on IntegriCloud