]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c/53063 (encode group options in the .opt files)
authorManuel López-Ibáñez <manu@gcc.gnu.org>
Mon, 14 May 2012 13:30:32 +0000 (13:30 +0000)
committerManuel López-Ibáñez <manu@gcc.gnu.org>
Mon, 14 May 2012 13:30:32 +0000 (13:30 +0000)
2012-05-14  Manuel López-Ibáñez  <manu@gcc.gnu.org>

PR 53063
c-family/
* c.opt (Wc++0X-compat,Wdelete-non-virtual-dtor,Wjump-misses-init,
Wreorder): Use LangEnabledBy.
* c-opts.c (c_common_handle_option): Do not enable them
explicitly. Call lang-specific generated functions.
(c_common_post_options): Do not set them here.
gcc/
* doc/options.texi: (LangEnabledBy): Document it.
* optc-gen.awk: Handle LangEnabledBy.
* opth-gen.awk: Generate declaration for lang-specific functions.
* opt-read.awk: Record lang numbers.
* opt-functions.awk (flag_set_p): Ignore the arguments of flags.
(lang_sanitized_name): New.
ada/
* gcc-interface/misc.c: Include opts.h and options.h before tm.h.
(gnat_handle_option): Call lang-specific generated function.
fortran/
* options.c (gfc_handle_option): Call lang-specific generated function.

From-SVN: r187462

13 files changed:
gcc/ChangeLog
gcc/ada/ChangeLog
gcc/ada/gcc-interface/misc.c
gcc/c-family/ChangeLog
gcc/c-family/c-opts.c
gcc/c-family/c.opt
gcc/doc/options.texi
gcc/fortran/ChangeLog
gcc/fortran/options.c
gcc/opt-functions.awk
gcc/opt-read.awk
gcc/optc-gen.awk
gcc/opth-gen.awk

index bd8f7759033248e5250c7f61aea3f6c0506d7b1a..9933288018fe430ecb1a8c1415780866944e973e 100644 (file)
@@ -1,3 +1,13 @@
+2012-05-14  Manuel López-Ibáñez  <manu@gcc.gnu.org>
+
+       PR 53063
+       * doc/options.texi: (LangEnabledBy): Document it.
+       * optc-gen.awk: Handle LangEnabledBy.
+       * opth-gen.awk: Generate declaration for lang-specific functions.
+       * opt-read.awk: Record lang numbers.
+       * opt-functions.awk (flag_set_p): Ignore the arguments of flags.
+       (lang_sanitized_name): New.
+
 2012-05-14  Bernd Schmidt  <bernds@codesourcery.com>
 
        * attribs.c (decl_attributes): Avoid emitting a warning if
index 2f623f9030e079f5fbd7b9b34ac466e2d6ac4a31..63039c9ac0940eb9b33ef558f1096efeeb5436ca 100644 (file)
@@ -1,3 +1,9 @@
+2012-05-14  Manuel López-Ibáñez  <manu@gcc.gnu.org>
+
+       PR 53063
+       * gcc-interface/misc.c: Include opts.h and options.h before tm.h.
+       (gnat_handle_option): Call lang-specific generated function.
+
 2012-05-13  Manuel López-Ibáñez  <manu@gcc.gnu.org>
 
        * gcc-interface/lang.opt (I): Comment out help text with no effect.
index ad15f6724239c08c58f38bfb934c15ecfde8d0f5..f2002f577eec2d8256859f9bba9ae4d088be0a16 100644 (file)
@@ -26,6 +26,8 @@
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
+#include "opts.h"
+#include "options.h"
 #include "tm.h"
 #include "tree.h"
 #include "diagnostic.h"
@@ -36,8 +38,6 @@
 #include "toplev.h"
 #include "langhooks.h"
 #include "langhooks-def.h"
-#include "opts.h"
-#include "options.h"
 #include "plugin.h"
 #include "real.h"
 #include "function.h"  /* For pass_by_reference.  */
@@ -153,6 +153,10 @@ gnat_handle_option (size_t scode, const char *arg ATTRIBUTE_UNUSED, int value,
       gcc_unreachable ();
     }
 
