]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: enable -Warray-compare by default
authorJason Merrill <jason@redhat.com>
Fri, 22 Nov 2024 07:47:56 +0000 (08:47 +0100)
committerJason Merrill <jason@redhat.com>
Wed, 27 Nov 2024 04:53:37 +0000 (23:53 -0500)
Discussion of P2865R5 mentioned that we only enabled this warning with
-Wall; we should handle it like other deprecations.

gcc/c-family/ChangeLog:

* c-opts.cc (c_common_post_options): Enable -Warray-compare
in C++20.

gcc/testsuite/ChangeLog:

* g++.dg/tree-ssa/pr15791-1.C: Add -Wno-array-compare.

gcc/c-family/c-opts.cc
gcc/testsuite/g++.dg/tree-ssa/pr15791-1.C

index a0029294d400969cd0c0068a5ebdf7b04055f42a..a02d011abc1fb92a8c0be42dd1e2da7f218445a9 100644 (file)
@@ -1051,6 +1051,11 @@ c_common_post_options (const char **pfilename)
                       warn_deprecated_literal_operator,
                       deprecated_in (cxx23));
 
+  /* -Warray-compare is enabled by default in C++20.  */
+  SET_OPTION_IF_UNSET (&global_options, &global_options_set,
+                      warn_array_compare,
+                      warn_array_compare || deprecated_in (cxx20));
+
   /* -Wtemplate-id-cdtor is enabled by default in C++20.  */
   SET_OPTION_IF_UNSET (&global_options, &global_options_set,
                       warn_template_id_cdtor,
index 68f14adad00a0f81acdae6c57f83633beaba343c..9905851ee7c40d83a5e5e54a77bd2b6b36e2661a 100644 (file)
@@ -1,4 +1,5 @@
 /* { dg-do link } */
+/* { dg-additional-options -Wno-array-compare } */
 
 void link_error ();