diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-02-24 18:41:57 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-02-24 18:41:57 +0000 |
commit | d01b669f26703663da3515638e254fa7a987e860 (patch) | |
tree | 9678f7e64df56cdb6295b50d9ad1af0b65d3c7e9 /lib/CodeGen/CGExprConstant.cpp | |
parent | 8ecbaf25c1373be6fb5a9d332b08b6be16d9fd4e (diff) |
Fix IRgen of constant expressions referring to external/static
variables.
- PR3657.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65381 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExprConstant.cpp')
-rw-r--r-- | lib/CodeGen/CGExprConstant.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/CodeGen/CGExprConstant.cpp b/lib/CodeGen/CGExprConstant.cpp index fd174237c0..1141c0da8a 100644 --- a/lib/CodeGen/CGExprConstant.cpp +++ b/lib/CodeGen/CGExprConstant.cpp @@ -384,11 +384,14 @@ public: if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(Decl)) return CGM.GetAddrOfFunction(FD); if (const VarDecl* VD = dyn_cast<VarDecl>(Decl)) { - if (VD->isFileVarDecl()) - return CGM.GetAddrOfGlobalVar(VD); - else if (VD->isBlockVarDecl()) { - assert(CGF && "Can't access static local vars without CGF"); - return CGF->GetAddrOfStaticLocalVar(VD); + // We can never refer to a variable with local storage. + if (!VD->hasLocalStorage()) { + if (VD->isFileVarDecl() || VD->hasExternalStorage()) + return CGM.GetAddrOfGlobalVar(VD); + else if (VD->isBlockVarDecl()) { + assert(CGF && "Can't access static local vars without CGF"); + return CGF->GetAddrOfStaticLocalVar(VD); + } } } break; |