Commit eea13ead by Joseph Myers Committed by Joseph Myers

darwin-driver.c (SWITCH_TAKES_ARG, [...]): Remove.

	* config/darwin-driver.c (SWITCH_TAKES_ARG,
	WORD_SWITCH_TAKES_ARG): Remove.
	* cppspec.c (SWITCH_TAKES_ARG, WORD_SWITCH_TAKES_ARG): Remove.
	* defaults.h (DEFAULT_SWITCH_TAKES_ARG,
	DEFAULT_WORD_SWITCH_TAKES_ARG): Move from gcc.h.
	(SWITCH_TAKES_ARG, WORD_SWITCH_TAKES_ARG): Move default
	definitions from gcc.c.
	* gcc.c (SWITCH_TAKES_ARG, WORD_SWITCH_TAKES_ARG): Move to
	defaults.h.
	* gcc.h (DEFAULT_SWITCH_TAKES_ARG, DEFAULT_WORD_SWITCH_TAKES_ARG):
	Move to defaults.h.
	* opts-common.c: Include tm.h.
	(decode_cmdline_option): Use SWITCH_TAKES_ARG and
	WORD_SWITCH_TAKES_ARG to count arguments to unknown options.
	Handle more than one argument.  Set canonical_option_num_elements.
	(decode_cmdline_options_to_array): Set
	canonical_option_num_elements and trailing elements of
	canonical_option.
	* opts.h (struct cl_decoded_option): Allow four elements in
	canonical_option.  Add field canonical_option_num_elements.
	* Makefile.in (opts-common.o): Update dependencies.

ada:
	* gcc-interface/misc.c (gnat_init_options): Ignore erroneous
	options.  Check canonical_option_num_elements on options copied.

fortran:
	* gfortranspec.c (SWITCH_TAKES_ARG, WORD_SWITCH_TAKES_ARG):
	Remove.

