Commit efe5e5a0 by Joseph Myers Committed by Joseph Myers

gcc.c (n_switches_alloc_debug_check): New.

	* gcc.c (n_switches_alloc_debug_check): New.
	(set_option_handlers): New.
	(process_command): Use set_option_handlers.
	(do_self_spec): Pass spec-generated options through option
	handlers.
	(main): Also save and restore n_switches_alloc when swapping
	switch arrays.

From-SVN: r165891
parent fe12dfe1
2010-10-23 Joseph Myers <joseph@codesourcery.com>
* gcc.c (n_switches_alloc_debug_check): New.
(set_option_handlers): New.
(process_command): Use set_option_handlers.
(do_self_spec): Pass spec-generated options through option
handlers.
(main): Also save and restore n_switches_alloc when swapping
switch arrays.
2010-10-23 Richard Henderson <rth@redhat.com> 2010-10-23 Richard Henderson <rth@redhat.com>
PR target/46144 PR target/46144
...@@ -2810,6 +2810,8 @@ static struct switchstr *switches_debug_check[2]; ...@@ -2810,6 +2810,8 @@ static struct switchstr *switches_debug_check[2];
static int n_switches_debug_check[2]; static int n_switches_debug_check[2];
static int n_switches_alloc_debug_check[2];
static char *debug_check_temp_file[2]; static char *debug_check_temp_file[2];
/* Language is one of three things: /* Language is one of three things:
...@@ -3506,6 +3508,19 @@ driver_handle_option (struct gcc_options *opts, ...@@ -3506,6 +3508,19 @@ driver_handle_option (struct gcc_options *opts,
return true; return true;
} }
/* Put the driver's standard set of option handlers in *HANDLERS. */
static void
set_option_handlers (struct cl_option_handlers *handlers)
{
handlers->unknown_option_callback = driver_unknown_option_callback;
handlers->wrong_lang_callback = driver_wrong_lang_callback;
handlers->post_handling_callback = driver_post_handling_callback;
handlers->num_handlers = 1;
handlers->handlers[0].handler = driver_handle_option;
handlers->handlers[0].mask = CL_DRIVER;
}
/* Create the vector `switches' and its contents. /* Create the vector `switches' and its contents.
Store its length in `n_switches'. */ Store its length in `n_switches'. */
...@@ -3730,12 +3745,7 @@ process_command (unsigned int decoded_options_count, ...@@ -3730,12 +3745,7 @@ process_command (unsigned int decoded_options_count,
last_language_n_infiles = -1; last_language_n_infiles = -1;
handlers.unknown_option_callback = driver_unknown_option_callback; set_option_handlers (&handlers);
handlers.wrong_lang_callback = driver_wrong_lang_callback;
handlers.post_handling_callback = driver_post_handling_callback;
handlers.num_handlers = 1;
handlers.handlers[0].handler = driver_handle_option;
handlers.handlers[0].mask = CL_DRIVER;
for (j = 1; j < decoded_options_count; j++) for (j = 1; j < decoded_options_count; j++)
{ {
...@@ -4250,66 +4260,59 @@ do_self_spec (const char *spec) ...@@ -4250,66 +4260,59 @@ do_self_spec (const char *spec)
if (argbuf_index > 0) if (argbuf_index > 0)
{ {
switches = XRESIZEVEC (struct switchstr, switches, const char **argbuf_copy;
n_switches + argbuf_index + 1); struct cl_decoded_option *decoded_options;
struct cl_option_handlers handlers;
unsigned int decoded_options_count;
unsigned int j;
for (i = 0; i < argbuf_index; i++) /* Create a copy of argbuf with a dummy argv[0] entry for
{ decode_cmdline_options_to_array. */
struct switchstr *sw; argbuf_copy = XNEWVEC (const char *, argbuf_index + 1);
const char *p = argbuf[i]; argbuf_copy[0] = "";
int c = *p; memcpy (argbuf_copy + 1, argbuf, argbuf_index * sizeof (const char *));
/* Each switch should start with '-'. */
if (c != '-')
fatal_error ("switch %qs does not start with %<-%>", argbuf[i]);
p++; decode_cmdline_options_to_array (argbuf_index + 1, argbuf_copy,
c = *p; CL_DRIVER, &decoded_options,
&decoded_options_count);
sw = &switches[n_switches++]; set_option_handlers (&handlers);
sw->part1 = p;
sw->live_cond = 0;
sw->validated = 0;
sw->ordering = 0;
/* Deal with option arguments in separate argv elements. */ for (j = 1; j < decoded_options_count; j++)
if ((SWITCH_TAKES_ARG (c) > (p[1] != 0)) {
|| WORD_SWITCH_TAKES_ARG (p)) switch (decoded_options[j].opt_index)
{ {
int j = 0; case OPT_SPECIAL_input_file:
int n_args = WORD_SWITCH_TAKES_ARG (p); /* Specs should only generate options, not input
files. */
if (strcmp (decoded_options[j].arg, "-") != 0)
fatal_error ("switch %qs does not start with %<-%>",
decoded_options[j].arg);
else
fatal_error ("spec-generated switch is just %<-%>");
break;
if (n_args == 0) case OPT_fcompare_debug_second:
{ case OPT_fcompare_debug:
/* Count only the option arguments in separate argv elements. */ case OPT_fcompare_debug_:
n_args = SWITCH_TAKES_ARG (c) - (p[1] != 0); case OPT_o:
} /* Avoid duplicate processing of some options from
if (i + n_args >= argbuf_index) compare-debug specs; just save them here. */
fatal_error ("argument to %<-%s%> is missing", p); save_switch (decoded_options[j].canonical_option[0],
sw->args (decoded_options[j].canonical_option_num_elements
= XNEWVEC (const char *, n_args + 1); - 1),
while (j < n_args) &decoded_options[j].canonical_option[1], false);
sw->args[j++] = argbuf[++i]; break;
/* Null-terminate the vector. */
sw->args[j] = 0; default:
} read_cmdline_option (&global_options, &global_options_set,
else if (c == 'o') decoded_options + j, CL_DRIVER, &handlers,
{ global_dc);
/* On some systems, ld cannot handle "-o" without break;
a space. So split the option from its argument. */
char *part1 = XNEWVEC (char, 2);
part1[0] = c;
part1[1] = '\0';
sw->part1 = part1;
sw->args = XNEWVEC (const char *, 2);
sw->args[0] = xstrdup (p+1);
sw->args[1] = 0;
} }
else
sw->args = 0;
} }
alloc_switch ();
switches[n_switches].part1 = 0; switches[n_switches].part1 = 0;
} }
} }
...@@ -6271,14 +6274,17 @@ main (int argc, char **argv) ...@@ -6271,14 +6274,17 @@ main (int argc, char **argv)
if (!compare_debug_second) if (!compare_debug_second)
{ {
n_switches_debug_check[1] = n_switches; n_switches_debug_check[1] = n_switches;
n_switches_alloc_debug_check[1] = n_switches_alloc;
switches_debug_check[1] = XDUPVEC (struct switchstr, switches, switches_debug_check[1] = XDUPVEC (struct switchstr, switches,
n_switches + 1); n_switches_alloc);
do_self_spec ("%:compare-debug-self-opt()"); do_self_spec ("%:compare-debug-self-opt()");
n_switches_debug_check[0] = n_switches; n_switches_debug_check[0] = n_switches;
n_switches_alloc_debug_check[0] = n_switches_alloc;
switches_debug_check[0] = switches; switches_debug_check[0] = switches;
n_switches = n_switches_debug_check[1]; n_switches = n_switches_debug_check[1];
n_switches_alloc = n_switches_alloc_debug_check[1];
switches = switches_debug_check[1]; switches = switches_debug_check[1];
} }
...@@ -6294,9 +6300,11 @@ main (int argc, char **argv) ...@@ -6294,9 +6300,11 @@ main (int argc, char **argv)
if (!compare_debug_second) if (!compare_debug_second)
{ {
n_switches_debug_check[1] = n_switches; n_switches_debug_check[1] = n_switches;
n_switches_alloc_debug_check[1] = n_switches_alloc;
switches_debug_check[1] = switches; switches_debug_check[1] = switches;
compare_debug = -compare_debug; compare_debug = -compare_debug;
n_switches = n_switches_debug_check[0]; n_switches = n_switches_debug_check[0];
n_switches_alloc = n_switches_debug_check[0];
switches = switches_debug_check[0]; switches = switches_debug_check[0];
} }
} }
...@@ -6712,12 +6720,14 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n" ...@@ -6712,12 +6720,14 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n"
compare_debug = -compare_debug; compare_debug = -compare_debug;
n_switches = n_switches_debug_check[1]; n_switches = n_switches_debug_check[1];
n_switches_alloc = n_switches_alloc_debug_check[1];
switches = switches_debug_check[1]; switches = switches_debug_check[1];
value = do_spec (input_file_compiler->spec); value = do_spec (input_file_compiler->spec);
compare_debug = -compare_debug; compare_debug = -compare_debug;
n_switches = n_switches_debug_check[0]; n_switches = n_switches_debug_check[0];
n_switches_alloc = n_switches_alloc_debug_check[0];
switches = switches_debug_check[0]; switches = switches_debug_check[0];
if (value < 0) if (value < 0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment