Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CodeGenCXX / union-dtor.cpp
bloba0b822aa54ddaafde171051202d42a84874d7fdd
1 // RUN: %clang_cc1 -std=c++11 %s -S -o - -emit-llvm | FileCheck %s
3 // PR10304: destructors should not call destructors for variant members.
5 template<bool b = false>
6 struct Foo {
7 Foo() { static_assert(b, "Foo::Foo used"); }
8 ~Foo() { static_assert(b, "Foo::~Foo used"); }
9 };
11 struct Bar {
12 Bar();
13 ~Bar();
16 union FooBar {
17 FooBar() {}
18 ~FooBar() {}
19 Foo<> foo;
20 Bar bar;
23 struct Variant {
24 Variant() {}
25 ~Variant() {}
26 union {
27 Foo<> foo;
28 Bar bar;
32 FooBar foobar;
33 Variant variant;
35 // The ctor and dtor of Foo<> and Bar should not be mentioned in the resulting
36 // code.
38 // CHECK-NOT: 3FooILb1EEC1
39 // CHECK-NOT: 3BarC1
41 // CHECK-NOT: 3FooILb1EED1
42 // CHECK-NOT: 3BarD1