public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Thomas Schwinge <thomas@codesourcery.com>
To: <gcc-patches@gcc.gnu.org>, "Joseph S. Myers" <joseph@codesourcery.com>
Cc: "Manuel López-Ibáñez" <lopezibanez@gmail.com>
Subject: options: Fix "Multiple different help strings" error diagnostic (was: make conflicting help text an error)
Date: Wed, 30 Mar 2022 22:42:10 +0200	[thread overview]
Message-ID: <8735iz18bh.fsf@euler.schwinge.homeip.net> (raw)
In-Reply-To: <CAESRpQAS8m0Gyy3LLZkiVjwoOs4OUYTzZAd3aHTdAwm-JH0F2Q@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1201 bytes --]

Hi!

On 2012-05-13T11:04:36+0200, Manuel López-Ibáñez <lopezibanez@gmail.com> 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

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-options-Fix-Multiple-different-help-strings-error-di.patch --]
[-- Type: text/x-diff, Size: 2572 bytes --]

From ab2f8ed4631ca94138ed0007a22e97a37f0311d3 Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <thomas@codesourcery.com>
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 <END>: 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


  parent reply	other threads:[~2022-03-30 20:42 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-13  9:05 make conflicting help text an error Manuel López-Ibáñez
2012-05-13 11:03 ` Joseph S. Myers
2022-03-30 21:09   ` options: Clarifications around option definition records' help texts (was: make conflicting help text an error) Thomas Schwinge
2022-03-31 17:18     ` Joseph Myers
2022-03-30 20:42 ` Thomas Schwinge [this message]
2022-03-31 17:17   ` options: Fix "Multiple different help strings" error diagnostic " Joseph Myers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8735iz18bh.fsf@euler.schwinge.homeip.net \
    --to=thomas@codesourcery.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=joseph@codesourcery.com \
    --cc=lopezibanez@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).