1 // RUN: %clang_cc1 -std=c++2c -fsyntax-only -verify %s
4 void f() = delete("deleted (1)"); // expected-note {{explicitly marked deleted}}
7 T
g() = delete("deleted (2)"); // expected-note {{explicitly deleted}}
12 T
f() = delete("deleted (3)"); // expected-note {{explicitly marked deleted}}
15 T
g(U
) = delete("deleted (4)"); // expected-note {{explicitly deleted}}
18 void f() = delete("deleted (5)"); // expected-note {{explicitly deleted}}
21 T
g() = delete("deleted (6)"); // expected-note {{explicitly deleted}}
23 template <typename T
, typename U
>
25 T
f() = delete("deleted (7)"); // expected-note 2 {{explicitly marked deleted}}
30 T
f() = delete("deleted (8)"); // expected-note {{explicitly marked deleted}}
34 struct TSp
<int, int> {
35 int f() = delete("deleted (9)"); // expected-note {{explicitly marked deleted}}
38 void u1() = delete(L
"\xFFFFFFFF"); // expected-error {{an unevaluated string literal cannot have an encoding prefix}} \
39 // expected-error {{invalid escape sequence '\xFFFFFFFF' in an unevaluated string literal}}
40 void u2() = delete(u
"\U000317FF"); // expected-error {{an unevaluated string literal cannot have an encoding prefix}}
42 void u3() = delete("Ω"); // expected-note {{explicitly deleted}}
43 void u4() = delete("\u1234"); // expected-note {{explicitly deleted}}
45 void u5() = delete("\x1ff" // expected-error {{hex escape sequence out of range}} \
46 // expected-error {{invalid escape sequence '\x1ff' in an unevaluated string literal}}
47 "0\x123" // expected-error {{invalid escape sequence '\x123' in an unevaluated string literal}}
48 "fx\xfffff" // expected-error {{invalid escape sequence '\xfffff' in an unevaluated string literal}}
51 void u6() = delete("\'\"\?\\\a\b\f\n\r\t\v"); // expected-note {{explicitly deleted}}
52 void u7() = delete("\xFF"); // expected-error {{invalid escape sequence '\xFF' in an unevaluated string literal}}
53 void u8() = delete("\123"); // expected-error {{invalid escape sequence '\123' in an unevaluated string literal}}
54 void u9() = delete("\pOh no, a Pascal string!"); // expected-warning {{unknown escape sequence '\p'}} \
55 // expected-error {{invalid escape sequence '\p' in an unevaluated string literal}}
56 // expected-note@+1 {{explicitly deleted}}
57 void u10() = delete(R
"(a
62 void u11() = delete("\u0080\u0081\u0082\u0083\u0099\u009A\u009B\u009C\u009D\u009E\u009F"); // expected-note {{explicitly deleted}}
65 //! Contains RTL/LTR marks
66 void u12() = delete("\u200Eabc\u200Fdef\u200Fgh"); // expected-note {{explicitly deleted}}
68 //! Contains ZWJ/regional indicators
69 void u13() = delete("🏳️🌈 🏴 🇪🇺"); // expected-note {{explicitly deleted}}
72 S
{}.f(); // expected-error {{attempt to use a deleted function: deleted (1)}}
73 S
{}.g
<int>(); // expected-error {{call to deleted member function 'g': deleted (2)}}
74 TS
<int>{}.f(); // expected-error {{attempt to use a deleted function: deleted (3)}}
75 TS
<int>{}.g
<int>(0); // expected-error {{call to deleted member function 'g': deleted (4)}}
76 f(); // expected-error {{call to deleted function 'f': deleted (5)}}
77 g
<int>(); // expected-error {{call to deleted function 'g': deleted (6)}}
78 TSp
<double, double>{}.f(); // expected-error {{attempt to use a deleted function: deleted (7)}}
79 TSp
<int, double>{}.f(); // expected-error {{attempt to use a deleted function: deleted (7)}}
80 TSp
<double, int>{}.f(); // expected-error {{attempt to use a deleted function: deleted (8)}}
81 TSp
<int, int>{}.f(); // expected-error {{attempt to use a deleted function: deleted (9)}}
82 u3(); // expected-error {{call to deleted function 'u3': Ω}}
83 u4(); // expected-error {{call to deleted function 'u4': ሴ}}
84 u6(); // expected-error {{call to deleted function 'u6': '"?\<U+0007><U+0008>}}
85 u10(); // expected-error {{call to deleted function 'u10': a\n\tb\nc\n}}
86 u11(); // expected-error {{call to deleted function 'u11': <U+0080><U+0081><U+0082><U+0083><U+0099><U+009A><U+009B><U+009C><U+009D><U+009E><U+009F>}}
87 u12(); // expected-error {{call to deleted function 'u12': abcdefgh}}
88 u13(); // expected-error {{call to deleted function 'u13': 🏳️🌈 🏴 🇪🇺}}
92 C() = delete("deleted (C, Constructor)"); // expected-note {{explicitly marked deleted}}
93 C(int) = delete("deleted (C, C(int))"); // expected-note {{explicitly marked deleted}}
94 C(const C
&) = delete("deleted (C, Copy Constructor)"); // expected-note {{explicitly marked deleted}}
95 C(C
&&) = delete("deleted (C, Move Constructor)"); // expected-note {{explicitly marked deleted}}
96 C
& operator=(const C
&) = delete("deleted (C, Copy Assignment)"); // expected-note 2 {{explicitly deleted}}
97 C
& operator=(C
&&) = delete("deleted (C, Move Assignment)"); // expected-note {{explicitly deleted}} expected-note {{not viable}}
98 ~C() = delete("deleted (C, Destructor)"); // expected-note {{explicitly marked deleted}}
99 void* operator new(__SIZE_TYPE__
) = delete("deleted (C, New)"); // expected-note {{explicitly deleted}}
100 void operator delete(void*) = delete("deleted (C, Delete)"); // expected-note {{explicitly marked deleted}}
103 template <typename T
, typename U
>
105 TC() = delete("deleted (TC, Constructor)"); // expected-note {{explicitly marked deleted}}
106 TC(int) = delete("deleted (TC, TC(int))"); // expected-note {{explicitly marked deleted}}
107 TC(const TC
&) = delete("deleted (TC, Copy Constructor)"); // expected-note {{explicitly marked deleted}}
108 TC(TC
&&) = delete("deleted (TC, Move Constructor)"); // expected-note {{explicitly marked deleted}}
109 TC
& operator=(const TC
&) = delete("deleted (TC, Copy Assignment)"); // expected-note 2 {{explicitly deleted}}
110 TC
& operator=(TC
&&) = delete("deleted (TC, Move Assignment)"); // expected-note {{explicitly deleted}} expected-note {{not viable}}
111 ~TC() = delete("deleted (TC, Destructor)"); // expected-note {{explicitly marked deleted}}
112 void* operator new(__SIZE_TYPE__
) = delete("deleted (TC, New)"); // expected-note {{explicitly deleted}}
113 void operator delete(void*) = delete("deleted (TC, Delete)"); // expected-note {{explicitly marked deleted}}
116 template <typename T
>
118 TC() = delete("deleted (TC<T, int>, Constructor)"); // expected-note {{explicitly marked deleted}}
119 TC(int) = delete("deleted (TC<T, int>, TC(int))"); // expected-note {{explicitly marked deleted}}
120 TC(const TC
&) = delete("deleted (TC<T, int>, Copy Constructor)"); // expected-note {{explicitly marked deleted}}
121 TC(TC
&&) = delete("deleted (TC<T, int>, Move Constructor)"); // expected-note {{explicitly marked deleted}}
122 TC
& operator=(const TC
&) = delete("deleted (TC<T, int>, Copy Assignment)"); // expected-note 2 {{explicitly deleted}}
123 TC
& operator=(TC
&&) = delete("deleted (TC<T, int>, Move Assignment)"); // expected-note {{explicitly deleted}} expected-note {{not viable}}
124 ~TC() = delete("deleted (TC<T, int>, Destructor)"); // expected-note {{explicitly marked deleted}}
125 void* operator new(__SIZE_TYPE__
) = delete("deleted (TC<T, int>, New)"); // expected-note {{explicitly deleted}}
126 void operator delete(void*) = delete("deleted (TC<T, int>, Delete)"); // expected-note {{explicitly marked deleted}}
130 struct TC
<int, int> {
131 TC() = delete("deleted (TC<int, int>, Constructor)"); // expected-note {{explicitly marked deleted}}
132 TC(int) = delete("deleted (TC<int, int>, TC(int))"); // expected-note {{explicitly marked deleted}}
133 TC(const TC
&) = delete("deleted (TC<int, int>, Copy Constructor)"); // expected-note {{explicitly marked deleted}}
134 TC(TC
&&) = delete("deleted (TC<int, int>, Move Constructor)"); // expected-note {{explicitly marked deleted}}
135 TC
& operator=(const TC
&) = delete("deleted (TC<int, int>, Copy Assignment)"); // expected-note 2 {{explicitly deleted}}
136 TC
& operator=(TC
&&) = delete("deleted (TC<int, int>, Move Assignment)"); // expected-note {{explicitly deleted}} expected-note {{not viable}}
137 ~TC() = delete("deleted (TC<int, int>, Destructor)"); // expected-note {{explicitly marked deleted}}
138 void* operator new(__SIZE_TYPE__
) = delete("deleted (TC<int, int>, New)"); // expected-note {{explicitly deleted}}
139 void operator delete(void*) = delete("deleted (TC<int, int>, Delete)"); // expected-note {{explicitly marked deleted}}
142 void special_members(
145 TC
<double, double>& tc1
,
146 TC
<double, double>& tc2
,
147 TC
<double, int>& tc_int1
,
148 TC
<double, int>& tc_int2
,
149 TC
<int, int>& tc_int_int1
,
150 TC
<int, int>& tc_int_int2
152 C
{}; // expected-error {{call to deleted constructor of 'C': deleted (C, Constructor)}}
153 C
{c1
}; // expected-error {{call to deleted constructor of 'C': deleted (C, Copy Constructor)}}
154 C
{static_cast<C
&&>(c1
)}; // expected-error {{call to deleted constructor of 'C': deleted (C, Move Constructor)}}
155 c1
= c2
; // expected-error {{overload resolution selected deleted operator '=': deleted (C, Copy Assignment)}}
156 c1
= static_cast<C
&&>(c2
); // expected-error {{overload resolution selected deleted operator '=': deleted (C, Move Assignment)}}
157 c1
.~C(); // expected-error {{attempt to use a deleted function: deleted (C, Destructor)}}
158 new C
{}; // expected-error {{call to deleted function 'operator new': deleted (C, New)}}
159 delete &c2
; // expected-error {{attempt to use a deleted function: deleted (C, Delete)}}
161 TC
<double, double>{}; // expected-error {{call to deleted constructor of 'TC<double, double>': deleted (TC, Constructor)}}
162 TC
<double, double>{tc1
}; // expected-error {{call to deleted constructor of 'TC<double, double>': deleted (TC, Copy Constructor)}}
163 TC
<double, double>{static_cast<TC
<double, double>&&>(tc1
)}; // expected-error {{call to deleted constructor of 'TC<double, double>': deleted (TC, Move Constructor)}}
164 tc1
= tc2
; // expected-error {{overload resolution selected deleted operator '=': deleted (TC, Copy Assignment)}}
165 tc1
= static_cast<TC
<double, double>&&>(tc2
); // expected-error {{overload resolution selected deleted operator '=': deleted (TC, Move Assignment)}}
166 tc1
.~TC(); // expected-error {{attempt to use a deleted function: deleted (TC, Destructor)}}
167 new TC
<double, double>{}; // expected-error {{call to deleted function 'operator new': deleted (TC, New)}}
168 delete &tc2
; // expected-error {{attempt to use a deleted function: deleted (TC, Delete)}}
170 TC
<double, int>{}; // expected-error {{call to deleted constructor of 'TC<double, int>': deleted (TC<T, int>, Constructor)}}
171 TC
<double, int>{tc_int1
}; // expected-error {{call to deleted constructor of 'TC<double, int>': deleted (TC<T, int>, Copy Constructor)}}
172 TC
<double, int>{static_cast<TC
<double, int>&&>(tc_int1
)}; // expected-error {{call to deleted constructor of 'TC<double, int>': deleted (TC<T, int>, Move Constructor)}}
173 tc_int1
= tc_int2
; // expected-error {{overload resolution selected deleted operator '=': deleted (TC<T, int>, Copy Assignment)}}
174 tc_int1
= static_cast<TC
<double, int>&&>(tc_int2
); // expected-error {{overload resolution selected deleted operator '=': deleted (TC<T, int>, Move Assignment)}}
175 tc_int1
.~TC(); // expected-error {{attempt to use a deleted function: deleted (TC<T, int>, Destructor)}}
176 new TC
<double, int>{}; // expected-error {{call to deleted function 'operator new': deleted (TC<T, int>, New)}}
177 delete &tc_int2
; // expected-error {{attempt to use a deleted function: deleted (TC<T, int>, Delete)}}
179 TC
<int, int>{}; // expected-error {{call to deleted constructor of 'TC<int, int>': deleted (TC<int, int>, Constructor)}}
180 TC
<int, int>{tc_int_int1
}; // expected-error {{call to deleted constructor of 'TC<int, int>': deleted (TC<int, int>, Copy Constructor)}}
181 TC
<int, int>{static_cast<TC
<int, int>&&>(tc_int_int1
)}; // expected-error {{call to deleted constructor of 'TC<int, int>': deleted (TC<int, int>, Move Constructor)}}
182 tc_int_int1
= tc_int_int2
; // expected-error {{overload resolution selected deleted operator '=': deleted (TC<int, int>, Copy Assignment)}}
183 tc_int_int1
= static_cast<TC
<int, int>&&>(tc_int_int2
); // expected-error {{overload resolution selected deleted operator '=': deleted (TC<int, int>, Move Assignment)}}
184 tc_int_int1
.~TC(); // expected-error {{attempt to use a deleted function: deleted (TC<int, int>, Destructor)}}
185 new TC
<int, int>{}; // expected-error {{call to deleted function 'operator new': deleted (TC<int, int>, New)}}
186 delete &tc_int_int2
; // expected-error {{attempt to use a deleted function: deleted (TC<int, int>, Delete)}}
189 C
conv1() { return 1; } // expected-error {{conversion function from 'int' to 'C' invokes a deleted function: deleted (C, C(int))}}
190 TC
<double, double> conv2() { return 1; } // expected-error {{conversion function from 'int' to 'TC<double, double>' invokes a deleted function: deleted (TC, TC(int))}}
191 TC
<double, int> conv3() { return 1; } // expected-error {{conversion function from 'int' to 'TC<double, int>' invokes a deleted function: deleted (TC<T, int>, TC(int))}}
192 TC
<int, int> conv4() { return 1; } // expected-error {{conversion function from 'int' to 'TC<int, int>' invokes a deleted function: deleted (TC<int, int>, TC(int))}}
196 int operator+() = delete("deleted (O, +)"); // expected-note {{explicitly deleted}}
197 O
* operator->() = delete("deleted (O, ->)"); // expected-note {{explicitly deleted}}
198 int operator-(O
) = delete("deleted (O, -)"); // expected-note {{explicitly deleted}}
199 int operator[](O
) = delete("deleted (O, [])"); // expected-note {{explicitly deleted}}
200 int operator()(O
) = delete("deleted (O, ())"); // expected-note {{explicitly marked deleted}} expected-note {{explicitly deleted}}
201 explicit operator bool() = delete("deleted (O, operator bool)"); // expected-note {{explicitly marked deleted}} expected-note {{explicitly deleted}}
204 template <typename T
, typename U
>
207 T
operator+() = delete("deleted (TO, +)"); // expected-note {{explicitly deleted}}
208 T
* operator->() = delete("deleted (TO, ->)"); // expected-note {{explicitly deleted}}
209 T
operator-(TO
) = delete("deleted (TO, -)"); // expected-note {{explicitly deleted}}
210 T
operator[](TO
) = delete("deleted (TO, [])"); // expected-note {{explicitly deleted}}
211 T
operator()(TO
) = delete("deleted (TO, ())"); // expected-note {{explicitly marked deleted}} expected-note {{explicitly deleted}}
212 explicit operator bool() = delete("deleted (TO, operator bool)"); // expected-note {{explicitly marked deleted}} expected-note {{explicitly deleted}}
215 template <typename T
>
218 T
operator+() = delete("deleted (TO<T, int>, +)"); // expected-note {{explicitly deleted}}
219 T
* operator->() = delete("deleted (TO<T, int>, ->)"); // expected-note {{explicitly deleted}}
220 T
operator-(TO
) = delete("deleted (TO<T, int>, -)"); // expected-note {{explicitly deleted}}
221 T
operator[](TO
) = delete("deleted (TO<T, int>, [])"); // expected-note {{explicitly deleted}}
222 T
operator()(TO
) = delete("deleted (TO<T, int>, ())"); // expected-note {{explicitly marked deleted}} expected-note {{explicitly deleted}}
223 explicit operator bool() = delete("deleted (TO<T, int>, operator bool)"); // expected-note {{explicitly marked deleted}} expected-note {{explicitly deleted}}
227 struct TO
<int, int> {
229 int operator+() = delete("deleted (TO<int, int>, +)"); // expected-note {{explicitly deleted}}
230 int* operator->() = delete("deleted (TO<int, int>, ->)"); // expected-note {{explicitly deleted}}
231 int operator-(TO
) = delete("deleted (TO<int, int>, -)"); // expected-note {{explicitly deleted}}
232 int operator[](TO
) = delete("deleted (TO<int, int>, [])"); // expected-note {{explicitly deleted}}
233 int operator()(TO
) = delete("deleted (TO<int, int>, ())"); // expected-note {{explicitly marked deleted}} expected-note {{explicitly deleted}}
234 explicit operator bool() = delete("deleted (TO<int, int>, operator bool)"); // expected-note {{explicitly marked deleted}} expected-note {{explicitly deleted}}
239 +o
; // expected-error {{overload resolution selected deleted operator '+': deleted (O, +)}}
240 o
->x
; // expected-error {{overload resolution selected deleted operator '->': deleted (O, ->)}}
241 o
- o
; // expected-error {{overload resolution selected deleted operator '-': deleted (O, -)}}
242 o
[o
]; // expected-error {{overload resolution selected deleted operator '[]': deleted (O, [])}}
243 o(o
); // expected-error {{call to deleted function call operator in type 'O': deleted (O, ())}} expected-error {{attempt to use a deleted function: deleted (O, ())}}
244 if (o
) {} // expected-error {{attempt to use a deleted function: deleted (O, operator bool)}}
245 static_cast<bool>(o
); // expected-error {{static_cast from 'O' to 'bool' uses deleted function: deleted (O, operator bool)}}
247 TO
<double, double> to
;
248 +to
; // expected-error {{overload resolution selected deleted operator '+': deleted (TO, +)}}
249 to
->x
; // expected-error {{overload resolution selected deleted operator '->': deleted (TO, ->)}}
250 to
- to
; // expected-error {{overload resolution selected deleted operator '-': deleted (TO, -)}}
251 to
[to
]; // expected-error {{overload resolution selected deleted operator '[]': deleted (TO, [])}}
252 to(to
); // expected-error {{call to deleted function call operator in type 'TO<double, double>': deleted (TO, ())}} expected-error {{attempt to use a deleted function: deleted (TO, ())}}
253 if (to
) {} // expected-error {{attempt to use a deleted function: deleted (TO, operator bool)}}
254 static_cast<bool>(to
); // expected-error {{static_cast from 'TO<double, double>' to 'bool' uses deleted function: deleted (TO, operator bool)}}
256 TO
<double, int> to_int
;
257 +to_int
; // expected-error {{overload resolution selected deleted operator '+': deleted (TO<T, int>, +)}}
258 to_int
->x
; // expected-error {{overload resolution selected deleted operator '->': deleted (TO<T, int>, ->)}}
259 to_int
- to_int
; // expected-error {{overload resolution selected deleted operator '-': deleted (TO<T, int>, -)}}
260 to_int
[to_int
]; // expected-error {{overload resolution selected deleted operator '[]': deleted (TO<T, int>, [])}}
261 to_int(to_int
); // expected-error {{call to deleted function call operator in type 'TO<double, int>': deleted (TO<T, int>, ())}} expected-error {{attempt to use a deleted function: deleted (TO<T, int>, ())}}
262 if (to_int
) {} // expected-error {{attempt to use a deleted function: deleted (TO<T, int>, operator bool)}}
263 static_cast<bool>(to_int
); // expected-error {{static_cast from 'TO<double, int>' to 'bool' uses deleted function: deleted (TO<T, int>, operator bool)}}
265 TO
<int, int> to_int_int
;
266 +to_int_int
; // expected-error {{overload resolution selected deleted operator '+': deleted (TO<int, int>, +)}}
267 to_int_int
->x
; // expected-error {{overload resolution selected deleted operator '->': deleted (TO<int, int>, ->)}}
268 to_int_int
- to_int_int
; // expected-error {{overload resolution selected deleted operator '-': deleted (TO<int, int>, -)}}
269 to_int_int
[to_int_int
]; // expected-error {{overload resolution selected deleted operator '[]': deleted (TO<int, int>, [])}}
270 to_int_int(to_int_int
); // expected-error {{call to deleted function call operator in type 'TO<int, int>': deleted (TO<int, int>, ())}} expected-error {{attempt to use a deleted function: deleted (TO<int, int>, ())}}
271 if (to_int_int
) {} // expected-error {{attempt to use a deleted function: deleted (TO<int, int>, operator bool)}}
272 static_cast<bool>(to_int_int
); // expected-error {{static_cast from 'TO<int, int>' to 'bool' uses deleted function: deleted (TO<int, int>, operator bool)}}