This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch, option handling] optc-gen.awk - support || in EnabledBy()


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]