A patch for spec parsing.
H.J. Lu
hjl@varesearch.com
Wed Sep 8 15:55:00 GMT 1999
There is a bug in handle_braces (). If I write my own spec file
with
%{march=pentium|march=i586:-D__pentium -D__pentium__}
for cpp. I got
# gcc -march=pentium -march=i586 -c x.c
x.c:0: malformed option `-D __pentium__-Di586'
The problem is gcc treates "%{S|P:X}" as "%{S:X}%{P:X}". We can either
force people to use "%{S|P: X}" or handle it gracefuly by appending a
space ' ' if necessary.
--
H.J. Lu (hjl@gnu.org)
---
Wed Sep 8 14:54:00 1999 H.J. Lu (hjl@gnu.org)
* gcc.c (handle_braces): Handle "gcc -S -P" for "%{S|P:X}".
--- ../../import/gcc-2.95.x/egcs/gcc/gcc.c Thu Aug 12 08:06:50 1999
+++ gcc/gcc.c Wed Sep 8 15:16:34 1999
@@ -4232,6 +4232,7 @@ handle_braces (p)
int pipe_p = 0;
int negate;
int suffix;
+ int either;
int include_blanks = 1;
if (*p == '^')
@@ -4244,6 +4245,7 @@ handle_braces (p)
This is used in %{|!pipe:...}. */
pipe_p = 1, ++p;
+ either = 0;
next_member:
negate = suffix = 0;
@@ -4359,7 +4361,10 @@ next_member:
/* We didn't match. Try again. */
if (*p++ == '|')
- goto next_member;
+ {
+ either = 1;
+ goto next_member;
+ }
return endbody;
}
}
@@ -4405,8 +4410,22 @@ next_member:
}
else
{
- if (do_spec_1 (save_string (body, endbody - body - 1),
- 0, NULL_PTR) < 0)
+ int len = endbody - body - 1;
+ char *buf;
+ if (either)
+ {
+ /* We have to handle "gcc -S -P" for spec "%{S|P:X}".
+ gcc treates "%{S|P:X}" as "%{S:X}%{P:X}". We can
+ either force people to use "%{S|P: X}" or handle
+ it gracefuly by appending a space ' ' here. */
+ buf = alloca (len + 1);
+ memcpy (&buf [1], body, len);
+ buf [0] = ' ';
+ len++;
+ }
+ else
+ buf = body;
+ if (do_spec_1 (save_string (buf, len), 0, NULL_PTR) < 0)
return 0;
}
}
@@ -4421,7 +4440,10 @@ next_member:
/* We didn't match; try again. */
if (*p++ == '|')
- goto next_member;
+ {
+ either = 1;
+ goto next_member;
+ }
return endbody;
}
More information about the Gcc-patches
mailing list