This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Fix optc-gen.awk handling of variables with both Variable and Var
- From: "Joseph S. Myers" <joseph at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 4 Apr 2011 14:21:16 +0000 (UTC)
- Subject: Fix optc-gen.awk handling of variables with both Variable and Var
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