Explicitly store the condition variable within switch statements, and
make sure that this variable is destroyed when we exit the switch
statement.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89776 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/CodeGenCXX/condition.cpp b/test/CodeGenCXX/condition.cpp
index f8a55d8..f3c8a9b 100644
--- a/test/CodeGenCXX/condition.cpp
+++ b/test/CodeGenCXX/condition.cpp
@@ -45,3 +45,27 @@
   // CHECK: if.end
   // CHECK: call  void @_ZN1XD1Ev
 }
+
+struct ConvertibleToInt {
+  ConvertibleToInt();
+  ~ConvertibleToInt();
+  operator int();
+};
+
+void switch_destruct(int z) {
+  // CHECK: call void @_ZN16ConvertibleToIntC1Ev
+  switch (ConvertibleToInt conv = ConvertibleToInt()) {
+  case 0:
+    break;
+
+  default:
+    // CHECK: sw.default:
+    // CHECK: store i32 19
+    z = 19;
+    break;
+  }
+  // CHECK: sw.epilog:
+  // CHECK: call void @_ZN16ConvertibleToIntD1Ev
+  // CHECK: store i32 20
+  z = 20;
+}