* [RFA/driver] Handle switches with arguments in self specs
@ 2009-04-23 15:23 Daniel Jacobowitz
2009-04-29 21:45 ` Richard Sandiford
0 siblings, 1 reply; 2+ messages in thread
From: Daniel Jacobowitz @ 2009-04-23 15:23 UTC (permalink / raw)
To: gcc-patches
I wanted to put a --param setting in DRIVER_SELF_SPECS. It didn't
work because this is after '=' to ' ' conversion, so you can't
write --param=a=b; and 'a=b' is not a switch so it can not go in
the switches array. I updated do_self_spec from the main option
processing code to use SWITCH_TAKES_ARG.
I ran the testsuite on arm-none-eabi (C/C++). I also tested it
with manually added DRIVER_SELF_SPECS on arm-none-eabi and
x86_64-linux.
OK to commit?
--
Daniel Jacobowitz
CodeSourcery
2009-04-23 Daniel Jacobowitz <dan@codesourcery.com>
* gcc.c (do_self_spec): Handle switches with arguments.
Index: gcc.c
===================================================================
--- gcc.c (revision 145603)
+++ gcc.c (working copy)
@@ -4658,27 +4658,51 @@ do_self_spec (const char *spec)
if (argbuf_index > 0)
{
- int i, first;
+ int i, first, n;
first = n_switches;
- n_switches += argbuf_index;
- switches = XRESIZEVEC (struct switchstr, switches, n_switches + 1);
-
- switches[n_switches] = switches[first];
+ n = n_switches + argbuf_index;
+ switches = XRESIZEVEC (struct switchstr, switches, n + 1);
+ switches[n] = switches[first];
for (i = 0; i < argbuf_index; i++)
{
struct switchstr *sw;
+ const char *p = &argbuf[i][1];
+ int c = *p;
/* Each switch should start with '-'. */
if (argbuf[i][0] != '-')
fatal ("switch '%s' does not start with '-'", argbuf[i]);
- sw = &switches[i + first];
+ sw = &switches[n_switches];
sw->part1 = &argbuf[i][1];
sw->args = 0;
sw->live_cond = 0;
sw->validated = 0;
sw->ordering = 0;
+
+ /* Deal with option arguments in separate argv elements. */
+ if ((SWITCH_TAKES_ARG (c) > (p[1] != 0))
+ || WORD_SWITCH_TAKES_ARG (p))
+ {
+ int j = 0;
+ int n_args = WORD_SWITCH_TAKES_ARG (p);
+
+ if (n_args == 0)
+ {
+ /* Count only the option arguments in separate argv elements. */
+ n_args = SWITCH_TAKES_ARG (c) - (p[1] != 0);
+ }
+ if (i + n_args >= argbuf_index)
+ fatal ("argument to '-%s' is missing", p);
+ switches[n_switches].args
+ = XNEWVEC (const char *, n_args + 1);
+ while (j < n_args)
+ switches[n_switches].args[j++] = argbuf[++i];
+ /* Null-terminate the vector. */
+ switches[n_switches].args[j] = 0;
+ }
+ n_switches++;
}
}
}
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [RFA/driver] Handle switches with arguments in self specs
2009-04-23 15:23 [RFA/driver] Handle switches with arguments in self specs Daniel Jacobowitz
@ 2009-04-29 21:45 ` Richard Sandiford
0 siblings, 0 replies; 2+ messages in thread
From: Richard Sandiford @ 2009-04-29 21:45 UTC (permalink / raw)
To: gcc-patches
Daniel Jacobowitz <drow@false.org> writes:
> +
> + /* Deal with option arguments in separate argv elements. */
> + if ((SWITCH_TAKES_ARG (c) > (p[1] != 0))
> + || WORD_SWITCH_TAKES_ARG (p))
> + {
> + int j = 0;
> + int n_args = WORD_SWITCH_TAKES_ARG (p);
> +
> + if (n_args == 0)
> + {
> + /* Count only the option arguments in separate argv elements. */
> + n_args = SWITCH_TAKES_ARG (c) - (p[1] != 0);
> + }
> + if (i + n_args >= argbuf_index)
> + fatal ("argument to '-%s' is missing", p);
> + switches[n_switches].args
> + = XNEWVEC (const char *, n_args + 1);
> + while (j < n_args)
> + switches[n_switches].args[j++] = argbuf[++i];
> + /* Null-terminate the vector. */
> + switches[n_switches].args[j] = 0;
> + }
> + n_switches++;
Sorry for sticking my oar in, but this looks like a cut-&-paste from
process_command. Maybe it would be worth splitting it out into a separate
function that can be shared by both.
Richard
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-04-29 19:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-23 15:23 [RFA/driver] Handle switches with arguments in self specs Daniel Jacobowitz
2009-04-29 21:45 ` Richard Sandiford
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).