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 | d4ecca135a78c3b4245264c10c191452603eff2d (patch) | |
tree | e32af86133a201b903fb3688cc771d5a45bcc6d2 /clang/lib/CodeGen | |
parent | c5437ea42948f1e4cc89c0e8d944a380e6c880e7 (diff) | |
download | bcm5719-llvm-d4ecca135a78c3b4245264c10c191452603eff2d.tar.gz bcm5719-llvm-d4ecca135a78c3b4245264c10c191452603eff2d.zip |
Fix IRgen of constant expressions referring to external/static
variables.
- PR3657.
llvm-svn: 65381
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r-- | clang/lib/CodeGen/CGExprConstant.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/clang/lib/CodeGen/CGExprConstant.cpp b/clang/lib/CodeGen/CGExprConstant.cpp index fd174237c09..1141c0da8aa 100644 --- a/clang/lib/CodeGen/CGExprConstant.cpp +++ b/clang/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; |