diff options
author | Martin Sebor <msebor@redhat.com> | 2019-07-24 20:34:03 +0000 |
---|---|---|
committer | Martin Sebor <msebor@gcc.gnu.org> | 2019-07-24 14:34:03 -0600 |
commit | fa5baeedd47e84b36aff8191bfdf86ee03829a4c (patch) | |
tree | 555ecd4cee3204df4576e6ad2ed71999246dd69c /gcc/opts.c | |
parent | e34616747028ebeb0be867dc6a23682539bfab60 (diff) | |
download | gcc-fa5baeedd47e84b36aff8191bfdf86ee03829a4c.zip gcc-fa5baeedd47e84b36aff8191bfdf86ee03829a4c.tar.gz gcc-fa5baeedd47e84b36aff8191bfdf86ee03829a4c.tar.bz2 |
PR driver/80545 - option -Wstringop-overflow not recognized by Fortran
gcc/cp/ChangeLog:
PR driver/80545
* decl.c (finish_function): Use lang_mask.
gcc/testsuite/ChangeLog:
PR driver/80545
* gcc.misc-tests/help.exp: Add tests.
* lib/options.exp: Handle C++.
gcc/ChangeLog:
PR driver/80545
* diagnostic.c (diagnostic_classify_diagnostic): Use lang_mask.
(diagnostic_report_diagnostic): Same.
* diagnostic.h (diagnostic_context::option_enabled): Add an argument.
(diagnostic_context::lang_mask): New data member.
* ipa-pure-const.c (suggest_attribute): Use
lang_hooks.option_lang_mask ().
* opts-common.c (option_enabled): Handle new argument.
(get_option_state): Pass an additional argument.
* opts.c (print_filtered_help): Print supported languages for
unsupported options. Adjust printing of current state.
* opts.h (option_enabled): Add argument.
* toplev.c (print_switch_values): Use lang_mask.
(general_init): Set global_dc->lang_mask.
From-SVN: r273771
Diffstat (limited to 'gcc/opts.c')
-rw-r--r-- | gcc/opts.c | 76 |
1 files changed, 71 insertions, 5 deletions
@@ -32,6 +32,7 @@ along with GCC; see the file COPYING3. If not see #include "common/common-target.h" #include "spellcheck.h" #include "opt-suggestions.h" +#include "diagnostic-color.h" static void set_Wstrict_aliasing (struct gcc_options *opts, int onoff); @@ -1460,10 +1461,37 @@ print_filtered_help (unsigned int include_flags, else strcpy (new_help, "\t"); + /* Set to print whether the option is enabled or disabled, + or, if it's an alias for another option, the name of + the aliased option. */ + bool print_state = false; + if (flag_var != NULL && option->var_type != CLVC_DEFER) { - if (option->flags & CL_JOINED) + /* If OPTION is only available for a specific subset + of languages other than this one, mention them. */ + bool avail_for_lang = true; + if (unsigned langset = option->flags & CL_LANG_ALL) + { + if (!(langset & lang_mask)) + { + avail_for_lang = false; + strcat (new_help, _("[available in ")); + for (unsigned i = 0, n = 0; (1U << i) < CL_LANG_ALL; ++i) + if (langset & (1U << i)) + { + if (n++) + strcat (new_help, ", "); + strcat (new_help, lang_names[i]); + } + strcat (new_help, "]"); + } + } + if (!avail_for_lang) + ; /* Print nothing else if the option is not available + in the current language. */ + else if (option->flags & CL_JOINED) { if (option->var_type == CLVC_STRING) { @@ -1487,12 +1515,50 @@ print_filtered_help (unsigned int include_flags, "%s", arg); } else - sprintf (new_help + strlen (new_help), - "%d", * (int *) flag_var); + { + if (option->cl_host_wide_int) + sprintf (new_help + strlen (new_help), + _("%llu bytes"), (unsigned long long) + *(unsigned HOST_WIDE_INT *) flag_var); + else + sprintf (new_help + strlen (new_help), + "%i", * (int *) flag_var); + } + } + else + print_state = true; + } + else + /* When there is no argument, print the option state only + if the option takes no argument. */ + print_state = !(option->flags & CL_JOINED); + + if (print_state) + { + if (option->alias_target < N_OPTS + && option->alias_target != OPT_SPECIAL_deprecated + && option->alias_target != OPT_SPECIAL_ignore + && option->alias_target != OPT_SPECIAL_input_file + && option->alias_target != OPT_SPECIAL_program_name + && option->alias_target != OPT_SPECIAL_unknown) + { + const struct cl_option *target + = &cl_options[option->alias_target]; + sprintf (new_help + strlen (new_help), "%s%s", + target->opt_text, + option->alias_arg ? option->alias_arg : ""); } + else if (option->alias_target == OPT_SPECIAL_ignore) + strcat (new_help, ("[ignored]")); else - strcat (new_help, option_enabled (i, opts) - ? _("[enabled]") : _("[disabled]")); + { + /* Print the state for an on/off option. */ + int ena = option_enabled (i, lang_mask, opts); + if (ena > 0) + strcat (new_help, _("[enabled]")); + else if (ena == 0) + strcat (new_help, _("[disabled]")); + } } help = new_help; |