1 // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
5 NonTrivial(const NonTrivial&);
8 // A defaulted copy constructor for a class X is defined as deleted if X has:
10 // -- a variant member with a non-trivial corresponding constructor
11 union DeletedNTVariant {
12 NonTrivial NT; // expected-note{{copy constructor of 'DeletedNTVariant' is implicitly deleted because variant field 'NT' has a non-trivial copy constructor}}
16 DeletedNTVariant DVb(DVa); // expected-error{{call to implicitly-deleted copy constructor}}
18 struct DeletedNTVariant2 {
20 NonTrivial NT; // expected-note{{copy constructor of 'DeletedNTVariant2' is implicitly deleted because variant field 'NT' has a non-trivial copy constructor}}
24 DeletedNTVariant2 DV2a;
25 DeletedNTVariant2 DV2b(DV2a); // expected-error{{call to implicitly-deleted copy constructor}}
27 // -- a non-static data member of class type M (or array thereof) that cannot be
28 // copied because overload resolution results in an ambiguity or a function
29 // that is deleted or inaccessible
33 NoAccess(const NoAccess&);
35 friend struct HasAccess;
39 NoAccess NA; // expected-note{{copy constructor of 'HasNoAccess' is implicitly deleted because field 'NA' has an inaccessible copy constructor}}
42 HasNoAccess HNAb(HNAa); // expected-error{{call to implicitly-deleted copy constructor}}
55 Ambiguity(const Ambiguity&);
56 Ambiguity(volatile Ambiguity&);
61 Ambiguity A; // expected-note 2{{copy constructor of 'IsAmbiguous' is implicitly deleted because field 'A' has multiple copy constructors}}
65 IsAmbiguous IAb(IAa); // expected-error{{call to implicitly-deleted copy constructor}}
68 IsAmbiguous IA; // expected-note{{copy constructor of 'Deleted' is implicitly deleted because field 'IA' has a deleted copy constructor}}
71 Deleted Db(Da); // expected-error{{call to implicitly-deleted copy constructor}}
73 // It's implied (but not stated) that this also applies in the case where
74 // overload resolution would fail.
75 struct VolatileMember {
76 volatile Trivial vm; // expected-note {{has no copy}}
77 } vm1, vm2(vm1); // expected-error {{deleted}}
79 // -- a direct or virtual base class B that cannot be copied because overload
80 // resolution results in an ambiguity or a function that is deleted or
82 struct AmbiguousCopyBase : Ambiguity { // expected-note 2{{copy constructor of 'AmbiguousCopyBase' is implicitly deleted because base class 'Ambiguity' has multiple copy constructors}}
85 extern AmbiguousCopyBase ACBa;
86 AmbiguousCopyBase ACBb(ACBa); // expected-error {{deleted copy constructor}}
88 struct DeletedCopyBase : AmbiguousCopyBase {}; // expected-note {{copy constructor of 'DeletedCopyBase' is implicitly deleted because base class 'AmbiguousCopyBase' has a deleted copy constructor}}
89 extern DeletedCopyBase DCBa;
90 DeletedCopyBase DCBb(DCBa); // expected-error {{deleted copy constructor}}
92 struct InaccessibleCopyBase : NoAccess {}; // expected-note {{copy constructor of 'InaccessibleCopyBase' is implicitly deleted because base class 'NoAccess' has an inaccessible copy constructor}}
93 extern InaccessibleCopyBase ICBa;
94 InaccessibleCopyBase ICBb(ICBa); // expected-error {{deleted copy constructor}}
96 // -- any direct or virtual base class or non-static data member of a type with
97 // a destructor that is deleted or inaccessible
101 friend struct HasAccessDtor;
104 struct HasNoAccessDtor {
105 NoAccessDtor NAD; // expected-note{{copy constructor of 'HasNoAccessDtor' is implicitly deleted because field 'NAD' has an inaccessible destructor}}
109 HasNoAccessDtor HNADa;
110 HasNoAccessDtor HNADb(HNADa); // expected-error{{call to implicitly-deleted copy constructor}}
112 struct HasAccessDtor {
116 HasAccessDtor HADb(HADa);
118 struct HasNoAccessDtorBase : NoAccessDtor { // expected-note{{copy constructor of 'HasNoAccessDtorBase' is implicitly deleted because base class 'NoAccessDtor' has an inaccessible destructor}}
120 extern HasNoAccessDtorBase HNADBa;
121 HasNoAccessDtorBase HNADBb(HNADBa); // expected-error{{implicitly-deleted copy constructor}}
123 // -- a non-static data member of rvalue reference type
125 int && ri = 1; // expected-note{{copy constructor of 'RValue' is implicitly deleted because field 'ri' is of rvalue reference type 'int &&'}}
126 // expected-warning@-1{{binding reference member 'ri' to a temporary}} expected-note@-1 {{here}}
129 RValue RVb(RVa); // expected-error{{call to implicitly-deleted copy constructor}}
134 S(const volatile S&) = delete; // expected-note{{deleted here}}
137 volatile S s; // expected-note{{field 's' has a deleted copy constructor}}
140 T t = f(); // expected-error{{call to implicitly-deleted copy constructor}}