From: Jason Merrill Date: Fri, 22 Nov 2024 07:47:56 +0000 (+0100) Subject: c++: enable -Warray-compare by default X-Git-Tag: basepoints/gcc-16~3840 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d89d033e2731a53bf71a0db5259380504357d2f5;p=thirdparty%2Fgcc.git c++: enable -Warray-compare by default 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. --- diff --git a/gcc/c-family/c-opts.cc b/gcc/c-family/c-opts.cc index a0029294d400..a02d011abc1f 100644 --- a/gcc/c-family/c-opts.cc +++ b/gcc/c-family/c-opts.cc @@ -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, diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr15791-1.C b/gcc/testsuite/g++.dg/tree-ssa/pr15791-1.C index 68f14adad00a..9905851ee7c4 100644 --- a/gcc/testsuite/g++.dg/tree-ssa/pr15791-1.C +++ b/gcc/testsuite/g++.dg/tree-ssa/pr15791-1.C @@ -1,4 +1,5 @@ /* { dg-do link } */ +/* { dg-additional-options -Wno-array-compare } */ void link_error ();