From 27e51192eb152291b2a55cadb836210314f64438 Mon Sep 17 00:00:00 2001 From: Tobias Burnus Date: Sat, 29 Nov 2014 01:04:48 +0100 Subject: [PATCH] opt-functions.awk (lang_enabled_by): Support || for enabled-by. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 2014-11-29 Tobias Burnus Manuel López-Ibáñez gcc/ * opt-functions.awk (lang_enabled_by): Support || for enabled-by. * optc-gen.awk: Ditto. * doc/options.texi (LangEnabledBy, EnabledBy): Document the || syntax. gcc/fortran/ * lang.opt (Wtabs): Combine duplicated item into a single one using || for LangEnabledBy. Co-Authored-By: Manuel López-Ibáñez From-SVN: r218175 --- gcc/ChangeLog | 9 +++++++++ gcc/c-family/c.opt | 30 +++++------------------------ gcc/doc/options.texi | 7 +++++-- gcc/fortran/ChangeLog | 6 ++++++ gcc/fortran/lang.opt | 6 +----- gcc/opt-functions.awk | 44 +++++++++++++++++++++++-------------------- gcc/optc-gen.awk | 14 +++++++++++--- 7 files changed, 61 insertions(+), 55 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9a525e5fe02..6fdbadb2c11 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2014-11-29 Tobias Burnus + Manuel López-Ibáñez + + * opt-functions.awk (lang_enabled_by): Support || for + enabled-by. + * optc-gen.awk: Ditto. + * doc/options.texi (LangEnabledBy, EnabledBy): Document the + || syntax. + 2014-11-28 Mike Stump * bitmap.c (bitmap_ior): Zap current as it could be deleted. diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt index 85dcb98b6a6..b9f7c656209 100644 --- a/gcc/c-family/c.opt +++ b/gcc/c-family/c.opt @@ -372,13 +372,9 @@ C++ ObjC++ Var(warn_delete_incomplete) Init(1) Warning Warn when deleting a pointer to incomplete type Wdelete-non-virtual-dtor -C++ ObjC++ Var(warn_delnonvdtor) Warning LangEnabledBy(C++ ObjC++,Wall) +C++ ObjC++ Var(warn_delnonvdtor) Warning LangEnabledBy(C++ ObjC++,Wall || Weffc++) Warn about deleting polymorphic objects with non-virtual destructors -Wdelete-non-virtual-dtor -LangEnabledBy(C++ ObjC++,Weffc++) -; - Wdeprecated C C++ ObjC ObjC++ CPP(cpp_warn_deprecated) CppReason(CPP_W_DEPRECATED) Var(warn_deprecated) Init(1) Warning Warn if a deprecated compiler feature, class, method, or field is used @@ -408,13 +404,9 @@ C ObjC C++ ObjC++ CPP(warn_endif_labels) CppReason(CPP_W_ENDIF_LABELS) Var(cpp_w Warn about stray tokens after #elif and #endif Wenum-compare -C ObjC C++ ObjC++ Var(warn_enum_compare) Init(-1) Warning LangEnabledBy(C ObjC,Wall) +C ObjC C++ ObjC++ Var(warn_enum_compare) Init(-1) Warning LangEnabledBy(C ObjC,Wall || Wc++-compat) Warn about comparison of different enum types -Wenum-compare -LangEnabledBy(C ObjC,Wc++-compat) -; - Werror C ObjC C++ ObjC++ ; Documented in common.opt @@ -614,13 +606,9 @@ C ObjC C++ ObjC++ CPP(warn_multichar) CppReason(CPP_W_MULTICHAR) Var(cpp_warn_mu Warn about use of multi-character character constants Wnarrowing -C ObjC C++ ObjC++ Warning Var(warn_narrowing) Init(-1) LangEnabledBy(C++ ObjC++,Wall) +C ObjC C++ ObjC++ Warning Var(warn_narrowing) Init(-1) LangEnabledBy(C++ ObjC++,Wall || Wc++0x-compat) Warn about narrowing conversions within { } that are ill-formed in C++11 -Wnarrowing -C ObjC C++ ObjC++ LangEnabledBy(C++ ObjC++,Wc++0x-compat) -; - Wnested-externs C ObjC Var(warn_nested_externs) Warning Warn about \"extern\" declarations not at file scope @@ -721,13 +709,9 @@ C ObjC C++ ObjC++ Var(warn_pointer_arith) Warning LangEnabledBy(C ObjC C++ ObjC+ Warn about function pointer arithmetic Wpointer-sign -C ObjC Var(warn_pointer_sign) Warning LangEnabledBy(C ObjC,Wall) +C ObjC Var(warn_pointer_sign) Warning LangEnabledBy(C ObjC,Wall || Wpedantic) Warn when a pointer differs in signedness in an assignment -Wpointer-sign -C ObjC LangEnabledBy(C ObjC,Wpedantic) -; - Wpointer-to-int-cast C ObjC Var(warn_pointer_to_int_cast) Init(1) Warning Warn when a pointer is cast to an integer of a different size @@ -877,13 +861,9 @@ C ObjC C++ ObjC++ Var(warn_unused_result) Init(1) Warning Warn if a caller of a function, marked with attribute warn_unused_result, does not use its return value Wvariadic-macros -C ObjC C++ ObjC++ CPP(warn_variadic_macros) CppReason(CPP_W_VARIADIC_MACROS) Var(cpp_warn_variadic_macros) Init(0) Warning LangEnabledBy(C ObjC C++ ObjC++,Wpedantic) +C ObjC C++ ObjC++ CPP(warn_variadic_macros) CppReason(CPP_W_VARIADIC_MACROS) Var(cpp_warn_variadic_macros) Init(0) Warning LangEnabledBy(C ObjC C++ ObjC++,Wpedantic || Wtraditional) Warn about using variadic macros -Wvariadic-macros -LangEnabledBy(C ObjC C++ ObjC++,Wtraditional) -; - Wvarargs C ObjC C++ ObjC++ Warning Var(warn_varargs) Init(1) Warn about questionable usage of the macros used to retrieve variable arguments diff --git a/gcc/doc/options.texi b/gcc/doc/options.texi index bcffdf86aaa..1ead0972134 100644 --- a/gcc/doc/options.texi +++ b/gcc/doc/options.texi @@ -459,15 +459,18 @@ value of @option{-fmath-errno} for languages that do not use @code{errno}. @item EnabledBy(@var{opt}) +@itemx EnabledBy(@var{opt} || @var{opt2}) @itemx EnabledBy(@var{opt} && @var{opt2}) If not explicitly set, the option is set to the value of -@option{-@var{opt}}. The second form specifies that the option is +@option{-@var{opt}}; multiple options can be given, separated by +@code{||}. The third form using @code{&&} specifies that the option is only set if both @var{opt} and @var{opt2} are set. @item LangEnabledBy(@var{language}, @var{opt}) @itemx LangEnabledBy(@var{language}, @var{opt}, @var{posarg}, @var{negarg}) When compiling for the given language, the option is set to the value -of @option{-@var{opt}}, if not explicitly set. In the second form, if +of @option{-@var{opt}}, if not explicitly set. @var{opt} can be also a list +of @code{||} separated options. In the second form, if @var{opt} is used in the positive form then @var{posarg} is considered to be passed to the option, and if @var{opt} is used in the negative form then @var{negarg} is considered to be passed to the option. It diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 68c941654f6..a6e9035a29f 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2014-11-29 Tobias Burnus + Manuel López-Ibáñez + + * lang.opt (Wtabs): Combine duplicated item into a single + one using || for LangEnabledBy. + 2014-11-25 Tobias Burnus * error.c (gfc_internal_error): Convert to common diagnostics. diff --git a/gcc/fortran/lang.opt b/gcc/fortran/lang.opt index dc7c2a7d522..1d6cdde47a9 100644 --- a/gcc/fortran/lang.opt +++ b/gcc/fortran/lang.opt @@ -298,13 +298,9 @@ Fortran Warning Warn about \"suspicious\" constructs Wtabs -Fortran Warning Var(warn_tabs) LangEnabledBy(Fortran,Wall) +Fortran Warning Var(warn_tabs) LangEnabledBy(Fortran,Wall || Wpedantic) Permit nonconforming uses of the tab character -Wtabs -LangEnabledBy(Fortran,Wpedantic) -; - Wunderflow Fortran Warning Warn about underflow of numerical constant expressions diff --git a/gcc/opt-functions.awk b/gcc/opt-functions.awk index 381bb50028a..a83b4a83c9d 100644 --- a/gcc/opt-functions.awk +++ b/gcc/opt-functions.awk @@ -319,29 +319,33 @@ function search_var_name(name, opt_numbers, opts, flags, n_opts) function lang_enabled_by(enabledby_langs, enabledby_name, enabledby_posarg, enabledby_negarg) { n_enabledby_arg_langs = split(enabledby_langs, enabledby_arg_langs, " "); - enabledby_index = opt_numbers[enabledby_name]; - if (enabledby_index == "") { - print "#error LangEnabledby: " enabledby_name + if (enabledby_posarg != "" && enabledby_negarg != "") { + with_args = "," enabledby_posarg "," enabledby_negarg + } else if (enabledby_posarg == "" && enabledby_negarg == "") { + with_args = "" } else { - if (enabledby_posarg != "" && enabledby_negarg != "") { - with_args = "," enabledby_posarg "," enabledby_negarg - } else if (enabledby_posarg == "" && enabledby_negarg == "") { - with_args = "" + print "#error LangEnabledBy("enabledby_langs","enabledby_name", " \ + enabledby_posarg", " enabledby_negargs \ + ") 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 LangEnabledBy("enabledby_langs","enabledby_name", " \ + enabledby_posarg", " enabledby_negargs") has invalid ENABLEDBY_NAME" } else { - print "#error LangEnabledBy("enabledby_langs","enabledby_name", " \ - enabledby_posarg", " enabledby_negargs \ - ") with three arguments, it should have either 2 or 4" - } - - 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_name] == "") { - enabledby[lang_name,n_enabledby_lang[lang_index]] = enabledby_name; - n_enabledby_lang[lang_index]++; + 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 ";"; } - enables[lang_name,enabledby_name] = enables[lang_name,enabledby_name] opts[i] with_args ";"; } } } - diff --git a/gcc/optc-gen.awk b/gcc/optc-gen.awk index ecb225c163a..8868510657f 100644 --- a/gcc/optc-gen.awk +++ b/gcc/optc-gen.awk @@ -38,8 +38,16 @@ for (i = 0; i < n_langs; i++) { for (i = 0; i < n_opts; i++) { enabledby_arg = opt_args("EnabledBy", flags[i]); if (enabledby_arg != "") { - n_enabledby_names = split(enabledby_arg, enabledby_names, " && "); - if (n_enabledby_names > 2) { + logical_and = index(enabledby_arg, " && "); + if (logical_and != 0) { + # EnabledBy(arg1 && arg2) + split_sep = " && "; + } else { + # EnabledBy(arg) or EnabledBy(arg1 || arg2 || arg3) + split_sep = " \\|\\| "; + } + n_enabledby_names = split(enabledby_arg, enabledby_names, split_sep); + if (logical_and != 0 && n_enabledby_names > 2) { print "#error EnabledBy (Wfoo && Wbar && Wbaz) not currently supported" } for (j = 1; j <= n_enabledby_names; j++) { @@ -49,7 +57,7 @@ for (i = 0; i < n_opts; i++) { print "#error Enabledby: " enabledby_name } else { condition = ""; - if (n_enabledby_names == 2) { + if (logical_and != 0) { opt_var_name_1 = search_var_name(enabledby_names[1], opt_numbers, opts, flags, n_opts); opt_var_name_2 = search_var_name(enabledby_names[2], opt_numbers, opts, flags, n_opts); if (opt_var_name_1 == "") { -- 2.30.2