From patchwork Wed Mar 30 20:42:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Schwinge X-Patchwork-Id: 1611369 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: 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 (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KTJKJ2vk3z9sBy for ; Thu, 31 Mar 2022 07:42:42 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6F6383839820 for ; Wed, 30 Mar 2022 20:42:40 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa1.mentor.iphmx.com (esa1.mentor.iphmx.com [68.232.129.153]) by sourceware.org (Postfix) with ESMTPS id D92BC3839801 for ; Wed, 30 Mar 2022 20:42:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D92BC3839801 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com X-IronPort-AV: E=Sophos;i="5.90,223,1643702400"; d="scan'208,223";a="76423843" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa1.mentor.iphmx.com with ESMTP; 30 Mar 2022 12:42:26 -0800 IronPort-SDR: 05/rnqr+oDrp1BER20/YCQwBEzDaxjnEFO98l0tEKbRRqw3nDPYffloNUMzMZIyoJEhKPEGfHR +5MN7TYkIArLJ6m0DbBEv44U1Ywf30bbW85di2XzTQswg7mt9Co+aXUFu7Us/kIMxQfOORVMeo ac/pozKYVkiyA+RI8FjLnH6NgJ4Hp3jVNxkCzNE6G0Pq1Szb6qFLTWEjPU2DDPnsejzkHni0n5 sUHdlomI3HCgvKx23p7qyJ38BqI5wQXnW/ahHTXLpCom/aGciT8ZZU/CLIV5tdNyQsKQx36dVO wK8= From: Thomas Schwinge To: , "Joseph S. Myers" Subject: options: Fix "Multiple different help strings" error diagnostic (was: make conflicting help text an error) In-Reply-To: References: User-Agent: Notmuch/0.29.3+94~g74c3f1b (https://notmuchmail.org) Emacs/27.1 (x86_64-pc-linux-gnu) Date: Wed, 30 Mar 2022 22:42:10 +0200 Message-ID: <8735iz18bh.fsf@euler.schwinge.homeip.net> MIME-Version: 1.0 X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-15.mgc.mentorg.com (139.181.222.15) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: , Cc: Manuel =?utf-8?b?TMOzcGV6LUliw6HDsWV6?= Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Hi! On 2012-05-13T11:04:36+0200, Manuel López-Ibáñez wrote: > These warnings are invisible when building but they may help to detect > if an option is duplicated somewhere else with different purpose , so > it would be better to make this an error, ACK. > --- gcc/optc-gen.awk (revision 187427) > +++ gcc/optc-gen.awk (working copy) > else if (help[i] != "" && help[i + 1] != help[i]) > - print "warning: multiple different help strings for " \ > - opts[i] ":\n\t" help[i] "\n\t" help[i + 1] \ > - | "cat 1>&2" > + print "#error Multiple different help strings for " \ > + opts[i] ":\n\t" help[i] "\n\t" help[i + 1] > + OK to push the attached 'options: Fix "Multiple different help strings" error diagnostic'? Grüße Thomas ----------------- Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955 From ab2f8ed4631ca94138ed0007a22e97a37f0311d3 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Wed, 30 Mar 2022 22:22:49 +0200 Subject: [PATCH] options: Fix "Multiple different help strings" error diagnostic This currently causes a confusing litany, for example: options.cc:3245:2: error: #error Multiple different help strings for Wunused-result: #error Multiple different help strings for Wunused-result: ^ options.cc:3246:2: error: 'Warn' was not declared in this scope Warn if a caller of a function, marked with attribute warn_unused_result, does not use its return value. ^ options.cc:3246:7: error: expected '}' before 'if' Warn if a caller of a function, marked with attribute warn_unused_result, does not use its return value. ^ options.cc:3246:7: error: expected ',' or ';' before 'if' options.cc:3256:54: error: expected unqualified-id before ',' token (unsigned short) -1, 0, CLVC_INTEGER, 0, -1, -1 }, ^ [going on for several thousands of lines] Fixed: options.cc:3245:2: error: #error Multiple different help strings for Wunused-result: #error Multiple different help strings for Wunused-result: ^ options.cc:3246:2: error: #error Warn if a caller of a function, marked with attribute warn_unused_result, does not use its return value. #error Warn if a caller of a function, marked with attribute warn_unused_result, does not use its return value. ^ options.cc:3247:2: error: #error TEST. #error TEST. ^ Fix-up for r187437/commit 71caddc5568f59a5990f39226f60979a7fe953ef "optc-gen.awk: Error instead of warning for conflicting help". gcc/ * optc-gen.awk : Fix "Multiple different help strings" error diagnostic. --- gcc/optc-gen.awk | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gcc/optc-gen.awk b/gcc/optc-gen.awk index 8a66126141a..7774dfc38df 100644 --- a/gcc/optc-gen.awk +++ b/gcc/optc-gen.awk @@ -270,9 +270,12 @@ for (i = 0; i < n_opts; i++) { flags[i + 1] = flags[i] " " flags[i + 1]; if (help[i + 1] == "") help[i + 1] = help[i] - else if (help[i] != "" && help[i + 1] != help[i]) + else if (help[i] != "" && help[i + 1] != help[i]) { print "#error Multiple different help strings for " \ - opts[i] ":\n\t" help[i] "\n\t" help[i + 1] + opts[i] ":" + print "#error " help[i] + print "#error " help[i + 1] + } i++; back_chain[i] = "N_OPTS"; -- 2.25.1