+  Ada_handle_option_auto (&global_options, &global_options_set, 
+                          scode, arg, value, 
+                          gnat_option_lang_mask (), kind,
+                          loc, handlers, global_dc);
   return true;
 }
 
index 226568593d849d524e8dd96ff6cb209fc28ed360..de50b2159610d0a55d4a9d7a3e3b7933054cf893 100644 (file)
@@ -1,3 +1,12 @@
+2012-05-14  Manuel López-Ibáñez  <manu@gcc.gnu.org>
+
+       PR 53063
+       * c.opt (Wc++0X-compat,Wdelete-non-virtual-dtor,Wjump-misses-init,
+       Wreorder): Use LangEnabledBy.
+       * c-opts.c (c_common_handle_option): Do not enable them
+       explicitly. Call lang-specific generated functions.
+       (c_common_post_options): Do not set them here.
+
 2012-05-13  Manuel López-Ibáñez  <manu@gcc.gnu.org>
 
        * c.opt (Wclobbered,Wempty-body,Wignored-qualifiers,
index 8470de15ce0be734972b3194441be5135231013b..a7fadc817aa473bdcf94d67715f39880ca1b14a8 100644 (file)
@@ -397,9 +397,9 @@ c_common_handle_option (size_t scode, const char *arg, int value,
          if (warn_main == -1)
            warn_main = (value ? 2 : 0);
 
-         /* In C, -Wall turns on -Wenum-compare, which we do here.
-            In C++ it is on by default, which is done in
-            c_common_post_options.  */
+         /* 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;
        }
@@ -407,9 +407,6 @@ c_common_handle_option (size_t scode, const char *arg, int value,
        {
          /* C++-specific warnings.  */
           warn_sign_compare = value;
-         warn_reorder = value;
-          warn_cxx0x_compat = value;
-          warn_delnonvdtor = value;
          warn_narrowing = value;
        }
 
@@ -434,10 +431,6 @@ c_common_handle_option (size_t scode, const char *arg, int value,
         implies -Wenum-compare.  */
       if (warn_enum_compare == -1 && value)
        warn_enum_compare = value;
-      /* Because C++ always warns about a goto which misses an
-        initialization, -Wc++-compat turns on -Wjump-misses-init.  */
-      if (warn_jump_misses_init == -1 && value)
-       warn_jump_misses_init = value;
       cpp_opts->warn_cxx_operator_names = value;
       break;
 
@@ -836,6 +829,40 @@ c_common_handle_option (size_t scode, const char *arg, int value,
       break;
     }
 
+  switch (c_language)
+    {
+    case clk_c:
+      C_handle_option_auto (&global_options, &global_options_set, 
+                            scode, arg, value, 
+                            c_family_lang_mask, kind,
+                            loc, handlers, global_dc);
+      break;
+
+    case clk_objc:
+      ObjC_handle_option_auto (&global_options, &global_options_set,
+                               scode, arg, value, 
+                               c_family_lang_mask, kind,
+                               loc, handlers, global_dc);
+      break;
+
+    case clk_cxx:
+      CXX_handle_option_auto (&global_options, &global_options_set,
+                              scode, arg, value,
+                              c_family_lang_mask, kind,
+                              loc, handlers, global_dc);
+      break;
+
+    case clk_objcxx:
+      ObjCXX_handle_option_auto (&global_options, &global_options_set,
+                                 scode, arg, value,
+                                 c_family_lang_mask, kind,
+                                 loc, handlers, global_dc);
+      break;
+
+    default:
+      gcc_unreachable ();
+    }
+  
   return result;
 }
 
@@ -926,8 +953,6 @@ c_common_post_options (const char **pfilename)
     warn_strict_aliasing = 0;
   if (warn_strict_overflow == -1)
     warn_strict_overflow = 0;
-  if (warn_jump_misses_init == -1)
-    warn_jump_misses_init = 0;
 
   /* -Woverlength-strings is off by default, but is enabled by -Wpedantic.
      It is never enabled in C++, as the minimum limit is not normative
index 8afde8a25e2294f7fc2d3f21a5c88e9a20201d2f..0f13dc34eef31bb1e8126aaeb61befa97067e1d0 100644 (file)
@@ -288,7 +288,7 @@ C ObjC Var(warn_cxx_compat) Warning
 Warn about C constructs that are not in the common subset of C and C++
 
 Wc++0x-compat
-C++ ObjC++ Var(warn_cxx0x_compat) Warning
+C++ ObjC++ Var(warn_cxx0x_compat) Warning LangEnabledBy(C++ ObjC++,Wall)
 Deprecated in favor of -Wc++11-compat
 
 Wc++11-compat
@@ -336,7 +336,7 @@ C ObjC Var(warn_declaration_after_statement) Warning
 Warn when a declaration is found after a statement
 
 Wdelete-non-virtual-dtor
-C++ ObjC++ Var(warn_delnonvdtor) Warning
+C++ ObjC++ Var(warn_delnonvdtor) Warning LangEnabledBy(C++ ObjC++,Wall)
 Warn about deleting polymorphic objects with non-virtual destructors
 
 Wdeprecated
@@ -446,7 +446,7 @@ C ObjC C++ ObjC++ Warning
 Warn about PCH files that are found but not used
 
 Wjump-misses-init
-C ObjC Var(warn_jump_misses_init) Init(-1) Warning
+C ObjC Var(warn_jump_misses_init) Warning LangEnabledby(C ObjC,Wc++-compat)
 Warn when a jump misses a variable initialization
 
 Wliteral-suffix
@@ -598,7 +598,7 @@ C ObjC C++ ObjC++ Var(warn_redundant_decls) Warning
 Warn about multiple declarations of the same object
 
 Wreorder
-C++ ObjC++ Var(warn_reorder) Warning
+C++ ObjC++ Var(warn_reorder) Warning LangEnabledBy(C++ ObjC++,Wall)
 Warn when the compiler reorders code
 
 Wreturn-type
index 360cbdfb662f12f6113c2c7cd70ee068e34f1265..ef720307eee60fad902042893987a09019aa6be2 100644 (file)
@@ -461,4 +461,11 @@ value of @option{-fmath-errno} for languages that do not use
 
 @item EnabledBy(@var{opt})
 If not explicitly set, the option is set to the value of @option{-@var{opt}}.
+
+@item LangEnabledBy(@var{language}, @var{opt})
+When compiling for the given language, the option is set to the value
+of @option{-@var{opt}}, if not explicitly set. It is possible to
+specify several different languages.  Each @var{language} must have
+been declared by an earlier @code{Language} record.  @xref{Option file
+format}.
 @end table
index 251194b46af04c42e6de76b54ddb05add85341c1..bfafc1b100c33b593e0ac56a6effa9646f06a754 100644 (file)
@@ -1,3 +1,8 @@
+2012-05-14  Manuel López-Ibáñez  <manu@gcc.gnu.org>
+
+       PR 53063
+       * options.c (gfc_handle_option): Call lang-specific generated function.
+
 2012-05-13  Alessandro Fanfarillo  <fanfarillo.gcc@gmail.com>
            Tobias Burnus  <burnus@net-b.de>
 
index 32a8a4cb464c285faf40d92d147064c6cb778d67..f1721ce0a9b2827a02d420ef48f95ec4acb033e4 100644 (file)
@@ -1090,6 +1090,10 @@ gfc_handle_option (size_t scode, const char *arg, int value,
       break;
     }
 
+  Fortran_handle_option_auto (&global_options, &global_options_set, 
+                              scode, arg, value, 
+                              gfc_option_lang_mask (), kind,
+                              loc, handlers, global_dc);
   return result;
 }
 
index 1f582fb4a1654bcfdb8d29aaeb1faa6da85035bb..8e098c28c2ccebb6c1982254f12a718efbdcba94 100644 (file)
@@ -30,7 +30,9 @@ BEGIN {
 # Return nonzero if FLAGS contains a flag matching REGEX.
 function flag_set_p(regex, flags)
 {
-       return (" " flags " ") ~ (" " regex " ")
+    # Ignore the arguments of flags with arguments.
+    gsub ("\\([^)]+\\)", "", flags);
+    return (" " flags " ") ~ (" " regex " ")
 }
 
 # Return STRING if FLAGS contains a flag matching regexp REGEX,
@@ -287,3 +289,10 @@ function opt_enum(name)
 {
        return "OPT_" opt_sanitized_name(name)
 }
+
+# Given the language called NAME return a sanitized version of its name.
+function lang_sanitized_name(name)
+{
+    gsub( "[^" alnum "_]", "X", name )
+    return name
+}
index 81c3ea894d9738571474ce585b4133bbba30212d..2ca71eebf98981e2a1c663cada7be518246c4a1f 100644 (file)
@@ -41,6 +41,7 @@ BEGIN {
        {
                if ($1 == "Language") {
                        langs[n_langs] = $2
+                        lang_numbers[$2] = n_langs
                        n_langs++;
                }
                else if ($1 == "TargetSave") {
index 61dbe8ce2ac754723abaa3c084ea95510751dbe4..1d46a5dc3c9177a667034f57009df3b93669e432 100644 (file)
 
 # Dump that array of options into a C file.
 END {
+
+# Record first EnabledBy and LangEnabledBy uses.
+n_enabledby = 0;
+for (i = 0; i < n_langs; i++) {
+    n_enabledby_lang[i] = 0;
+}
+for (i = 0; i < n_opts; i++) {
+    enabledby_arg = opt_args("EnabledBy", flags[i]);
+    if (enabledby_arg != "") {
+        enabledby_name = enabledby_arg;
+        enabledby_index = opt_numbers[enabledby_name];
+        if (enabledby_index == "") {
+            print "#error Enabledby: " enabledby_name 
+        } else {
+            if (enables[enabledby_name] == "") {
+                enabledby[n_enabledby] = enabledby_name;
+                n_enabledby++;
+            }
+            enables[enabledby_name] = enables[enabledby_name] opts[i] ",";
+        }
+    }
+
+    enabledby_arg = opt_args("LangEnabledBy", flags[i]);
+    if (enabledby_arg != "") {
+        n_enabledby_arg_langs = split(nth_arg(0, enabledby_arg), enabledby_arg_langs, " ");
+        enabledby_name = nth_arg(1, enabledby_arg);
+        enabledby_index = opt_numbers[enabledby_name];
+        if (enabledby_index == "") {
+            print "#error Enabledby: " enabledby_name 
+        } else {
+            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]++;
+                }
+                enables[lang_name,enabledby_name] = enables[lang_name,enabledby_name] opts[i] ",";
+            }
+        }
+    }
+}
+
+
 print "/* This file is auto-generated by optc-gen.awk.  */"
 print ""
 n_headers = split(header_name, headers, " ")
@@ -161,8 +205,7 @@ print ""
 
 print "const char * const lang_names[] =\n{"
 for (i = 0; i < n_langs; i++) {
-       macros[i] = "CL_" langs[i]
-       gsub( "[^" alnum "_]", "X", macros[i] )
+        macros[i] = "CL_" lang_sanitized_name(langs[i])
        s = substr("         ", length (macros[i]))
        print "  " quote langs[i] quote ","
     }
@@ -342,30 +385,6 @@ print "  gcc_assert (decoded->canonical_option_num_elements <= 2);           "
 print "                                                                      "
 print "  switch (code)                                                       "
 print "    {                                                                 "
-n_enabledby = 0;
-for (i = 0; i < n_opts; i++) {
-    # With identical flags, pick only the last one.  The
-    # earlier loop ensured that it has all flags merged,
-    # and a nonempty help text if one of the texts was nonempty.
-    while( i + 1 != n_opts && opts[i] == opts[i + 1] ) {
-        i++;
-    }
-    enabledby_arg = opt_args("EnabledBy", flags[i]);
-    if (enabledby_arg != "") {
-        enabledby_name = enabledby_arg;
-        enabledby_index = opt_numbers[enabledby_name];
-        if (enabledby_index == "") {
-            print "#error Enabledby: " enabledby_name 
-        } else {
-            enabledby_var_name = var_name(flags[enabledby_index]);
-            if (enables[enabledby_name] == "") {
-                enabledby[n_enabledby] = enabledby_name;
-                n_enabledby++;
-            }
-            enables[enabledby_name] = enables[enabledby_name] opts[i] ",";
-        }
-    }
-}
 for (i = 0; i < n_enabledby; i++) {
     enabledby_name = enabledby[i];
     print "    case " opt_enum(enabledby_name) ":"
@@ -378,7 +397,6 @@ for (i = 0; i < n_enabledby; i++) {
         print "                                 lang_mask, kind, loc, handlers, dc);"
     }
     print "      break;\n"
-
 }
 print "    default:    "
 print "      break;    "
@@ -386,4 +404,44 @@ print "    }           "
 print "  return true;  "
 print "}               "
 
+# Handle LangEnabledBy
+for (i = 0; i < n_langs; i++) {
+    lang_name = lang_sanitized_name(langs[i]);
+    mark_unused = " ATTRIBUTE_UNUSED";
+
+    print "\n\n"
+    print "bool                                                                  "
+    print lang_name "_handle_option_auto (struct gcc_options *opts" mark_unused ",              "
+    print "                           struct gcc_options *opts_set" mark_unused ",              "
+    print "                           size_t scode" mark_unused ", const char *arg" mark_unused ", int value" mark_unused ",  "
+    print "                           unsigned int lang_mask" mark_unused ", int kind" mark_unused ",          "
+    print "                           location_t loc" mark_unused ",                            "
+    print "                           const struct cl_option_handlers *handlers" mark_unused ", "
+    print "                           diagnostic_context *dc" mark_unused ")                    "
+    print "{                                                                     "
+    print "  enum opt_code code = (enum opt_code) scode;                         "
+    print "                                                                      "
+    print "  switch (code)                                                       "
+    print "    {                                                                 "
+    
+    for (k = 0; k < n_enabledby_lang[i]; k++) {
+        enabledby_name = enabledby[lang_name,k];
+        print "    case " opt_enum(enabledby_name) ":"
+        n_enables = split(enables[lang_name,enabledby_name], thisenable, ",");
+        for (j = 1; j < n_enables; j++) {
+            opt_var_name = var_name(flags[opt_numbers[thisenable[j]]]);
+            print "      if (!opts_set->x_" opt_var_name ")"
+            print "        handle_generated_option (opts, opts_set,"
+            print "                                 " opt_enum(thisenable[j]) ", arg, value,"
+            print "                                 lang_mask, kind, loc, handlers, dc);"
+        }
+        print "      break;\n"
+    }
+    print "    default:    "
+    print "      break;    "
+    print "    }           "
+    print "  return true;  "
+    print "}               "
+}
+
 }
