LCOV - code coverage report
Current view: top level - gcc/cp - lex.cc (source / functions) Coverage Total Hit
Test: gcc.info Lines: 93.5 % 461 431
Test Date: 2024-04-13 14:00:49 Functions: 92.3 % 39 36
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : /* Separate lexical analyzer for GNU C++.
       2                 :             :    Copyright (C) 1987-2024 Free Software Foundation, Inc.
       3                 :             :    Hacked by Michael Tiemann (tiemann@cygnus.com)
       4                 :             : 
       5                 :             : This file is part of GCC.
       6                 :             : 
       7                 :             : GCC is free software; you can redistribute it and/or modify
       8                 :             : it under the terms of the GNU General Public License as published by
       9                 :             : the Free Software Foundation; either version 3, or (at your option)
      10                 :             : any later version.
      11                 :             : 
      12                 :             : GCC is distributed in the hope that it will be useful,
      13                 :             : but WITHOUT ANY WARRANTY; without even the implied warranty of
      14                 :             : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      15                 :             : GNU General Public License for more details.
      16                 :             : 
      17                 :             : You should have received a copy of the GNU General Public License
      18                 :             : along with GCC; see the file COPYING3.  If not see
      19                 :             : <http://www.gnu.org/licenses/>.  */
      20                 :             : 
      21                 :             : 
      22                 :             : /* This file is the lexical analyzer for GNU C++.  */
      23                 :             : 
      24                 :             : #include "config.h"
      25                 :             : /* For use with name_hint.  */
      26                 :             : #define INCLUDE_MEMORY
      27                 :             : #include "system.h"
      28                 :             : #include "coretypes.h"
      29                 :             : #include "cp-tree.h"
      30                 :             : #include "stringpool.h"
      31                 :             : #include "c-family/c-pragma.h"
      32                 :             : #include "c-family/c-objc.h"
      33                 :             : #include "gcc-rich-location.h"
      34                 :             : #include "cp-name-hint.h"
      35                 :             : #include "langhooks.h"
      36                 :             : 
      37                 :             : static int interface_strcmp (const char *);
      38                 :             : static void init_cp_traits (void);
      39                 :             : static void init_cp_pragma (void);
      40                 :             : 
      41                 :             : static tree parse_strconst_pragma (const char *, int);
      42                 :             : static void handle_pragma_vtable (cpp_reader *);
      43                 :             : static void handle_pragma_unit (cpp_reader *);
      44                 :             : static void handle_pragma_interface (cpp_reader *);
      45                 :             : static void handle_pragma_implementation (cpp_reader *);
      46                 :             : 
      47                 :             : static void init_operators (void);
      48                 :             : static void copy_lang_type (tree);
      49                 :             : 
      50                 :             : /* A constraint that can be tested at compile time.  */
      51                 :             : #define CONSTRAINT(name, expr) extern int constraint_##name [(expr) ? 1 : -1]
      52                 :             : 
      53                 :             : /* Functions and data structures for #pragma interface.
      54                 :             : 
      55                 :             :    `#pragma implementation' means that the main file being compiled
      56                 :             :    is considered to implement (provide) the classes that appear in
      57                 :             :    its main body.  I.e., if this is file "foo.cc", and class `bar'
      58                 :             :    is defined in "foo.cc", then we say that "foo.cc implements bar".
      59                 :             : 
      60                 :             :    All main input files "implement" themselves automagically.
      61                 :             : 
      62                 :             :    `#pragma interface' means that unless this file (of the form "foo.h"
      63                 :             :    is not presently being included by file "foo.cc", the
      64                 :             :    CLASSTYPE_INTERFACE_ONLY bit gets set.  The effect is that none
      65                 :             :    of the vtables nor any of the inline functions defined in foo.h
      66                 :             :    will ever be output.
      67                 :             : 
      68                 :             :    There are cases when we want to link files such as "defs.h" and
      69                 :             :    "main.cc".  In this case, we give "defs.h" a `#pragma interface',
      70                 :             :    and "main.cc" has `#pragma implementation "defs.h"'.  */
      71                 :             : 
      72                 :             : struct impl_files
      73                 :             : {
      74                 :             :   const char *filename;
      75                 :             :   struct impl_files *next;
      76                 :             : };
      77                 :             : 
      78                 :             : static struct impl_files *impl_file_chain;
      79                 :             : 
      80                 :             : void
      81                 :      100885 : cxx_finish (void)
      82                 :             : {
      83                 :      100885 :   c_common_finish ();
      84                 :      100885 : }
      85                 :             : 
      86                 :             : ovl_op_info_t ovl_op_info[2][OVL_OP_MAX] = 
      87                 :             :   {
      88                 :             :     {
      89                 :             :       {NULL_TREE, NULL, NULL, ERROR_MARK, OVL_OP_ERROR_MARK, 0},
      90                 :             :       {NULL_TREE, NULL, NULL, NOP_EXPR, OVL_OP_NOP_EXPR, 0},
      91                 :             : #define DEF_OPERATOR(NAME, CODE, MANGLING, FLAGS) \
      92                 :             :       {NULL_TREE, NAME, MANGLING, CODE, OVL_OP_##CODE, FLAGS},
      93                 :             : #define OPERATOR_TRANSITION }, {                        \
      94                 :             :       {NULL_TREE, NULL, NULL, ERROR_MARK, OVL_OP_ERROR_MARK, 0},
      95                 :             : #include "operators.def"
      96                 :             :     }
      97                 :             :   };
      98                 :             : unsigned char ovl_op_mapping[MAX_TREE_CODES];
      99                 :             : unsigned char ovl_op_alternate[OVL_OP_MAX];
     100                 :             : 
     101                 :             : /* The trait table, declared in cp-tree.h.  */
     102                 :             : const cp_trait cp_traits[] =
     103                 :             : {
     104                 :             : #define DEFTRAIT(TCC, CODE, NAME, ARITY) \
     105                 :             :   { NAME, CPTK_##CODE, ARITY, (TCC == tcc_type) },
     106                 :             : #include "cp-trait.def"
     107                 :             : #undef DEFTRAIT
     108                 :             : };
     109                 :             : /* The trait table cannot have more than 255 (addr_space_t) entries since
     110                 :             :    the index is retrieved through IDENTIFIER_CP_INDEX.  */
     111                 :             : static_assert(ARRAY_SIZE (cp_traits) <= 255,
     112                 :             :               "cp_traits array cannot have more than 255 entries");
     113                 :             : 
     114                 :             : /* Get the name of the kind of identifier T.  */
     115                 :             : 
     116                 :             : const char *
     117                 :           0 : get_identifier_kind_name (tree id)
     118                 :             : {
     119                 :             :   /* Keep in sync with cp_id_kind enumeration.  */
     120                 :           0 :   static const char *const names[cik_max] = {
     121                 :             :     "normal", "keyword", "constructor", "destructor",
     122                 :             :     "simple-op", "assign-op", "conv-op", "<reserved>udlit-op"
     123                 :             :   };
     124                 :             : 
     125                 :           0 :   unsigned kind = 0;
     126                 :           0 :   kind |= IDENTIFIER_KIND_BIT_2 (id) << 2;
     127                 :           0 :   kind |= IDENTIFIER_KIND_BIT_1 (id) << 1;
     128                 :           0 :   kind |= IDENTIFIER_KIND_BIT_0 (id) << 0;
     129                 :             : 
     130                 :           0 :   return names[kind];
     131                 :             : }
     132                 :             : 
     133                 :             : /* Set the identifier kind, which we expect to currently be zero.  */
     134                 :             : 
     135                 :             : void
     136                 :    24588795 : set_identifier_kind (tree id, cp_identifier_kind kind)
     137                 :             : {
     138                 :    24588795 :   gcc_checking_assert (!IDENTIFIER_KIND_BIT_2 (id)
     139                 :             :                        & !IDENTIFIER_KIND_BIT_1 (id)
     140                 :             :                        & !IDENTIFIER_KIND_BIT_0 (id));
     141                 :    24588795 :   IDENTIFIER_KIND_BIT_2 (id) |= (kind >> 2) & 1;
     142                 :    24588795 :   IDENTIFIER_KIND_BIT_1 (id) |= (kind >> 1) & 1;
     143                 :    24588795 :   IDENTIFIER_KIND_BIT_0 (id) |= (kind >> 0) & 1;
     144                 :    24588795 : }
     145                 :             : 
     146                 :             : /* Create and tag the internal operator name for the overloaded
     147                 :             :    operator PTR describes.  */
     148                 :             : 
     149                 :             : static tree
     150                 :     5660088 : set_operator_ident (ovl_op_info_t *ptr)
     151                 :             : {
     152                 :     5660088 :   char buffer[32];
     153                 :    11320176 :   size_t len = snprintf (buffer, sizeof (buffer), "operator%s%s",
     154                 :     5660088 :                          &" "[ptr->name[0] && ptr->name[0] != '_'
     155                 :     5660088 :                               && !ISALPHA (ptr->name[0])],
     156                 :     5660088 :                          ptr->name);
     157                 :     5660088 :   gcc_checking_assert (len < sizeof (buffer));
     158                 :             : 
     159                 :     5660088 :   tree ident = get_identifier_with_length (buffer, len);
     160                 :     5660088 :   ptr->identifier = ident;
     161                 :             : 
     162                 :     5660088 :   return ident;
     163                 :             : }
     164                 :             : 
     165                 :             : /* Initialize data structures that keep track of operator names.  */
     166                 :             : 
     167                 :             : static void
     168                 :      101073 : init_operators (void)
     169                 :             : {
     170                 :             :   /* We rely on both these being zero.  */
     171                 :      101073 :   gcc_checking_assert (!OVL_OP_ERROR_MARK && !ERROR_MARK);
     172                 :             : 
     173                 :             :   /* This loop iterates backwards because we need to move the
     174                 :             :      assignment operators down to their correct slots.  I.e. morally
     175                 :             :      equivalent to an overlapping memmove where dest > src.  Slot
     176                 :             :      zero is for error_mark, so hae no operator. */
     177                 :     5862234 :   for (unsigned ix = OVL_OP_MAX; --ix;)
     178                 :             :     {
     179                 :     5761161 :       ovl_op_info_t *op_ptr = &ovl_op_info[false][ix];
     180                 :             : 
     181                 :     5761161 :       if (op_ptr->name)
     182                 :             :         {
     183                 :     4548285 :           tree ident = set_operator_ident (op_ptr);
     184                 :     4548285 :           if (unsigned index = IDENTIFIER_CP_INDEX (ident))
     185                 :             :             {
     186                 :      606438 :               ovl_op_info_t *bin_ptr = &ovl_op_info[false][index];
     187                 :             : 
     188                 :             :               /* They should only differ in unary/binary ness.  */
     189                 :      606438 :               gcc_checking_assert ((op_ptr->flags ^ bin_ptr->flags)
     190                 :             :                                    == OVL_OP_FLAG_AMBIARY);
     191                 :      606438 :               bin_ptr->flags |= op_ptr->flags;
     192                 :      606438 :               ovl_op_alternate[index] = ix;
     193                 :             :             }
     194                 :             :           else
     195                 :             :             {
     196                 :     3941847 :               IDENTIFIER_CP_INDEX (ident) = ix;
     197                 :     3941847 :               set_identifier_kind (ident, cik_simple_op);
     198                 :             :             }
     199                 :             :         }
     200                 :     5761161 :       if (op_ptr->tree_code)
     201                 :             :         {
     202                 :     5761161 :           gcc_checking_assert (op_ptr->ovl_op_code == ix
     203                 :             :                                && !ovl_op_mapping[op_ptr->tree_code]);
     204                 :     5761161 :           ovl_op_mapping[op_ptr->tree_code] = op_ptr->ovl_op_code;
     205                 :             :         }
     206                 :             : 
     207                 :     5761161 :       ovl_op_info_t *as_ptr = &ovl_op_info[true][ix];
     208                 :     5761161 :       if (as_ptr->name)
     209                 :             :         {
     210                 :             :           /* These will be placed at the start of the array, move to
     211                 :             :              the correct slot and initialize.  */
     212                 :     1111803 :           if (as_ptr->ovl_op_code != ix)
     213                 :             :             {
     214                 :     1010730 :               ovl_op_info_t *dst_ptr = &ovl_op_info[true][as_ptr->ovl_op_code];
     215                 :     1010730 :               gcc_assert (as_ptr->ovl_op_code > ix && !dst_ptr->tree_code);
     216                 :     1010730 :               memcpy (dst_ptr, as_ptr, sizeof (*dst_ptr));
     217                 :     1010730 :               memset (as_ptr, 0, sizeof (*as_ptr));
     218                 :     1010730 :               as_ptr = dst_ptr;
     219                 :             :             }
     220                 :             : 
     221                 :     1111803 :           tree ident = set_operator_ident (as_ptr);
     222                 :     1111803 :           gcc_checking_assert (!IDENTIFIER_CP_INDEX (ident));
     223                 :     1111803 :           IDENTIFIER_CP_INDEX (ident) = as_ptr->ovl_op_code;
     224                 :     1111803 :           set_identifier_kind (ident, cik_assign_op);
     225                 :             : 
     226                 :     1111803 :           gcc_checking_assert (!ovl_op_mapping[as_ptr->tree_code]
     227                 :             :                                || (ovl_op_mapping[as_ptr->tree_code]
     228                 :             :                                    == as_ptr->ovl_op_code));
     229                 :     1111803 :           ovl_op_mapping[as_ptr->tree_code] = as_ptr->ovl_op_code;
     230                 :             :         }
     231                 :             :     }
     232                 :      101073 : }
     233                 :             : 
     234                 :             : /* Initialize the reserved words.  */
     235                 :             : 
     236                 :             : void
     237                 :      101073 : init_reswords (void)
     238                 :             : {
     239                 :      101073 :   unsigned int i;
     240                 :      101073 :   tree id;
     241                 :      101073 :   int mask = 0;
     242                 :             : 
     243                 :      101073 :   if (cxx_dialect < cxx11)
     244                 :       13505 :     mask |= D_CXX11;
     245                 :      101073 :   if (cxx_dialect < cxx20)
     246                 :       76419 :     mask |= D_CXX20;
     247                 :      101073 :   if (!flag_concepts)
     248                 :       76227 :     mask |= D_CXX_CONCEPTS;
     249                 :      101073 :   if (!flag_coroutines)
     250                 :       75525 :     mask |= D_CXX_COROUTINES;
     251                 :      101073 :   if (!flag_modules)
     252                 :       97844 :     mask |= D_CXX_MODULES;
     253                 :      101073 :   if (!flag_tm)
     254                 :      100630 :     mask |= D_TRANSMEM;
     255                 :      101073 :   if (!flag_char8_t)
     256                 :       76355 :     mask |= D_CXX_CHAR8_T;
     257                 :      101073 :   if (flag_no_asm)
     258                 :           4 :     mask |= D_ASM | D_EXT | D_EXT11;
     259                 :      101073 :   if (flag_no_gnu_keywords)
     260                 :       52567 :     mask |= D_EXT | D_EXT11;
     261                 :             : 
     262                 :             :   /* The Objective-C keywords are all context-dependent.  */
     263                 :      101073 :   mask |= D_OBJC;
     264                 :             : 
     265                 :      101073 :   ridpointers = ggc_cleared_vec_alloc<tree> ((int) RID_MAX);
     266                 :    22337133 :   for (i = 0; i < num_c_common_reswords; i++)
     267                 :             :     {
     268                 :    22236060 :       if (c_common_reswords[i].disable & D_CONLY)
     269                 :     4346139 :         continue;
     270                 :    17889921 :       id = get_identifier (c_common_reswords[i].word);
     271                 :    17889921 :       C_SET_RID_CODE (id, c_common_reswords[i].rid);
     272                 :    17889921 :       ridpointers [(int) c_common_reswords[i].rid] = id;
     273                 :    17889921 :       if (! (c_common_reswords[i].disable & mask))
     274                 :    12961540 :         set_identifier_kind (id, cik_keyword);
     275                 :             :     }
     276                 :             : 
     277                 :      202146 :   for (i = 0; i < NUM_INT_N_ENTS; i++)
     278                 :             :     {
     279                 :      101073 :       char name[50];
     280                 :      101073 :       sprintf (name, "__int%d", int_n_data[i].bitsize);
     281                 :      101073 :       id = get_identifier (name);
     282                 :      101073 :       C_SET_RID_CODE (id, RID_FIRST_INT_N + i);
     283                 :      101073 :       set_identifier_kind (id, cik_keyword);
     284                 :             : 
     285                 :      101073 :       sprintf (name, "__int%d__", int_n_data[i].bitsize);
     286                 :      101073 :       id = get_identifier (name);
     287                 :      101073 :       C_SET_RID_CODE (id, RID_FIRST_INT_N + i);
     288                 :      101073 :       set_identifier_kind (id, cik_keyword);
     289                 :             :     }
     290                 :             : 
     291                 :      101073 :   if (flag_openmp)
     292                 :             :     {
     293                 :        3860 :       id = get_identifier ("omp_all_memory");
     294                 :        3860 :       C_SET_RID_CODE (id, RID_OMP_ALL_MEMORY);
     295                 :        3860 :       set_identifier_kind (id, cik_keyword);
     296                 :        3860 :       ridpointers [RID_OMP_ALL_MEMORY] = id;
     297                 :             :     }
     298                 :      101073 : }
     299                 :             : 
     300                 :             : /* Initialize the C++ traits.  */
     301                 :             : static void
     302                 :      101073 : init_cp_traits (void)
     303                 :             : {
     304                 :      101073 :   tree id;
     305                 :             : 
     306                 :     5559015 :   for (unsigned int i = 0; i < ARRAY_SIZE (cp_traits); ++i)
     307                 :             :     {
     308                 :     5457942 :       id = get_identifier (cp_traits[i].name);
     309                 :     5457942 :       IDENTIFIER_CP_INDEX (id) = cp_traits[i].kind;
     310                 :     5457942 :       set_identifier_kind (id, cik_trait);
     311                 :             :     }
     312                 :             : 
     313                 :             :   /* An alias for __is_same.  */
     314                 :      101073 :   id = get_identifier ("__is_same_as");
     315                 :      101073 :   IDENTIFIER_CP_INDEX (id) = CPTK_IS_SAME;
     316                 :      101073 :   set_identifier_kind (id, cik_trait);
     317                 :      101073 : }
     318                 :             : 
     319                 :             : static void
     320                 :       99893 : init_cp_pragma (void)
     321                 :             : {
     322                 :       99893 :   c_register_pragma (0, "vtable", handle_pragma_vtable);
     323                 :       99893 :   c_register_pragma (0, "unit", handle_pragma_unit);
     324                 :       99893 :   c_register_pragma (0, "interface", handle_pragma_interface);
     325                 :       99893 :   c_register_pragma (0, "implementation", handle_pragma_implementation);
     326                 :       99893 :   c_register_pragma ("GCC", "interface", handle_pragma_interface);
     327                 :       99893 :   c_register_pragma ("GCC", "implementation", handle_pragma_implementation);
     328                 :       99893 : }
     329                 :             : 
     330                 :             : /* TRUE if a code represents a statement.  */
     331                 :             : 
     332                 :             : bool statement_code_p[MAX_TREE_CODES];
     333                 :             : 
     334                 :             : /* Initialize the C++ front end.  This function is very sensitive to
     335                 :             :    the exact order that things are done here.  It would be nice if the
     336                 :             :    initialization done by this routine were moved to its subroutines,
     337                 :             :    and the ordering dependencies clarified and reduced.  */
     338                 :             : bool
     339                 :      101073 : cxx_init (void)
     340                 :             : {
     341                 :      101073 :   location_t saved_loc;
     342                 :      101073 :   unsigned int i;
     343                 :      101073 :   static const enum tree_code stmt_codes[] = {
     344                 :             :    CTOR_INITIALIZER,    TRY_BLOCK,      HANDLER,
     345                 :             :    EH_SPEC_BLOCK,       USING_STMT,     TAG_DEFN,
     346                 :             :    IF_STMT,             CLEANUP_STMT,   FOR_STMT,
     347                 :             :    RANGE_FOR_STMT,      WHILE_STMT,     DO_STMT,
     348                 :             :    BREAK_STMT,          CONTINUE_STMT,  SWITCH_STMT,
     349                 :             :    EXPR_STMT,           OMP_DEPOBJ
     350                 :             :   };
     351                 :             : 
     352                 :      101073 :   memset (&statement_code_p, 0, sizeof (statement_code_p));
     353                 :     1819314 :   for (i = 0; i < ARRAY_SIZE (stmt_codes); i++)
     354                 :     1718241 :     statement_code_p[stmt_codes[i]] = true;
     355                 :             : 
     356                 :      101073 :   saved_loc = input_location;
     357                 :      101073 :   input_location = BUILTINS_LOCATION;
     358                 :             : 
     359                 :      101073 :   init_reswords ();
     360                 :      101073 :   init_cp_traits ();
     361                 :      101073 :   init_tree ();
     362                 :      101073 :   init_cp_semantics ();
     363                 :      101073 :   init_operators ();
     364                 :      101073 :   init_method ();
     365                 :             : 
     366                 :      101073 :   current_function_decl = NULL;
     367                 :             : 
     368                 :      101073 :   class_type_node = ridpointers[(int) RID_CLASS];
     369                 :             : 
     370                 :      101073 :   cxx_init_decl_processing ();
     371                 :             : 
     372                 :      101073 :   if (c_common_init () == false)
     373                 :             :     {
     374                 :        1150 :       input_location = saved_loc;
     375                 :        1150 :       return false;
     376                 :             :     }
     377                 :             : 
     378                 :       99893 :   init_cp_pragma ();
     379                 :             : 
     380                 :       99893 :   input_location = saved_loc;
     381                 :       99893 :   return true;
     382                 :             : }
     383                 :             : 
     384                 :             : /* Return nonzero if S is not considered part of an
     385                 :             :    INTERFACE/IMPLEMENTATION pair.  Otherwise, return 0.  */
     386                 :             : 
     387                 :             : static int
     388                 :         101 : interface_strcmp (const char* s)
     389                 :             : {
     390                 :             :   /* Set the interface/implementation bits for this scope.  */
     391                 :         101 :   struct impl_files *ifiles;
     392                 :         101 :   const char *s1;
     393                 :             : 
     394                 :         117 :   for (ifiles = impl_file_chain; ifiles; ifiles = ifiles->next)
     395                 :             :     {
     396                 :          62 :       const char *t1 = ifiles->filename;
     397                 :          62 :       s1 = s;
     398                 :             : 
     399                 :          62 :       if (*s1 == 0 || filename_ncmp (s1, t1, 1) != 0)
     400                 :           8 :         continue;
     401                 :             : 
     402                 :         590 :       while (*s1 != 0 && filename_ncmp (s1, t1, 1) == 0)
     403                 :         536 :         s1++, t1++;
     404                 :             : 
     405                 :             :       /* A match.  */
     406                 :          54 :       if (*s1 == *t1)
     407                 :             :         return 0;
     408                 :             : 
     409                 :             :       /* Don't get faked out by xxx.yyy.cc vs xxx.zzz.cc.  */
     410                 :          24 :       if (strchr (s1, '.') || strchr (t1, '.'))
     411                 :           8 :         continue;
     412                 :             : 
     413                 :          16 :       if (*s1 == '\0' || s1[-1] != '.' || t1[-1] != '.')
     414                 :           0 :         continue;
     415                 :             : 
     416                 :             :       /* A match.  */
     417                 :             :       return 0;
     418                 :             :     }
     419                 :             : 
     420                 :             :   /* No matches.  */
     421                 :             :   return 1;
     422                 :             : }
     423                 :             : 
     424                 :             : /* We've just read a cpp-token, figure out our next state.  Hey, this
     425                 :             :    is a hand-coded co-routine!  */
     426                 :             : 
     427                 :             : struct module_token_filter
     428                 :             : {
     429                 :             :   enum state
     430                 :             :   {
     431                 :             :    idle,
     432                 :             :    module_first,
     433                 :             :    module_cont,
     434                 :             :    module_end,
     435                 :             :   };
     436                 :             : 
     437                 :             :   enum state state : 8;
     438                 :             :   bool is_import : 1;
     439                 :             :   bool got_export : 1;
     440                 :             :   bool got_colon : 1;
     441                 :             :   bool want_dot : 1;
     442                 :             : 
     443                 :             :   location_t token_loc;
     444                 :             :   cpp_reader *reader;
     445                 :             :   module_state *module;
     446                 :             :   module_state *import;
     447                 :             : 
     448                 :        3229 :   module_token_filter (cpp_reader *reader)
     449                 :        3229 :     : state (idle), is_import (false),
     450                 :        3229 :     got_export (false), got_colon (false), want_dot (false),
     451                 :        3229 :     token_loc (UNKNOWN_LOCATION),
     452                 :        3229 :     reader (reader), module (NULL), import (NULL)
     453                 :             :   {
     454                 :             :   };
     455                 :             : 
     456                 :             :   /* Process the next token.  Note we cannot see CPP_EOF inside a
     457                 :             :      pragma -- a CPP_PRAGMA_EOL always happens.  */
     458                 :    37108102 :   uintptr_t resume (int type, int keyword, tree value, location_t loc)
     459                 :             :   {
     460                 :    37108102 :     unsigned res = 0;
     461                 :             : 
     462                 :    37108102 :     switch (state)
     463                 :             :       {
     464                 :    37096971 :       case idle:
     465                 :    37096971 :         if (type == CPP_KEYWORD)
     466                 :     6342781 :           switch (keyword)
     467                 :             :             {
     468                 :             :             default:
     469                 :             :               break;
     470                 :             : 
     471                 :        1358 :             case RID__EXPORT:
     472                 :        1358 :               got_export = true;
     473                 :        1358 :               res = lang_hooks::PT_begin_pragma;
     474                 :        1358 :               break;
     475                 :             : 
     476                 :        1784 :             case RID__IMPORT:
     477                 :        1784 :               is_import = true;
     478                 :             :               /* FALLTHRU */
     479                 :        3459 :             case RID__MODULE:
     480                 :        3459 :               state = module_first;
     481                 :        3459 :               want_dot = false;
     482                 :        3459 :               got_colon = false;
     483                 :        3459 :               token_loc = loc;
     484                 :        3459 :               import = NULL;
     485                 :        3459 :               if (!got_export)
     486                 :        3459 :                 res = lang_hooks::PT_begin_pragma;
     487                 :             :               break;
     488                 :             :             }
     489                 :             :         break;
     490                 :             : 
     491                 :        3474 :       case module_first:
     492                 :        3474 :         if (is_import && type == CPP_HEADER_NAME)
     493                 :             :           {
     494                 :             :             /* A header name.  The preprocessor will have already
     495                 :             :                done include searching and canonicalization.  */
     496                 :         722 :             state = module_end;
     497                 :         722 :             goto header_unit;
     498                 :             :           }
     499                 :             :         
     500                 :        2752 :         if (type == CPP_PADDING || type == CPP_COMMENT)
     501                 :             :           break;
     502                 :             : 
     503                 :        2737 :         state = module_cont;
     504                 :        2737 :         if (type == CPP_COLON && module)
     505                 :             :           {
     506                 :         132 :             got_colon = true;
     507                 :         132 :             import = module;
     508                 :         132 :             break;
     509                 :             :           }
     510                 :             :         /* FALLTHROUGH  */
     511                 :             : 
     512                 :        5881 :       case module_cont:
     513                 :        5881 :         switch (type)
     514                 :             :           {
     515                 :             :           case CPP_PADDING:
     516                 :             :           case CPP_COMMENT:
     517                 :             :             break;
     518                 :             : 
     519                 :        2725 :           default:
     520                 :             :             /* If we ever need to pay attention to attributes for
     521                 :             :                header modules, more logic will be needed.  */
     522                 :        2725 :             state = module_end;
     523                 :        2725 :             break;
     524                 :             : 
     525                 :         135 :           case CPP_COLON:
     526                 :         135 :             if (got_colon)
     527                 :           0 :               state = module_end;
     528                 :         135 :             got_colon = true;
     529                 :             :             /* FALLTHROUGH  */
     530                 :         329 :           case CPP_DOT:
     531                 :         329 :             if (!want_dot)
     532                 :           9 :               state = module_end;
     533                 :         329 :             want_dot = false;
     534                 :         329 :             break;
     535                 :             : 
     536                 :           3 :           case CPP_PRAGMA_EOL:
     537                 :           3 :             goto module_end;
     538                 :             : 
     539                 :        2824 :           case CPP_NAME:
     540                 :        2824 :             if (want_dot)
     541                 :             :               {
     542                 :             :                 /* Got name instead of [.:].  */
     543                 :           0 :                 state = module_end;
     544                 :           0 :                 break;
     545                 :             :               }
     546                 :        2824 :           header_unit:
     547                 :        3546 :             import = get_module (value, import, got_colon);
     548                 :        3546 :             want_dot = true;
     549                 :        3546 :             break;
     550                 :             :           }
     551                 :             :         break;
     552                 :             : 
     553                 :        4381 :       case module_end:
     554                 :        4381 :         if (type == CPP_PRAGMA_EOL)
     555                 :             :           {
     556                 :        3456 :           module_end:;
     557                 :             :             /* End of the directive, handle the name.  */
     558                 :        3459 :             if (import && (is_import || !flag_header_unit))
     559                 :        6470 :               if (module_state *m
     560                 :        3235 :                   = preprocess_module (import, token_loc, module != NULL,
     561                 :        3235 :                                        is_import, got_export, reader))
     562                 :        1442 :                 if (!module)
     563                 :        1427 :                   module = m;
     564                 :             : 
     565                 :        3459 :             is_import = got_export = false;
     566                 :        3459 :             state = idle;
     567                 :             :           }
     568                 :             :         break;
     569                 :             :       }
     570                 :             : 
     571                 :    37108102 :     return res;
     572                 :             :   }
     573                 :             : };
     574                 :             : 
     575                 :             : /* Initialize or teardown.  */
     576                 :             : 
     577                 :             : uintptr_t
     578                 :        7577 : module_token_cdtor (cpp_reader *pfile, uintptr_t data_)
     579                 :             : {
     580                 :        7577 :   if (module_token_filter *filter = reinterpret_cast<module_token_filter *> (data_))
     581                 :             :     {
     582                 :        3229 :       preprocessed_module (pfile);
     583                 :        3229 :       delete filter;
     584                 :        3229 :       data_ = 0;
     585                 :             :     }
     586                 :        4348 :   else if (modules_p ())
     587                 :        3229 :     data_ = reinterpret_cast<uintptr_t > (new module_token_filter (pfile));
     588                 :             : 
     589                 :        7577 :   return data_;
     590                 :             : }
     591                 :             : 
     592                 :             : uintptr_t
     593                 :    37108102 : module_token_lang (int type, int keyword, tree value, location_t loc,
     594                 :             :                    uintptr_t data_)
     595                 :             : {
     596                 :    37108102 :   module_token_filter *filter = reinterpret_cast<module_token_filter *> (data_);
     597                 :    37108102 :   return filter->resume (type, keyword, value, loc);
     598                 :             : }
     599                 :             : 
     600                 :             : uintptr_t
     601                 :      736612 : module_token_pre (cpp_reader *pfile, const cpp_token *tok, uintptr_t data_)
     602                 :             : {
     603                 :      736612 :   if (!tok)
     604                 :        1233 :     return module_token_cdtor (pfile, data_);
     605                 :             : 
     606                 :      735379 :   int type = tok->type;
     607                 :      735379 :   int keyword = RID_MAX;
     608                 :      735379 :   tree value = NULL_TREE;
     609                 :             : 
     610                 :      735379 :   if (tok->type == CPP_NAME)
     611                 :             :     {
     612                 :      319955 :       value = HT_IDENT_TO_GCC_IDENT (HT_NODE (tok->val.node.node));
     613                 :      319955 :       if (IDENTIFIER_KEYWORD_P (value))
     614                 :             :         {
     615                 :      122567 :           keyword = C_RID_CODE (value);
     616                 :      122567 :           type = CPP_KEYWORD;
     617                 :             :         }
     618                 :             :     }
     619                 :      415424 :   else if (tok->type == CPP_HEADER_NAME)
     620                 :          36 :     value = build_string (tok->val.str.len, (const char *)tok->val.str.text);
     621                 :             : 
     622                 :      735379 :   return module_token_lang (type, keyword, value, tok->src_loc, data_);
     623                 :             : }
     624                 :             : 
     625                 :             : /* Parse a #pragma whose sole argument is a string constant.
     626                 :             :    If OPT is true, the argument is optional.  */
     627                 :             : static tree
     628                 :         155 : parse_strconst_pragma (const char* name, int opt)
     629                 :             : {
     630                 :         155 :   tree result, x;
     631                 :         155 :   enum cpp_ttype t;
     632                 :             : 
     633                 :         155 :   t = pragma_lex (&result);
     634                 :         155 :   if (t == CPP_STRING)
     635                 :             :     {
     636                 :          64 :       if (pragma_lex (&x) != CPP_EOF)
     637                 :           0 :         warning (0, "junk at end of %<#pragma %s%>", name);
     638                 :          64 :       return result;
     639                 :             :     }
     640                 :             : 
     641                 :          91 :   if (t == CPP_EOF && opt)
     642                 :             :     return NULL_TREE;
     643                 :             : 
     644                 :           0 :   error ("invalid %<#pragma %s%>", name);
     645                 :           0 :   return error_mark_node;
     646                 :             : }
     647                 :             : 
     648                 :             : static void
     649                 :           0 : handle_pragma_vtable (cpp_reader* /*dfile*/)
     650                 :             : {
     651                 :           0 :   parse_strconst_pragma ("vtable", 0);
     652                 :           0 :   sorry ("%<#pragma vtable%> no longer supported");
     653                 :           0 : }
     654                 :             : 
     655                 :             : static void
     656                 :           0 : handle_pragma_unit (cpp_reader* /*dfile*/)
     657                 :             : {
     658                 :             :   /* Validate syntax, but don't do anything.  */
     659                 :           0 :   parse_strconst_pragma ("unit", 0);
     660                 :           0 : }
     661                 :             : 
     662                 :             : static void
     663                 :         101 : handle_pragma_interface (cpp_reader* /*dfile*/)
     664                 :             : {
     665                 :         101 :   tree fname = parse_strconst_pragma ("interface", 1);
     666                 :         101 :   struct c_fileinfo *finfo;
     667                 :         101 :   const char *filename;
     668                 :             : 
     669                 :         101 :   if (fname == error_mark_node)
     670                 :             :     return;
     671                 :         101 :   else if (fname == 0)
     672                 :          77 :     filename = lbasename (LOCATION_FILE (input_location));
     673                 :             :   else
     674                 :          24 :     filename = TREE_STRING_POINTER (fname);
     675                 :             : 
     676                 :         101 :   finfo = get_fileinfo (LOCATION_FILE (input_location));
     677                 :             : 
     678                 :         101 :   if (impl_file_chain == 0)
     679                 :             :     {
     680                 :             :       /* If this is zero at this point, then we are
     681                 :             :          auto-implementing.  */
     682                 :          43 :       if (main_input_filename == 0)
     683                 :           0 :         main_input_filename = LOCATION_FILE (input_location);
     684                 :             :     }
     685                 :             : 
     686                 :         101 :   finfo->interface_only = interface_strcmp (filename);
     687                 :             :   /* If MULTIPLE_SYMBOL_SPACES is set, we cannot assume that we can see
     688                 :             :      a definition in another file.  */
     689                 :         101 :   if (!MULTIPLE_SYMBOL_SPACES || !finfo->interface_only)
     690                 :         101 :     finfo->interface_unknown = 0;
     691                 :             : }
     692                 :             : 
     693                 :             : /* Note that we have seen a #pragma implementation for the key MAIN_FILENAME.
     694                 :             :    We used to only allow this at toplevel, but that restriction was buggy
     695                 :             :    in older compilers and it seems reasonable to allow it in the headers
     696                 :             :    themselves, too.  It only needs to precede the matching #p interface.
     697                 :             : 
     698                 :             :    We don't touch finfo->interface_only or finfo->interface_unknown;
     699                 :             :    the user must specify a matching #p interface for this to have
     700                 :             :    any effect.  */
     701                 :             : 
     702                 :             : static void
     703                 :          54 : handle_pragma_implementation (cpp_reader* /*dfile*/)
     704                 :             : {
     705                 :          54 :   tree fname = parse_strconst_pragma ("implementation", 1);
     706                 :          54 :   const char *filename;
     707                 :          54 :   struct impl_files *ifiles = impl_file_chain;
     708                 :             : 
     709                 :          54 :   if (fname == error_mark_node)
     710                 :             :     return;
     711                 :             : 
     712                 :          54 :   if (fname == 0)
     713                 :             :     {
     714                 :          14 :       if (main_input_filename)
     715                 :             :         filename = main_input_filename;
     716                 :             :       else
     717                 :           0 :         filename = LOCATION_FILE (input_location);
     718                 :          14 :       filename = lbasename (filename);
     719                 :             :     }
     720                 :             :   else
     721                 :             :     {
     722                 :          40 :       filename = TREE_STRING_POINTER (fname);
     723                 :          40 :       if (cpp_included_before (parse_in, filename, input_location))
     724                 :           4 :         warning (0, "%<#pragma implementation%> for %qs appears after "
     725                 :             :                  "file is included", filename);
     726                 :             :     }
     727                 :             : 
     728                 :          58 :   for (; ifiles; ifiles = ifiles->next)
     729                 :             :     {
     730                 :           4 :       if (! filename_cmp (ifiles->filename, filename))
     731                 :             :         break;
     732                 :             :     }
     733                 :          54 :   if (ifiles == 0)
     734                 :             :     {
     735                 :          54 :       ifiles = XNEW (struct impl_files);
     736                 :          54 :       ifiles->filename = xstrdup (filename);
     737                 :          54 :       ifiles->next = impl_file_chain;
     738                 :          54 :       impl_file_chain = ifiles;
     739                 :             :     }
     740                 :             : }
     741                 :             : 
     742                 :             : /* Issue an error message indicating that the lookup of NAME (an
     743                 :             :    IDENTIFIER_NODE) failed.  Returns the ERROR_MARK_NODE.  */
     744                 :             : 
     745                 :             : tree
     746                 :        2035 : unqualified_name_lookup_error (tree name, location_t loc)
     747                 :             : {
     748                 :        2035 :   if (loc == UNKNOWN_LOCATION)
     749                 :        1496 :     loc = cp_expr_loc_or_input_loc (name);
     750                 :             : 
     751                 :        2035 :   if (IDENTIFIER_ANY_OP_P (name))
     752                 :          12 :     error_at (loc, "%qD not defined", name);
     753                 :             :   else
     754                 :             :     {
     755                 :        2023 :       if (!objc_diagnose_private_ivar (name))
     756                 :             :         {
     757                 :        2023 :           auto_diagnostic_group d;
     758                 :        2023 :           name_hint hint = suggest_alternatives_for (loc, name, true);
     759                 :        2023 :           if (const char *suggestion = hint.suggestion ())
     760                 :             :             {
     761                 :         292 :               gcc_rich_location richloc (loc);
     762                 :         292 :               richloc.add_fixit_replace (suggestion);
     763                 :         292 :               error_at (&richloc,
     764                 :             :                         "%qD was not declared in this scope; did you mean %qs?",
     765                 :             :                         name, suggestion);
     766                 :         292 :             }
     767                 :             :           else
     768                 :        1731 :             error_at (loc, "%qD was not declared in this scope", name);
     769                 :        2023 :         }
     770                 :             :       /* Prevent repeated error messages by creating a VAR_DECL with
     771                 :             :          this NAME in the innermost block scope.  */
     772                 :        2023 :       if (local_bindings_p ())
     773                 :             :         {
     774                 :        1621 :           tree decl = build_decl (loc, VAR_DECL, name, error_mark_node);
     775                 :        1621 :           TREE_USED (decl) = true;
     776                 :        1621 :           pushdecl (decl);
     777                 :             :         }
     778                 :             :     }
     779                 :             : 
     780                 :        2035 :   return error_mark_node;
     781                 :             : }
     782                 :             : 
     783                 :             : /* Like unqualified_name_lookup_error, but NAME_EXPR is an unqualified-id
     784                 :             :    NAME, encapsulated with its location in a CP_EXPR, used as a function.
     785                 :             :    Returns an appropriate expression for NAME.  */
     786                 :             : 
     787                 :             : tree
     788                 :         615 : unqualified_fn_lookup_error (cp_expr name_expr)
     789                 :             : {
     790                 :         615 :   tree name = name_expr.get_value ();
     791                 :         615 :   location_t loc = name_expr.get_location ();
     792                 :         615 :   if (loc == UNKNOWN_LOCATION)
     793                 :          52 :     loc = input_location;
     794                 :             : 
     795                 :         615 :   if (TREE_CODE (name) == TEMPLATE_ID_EXPR)
     796                 :           1 :     name = TREE_OPERAND (name, 0);
     797                 :             : 
     798                 :         615 :   if (processing_template_decl)
     799                 :             :     {
     800                 :             :       /* In a template, it is invalid to write "f()" or "f(3)" if no
     801                 :             :          declaration of "f" is available.  Historically, G++ and most
     802                 :             :          other compilers accepted that usage since they deferred all name
     803                 :             :          lookup until instantiation time rather than doing unqualified
     804                 :             :          name lookup at template definition time; explain to the user what
     805                 :             :          is going wrong.
     806                 :             : 
     807                 :             :          Note that we have the exact wording of the following message in
     808                 :             :          the manual (trouble.texi, node "Name lookup"), so they need to
     809                 :             :          be kept in synch.  */
     810                 :          76 :       permerror (loc, "there are no arguments to %qD that depend on a template "
     811                 :             :                  "parameter, so a declaration of %qD must be available",
     812                 :             :                  name, name);
     813                 :             : 
     814                 :          76 :       if (!flag_permissive)
     815                 :             :         {
     816                 :          54 :           static bool hint;
     817                 :          54 :           if (!hint)
     818                 :             :             {
     819                 :          44 :               inform (loc, "(if you use %<-fpermissive%>, G++ will accept your "
     820                 :             :                       "code, but allowing the use of an undeclared name is "
     821                 :             :                       "deprecated)");
     822                 :          44 :               hint = true;
     823                 :             :             }
     824                 :             :         }
     825                 :          76 :       return name;
     826                 :             :     }
     827                 :             : 
     828                 :         539 :   return unqualified_name_lookup_error (name, loc);
     829                 :             : }
     830                 :             : 
     831                 :             : 
     832                 :             : /* Hasher for the conversion operator name hash table.  */
     833                 :             : struct conv_type_hasher : ggc_ptr_hash<tree_node>
     834                 :             : {
     835                 :             :   /* Hash NODE, an identifier node in the table.  TYPE_UID is
     836                 :             :      suitable, as we're not concerned about matching canonicalness
     837                 :             :      here.  */
     838                 :    10218744 :   static hashval_t hash (tree node)
     839                 :             :   {
     840                 :    10218744 :     return (hashval_t) TYPE_UID (TREE_TYPE (node));
     841                 :             :   }
     842                 :             : 
     843                 :             :   /* Compare NODE, an identifier node in the table, against TYPE, an
     844                 :             :      incoming TYPE being looked up.  */
     845                 :    12151280 :   static bool equal (tree node, tree type)
     846                 :             :   {
     847                 :    12151280 :     return TREE_TYPE (node) == type;
     848                 :             :   }
     849                 :             : };
     850                 :             : 
     851                 :             : /* This hash table maps TYPEs to the IDENTIFIER for a conversion
     852                 :             :    operator to TYPE.  The nodes are IDENTIFIERs whose TREE_TYPE is the
     853                 :             :    TYPE.  */
     854                 :             : 
     855                 :             : static GTY (()) hash_table<conv_type_hasher> *conv_type_names;
     856                 :             : 
     857                 :             : /* Return an identifier for a conversion operator to TYPE.  We can get
     858                 :             :    from the returned identifier to the type.  We store TYPE, which is
     859                 :             :    not necessarily the canonical type,  which allows us to report the
     860                 :             :    form the user used in error messages.  All these identifiers are
     861                 :             :    not in the identifier hash table, and have the same string name.
     862                 :             :    These IDENTIFIERS are not in the identifier hash table, and all
     863                 :             :    have the same IDENTIFIER_STRING.  */
     864                 :             : 
     865                 :             : tree
     866                 :     2049865 : make_conv_op_name (tree type)
     867                 :             : {
     868                 :     2049865 :   if (type == error_mark_node)
     869                 :             :     return error_mark_node;
     870                 :             : 
     871                 :     2049861 :   if (conv_type_names == NULL)
     872                 :       17771 :     conv_type_names = hash_table<conv_type_hasher>::create_ggc (31);
     873                 :             : 
     874                 :     2049861 :   tree *slot = conv_type_names->find_slot_with_hash
     875                 :     2049861 :     (type, (hashval_t) TYPE_UID (type), INSERT);
     876                 :     2049861 :   tree identifier = *slot;
     877                 :     2049861 :   if (!identifier)
     878                 :             :     {
     879                 :             :       /* Create a raw IDENTIFIER outside of the identifier hash
     880                 :             :          table.  */
     881                 :      837727 :       identifier = copy_node (conv_op_identifier);
     882                 :             : 
     883                 :             :       /* Just in case something managed to bind.  */
     884                 :      837727 :       IDENTIFIER_BINDING (identifier) = NULL;
     885                 :             : 
     886                 :             :       /* Hang TYPE off the identifier so it can be found easily later
     887                 :             :          when performing conversions.  */
     888                 :      837727 :       TREE_TYPE (identifier) = type;
     889                 :             : 
     890                 :      837727 :       *slot = identifier;
     891                 :             :     }
     892                 :             : 
     893                 :             :   return identifier;
     894                 :             : }
     895                 :             : 
     896                 :             : /* Wrapper around build_lang_decl_loc(). Should gradually move to
     897                 :             :    build_lang_decl_loc() and then rename build_lang_decl_loc() back to
     898                 :             :    build_lang_decl().  */
     899                 :             : 
     900                 :             : tree
     901                 :   225226489 : build_lang_decl (enum tree_code code, tree name, tree type)
     902                 :             : {
     903                 :   225226489 :   return build_lang_decl_loc (input_location, code, name, type);
     904                 :             : }
     905                 :             : 
     906                 :             : /* Build a decl from CODE, NAME, TYPE declared at LOC, and then add
     907                 :             :    DECL_LANG_SPECIFIC info to the result.  */
     908                 :             : 
     909                 :             : tree
     910                 :   417437826 : build_lang_decl_loc (location_t loc, enum tree_code code, tree name, tree type)
     911                 :             : {
     912                 :   417437826 :   tree t;
     913                 :             : 
     914                 :   417437826 :   t = build_decl (loc, code, name, type);
     915                 :   417437826 :   retrofit_lang_decl (t);
     916                 :             : 
     917                 :   417437826 :   return t;
     918                 :             : }
     919                 :             : 
     920                 :             : /* Maybe add a raw lang_decl to T, a decl.  Return true if it needed
     921                 :             :    one.  */
     922                 :             : 
     923                 :             : bool
     924                 :   906514064 : maybe_add_lang_decl_raw (tree t, bool decomp_p)
     925                 :             : {
     926                 :   906514064 :   size_t size;
     927                 :   906514064 :   lang_decl_selector sel;
     928                 :             : 
     929                 :   906514064 :   if (decomp_p)
     930                 :             :     sel = lds_decomp, size = sizeof (struct lang_decl_decomp);
     931                 :   906344965 :   else if (TREE_CODE (t) == FUNCTION_DECL)
     932                 :             :     sel = lds_fn, size = sizeof (struct lang_decl_fn);
     933                 :             :   else if (TREE_CODE (t) == NAMESPACE_DECL)
     934                 :             :     sel = lds_ns, size = sizeof (struct lang_decl_ns);
     935                 :             :   else if (TREE_CODE (t) == PARM_DECL)
     936                 :             :     sel = lds_parm, size = sizeof (struct lang_decl_parm);
     937                 :             :   else if (LANG_DECL_HAS_MIN (t))
     938                 :             :     sel = lds_min, size = sizeof (struct lang_decl_min);
     939                 :             :   else
     940                 :             :     return false;
     941                 :             : 
     942                 :   906514064 :   struct lang_decl *ld
     943                 :   906514064 :     = (struct lang_decl *) ggc_internal_cleared_alloc (size);
     944                 :             : 
     945                 :   906514064 :   ld->u.base.selector = sel;
     946                 :   906514064 :   DECL_LANG_SPECIFIC (t) = ld;
     947                 :             : 
     948                 :   906514064 :   if (sel == lds_ns)
     949                 :             :     /* Who'd create a namespace, only to put nothing in it?  */
     950                 :      825978 :     ld->u.ns.bindings = hash_table<named_decl_hash>::create_ggc (499);
     951                 :             : 
     952                 :             :   if (GATHER_STATISTICS)
     953                 :             :     {
     954                 :             :       tree_node_counts[(int)lang_decl] += 1;
     955                 :             :       tree_node_sizes[(int)lang_decl] += size;
     956                 :             :     }
     957                 :             :   return true;
     958                 :             : }
     959                 :             : 
     960                 :             : /* T has just had a decl_lang_specific added.  Initialize its
     961                 :             :    linkage.  */
     962                 :             : 
     963                 :             : static void
     964                 :   903413275 : set_decl_linkage (tree t)
     965                 :             : {
     966                 :   903413275 :   if (current_lang_name == lang_name_cplusplus
     967                 :   903413275 :       || decl_linkage (t) == lk_none)
     968                 :   612826757 :     SET_DECL_LANGUAGE (t, lang_cplusplus);
     969                 :   290586518 :   else if (current_lang_name == lang_name_c)
     970                 :   290586518 :     SET_DECL_LANGUAGE (t, lang_c);
     971                 :             :   else
     972                 :           0 :     gcc_unreachable ();
     973                 :   903413275 : }
     974                 :             : 
     975                 :             : /* T is a VAR_DECL node that needs to be a decomposition of BASE.  */
     976                 :             : 
     977                 :             : void
     978                 :      324934 : fit_decomposition_lang_decl (tree t, tree base)
     979                 :             : {
     980                 :      324934 :   if (struct lang_decl *orig_ld = DECL_LANG_SPECIFIC (t))
     981                 :             :     {
     982                 :      158085 :       if (orig_ld->u.base.selector == lds_min)
     983                 :             :         {
     984                 :         839 :           maybe_add_lang_decl_raw (t, true);
     985                 :         839 :           memcpy (DECL_LANG_SPECIFIC (t), orig_ld,
     986                 :             :                   sizeof (struct lang_decl_min));
     987                 :             :           /* Reset selector, which will have been bashed by the
     988                 :             :              memcpy.  */
     989                 :         839 :           DECL_LANG_SPECIFIC (t)->u.base.selector = lds_decomp;
     990                 :             :         }
     991                 :             :       else
     992                 :      157246 :         gcc_checking_assert (orig_ld->u.base.selector == lds_decomp);
     993                 :             :     }
     994                 :             :   else
     995                 :             :     {
     996                 :      166849 :       maybe_add_lang_decl_raw (t, true);
     997                 :      166849 :       set_decl_linkage (t);
     998                 :             :     }
     999                 :             : 
    1000                 :      324934 :   DECL_DECOMP_BASE (t) = base;
    1001                 :      324934 : }
    1002                 :             : 
    1003                 :             : /* Add DECL_LANG_SPECIFIC info to T, if it needs one.  Generally
    1004                 :             :    every C++ decl needs one, but C builtins etc do not.   */
    1005                 :             : 
    1006                 :             : void
    1007                 :  1098083681 : retrofit_lang_decl (tree t)
    1008                 :             : {
    1009                 :  1098083681 :   if (DECL_LANG_SPECIFIC (t))
    1010                 :             :     return;
    1011                 :             : 
    1012                 :   903246426 :   if (maybe_add_lang_decl_raw (t, false))
    1013                 :   903246426 :     set_decl_linkage (t);
    1014                 :             : }
    1015                 :             : 
    1016                 :             : void
    1017                 :   651913818 : cxx_dup_lang_specific_decl (tree node)
    1018                 :             : {
    1019                 :   651913818 :   int size;
    1020                 :             : 
    1021                 :   651913818 :   if (! DECL_LANG_SPECIFIC (node))
    1022                 :             :     return;
    1023                 :             : 
    1024                 :   485828690 :   switch (DECL_LANG_SPECIFIC (node)->u.base.selector)
    1025                 :             :     {
    1026                 :             :     case lds_min:
    1027                 :             :       size = sizeof (struct lang_decl_min);
    1028                 :             :       break;
    1029                 :             :     case lds_fn:
    1030                 :             :       size = sizeof (struct lang_decl_fn);
    1031                 :             :       break;
    1032                 :             :     case lds_ns:
    1033                 :             :       size = sizeof (struct lang_decl_ns);
    1034                 :             :       break;
    1035                 :             :     case lds_parm:
    1036                 :             :       size = sizeof (struct lang_decl_parm);
    1037                 :             :       break;
    1038                 :             :     case lds_decomp:
    1039                 :             :       size = sizeof (struct lang_decl_decomp);
    1040                 :             :       break;
    1041                 :           0 :     default:
    1042                 :           0 :       gcc_unreachable ();
    1043                 :             :     }
    1044                 :             : 
    1045                 :   485828690 :   struct lang_decl *ld = (struct lang_decl *) ggc_internal_alloc (size);
    1046                 :   485828690 :   memcpy (ld, DECL_LANG_SPECIFIC (node), size);
    1047                 :   485828690 :   DECL_LANG_SPECIFIC (node) = ld;
    1048                 :             : 
    1049                 :             :   /* Directly clear some flags that do not apply to the copy
    1050                 :             :      (module_purview_p still does).  */
    1051                 :   485828690 :   ld->u.base.module_entity_p = false;
    1052                 :   485828690 :   ld->u.base.module_import_p = false;
    1053                 :   485828690 :   ld->u.base.module_keyed_decls_p = false;
    1054                 :             : 
    1055                 :   485828690 :   if (GATHER_STATISTICS)
    1056                 :             :     {
    1057                 :             :       tree_node_counts[(int)lang_decl] += 1;
    1058                 :             :       tree_node_sizes[(int)lang_decl] += size;
    1059                 :             :     }
    1060                 :             : }
    1061                 :             : 
    1062                 :             : /* Copy DECL, including any language-specific parts.  */
    1063                 :             : 
    1064                 :             : tree
    1065                 :   389736412 : copy_decl (tree decl MEM_STAT_DECL)
    1066                 :             : {
    1067                 :   389736412 :   tree copy;
    1068                 :             : 
    1069                 :   389736412 :   copy = copy_node (decl PASS_MEM_STAT);
    1070                 :   389736412 :   cxx_dup_lang_specific_decl (copy);
    1071                 :   389736412 :   return copy;
    1072                 :             : }
    1073                 :             : 
    1074                 :             : /* Replace the shared language-specific parts of NODE with a new copy.  */
    1075                 :             : 
    1076                 :             : static void
    1077                 :    11547006 : copy_lang_type (tree node)
    1078                 :             : {
    1079                 :    11547006 :   if (! TYPE_LANG_SPECIFIC (node))
    1080                 :             :     return;
    1081                 :             : 
    1082                 :           0 :   auto *lt = (struct lang_type *) ggc_internal_alloc (sizeof (struct lang_type));
    1083                 :             : 
    1084                 :           0 :   memcpy (lt, TYPE_LANG_SPECIFIC (node), (sizeof (struct lang_type)));
    1085                 :           0 :   TYPE_LANG_SPECIFIC (node) = lt;
    1086                 :             : 
    1087                 :           0 :   if (GATHER_STATISTICS)
    1088                 :             :     {
    1089                 :             :       tree_node_counts[(int)lang_type] += 1;
    1090                 :             :       tree_node_sizes[(int)lang_type] += sizeof (struct lang_type);
    1091                 :             :     }
    1092                 :             : }
    1093                 :             : 
    1094                 :             : /* Copy TYPE, including any language-specific parts.  */
    1095                 :             : 
    1096                 :             : tree
    1097                 :    11547006 : copy_type (tree type MEM_STAT_DECL)
    1098                 :             : {
    1099                 :    11547006 :   tree copy;
    1100                 :             : 
    1101                 :    11547006 :   copy = copy_node (type PASS_MEM_STAT);
    1102                 :    11547006 :   copy_lang_type (copy);
    1103                 :    11547006 :   return copy;
    1104                 :             : }
    1105                 :             : 
    1106                 :             : /* Add a raw lang_type to T, a type, should it need one.  */
    1107                 :             : 
    1108                 :             : bool
    1109                 :   619450289 : maybe_add_lang_type_raw (tree t)
    1110                 :             : {
    1111                 :   619450289 :   if (!RECORD_OR_UNION_CODE_P (TREE_CODE (t)))
    1112                 :             :     return false;
    1113                 :             :   
    1114                 :   103256801 :   auto *lt = (struct lang_type *) (ggc_internal_cleared_alloc
    1115                 :   103256801 :                                    (sizeof (struct lang_type)));
    1116                 :   103256801 :   TYPE_LANG_SPECIFIC (t) = lt;
    1117                 :             : 
    1118                 :   103256801 :   if (GATHER_STATISTICS)
    1119                 :             :     {
    1120                 :             :       tree_node_counts[(int)lang_type] += 1;
    1121                 :             :       tree_node_sizes[(int)lang_type] += sizeof (struct lang_type);
    1122                 :             :     }
    1123                 :             : 
    1124                 :   103256801 :   return true;
    1125                 :             : }
    1126                 :             : 
    1127                 :             : tree
    1128                 :   619211836 : cxx_make_type (enum tree_code code MEM_STAT_DECL)
    1129                 :             : {
    1130                 :   619211836 :   tree t = make_node (code PASS_MEM_STAT);
    1131                 :             : 
    1132                 :   619211836 :   if (maybe_add_lang_type_raw (t))
    1133                 :             :     {
    1134                 :             :       /* Set up some flags that give proper default behavior.  */
    1135                 :   103018348 :       struct c_fileinfo *finfo =
    1136                 :   103018348 :         get_fileinfo (LOCATION_FILE (input_location));
    1137                 :   103018348 :       SET_CLASSTYPE_INTERFACE_UNKNOWN_X (t, finfo->interface_unknown);
    1138                 :   103018348 :       CLASSTYPE_INTERFACE_ONLY (t) = finfo->interface_only;
    1139                 :             :     }
    1140                 :             : 
    1141                 :   619211836 :   if (code == RECORD_TYPE || code == UNION_TYPE)
    1142                 :   103018348 :     TYPE_CXX_ODR_P (t) = 1;
    1143                 :             : 
    1144                 :   619211836 :   return t;
    1145                 :             : }
    1146                 :             : 
    1147                 :             : /* A wrapper without the memory stats for LANG_HOOKS_MAKE_TYPE.  */
    1148                 :             : 
    1149                 :             : tree
    1150                 :      134718 : cxx_make_type_hook (enum tree_code code)
    1151                 :             : {
    1152                 :      134718 :   return cxx_make_type (code);
    1153                 :             : }
    1154                 :             : 
    1155                 :             : tree
    1156                 :   102883627 : make_class_type (enum tree_code code MEM_STAT_DECL)
    1157                 :             : {
    1158                 :   102883627 :   tree t = cxx_make_type (code PASS_MEM_STAT);
    1159                 :   102883627 :   SET_CLASS_TYPE_P (t, 1);
    1160                 :   102883627 :   return t;
    1161                 :             : }
    1162                 :             : 
    1163                 :             : /* Returns true if we are currently in the main source file, or in a
    1164                 :             :    template instantiation started from the main source file.  */
    1165                 :             : 
    1166                 :             : bool
    1167                 :         164 : in_main_input_context (void)
    1168                 :             : {
    1169                 :         164 :   struct tinst_level *tl = outermost_tinst_level();
    1170                 :             : 
    1171                 :         164 :   if (tl)
    1172                 :          11 :     return filename_cmp (main_input_filename,
    1173                 :          22 :                          LOCATION_FILE (tl->locus)) == 0;
    1174                 :             :   else
    1175                 :         153 :     return filename_cmp (main_input_filename, LOCATION_FILE (input_location)) == 0;
    1176                 :             : }
    1177                 :             : 
    1178                 :             : #include "gt-cp-lex.h"
        

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.