diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2009-01-25 01:21:06 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2009-01-25 01:21:06 +0000 |
commit | f01158941ba4560c63150032073bb231ce38999e (patch) | |
tree | 1afbe6ec213c28115125571e91aedf5a01dcbcf1 /lib/CodeGen/CGExprConstant.cpp | |
parent | 13ca96a238089fb8e622791bc0dc441eb2dd29b4 (diff) |
Fix the address of a label to be properly considered and emitted as a
constant.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62948 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExprConstant.cpp')
-rw-r--r-- | lib/CodeGen/CGExprConstant.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/CodeGen/CGExprConstant.cpp b/lib/CodeGen/CGExprConstant.cpp index 9d709d3a50..0e31cacd1b 100644 --- a/lib/CodeGen/CGExprConstant.cpp +++ b/lib/CodeGen/CGExprConstant.cpp @@ -619,6 +619,12 @@ public: return CGM.GetAddrOfConstantCString(Str, ".tmp"); } + case Expr::AddrLabelExprClass: { + assert(CGF && "Invalid address of label expression outside function."); + unsigned id = CGF->GetIDForAddrOfLabel(cast<AddrLabelExpr>(E)->getLabel()); + llvm::Constant *C = llvm::ConstantInt::get(llvm::Type::Int32Ty, id); + return llvm::ConstantExpr::getIntToPtr(C, ConvertType(E->getType())); + } } CGM.ErrorUnsupported(E, "constant l-value expression"); llvm::Type *Ty = llvm::PointerType::getUnqual(ConvertType(E->getType())); |