]> granicus.if.org Git - clang/commitdiff
Don't consider casted non-global pointers to be evaluatable.
authorJohn McCall <rjmccall@apple.com>
Wed, 7 Jul 2010 05:08:32 +0000 (05:08 +0000)
committerJohn McCall <rjmccall@apple.com>
Wed, 7 Jul 2010 05:08:32 +0000 (05:08 +0000)
Fixes rdar://problem/8154689

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107755 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/ExprConstant.cpp
test/CodeGen/init.c

index bec379200049c8fc6def426dc70fa7ffc24fd741..5dae4d447582ae68608a7ab2d6445efa8d02c849 100644 (file)
@@ -2210,6 +2210,8 @@ bool Expr::Evaluate(EvalResult &Result, ASTContext &Ctx) const {
   } 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))
index d48e723c58a1af115a062cafa114533d01cea4fc..c8de99d901777c228c11411519d5bf82045cceda 100644 (file)
@@ -40,3 +40,9 @@ vec3 f5(vec3 value) {
     .x = value.x
   }};
 }
+
+// rdar://problem/8154689
+void f6() {
+  int x;
+  long ids[] = { (long) &x };  
+}