From 0f2b692bb10be35fdc60d0a72a847bdd73124670 Mon Sep 17 00:00:00 2001 From: John McCall Date: Wed, 7 Jul 2010 05:08:32 +0000 Subject: [PATCH] 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 --- lib/AST/ExprConstant.cpp | 2 ++ test/CodeGen/init.c | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp index bec3792000..5dae4d4475 100644 --- a/lib/AST/ExprConstant.cpp +++ b/lib/AST/ExprConstant.cpp @@ -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(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 d48e723c58..c8de99d901 100644 --- a/test/CodeGen/init.c +++ b/test/CodeGen/init.c @@ -40,3 +40,9 @@ vec3 f5(vec3 value) { .x = value.x }}; } + +// rdar://problem/8154689 +void f6() { + int x; + long ids[] = { (long) &x }; +} -- 2.40.0