[RISCV][VLOPT] Remove dead passthru check in getOperandLog2EEW. NFC (#123911)
[llvm-project.git] / clang / test / CXX / special / class.dtor / p5-0x.cpp
blobae14dcdaf102ac4446d92a51b198ee12169b1b5e
1 // RUN: %clang_cc1 -verify -std=c++11 %s -Wno-defaulted-function-deleted -triple x86_64-linux-gnu
3 struct NonTrivDtor {
4 ~NonTrivDtor();
5 };
6 struct DeletedDtor {
7 ~DeletedDtor() = delete; // expected-note 5 {{deleted here}}
8 };
9 class InaccessibleDtor {
10 ~InaccessibleDtor() = default;
13 // A defaulted destructor for a class X is defined as deleted if:
15 // -- X is a union-like class that has a variant member with a non-trivial
16 // destructor.
17 union A1 {
18 A1();
19 NonTrivDtor n; // expected-note {{destructor of 'A1' is implicitly deleted because variant field 'n' has a non-trivial destructor}}
21 A1 a1; // expected-error {{deleted function}}
22 struct A2 {
23 A2();
24 union {
25 NonTrivDtor n; // expected-note {{because variant field 'n' has a non-trivial destructor}}
28 A2 a2; // expected-error {{deleted function}}
29 union A3 {
30 A3();
31 NonTrivDtor n[3]; // expected-note {{because variant field 'n' has a non-trivial destructor}}
33 A3 a3; // expected-error {{deleted function}}
34 struct A4 {
35 A4();
36 union {
37 NonTrivDtor n[3]; // expected-note {{because variant field 'n' has a non-trivial destructor}}
40 A4 a4; // expected-error {{deleted function}}
42 // -- any of the non-static data members has class type M (or array thereof) and
43 // M has a deleted or inaccessible destructor.
44 struct B1 {
45 B1();
46 DeletedDtor a; // expected-note {{because field 'a' has a deleted destructor}}
48 B1 b1; // expected-error {{deleted function}}
49 struct B2 {
50 B2();
51 InaccessibleDtor a; // expected-note {{because field 'a' has an inaccessible destructor}}
53 B2 b2; // expected-error {{deleted function}}
54 struct B3 {
55 B3();
56 DeletedDtor a[4]; // expected-note {{because field 'a' has a deleted destructor}}
58 B3 b3; // expected-error {{deleted function}}
59 struct B4 {
60 B4();
61 InaccessibleDtor a[4]; // expected-note {{because field 'a' has an inaccessible destructor}}
63 B4 b4; // expected-error {{deleted function}}
64 union B5 {
65 B5();
66 union { // expected-note-re {{because field 'B5::(anonymous union at {{.+}})' has a deleted destructor}}
67 DeletedDtor a; // expected-note {{because field 'a' has a deleted destructor}}
70 B5 b5; // expected-error {{deleted function}}
71 union B6 {
72 B6();
73 union { // expected-note-re {{because field 'B6::(anonymous union at {{.+}})' has a deleted destructor}}
74 InaccessibleDtor a; // expected-note {{because field 'a' has an inaccessible destructor}}
77 B6 b6; // expected-error {{deleted function}}
79 // -- any direct or virtual base class has a deleted or inaccessible destructor.
80 struct C1 : DeletedDtor { C1(); } c1; // expected-error {{deleted function}} expected-note {{base class 'DeletedDtor' has a deleted destructor}}
81 struct C2 : InaccessibleDtor { C2(); } c2; // expected-error {{deleted function}} expected-note {{base class 'InaccessibleDtor' has an inaccessible destructor}}
82 struct C3 : virtual DeletedDtor { C3(); } c3; // expected-error {{deleted function}} expected-note {{base class 'DeletedDtor' has a deleted destructor}}
83 struct C4 : virtual InaccessibleDtor { C4(); } c4; // expected-error {{deleted function}} expected-note {{base class 'InaccessibleDtor' has an inaccessible destructor}}
85 // -- for a virtual destructor, lookup of the non-array deallocation function
86 // results in an ambiguity or a function that is deleted or inaccessible.
87 class D1 {
88 void operator delete(void*); // expected-note {{here}}
89 public:
90 virtual ~D1() = default; // expected-note 2{{here}}
91 } d1; // ok
92 struct D2 : D1 { // expected-note 2{{virtual destructor requires an unambiguous, accessible 'operator delete'}} \
93 // expected-error {{deleted function '~D2' cannot override a non-deleted}}
94 // implicitly-virtual destructor
95 } d2; // expected-error {{deleted function}}
96 struct D3 { // expected-note {{virtual destructor requires an unambiguous, accessible 'operator delete'}}
97 virtual ~D3() = default; // expected-note {{explicitly defaulted function was implicitly deleted here}}
98 void operator delete(void*, double = 0.0);
99 void operator delete(void*, char = 0);
100 } d3; // expected-error {{deleted function}}
101 struct D4 { // expected-note {{virtual destructor requires an unambiguous, accessible 'operator delete'}}
102 virtual ~D4() = default; // expected-note {{implicitly deleted here}}
103 void operator delete(void*) = delete;
104 } d4; // expected-error {{deleted function}}
105 struct D5 : D1 {
106 ~D5(); // ok (but not definable)
107 } d5;
108 D5::~D5() {} // expected-error {{'operator delete' is a private member of 'D1'}}
109 struct D6 : D1 {
110 ~D6() = delete; // expected-error {{deleted function '~D6' cannot override a non-deleted}}