diff options
author | Joseph Myers <joseph@codesourcery.com> | 2010-11-05 13:06:27 +0000 |
---|---|---|
committer | Joseph Myers <jsm28@gcc.gnu.org> | 2010-11-05 13:06:27 +0000 |
commit | c243beb03c0fc64c2400835b9cbd770cbbd48222 (patch) | |
tree | 6b1a8cba615f48d1963fa98f1d69555be29e0ee1 | |
parent | d73ee4e74eb82f29e5949c13c6544b50d0f96d4c (diff) | |
download | gcc-c243beb03c0fc64c2400835b9cbd770cbbd48222.tar.gz |
defaults.h (DEFAULT_WORD_SWITCH_TAKES_ARG, [...]): Remove.
* defaults.h (DEFAULT_WORD_SWITCH_TAKES_ARG,
WORD_SWITCH_TAKES_ARG): Remove.
* doc/options.texi (Args): Document.
* doc/tm.texi.in (WORD_SWITCH_TAKES_ARG): Remove.
* doc/tm.texi: Regenerate.
* opt-functions.awk (switch_flags): Handle Args.
* opts-common.c: Update comment on tm.h include.
(decode_cmdline_option): Handle options with multiple arguments.
Don't check WORD_SWITCH_TAKES_ARG for unknown options.
* opts.h (CL_SEPARATE_NARGS_SHIFT, CL_SEPARATE_NARGS_MASK):
Define.
(CL_PARAMS, CL_WARNING, CL_OPTIMIZATION, CL_DRIVER, CL_TARGET,
CL_COMMON): Update values.
* system.h (WORD_SWITCH_TAKES_ARG): Poison.
* config/darwin.h (WORD_SWITCH_TAKES_ARG): Remove.
* config/darwin.opt (Zsegaddr, sectalign, sectcreate,
sectobjectsymbols, sectorder, segcreate, segprot): New.
From-SVN: r166359
-rw-r--r-- | gcc/ChangeLog | 20 | ||||
-rw-r--r-- | gcc/config/darwin.h | 14 | ||||
-rw-r--r-- | gcc/config/darwin.opt | 21 | ||||
-rw-r--r-- | gcc/defaults.h | 8 | ||||
-rw-r--r-- | gcc/doc/options.texi | 4 | ||||
-rw-r--r-- | gcc/doc/tm.texi | 15 | ||||
-rw-r--r-- | gcc/doc/tm.texi.in | 15 | ||||
-rw-r--r-- | gcc/opt-functions.awk | 6 | ||||
-rw-r--r-- | gcc/opts-common.c | 62 | ||||
-rw-r--r-- | gcc/opts.h | 17 | ||||
-rw-r--r-- | gcc/system.h | 2 |
11 files changed, 100 insertions, 84 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 1d0902fe5f7..732c42384e2 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,23 @@ +2010-11-05 Joseph Myers <joseph@codesourcery.com> + + * defaults.h (DEFAULT_WORD_SWITCH_TAKES_ARG, + WORD_SWITCH_TAKES_ARG): Remove. + * doc/options.texi (Args): Document. + * doc/tm.texi.in (WORD_SWITCH_TAKES_ARG): Remove. + * doc/tm.texi: Regenerate. + * opt-functions.awk (switch_flags): Handle Args. + * opts-common.c: Update comment on tm.h include. + (decode_cmdline_option): Handle options with multiple arguments. + Don't check WORD_SWITCH_TAKES_ARG for unknown options. + * opts.h (CL_SEPARATE_NARGS_SHIFT, CL_SEPARATE_NARGS_MASK): + Define. + (CL_PARAMS, CL_WARNING, CL_OPTIMIZATION, CL_DRIVER, CL_TARGET, + CL_COMMON): Update values. + * system.h (WORD_SWITCH_TAKES_ARG): Poison. + * config/darwin.h (WORD_SWITCH_TAKES_ARG): Remove. + * config/darwin.opt (Zsegaddr, sectalign, sectcreate, + sectobjectsymbols, sectorder, segcreate, segprot): New. + 2010-11-05 H.J. Lu <hongjiu.lu@intel.com> Uros Bizjak <ubizjak@gmail.com> diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h index 438b7e03c4c..1974704d25a 100644 --- a/gcc/config/darwin.h +++ b/gcc/config/darwin.h @@ -194,20 +194,6 @@ extern GTY(()) int darwin_ms_struct; darwin_override_options (); \ } while (0) -/* These compiler options take n arguments. */ - -#undef WORD_SWITCH_TAKES_ARG -#define WORD_SWITCH_TAKES_ARG(STR) \ - (DEFAULT_WORD_SWITCH_TAKES_ARG (STR) ? 1 : \ - !strcmp (STR, "sectcreate") ? 3 : \ - !strcmp (STR, "sectorder") ? 3 : \ - !strcmp (STR, "Zsegaddr") ? 2 : \ - !strcmp (STR, "segprot") ? 3 : \ - !strcmp (STR, "sectalign") ? 3 : \ - !strcmp (STR, "sectobjectsymbols") ? 2 : \ - !strcmp (STR, "segcreate") ? 3 : \ - 0) - #define SUBTARGET_C_COMMON_OVERRIDE_OPTIONS do { \ if (flag_mkernel || flag_apple_kext) \ { \ diff --git a/gcc/config/darwin.opt b/gcc/config/darwin.opt index fac30bbd2bd..6bdfb06372d 100644 --- a/gcc/config/darwin.opt +++ b/gcc/config/darwin.opt @@ -96,6 +96,9 @@ Driver Separate Zseg_addr_table Driver Separate +Zsegaddr +Driver Separate Args(2) + Zsegs_read_only_addr Driver Separate @@ -129,9 +132,27 @@ Driver Separate read_only_relocs Driver Separate +sectalign +Driver Separate Args(3) + +sectcreate +Driver Separate Args(3) + +sectobjectsymbols +Driver Separate Args(2) + +sectorder +Driver Separate Args(3) + seg1addr Driver Separate +segcreate +Driver Separate Args(3) + +segprot +Driver Separate Args(3) + segs_read_only_addr Driver Separate diff --git a/gcc/defaults.h b/gcc/defaults.h index b03abfb022b..7d3b8499c19 100644 --- a/gcc/defaults.h +++ b/gcc/defaults.h @@ -32,14 +32,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #define GET_ENVIRONMENT(VALUE, NAME) do { (VALUE) = getenv (NAME); } while (0) #endif -/* This defines which multi-letter switches take arguments. */ - -#define DEFAULT_WORD_SWITCH_TAKES_ARG(STR) 0 - -#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 assembler-name for a local static variable or function named NAME. LABELNO is an integer which is different for each call. */ diff --git a/gcc/doc/options.texi b/gcc/doc/options.texi index d774b36d563..3b844bb9eb6 100644 --- a/gcc/doc/options.texi +++ b/gcc/doc/options.texi @@ -162,6 +162,10 @@ generic error message is used. @var{message} should contain a single @samp{%qs} format, which will be used to format the name of the option passed. +@item Args(@var{n}) +For an option marked @code{Separate}, indicate that it takes @var{n} +arguments. The default is 1. + @item UInteger The option's argument is a non-negative integer. The option parser will check and convert the argument before passing it to the relevant diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index 7ce1c50f434..0bb146e9cf2 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -99,21 +99,6 @@ from being defined in the @file{.h} file to being part of the @c prevent bad page break with this line You can control the compilation driver. -@defmac WORD_SWITCH_TAKES_ARG (@var{name}) -A C expression which determines whether the option @option{-@var{name}} -takes arguments. The value should be the number of arguments that -option takes--zero, for many options. -This macro does not need to handle options defined in @file{.opt} -files, only those that are handled purely through specs. - -By default, this macro is defined as -@code{DEFAULT_WORD_SWITCH_TAKES_ARG}, which handles the standard options -properly. You need not define @code{WORD_SWITCH_TAKES_ARG} unless you -wish to add additional options which take arguments. Any redefinition -should call @code{DEFAULT_WORD_SWITCH_TAKES_ARG} and then check for -additional options. -@end defmac - @defmac TARGET_OPTION_TRANSLATE_TABLE If defined, a list of pairs of strings, the first of which is a potential command line target to the @file{gcc} driver program, and the diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in index 23b38d3337f..6bf51d65d24 100644 --- a/gcc/doc/tm.texi.in +++ b/gcc/doc/tm.texi.in @@ -99,21 +99,6 @@ from being defined in the @file{.h} file to being part of the @c prevent bad page break with this line You can control the compilation driver. -@defmac WORD_SWITCH_TAKES_ARG (@var{name}) -A C expression which determines whether the option @option{-@var{name}} -takes arguments. The value should be the number of arguments that -option takes--zero, for many options. -This macro does not need to handle options defined in @file{.opt} -files, only those that are handled purely through specs. - -By default, this macro is defined as -@code{DEFAULT_WORD_SWITCH_TAKES_ARG}, which handles the standard options -properly. You need not define @code{WORD_SWITCH_TAKES_ARG} unless you -wish to add additional options which take arguments. Any redefinition -should call @code{DEFAULT_WORD_SWITCH_TAKES_ARG} and then check for -additional options. -@end defmac - @defmac TARGET_OPTION_TRANSLATE_TABLE If defined, a list of pairs of strings, the first of which is a potential command line target to the @file{gcc} driver program, and the diff --git a/gcc/opt-functions.awk b/gcc/opt-functions.awk index bd75b43410f..c85df5cd3de 100644 --- a/gcc/opt-functions.awk +++ b/gcc/opt-functions.awk @@ -100,6 +100,12 @@ function switch_flags (flags) test_flag("Warning", flags, " | CL_WARNING") \ test_flag("Optimization", flags, " | CL_OPTIMIZATION") \ test_flag("Report", flags, " | CL_REPORT") + sep_args = opt_args("Args", flags) + if (sep_args != "") { + sep_args-- + result = result " | (" sep_args \ + " << CL_SEPARATE_NARGS_SHIFT)" + } sub( "^0 \\| ", "", result ) return result } diff --git a/gcc/opts-common.c b/gcc/opts-common.c index ab4b1b26f8f..9239a5aaa13 100644 --- a/gcc/opts-common.c +++ b/gcc/opts-common.c @@ -24,8 +24,7 @@ along with GCC; see the file COPYING3. If not see #include "opts.h" #include "flags.h" #include "diagnostic.h" -#include "tm.h" /* For WORD_SWITCH_TAKES_ARG and - TARGET_OPTION_TRANSLATE_TABLE. */ +#include "tm.h" /* For TARGET_OPTION_TRANSLATE_TABLE. */ static void prune_options (struct cl_decoded_option **, unsigned int *); @@ -288,7 +287,7 @@ decode_cmdline_option (const char **argv, unsigned int lang_mask, size_t opt_index; const char *arg = 0; int value = 1; - unsigned int result = 1, i, extra_args; + unsigned int result = 1, i, extra_args, separate_args; int adjust_len = 0; size_t total_len; char *p; @@ -366,10 +365,15 @@ decode_cmdline_option (const char **argv, unsigned int lang_mask, errors |= CL_ERR_DISABLED; /* Determine whether there may be a separate argument based on - whether this option is being processed for the driver. */ + whether this option is being processed for the driver, and, if + so, how many such arguments. */ separate_arg_flag = ((option->flags & CL_SEPARATE) && !((option->flags & CL_NO_DRIVER_ARG) && (lang_mask & CL_DRIVER))); + separate_args = (separate_arg_flag + ? ((option->flags & CL_SEPARATE_NARGS_MASK) + >> CL_SEPARATE_NARGS_SHIFT) + 1 + : 0); joined_arg_flag = (option->flags & CL_JOINED) != 0; /* Sort out any argument the switch takes. */ @@ -399,10 +403,14 @@ decode_cmdline_option (const char **argv, unsigned int lang_mask, else if (separate_arg_flag) { arg = argv[extra_args + 1]; - result = extra_args + 2; - if (arg == NULL) - result = extra_args + 1; - else + for (i = 0; i < separate_args; i++) + if (argv[extra_args + 1 + i] == NULL) + { + errors |= CL_ERR_MISSING_ARG; + break; + } + result = extra_args + 1 + i; + if (arg != NULL) have_separate_arg = true; } @@ -461,6 +469,11 @@ decode_cmdline_option (const char **argv, unsigned int lang_mask, && (lang_mask & CL_DRIVER))); joined_arg_flag = (option->flags & CL_JOINED) != 0; + if (separate_args > 1 || (option->flags & CL_SEPARATE_NARGS_MASK)) + gcc_assert (separate_args + == ((option->flags & CL_SEPARATE_NARGS_MASK) + >> CL_SEPARATE_NARGS_SHIFT) + 1); + if (!(errors & CL_ERR_MISSING_ARG)) { if (separate_arg_flag || joined_arg_flag) @@ -504,22 +517,7 @@ decode_cmdline_option (const char **argv, unsigned int lang_mask, decoded->warn_message = warn_message; if (opt_index == OPT_SPECIAL_unknown) - { - /* Skip the correct number of arguments for options handled - through specs. */ - const char *popt ATTRIBUTE_UNUSED = argv[0] + 1; - - gcc_assert (result == 1); - if (WORD_SWITCH_TAKES_ARG (popt)) - result += WORD_SWITCH_TAKES_ARG (popt); - if (result > 1) - for (i = 1; i < result; i++) - if (argv[i] == NULL) - { - result = i; - break; - } - } + gcc_assert (result == 1); gcc_assert (result >= 1 && result <= ARRAY_SIZE (decoded->canonical_option)); decoded->canonical_option_num_elements = result; @@ -538,7 +536,21 @@ decode_cmdline_option (const char **argv, unsigned int lang_mask, decoded->canonical_option[i] = NULL; } if (opt_index != OPT_SPECIAL_unknown && opt_index != OPT_SPECIAL_ignore) - generate_canonical_option (opt_index, arg, value, decoded); + { + generate_canonical_option (opt_index, arg, value, decoded); + if (separate_args > 1) + { + for (i = 0; i < separate_args; i++) + { + if (argv[extra_args + 1 + i] == NULL) + break; + else + decoded->canonical_option[1 + i] = argv[extra_args + 1 + i]; + } + gcc_assert (result == 1 + i); + decoded->canonical_option_num_elements = result; + } + } decoded->orig_option_with_args_text = p = XNEWVEC (char, total_len); for (i = 0; i < result; i++) { diff --git a/gcc/opts.h b/gcc/opts.h index a1ab4cb6ca9..2643c37070c 100644 --- a/gcc/opts.h +++ b/gcc/opts.h @@ -71,12 +71,12 @@ extern const unsigned int cl_options_count; extern const char *const lang_names[]; extern const unsigned int cl_lang_count; -#define CL_PARAMS (1 << 13) /* Fake entry. Used to display --param info with --help. */ -#define CL_WARNING (1 << 14) /* Enables an (optional) warning message. */ -#define CL_OPTIMIZATION (1 << 15) /* Enables an (optional) optimization. */ -#define CL_DRIVER (1 << 16) /* Driver option. */ -#define CL_TARGET (1 << 17) /* Target-specific option. */ -#define CL_COMMON (1 << 18) /* Language-independent. */ +#define CL_PARAMS (1 << 11) /* Fake entry. Used to display --param info with --help. */ +#define CL_WARNING (1 << 12) /* Enables an (optional) warning message. */ +#define CL_OPTIMIZATION (1 << 13) /* Enables an (optional) optimization. */ +#define CL_DRIVER (1 << 14) /* Driver option. */ +#define CL_TARGET (1 << 15) /* Target-specific option. */ +#define CL_COMMON (1 << 16) /* Language-independent. */ #define CL_MIN_OPTION_CLASS CL_PARAMS #define CL_MAX_OPTION_CLASS CL_COMMON @@ -86,6 +86,11 @@ extern const unsigned int cl_lang_count; This distinction is important because --help will not list options which only have these higher bits set. */ +/* Options marked with CL_SEPARATE take a number of separate arguments + (1 to 4) that is one more than the number in this bit-field. */ +#define CL_SEPARATE_NARGS_SHIFT 17 +#define CL_SEPARATE_NARGS_MASK (3 << CL_SEPARATE_NARGS_SHIFT) + #define CL_SEPARATE_ALIAS (1 << 19) /* Option is an alias when used with separate argument. */ #define CL_NO_DRIVER_ARG (1 << 20) /* Option takes no argument in the driver. */ #define CL_REJECT_DRIVER (1 << 21) /* Reject this option in the driver. */ diff --git a/gcc/system.h b/gcc/system.h index 65b523604b9..afe015a4a31 100644 --- a/gcc/system.h +++ b/gcc/system.h @@ -776,7 +776,7 @@ extern void fancy_abort (const char *, int, const char *) ATTRIBUTE_NORETURN; STACK_CHECK_PROBE_INTERVAL STACK_CHECK_PROBE_LOAD \ ORDER_REGS_FOR_LOCAL_ALLOC FUNCTION_OUTGOING_VALUE \ ASM_DECLARE_CONSTANT_NAME MODIFY_TARGET_NAME SWITCHES_NEED_SPACES \ - SWITCH_CURTAILS_COMPILATION SWITCH_TAKES_ARG + SWITCH_CURTAILS_COMPILATION SWITCH_TAKES_ARG WORD_SWITCH_TAKES_ARG /* Hooks that are no longer used. */ #pragma GCC poison LANG_HOOKS_FUNCTION_MARK LANG_HOOKS_FUNCTION_FREE \ |