From 09349145d7e9b2142a9cef94e30eb8b70ce99bdc Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Tue, 7 Sep 2010 23:26:17 +0000 Subject: Local static block variable referecned in its block-literal initializer expression causes IRgen to crash. This patch fixes by saving it in StaticLocalDecl map already used for such purposes. (radar 8390455). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113307 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGDecl.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'lib/CodeGen/CGDecl.cpp') diff --git a/lib/CodeGen/CGDecl.cpp b/lib/CodeGen/CGDecl.cpp index 57e5236c67..97c0341087 100644 --- a/lib/CodeGen/CGDecl.cpp +++ b/lib/CodeGen/CGDecl.cpp @@ -244,6 +244,10 @@ void CodeGenFunction::EmitStaticBlockVarDecl(const VarDecl &D, // Make sure to evaluate VLA bounds now so that we have them for later. if (D.getType()->isVariablyModifiedType()) EmitVLASize(D.getType()); + + // Local static block variables must be treated as globals as they may be + // referenced in their RHS initializer block-literal expresion. + CGM.setStaticLocalDeclAddress(&D, GV); // If this value has an initializer, emit it. if (D.getInit()) @@ -266,9 +270,6 @@ void CodeGenFunction::EmitStaticBlockVarDecl(const VarDecl &D, if (D.hasAttr()) CGM.AddUsedGlobal(GV); - if (getContext().getLangOptions().CPlusPlus) - CGM.setStaticLocalDeclAddress(&D, GV); - // We may have to cast the constant because of the initializer // mismatch above. // -- cgit v1.2.3-18-g5258