diff options
author | Thomas Schwinge <thomas@codesourcery.com> | 2022-03-28 10:55:49 +0200 |
---|---|---|
committer | Thomas Schwinge <thomas@codesourcery.com> | 2022-03-30 08:58:00 +0200 |
commit | d8e91994bad073b713f2b47bc6171f3a4e422562 (patch) | |
tree | e054b7de1c3c6ca5a13d30d17e6779569758cf62 /gcc/opt-functions.awk | |
parent | 0087f3600be51167f6bcaf2d887b0ac8a320ede2 (diff) | |
download | gcc-d8e91994bad073b713f2b47bc6171f3a4e422562.zip gcc-d8e91994bad073b713f2b47bc6171f3a4e422562.tar.gz gcc-d8e91994bad073b713f2b47bc6171f3a4e422562.tar.bz2 |
options: Improve 'LangEnabledBy' option property diagnostics
No changes in generated files.
gcc/
* opt-functions.awk (n_args): New function.
(lang_enabled_by): Merge function into...
* optc-gen.awk <END>: ... sole user here.
Improve diagnostics.
Diffstat (limited to 'gcc/opt-functions.awk')
-rw-r--r-- | gcc/opt-functions.awk | 47 |
1 files changed, 11 insertions, 36 deletions
diff --git a/gcc/opt-functions.awk b/gcc/opt-functions.awk index 9eccf9b..2aee0b9 100644 --- a/gcc/opt-functions.awk +++ b/gcc/opt-functions.awk @@ -82,6 +82,17 @@ function opt_args_non_empty(name, flags, description) return args } +# Return the number of comma-separated element of S. +function n_args(s) +{ + n = 1 + while (s ~ ",") { + n++ + sub("[^,]*, *", "", s) + } + return n +} + # Return the Nth comma-separated element of S. Return the empty string # if S does not contain N elements. function nth_arg(n, s) @@ -376,39 +387,3 @@ function integer_range_info(range_option, init, option, uinteger_used) else return "-1, -1" } - -# Handle LangEnabledBy(ENABLED_BY_LANGS, ENABLEDBY_NAME, ENABLEDBY_POSARG, -# ENABLEDBY_NEGARG). This function does not return anything. -function lang_enabled_by(enabledby_langs, enabledby_name, enabledby_posarg, enabledby_negarg) -{ - n_enabledby_arg_langs = split(enabledby_langs, enabledby_arg_langs, " "); - if (enabledby_posarg != "" && enabledby_negarg != "") { - with_args = "," enabledby_posarg "," enabledby_negarg - } else if (enabledby_posarg == "" && enabledby_negarg == "") { - with_args = "" - } else { - print "#error " opts[i] " LangEnabledBy("enabledby_langs","enabledby_name", " \ - enabledby_posarg", " enabledby_negarg \ - ") with three arguments, it should have either 2 or 4" - } - - n_enabledby_array = split(enabledby_name, enabledby_array, " \\|\\| "); - for (k = 1; k <= n_enabledby_array; k++) { - enabledby_index = opt_numbers[enabledby_array[k]]; - if (enabledby_index == "") { - print "#error " opts[i] " LangEnabledBy("enabledby_langs","enabledby_name", " \ - enabledby_posarg", " enabledby_negarg"), unknown option '" enabledby_name "'" - } else { - for (j = 1; j <= n_enabledby_arg_langs; j++) { - lang_name = lang_sanitized_name(enabledby_arg_langs[j]); - lang_index = lang_numbers[enabledby_arg_langs[j]]; - if (enables[lang_name,enabledby_array[k]] == "") { - enabledby[lang_name,n_enabledby_lang[lang_index]] = enabledby_array[k]; - n_enabledby_lang[lang_index]++; - } - enables[lang_name,enabledby_array[k]] \ - = enables[lang_name,enabledby_array[k]] opts[i] with_args ";"; - } - } - } -} |