// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -emit-llvm -std=c++98 -o - -fcxx-exceptions -fexceptions | FileCheck -check-prefix=CHECK -check-prefix=CHECK98 %s
// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -emit-llvm -std=c++11 -o - -fcxx-exceptions -fexceptions | FileCheck -check-prefix=CHECK -check-prefix=CHECK11 %s
+// CHECK: %[[STRUCT_TEST13_A:.*]] = type { i32, i32 }
+
typedef __typeof(sizeof(0)) size_t;
// Declare the reserved global placement new.
// CHECK11: call void @_ZN6test121AdlEPvS1_(i8* [[PTR]], i8* [[PTR]])
}
+namespace test13 {
+
+struct A {
+ A();
+ ~A();
+ int a, b;
+};
+
+// CHECK: define void @_ZN6test134testEi(
+// CHECK: %[[REF_TMP:.*]] = alloca %[[STRUCT_TEST13_A]], align 4
+// CHECK: %[[CLEANUP_COND:.*]] = alloca i1, align 1
+// CHECK: %[[REF_TMP1:.*]] = alloca %[[STRUCT_TEST13_A]], align 4
+// CHECK: %[[CLEANUP_COND2:.*]] = alloca i1, align 1
+
+// CHECK: call void @_ZN6test131AC1Ev(%[[STRUCT_TEST13_A]]* %[[REF_TMP]])
+// CHECK: store i1 true, i1* %[[CLEANUP_COND]], align 1
+// CHECK: br
+
+// CHECK: invoke void @_ZN6test131AC1Ev(%[[STRUCT_TEST13_A]]* %[[REF_TMP1]])
+
+// CHECK: store i1 true, i1* %[[CLEANUP_COND2]], align 1
+// CHECK: br
+
+// Check the flag before destructing the temporary.
+
+// CHECK: landingpad { i8*, i32 }
+// CHECK: %[[CLEANUP_IS_ACTIVE:.*]] = load i1, i1* %[[CLEANUP_COND]], align 1
+// CHECK: br i1 %[[CLEANUP_IS_ACTIVE]],
+
+// CHECK: void @_ZN6test131AD1Ev(%[[STRUCT_TEST13_A]]* %[[REF_TMP]])
+
+void test(int c) {
+ const A &s = c ? static_cast<const A &>(A()) : static_cast<const A &>(A());
+}
+
+}
+
// CHECK98: attributes [[NI_NR_NUW]] = { noinline noreturn nounwind }