Hi,

This patch changes most trivial cases to use the new  (Lang)EnabledBy.

Bootstrapped and regression tested on x86_64-linux-gnu. OK?

2012-10-17  Manuel López-Ibáñez  <m...@gcc.gnu.org>

        PR c/53063
        PR c/40989
c-family/
        * c.opt (Waddress,Wchar-subscripts,Wsign-conversion,Wimplicit,
        Wimplicit-function-declaration,Wimplicit-int,Wsizeof-pointer-memaccess,
        Wnarrowing,Wparentheses,Wpointer-sign,Wreturn-type,Wsequence-point,
        Wsign-compare,Wuninitialized,Wmaybe-uninitialized,Wunused,
        Wvolatile-register-var): Add LangEnabledBy or EnabledBy.
        * c-opts.c (c_common_handle_option): Remove explicit handling from
        here.
        (c_common_post_options): Likewise.
gcc/
        * opts.c (finish_options): Remove explicit handling from here.


Unfortunately, I cannot remove all Init(-1) because the real Init
value is conditional on the language or a more complex condition:

[...]
      if (!c_dialect_cxx ())
        {
          /* We set this to 2 here, but 1 in -Wmain, so -ffreestanding
             can turn it off only if it's not explicit.  */
          if (warn_main == -1)
            warn_main = (value ? 2 : 0);

          /* In C, -Wall and -Wc++-compat turns on -Wenum-compare,
             which we do here.  In C++ it is on by default, which is
             done in c_common_post_options.  */
          if (warn_enum_compare == -1)
            warn_enum_compare = value;
        }
[...]
    case OPT_Wc___compat:
      /* Because -Wenum-compare is the default in C++, -Wc++-compat
         implies -Wenum-compare.  */
      if (warn_enum_compare == -1 && value)
        warn_enum_compare = value;
      break;

[...]
   /* -Woverlength-strings is off by default, but is enabled by -Wpedantic.
      It is never enabled in C++, as the minimum limit is not normative
      in that standard.  */
   if (warn_overlength_strings == -1 || c_dialect_cxx ())
     warn_overlength_strings = 0;
  /* Wmain is enabled by default in C++ but not in C.  */
  /* Wmain is disabled by default for -ffreestanding (!flag_hosted),
     even if -Wall was given (warn_main will be 2 if set by -Wall, 1
     if set by -Wmain).  */
  if (warn_main == -1)
    warn_main = (c_dialect_cxx () && flag_hosted) ? 1 : 0;
  else if (warn_main == 2)
    warn_main = flag_hosted ? 1 : 0;

  /* -Wimplicit-function-declaration is enabled by default for C99.  */
  if (warn_implicit_function_declaration == -1)
    warn_implicit_function_declaration = flag_isoc99;

  if (cxx_dialect >= cxx0x)
    {
      /* If we're allowing C++0x constructs, don't warn about C++98
         identifiers which are keywords in C++0x.  */
      warn_cxx0x_compat = 0;

      if (warn_narrowing == -1)
        warn_narrowing = 1;
    }
  else if (warn_narrowing == -1)
    warn_narrowing = 0;

Not sure how to encode these dependencies. Ideas?

Attachment: manyenabledby.diff
Description: Binary data

Reply via email to