https://github.com/a-tarasyuk updated https://github.com/llvm/llvm-project/pull/114713
>From c07fa270194eadde3ccecab368b2225702fc2e63 Mon Sep 17 00:00:00 2001 From: Oleksandr T <oleksandr.taras...@outlook.com> Date: Sun, 3 Nov 2024 19:22:56 +0200 Subject: [PATCH 1/2] [Clang] update reasoned delete diagnostic kind to use Extension, making it pedantic only --- clang/docs/ReleaseNotes.rst | 2 ++ clang/include/clang/Basic/DiagnosticParseKinds.td | 2 +- clang/test/Parser/cxx2c-delete-with-message.cpp | 13 ++++++++++++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 1372e49dfac03c..3db2aa472902bc 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -464,6 +464,8 @@ Improvements to Clang's diagnostics - Clang now diagnoses ``[[deprecated]]`` attribute usage on local variables (#GH90073). +- Clang now diagnoses misused reasoned ``delete("reason")`` warnings only in pedantic mode. (#GH109311). + Improvements to Clang's time-trace ---------------------------------- diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td b/clang/include/clang/Basic/DiagnosticParseKinds.td index 78510e61a639fa..6fbe874c5e6425 100644 --- a/clang/include/clang/Basic/DiagnosticParseKinds.td +++ b/clang/include/clang/Basic/DiagnosticParseKinds.td @@ -971,7 +971,7 @@ def warn_cxx98_compat_defaulted_deleted_function : Warning< "%select{defaulted|deleted}0 function definitions are incompatible with C++98">, InGroup<CXX98Compat>, DefaultIgnore; -def ext_delete_with_message : ExtWarn< +def ext_delete_with_message : Extension< "'= delete' with a message is a C++2c extension">, InGroup<CXX26>; def warn_cxx23_delete_with_message : Warning< "'= delete' with a message is incompatible with C++ standards before C++2c">, diff --git a/clang/test/Parser/cxx2c-delete-with-message.cpp b/clang/test/Parser/cxx2c-delete-with-message.cpp index 1767a080a7dcd8..5796c548632ae4 100644 --- a/clang/test/Parser/cxx2c-delete-with-message.cpp +++ b/clang/test/Parser/cxx2c-delete-with-message.cpp @@ -1,7 +1,17 @@ -// RUN: %clang_cc1 -std=c++23 -fsyntax-only -verify=expected,pre26 -pedantic %s +// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify=expected -DTEST_NON_PEDANTIC %s +// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify=expected,pre26 -pedantic %s // RUN: %clang_cc1 -std=c++2c -fsyntax-only -verify=expected,compat -Wpre-c++26-compat %s // RUN: %clang_cc1 -std=c++2c -fsyntax-only -verify %s +#ifdef DTEST_NON_PEDANTIC +namespace GH109311 { +void f() = delete +#if __cpp_deleted_function >= 202403L + ("reason") // ok +#endif +; +} +#else struct S { void a() = delete; void b() = delete(; // expected-error {{expected string literal}} expected-error {{expected ')'}} expected-note {{to match this '('}} @@ -49,3 +59,4 @@ struct C { U f = delete ("hello"); // expected-error {{cannot delete expression of type 'const char[6]'}} }; } +#endif \ No newline at end of file >From ea607a92cec49141deb768d80fb890bea942c24f Mon Sep 17 00:00:00 2001 From: Oleksandr T <oleksandr.taras...@outlook.com> Date: Mon, 4 Nov 2024 19:27:58 +0200 Subject: [PATCH 2/2] update tests/release notes --- clang/docs/ReleaseNotes.rst | 2 +- .../test/Parser/cxx2c-delete-with-message.cpp | 45 +++++++++---------- 2 files changed, 23 insertions(+), 24 deletions(-) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 3db2aa472902bc..4f5e4e647bd6e5 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -464,7 +464,7 @@ Improvements to Clang's diagnostics - Clang now diagnoses ``[[deprecated]]`` attribute usage on local variables (#GH90073). -- Clang now diagnoses misused reasoned ``delete("reason")`` warnings only in pedantic mode. (#GH109311). +- Clang now diagnoses ``= delete("reason")`` extension warnings only in pedantic mode rather than on by default. (#GH109311). Improvements to Clang's time-trace ---------------------------------- diff --git a/clang/test/Parser/cxx2c-delete-with-message.cpp b/clang/test/Parser/cxx2c-delete-with-message.cpp index 5796c548632ae4..d2d5ccf4623c9c 100644 --- a/clang/test/Parser/cxx2c-delete-with-message.cpp +++ b/clang/test/Parser/cxx2c-delete-with-message.cpp @@ -1,31 +1,22 @@ -// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify=expected -DTEST_NON_PEDANTIC %s -// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify=expected,pre26 -pedantic %s +// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify=expected,pre26 %s +// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify=expected,pre26-pedantic -pedantic %s // RUN: %clang_cc1 -std=c++2c -fsyntax-only -verify=expected,compat -Wpre-c++26-compat %s // RUN: %clang_cc1 -std=c++2c -fsyntax-only -verify %s -#ifdef DTEST_NON_PEDANTIC -namespace GH109311 { -void f() = delete -#if __cpp_deleted_function >= 202403L - ("reason") // ok -#endif -; -} -#else struct S { void a() = delete; void b() = delete(; // expected-error {{expected string literal}} expected-error {{expected ')'}} expected-note {{to match this '('}} void c() = delete(); // expected-error {{expected string literal}} void d() = delete(42); // expected-error {{expected string literal}} - void e() = delete("foo"[0]); // expected-error {{expected ')'}} expected-note {{to match this '('}} // pre26-warning {{'= delete' with a message is a C++2c extension}} compat-warning {{'= delete' with a message is incompatible with C++ standards before C++2c}} - void f() = delete("foo"); // pre26-warning {{'= delete' with a message is a C++2c extension}} compat-warning {{'= delete' with a message is incompatible with C++ standards before C++2c}} - - S() = delete("foo"); // pre26-warning {{'= delete' with a message is a C++2c extension}} compat-warning {{'= delete' with a message is incompatible with C++ standards before C++2c}} - ~S() = delete("foo"); // pre26-warning {{'= delete' with a message is a C++2c extension}} compat-warning {{'= delete' with a message is incompatible with C++ standards before C++2c}} - S(const S&) = delete("foo"); // pre26-warning {{'= delete' with a message is a C++2c extension}} compat-warning {{'= delete' with a message is incompatible with C++ standards before C++2c}} - S(S&&) = delete("foo"); // pre26-warning {{'= delete' with a message is a C++2c extension}} compat-warning {{'= delete' with a message is incompatible with C++ standards before C++2c}} - S& operator=(const S&) = delete("foo"); // pre26-warning {{'= delete' with a message is a C++2c extension}} compat-warning {{'= delete' with a message is incompatible with C++ standards before C++2c}} - S& operator=(S&&) = delete("foo"); // pre26-warning {{'= delete' with a message is a C++2c extension}} compat-warning {{'= delete' with a message is incompatible with C++ standards before C++2c}} + 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}} + 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}} + + 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}} + ~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}} + 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}} + 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}} + 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}} + 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}} }; struct T { @@ -41,8 +32,8 @@ void a() = delete; void b() = delete(; // expected-error {{expected string literal}} expected-error {{expected ')'}} expected-note {{to match this '('}} void c() = delete(); // expected-error {{expected string literal}} void d() = delete(42); // expected-error {{expected string literal}} -void e() = delete("foo"[0]); // expected-error {{expected ')'}} expected-note {{to match this '('}} // pre26-warning {{'= delete' with a message is a C++2c extension}} compat-warning {{'= delete' with a message is incompatible with C++ standards before C++2c}} -void f() = delete("foo"); // pre26-warning {{'= delete' with a message is a C++2c extension}} compat-warning {{'= delete' with a message is incompatible with C++ standards before C++2c}} +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}} +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}} constexpr const char *getMsg() { return "this is a message"; } void func() = delete(getMsg()); // expected-error {{expected string literal}} @@ -59,4 +50,12 @@ struct C { U f = delete ("hello"); // expected-error {{cannot delete expression of type 'const char[6]'}} }; } -#endif \ No newline at end of file + +namespace GH109311 { +void f() = delete +#if __cpp_deleted_function >= 202403L + ("reason") // 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++2}} +#endif +; +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits