From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C9B3E3858C39; Fri, 21 Jan 2022 21:45:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C9B3E3858C39 From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/104148] [11/12 Regression] -Wformat warning no longer warns about () wrapped args since r11-2457 Date: Fri, 21 Jan 2022 21:45:43 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: jakub at gcc dot gnu.org X-Bugzilla-Target-Milestone: 11.3 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Jan 2022 21:45:43 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D104148 --- Comment #5 from CVS Commits --- The master branch has been updated by Jakub Jelinek : https://gcc.gnu.org/g:f36efe71bef8ddf72306aca313d28759434cf97a commit r12-6810-gf36efe71bef8ddf72306aca313d28759434cf97a Author: Jakub Jelinek Date: Fri Jan 21 22:44:53 2022 +0100 c-family: Fix up a -Wformat regression [PR104148] As can be seen on the testcase, GCC 11 no longer warns if the format string is wrapped inside of ()s. This regressed with r11-2457-gdf5cf47a978, which added if (TREE_NO_WARNING (param)) return; to check_function_arguments_recurse. That function is used with a call= back for two cases, for -Wformat and for -Wnonnull. For the latter it is desirable to not warn in parameters or their subexpressions where that warning is suppressed, but for -Wformat the function is used solely to discover the string literals if any so that the c-format.cc code can diagnose them. I believe no warning suppression should stand in the way of that, -Wformat* warnings should be decided from warning suppress= ion on the CALL_EXPR only. In the PR Martin argued that now that we have specialized warning_suppressed_p we should use it, so instead of adding a bool arg to check_function_arguments_recurse I've added opt_code to the function, but will defer the warning_suppressed_p change to him. For OPT_Wformat_ we don't want to call it anyway at all (as I said, I think there should be no suppression for it during the string discove= ry, there isn't just one -Wformat=3D option, there are many and warning_suppression_p even with no_warnings actually tests the TREE_NO_WARNING bit). Initially, I thought I'd restrict also call to fn with format_arg attri= bute handling in check_function_arguments_recurse to OPT_Wformat_ only, but after looking around, it perhaps is intentional that way, most functions with format_arg attribute don't have nonnull attribute for that arg too, various gettext implementations handle NULL argument by passing it thro= ugh, but when result of gettext (NULL) etc. is passed to non-NULL argument, = it makes sense to warn. 2022-01-21 Jakub Jelinek PR c++/104148 * c-common.h (check_function_arguments_recurse): Add for_format arg. * c-common.cc (check_function_nonnull): Pass false to check_function_arguments_recurse's last argument. (check_function_arguments_recurse): Add for_format argument, if true, don't stop on warning_suppressed_p. * c-format.cc (check_format_info): Pass true to check_function_arguments_recurse's last argument. * c-c++-common/Wformat-pr104148.c: New test.=