From: Martin Liska Date: Tue, 12 Nov 2019 10:07:37 +0000 (+0100) Subject: Param to options conversion. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=76c26af90ea3af7487e701e451a4591a81727e8a;p=gcc.git Param to options conversion. 2019-11-12 Martin Liska * common.opt: Remove --param and --param= options. * opt-functions.awk: Mark CL_PARAMS for options that have Param keyword. * opts-common.c (decode_cmdline_options_to_array): Replace --param key=value with --param=key=value. * opts.c (print_filtered_help): Remove special printing of params. (print_specific_help): Update title for params. (common_handle_option): Do not handle OPT__param. opts.h (SET_OPTION_IF_UNSET): New macro. * doc/options.texi: Document Param keyword. From-SVN: r278083 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 008e0db21de..a1a3c8b5c5c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,17 @@ +2019-11-12 Martin Liska + + * common.opt: Remove --param and --param= options. + * opt-functions.awk: Mark CL_PARAMS for options + that have Param keyword. + * opts-common.c (decode_cmdline_options_to_array): + Replace --param key=value with --param=key=value. + * opts.c (print_filtered_help): Remove special + printing of params. + (print_specific_help): Update title for params. + (common_handle_option): Do not handle OPT__param. + opts.h (SET_OPTION_IF_UNSET): New macro. + * doc/options.texi: Document Param keyword. + 2019-11-12 Maciej W. Rozycki Frederik Harwath Thomas Schwinge diff --git a/gcc/common.opt b/gcc/common.opt index 12c0083964e..8c6acabb1fc 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -437,13 +437,6 @@ Common Driver Alias(-target-help) fversion Common Driver Alias(-version) --param -Common Separate ---param = Set parameter to value. See below for a complete list of parameters. - --param= -Common Joined Alias(-param) - -sysroot Driver Separate Alias(-sysroot=) diff --git a/gcc/doc/options.texi b/gcc/doc/options.texi index b59f4d39aef..c7c70acd526 100644 --- a/gcc/doc/options.texi +++ b/gcc/doc/options.texi @@ -475,6 +475,9 @@ affect executable code generation may use this flag instead, so that the option is not taken into account in ways that might affect executable code generation. +@item Param +This is an option that is a parameter. + @item Undocumented The option is deliberately missing documentation and should not be included in the @option{--help} output. diff --git a/gcc/opt-functions.awk b/gcc/opt-functions.awk index c1da80c648c..4f02b74e97c 100644 --- a/gcc/opt-functions.awk +++ b/gcc/opt-functions.awk @@ -105,7 +105,8 @@ function switch_flags (flags) test_flag("Undocumented", flags, " | CL_UNDOCUMENTED") \ test_flag("NoDWARFRecord", flags, " | CL_NO_DWARF_RECORD") \ test_flag("Warning", flags, " | CL_WARNING") \ - test_flag("(Optimization|PerFunction)", flags, " | CL_OPTIMIZATION") + test_flag("(Optimization|PerFunction)", flags, " | CL_OPTIMIZATION") \ + test_flag("Param", flags, " | CL_PARAMS") sub( "^0 \\| ", "", result ) return result } diff --git a/gcc/opts-common.c b/gcc/opts-common.c index b4ec1bd25ac..d55dc93e165 100644 --- a/gcc/opts-common.c +++ b/gcc/opts-common.c @@ -961,6 +961,15 @@ decode_cmdline_options_to_array (unsigned int argc, const char **argv, continue; } + /* Interpret "--param" "key=name" as "--param=key=name". */ + const char *needle = "--param"; + if (i + 1 < argc && strcmp (opt, needle) == 0) + { + const char *replacement + = opts_concat (needle, "=", argv[i + 1], NULL); + argv[++i] = replacement; + } + n = decode_cmdline_option (argv + i, lang_mask, &opt_array[num_decoded_options]); num_decoded_options++; diff --git a/gcc/opts.c b/gcc/opts.c index f46b468a968..394cbfd1c56 100644 --- a/gcc/opts.c +++ b/gcc/opts.c @@ -1278,38 +1278,6 @@ print_filtered_help (unsigned int include_flags, bool displayed = false; char new_help[256]; - if (include_flags == CL_PARAMS) - { - for (i = 0; i < LAST_PARAM; i++) - { - const char *param = compiler_params[i].option; - - help = compiler_params[i].help; - if (help == NULL || *help == '\0') - { - if (exclude_flags & CL_UNDOCUMENTED) - continue; - help = undocumented_msg; - } - - /* Get the translation. */ - help = _(help); - - if (!opts->x_quiet_flag) - { - snprintf (new_help, sizeof (new_help), - _("default %d minimum %d maximum %d"), - compiler_params[i].default_value, - compiler_params[i].min_value, - compiler_params[i].max_value); - help = new_help; - } - wrap_help (help, param, strlen (param), columns); - } - putchar ('\n'); - return; - } - if (!opts->x_help_printed) opts->x_help_printed = XCNEWVAR (char, cl_options_count); @@ -1679,7 +1647,7 @@ print_specific_help (unsigned int include_flags, description = _("The following options are language-independent"); break; case CL_PARAMS: - description = _("The --param option recognizes the following as parameters"); + description = _("The following options control parameters"); break; default: if (i >= cl_lang_count) @@ -2241,10 +2209,6 @@ common_handle_option (struct gcc_options *opts, switch (code) { - case OPT__param: - handle_param (opts, opts_set, loc, arg); - break; - case OPT__help: { unsigned int all_langs_mask = (1U << cl_lang_count) - 1; diff --git a/gcc/opts.h b/gcc/opts.h index 47223229388..0de8e4269db 100644 --- a/gcc/opts.h +++ b/gcc/opts.h @@ -461,4 +461,14 @@ extern bool parse_and_check_align_values (const char *flag, bool report_error, location_t loc); +/* Set OPTION in OPTS to VALUE if the option is not set in OPTS_SET. */ + +#define SET_OPTION_IF_UNSET(OPTS, OPTS_SET, OPTION, VALUE) \ + do \ + { \ + if (!(OPTS_SET)->x_ ## OPTION) \ + (OPTS)->x_ ## OPTION = VALUE; \ + } \ + while (false) + #endif