diff options
author | Anders Carlsson <andersca@mac.com> | 2009-05-20 01:03:17 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2009-05-20 01:03:17 +0000 |
commit | e04d1c77ae15a6e973e2fac7723f6c364884f58d (patch) | |
tree | 5f82922adb4b6bd1ada21e0a7421b9460606df42 /lib/CodeGen/CGExpr.cpp | |
parent | 4bbab92167713bf4f79c0b14dcc4e83d08ac4019 (diff) |
Add support for binding references to scalar rvalues.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72153 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExpr.cpp')
-rw-r--r-- | lib/CodeGen/CGExpr.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index bb9f20003a..299bb6b4a4 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -78,6 +78,14 @@ RValue CodeGenFunction::EmitReferenceBindingToExpr(const Expr* E, return RValue::get(LV.getAddress()); } + if (!hasAggregateLLVMType(E->getType())) { + // Make a temporary variable that we can bind the reference to. + llvm::Value *Temp = CreateTempAlloca(ConvertTypeForMem(E->getType()), + "reftmp"); + EmitStoreOfScalar(EmitScalarExpr(E), Temp, false, E->getType()); + return RValue::get(Temp); + } + CGM.ErrorUnsupported(E, "reference binding"); return GetUndefRValue(DestType); } |