When binding a reference to a temporary, it's important that other temporaries created as on the RHS are destroyed before emitting the dtor for the temporary.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84451 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/CodeGenCXX/references.cpp b/test/CodeGenCXX/references.cpp
index 32d46b3..682aab3 100644
--- a/test/CodeGenCXX/references.cpp
+++ b/test/CodeGenCXX/references.cpp
@@ -107,3 +107,26 @@
const C& c = D();
}
+namespace T {
+ struct A {
+ A();
+ ~A();
+ };
+
+ struct B {
+ B();
+ ~B();
+ A f();
+ };
+
+ void f() {
+ // CHECK: call void @_ZN1T1BC1Ev
+ // CHECK: call void @_ZN1T1B1fEv
+ // CHECK: call void @_ZN1T1BD1Ev
+ const A& a = B().f();
+ // CHECK: call void @_ZN1T1fEv
+ f();
+ // CHECK: call void @_ZN1T1AD1Ev
+ }
+}
+