blob: 77b6166aff413685ab56f42eb2769968a4c4a8b1 [file] [log] [blame]
Anders Carlssonabea9512011-02-28 00:40:07 +00001// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -fcxx-exceptions -fexceptions -emit-llvm -o - | FileCheck %s
John McCalle71d60d2010-10-05 20:48:15 +00002
3// Reduced from a crash on boost::interprocess's node_allocator_test.cpp.
4namespace test0 {
5 struct A { A(); ~A(); };
6 struct V { V(const A &a = A()); ~V(); };
7
John McCall63d5fb32010-10-05 22:36:42 +00008 // CHECK: define linkonce_odr i32 @_ZN5test04testILi0EEEii
9 template<int X> int test(int x) {
10 // CHECK: [[RET:%.*]] = alloca i32
11 // CHECK-NEXT: [[X:%.*]] = alloca i32
12 // CHECK-NEXT: [[Y:%.*]] = alloca [[A:%.*]],
13 // CHECK-NEXT: [[Z:%.*]] = alloca [[A]]
14 // CHECK-NEXT: [[EXN:%.*]] = alloca i8*
John McCall93c332a2011-05-28 21:13:02 +000015 // CHECK-NEXT: [[SEL:%.*]] = alloca i32
John McCall63d5fb32010-10-05 22:36:42 +000016 // CHECK-NEXT: [[V:%.*]] = alloca [[V:%.*]]*,
17 // CHECK-NEXT: [[TMP:%.*]] = alloca [[A]]
18 // CHECK-NEXT: [[CLEANUPACTIVE:%.*]] = alloca i1
John McCall63d5fb32010-10-05 22:36:42 +000019 // CHECK: call void @_ZN5test01AC1Ev([[A]]* [[Y]])
20 // CHECK-NEXT: invoke void @_ZN5test01AC1Ev([[A]]* [[Z]])
21 // CHECK: [[NEW:%.*]] = invoke noalias i8* @_Znwm(i64 1)
John McCall6f103ba2011-11-10 10:43:54 +000022 // CHECK: store i1 true, i1* [[CLEANUPACTIVE]]
John McCall63d5fb32010-10-05 22:36:42 +000023 // CHECK: [[NEWCAST:%.*]] = bitcast i8* [[NEW]] to [[V]]*
24 // CHECK-NEXT: invoke void @_ZN5test01AC1Ev([[A]]* [[TMP]])
25 // CHECK: invoke void @_ZN5test01VC1ERKNS_1AE([[V]]* [[NEWCAST]], [[A]]* [[TMP]])
26 // CHECK: store i1 false, i1* [[CLEANUPACTIVE]]
27 // CHECK-NEXT: invoke void @_ZN5test01AD1Ev([[A]]* [[TMP]])
28 A y;
29 try {
30 A z;
31 V *v = new V();
John McCalle71d60d2010-10-05 20:48:15 +000032
John McCall63d5fb32010-10-05 22:36:42 +000033 if (x) return 1;
34 } catch (int ex) {
35 return 1;
36 }
37 return 0;
38 }
John McCalle71d60d2010-10-05 20:48:15 +000039
John McCall63d5fb32010-10-05 22:36:42 +000040 int test() {
41 return test<0>(5);
42 }
John McCalle71d60d2010-10-05 20:48:15 +000043}