aboutsummaryrefslogtreecommitdiff
path: root/gcc/toplev.c
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2010-06-20 22:02:46 +0100
committerJoseph Myers <jsm28@gcc.gnu.org>2010-06-20 22:02:46 +0100
commit6e2f19568ad7378a11073048ffb2372045dc665a (patch)
tree2c4f1fab67e1d031a842bdda5d4777aed748b3b5 /gcc/toplev.c
parent1d63e3de09ef2a47b63f29db8da5289404cec4d1 (diff)
downloadgcc-6e2f19568ad7378a11073048ffb2372045dc665a.zip
gcc-6e2f19568ad7378a11073048ffb2372045dc665a.tar.gz
gcc-6e2f19568ad7378a11073048ffb2372045dc665a.tar.bz2
re PR other/32998 (-frecord-gcc-switches issues)
PR other/32998 * opth-gen.awk: Generate definitions of OPT_SPECIAL_unknown, OPT_SPECIAL_program_name and OPT_SPECIAL_input_file. * opts-common.c (find_opt): Return OPT_SPECIAL_unknown on failure. (decode_cmdline_option): Update for this return value. Set orig_option_with_args_text field. Set arg field for unknown options. Make static. (decode_cmdline_options_to_array): New. (prune_options): Update handling of find_opt return value. * opts.c (read_cmdline_option): Take decoded option. Return void. (read_cmdline_options): Take decoded options. (decode_options): Add parameters for decoded options. Use decode_cmdline_options_to_array. Use decoded options for -O scan. Use integral_argument for -O parameters. Update call to read_cmdline_options. (enable_warning_as_error): Update handling of find_opt return value. * opts.h: Update comment on unknown options. (struct cl_decoded_option): Update comments on opt_index and arg. Add orig_option_with_args_text. (decode_cmdline_option): Remove. (decode_cmdline_options_to_array): Declare. (decode_options): Update prototype. * toplev.c (save_argv): Remove. (save_decoded_options, save_decoded_options_count): New. (read_integral_parameter): Remove. (print_switch_values): Use decoded options. (toplev_main): Don't set save_argv. Update call to decode_options. * toplev.h (read_integral_parameter): Remove. * varasm.c (elf_record_gcc_switches): Don't handle holding back names. c-family: * c-common.c (parse_optimize_options): Update call to decode_options. fortran: * options.c (gfc_handle_option): Don't handle N_OPTS. testsuite: * gcc.dg/opts-2.c: New test. From-SVN: r161053
Diffstat (limited to 'gcc/toplev.c')
-rw-r--r--gcc/toplev.c70
1 files changed, 17 insertions, 53 deletions
diff --git a/gcc/toplev.c b/gcc/toplev.c
index 20da382..220c1f7 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -126,8 +126,9 @@ static bool no_backend;
/* Length of line when printing switch values. */
#define MAX_LINE 75
-/* Copy of argument vector to toplev_main. */
-static const char **save_argv;
+/* Decoded options, and number of such options. */
+static struct cl_decoded_option *save_decoded_options;
+static unsigned int save_decoded_options_count;
/* Name of top-level original source file (what was input to cpp).
This comes from the #-command at the beginning of the actual input.
@@ -488,34 +489,6 @@ set_random_seed (const char *val)
return old;
}
-/* Decode the string P as an integral parameter.
- If the string is indeed an integer return its numeric value else
- issue an Invalid Option error for the option PNAME and return DEFVAL.
- If PNAME is zero just return DEFVAL, do not call error. */
-
-int
-read_integral_parameter (const char *p, const char *pname, const int defval)
-{
- const char *endp = p;
-
- while (*endp)
- {
- if (ISDIGIT (*endp))
- endp++;
- else
- break;
- }
-
- if (*endp != 0)
- {
- if (pname != 0)
- error ("invalid option argument %qs", pname);
- return defval;
- }
-
- return atoi (p);
-}
-
#if GCC_VERSION < 3004
/* The functions floor_log2 and exact_log2 are defined as inline
@@ -1338,7 +1311,6 @@ print_switch_values (print_switch_fn_type print_fn)
{
int pos = 0;
size_t j;
- const char **p;
/* Fill in the -frandom-seed option, if the user didn't pass it, so
that it can be printed below. This helps reproducibility. */
@@ -1349,30 +1321,23 @@ print_switch_values (print_switch_fn_type print_fn)
pos = print_single_switch (print_fn, pos,
SWITCH_TYPE_DESCRIPTIVE, _("options passed: "));
- for (p = &save_argv[1]; *p != NULL; p++)
+ for (j = 1; j < save_decoded_options_count; j++)
{
- if (**p == '-')
+ switch (save_decoded_options[j].opt_index)
{
+ case OPT_o:
+ case OPT_d:
+ case OPT_dumpbase:
+ case OPT_dumpdir:
+ case OPT_auxbase:
+ case OPT_quiet:
+ case OPT_version:
/* Ignore these. */
- if (strcmp (*p, "-o") == 0
- || strcmp (*p, "-dumpbase") == 0
- || strcmp (*p, "-dumpdir") == 0
- || strcmp (*p, "-auxbase") == 0)
- {
- if (p[1] != NULL)
- p++;
- continue;
- }
-
- if (strcmp (*p, "-quiet") == 0
- || strcmp (*p, "-version") == 0)
- continue;
-
- if ((*p)[1] == 'd')
- continue;
+ continue;
}
- pos = print_single_switch (print_fn, pos, SWITCH_TYPE_PASSED, *p);
+ pos = print_single_switch (print_fn, pos, SWITCH_TYPE_PASSED,
+ save_decoded_options[j].orig_option_with_args_text);
}
if (pos > 0)
@@ -2395,14 +2360,13 @@ toplev_main (int argc, char **argv)
{
expandargv (&argc, &argv);
- save_argv = CONST_CAST2 (const char **, char **, argv);
-
/* Initialization of GCC's environment, and diagnostics. */
general_init (argv[0]);
/* Parse the options and do minimal processing; basically just
enough to default flags appropriately. */
- decode_options (argc, CONST_CAST2 (const char **, char **, argv));
+ decode_options (argc, CONST_CAST2 (const char **, char **, argv),
+ &save_decoded_options, &save_decoded_options_count);
init_local_tick ();