From-SVN: r162620
parent 57e15568
2010-07-28 Joseph Myers <joseph@codesourcery.com>
* config/darwin-driver.c (SWITCH_TAKES_ARG,
WORD_SWITCH_TAKES_ARG): Remove.
* cppspec.c (SWITCH_TAKES_ARG, WORD_SWITCH_TAKES_ARG): Remove.
* defaults.h (DEFAULT_SWITCH_TAKES_ARG,
DEFAULT_WORD_SWITCH_TAKES_ARG): Move from gcc.h.
(SWITCH_TAKES_ARG, WORD_SWITCH_TAKES_ARG): Move default
definitions from gcc.c.
* gcc.c (SWITCH_TAKES_ARG, WORD_SWITCH_TAKES_ARG): Move to
defaults.h.
* gcc.h (DEFAULT_SWITCH_TAKES_ARG, DEFAULT_WORD_SWITCH_TAKES_ARG):
Move to defaults.h.
* opts-common.c: Include tm.h.
(decode_cmdline_option): Use SWITCH_TAKES_ARG and
WORD_SWITCH_TAKES_ARG to count arguments to unknown options.
Handle more than one argument. Set canonical_option_num_elements.
(decode_cmdline_options_to_array): Set
canonical_option_num_elements and trailing elements of
canonical_option.
* opts.h (struct cl_decoded_option): Allow four elements in
canonical_option. Add field canonical_option_num_elements.
* Makefile.in (opts-common.o): Update dependencies.
2010-07-28 Eric Botcazou <ebotcazou@adacore.com> 2010-07-28 Eric Botcazou <ebotcazou@adacore.com>
PR middle-end/44790 PR middle-end/44790
......
...@@ -2806,7 +2806,7 @@ opts.o : opts.c opts.h options.h $(TOPLEV_H) $(DIAGNOSTIC_CORE_H) $(CONFIG_H) $( ...@@ -2806,7 +2806,7 @@ opts.o : opts.c opts.h options.h $(TOPLEV_H) $(DIAGNOSTIC_CORE_H) $(CONFIG_H) $(
$(FLAGS_H) $(PARAMS_H) $(TREE_PASS_H) $(DBGCNT_H) debug.h \ $(FLAGS_H) $(PARAMS_H) $(TREE_PASS_H) $(DBGCNT_H) debug.h \
$(PLUGIN_H) $(EXCEPT_H) $(LTO_STREAMER_H) opts-diagnostic.h $(PLUGIN_H) $(EXCEPT_H) $(LTO_STREAMER_H) opts-diagnostic.h
opts-common.o : opts-common.c opts.h options.h $(CONFIG_H) $(SYSTEM_H) \ opts-common.o : opts-common.c opts.h options.h $(CONFIG_H) $(SYSTEM_H) \
coretypes.h intl.h $(DIAGNOSTIC_H) coretypes.h intl.h $(DIAGNOSTIC_H) $(TM_H)
targhooks.o : targhooks.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TREE_H) \ targhooks.o : targhooks.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TREE_H) \
$(EXPR_H) $(TM_H) $(RTL_H) $(TM_P_H) $(FUNCTION_H) output.h $(TOPLEV_H) $(DIAGNOSTIC_CORE_H) \ $(EXPR_H) $(TM_H) $(RTL_H) $(TM_P_H) $(FUNCTION_H) output.h $(TOPLEV_H) $(DIAGNOSTIC_CORE_H) \
$(MACHMODE_H) $(TARGET_DEF_H) $(TARGET_H) $(GGC_H) gt-targhooks.h \ $(MACHMODE_H) $(TARGET_DEF_H) $(TARGET_H) $(GGC_H) gt-targhooks.h \
......
2010-07-28 Joseph Myers <joseph@codesourcery.com>
* gcc-interface/misc.c (gnat_init_options): Ignore erroneous
options. Check canonical_option_num_elements on options copied.
2010-07-27 Joseph Myers <joseph@codesourcery.com> 2010-07-27 Joseph Myers <joseph@codesourcery.com>
* gcc-interface/misc.c (gnat_handle_option): Update prototype and * gcc-interface/misc.c (gnat_handle_option): Update prototype and
......
...@@ -272,8 +272,13 @@ gnat_init_options (unsigned int decoded_options_count, ...@@ -272,8 +272,13 @@ gnat_init_options (unsigned int decoded_options_count,
save_argc = 0; save_argc = 0;
for (i = 0; i < decoded_options_count; i++) for (i = 0; i < decoded_options_count; i++)
{ {
if (decoded_options[i].errors
|| decoded_options[i].opt_index == OPT_SPECIAL_unknown)
continue;
gcc_assert (decoded_options[i].canonical_option_num_elements >= 1
&& decoded_options[i].canonical_option_num_elements <= 2);
save_argv[save_argc++] = decoded_options[i].canonical_option[0]; save_argv[save_argc++] = decoded_options[i].canonical_option[0];
if (decoded_options[i].canonical_option[1] != NULL) if (decoded_options[i].canonical_option_num_elements >= 2)
save_argv[save_argc++] = decoded_options[i].canonical_option[1]; save_argv[save_argc++] = decoded_options[i].canonical_option[1];
} }
save_argv[save_argc] = NULL; save_argv[save_argc] = NULL;
......
...@@ -27,14 +27,6 @@ along with GCC; see the file COPYING3. If not see ...@@ -27,14 +27,6 @@ along with GCC; see the file COPYING3. If not see
#include <sys/sysctl.h> #include <sys/sysctl.h>
#include "xregex.h" #include "xregex.h"
#ifndef SWITCH_TAKES_ARG
#define SWITCH_TAKES_ARG(CHAR) DEFAULT_SWITCH_TAKES_ARG(CHAR)
#endif
#ifndef WORD_SWITCH_TAKES_ARG
#define WORD_SWITCH_TAKES_ARG(STR) DEFAULT_WORD_SWITCH_TAKES_ARG (STR)
#endif
/* When running on a Darwin system and using that system's headers and /* When running on a Darwin system and using that system's headers and
libraries, default the -mmacosx-version-min flag to be the version libraries, default the -mmacosx-version-min flag to be the version
of the system on which the compiler is running. */ of the system on which the compiler is running. */
......
...@@ -30,14 +30,6 @@ along with GCC; see the file COPYING3. If not see ...@@ -30,14 +30,6 @@ along with GCC; see the file COPYING3. If not see
assume the user knows what they're doing. If no explicit input is assume the user knows what they're doing. If no explicit input is
mentioned, it will read stdin. */ mentioned, it will read stdin. */
#ifndef SWITCH_TAKES_ARG
#define SWITCH_TAKES_ARG(CHAR) DEFAULT_SWITCH_TAKES_ARG(CHAR)
#endif
#ifndef WORD_SWITCH_TAKES_ARG
#define WORD_SWITCH_TAKES_ARG(STR) DEFAULT_WORD_SWITCH_TAKES_ARG (STR)
#endif
/* Suffixes for known sorts of input files. Note that we do not list /* Suffixes for known sorts of input files. Note that we do not list
files which are normally considered to have been preprocessed already, files which are normally considered to have been preprocessed already,
since the user's expectation is that `cpp' always preprocesses. */ since the user's expectation is that `cpp' always preprocesses. */
......
...@@ -32,6 +32,38 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see ...@@ -32,6 +32,38 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#define GET_ENVIRONMENT(VALUE, NAME) do { (VALUE) = getenv (NAME); } while (0) #define GET_ENVIRONMENT(VALUE, NAME) do { (VALUE) = getenv (NAME); } while (0)
#endif #endif
/* This defines which switch letters take arguments. */
#define DEFAULT_SWITCH_TAKES_ARG(CHAR) \
((CHAR) == 'D' || (CHAR) == 'U' || (CHAR) == 'o' \
|| (CHAR) == 'e' || (CHAR) == 'T' || (CHAR) == 'u' \
|| (CHAR) == 'I' || (CHAR) == 'J' || (CHAR) == 'm' \
|| (CHAR) == 'x' || (CHAR) == 'L' || (CHAR) == 'A' \
|| (CHAR) == 'B' )
/* This defines which multi-letter switches take arguments. */
#define DEFAULT_WORD_SWITCH_TAKES_ARG(STR) \
(!strcmp (STR, "Tdata") || !strcmp (STR, "Ttext") \
|| !strcmp (STR, "Tbss") || !strcmp (STR, "include") \
|| !strcmp (STR, "imacros") || !strcmp (STR, "aux-info") \
|| !strcmp (STR, "idirafter") || !strcmp (STR, "iprefix") \
|| !strcmp (STR, "iwithprefix") || !strcmp (STR, "iwithprefixbefore") \
|| !strcmp (STR, "iquote") || !strcmp (STR, "isystem") \
|| !strcmp (STR, "isysroot") \
|| !strcmp (STR, "-param") || !strcmp (STR, "specs") \
|| !strcmp (STR, "MF") || !strcmp (STR, "MT") || !strcmp (STR, "MQ") \
|| !strcmp (STR, "fintrinsic-modules-path") \
|| !strcmp (STR, "dumpbase") || !strcmp (STR, "dumpdir"))
#ifndef SWITCH_TAKES_ARG
#define SWITCH_TAKES_ARG(CHAR) DEFAULT_SWITCH_TAKES_ARG (CHAR)
#endif
#ifndef WORD_SWITCH_TAKES_ARG
#define WORD_SWITCH_TAKES_ARG(STR) DEFAULT_WORD_SWITCH_TAKES_ARG (STR)
#endif
/* Store in OUTPUT a string (made with alloca) containing an /* Store in OUTPUT a string (made with alloca) containing an
assembler-name for a local static variable or function named NAME. assembler-name for a local static variable or function named NAME.
LABELNO is an integer which is different for each call. */ LABELNO is an integer which is different for each call. */
......
2010-07-28 Joseph Myers <joseph@codesourcery.com>
* gfortranspec.c (SWITCH_TAKES_ARG, WORD_SWITCH_TAKES_ARG):
Remove.
2010-07-28 Tobias Burnus <burnus@net-b.de> 2010-07-28 Tobias Burnus <burnus@net-b.de>
PR fortran/45077 PR fortran/45077
......
...@@ -113,22 +113,6 @@ static void append_arg (const char *); ...@@ -113,22 +113,6 @@ static void append_arg (const char *);
static int g77_newargc; static int g77_newargc;
static const char **g77_newargv; static const char **g77_newargv;
/* --- This comes from gcc.c (2.8.1) verbatim: */
/* This defines which switch letters take arguments. */
#ifndef SWITCH_TAKES_ARG
#define SWITCH_TAKES_ARG(CHAR) DEFAULT_SWITCH_TAKES_ARG(CHAR)
#endif
/* This defines which multi-letter switches take arguments. */
#ifndef WORD_SWITCH_TAKES_ARG
#define WORD_SWITCH_TAKES_ARG(STR) DEFAULT_WORD_SWITCH_TAKES_ARG (STR)
#endif
/* --- End of verbatim. */
/* Assumes text[0] == '-'. Returns number of argv items that belong to /* Assumes text[0] == '-'. Returns number of argv items that belong to
(and follow) this one, an option id for options important to the (and follow) this one, an option id for options important to the
caller, and a pointer to the first char of the arg, if embedded (else caller, and a pointer to the first char of the arg, if embedded (else
......
...@@ -946,13 +946,6 @@ struct user_specs ...@@ -946,13 +946,6 @@ struct user_specs
static struct user_specs *user_specs_head, *user_specs_tail; static struct user_specs *user_specs_head, *user_specs_tail;
#ifndef SWITCH_TAKES_ARG
#define SWITCH_TAKES_ARG(CHAR) DEFAULT_SWITCH_TAKES_ARG(CHAR)
#endif
#ifndef WORD_SWITCH_TAKES_ARG
#define WORD_SWITCH_TAKES_ARG(STR) DEFAULT_WORD_SWITCH_TAKES_ARG (STR)
#endif
#ifdef HAVE_TARGET_EXECUTABLE_SUFFIX #ifdef HAVE_TARGET_EXECUTABLE_SUFFIX
/* This defines which switches stop a full compilation. */ /* This defines which switches stop a full compilation. */
......
...@@ -32,31 +32,6 @@ struct spec_function ...@@ -32,31 +32,6 @@ struct spec_function
const char *(*func) (int, const char **); const char *(*func) (int, const char **);
}; };
/* This defines which switch letters take arguments. */
#define DEFAULT_SWITCH_TAKES_ARG(CHAR) \
((CHAR) == 'D' || (CHAR) == 'U' || (CHAR) == 'o' \
|| (CHAR) == 'e' || (CHAR) == 'T' || (CHAR) == 'u' \
|| (CHAR) == 'I' || (CHAR) == 'J' || (CHAR) == 'm' \
|| (CHAR) == 'x' || (CHAR) == 'L' || (CHAR) == 'A' \
|| (CHAR) == 'B' )
/* This defines which multi-letter switches take arguments. */
#define DEFAULT_WORD_SWITCH_TAKES_ARG(STR) \
(!strcmp (STR, "Tdata") || !strcmp (STR, "Ttext") \
|| !strcmp (STR, "Tbss") || !strcmp (STR, "include") \
|| !strcmp (STR, "imacros") || !strcmp (STR, "aux-info") \
|| !strcmp (STR, "idirafter") || !strcmp (STR, "iprefix") \
|| !strcmp (STR, "iwithprefix") || !strcmp (STR, "iwithprefixbefore") \
|| !strcmp (STR, "iquote") || !strcmp (STR, "isystem") \
|| !strcmp (STR, "isysroot") \
|| !strcmp (STR, "-param") || !strcmp (STR, "specs") \
|| !strcmp (STR, "MF") || !strcmp (STR, "MT") || !strcmp (STR, "MQ") \
|| !strcmp (STR, "fintrinsic-modules-path") \
|| !strcmp (STR, "dumpbase") || !strcmp (STR, "dumpdir"))
/* These are exported by gcc.c. */ /* These are exported by gcc.c. */
extern int do_spec (const char *); extern int do_spec (const char *);
extern void record_temp_file (const char *, int, int); extern void record_temp_file (const char *, int, int);
......
...@@ -24,6 +24,7 @@ along with GCC; see the file COPYING3. If not see ...@@ -24,6 +24,7 @@ along with GCC; see the file COPYING3. If not see
#include "opts.h" #include "opts.h"
#include "options.h" #include "options.h"
#include "diagnostic.h" #include "diagnostic.h"
#include "tm.h" /* For SWITCH_TAKES_ARG and WORD_SWITCH_TAKES_ARG. */
/* Perform a binary search to find which option the command-line INPUT /* Perform a binary search to find which option the command-line INPUT
matches. Returns its index in the option array, and matches. Returns its index in the option array, and
...@@ -138,7 +139,9 @@ decode_cmdline_option (const char **argv, unsigned int lang_mask, ...@@ -138,7 +139,9 @@ decode_cmdline_option (const char **argv, unsigned int lang_mask,
const char *opt, *arg = 0; const char *opt, *arg = 0;
char *dup = 0; char *dup = 0;
int value = 1; int value = 1;
unsigned int result = 1; unsigned int result = 1, i;
size_t total_len;
char *p;
const struct cl_option *option; const struct cl_option *option;
int errors = 0; int errors = 0;
...@@ -242,22 +245,54 @@ decode_cmdline_option (const char **argv, unsigned int lang_mask, ...@@ -242,22 +245,54 @@ decode_cmdline_option (const char **argv, unsigned int lang_mask,
decoded->arg = arg; decoded->arg = arg;
decoded->value = value; decoded->value = value;
decoded->errors = errors; decoded->errors = errors;
switch (result)
if (opt_index == OPT_SPECIAL_unknown)
{ {
case 1: /* Skip the correct number of arguments for options handled
decoded->orig_option_with_args_text = argv[0]; through specs. */
decoded->canonical_option[0] = argv[0]; const char *popt = argv[0] + 1;
decoded->canonical_option[1] = NULL; int c = *popt;
break;
case 2: gcc_assert (result == 1);
decoded->orig_option_with_args_text = concat (argv[0], " ", if (SWITCH_TAKES_ARG (c) > (popt[1] != 0))
argv[1], NULL); result += SWITCH_TAKES_ARG (c) - (popt[1] != 0);
decoded->canonical_option[0] = argv[0]; else if (WORD_SWITCH_TAKES_ARG (popt))
decoded->canonical_option[1] = argv[1]; result += WORD_SWITCH_TAKES_ARG (popt);
break; if (result > 1)
default: for (i = 1; i < result; i++)
gcc_unreachable (); if (argv[i] == NULL)
{
result = i;
break;
}
} }
gcc_assert (result >= 1 && result <= ARRAY_SIZE (decoded->canonical_option));
decoded->canonical_option_num_elements = result;
total_len = 0;
for (i = 0; i < ARRAY_SIZE (decoded->canonical_option); i++)
{
if (i < result)
{
decoded->canonical_option[i] = argv[i];
total_len += strlen (argv[i]) + 1;
}
else
decoded->canonical_option[i] = NULL;
}
decoded->orig_option_with_args_text = p = XNEWVEC (char, total_len);
for (i = 0; i < result; i++)
{
size_t len = strlen (argv[i]);
memcpy (p, argv[i], len);
p += len;
if (i == result - 1)
*p++ = 0;
else
*p++ = ' ';
}
return result; return result;
} }
...@@ -284,8 +319,11 @@ decode_cmdline_options_to_array (unsigned int argc, const char **argv, ...@@ -284,8 +319,11 @@ decode_cmdline_options_to_array (unsigned int argc, const char **argv,
opt_array[0].opt_index = OPT_SPECIAL_program_name; opt_array[0].opt_index = OPT_SPECIAL_program_name;
opt_array[0].arg = argv[0]; opt_array[0].arg = argv[0];
opt_array[0].orig_option_with_args_text = argv[0]; opt_array[0].orig_option_with_args_text = argv[0];
opt_array[0].canonical_option_num_elements = 1;
opt_array[0].canonical_option[0] = argv[0]; opt_array[0].canonical_option[0] = argv[0];
opt_array[0].canonical_option[1] = NULL; opt_array[0].canonical_option[1] = NULL;
opt_array[0].canonical_option[2] = NULL;
opt_array[0].canonical_option[3] = NULL;
opt_array[0].value = 1; opt_array[0].value = 1;
opt_array[0].errors = 0; opt_array[0].errors = 0;
num_decoded_options = 1; num_decoded_options = 1;
...@@ -300,8 +338,11 @@ decode_cmdline_options_to_array (unsigned int argc, const char **argv, ...@@ -300,8 +338,11 @@ decode_cmdline_options_to_array (unsigned int argc, const char **argv,
opt_array[num_decoded_options].opt_index = OPT_SPECIAL_input_file; opt_array[num_decoded_options].opt_index = OPT_SPECIAL_input_file;
opt_array[num_decoded_options].arg = opt; opt_array[num_decoded_options].arg = opt;
opt_array[num_decoded_options].orig_option_with_args_text = opt; opt_array[num_decoded_options].orig_option_with_args_text = opt;
opt_array[num_decoded_options].canonical_option_num_elements = 1;
opt_array[num_decoded_options].canonical_option[0] = opt; opt_array[num_decoded_options].canonical_option[0] = opt;
opt_array[num_decoded_options].canonical_option[1] = NULL; opt_array[num_decoded_options].canonical_option[1] = NULL;
opt_array[num_decoded_options].canonical_option[2] = NULL;
opt_array[num_decoded_options].canonical_option[3] = NULL;
opt_array[num_decoded_options].value = 1; opt_array[num_decoded_options].value = 1;
opt_array[num_decoded_options].errors = 0; opt_array[num_decoded_options].errors = 0;
num_decoded_options++; num_decoded_options++;
......
...@@ -121,10 +121,12 @@ struct cl_decoded_option ...@@ -121,10 +121,12 @@ struct cl_decoded_option
/* The canonical form of the option and its argument, for when it is /* The canonical form of the option and its argument, for when it is
necessary to reconstruct argv elements (in particular, for necessary to reconstruct argv elements (in particular, for
processing specs and passing options to subprocesses from the processing specs and passing options to subprocesses from the
driver). The first element of this array is non-NULL; the second driver). */
is NULL if the canonical form uses only one argv element, const char *canonical_option[4];
non-NULL otherwise. */
const char *canonical_option[2]; /* The number of elements in the canonical form of the option and
arguments; always at least 1. */
size_t canonical_option_num_elements;
/* For a boolean option, 1 for the true case and 0 for the "no-" /* For a boolean option, 1 for the true case and 0 for the "no-"
case. For an unsigned integer option, the value of the case. For an unsigned integer option, the value of the
......
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