brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.3 KiB · d2d5ccf Raw
62 lines · cpp
1// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify=expected,pre26 %s2// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify=expected,pre26-pedantic -pedantic %s3// RUN: %clang_cc1 -std=c++2c -fsyntax-only -verify=expected,compat -Wpre-c++26-compat %s4// RUN: %clang_cc1 -std=c++2c -fsyntax-only -verify %s5 6struct S {7  void a() = delete;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}}13 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}}20};21 22struct T {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}}29};30 31void a() = delete;32void b() = delete(; // expected-error {{expected string literal}} expected-error {{expected ')'}} expected-note {{to match this '('}}33void c() = delete(); // expected-error {{expected string literal}}34void d() = delete(42); // expected-error {{expected string literal}}35void 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}}36void 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}}37 38constexpr const char *getMsg() { return "this is a message"; }39void func() = delete(getMsg()); // expected-error {{expected string literal}}40 41namespace CWG2876 {42using T = void ();43using U = int;44 45T a = delete ("hello"); // expected-error {{only functions can have deleted definitions}}46U b = delete ("hello"), c, d = delete ("hello"); // expected-error 2 {{only functions can have deleted definitions}}47 48struct C {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]'}}51};52}53 54namespace GH109311 {55void f() = delete56#if __cpp_deleted_function >= 202403L57    ("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}}59#endif60;61}62