Home | History | Annotate | Download | only in CodeGenCXX
      1 // RUN: %clang_cc1 -std=c++11 %s -S -o - -emit-llvm | FileCheck %s
      2 
      3 // PR10304: destructors should not call destructors for variant members.
      4 
      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 };
     10 
     11 struct Bar {
     12   Bar();
     13   ~Bar();
     14 };
     15 
     16 union FooBar {
     17   FooBar() {}
     18   ~FooBar() {}
     19   Foo<> foo;
     20   Bar bar;
     21 };
     22 
     23 struct Variant {
     24   Variant() {}
     25   ~Variant() {}
     26   union {
     27     Foo<> foo;
     28     Bar bar;
     29   };
     30 };
     31 
     32 FooBar foobar;
     33 Variant variant;
     34 
     35 // The ctor and dtor of Foo<> and Bar should not be mentioned in the resulting
     36 // code.
     37 //
     38 // CHECK-NOT: 3FooILb1EEC1
     39 // CHECK-NOT: 3BarC1
     40 //
     41 // CHECK-NOT: 3FooILb1EED1
     42 // CHECK-NOT: 3BarD1
     43