OSDN Git Service

Sanitize the behavior of -Wcoverage-mismatch.
[pf3gnuchains/gcc-fork.git] / gcc / opts.c
index 7c928bb..fd8a504 100644 (file)
@@ -858,6 +858,7 @@ decode_options (unsigned int argc, const char **argv)
   flag_if_conversion2 = opt1;
   flag_ipa_pure_const = opt1;
   flag_ipa_reference = opt1;
+  flag_ipa_profile = opt1;
   flag_merge_constants = opt1;
   flag_split_wide_types = opt1;
   flag_tree_ccp = opt1;
@@ -945,6 +946,9 @@ decode_options (unsigned int argc, const char **argv)
   else
     set_param_value ("min-crossjump-insns", initial_min_crossjump_insns);
 
+  /* Enable -Werror=coverage-mismatch by default */
+  enable_warning_as_error("coverage-mismatch", 1, lang_mask);
+
   if (first_time_p)
     {
       /* Initialize whether `char' is signed.  */
@@ -1120,6 +1124,15 @@ decode_options (unsigned int argc, const char **argv)
       if (!PARAM_SET_P (PARAM_STACK_FRAME_GROWTH))
         PARAM_VALUE (PARAM_STACK_FRAME_GROWTH) = 40;
     }
+  if (flag_wpa || flag_ltrans)
+    {
+      /* These passes are not WHOPR compatible yet.  */
+      flag_ipa_cp = 0;
+      flag_ipa_reference = 0;
+      flag_ipa_type_escape = 0;
+      flag_ipa_pta = 0;
+      flag_ipa_struct_reorg = 0;
+    }
 
   if (flag_lto || flag_whopr)
     {
@@ -1757,7 +1770,7 @@ common_handle_option (size_t scode, const char *arg, int value,
       break;
 
     case OPT_fdiagnostics_show_option:
-      global_dc->show_option_requested = true;
+      global_dc->show_option_requested = value;
       break;
 
     case OPT_fdump_:
@@ -2396,6 +2409,20 @@ set_option (const struct cl_option *option, int value, const char *arg)
     }
 }
 
+
+/* Callback function, called when -Werror= enables a warning.  */
+
+static void (*warning_as_error_callback) (int) = NULL;
+
+/* Register a callback for enable_warning_as_error calls.  */
+
+void
+register_warning_as_error_callback (void (*callback) (int))
+{
+  gcc_assert (warning_as_error_callback == NULL || callback == NULL);
+  warning_as_error_callback = callback;
+}
+
 /* Enable a warning option as an error.  This is used by -Werror= and
    also by legacy Werror-implicit-function-declaration.  */
 
@@ -2415,14 +2442,20 @@ enable_warning_as_error (const char *arg, int value, unsigned int lang_mask)
     }
   else
     {
-      diagnostic_t kind = value ? DK_ERROR : DK_WARNING;
+      const diagnostic_t kind = value ? DK_ERROR : DK_WARNING;
+
       diagnostic_classify_diagnostic (global_dc, option_index, kind);
+      if (kind == DK_ERROR)
+       {
+         const struct cl_option * const option = cl_options + option_index;
+
+         /* -Werror=foo implies -Wfoo.  */
+         if (option->var_type == CLVC_BOOLEAN && option->flag_var)
+           *(int *) option->flag_var = 1;
 
-      /* -Werror=foo implies -Wfoo.  */
-      if (cl_options[option_index].var_type == CLVC_BOOLEAN
-         && cl_options[option_index].flag_var
-         && kind == DK_ERROR)
-       *(int *) cl_options[option_index].flag_var = 1;
+         if (warning_as_error_callback)
+           warning_as_error_callback (option_index);
+       }
     }
   free (new_option);
 }