LCOV - code coverage report
Current view: top level - gcc/c-family - c-opts.cc (source / functions) Coverage Total Hit
Test: gcc.info Lines: 89.3 % 980 875
Test Date: 2024-04-20 14:03:02 Functions: 91.4 % 35 32
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: - 0 0

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

Generated by: LCOV version 2.1-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.