[LoongArch][Clang] Make the parameters and return value of {x,}vorn.v builti ns ...
[llvm-project.git] / clang / test / CodeGenCXX / attr-no-destroy-d54344.cpp
blob053043adb61c17d74ad815c6b43786404a43151d
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
14 // incorrect code.
16 class a {
17 public:
18 a();
19 ~a();
21 class logger_base {
22 a d;
24 class e : logger_base {};
25 #ifndef NOATTR
26 __attribute((no_destroy))
27 #endif
28 e g;
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
37 // registration.
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