LCOV - code coverage report
Current view: top level - gcc/c-family - c-lex.cc (source / functions) Coverage Total Hit
Test: gcc.info Lines: 79.2 % 885 701
Test Date: 2024-04-20 14:03:02 Functions: 92.3 % 26 24
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : /* Mainly the interface between cpplib and the C front ends.
       2                 :             :    Copyright (C) 1987-2024 Free Software Foundation, Inc.
       3                 :             : 
       4                 :             : This file is part of GCC.
       5                 :             : 
       6                 :             : GCC is free software; you can redistribute it and/or modify it under
       7                 :             : the terms of the GNU General Public License as published by the Free
       8                 :             : Software Foundation; either version 3, or (at your option) any later
       9                 :             : version.
      10                 :             : 
      11                 :             : GCC is distributed in the hope that it will be useful, but WITHOUT ANY
      12                 :             : WARRANTY; without even the implied warranty of MERCHANTABILITY or
      13                 :             : FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
      14                 :             : for more details.
      15                 :             : 
      16                 :             : You should have received a copy of the GNU General Public License
      17                 :             : along with GCC; see the file COPYING3.  If not see
      18                 :             : <http://www.gnu.org/licenses/>.  */
      19                 :             : 
      20                 :             : #include "config.h"
      21                 :             : #include "system.h"
      22                 :             : #include "coretypes.h"
      23                 :             : #include "target.h"
      24                 :             : #include "c-common.h"
      25                 :             : #include "timevar.h"
      26                 :             : #include "stringpool.h"
      27                 :             : #include "stor-layout.h"
      28                 :             : #include "c-pragma.h"
      29                 :             : #include "debug.h"
      30                 :             : #include "flags.h"
      31                 :             : #include "file-prefix-map.h" /* remap_macro_filename()  */
      32                 :             : #include "langhooks.h"
      33                 :             : #include "attribs.h"
      34                 :             : #include "rich-location.h"
      35                 :             : 
      36                 :             : /* We may keep statistics about how long which files took to compile.  */
      37                 :             : static int header_time, body_time;
      38                 :             : static splay_tree file_info_tree;
      39                 :             : 
      40                 :             : int pending_lang_change; /* If we need to switch languages - C++ only */
      41                 :             : int c_header_level;      /* depth in C headers - C++ only */
      42                 :             : 
      43                 :             : static tree interpret_integer (const cpp_token *, unsigned int,
      44                 :             :                                enum overflow_type *);
      45                 :             : static tree interpret_float (const cpp_token *, unsigned int, const char *,
      46                 :             :                              enum overflow_type *);
      47                 :             : static tree interpret_fixed (const cpp_token *, unsigned int);
      48                 :             : static enum integer_type_kind narrowest_unsigned_type
      49                 :             :         (const widest_int &, unsigned int);
      50                 :             : static enum integer_type_kind narrowest_signed_type
      51                 :             :         (const widest_int &, unsigned int);
      52                 :             : static enum cpp_ttype lex_string (const cpp_token *, tree *, bool, bool);
      53                 :             : static tree lex_charconst (const cpp_token *);
      54                 :             : static void update_header_times (const char *);
      55                 :             : static int dump_one_header (splay_tree_node, void *);
      56                 :             : static void cb_line_change (cpp_reader *, const cpp_token *, int);
      57                 :             : static void cb_ident (cpp_reader *, unsigned int, const cpp_string *);
      58                 :             : static void cb_def_pragma (cpp_reader *, unsigned int);
      59                 :             : static void cb_define (cpp_reader *, unsigned int, cpp_hashnode *);
      60                 :             : static void cb_undef (cpp_reader *, unsigned int, cpp_hashnode *);
      61                 :             : 
      62                 :             : void
      63                 :      199773 : init_c_lex (void)
      64                 :             : {
      65                 :      199773 :   struct c_fileinfo *toplevel;
      66                 :             : 
      67                 :             :   /* The get_fileinfo data structure must be initialized before
      68                 :             :      cpp_read_main_file is called.  */
      69                 :      199773 :   toplevel = get_fileinfo ("<top level>");
      70                 :      199773 :   if (flag_detailed_statistics)
      71                 :             :     {
      72                 :           0 :       header_time = 0;
      73                 :           0 :       body_time = get_run_time ();
      74                 :           0 :       toplevel->time = body_time;
      75                 :             :     }
      76                 :             : 
      77                 :      199773 :   struct cpp_callbacks *cb = cpp_get_callbacks (parse_in);
      78                 :             : 
      79                 :      199773 :   cb->line_change = cb_line_change;
      80                 :      199773 :   cb->ident = cb_ident;
      81                 :      199773 :   cb->def_pragma = cb_def_pragma;
      82                 :      199773 :   cb->valid_pch = c_common_valid_pch;
      83                 :      199773 :   cb->read_pch = c_common_read_pch;
      84                 :      199773 :   cb->has_attribute = c_common_has_attribute;
      85                 :      199773 :   cb->has_builtin = c_common_has_builtin;
      86                 :      199773 :   cb->has_feature = c_common_has_feature;
      87                 :      199773 :   cb->get_source_date_epoch = cb_get_source_date_epoch;
      88                 :      199773 :   cb->get_suggestion = cb_get_suggestion;
      89                 :      199773 :   cb->remap_filename = remap_macro_filename;
      90                 :             : 
      91                 :             :   /* Set the debug callbacks if we can use them.  */
      92                 :      199773 :   if ((debug_info_level == DINFO_LEVEL_VERBOSE
      93                 :         509 :        && dwarf_debuginfo_p ())
      94                 :      199773 :       || flag_dump_go_spec != NULL)
      95                 :             :     {
      96                 :         513 :       cb->define = cb_define;
      97                 :         513 :       cb->undef = cb_undef;
      98                 :             :     }
      99                 :      199773 : }
     100                 :             : 
     101                 :             : struct c_fileinfo *
     102                 :   261620413 : get_fileinfo (const char *name)
     103                 :             : {
     104                 :   261620413 :   splay_tree_node n;
     105                 :   261620413 :   struct c_fileinfo *fi;
     106                 :             : 
     107                 :   261620413 :   if (!file_info_tree)
     108                 :      200977 :     file_info_tree = splay_tree_new (splay_tree_compare_strings,
     109                 :             :                                      0,
     110                 :             :                                      splay_tree_delete_pointers);
     111                 :             : 
     112                 :   261620413 :   n = splay_tree_lookup (file_info_tree, (splay_tree_key) name);
     113                 :   261620413 :   if (n)
     114                 :   258155858 :     return (struct c_fileinfo *) n->value;
     115                 :             : 
     116                 :     3464555 :   fi = XNEW (struct c_fileinfo);
     117                 :     3464555 :   fi->time = 0;
     118                 :     3464555 :   fi->interface_only = 0;
     119                 :     3464555 :   fi->interface_unknown = 1;
     120                 :     3464555 :   splay_tree_insert (file_info_tree, (splay_tree_key) name,
     121                 :             :                      (splay_tree_value) fi);
     122                 :     3464555 :   return fi;
     123                 :             : }
     124                 :             : 
     125                 :             : static void
     126                 :    21764262 : update_header_times (const char *name)
     127                 :             : {
     128                 :             :   /* Changing files again.  This means currently collected time
     129                 :             :      is charged against header time, and body time starts back at 0.  */
     130                 :    21764262 :   if (flag_detailed_statistics)
     131                 :             :     {
     132                 :           0 :       int this_time = get_run_time ();
     133                 :           0 :       struct c_fileinfo *file = get_fileinfo (name);
     134                 :           0 :       header_time += this_time - body_time;
     135                 :           0 :       file->time += this_time - body_time;
     136                 :           0 :       body_time = this_time;
     137                 :             :     }
     138                 :    21764262 : }
     139                 :             : 
     140                 :             : static int
     141                 :           0 : dump_one_header (splay_tree_node n, void * ARG_UNUSED (dummy))
     142                 :             : {
     143                 :           0 :   print_time ((const char *) n->key,
     144                 :           0 :               ((struct c_fileinfo *) n->value)->time);
     145                 :           0 :   return 0;
     146                 :             : }
     147                 :             : 
     148                 :             : void
     149                 :           0 : dump_time_statistics (void)
     150                 :             : {
     151                 :           0 :   struct c_fileinfo *file = get_fileinfo (LOCATION_FILE (input_location));
     152                 :           0 :   int this_time = get_run_time ();
     153                 :           0 :   file->time += this_time - body_time;
     154                 :             : 
     155                 :           0 :   fprintf (stderr, "\n******\n");
     156                 :           0 :   print_time ("header files (total)", header_time);
     157                 :           0 :   print_time ("main file (total)", this_time - body_time);
     158                 :           0 :   fprintf (stderr, "ratio = %g : 1\n",
     159                 :           0 :            (double) header_time / (double) (this_time - body_time));
     160                 :           0 :   fprintf (stderr, "\n******\n");
     161                 :             : 
     162                 :           0 :   splay_tree_foreach (file_info_tree, dump_one_header, 0);
     163                 :           0 : }
     164                 :             : 
     165                 :             : static void
     166                 :          22 : cb_ident (cpp_reader * ARG_UNUSED (pfile),
     167                 :             :           unsigned int ARG_UNUSED (line),
     168                 :             :           const cpp_string * ARG_UNUSED (str))
     169                 :             : {
     170                 :          22 :   if (!flag_no_ident)
     171                 :             :     {
     172                 :             :       /* Convert escapes in the string.  */
     173                 :          22 :       cpp_string cstr = { 0, 0 };
     174                 :          22 :       if (cpp_interpret_string (pfile, str, 1, &cstr, CPP_STRING))
     175                 :             :         {
     176                 :          22 :           targetm.asm_out.output_ident ((const char *) cstr.text);
     177                 :          22 :           free (CONST_CAST (unsigned char *, cstr.text));
     178                 :             :         }
     179                 :             :     }
     180                 :          22 : }
     181                 :             : 
     182                 :             : /* Called at the start of every non-empty line.  TOKEN is the first
     183                 :             :    lexed token on the line.  Used for diagnostic line numbers.  */
     184                 :             : static void
     185                 :  1352988111 : cb_line_change (cpp_reader * ARG_UNUSED (pfile), const cpp_token *token,
     186                 :             :                 int parsing_args)
     187                 :             : {
     188                 :  1352988111 :   if (token->type != CPP_EOF && !parsing_args)
     189                 :  1346334637 :     input_location = token->src_loc;
     190                 :  1352988111 : }
     191                 :             : 
     192                 :             : void
     193                 :    21963637 : fe_file_change (const line_map_ordinary *new_map)
     194                 :             : {
     195                 :    21963637 :   if (new_map == NULL)
     196                 :             :     return;
     197                 :             : 
     198                 :    21764262 :   if (new_map->reason == LC_ENTER)
     199                 :             :     {
     200                 :             :       /* Don't stack the main buffer on the input stack;
     201                 :             :          we already did in compile_file.  */
     202                 :     9279704 :       if (!MAIN_FILE_P (new_map))
     203                 :             :         {
     204                 :     9079931 :           location_t included_at = linemap_included_from (new_map);
     205                 :     9079931 :           int line = 0;
     206                 :     9079931 :           if (included_at > BUILTINS_LOCATION)
     207                 :     9079931 :             line = SOURCE_LINE (new_map - 1, included_at);
     208                 :             : 
     209                 :     9079931 :           input_location = new_map->start_location;
     210                 :     9079931 :           (*debug_hooks->start_source_file) (line, LINEMAP_FILE (new_map));
     211                 :             : #ifdef SYSTEM_IMPLICIT_EXTERN_C
     212                 :             :           if (c_header_level)
     213                 :             :             ++c_header_level;
     214                 :             :           else if (LINEMAP_SYSP (new_map) == 2)
     215                 :             :             {
     216                 :             :               c_header_level = 1;
     217                 :             :               ++pending_lang_change;
     218                 :             :             }
     219                 :             : #endif
     220                 :             :         }
     221                 :             :     }
     222                 :    12484558 :   else if (new_map->reason == LC_LEAVE)
     223                 :             :     {
     224                 :             : #ifdef SYSTEM_IMPLICIT_EXTERN_C
     225                 :             :       if (c_header_level && --c_header_level == 0)
     226                 :             :         {
     227                 :             :           if (LINEMAP_SYSP (new_map) == 2)
     228                 :             :             warning (0, "badly nested C headers from preprocessor");
     229                 :             :           --pending_lang_change;
     230                 :             :         }
     231                 :             : #endif
     232                 :     9079927 :       input_location = new_map->start_location;
     233                 :             : 
     234                 :     9079927 :       (*debug_hooks->end_source_file) (LINEMAP_LINE (new_map));
     235                 :             :     }
     236                 :             : 
     237                 :    21764262 :   update_header_times (LINEMAP_FILE (new_map));
     238                 :    21764262 :   input_location = new_map->start_location;
     239                 :             : }
     240                 :             : 
     241                 :             : static void
     242                 :        1478 : cb_def_pragma (cpp_reader *pfile, location_t loc)
     243                 :             : {
     244                 :             :   /* Issue a warning message if we have been asked to do so.  Ignore
     245                 :             :      unknown pragmas in system headers unless an explicit
     246                 :             :      -Wunknown-pragmas has been given.  */
     247                 :        1478 :   if (warn_unknown_pragmas > in_system_header_at (input_location))
     248                 :             :     {
     249                 :          68 :       const unsigned char *space, *name;
     250                 :          68 :       const cpp_token *s;
     251                 :          68 :       location_t fe_loc = loc;
     252                 :             : 
     253                 :          68 :       space = name = (const unsigned char *) "";
     254                 :             : 
     255                 :             :       /* N.B.  It's fine to call cpp_get_token () directly here (rather than our
     256                 :             :          local wrapper get_token ()), because this callback is not used with
     257                 :             :          flag_preprocess_only==true.  */
     258                 :          68 :       s = cpp_get_token (pfile);
     259                 :          68 :       if (s->type != CPP_EOF)
     260                 :             :         {
     261                 :          67 :           space = cpp_token_as_text (pfile, s);
     262                 :          67 :           s = cpp_get_token (pfile);
     263                 :          67 :           if (s->type == CPP_NAME)
     264                 :          46 :             name = cpp_token_as_text (pfile, s);
     265                 :             :         }
     266                 :             : 
     267                 :          68 :       warning_at (fe_loc, OPT_Wunknown_pragmas, "ignoring %<#pragma %s %s%>",
     268                 :             :                   space, name);
     269                 :             :     }
     270                 :        1478 : }
     271                 :             : 
     272                 :             : /* #define callback for DWARF and DWARF2 debug info.  */
     273                 :             : static void
     274                 :      239914 : cb_define (cpp_reader *pfile, location_t loc, cpp_hashnode *node)
     275                 :             : {
     276                 :      239914 :   const struct line_map *map = linemap_lookup (line_table, loc);
     277                 :      239914 :   (*debug_hooks->define) (SOURCE_LINE (linemap_check_ordinary (map), loc),
     278                 :      239914 :                           (const char *) cpp_macro_definition (pfile, node));
     279                 :      239914 : }
     280                 :             : 
     281                 :             : /* #undef callback for DWARF and DWARF2 debug info.  */
     282                 :             : static void
     283                 :        1298 : cb_undef (cpp_reader *pfile, location_t loc, cpp_hashnode *node)
     284                 :             : {
     285                 :        1298 :   if (lang_hooks.preprocess_undef)
     286                 :           0 :     lang_hooks.preprocess_undef (pfile, loc, node);
     287                 :             : 
     288                 :        1298 :   const struct line_map *map = linemap_lookup (line_table, loc);
     289                 :        1298 :   (*debug_hooks->undef) (SOURCE_LINE (linemap_check_ordinary (map), loc),
     290                 :        1298 :                          (const char *) NODE_NAME (node));
     291                 :        1298 : }
     292                 :             : 
     293                 :             : /* Wrapper around cpp_get_token_with_location to stream the token to the
     294                 :             :    preprocessor so it can output it.  This is necessary with
     295                 :             :    flag_preprocess_only if we are obtaining tokens here instead of from the loop
     296                 :             :    in c-ppoutput.cc, such as while processing a #pragma.  */
     297                 :             : 
     298                 :             : static const cpp_token *
     299                 : 10555403208 : get_token (cpp_reader *pfile, location_t *loc = nullptr)
     300                 :             : {
     301                 : 10555403208 :   if (flag_preprocess_only)
     302                 :             :     {
     303                 :       29461 :       location_t x;
     304                 :       29461 :       if (!loc)
     305                 :           0 :         loc = &x;
     306                 :       29461 :       const auto tok = cpp_get_token_with_location (pfile, loc);
     307                 :       29461 :       c_pp_stream_token (pfile, tok, *loc);
     308                 :       29461 :       return tok;
     309                 :             :     }
     310                 :             :   else
     311                 : 10555373747 :     return cpp_get_token_with_location (pfile, loc);
     312                 :             : }
     313                 :             : 
     314                 :             : /* Wrapper around cpp_get_token to skip CPP_PADDING tokens
     315                 :             :    and not consume CPP_EOF.  This does not perform the optional
     316                 :             :    streaming in preprocess_only mode, so is suitable to be used
     317                 :             :    when processing builtin expansions such as c_common_has_attribute.  */
     318                 :             : 
     319                 :             : static const cpp_token *
     320                 :    16340782 : get_token_no_padding (cpp_reader *pfile)
     321                 :             : {
     322                 :    16341154 :   for (;;)
     323                 :             :     {
     324                 :    16341154 :       const cpp_token *ret = cpp_peek_token (pfile, 0);
     325                 :    16341154 :       if (ret->type == CPP_EOF)
     326                 :          24 :         return ret;
     327                 :    16341130 :       ret = cpp_get_token (pfile);
     328                 :    16341130 :       if (ret->type != CPP_PADDING)
     329                 :    16340758 :         return ret;
     330                 :             :     }
     331                 :             : }
     332                 :             : 
     333                 :             : /* Callback for has_attribute.  */
     334                 :             : int
     335                 :      747665 : c_common_has_attribute (cpp_reader *pfile, bool std_syntax)
     336                 :             : {
     337                 :      747665 :   int result = 0;
     338                 :      747665 :   tree attr_name = NULL_TREE;
     339                 :      747665 :   const cpp_token *token;
     340                 :             : 
     341                 :      747665 :   token = get_token_no_padding (pfile);
     342                 :      747665 :   if (token->type != CPP_OPEN_PAREN)
     343                 :             :     {
     344                 :           2 :       cpp_error (pfile, CPP_DL_ERROR,
     345                 :             :                  "missing '(' after \"__has_attribute\"");
     346                 :           2 :       return 0;
     347                 :             :     }
     348                 :      747663 :   token = get_token_no_padding (pfile);
     349                 :      747663 :   if (token->type == CPP_NAME)
     350                 :             :     {
     351                 :      747659 :       attr_name = get_identifier ((const char *)
     352                 :             :                                   cpp_token_as_text (pfile, token));
     353                 :      747659 :       attr_name = canonicalize_attr_name (attr_name);
     354                 :      747659 :       bool have_scope = false;
     355                 :      747659 :       int idx = 0;
     356                 :      747734 :       const cpp_token *nxt_token;
     357                 :      747734 :       do
     358                 :      747734 :         nxt_token = cpp_peek_token (pfile, idx++);
     359                 :      747734 :       while (nxt_token->type == CPP_PADDING);
     360                 :      747659 :       if (!c_dialect_cxx ()
     361                 :      374221 :           && nxt_token->type == CPP_COLON
     362                 :           2 :           && (nxt_token->flags & COLON_SCOPE) != 0)
     363                 :             :         {
     364                 :             :           const cpp_token *prev_token = nxt_token;
     365                 :           2 :           do
     366                 :           2 :             nxt_token = cpp_peek_token (pfile, idx++);
     367                 :           2 :           while (nxt_token->type == CPP_PADDING);
     368                 :           2 :           if (nxt_token->type == CPP_COLON)
     369                 :             :             {
     370                 :             :               /* __has_attribute (vendor::attr) in -std=c17 etc. modes.
     371                 :             :                  :: isn't CPP_SCOPE but 2 CPP_COLON tokens, where the
     372                 :             :                  first one should have COLON_SCOPE flag to distinguish
     373                 :             :                  it from : :.  */
     374                 :           2 :               have_scope = true;
     375                 :           2 :               get_token_no_padding (pfile); // Eat first colon.
     376                 :             :             }
     377                 :             :           else
     378                 :             :             nxt_token = prev_token;
     379                 :             :         }
     380                 :      747659 :       if (nxt_token->type == CPP_SCOPE || have_scope)
     381                 :             :         {
     382                 :         880 :           have_scope = true;
     383                 :         880 :           get_token_no_padding (pfile); // Eat scope.
     384                 :         880 :           nxt_token = get_token_no_padding (pfile);
     385                 :         880 :           if (nxt_token->type == CPP_NAME)
     386                 :             :             {
     387                 :         879 :               tree attr_ns = attr_name;
     388                 :         879 :               tree attr_id
     389                 :         879 :                 = get_identifier ((const char *)
     390                 :             :                                   cpp_token_as_text (pfile, nxt_token));
     391                 :         879 :               attr_id = canonicalize_attr_name (attr_id);
     392                 :             :               /* OpenMP attributes need special handling.  */
     393                 :         759 :               if ((flag_openmp || flag_openmp_simd)
     394                 :         240 :                   && is_attribute_p ("omp", attr_ns)
     395                 :        1119 :                   && (is_attribute_p ("directive", attr_id)
     396                 :         180 :                       || is_attribute_p ("sequence", attr_id)
     397                 :         120 :                       || is_attribute_p ("decl", attr_id)))
     398                 :             :                 result = 1;
     399                 :         699 :               if (result)
     400                 :             :                 attr_name = NULL_TREE;
     401                 :             :               else
     402                 :         699 :                 attr_name = build_tree_list (attr_ns, attr_id);
     403                 :             :             }
     404                 :             :           else
     405                 :             :             {
     406                 :           1 :               cpp_error (pfile, CPP_DL_ERROR,
     407                 :             :                          "attribute identifier required after scope");
     408                 :           1 :               attr_name = NULL_TREE;
     409                 :             :             }
     410                 :             :         }
     411                 :             :       else
     412                 :             :         {
     413                 :             :           /* Some standard attributes need special handling.  */
     414                 :      746779 :           if (c_dialect_cxx ())
     415                 :             :             {
     416                 :      372637 :               if (is_attribute_p ("noreturn", attr_name))
     417                 :             :                 result = 200809;
     418                 :      372576 :               else if (is_attribute_p ("deprecated", attr_name))
     419                 :             :                 result = 201309;
     420                 :      351334 :               else if (is_attribute_p ("maybe_unused", attr_name)
     421                 :      351334 :                        || is_attribute_p ("fallthrough", attr_name))
     422                 :             :                 result = 201603;
     423                 :      350877 :               else if (is_attribute_p ("no_unique_address", attr_name)
     424                 :      339098 :                        || is_attribute_p ("likely", attr_name)
     425                 :      689969 :                        || is_attribute_p ("unlikely", attr_name))
     426                 :             :                 result = 201803;
     427                 :      339086 :               else if (is_attribute_p ("nodiscard", attr_name))
     428                 :             :                 result = 201907;
     429                 :      339077 :               else if (is_attribute_p ("assume", attr_name))
     430                 :             :                 result = 202207;
     431                 :      328777 :               else if (is_attribute_p ("init_priority", attr_name))
     432                 :             :                 {
     433                 :             :                   /* The (non-standard) init_priority attribute is always
     434                 :             :                      included in the attribute table, but we don't want to
     435                 :             :                      advertise the attribute unless the target actually
     436                 :             :                      supports init priorities.  */
     437                 :             :                   result = SUPPORTS_INIT_PRIORITY ? 1 : 0;
     438                 :             :                   attr_name = NULL_TREE;
     439                 :             :                 }
     440                 :             :             }
     441                 :             :           else
     442                 :             :             {
     443                 :      374142 :               if (is_attribute_p ("deprecated", attr_name)
     444                 :      350756 :                   || is_attribute_p ("fallthrough", attr_name)
     445                 :      350754 :                   || is_attribute_p ("maybe_unused", attr_name)
     446                 :      350752 :                   || is_attribute_p ("nodiscard", attr_name)
     447                 :      350750 :                   || is_attribute_p ("noreturn", attr_name)
     448                 :      724878 :                   || is_attribute_p ("_Noreturn", attr_name))
     449                 :             :                 result = 202311;
     450                 :             :             }
     451                 :             :           if (result)
     452                 :             :             attr_name = NULL_TREE;
     453                 :             :         }
     454                 :      747659 :       if (attr_name && (have_scope || !std_syntax))
     455                 :             :         {
     456                 :      669985 :           init_attributes ();
     457                 :      669985 :           const struct attribute_spec *attr = lookup_attribute_spec (attr_name);
     458                 :      669985 :           if (attr)
     459                 :      747659 :             result = 1;
     460                 :             :         }
     461                 :             :     }
     462                 :             :   else
     463                 :             :     {
     464                 :           4 :       cpp_error (pfile, CPP_DL_ERROR,
     465                 :             :                  "macro \"__has_attribute\" requires an identifier");
     466                 :           4 :       return 0;
     467                 :             :     }
     468                 :             : 
     469                 :      747659 :   if (get_token_no_padding (pfile)->type != CPP_CLOSE_PAREN)
     470                 :           3 :     cpp_error (pfile, CPP_DL_ERROR,
     471                 :             :                "missing ')' after \"__has_attribute\"");
     472                 :             : 
     473                 :             :   return result;
     474                 :             : }
     475                 :             : 
     476                 :             : /* Helper for __has_{builtin,feature,extension}.  */
     477                 :             : 
     478                 :             : static const char *
     479                 :     4698651 : c_common_lex_availability_macro (cpp_reader *pfile, const char *builtin)
     480                 :             : {
     481                 :     4698651 :   const cpp_token *token = get_token_no_padding (pfile);
     482                 :     4698651 :   if (token->type != CPP_OPEN_PAREN)
     483                 :             :     {
     484                 :           5 :       cpp_error (pfile, CPP_DL_ERROR,
     485                 :             :                  "missing '(' after \"__has_%s\"", builtin);
     486                 :           5 :       return 0;
     487                 :             :     }
     488                 :             : 
     489                 :     4698646 :   const char *name = "";
     490                 :     4698646 :   token = get_token_no_padding (pfile);
     491                 :     4698646 :   if (token->type == CPP_NAME)
     492                 :             :     {
     493                 :     4698606 :       name = (const char *) cpp_token_as_text (pfile, token);
     494                 :     4698606 :       token = get_token_no_padding (pfile);
     495                 :     4698606 :       if (token->type != CPP_CLOSE_PAREN)
     496                 :             :         {
     497                 :          20 :           cpp_error (pfile, CPP_DL_ERROR,
     498                 :             :                      "expected ')' after \"%s\"", name);
     499                 :          20 :           name = "";
     500                 :             :         }
     501                 :             :     }
     502                 :             :   else
     503                 :             :     {
     504                 :          40 :       cpp_error (pfile, CPP_DL_ERROR,
     505                 :             :                  "macro \"__has_%s\" requires an identifier", builtin);
     506                 :          40 :       if (token->type == CPP_CLOSE_PAREN)
     507                 :             :         return 0;
     508                 :             :     }
     509                 :             : 
     510                 :             :   /* Consume tokens up to the closing parenthesis, including any nested
     511                 :             :      pairs of parentheses, to avoid confusing redundant errors.  */
     512                 :     4698771 :   for (unsigned nparen = 1; ; token = get_token_no_padding (pfile))
     513                 :             :     {
     514                 :     4698771 :       if (token->type == CPP_OPEN_PAREN)
     515                 :          30 :         ++nparen;
     516                 :     4698741 :       else if (token->type == CPP_CLOSE_PAREN)
     517                 :     4698646 :         --nparen;
     518                 :          95 :       else if (token->type == CPP_EOF)
     519                 :             :         break;
     520                 :     4698756 :       if (!nparen)
     521                 :             :         break;
     522                 :             :     }
     523                 :             : 
     524                 :             :   return name;
     525                 :             : }
     526                 :             : 
     527                 :             : /* Callback for has_builtin.  */
     528                 :             : 
     529                 :             : int
     530                 :     4577192 : c_common_has_builtin (cpp_reader *pfile)
     531                 :             : {
     532                 :     4577192 :   const char *name = c_common_lex_availability_macro (pfile, "builtin");
     533                 :     4577192 :   if (!name)
     534                 :             :     return 0;
     535                 :             : 
     536                 :     4577182 :   return names_builtin_p (name);
     537                 :             : }
     538                 :             : 
     539                 :             : /* Callback for has_feature.  STRICT_P is true for has_feature and false
     540                 :             :    for has_extension.  */
     541                 :             : 
     542                 :             : int
     543                 :      121459 : c_common_has_feature (cpp_reader *pfile, bool strict_p)
     544                 :             : {
     545                 :      121459 :   const char *builtin = strict_p ? "feature" : "extension";
     546                 :      121459 :   const char *name = c_common_lex_availability_macro (pfile, builtin);
     547                 :      121459 :   if (!name)
     548                 :             :     return 0;
     549                 :             : 
     550                 :             :   /* If -pedantic-errors is given, __has_extension is equivalent to
     551                 :             :      __has_feature.  */
     552                 :      121459 :   strict_p |= flag_pedantic_errors;
     553                 :      121459 :   return has_feature_p (name, strict_p);
     554                 :             : }
     555                 :             : 
     556                 :             : 
     557                 :             : /* Read a token and return its type.  Fill *VALUE with its value, if
     558                 :             :    applicable.  Fill *CPP_FLAGS with the token's flags, if it is
     559                 :             :    non-NULL.  */
     560                 :             : 
     561                 :             : enum cpp_ttype
     562                 :  9549167470 : c_lex_with_flags (tree *value, location_t *loc, unsigned char *cpp_flags,
     563                 :             :                   int lex_flags)
     564                 :             : {
     565                 :  9549167470 :   const cpp_token *tok;
     566                 :  9549167470 :   enum cpp_ttype type;
     567                 :  9549167470 :   unsigned char add_flags = 0;
     568                 :  9549167470 :   enum overflow_type overflow = OT_NONE;
     569                 :             : 
     570                 :  9549167470 :   timevar_push (TV_CPP);
     571                 : 10555402980 :  retry:
     572                 : 10555402980 :   tok = get_token (parse_in, loc);
     573                 : 10555402797 :   type = tok->type;
     574                 :             : 
     575                 : 10555402977 :  retry_after_at:
     576                 : 10555402977 :   switch (type)
     577                 :             :     {
     578                 :  1006235169 :     case CPP_PADDING:
     579                 :  1006235169 :       goto retry;
     580                 :             : 
     581                 :  4413384522 :     case CPP_NAME:
     582                 :  4413384522 :       *value = HT_IDENT_TO_GCC_IDENT (HT_NODE (tok->val.node.node));
     583                 :  4413384522 :       break;
     584                 :             : 
     585                 :   135869290 :     case CPP_NUMBER:
     586                 :   135869290 :       {
     587                 :   135869290 :         const char *suffix = NULL;
     588                 :   135869290 :         unsigned int flags = cpp_classify_number (parse_in, tok, &suffix, *loc);
     589                 :             : 
     590                 :   135869290 :         switch (flags & CPP_N_CATEGORY)
     591                 :             :           {
     592                 :         165 :           case CPP_N_INVALID:
     593                 :             :             /* cpplib has issued an error.  */
     594                 :         165 :             *value = error_mark_node;
     595                 :         165 :             break;
     596                 :             : 
     597                 :   131403979 :           case CPP_N_INTEGER:
     598                 :             :             /* C++ uses '0' to mark virtual functions as pure.
     599                 :             :                Set PURE_ZERO to pass this information to the C++ parser.  */
     600                 :   131403979 :             if (tok->val.str.len == 1 && *tok->val.str.text == '0')
     601                 :             :               add_flags = PURE_ZERO | DECIMAL_INT;
     602                 :    99440189 :             else if ((flags & CPP_N_INTEGER) && (flags & CPP_N_DECIMAL))
     603                 :             :               /* -Wxor-used-as-pow is only active for LHS of ^ expressed
     604                 :             :                  as a decimal integer. */
     605                 :    87083408 :               add_flags = DECIMAL_INT;
     606                 :   131403979 :             *value = interpret_integer (tok, flags, &overflow);
     607                 :   131403979 :             break;
     608                 :             : 
     609                 :     4465146 :           case CPP_N_FLOATING:
     610                 :     4465146 :             *value = interpret_float (tok, flags, suffix, &overflow);
     611                 :     4465146 :             break;
     612                 :             : 
     613                 :           0 :           default:
     614                 :           0 :             gcc_unreachable ();
     615                 :             :           }
     616                 :             : 
     617                 :   135869290 :         if (flags & CPP_N_USERDEF)
     618                 :             :           {
     619                 :       86045 :             char *str;
     620                 :       86045 :             tree literal;
     621                 :       86045 :             tree suffix_id = get_identifier (suffix);
     622                 :       86045 :             int len = tok->val.str.len - strlen (suffix);
     623                 :             :             /* If this is going to be used as a C string to pass to a
     624                 :             :                raw literal operator, we need to add a trailing NUL.  */
     625                 :      172090 :             tree num_string = build_string (len + 1,
     626                 :       86045 :                                             (const char *) tok->val.str.text);
     627                 :       86045 :             TREE_TYPE (num_string) = char_array_type_node;
     628                 :       86045 :             num_string = fix_string_type (num_string);
     629                 :       86045 :             str = CONST_CAST (char *, TREE_STRING_POINTER (num_string));
     630                 :       86045 :             str[len] = '\0';
     631                 :       86045 :             literal = build_userdef_literal (suffix_id, *value, overflow,
     632                 :             :                                              num_string);
     633                 :       86045 :             *value = literal;
     634                 :             :           }
     635                 :             :       }
     636                 :   135869290 :       break;
     637                 :             : 
     638                 :           4 :     case CPP_ATSIGN:
     639                 :             :       /* An @ may give the next token special significance in Objective-C.  */
     640                 :           4 :       if (c_dialect_objc ())
     641                 :             :         {
     642                 :           0 :           location_t atloc = *loc;
     643                 :           0 :           location_t newloc;
     644                 :             : 
     645                 :           0 :         retry_at:
     646                 :           0 :           tok = get_token (parse_in, &newloc);
     647                 :           0 :           type = tok->type;
     648                 :           0 :           switch (type)
     649                 :             :             {
     650                 :           0 :             case CPP_PADDING:
     651                 :           0 :               goto retry_at;
     652                 :             : 
     653                 :           0 :             case CPP_STRING:
     654                 :           0 :             case CPP_WSTRING:
     655                 :           0 :             case CPP_STRING16:
     656                 :           0 :             case CPP_STRING32:
     657                 :           0 :             case CPP_UTF8STRING:
     658                 :           0 :               type = lex_string (tok, value, true, true);
     659                 :           0 :               break;
     660                 :             : 
     661                 :           0 :             case CPP_NAME:
     662                 :           0 :               *value = HT_IDENT_TO_GCC_IDENT (HT_NODE (tok->val.node.node));
     663                 :           0 :               if (OBJC_IS_AT_KEYWORD (C_RID_CODE (*value))
     664                 :             :                   || OBJC_IS_CXX_KEYWORD (C_RID_CODE (*value)))
     665                 :             :                 {
     666                 :           0 :                   type = CPP_AT_NAME;
     667                 :             :                   /* Note the complication: if we found an OBJC_CXX
     668                 :             :                      keyword, for example, 'class', we will be
     669                 :             :                      returning a token of type CPP_AT_NAME and rid
     670                 :             :                      code RID_CLASS (not RID_AT_CLASS).  The language
     671                 :             :                      parser needs to convert that to RID_AT_CLASS.
     672                 :             :                      However, we've now spliced the '@' together with the
     673                 :             :                      keyword that follows; Adjust the location so that we
     674                 :             :                      get a source range covering the composite.
     675                 :             :                   */
     676                 :           0 :                  *loc = make_location (atloc, atloc, newloc);
     677                 :           0 :                   break;
     678                 :             :                 }
     679                 :             :               /* FALLTHROUGH */
     680                 :             : 
     681                 :           0 :             default:
     682                 :             :               /* ... or not.  */
     683                 :           0 :               error_at (atloc, "stray %<@%> in program");
     684                 :           0 :               *loc = newloc;
     685                 :           0 :               goto retry_after_at;
     686                 :             :             }
     687                 :           0 :           break;
     688                 :             :         }
     689                 :             : 
     690                 :             :       /* FALLTHROUGH */
     691                 :          28 :     case CPP_HASH:
     692                 :          28 :     case CPP_PASTE:
     693                 :          28 :       {
     694                 :          28 :         unsigned char name[8];
     695                 :             : 
     696                 :          28 :         *cpp_spell_token (parse_in, tok, name, true) = 0;
     697                 :             : 
     698                 :          28 :         error_at (*loc, "stray %qs in program", name);
     699                 :             :       }
     700                 :             : 
     701                 :          28 :       goto retry;
     702                 :             : 
     703                 :          83 :     case CPP_OTHER:
     704                 :          83 :       {
     705                 :          83 :         cppchar_t c = tok->val.str.text[0];
     706                 :             : 
     707                 :          83 :         if (c == '"' || c == '\'')
     708                 :          24 :           error_at (*loc, "missing terminating %c character", (int) c);
     709                 :          59 :         else if (ISGRAPH (c))
     710                 :          49 :           error_at (*loc, "stray %qc in program", (int) c);
     711                 :             :         else
     712                 :             :           {
     713                 :          10 :             rich_location rich_loc (line_table, *loc);
     714                 :          10 :             rich_loc.set_escape_on_output (true);
     715                 :          10 :             error_at (&rich_loc, "stray %<\\%o%> in program", (int) c);
     716                 :          10 :           }
     717                 :             :       }
     718                 :          83 :       goto retry;
     719                 :             : 
     720                 :         109 :     case CPP_CHAR_USERDEF:
     721                 :         109 :     case CPP_WCHAR_USERDEF:
     722                 :         109 :     case CPP_CHAR16_USERDEF:
     723                 :         109 :     case CPP_CHAR32_USERDEF:
     724                 :         109 :     case CPP_UTF8CHAR_USERDEF:
     725                 :         109 :       {
     726                 :         109 :         tree literal;
     727                 :         109 :         cpp_token temp_tok = *tok;
     728                 :         109 :         const char *suffix = cpp_get_userdef_suffix (tok);
     729                 :         109 :         temp_tok.val.str.len -= strlen (suffix);
     730                 :         109 :         temp_tok.type = cpp_userdef_char_remove_type (type);
     731                 :         109 :         literal = build_userdef_literal (get_identifier (suffix),
     732                 :             :                                          lex_charconst (&temp_tok),
     733                 :             :                                          OT_NONE, NULL_TREE);
     734                 :         109 :         *value = literal;
     735                 :             :       }
     736                 :         109 :       break;
     737                 :             : 
     738                 :     5666990 :     case CPP_CHAR:
     739                 :     5666990 :     case CPP_WCHAR:
     740                 :     5666990 :     case CPP_CHAR16:
     741                 :     5666990 :     case CPP_CHAR32:
     742                 :     5666990 :     case CPP_UTF8CHAR:
     743                 :     5666990 :       *value = lex_charconst (tok);
     744                 :     5666990 :       break;
     745                 :             : 
     746                 :      271618 :     case CPP_STRING_USERDEF:
     747                 :      271618 :     case CPP_WSTRING_USERDEF:
     748                 :      271618 :     case CPP_STRING16_USERDEF:
     749                 :      271618 :     case CPP_STRING32_USERDEF:
     750                 :      271618 :     case CPP_UTF8STRING_USERDEF:
     751                 :      271618 :       {
     752                 :      271618 :         tree literal, string;
     753                 :      271618 :         const char *suffix = cpp_get_userdef_suffix (tok);
     754                 :      543236 :         string = build_string (tok->val.str.len - strlen (suffix),
     755                 :      271618 :                                (const char *) tok->val.str.text);
     756                 :      271618 :         literal = build_userdef_literal (get_identifier (suffix),
     757                 :             :                                          string, OT_NONE, NULL_TREE);
     758                 :      271618 :         *value = literal;
     759                 :             :       }
     760                 :      271618 :       break;
     761                 :             : 
     762                 :    48433965 :     case CPP_STRING:
     763                 :    48433965 :     case CPP_WSTRING:
     764                 :    48433965 :     case CPP_STRING16:
     765                 :    48433965 :     case CPP_STRING32:
     766                 :    48433965 :     case CPP_UTF8STRING:
     767                 :    48433965 :       if ((lex_flags & C_LEX_STRING_NO_JOIN) == 0)
     768                 :             :         {
     769                 :          18 :           type = lex_string (tok, value, false,
     770                 :          18 :                              (lex_flags & C_LEX_STRING_NO_TRANSLATE) == 0);
     771                 :          18 :           break;
     772                 :             :         }
     773                 :    48433947 :       *value = build_string (tok->val.str.len, (const char *) tok->val.str.text);
     774                 :    48433947 :       break;
     775                 :             : 
     776                 :     3789161 :     case CPP_PRAGMA:
     777                 :     3789161 :       *value = build_int_cst (integer_type_node, tok->val.pragma);
     778                 :     3789161 :       break;
     779                 :             : 
     780                 :         689 :     case CPP_HEADER_NAME:
     781                 :         689 :       *value = build_string (tok->val.str.len, (const char *)tok->val.str.text);
     782                 :         689 :       break;
     783                 :             : 
     784                 :             :       /* This token should not be visible outside cpplib.  */
     785                 :           0 :     case CPP_MACRO_ARG:
     786                 :           0 :       gcc_unreachable ();
     787                 :             : 
     788                 :             :     /* CPP_COMMENT will appear when compiling with -C.  Ignore, except
     789                 :             :        when it is a FALLTHROUGH comment, in that case set
     790                 :             :        PREV_FALLTHROUGH flag on the next non-comment token.  */
     791                 :         410 :     case CPP_COMMENT:
     792                 :         410 :       if (tok->flags & PREV_FALLTHROUGH)
     793                 :             :         {
     794                 :         210 :           do
     795                 :             :             {
     796                 :         210 :               tok = get_token (parse_in, loc);
     797                 :         210 :               type = tok->type;
     798                 :             :             }
     799                 :         210 :           while (type == CPP_PADDING || type == CPP_COMMENT);
     800                 :         180 :           add_flags |= PREV_FALLTHROUGH;
     801                 :         180 :           goto retry_after_at;
     802                 :             :         }
     803                 :         230 :        goto retry;
     804                 :             : 
     805                 :  4941750943 :     default:
     806                 :  4941750943 :       *value = NULL_TREE;
     807                 :  4941750943 :       break;
     808                 :             :     }
     809                 :             : 
     810                 :  9549167287 :   if (cpp_flags)
     811                 :  9549167287 :     *cpp_flags = tok->flags | add_flags;
     812                 :             : 
     813                 :  9549167287 :   timevar_pop (TV_CPP);
     814                 :             : 
     815                 :  9549167287 :   return type;
     816                 :             : }
     817                 :             : 
     818                 :             : /* Returns the narrowest C-visible unsigned type, starting with the
     819                 :             :    minimum specified by FLAGS, that can fit HIGH:LOW, or itk_none if
     820                 :             :    there isn't one.  */
     821                 :             : 
     822                 :             : static enum integer_type_kind
     823                 :   131385433 : narrowest_unsigned_type (const widest_int &val, unsigned int flags)
     824                 :             : {
     825                 :   131385433 :   int itk;
     826                 :             : 
     827                 :   131385433 :   if ((flags & CPP_N_WIDTH) == CPP_N_SMALL)
     828                 :             :     itk = itk_unsigned_int;
     829                 :     3298773 :   else if ((flags & CPP_N_WIDTH) == CPP_N_MEDIUM)
     830                 :             :     itk = itk_unsigned_long;
     831                 :             :   else
     832                 :     1070418 :     itk = itk_unsigned_long_long;
     833                 :             : 
     834                 :   131527825 :   for (; itk < itk_none; itk += 2 /* skip unsigned types */)
     835                 :             :     {
     836                 :   131527825 :       tree upper;
     837                 :             : 
     838                 :   131527825 :       if (integer_types[itk] == NULL_TREE)
     839                 :           0 :         continue;
     840                 :   131527825 :       upper = TYPE_MAX_VALUE (integer_types[itk]);
     841                 :             : 
     842                 :   131527825 :       if (wi::geu_p (wi::to_widest (upper), val))
     843                 :   131385433 :         return (enum integer_type_kind) itk;
     844                 :             :     }
     845                 :             : 
     846                 :             :   return itk_none;
     847                 :             : }
     848                 :             : 
     849                 :             : /* Ditto, but narrowest signed type.  */
     850                 :             : static enum integer_type_kind
     851                 :   128329728 : narrowest_signed_type (const widest_int &val, unsigned int flags)
     852                 :             : {
     853                 :   128329728 :   int itk;
     854                 :             : 
     855                 :   128329728 :   if ((flags & CPP_N_WIDTH) == CPP_N_SMALL)
     856                 :             :     itk = itk_int;
     857                 :     1129945 :   else if ((flags & CPP_N_WIDTH) == CPP_N_MEDIUM)
     858                 :             :     itk = itk_long;
     859                 :             :   else
     860                 :      259988 :     itk = itk_long_long;
     861                 :             : 
     862                 :   128514640 :   for (; itk < itk_none; itk += 2 /* skip signed types */)
     863                 :             :     {
     864                 :   128513542 :       tree upper;
     865                 :             : 
     866                 :   128513542 :       if (integer_types[itk] == NULL_TREE)
     867                 :        4392 :         continue;
     868                 :   128509150 :       upper = TYPE_MAX_VALUE (integer_types[itk]);
     869                 :             : 
     870                 :   128509150 :       if (wi::geu_p (wi::to_widest (upper), val))
     871                 :   128328630 :         return (enum integer_type_kind) itk;
     872                 :             :     }
     873                 :             : 
     874                 :             :   return itk_none;
     875                 :             : }
     876                 :             : 
     877                 :             : /* Interpret TOKEN, an integer with FLAGS as classified by cpplib.  */
     878                 :             : static tree
     879                 :   131403979 : interpret_integer (const cpp_token *token, unsigned int flags,
     880                 :             :                    enum overflow_type *overflow)
     881                 :             : {
     882                 :   131403979 :   tree value, type;
     883                 :   131403979 :   enum integer_type_kind itk;
     884                 :   131403979 :   cpp_num integer;
     885                 :   131403979 :   HOST_WIDE_INT ival[3];
     886                 :             : 
     887                 :   131403979 :   *overflow = OT_NONE;
     888                 :             : 
     889                 :   131403979 :   if (UNLIKELY (flags & CPP_N_BITINT))
     890                 :             :     {
     891                 :       18546 :       unsigned int suffix_len = 2 + ((flags & CPP_N_UNSIGNED) ? 1 : 0);
     892                 :       18546 :       int max_bits_per_digit = 4; // ceil (log2 (10))
     893                 :       18546 :       unsigned int prefix_len = 0;
     894                 :       18546 :       bool hex = false;
     895                 :       18546 :       const int bitint_maxwidth = WIDE_INT_MAX_PRECISION - 1;
     896                 :       18546 :       if ((flags & CPP_N_RADIX) == CPP_N_OCTAL)
     897                 :             :         {
     898                 :             :           max_bits_per_digit = 3;
     899                 :             :           prefix_len = 1;
     900                 :             :         }
     901                 :       17618 :       else if ((flags & CPP_N_RADIX) == CPP_N_HEX)
     902                 :             :         {
     903                 :             :           max_bits_per_digit = 4;
     904                 :             :           prefix_len = 2;
     905                 :             :           hex = true;
     906                 :             :         }
     907                 :       17491 :       else if ((flags & CPP_N_RADIX) == CPP_N_BINARY)
     908                 :             :         {
     909                 :           1 :           max_bits_per_digit = 1;
     910                 :           1 :           prefix_len = 2;
     911                 :             :         }
     912                 :       18546 :       int max_digits
     913                 :       18546 :         = TYPE_PRECISION (intmax_type_node) >> max_bits_per_digit;
     914                 :       18546 :       const int max_buf = 128;
     915                 :       18546 :       if (max_digits > max_buf)
     916                 :             :         max_digits = max_buf;
     917                 :             : 
     918                 :       18546 :       widest_int wval;
     919                 :       18546 :       unsigned int prec;
     920                 :       18546 :       gcc_checking_assert (token->val.str.len > prefix_len + suffix_len
     921                 :             :                            || token->val.str.len == 1 + suffix_len);
     922                 :       18546 :       if (token->val.str.len - (prefix_len + suffix_len)
     923                 :       18546 :           <= (unsigned) max_digits)
     924                 :             :         {
     925                 :        2796 :           integer = cpp_interpret_integer (parse_in, token,
     926                 :             :                                            (flags & CPP_N_RADIX)
     927                 :             :                                            | CPP_N_UNSIGNED);
     928                 :        2796 :           ival[0] = integer.low;
     929                 :        2796 :           ival[1] = integer.high;
     930                 :        2796 :           ival[2] = 0;
     931                 :        2796 :           wval = widest_int::from_array (ival, 3);
     932                 :             :         }
     933                 :             :       else
     934                 :             :         {
     935                 :       15750 :           unsigned char buf[3 + max_buf];
     936                 :       15750 :           memcpy (buf, token->val.str.text, prefix_len);
     937                 :       15750 :           wval = 0U;
     938                 :       15750 :           const unsigned char *p = token->val.str.text + prefix_len;
     939                 :       15750 :           cpp_token tok = *token;
     940                 :       15750 :           tok.val.str.text = buf;
     941                 :       15750 :           if (!prefix_len)
     942                 :       15622 :             max_digits = 19;
     943                 :      177756 :           do
     944                 :             :             {
     945                 :       96753 :               unsigned char *q = buf + prefix_len;
     946                 :     1356861 :               do
     947                 :             :                 {
     948                 :     1356861 :                   unsigned char c = *p++;
     949                 :     1356861 :                   if (ISDIGIT (c) || (hex && ISXDIGIT (c)))
     950                 :             :                     {
     951                 :     1326452 :                       *q++ = c;
     952                 :     1326452 :                       if (q == buf + prefix_len + max_digits)
     953                 :             :                         break;
     954                 :             :                     }
     955                 :       30409 :                   else if (c != '\'')
     956                 :             :                     {
     957                 :             :                       --p;
     958                 :             :                       break;
     959                 :             :                     }
     960                 :             :                 }
     961                 :             :               while (1);
     962                 :       96753 :               if (q == buf + prefix_len)
     963                 :             :                 break;
     964                 :             :               else
     965                 :             :                 {
     966                 :       81003 :                   wi::overflow_type wioverflow;
     967                 :       81003 :                   *q = '\0';
     968                 :       81003 :                   tok.val.str.len = q - buf;
     969                 :       81003 :                   if (wval == 0)
     970                 :             :                     ;
     971                 :       65242 :                   else if (prefix_len)
     972                 :             :                     {
     973                 :        1172 :                       prec = wi::min_precision (wval, UNSIGNED);
     974                 :        1172 :                       unsigned HOST_WIDE_INT shift
     975                 :        1172 :                         = (tok.val.str.len - prefix_len) * max_bits_per_digit;
     976                 :        1172 :                       if (prec + shift > bitint_maxwidth)
     977                 :           0 :                         goto bitint_overflow;
     978                 :        1172 :                       wval = wi::lshift (wval, shift);
     979                 :             :                     }
     980                 :             :                   else
     981                 :             :                     {
     982                 :       64070 :                       static unsigned HOST_WIDE_INT tens[]
     983                 :             :                         = { 1U, 10U, 100U, 1000U,
     984                 :             :                             HOST_WIDE_INT_UC (10000),
     985                 :             :                             HOST_WIDE_INT_UC (100000),
     986                 :             :                             HOST_WIDE_INT_UC (1000000),
     987                 :             :                             HOST_WIDE_INT_UC (10000000),
     988                 :             :                             HOST_WIDE_INT_UC (100000000),
     989                 :             :                             HOST_WIDE_INT_UC (1000000000),
     990                 :             :                             HOST_WIDE_INT_UC (10000000000),
     991                 :             :                             HOST_WIDE_INT_UC (100000000000),
     992                 :             :                             HOST_WIDE_INT_UC (1000000000000),
     993                 :             :                             HOST_WIDE_INT_UC (10000000000000),
     994                 :             :                             HOST_WIDE_INT_UC (100000000000000),
     995                 :             :                             HOST_WIDE_INT_UC (1000000000000000),
     996                 :             :                             HOST_WIDE_INT_UC (10000000000000000),
     997                 :             :                             HOST_WIDE_INT_UC (100000000000000000),
     998                 :             :                             HOST_WIDE_INT_UC (1000000000000000000),
     999                 :             :                             HOST_WIDE_INT_UC (10000000000000000000) };
    1000                 :       64070 :                       widest_int ten = tens[q - buf];
    1001                 :       64070 :                       wval = wi::umul (wval, ten, &wioverflow);
    1002                 :       64070 :                       if (wioverflow)
    1003                 :           0 :                         goto bitint_overflow;
    1004                 :       64070 :                     }
    1005                 :       81003 :                   integer = cpp_interpret_integer (parse_in, &tok,
    1006                 :             :                                                    (flags & CPP_N_RADIX)
    1007                 :             :                                                    | CPP_N_UNSIGNED);
    1008                 :       81003 :                   ival[0] = integer.low;
    1009                 :       81003 :                   ival[1] = integer.high;
    1010                 :       81003 :                   ival[2] = 0;
    1011                 :       81003 :                   if (prefix_len)
    1012                 :        1311 :                     wval = wval + widest_int::from_array (ival, 3);
    1013                 :             :                   else
    1014                 :             :                     {
    1015                 :       79692 :                       widest_int addend = widest_int::from_array (ival, 3);
    1016                 :       79692 :                       wval = wi::add (wval, addend, UNSIGNED, &wioverflow);
    1017                 :       79692 :                       if (wioverflow)
    1018                 :           0 :                         goto bitint_overflow;
    1019                 :       79692 :                     }
    1020                 :             :                 }
    1021                 :       81003 :             }
    1022                 :             :           while (1);
    1023                 :             :         }
    1024                 :             : 
    1025                 :       18546 :       prec = wi::min_precision (wval, UNSIGNED);
    1026                 :       18546 :       if (prec == 0)
    1027                 :             :         prec = 1;
    1028                 :       18546 :       if ((flags & CPP_N_UNSIGNED) == 0)
    1029                 :       13618 :         ++prec;
    1030                 :       18546 :       if (prec > bitint_maxwidth)
    1031                 :             :         {
    1032                 :           0 :         bitint_overflow:
    1033                 :           0 :           if ((flags & CPP_N_UNSIGNED) != 0)
    1034                 :           0 :             error ("integer constant is too large for "
    1035                 :             :                    "%<unsigned _BitInt(%d)%> type", bitint_maxwidth);
    1036                 :             :           else
    1037                 :           0 :             error ("integer constant is too large for "
    1038                 :             :                    "%<_BitInt(%d)%> type", bitint_maxwidth);
    1039                 :           0 :           return integer_zero_node;
    1040                 :             :         }
    1041                 :             : 
    1042                 :       18546 :       struct bitint_info info;
    1043                 :       18546 :       if (!targetm.c.bitint_type_info (prec, &info))
    1044                 :             :         {
    1045                 :           0 :           sorry ("%<_BitInt(%d)%> is not supported on this target", prec);
    1046                 :           0 :           return integer_zero_node;
    1047                 :             :         }
    1048                 :             : 
    1049                 :       18546 :       type = build_bitint_type (prec, (flags & CPP_N_UNSIGNED) != 0);
    1050                 :       18546 :       return wide_int_to_tree (type, wval);
    1051                 :       18546 :     }
    1052                 :             : 
    1053                 :   131385433 :   integer = cpp_interpret_integer (parse_in, token, flags);
    1054                 :   131385433 :   if (integer.overflow)
    1055                 :          20 :     *overflow = OT_OVERFLOW;
    1056                 :             : 
    1057                 :   131385433 :   ival[0] = integer.low;
    1058                 :   131385433 :   ival[1] = integer.high;
    1059                 :   131385433 :   ival[2] = 0;
    1060                 :   262770866 :   widest_int wval = widest_int::from_array (ival, 3);
    1061                 :             : 
    1062                 :             :   /* The type of a constant with a U suffix is straightforward.  */
    1063                 :   131385433 :   if (flags & CPP_N_UNSIGNED)
    1064                 :     3055705 :     itk = narrowest_unsigned_type (wval, flags);
    1065                 :             :   else
    1066                 :             :     {
    1067                 :             :       /* The type of a potentially-signed integer constant varies
    1068                 :             :          depending on the base it's in, the standard in use, and the
    1069                 :             :          length suffixes.  */
    1070                 :   128329728 :       enum integer_type_kind itk_u
    1071                 :   128329728 :         = narrowest_unsigned_type (wval, flags);
    1072                 :   128329728 :       enum integer_type_kind itk_s
    1073                 :   128329728 :         = narrowest_signed_type (wval, flags);
    1074                 :             : 
    1075                 :             :       /* In both C89 and C99, octal and hex constants may be signed or
    1076                 :             :          unsigned, whichever fits tighter.  We do not warn about this
    1077                 :             :          choice differing from the traditional choice, as the constant
    1078                 :             :          is probably a bit pattern and either way will work.  */
    1079                 :   128329728 :       if ((flags & CPP_N_RADIX) != CPP_N_DECIMAL)
    1080                 :    11544756 :         itk = MIN (itk_u, itk_s);
    1081                 :             :       else
    1082                 :             :         {
    1083                 :             :           /* In C99, decimal constants are always signed.
    1084                 :             :              In C89, decimal constants that don't fit in long have
    1085                 :             :              undefined behavior; we try to make them unsigned long.
    1086                 :             :              In GCC's extended C89, that last is true of decimal
    1087                 :             :              constants that don't fit in long long, too.  */
    1088                 :             : 
    1089                 :   116784972 :           itk = itk_s;
    1090                 :   116784972 :           if (itk_s > itk_u && itk_s > itk_long)
    1091                 :             :             {
    1092                 :          27 :               if (!flag_isoc99)
    1093                 :             :                 {
    1094                 :          16 :                   if (itk_u < itk_unsigned_long)
    1095                 :           0 :                     itk_u = itk_unsigned_long;
    1096                 :          16 :                   itk = itk_u;
    1097                 :          16 :                   warning (0, "this decimal constant is unsigned only in ISO C90");
    1098                 :             :                 }
    1099                 :             :               else
    1100                 :          11 :                 warning (OPT_Wtraditional,
    1101                 :             :                          "this decimal constant would be unsigned in ISO C90");
    1102                 :             :             }
    1103                 :             :         }
    1104                 :             :     }
    1105                 :             : 
    1106                 :   131385433 :   if (itk == itk_none)
    1107                 :             :     /* cpplib has already issued a warning for overflow.  */
    1108                 :           0 :     type = ((flags & CPP_N_UNSIGNED)
    1109                 :           0 :             ? widest_unsigned_literal_type_node
    1110                 :             :             : widest_integer_literal_type_node);
    1111                 :   131385433 :   else if (flags & CPP_N_SIZE_T)
    1112                 :             :     {
    1113                 :             :       /* itk refers to fundamental types not aliased size types.  */
    1114                 :          22 :       if (flags & CPP_N_UNSIGNED)
    1115                 :          14 :         type = size_type_node;
    1116                 :             :       else
    1117                 :           8 :         type = signed_size_type_node;
    1118                 :             :     }
    1119                 :             :   else
    1120                 :             :     {
    1121                 :   131385411 :       type = integer_types[itk];
    1122                 :   131385411 :       if (itk > itk_unsigned_long
    1123                 :     1086252 :           && (flags & CPP_N_WIDTH) != CPP_N_LARGE)
    1124                 :       15834 :         emit_diagnostic
    1125                 :       33496 :           ((c_dialect_cxx () ? cxx_dialect == cxx98 : !flag_isoc99)
    1126                 :             :            ? DK_PEDWARN : DK_WARNING,
    1127                 :             :            input_location, OPT_Wlong_long,
    1128                 :             :            (flags & CPP_N_UNSIGNED)
    1129                 :             :            ? "integer constant is too large for %<unsigned long%> type"
    1130                 :             :            : "integer constant is too large for %<long%> type");
    1131                 :             :     }
    1132                 :             : 
    1133                 :   131385433 :   value = wide_int_to_tree (type, wval);
    1134                 :             : 
    1135                 :             :   /* Convert imaginary to a complex type.  */
    1136                 :   131385433 :   if (flags & CPP_N_IMAGINARY)
    1137                 :        3104 :     value = build_complex (NULL_TREE, build_int_cst (type, 0), value);
    1138                 :             : 
    1139                 :   131385433 :   return value;
    1140                 :             : }
    1141                 :             : 
    1142                 :             : /* Interpret TOKEN, a floating point number with FLAGS as classified
    1143                 :             :    by cpplib.  For C++11 SUFFIX may contain a user-defined literal suffix.  */
    1144                 :             : static tree
    1145                 :     4465146 : interpret_float (const cpp_token *token, unsigned int flags,
    1146                 :             :                  const char *suffix, enum overflow_type *overflow)
    1147                 :             : {
    1148                 :     4465146 :   tree type;
    1149                 :     4465146 :   tree const_type;
    1150                 :     4465146 :   tree value;
    1151                 :     4465146 :   REAL_VALUE_TYPE real;
    1152                 :     4465146 :   REAL_VALUE_TYPE real_trunc;
    1153                 :     4465146 :   char *copy;
    1154                 :     4465146 :   size_t copylen;
    1155                 :             : 
    1156                 :     4465146 :   *overflow = OT_NONE;
    1157                 :             : 
    1158                 :             :   /* Default (no suffix) depends on whether the FLOAT_CONST_DECIMAL64
    1159                 :             :      pragma has been used and is either double or _Decimal64.  Types
    1160                 :             :      that are not allowed with decimal float default to double.  */
    1161                 :     4465146 :   if (flags & CPP_N_DEFAULT)
    1162                 :             :     {
    1163                 :     2498175 :       flags ^= CPP_N_DEFAULT;
    1164                 :     2498175 :       flags |= CPP_N_MEDIUM;
    1165                 :             : 
    1166                 :     2498175 :       if (((flags & CPP_N_HEX) == 0) && ((flags & CPP_N_IMAGINARY) == 0))
    1167                 :             :         {
    1168                 :     2473809 :           warning (OPT_Wunsuffixed_float_constants,
    1169                 :             :                    "unsuffixed floating constant");
    1170                 :     2473809 :           if (float_const_decimal64_p ())
    1171                 :          23 :             flags |= CPP_N_DFLOAT;
    1172                 :             :         }
    1173                 :             :     }
    1174                 :             : 
    1175                 :             :   /* Decode _Fract and _Accum.  */
    1176                 :     4465146 :   if (flags & CPP_N_FRACT || flags & CPP_N_ACCUM)
    1177                 :          57 :     return interpret_fixed (token, flags);
    1178                 :             : 
    1179                 :             :   /* Decode type based on width and properties. */
    1180                 :     4465089 :   if (flags & CPP_N_DFLOAT)
    1181                 :       17830 :     if (!targetm.decimal_float_supported_p ())
    1182                 :             :       {
    1183                 :           0 :         error ("decimal floating-point not supported for this target");
    1184                 :           0 :         return error_mark_node;
    1185                 :             :       }
    1186                 :       17830 :     else if ((flags & CPP_N_WIDTH) == CPP_N_LARGE)
    1187                 :        5597 :       type = dfloat128_type_node;
    1188                 :       12233 :     else if ((flags & CPP_N_WIDTH) == CPP_N_SMALL)
    1189                 :        6167 :       type = dfloat32_type_node;
    1190                 :             :     else
    1191                 :        6066 :       type = dfloat64_type_node;
    1192                 :             :   else
    1193                 :     4447259 :     if (flags & CPP_N_WIDTH_MD)
    1194                 :             :       {
    1195                 :       75220 :         char suffix;
    1196                 :       75220 :         machine_mode mode;
    1197                 :             : 
    1198                 :       75220 :         if ((flags & CPP_N_WIDTH_MD) == CPP_N_MD_W)
    1199                 :             :           suffix = 'w';
    1200                 :             :         else
    1201                 :       75181 :           suffix = 'q';
    1202                 :             : 
    1203                 :       75220 :         mode = targetm.c.mode_for_suffix (suffix);
    1204                 :       75220 :         if (mode == VOIDmode)
    1205                 :             :           {
    1206                 :           0 :             error ("unsupported non-standard suffix on floating constant");
    1207                 :             : 
    1208                 :           0 :             return error_mark_node;
    1209                 :             :           }
    1210                 :             :         else
    1211                 :       75220 :           pedwarn (input_location, OPT_Wpedantic, "non-standard suffix on floating constant");
    1212                 :             : 
    1213                 :       75220 :         type = c_common_type_for_mode (mode, 0);
    1214                 :             :         /* For Q suffix, prefer float128t_type_node (__float128) type
    1215                 :             :            over float128_type_node (_Float128) type if they are distinct.  */
    1216                 :       75220 :         if (type == float128_type_node && float128t_type_node)
    1217                 :       75220 :           type = float128t_type_node;
    1218                 :       75220 :         gcc_assert (type);
    1219                 :             :       }
    1220                 :     4372039 :     else if ((flags & (CPP_N_FLOATN | CPP_N_FLOATNX)) != 0)
    1221                 :             :       {
    1222                 :      351385 :         unsigned int n = (flags & CPP_N_WIDTH_FLOATN_NX) >> CPP_FLOATN_SHIFT;
    1223                 :      351385 :         bool extended = (flags & CPP_N_FLOATNX) != 0;
    1224                 :      351385 :         type = NULL_TREE;
    1225                 :      833952 :         for (int i = 0; i < NUM_FLOATN_NX_TYPES; i++)
    1226                 :      833952 :           if (floatn_nx_types[i].n == (int) n
    1227                 :      353995 :               && floatn_nx_types[i].extended == extended)
    1228                 :             :             {
    1229                 :      351385 :               type = FLOATN_NX_TYPE_NODE (i);
    1230                 :      351385 :               break;
    1231                 :             :             }
    1232                 :      351385 :         if (type == NULL_TREE)
    1233                 :             :           {
    1234                 :           0 :             error ("unsupported non-standard suffix on floating constant");
    1235                 :           0 :             return error_mark_node;
    1236                 :             :           }
    1237                 :      351385 :         else if (!c_dialect_cxx ())
    1238                 :             :           {
    1239                 :       91149 :             if (warn_c11_c23_compat > 0)
    1240                 :             :               {
    1241                 :          12 :                 if (pedantic && !flag_isoc23)
    1242                 :           0 :                   pedwarn (input_location, OPT_Wc11_c23_compat,
    1243                 :             :                            "non-standard suffix on floating constant "
    1244                 :             :                            "before C23");
    1245                 :             :                 else
    1246                 :          12 :                   warning (OPT_Wc11_c23_compat,
    1247                 :             :                            "non-standard suffix on floating constant "
    1248                 :             :                            "before C23");
    1249                 :             :               }
    1250                 :       91137 :             else if (warn_c11_c23_compat != 0 && pedantic && !flag_isoc23)
    1251                 :          23 :               pedwarn (input_location, OPT_Wpedantic,
    1252                 :             :                        "non-standard suffix on floating constant "
    1253                 :             :                        "before C23");
    1254                 :             :           }
    1255                 :      260236 :         else if (!extended)
    1256                 :             :           {
    1257                 :      260120 :             if (cxx_dialect < cxx23)
    1258                 :      162909 :               pedwarn (input_location, OPT_Wpedantic,
    1259                 :             :                        "%<f%d%> or %<F%d%> suffix on floating constant only "
    1260                 :             :                        "available with %<-std=c++2b%> or %<-std=gnu++2b%>",
    1261                 :             :                        n, n);
    1262                 :             :           }
    1263                 :             :         else
    1264                 :         116 :           pedwarn (input_location, OPT_Wpedantic,
    1265                 :             :                    "non-standard suffix on floating constant");
    1266                 :             :       }
    1267                 :     4020654 :     else if ((flags & CPP_N_BFLOAT16) != 0)
    1268                 :             :       {
    1269                 :       91219 :         type = bfloat16_type_node;
    1270                 :       91219 :         if (type == NULL_TREE)
    1271                 :             :           {
    1272                 :           0 :             error ("unsupported non-standard suffix on floating constant");
    1273                 :           0 :             return error_mark_node;
    1274                 :             :           }
    1275                 :       91219 :         if (!c_dialect_cxx ())
    1276                 :         350 :           pedwarn (input_location, OPT_Wpedantic,
    1277                 :             :                    "non-standard suffix on floating constant");
    1278                 :       90869 :         else if (cxx_dialect < cxx23)
    1279                 :       17638 :           pedwarn (input_location, OPT_Wpedantic,
    1280                 :             :                    "%<bf16%> or %<BF16%> suffix on floating constant only "
    1281                 :             :                    "available with %<-std=c++2b%> or %<-std=gnu++2b%>");
    1282                 :             :       }
    1283                 :     3929435 :     else if ((flags & CPP_N_WIDTH) == CPP_N_LARGE)
    1284                 :     1035710 :       type = long_double_type_node;
    1285                 :     2893725 :     else if ((flags & CPP_N_WIDTH) == CPP_N_SMALL
    1286                 :     2498284 :              || flag_single_precision_constant)
    1287                 :      395628 :       type = float_type_node;
    1288                 :             :     else
    1289                 :     2498097 :       type = double_type_node;
    1290                 :             : 
    1291                 :     4465089 :   const_type = excess_precision_type (type);
    1292                 :     4465089 :   if (!const_type)
    1293                 :     4344314 :     const_type = type;
    1294                 :             : 
    1295                 :             :   /* Copy the constant to a nul-terminated buffer.  If the constant
    1296                 :             :      has any suffixes, cut them off; REAL_VALUE_ATOF/ REAL_VALUE_HTOF
    1297                 :             :      can't handle them.  */
    1298                 :     4465089 :   copylen = token->val.str.len;
    1299                 :     4465089 :   if (flags & CPP_N_USERDEF)
    1300                 :       31793 :     copylen -= strlen (suffix);
    1301                 :     4433296 :   else if (flags & CPP_N_DFLOAT)
    1302                 :       17830 :     copylen -= 2;
    1303                 :             :   else
    1304                 :             :     {
    1305                 :     4415466 :       if ((flags & CPP_N_WIDTH) != CPP_N_MEDIUM)
    1306                 :             :         /* Must be an F or L or machine defined suffix.  */
    1307                 :     1917182 :         copylen--;
    1308                 :     4415466 :       if (flags & CPP_N_IMAGINARY)
    1309                 :             :         /* I or J suffix.  */
    1310                 :       50848 :         copylen--;
    1311                 :     4415466 :       if (flags & CPP_N_FLOATNX)
    1312                 :        2610 :         copylen--;
    1313                 :     4415466 :       if (flags & (CPP_N_FLOATN | CPP_N_FLOATNX))
    1314                 :             :         {
    1315                 :      351385 :           unsigned int n = (flags & CPP_N_WIDTH_FLOATN_NX) >> CPP_FLOATN_SHIFT;
    1316                 :     1133189 :           while (n > 0)
    1317                 :             :             {
    1318                 :      781804 :               copylen--;
    1319                 :      781804 :               n /= 10;
    1320                 :             :             }
    1321                 :             :         }
    1322                 :             :     }
    1323                 :             : 
    1324                 :     4465089 :   copy = (char *) alloca (copylen + 1);
    1325                 :     4465089 :   if (c_dialect_cxx () ? cxx_dialect > cxx11 : flag_isoc23)
    1326                 :             :     {
    1327                 :             :       size_t maxlen = 0;
    1328                 :    44810566 :       for (size_t i = 0; i < copylen; ++i)
    1329                 :    41388724 :         if (token->val.str.text[i] != '\'')
    1330                 :    41388668 :           copy[maxlen++] = token->val.str.text[i];
    1331                 :     3421842 :       copy[maxlen] = '\0';
    1332                 :             :     }
    1333                 :             :   else
    1334                 :             :     {
    1335                 :     1043247 :       memcpy (copy, token->val.str.text, copylen);
    1336                 :     1043247 :       copy[copylen] = '\0';
    1337                 :             :     }
    1338                 :             : 
    1339                 :     4465089 :   real_from_string3 (&real, copy, TYPE_MODE (const_type));
    1340                 :     4465089 :   if (const_type != type)
    1341                 :             :     /* Diagnosing if the result of converting the value with excess
    1342                 :             :        precision to the semantic type would overflow (with associated
    1343                 :             :        double rounding) is more appropriate than diagnosing if the
    1344                 :             :        result of converting the string directly to the semantic type
    1345                 :             :        would overflow.  */
    1346                 :      120775 :     real_convert (&real_trunc, TYPE_MODE (type), &real);
    1347                 :             : 
    1348                 :             :   /* Both C and C++ require a diagnostic for a floating constant
    1349                 :             :      outside the range of representable values of its type.  Since we
    1350                 :             :      have __builtin_inf* to produce an infinity, this is now a
    1351                 :             :      mandatory pedwarn if the target does not support infinities.  */
    1352                 :     4465089 :   if (REAL_VALUE_ISINF (real)
    1353                 :     4465089 :       || (const_type != type && REAL_VALUE_ISINF (real_trunc)))
    1354                 :             :     {
    1355                 :          66 :       *overflow = OT_OVERFLOW;
    1356                 :          66 :       if (!(flags & CPP_N_USERDEF))
    1357                 :             :         {
    1358                 :         218 :           if (!MODE_HAS_INFINITIES (TYPE_MODE (type)))
    1359                 :           0 :             pedwarn (input_location, 0,
    1360                 :             :                      "floating constant exceeds range of %qT", type);
    1361                 :             :           else
    1362                 :          57 :             warning (OPT_Woverflow,
    1363                 :             :                      "floating constant exceeds range of %qT", type);
    1364                 :             :         }
    1365                 :             :     }
    1366                 :             :   /* We also give a warning if the value underflows.  */
    1367                 :     4465023 :   else if (real_equal (&real, &dconst0)
    1368                 :     4465023 :            || (const_type != type
    1369                 :       40499 :                && real_equal (&real_trunc, &dconst0)))
    1370                 :             :     {
    1371                 :     1174807 :       REAL_VALUE_TYPE realvoidmode;
    1372                 :     1174807 :       int oflow = real_from_string (&realvoidmode, copy);
    1373                 :     1174807 :       *overflow = (oflow == 0 ? OT_NONE
    1374                 :          21 :                               : (oflow < 0 ? OT_UNDERFLOW : OT_OVERFLOW));
    1375                 :     1174807 :       if (!(flags & CPP_N_USERDEF))
    1376                 :             :         {
    1377                 :     1143286 :           if (oflow < 0 || !real_equal (&realvoidmode, &dconst0))
    1378                 :          30 :             warning (OPT_Woverflow, "floating constant truncated to zero");
    1379                 :             :         }
    1380                 :             :     }
    1381                 :             : 
    1382                 :             :   /* Create a node with determined type and value.  */
    1383                 :     4465089 :   value = build_real (const_type, real);
    1384                 :     4465089 :   if (flags & CPP_N_IMAGINARY)
    1385                 :             :     {
    1386                 :       50848 :       value = build_complex (NULL_TREE,
    1387                 :             :                              fold_convert (const_type,
    1388                 :             :                                            integer_zero_node), value);
    1389                 :       50848 :       if (type != const_type)
    1390                 :             :         {
    1391                 :          26 :           const_type = TREE_TYPE (value);
    1392                 :          26 :           type = build_complex_type (type);
    1393                 :             :         }
    1394                 :             :     }
    1395                 :             : 
    1396                 :     4465089 :   if (type != const_type)
    1397                 :      120775 :     value = build1_loc (token->src_loc, EXCESS_PRECISION_EXPR, type, value);
    1398                 :             : 
    1399                 :             :   return value;
    1400                 :             : }
    1401                 :             : 
    1402                 :             : /* Interpret TOKEN, a fixed-point number with FLAGS as classified
    1403                 :             :    by cpplib.  */
    1404                 :             : 
    1405                 :             : static tree
    1406                 :          57 : interpret_fixed (const cpp_token *token, unsigned int flags)
    1407                 :             : {
    1408                 :          57 :   tree type;
    1409                 :          57 :   tree value;
    1410                 :          57 :   FIXED_VALUE_TYPE fixed;
    1411                 :          57 :   char *copy;
    1412                 :          57 :   size_t copylen;
    1413                 :             : 
    1414                 :          57 :   copylen = token->val.str.len;
    1415                 :             : 
    1416                 :          57 :   if (flags & CPP_N_FRACT) /* _Fract.  */
    1417                 :             :     {
    1418                 :          43 :       if (flags & CPP_N_UNSIGNED) /* Unsigned _Fract.  */
    1419                 :             :         {
    1420                 :           0 :           if ((flags & CPP_N_WIDTH) == CPP_N_LARGE)
    1421                 :             :             {
    1422                 :           0 :               type = unsigned_long_long_fract_type_node;
    1423                 :           0 :               copylen -= 4;
    1424                 :             :             }
    1425                 :           0 :           else if ((flags & CPP_N_WIDTH) == CPP_N_MEDIUM)
    1426                 :             :             {
    1427                 :           0 :               type = unsigned_long_fract_type_node;
    1428                 :           0 :               copylen -= 3;
    1429                 :             :             }
    1430                 :           0 :           else if ((flags & CPP_N_WIDTH) == CPP_N_SMALL)
    1431                 :             :             {
    1432                 :           0 :               type = unsigned_short_fract_type_node;
    1433                 :           0 :               copylen -= 3;
    1434                 :             :             }
    1435                 :             :           else
    1436                 :             :             {
    1437                 :           0 :               type = unsigned_fract_type_node;
    1438                 :           0 :               copylen -= 2;
    1439                 :             :             }
    1440                 :             :         }
    1441                 :             :       else /* Signed _Fract.  */
    1442                 :             :         {
    1443                 :          43 :           if ((flags & CPP_N_WIDTH) == CPP_N_LARGE)
    1444                 :             :             {
    1445                 :           0 :               type = long_long_fract_type_node;
    1446                 :           0 :               copylen -= 3;
    1447                 :             :             }
    1448                 :          43 :           else if ((flags & CPP_N_WIDTH) == CPP_N_MEDIUM)
    1449                 :             :             {
    1450                 :           0 :               type = long_fract_type_node;
    1451                 :           0 :               copylen -= 2;
    1452                 :             :             }
    1453                 :          43 :           else if ((flags & CPP_N_WIDTH) == CPP_N_SMALL)
    1454                 :             :             {
    1455                 :           0 :               type = short_fract_type_node;
    1456                 :           0 :               copylen -= 2;
    1457                 :             :             }
    1458                 :             :           else
    1459                 :             :             {
    1460                 :          43 :               type = fract_type_node;
    1461                 :          43 :               copylen --;
    1462                 :             :             }
    1463                 :             :           }
    1464                 :             :     }
    1465                 :             :   else /* _Accum.  */
    1466                 :             :     {
    1467                 :          14 :       if (flags & CPP_N_UNSIGNED) /* Unsigned _Accum.  */
    1468                 :             :         {
    1469                 :           0 :           if ((flags & CPP_N_WIDTH) == CPP_N_LARGE)
    1470                 :             :             {
    1471                 :           0 :               type = unsigned_long_long_accum_type_node;
    1472                 :           0 :               copylen -= 4;
    1473                 :             :             }
    1474                 :           0 :           else if ((flags & CPP_N_WIDTH) == CPP_N_MEDIUM)
    1475                 :             :             {
    1476                 :           0 :               type = unsigned_long_accum_type_node;
    1477                 :           0 :               copylen -= 3;
    1478                 :             :             }
    1479                 :           0 :           else if ((flags & CPP_N_WIDTH) == CPP_N_SMALL)
    1480                 :             :             {
    1481                 :           0 :               type = unsigned_short_accum_type_node;
    1482                 :           0 :               copylen -= 3;
    1483                 :             :              }
    1484                 :             :           else
    1485                 :             :             {
    1486                 :           0 :               type = unsigned_accum_type_node;
    1487                 :           0 :               copylen -= 2;
    1488                 :             :             }
    1489                 :             :         }
    1490                 :             :       else /* Signed _Accum.  */
    1491                 :             :         {
    1492                 :          14 :           if ((flags & CPP_N_WIDTH) == CPP_N_LARGE)
    1493                 :             :             {
    1494                 :           0 :               type = long_long_accum_type_node;
    1495                 :           0 :               copylen -= 3;
    1496                 :             :             }
    1497                 :          14 :           else if ((flags & CPP_N_WIDTH) == CPP_N_MEDIUM)
    1498                 :             :             {
    1499                 :           0 :               type = long_accum_type_node;
    1500                 :           0 :               copylen -= 2;
    1501                 :             :             }
    1502                 :          14 :           else if ((flags & CPP_N_WIDTH) == CPP_N_SMALL)
    1503                 :             :             {
    1504                 :           0 :               type = short_accum_type_node;
    1505                 :           0 :               copylen -= 2;
    1506                 :             :             }
    1507                 :             :           else
    1508                 :             :             {
    1509                 :          14 :               type = accum_type_node;
    1510                 :          14 :               copylen --;
    1511                 :             :             }
    1512                 :             :         }
    1513                 :             :     }
    1514                 :             : 
    1515                 :          57 :   copy = (char *) alloca (copylen + 1);
    1516                 :          57 :   memcpy (copy, token->val.str.text, copylen);
    1517                 :          57 :   copy[copylen] = '\0';
    1518                 :             : 
    1519                 :          57 :   fixed_from_string (&fixed, copy, SCALAR_TYPE_MODE (type));
    1520                 :             : 
    1521                 :             :   /* Create a node with determined type and value.  */
    1522                 :          57 :   value = build_fixed (type, fixed);
    1523                 :             : 
    1524                 :          57 :   return value;
    1525                 :             : }
    1526                 :             : 
    1527                 :             : /* Convert a series of STRING, WSTRING, STRING16, STRING32 and/or
    1528                 :             :    UTF8STRING tokens into a tree, performing string constant
    1529                 :             :    concatenation.  TOK is the first of these.  VALP is the location to
    1530                 :             :    write the string into.  OBJC_STRING indicates whether an '@' token
    1531                 :             :    preceded the incoming token (in that case, the strings can either
    1532                 :             :    be ObjC strings, preceded by a single '@', or normal strings, not
    1533                 :             :    preceded by '@'.  The result will be a CPP_OBJC_STRING).  Returns
    1534                 :             :    the CPP token type of the result (CPP_STRING, CPP_WSTRING,
    1535                 :             :    CPP_STRING32, CPP_STRING16, CPP_UTF8STRING, or CPP_OBJC_STRING).
    1536                 :             : 
    1537                 :             :    This is unfortunately more work than it should be.  If any of the
    1538                 :             :    strings in the series has an L prefix, the result is a wide string
    1539                 :             :    (6.4.5p4).  Whether or not the result is a wide string affects the
    1540                 :             :    meaning of octal and hexadecimal escapes (6.4.4.4p6,9).  But escape
    1541                 :             :    sequences do not continue across the boundary between two strings in
    1542                 :             :    a series (6.4.5p7), so we must not lose the boundaries.  Therefore
    1543                 :             :    cpp_interpret_string takes a vector of cpp_string structures, which
    1544                 :             :    we must arrange to provide.  */
    1545                 :             : 
    1546                 :             : static enum cpp_ttype
    1547                 :          18 : lex_string (const cpp_token *tok, tree *valp, bool objc_string, bool translate)
    1548                 :             : {
    1549                 :          18 :   tree value;
    1550                 :          18 :   size_t concats = 0;
    1551                 :          18 :   struct obstack str_ob;
    1552                 :          18 :   struct obstack loc_ob;
    1553                 :          18 :   cpp_string istr;
    1554                 :          18 :   enum cpp_ttype type = tok->type;
    1555                 :             : 
    1556                 :             :   /* Try to avoid the overhead of creating and destroying an obstack
    1557                 :             :      for the common case of just one string.  */
    1558                 :          18 :   cpp_string str = tok->val.str;
    1559                 :          18 :   location_t init_loc = tok->src_loc;
    1560                 :          18 :   cpp_string *strs = &str;
    1561                 :          18 :   location_t *locs = NULL;
    1562                 :             : 
    1563                 :             :   /* objc_at_sign_was_seen is only used when doing Objective-C string
    1564                 :             :      concatenation.  It is 'true' if we have seen an '@' before the
    1565                 :             :      current string, and 'false' if not.  We must see exactly one or
    1566                 :             :      zero '@' before each string.  */
    1567                 :          18 :   bool objc_at_sign_was_seen = false;
    1568                 :             : 
    1569                 :          18 :  retry:
    1570                 :          18 :   tok = get_token (parse_in);
    1571                 :          18 :   switch (tok->type)
    1572                 :             :     {
    1573                 :           0 :     case CPP_PADDING:
    1574                 :           0 :       goto retry;
    1575                 :           0 :     case CPP_ATSIGN:
    1576                 :           0 :       if (objc_string)
    1577                 :             :         {
    1578                 :           0 :           if (objc_at_sign_was_seen)
    1579                 :           0 :             error ("repeated %<@%> before Objective-C string");
    1580                 :             : 
    1581                 :           0 :           objc_at_sign_was_seen = true;
    1582                 :           0 :           goto retry;
    1583                 :             :         }
    1584                 :             :       /* FALLTHROUGH */
    1585                 :             : 
    1586                 :          18 :     default:
    1587                 :          18 :       break;
    1588                 :             : 
    1589                 :           0 :     case CPP_WSTRING:
    1590                 :           0 :     case CPP_STRING16:
    1591                 :           0 :     case CPP_STRING32:
    1592                 :           0 :     case CPP_UTF8STRING:
    1593                 :           0 :       if (type != tok->type)
    1594                 :             :         {
    1595                 :           0 :           if (type == CPP_STRING)
    1596                 :           0 :             type = tok->type;
    1597                 :             :           else
    1598                 :           0 :             error ("unsupported non-standard concatenation of string literals");
    1599                 :             :         }
    1600                 :             :       /* FALLTHROUGH */
    1601                 :             : 
    1602                 :           0 :     case CPP_STRING:
    1603                 :           0 :       if (!concats)
    1604                 :             :         {
    1605                 :           0 :           gcc_obstack_init (&str_ob);
    1606                 :           0 :           gcc_obstack_init (&loc_ob);
    1607                 :           0 :           obstack_grow (&str_ob, &str, sizeof (cpp_string));
    1608                 :           0 :           obstack_grow (&loc_ob, &init_loc, sizeof (location_t));
    1609                 :             :         }
    1610                 :             : 
    1611                 :           0 :       concats++;
    1612                 :           0 :       obstack_grow (&str_ob, &tok->val.str, sizeof (cpp_string));
    1613                 :           0 :       obstack_grow (&loc_ob, &tok->src_loc, sizeof (location_t));
    1614                 :             : 
    1615                 :           0 :       if (objc_string)
    1616                 :           0 :         objc_at_sign_was_seen = false;
    1617                 :           0 :       goto retry;
    1618                 :             :     }
    1619                 :             : 
    1620                 :             :   /* It is an error if we saw a '@' with no following string.  */
    1621                 :          18 :   if (objc_at_sign_was_seen)
    1622                 :           0 :     error ("stray %<@%> in program");
    1623                 :             : 
    1624                 :             :   /* We have read one more token than we want.  */
    1625                 :          18 :   _cpp_backup_tokens (parse_in, 1);
    1626                 :          18 :   if (concats)
    1627                 :             :     {
    1628                 :           0 :       strs = XOBFINISH (&str_ob, cpp_string *);
    1629                 :           0 :       locs = XOBFINISH (&loc_ob, location_t *);
    1630                 :             :     }
    1631                 :             : 
    1632                 :          18 :   if (concats && !objc_string && !in_system_header_at (input_location))
    1633                 :           0 :     warning (OPT_Wtraditional,
    1634                 :             :              "traditional C rejects string constant concatenation");
    1635                 :             : 
    1636                 :          18 :   if ((translate
    1637                 :          18 :        ? cpp_interpret_string : cpp_interpret_string_notranslate)
    1638                 :          18 :       (parse_in, strs, concats + 1, &istr, type))
    1639                 :             :     {
    1640                 :          18 :       value = build_string (istr.len, (const char *) istr.text);
    1641                 :          18 :       free (CONST_CAST (unsigned char *, istr.text));
    1642                 :          18 :       if (concats)
    1643                 :             :         {
    1644                 :           0 :           gcc_assert (locs);
    1645                 :           0 :           gcc_assert (g_string_concat_db);
    1646                 :           0 :           g_string_concat_db->record_string_concatenation (concats + 1, locs);
    1647                 :             :         }
    1648                 :             :     }
    1649                 :             :   else
    1650                 :             :     {
    1651                 :             :       /* Callers cannot generally handle error_mark_node in this context,
    1652                 :             :          so return the empty string instead.  cpp_interpret_string has
    1653                 :             :          issued an error.  */
    1654                 :           0 :       switch (type)
    1655                 :             :         {
    1656                 :           0 :         default:
    1657                 :           0 :         case CPP_STRING:
    1658                 :           0 :         case CPP_UTF8STRING:
    1659                 :           0 :           if (type == CPP_UTF8STRING && flag_char8_t)
    1660                 :             :             {
    1661                 :           0 :               value = build_string (TYPE_PRECISION (char8_type_node)
    1662                 :           0 :                                     / TYPE_PRECISION (char_type_node),
    1663                 :             :                                     "");  /* char8_t is 8 bits */
    1664                 :             :             }
    1665                 :             :           else
    1666                 :           0 :             value = build_string (1, "");
    1667                 :             :           break;
    1668                 :           0 :         case CPP_STRING16:
    1669                 :           0 :           value = build_string (TYPE_PRECISION (char16_type_node)
    1670                 :           0 :                                 / TYPE_PRECISION (char_type_node),
    1671                 :             :                                 "\0");  /* char16_t is 16 bits */
    1672                 :           0 :           break;
    1673                 :           0 :         case CPP_STRING32:
    1674                 :           0 :           value = build_string (TYPE_PRECISION (char32_type_node)
    1675                 :           0 :                                 / TYPE_PRECISION (char_type_node),
    1676                 :             :                                 "\0\0\0");  /* char32_t is 32 bits */
    1677                 :           0 :           break;
    1678                 :           0 :         case CPP_WSTRING:
    1679                 :           0 :           value = build_string (TYPE_PRECISION (wchar_type_node)
    1680                 :           0 :                                 / TYPE_PRECISION (char_type_node),
    1681                 :             :                                 "\0\0\0");  /* widest supported wchar_t
    1682                 :             :                                                is 32 bits */
    1683                 :           0 :           break;
    1684                 :             :         }
    1685                 :             :     }
    1686                 :             : 
    1687                 :          18 :   switch (type)
    1688                 :             :     {
    1689                 :          18 :     default:
    1690                 :          18 :     case CPP_STRING:
    1691                 :          18 :       TREE_TYPE (value) = char_array_type_node;
    1692                 :          18 :       break;
    1693                 :           0 :     case CPP_UTF8STRING:
    1694                 :           0 :       if (flag_char8_t)
    1695                 :           0 :         TREE_TYPE (value) = char8_array_type_node;
    1696                 :             :       else
    1697                 :           0 :         TREE_TYPE (value) = char_array_type_node;
    1698                 :             :       break;
    1699                 :           0 :     case CPP_STRING16:
    1700                 :           0 :       TREE_TYPE (value) = char16_array_type_node;
    1701                 :           0 :       break;
    1702                 :           0 :     case CPP_STRING32:
    1703                 :           0 :       TREE_TYPE (value) = char32_array_type_node;
    1704                 :           0 :       break;
    1705                 :           0 :     case CPP_WSTRING:
    1706                 :           0 :       TREE_TYPE (value) = wchar_array_type_node;
    1707                 :             :     }
    1708                 :          18 :   *valp = fix_string_type (value);
    1709                 :             : 
    1710                 :          18 :   if (concats)
    1711                 :             :     {
    1712                 :           0 :       obstack_free (&str_ob, 0);
    1713                 :           0 :       obstack_free (&loc_ob, 0);
    1714                 :             :     }
    1715                 :             : 
    1716                 :          18 :   return objc_string ? CPP_OBJC_STRING : type;
    1717                 :             : }
    1718                 :             : 
    1719                 :             : /* Converts a (possibly wide) character constant token into a tree.  */
    1720                 :             : static tree
    1721                 :     5667099 : lex_charconst (const cpp_token *token)
    1722                 :             : {
    1723                 :     5667099 :   cppchar_t result;
    1724                 :     5667099 :   tree type, value;
    1725                 :     5667099 :   unsigned int chars_seen;
    1726                 :     5667099 :   int unsignedp = 0;
    1727                 :             : 
    1728                 :     5667099 :   result = cpp_interpret_charconst (parse_in, token,
    1729                 :             :                                     &chars_seen, &unsignedp);
    1730                 :             : 
    1731                 :     5667099 :   if (token->type == CPP_WCHAR)
    1732                 :      394207 :     type = wchar_type_node;
    1733                 :     5272892 :   else if (token->type == CPP_CHAR32)
    1734                 :         510 :     type = char32_type_node;
    1735                 :     5272382 :   else if (token->type == CPP_CHAR16)
    1736                 :       18902 :     type = char16_type_node;
    1737                 :     5253480 :   else if (token->type == CPP_UTF8CHAR)
    1738                 :             :     {
    1739                 :         162 :       if (flag_char8_t)
    1740                 :         128 :         type = char8_type_node;
    1741                 :             :       else
    1742                 :          34 :         type = char_type_node;
    1743                 :             :     }
    1744                 :             :   /* In C, a character constant has type 'int'.
    1745                 :             :      In C++ 'char', but multi-char charconsts have type 'int'.  */
    1746                 :     5253318 :   else if (!c_dialect_cxx () || chars_seen > 1)
    1747                 :      111603 :     type = integer_type_node;
    1748                 :             :   else
    1749                 :     5141715 :     type = char_type_node;
    1750                 :             : 
    1751                 :             :   /* Cast to cppchar_signed_t to get correct sign-extension of RESULT
    1752                 :             :      before possibly widening to HOST_WIDE_INT for build_int_cst.  */
    1753                 :     5667099 :   if (unsignedp || (cppchar_signed_t) result >= 0)
    1754                 :     5665541 :     value = build_int_cst (type, result);
    1755                 :             :   else
    1756                 :        1558 :     value = build_int_cst (type, (cppchar_signed_t) result);
    1757                 :             : 
    1758                 :     5667099 :   return value;
    1759                 :             : }
    1760                 :             : 
    1761                 :             : /* Helper function for c_parser_peek_conflict_marker
    1762                 :             :    and cp_lexer_peek_conflict_marker.
    1763                 :             :    Given a possible conflict marker token of kind TOK1_KIND
    1764                 :             :    consisting of a pair of characters, get the token kind for the
    1765                 :             :    standalone final character.  */
    1766                 :             : 
    1767                 :             : enum cpp_ttype
    1768                 :         123 : conflict_marker_get_final_tok_kind (enum cpp_ttype tok1_kind)
    1769                 :             : {
    1770                 :         123 :   switch (tok1_kind)
    1771                 :             :     {
    1772                 :           0 :     default: gcc_unreachable ();
    1773                 :             :     case CPP_LSHIFT:
    1774                 :             :       /* "<<" and '<' */
    1775                 :             :       return CPP_LESS;
    1776                 :             : 
    1777                 :          38 :     case CPP_EQ_EQ:
    1778                 :             :       /* "==" and '=' */
    1779                 :          38 :       return CPP_EQ;
    1780                 :             : 
    1781                 :          43 :     case CPP_RSHIFT:
    1782                 :             :       /* ">>" and '>' */
    1783                 :          43 :       return CPP_GREATER;
    1784                 :             :     }
    1785                 :             : }
        

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.