[clang] [Clang] update reasoned delete diagnostic kind to use Extension, making it pedantic only (PR #114713)
Oleksandr T. via cfe-commits
cfe-commits at lists.llvm.org
Sun Nov 3 09:25:36 PST 2024
https://github.com/a-tarasyuk created https://github.com/llvm/llvm-project/pull/114713
Fixes #109311
---
https://github.com/llvm/llvm-project/issues/109311#issuecomment-2422963686
>From c07fa270194eadde3ccecab368b2225702fc2e63 Mon Sep 17 00:00:00 2001
From: Oleksandr T <oleksandr.tarasiuk at outlook.com>
Date: Sun, 3 Nov 2024 19:22:56 +0200
Subject: [PATCH] [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
More information about the cfe-commits
mailing list