1 // RUN: %clang_cc1 -std=c++2a -emit-llvm -O0 -triple x86_64-unknown-linux-gnu -DNOATTR %s -o - | FileCheck %s
2 // RUN: %clang_cc1 -std=c++2a -emit-llvm -O0 -triple x86_64-unknown-linux-gnu %s -o - | FileCheck %s --check-prefix=CHECK-ATTR
3 // RUN: %clang_cc1 -std=c++2a -emit-llvm -O0 -triple x86_64-unknown-linux-gnu -DNOATTR -fno-c++-static-destructors %s -o - | FileCheck %s --check-prefix=CHECK-FLAG
5 // Regression test for D54344. Class with no user-defined destructor
6 // that has an inherited member that has a non-trivial destructor
7 // and a non-default constructor will attempt to emit a destructor
8 // despite being marked as __attribute((no_destroy)) in which case
9 // it would trigger an assertion due to an incorrect assumption.
11 // This test is more reliable with asserts to work as without
12 // the crash may (unlikely) could generate working but semantically
23 class e
: logger_base
{};
25 __attribute((no_destroy
))
29 // In the absence of the attribute and flag, both ctor and dtor should
30 // be emitted, check for that.
31 // CHECK: @__cxx_global_var_init
32 // CHECK: @__cxa_atexit
34 // When attribute is enabled, the constructor should not be balanced
35 // by a destructor. Make sure we have the ctor but not the dtor
37 // CHECK-ATTR: @__cxx_global_var_init
38 // CHECK-ATTR-NOT: @__cxa_atexit
40 // Same scenario except with global flag (-fno-c++-static-destructors)
41 // supressing it instead of the attribute.
42 // CHECK-FLAG: @__cxx_global_var_init
43 // CHECK-FLAG-NOT: @__cxa_atexit