re PR debug/66691 (ICE on valid code at -O3 with -g enabled in simplify_subreg, at...
[gcc.git] / gcc / opts-global.c
index 5ebc6309e6ba2d808a19b4acd53aa20cc3e6b685..2fc62503f03728a4aeac1261ef2bad4dd9ed2086 100644 (file)
@@ -1,7 +1,6 @@
 /* Command line option handling.  Code involving global state that
    should not be shared with the driver.
-   Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
-   Free Software Foundation, Inc.
+   Copyright (C) 2002-2015 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -25,24 +24,35 @@ along with GCC; see the file COPYING3.  If not see
 #include "diagnostic.h"
 #include "opts.h"
 #include "flags.h"
-#include "ggc.h"
+#include "alias.h"
+#include "symtab.h"
 #include "tree.h" /* Required by langhooks.h.  */
+#include "fold-const.h"
+#include "predict.h"
+#include "tm.h"
+#include "hard-reg-set.h"
+#include "function.h"
+#include "basic-block.h"
+#include "tree-ssa-alias.h"
+#include "internal-fn.h"
+#include "gimple-expr.h"
+#include "gimple.h"
 #include "langhooks.h"
-#include "tm.h" /* Required by rtl.h.  */
 #include "rtl.h"
 #include "dbgcnt.h"
 #include "debug.h"
+#include "cgraph.h"
 #include "lto-streamer.h"
 #include "output.h"
 #include "plugin.h"
 #include "toplev.h"
 #include "tree-pass.h"
+#include "context.h"
+#include "asan.h"
 
 typedef const char *const_char_p; /* For DEF_VEC_P.  */
-DEF_VEC_P(const_char_p);
-DEF_VEC_ALLOC_P(const_char_p,heap);
 
-static VEC(const_char_p,heap) *ignored_options;
+static vec<const_char_p> ignored_options;
 
 /* Input file names.  */
 const char **in_fnames;
@@ -116,13 +126,13 @@ complain_wrong_lang (const struct cl_decoded_option *decoded,
    we only complain about unknown -Wno-* options if they may have
    prevented a diagnostic. Otherwise, we just ignore them.  Note that
    if we do complain, it is only as a warning, not an error; passing
-   the compiler an unrecognised -Wno-* option should never change
+   the compiler an unrecognized -Wno-* option should never change
    whether the compilation succeeds or fails.  */
 
 static void
 postpone_unknown_option_warning (const char *opt)
 {
-  VEC_safe_push (const_char_p, heap, ignored_options, opt);
+  ignored_options.safe_push (opt);
 }
 
 /* Produce a warning for each option previously buffered.  */
@@ -130,13 +140,13 @@ postpone_unknown_option_warning (const char *opt)
 void
 print_ignored_options (void)
 {
-  while (!VEC_empty (const_char_p, ignored_options))
+  while (!ignored_options.is_empty ())
     {
       const char *opt;
 
-      opt = VEC_pop (const_char_p, ignored_options);
+      opt = ignored_options.pop ();
       warning_at (UNKNOWN_LOCATION, 0,
-                 "unrecognized command line option \"%s\"", opt);
+                 "unrecognized command line option %qs", opt);
     }
 }
 
@@ -233,40 +243,6 @@ read_cmdline_options (struct gcc_options *opts, struct gcc_options *opts_set,
     }
 }
 
-/* Handle -ftree-vectorizer-verbose=ARG by remapping it to -fopt-info.
-   It remaps the old verbosity values as following:
-
-   REPORT_NONE ==> No dump is output
-   REPORT_VECTORIZED_LOCATIONS ==> "-optimized"
-   REPORT_UNVECTORIZED_LOCATIONS ==> "-missed"
-
-   Any higher verbosity levels get mapped to "-all" flags.  */
-
-static void
-dump_remap_tree_vectorizer_verbose (const char *arg)
-{
-  int value = atoi (arg);
-  const char *remapped_opt_info = NULL;
-
-  switch (value)
-    {
-    case 0:
-      break;
-    case 1:
-      remapped_opt_info = "optimized";
-      break;
-    case 2:
-      remapped_opt_info = "missed";
-      break;
-    default:
-      remapped_opt_info = "all";
-      break;
-    }
-
-  if (remapped_opt_info)
-    opt_info_switch_p (remapped_opt_info);
-}
-
 /* Language mask determined at initialization.  */
 static unsigned int initial_lang_mask;
 
@@ -279,6 +255,11 @@ init_options_once (void)
   initial_lang_mask = lang_hooks.option_lang_mask ();
 
   lang_hooks.initialize_diagnostics (global_dc);
+  /* ??? Ideally, we should do this earlier and the FEs will override
+     it if desired (none do it so far).  However, the way the FEs
+     construct their pretty-printers means that all previous settings
+     are overriden.  */
+  diagnostic_color_init (global_dc);
 }
 
 /* Decode command-line options to an array, like
@@ -350,8 +331,12 @@ handle_common_deferred_options (void)
 {
   unsigned int i;
   cl_deferred_option *opt;
-  VEC(cl_deferred_option,heap) *vec
-    = (VEC(cl_deferred_option,heap) *) common_deferred_options;
+  vec<cl_deferred_option> v;
+
+  if (common_deferred_options)
+    v = *((vec<cl_deferred_option> *) common_deferred_options);
+  else
+    v = vNULL;
 
   if (flag_dump_all_passed)
     enable_rtl_dump_file ();
@@ -359,7 +344,7 @@ handle_common_deferred_options (void)
   if (flag_opt_info)
     opt_info_switch_p (NULL);
 
-  FOR_EACH_VEC_ELT (cl_deferred_option, vec, i, opt)
+  FOR_EACH_VEC_ELT (v, i, opt)
     {
       switch (opt->opt_index)
        {
@@ -384,7 +369,7 @@ handle_common_deferred_options (void)
          break;
 
        case OPT_fdump_:
-         if (!dump_switch_p (opt->arg))
+         if (!g->get_dumps ()->dump_switch_p (opt->arg))
            error ("unrecognized command line option %<-fdump-%s%>", opt->arg);
          break;
 
@@ -453,9 +438,17 @@ handle_common_deferred_options (void)
          stack_limit_rtx = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (opt->arg));
          break;
 
-        case OPT_ftree_vectorizer_verbose_:
-         dump_remap_tree_vectorizer_verbose (opt->arg);
-          break;
+       case OPT_fasan_shadow_offset_:
+         if (!(flag_sanitize & SANITIZE_KERNEL_ADDRESS))
+           error ("-fasan-shadow-offset should only be used "
+                  "with -fsanitize=kernel-address");
+         if (!set_asan_shadow_offset (opt->arg))
+            error ("unrecognized shadow offset %qs", opt->arg);
+         break;
+
+       case OPT_fsanitize_sections_:
+         set_sanitized_sections (opt->arg);
+         break;
 
        default:
          gcc_unreachable ();