Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CXX / class / class.dtor / p4.cpp
blob854d14c3c3c28295e37037434a9e11a902a8d8e9
1 // RUN: %clang_cc1 -std=c++20 -verify %s
3 template <int N>
4 struct A {
5 ~A() = delete; // expected-note {{explicitly marked deleted}}
6 ~A() requires(N == 1) = delete; // expected-note {{explicitly marked deleted}}
7 };
9 // FIXME: We should probably make it illegal to mix virtual and non-virtual methods
10 // this way. See CWG2488 and some discussion in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105699.
11 template <int N>
12 struct B {
13 ~B() requires(N == 1) = delete; // expected-note {{explicitly marked deleted}}
14 virtual ~B() = delete; // expected-note {{explicitly marked deleted}}
17 template <int N>
18 concept CO1 = N == 1;
20 template <int N>
21 concept CO2 = N >
24 template <int N>
25 struct C {
26 ~C() = delete; // expected-note {{explicitly marked deleted}}
27 ~C() requires(CO1<N>) = delete;
28 ~C() requires(CO1<N> &&CO2<N>) = delete; // expected-note {{explicitly marked deleted}}
31 template <int N>
32 struct D {
33 ~D() requires(N != 0) = delete; // expected-note {{explicitly marked deleted}}
34 // expected-note@-1 {{candidate function has been explicitly deleted}}
35 // expected-note@-2 {{candidate function not viable: constraints not satisfied}}
36 // expected-note@-3 {{evaluated to false}}
37 ~D() requires(N == 1) = delete;
38 // expected-note@-1 {{candidate function has been explicitly deleted}}
39 // expected-note@-2 {{candidate function not viable: constraints not satisfied}}
40 // expected-note@-3 {{evaluated to false}}
43 template <class T>
44 concept Foo = requires(T t) {
45 {t.foo()};
48 template <int N>
49 struct E {
50 void foo();
51 ~E();
52 ~E() requires Foo<E> = delete; // expected-note {{explicitly marked deleted}}
55 template struct A<1>;
56 template struct A<2>;
57 template struct B<1>;
58 template struct B<2>;
59 template struct C<1>;
60 template struct C<2>;
61 template struct D<0>; // expected-error {{no viable destructor found for class 'D<0>'}} expected-note {{in instantiation of template}}
62 template struct D<1>; // expected-error {{destructor of class 'D<1>' is ambiguous}} expected-note {{in instantiation of template}}
63 template struct D<2>;
64 template struct E<1>;
66 int main() {
67 A<1> a1; // expected-error {{attempt to use a deleted function}}
68 A<2> a2; // expected-error {{attempt to use a deleted function}}
69 B<1> b1; // expected-error {{attempt to use a deleted function}}
70 B<2> b2; // expected-error {{attempt to use a deleted function}}
71 C<1> c1; // expected-error {{attempt to use a deleted function}}
72 C<2> c2; // expected-error {{attempt to use a deleted function}}
73 D<0> d0;
74 D<1> d1;
75 D<2> d2; // expected-error {{attempt to use a deleted function}}
76 E<1> e1; // expected-error {{attempt to use a deleted function}}