diff gcc/opts-global.c @ 16:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents 561a7518be6b
children 84e7813d76e9
line wrap: on
line diff
--- a/gcc/opts-global.c	Sun Aug 21 07:07:55 2011 +0900
+++ b/gcc/opts-global.c	Fri Oct 27 22:46:09 2017 +0900
@@ -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-2017 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -22,27 +21,27 @@
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
+#include "backend.h"
+#include "rtl.h"
+#include "tree.h"
+#include "tree-pass.h"
 #include "diagnostic.h"
 #include "opts.h"
 #include "flags.h"
-#include "ggc.h"
-#include "tree.h" /* Required by langhooks.h.  */
 #include "langhooks.h"
-#include "tm.h" /* Required by rtl.h.  */
-#include "rtl.h"
 #include "dbgcnt.h"
 #include "debug.h"
-#include "lto-streamer.h"
 #include "output.h"
 #include "plugin.h"
 #include "toplev.h"
-#include "tree-pass.h"
+#include "context.h"
+#include "stringpool.h"
+#include "attribs.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;
@@ -50,7 +49,7 @@
 
 /* Return a malloced slash-separated list of languages in MASK.  */
 
-static char *
+char *
 write_langs (unsigned int mask)
 {
   unsigned int n = 0, len = 0;
@@ -116,13 +115,13 @@
    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 +129,13 @@
 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);
     }
 }
 
@@ -160,19 +159,6 @@
     return true;
 }
 
-/* Note that an option DECODED has been successfully handled with a
-   handler for mask MASK.  */
-
-static void
-post_handling_callback (const struct cl_decoded_option *decoded ATTRIBUTE_UNUSED,
-			unsigned int mask ATTRIBUTE_UNUSED)
-{
-#ifdef ENABLE_LTO
-  lto_register_user_option (decoded->opt_index, decoded->arg,
-			    decoded->value, mask);
-#endif
-}
-
 /* Handle a front-end option; arguments and return value as for
    handle_option.  */
 
@@ -183,7 +169,8 @@
 		    unsigned int lang_mask ATTRIBUTE_UNUSED, int kind,
 		    location_t loc,
 		    const struct cl_option_handlers *handlers,
-		    diagnostic_context *dc)
+		    diagnostic_context *dc,
+		    void (*) (void))
 {
   gcc_assert (opts == &global_options);
   gcc_assert (opts_set == &global_options_set);
@@ -258,6 +245,11 @@
   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
@@ -278,11 +270,12 @@
 /* Set *HANDLERS to the default set of option handlers for use in the
    compilers proper (not the driver).  */
 void
-set_default_handlers (struct cl_option_handlers *handlers)
+set_default_handlers (struct cl_option_handlers *handlers,
+		      void (*target_option_override_hook) (void))
 {
   handlers->unknown_option_callback = unknown_option_callback;
   handlers->wrong_lang_callback = complain_wrong_lang;
-  handlers->post_handling_callback = post_handling_callback;
+  handlers->target_option_override_hook = target_option_override_hook;
   handlers->num_handlers = 3;
   handlers->handlers[0].handler = lang_handle_option;
   handlers->handlers[0].mask = initial_lang_mask;
@@ -300,7 +293,8 @@
 decode_options (struct gcc_options *opts, struct gcc_options *opts_set,
 		struct cl_decoded_option *decoded_options,
 		unsigned int decoded_options_count,
-		location_t loc, diagnostic_context *dc)
+		location_t loc, diagnostic_context *dc,
+		void (*target_option_override_hook) (void))
 {
   struct cl_option_handlers handlers;
 
@@ -308,22 +302,12 @@
 
   lang_mask = initial_lang_mask;
 
-  set_default_handlers (&handlers);
-
-  /* Enable -Werror=coverage-mismatch by default.  */
-  control_warning_option (OPT_Wcoverage_mismatch, (int) DK_ERROR, true,
-			  loc, lang_mask,
-			  &handlers, opts, opts_set, dc);
+  set_default_handlers (&handlers, target_option_override_hook);
 
   default_options_optimization (opts, opts_set,
 				decoded_options, decoded_options_count,
 				loc, lang_mask, &handlers, dc);
 
-#ifdef ENABLE_LTO
-  /* Clear any options currently held for LTO.  */
-  lto_clear_user_options ();
-#endif
-
   read_cmdline_options (opts, opts_set,
 			decoded_options, decoded_options_count,
 			loc, lang_mask,
@@ -332,6 +316,10 @@
   finish_options (opts, opts_set, loc);
 }
 
+/* Hold command-line options associated with stack limitation.  */
+const char *opt_fstack_limit_symbol_arg = NULL;
+int opt_fstack_limit_register_no = -1;
+
 /* Process common options that have been deferred until after the
    handlers have been called for all options.  */
 
@@ -340,13 +328,20 @@
 {
   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 ();
 
-  FOR_EACH_VEC_ELT (cl_deferred_option, vec, i, opt)
+  if (flag_opt_info)
+    opt_info_switch_p (NULL);
+
+  FOR_EACH_VEC_ELT (v, i, opt)
     {
       switch (opt->opt_index)
 	{
@@ -371,10 +366,24 @@
 	  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;
 
+        case OPT_fopt_info_:
+	  if (!opt_info_switch_p (opt->arg))
+	    error ("unrecognized command line option %<-fopt-info-%s%>",
+                   opt->arg);
+          break;
+
+	case OPT_fenable_:
+	case OPT_fdisable_:
+	  if (opt->opt_index == OPT_fenable_)
+	    enable_pass (opt->arg);
+          else
+	    disable_pass (opt->arg);
+          break;
+
 	case OPT_ffixed_:
 	  /* Deferred.  */
 	  fix_register (opt->arg, 1, 1);
@@ -418,12 +427,30 @@
 	    if (reg < 0)
 	      error ("unrecognized register name %qs", opt->arg);
 	    else
-	      stack_limit_rtx = gen_rtx_REG (Pmode, reg);
+	      {
+		/* Deactivate previous OPT_fstack_limit_symbol_ options.  */
+		opt_fstack_limit_symbol_arg = NULL;
+		opt_fstack_limit_register_no = reg;
+	      }
 	  }
 	  break;
 
 	case OPT_fstack_limit_symbol_:
-	  stack_limit_rtx = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (opt->arg));
+	  /* Deactivate previous OPT_fstack_limit_register_ options.  */
+	  opt_fstack_limit_register_no = -1;
+	  opt_fstack_limit_symbol_arg = 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: