43 lines · cpp
1// RUN: %clang_cc1 -std=c++11 %s -o - -emit-llvm | FileCheck %s2 3// PR10304: destructors should not call destructors for variant members.4 5template<bool b = false>6struct Foo {7 Foo() { static_assert(b, "Foo::Foo used"); }8 ~Foo() { static_assert(b, "Foo::~Foo used"); }9};10 11struct Bar {12 Bar();13 ~Bar();14};15 16union FooBar {17 FooBar() {}18 ~FooBar() {}19 Foo<> foo;20 Bar bar;21};22 23struct Variant {24 Variant() {}25 ~Variant() {}26 union {27 Foo<> foo;28 Bar bar;29 };30};31 32FooBar foobar;33Variant variant;34 35// The ctor and dtor of Foo<> and Bar should not be mentioned in the resulting36// code.37//38// CHECK-NOT: 3FooILb1EEC139// CHECK-NOT: 3BarC140//41// CHECK-NOT: 3FooILb1EED142// CHECK-NOT: 3BarD143