p3-0x.cpp revision 3bba3efba0e57071d60b355ed62639f93e37711c
1// RUN: %clang_cc1 -std=c++11 -fexceptions -fcxx-exceptions -emit-llvm -o - %s | FileCheck %s
2
3struct A {
4  ~A();
5};
6
7struct B {
8  ~B() throw(int);
9};
10
11struct C {
12  B b;
13  ~C() {}
14};
15
16struct D {
17  ~D() noexcept(false);
18};
19
20struct E {
21  D d;
22  ~E() {}
23};
24
25void foo() {
26  A a;
27  C c;
28  E e;
29  // CHECK: invoke {{.*}} @_ZN1ED1Ev
30  // CHECK: invoke {{.*}} @_ZN1CD1Ev
31  // CHECK: call {{.*}} @_ZN1AD1Ev
32}
33
34struct F {
35  D d;
36  ~F();
37};
38F::~F() noexcept(false) {}
39
40struct G {
41  D d;
42  ~G();
43};
44G::~G() {}
45
46struct H {
47  B b;
48  ~H() throw(int);
49};
50H::~H() throw(int) {}
51
52struct I {
53  B b;
54  ~I();
55};
56I::~I() {}
57
58// Template variants.
59
60template <typename T>
61struct TA {
62  ~TA();
63};
64
65template <typename T>
66struct TB {
67  ~TB() throw(int);
68};
69
70template <typename T>
71struct TC {
72  TB<T> b;
73  ~TC() {}
74};
75
76template <typename T>
77struct TD {
78  ~TD() noexcept(false);
79};
80
81template <typename T>
82struct TE {
83  TD<T> d;
84  ~TE() {}
85};
86
87void tfoo() {
88  TA<int> a;
89  TC<int> c;
90  TE<int> e;
91  // CHECK: invoke {{.*}} @_ZN2TEIiED1Ev
92  // CHECK: invoke {{.*}} @_ZN2TCIiED1Ev
93  // CHECK: call {{.*}} @_ZN2TAIiED1Ev
94}
95
96template <typename T>
97struct TF {
98  TD<T> d;
99  ~TF();
100};
101template <typename T>
102TF<T>::~TF() noexcept(false) {}
103
104template <typename T>
105struct TG {
106  TD<T> d;
107  ~TG();
108};
109template <typename T>
110TG<T>::~TG() {}
111
112template <typename T>
113struct TH {
114  TB<T> b;
115  ~TH();
116};
117template <typename T>
118TH<T>::~TH() {}
119
120void tinst() {
121  TF<int> f;
122  TG<int> g;
123  TH<int> h;
124}
125// CHECK: define linkonce_odr {{.*}} @_ZN2THIiED1Ev
126// CHECK: _ZTIi
127// CHECK: __cxa_call_unexpected
128
129struct VX
130{ virtual ~VX() {} };
131
132struct VY : VX
133{ virtual ~VY() {} };
134
135template<typename T>
136struct TVY : VX
137{ virtual ~TVY() {} };
138
139
140struct VA {
141  B b;
142  virtual ~VA() {}
143};
144
145struct VB : VA
146{ virtual ~VB() {} };
147
148template<typename T>
149struct TVB : VA
150{ virtual ~TVB() {} };
151
152void tinst2() {
153  TVY<int> tvy;
154  TVB<int> tvb;
155}
156
157template <typename T>
158struct Sw {
159  T t;
160  ~Sw() {}
161};
162
163void tsw() {
164  Sw<int> swi;
165  Sw<B> swb;
166}
167// CHECK-NOT: define linkonce_odr {{.*}} @_ZN2SwI1BED1Ev({{.*}} #
168// CHECK: define linkonce_odr {{.*}} @_ZN2SwI1BED1Ev({{.*}}
169// CHECK: _ZTIi
170// CHECK: __cxa_call_unexpected
171// CHECK: define linkonce_odr {{.*}} @_ZN2SwIiED1Ev({{.*}} [[ATTRGRP:#[0-9]+]]
172
173template <typename T>
174struct TVC : VX
175{ virtual ~TVC(); };
176template <typename T>
177TVC<T>::~TVC() {}
178
179// CHECK: attributes [[ATTRGRP]] = { nounwind "target-features"={{.*}} }
180