]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
2012-05-11 Manuel López-Ibáñez <manu@gcc.gnu.org>
authormanu <manu@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 11 May 2012 12:23:50 +0000 (12:23 +0000)
committermanu <manu@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 11 May 2012 12:23:50 +0000 (12:23 +0000)
PR 53063
gcc/
* doc/options.texi (EnabledBy): Document
* opts.c: Include opts.h and options.h before tm.h.
(finish_options): Do not handle some sub-options here...
(common_handle_option): ... instead call common_handle_option_auto here.
* optc-gen.awk: Handle EnabledBy.
* opth-gen.awk: Declare common_handle_option_auto.
* common.opt (Wuninitialized): Use EnabledBy. Delete Init.
(Wmaybe-uninitialized): Likewise.
        (Wunused-but-set-variable): Likewise.
        (Wunused-function): Likewise.
        (Wunused-label): Likewise.
        (Wunused-value): Likewise.
        (Wunused-variable): Likewise.
        * opt-read.awk: Create opt_numbers array.
ada/
* gcc-interface/misc.c (gnat_parse_file): Move before ...
(gnat_handle_option): ... this. Use handle_generated_option.
c-family/
* c-opts.c (c_common_handle_option): Use handle_generated_option
to enable sub-options.
fortran/
* options.c: Include diagnostics.h instead of
diagnostics-core.h.
(set_Wall): Do not see warn_unused here.
(gfc_handle_option): Set it here using handle_generated_option.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@187403 138bc75d-0d04-0410-961f-82ee72b054a4

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/common.opt
gcc/doc/options.texi
gcc/fortran/ChangeLog
gcc/fortran/options.c
gcc/opt-read.awk
gcc/optc-gen.awk
gcc/opth-gen.awk
gcc/opts.c

index c5d733aa88cbd0ff4d12c24073a0066770d44ed6..c9f7f499b74fd7877f89d9091420a0a7cca722c8 100644 (file)
@@ -1,3 +1,21 @@
+2012-05-11  Manuel López-Ibáñez  <manu@gcc.gnu.org>
+
+       PR 53063
+       * doc/options.texi (EnabledBy): Document
+       * opts.c: Include opts.h and options.h before tm.h.
+       (finish_options): Do not handle some sub-options here...
+       (common_handle_option): ... instead call common_handle_option_auto here.
+       * optc-gen.awk: Handle EnabledBy.
+       * opth-gen.awk: Declare common_handle_option_auto.
+       * common.opt (Wuninitialized): Use EnabledBy. Delete Init.
+       (Wmaybe-uninitialized): Likewise.
+        (Wunused-but-set-variable): Likewise.
+        (Wunused-function): Likewise.
+        (Wunused-label): Likewise.
+        (Wunused-value): Likewise.
+        (Wunused-variable): Likewise.
+        * opt-read.awk: Create opt_numbers array.
+
 2012-05-11  Richard Guenther  <rguenther@suse.de>
 
        PR tree-optimization/53295
index d24810fed89235ed81b4c0fea17aa32ea35948da..537b39e98caaee5d81254e80717ca081b225c0fb 100644 (file)
@@ -1,3 +1,9 @@
+2012-05-11  Manuel López-Ibáñez  <manu@gcc.gnu.org>
+
+       PR 53063
+       * gcc-interface/misc.c (gnat_parse_file): Move before ...
+       (gnat_handle_option): ... this. Use handle_generated_option.
+
 2012-05-10  Richard Guenther  <rguenther@suse.de>
 
        * gcc-interface/cuintp.c (UI_From_gnu): Remove TYPE_IS_SIZETYPE use.
index 974827a787fcd049b14b05277d890985eb4ed950..ad15f6724239c08c58f38bfb934c15ecfde8d0f5 100644 (file)
@@ -105,6 +105,14 @@ gnat_parse_file (void)
   _ada_gnat1drv ();
 }
 
+/* Return language mask for option processing.  */
+
+static unsigned int
+gnat_option_lang_mask (void)
+{
+  return CL_Ada;
+}
+
 /* Decode all the language specific options that cannot be decoded by GCC.
    The option decoding phase of GCC calls this routine on the flags that
    are marked as Ada-specific.  Return true on success or false on failure.  */
