diff options
Diffstat (limited to 'lib/CodeGen')
-rw-r--r-- | lib/CodeGen/CGDecl.cpp | 7 | ||||
-rw-r--r-- | lib/CodeGen/CGExpr.cpp | 3 |
2 files changed, 5 insertions, 5 deletions
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<UsedAttr>()) CGM.AddUsedGlobal(GV); - if (getContext().getLangOptions().CPlusPlus) - CGM.setStaticLocalDeclAddress(&D, GV); - // We may have to cast the constant because of the initializer // mismatch above. // diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index dacc04f599..bb0462f963 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -1152,8 +1152,7 @@ LValue CodeGenFunction::EmitDeclRefLValue(const DeclRefExpr *E) { bool NonGCable = VD->hasLocalStorage() && !VD->hasAttr<BlocksAttr>(); llvm::Value *V = LocalDeclMap[VD]; - if (!V && getContext().getLangOptions().CPlusPlus && - VD->isStaticLocal()) + if (!V && VD->isStaticLocal()) V = CGM.getStaticLocalDeclAddress(VD); assert(V && "DeclRefExpr not entered in LocalDeclMap?"); |