2014-11-23 Tobias Burnus <burnus@net-b.de>
Manuel López-Ibáñez <manu@gcc.gnu.org>
gcc/c-family/
* c.opt (Wdelete-non-virtual-dtor, Wenum-compare, Wnarrowing,
Wpointer-sign, Wvariadic-macros): Combine duplicated warning
lines into a single one using || for LangEnabledBy.
gcc/
* opt-functions.awk (lang_enabled_by): Support || for
enabled-by.
* optc-gen.awk: Ditto.
* doc/options.texi (LangEnabledBy, EnabledBy): Document the
|| syntax.
fortran/
* lang.opt (Wtabs): Combine duplicated item into a single
one using || for LangEnabledBy.
@@ -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
@@ -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
@@ -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
@@ -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 ";";
}
}
}
-
@@ -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 == "") {