[cfe-commits] r144483 - in /cfe/trunk: lib/Sema/SemaInit.cpp test/CodeGenCXX/compound-literals.cpp
Peter Collingbourne
peter at pcc.me.uk
Sat Nov 12 16:51:30 PST 2011
Author: pcc
Date: Sat Nov 12 18:51:30 2011
New Revision: 144483
URL: http://llvm.org/viewvc/llvm-project?rev=144483&view=rev
Log:
When reference binding array rvalues, such as those created by compound
literals of array type, materialise a temporary.
Modified:
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/test/CodeGenCXX/compound-literals.cpp
Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=144483&r1=144482&r2=144483&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Sat Nov 12 18:51:30 2011
@@ -3187,7 +3187,7 @@
if (T1Quals != T2Quals)
Sequence.AddQualificationConversionStep(cv1T1, ValueKind);
Sequence.AddReferenceBindingStep(cv1T1,
- /*bindingTemporary=*/(InitCategory.isPRValue() && !T2->isArrayType()));
+ /*bindingTemporary=*/InitCategory.isPRValue());
return;
}
Modified: cfe/trunk/test/CodeGenCXX/compound-literals.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/compound-literals.cpp?rev=144483&r1=144482&r2=144483&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/compound-literals.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/compound-literals.cpp Sat Nov 12 18:51:30 2011
@@ -25,3 +25,15 @@
// CHECK-NEXT: ret i32 [[RESULT]]
return ((Y){17, "seventeen"}).i;
}
+
+// CHECK: define i32 @_Z1gv()
+int g() {
+ // CHECK: store [2 x i32]* %{{[a-z0-9.]+}}, [2 x i32]** [[V:%[a-z0-9.]+]]
+ const int (&v)[2] = (int [2]) {1,2};
+
+ // CHECK: [[A:%[a-z0-9.]+]] = load [2 x i32]** [[V]]
+ // CHECK-NEXT: [[A0ADDR:%[a-z0-9.]+]] = getelementptr inbounds [2 x i32]* [[A]], i32 0, {{.*}} 0
+ // CHECK-NEXT: [[A0:%[a-z0-9.]+]] = load i32* [[A0ADDR]]
+ // CHECK-NEXT: ret i32 [[A0]]
+ return v[0];
+}
More information about the cfe-commits
mailing list