]> granicus.if.org Git - clang/commitdiff
irgen for references to complex rvales (Very important...)
authorAnders Carlsson <andersca@mac.com>
Wed, 20 May 2009 01:35:03 +0000 (01:35 +0000)
committerAnders Carlsson <andersca@mac.com>
Wed, 20 May 2009 01:35:03 +0000 (01:35 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72157 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGExpr.cpp
test/CodeGenCXX/references.cpp

index eaf0873610dd0ab366a9760e71e193633e11b9c8..0886ad040a4b87c330b7559ed5b6cfabbb16c0d9 100644 (file)
@@ -79,11 +79,17 @@ RValue CodeGenFunction::EmitReferenceBindingToExpr(const Expr* E,
   }
   
   if (!hasAggregateLLVMType(E->getType())) {
-    // Make a temporary variable that we can bind the reference to.
+    // Create 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);
+  } else if (E->getType()->isAnyComplexType()) {
+    // Create a temporary variable that we can bind the reference to.
+    llvm::Value *Temp = CreateTempAlloca(ConvertTypeForMem(E->getType()), 
+                                         "reftmp");
+    EmitComplexExprIntoAddr(E, Temp, false);
+    return RValue::get(Temp);
   }
   
   CGM.ErrorUnsupported(E, "reference binding");
index afcaaf2d7c1cd4faac5f2acf8e3a7a2aaa1f2ce4..9b9e0f8623b0620018d1a1798e7d4528455cda4c 100644 (file)
@@ -44,6 +44,8 @@ void test_scalar() {
 void test_complex() {
   _Complex int a = 10i;
   f(a);
+  
+  f(10i);
 }
 
 void test_aggregate() {