summaryrefslogtreecommitdiff
path: root/gcc/opts.c
diff options
context:
space:
mode:
authorjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>2010-08-16 10:15:15 +0000
committerjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>2010-08-16 10:15:15 +0000
commite28aa11462a447d3a30e8a53a7058d1158e33e5f (patch)
treea8e55701ad8152ef11268c33109062e262817e2e /gcc/opts.c
parent9a14ba4fd861436294514c3008d03f1f77de058a (diff)
downloadgcc-e28aa11462a447d3a30e8a53a7058d1158e33e5f.tar.gz
* common.opt: Add driver options.
(auxbase, auxbase-strip, quiet, version): Mark RejectDriver. * doc/options.texi (Driver, RejectDriver): Document. * gcc.c (pass_exit_codes, print_search_dirs, print_file_name, print_prog_name, print_multi_directory, print_sysroot, print_multi_os_directory, print_multi_lib, print_sysroot_headers_suffix, report_times, combine_flag, use_pipes, wrapper_string): Remove. (save_switch, driver_unknown_option_callback, driver_wrong_lang_callback, driver_post_handling_callback, driver_handle_option): New. (spec_lang, last_language_n_infiles): Make file-scope static instead of local to process_command. (process_command): Use decode_cmdline_options_to_array and read_cmdline_option for option processing. Compute have_c in prescan of decoded options. * opt-functions.awk (switch_flags): Handle Driver and RejectDriver. (var_type, var_type_struct): Handle Separate options as generating const char * variables. * opts-common.c (decode_cmdline_option): Expect CL_COMMON and CL_TARGET to be passed by caller if required. (decode_cmdline_options_to_array): Update comment. * opts.c (complain_wrong_lang): Handle options only valid for the driver. (decode_options): Update call to decode_cmdline_options_to_array. (print_filtered_help): Ignore driver-only options. (print_specific_help): Ignore CL_DRIVER. (common_handle_option): Don't call print_specific_help for CL_DRIVER. * opts.h (CL_DRIVER, CL_REJECT_DRIVER): Define. (CL_PARAMS, CL_WARNING, CL_OPTIMIZATION, CL_TARGET, CL_COMMON): Update values. c-family: * c.opt (MDX, MMDX, lang-asm): Mark RejectDriver. fortran: * lang.opt (MDX, MMDX): Mark RejectDriver. java: * lang.opt (MD_, MMD_, version): Mark RejectDriver. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@163279 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/opts.c')
-rw-r--r--gcc/opts.c37
1 files changed, 28 insertions, 9 deletions
diff --git a/gcc/opts.c b/gcc/opts.c
index 6e528058750..d04e81c6493 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -418,17 +418,27 @@ complain_wrong_lang (const struct cl_decoded_option *decoded,
{
const struct cl_option *option = &cl_options[decoded->opt_index];
const char *text = decoded->orig_option_with_args_text;
- char *ok_langs, *bad_lang;
+ char *ok_langs = NULL, *bad_lang = NULL;
+ unsigned int opt_flags = option->flags;
if (!lang_hooks.complain_wrong_lang_p (option))
return;
- ok_langs = write_langs (option->flags);
- bad_lang = write_langs (lang_mask);
-
- /* Eventually this should become a hard error IMO. */
- warning (0, "command line option \"%s\" is valid for %s but not for %s",
- text, ok_langs, bad_lang);
+ opt_flags &= ((1U << cl_lang_count) - 1) | CL_DRIVER;
+ if (opt_flags != CL_DRIVER)
+ ok_langs = write_langs (opt_flags);
+ if (lang_mask != CL_DRIVER)
+ bad_lang = write_langs (lang_mask);
+
+ if (opt_flags == CL_DRIVER)
+ error ("command line option %qs is valid for the driver but not for %s",
+ text, bad_lang);
+ else if (lang_mask == CL_DRIVER)
+ gcc_unreachable ();
+ else
+ /* Eventually this should become a hard error IMO. */
+ warning (0, "command line option %qs is valid for %s but not for %s",
+ text, ok_langs, bad_lang);
free (ok_langs);
free (bad_lang);
@@ -681,7 +691,8 @@ decode_options (unsigned int argc, const char **argv,
else
lang_mask = initial_lang_mask;
- decode_cmdline_options_to_array (argc, argv, lang_mask,
+ decode_cmdline_options_to_array (argc, argv,
+ lang_mask | CL_COMMON | CL_TARGET,
decoded_options, decoded_options_count);
if (first_time_p)
/* Perform language-specific options initialization. */
@@ -1193,6 +1204,12 @@ print_filtered_help (unsigned int include_flags,
if ((option->flags & exclude_flags) != 0)
continue;
+ /* The driver currently prints its own help text. */
+ if ((option->flags & CL_DRIVER) != 0
+ && (option->flags & (((1U << cl_lang_count) - 1)
+ | CL_COMMON | CL_TARGET)) == 0)
+ continue;
+
found = true;
/* Skip switches that have already been printed. */
if (printed[i])
@@ -1333,6 +1350,7 @@ print_specific_help (unsigned int include_flags,
switch (flag & include_flags)
{
case 0:
+ case CL_DRIVER:
break;
case CL_TARGET:
@@ -1436,7 +1454,8 @@ common_handle_option (const struct cl_decoded_option *decoded,
print_specific_help (0, undoc_mask, all_langs_mask);
/* Then display any remaining, non-language options. */
for (i = CL_MIN_OPTION_CLASS; i <= CL_MAX_OPTION_CLASS; i <<= 1)
- print_specific_help (i, undoc_mask, 0);
+ if (i != CL_DRIVER)
+ print_specific_help (i, undoc_mask, 0);
exit_after_options = true;
break;
}