public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Sanity check that 'Init' doesn't appear without 'Var' in '*.opt' files
@ 2021-08-03 13:11 Thomas Schwinge
  2021-08-03 19:34 ` Joseph Myers
  0 siblings, 1 reply; 2+ messages in thread
From: Thomas Schwinge @ 2021-08-03 13:11 UTC (permalink / raw)
  To: gcc-patches, Joseph Myers

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

Hi!

Is the attached OK to push?

No violations found per:

    $ find -type f -name \*.opt | xargs grep -F 'Init(' | grep -v -F 'Var('

..., and manually verified the error condition.


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-Sanity-check-that-Init-doesn-t-appear-without-Var-in.patch --]
[-- Type: text/x-diff, Size: 1189 bytes --]

From 67b88991c4a37e63bfecd9a0a17d9d7561b23dce Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <thomas@codesourcery.com>
Date: Tue, 3 Aug 2021 14:59:56 +0200
Subject: [PATCH] Sanity check that 'Init' doesn't appear without 'Var' in
 '*.opt' files

... as that doesn't make sense.

    @item Init(@var{value})
    The variable specified by the @code{Var} property should be statically
    initialized to @var{value}.  [...]

	gcc/
	* optc-gen.awk: Sanity check that 'Init' doesn't appear without
	'Var'.
---
 gcc/optc-gen.awk | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/gcc/optc-gen.awk b/gcc/optc-gen.awk
index 880ac776d8a..77e598efd60 100644
--- a/gcc/optc-gen.awk
+++ b/gcc/optc-gen.awk
@@ -195,10 +195,14 @@ for (i = 0; i < n_extra_vars; i++) {
 }
 for (i = 0; i < n_opts; i++) {
 	name = var_name(flags[i]);
-	if (name == "")
+	init = opt_args("Init", flags[i])
+
+	if (name == "") {
+		if (init != "")
+		    print "#error " opts[i] " must specify Var to use Init"
 		continue;
+	}
 
-	init = opt_args("Init", flags[i])
 	if (init != "") {
 		if (name in var_init && var_init[name] != init)
 			print "#error multiple initializers for " name
-- 
2.25.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Sanity check that 'Init' doesn't appear without 'Var' in '*.opt' files
  2021-08-03 13:11 Sanity check that 'Init' doesn't appear without 'Var' in '*.opt' files Thomas Schwinge
@ 2021-08-03 19:34 ` Joseph Myers
  0 siblings, 0 replies; 2+ messages in thread
From: Joseph Myers @ 2021-08-03 19:34 UTC (permalink / raw)
  To: Thomas Schwinge; +Cc: gcc-patches

On Tue, 3 Aug 2021, Thomas Schwinge wrote:

> Hi!
> 
> Is the attached OK to push?
> 
> No violations found per:
> 
>     $ find -type f -name \*.opt | xargs grep -F 'Init(' | grep -v -F 'Var('
> 
> ..., and manually verified the error condition.

OK.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-08-03 19:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-03 13:11 Sanity check that 'Init' doesn't appear without 'Var' in '*.opt' files Thomas Schwinge
2021-08-03 19:34 ` Joseph Myers

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).