This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Patch, option handling] optc-gen.awk - support || in EnabledBy()
- From: Manuel López-Ibáñez <lopezibanez at gmail dot com>
- To: Tobias Burnus <burnus at net-b dot de>, Gcc Patch List <gcc-patches at gcc dot gnu dot org>, "Joseph S. Myers" <joseph at codesourcery dot com>
- Date: Sat, 22 Nov 2014 23:37:38 +0100
- Subject: Re: [Patch, option handling] optc-gen.awk - support || in EnabledBy()
- Authentication-results: sourceware.org; auth=none
For what is worth, the patch looks good to me, except that the form
EnabledBy(@var{opt} || @var{opt2} needs documentation in
doc/options.texi.
Perhaps it could be more condensed as (untested!):
Index: optc-gen.awk
===================================================================
--- optc-gen.awk (revision 217510)
+++ optc-gen.awk (working copy)
@@ -38,8 +38,16 @@
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 @@
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 == "") {
If I recall correctly, there are several -W* flags in common.opt and
c-family/c.opt that benefit from this cleanup (Wpointer-sign being
one). It would be nice to convert them to the new format together with
the patch.
A version handling LangEnabledBy(Lang, Wx || Wy) should be fairly
similar and probably even more useful, if you wish to fix also that.
Cheers,
Manuel.