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