[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / SemaCXX / explicitly-defaulted.cpp
blob724f7bbbc30b63a37c262ee8f55feec58d58b82a
1 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
3 struct Deleted {
4 Deleted() = delete; // expected-note 3{{marked deleted here}}
5 Deleted(const Deleted &) = delete; // expected-note 2{{marked deleted here}}
6 Deleted(Deleted &&) = delete; // expected-note 2{{marked deleted here}}
7 Deleted &operator=(const Deleted &) = delete; // expected-note 2{{marked deleted here}}
8 Deleted &operator=(Deleted &&) = delete; // expected-note 2{{marked deleted here}}
9 ~Deleted() = delete; // expected-note 2{{marked deleted here}}
12 struct Derive : Deleted { // expected-note 6{{because base class}}
13 Derive() = default; // expected-warning{{explicitly defaulted}} expected-note{{replace 'default' with 'delete'}}
14 Derive(const Derive &) = default; // expected-warning{{explicitly defaulted}} expected-note{{replace 'default' with 'delete'}}
15 Derive(Derive &&) = default; // expected-warning{{explicitly defaulted}} expected-note{{replace 'default' with 'delete'}}
16 Derive &operator=(const Derive &) = default; // expected-warning{{explicitly defaulted}} expected-note{{replace 'default' with 'delete'}}
17 Derive &operator=(Derive &&) = default; // expected-warning{{explicitly defaulted}} expected-note{{replace 'default' with 'delete'}}
18 ~Derive() = default; // expected-warning{{explicitly defaulted}} expected-note{{replace 'default' with 'delete'}}
21 struct Member {
22 Deleted A; // expected-note 6{{because field 'A'}}
23 Member() = default; // expected-warning{{explicitly defaulted}} expected-note{{replace 'default' with 'delete'}}
24 Member(const Member &) = default; // expected-warning{{explicitly defaulted}} expected-note{{replace 'default' with 'delete'}}
25 Member(Member &&) = default; // expected-warning{{explicitly defaulted}} expected-note{{replace 'default' with 'delete'}}
26 Member &operator=(const Member &) = default; // expected-warning{{explicitly defaulted}} expected-note{{replace 'default' with 'delete'}}
27 Member &operator=(Member &&) = default; // expected-warning{{explicitly defaulted}} expected-note{{replace 'default' with 'delete'}}
28 ~Member() = default; // expected-warning{{explicitly defaulted}} expected-note{{replace 'default' with 'delete'}}
31 template<typename T>
32 struct TDerive : T { // expected-note {{because base class}}
33 TDerive() = default; //expected-note {{explicitly defaulted}} // Don't expect a fix note to be emitted
36 using ShouldDelete = TDerive<Deleted>;
38 ShouldDelete A; // expected-error{{call to implicitly-deleted}}