global trees
[gcc.git] / gcc / c-family / c-opts.c
index 7695e88c13015a57fa806a68b1b9634dac178fb1..77844d7daf19eaecb3dc1d690dcd3be4fd806d99 100644 (file)
@@ -256,9 +256,9 @@ c_common_init_options (unsigned int decoded_options_count,
          }
     }
 
-  /* Set C++ standard to C++14 if not specified on the command line.  */
+  /* Set C++ standard to C++17 if not specified on the command line.  */
   if (c_dialect_cxx ())
-    set_std_cxx14 (/*ISO*/false);
+    set_std_cxx17 (/*ISO*/false);
 
   global_dc->colorize_source_p = true;
 }
@@ -504,12 +504,6 @@ c_common_handle_option (size_t scode, const char *arg, HOST_WIDE_INT value,
        cpp_opts->track_macro_expansion = 2;
       break;
 
-    case OPT_ftabstop_:
-      /* It is documented that we silently ignore silly values.  */
-      if (value >= 1 && value <= 100)
-       cpp_opts->tabstop = value;
-      break;
-
     case OPT_fexec_charset_:
       cpp_opts->narrow_charset = arg;
       break;
@@ -758,8 +752,6 @@ default_handle_c_option (size_t code ATTRIBUTE_UNUSED,
 bool
 c_common_post_options (const char **pfilename)
 {
-  struct cpp_callbacks *cb;
-
   /* Canonicalize the input and output filenames.  */
   if (in_fnames == NULL)
     {
@@ -931,6 +923,16 @@ c_common_post_options (const char **pfilename)
   SET_OPTION_IF_UNSET (&global_options, &global_options_set, warn_volatile,
                       cxx_dialect >= cxx20 && warn_deprecated);
 
+  /* -Wdeprecated-enum-enum-conversion is enabled by default in C++20.  */
+  SET_OPTION_IF_UNSET (&global_options, &global_options_set,
+                      warn_deprecated_enum_enum_conv,
+                      cxx_dialect >= cxx20 && warn_deprecated);
+
+  /* -Wdeprecated-enum-float-conversion is enabled by default in C++20.  */
+  SET_OPTION_IF_UNSET (&global_options, &global_options_set,
+                      warn_deprecated_enum_float_conv,
+                      cxx_dialect >= cxx20 && warn_deprecated);
+
   /* Declone C++ 'structors if -Os.  */
   if (flag_declone_ctor_dtor == -1)
     flag_declone_ctor_dtor = optimize_size;
@@ -943,7 +945,7 @@ c_common_post_options (const char **pfilename)
 
   /* Change flag_abi_version to be the actual current ABI level, for the
      benefit of c_cpp_builtins, and to make comparison simpler.  */
-  const int latest_abi_version = 14;
+  const int latest_abi_version = 15;
   /* Generate compatibility aliases for ABI v11 (7.1) by default.  */
   const int abi_compat_default = 11;
 
@@ -1101,16 +1103,22 @@ c_common_post_options (const char **pfilename)
       input_location = UNKNOWN_LOCATION;
     }
 
-  cb = cpp_get_callbacks (parse_in);
+  struct cpp_callbacks *cb = cpp_get_callbacks (parse_in);
   cb->file_change = cb_file_change;
   cb->dir_change = cb_dir_change;
+  if (lang_hooks.preprocess_options)
+    lang_hooks.preprocess_options (parse_in);
   cpp_post_options (parse_in);
   init_global_opts_from_cpp (&global_options, cpp_get_options (parse_in));
 
   input_location = UNKNOWN_LOCATION;
 
   *pfilename = this_input_filename
-    = cpp_read_main_file (parse_in, in_fnames[0]);
+    = cpp_read_main_file (parse_in, in_fnames[0],
+                         /* We'll inject preamble pieces if this is
+                            not preprocessed.  */
+                         !cpp_opts->preprocessed);
+
   /* Don't do any compilation or preprocessing if there is no input file.  */
   if (this_input_filename == NULL)
     {
@@ -1317,15 +1325,14 @@ handle_deferred_opts (void)
   if (!deps_seen)
     return;
 
-  mkdeps *deps = cpp_get_deps (parse_in);
-
-  for (size_t i = 0; i < deferred_count; i++)
-    {
-      struct deferred_opt *opt = &deferred_opts[i];
+  if (mkdeps *deps = cpp_get_deps (parse_in))
+    for (unsigned i = 0; i < deferred_count; i++)
+      {
+       struct deferred_opt *opt = &deferred_opts[i];
 
-      if (opt->code == OPT_MT || opt->code == OPT_MQ)
-       deps_add_target (deps, opt->arg, opt->code == OPT_MQ);
-    }
+       if (opt->code == OPT_MT || opt->code == OPT_MQ)
+         deps_add_target (deps, opt->arg, opt->code == OPT_MQ);
+      }
 }
 
 /* These settings are appropriate for GCC, but not necessarily so for
@@ -1430,6 +1437,7 @@ c_finish_options (void)
        = linemap_check_ordinary (linemap_add (line_table, LC_RENAME, 0,
                                               _("<built-in>"), 0));
       cb_file_change (parse_in, bltin_map);
+      linemap_line_start (line_table, 0, 1);
 
       /* Make sure all of the builtins about to be declared have
         BUILTINS_LOCATION has their location_t.  */
@@ -1453,9 +1461,10 @@ c_finish_options (void)
        = linemap_check_ordinary (linemap_add (line_table, LC_RENAME, 0,
                                               _("<command-line>"), 0));
       cb_file_change (parse_in, cmd_map);
+      linemap_line_start (line_table, 0, 1);
 
       /* All command line defines must have the same location.  */
-      cpp_force_token_locations (parse_in, cmd_map->start_location);
+      cpp_force_token_locations (parse_in, line_table->highest_line);
       for (size_t i = 0; i < deferred_count; i++)
        {
          struct deferred_opt *opt = &deferred_opts[i];
@@ -1541,7 +1550,13 @@ push_command_line_include (void)
       cpp_opts->warn_unused_macros = cpp_warn_unused_macros;
       /* Restore the line map back to the main file.  */
       if (!cpp_opts->preprocessed)
-       cpp_change_file (parse_in, LC_RENAME, this_input_filename);
+       {
+         cpp_change_file (parse_in, LC_RENAME, this_input_filename);
+         if (lang_hooks.preprocess_main_file)
+           /* We're starting the main file.  Inform the FE of that.  */
+           lang_hooks.preprocess_main_file
+             (parse_in, line_table, LINEMAPS_LAST_ORDINARY_MAP (line_table));
+       }
 
       /* Set this here so the client can change the option if it wishes,
         and after stacking the main file so we don't trace the main file.  */
@@ -1551,14 +1566,19 @@ push_command_line_include (void)
 
 /* File change callback.  Has to handle -include files.  */
 static void
-cb_file_change (cpp_reader * ARG_UNUSED (pfile),
-               const line_map_ordinary *new_map)
+cb_file_change (cpp_reader *reader, const line_map_ordinary *new_map)
 {
   if (flag_preprocess_only)
     pp_file_change (new_map);
   else
     fe_file_change (new_map);
 
+  if (new_map && cpp_opts->preprocessed
+      && lang_hooks.preprocess_main_file && MAIN_FILE_P (new_map)
+      && ORDINARY_MAP_STARTING_LINE_NUMBER (new_map))
+    /* We're starting the main file.  Inform the FE of that.  */
+    lang_hooks.preprocess_main_file (reader, line_table, new_map);
+
   if (new_map 
       && (new_map->reason == LC_ENTER || new_map->reason == LC_RENAME))
     {