public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Fix optc-gen.awk handling of variables with both Variable and Var
@ 2011-04-04 14:21 Joseph S. Myers
  0 siblings, 0 replies; only message in thread
From: Joseph S. Myers @ 2011-04-04 14:21 UTC (permalink / raw)
  To: gcc-patches

In the course of testing another patch I noticed an "excess elements
in struct initializer" warning building options.c for iq2000-elf.  The
problem turns out to be that if a .opt variable is specified both with
a Variable entry, without an initializer, and with Var on individual
options, then it gets listed in var_seen in two different ways,
resulting in two initializers even though there is only one structure
field for the variable.  This patch fixes this, making the logic on
optc-gen.awk follow that in opth-gen.awk more closely.

Tested building cc1 and xgcc for cross to iq2000-elf and committed to
trunk.  (Though the bug in optc-gen.awk is present on 4.6 branch, I
don't think it actually affects any targets there.)

2011-04-04  Joseph Myers  <joseph@codesourcery.com>

	* optc-gen.awk: Always remove type from Variable entry before
	recording in var_seen.

Index: optc-gen.awk
===================================================================
--- optc-gen.awk	(revision 171932)
+++ optc-gen.awk	(working copy)
@@ -202,14 +202,15 @@
 	init = extra_vars[i]
 	if (var ~ "=" ) {
 		sub(".*= *", "", init)
-		sub(" *=.*", "", var)
-		sub("^.*[ *]", "", var)
-		sub("\\[.*\\]$", "", var)
 	} else {
 		init = "0"
 	}
-	var_seen[var] = 1
-	print "  " init ", /* " var " */"
+	sub(" *=.*", "", var)
+	name = var
+	sub("^.*[ *]", "", name)
+	sub("\\[.*\\]$", "", name)
+	var_seen[name] = 1
+	print "  " init ", /* " name " */"
 }
 for (i = 0; i < n_opts; i++) {
 	if (flag_set_p("Save", flags[i]))

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-04-04 14:21 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-04 14:21 Fix optc-gen.awk handling of variables with both Variable and Var Joseph S. 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).