From 5f81b9f3f610400f09becc5d1cf005ed45c9c984 Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Wed, 26 May 2010 21:45:50 +0000 Subject: Patch to fix a irgen crash accessing an initialized local static variable in a local function. Fixes pr7101. llvm-svn: 104743 --- clang/lib/CodeGen/CGDecl.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'clang/lib/CodeGen/CGDecl.cpp') diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp index 8115e384db8..07edca0f5fe 100644 --- a/clang/lib/CodeGen/CGDecl.cpp +++ b/clang/lib/CodeGen/CGDecl.cpp @@ -239,8 +239,6 @@ void CodeGenFunction::EmitStaticBlockVarDecl(const VarDecl &D, // Store into LocalDeclMap before generating initializer to handle // circular references. DMEntry = GV; - if (getContext().getLangOptions().CPlusPlus) - CGM.setStaticLocalDeclAddress(&D, GV); // We can't have a VLA here, but we can have a pointer to a VLA, // even though that doesn't really make any sense. @@ -269,6 +267,9 @@ 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