LCOV - code coverage report
Current view: top level - gcc/c-family - c-opts.cc (source / functions) Coverage Total Hit
Test: gcc.info Lines: 89.9 % 1065 957
Test Date: 2026-06-20 15:32:29 Functions: 94.7 % 38 36
Legend: Lines:     hit not hit

            Line data    Source code
       1              : /* C/ObjC/C++ command line option handling.
       2              :    Copyright (C) 2002-2026 Free Software Foundation, Inc.
       3              :    Contributed by Neil Booth.
       4              : 
       5              : This file is part of GCC.
       6              : 
       7              : GCC is free software; you can redistribute it and/or modify it under
       8              : the terms of the GNU General Public License as published by the Free
       9              : Software Foundation; either version 3, or (at your option) any later
      10              : version.
      11              : 
      12              : GCC is distributed in the hope that it will be useful, but WITHOUT ANY
      13              : WARRANTY; without even the implied warranty of MERCHANTABILITY or
      14              : FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
      15              : for more details.
      16              : 
      17              : You should have received a copy of the GNU General Public License
      18              : along with GCC; see the file COPYING3.  If not see
      19              : <http://www.gnu.org/licenses/>.  */
      20              : 
      21              : #define INCLUDE_VECTOR
      22              : #include "config.h"
      23              : #include "system.h"
      24              : #include "coretypes.h"
      25              : #include "tm.h"
      26              : #include "target.h"
      27              : #include "c-target.h"
      28              : #include "c-common.h"
      29              : #include "memmodel.h"
      30              : #include "tm_p.h"             /* For C_COMMON_OVERRIDE_OPTIONS.  */
      31              : #include "diagnostic.h"
      32              : #include "c-pragma.h"
      33              : #include "flags.h"
      34              : #include "toplev.h"
      35              : #include "langhooks.h"
      36              : #include "diagnostics/macro-unwinding.h" /* for virt_loc_aware_diagnostic_finalizer */
      37              : #include "intl.h"
      38              : #include "cppdefault.h"
      39              : #include "incpath.h"
      40              : #include "debug.h"            /* For debug_hooks.  */
      41              : #include "opts.h"
      42              : #include "plugin.h"           /* For PLUGIN_INCLUDE_FILE event.  */
      43              : #include "mkdeps.h"
      44              : #include "dumpfile.h"
      45              : #include "file-prefix-map.h"    /* add_*_prefix_map()  */
      46              : #include "context.h"
      47              : #include "diagnostics/text-sink.h"
      48              : 
      49              : #ifndef DOLLARS_IN_IDENTIFIERS
      50              : # define DOLLARS_IN_IDENTIFIERS true
      51              : #endif
      52              : 
      53              : #ifndef TARGET_SYSTEM_ROOT
      54              : # define TARGET_SYSTEM_ROOT NULL
      55              : #endif
      56              : 
      57              : #ifndef TARGET_OPTF
      58              : #define TARGET_OPTF(ARG)
      59              : #endif
      60              : 
      61              : /* CPP's options.  */
      62              : cpp_options *cpp_opts;
      63              : 
      64              : /* Input filename.  */
      65              : static const char *this_input_filename;
      66              : 
      67              : /* Filename and stream for preprocessed output.  */
      68              : static const char *out_fname;
      69              : static FILE *out_stream;
      70              : 
      71              : /* Append dependencies to deps_file.  */
      72              : static bool deps_append;
      73              : 
      74              : /* If dependency switches (-MF etc.) have been given.  */
      75              : static bool deps_seen;
      76              : 
      77              : /* If -v seen.  */
      78              : static bool verbose;
      79              : 
      80              : /* Dependency output file.  */
      81              : static const char *deps_file;
      82              : 
      83              : /* Structured dependency output file.  */
      84              : static const char *fdeps_file;
      85              : 
      86              : /* The prefix given by -iprefix, if any.  */
      87              : static const char *iprefix;
      88              : 
      89              : /* The multilib directory given by -imultilib, if any.  */
      90              : static const char *imultilib;
      91              : 
      92              : /* The system root, if any.  Overridden by -isysroot.  */
      93              : static const char *sysroot = TARGET_SYSTEM_ROOT;
      94              : 
      95              : /* Zero disables all standard directories for headers.  */
      96              : static bool std_inc = true;
      97              : 
      98              : /* Zero disables the C++-specific standard directories for headers.  */
      99              : static bool std_cxx_inc = true;
     100              : 
     101              : /* If the quote chain has been split by -I-.  */
     102              : static bool quote_chain_split;
     103              : 
     104              : /* Number of deferred options.  */
     105              : static size_t deferred_count;
     106              : 
     107              : /* Number of deferred options scanned for -include.  */
     108              : static size_t include_cursor;
     109              : 
     110              : /* Whether any standard preincluded header has been preincluded.  */
     111              : static bool done_preinclude;
     112              : 
     113              : static void handle_OPT_d (const char *);
     114              : static void set_std_cxx98 (int);
     115              : static void set_std_cxx11 (int);
     116              : static void set_std_cxx14 (int);
     117              : static void set_std_cxx17 (int);
     118              : static void set_std_cxx20 (int);
     119              : static void set_std_cxx23 (int);
     120              : static void set_std_cxx26 (int);
     121              : static void set_std_cxx29 (int);
     122              : static void set_std_c89 (int, int);
     123              : static void set_std_c99 (int);
     124              : static void set_std_c11 (int);
     125              : static void set_std_c17 (int);
     126              : static void set_std_c23 (int);
     127              : static void set_std_c2y (int);
     128              : static void check_deps_environment_vars (void);
     129              : static void handle_deferred_opts (void);
     130              : static void sanitize_cpp_opts (void);
     131              : static void add_prefixed_path (const char *, incpath_kind);
     132              : static void push_command_line_include (void);
     133              : static void cb_file_change (cpp_reader *, const line_map_ordinary *);
     134              : static void cb_dir_change (cpp_reader *, const char *);
     135              : static void c_finish_options (void);
     136              : 
     137              : #ifndef STDC_0_IN_SYSTEM_HEADERS
     138              : #define STDC_0_IN_SYSTEM_HEADERS 0
     139              : #endif
     140              : 
     141              : /* Holds switches parsed by c_common_handle_option (), but whose
     142              :    handling is deferred to c_common_post_options ().  */
     143              : static void defer_opt (enum opt_code, const char *);
     144              : static struct deferred_opt
     145              : {
     146              :   enum opt_code code;
     147              :   const char *arg;
     148              : } *deferred_opts;
     149              : 
     150              : 
     151              : extern const unsigned int
     152              : c_family_lang_mask = (CL_C | CL_CXX | CL_ObjC | CL_ObjCXX);
     153              : 
     154              : /* Defer option CODE with argument ARG.  */
     155              : static void
     156       187427 : defer_opt (enum opt_code code, const char *arg)
     157              : {
     158       187427 :   deferred_opts[deferred_count].code = code;
     159       187427 :   deferred_opts[deferred_count].arg = arg;
     160       187427 :   deferred_count++;
     161       187427 : }
     162              : 
     163              : /* Return language mask for option parsing.  */
     164              : unsigned int
     165      6624325 : c_common_option_lang_mask (void)
     166              : {
     167      6624325 :   static const unsigned int lang_flags[] = {CL_C, CL_ObjC, CL_CXX, CL_ObjCXX};
     168              : 
     169      6624325 :   return lang_flags[c_language];
     170              : }
     171              : 
     172              : /* Diagnostic finalizer for C/C++/Objective-C/Objective-C++.  */
     173              : static void
     174       339995 : c_diagnostic_text_finalizer (diagnostics::text_sink &text_output,
     175              :                              const diagnostics::diagnostic_info *diagnostic,
     176              :                              enum diagnostics::kind)
     177              : {
     178       339995 :   pretty_printer *const pp = text_output.get_printer ();
     179       339995 :   char *saved_prefix = pp_take_prefix (pp);
     180       339995 :   pp_set_prefix (pp, text_output.build_indent_prefix (false));
     181       339995 :   pp_newline (pp);
     182       339995 :   diagnostic_show_locus (&text_output.get_context (),
     183       339995 :                          text_output.get_source_printing_options (),
     184       339995 :                          diagnostic->m_richloc, diagnostic->m_kind, pp);
     185              :   /* By default print macro expansion contexts in the diagnostic
     186              :      finalizer -- for tokens resulting from macro expansion.  */
     187       339995 :   diagnostics::virt_loc_aware_text_finalizer (text_output, diagnostic);
     188       339995 :   pp_set_prefix (pp, saved_prefix);
     189       339995 :   pp_flush (pp);
     190       339995 : }
     191              : 
     192              : /* Common default settings for diagnostics.  */
     193              : void
     194       216649 : c_common_diagnostics_set_defaults (diagnostics::context *context)
     195              : {
     196       216649 :   diagnostics::text_finalizer (context) = c_diagnostic_text_finalizer;
     197       216649 :   context->set_permissive_option (OPT_fpermissive);
     198       216649 : }
     199              : 
     200              : /* Input charset configuration for diagnostics.  */
     201              : static const char *
     202        65917 : c_common_input_charset_cb (const char * /*filename*/)
     203              : {
     204        65917 :   const char *cs = cpp_opts->input_charset;
     205        65917 :   return cpp_input_conversion_is_trivial (cs) ? nullptr : cs;
     206              : }
     207              : 
     208              : /* Whether options from all C-family languages should be accepted
     209              :    quietly.  */
     210              : static bool accept_all_c_family_options = false;
     211              : 
     212              : /* Return whether to complain about a wrong-language option.  */
     213              : bool
     214          293 : c_common_complain_wrong_lang_p (const struct cl_option *option)
     215              : {
     216          293 :   if (accept_all_c_family_options
     217            6 :       && (option->flags & c_family_lang_mask))
     218            6 :     return false;
     219              : 
     220              :   return true;
     221              : }
     222              : 
     223              : /* Initialize options structure OPTS.  */
     224              : void
     225     47994628 : c_common_init_options_struct (struct gcc_options *opts)
     226              : {
     227     47994628 :   opts->x_flag_exceptions = c_dialect_cxx ();
     228     47994628 :   opts->x_warn_pointer_arith = c_dialect_cxx ();
     229     47994628 :   opts->x_warn_write_strings = c_dialect_cxx ();
     230     47994628 :   opts->x_flag_warn_unused_result = true;
     231              : 
     232              :   /* By default, C99-like requirements for complex multiply and divide.  */
     233     47994628 :   opts->x_flag_complex_method = 2;
     234     47994628 : }
     235              : 
     236              : /* Common initialization before calling option handlers.  */
     237              : void
     238       216649 : c_common_init_options (unsigned int decoded_options_count,
     239              :                        struct cl_decoded_option *decoded_options)
     240              : {
     241       216649 :   unsigned int i;
     242       216649 :   struct cpp_callbacks *cb;
     243              : 
     244       216649 :   g_string_concat_db
     245       216649 :     = new (ggc_alloc <string_concat_db> ()) string_concat_db ();
     246              : 
     247       333533 :   parse_in = cpp_create_reader (c_dialect_cxx () ? CLK_GNUCXX : CLK_GNUC89,
     248              :                                 ident_hash, line_table, ident_hash_extra);
     249       216649 :   cb = cpp_get_callbacks (parse_in);
     250       216649 :   cb->diagnostic = c_cpp_diagnostic;
     251              : 
     252       216649 :   cpp_opts = cpp_get_options (parse_in);
     253       216649 :   cpp_opts->dollars_in_ident = DOLLARS_IN_IDENTIFIERS;
     254       216649 :   cpp_opts->objc = c_dialect_objc ();
     255       216649 :   cpp_opts->deps.modules = true;
     256              : 
     257              :   /* Reset to avoid warnings on internal definitions.  We set it just
     258              :      before passing on command-line options to cpplib.  */
     259       216649 :   cpp_opts->warn_dollars = 0;
     260              : 
     261       216649 :   deferred_opts = XNEWVEC (struct deferred_opt, decoded_options_count);
     262              : 
     263       216649 :   if (c_language == clk_c)
     264              :     {
     265              :       /* The default for C is gnu23.  */
     266       116884 :       set_std_c23 (false /* ISO */);
     267              : 
     268              :       /* If preprocessing assembly language, accept any of the C-family
     269              :          front end options since the driver may pass them through.  */
     270      2981467 :       for (i = 1; i < decoded_options_count; i++)
     271      2748679 :         if (decoded_options[i].opt_index == OPT_lang_asm)
     272              :           {
     273          980 :             accept_all_c_family_options = true;
     274          980 :             break;
     275              :           }
     276              :     }
     277              : 
     278              :   /* Set C++ standard to C++20 if not specified on the command line.  */
     279       216649 :   if (c_dialect_cxx ())
     280        99765 :     set_std_cxx20 (/*ISO*/false);
     281              : 
     282       216649 :   global_dc->get_source_printing_options ().colorize_source_p = true;
     283       216649 : }
     284              : 
     285              : /* Handle switch SCODE with argument ARG.  VALUE is true, unless no-
     286              :    form of an -f or -W option was given.  Returns false if the switch was
     287              :    invalid, true if valid.  Use HANDLERS in recursive handle_option calls.  */
     288              : bool
     289      3413799 : c_common_handle_option (size_t scode, const char *arg, HOST_WIDE_INT value,
     290              :                         int kind, location_t loc,
     291              :                         const struct cl_option_handlers *handlers)
     292              : {
     293      3413799 :   const struct cl_option *option = &cl_options[scode];
     294      3413799 :   enum opt_code code = (enum opt_code) scode;
     295      3413799 :   bool result = true;
     296              : 
     297              :   /* Prevent resetting the language standard to a C dialect when the driver
     298              :      has already determined that we're looking at assembler input.  */
     299      3413799 :   bool preprocessing_asm_p = (cpp_get_options (parse_in)->lang == CLK_ASM);
     300              : 
     301      3413799 :   switch (code)
     302              :     {
     303      1473040 :     default:
     304      1473040 :       if (cl_options[code].flags & c_family_lang_mask)
     305              :         {
     306      1473040 :           if ((option->flags & CL_TARGET)
     307      1473040 :               && ! targetcm.handle_c_option (scode, arg, value))
     308              :             result = false;
     309              :           break;
     310              :         }
     311              :       result = false;
     312              :       break;
     313              : 
     314          474 :     case OPT__output_pch:
     315          474 :       pch_file = arg;
     316          474 :       break;
     317              : 
     318           10 :     case OPT_A:
     319           10 :       defer_opt (code, arg);
     320           10 :       break;
     321              : 
     322           13 :     case OPT_C:
     323           13 :       cpp_opts->discard_comments = 0;
     324           13 :       break;
     325              : 
     326           11 :     case OPT_CC:
     327           11 :       cpp_opts->discard_comments = 0;
     328           11 :       cpp_opts->discard_comments_in_macro_exp = 0;
     329           11 :       break;
     330              : 
     331       172048 :     case OPT_D:
     332       172048 :       defer_opt (code, arg);
     333       172048 :       break;
     334              : 
     335           25 :     case OPT_H:
     336           25 :       cpp_opts->print_include_names = 1;
     337           25 :       break;
     338              : 
     339              :     case OPT_F:
     340              :       TARGET_OPTF (xstrdup (arg));
     341              :       break;
     342              : 
     343       564642 :     case OPT_I:
     344       564642 :       if (strcmp (arg, "-"))
     345       564642 :         add_path (xstrdup (arg), INC_BRACKET, 0, true);
     346              :       else
     347              :         {
     348            0 :           if (quote_chain_split)
     349            0 :             error ("%<-I-%> specified twice");
     350            0 :           quote_chain_split = true;
     351            0 :           split_quote_chain ();
     352            0 :           inform (input_location, "obsolete option %<-I-%> used, "
     353              :                   "please use %<-iquote%> instead");
     354              :         }
     355              :       break;
     356              : 
     357           31 :     case OPT_M:
     358           31 :     case OPT_MM:
     359              :       /* When doing dependencies with -M or -MM, suppress normal
     360              :          preprocessed output, but still do -dM etc. as software
     361              :          depends on this.  Preprocessed output does occur if -MD, -MMD
     362              :          or environment var dependency generation is used.  */
     363           31 :       cpp_opts->deps.style = (code == OPT_M ? DEPS_SYSTEM : DEPS_USER);
     364           31 :       flag_no_output = 1;
     365           31 :       break;
     366              : 
     367         5892 :     case OPT_MD:
     368         5892 :     case OPT_MMD:
     369         5892 :       cpp_opts->deps.style = (code == OPT_MD ? DEPS_SYSTEM : DEPS_USER);
     370         5892 :       cpp_opts->deps.need_preprocessor_output = true;
     371         5892 :       deps_file = arg;
     372         5892 :       break;
     373              : 
     374           51 :     case OPT_fdeps_format_:
     375              :       /* https://wg21.link/p1689r5 */
     376           51 :       if (!strcmp (arg, "p1689r5"))
     377           48 :         cpp_opts->deps.fdeps_format = FDEPS_FMT_P1689R5;
     378              :       else
     379            3 :         error ("%<-fdeps-format=%> unknown format %qs", arg);
     380              :       break;
     381              : 
     382           63 :     case OPT_fdeps_file_:
     383           63 :       deps_seen = true;
     384           63 :       fdeps_file = arg;
     385           63 :       break;
     386              : 
     387           63 :     case OPT_fdeps_target_:
     388           63 :       deps_seen = true;
     389           63 :       defer_opt (code, arg);
     390           63 :       break;
     391              : 
     392         5839 :     case OPT_MF:
     393         5839 :       deps_seen = true;
     394         5839 :       deps_file = arg;
     395         5839 :       break;
     396              : 
     397            6 :     case OPT_MG:
     398            6 :       deps_seen = true;
     399            6 :       cpp_opts->deps.missing_files = true;
     400            6 :       break;
     401              : 
     402         5821 :     case OPT_MP:
     403         5821 :       deps_seen = true;
     404         5821 :       cpp_opts->deps.phony_targets = true;
     405         5821 :       break;
     406              : 
     407            0 :     case OPT_Mmodules:
     408              :       /* Do not set deps_seen, so the user can unconditionally turn
     409              :          this on or off.  */
     410            0 :       cpp_opts->deps.modules = true;
     411            0 :       break;
     412              : 
     413            3 :     case OPT_Mno_modules:
     414              :       /* Do not set deps_seen, so the user can unconditionally turn
     415              :          this on or off.  */
     416            3 :       cpp_opts->deps.modules = false;
     417            3 :       break;
     418              : 
     419         5888 :     case OPT_MQ:
     420         5888 :     case OPT_MT:
     421         5888 :       deps_seen = true;
     422         5888 :       defer_opt (code, arg);
     423         5888 :       break;
     424              : 
     425           43 :     case OPT_P:
     426           43 :       flag_no_line_commands = 1;
     427           43 :       break;
     428              : 
     429           60 :     case OPT_U:
     430           60 :       defer_opt (code, arg);
     431           60 :       break;
     432              : 
     433        11034 :     case OPT_Wall:
     434              :       /* ??? Don't add new options here. Use LangEnabledBy in c.opt.  */
     435              : 
     436        11034 :       cpp_opts->warn_num_sign_change = value;
     437        11034 :       break;
     438              : 
     439        11124 :     case OPT_Wunknown_pragmas:
     440              :       /* Set to greater than 1, so that even unknown pragmas in
     441              :          system headers will be warned about.  */
     442              :       /* ??? There is no way to handle this automatically for now.  */
     443        11124 :       warn_unknown_pragmas = value * 2;
     444        11124 :       break;
     445              : 
     446         3972 :     case OPT_ansi:
     447         3972 :       if (!c_dialect_cxx ())
     448         3826 :         set_std_c89 (false, true);
     449              :       else
     450          146 :         set_std_cxx98 (true);
     451              :       break;
     452              : 
     453         1634 :     case OPT_d:
     454         1634 :       handle_OPT_d (arg);
     455         1634 :       break;
     456              : 
     457        12385 :     case OPT_Wabi_:
     458        12385 :       warn_abi = true;
     459        12385 :       if (value == 1)
     460              :         {
     461            0 :           warning (0, "%<-Wabi=1%> is not supported, using =2");
     462            0 :           value = 2;
     463              :         }
     464        12385 :       warn_abi_version = value;
     465        12385 :       break;
     466              : 
     467           18 :     case OPT_fcanonical_system_headers:
     468           18 :       cpp_opts->canonical_system_headers = value;
     469           18 :       break;
     470              : 
     471           12 :     case OPT_fcond_mismatch:
     472           12 :       if (!c_dialect_cxx ())
     473              :         {
     474           12 :           flag_cond_mismatch = value;
     475           12 :           break;
     476              :         }
     477            0 :       warning (0, "switch %qs is no longer supported", option->opt_text);
     478            0 :       break;
     479              : 
     480          308 :     case OPT_fbuiltin_:
     481          308 :       if (value)
     482              :         result = false;
     483              :       else
     484          308 :         disable_builtin_function (arg);
     485              :       break;
     486              : 
     487         1101 :     case OPT_fdirectives_only:
     488         1101 :       cpp_opts->directives_only = value;
     489         1101 :       break;
     490              : 
     491            7 :     case OPT_fdollars_in_identifiers:
     492            7 :       cpp_opts->dollars_in_ident = value;
     493            7 :       break;
     494              : 
     495            8 :     case OPT_fmacro_prefix_map_:
     496            8 :       add_macro_prefix_map (arg);
     497            8 :       break;
     498              : 
     499          663 :     case OPT_ffreestanding:
     500          663 :       value = !value;
     501              :       /* Fall through.  */
     502          671 :     case OPT_fhosted:
     503          671 :       flag_hosted = value;
     504          671 :       flag_no_builtin = !value;
     505          671 :       break;
     506              : 
     507            0 :     case OPT_fconstant_string_class_:
     508            0 :       constant_string_class_name = arg;
     509            0 :       break;
     510              : 
     511            0 :     case OPT_fextended_identifiers:
     512            0 :       cpp_opts->extended_identifiers = value;
     513            0 :       break;
     514              : 
     515            4 :     case OPT_fmax_include_depth_:
     516            4 :         cpp_opts->max_include_depth = value;
     517            4 :       break;
     518              : 
     519            4 :     case OPT_foperator_names:
     520            4 :       cpp_opts->operator_names = value;
     521            4 :       break;
     522              : 
     523            0 :     case OPT_fpch_deps:
     524            0 :       cpp_opts->restore_pch_deps = value;
     525            0 :       break;
     526              : 
     527          485 :     case OPT_fpch_preprocess:
     528          485 :       flag_pch_preprocess = value;
     529          485 :       break;
     530              : 
     531         1152 :     case OPT_fpermissive:
     532         1152 :       flag_permissive = value;
     533         1152 :       global_dc->m_permissive = value;
     534         1152 :       break;
     535              : 
     536          537 :     case OPT_fpreprocessed:
     537          537 :       cpp_opts->preprocessed = value;
     538          537 :       break;
     539              : 
     540            2 :     case OPT_fdebug_cpp:
     541            2 :       cpp_opts->debug = value;
     542            2 :       break;
     543              : 
     544            1 :     case OPT_ftrack_macro_expansion:
     545            1 :       if (value)
     546            0 :         value = 2;
     547              :       /* Fall Through.  */
     548              : 
     549          483 :     case OPT_ftrack_macro_expansion_:
     550          483 :       if (arg && *arg != '\0')
     551          482 :         cpp_opts->track_macro_expansion = value;
     552              :       else
     553            1 :         cpp_opts->track_macro_expansion = 2;
     554              :       break;
     555              : 
     556          125 :     case OPT_fexec_charset_:
     557          125 :       cpp_opts->narrow_charset = arg;
     558          125 :       break;
     559              : 
     560            2 :     case OPT_fwide_exec_charset_:
     561            2 :       cpp_opts->wide_charset = arg;
     562            2 :       break;
     563              : 
     564          106 :     case OPT_finput_charset_:
     565          106 :       cpp_opts->input_charset = arg;
     566          106 :       cpp_opts->cpp_input_charset_explicit = 1;
     567          106 :       break;
     568              : 
     569           29 :     case OPT_ftemplate_depth_:
     570           29 :       max_tinst_depth = value;
     571           29 :       break;
     572              : 
     573           21 :     case OPT_fvisibility_inlines_hidden:
     574           21 :       visibility_options.inlines_hidden = value;
     575           21 :       break;
     576              : 
     577           22 :     case OPT_femit_struct_debug_baseonly:
     578           22 :       set_struct_debug_option (&global_options, loc, "base");
     579           22 :       break;
     580              : 
     581            8 :     case OPT_femit_struct_debug_reduced:
     582            8 :       set_struct_debug_option (&global_options, loc,
     583              :                                "dir:ord:sys,dir:gen:any,ind:base");
     584            8 :       break;
     585              : 
     586           12 :     case OPT_femit_struct_debug_detailed_:
     587           12 :       set_struct_debug_option (&global_options, loc, arg);
     588           12 :       break;
     589              : 
     590           17 :     case OPT_fext_numeric_literals:
     591           17 :       cpp_opts->ext_numeric_literals = value;
     592           17 :       break;
     593              : 
     594            4 :     case OPT_idirafter:
     595            4 :       add_path (xstrdup (arg), INC_AFTER, 0, true);
     596            4 :       break;
     597              : 
     598         9358 :     case OPT_imacros:
     599         9358 :     case OPT_include:
     600         9358 :       defer_opt (code, arg);
     601         9358 :       break;
     602              : 
     603         5366 :     case OPT_imultilib:
     604         5366 :       imultilib = arg;
     605         5366 :       break;
     606              : 
     607       213304 :     case OPT_iprefix:
     608       213304 :       iprefix = arg;
     609       213304 :       break;
     610              : 
     611         2918 :     case OPT_iquote:
     612         2918 :       add_path (xstrdup (arg), INC_QUOTE, 0, true);
     613         2918 :       break;
     614              : 
     615            0 :     case OPT_isysroot:
     616            0 :       sysroot = arg;
     617            0 :       break;
     618              : 
     619       476749 :     case OPT_isystem:
     620       476749 :       add_path (xstrdup (arg), INC_SYSTEM, 0, true);
     621       476749 :       break;
     622              : 
     623            0 :     case OPT_iwithprefix:
     624            0 :       add_prefixed_path (arg, INC_SYSTEM);
     625            0 :       break;
     626              : 
     627            0 :     case OPT_iwithprefixbefore:
     628            0 :       add_prefixed_path (arg, INC_BRACKET);
     629            0 :       break;
     630              : 
     631           88 :     case OPT__embed_dir_:
     632           88 :       add_path (xstrdup (arg), INC_EMBED, 0, true);
     633           88 :       break;
     634              : 
     635          980 :     case OPT_lang_asm:
     636          980 :       cpp_set_lang (parse_in, CLK_ASM);
     637          980 :       cpp_opts->dollars_in_ident = false;
     638          980 :       break;
     639              : 
     640           60 :     case OPT_nostdinc:
     641           60 :       std_inc = false;
     642           60 :       break;
     643              : 
     644       111370 :     case OPT_nostdinc__:
     645       111370 :       std_cxx_inc = false;
     646       111370 :       break;
     647              : 
     648       215904 :     case OPT_o:
     649       215904 :       if (!out_fname)
     650       215904 :         out_fname = arg;
     651              :       else
     652            0 :         error ("output filename specified twice");
     653              :       break;
     654              : 
     655            0 :     case OPT_print_objc_runtime_info:
     656            0 :       print_struct_values = 1;
     657            0 :       break;
     658              : 
     659            2 :     case OPT_remap:
     660            2 :       cpp_opts->remap = 1;
     661            2 :       break;
     662              : 
     663        14119 :     case OPT_std_c__98:
     664        14119 :     case OPT_std_gnu__98:
     665        14119 :       if (!preprocessing_asm_p)
     666        14119 :         set_std_cxx98 (code == OPT_std_c__98 /* ISO */);
     667              :       break;
     668              : 
     669         5709 :     case OPT_std_c__11:
     670         5709 :     case OPT_std_gnu__11:
     671         5709 :       if (!preprocessing_asm_p)
     672         5709 :         set_std_cxx11 (code == OPT_std_c__11 /* ISO */);
     673              :       break;
     674              : 
     675         1299 :     case OPT_std_c__14:
     676         1299 :     case OPT_std_gnu__14:
     677         1299 :       if (!preprocessing_asm_p)
     678         1299 :         set_std_cxx14 (code == OPT_std_c__14 /* ISO */);
     679              :       break;
     680              : 
     681         4208 :     case OPT_std_c__17:
     682         4208 :     case OPT_std_gnu__17:
     683         4208 :       if (!preprocessing_asm_p)
     684         4208 :         set_std_cxx17 (code == OPT_std_c__17 /* ISO */);
     685              :       break;
     686              : 
     687        32182 :     case OPT_std_c__20:
     688        32182 :     case OPT_std_gnu__20:
     689        32182 :       if (!preprocessing_asm_p)
     690        32182 :         set_std_cxx20 (code == OPT_std_c__20 /* ISO */);
     691              :       break;
     692              : 
     693         2144 :     case OPT_std_c__23:
     694         2144 :     case OPT_std_gnu__23:
     695         2144 :       if (!preprocessing_asm_p)
     696         2144 :         set_std_cxx23 (code == OPT_std_c__23 /* ISO */);
     697              :       break;
     698              : 
     699         1632 :     case OPT_std_c__26:
     700         1632 :     case OPT_std_gnu__26:
     701         1632 :       if (!preprocessing_asm_p)
     702         1632 :         set_std_cxx26 (code == OPT_std_c__26 /* ISO */);
     703              :       break;
     704              : 
     705        23249 :     case OPT_std_c__29:
     706        23249 :     case OPT_std_gnu__29:
     707        23249 :       if (!preprocessing_asm_p)
     708        23249 :         set_std_cxx29 (code == OPT_std_c__29 /* ISO */);
     709              :       break;
     710              : 
     711          191 :     case OPT_std_c90:
     712          191 :     case OPT_std_iso9899_199409:
     713          191 :       if (!preprocessing_asm_p)
     714          191 :         set_std_c89 (code == OPT_std_iso9899_199409 /* c94 */, true /* ISO */);
     715              :       break;
     716              : 
     717         2953 :     case OPT_std_gnu90:
     718         2953 :       if (!preprocessing_asm_p)
     719         2953 :         set_std_c89 (false /* c94 */, false /* ISO */);
     720              :       break;
     721              : 
     722          581 :     case OPT_std_c99:
     723          581 :       if (!preprocessing_asm_p)
     724          580 :         set_std_c99 (true /* ISO */);
     725              :       break;
     726              : 
     727          616 :     case OPT_std_gnu99:
     728          616 :       if (!preprocessing_asm_p)
     729          616 :         set_std_c99 (false /* ISO */);
     730              :       break;
     731              : 
     732          514 :     case OPT_std_c11:
     733          514 :       if (!preprocessing_asm_p)
     734          514 :         set_std_c11 (true /* ISO */);
     735              :       break;
     736              : 
     737         3718 :     case OPT_std_gnu11:
     738         3718 :       if (!preprocessing_asm_p)
     739         3718 :         set_std_c11 (false /* ISO */);
     740              :       break;
     741              : 
     742           42 :     case OPT_std_c17:
     743           42 :       if (!preprocessing_asm_p)
     744           42 :         set_std_c17 (true /* ISO */);
     745              :       break;
     746              : 
     747          777 :     case OPT_std_gnu17:
     748          777 :       if (!preprocessing_asm_p)
     749          777 :         set_std_c17 (false /* ISO */);
     750              :       break;
     751              : 
     752          908 :     case OPT_std_c23:
     753          908 :       if (!preprocessing_asm_p)
     754          908 :         set_std_c23 (true /* ISO */);
     755              :       break;
     756              : 
     757          205 :     case OPT_std_gnu23:
     758          205 :       if (!preprocessing_asm_p)
     759          205 :         set_std_c23 (false /* ISO */);
     760              :       break;
     761              : 
     762          204 :     case OPT_std_c2y:
     763          204 :       if (!preprocessing_asm_p)
     764          204 :         set_std_c2y (true /* ISO */);
     765              :       break;
     766              : 
     767           11 :     case OPT_std_gnu2y:
     768           11 :       if (!preprocessing_asm_p)
     769           11 :         set_std_c2y (false /* ISO */);
     770              :       break;
     771              : 
     772           20 :     case OPT_trigraphs:
     773           20 :       cpp_opts->trigraphs = 1;
     774           20 :       break;
     775              : 
     776         2927 :     case OPT_traditional_cpp:
     777         2927 :       cpp_opts->traditional = 1;
     778         2927 :       break;
     779              : 
     780            0 :     case OPT_fsearch_include_path:
     781            0 :       cpp_opts->main_search = CMS_user;
     782            0 :       break;
     783              : 
     784            5 :     case OPT_fsearch_include_path_:
     785            5 :       if (!strcmp (arg, "user"))
     786            0 :         cpp_opts->main_search = CMS_user;
     787            5 :       else if (!strcmp (arg, "system"))
     788            5 :         cpp_opts->main_search = CMS_system;
     789              :       else
     790            0 :         error ("invalid argument %qs to %<-fsearch-include-path%>", arg);
     791              :       break;
     792              : 
     793          176 :     case OPT_v:
     794          176 :       verbose = true;
     795          176 :       break;
     796              :     }
     797              : 
     798      3413799 :   switch (c_language)
     799              :     {
     800      1471563 :     case clk_c:
     801      1471563 :       C_handle_option_auto (&global_options, &global_options_set,
     802              :                             scode, arg, value,
     803              :                             c_family_lang_mask, kind,
     804              :                             loc, handlers, global_dc);
     805      1471563 :       break;
     806              : 
     807            0 :     case clk_objc:
     808            0 :       ObjC_handle_option_auto (&global_options, &global_options_set,
     809              :                                scode, arg, value,
     810              :                                c_family_lang_mask, kind,
     811              :                                loc, handlers, global_dc);
     812            0 :       break;
     813              : 
     814      1942236 :     case clk_cxx:
     815      1942236 :       CXX_handle_option_auto (&global_options, &global_options_set,
     816              :                               scode, arg, value,
     817              :                               c_family_lang_mask, kind,
     818              :                               loc, handlers, global_dc);
     819      1942236 :       break;
     820              : 
     821            0 :     case clk_objcxx:
     822            0 :       ObjCXX_handle_option_auto (&global_options, &global_options_set,
     823              :                                  scode, arg, value,
     824              :                                  c_family_lang_mask, kind,
     825              :                                  loc, handlers, global_dc);
     826            0 :       break;
     827              : 
     828            0 :     default:
     829            0 :       gcc_unreachable ();
     830              :     }
     831              : 
     832      3413799 :   cpp_handle_option_auto (&global_options, scode, cpp_opts);
     833      3413799 :   return result;
     834              : }
     835              : 
     836              : /* Default implementation of TARGET_HANDLE_C_OPTION.  */
     837              : 
     838              : bool
     839            0 : default_handle_c_option (size_t code ATTRIBUTE_UNUSED,
     840              :                          const char *arg ATTRIBUTE_UNUSED,
     841              :                          int value ATTRIBUTE_UNUSED)
     842              : {
     843            0 :   return false;
     844              : }
     845              : 
     846              : /* Post-switch processing.  */
     847              : bool
     848       216533 : c_common_post_options (const char **pfilename)
     849              : {
     850              :   /* Canonicalize the input and output filenames.  */
     851       216533 :   if (in_fnames == NULL)
     852              :     {
     853            0 :       in_fnames = XNEWVEC (const char *, 1);
     854            0 :       in_fnames[0] = "";
     855              :     }
     856       216533 :   else if (strcmp (in_fnames[0], "-") == 0)
     857              :     {
     858          407 :       if (pch_file)
     859            0 :         error ("cannot use %<-%> as input filename for a precompiled header");
     860              : 
     861          407 :       in_fnames[0] = "";
     862              :     }
     863              : 
     864       216533 :   if (out_fname == NULL || !strcmp (out_fname, "-"))
     865          745 :     out_fname = "";
     866              : 
     867       216533 :   if (cpp_opts->deps.style == DEPS_NONE)
     868       210610 :     check_deps_environment_vars ();
     869              : 
     870       216533 :   handle_deferred_opts ();
     871              : 
     872       216533 :   sanitize_cpp_opts ();
     873              : 
     874              :   /* Don't register include chains if under -fpreprocessed since we might not
     875              :      have correct sysroot this mode, and this may cause file permission
     876              :      issue.  */
     877       216533 :   if (!cpp_opts->preprocessed)
     878       215996 :     register_include_chains (parse_in, sysroot, iprefix, imultilib,
     879       215996 :                              std_inc, std_cxx_inc && c_dialect_cxx (), verbose);
     880              : 
     881              : #ifdef C_COMMON_OVERRIDE_OPTIONS
     882              :   /* Some machines may reject certain combinations of C
     883              :      language-specific options.  */
     884              :   C_COMMON_OVERRIDE_OPTIONS;
     885              : #endif
     886              : 
     887       216533 :   if (flag_excess_precision == EXCESS_PRECISION_DEFAULT)
     888       370070 :     flag_excess_precision = (flag_iso ? EXCESS_PRECISION_STANDARD
     889              :                              : EXCESS_PRECISION_FAST);
     890              : 
     891              :   /* ISO C restricts floating-point expression contraction to within
     892              :      source-language expressions (-ffp-contract=on, currently an alias
     893              :      for -ffp-contract=off).  */
     894       216533 :   if (flag_iso
     895        59772 :       && !c_dialect_cxx ()
     896         6253 :       && (OPTION_SET_P (flag_fp_contract_mode)
     897              :           == (enum fp_contract_mode) 0)
     898         6253 :       && flag_unsafe_math_optimizations == 0)
     899         6248 :     flag_fp_contract_mode = FP_CONTRACT_OFF;
     900              : 
     901              :   /* C language modes before C99 enable -fpermissive by default, but
     902              :      only if -pedantic-errors is not specified.  Also treat
     903              :      -fno-permissive as a subset of -pedantic-errors that does not
     904              :      reject certain GNU extensions also present the defaults for later
     905              :      language modes.  */
     906       216533 :   if (!c_dialect_cxx ()
     907       116769 :       && !flag_isoc99
     908         6958 :       && !global_dc->m_pedantic_errors
     909         5938 :       && !OPTION_SET_P (flag_permissive))
     910              :     {
     911         5937 :       flag_permissive = 1;
     912         5937 :       global_dc->m_permissive = 1;
     913              :     }
     914              : 
     915              :   /* If we are compiling C, and we are outside of a standards mode,
     916              :      we can permit the new values from ISO/IEC TS 18661-3 for
     917              :      FLT_EVAL_METHOD.  Otherwise, we must restrict the possible values to
     918              :      the set specified in ISO C99/C11.  */
     919       216533 :   if (!flag_iso
     920       156761 :       && !c_dialect_cxx ()
     921       110516 :       && (OPTION_SET_P (flag_permitted_flt_eval_methods)
     922              :           == PERMITTED_FLT_EVAL_METHODS_DEFAULT))
     923       110515 :     flag_permitted_flt_eval_methods = PERMITTED_FLT_EVAL_METHODS_TS_18661;
     924              :   else
     925       106018 :     flag_permitted_flt_eval_methods = PERMITTED_FLT_EVAL_METHODS_C11;
     926              : 
     927       216533 :   if (cxx_dialect >= cxx26)
     928        24835 :     SET_OPTION_IF_UNSET (&global_options, &global_options_set,
     929              :                          flag_auto_var_init, AUTO_INIT_CXX26);
     930              : 
     931              :   /* The -Wtrivial-auto-var-init warning is useless for C++, where we always
     932              :      add .DEFERRED_INIT calls when some (vacuous) initializers are bypassed
     933              :      through jumps from switch condition to case/default label.  */
     934       216533 :   if (c_dialect_cxx ())
     935        99764 :     warn_trivial_auto_var_init = 0;
     936              : 
     937              :   /* C23 Annex F does not permit certain built-in functions to raise
     938              :      "inexact".  */
     939       216533 :   if (flag_isoc23)
     940       103564 :     SET_OPTION_IF_UNSET (&global_options, &global_options_set,
     941              :                          flag_fp_int_builtin_inexact, 0);
     942              : 
     943              :   /* By default we use C99 inline semantics in GNU99 or C99 mode.  C99
     944              :      inline semantics are not supported in GNU89 or C89 mode.  */
     945       216533 :   if (flag_gnu89_inline == -1)
     946       216089 :     flag_gnu89_inline = !flag_isoc99;
     947          444 :   else if (!flag_gnu89_inline && !flag_isoc99)
     948            1 :     error ("%<-fno-gnu89-inline%> is only supported in GNU99 or C99 mode");
     949              : 
     950              :   /* Default to ObjC sjlj exception handling if NeXT runtime < v2.  */
     951       216533 :   if (flag_objc_sjlj_exceptions < 0)
     952       433066 :     flag_objc_sjlj_exceptions = (flag_next_runtime && flag_objc_abi < 2);
     953       216533 :   if (flag_objc_exceptions && !flag_objc_sjlj_exceptions)
     954            0 :     flag_exceptions = 1;
     955              : 
     956              :   /* If -ffreestanding, -fno-hosted or -fno-builtin then disable
     957              :      pattern recognition.  */
     958       216533 :   if (flag_no_builtin)
     959          782 :     SET_OPTION_IF_UNSET (&global_options, &global_options_set,
     960              :                          flag_tree_loop_distribute_patterns, 0);
     961              : 
     962              :   /* -Woverlength-strings is off by default, but is enabled by -Wpedantic.
     963              :      It is never enabled in C++, as the minimum limit is not normative
     964              :      in that standard.  */
     965       216533 :   if (c_dialect_cxx ())
     966        99764 :     warn_overlength_strings = 0;
     967              : 
     968              :   /* Wmain is enabled by default in C++ but not in C.  */
     969              :   /* Wmain is disabled by default for -ffreestanding (!flag_hosted),
     970              :      even if -Wall or -Wpedantic was given (warn_main will be 2 if set
     971              :      by -Wall, 1 if set by -Wmain).  */
     972       216533 :   if (warn_main == -1)
     973       263584 :     warn_main = (c_dialect_cxx () && flag_hosted) ? 1 : 0;
     974        58345 :   else if (warn_main == 2)
     975        57994 :     warn_main = flag_hosted ? 1 : 0;
     976              : 
     977              :   /* In C, -Wall and -Wc++-compat enable -Wenum-compare; if it has not
     978              :      yet been set, it is disabled by default.  In C++, it is enabled
     979              :      by default.  */
     980       216533 :   if (warn_enum_compare == -1)
     981       206923 :     warn_enum_compare = c_dialect_cxx () ? 1 : 0;
     982              : 
     983              :   /* For C++26 default to -Wkeyword-macro if -Wpedantic.  */
     984       216533 :   if (cxx_dialect >= cxx26 && pedantic)
     985              :     {
     986        15948 :       SET_OPTION_IF_UNSET (&global_options, &global_options_set,
     987              :                            warn_keyword_macro, 1);
     988        15948 :       if (warn_keyword_macro)
     989        15947 :         cpp_opts->cpp_warn_keyword_macro = warn_keyword_macro;
     990              :     }
     991              : 
     992              :   /* -Wpacked-bitfield-compat is on by default for the C languages.  The
     993              :      warning is issued in stor-layout.cc which is not part of the front-end so
     994              :      we need to selectively turn it on here.  */
     995       216533 :   if (warn_packed_bitfield_compat == -1)
     996       216525 :     warn_packed_bitfield_compat = 1;
     997              : 
     998              :   /* Special format checking options don't work without -Wformat; warn if
     999              :      they are used.  */
    1000       216533 :   if (!warn_format)
    1001              :     {
    1002       205152 :       warning (OPT_Wformat_y2k,
    1003              :                "%<-Wformat-y2k%> ignored without %<-Wformat%>");
    1004       205152 :       warning (OPT_Wformat_extra_args,
    1005              :                "%<-Wformat-extra-args%> ignored without %<-Wformat%>");
    1006       205152 :       warning (OPT_Wformat_zero_length,
    1007              :                "%<-Wformat-zero-length%> ignored without %<-Wformat%>");
    1008       205152 :       warning (OPT_Wformat_nonliteral,
    1009              :                "%<-Wformat-nonliteral%> ignored without %<-Wformat%>");
    1010       205152 :       warning (OPT_Wformat_contains_nul,
    1011              :                "%<-Wformat-contains-nul%> ignored without %<-Wformat%>");
    1012       205152 :       warning (OPT_Wformat_security,
    1013              :                "%<-Wformat-security%> ignored without %<-Wformat%>");
    1014              :     }
    1015              : 
    1016              :   /* -Wimplicit-function-declaration is enabled by default for C99.  */
    1017       216533 :   if (warn_implicit_function_declaration == -1)
    1018       208089 :     warn_implicit_function_declaration = flag_isoc99;
    1019              : 
    1020              :   /* -Wimplicit-int is enabled by default for C99.  */
    1021       216533 :   if (warn_implicit_int == -1)
    1022       208146 :     warn_implicit_int = flag_isoc99;
    1023              : 
    1024              :   /* -Wold-style-definition is enabled by default for C23.  */
    1025       216533 :   if (warn_old_style_definition == -1)
    1026       212236 :     warn_old_style_definition = flag_isoc23;
    1027              : 
    1028              :   /* -Wshift-overflow is enabled by default in C99 and C++11 modes.  */
    1029       216533 :   if (warn_shift_overflow == -1)
    1030       411810 :     warn_shift_overflow = cxx_dialect >= cxx11 || flag_isoc99;
    1031              : 
    1032              :   /* -Wmissing-parameter-name is enabled by -pedantic before C23,
    1033              :      and for -Wc11-c23-compat.  */
    1034       216533 :   if (warn_missing_parameter_name == -1)
    1035       216530 :     warn_missing_parameter_name
    1036        49643 :       = ((pedantic && !flag_isoc23 && warn_c11_c23_compat != 0)
    1037       266218 :          || warn_c11_c23_compat > 0);
    1038              : 
    1039              :   /* Likewise for -Wfree-labels.  */
    1040       216533 :   if (warn_free_labels == -1)
    1041        49643 :     warn_free_labels = ((pedantic && !flag_isoc23 && warn_c11_c23_compat != 0)
    1042       266218 :                         || warn_c11_c23_compat > 0);
    1043              : 
    1044       216533 :   if (warn_deprecated_non_prototype == -1)
    1045       216528 :     warn_deprecated_non_prototype = warn_c11_c23_compat > 0;
    1046              : 
    1047              :   /* -Wshift-negative-value is enabled by -Wextra in C99 and C++11 to C++17
    1048              :      modes.  */
    1049       216533 :   if (warn_shift_negative_value == -1)
    1050       433026 :     warn_shift_negative_value = (extra_warnings
    1051         7866 :                                  && (cxx_dialect >= cxx11 || flag_isoc99)
    1052       433390 :                                  && cxx_dialect < cxx20);
    1053              : 
    1054              :   /* -Wregister is enabled by default in C++17.  */
    1055       216533 :   SET_OPTION_IF_UNSET (&global_options, &global_options_set, warn_register,
    1056              :                        cxx_dialect >= cxx17);
    1057              : 
    1058              :   /* Explicit -Wdeprecated turns on warnings from later standards.  */
    1059      1694151 :   auto deprecated_in = [&](enum cxx_dialect d)
    1060              :   {
    1061      1477618 :     if (OPTION_SET_P (warn_deprecated)) return !!warn_deprecated;
    1062      1476130 :     return (warn_deprecated && cxx_dialect >= d);
    1063              :   };
    1064              : 
    1065              :   /* -Wcomma-subscript is enabled by default in C++20.  */
    1066       216533 :   SET_OPTION_IF_UNSET (&global_options, &global_options_set,
    1067              :                        warn_comma_subscript,
    1068              :                        cxx_dialect >= cxx23
    1069              :                        || deprecated_in (cxx20));
    1070              : 
    1071              :   /* -Wvolatile is enabled by default in C++20.  */
    1072       216533 :   SET_OPTION_IF_UNSET (&global_options, &global_options_set, warn_volatile,
    1073              :                        deprecated_in (cxx20));
    1074              : 
    1075              :   /* -Wdeprecated-enum-enum-conversion is enabled by default in C++20.  */
    1076       216533 :   SET_OPTION_IF_UNSET (&global_options, &global_options_set,
    1077              :                        warn_deprecated_enum_enum_conv,
    1078              :                        deprecated_in (cxx20));
    1079              : 
    1080              :   /* -Wdeprecated-enum-float-conversion is enabled by default in C++20.  */
    1081       216533 :   SET_OPTION_IF_UNSET (&global_options, &global_options_set,
    1082              :                        warn_deprecated_enum_float_conv,
    1083              :                        deprecated_in (cxx20));
    1084              : 
    1085              :   /* -Wdeprecated-literal-operator is enabled by default in C++23.  */
    1086       216533 :   SET_OPTION_IF_UNSET (&global_options, &global_options_set,
    1087              :                        warn_deprecated_literal_operator,
    1088              :                        deprecated_in (cxx23));
    1089              : 
    1090              :   /* -Warray-compare is enabled by default in C++20.  */
    1091       216533 :   SET_OPTION_IF_UNSET (&global_options, &global_options_set,
    1092              :                        warn_array_compare,
    1093              :                        warn_array_compare || deprecated_in (cxx20));
    1094              : 
    1095              :   /* -Wdeprecated-variadic-comma-omission is enabled by default in C++26.  */
    1096       216533 :   SET_OPTION_IF_UNSET (&global_options, &global_options_set,
    1097              :                        warn_deprecated_variadic_comma_omission,
    1098              :                        deprecated_in (cxx26));
    1099              : 
    1100              :   /* -Wtemplate-id-cdtor is enabled by default in C++20.  */
    1101       292348 :   SET_OPTION_IF_UNSET (&global_options, &global_options_set,
    1102              :                        warn_template_id_cdtor,
    1103              :                        cxx_dialect >= cxx20 || warn_cxx20_compat);
    1104              : 
    1105              :   /* Declone C++ 'structors if -Os.  */
    1106       216533 :   if (flag_declone_ctor_dtor == -1)
    1107       216496 :     flag_declone_ctor_dtor = optimize_size;
    1108              : 
    1109       216533 :   if (flag_abi_compat_version == 1)
    1110              :     {
    1111            0 :       warning (0, "%<-fabi-compat-version=1%> is not supported, using =2");
    1112            0 :       flag_abi_compat_version = 2;
    1113              :     }
    1114              : 
    1115              :   /* Change flag_abi_version to be the actual current ABI level, for the
    1116              :      benefit of c_cpp_builtins, and to make comparison simpler.  */
    1117       216533 :   const int latest_abi_version = 21;
    1118              :   /* Possibly different for non-default ABI fixes within a release.  */
    1119       216533 :   const int default_abi_version = latest_abi_version;
    1120              :   /* Generate compatibility aliases for ABI v18 (GCC 13) by default.  */
    1121       216533 :   const int abi_compat_default = 18;
    1122              : 
    1123       216533 :   if (flag_abi_version > latest_abi_version)
    1124            0 :     warning (0, "%<-fabi-version=%d%> is not supported, using =%d",
    1125              :              flag_abi_version, latest_abi_version);
    1126              : 
    1127       216533 :   SET_OPTION_IF_UNSET (&global_options, &global_options_set,
    1128              :                        flag_abi_version, default_abi_version);
    1129              : 
    1130              : #define clamp(X) if (X == 0 || X > latest_abi_version) X = latest_abi_version
    1131       216533 :   clamp (flag_abi_version);
    1132              :   /* Don't clamp warn_abi_version, let it be 0 or out of bounds.  */
    1133       216533 :   clamp (flag_abi_compat_version);
    1134              : #undef clamp
    1135              : 
    1136              :   /* Default -Wabi= or -fabi-compat-version= from each other.  */
    1137       216533 :   if (warn_abi_version == -1 && flag_abi_compat_version != -1)
    1138          197 :     warn_abi_version = flag_abi_compat_version;
    1139       216336 :   else if (flag_abi_compat_version == -1 && warn_abi_version != -1)
    1140        12338 :     flag_abi_compat_version = warn_abi_version;
    1141       203998 :   else if (warn_abi_version == -1 && flag_abi_compat_version == -1)
    1142              :     {
    1143       203953 :       warn_abi_version = 0;
    1144       203953 :       if (flag_abi_version == default_abi_version)
    1145       203718 :         flag_abi_compat_version = abi_compat_default;
    1146              :       else
    1147          235 :         flag_abi_compat_version = latest_abi_version;
    1148              :     }
    1149              : 
    1150              :   /* Allow warnings vs ABI versions beyond what we currently support.  */
    1151       216533 :   if (warn_abi_version == 0)
    1152       203968 :     warn_abi_version = 1000;
    1153              : 
    1154              :   /* By default, enable the new inheriting constructor semantics along with ABI
    1155              :      11.  New and old should coexist fine, but it is a change in what
    1156              :      artificial symbols are generated.  */
    1157       432810 :   SET_OPTION_IF_UNSET (&global_options, &global_options_set,
    1158              :                        flag_new_inheriting_ctors,
    1159              :                        abi_version_at_least (11));
    1160              : 
    1161              :   /* For GCC 7, only enable DR150 resolution by default if -std=c++17.  */
    1162       216533 :   SET_OPTION_IF_UNSET (&global_options, &global_options_set, flag_new_ttp,
    1163              :                        cxx_dialect >= cxx17);
    1164              : 
    1165              :   /* C++11 guarantees forward progress.  */
    1166       407480 :   SET_OPTION_IF_UNSET (&global_options, &global_options_set, flag_finite_loops,
    1167              :                        optimize >= 2 && cxx_dialect >= cxx11);
    1168              : 
    1169              :   /* It's OK to discard calls to pure/const functions that might throw.  */
    1170       216533 :   SET_OPTION_IF_UNSET (&global_options, &global_options_set,
    1171              :                        flag_delete_dead_exceptions, true);
    1172              : 
    1173       216533 :   if (cxx_dialect >= cxx11)
    1174              :     {
    1175              :       /* If we're allowing C++0x constructs, don't warn about C++98
    1176              :          identifiers which are keywords in C++0x.  */
    1177        85569 :       warn_cxx11_compat = 0;
    1178        85569 :       cpp_opts->cpp_warn_cxx11_compat = 0;
    1179              : 
    1180        85569 :       if (warn_narrowing == -1)
    1181        83359 :         warn_narrowing = 1;
    1182              : 
    1183              :       /* Unless -f{,no-}ext-numeric-literals has been used explicitly,
    1184              :          for -std=c++{11,14,17,20,23,26} default to
    1185              :          -fno-ext-numeric-literals.  */
    1186        85569 :       if (flag_iso && !OPTION_SET_P (flag_ext_numeric_literals))
    1187        44630 :         cpp_opts->ext_numeric_literals = 0;
    1188              :     }
    1189       130964 :   else if (warn_narrowing == -1)
    1190       130470 :     warn_narrowing = 0;
    1191              : 
    1192       216533 :   if (cxx_dialect >= cxx20)
    1193              :     {
    1194              :       /* Don't warn about C++20 compatibility changes in C++20 or later.  */
    1195        74391 :       warn_cxx20_compat = 0;
    1196        74391 :       cpp_opts->cpp_warn_cxx20_compat = 0;
    1197              :     }
    1198       216533 :   if (cxx_dialect >= cxx26)
    1199              :     /* Don't warn about C++26 compatibility changes in C++26 or later.  */
    1200        24835 :     warn_cxx26_compat = 0;
    1201              : 
    1202              :   /* C++17 has stricter evaluation order requirements; let's use some of them
    1203              :      for earlier C++ as well, so chaining works as expected.  */
    1204       216533 :   if (c_dialect_cxx ()
    1205        99764 :       && flag_strong_eval_order == -1)
    1206       120918 :     flag_strong_eval_order = (cxx_dialect >= cxx17 ? 2 : 1);
    1207              : 
    1208       216533 :   if (flag_implicit_constexpr && cxx_dialect < cxx14)
    1209            0 :     flag_implicit_constexpr = false;
    1210              : 
    1211              :   /* Global sized deallocation is new in C++14.  */
    1212       216533 :   if (flag_sized_deallocation == -1)
    1213       216529 :     flag_sized_deallocation = (cxx_dialect >= cxx14);
    1214              : 
    1215              :   /* Pedwarn about invalid constexpr functions before C++23.  */
    1216       216533 :   if (warn_invalid_constexpr == -1)
    1217       216513 :     warn_invalid_constexpr = (cxx_dialect < cxx23);
    1218              : 
    1219              :   /* char8_t support is implicitly enabled in C++20 and C23.  */
    1220       216533 :   if (flag_char8_t == -1)
    1221       394323 :     flag_char8_t = (cxx_dialect >= cxx20) || flag_isoc23;
    1222       216533 :   cpp_opts->unsigned_utf8char = flag_char8_t ? 1 : cpp_opts->unsigned_char;
    1223              : 
    1224       216533 :   cpp_opts->cpp_tabstop = global_dc->get_column_options ().m_tabstop;
    1225              : 
    1226       216533 :   if (flag_extern_tls_init)
    1227              :     {
    1228       216531 :       if (!TARGET_SUPPORTS_ALIASES || !SUPPORTS_WEAK)
    1229              :         {
    1230              :           /* Lazy TLS initialization for a variable in another TU requires
    1231              :              alias and weak reference support.  */
    1232              :           if (flag_extern_tls_init > 0)
    1233              :             sorry ("external TLS initialization functions not supported "
    1234              :                    "on this target");
    1235              : 
    1236              :           flag_extern_tls_init = 0;
    1237              :         }
    1238              :       else
    1239       216531 :         flag_extern_tls_init = 1;
    1240              :     }
    1241              : 
    1242              :   /* Enable by default only for C++ and C++ with ObjC extensions.  */
    1243       216533 :   if (warn_return_type == -1 && c_dialect_cxx ())
    1244        96202 :     warn_return_type = 1;
    1245              : 
    1246              :   /* C++20 is the final version of concepts.  We still use -fconcepts
    1247              :      to know when concepts are enabled.  */
    1248       216533 :   if (cxx_dialect >= cxx20)
    1249        74391 :     flag_concepts = 1;
    1250              : 
    1251              :   /* Coroutines are also a C++20 feature.  */
    1252       216533 :   SET_OPTION_IF_UNSET (&global_options, &global_options_set,
    1253              :                        flag_coroutines, cxx_dialect >= cxx20);
    1254              : 
    1255              :   /* Enable lifetime extension of range based for temporaries for C++23.  */
    1256       216533 :   SET_OPTION_IF_UNSET (&global_options, &global_options_set,
    1257              :                        flag_range_for_ext_temps, cxx_dialect >= cxx23);
    1258              : 
    1259              :   /* Contracts are in C++26.  */
    1260       216533 :   SET_OPTION_IF_UNSET (&global_options, &global_options_set,
    1261              :                        flag_contracts, cxx_dialect >= cxx26);
    1262              : 
    1263              :   /* EnabledBy unfortunately can't specify value to use if set and
    1264              :      LangEnabledBy can't specify multiple options with &&.  For -Wunused
    1265              :      or -Wunused -Wextra we want these to default to 3 unless user specified
    1266              :      some other level explicitly.  */
    1267       216533 :   if (warn_unused_but_set_parameter == 1)
    1268         7710 :     SET_OPTION_IF_UNSET (&global_options, &global_options_set,
    1269              :                          warn_unused_but_set_parameter, 3);
    1270       216533 :   if (warn_unused_but_set_variable == 1)
    1271        10580 :     SET_OPTION_IF_UNSET (&global_options, &global_options_set,
    1272              :                          warn_unused_but_set_variable, 3);
    1273              : 
    1274              :   /* -fimmediate-escalation has no effect when immediate functions are not
    1275              :      supported.  */
    1276       216533 :   if (flag_immediate_escalation && cxx_dialect < cxx20)
    1277       142142 :     flag_immediate_escalation = 0;
    1278              : 
    1279       216533 :   if (flag_reflection && cxx_dialect < cxx26)
    1280            0 :     error ("%<-freflection%> only supported with %<-std=c++26%> or "
    1281              :            "%<-std=gnu++26%>");
    1282              : 
    1283       216533 :   if (num_in_fnames > 1)
    1284            0 :     error ("too many filenames given; type %<%s %s%> for usage",
    1285              :            progname, "--help");
    1286              : 
    1287       216533 :   if (flag_preprocess_only)
    1288              :     {
    1289              :       /* Open the output now.  We must do so even if flag_no_output is
    1290              :          on, because there may be other output than from the actual
    1291              :          preprocessing (e.g. from -dM).  */
    1292         7199 :       if (out_fname[0] == '\0')
    1293          745 :         out_stream = stdout;
    1294              :       else
    1295         6454 :         out_stream = fopen (out_fname, "w");
    1296              : 
    1297         7199 :       if (out_stream == NULL)
    1298            0 :         fatal_error (input_location, "opening output file %s: %m", out_fname);
    1299              : 
    1300         7199 :       init_pp_output (out_stream);
    1301              :     }
    1302              :   else
    1303              :     {
    1304       209334 :       init_c_lex ();
    1305              : 
    1306              :       /* When writing a PCH file, avoid reading some other PCH file,
    1307              :          because the default address space slot then can't be used
    1308              :          for the output PCH file.  */
    1309       209334 :       if (pch_file)
    1310              :         {
    1311          474 :           c_common_no_more_pch ();
    1312              :           /* Only -g0 and -gdwarf* are supported with PCH, for other
    1313              :              debug formats we warn here and refuse to load any PCH files.  */
    1314          474 :           if (write_symbols != NO_DEBUG && write_symbols != DWARF2_DEBUG)
    1315            0 :               warning (OPT_Wdeprecated,
    1316              :                        "the %qs debug info cannot be used with "
    1317              :                        "pre-compiled headers",
    1318              :                        debug_set_names (write_symbols & ~DWARF2_DEBUG));
    1319              :           /* Let libcpp know that the main file is a header so it won't
    1320              :              complain about things like #include_next and #pragma once.  */
    1321          474 :           cpp_opts->main_search = CMS_header;
    1322              :         }
    1323       208860 :       else if (write_symbols != NO_DEBUG && write_symbols != DWARF2_DEBUG)
    1324          500 :         c_common_no_more_pch ();
    1325              : 
    1326              :       /* Yuk.  WTF is this?  I do know ObjC relies on it somewhere.  */
    1327       209334 :       input_location = UNKNOWN_LOCATION;
    1328              :     }
    1329              : 
    1330       216533 :   struct cpp_callbacks *cb = cpp_get_callbacks (parse_in);
    1331       216533 :   cb->file_change = cb_file_change;
    1332       216533 :   cb->dir_change = cb_dir_change;
    1333       216533 :   if (lang_hooks.preprocess_options)
    1334        99764 :     lang_hooks.preprocess_options (parse_in);
    1335       216533 :   cpp_post_options (parse_in);
    1336       216533 :   init_global_opts_from_cpp (&global_options, cpp_get_options (parse_in));
    1337              :   /* For C++23 and explicit -finput-charset=UTF-8, turn on -Winvalid-utf8
    1338              :      by default and make it a pedwarn unless -Wno-invalid-utf8.  */
    1339       216533 :   if (cxx_dialect >= cxx23
    1340        26976 :       && cpp_opts->cpp_input_charset_explicit
    1341           28 :       && strcmp (cpp_opts->input_charset, "UTF-8") == 0
    1342           26 :       && (cpp_opts->cpp_warn_invalid_utf8
    1343           21 :           || !global_options_set.x_warn_invalid_utf8))
    1344              :     {
    1345           23 :       global_options.x_warn_invalid_utf8 = 1;
    1346           34 :       cpp_opts->cpp_warn_invalid_utf8 = cpp_opts->cpp_pedantic ? 2 : 1;
    1347              :     }
    1348              : 
    1349              :   /* Let diagnostics infrastructure know how to convert input files the same
    1350              :      way libcpp will do it, namely using the configured input charset and
    1351              :      skipping a UTF-8 BOM if present.  */
    1352       216533 :   diagnostic_initialize_input_context (global_dc,
    1353              :                                        c_common_input_charset_cb, true);
    1354       216533 :   input_location = UNKNOWN_LOCATION;
    1355              : 
    1356       433066 :   *pfilename = this_input_filename
    1357       433066 :     = cpp_read_main_file (parse_in, in_fnames[0],
    1358              :                           /* We'll inject preamble pieces if this is
    1359              :                              not preprocessed.  */
    1360       216533 :                           !cpp_opts->preprocessed);
    1361              : 
    1362              :   /* Don't do any compilation or preprocessing if there is no input file.  */
    1363       216533 :   if (this_input_filename == NULL)
    1364              :     {
    1365            0 :       errorcount++;
    1366            0 :       return false;
    1367              :     }
    1368              : 
    1369       216533 :   if (flag_working_directory
    1370        42146 :       && flag_preprocess_only && !flag_no_line_commands)
    1371         2220 :     pp_dir_change (parse_in, get_src_pwd ());
    1372              : 
    1373              :   /* Disable LTO output when outputting a precompiled header.  */
    1374       216533 :   if (pch_file && flag_lto)
    1375              :     {
    1376            0 :       flag_lto = 0;
    1377            0 :       flag_generate_lto = 0;
    1378              :     }
    1379              : 
    1380       216533 :   return flag_preprocess_only;
    1381              : }
    1382              : 
    1383              : /* Front end initialization common to C, ObjC and C++.  */
    1384              : bool
    1385       216307 : c_common_init (void)
    1386              : {
    1387              :   /* Set up preprocessor arithmetic.  Must be done after call to
    1388              :      c_common_nodes_and_builtins for type nodes to be good.  */
    1389       216307 :   cpp_opts->precision = TYPE_PRECISION (intmax_type_node);
    1390       216307 :   cpp_opts->char_precision = TYPE_PRECISION (char_type_node);
    1391       216307 :   cpp_opts->int_precision = TYPE_PRECISION (integer_type_node);
    1392       216307 :   cpp_opts->wchar_precision = TYPE_PRECISION (wchar_type_node);
    1393       216307 :   cpp_opts->unsigned_wchar = TYPE_UNSIGNED (wchar_type_node);
    1394       216307 :   cpp_opts->bytes_big_endian = BYTES_BIG_ENDIAN;
    1395              : 
    1396              :   /* This can't happen until after wchar_precision and bytes_big_endian
    1397              :      are known.  */
    1398       216307 :   cpp_init_iconv (parse_in);
    1399              : 
    1400       216307 :   if (version_flag)
    1401              :     {
    1402          173 :       int i;
    1403          173 :       fputs ("Compiler executable checksum: ", stderr);
    1404         3114 :       for (i = 0; i < 16; i++)
    1405         2768 :         fprintf (stderr, "%02x", executable_checksum[i]);
    1406          173 :       putc ('\n', stderr);
    1407              :     }
    1408              : 
    1409              :   /* Has to wait until now so that cpplib has its hash table.  */
    1410       216307 :   init_pragma ();
    1411              : 
    1412       216307 :   if (flag_preprocess_only)
    1413              :     {
    1414         7194 :       c_init_preprocess ();
    1415         7194 :       c_finish_options ();
    1416         7194 :       preprocess_file (parse_in);
    1417         7194 :       return false;
    1418              :     }
    1419              : 
    1420              :   return true;
    1421              : }
    1422              : 
    1423              : /* Initialize the integrated preprocessor after debug output has been
    1424              :    initialized; loop over each input file.  */
    1425              : void
    1426       209113 : c_common_parse_file (void)
    1427              : {
    1428       209113 :   auto dumps = g->get_dumps ();
    1429       209113 :   for (unsigned int i = 0;;)
    1430              :     {
    1431       209113 :       c_finish_options ();
    1432              :       /* Open the dump file to use for the original dump output
    1433              :          here, to be used during parsing for the current file.  */
    1434       209113 :       dumps->dump_start (TDI_original, &dump_flags);
    1435       209113 :       pch_init ();
    1436       209113 :       push_file_scope ();
    1437       209113 :       c_parse_file ();
    1438       208809 :       pop_file_scope ();
    1439              :       /* And end the main input file, if the debug writer wants it  */
    1440       208809 :       if (debug_hooks->start_end_main_source_file)
    1441        39738 :         (*debug_hooks->end_source_file) (0);
    1442       208809 :       if (++i >= num_in_fnames)
    1443              :         break;
    1444            0 :       cpp_undef_all (parse_in);
    1445            0 :       cpp_clear_file_cache (parse_in);
    1446            0 :       this_input_filename
    1447            0 :         = cpp_read_main_file (parse_in, in_fnames[i]);
    1448              :       /* If an input file is missing, abandon further compilation.
    1449              :          cpplib has issued a diagnostic.  */
    1450            0 :       if (!this_input_filename)
    1451              :         break;
    1452            0 :       dumps->dump_finish (TDI_original);
    1453              :     }
    1454              : 
    1455       208809 :   c_parse_final_cleanups ();
    1456       208797 :   dumps->dump_finish (TDI_original);
    1457       208797 : }
    1458              : 
    1459              : /* Common finish hook for the C, ObjC and C++ front ends.  */
    1460              : void
    1461       215796 : c_common_finish (void)
    1462              : {
    1463       215796 :   FILE *deps_stream = NULL;
    1464       215796 :   FILE *fdeps_stream = NULL;
    1465              : 
    1466              :   /* Note that we write the dependencies even if there are errors. This is
    1467              :      useful for handling outdated generated headers that now trigger errors
    1468              :      (for example, with #error) which would be resolved by re-generating
    1469              :      them. In a sense, this complements -MG.  */
    1470       215796 :   if (cpp_opts->deps.style != DEPS_NONE)
    1471              :     {
    1472              :       /* If -M or -MM was seen without -MF, default output to the
    1473              :          output stream.  */
    1474         5918 :       if (!deps_file)
    1475           25 :         deps_stream = out_stream;
    1476         5893 :       else if (deps_file[0] == '-' && deps_file[1] == '\0')
    1477            0 :         deps_stream = stdout;
    1478              :       else
    1479              :         {
    1480        11786 :           deps_stream = fopen (deps_file, deps_append ? "a" : "w");
    1481         5893 :           if (!deps_stream)
    1482            0 :             fatal_error (input_location, "opening dependency file %s: %m",
    1483              :                          deps_file);
    1484              :         }
    1485              :     }
    1486              : 
    1487              :   /* When we call cpp_finish (), it may generate some diagnostics using
    1488              :      locations it remembered from the preprocessing phase, e.g. for
    1489              :      -Wunused-macros.  So inform c_cpp_diagnostic () not to override those
    1490              :      locations with input_location, which would be incorrect now.  */
    1491       215796 :   override_libcpp_locations = false;
    1492              : 
    1493       215796 :   if (cpp_opts->deps.fdeps_format != FDEPS_FMT_NONE)
    1494              :     {
    1495           36 :       if (!fdeps_file)
    1496            0 :         fdeps_stream = out_stream;
    1497           36 :       else if (fdeps_file[0] == '-' && fdeps_file[1] == '\0')
    1498            0 :         fdeps_stream = stdout;
    1499              :       else
    1500              :         {
    1501           36 :           fdeps_stream = fopen (fdeps_file, "w");
    1502           36 :           if (!fdeps_stream)
    1503            0 :             fatal_error (input_location, "opening dependency file %s: %m",
    1504              :                          fdeps_file);
    1505              :         }
    1506           36 :       if (fdeps_stream == deps_stream && fdeps_stream != stdout)
    1507            0 :         fatal_error (input_location, "%<-MF%> and %<-fdeps-file=%> cannot share an output file %s: %m",
    1508            0 :                      fdeps_file ? fdeps_file : out_fname);
    1509              :     }
    1510              : 
    1511              :   /* For performance, avoid tearing down cpplib's internal structures
    1512              :      with cpp_destroy ().  */
    1513       215796 :   cpp_finish (parse_in, deps_stream, fdeps_stream);
    1514              : 
    1515         5918 :   if (deps_stream && deps_stream != out_stream && deps_stream != stdout
    1516       221689 :       && (ferror (deps_stream) || fclose (deps_stream)))
    1517            0 :     fatal_error (input_location, "closing dependency file %s: %m", deps_file);
    1518              : 
    1519       215796 :   if (out_stream && (ferror (out_stream) || fclose (out_stream)))
    1520            0 :     fatal_error (input_location, "when writing output to %s: %m", out_fname);
    1521       215796 : }
    1522              : 
    1523              : /* Either of two environment variables can specify output of
    1524              :    dependencies.  Their value is either "OUTPUT_FILE" or "OUTPUT_FILE
    1525              :    DEPS_TARGET", where OUTPUT_FILE is the file to write deps info to
    1526              :    and DEPS_TARGET is the target to mention in the deps.  They also
    1527              :    result in dependency information being appended to the output file
    1528              :    rather than overwriting it, and like Sun's compiler
    1529              :    SUNPRO_DEPENDENCIES suppresses the dependency on the main file.  */
    1530              : static void
    1531       210610 : check_deps_environment_vars (void)
    1532              : {
    1533       210610 :   char *spec;
    1534              : 
    1535       210610 :   spec = getenv ("DEPENDENCIES_OUTPUT");
    1536       210610 :   if (spec)
    1537            0 :     cpp_opts->deps.style = DEPS_USER;
    1538              :   else
    1539              :     {
    1540       210610 :       spec = getenv ("SUNPRO_DEPENDENCIES");
    1541       210610 :       if (spec)
    1542              :         {
    1543            0 :           cpp_opts->deps.style = DEPS_SYSTEM;
    1544            0 :           cpp_opts->deps.ignore_main_file = true;
    1545              :         }
    1546              :     }
    1547              : 
    1548            0 :   if (spec)
    1549              :     {
    1550              :       /* Find the space before the DEPS_TARGET, if there is one.  */
    1551            0 :       char *s = strchr (spec, ' ');
    1552            0 :       if (s)
    1553              :         {
    1554              :           /* Let the caller perform MAKE quoting.  */
    1555            0 :           defer_opt (OPT_MT, s + 1);
    1556            0 :           *s = '\0';
    1557              :         }
    1558              : 
    1559              :       /* Command line -MF overrides environment variables and default.  */
    1560            0 :       if (!deps_file)
    1561            0 :         deps_file = spec;
    1562              : 
    1563            0 :       deps_append = 1;
    1564            0 :       deps_seen = true;
    1565              :     }
    1566       210610 : }
    1567              : 
    1568              : /* Handle deferred command line switches.  */
    1569              : static void
    1570       216533 : handle_deferred_opts (void)
    1571              : {
    1572              :   /* Avoid allocating the deps buffer if we don't need it.
    1573              :      (This flag may be true without there having been -MT or -MQ
    1574              :      options, but we'll still need the deps buffer.)  */
    1575       216533 :   if (!deps_seen)
    1576              :     return;
    1577              : 
    1578         5922 :   if (mkdeps *deps = cpp_get_deps (parse_in))
    1579        35028 :     for (unsigned i = 0; i < deferred_count; i++)
    1580              :       {
    1581        29130 :         struct deferred_opt *opt = &deferred_opts[i];
    1582              : 
    1583        29130 :         if (opt->code == OPT_MT || opt->code == OPT_MQ)
    1584         5888 :           deps_add_target (deps, opt->arg, opt->code == OPT_MQ);
    1585        23242 :         else if (opt->code == OPT_fdeps_target_)
    1586           42 :           fdeps_add_target (deps, opt->arg, true);
    1587              :       }
    1588              : }
    1589              : 
    1590              : /* These settings are appropriate for GCC, but not necessarily so for
    1591              :    cpplib as a library.  */
    1592              : static void
    1593       216533 : sanitize_cpp_opts (void)
    1594              : {
    1595              :   /* If we don't know what style of dependencies to output, complain
    1596              :      if any other dependency switches have been given.  */
    1597       216533 :   if (deps_seen && cpp_opts->deps.style == DEPS_NONE)
    1598           24 :     error ("to generate dependencies you must specify either %<-M%> "
    1599              :            "or %<-MM%>");
    1600              : 
    1601              :   /* -dM and dependencies suppress normal output; do it here so that
    1602              :      the last -d[MDN] switch overrides earlier ones.  */
    1603       216533 :   if (flag_dump_macros == 'M')
    1604           80 :     flag_no_output = 1;
    1605              : 
    1606              :   /* By default, -fdirectives-only implies -dD.  This allows subsequent phases
    1607              :      to perform proper macro expansion.  */
    1608       216533 :   if (cpp_opts->directives_only && !cpp_opts->preprocessed && !flag_dump_macros)
    1609           80 :     flag_dump_macros = 'D';
    1610              : 
    1611              :   /* Disable -dD, -dN and -dI if normal output is suppressed.  Allow
    1612              :      -dM since at least glibc relies on -M -dM to work.  */
    1613              :   /* Also, flag_no_output implies flag_no_line_commands, always.  */
    1614       216533 :   if (flag_no_output)
    1615              :     {
    1616          110 :       if (flag_dump_macros != 'M')
    1617           30 :         flag_dump_macros = 0;
    1618          110 :       flag_dump_includes = 0;
    1619          110 :       flag_no_line_commands = 1;
    1620              :     }
    1621       216423 :   else if (cpp_opts->deps.missing_files)
    1622            1 :     error ("%<-MG%> may only be used with %<-M%> or %<-MM%>");
    1623              : 
    1624       216533 :   cpp_opts->unsigned_char = !flag_signed_char;
    1625       216533 :   cpp_opts->stdc_0_in_system_headers = STDC_0_IN_SYSTEM_HEADERS;
    1626              : 
    1627              :   /* Wlong-long is disabled by default. It is enabled by:
    1628              :       [-Wpedantic | -Wtraditional] -std=[gnu|c]++98 ; or
    1629              :       [-Wpedantic | -Wtraditional] -std=non-c99
    1630              : 
    1631              :       Either -Wlong-long or -Wno-long-long override any other settings.
    1632              :       ??? These conditions should be handled in c.opt.  */
    1633       216533 :   if (warn_long_long == -1)
    1634              :     {
    1635       166135 :       warn_long_long = ((pedantic || warn_traditional)
    1636       169896 :                         && (c_dialect_cxx () ? cxx_dialect == cxx98 : !flag_isoc99));
    1637       169872 :       cpp_opts->cpp_warn_long_long = warn_long_long;
    1638              :     }
    1639              : 
    1640              :   /* If we're generating preprocessor output, emit current directory
    1641              :      if explicitly requested or if debugging information is enabled.
    1642              :      ??? Maybe we should only do it for debugging formats that
    1643              :      actually output the current directory?  */
    1644       216533 :   if (flag_working_directory == -1)
    1645       215263 :     flag_working_directory = (debug_info_level != DINFO_LEVEL_NONE);
    1646              : 
    1647       216533 :   if (warn_implicit_fallthrough < 5)
    1648       216529 :     cpp_opts->cpp_warn_implicit_fallthrough = warn_implicit_fallthrough;
    1649              :   else
    1650            4 :     cpp_opts->cpp_warn_implicit_fallthrough = 0;
    1651              : 
    1652       216533 :   if (cpp_opts->directives_only)
    1653              :     {
    1654          121 :       if (cpp_warn_unused_macros)
    1655            4 :         error ("%<-fdirectives-only%> is incompatible "
    1656              :                "with %<-Wunused-macros%>");
    1657          121 :       if (cpp_opts->traditional)
    1658            1 :         error ("%<-fdirectives-only%> is incompatible with %<-traditional%>");
    1659              :     }
    1660       216533 : }
    1661              : 
    1662              : /* Add include path with a prefix at the front of its name.  */
    1663              : static void
    1664            0 : add_prefixed_path (const char *suffix, incpath_kind chain)
    1665              : {
    1666            0 :   char *path;
    1667            0 :   const char *prefix;
    1668            0 :   size_t prefix_len, suffix_len;
    1669              : 
    1670            0 :   suffix_len = strlen (suffix);
    1671            0 :   prefix     = iprefix ? iprefix : cpp_GCC_INCLUDE_DIR;
    1672            0 :   prefix_len = iprefix ? strlen (iprefix) : cpp_GCC_INCLUDE_DIR_len;
    1673              : 
    1674            0 :   path = (char *) xmalloc (prefix_len + suffix_len + 1);
    1675            0 :   memcpy (path, prefix, prefix_len);
    1676            0 :   memcpy (path + prefix_len, suffix, suffix_len);
    1677            0 :   path[prefix_len + suffix_len] = '\0';
    1678              : 
    1679            0 :   add_path (path, chain, 0, false);
    1680            0 : }
    1681              : 
    1682              : /* Handle -D, -U, -A, -imacros, and the first -include.  */
    1683              : static void
    1684       216307 : c_finish_options (void)
    1685              : {
    1686       216307 :   if (!cpp_opts->preprocessed)
    1687              :     {
    1688       215770 :       const line_map_ordinary *bltin_map
    1689       215770 :         = linemap_check_ordinary (linemap_add (line_table, LC_RENAME, 0,
    1690              :                                                special_fname_builtin (), 0));
    1691       215770 :       cb_file_change (parse_in, bltin_map);
    1692       215770 :       linemap_line_start (line_table, 0, 1);
    1693              : 
    1694              :       /* Make sure all of the builtins about to be declared have
    1695              :          BUILTINS_LOCATION has their location_t.  */
    1696       215770 :       cpp_force_token_locations (parse_in, BUILTINS_LOCATION);
    1697              : 
    1698       215770 :       cpp_init_builtins (parse_in, flag_hosted);
    1699       215770 :       c_cpp_builtins (parse_in);
    1700              : 
    1701              :       /* We're about to send user input to cpplib, so make it warn for
    1702              :          things that we previously (when we sent it internal definitions)
    1703              :          told it to not warn.
    1704              : 
    1705              :          C99 permits implementation-defined characters in identifiers.
    1706              :          The documented meaning of -std= is to turn off extensions that
    1707              :          conflict with the specified standard, and since a strictly
    1708              :          conforming program cannot contain a '$', we do not condition
    1709              :          their acceptance on the -std= setting.  */
    1710       215770 :       cpp_opts->warn_dollars = (cpp_opts->cpp_pedantic && !cpp_opts->c99);
    1711              : 
    1712       215770 :       const line_map_ordinary *cmd_map
    1713       215770 :         = linemap_check_ordinary (linemap_add (line_table, LC_RENAME, 0,
    1714       215770 :                                                _("<command-line>"), 0));
    1715       215770 :       cb_file_change (parse_in, cmd_map);
    1716       215770 :       linemap_line_start (line_table, 0, 1);
    1717              : 
    1718       215770 :       bool fortify_seen_p = false;
    1719       215770 :       bool cxx_assert_seen_p = false;
    1720              : 
    1721              :       /* All command line defines must have the same location.  */
    1722       215770 :       line_table->cmdline_location = line_table->highest_line;
    1723       215770 :       cpp_force_token_locations (parse_in, line_table->highest_line);
    1724       403034 :       for (size_t i = 0; i < deferred_count; i++)
    1725              :         {
    1726       187264 :           struct deferred_opt *opt = &deferred_opts[i];
    1727              : 
    1728       187264 :           if (opt->code == OPT_D)
    1729       171907 :             cpp_define (parse_in, opt->arg);
    1730        15357 :           else if (opt->code == OPT_U)
    1731           60 :             cpp_undef (parse_in, opt->arg);
    1732        15297 :           else if (opt->code == OPT_A)
    1733              :             {
    1734           10 :               if (opt->arg[0] == '-')
    1735            2 :                 cpp_unassert (parse_in, opt->arg + 1);
    1736              :               else
    1737            8 :                 cpp_assert (parse_in, opt->arg);
    1738              :             }
    1739              : 
    1740       187264 :           if (UNLIKELY (flag_hardened)
    1741           83 :               && (opt->code == OPT_D || opt->code == OPT_U))
    1742              :             {
    1743           83 :               if (!fortify_seen_p)
    1744           79 :                 fortify_seen_p
    1745           79 :                   = (!strncmp (opt->arg, "_FORTIFY_SOURCE", 15)
    1746           79 :                      && (opt->arg[15] == '\0' || opt->arg[15] == '='));
    1747           83 :               if (!cxx_assert_seen_p)
    1748           83 :                 cxx_assert_seen_p
    1749           83 :                   = (!strncmp (opt->arg, "_GLIBCXX_ASSERTIONS", 19)
    1750           83 :                      && (opt->arg[19] == '\0' || opt->arg[19] == '='));
    1751              :             }
    1752              :         }
    1753              : 
    1754       215770 :       if (flag_hardened)
    1755              :         {
    1756           92 :           if (!fortify_seen_p && optimize > 0)
    1757           72 :             cpp_define_formatted (parse_in, "_FORTIFY_SOURCE=%u",
    1758           72 :                                   targetm.fortify_source_default_level ());
    1759           20 :           else if (optimize == 0)
    1760           20 :             warning_at (UNKNOWN_LOCATION, OPT_Whardened,
    1761              :                         "%<_FORTIFY_SOURCE%> is not enabled by %<-fhardened%> "
    1762              :                         "because optimizations are turned off");
    1763              :           else
    1764            0 :             warning_at (UNKNOWN_LOCATION, OPT_Whardened,
    1765              :                         "%<_FORTIFY_SOURCE%> is not enabled by %<-fhardened%> "
    1766              :                         "because it was specified in %<-D%> or %<-U%>");
    1767           92 :           if (!cxx_assert_seen_p)
    1768           88 :             cpp_define (parse_in, "_GLIBCXX_ASSERTIONS");
    1769              :           else
    1770            4 :             warning_at (UNKNOWN_LOCATION, OPT_Whardened,
    1771              :                         "%<_GLIBCXX_ASSERTIONS%> is not enabled by "
    1772              :                         "%<-fhardened%> because it was specified in %<-D%> "
    1773              :                         "or %<-U%>");
    1774              :         }
    1775              : 
    1776       215770 :       cpp_stop_forcing_token_locations (parse_in);
    1777              :     }
    1778          537 :   else if (cpp_opts->directives_only)
    1779           41 :     cpp_init_special_builtins (parse_in);
    1780              : 
    1781              :   /* Start the main input file, if the debug writer wants it. */
    1782       216307 :   if (debug_hooks->start_end_main_source_file
    1783        42077 :       && !flag_preprocess_only)
    1784        39853 :     (*debug_hooks->start_source_file) (0, this_input_filename);
    1785              : 
    1786       216307 :   if (!cpp_opts->preprocessed)
    1787              :     /* Handle -imacros after -D and -U.  */
    1788       403034 :     for (size_t i = 0; i < deferred_count; i++)
    1789              :       {
    1790       187264 :         struct deferred_opt *opt = &deferred_opts[i];
    1791              : 
    1792       187264 :         if (opt->code == OPT_imacros
    1793       187264 :             && cpp_push_include (parse_in, opt->arg))
    1794              :           {
    1795              :             /* Disable push_command_line_include callback for now.  */
    1796            8 :             include_cursor = deferred_count + 1;
    1797            8 :             cpp_scan_nooutput (parse_in);
    1798              :           }
    1799              :       }
    1800              : 
    1801       216307 :   include_cursor = 0;
    1802       216307 :   push_command_line_include ();
    1803       216307 : }
    1804              : 
    1805              : /* Give CPP the next file given by -include, if any.  */
    1806              : static void
    1807       761911 : push_command_line_include (void)
    1808              : {
    1809              :   /* This can happen if disabled by -imacros for example.
    1810              :      Punt so that we don't set "<command-line>" as the filename for
    1811              :      the header.  */
    1812       761911 :   if (include_cursor > deferred_count)
    1813              :     return;
    1814              : 
    1815       441341 :   if (!done_preinclude)
    1816              :     {
    1817       216307 :       done_preinclude = true;
    1818       216307 :       if (flag_hosted && std_inc && !cpp_opts->preprocessed)
    1819              :         {
    1820       215688 :           const char *preinc = targetcm.c_preinclude ();
    1821       215688 :           if (preinc && cpp_push_default_include (parse_in, preinc))
    1822              :             return;
    1823              :         }
    1824              :     }
    1825              : 
    1826       225653 :   pch_cpp_save_state ();
    1827              : 
    1828       629275 :   while (include_cursor < deferred_count)
    1829              :     {
    1830       187316 :       struct deferred_opt *opt = &deferred_opts[include_cursor++];
    1831              : 
    1832       374579 :       if (!cpp_opts->preprocessed && opt->code == OPT_include
    1833       196666 :           && cpp_push_include (parse_in, opt->arg))
    1834              :         return;
    1835              :     }
    1836              : 
    1837       216306 :   if (include_cursor == deferred_count)
    1838              :     {
    1839       216306 :       include_cursor++;
    1840              :       /* -Wunused-macros should only warn about macros defined hereafter.  */
    1841       216306 :       cpp_opts->warn_unused_macros = cpp_warn_unused_macros;
    1842              :       /* Restore the line map back to the main file.  */
    1843       216306 :       if (!cpp_opts->preprocessed)
    1844              :         {
    1845       215769 :           cpp_change_file (parse_in, LC_RENAME, this_input_filename);
    1846       215769 :           if (lang_hooks.preprocess_main_file)
    1847              :             /* We're starting the main file.  Inform the FE of that.  */
    1848        99499 :             lang_hooks.preprocess_main_file
    1849        99499 :               (parse_in, line_table, LINEMAPS_LAST_ORDINARY_MAP (line_table));
    1850              :         }
    1851              : 
    1852              :       /* Set this here so the client can change the option if it wishes,
    1853              :          and after stacking the main file so we don't trace the main file.  */
    1854       216306 :       line_table->trace_includes = cpp_opts->print_include_names;
    1855              :     }
    1856              : }
    1857              : 
    1858              : /* File change callback.  Has to handle -include files.  */
    1859              : static void
    1860     20654246 : cb_file_change (cpp_reader *reader, const line_map_ordinary *new_map)
    1861              : {
    1862     20654246 :   if (flag_preprocess_only)
    1863       182741 :     pp_file_change (new_map);
    1864              :   else
    1865     20471505 :     fe_file_change (new_map);
    1866              : 
    1867     20438343 :   if (new_map && cpp_opts->preprocessed
    1868        40416 :       && lang_hooks.preprocess_main_file && MAIN_FILE_P (new_map)
    1869     20656860 :       && ORDINARY_MAP_STARTING_LINE_NUMBER (new_map))
    1870              :     /* We're starting the main file.  Inform the FE of that.  */
    1871          468 :     lang_hooks.preprocess_main_file (reader, line_table, new_map);
    1872              : 
    1873     20654246 :   if (new_map
    1874     20438343 :       && (new_map->reason == LC_ENTER || new_map->reason == LC_RENAME))
    1875              :     {
    1876              :       /* Signal to plugins that a file is included.  This could happen
    1877              :          several times with the same file path, e.g. because of
    1878              :          several '#include' or '#line' directives...  */
    1879     10653017 :       invoke_plugin_callbacks
    1880     10653017 :         (PLUGIN_INCLUDE_FILE,
    1881     10653017 :          const_cast<char*> (ORDINARY_MAP_FILE_NAME (new_map)));
    1882              :     }
    1883              : 
    1884     20438343 :   if (new_map == 0 || (new_map->reason == LC_LEAVE && MAIN_FILE_P (new_map)))
    1885              :     {
    1886       545604 :       pch_cpp_save_state ();
    1887       545604 :       push_command_line_include ();
    1888              :     }
    1889     20654245 : }
    1890              : 
    1891              : void
    1892           53 : cb_dir_change (cpp_reader * ARG_UNUSED (pfile), const char *dir)
    1893              : {
    1894           53 :   if (!set_src_pwd (dir))
    1895            0 :     warning (0, "too late for # directive to set debug directory");
    1896           53 : }
    1897              : 
    1898              : /* Set the C 89 standard (with 1994 amendments if C94, without GNU
    1899              :    extensions if ISO).  There is no concept of gnu94.  */
    1900              : static void
    1901         6970 : set_std_c89 (int c94, int iso)
    1902              : {
    1903         9923 :   cpp_set_lang (parse_in, c94 ? CLK_STDC94 : iso ? CLK_STDC89 : CLK_GNUC89);
    1904         6970 :   flag_iso = iso;
    1905         6970 :   flag_no_asm = iso;
    1906         6970 :   flag_no_gnu_keywords = iso;
    1907         6970 :   flag_no_nonansi_builtin = iso;
    1908         6970 :   flag_isoc94 = c94;
    1909         6970 :   flag_isoc99 = 0;
    1910         6970 :   flag_isoc11 = 0;
    1911         6970 :   flag_isoc23 = 0;
    1912         6970 :   flag_isoc2y = 0;
    1913         6970 :   lang_hooks.name = "GNU C89";
    1914         6970 : }
    1915              : 
    1916              : /* Set the C 99 standard (without GNU extensions if ISO).  */
    1917              : static void
    1918         1196 : set_std_c99 (int iso)
    1919              : {
    1920         1812 :   cpp_set_lang (parse_in, iso ? CLK_STDC99 : CLK_GNUC99);
    1921         1196 :   flag_no_asm = iso;
    1922         1196 :   flag_no_nonansi_builtin = iso;
    1923         1196 :   flag_iso = iso;
    1924         1196 :   flag_isoc2y = 0;
    1925         1196 :   flag_isoc23 = 0;
    1926         1196 :   flag_isoc11 = 0;
    1927         1196 :   flag_isoc99 = 1;
    1928         1196 :   flag_isoc94 = 1;
    1929         1196 :   lang_hooks.name = "GNU C99";
    1930         1196 : }
    1931              : 
    1932              : /* Set the C 11 standard (without GNU extensions if ISO).  */
    1933              : static void
    1934         4232 : set_std_c11 (int iso)
    1935              : {
    1936         7950 :   cpp_set_lang (parse_in, iso ? CLK_STDC11 : CLK_GNUC11);
    1937         4232 :   flag_no_asm = iso;
    1938         4232 :   flag_no_nonansi_builtin = iso;
    1939         4232 :   flag_iso = iso;
    1940         4232 :   flag_isoc2y = 0;
    1941         4232 :   flag_isoc23 = 0;
    1942         4232 :   flag_isoc11 = 1;
    1943         4232 :   flag_isoc99 = 1;
    1944         4232 :   flag_isoc94 = 1;
    1945         4232 :   lang_hooks.name = "GNU C11";
    1946         4232 : }
    1947              : 
    1948              : /* Set the C 17 standard (without GNU extensions if ISO).  */
    1949              : static void
    1950          819 : set_std_c17 (int iso)
    1951              : {
    1952         1596 :   cpp_set_lang (parse_in, iso ? CLK_STDC17 : CLK_GNUC17);
    1953          819 :   flag_no_asm = iso;
    1954          819 :   flag_no_nonansi_builtin = iso;
    1955          819 :   flag_iso = iso;
    1956          819 :   flag_isoc2y = 0;
    1957          819 :   flag_isoc23 = 0;
    1958          819 :   flag_isoc11 = 1;
    1959          819 :   flag_isoc99 = 1;
    1960          819 :   flag_isoc94 = 1;
    1961          819 :   lang_hooks.name = "GNU C17";
    1962          819 : }
    1963              : 
    1964              : /* Set the C 23 standard (without GNU extensions if ISO).  */
    1965              : static void
    1966       117997 : set_std_c23 (int iso)
    1967              : {
    1968       235086 :   cpp_set_lang (parse_in, iso ? CLK_STDC23 : CLK_GNUC23);
    1969       117997 :   flag_no_asm = iso;
    1970       117997 :   flag_no_nonansi_builtin = iso;
    1971       117997 :   flag_iso = iso;
    1972       117997 :   flag_isoc2y = 0;
    1973       117997 :   flag_isoc23 = 1;
    1974       117997 :   flag_isoc11 = 1;
    1975       117997 :   flag_isoc99 = 1;
    1976       117997 :   flag_isoc94 = 1;
    1977       117997 :   lang_hooks.name = "GNU C23";
    1978       117997 : }
    1979              : 
    1980              : /* Set the C 2Y standard (without GNU extensions if ISO).  */
    1981              : static void
    1982          215 : set_std_c2y (int iso)
    1983              : {
    1984          226 :   cpp_set_lang (parse_in, iso ? CLK_STDC2Y : CLK_GNUC2Y);
    1985          215 :   flag_no_asm = iso;
    1986          215 :   flag_no_nonansi_builtin = iso;
    1987          215 :   flag_iso = iso;
    1988          215 :   flag_isoc2y = 1;
    1989          215 :   flag_isoc23 = 1;
    1990          215 :   flag_isoc11 = 1;
    1991          215 :   flag_isoc99 = 1;
    1992          215 :   flag_isoc94 = 1;
    1993          215 :   lang_hooks.name = "GNU C2Y";
    1994          215 : }
    1995              : 
    1996              : 
    1997              : /* Set the C++ 98 standard (without GNU extensions if ISO).  */
    1998              : static void
    1999        14265 : set_std_cxx98 (int iso)
    2000              : {
    2001        19644 :   cpp_set_lang (parse_in, iso ? CLK_CXX98 : CLK_GNUCXX);
    2002        14265 :   flag_no_gnu_keywords = iso;
    2003        14265 :   flag_no_nonansi_builtin = iso;
    2004        14265 :   flag_iso = iso;
    2005        14265 :   flag_isoc94 = 0;
    2006        14265 :   flag_isoc99 = 0;
    2007        14265 :   cxx_dialect = cxx98;
    2008        14265 :   lang_hooks.name = "GNU C++98";
    2009        14265 : }
    2010              : 
    2011              : /* Set the C++ 2011 standard (without GNU extensions if ISO).  */
    2012              : static void
    2013         5709 : set_std_cxx11 (int iso)
    2014              : {
    2015         7159 :   cpp_set_lang (parse_in, iso ? CLK_CXX11 : CLK_GNUCXX11);
    2016         5709 :   flag_no_gnu_keywords = iso;
    2017         5709 :   flag_no_nonansi_builtin = iso;
    2018         5709 :   flag_iso = iso;
    2019              :   /* C++11 includes the C99 standard library.  */
    2020         5709 :   flag_isoc94 = 1;
    2021         5709 :   flag_isoc99 = 1;
    2022         5709 :   cxx_dialect = cxx11;
    2023         5709 :   lang_hooks.name = "GNU C++11";
    2024         5709 : }
    2025              : 
    2026              : /* Set the C++ 2014 standard (without GNU extensions if ISO).  */
    2027              : static void
    2028         1299 : set_std_cxx14 (int iso)
    2029              : {
    2030         1579 :   cpp_set_lang (parse_in, iso ? CLK_CXX14 : CLK_GNUCXX14);
    2031         1299 :   flag_no_gnu_keywords = iso;
    2032         1299 :   flag_no_nonansi_builtin = iso;
    2033         1299 :   flag_iso = iso;
    2034              :   /* C++14 includes the C99 standard library.  */
    2035         1299 :   flag_isoc94 = 1;
    2036         1299 :   flag_isoc99 = 1;
    2037         1299 :   cxx_dialect = cxx14;
    2038         1299 :   lang_hooks.name = "GNU C++14";
    2039         1299 : }
    2040              : 
    2041              : /* Set the C++ 2017 standard (without GNU extensions if ISO).  */
    2042              : static void
    2043         4208 : set_std_cxx17 (int iso)
    2044              : {
    2045         5142 :   cpp_set_lang (parse_in, iso ? CLK_CXX17 : CLK_GNUCXX17);
    2046         4208 :   flag_no_gnu_keywords = iso;
    2047         4208 :   flag_no_nonansi_builtin = iso;
    2048         4208 :   flag_iso = iso;
    2049              :   /* C++17 includes the C11 standard library.  */
    2050         4208 :   flag_isoc94 = 1;
    2051         4208 :   flag_isoc99 = 1;
    2052         4208 :   flag_isoc11 = 1;
    2053         4208 :   cxx_dialect = cxx17;
    2054         4208 :   lang_hooks.name = "GNU C++17";
    2055         4208 : }
    2056              : 
    2057              : /* Set the C++ 2020 standard (without GNU extensions if ISO).  */
    2058              : static void
    2059       131947 : set_std_cxx20 (int iso)
    2060              : {
    2061       247216 :   cpp_set_lang (parse_in, iso ? CLK_CXX20 : CLK_GNUCXX20);
    2062       131947 :   flag_no_gnu_keywords = iso;
    2063       131947 :   flag_no_nonansi_builtin = iso;
    2064       131947 :   flag_iso = iso;
    2065              :   /* C++20 includes the C11 standard library.  */
    2066       131947 :   flag_isoc94 = 1;
    2067       131947 :   flag_isoc99 = 1;
    2068       131947 :   flag_isoc11 = 1;
    2069       131947 :   cxx_dialect = cxx20;
    2070       131947 :   lang_hooks.name = "GNU C++20";
    2071       131947 : }
    2072              : 
    2073              : /* Set the C++ 2023 standard (without GNU extensions if ISO).  */
    2074              : static void
    2075         2144 : set_std_cxx23 (int iso)
    2076              : {
    2077         2713 :   cpp_set_lang (parse_in, iso ? CLK_CXX23 : CLK_GNUCXX23);
    2078         2144 :   flag_no_gnu_keywords = iso;
    2079         2144 :   flag_no_nonansi_builtin = iso;
    2080         2144 :   flag_iso = iso;
    2081              :   /* C++23 includes the C11 standard library.  */
    2082         2144 :   flag_isoc94 = 1;
    2083         2144 :   flag_isoc99 = 1;
    2084         2144 :   flag_isoc11 = 1;
    2085         2144 :   cxx_dialect = cxx23;
    2086         2144 :   lang_hooks.name = "GNU C++23";
    2087         2144 : }
    2088              : 
    2089              : /* Set the C++ 2026 standard (without GNU extensions if ISO).  */
    2090              : static void
    2091         1632 : set_std_cxx26 (int iso)
    2092              : {
    2093         2308 :   cpp_set_lang (parse_in, iso ? CLK_CXX26 : CLK_GNUCXX26);
    2094         1632 :   flag_no_gnu_keywords = iso;
    2095         1632 :   flag_no_nonansi_builtin = iso;
    2096         1632 :   flag_iso = iso;
    2097              :   /* C++26 includes the C11 standard library.  */
    2098         1632 :   flag_isoc94 = 1;
    2099         1632 :   flag_isoc99 = 1;
    2100         1632 :   flag_isoc11 = 1;
    2101         1632 :   cxx_dialect = cxx26;
    2102         1632 :   lang_hooks.name = "GNU C++26";
    2103         1632 : }
    2104              : 
    2105              : /* Set the C++ 2029 standard (without GNU extensions if ISO).  */
    2106              : static void
    2107        23249 : set_std_cxx29 (int iso)
    2108              : {
    2109        29586 :   cpp_set_lang (parse_in, iso ? CLK_CXX29 : CLK_GNUCXX29);
    2110        23249 :   flag_no_gnu_keywords = iso;
    2111        23249 :   flag_no_nonansi_builtin = iso;
    2112        23249 :   flag_iso = iso;
    2113              :   /* C++29 includes the C11 standard library.  */
    2114        23249 :   flag_isoc94 = 1;
    2115        23249 :   flag_isoc99 = 1;
    2116        23249 :   flag_isoc11 = 1;
    2117        23249 :   cxx_dialect = cxx29;
    2118        23249 :   lang_hooks.name = "GNU C++29";
    2119        23249 : }
    2120              : 
    2121              : /* Args to -d specify what to dump.  Silently ignore
    2122              :    unrecognized options; they may be aimed at toplev.cc.  */
    2123              : static void
    2124         1634 : handle_OPT_d (const char *arg)
    2125              : {
    2126         1634 :   char c;
    2127              : 
    2128         3268 :   while ((c = *arg++) != '\0')
    2129         1634 :     switch (c)
    2130              :       {
    2131          793 :       case 'M':                 /* Dump macros only.  */
    2132          793 :       case 'N':                 /* Dump names.  */
    2133          793 :       case 'D':                 /* Dump definitions.  */
    2134          793 :       case 'U':                 /* Dump used macros.  */
    2135          793 :         flag_dump_macros = c;
    2136          793 :         break;
    2137              : 
    2138            2 :       case 'I':
    2139            2 :         flag_dump_includes = 1;
    2140            2 :         break;
    2141              :       }
    2142         1634 : }
        

Generated by: LCOV version 2.4-beta

LCOV profile is generated on x86_64 machine using following configure options: configure --disable-bootstrap --enable-coverage=opt --enable-languages=c,c++,fortran,go,jit,lto,rust,m2 --enable-host-shared. GCC test suite is run with the built compiler.