Don't consider casted non-global pointers to be evaluatable.
Fixes rdar://problem/8154689
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107755 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp
index bec3792..5dae4d4 100644
--- a/lib/AST/ExprConstant.cpp
+++ b/lib/AST/ExprConstant.cpp
@@ -2210,6 +2210,8 @@
} else if (E->getType()->isIntegerType()) {
if (!IntExprEvaluator(Info, Info.EvalResult.Val).Visit(const_cast<Expr*>(E)))
return false;
+ if (Result.Val.isLValue() && !IsGlobalLValue(Result.Val.getLValueBase()))
+ return false;
} else if (E->getType()->hasPointerRepresentation()) {
LValue LV;
if (!EvaluatePointer(E, LV, Info))
diff --git a/test/CodeGen/init.c b/test/CodeGen/init.c
index d48e723..c8de99d 100644
--- a/test/CodeGen/init.c
+++ b/test/CodeGen/init.c
@@ -40,3 +40,9 @@
.x = value.x
}};
}
+
+// rdar://problem/8154689
+void f6() {
+ int x;
+ long ids[] = { (long) &x };
+}