tradtradcpp0, cpp spec bugs, and use of '|'
Chris G. Demetriou
cgd@sibyte.com
Mon Nov 20 18:11:00 GMT 2000
[ cc'd gcc-patches since i've supplied a patch. ]
Neil Booth <neilb@earthling.net> writes:
> Chris G. Demetriou wrote:-
>
> > (1) probably simple to fix: -traditional-cpp is now called an
> > unrecognized option, when given to gcc. (Not quite sure where the
> > right place to fix this one would be...)
>
> I'm not sure either.
originally i wasn't sure in the sense that i thought it would be one
of c_decode_option() and cpp_handle_option(), but then decided the
former, but then tried it and it didn't work. 8-)
I looked into it some more, and it looks like the problem is that
validate_switches() doesn't bother handling specs which have multiple
members separated by |. so it'd look for and validate an argument
'traditional|ftraditional|traditional-cpp', but not,
e.g. traditional-cpp. 8-)
Below is a patch which addresses that (or attempts to 8-). (It
doesn't even touch the 'tradtradcpp0' issue due to apparent incorrect
expectations about the meaning of '|'.)
i've not tested it particularly thoroughly -- just built it into my
cross-compiler (based on 2000-10-10 sources, with a slightly hacked
mips64-elf -ish target), and tried it out. the 'unrecognized option'
warning is gone, at least. and i ran it through gdb, and watched it
work, and it looked OK.
so: it's not been tested enough, somebody should test it more. but i
can't easily to so right now. 8-)
I've verified that it applies, offset 46 lines, to the current sources
as of a few minutes ago.
2000-11-20 Chris Demetriou <cgd@sibyte.com>
* gcc.c (validate_switches): Validate multiple switches named
in '|' (or) expressions in specs.
comments appreciated.
chris
===================================================================
Index: gcc/gcc/gcc.c
===================================================================
RCS file: /cvsroot/systemsw/tools/src/gcc/gcc/gcc.c,v
retrieving revision 1.3
diff -c -r1.3 gcc.c
*** gcc.c 2000/10/29 00:35:18 1.3
--- gcc.c 2000/11/21 02:01:13
***************
*** 5892,5898 ****
register const char *p = start;
const char *filter;
register int i;
! int suffix = 0;
if (*p == '|')
++p;
--- 5892,5898 ----
register const char *p = start;
const char *filter;
register int i;
! int suffix;
if (*p == '|')
++p;
***************
*** 5900,5910 ****
if (*p == '!')
++p;
if (*p == '.')
suffix = 1, ++p;
filter = p;
! while (*p != ':' && *p != '}')
p++;
if (suffix)
--- 5900,5913 ----
if (*p == '!')
++p;
+ next_member:
+ suffix = 0;
+
if (*p == '.')
suffix = 1, ++p;
filter = p;
! while (*p != ':' && *p != '}' && *p != '|')
p++;
if (suffix)
***************
*** 5912,5920 ****
else if (p[-1] == '*')
{
/* Mark all matching switches as valid. */
- --p;
for (i = 0; i < n_switches; i++)
! if (!strncmp (switches[i].part1, filter, p - filter))
switches[i].validated = 1;
}
else
--- 5915,5922 ----
else if (p[-1] == '*')
{
/* Mark all matching switches as valid. */
for (i = 0; i < n_switches; i++)
! if (!strncmp (switches[i].part1, filter, p - filter - 1))
switches[i].validated = 1;
}
else
***************
*** 5927,5932 ****
--- 5929,5937 ----
switches[i].validated = 1;
}
}
+
+ if (*p++ == '|')
+ goto next_member;
}
/* Check whether a particular argument was used. The first time we
More information about the Gcc-bugs
mailing list