The address of a variable is only constant if the variable has global storage.
llvm-svn: 59939
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 7b927f4..6cdbc80 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -121,7 +121,7 @@
}
APValue VisitParenExpr(ParenExpr *E) { return Visit(E->getSubExpr()); }
- APValue VisitDeclRefExpr(DeclRefExpr *E) { return APValue(E, 0); }
+ APValue VisitDeclRefExpr(DeclRefExpr *E);
APValue VisitPredefinedExpr(PredefinedExpr *E) { return APValue(E, 0); }
APValue VisitCompoundLiteralExpr(CompoundLiteralExpr *E);
APValue VisitMemberExpr(MemberExpr *E);
@@ -135,6 +135,14 @@
return Result.isLValue();
}
+APValue LValueExprEvaluator::VisitDeclRefExpr(DeclRefExpr *E)
+{
+ if (!E->hasGlobalStorage())
+ return APValue();
+
+ return APValue(E, 0);
+}
+
APValue LValueExprEvaluator::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
if (E->isFileScope())
return APValue(E, 0);