1 // RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify=expected,pre26 %s
2 // RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify=expected,pre26-pedantic -pedantic %s
3 // RUN: %clang_cc1 -std=c++2c -fsyntax-only -verify=expected,compat -Wpre-c++26-compat %s
4 // RUN: %clang_cc1 -std=c++2c -fsyntax-only -verify %s
8 void b() = delete(; // expected-error {{expected string literal}} expected-error {{expected ')'}} expected-note {{to match this '('}}
9 void c() = delete(); // expected-error {{expected string literal}}
10 void d() = delete(42); // expected-error {{expected string literal}}
11 void e() = delete("foo"[0]); // expected-error {{expected ')'}} expected-note {{to match this '('}} // pre26-pedantic-warning {{'= delete' with a message is a C++2c extension}} compat-warning {{'= delete' with a message is incompatible with C++ standards before C++2c}}
12 void f() = delete("foo"); // pre26-pedantic-warning {{'= delete' with a message is a C++2c extension}} compat-warning {{'= delete' with a message is incompatible with C++ standards before C++2c}}
14 S() = delete("foo"); // pre26-pedantic-warning {{'= delete' with a message is a C++2c extension}} compat-warning {{'= delete' with a message is incompatible with C++ standards before C++2c}}
15 ~S() = delete("foo"); // pre26-pedantic-warning {{'= delete' with a message is a C++2c extension}} compat-warning {{'= delete' with a message is incompatible with C++ standards before C++2c}}
16 S(const S
&) = delete("foo"); // pre26-pedantic-warning {{'= delete' with a message is a C++2c extension}} compat-warning {{'= delete' with a message is incompatible with C++ standards before C++2c}}
17 S(S
&&) = delete("foo"); // pre26-pedantic-warning {{'= delete' with a message is a C++2c extension}} compat-warning {{'= delete' with a message is incompatible with C++ standards before C++2c}}
18 S
& operator=(const S
&) = delete("foo"); // pre26-pedantic-warning {{'= delete' with a message is a C++2c extension}} compat-warning {{'= delete' with a message is incompatible with C++ standards before C++2c}}
19 S
& operator=(S
&&) = delete("foo"); // pre26-pedantic-warning {{'= delete' with a message is a C++2c extension}} compat-warning {{'= delete' with a message is incompatible with C++ standards before C++2c}}
23 T() = delete(); // expected-error {{expected string literal}}
24 ~T() = delete(); // expected-error {{expected string literal}}
25 T(const T
&) = delete(); // expected-error {{expected string literal}}
26 T(T
&&) = delete(); // expected-error {{expected string literal}}
27 T
& operator=(const T
&) = delete(); // expected-error {{expected string literal}}
28 T
& operator=(T
&&) = delete(); // expected-error {{expected string literal}}
32 void b() = delete(; // expected-error {{expected string literal}} expected-error {{expected ')'}} expected-note {{to match this '('}}
33 void c() = delete(); // expected-error {{expected string literal}}
34 void d() = delete(42); // expected-error {{expected string literal}}
35 void e() = delete("foo"[0]); // expected-error {{expected ')'}} expected-note {{to match this '('}} // pre26-pedantic-warning {{'= delete' with a message is a C++2c extension}} compat-warning {{'= delete' with a message is incompatible with C++ standards before C++2c}}
36 void f() = delete("foo"); // pre26-pedantic-warning {{'= delete' with a message is a C++2c extension}} compat-warning {{'= delete' with a message is incompatible with C++ standards before C++2c}}
38 constexpr const char *getMsg() { return "this is a message"; }
39 void func() = delete(getMsg()); // expected-error {{expected string literal}}
45 T a
= delete ("hello"); // expected-error {{only functions can have deleted definitions}}
46 U b
= delete ("hello"), c
, d
= delete ("hello"); // expected-error 2 {{only functions can have deleted definitions}}
49 T e
= delete ("hello"); // expected-error {{'= delete' is a function definition and must occur in a standalone declaration}}
50 U f
= delete ("hello"); // expected-error {{cannot delete expression of type 'const char[6]'}}
56 #if __cpp_deleted_function >= 202403L
57 ("reason") // pre26-pedantic-warning {{'= delete' with a message is a C++2c extension}} \
58 // compat-warning {{'= delete' with a message is incompatible with C++ standards before C++2}}