[clang] 270a6a2 - No longer issue pedantic warning about pre-c++2b compat

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 21 07:52:04 PDT 2023


Author: Aaron Ballman
Date: 2023-03-21T10:51:53-04:00
New Revision: 270a6a2824e3b42bd87acc986732a8b8f0765be7

URL: https://github.com/llvm/llvm-project/commit/270a6a2824e3b42bd87acc986732a8b8f0765be7
DIFF: https://github.com/llvm/llvm-project/commit/270a6a2824e3b42bd87acc986732a8b8f0765be7.diff

LOG: No longer issue pedantic warning about pre-c++2b compat

We were accidentally issuing "overloaded 'operator[]' with more than
one parameter is a C++2b extension" with -pedantic because it was an
ExtWarn diagnostic rather than a Warning. This corrects the diagnostic
category and adds some test coverage.

Fixes #61582

Added: 
    clang/test/SemaCXX/cxx2b-overloaded-operator-pedantic.cpp

Modified: 
    clang/docs/ReleaseNotes.rst
    clang/include/clang/Basic/DiagnosticSemaKinds.td

Removed: 
    


################################################################################
diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index e7688b09f68e6..e2e4d6f51d81a 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -238,6 +238,9 @@ Bug Fixes to C++ Support
   (`#58674 <https://github.com/llvm/llvm-project/issues/58674>`_)
 - Fix incorrect deletion of the default constructor of unions in some
   cases. (`#48416 <https://github.com/llvm/llvm-project/issues/48416>`_)
+- No longer issue a pre-C++2b compatibility warning in ``-pedantic`` mode
+  regading overloaded `operator[]` with more than one parmeter. (`#61582
+  <https://github.com/llvm/llvm-project/issues/61582>`_)
 
 Bug Fixes to AST Handling
 ^^^^^^^^^^^^^^^^^^^^^^^^^

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index bbab5752c9bfe..613e4a5006561 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -9140,8 +9140,9 @@ def err_operator_overload_static : Error<
 def err_operator_overload_default_arg : Error<
   "parameter of overloaded %0 cannot have a default argument">;
 
-def ext_subscript_overload : ExtWarn<
-  "overloaded %0 with %select{no|a defaulted|more than one}1 parameter is a C++2b extension">, InGroup<CXXPre2bCompat>, DefaultIgnore;
+def ext_subscript_overload : Warning<
+  "overloaded %0 with %select{no|a defaulted|more than one}1 parameter is a "
+  "C++2b extension">, InGroup<CXXPre2bCompat>, DefaultIgnore;
 def error_subscript_overload : Error<
   "overloaded %0 cannot have %select{no|a defaulted|more than one}1 parameter before C++2b">;
 

diff  --git a/clang/test/SemaCXX/cxx2b-overloaded-operator-pedantic.cpp b/clang/test/SemaCXX/cxx2b-overloaded-operator-pedantic.cpp
new file mode 100644
index 0000000000000..53782c61c1c53
--- /dev/null
+++ b/clang/test/SemaCXX/cxx2b-overloaded-operator-pedantic.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -verify -std=c++2b -pedantic %s
+// RUN: %clang_cc1 -verify=compat -std=c++2b -Wpre-c++2b-compat %s
+
+// expected-no-diagnostics
+
+struct GH61582 {
+  // We accidentally would issue this diagnostic in pedantic mode; show that we
+  // only issue it when enabling the compat warnings now.
+  void operator[](int, int); // compat-warning {{overloaded 'operator[]' with more than one parameter is a C++2b extension}}
+};
+


        


More information about the cfe-commits mailing list