@@ -119,7 +127,10 @@ gnat_handle_option (size_t scode, const char *arg ATTRIBUTE_UNUSED, int value,
   switch (code)
     {
     case OPT_Wall:
-      warn_unused = value;
+      handle_generated_option (&global_options, &global_options_set,
+                              OPT_Wunused, NULL, value,
+                              gnat_option_lang_mask (), kind, loc,
+                              handlers, global_dc);
       warn_uninitialized = value;
       warn_maybe_uninitialized = value;
       break;
@@ -145,14 +156,6 @@ gnat_handle_option (size_t scode, const char *arg ATTRIBUTE_UNUSED, int value,
   return true;
 }
 
-/* Return language mask for option processing.  */
-
-static unsigned int
-gnat_option_lang_mask (void)
-{
-  return CL_Ada;
-}
-
 /* Initialize options structure OPTS.  */
 
 static void
index a01f3eaef459000d4931e0e6ec261953b899c062..2c85d515f079f0858b4d7783e468eaa2e7d83c47 100644 (file)
@@ -1,3 +1,9 @@
+2012-05-11  Manuel López-Ibáñez  <manu@gcc.gnu.org>
+
+       PR 53063
+       * c-opts.c (c_common_handle_option): Use handle_generated_option
+       to enable sub-options.
+
 2012-05-10  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/53158
index 2510747c40e53a10a501dcf3175fb862a2c228cc..7d8ee6b334f500becee77193d27561e4fe3a7292 100644 (file)
@@ -360,7 +360,10 @@ c_common_handle_option (size_t scode, const char *arg, int value,
       break;
 
     case OPT_Wall:
-      warn_unused = value;
+      handle_generated_option (&global_options, &global_options_set,
+                              OPT_Wunused, NULL, value,
+                              c_family_lang_mask, kind, loc,
+                              handlers, global_dc);
       set_Wformat (value);
       handle_generated_option (&global_options, &global_options_set,
                               OPT_Wimplicit, NULL, value,
index c25713b31a187e9b4cd431da52c6999006e62ad9..375c10d713e97622c8d8b2f5bcb692224ee223ff 100644 (file)
@@ -650,11 +650,11 @@ Common Var(warn_type_limits) Init(-1) Warning
 Warn if a comparison is always true or always false due to the limited range of the data type
 
 Wuninitialized
-Common Var(warn_uninitialized) Init(-1) Warning
+Common Var(warn_uninitialized) Warning EnabledBy(Wextra)
 Warn about uninitialized automatic variables
 
 Wmaybe-uninitialized
-Common Var(warn_maybe_uninitialized) Warning
+Common Var(warn_maybe_uninitialized) Warning EnabledBy(Wuninitialized)
 Warn about maybe uninitialized automatic variables
 
 Wunreachable-code
@@ -670,15 +670,15 @@ Common Var(warn_unused_but_set_parameter) Init(-1) Warning
 Warn when a function parameter is only set, otherwise unused
 
 Wunused-but-set-variable
-Common Var(warn_unused_but_set_variable) Init(-1) Warning
+Common Var(warn_unused_but_set_variable) Warning EnabledBy(Wunused)
 Warn when a variable is only set, otherwise unused
 
 Wunused-function
-Common Var(warn_unused_function) Init(-1) Warning
+Common Var(warn_unused_function) Warning EnabledBy(Wunused)
 Warn when a function is unused
 
 Wunused-label
-Common Var(warn_unused_label) Init(-1) Warning
+Common Var(warn_unused_label) Warning EnabledBy(Wunused)
 Warn when a label is unused
 
 Wunused-parameter
@@ -686,11 +686,11 @@ Common Var(warn_unused_parameter) Init(-1) Warning
 Warn when a function parameter is unused
 
 Wunused-value
-Common Var(warn_unused_value) Init(-1) Warning
+Common Var(warn_unused_value) Warning EnabledBy(Wunused)
 Warn when an expression value is unused
 
 Wunused-variable
-Common Var(warn_unused_variable) Init(-1) Warning
+Common Var(warn_unused_variable) Warning EnabledBy(Wunused)
 Warn when a variable is unused
 
 Wcoverage-mismatch
index 08b8b793a0469867ab768b503f9679432b746a6e..360cbdfb662f12f6113c2c7cd70ee068e34f1265 100644 (file)
@@ -459,4 +459,6 @@ combined option.  For example, some front ends use this to prevent
 value of @option{-fmath-errno} for languages that do not use
 @code{errno}.
 
+@item EnabledBy(@var{opt})
+If not explicitly set, the option is set to the value of @option{-@var{opt}}.
 @end table
index b26b5c72735309364393547a0413b4935ff044b3..a488dcac5672cd58a517b0574fa8985cb85d49b6 100644 (file)
@@ -1,3 +1,11 @@
+2012-05-11  Manuel López-Ibáñez  <manu@gcc.gnu.org>
+
+       PR 53063
+       * options.c: Include diagnostics.h instead of
+       diagnostics-core.h.
+       (set_Wall): Do not see warn_unused here.
+       (gfc_handle_option): Set it here using handle_generated_option.
+
 2012-05-08  Jan Hubicka  <jh@suse.cz>
        
        * trans-common.c (create_common): Do not fake TREE_ASM_WRITTEN.
index dde7ff2f38283eaaf4217e0792fb9de1aadf714d..32a8a4cb464c285faf40d92d147064c6cb778d67 100644 (file)
@@ -34,7 +34,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "gfortran.h"
 #include "target.h"
 #include "cpp.h"
-#include "diagnostic-core.h"   /* For sorry.  */
+#include "diagnostic.h"        /* For global_dc.  */
 #include "tm.h"
 
 gfc_option_t gfc_option;
@@ -474,7 +474,6 @@ set_Wall (int setting)
   gfc_option.warn_real_q_constant = setting;
   gfc_option.warn_unused_dummy_argument = setting;
 
-  warn_unused = setting;
   warn_return_type = setting;
   warn_switch = setting;
   warn_uninitialized = setting;
@@ -612,6 +611,10 @@ gfc_handle_option (size_t scode, const char *arg, int value,
       break;
 
     case OPT_Wall:
+      handle_generated_option (&global_options, &global_options_set,
+                              OPT_Wunused, NULL, value,
+                              gfc_option_lang_mask (), kind, loc,
+                              handlers, global_dc);
       set_Wall (value);
       break;
 
index 6a4d4de0eb42ab91fa7dd09e997f01771b470498..81c3ea894d9738571474ce585b4133bbba30212d 100644 (file)
@@ -1,4 +1,4 @@
-#  Copyright (C) 2003,2004,2005,2006,2007,2008, 2010, 2011
+#  Copyright (C) 2003,2004,2005,2006,2007,2008, 2010, 2011, 2012
 #  Free Software Foundation, Inc.
 #  Contributed by Kelley Cook, June 2004.
 #  Original code from Neil Booth, May 2003.
@@ -108,6 +108,7 @@ BEGIN {
                        name = opt_args("Mask", $1)
                        if (name == "") {
                                opts[n_opts]  = $1
+                               opt_numbers[$1] = n_opts
                                flags[n_opts] = $2
                                help[n_opts]  = $3
                                for (i = 4; i <= NF; i++)
index e28c397f48a9a3614d58a172c34b21d855c7d0f6..4dc97f9ca6a56c80477f6553ac0d86038c5c0d36 100644 (file)
@@ -1,4 +1,4 @@
-#  Copyright (C) 2003, 2004, 2007, 2008, 2009, 2010, 2011
+#  Copyright (C) 2003, 2004, 2007, 2008, 2009, 2010, 2011, 2012
 #  Free Software Foundation, Inc.
 #  Contributed by Kelley Cook, June 2004.
 #  Original code from Neil Booth, May 2003.
@@ -324,4 +324,66 @@ for (i = 0; i < n_opts; i++) {
 
 print "};"
 
+print "\n\n"
+print "bool                                                                  "
+print "common_handle_option_auto (struct gcc_options *opts,                  "
+print "                           struct gcc_options *opts_set,              "
+print "                           const struct cl_decoded_option *decoded,   "
+print "                           unsigned int lang_mask, int kind,          "
+print "                           location_t loc,                            "
+print "                           const struct cl_option_handlers *handlers, "
+print "                           diagnostic_context *dc)                    "
+print "{                                                                     "
+print "  size_t scode = decoded->opt_index;                                  "
+print "  int value = decoded->value;                                         "
+print "  enum opt_code code = (enum opt_code) scode;                         "
+print "                                                                      "
+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) ":"
+    n_enables = split(enables[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]) ", NULL, value,"
+        print "                                 lang_mask, kind, loc, handlers, dc);"
+    }
+    print "      break;\n"
+
+}
+print "    default:    "
+print "      break;    "
+print "    }           "
+print "  return true;  "
+print "}               "
+
 }
index a600b30502b405e5fc66eee095d91600534e5875..8257587e1b34a565072334ece02c18b2e424e42f 100644 (file)
@@ -1,4 +1,4 @@
-#  Copyright (C) 2003,2004,2005,2006,2007,2008, 2010, 2011
+#  Copyright (C) 2003,2004,2005,2006,2007,2008, 2010, 2011, 2012
 #  Free Software Foundation, Inc.
 #  Contributed by Kelley Cook, June 2004.
 #  Original code from Neil Booth, May 2003.
@@ -293,6 +293,19 @@ print "extern void cl_target_option_restore (struct gcc_options *, struct cl_tar
 print "";
 print "/* Print target option variables from a structure.  */";
 print "extern void cl_target_option_print (FILE *, int, struct cl_target_option *);";
+print "";
+print "/* Anything that includes tm.h, does not necessarily need this.  */"
+print "#if !defined(GCC_TM_H)"
+print "#include \"input.h\" /* for location_t */"
+print "bool                                                                  "
+print "common_handle_option_auto (struct gcc_options *opts,                  "
+print "                           struct gcc_options *opts_set,              "
+print "                           const struct cl_decoded_option *decoded,   "
+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 "";
 
index b6c786f950e28c0922d828cdb5b2ae8bafe7e390..ac43d4a2da7c391496e85edb7a776b6e8fe94e4e 100644 (file)
@@ -1,5 +1,7 @@
 /* Command line option handling.
-   Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
+   Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011,
+   2012
+
    Free Software Foundation, Inc.
    Contributed by Neil Booth.
 
@@ -23,11 +25,11 @@ along with GCC; see the file COPYING3.  If not see
 #include "system.h"
 #include "intl.h"
 #include "coretypes.h"
+#include "opts.h"
+#include "options.h"
 #include "tm.h" /* For STACK_CHECK_BUILTIN,
                   STACK_CHECK_STATIC_BUILTIN, DEFAULT_GDB_EXTENSIONS,
                   DWARF2_DEBUGGING_INFO and DBX_DEBUGGING_INFO.  */
-#include "opts.h"
-#include "options.h"
 #include "flags.h"
 #include "params.h"
 #include "diagnostic.h"
@@ -815,33 +817,18 @@ finish_options (struct gcc_options *opts, struct gcc_options *opts_set,
                            opts->x_param_values, opts_set->x_param_values);
 
   /* This replaces set_Wunused.  */
-  if (opts->x_warn_unused_function == -1)
-    opts->x_warn_unused_function = opts->x_warn_unused;
-  if (opts->x_warn_unused_label == -1)
-    opts->x_warn_unused_label = opts->x_warn_unused;
   /* Wunused-parameter is enabled if both -Wunused -Wextra are enabled.  */
   if (opts->x_warn_unused_parameter == -1)
     opts->x_warn_unused_parameter = (opts->x_warn_unused
                                     && opts->x_extra_warnings);
-  if (opts->x_warn_unused_variable == -1)
-    opts->x_warn_unused_variable = opts->x_warn_unused;
   /* Wunused-but-set-parameter is enabled if both -Wunused -Wextra are
      enabled.  */
   if (opts->x_warn_unused_but_set_parameter == -1)
     opts->x_warn_unused_but_set_parameter = (opts->x_warn_unused
                                             && opts->x_extra_warnings);
-  if (opts->x_warn_unused_but_set_variable == -1)
-    opts->x_warn_unused_but_set_variable = opts->x_warn_unused;
-  if (opts->x_warn_unused_value == -1)
-    opts->x_warn_unused_value = opts->x_warn_unused;
-
   /* Wunused-local-typedefs is enabled by -Wunused or -Wall.  */
   if (opts->x_warn_unused_local_typedefs == -1)
     opts->x_warn_unused_local_typedefs = opts->x_warn_unused;
-
-  /* This replaces set_Wextra.  */
-  if (opts->x_warn_uninitialized == -1)
-    opts->x_warn_uninitialized = opts->x_extra_warnings;
 }
 
 #define LEFT_COLUMN    27
@@ -1745,11 +1732,6 @@ common_handle_option (struct gcc_options *opts,
       /* No-op. Used by the driver and passed to us because it starts with f.*/
       break;
 
-    case OPT_Wuninitialized:
-      /* Also turn on maybe uninitialized warning.  */
-      opts->x_warn_maybe_uninitialized = value;
-      break;
-
     default:
       /* If the flag was handled in a standard way, assume the lack of
         processing here is intentional.  */
@@ -1757,6 +1739,8 @@ common_handle_option (struct gcc_options *opts,
       break;
     }
 
+  common_handle_option_auto (opts, opts_set, decoded, lang_mask, kind,
+                             loc, handlers, dc);
   return true;
 }