From patchwork Thu Sep 8 11:02:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan-Benedict Glaw X-Patchwork-Id: 1675537 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MNbnQ3vWHz1yhR for ; Thu, 8 Sep 2022 21:02:50 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 93A163858424 for ; Thu, 8 Sep 2022 11:02:48 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from lug-owl.de (lug-owl.de [IPv6:2a03:4000:10:469::]) by sourceware.org (Postfix) with ESMTPS id 329D3385841A for ; Thu, 8 Sep 2022 11:02:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 329D3385841A Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=lug-owl.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=lug-owl.de Received: by lug-owl.de (Postfix, from userid 1001) id 8DF8F41FAC; Thu, 8 Sep 2022 13:02:34 +0200 (CEST) Date: Thu, 8 Sep 2022 13:02:34 +0200 From: Jan-Benedict Glaw To: gcc-patches@gcc.gnu.org, Jonathan Yong <10walls@gmail.com>, Kai Tietz Subject: [PATCH] mingw32: Fix warning, update documentation Message-ID: <20220908110234.xdj5n7urppr52nh2@lug-owl.de> MIME-Version: 1.0 Content-Disposition: inline X-Operating-System: Linux chamaeleon 5.14.0-0.bpo.2-amd64 X-gpg-fingerprint: 250D 3BCF 7127 0D8C A444 A961 1DBD 5E75 8399 E1BB X-gpg-key: wwwkeys.de.pgp.net X-Echelon-Enable: howto poison arsenous mail psychological biological nuclear warfare test the bombastical terror of flooding the spy listeners explosion sex drugs and rock'n'roll X-TKUeV: howto poison arsenous mail psychological biological nuclear warfare test the bombastical terror of flooding the spy listeners explosion sex drugs and rock'n'roll X-message-flag: Please send plain text messages only. Do not send HTML emails. Thank you. User-Agent: NeoMutt/20170113 (1.7.2) X-Spam-Status: No, score=-10.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Hi! The mingw32 port is the only port to have TARGET_OVERRIDES_FORMAT_ATTRIBUTES defined. When this macro is defined, it will never evaluate to NULL, so this check just leads to a warning: /usr/lib/gcc-snapshot/bin/g++ -fcf-protection -fno-PIE -c -DIN_GCC_FRONTEND -DIN_GCC_FRONTEND -DIN_GCC_FRONTEND -g -O2 -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wmissing-format-attribute -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -Werror -fno-common -DHAVE_CONFIG_H -I. -Ic-family -I../../gcc/gcc -I../../gcc/gcc/c-family -I../../gcc/gcc/../include -I../../gcc/gcc/../libcpp/include -I../../gcc/gcc/../libcody -I../../gcc/gcc/../libdecnumber -I../../gcc/gcc/../libdecnumber/bid -I../libdecnumber -I../../gcc/gcc/../libbacktrace -o c-family/c-format.o -MT c-family/c-format.o -MMD -MP -MF c-family/.deps/c-format.TPo ../../gcc/gcc/c-family/c-format.cc ../../gcc/gcc/c-family/c-format.cc: In function 'const char* convert_format_name_to_system_name(const char*)': ../../gcc/gcc/c-family/c-format.cc:5114:42: error: the address of 'mingw_format_attribute_overrides' will never be NULL [-Werror=address] 5114 | if (TARGET_OVERRIDES_FORMAT_ATTRIBUTES != NULL In file included from ./tm.h:26, from ../../gcc/gcc/c-family/c-format.cc:23: ../../gcc/gcc/config/i386/mingw32.h:268:44: note: 'mingw_format_attribute_overrides' declared here 268 | #define TARGET_OVERRIDES_FORMAT_ATTRIBUTES mingw_format_attribute_overrides | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../../gcc/gcc/c-family/c-format.cc:5079:30: note: in expansion of macro 'TARGET_OVERRIDES_FORMAT_ATTRIBUTES' 5079 | extern const target_ovr_attr TARGET_OVERRIDES_FORMAT_ATTRIBUTES[]; | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1plus: all warnings being treated as errors make[1]: *** [Makefile:1146: c-family/c-format.o] Error 1 make[1]: Leaving directory '/var/lib/laminar/run/gcc-x86_64-w64-mingw32/1/toolchain-build/gcc' make: *** [Makefile:4588: all-gcc] Error 2 Also, when TARGET_OVERRIDES_FORMAT_ATTRIBUTES is defined, TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT must be defined as well. Add that requirement to the docs. 2022-09-07 Jan-Benedict Glaw gcc/ChangeLog: * c-family/c-format.cc (convert_format_name_to_system_name): Fix warning. * doc/tm.texi.in (TARGET_OVERRIDES_FORMAT_ATTRIBUTES): Document requirement of TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT being defined as well. * doc/tm.texi: Regenerate. Okay for HEAD? Thanks, Jan-Benedict diff --git a/gcc/c-family/c-format.cc b/gcc/c-family/c-format.cc index 68b94da40cc..a6c380bf1c8 100644 --- a/gcc/c-family/c-format.cc +++ b/gcc/c-family/c-format.cc @@ -5111,8 +5111,7 @@ convert_format_name_to_system_name (const char *attr_name) #ifdef TARGET_OVERRIDES_FORMAT_ATTRIBUTES /* Check if format attribute is overridden by target. */ - if (TARGET_OVERRIDES_FORMAT_ATTRIBUTES != NULL - && TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT > 0) + if (TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT > 0) { for (i = 0; i < TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT; ++i) { diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in index 5312059ea79..21b849ea32a 100644 --- a/gcc/doc/tm.texi.in +++ b/gcc/doc/tm.texi.in @@ -7836,7 +7836,8 @@ If defined, this macro is the number of entries in If defined, this macro is the name of a global variable containing target-specific format overrides for the @option{-Wformat} option. The default is to have no target-specific format overrides. If defined, -@code{TARGET_FORMAT_TYPES} must be defined, too. +@code{TARGET_FORMAT_TYPES} and @code{TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT} +must be defined, too. @end defmac @defmac TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index e47bf28089a..858bfb80cec 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -12043,7 +12043,8 @@ If defined, this macro is the number of entries in If defined, this macro is the name of a global variable containing target-specific format overrides for the @option{-Wformat} option. The default is to have no target-specific format overrides. If defined, -@code{TARGET_FORMAT_TYPES} must be defined, too. +@code{TARGET_FORMAT_TYPES} and @code{TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT} +must be defined, too. @end defmac @defmac TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT