Skip to content

[Clang] update reasoned delete diagnostic kind to use Extension, making it pedantic only #114713

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Nov 19, 2024

Conversation

a-tarasyuk
Copy link
Member

@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Nov 3, 2024
@llvmbot
Copy link
Member

llvmbot commented Nov 3, 2024

@llvm/pr-subscribers-clang

Author: Oleksandr T. (a-tarasyuk)

Changes

Fixes #109311


#109311 (comment)


Full diff: https://github.com/llvm/llvm-project/pull/114713.diff

3 Files Affected:

  • (modified) clang/docs/ReleaseNotes.rst (+2)
  • (modified) clang/include/clang/Basic/DiagnosticParseKinds.td (+1-1)
  • (modified) clang/test/Parser/cxx2c-delete-with-message.cpp (+12-1)
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

@zwuis
Copy link
Contributor

zwuis commented Nov 4, 2024

I think we should make these changes to all backported features.

@a-tarasyuk
Copy link
Member Author

I think we should make these changes to all backported features.

@zwuis @AaronBallman is it okay to handle that in a separate issue/PR?

@AaronBallman AaronBallman self-requested a review November 4, 2024 16:08
Copy link
Collaborator

@AaronBallman AaronBallman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for working on this!

@AaronBallman
Copy link
Collaborator

I think we should make these changes to all backported features.

@zwuis @AaronBallman is it okay to handle that in a separate issue/PR?

Yeah, I think it's fine to handle separately.

Copy link
Collaborator

@AaronBallman AaronBallman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM assuming precommit CI comes back green.

Btw, now would probably be a good time for you to get your own commit privileges, you've done a number of quality contributions already: https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access

@AaronBallman AaronBallman merged commit d8a1c6d into llvm:main Nov 19, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clang should not warn about =delete("reason") in C++17 mode while claiming to support it
4 participants