index 8257587e1b34a565072334ece02c18b2e424e42f..8e583f03064942cf1a7405ec1be9c6f4773eb9a7 100644 (file)
@@ -305,6 +305,17 @@ print "                           unsigned int lang_mask, int kind,          "
 print "                           location_t loc,                            "
 print "                           const struct cl_option_handlers *handlers, "
 print "                           diagnostic_context *dc);                   "
+for (i = 0; i < n_langs; i++) {
+    lang_name = lang_sanitized_name(langs[i]);
+    print "bool                                                                  "
+    print lang_name "_handle_option_auto (struct gcc_options *opts,              "
+    print "                           struct gcc_options *opts_set,              "
+    print "                           size_t scode, const char *arg, int value,  "
+    print "                           unsigned int lang_mask, int kind,          "
+    print "                           location_t loc,                            "
+    print "                           const struct cl_option_handlers *handlers, "
+    print "                           diagnostic_context *dc);                   "
+}
 print "#endif";
 print "#endif";
 print "";
@@ -401,8 +412,7 @@ for (i = 0; i < n_opts; i++) {
 print ""
 
 for (i = 0; i < n_langs; i++) {
-       macros[i] = "CL_" langs[i]
-       gsub( "[^" alnum "_]", "X", macros[i] )
+        macros[i] = "CL_" lang_sanitized_name(langs[i])
        s = substr("            ", length (macros[i]))
        print "#define " macros[i] s " (1U << " i ")"
     }