diff options
author | jsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-08-22 12:19:01 +0000 |
---|---|---|
committer | jsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-08-22 12:19:01 +0000 |
commit | cb22f9309c33b3b166e6c6d3ce9f426ed6c32e5a (patch) | |
tree | c0fcc55a02b851820af00ecab1b47d4cc06898cf /gcc/opts-common.c | |
parent | 7d445128bd5c67287babd868240a65437a20a931 (diff) | |
download | gcc-cb22f9309c33b3b166e6c6d3ce9f426ed6c32e5a.tar.gz |
* Makefile.in (gccspec.o, cppspec.o): Update dependencies.
* common.opt (L, nodefaultlibs, nostdlib, pg, static): New
options.
* config/avr/avr.h (LIBSTDCXX): Remove initial "-l".
* config/freebsd.h (MATH_LIBRARY_PROFILE): Remove initial "-l".
* config/i386/djgpp.h (LIBSTDCXX): Remove initial "-l".
* config/rs6000/aix.h (LIBSTDCXX_STATIC): Remove initial "-l".
* config/s390/tpf.h (MATH_LIBRARY, LIBSTDCXX): Remove initial
"-l".
* cppspec.c: Include opts.h.
(lang_specific_driver): Use cl_decoded_option structures.
* doc/tm.texi.in (MATH_LIBRARY): Update documentation.
* doc/tm.texi: Regenerate.
* gcc.c (translate_options): Translate -d to -foutput-class-dir=.
(driver_handle_option): Allow driver options needing no special
processing.
(process_command): Decode options before call to
lang_specific_driver. Pass decoded options to
lang_specific_driver.
* gcc.h (lang_specific_driver): Update prototype.
* gccspec.c: Include opts.h.
(lang_specific_driver): Use cl_decoded_option structures.
* opts-common.c (option_ok_for_language, generate_option,
generate_option_input_file): New.
(decode_cmdline_option): Use option_ok_for_language.
(decode_cmdline_options_to_array): Use generate_option_input_file.
(handle_generated_option): Use generate_option.
* opts.h (generate_option, generate_option_input_file): Declare.
cp:
* Make-lang.in (g++spec.o): Update dependencies.
* g++spec.c: Include opts.h
(MATH_LIBRARY, LIBSTDCXX): Remove initial "-l".
(lang_specific_driver): Use cl_decoded_option structures.
fortran:
* Make-lang.in (gfortranspec.o): Update dependencies.
* gfortranspec.c: Include coretypes.h before gcc.h. Include
opts.h.
(MATH_LIBRARY, FORTRAN_LIBRARY): Remove initial "-l".
(ADD_ARG_LIBGFORTRAN, Option, lookup_option): Remove.
(g77_xargc): Make unsigned.
(g77_xargv): Change to g77_x_decoded_options.
(g77_newargc): Make unsigned.
(g77_newargv): Change to g77_new_decoded_options.
(strings_same, options_same): New.
(append_arg): Use cl_decoded_option structures.
(append_option): New.
(add_arg_libgfortran): New.
(lang_specific_driver): Use cl_decoded_option structures.
java:
* Make-lang.in (jvspec.o): Update dependencies.
* jvspec.c: Include opts.h.
(PARAM_ARG): Remove.
(find_spec_file): Do not add leading -specs=.
(lang_specific_driver): Use cl_decoded_option structures.
* lang.opt (C, CLASSPATH, D, bootclasspath, classpath, encoding,
extdirs, fmain=, s-bc-abi): New options.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@163459 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/opts-common.c')
-rw-r--r-- | gcc/opts-common.c | 111 |
1 files changed, 72 insertions, 39 deletions
diff --git a/gcc/opts-common.c b/gcc/opts-common.c index 1296653ece5..cd4ec2b5586 100644 --- a/gcc/opts-common.c +++ b/gcc/opts-common.c @@ -127,6 +127,23 @@ integral_argument (const char *arg) return -1; } +/* Return whether OPTION is OK for the language given by + LANG_MASK. */ +static bool +option_ok_for_language (const struct cl_option *option, + unsigned int lang_mask) +{ + if (!(option->flags & lang_mask)) + return false; + else if ((option->flags & CL_TARGET) + && (option->flags & (CL_LANG_ALL | CL_DRIVER)) + && !(option->flags & (lang_mask & ~CL_COMMON & ~CL_TARGET))) + /* Complain for target flag language mismatches if any languages + are specified. */ + return false; + return true; +} + /* Decode the switch beginning at ARGV for the language indicated by LANG_MASK (including CL_COMMON and CL_TARGET if applicable), into the structure *DECODED. Returns the number of switches @@ -228,14 +245,8 @@ decode_cmdline_option (const char **argv, unsigned int lang_mask, } /* Check if this is a switch for a different front end. */ - if (!(option->flags & lang_mask)) + if (!option_ok_for_language (option, lang_mask)) errors |= CL_ERR_WRONG_LANG; - else if ((option->flags & CL_TARGET) - && (option->flags & (CL_LANG_ALL | CL_DRIVER)) - && !(option->flags & (lang_mask & ~CL_COMMON & ~CL_TARGET))) - /* Complain for target flag language mismatches if any languages - are specified. */ - errors |= CL_ERR_WRONG_LANG; if (arg == NULL && (separate_arg_flag || joined_arg_flag)) errors |= CL_ERR_MISSING_ARG; @@ -346,16 +357,7 @@ decode_cmdline_options_to_array (unsigned int argc, const char **argv, /* Interpret "-" or a non-switch as a file name. */ if (opt[0] != '-' || opt[1] == '\0') { - opt_array[num_decoded_options].opt_index = OPT_SPECIAL_input_file; - opt_array[num_decoded_options].arg = 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[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].errors = 0; + generate_option_input_file (opt, &opt_array[num_decoded_options]); num_decoded_options++; n = 1; continue; @@ -550,45 +552,76 @@ handle_generated_option (size_t opt_index, const char *arg, int value, unsigned int lang_mask, int kind, const struct cl_option_handlers *handlers) { - const struct cl_option *option = &cl_options[opt_index]; struct cl_decoded_option decoded; - decoded.opt_index = opt_index; - decoded.arg = arg; - decoded.canonical_option[2] = NULL; - decoded.canonical_option[3] = NULL; - decoded.value = value; - decoded.errors = 0; + generate_option (opt_index, arg, value, lang_mask, &decoded); + return handle_option (&decoded, lang_mask, kind, handlers); +} + +/* Fill in *DECODED with an option described by OPT_INDEX, ARG and + VALUE for a front end using LANG_MASK. This is used when the + compiler generates options internally. */ + +void +generate_option (size_t opt_index, const char *arg, int value, + unsigned int lang_mask, struct cl_decoded_option *decoded) +{ + const struct cl_option *option = &cl_options[opt_index]; + + decoded->opt_index = opt_index; + decoded->arg = arg; + decoded->canonical_option[2] = NULL; + decoded->canonical_option[3] = NULL; + decoded->value = value; + decoded->errors = (option_ok_for_language (option, lang_mask) + ? 0 + : CL_ERR_WRONG_LANG); if (arg) { if (option->flags & CL_SEPARATE) { - decoded.orig_option_with_args_text = concat (option->opt_text, " ", - arg, NULL); - decoded.canonical_option[0] = option->opt_text; - decoded.canonical_option[1] = arg; - decoded.canonical_option_num_elements = 2; + decoded->orig_option_with_args_text = concat (option->opt_text, " ", + arg, NULL); + decoded->canonical_option[0] = option->opt_text; + decoded->canonical_option[1] = arg; + decoded->canonical_option_num_elements = 2; } else { gcc_assert (option->flags & CL_JOINED); - decoded.orig_option_with_args_text = concat (option->opt_text, arg, - NULL); - decoded.canonical_option[0] = decoded.orig_option_with_args_text; - decoded.canonical_option[1] = NULL; - decoded.canonical_option_num_elements = 1; + decoded->orig_option_with_args_text = concat (option->opt_text, arg, + NULL); + decoded->canonical_option[0] = decoded->orig_option_with_args_text; + decoded->canonical_option[1] = NULL; + decoded->canonical_option_num_elements = 1; } } else { - decoded.orig_option_with_args_text = option->opt_text; - decoded.canonical_option[0] = option->opt_text; - decoded.canonical_option[1] = NULL; - decoded.canonical_option_num_elements = 1; + decoded->orig_option_with_args_text = option->opt_text; + decoded->canonical_option[0] = option->opt_text; + decoded->canonical_option[1] = NULL; + decoded->canonical_option_num_elements = 1; } +} - return handle_option (&decoded, lang_mask, kind, handlers); +/* Fill in *DECODED with an option for input file FILE. */ + +void +generate_option_input_file (const char *file, + struct cl_decoded_option *decoded) +{ + decoded->opt_index = OPT_SPECIAL_input_file; + decoded->arg = file; + decoded->orig_option_with_args_text = file; + decoded->canonical_option_num_elements = 1; + decoded->canonical_option[0] = file; + decoded->canonical_option[1] = NULL; + decoded->canonical_option[2] = NULL; + decoded->canonical_option[3] = NULL; + decoded->value = 1; + decoded->errors = 0; } /* Handle the switch DECODED for the language indicated by LANG_MASK, |