LCOV - code coverage report
Current view: top level - gcc/c - c-decl.cc (source / functions) Coverage Total Hit
Test: gcc.info Lines: 92.3 % 5979 5516
Test Date: 2024-03-23 14:05:01 Functions: 91.8 % 171 157
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : /* Process declarations and variables for C compiler.
       2                 :             :    Copyright (C) 1988-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                 :             : /* Process declarations and symbol lookup for C front end.
      21                 :             :    Also constructs types; the standard scalar types at initialization,
      22                 :             :    and structure, union, array and enum types when they are declared.  */
      23                 :             : 
      24                 :             : /* ??? not all decl nodes are given the most useful possible
      25                 :             :    line numbers.  For example, the CONST_DECLs for enum values.  */
      26                 :             : 
      27                 :             : #include "config.h"
      28                 :             : #define INCLUDE_STRING
      29                 :             : #define INCLUDE_MEMORY
      30                 :             : #include "system.h"
      31                 :             : #include "coretypes.h"
      32                 :             : #include "target.h"
      33                 :             : #include "function.h"
      34                 :             : #include "c-tree.h"
      35                 :             : #include "timevar.h"
      36                 :             : #include "stringpool.h"
      37                 :             : #include "cgraph.h"
      38                 :             : #include "intl.h"
      39                 :             : #include "print-tree.h"
      40                 :             : #include "stor-layout.h"
      41                 :             : #include "varasm.h"
      42                 :             : #include "attribs.h"
      43                 :             : #include "toplev.h"
      44                 :             : #include "debug.h"
      45                 :             : #include "c-family/c-objc.h"
      46                 :             : #include "c-family/c-pragma.h"
      47                 :             : #include "c-family/c-ubsan.h"
      48                 :             : #include "c-lang.h"
      49                 :             : #include "langhooks.h"
      50                 :             : #include "tree-iterator.h"
      51                 :             : #include "dumpfile.h"
      52                 :             : #include "plugin.h"
      53                 :             : #include "c-family/c-ada-spec.h"
      54                 :             : #include "builtins.h"
      55                 :             : #include "spellcheck-tree.h"
      56                 :             : #include "gcc-rich-location.h"
      57                 :             : #include "asan.h"
      58                 :             : #include "c-family/name-hint.h"
      59                 :             : #include "c-family/known-headers.h"
      60                 :             : #include "c-family/c-spellcheck.h"
      61                 :             : #include "context.h"  /* For 'g'.  */
      62                 :             : #include "omp-general.h"
      63                 :             : #include "omp-offload.h"  /* For offload_vars.  */
      64                 :             : #include "c-parser.h"
      65                 :             : 
      66                 :             : #include "tree-pretty-print.h"
      67                 :             : 
      68                 :             : /* In grokdeclarator, distinguish syntactic contexts of declarators.  */
      69                 :             : enum decl_context
      70                 :             : { NORMAL,                       /* Ordinary declaration */
      71                 :             :   FUNCDEF,                      /* Function definition */
      72                 :             :   PARM,                         /* Declaration of parm before function body */
      73                 :             :   FIELD,                        /* Declaration inside struct or union */
      74                 :             :   TYPENAME};                    /* Typename (inside cast or sizeof)  */
      75                 :             : 
      76                 :             : /* States indicating how grokdeclarator() should handle declspecs marked
      77                 :             :    with __attribute__((deprecated)) or __attribute__((unavailable)).
      78                 :             :    An object declared as __attribute__((unavailable)) should suppress
      79                 :             :    any reports of being declared  with unavailable or deprecated items.
      80                 :             :    An object declared as __attribute__((deprecated)) should suppress
      81                 :             :    warnings of uses of other deprecated items.  */
      82                 :             : 
      83                 :             : enum deprecated_states {
      84                 :             :   DEPRECATED_NORMAL,
      85                 :             :   DEPRECATED_SUPPRESS,
      86                 :             :   UNAVAILABLE_DEPRECATED_SUPPRESS
      87                 :             : };
      88                 :             : 
      89                 :             : 
      90                 :             : /* Nonzero if we have seen an invalid cross reference
      91                 :             :    to a struct, union, or enum, but not yet printed the message.  */
      92                 :             : tree pending_invalid_xref;
      93                 :             : 
      94                 :             : /* File and line to appear in the eventual error message.  */
      95                 :             : location_t pending_invalid_xref_location;
      96                 :             : 
      97                 :             : /* The file and line that the prototype came from if this is an
      98                 :             :    old-style definition; used for diagnostics in
      99                 :             :    store_parm_decls_oldstyle.  */
     100                 :             : 
     101                 :             : static location_t current_function_prototype_locus;
     102                 :             : 
     103                 :             : /* Whether this prototype was built-in.  */
     104                 :             : 
     105                 :             : static bool current_function_prototype_built_in;
     106                 :             : 
     107                 :             : /* The argument type information of this prototype.  */
     108                 :             : 
     109                 :             : static tree current_function_prototype_arg_types;
     110                 :             : 
     111                 :             : /* The argument information structure for the function currently being
     112                 :             :    defined.  */
     113                 :             : 
     114                 :             : static struct c_arg_info *current_function_arg_info;
     115                 :             : 
     116                 :             : /* The obstack on which parser and related data structures, which are
     117                 :             :    not live beyond their top-level declaration or definition, are
     118                 :             :    allocated.  */
     119                 :             : struct obstack parser_obstack;
     120                 :             : 
     121                 :             : /* The current statement tree.  */
     122                 :             : 
     123                 :             : static GTY(()) struct stmt_tree_s c_stmt_tree;
     124                 :             : 
     125                 :             : /* Zero if we are not in an iteration or switch statement, otherwise
     126                 :             :    a bitmask.  See bitmask definitions in c-tree.h.  */
     127                 :             : unsigned char in_statement;
     128                 :             : 
     129                 :             : /* A list of decls to be made automatically visible in each file scope.  */
     130                 :             : static GTY(()) tree visible_builtins;
     131                 :             : 
     132                 :             : /* Set to 0 at beginning of a function definition, set to 1 if
     133                 :             :    a return statement that specifies a return value is seen.  */
     134                 :             : 
     135                 :             : int current_function_returns_value;
     136                 :             : 
     137                 :             : /* Set to 0 at beginning of a function definition, set to 1 if
     138                 :             :    a return statement with no argument is seen.  */
     139                 :             : 
     140                 :             : int current_function_returns_null;
     141                 :             : 
     142                 :             : /* Set to 0 at beginning of a function definition, set to 1 if
     143                 :             :    a call to a noreturn function is seen.  */
     144                 :             : 
     145                 :             : int current_function_returns_abnormally;
     146                 :             : 
     147                 :             : /* Set to nonzero by `grokdeclarator' for a function
     148                 :             :    whose return type is defaulted, if warnings for this are desired.  */
     149                 :             : 
     150                 :             : static int warn_about_return_type;
     151                 :             : 
     152                 :             : /* Nonzero when the current toplevel function contains a declaration
     153                 :             :    of a nested function which is never defined.  */
     154                 :             : 
     155                 :             : static bool undef_nested_function;
     156                 :             : 
     157                 :             : /* Vector of implicit "omp declare target" attributes to be added into
     158                 :             :    the attribute lists.  */
     159                 :             : vec<c_omp_declare_target_attr, va_gc> *current_omp_declare_target_attribute;
     160                 :             : 
     161                 :             : /* Vector of
     162                 :             :    #pragma omp begin assumes ... #pragma omp end assumes regions
     163                 :             :    we are in.  */
     164                 :             : vec<c_omp_begin_assumes_data, va_gc> *current_omp_begin_assumes;
     165                 :             : 
     166                 :             : /* Each c_binding structure describes one binding of an identifier to
     167                 :             :    a decl.  All the decls in a scope - irrespective of namespace - are
     168                 :             :    chained together by the ->prev field, which (as the name implies)
     169                 :             :    runs in reverse order.  All the decls in a given namespace bound to
     170                 :             :    a given identifier are chained by the ->shadowed field, which runs
     171                 :             :    from inner to outer scopes.
     172                 :             : 
     173                 :             :    The ->decl field usually points to a DECL node, but there are two
     174                 :             :    exceptions.  In the namespace of type tags, the bound entity is a
     175                 :             :    RECORD_TYPE, UNION_TYPE, or ENUMERAL_TYPE node.  If an undeclared
     176                 :             :    identifier is encountered, it is bound to error_mark_node to
     177                 :             :    suppress further errors about that identifier in the current
     178                 :             :    function.
     179                 :             : 
     180                 :             :    The ->u.type field stores the type of the declaration in this scope;
     181                 :             :    if NULL, the type is the type of the ->decl field.  This is only of
     182                 :             :    relevance for objects with external or internal linkage which may
     183                 :             :    be redeclared in inner scopes, forming composite types that only
     184                 :             :    persist for the duration of those scopes.  In the external scope,
     185                 :             :    this stores the composite of all the types declared for this
     186                 :             :    object, visible or not.  The ->inner_comp field (used only at file
     187                 :             :    scope) stores whether an incomplete array type at file scope was
     188                 :             :    completed at an inner scope to an array size other than 1.
     189                 :             : 
     190                 :             :    The ->u.label field is used for labels.  It points to a structure
     191                 :             :    which stores additional information used for warnings.
     192                 :             : 
     193                 :             :    The depth field is copied from the scope structure that holds this
     194                 :             :    decl.  It is used to preserve the proper ordering of the ->shadowed
     195                 :             :    field (see bind()) and also for a handful of special-case checks.
     196                 :             :    Finally, the invisible bit is true for a decl which should be
     197                 :             :    ignored for purposes of normal name lookup, and the nested bit is
     198                 :             :    true for a decl that's been bound a second time in an inner scope;
     199                 :             :    in all such cases, the binding in the outer scope will have its
     200                 :             :    invisible bit true.  */
     201                 :             : 
     202                 :             : struct GTY((chain_next ("%h.prev"))) c_binding {
     203                 :             :   union GTY(()) {               /* first so GTY desc can use decl */
     204                 :             :     tree GTY((tag ("0"))) type; /* the type in this scope */
     205                 :             :     struct c_label_vars * GTY((tag ("1"))) label; /* for warnings */
     206                 :             :   } GTY((desc ("TREE_CODE (%0.decl) == LABEL_DECL"))) u;
     207                 :             :   tree decl;                    /* the decl bound */
     208                 :             :   tree id;                      /* the identifier it's bound to */
     209                 :             :   struct c_binding *prev;       /* the previous decl in this scope */
     210                 :             :   struct c_binding *shadowed;   /* the innermost decl shadowed by this one */
     211                 :             :   unsigned int depth : 28;      /* depth of this scope */
     212                 :             :   BOOL_BITFIELD invisible : 1;  /* normal lookup should ignore this binding */
     213                 :             :   BOOL_BITFIELD nested : 1;     /* do not set DECL_CONTEXT when popping */
     214                 :             :   BOOL_BITFIELD inner_comp : 1; /* incomplete array completed in inner scope */
     215                 :             :   BOOL_BITFIELD in_struct : 1;  /* currently defined as struct field */
     216                 :             :   location_t locus;             /* location for nested bindings */
     217                 :             : };
     218                 :             : #define B_IN_SCOPE(b1, b2) ((b1)->depth == (b2)->depth)
     219                 :             : #define B_IN_CURRENT_SCOPE(b) ((b)->depth == current_scope->depth)
     220                 :             : #define B_IN_FILE_SCOPE(b) ((b)->depth == 1 /*file_scope->depth*/)
     221                 :             : #define B_IN_EXTERNAL_SCOPE(b) ((b)->depth == 0 /*external_scope->depth*/)
     222                 :             : 
     223                 :             : /* Each C symbol points to three linked lists of c_binding structures.
     224                 :             :    These describe the values of the identifier in the three different
     225                 :             :    namespaces defined by the language.  */
     226                 :             : 
     227                 :             : struct GTY(()) lang_identifier {
     228                 :             :   struct c_common_identifier common_id;
     229                 :             :   struct c_binding *symbol_binding; /* vars, funcs, constants, typedefs */
     230                 :             :   struct c_binding *tag_binding;    /* struct/union/enum tags */
     231                 :             :   struct c_binding *label_binding;  /* labels */
     232                 :             : };
     233                 :             : 
     234                 :             : /* Validate c-lang.cc's assumptions.  */
     235                 :             : extern char C_SIZEOF_STRUCT_LANG_IDENTIFIER_isnt_accurate
     236                 :             : [(sizeof(struct lang_identifier) == C_SIZEOF_STRUCT_LANG_IDENTIFIER) ? 1 : -1];
     237                 :             : 
     238                 :             : /* The binding oracle; see c-tree.h.  */
     239                 :             : void (*c_binding_oracle) (enum c_oracle_request, tree identifier);
     240                 :             : 
     241                 :             : /* This flag is set on an identifier if we have previously asked the
     242                 :             :    binding oracle for this identifier's symbol binding.  */
     243                 :             : #define I_SYMBOL_CHECKED(node) \
     244                 :             :   (TREE_LANG_FLAG_4 (IDENTIFIER_NODE_CHECK (node)))
     245                 :             : 
     246                 :             : static inline struct c_binding* *
     247                 :  4066569105 : i_symbol_binding (tree node)
     248                 :             : {
     249                 :  4066569105 :   struct lang_identifier *lid
     250                 :  4066569105 :     = (struct lang_identifier *) IDENTIFIER_NODE_CHECK (node);
     251                 :             : 
     252                 :  4066569105 :   if (lid->symbol_binding == NULL
     253                 :  1492032926 :       && c_binding_oracle != NULL
     254                 :  4066569105 :       && !I_SYMBOL_CHECKED (node))
     255                 :             :     {
     256                 :             :       /* Set the "checked" flag first, to avoid infinite recursion
     257                 :             :          when the binding oracle calls back into gcc.  */
     258                 :           0 :       I_SYMBOL_CHECKED (node) = 1;
     259                 :           0 :       c_binding_oracle (C_ORACLE_SYMBOL, node);
     260                 :             :     }
     261                 :             : 
     262                 :  4066569105 :   return &lid->symbol_binding;
     263                 :             : }
     264                 :             : 
     265                 :             : #define I_SYMBOL_BINDING(node) (*i_symbol_binding (node))
     266                 :             : 
     267                 :             : #define I_SYMBOL_DECL(node) \
     268                 :             :  (I_SYMBOL_BINDING(node) ? I_SYMBOL_BINDING(node)->decl : 0)
     269                 :             : 
     270                 :             : /* This flag is set on an identifier if we have previously asked the
     271                 :             :    binding oracle for this identifier's tag binding.  */
     272                 :             : #define I_TAG_CHECKED(node) \
     273                 :             :   (TREE_LANG_FLAG_5 (IDENTIFIER_NODE_CHECK (node)))
     274                 :             : 
     275                 :             : static inline struct c_binding **
     276                 :     3707045 : i_tag_binding (tree node)
     277                 :             : {
     278                 :     3707045 :   struct lang_identifier *lid
     279                 :     3707045 :     = (struct lang_identifier *) IDENTIFIER_NODE_CHECK (node);
     280                 :             : 
     281                 :     3707045 :   if (lid->tag_binding == NULL
     282                 :     1173666 :       && c_binding_oracle != NULL
     283                 :     3707045 :       && !I_TAG_CHECKED (node))
     284                 :             :     {
     285                 :             :       /* Set the "checked" flag first, to avoid infinite recursion
     286                 :             :          when the binding oracle calls back into gcc.  */
     287                 :           0 :       I_TAG_CHECKED (node) = 1;
     288                 :           0 :       c_binding_oracle (C_ORACLE_TAG, node);
     289                 :             :     }
     290                 :             : 
     291                 :     3707045 :   return &lid->tag_binding;
     292                 :             : }
     293                 :             : 
     294                 :             : #define I_TAG_BINDING(node) (*i_tag_binding (node))
     295                 :             : 
     296                 :             : #define I_TAG_DECL(node) \
     297                 :             :  (I_TAG_BINDING(node) ? I_TAG_BINDING(node)->decl : 0)
     298                 :             : 
     299                 :             : /* This flag is set on an identifier if we have previously asked the
     300                 :             :    binding oracle for this identifier's label binding.  */
     301                 :             : #define I_LABEL_CHECKED(node) \
     302                 :             :   (TREE_LANG_FLAG_6 (IDENTIFIER_NODE_CHECK (node)))
     303                 :             : 
     304                 :             : static inline struct c_binding **
     305                 :      350402 : i_label_binding (tree node)
     306                 :             : {
     307                 :      350402 :   struct lang_identifier *lid
     308                 :      350402 :     = (struct lang_identifier *) IDENTIFIER_NODE_CHECK (node);
     309                 :             : 
     310                 :      350402 :   if (lid->label_binding == NULL
     311                 :       45234 :       && c_binding_oracle != NULL
     312                 :      350402 :       && !I_LABEL_CHECKED (node))
     313                 :             :     {
     314                 :             :       /* Set the "checked" flag first, to avoid infinite recursion
     315                 :             :          when the binding oracle calls back into gcc.  */
     316                 :           0 :       I_LABEL_CHECKED (node) = 1;
     317                 :           0 :       c_binding_oracle (C_ORACLE_LABEL, node);
     318                 :             :     }
     319                 :             : 
     320                 :      350402 :   return &lid->label_binding;
     321                 :             : }
     322                 :             : 
     323                 :             : #define I_LABEL_BINDING(node) (*i_label_binding (node))
     324                 :             : 
     325                 :             : #define I_LABEL_DECL(node) \
     326                 :             :  (I_LABEL_BINDING(node) ? I_LABEL_BINDING(node)->decl : 0)
     327                 :             : 
     328                 :             : /* Used by C_TOKEN_VEC tree.  */
     329                 :             : struct GTY (()) c_tree_token_vec {
     330                 :             :   struct tree_base base;
     331                 :             :   vec<c_token, va_gc> *tokens;
     332                 :             : };
     333                 :             : 
     334                 :             : STATIC_ASSERT (sizeof (c_tree_token_vec) == sizeof (c_tree_token_vec_struct));
     335                 :             : STATIC_ASSERT (offsetof (c_tree_token_vec, tokens)
     336                 :             :                == offsetof (c_tree_token_vec_struct, tokens));
     337                 :             : 
     338                 :             : /* The resulting tree type.  */
     339                 :             : 
     340                 :             : union GTY((desc ("TREE_CODE (&%h.generic) == IDENTIFIER_NODE + 2 * (TREE_CODE (&%h.generic) == C_TOKEN_VEC)"),
     341                 :             :        chain_next ("(union lang_tree_node *) c_tree_chain_next (&%h.generic)"))) lang_tree_node
     342                 :             :  {
     343                 :             :   union tree_node GTY ((tag ("0"),
     344                 :             :                         desc ("tree_node_structure (&%h)")))
     345                 :             :     generic;
     346                 :             :   struct lang_identifier GTY ((tag ("1"))) identifier;
     347                 :             :   struct c_tree_token_vec GTY ((tag ("2"))) c_token_vec;
     348                 :             : };
     349                 :             : 
     350                 :             : /* Langhook for tree_size.  */
     351                 :             : size_t
     352                 :         640 : c_tree_size (enum tree_code code)
     353                 :             : {
     354                 :         640 :   gcc_checking_assert (code >= NUM_TREE_CODES);
     355                 :         640 :   switch (code)
     356                 :             :     {
     357                 :             :     case C_TOKEN_VEC: return sizeof (c_tree_token_vec);
     358                 :           0 :     default:
     359                 :           0 :       switch (TREE_CODE_CLASS (code))
     360                 :             :         {
     361                 :             :         case tcc_declaration: return sizeof (tree_decl_non_common);
     362                 :           0 :         case tcc_type: return sizeof (tree_type_non_common);
     363                 :           0 :         default: gcc_unreachable ();
     364                 :             :         }
     365                 :             :     }
     366                 :             : }
     367                 :             : 
     368                 :             : /* Track bindings and other things that matter for goto warnings.  For
     369                 :             :    efficiency, we do not gather all the decls at the point of
     370                 :             :    definition.  Instead, we point into the bindings structure.  As
     371                 :             :    scopes are popped, we update these structures and gather the decls
     372                 :             :    that matter at that time.  */
     373                 :             : 
     374                 :             : struct GTY(()) c_spot_bindings {
     375                 :             :   /* The currently open scope which holds bindings defined when the
     376                 :             :      label was defined or the goto statement was found.  */
     377                 :             :   struct c_scope *scope;
     378                 :             :   /* The bindings in the scope field which were defined at the point
     379                 :             :      of the label or goto.  This lets us look at older or newer
     380                 :             :      bindings in the scope, as appropriate.  */
     381                 :             :   struct c_binding *bindings_in_scope;
     382                 :             :   /* The number of statement expressions that have started since this
     383                 :             :      label or goto statement was defined.  This is zero if we are at
     384                 :             :      the same statement expression level.  It is positive if we are in
     385                 :             :      a statement expression started since this spot.  It is negative
     386                 :             :      if this spot was in a statement expression and we have left
     387                 :             :      it.  */
     388                 :             :   int stmt_exprs;
     389                 :             :   /* Whether we started in a statement expression but are no longer in
     390                 :             :      it.  This is set to true if stmt_exprs ever goes negative.  */
     391                 :             :   bool left_stmt_expr;
     392                 :             : };
     393                 :             : 
     394                 :             : /* This structure is used to keep track of bindings seen when a goto
     395                 :             :    statement is defined.  This is only used if we see the goto
     396                 :             :    statement before we see the label.  */
     397                 :             : 
     398                 :             : struct GTY(()) c_goto_bindings {
     399                 :             :   /* The location of the goto statement.  */
     400                 :             :   location_t loc;
     401                 :             :   /* The bindings of the goto statement.  */
     402                 :             :   struct c_spot_bindings goto_bindings;
     403                 :             : };
     404                 :             : 
     405                 :             : typedef struct c_goto_bindings *c_goto_bindings_p;
     406                 :             : 
     407                 :             : /* The additional information we keep track of for a label binding.
     408                 :             :    These fields are updated as scopes are popped.  */
     409                 :             : 
     410                 :             : struct GTY(()) c_label_vars {
     411                 :             :   /* The shadowed c_label_vars, when one label shadows another (which
     412                 :             :      can only happen using a __label__ declaration).  */
     413                 :             :   struct c_label_vars *shadowed;
     414                 :             :   /* The bindings when the label was defined.  */
     415                 :             :   struct c_spot_bindings label_bindings;
     416                 :             :   /* A list of decls that we care about: decls about which we should
     417                 :             :      warn if a goto branches to this label from later in the function.
     418                 :             :      Decls are added to this list as scopes are popped.  We only add
     419                 :             :      the decls that matter.  */
     420                 :             :   vec<tree, va_gc> *decls_in_scope;
     421                 :             :   /* A list of goto statements to this label.  This is only used for
     422                 :             :      goto statements seen before the label was defined, so that we can
     423                 :             :      issue appropriate warnings for them.  */
     424                 :             :   vec<c_goto_bindings_p, va_gc> *gotos;
     425                 :             : };
     426                 :             : 
     427                 :             : /* Each c_scope structure describes the complete contents of one
     428                 :             :    scope.  Four scopes are distinguished specially: the innermost or
     429                 :             :    current scope, the innermost function scope, the file scope (always
     430                 :             :    the second to outermost) and the outermost or external scope.
     431                 :             : 
     432                 :             :    Most declarations are recorded in the current scope.
     433                 :             : 
     434                 :             :    All normal label declarations are recorded in the innermost
     435                 :             :    function scope, as are bindings of undeclared identifiers to
     436                 :             :    error_mark_node.  (GCC permits nested functions as an extension,
     437                 :             :    hence the 'innermost' qualifier.)  Explicitly declared labels
     438                 :             :    (using the __label__ extension) appear in the current scope.
     439                 :             : 
     440                 :             :    Being in the file scope (current_scope == file_scope) causes
     441                 :             :    special behavior in several places below.  Also, under some
     442                 :             :    conditions the Objective-C front end records declarations in the
     443                 :             :    file scope even though that isn't the current scope.
     444                 :             : 
     445                 :             :    All declarations with external linkage are recorded in the external
     446                 :             :    scope, even if they aren't visible there; this models the fact that
     447                 :             :    such declarations are visible to the entire program, and (with a
     448                 :             :    bit of cleverness, see pushdecl) allows diagnosis of some violations
     449                 :             :    of C99 6.2.2p7 and 6.2.7p2:
     450                 :             : 
     451                 :             :      If, within the same translation unit, the same identifier appears
     452                 :             :      with both internal and external linkage, the behavior is
     453                 :             :      undefined.
     454                 :             : 
     455                 :             :      All declarations that refer to the same object or function shall
     456                 :             :      have compatible type; otherwise, the behavior is undefined.
     457                 :             : 
     458                 :             :    Initially only the built-in declarations, which describe compiler
     459                 :             :    intrinsic functions plus a subset of the standard library, are in
     460                 :             :    this scope.
     461                 :             : 
     462                 :             :    The order of the blocks list matters, and it is frequently appended
     463                 :             :    to.  To avoid having to walk all the way to the end of the list on
     464                 :             :    each insertion, or reverse the list later, we maintain a pointer to
     465                 :             :    the last list entry.  (FIXME: It should be feasible to use a reversed
     466                 :             :    list here.)
     467                 :             : 
     468                 :             :    The bindings list is strictly in reverse order of declarations;
     469                 :             :    pop_scope relies on this.  */
     470                 :             : 
     471                 :             : 
     472                 :             : struct GTY((chain_next ("%h.outer"))) c_scope {
     473                 :             :   /* The scope containing this one.  */
     474                 :             :   struct c_scope *outer;
     475                 :             : 
     476                 :             :   /* The next outermost function scope.  */
     477                 :             :   struct c_scope *outer_function;
     478                 :             : 
     479                 :             :   /* All bindings in this scope.  */
     480                 :             :   struct c_binding *bindings;
     481                 :             : 
     482                 :             :   /* For each scope (except the global one), a chain of BLOCK nodes
     483                 :             :      for all the scopes that were entered and exited one level down.  */
     484                 :             :   tree blocks;
     485                 :             :   tree blocks_last;
     486                 :             : 
     487                 :             :   /* The depth of this scope.  Used to keep the ->shadowed chain of
     488                 :             :      bindings sorted innermost to outermost.  */
     489                 :             :   unsigned int depth : 28;
     490                 :             : 
     491                 :             :   /* True if we are currently filling this scope with parameter
     492                 :             :      declarations.  */
     493                 :             :   BOOL_BITFIELD parm_flag : 1;
     494                 :             : 
     495                 :             :   /* True if we saw [*] in this scope.  Used to give an error messages
     496                 :             :      if these appears in a function definition.  */
     497                 :             :   BOOL_BITFIELD had_vla_unspec : 1;
     498                 :             : 
     499                 :             :   /* True if we already complained about forward parameter decls
     500                 :             :      in this scope.  This prevents double warnings on
     501                 :             :      foo (int a; int b; ...)  */
     502                 :             :   BOOL_BITFIELD warned_forward_parm_decls : 1;
     503                 :             : 
     504                 :             :   /* True if this is the outermost block scope of a function body.
     505                 :             :      This scope contains the parameters, the local variables declared
     506                 :             :      in the outermost block, and all the labels (except those in
     507                 :             :      nested functions, or declared at block scope with __label__).  */
     508                 :             :   BOOL_BITFIELD function_body : 1;
     509                 :             : 
     510                 :             :   /* True means make a BLOCK for this scope no matter what.  */
     511                 :             :   BOOL_BITFIELD keep : 1;
     512                 :             : 
     513                 :             :   /* True means that an unsuffixed float constant is _Decimal64.  */
     514                 :             :   BOOL_BITFIELD float_const_decimal64 : 1;
     515                 :             : 
     516                 :             :   /* True if this scope has any label bindings.  This is used to speed
     517                 :             :      up searching for labels when popping scopes, particularly since
     518                 :             :      labels are normally only found at function scope.  */
     519                 :             :   BOOL_BITFIELD has_label_bindings : 1;
     520                 :             : 
     521                 :             :   /* True if we should issue a warning if a goto statement crosses any
     522                 :             :      of the bindings.  We still need to check the list of bindings to
     523                 :             :      find the specific ones we need to warn about.  This is true if
     524                 :             :      decl_jump_unsafe would return true for any of the bindings.  This
     525                 :             :      is used to avoid looping over all the bindings unnecessarily.  */
     526                 :             :   BOOL_BITFIELD has_jump_unsafe_decl : 1;
     527                 :             : };
     528                 :             : 
     529                 :             : /* The scope currently in effect.  */
     530                 :             : 
     531                 :             : static GTY(()) struct c_scope *current_scope;
     532                 :             : 
     533                 :             : /* The innermost function scope.  Ordinary (not explicitly declared)
     534                 :             :    labels, bindings to error_mark_node, and the lazily-created
     535                 :             :    bindings of __func__ and its friends get this scope.  */
     536                 :             : 
     537                 :             : static GTY(()) struct c_scope *current_function_scope;
     538                 :             : 
     539                 :             : /* The C file scope.  This is reset for each input translation unit.  */
     540                 :             : 
     541                 :             : static GTY(()) struct c_scope *file_scope;
     542                 :             : 
     543                 :             : /* The outermost scope.  This is used for all declarations with
     544                 :             :    external linkage, and only these, hence the name.  */
     545                 :             : 
     546                 :             : static GTY(()) struct c_scope *external_scope;
     547                 :             : 
     548                 :             : /* A chain of c_scope structures awaiting reuse.  */
     549                 :             : 
     550                 :             : static GTY((deletable)) struct c_scope *scope_freelist;
     551                 :             : 
     552                 :             : /* A chain of c_binding structures awaiting reuse.  */
     553                 :             : 
     554                 :             : static GTY((deletable)) struct c_binding *binding_freelist;
     555                 :             : 
     556                 :             : /* Append VAR to LIST in scope SCOPE.  */
     557                 :             : #define SCOPE_LIST_APPEND(scope, list, decl) do {       \
     558                 :             :   struct c_scope *s_ = (scope);                         \
     559                 :             :   tree d_ = (decl);                                     \
     560                 :             :   if (s_->list##_last)                                       \
     561                 :             :     BLOCK_CHAIN (s_->list##_last) = d_;                      \
     562                 :             :   else                                                  \
     563                 :             :     s_->list = d_;                                   \
     564                 :             :   s_->list##_last = d_;                                      \
     565                 :             : } while (0)
     566                 :             : 
     567                 :             : /* Concatenate FROM in scope FSCOPE onto TO in scope TSCOPE.  */
     568                 :             : #define SCOPE_LIST_CONCAT(tscope, to, fscope, from) do {        \
     569                 :             :   struct c_scope *t_ = (tscope);                                \
     570                 :             :   struct c_scope *f_ = (fscope);                                \
     571                 :             :   if (t_->to##_last)                                         \
     572                 :             :     BLOCK_CHAIN (t_->to##_last) = f_->from;                       \
     573                 :             :   else                                                          \
     574                 :             :     t_->to = f_->from;                                            \
     575                 :             :   t_->to##_last = f_->from##_last;                                \
     576                 :             : } while (0)
     577                 :             : 
     578                 :             : /* A c_inline_static structure stores details of a static identifier
     579                 :             :    referenced in a definition of a function that may be an inline
     580                 :             :    definition if no subsequent declaration of that function uses
     581                 :             :    "extern" or does not use "inline".  */
     582                 :             : 
     583                 :             : struct GTY((chain_next ("%h.next"))) c_inline_static {
     584                 :             :   /* The location for a diagnostic.  */
     585                 :             :   location_t location;
     586                 :             : 
     587                 :             :   /* The function that may be an inline definition.  */
     588                 :             :   tree function;
     589                 :             : 
     590                 :             :   /* The object or function referenced.  */
     591                 :             :   tree static_decl;
     592                 :             : 
     593                 :             :   /* What sort of reference this is.  */
     594                 :             :   enum c_inline_static_type type;
     595                 :             : 
     596                 :             :   /* The next such structure or NULL.  */
     597                 :             :   struct c_inline_static *next;
     598                 :             : };
     599                 :             : 
     600                 :             : /* List of static identifiers used or referenced in functions that may
     601                 :             :    be inline definitions.  */
     602                 :             : static GTY(()) struct c_inline_static *c_inline_statics;
     603                 :             : 
     604                 :             : /* True means unconditionally make a BLOCK for the next scope pushed.  */
     605                 :             : 
     606                 :             : static bool keep_next_level_flag;
     607                 :             : 
     608                 :             : /* True means the next call to push_scope will be the outermost scope
     609                 :             :    of a function body, so do not push a new scope, merely cease
     610                 :             :    expecting parameter decls.  */
     611                 :             : 
     612                 :             : static bool next_is_function_body;
     613                 :             : 
     614                 :             : /* A vector of pointers to c_binding structures.  */
     615                 :             : 
     616                 :             : typedef struct c_binding *c_binding_ptr;
     617                 :             : 
     618                 :             : /* Information that we keep for a struct or union while it is being
     619                 :             :    parsed.  */
     620                 :             : 
     621                 :     1072866 : class c_struct_parse_info
     622                 :             : {
     623                 :             : public:
     624                 :             :   /* If warn_cxx_compat, a list of types defined within this
     625                 :             :      struct.  */
     626                 :             :   auto_vec<tree> struct_types;
     627                 :             :   /* If warn_cxx_compat, a list of field names which have bindings,
     628                 :             :      and which are defined in this struct, but which are not defined
     629                 :             :      in any enclosing struct.  This is used to clear the in_struct
     630                 :             :      field of the c_bindings structure.  */
     631                 :             :   auto_vec<c_binding_ptr> fields;
     632                 :             :   /* If warn_cxx_compat, a list of typedef names used when defining
     633                 :             :      fields in this struct.  */
     634                 :             :   auto_vec<tree> typedefs_seen;
     635                 :             : };
     636                 :             : 
     637                 :             : 
     638                 :             : /* Hash table for structs and unions.  */
     639                 :             : struct c_struct_hasher : ggc_ptr_hash<tree_node>
     640                 :             : {
     641                 :             :   static hashval_t hash (tree t);
     642                 :             :   static bool equal (tree, tree);
     643                 :             : };
     644                 :             : 
     645                 :             : /* Hash an RECORD OR UNION.  */
     646                 :             : hashval_t
     647                 :        1407 : c_struct_hasher::hash (tree type)
     648                 :             : {
     649                 :        1407 :   inchash::hash hstate;
     650                 :             : 
     651                 :        1407 :   hstate.add_int (TREE_CODE (type));
     652                 :        1407 :   hstate.add_object (TYPE_NAME (type));
     653                 :             : 
     654                 :        1407 :   return hstate.end ();
     655                 :             : }
     656                 :             : 
     657                 :             : /* Compare two RECORD or UNION types.  */
     658                 :             : bool
     659                 :        1128 : c_struct_hasher::equal (tree t1,  tree t2)
     660                 :             : {
     661                 :        1128 :   return comptypes_equiv_p (t1, t2);
     662                 :             : }
     663                 :             : 
     664                 :             : /* All tagged typed so that TYPE_CANONICAL can be set correctly.  */
     665                 :             : static GTY (()) hash_table<c_struct_hasher> *c_struct_htab;
     666                 :             : 
     667                 :             : /* Information for the struct or union currently being parsed, or
     668                 :             :    NULL if not parsing a struct or union.  */
     669                 :             : static class c_struct_parse_info *struct_parse_info;
     670                 :             : 
     671                 :             : /* Forward declarations.  */
     672                 :             : static tree lookup_name_in_scope (tree, struct c_scope *);
     673                 :             : static tree c_make_fname_decl (location_t, tree, int);
     674                 :             : static tree grokdeclarator (const struct c_declarator *,
     675                 :             :                             struct c_declspecs *,
     676                 :             :                             enum decl_context, bool, tree *, tree *, tree *,
     677                 :             :                             bool *, enum deprecated_states);
     678                 :             : static tree grokparms (struct c_arg_info *, bool);
     679                 :             : static void layout_array_type (tree);
     680                 :             : static const char *header_for_builtin_fn (tree);
     681                 :             : 
     682                 :             : /* T is a statement.  Add it to the statement-tree.  This is the
     683                 :             :    C/ObjC version--C++ has a slightly different version of this
     684                 :             :    function.  */
     685                 :             : 
     686                 :             : tree
     687                 :    83885188 : add_stmt (tree t)
     688                 :             : {
     689                 :    83885188 :   enum tree_code code = TREE_CODE (t);
     690                 :             : 
     691                 :    83885188 :   if (CAN_HAVE_LOCATION_P (t) && code != LABEL_EXPR)
     692                 :             :     {
     693                 :    83223280 :       if (!EXPR_HAS_LOCATION (t))
     694                 :      153709 :         SET_EXPR_LOCATION (t, input_location);
     695                 :             :     }
     696                 :             : 
     697                 :    83885188 :   if (code == LABEL_EXPR || code == CASE_LABEL_EXPR)
     698                 :     1069503 :     STATEMENT_LIST_HAS_LABEL (cur_stmt_list) = 1;
     699                 :             : 
     700                 :             :   /* Add T to the statement-tree.  Non-side-effect statements need to be
     701                 :             :      recorded during statement expressions.  */
     702                 :    83885188 :   if (!building_stmt_list_p ())
     703                 :           1 :     push_stmt_list ();
     704                 :    83885188 :   append_to_statement_list_force (t, &cur_stmt_list);
     705                 :             : 
     706                 :    83885188 :   return t;
     707                 :             : }
     708                 :             : 
     709                 :             : /* Build a pointer type using the default pointer mode.  */
     710                 :             : 
     711                 :             : static tree
     712                 :    17015106 : c_build_pointer_type (tree to_type)
     713                 :             : {
     714                 :    17015106 :   addr_space_t as = to_type == error_mark_node? ADDR_SPACE_GENERIC
     715                 :    17015106 :                                               : TYPE_ADDR_SPACE (to_type);
     716                 :    17015106 :   machine_mode pointer_mode;
     717                 :             : 
     718                 :    17015106 :   if (as != ADDR_SPACE_GENERIC || c_default_pointer_mode == VOIDmode)
     719                 :    17015106 :     pointer_mode = targetm.addr_space.pointer_mode (as);
     720                 :             :   else
     721                 :             :     pointer_mode = c_default_pointer_mode;
     722                 :    17015106 :   return build_pointer_type_for_mode (to_type, pointer_mode, false);
     723                 :             : }
     724                 :             : 
     725                 :             : 
     726                 :             : /* Return true if we will want to say something if a goto statement
     727                 :             :    crosses DECL.  */
     728                 :             : 
     729                 :             : static bool
     730                 :   807501413 : decl_jump_unsafe (tree decl)
     731                 :             : {
     732                 :   807501413 :   if (error_operand_p (decl))
     733                 :             :     return false;
     734                 :             : 
     735                 :             :   /* Don't warn for compound literals.  If a goto statement crosses
     736                 :             :      their initialization, it should cross also all the places where
     737                 :             :      the complit is used or where the complit address might be saved
     738                 :             :      into some variable, so code after the label to which goto jumps
     739                 :             :      should not be able to refer to the compound literal.  */
     740                 :   807499232 :   if (VAR_P (decl) && C_DECL_COMPOUND_LITERAL_P (decl))
     741                 :             :     return false;
     742                 :             : 
     743                 :   806630285 :   if (flag_openmp
     744                 :     9630268 :       && VAR_P (decl)
     745                 :   806657759 :       && lookup_attribute ("omp allocate", DECL_ATTRIBUTES (decl)))
     746                 :             :     return true;
     747                 :             : 
     748                 :             :   /* Always warn about crossing variably modified types.  */
     749                 :   796831470 :   if ((VAR_P (decl) || TREE_CODE (decl) == TYPE_DECL)
     750                 :   817874385 :       && c_type_variably_modified_p (TREE_TYPE (decl)))
     751                 :             :     return true;
     752                 :             : 
     753                 :             :   /* Otherwise, only warn if -Wgoto-misses-init and this is an
     754                 :             :      initialized automatic decl.  */
     755                 :   806590246 :   if (warn_jump_misses_init
     756                 :             :       && VAR_P (decl)
     757                 :       13137 :       && !TREE_STATIC (decl)
     758                 :   806590268 :       && DECL_INITIAL (decl) != NULL_TREE)
     759                 :             :     return true;
     760                 :             : 
     761                 :             :   return false;
     762                 :             : }
     763                 :             : 
     764                 :             : 
     765                 :             : void
     766                 :           0 : c_print_identifier (FILE *file, tree node, int indent)
     767                 :             : {
     768                 :           0 :   void (*save) (enum c_oracle_request, tree identifier);
     769                 :             : 
     770                 :             :   /* Temporarily hide any binding oracle.  Without this, calls to
     771                 :             :      debug_tree from the debugger will end up calling into the oracle,
     772                 :             :      making for a confusing debug session.  As the oracle isn't needed
     773                 :             :      here for normal operation, it's simplest to suppress it.  */
     774                 :           0 :   save = c_binding_oracle;
     775                 :           0 :   c_binding_oracle = NULL;
     776                 :             : 
     777                 :           0 :   print_node (file, "symbol", I_SYMBOL_DECL (node), indent + 4);
     778                 :           0 :   print_node (file, "tag", I_TAG_DECL (node), indent + 4);
     779                 :           0 :   print_node (file, "label", I_LABEL_DECL (node), indent + 4);
     780                 :           0 :   if (C_IS_RESERVED_WORD (node) && C_RID_CODE (node) != RID_CXX_COMPAT_WARN)
     781                 :             :     {
     782                 :           0 :       tree rid = ridpointers[C_RID_CODE (node)];
     783                 :           0 :       indent_to (file, indent + 4);
     784                 :           0 :       fprintf (file, "rid " HOST_PTR_PRINTF " \"%s\"",
     785                 :           0 :                (void *) rid, IDENTIFIER_POINTER (rid));
     786                 :             :     }
     787                 :             : 
     788                 :           0 :   c_binding_oracle = save;
     789                 :           0 : }
     790                 :             : 
     791                 :             : /* Establish that the scope contains declarations that are sensitive to
     792                 :             :    jumps that cross a binding.  Together with decl_jump_unsafe, this is
     793                 :             :    used to diagnose such jumps.  */
     794                 :             : void
     795                 :          57 : c_mark_decl_jump_unsafe_in_current_scope ()
     796                 :             : {
     797                 :          57 :   current_scope->has_jump_unsafe_decl = 1;
     798                 :          57 : }
     799                 :             : 
     800                 :             : /* Establish a binding between NAME, an IDENTIFIER_NODE, and DECL,
     801                 :             :    which may be any of several kinds of DECL or TYPE or error_mark_node,
     802                 :             :    in the scope SCOPE.  */
     803                 :             : static void
     804                 :   807352423 : bind (tree name, tree decl, struct c_scope *scope, bool invisible,
     805                 :             :       bool nested, location_t locus)
     806                 :             : {
     807                 :   807352423 :   struct c_binding *b, **here;
     808                 :             : 
     809                 :   807352423 :   if (binding_freelist)
     810                 :             :     {
     811                 :   202562435 :       b = binding_freelist;
     812                 :   202562435 :       binding_freelist = b->prev;
     813                 :             :     }
     814                 :             :   else
     815                 :   604789988 :     b = ggc_alloc<c_binding> ();
     816                 :             : 
     817                 :   807352423 :   b->shadowed = 0;
     818                 :   807352423 :   b->decl = decl;
     819                 :   807352423 :   b->id = name;
     820                 :   807352423 :   b->depth = scope->depth;
     821                 :   807352423 :   b->invisible = invisible;
     822                 :   807352423 :   b->nested = nested;
     823                 :   807352423 :   b->inner_comp = 0;
     824                 :   807352423 :   b->in_struct = 0;
     825                 :   807352423 :   b->locus = locus;
     826                 :             : 
     827                 :   807352423 :   b->u.type = NULL;
     828                 :             : 
     829                 :   807352423 :   b->prev = scope->bindings;
     830                 :   807352423 :   scope->bindings = b;
     831                 :             : 
     832                 :   807352423 :   if (decl_jump_unsafe (decl))
     833                 :       19941 :     scope->has_jump_unsafe_decl = 1;
     834                 :             : 
     835                 :   807352423 :   if (!name)
     836                 :             :     return;
     837                 :             : 
     838                 :   799536609 :   switch (TREE_CODE (decl))
     839                 :             :     {
     840                 :       22645 :     case LABEL_DECL:     here = &I_LABEL_BINDING (name);   break;
     841                 :      586148 :     case ENUMERAL_TYPE:
     842                 :      586148 :     case UNION_TYPE:
     843                 :      586148 :     case RECORD_TYPE:    here = &I_TAG_BINDING (name);     break;
     844                 :   798927816 :     case VAR_DECL:
     845                 :   798927816 :     case FUNCTION_DECL:
     846                 :   798927816 :     case TYPE_DECL:
     847                 :   798927816 :     case CONST_DECL:
     848                 :   798927816 :     case PARM_DECL:
     849                 :   798927816 :     case ERROR_MARK:     here = &I_SYMBOL_BINDING (name);  break;
     850                 :             : 
     851                 :           0 :     default:
     852                 :           0 :       gcc_unreachable ();
     853                 :             :     }
     854                 :             : 
     855                 :             :   /* Locate the appropriate place in the chain of shadowed decls
     856                 :             :      to insert this binding.  Normally, scope == current_scope and
     857                 :             :      this does nothing.  */
     858                 :   799536649 :   while (*here && (*here)->depth > scope->depth)
     859                 :          40 :     here = &(*here)->shadowed;
     860                 :             : 
     861                 :   799536609 :   b->shadowed = *here;
     862                 :   799536609 :   *here = b;
     863                 :             : }
     864                 :             : 
     865                 :             : /* Clear the binding structure B, stick it on the binding_freelist,
     866                 :             :    and return the former value of b->prev.  This is used by pop_scope
     867                 :             :    and get_parm_info to iterate destructively over all the bindings
     868                 :             :    from a given scope.  */
     869                 :             : static struct c_binding *
     870                 :   793315436 : free_binding_and_advance (struct c_binding *b)
     871                 :             : {
     872                 :   793315436 :   struct c_binding *prev = b->prev;
     873                 :             : 
     874                 :   793315436 :   memset (b, 0, sizeof (struct c_binding));
     875                 :   793315436 :   b->prev = binding_freelist;
     876                 :   793315436 :   binding_freelist = b;
     877                 :             : 
     878                 :   793315436 :   return prev;
     879                 :             : }
     880                 :             : 
     881                 :             : /* Bind a label.  Like bind, but skip fields which aren't used for
     882                 :             :    labels, and add the LABEL_VARS value.  */
     883                 :             : static void
     884                 :       22645 : bind_label (tree name, tree label, struct c_scope *scope,
     885                 :             :             struct c_label_vars *label_vars)
     886                 :             : {
     887                 :       22645 :   struct c_binding *b;
     888                 :             : 
     889                 :       22645 :   bind (name, label, scope, /*invisible=*/false, /*nested=*/false,
     890                 :             :         UNKNOWN_LOCATION);
     891                 :             : 
     892                 :       22645 :   scope->has_label_bindings = true;
     893                 :             : 
     894                 :       22645 :   b = scope->bindings;
     895                 :       22645 :   gcc_assert (b->decl == label);
     896                 :       22645 :   label_vars->shadowed = b->u.label;
     897                 :       22645 :   b->u.label = label_vars;
     898                 :       22645 : }
     899                 :             : 
     900                 :             : /* Hook called at end of compilation to assume 1 elt
     901                 :             :    for a file-scope tentative array defn that wasn't complete before.  */
     902                 :             : 
     903                 :             : void
     904                 :        7391 : c_finish_incomplete_decl (tree decl)
     905                 :             : {
     906                 :        7391 :   if (VAR_P (decl))
     907                 :             :     {
     908                 :        7391 :       tree type = TREE_TYPE (decl);
     909                 :        7391 :       if (type != error_mark_node
     910                 :        7317 :           && TREE_CODE (type) == ARRAY_TYPE
     911                 :        7155 :           && !DECL_EXTERNAL (decl)
     912                 :        7469 :           && TYPE_DOMAIN (type) == NULL_TREE)
     913                 :             :         {
     914                 :          78 :           warning_at (DECL_SOURCE_LOCATION (decl),
     915                 :             :                       0, "array %q+D assumed to have one element", decl);
     916                 :             : 
     917                 :          78 :           complete_array_type (&TREE_TYPE (decl), NULL_TREE, true);
     918                 :             : 
     919                 :          78 :           relayout_decl (decl);
     920                 :             :         }
     921                 :             :     }
     922                 :        7391 : }
     923                 :             : 
     924                 :             : /* Record that inline function FUNC contains a reference (location
     925                 :             :    LOC) to static DECL (file-scope or function-local according to
     926                 :             :    TYPE).  */
     927                 :             : 
     928                 :             : void
     929                 :          36 : record_inline_static (location_t loc, tree func, tree decl,
     930                 :             :                       enum c_inline_static_type type)
     931                 :             : {
     932                 :          36 :   c_inline_static *csi = ggc_alloc<c_inline_static> ();
     933                 :          36 :   csi->location = loc;
     934                 :          36 :   csi->function = func;
     935                 :          36 :   csi->static_decl = decl;
     936                 :          36 :   csi->type = type;
     937                 :          36 :   csi->next = c_inline_statics;
     938                 :          36 :   c_inline_statics = csi;
     939                 :          36 : }
     940                 :             : 
     941                 :             : /* Check for references to static declarations in inline functions at
     942                 :             :    the end of the translation unit and diagnose them if the functions
     943                 :             :    are still inline definitions.  */
     944                 :             : 
     945                 :             : static void
     946                 :      103411 : check_inline_statics (void)
     947                 :             : {
     948                 :      103411 :   struct c_inline_static *csi;
     949                 :      103447 :   for (csi = c_inline_statics; csi; csi = csi->next)
     950                 :             :     {
     951                 :          36 :       if (DECL_EXTERNAL (csi->function))
     952                 :          30 :         switch (csi->type)
     953                 :             :           {
     954                 :          23 :           case csi_internal:
     955                 :          23 :             pedwarn (csi->location, 0,
     956                 :             :                      "%qD is static but used in inline function %qD "
     957                 :             :                      "which is not static", csi->static_decl, csi->function);
     958                 :          23 :             break;
     959                 :           7 :           case csi_modifiable:
     960                 :           7 :             pedwarn (csi->location, 0,
     961                 :             :                      "%q+D is static but declared in inline function %qD "
     962                 :             :                      "which is not static", csi->static_decl, csi->function);
     963                 :           7 :             break;
     964                 :           0 :           default:
     965                 :           0 :             gcc_unreachable ();
     966                 :             :           }
     967                 :             :     }
     968                 :      103411 :   c_inline_statics = NULL;
     969                 :      103411 : }
     970                 :             : 
     971                 :             : /* Fill in a c_spot_bindings structure.  If DEFINING is true, set it
     972                 :             :    for the current state, otherwise set it to uninitialized.  */
     973                 :             : 
     974                 :             : static void
     975                 :      131129 : set_spot_bindings (struct c_spot_bindings *p, bool defining)
     976                 :             : {
     977                 :           0 :   if (defining)
     978                 :             :     {
     979                 :      124615 :       p->scope = current_scope;
     980                 :       16131 :       p->bindings_in_scope = current_scope->bindings;
     981                 :             :     }
     982                 :             :   else
     983                 :             :     {
     984                 :        6514 :       p->scope = NULL;
     985                 :        6514 :       p->bindings_in_scope = NULL;
     986                 :             :     }
     987                 :      131129 :   p->stmt_exprs = 0;
     988                 :      131129 :   p->left_stmt_expr = false;
     989                 :           0 : }
     990                 :             : 
     991                 :             : /* Update spot bindings P as we pop out of SCOPE.  Return true if we
     992                 :             :    should push decls for a label.  */
     993                 :             : 
     994                 :             : static bool
     995                 :   470575492 : update_spot_bindings (struct c_scope *scope, struct c_spot_bindings *p)
     996                 :             : {
     997                 :           0 :   if (p->scope != scope)
     998                 :             :     {
     999                 :             :       /* This label or goto is defined in some other scope, or it is a
    1000                 :             :          label which is not yet defined.  There is nothing to
    1001                 :             :          update.  */
    1002                 :             :       return false;
    1003                 :             :     }
    1004                 :             : 
    1005                 :             :   /* Adjust the spot bindings to refer to the bindings already defined
    1006                 :             :      in the enclosing scope.  */
    1007                 :      198600 :   p->scope = scope->outer;
    1008                 :      198600 :   p->bindings_in_scope = p->scope->bindings;
    1009                 :             : 
    1010                 :      148566 :   return true;
    1011                 :             : }
    1012                 :             : 
    1013                 :             : /* The Objective-C front-end often needs to determine the current scope.  */
    1014                 :             : 
    1015                 :             : void *
    1016                 :           0 : objc_get_current_scope (void)
    1017                 :             : {
    1018                 :           0 :   return current_scope;
    1019                 :             : }
    1020                 :             : 
    1021                 :             : /* The following function is used only by Objective-C.  It needs to live here
    1022                 :             :    because it accesses the innards of c_scope.  */
    1023                 :             : 
    1024                 :             : void
    1025                 :           0 : objc_mark_locals_volatile (void *enclosing_blk)
    1026                 :             : {
    1027                 :           0 :   struct c_scope *scope;
    1028                 :           0 :   struct c_binding *b;
    1029                 :             : 
    1030                 :           0 :   for (scope = current_scope;
    1031                 :           0 :        scope && scope != enclosing_blk;
    1032                 :           0 :        scope = scope->outer)
    1033                 :             :     {
    1034                 :           0 :       for (b = scope->bindings; b; b = b->prev)
    1035                 :           0 :         objc_volatilize_decl (b->decl);
    1036                 :             : 
    1037                 :             :       /* Do not climb up past the current function.  */
    1038                 :           0 :       if (scope->function_body)
    1039                 :             :         break;
    1040                 :             :     }
    1041                 :           0 : }
    1042                 :             : 
    1043                 :             : /* Return true if we are in the global binding level.  */
    1044                 :             : 
    1045                 :             : bool
    1046                 :     2025635 : global_bindings_p (void)
    1047                 :             : {
    1048                 :     2025635 :   return current_scope == file_scope;
    1049                 :             : }
    1050                 :             : 
    1051                 :             : /* Return true if we're declaring parameters in an old-style function
    1052                 :             :    declaration.  */
    1053                 :             : 
    1054                 :             : bool
    1055                 :       33064 : old_style_parameter_scope (void)
    1056                 :             : {
    1057                 :             :   /* If processing parameters and there is no function statement list, we
    1058                 :             :    * have an old-style function declaration.  */
    1059                 :       33064 :   return (current_scope->parm_flag && !DECL_SAVED_TREE (current_function_decl));
    1060                 :             : }
    1061                 :             : 
    1062                 :             : void
    1063                 :       49550 : keep_next_level (void)
    1064                 :             : {
    1065                 :       49550 :   keep_next_level_flag = true;
    1066                 :       49550 : }
    1067                 :             : 
    1068                 :             : /* Set the flag for the FLOAT_CONST_DECIMAL64 pragma being ON.  */
    1069                 :             : 
    1070                 :             : void
    1071                 :          20 : set_float_const_decimal64 (void)
    1072                 :             : {
    1073                 :          20 :   current_scope->float_const_decimal64 = true;
    1074                 :          20 : }
    1075                 :             : 
    1076                 :             : /* Clear the flag for the FLOAT_CONST_DECIMAL64 pragma.  */
    1077                 :             : 
    1078                 :             : void
    1079                 :          28 : clear_float_const_decimal64 (void)
    1080                 :             : {
    1081                 :          28 :   current_scope->float_const_decimal64 = false;
    1082                 :          28 : }
    1083                 :             : 
    1084                 :             : /* Return nonzero if an unsuffixed float constant is _Decimal64.  */
    1085                 :             : 
    1086                 :             : bool
    1087                 :      586571 : float_const_decimal64_p (void)
    1088                 :             : {
    1089                 :      586571 :   return current_scope->float_const_decimal64;
    1090                 :             : }
    1091                 :             : 
    1092                 :             : /* Identify this scope as currently being filled with parameters.  */
    1093                 :             : 
    1094                 :             : void
    1095                 :    75604200 : declare_parm_level (void)
    1096                 :             : {
    1097                 :    75604200 :   current_scope->parm_flag = true;
    1098                 :    75604200 : }
    1099                 :             : 
    1100                 :             : void
    1101                 :   112140921 : push_scope (void)
    1102                 :             : {
    1103                 :   112140921 :   if (next_is_function_body)
    1104                 :             :     {
    1105                 :             :       /* This is the transition from the parameters to the top level
    1106                 :             :          of the function body.  These are the same scope
    1107                 :             :          (C99 6.2.1p4,6) so we do not push another scope structure.
    1108                 :             :          next_is_function_body is set only by store_parm_decls, which
    1109                 :             :          in turn is called when and only when we are about to
    1110                 :             :          encounter the opening curly brace for the function body.
    1111                 :             : 
    1112                 :             :          The outermost block of a function always gets a BLOCK node,
    1113                 :             :          because the debugging output routines expect that each
    1114                 :             :          function has at least one BLOCK.  */
    1115                 :    31761899 :       current_scope->parm_flag         = false;
    1116                 :    31761899 :       current_scope->function_body     = true;
    1117                 :    31761899 :       current_scope->keep              = true;
    1118                 :    31761899 :       current_scope->outer_function    = current_function_scope;
    1119                 :    31761899 :       current_function_scope           = current_scope;
    1120                 :             : 
    1121                 :    31761899 :       keep_next_level_flag = false;
    1122                 :    31761899 :       next_is_function_body = false;
    1123                 :             : 
    1124                 :             :       /* The FLOAT_CONST_DECIMAL64 pragma applies to nested scopes.  */
    1125                 :    31761899 :       if (current_scope->outer)
    1126                 :    31761899 :         current_scope->float_const_decimal64
    1127                 :    31761899 :           = current_scope->outer->float_const_decimal64;
    1128                 :             :       else
    1129                 :           0 :         current_scope->float_const_decimal64 = false;
    1130                 :             :     }
    1131                 :             :   else
    1132                 :             :     {
    1133                 :    80379022 :       struct c_scope *scope;
    1134                 :    80379022 :       if (scope_freelist)
    1135                 :             :         {
    1136                 :    79561408 :           scope = scope_freelist;
    1137                 :    79561408 :           scope_freelist = scope->outer;
    1138                 :             :         }
    1139                 :             :       else
    1140                 :      817614 :         scope = ggc_cleared_alloc<c_scope> ();
    1141                 :             : 
    1142                 :             :       /* The FLOAT_CONST_DECIMAL64 pragma applies to nested scopes.  */
    1143                 :    80379022 :       if (current_scope)
    1144                 :    80271044 :         scope->float_const_decimal64 = current_scope->float_const_decimal64;
    1145                 :             :       else
    1146                 :      107978 :         scope->float_const_decimal64 = false;
    1147                 :             : 
    1148                 :    80379022 :       scope->keep          = keep_next_level_flag;
    1149                 :    80379022 :       scope->outer         = current_scope;
    1150                 :    80379022 :       scope->depth      = current_scope ? (current_scope->depth + 1) : 0;
    1151                 :             : 
    1152                 :             :       /* Check for scope depth overflow.  Unlikely (2^28 == 268,435,456) but
    1153                 :             :          possible.  */
    1154                 :    80379022 :       if (current_scope && scope->depth == 0)
    1155                 :             :         {
    1156                 :           0 :           scope->depth--;
    1157                 :           0 :           sorry ("GCC supports only %u nested scopes", scope->depth);
    1158                 :             :         }
    1159                 :             : 
    1160                 :    80379022 :       current_scope        = scope;
    1161                 :    80379022 :       keep_next_level_flag = false;
    1162                 :             :     }
    1163                 :   112140921 : }
    1164                 :             : 
    1165                 :             : /* This is called when we are leaving SCOPE.  For each label defined
    1166                 :             :    in SCOPE, add any appropriate decls to its decls_in_scope fields.
    1167                 :             :    These are the decls whose initialization will be skipped by a goto
    1168                 :             :    later in the function.  */
    1169                 :             : 
    1170                 :             : static void
    1171                 :    80373585 : update_label_decls (struct c_scope *scope)
    1172                 :             : {
    1173                 :    80373585 :   struct c_scope *s;
    1174                 :             : 
    1175                 :    80373585 :   s = scope;
    1176                 :   300808268 :   while (s != NULL)
    1177                 :             :     {
    1178                 :   256775117 :       if (s->has_label_bindings)
    1179                 :             :         {
    1180                 :      228132 :           struct c_binding *b;
    1181                 :             : 
    1182                 :     2099401 :           for (b = s->bindings; b != NULL; b = b->prev)
    1183                 :             :             {
    1184                 :     1871269 :               struct c_label_vars *label_vars;
    1185                 :     1871269 :               struct c_binding *b1;
    1186                 :     1871269 :               bool hjud;
    1187                 :     1871269 :               unsigned int ix;
    1188                 :     1871269 :               struct c_goto_bindings *g;
    1189                 :             : 
    1190                 :     1871269 :               if (TREE_CODE (b->decl) != LABEL_DECL)
    1191                 :     1398548 :                 continue;
    1192                 :      472721 :               label_vars = b->u.label;
    1193                 :             : 
    1194                 :      472721 :               b1 = label_vars->label_bindings.bindings_in_scope;
    1195                 :      472721 :               if (label_vars->label_bindings.scope == NULL)
    1196                 :             :                 hjud = false;
    1197                 :             :               else
    1198                 :      167558 :                 hjud = label_vars->label_bindings.scope->has_jump_unsafe_decl;
    1199                 :      472721 :               if (update_spot_bindings (scope, &label_vars->label_bindings))
    1200                 :             :                 {
    1201                 :             :                   /* This label is defined in this scope.  */
    1202                 :       50034 :                   if (hjud)
    1203                 :             :                     {
    1204                 :      169525 :                       for (; b1 != NULL; b1 = b1->prev)
    1205                 :             :                         {
    1206                 :             :                           /* A goto from later in the function to this
    1207                 :             :                              label will never see the initialization
    1208                 :             :                              of B1, if any.  Save it to issue a
    1209                 :             :                              warning if needed.  */
    1210                 :      148129 :                           if (decl_jump_unsafe (b1->decl))
    1211                 :       19418 :                             vec_safe_push(label_vars->decls_in_scope, b1->decl);
    1212                 :             :                         }
    1213                 :             :                     }
    1214                 :             :                 }
    1215                 :             : 
    1216                 :             :               /* Update the bindings of any goto statements associated
    1217                 :             :                  with this label.  */
    1218                 :   472262934 :               FOR_EACH_VEC_SAFE_ELT (label_vars->gotos, ix, g)
    1219                 :   470251337 :                 update_spot_bindings (scope, &g->goto_bindings);
    1220                 :             :             }
    1221                 :             :         }
    1222                 :             : 
    1223                 :             :       /* Don't search beyond the current function.  */
    1224                 :   256775117 :       if (s == current_function_scope)
    1225                 :             :         break;
    1226                 :             : 
    1227                 :   220434683 :       s = s->outer;
    1228                 :             :     }
    1229                 :    80373585 : }
    1230                 :             : 
    1231                 :             : /* Exit a scope.  Restore the state of the identifier-decl mappings
    1232                 :             :    that were in effect when this scope was entered.  Return a BLOCK
    1233                 :             :    node containing all the DECLs in this scope that are of interest
    1234                 :             :    to debug info generation.  */
    1235                 :             : 
    1236                 :             : tree
    1237                 :    80373585 : pop_scope (void)
    1238                 :             : {
    1239                 :    80373585 :   struct c_scope *scope = current_scope;
    1240                 :    80373585 :   tree block, context, p;
    1241                 :    80373585 :   struct c_binding *b;
    1242                 :             : 
    1243                 :    80373585 :   bool functionbody = scope->function_body;
    1244                 :    80373585 :   bool keep = functionbody || scope->keep || scope->bindings;
    1245                 :             : 
    1246                 :    80373585 :   update_label_decls (scope);
    1247                 :             : 
    1248                 :             :   /* If appropriate, create a BLOCK to record the decls for the life
    1249                 :             :      of this function.  */
    1250                 :    80373585 :   block = NULL_TREE;
    1251                 :    80373585 :   if (keep)
    1252                 :             :     {
    1253                 :    32227772 :       block = make_node (BLOCK);
    1254                 :    32227772 :       BLOCK_SUBBLOCKS (block) = scope->blocks;
    1255                 :    32227772 :       TREE_USED (block) = 1;
    1256                 :             : 
    1257                 :             :       /* In each subblock, record that this is its superior.  */
    1258                 :    32487546 :       for (p = scope->blocks; p; p = BLOCK_CHAIN (p))
    1259                 :      259774 :         BLOCK_SUPERCONTEXT (p) = block;
    1260                 :             : 
    1261                 :    32227772 :       BLOCK_VARS (block) = NULL_TREE;
    1262                 :             :     }
    1263                 :             : 
    1264                 :             :   /* The TYPE_CONTEXTs for all of the tagged types belonging to this
    1265                 :             :      scope must be set so that they point to the appropriate
    1266                 :             :      construct, i.e.  either to the current FUNCTION_DECL node, or
    1267                 :             :      else to the BLOCK node we just constructed.
    1268                 :             : 
    1269                 :             :      Note that for tagged types whose scope is just the formal
    1270                 :             :      parameter list for some function type specification, we can't
    1271                 :             :      properly set their TYPE_CONTEXTs here, because we don't have a
    1272                 :             :      pointer to the appropriate FUNCTION_TYPE node readily available
    1273                 :             :      to us.  For those cases, the TYPE_CONTEXTs of the relevant tagged
    1274                 :             :      type nodes get set in `grokdeclarator' as soon as we have created
    1275                 :             :      the FUNCTION_TYPE node which will represent the "scope" for these
    1276                 :             :      "parameter list local" tagged types.  */
    1277                 :    80373585 :   if (scope->function_body)
    1278                 :    31761898 :     context = current_function_decl;
    1279                 :    48611687 :   else if (scope == file_scope)
    1280                 :             :     {
    1281                 :      103050 :       tree file_decl
    1282                 :      103050 :         = build_translation_unit_decl (get_identifier (main_input_filename));
    1283                 :      103050 :       context = file_decl;
    1284                 :      103050 :       debug_hooks->register_main_translation_unit (file_decl);
    1285                 :             :     }
    1286                 :             :   else
    1287                 :             :     context = block;
    1288                 :             : 
    1289                 :             :   /* Clear all bindings in this scope.  */
    1290                 :   766107516 :   for (b = scope->bindings; b; b = free_binding_and_advance (b))
    1291                 :             :     {
    1292                 :   685733931 :       p = b->decl;
    1293                 :   685733931 :       switch (TREE_CODE (p))
    1294                 :             :         {
    1295                 :       22645 :         case LABEL_DECL:
    1296                 :             :           /* Warnings for unused labels, errors for undefined labels.  */
    1297                 :       22645 :           if (TREE_USED (p) && !DECL_INITIAL (p))
    1298                 :             :             {
    1299                 :          63 :               error ("label %q+D used but not defined", p);
    1300                 :          63 :               DECL_INITIAL (p) = error_mark_node;
    1301                 :             :             }
    1302                 :             :           else
    1303                 :       22582 :             warn_for_unused_label (p);
    1304                 :             : 
    1305                 :             :           /* Labels go in BLOCK_VARS.  */
    1306                 :       22645 :           DECL_CHAIN (p) = BLOCK_VARS (block);
    1307                 :       22645 :           BLOCK_VARS (block) = p;
    1308                 :       22645 :           gcc_assert (I_LABEL_BINDING (b->id) == b);
    1309                 :       22645 :           I_LABEL_BINDING (b->id) = b->shadowed;
    1310                 :             : 
    1311                 :             :           /* Also pop back to the shadowed label_vars.  */
    1312                 :       22645 :           release_tree_vector (b->u.label->decls_in_scope);
    1313                 :       22645 :           b->u.label = b->u.label->shadowed;
    1314                 :       22645 :           break;
    1315                 :             : 
    1316                 :     1292546 :         case ENUMERAL_TYPE:
    1317                 :     1292546 :         case UNION_TYPE:
    1318                 :     1292546 :         case RECORD_TYPE:
    1319                 :             : 
    1320                 :             :           /* Types may not have tag-names, in which case the type
    1321                 :             :              appears in the bindings list with b->id NULL.  */
    1322                 :     1292546 :           if (b->id)
    1323                 :             :             {
    1324                 :      584330 :               gcc_assert (I_TAG_BINDING (b->id) == b);
    1325                 :      584330 :               I_TAG_BINDING (b->id) = b->shadowed;
    1326                 :             :             }
    1327                 :             :           break;
    1328                 :             : 
    1329                 :   569599029 :         case FUNCTION_DECL:
    1330                 :             :           /* Propagate TREE_ADDRESSABLE from nested functions to their
    1331                 :             :              containing functions.  */
    1332                 :   569599029 :           if (!TREE_ASM_WRITTEN (p)
    1333                 :   569599029 :               && DECL_INITIAL (p) != NULL_TREE
    1334                 :    63190815 :               && TREE_ADDRESSABLE (p)
    1335                 :     3432881 :               && DECL_ABSTRACT_ORIGIN (p) != NULL_TREE
    1336                 :   569599029 :               && DECL_ABSTRACT_ORIGIN (p) != p)
    1337                 :           0 :             TREE_ADDRESSABLE (DECL_ABSTRACT_ORIGIN (p)) = 1;
    1338                 :   569599029 :           if (!TREE_PUBLIC (p)
    1339                 :      340438 :               && !DECL_INITIAL (p)
    1340                 :         146 :               && !b->nested
    1341                 :         115 :               && scope != file_scope
    1342                 :   569599035 :               && scope != external_scope)
    1343                 :             :             {
    1344                 :           6 :               error ("nested function %q+D declared but never defined", p);
    1345                 :           6 :               undef_nested_function = true;
    1346                 :             :             }
    1347                 :   569599023 :           else if (DECL_DECLARED_INLINE_P (p)
    1348                 :    62057722 :                    && TREE_PUBLIC (p)
    1349                 :   631507015 :                    && !DECL_INITIAL (p))
    1350                 :             :             {
    1351                 :             :               /* C99 6.7.4p6: "a function with external linkage... declared
    1352                 :             :                  with an inline function specifier ... shall also be defined
    1353                 :             :                  in the same translation unit."  */
    1354                 :          72 :               if (!flag_gnu89_inline
    1355                 :          47 :                   && !lookup_attribute ("gnu_inline", DECL_ATTRIBUTES (p))
    1356                 :         103 :                   && scope == external_scope)
    1357                 :          11 :                 pedwarn (input_location, 0,
    1358                 :             :                          "inline function %q+D declared but never defined", p);
    1359                 :          72 :               DECL_EXTERNAL (p) = 1;
    1360                 :             :             }
    1361                 :             : 
    1362                 :   569599029 :           goto common_symbol;
    1363                 :             : 
    1364                 :    10659596 :         case VAR_DECL:
    1365                 :             :           /* Warnings for unused variables.  */
    1366                 :     8104754 :           if ((!TREE_USED (p) || !DECL_READ_P (p))
    1367                 :     2581428 :               && !warning_suppressed_p (p, OPT_Wunused_but_set_variable)
    1368                 :     2580934 :               && !DECL_IN_SYSTEM_HEADER (p)
    1369                 :     2505151 :               && DECL_NAME (p)
    1370                 :     2505151 :               && !DECL_ARTIFICIAL (p)
    1371                 :     2504837 :               && scope != file_scope
    1372                 :    12279779 :               && scope != external_scope)
    1373                 :             :             {
    1374                 :      737106 :               if (!TREE_USED (p))
    1375                 :             :                 {
    1376                 :      732029 :                   warning (OPT_Wunused_variable, "unused variable %q+D", p);
    1377                 :      732029 :                   suppress_warning (p, OPT_Wunused_variable);
    1378                 :             :                 }
    1379                 :        5077 :               else if (DECL_CONTEXT (p) == current_function_decl)
    1380                 :        5058 :                 warning_at (DECL_SOURCE_LOCATION (p),
    1381                 :             :                             OPT_Wunused_but_set_variable,
    1382                 :             :                             "variable %qD set but not used", p);
    1383                 :             :             }
    1384                 :             : 
    1385                 :    10659596 :           if (b->inner_comp)
    1386                 :             :             {
    1387                 :           2 :               error ("type of array %q+D completed incompatibly with"
    1388                 :             :                      " implicit initialization", p);
    1389                 :             :             }
    1390                 :             : 
    1391                 :             :           /* Fall through.  */
    1392                 :   596518463 :         case TYPE_DECL:
    1393                 :   596518463 :         case CONST_DECL:
    1394                 :    10659594 :         common_symbol:
    1395                 :             :           /* All of these go in BLOCK_VARS, but only if this is the
    1396                 :             :              binding in the home scope.  */
    1397                 :   596518463 :           if (!b->nested)
    1398                 :             :             {
    1399                 :   359186683 :               DECL_CHAIN (p) = BLOCK_VARS (block);
    1400                 :   359186683 :               BLOCK_VARS (block) = p;
    1401                 :             :             }
    1402                 :   237331780 :           else if (VAR_OR_FUNCTION_DECL_P (p) && scope != file_scope)
    1403                 :             :             {
    1404                 :             :               /* For block local externs add a special
    1405                 :             :                  DECL_EXTERNAL decl for debug info generation.  */
    1406                 :       14557 :               tree extp = copy_node (p);
    1407                 :             : 
    1408                 :       14557 :               DECL_EXTERNAL (extp) = 1;
    1409                 :       14557 :               TREE_STATIC (extp) = 0;
    1410                 :       14557 :               TREE_PUBLIC (extp) = 1;
    1411                 :       14557 :               DECL_INITIAL (extp) = NULL_TREE;
    1412                 :       14557 :               DECL_LANG_SPECIFIC (extp) = NULL;
    1413                 :       14557 :               DECL_CONTEXT (extp) = current_function_decl;
    1414                 :       14557 :               if (TREE_CODE (p) == FUNCTION_DECL)
    1415                 :             :                 {
    1416                 :       13027 :                   DECL_RESULT (extp) = NULL_TREE;
    1417                 :       13027 :                   DECL_SAVED_TREE (extp) = NULL_TREE;
    1418                 :       13027 :                   DECL_STRUCT_FUNCTION (extp) = NULL;
    1419                 :             :                 }
    1420                 :       14557 :               if (b->locus != UNKNOWN_LOCATION)
    1421                 :       14557 :                 DECL_SOURCE_LOCATION (extp) = b->locus;
    1422                 :       14557 :               DECL_CHAIN (extp) = BLOCK_VARS (block);
    1423                 :       14557 :               BLOCK_VARS (block) = extp;
    1424                 :             :             }
    1425                 :             :           /* If this is the file scope set DECL_CONTEXT of each decl to
    1426                 :             :              the TRANSLATION_UNIT_DECL.  This makes same_translation_unit_p
    1427                 :             :              work.  */
    1428                 :   596518463 :           if (scope == file_scope)
    1429                 :   247832600 :               DECL_CONTEXT (p) = context;
    1430                 :             : 
    1431                 :   684418740 :           gcc_fallthrough ();
    1432                 :             :           /* Parameters go in DECL_ARGUMENTS, not BLOCK_VARS, and have
    1433                 :             :              already been put there by store_parm_decls.  Unused-
    1434                 :             :              parameter warnings are handled by function.cc.
    1435                 :             :              error_mark_node obviously does not go in BLOCK_VARS and
    1436                 :             :              does not get unused-variable warnings.  */
    1437                 :   684418740 :         case PARM_DECL:
    1438                 :   684418740 :         case ERROR_MARK:
    1439                 :             :           /* It is possible for a decl not to have a name.  We get
    1440                 :             :              here with b->id NULL in this case.  */
    1441                 :   684418740 :           if (b->id)
    1442                 :             :             {
    1443                 :   681426273 :               gcc_assert (I_SYMBOL_BINDING (b->id) == b);
    1444                 :   681426273 :               I_SYMBOL_BINDING (b->id) = b->shadowed;
    1445                 :   681426273 :               if (b->shadowed && b->shadowed->u.type)
    1446                 :     3778141 :                 TREE_TYPE (b->shadowed->decl) = b->shadowed->u.type;
    1447                 :             :             }
    1448                 :             :           break;
    1449                 :             : 
    1450                 :           0 :         default:
    1451                 :           0 :           gcc_unreachable ();
    1452                 :             :         }
    1453                 :             :     }
    1454                 :             : 
    1455                 :             : 
    1456                 :             :   /* Dispose of the block that we just made inside some higher level.  */
    1457                 :    80373585 :   if ((scope->function_body || scope == file_scope) && context)
    1458                 :             :     {
    1459                 :    31864948 :       DECL_INITIAL (context) = block;
    1460                 :    31864948 :       BLOCK_SUPERCONTEXT (block) = context;
    1461                 :             :     }
    1462                 :    48508637 :   else if (scope->outer)
    1463                 :             :     {
    1464                 :    48405587 :       if (block)
    1465                 :      259774 :         SCOPE_LIST_APPEND (scope->outer, blocks, block);
    1466                 :             :       /* If we did not make a block for the scope just exited, any
    1467                 :             :          blocks made for inner scopes must be carried forward so they
    1468                 :             :          will later become subblocks of something else.  */
    1469                 :    48145813 :       else if (scope->blocks)
    1470                 :      332278 :         SCOPE_LIST_CONCAT (scope->outer, blocks, scope, blocks);
    1471                 :             :     }
    1472                 :             : 
    1473                 :             :   /* Pop the current scope, and free the structure for reuse.  */
    1474                 :    80373585 :   current_scope = scope->outer;
    1475                 :    80373585 :   if (scope->function_body)
    1476                 :    31761898 :     current_function_scope = scope->outer_function;
    1477                 :             : 
    1478                 :    80373585 :   memset (scope, 0, sizeof (struct c_scope));
    1479                 :    80373585 :   scope->outer = scope_freelist;
    1480                 :    80373585 :   scope_freelist = scope;
    1481                 :             : 
    1482                 :    80373585 :   return block;
    1483                 :             : }
    1484                 :             : 
    1485                 :             : void
    1486                 :      103557 : push_file_scope (void)
    1487                 :             : {
    1488                 :      103557 :   tree decl;
    1489                 :             : 
    1490                 :      103557 :   if (file_scope)
    1491                 :             :     return;
    1492                 :             : 
    1493                 :      103557 :   push_scope ();
    1494                 :      103557 :   file_scope = current_scope;
    1495                 :             : 
    1496                 :      103557 :   start_fname_decls ();
    1497                 :             : 
    1498                 :   194310463 :   for (decl = visible_builtins; decl; decl = DECL_CHAIN (decl))
    1499                 :   194206906 :     bind (DECL_NAME (decl), decl, file_scope,
    1500                 :   194206906 :           /*invisible=*/false, /*nested=*/true, DECL_SOURCE_LOCATION (decl));
    1501                 :             : }
    1502                 :             : 
    1503                 :             : void
    1504                 :      103411 : pop_file_scope (void)
    1505                 :             : {
    1506                 :             :   /* In case there were missing closebraces, get us back to the global
    1507                 :             :      binding level.  */
    1508                 :      103411 :   while (current_scope != file_scope)
    1509                 :           0 :     pop_scope ();
    1510                 :             : 
    1511                 :             :   /* __FUNCTION__ is defined at file scope ("").  This
    1512                 :             :      call may not be necessary as my tests indicate it
    1513                 :             :      still works without it.  */
    1514                 :      103411 :   finish_fname_decls ();
    1515                 :             : 
    1516                 :      103411 :   check_inline_statics ();
    1517                 :             : 
    1518                 :             :   /* This is the point to write out a PCH if we're doing that.
    1519                 :             :      In that case we do not want to do anything else.  */
    1520                 :      103411 :   if (pch_file)
    1521                 :             :     {
    1522                 :         361 :       c_common_write_pch ();
    1523                 :             :       /* Ensure even the callers don't try to finalize the CU.  */
    1524                 :         361 :       flag_syntax_only = 1;
    1525                 :         361 :       return;
    1526                 :             :     }
    1527                 :             : 
    1528                 :             :   /* Pop off the file scope and close this translation unit.  */
    1529                 :      103050 :   pop_scope ();
    1530                 :      103050 :   file_scope = 0;
    1531                 :             : 
    1532                 :      103050 :   maybe_apply_pending_pragma_weaks ();
    1533                 :             : }
    1534                 :             : 
    1535                 :             : /* Whether we are curently inside the initializer for an
    1536                 :             :    underspecified object definition (C23 auto or constexpr).  */
    1537                 :             : static bool in_underspecified_init;
    1538                 :             : 
    1539                 :             : /* Start an underspecified object definition for NAME at LOC.  This
    1540                 :             :    means that NAME is shadowed inside its initializer, so neither the
    1541                 :             :    definition being initialized, nor any definition from an outer
    1542                 :             :    scope, may be referenced during that initializer.  Return state to
    1543                 :             :    be passed to finish_underspecified_init.  If NAME is NULL_TREE, the
    1544                 :             :    underspecified object is a (constexpr) compound literal; there is
    1545                 :             :    no shadowing in that case, but all the other restrictions on
    1546                 :             :    underspecified object definitions still apply.  */
    1547                 :             : unsigned int
    1548                 :         606 : start_underspecified_init (location_t loc, tree name)
    1549                 :             : {
    1550                 :         606 :   bool prev = in_underspecified_init;
    1551                 :         606 :   bool ok;
    1552                 :         606 :   if (name == NULL_TREE)
    1553                 :             :     ok = true;
    1554                 :             :   else
    1555                 :             :     {
    1556                 :         374 :       tree decl = build_decl (loc, VAR_DECL, name, error_mark_node);
    1557                 :         374 :       C_DECL_UNDERSPECIFIED (decl) = 1;
    1558                 :         374 :       struct c_scope *scope = current_scope;
    1559                 :         374 :       struct c_binding *b = I_SYMBOL_BINDING (name);
    1560                 :         374 :       if (b && B_IN_SCOPE (b, scope))
    1561                 :             :         {
    1562                 :           4 :           error_at (loc, "underspecified declaration of %qE, which is already "
    1563                 :             :                     "declared in this scope", name);
    1564                 :           4 :           ok = false;
    1565                 :             :         }
    1566                 :             :       else
    1567                 :             :         {
    1568                 :         370 :           bind (name, decl, scope, false, false, loc);
    1569                 :         370 :           ok = true;
    1570                 :             :         }
    1571                 :             :     }
    1572                 :         606 :   in_underspecified_init = true;
    1573                 :         606 :   return ok | (prev << 1);
    1574                 :             : }
    1575                 :             : 
    1576                 :             : /* Finish an underspecified object definition for NAME, before that
    1577                 :             :    name is bound to the real declaration instead of a placeholder.
    1578                 :             :    PREV_STATE is the value returned by the call to
    1579                 :             :    start_underspecified_init.  If NAME is NULL_TREE, this means a
    1580                 :             :    compound literal, as for start_underspecified_init.  */
    1581                 :             : void
    1582                 :         606 : finish_underspecified_init (tree name, unsigned int prev_state)
    1583                 :             : {
    1584                 :         606 :   if (name != NULL_TREE && (prev_state & 1))
    1585                 :             :     {
    1586                 :             :       /* A VAR_DECL was bound to the name to shadow any previous
    1587                 :             :          declarations for the name; remove that binding now.  */
    1588                 :         370 :       struct c_scope *scope = current_scope;
    1589                 :         370 :       struct c_binding *b = I_SYMBOL_BINDING (name);
    1590                 :         370 :       gcc_assert (b);
    1591                 :         370 :       gcc_assert (B_IN_SCOPE (b, scope));
    1592                 :         370 :       gcc_assert (VAR_P (b->decl));
    1593                 :         370 :       gcc_assert (C_DECL_UNDERSPECIFIED (b->decl));
    1594                 :         370 :       I_SYMBOL_BINDING (name) = b->shadowed;
    1595                 :             :       /* In erroneous cases there may be other bindings added to this
    1596                 :             :          scope during the initializer.  */
    1597                 :         370 :       struct c_binding **p = &scope->bindings;
    1598                 :         425 :       while (*p != b)
    1599                 :          55 :         p = &((*p)->prev);
    1600                 :         370 :       *p = free_binding_and_advance (*p);
    1601                 :             :     }
    1602                 :         606 :   in_underspecified_init = (prev_state & (1u << 1)) >> 1;
    1603                 :         606 : }
    1604                 :             : 
    1605                 :             : /* Adjust the bindings for the start of a statement expression.  */
    1606                 :             : 
    1607                 :             : void
    1608                 :       33043 : c_bindings_start_stmt_expr (struct c_spot_bindings* switch_bindings)
    1609                 :             : {
    1610                 :       33043 :   struct c_scope *scope;
    1611                 :             : 
    1612                 :      224950 :   for (scope = current_scope; scope != NULL; scope = scope->outer)
    1613                 :             :     {
    1614                 :      191907 :       struct c_binding *b;
    1615                 :             : 
    1616                 :      191907 :       if (!scope->has_label_bindings)
    1617                 :      189539 :         continue;
    1618                 :             : 
    1619                 :       12410 :       for (b = scope->bindings; b != NULL; b = b->prev)
    1620                 :             :         {
    1621                 :       10042 :           struct c_label_vars *label_vars;
    1622                 :       10042 :           unsigned int ix;
    1623                 :       10042 :           struct c_goto_bindings *g;
    1624                 :             : 
    1625                 :       10042 :           if (TREE_CODE (b->decl) != LABEL_DECL)
    1626                 :        1434 :             continue;
    1627                 :        8608 :           label_vars = b->u.label;
    1628                 :        8608 :           ++label_vars->label_bindings.stmt_exprs;
    1629                 :       12578 :           FOR_EACH_VEC_SAFE_ELT (label_vars->gotos, ix, g)
    1630                 :        1795 :             ++g->goto_bindings.stmt_exprs;
    1631                 :             :         }
    1632                 :             :     }
    1633                 :             : 
    1634                 :       33043 :   if (switch_bindings != NULL)
    1635                 :         148 :     ++switch_bindings->stmt_exprs;
    1636                 :       33043 : }
    1637                 :             : 
    1638                 :             : /* Adjust the bindings for the end of a statement expression.  */
    1639                 :             : 
    1640                 :             : void
    1641                 :       33043 : c_bindings_end_stmt_expr (struct c_spot_bindings *switch_bindings)
    1642                 :             : {
    1643                 :       33043 :   struct c_scope *scope;
    1644                 :             : 
    1645                 :      191907 :   for (scope = current_scope; scope != NULL; scope = scope->outer)
    1646                 :             :     {
    1647                 :      158864 :       struct c_binding *b;
    1648                 :             : 
    1649                 :      158864 :       if (!scope->has_label_bindings)
    1650                 :      156262 :         continue;
    1651                 :             : 
    1652                 :       15882 :       for (b = scope->bindings; b != NULL; b = b->prev)
    1653                 :             :         {
    1654                 :       13280 :           struct c_label_vars *label_vars;
    1655                 :       13280 :           unsigned int ix;
    1656                 :       13280 :           struct c_goto_bindings *g;
    1657                 :             : 
    1658                 :       13280 :           if (TREE_CODE (b->decl) != LABEL_DECL)
    1659                 :        1494 :             continue;
    1660                 :       11786 :           label_vars = b->u.label;
    1661                 :       11786 :           --label_vars->label_bindings.stmt_exprs;
    1662                 :       11786 :           if (label_vars->label_bindings.stmt_exprs < 0)
    1663                 :             :             {
    1664                 :        3317 :               label_vars->label_bindings.left_stmt_expr = true;
    1665                 :        3317 :               label_vars->label_bindings.stmt_exprs = 0;
    1666                 :             :             }
    1667                 :       15808 :           FOR_EACH_VEC_SAFE_ELT (label_vars->gotos, ix, g)
    1668                 :             :             {
    1669                 :        1791 :               --g->goto_bindings.stmt_exprs;
    1670                 :        1791 :               if (g->goto_bindings.stmt_exprs < 0)
    1671                 :             :                 {
    1672                 :         128 :                   g->goto_bindings.left_stmt_expr = true;
    1673                 :         128 :                   g->goto_bindings.stmt_exprs = 0;
    1674                 :             :                 }
    1675                 :             :             }
    1676                 :             :         }
    1677                 :             :     }
    1678                 :             : 
    1679                 :       33043 :   if (switch_bindings != NULL)
    1680                 :             :     {
    1681                 :         148 :       --switch_bindings->stmt_exprs;
    1682                 :         148 :       gcc_assert (switch_bindings->stmt_exprs >= 0);
    1683                 :             :     }
    1684                 :       33043 : }
    1685                 :             : 
    1686                 :             : /* Push a definition or a declaration of struct, union or enum tag "name".
    1687                 :             :    "type" should be the type node.
    1688                 :             :    We assume that the tag "name" is not already defined, and has a location
    1689                 :             :    of LOC.
    1690                 :             : 
    1691                 :             :    Note that the definition may really be just a forward reference.
    1692                 :             :    In that case, the TYPE_SIZE will be zero.  */
    1693                 :             : 
    1694                 :             : static void
    1695                 :     1296497 : pushtag (location_t loc, tree name, tree type)
    1696                 :             : {
    1697                 :             :   /* Record the identifier as the type's name if it has none.  */
    1698                 :     1296497 :   if (name && !TYPE_NAME (type))
    1699                 :      586127 :     TYPE_NAME (type) = name;
    1700                 :     1296497 :   bind (name, type, current_scope, /*invisible=*/false, /*nested=*/false, loc);
    1701                 :             : 
    1702                 :             :   /* Create a fake NULL-named TYPE_DECL node whose TREE_TYPE will be the
    1703                 :             :      tagged type we just added to the current scope.  This fake
    1704                 :             :      NULL-named TYPE_DECL node helps dwarfout.c to know when it needs
    1705                 :             :      to output a representation of a tagged type, and it also gives
    1706                 :             :      us a convenient place to record the "scope start" address for the
    1707                 :             :      tagged type.  */
    1708                 :             : 
    1709                 :     1296497 :   TYPE_STUB_DECL (type) = pushdecl (build_decl (loc,
    1710                 :             :                                                 TYPE_DECL, NULL_TREE, type));
    1711                 :             : 
    1712                 :             :   /* An approximation for now, so we can tell this is a function-scope tag.
    1713                 :             :      This will be updated in pop_scope.  */
    1714                 :     1296497 :   TYPE_CONTEXT (type) = DECL_CONTEXT (TYPE_STUB_DECL (type));
    1715                 :             : 
    1716                 :     1296497 :   if (warn_cxx_compat && name != NULL_TREE)
    1717                 :             :     {
    1718                 :         506 :       struct c_binding *b = I_SYMBOL_BINDING (name);
    1719                 :             : 
    1720                 :         506 :       if (b != NULL
    1721                 :          12 :           && b->decl != NULL_TREE
    1722                 :          12 :           && TREE_CODE (b->decl) == TYPE_DECL
    1723                 :          11 :           && (B_IN_CURRENT_SCOPE (b)
    1724                 :           6 :               || (current_scope == file_scope && B_IN_EXTERNAL_SCOPE (b)))
    1725                 :         511 :           && (TYPE_MAIN_VARIANT (TREE_TYPE (b->decl))
    1726                 :           5 :               != TYPE_MAIN_VARIANT (type)))
    1727                 :             :         {
    1728                 :           5 :           auto_diagnostic_group d;
    1729                 :           5 :           if (warning_at (loc, OPT_Wc___compat,
    1730                 :             :                           ("using %qD as both a typedef and a tag is "
    1731                 :             :                            "invalid in C++"), b->decl)
    1732                 :           5 :               && b->locus != UNKNOWN_LOCATION)
    1733                 :           4 :             inform (b->locus, "originally defined here");
    1734                 :           5 :         }
    1735                 :             :     }
    1736                 :     1296497 : }
    1737                 :             : 
    1738                 :             : /* An exported interface to pushtag.  This is used by the gdb plugin's
    1739                 :             :    binding oracle to introduce a new tag binding.  */
    1740                 :             : 
    1741                 :             : void
    1742                 :           0 : c_pushtag (location_t loc, tree name, tree type)
    1743                 :             : {
    1744                 :           0 :   pushtag (loc, name, type);
    1745                 :           0 : }
    1746                 :             : 
    1747                 :             : /* An exported interface to bind a declaration.  LOC is the location
    1748                 :             :    to use.  DECL is the declaration to bind.  The decl's name is used
    1749                 :             :    to determine how it is bound.  If DECL is a VAR_DECL, then
    1750                 :             :    IS_GLOBAL determines whether the decl is put into the global (file
    1751                 :             :    and external) scope or the current function's scope; if DECL is not
    1752                 :             :    a VAR_DECL then it is always put into the file scope.  */
    1753                 :             : 
    1754                 :             : void
    1755                 :           0 : c_bind (location_t loc, tree decl, bool is_global)
    1756                 :             : {
    1757                 :           0 :   struct c_scope *scope;
    1758                 :           0 :   bool nested = false;
    1759                 :             : 
    1760                 :           0 :   if (!VAR_P (decl) || current_function_scope == NULL)
    1761                 :             :     {
    1762                 :             :       /* Types and functions are always considered to be global.  */
    1763                 :           0 :       scope = file_scope;
    1764                 :           0 :       DECL_EXTERNAL (decl) = 1;
    1765                 :           0 :       TREE_PUBLIC (decl) = 1;
    1766                 :             :     }
    1767                 :           0 :   else if (is_global)
    1768                 :             :     {
    1769                 :             :       /* Also bind it into the external scope.  */
    1770                 :           0 :       bind (DECL_NAME (decl), decl, external_scope, true, false, loc);
    1771                 :           0 :       nested = true;
    1772                 :           0 :       scope = file_scope;
    1773                 :           0 :       DECL_EXTERNAL (decl) = 1;
    1774                 :           0 :       TREE_PUBLIC (decl) = 1;
    1775                 :             :     }
    1776                 :             :   else
    1777                 :             :     {
    1778                 :           0 :       DECL_CONTEXT (decl) = current_function_decl;
    1779                 :           0 :       TREE_PUBLIC (decl) = 0;
    1780                 :           0 :       scope = current_function_scope;
    1781                 :             :     }
    1782                 :             : 
    1783                 :           0 :   bind (DECL_NAME (decl), decl, scope, false, nested, loc);
    1784                 :           0 : }
    1785                 :             : 
    1786                 :             : 
    1787                 :             : /* Stores the first FILE*, const struct tm* etc. argument type (whatever
    1788                 :             :    it is) seen in a declaration of a file I/O etc. built-in, corresponding
    1789                 :             :    to the builtin_structptr_types array.  Subsequent declarations of such
    1790                 :             :    built-ins are expected to refer to it rather than to fileptr_type_node,
    1791                 :             :    etc. which is just void* (or to any other type).
    1792                 :             :    Used only by match_builtin_function_types.  */
    1793                 :             : 
    1794                 :             : static const unsigned builtin_structptr_type_count
    1795                 :             :   = ARRAY_SIZE (builtin_structptr_types);
    1796                 :             : 
    1797                 :             : static GTY(()) tree last_structptr_types[builtin_structptr_type_count];
    1798                 :             : 
    1799                 :             : /* Returns true if types T1 and T2 representing return types or types
    1800                 :             :    of function arguments are close enough to be considered interchangeable
    1801                 :             :    in redeclarations of built-in functions.  */
    1802                 :             : 
    1803                 :             : static bool
    1804                 :      590918 : types_close_enough_to_match (tree t1, tree t2)
    1805                 :             : {
    1806                 :      590918 :   return (TYPE_MODE (t1) == TYPE_MODE (t2)
    1807                 :      590605 :           && POINTER_TYPE_P (t1) == POINTER_TYPE_P (t2)
    1808                 :     2362580 :           && FUNCTION_POINTER_TYPE_P (t1) == FUNCTION_POINTER_TYPE_P (t2));
    1809                 :             : }
    1810                 :             : 
    1811                 :             : /* Subroutine of compare_decls.  Allow harmless mismatches in return
    1812                 :             :    and argument types provided that the type modes match.  Set *STRICT
    1813                 :             :    and *ARGNO to the expected argument type and number in case of
    1814                 :             :    an argument type mismatch or null and zero otherwise.  Return
    1815                 :             :    a unified type given a suitable match, and 0 otherwise.  */
    1816                 :             : 
    1817                 :             : static tree
    1818                 :      137031 : match_builtin_function_types (tree newtype, tree oldtype,
    1819                 :             :                               tree *strict, unsigned *argno)
    1820                 :             : {
    1821                 :      137031 :   *argno = 0;
    1822                 :      137031 :   *strict = NULL_TREE;
    1823                 :             : 
    1824                 :             :   /* Accept the return type of the new declaration if it has the same
    1825                 :             :      mode and if they're both pointers or if neither is.  */
    1826                 :      137031 :   tree oldrettype = TREE_TYPE (oldtype);
    1827                 :      137031 :   tree newrettype = TREE_TYPE (newtype);
    1828                 :             : 
    1829                 :      137031 :   if (!types_close_enough_to_match (oldrettype, newrettype))
    1830                 :             :     return NULL_TREE;
    1831                 :             : 
    1832                 :             :   /* Check that the return types are compatible but don't fail if they
    1833                 :             :      are not (e.g., int vs long in ILP32) and just let the caller know.  */
    1834                 :      136690 :   if (!comptypes (TYPE_MAIN_VARIANT (oldrettype),
    1835                 :      136690 :                   TYPE_MAIN_VARIANT (newrettype)))
    1836                 :          38 :     *strict = oldrettype;
    1837                 :             : 
    1838                 :      136690 :   tree oldargs = TYPE_ARG_TYPES (oldtype);
    1839                 :      136690 :   tree newargs = TYPE_ARG_TYPES (newtype);
    1840                 :      136690 :   tree tryargs = newargs;
    1841                 :             : 
    1842                 :      136690 :   const unsigned nlst = ARRAY_SIZE (last_structptr_types);
    1843                 :      136690 :   const unsigned nbst = ARRAY_SIZE (builtin_structptr_types);
    1844                 :             : 
    1845                 :      136690 :   gcc_checking_assert (nlst == nbst);
    1846                 :             : 
    1847                 :      590501 :   for (unsigned i = 1; oldargs || newargs; ++i)
    1848                 :             :     {
    1849                 :      453961 :       if (!oldargs
    1850                 :      453961 :           || !newargs
    1851                 :      453891 :           || !TREE_VALUE (oldargs)
    1852                 :      907852 :           || !TREE_VALUE (newargs))
    1853                 :             :         return NULL_TREE;
    1854                 :             : 
    1855                 :      453891 :       tree oldtype = TYPE_MAIN_VARIANT (TREE_VALUE (oldargs));
    1856                 :      453891 :       tree newtype = TREE_VALUE (newargs);
    1857                 :      453891 :       if (newtype == error_mark_node)
    1858                 :             :        return NULL_TREE;
    1859                 :      453887 :       newtype = TYPE_MAIN_VARIANT (newtype);
    1860                 :             : 
    1861                 :      453887 :       if (!types_close_enough_to_match (oldtype, newtype))
    1862                 :             :         return NULL_TREE;
    1863                 :             : 
    1864                 :      453864 :       unsigned j = nbst;
    1865                 :      453864 :       if (POINTER_TYPE_P (oldtype))
    1866                 :             :         /* Iterate over well-known struct types like FILE (whose types
    1867                 :             :            aren't known to us) and compare the pointer to each to
    1868                 :             :            the pointer argument.  */
    1869                 :      927049 :         for (j = 0; j < nbst; ++j)
    1870                 :             :           {
    1871                 :      816828 :             if (TREE_VALUE (oldargs) != builtin_structptr_types[j].node)
    1872                 :      680496 :               continue;
    1873                 :             :             /* Store the first FILE* etc. argument type (whatever it is), and
    1874                 :             :                expect any subsequent declarations of file I/O etc. built-ins
    1875                 :             :                to refer to it rather than to fileptr_type_node etc. which is
    1876                 :             :                just void* (or const void*).  */
    1877                 :      136332 :             if (last_structptr_types[j])
    1878                 :             :               {
    1879                 :      119576 :                 if (!comptypes (last_structptr_types[j], newtype))
    1880                 :             :                   {
    1881                 :           2 :                     *argno = i;
    1882                 :           2 :                     *strict = last_structptr_types[j];
    1883                 :             :                   }
    1884                 :             :               }
    1885                 :             :             else
    1886                 :       16756 :               last_structptr_types[j] = newtype;
    1887                 :             :             break;
    1888                 :             :           }
    1889                 :             : 
    1890                 :      453864 :       if (j == nbst && !comptypes (oldtype, newtype))
    1891                 :             :         {
    1892                 :         245 :           if (POINTER_TYPE_P (oldtype))
    1893                 :             :             {
    1894                 :             :               /* For incompatible pointers, only reject differences in
    1895                 :             :                  the unqualified variants of the referenced types but
    1896                 :             :                  consider differences in qualifiers as benign (report
    1897                 :             :                  those to caller via *STRICT below).  */
    1898                 :         204 :               tree oldref = TYPE_MAIN_VARIANT (TREE_TYPE (oldtype));
    1899                 :         204 :               tree newref = TYPE_MAIN_VARIANT (TREE_TYPE (newtype));
    1900                 :         204 :               if (!comptypes (oldref, newref))
    1901                 :             :                 return NULL_TREE;
    1902                 :             :             }
    1903                 :             : 
    1904                 :         192 :           if (!*strict)
    1905                 :             :             {
    1906                 :         187 :               *argno = i;
    1907                 :         187 :               *strict = oldtype;
    1908                 :             :             }
    1909                 :             :         }
    1910                 :             : 
    1911                 :      453811 :       oldargs = TREE_CHAIN (oldargs);
    1912                 :      453811 :       newargs = TREE_CHAIN (newargs);
    1913                 :             :     }
    1914                 :             : 
    1915                 :      136540 :   tree trytype = build_function_type (newrettype, tryargs);
    1916                 :             : 
    1917                 :             :   /* Allow declaration to change transaction_safe attribute.  */
    1918                 :      136540 :   tree oldattrs = TYPE_ATTRIBUTES (oldtype);
    1919                 :      136540 :   tree oldtsafe = lookup_attribute ("transaction_safe", oldattrs);
    1920                 :      136540 :   tree newattrs = TYPE_ATTRIBUTES (newtype);
    1921                 :      136540 :   tree newtsafe = lookup_attribute ("transaction_safe", newattrs);
    1922                 :      136540 :   if (oldtsafe && !newtsafe)
    1923                 :           0 :     oldattrs = remove_attribute ("transaction_safe", oldattrs);
    1924                 :      136540 :   else if (newtsafe && !oldtsafe)
    1925                 :           7 :     oldattrs = tree_cons (get_identifier ("transaction_safe"),
    1926                 :             :                           NULL_TREE, oldattrs);
    1927                 :             : 
    1928                 :      136540 :   return build_type_attribute_variant (trytype, oldattrs);
    1929                 :             : }
    1930                 :             : 
    1931                 :             : /* Subroutine of diagnose_mismatched_decls.  Check for function type
    1932                 :             :    mismatch involving an empty arglist vs a nonempty one and give clearer
    1933                 :             :    diagnostics.  */
    1934                 :             : static void
    1935                 :         162 : diagnose_arglist_conflict (tree newdecl, tree olddecl,
    1936                 :             :                            tree newtype, tree oldtype)
    1937                 :             : {
    1938                 :         162 :   tree t;
    1939                 :             : 
    1940                 :         162 :   if (TREE_CODE (olddecl) != FUNCTION_DECL
    1941                 :          92 :       || !comptypes (TREE_TYPE (oldtype), TREE_TYPE (newtype))
    1942                 :         279 :       || !((!prototype_p (oldtype) && DECL_INITIAL (olddecl) == NULL_TREE)
    1943                 :          62 :            || (!prototype_p (newtype) && DECL_INITIAL (newdecl) == NULL_TREE)))
    1944                 :         145 :     return;
    1945                 :             : 
    1946                 :          17 :   t = TYPE_ARG_TYPES (oldtype);
    1947                 :          17 :   if (t == NULL_TREE)
    1948                 :           9 :     t = TYPE_ARG_TYPES (newtype);
    1949                 :          18 :   for (; t; t = TREE_CHAIN (t))
    1950                 :             :     {
    1951                 :          18 :       tree type = TREE_VALUE (t);
    1952                 :             : 
    1953                 :          18 :       if (TREE_CHAIN (t) == NULL_TREE
    1954                 :          18 :           && TYPE_MAIN_VARIANT (type) != void_type_node)
    1955                 :             :         {
    1956                 :          10 :           inform (input_location, "a parameter list with an ellipsis "
    1957                 :             :                   "cannot match an empty parameter name list declaration");
    1958                 :          10 :           break;
    1959                 :             :         }
    1960                 :             : 
    1961                 :           8 :       if (!error_operand_p (type)
    1962                 :           8 :           && c_type_promotes_to (type) != type)
    1963                 :             :         {
    1964                 :           7 :           inform (input_location, "an argument type that has a default "
    1965                 :             :                   "promotion cannot match an empty parameter name list "
    1966                 :             :                   "declaration");
    1967                 :           7 :           break;
    1968                 :             :         }
    1969                 :             :     }
    1970                 :             : }
    1971                 :             : 
    1972                 :             : /* Another subroutine of diagnose_mismatched_decls.  OLDDECL is an
    1973                 :             :    old-style function definition, NEWDECL is a prototype declaration.
    1974                 :             :    Diagnose inconsistencies in the argument list.  Returns TRUE if
    1975                 :             :    the prototype is compatible, FALSE if not.  */
    1976                 :             : static bool
    1977                 :          19 : validate_proto_after_old_defn (tree newdecl, tree newtype, tree oldtype)
    1978                 :             : {
    1979                 :          19 :   tree newargs, oldargs;
    1980                 :          19 :   int i;
    1981                 :             : 
    1982                 :             : #define END_OF_ARGLIST(t) ((t) == void_type_node)
    1983                 :             : 
    1984                 :          19 :   oldargs = TYPE_ACTUAL_ARG_TYPES (oldtype);
    1985                 :          19 :   newargs = TYPE_ARG_TYPES (newtype);
    1986                 :          19 :   i = 1;
    1987                 :             : 
    1988                 :          45 :   for (;;)
    1989                 :             :     {
    1990                 :          32 :       tree oldargtype = TREE_VALUE (oldargs);
    1991                 :          32 :       tree newargtype = TREE_VALUE (newargs);
    1992                 :             : 
    1993                 :          32 :       if (oldargtype == error_mark_node || newargtype == error_mark_node)
    1994                 :             :         return false;
    1995                 :             : 
    1996                 :          31 :       oldargtype = (TYPE_ATOMIC (oldargtype)
    1997                 :          58 :                     ? c_build_qualified_type (TYPE_MAIN_VARIANT (oldargtype),
    1998                 :             :                                               TYPE_QUAL_ATOMIC)
    1999                 :          27 :                     : TYPE_MAIN_VARIANT (oldargtype));
    2000                 :          31 :       newargtype = (TYPE_ATOMIC (newargtype)
    2001                 :          60 :                     ? c_build_qualified_type (TYPE_MAIN_VARIANT (newargtype),
    2002                 :             :                                               TYPE_QUAL_ATOMIC)
    2003                 :          29 :                     : TYPE_MAIN_VARIANT (newargtype));
    2004                 :             : 
    2005                 :          31 :       if (END_OF_ARGLIST (oldargtype) && END_OF_ARGLIST (newargtype))
    2006                 :             :         break;
    2007                 :             : 
    2008                 :             :       /* Reaching the end of just one list means the two decls don't
    2009                 :             :          agree on the number of arguments.  */
    2010                 :          22 :       if (END_OF_ARGLIST (oldargtype))
    2011                 :             :         {
    2012                 :           2 :           error ("prototype for %q+D declares more arguments "
    2013                 :             :                  "than previous old-style definition", newdecl);
    2014                 :           2 :           return false;
    2015                 :             :         }
    2016                 :          20 :       else if (END_OF_ARGLIST (newargtype))
    2017                 :             :         {
    2018                 :           2 :           error ("prototype for %q+D declares fewer arguments "
    2019                 :             :                  "than previous old-style definition", newdecl);
    2020                 :           2 :           return false;
    2021                 :             :         }
    2022                 :             : 
    2023                 :             :       /* Type for passing arg must be consistent with that declared
    2024                 :             :          for the arg.  */
    2025                 :          18 :       else if (!comptypes (oldargtype, newargtype))
    2026                 :             :         {
    2027                 :           5 :           error ("prototype for %q+D declares argument %d"
    2028                 :             :                  " with incompatible type",
    2029                 :             :                  newdecl, i);
    2030                 :           5 :           return false;
    2031                 :             :         }
    2032                 :             : 
    2033                 :          13 :       oldargs = TREE_CHAIN (oldargs);
    2034                 :          13 :       newargs = TREE_CHAIN (newargs);
    2035                 :          13 :       i++;
    2036                 :          13 :     }
    2037                 :             : 
    2038                 :             :   /* If we get here, no errors were found, but do issue a warning
    2039                 :             :      for this poor-style construct.  */
    2040                 :           9 :   warning (0, "prototype for %q+D follows non-prototype definition",
    2041                 :             :            newdecl);
    2042                 :           9 :   return true;
    2043                 :             : #undef END_OF_ARGLIST
    2044                 :             : }
    2045                 :             : 
    2046                 :             : /* Subroutine of diagnose_mismatched_decls.  Report the location of DECL,
    2047                 :             :    first in a pair of mismatched declarations, using the diagnostic
    2048                 :             :    function DIAG.  */
    2049                 :             : static void
    2050                 :         394 : locate_old_decl (tree decl)
    2051                 :             : {
    2052                 :         394 :   if (TREE_CODE (decl) == FUNCTION_DECL
    2053                 :         190 :       && fndecl_built_in_p (decl)
    2054                 :         397 :       && !C_DECL_DECLARED_BUILTIN (decl))
    2055                 :             :     ;
    2056                 :         394 :   else if (DECL_INITIAL (decl))
    2057                 :         115 :     inform (input_location,
    2058                 :             :             "previous definition of %q+D with type %qT",
    2059                 :         115 :             decl, TREE_TYPE (decl));
    2060                 :         279 :   else if (C_DECL_IMPLICIT (decl))
    2061                 :          16 :     inform (input_location,
    2062                 :             :             "previous implicit declaration of %q+D with type %qT",
    2063                 :          16 :             decl, TREE_TYPE (decl));
    2064                 :             :   else
    2065                 :         263 :     inform (input_location,
    2066                 :             :             "previous declaration of %q+D with type %qT",
    2067                 :         263 :             decl, TREE_TYPE (decl));
    2068                 :         394 : }
    2069                 :             : 
    2070                 :             : 
    2071                 :             : /* Helper function.  For a tagged type, it finds the declaration
    2072                 :             :    for a visible tag declared in the the same scope if such a
    2073                 :             :    declaration exists.  */
    2074                 :             : static tree
    2075                 :         911 : previous_tag (tree type)
    2076                 :             : {
    2077                 :         911 :   struct c_binding *b = NULL;
    2078                 :         911 :   tree name = TYPE_NAME (type);
    2079                 :             : 
    2080                 :         911 :   if (name)
    2081                 :         564 :     b = I_TAG_BINDING (name);
    2082                 :             : 
    2083                 :         564 :   if (b)
    2084                 :         564 :     b = b->shadowed;
    2085                 :             : 
    2086                 :         911 :   if (b && B_IN_CURRENT_SCOPE (b))
    2087                 :          82 :     return b->decl;
    2088                 :             : 
    2089                 :             :   return NULL_TREE;
    2090                 :             : }
    2091                 :             : 
    2092                 :             : /* Subroutine of duplicate_decls.  Compare NEWDECL to OLDDECL.
    2093                 :             :    Returns true if the caller should proceed to merge the two, false
    2094                 :             :    if OLDDECL should simply be discarded.  As a side effect, issues
    2095                 :             :    all necessary diagnostics for invalid or poor-style combinations.
    2096                 :             :    If it returns true, writes the types of NEWDECL and OLDDECL to
    2097                 :             :    *NEWTYPEP and *OLDTYPEP - these may have been adjusted from
    2098                 :             :    TREE_TYPE (NEWDECL, OLDDECL) respectively.  */
    2099                 :             : 
    2100                 :             : static bool
    2101                 :     4022870 : diagnose_mismatched_decls (tree newdecl, tree olddecl,
    2102                 :             :                            tree *newtypep, tree *oldtypep)
    2103                 :             : {
    2104                 :     4022870 :   tree newtype, oldtype;
    2105                 :     4022870 :   bool retval = true;
    2106                 :             : 
    2107                 :             : #define DECL_EXTERN_INLINE(DECL) (DECL_DECLARED_INLINE_P (DECL)  \
    2108                 :             :                                   && DECL_EXTERNAL (DECL))
    2109                 :             : 
    2110                 :             :   /* If we have error_mark_node for either decl or type, just discard
    2111                 :             :      the previous decl - we're in an error cascade already.  */
    2112                 :     4022870 :   if (olddecl == error_mark_node || newdecl == error_mark_node)
    2113                 :             :     return false;
    2114                 :     4022855 :   *oldtypep = oldtype = TREE_TYPE (olddecl);
    2115                 :     4022855 :   *newtypep = newtype = TREE_TYPE (newdecl);
    2116                 :     4022855 :   if (oldtype == error_mark_node || newtype == error_mark_node)
    2117                 :             :     return false;
    2118                 :             : 
    2119                 :             :   /* Two different categories of symbol altogether.  This is an error
    2120                 :             :      unless OLDDECL is a builtin.  OLDDECL will be discarded in any case.  */
    2121                 :     4022847 :   if (TREE_CODE (olddecl) != TREE_CODE (newdecl))
    2122                 :             :     {
    2123                 :          26 :       if (!(TREE_CODE (olddecl) == FUNCTION_DECL
    2124                 :          17 :             && fndecl_built_in_p (olddecl)
    2125                 :          15 :             && !C_DECL_DECLARED_BUILTIN (olddecl)))
    2126                 :             :         {
    2127                 :          12 :           auto_diagnostic_group d;
    2128                 :          12 :           error ("%q+D redeclared as different kind of symbol", newdecl);
    2129                 :          12 :           locate_old_decl (olddecl);
    2130                 :          12 :         }
    2131                 :          14 :       else if (TREE_PUBLIC (newdecl))
    2132                 :           3 :         warning (OPT_Wbuiltin_declaration_mismatch,
    2133                 :             :                  "built-in function %q+D declared as non-function",
    2134                 :             :                  newdecl);
    2135                 :             :       else
    2136                 :          11 :         warning (OPT_Wshadow, "declaration of %q+D shadows "
    2137                 :             :                  "a built-in function", newdecl);
    2138                 :          26 :       return false;
    2139                 :             :     }
    2140                 :             : 
    2141                 :             :   /* Enumerators have no linkage, so may only be declared once in a
    2142                 :             :      given scope.  */
    2143                 :     4022821 :   if (TREE_CODE (olddecl) == CONST_DECL)
    2144                 :             :     {
    2145                 :          20 :       if (flag_isoc23
    2146                 :          18 :           && TYPE_NAME (DECL_CONTEXT (newdecl))
    2147                 :          16 :           && DECL_CONTEXT (newdecl) != DECL_CONTEXT (olddecl)
    2148                 :          34 :           && TYPE_NAME (DECL_CONTEXT (newdecl)) == TYPE_NAME (DECL_CONTEXT (olddecl)))
    2149                 :             :         {
    2150                 :          12 :           if (!simple_cst_equal (DECL_INITIAL (olddecl), DECL_INITIAL (newdecl)))
    2151                 :             :             {
    2152                 :           1 :               auto_diagnostic_group d;
    2153                 :           1 :               error ("conflicting redeclaration of enumerator %q+D", newdecl);
    2154                 :           1 :               locate_old_decl (olddecl);
    2155                 :           1 :             }
    2156                 :             :         }
    2157                 :             :       else
    2158                 :             :         {
    2159                 :           8 :           auto_diagnostic_group d;
    2160                 :           8 :           error ("redeclaration of enumerator %q+D", newdecl);
    2161                 :           8 :           locate_old_decl (olddecl);
    2162                 :           8 :         }
    2163                 :          20 :       return false;
    2164                 :             :     }
    2165                 :             : 
    2166                 :     4022801 :   bool pedwarned = false;
    2167                 :     4022801 :   bool warned = false;
    2168                 :     4022801 :   bool enum_and_int_p = false;
    2169                 :     4022801 :   auto_diagnostic_group d;
    2170                 :             : 
    2171                 :     4022801 :   int comptypes_result = comptypes_check_enum_int (oldtype, newtype,
    2172                 :             :                                                    &enum_and_int_p);
    2173                 :     4022801 :   if (!comptypes_result)
    2174                 :             :     {
    2175                 :      137217 :       if (TREE_CODE (olddecl) == FUNCTION_DECL
    2176                 :      137147 :           && fndecl_built_in_p (olddecl, BUILT_IN_NORMAL)
    2177                 :      274249 :           && !C_DECL_DECLARED_BUILTIN (olddecl))
    2178                 :             :         {
    2179                 :             :           /* Accept "harmless" mismatches in function types such
    2180                 :             :              as missing qualifiers or int vs long when they're the same
    2181                 :             :              size.  However, diagnose return and argument types that are
    2182                 :             :              incompatible according to language rules.  */
    2183                 :      137031 :           tree mismatch_expect;
    2184                 :      137031 :           unsigned mismatch_argno;
    2185                 :             : 
    2186                 :      137031 :           tree trytype = match_builtin_function_types (newtype, oldtype,
    2187                 :             :                                                        &mismatch_expect,
    2188                 :             :                                                        &mismatch_argno);
    2189                 :             : 
    2190                 :      137031 :           if (trytype && comptypes (newtype, trytype))
    2191                 :      136540 :             *oldtypep = oldtype = trytype;
    2192                 :             :           else
    2193                 :             :             {
    2194                 :             :               /* If types don't match for a built-in, throw away the
    2195                 :             :                  built-in.  No point in calling locate_old_decl here, it
    2196                 :             :                  won't print anything.  */
    2197                 :         491 :               const char *header = header_for_builtin_fn (olddecl);
    2198                 :         491 :               location_t loc = DECL_SOURCE_LOCATION (newdecl);
    2199                 :         491 :               if (warning_at (loc, OPT_Wbuiltin_declaration_mismatch,
    2200                 :             :                               "conflicting types for built-in function %q+D; "
    2201                 :             :                               "expected %qT",
    2202                 :             :                               newdecl, oldtype)
    2203                 :         491 :                   && header)
    2204                 :             :                 {
    2205                 :             :                   /* Suggest the right header to include as the preferred
    2206                 :             :                      solution rather than the spelling of the declaration.  */
    2207                 :         203 :                   rich_location richloc (line_table, loc);
    2208                 :         203 :                   maybe_add_include_fixit (&richloc, header, true);
    2209                 :         203 :                   inform (&richloc,
    2210                 :             :                           "%qD is declared in header %qs", olddecl, header);
    2211                 :         203 :                 }
    2212                 :         491 :               return false;
    2213                 :             :             }
    2214                 :             : 
    2215                 :      136540 :           if (mismatch_expect && extra_warnings)
    2216                 :             :             {
    2217                 :           5 :               location_t newloc = DECL_SOURCE_LOCATION (newdecl);
    2218                 :           5 :               bool warned = false;
    2219                 :           5 :               if (mismatch_argno)
    2220                 :           5 :                 warned = warning_at (newloc, OPT_Wbuiltin_declaration_mismatch,
    2221                 :             :                                      "mismatch in argument %u type of built-in "
    2222                 :             :                                      "function %qD; expected %qT",
    2223                 :             :                                      mismatch_argno, newdecl, mismatch_expect);
    2224                 :             :               else
    2225                 :           0 :                 warned = warning_at (newloc, OPT_Wbuiltin_declaration_mismatch,
    2226                 :             :                                      "mismatch in return type of built-in "
    2227                 :             :                                      "function %qD; expected %qT",
    2228                 :             :                                      newdecl, mismatch_expect);
    2229                 :           5 :               const char *header = header_for_builtin_fn (olddecl);
    2230                 :           5 :               if (warned && header)
    2231                 :             :                 {
    2232                 :           5 :                   rich_location richloc (line_table, newloc);
    2233                 :           5 :                   maybe_add_include_fixit (&richloc, header, true);
    2234                 :           5 :                   inform (&richloc,
    2235                 :             :                           "%qD is declared in header %qs", olddecl, header);
    2236                 :           5 :                 }
    2237                 :             :             }
    2238                 :             :         }
    2239                 :         186 :       else if (TREE_CODE (olddecl) == FUNCTION_DECL
    2240                 :         186 :                && DECL_IS_UNDECLARED_BUILTIN (olddecl))
    2241                 :             :         {
    2242                 :             :           /* A conflicting function declaration for a predeclared
    2243                 :             :              function that isn't actually built in.  Objective C uses
    2244                 :             :              these.  The new declaration silently overrides everything
    2245                 :             :              but the volatility (i.e. noreturn) indication.  See also
    2246                 :             :              below.  FIXME: Make Objective C use normal builtins.  */
    2247                 :           0 :           TREE_THIS_VOLATILE (newdecl) |= TREE_THIS_VOLATILE (olddecl);
    2248                 :           0 :           return false;
    2249                 :             :         }
    2250                 :             :       /* Permit void foo (...) to match int foo (...) if the latter is
    2251                 :             :          the definition and implicit int was used.  See
    2252                 :             :          c-torture/compile/920625-2.c.  */
    2253                 :         116 :       else if (TREE_CODE (newdecl) == FUNCTION_DECL && DECL_INITIAL (newdecl)
    2254                 :          56 :                && TYPE_MAIN_VARIANT (TREE_TYPE (oldtype)) == void_type_node
    2255                 :          26 :                && TYPE_MAIN_VARIANT (TREE_TYPE (newtype)) == integer_type_node
    2256                 :         192 :                && C_FUNCTION_IMPLICIT_INT (newdecl) && !DECL_INITIAL (olddecl))
    2257                 :             :         {
    2258                 :           5 :           pedwarned = pedwarn (input_location, 0,
    2259                 :             :                                "conflicting types for %q+D", newdecl);
    2260                 :             :           /* Make sure we keep void as the return type.  */
    2261                 :           5 :           TREE_TYPE (newdecl) = *newtypep = newtype = oldtype;
    2262                 :           5 :           C_FUNCTION_IMPLICIT_INT (newdecl) = 0;
    2263                 :             :         }
    2264                 :             :       /* Permit void foo (...) to match an earlier call to foo (...) with
    2265                 :             :          no declared type (thus, implicitly int).  */
    2266                 :         181 :       else if (TREE_CODE (newdecl) == FUNCTION_DECL
    2267                 :         111 :                && TYPE_MAIN_VARIANT (TREE_TYPE (newtype)) == void_type_node
    2268                 :          81 :                && TYPE_MAIN_VARIANT (TREE_TYPE (oldtype)) == integer_type_node
    2269                 :         204 :                && C_DECL_IMPLICIT (olddecl) && !DECL_INITIAL (olddecl))
    2270                 :             :         {
    2271                 :          19 :           pedwarned = pedwarn (input_location, 0,
    2272                 :             :                                "conflicting types for %q+D; have %qT",
    2273                 :             :                                newdecl, newtype);
    2274                 :             :           /* Make sure we keep void as the return type.  */
    2275                 :          19 :           TREE_TYPE (olddecl) = *oldtypep = oldtype = newtype;
    2276                 :             :         }
    2277                 :             :       else
    2278                 :             :         {
    2279                 :         162 :           int new_quals = TYPE_QUALS (newtype);
    2280                 :         162 :           int old_quals = TYPE_QUALS (oldtype);
    2281                 :             : 
    2282                 :         162 :           if (new_quals != old_quals)
    2283                 :             :             {
    2284                 :          20 :               addr_space_t new_addr = DECODE_QUAL_ADDR_SPACE (new_quals);
    2285                 :          20 :               addr_space_t old_addr = DECODE_QUAL_ADDR_SPACE (old_quals);
    2286                 :          20 :               if (new_addr != old_addr)
    2287                 :             :                 {
    2288                 :           0 :                   if (ADDR_SPACE_GENERIC_P (new_addr))
    2289                 :           0 :                     error ("conflicting named address spaces (generic vs %s) "
    2290                 :             :                            "for %q+D",
    2291                 :             :                            c_addr_space_name (old_addr), newdecl);
    2292                 :           0 :                   else if (ADDR_SPACE_GENERIC_P (old_addr))
    2293                 :           0 :                     error ("conflicting named address spaces (%s vs generic) "
    2294                 :             :                            "for %q+D",
    2295                 :             :                            c_addr_space_name (new_addr), newdecl);
    2296                 :             :                   else
    2297                 :           0 :                     error ("conflicting named address spaces (%s vs %s) "
    2298                 :             :                            "for %q+D",
    2299                 :             :                            c_addr_space_name (new_addr),
    2300                 :             :                            c_addr_space_name (old_addr),
    2301                 :             :                            newdecl);
    2302                 :             :                 }
    2303                 :             : 
    2304                 :          20 :               if (CLEAR_QUAL_ADDR_SPACE (new_quals)
    2305                 :          20 :                   != CLEAR_QUAL_ADDR_SPACE (old_quals))
    2306                 :          20 :                 error ("conflicting type qualifiers for %q+D", newdecl);
    2307                 :             :             }
    2308                 :             :           else
    2309                 :         142 :             error ("conflicting types for %q+D; have %qT", newdecl, newtype);
    2310                 :         162 :           diagnose_arglist_conflict (newdecl, olddecl, newtype, oldtype);
    2311                 :         162 :           locate_old_decl (olddecl);
    2312                 :         162 :           return false;
    2313                 :             :         }
    2314                 :             :     }
    2315                 :             :   /* Warn about enum/integer type mismatches.  They are compatible types
    2316                 :             :      (C23 6.7.2.2/5), but may pose portability problems.  */
    2317                 :     3885584 :   else if (enum_and_int_p
    2318                 :         192 :            && TREE_CODE (newdecl) != TYPE_DECL
    2319                 :             :            /* Don't warn about about acc_on_device built-in redeclaration,
    2320                 :             :               the built-in is declared with int rather than enum because
    2321                 :             :               the enum isn't intrinsic.  */
    2322                 :     3885772 :            && !(TREE_CODE (olddecl) == FUNCTION_DECL
    2323                 :         151 :                 && fndecl_built_in_p (olddecl, BUILT_IN_ACC_ON_DEVICE)
    2324                 :         121 :                 && !C_DECL_DECLARED_BUILTIN (olddecl)))
    2325                 :          67 :     warned = warning_at (DECL_SOURCE_LOCATION (newdecl),
    2326                 :             :                          OPT_Wenum_int_mismatch,
    2327                 :             :                          "conflicting types for %q+D due to enum/integer "
    2328                 :             :                          "mismatch; have %qT", newdecl, newtype);
    2329                 :             : 
    2330                 :             :   /* Redeclaration of a type is a constraint violation (6.7.2.3p1),
    2331                 :             :      but silently ignore the redeclaration if either is in a system
    2332                 :             :      header.  (Conflicting redeclarations were handled above.)  This
    2333                 :             :      is allowed for C11 if the types are the same, not just
    2334                 :             :      compatible.  */
    2335                 :     4022148 :   if (TREE_CODE (newdecl) == TYPE_DECL)
    2336                 :             :     {
    2337                 :       95421 :       bool types_different = false;
    2338                 :             : 
    2339                 :       95421 :       comptypes_result
    2340                 :       95421 :         = comptypes_check_different_types (oldtype, newtype, &types_different);
    2341                 :             : 
    2342                 :       95421 :       if (comptypes_result != 1 || types_different)
    2343                 :             :         {
    2344                 :          11 :           error ("redefinition of typedef %q+D with different type", newdecl);
    2345                 :          11 :           locate_old_decl (olddecl);
    2346                 :          11 :           return false;
    2347                 :             :         }
    2348                 :             : 
    2349                 :       95410 :       if (DECL_IN_SYSTEM_HEADER (newdecl)
    2350                 :        2169 :           || DECL_IN_SYSTEM_HEADER (olddecl)
    2351                 :        1963 :           || warning_suppressed_p (newdecl, OPT_Wpedantic)
    2352                 :       97373 :           || warning_suppressed_p (olddecl, OPT_Wpedantic))
    2353                 :       93447 :         return true;  /* Allow OLDDECL to continue in use.  */
    2354                 :             : 
    2355                 :        1963 :       if (c_type_variably_modified_p (newtype))
    2356                 :             :         {
    2357                 :           3 :           error ("redefinition of typedef %q+D with variably modified type",
    2358                 :             :                  newdecl);
    2359                 :           3 :           locate_old_decl (olddecl);
    2360                 :             :         }
    2361                 :        1960 :       else if (pedwarn_c99 (input_location, OPT_Wpedantic,
    2362                 :             :                             "redefinition of typedef %q+D", newdecl))
    2363                 :           8 :         locate_old_decl (olddecl);
    2364                 :             : 
    2365                 :        1963 :       return true;
    2366                 :             :     }
    2367                 :             : 
    2368                 :             :   /* Function declarations can either be 'static' or 'extern' (no
    2369                 :             :      qualifier is equivalent to 'extern' - C99 6.2.2p5) and therefore
    2370                 :             :      can never conflict with each other on account of linkage
    2371                 :             :      (6.2.2p4).  Multiple definitions are not allowed (6.9p3,5) but
    2372                 :             :      gnu89 mode permits two definitions if one is 'extern inline' and
    2373                 :             :      one is not.  The non- extern-inline definition supersedes the
    2374                 :             :      extern-inline definition.  */
    2375                 :             : 
    2376                 :     3926727 :   else if (TREE_CODE (newdecl) == FUNCTION_DECL)
    2377                 :             :     {
    2378                 :             :       /* If you declare a built-in function name as static, or
    2379                 :             :          define the built-in with an old-style definition (so we
    2380                 :             :          can't validate the argument list) the built-in definition is
    2381                 :             :          overridden, but optionally warn this was a bad choice of name.  */
    2382                 :     3909873 :       if (fndecl_built_in_p (olddecl)
    2383                 :     7080842 :           && !C_DECL_DECLARED_BUILTIN (olddecl))
    2384                 :             :         {
    2385                 :     3041838 :           if (!TREE_PUBLIC (newdecl)
    2386                 :     3041838 :               || (DECL_INITIAL (newdecl)
    2387                 :        4587 :                   && !prototype_p (TREE_TYPE (newdecl))))
    2388                 :             :             {
    2389                 :         120 :               warning_at (DECL_SOURCE_LOCATION (newdecl),
    2390                 :             :                           OPT_Wshadow, "declaration of %qD shadows "
    2391                 :             :                           "a built-in function", newdecl);
    2392                 :             :               /* Discard the old built-in function.  */
    2393                 :         120 :               return false;
    2394                 :             :             }
    2395                 :             : 
    2396                 :     3041718 :           if (!prototype_p (TREE_TYPE (newdecl)))
    2397                 :             :             {
    2398                 :             :               /* Set for built-ins that take no arguments.  */
    2399                 :        1075 :               bool func_void_args = false;
    2400                 :        1075 :               if (tree at = TYPE_ARG_TYPES (oldtype))
    2401                 :        1075 :                 func_void_args = VOID_TYPE_P (TREE_VALUE (at));
    2402                 :             : 
    2403                 :        1075 :               if (extra_warnings && !func_void_args)
    2404                 :          47 :                 warning_at (DECL_SOURCE_LOCATION (newdecl),
    2405                 :             :                             OPT_Wbuiltin_declaration_mismatch,
    2406                 :             :                             "declaration of built-in function %qD without "
    2407                 :             :                             "a prototype; expected %qT",
    2408                 :          47 :                             newdecl, TREE_TYPE (olddecl));
    2409                 :             :             }
    2410                 :             :         }
    2411                 :             : 
    2412                 :     3909753 :       if (DECL_INITIAL (newdecl))
    2413                 :             :         {
    2414                 :      218318 :           if (DECL_INITIAL (olddecl))
    2415                 :             :             {
    2416                 :             :               /* If the new declaration isn't overriding an extern inline
    2417                 :             :                  reject the new decl. In c99, no overriding is allowed
    2418                 :             :                  in the same translation unit.  */
    2419                 :         209 :               if (!DECL_EXTERN_INLINE (olddecl)
    2420                 :          91 :                   || DECL_EXTERN_INLINE (newdecl)
    2421                 :         204 :                   || (!flag_gnu89_inline
    2422                 :          15 :                       && (!DECL_DECLARED_INLINE_P (olddecl)
    2423                 :          15 :                           || !lookup_attribute ("gnu_inline",
    2424                 :          15 :                                                 DECL_ATTRIBUTES (olddecl)))
    2425                 :           0 :                       && (!DECL_DECLARED_INLINE_P (newdecl)
    2426                 :           0 :                           || !lookup_attribute ("gnu_inline",
    2427                 :           0 :                                                 DECL_ATTRIBUTES (newdecl)))))
    2428                 :             :                 {
    2429                 :          26 :                   auto_diagnostic_group d;
    2430                 :          26 :                   error ("redefinition of %q+D", newdecl);
    2431                 :          26 :                   locate_old_decl (olddecl);
    2432                 :          26 :                   return false;
    2433                 :          26 :                 }
    2434                 :             :             }
    2435                 :             :         }
    2436                 :             :       /* If we have a prototype after an old-style function definition,
    2437                 :             :          the argument types must be checked specially.  */
    2438                 :     3691435 :       else if (DECL_INITIAL (olddecl)
    2439                 :         805 :                && !prototype_p (oldtype) && prototype_p (newtype)
    2440                 :     3691455 :                && TYPE_ACTUAL_ARG_TYPES (oldtype))
    2441                 :             :         {
    2442                 :          19 :           auto_diagnostic_group d;
    2443                 :          19 :           if (!validate_proto_after_old_defn (newdecl, newtype, oldtype))
    2444                 :             :             {
    2445                 :          10 :               locate_old_decl (olddecl);
    2446                 :          10 :               return false;
    2447                 :             :             }
    2448                 :          19 :         }
    2449                 :             :       /* A non-static declaration (even an "extern") followed by a
    2450                 :             :          static declaration is undefined behavior per C99 6.2.2p3-5,7.
    2451                 :             :          The same is true for a static forward declaration at block
    2452                 :             :          scope followed by a non-static declaration/definition at file
    2453                 :             :          scope.  Static followed by non-static at the same scope is
    2454                 :             :          not undefined behavior, and is the most convenient way to get
    2455                 :             :          some effects (see e.g.  what unwind-dw2-fde-glibc.c does to
    2456                 :             :          the definition of _Unwind_Find_FDE in unwind-dw2-fde.c), but
    2457                 :             :          we do diagnose it if -Wtraditional.  */
    2458                 :     3909717 :       if (TREE_PUBLIC (olddecl) && !TREE_PUBLIC (newdecl))
    2459                 :             :         {
    2460                 :             :           /* Two exceptions to the rule.  If olddecl is an extern
    2461                 :             :              inline, or a predeclared function that isn't actually
    2462                 :             :              built in, newdecl silently overrides olddecl.  The latter
    2463                 :             :              occur only in Objective C; see also above.  (FIXME: Make
    2464                 :             :              Objective C use normal builtins.)  */
    2465                 :          18 :           if (!DECL_IS_UNDECLARED_BUILTIN (olddecl)
    2466                 :          36 :               && !DECL_EXTERN_INLINE (olddecl))
    2467                 :             :             {
    2468                 :           4 :               auto_diagnostic_group d;
    2469                 :           4 :               error ("static declaration of %q+D follows "
    2470                 :             :                      "non-static declaration", newdecl);
    2471                 :           4 :               locate_old_decl (olddecl);
    2472                 :           4 :             }
    2473                 :          18 :           return false;
    2474                 :             :         }
    2475                 :     3909699 :       else if (TREE_PUBLIC (newdecl) && !TREE_PUBLIC (olddecl))
    2476                 :             :         {
    2477                 :        2081 :           if (DECL_CONTEXT (olddecl))
    2478                 :             :             {
    2479                 :           0 :               auto_diagnostic_group d;
    2480                 :           0 :               error ("non-static declaration of %q+D follows "
    2481                 :             :                      "static declaration", newdecl);
    2482                 :           0 :               locate_old_decl (olddecl);
    2483                 :           0 :               return false;
    2484                 :           0 :             }
    2485                 :        2081 :           else if (warn_traditional)
    2486                 :             :             {
    2487                 :           2 :               warned |= warning (OPT_Wtraditional,
    2488                 :             :                                  "non-static declaration of %q+D "
    2489                 :             :                                  "follows static declaration", newdecl);
    2490                 :             :             }
    2491                 :             :         }
    2492                 :             : 
    2493                 :             :       /* Make sure gnu_inline attribute is either not present, or
    2494                 :             :          present on all inline decls.  */
    2495                 :     3909699 :       if (DECL_DECLARED_INLINE_P (olddecl)
    2496                 :     3910756 :           && DECL_DECLARED_INLINE_P (newdecl))
    2497                 :             :         {
    2498                 :         802 :           bool newa = lookup_attribute ("gnu_inline",
    2499                 :         802 :                                         DECL_ATTRIBUTES (newdecl)) != NULL;
    2500                 :         802 :           bool olda = lookup_attribute ("gnu_inline",
    2501                 :         802 :                                         DECL_ATTRIBUTES (olddecl)) != NULL;
    2502                 :         802 :           if (newa != olda)
    2503                 :             :             {
    2504                 :           0 :               auto_diagnostic_group d;
    2505                 :           0 :               error_at (input_location, "%<gnu_inline%> attribute present on %q+D",
    2506                 :             :                         newa ? newdecl : olddecl);
    2507                 :           0 :               error_at (DECL_SOURCE_LOCATION (newa ? olddecl : newdecl),
    2508                 :             :                         "but not here");
    2509                 :           0 :             }
    2510                 :             :         }
    2511                 :             :     }
    2512                 :       16854 :   else if (VAR_P (newdecl))
    2513                 :             :     {
    2514                 :             :       /* Only variables can be thread-local, and all declarations must
    2515                 :             :          agree on this property.  */
    2516                 :       16823 :       if (C_DECL_THREADPRIVATE_P (olddecl) && !DECL_THREAD_LOCAL_P (newdecl))
    2517                 :             :         {
    2518                 :             :           /* Nothing to check.  Since OLDDECL is marked threadprivate
    2519                 :             :              and NEWDECL does not have a thread-local attribute, we
    2520                 :             :              will merge the threadprivate attribute into NEWDECL.  */
    2521                 :             :           ;
    2522                 :             :         }
    2523                 :       50256 :       else if (DECL_THREAD_LOCAL_P (newdecl) != DECL_THREAD_LOCAL_P (olddecl))
    2524                 :             :         {
    2525                 :           6 :           auto_diagnostic_group d;
    2526                 :           6 :           if (DECL_THREAD_LOCAL_P (newdecl))
    2527                 :           3 :             error ("thread-local declaration of %q+D follows "
    2528                 :             :                    "non-thread-local declaration", newdecl);
    2529                 :             :           else
    2530                 :           3 :             error ("non-thread-local declaration of %q+D follows "
    2531                 :             :                    "thread-local declaration", newdecl);
    2532                 :             : 
    2533                 :           6 :           locate_old_decl (olddecl);
    2534                 :           6 :           return false;
    2535                 :           6 :         }
    2536                 :             : 
    2537                 :             :       /* Multiple initialized definitions are not allowed (6.9p3,5).
    2538                 :             :          For this purpose, C23 makes it clear that thread-local
    2539                 :             :          declarations without extern are definitions, not tentative
    2540                 :             :          definitions, whether or not they have initializers.  The
    2541                 :             :          wording before C23 was unclear; literally it would have made
    2542                 :             :          uninitialized thread-local declarations into tentative
    2543                 :             :          definitions only if they also used static, but without saying
    2544                 :             :          explicitly whether or not other cases count as
    2545                 :             :          definitions at all.  */
    2546                 :       17397 :       if ((DECL_INITIAL (newdecl) && DECL_INITIAL (olddecl))
    2547                 :       17396 :           || (flag_isoc23
    2548                 :         199 :               && DECL_THREAD_LOCAL_P (newdecl)
    2549                 :          11 :               && !DECL_EXTERNAL (newdecl)
    2550                 :           7 :               && !DECL_EXTERNAL (olddecl)))
    2551                 :             :         {
    2552                 :           7 :           auto_diagnostic_group d;
    2553                 :           7 :           error ("redefinition of %q+D", newdecl);
    2554                 :           7 :           locate_old_decl (olddecl);
    2555                 :           7 :           return false;
    2556                 :           7 :         }
    2557                 :             : 
    2558                 :             :       /* Objects declared at file scope: if the first declaration had
    2559                 :             :          external linkage (even if it was an external reference) the
    2560                 :             :          second must have external linkage as well, or the behavior is
    2561                 :             :          undefined.  If the first declaration had internal linkage, then
    2562                 :             :          the second must too, or else be an external reference (in which
    2563                 :             :          case the composite declaration still has internal linkage).
    2564                 :             :          As for function declarations, we warn about the static-then-
    2565                 :             :          extern case only for -Wtraditional.  See generally 6.2.2p3-5,7.  */
    2566                 :       16827 :       if (DECL_FILE_SCOPE_P (newdecl)
    2567                 :       16810 :           && TREE_PUBLIC (newdecl) != TREE_PUBLIC (olddecl))
    2568                 :             :         {
    2569                 :         141 :           if (DECL_EXTERNAL (newdecl))
    2570                 :             :             {
    2571                 :         139 :               if (!DECL_FILE_SCOPE_P (olddecl))
    2572                 :             :                 {
    2573                 :           2 :                   auto_diagnostic_group d;
    2574                 :           2 :                   error ("extern declaration of %q+D follows "
    2575                 :             :                          "declaration with no linkage", newdecl);
    2576                 :           2 :                   locate_old_decl (olddecl);
    2577                 :           2 :                   return false;
    2578                 :           2 :                 }
    2579                 :         137 :               else if (warn_traditional)
    2580                 :             :                 {
    2581                 :           0 :                   warned |= warning (OPT_Wtraditional,
    2582                 :             :                                      "non-static declaration of %q+D "
    2583                 :             :                                      "follows static declaration", newdecl);
    2584                 :             :                 }
    2585                 :             :             }
    2586                 :             :           else
    2587                 :             :             {
    2588                 :           2 :               auto_diagnostic_group d;
    2589                 :           2 :               if (TREE_PUBLIC (newdecl))
    2590                 :           2 :                 error ("non-static declaration of %q+D follows "
    2591                 :             :                        "static declaration", newdecl);
    2592                 :             :               else
    2593                 :           0 :                 error ("static declaration of %q+D follows "
    2594                 :             :                        "non-static declaration", newdecl);
    2595                 :             : 
    2596                 :           2 :               locate_old_decl (olddecl);
    2597                 :           2 :               return false;
    2598                 :           2 :             }
    2599                 :             :         }
    2600                 :             :       /* Two objects with the same name declared at the same block
    2601                 :             :          scope must both be external references (6.7p3).  */
    2602                 :       16669 :       else if (!DECL_FILE_SCOPE_P (newdecl))
    2603                 :             :         {
    2604                 :          17 :           if (DECL_EXTERNAL (newdecl))
    2605                 :             :             {
    2606                 :             :               /* Extern with initializer at block scope, which will
    2607                 :             :                  already have received an error.  */
    2608                 :             :             }
    2609                 :          15 :           else if (DECL_EXTERNAL (olddecl))
    2610                 :             :             {
    2611                 :           4 :               auto_diagnostic_group d;
    2612                 :           4 :               error ("declaration of %q+D with no linkage follows "
    2613                 :             :                      "extern declaration", newdecl);
    2614                 :           4 :               locate_old_decl (olddecl);
    2615                 :           4 :             }
    2616                 :             :           else
    2617                 :             :             {
    2618                 :          11 :               auto_diagnostic_group d;
    2619                 :          11 :               error ("redeclaration of %q+D with no linkage", newdecl);
    2620                 :          11 :               locate_old_decl (olddecl);
    2621                 :          11 :             }
    2622                 :             : 
    2623                 :          17 :           return false;
    2624                 :             :         }
    2625                 :             : 
    2626                 :             :       /* C++ does not permit a decl to appear multiple times at file
    2627                 :             :          scope.  */
    2628                 :       16789 :       if (warn_cxx_compat
    2629                 :          32 :           && DECL_FILE_SCOPE_P (newdecl)
    2630                 :          32 :           && !DECL_EXTERNAL (newdecl)
    2631                 :       16799 :           && !DECL_EXTERNAL (olddecl))
    2632                 :           5 :         warned |= warning_at (DECL_SOURCE_LOCATION (newdecl),
    2633                 :             :                               OPT_Wc___compat,
    2634                 :             :                               ("duplicate declaration of %qD is "
    2635                 :             :                                "invalid in C++"),
    2636                 :             :                               newdecl);
    2637                 :             :     }
    2638                 :             : 
    2639                 :             :   /* warnings */
    2640                 :             :   /* All decls must agree on a visibility.  */
    2641                 :     3926519 :   if (CODE_CONTAINS_STRUCT (TREE_CODE (newdecl), TS_DECL_WITH_VIS)
    2642                 :     3926488 :       && DECL_VISIBILITY_SPECIFIED (newdecl) && DECL_VISIBILITY_SPECIFIED (olddecl)
    2643                 :     3927246 :       && DECL_VISIBILITY (newdecl) != DECL_VISIBILITY (olddecl))
    2644                 :             :     {
    2645                 :           1 :       warned |= warning (0, "redeclaration of %q+D with different visibility "
    2646                 :             :                          "(old visibility preserved)", newdecl);
    2647                 :             :     }
    2648                 :             : 
    2649                 :     3926519 :   if (TREE_CODE (newdecl) == FUNCTION_DECL)
    2650                 :     3909699 :     warned |= diagnose_mismatched_attributes (olddecl, newdecl);
    2651                 :             :   else /* PARM_DECL, VAR_DECL */
    2652                 :             :     {
    2653                 :             :       /* Redeclaration of a parameter is a constraint violation (this is
    2654                 :             :          not explicitly stated, but follows from C99 6.7p3 [no more than
    2655                 :             :          one declaration of the same identifier with no linkage in the
    2656                 :             :          same scope, except type tags] and 6.2.2p6 [parameters have no
    2657                 :             :          linkage]).  We must check for a forward parameter declaration,
    2658                 :             :          indicated by TREE_ASM_WRITTEN on the old declaration - this is
    2659                 :             :          an extension, the mandatory diagnostic for which is handled by
    2660                 :             :          mark_forward_parm_decls.  */
    2661                 :             : 
    2662                 :       16820 :       if (TREE_CODE (newdecl) == PARM_DECL
    2663                 :          31 :           && (!TREE_ASM_WRITTEN (olddecl) || TREE_ASM_WRITTEN (newdecl)))
    2664                 :             :         {
    2665                 :           2 :           auto_diagnostic_group d;
    2666                 :           2 :           error ("redefinition of parameter %q+D", newdecl);
    2667                 :           2 :           locate_old_decl (olddecl);
    2668                 :           2 :           return false;
    2669                 :           2 :         }
    2670                 :             :     }
    2671                 :             : 
    2672                 :             :   /* Optional warning for completely redundant decls.  */
    2673                 :     3926517 :   if (!warned && !pedwarned
    2674                 :     3926443 :       && warn_redundant_decls
    2675                 :             :       /* Don't warn about a function declaration followed by a
    2676                 :             :          definition.  */
    2677                 :          18 :       && !(TREE_CODE (newdecl) == FUNCTION_DECL
    2678                 :           2 :            && DECL_INITIAL (newdecl) && !DECL_INITIAL (olddecl))
    2679                 :             :       /* Don't warn about redundant redeclarations of builtins.  */
    2680                 :          18 :       && !(TREE_CODE (newdecl) == FUNCTION_DECL
    2681                 :           2 :            && !fndecl_built_in_p (newdecl)
    2682                 :           2 :            && fndecl_built_in_p (olddecl)
    2683                 :           2 :            && !C_DECL_DECLARED_BUILTIN (olddecl))
    2684                 :             :       /* Don't warn about an extern followed by a definition.  */
    2685                 :          17 :       && !(DECL_EXTERNAL (olddecl) && !DECL_EXTERNAL (newdecl))
    2686                 :             :       /* Don't warn about forward parameter decls.  */
    2687                 :          17 :       && !(TREE_CODE (newdecl) == PARM_DECL
    2688                 :           6 :            && TREE_ASM_WRITTEN (olddecl) && !TREE_ASM_WRITTEN (newdecl))
    2689                 :             :       /* Don't warn about a variable definition following a declaration.  */
    2690                 :     3926528 :       && !(VAR_P (newdecl)
    2691                 :          10 :            && DECL_INITIAL (newdecl) && !DECL_INITIAL (olddecl)))
    2692                 :             :     {
    2693                 :           6 :       warned = warning (OPT_Wredundant_decls, "redundant redeclaration of %q+D",
    2694                 :             :                         newdecl);
    2695                 :             :     }
    2696                 :             : 
    2697                 :             :   /* Report location of previous decl/defn.  */
    2698                 :     3926517 :   if (warned || pedwarned)
    2699                 :          80 :     locate_old_decl (olddecl);
    2700                 :             : 
    2701                 :             : #undef DECL_EXTERN_INLINE
    2702                 :             : 
    2703                 :             :   return retval;
    2704                 :     4022801 : }
    2705                 :             : 
    2706                 :             : /* Subroutine of duplicate_decls.  NEWDECL has been found to be
    2707                 :             :    consistent with OLDDECL, but carries new information.  Merge the
    2708                 :             :    new information into OLDDECL.  This function issues no
    2709                 :             :    diagnostics.  */
    2710                 :             : 
    2711                 :             : static void
    2712                 :     4021927 : merge_decls (tree newdecl, tree olddecl, tree newtype, tree oldtype)
    2713                 :             : {
    2714                 :     4021927 :   bool new_is_definition = (TREE_CODE (newdecl) == FUNCTION_DECL
    2715                 :     4021927 :                             && DECL_INITIAL (newdecl) != NULL_TREE);
    2716                 :     4021927 :   bool new_is_prototype = (TREE_CODE (newdecl) == FUNCTION_DECL
    2717                 :     4021927 :                            && prototype_p (TREE_TYPE (newdecl)));
    2718                 :     4021927 :   bool old_is_prototype = (TREE_CODE (olddecl) == FUNCTION_DECL
    2719                 :     4021927 :                            && prototype_p (TREE_TYPE (olddecl)));
    2720                 :             : 
    2721                 :             :   /* For real parm decl following a forward decl, rechain the old decl
    2722                 :             :      in its new location and clear TREE_ASM_WRITTEN (it's not a
    2723                 :             :      forward decl anymore).  */
    2724                 :     4021927 :   if (TREE_CODE (newdecl) == PARM_DECL
    2725                 :          29 :       && TREE_ASM_WRITTEN (olddecl) && !TREE_ASM_WRITTEN (newdecl))
    2726                 :             :     {
    2727                 :          29 :       struct c_binding *b, **here;
    2728                 :             : 
    2729                 :          44 :       for (here = &current_scope->bindings; *here; here = &(*here)->prev)
    2730                 :          44 :         if ((*here)->decl == olddecl)
    2731                 :          29 :           goto found;
    2732                 :           0 :       gcc_unreachable ();
    2733                 :             : 
    2734                 :          29 :     found:
    2735                 :          29 :       b = *here;
    2736                 :          29 :       *here = b->prev;
    2737                 :          29 :       b->prev = current_scope->bindings;
    2738                 :          29 :       current_scope->bindings = b;
    2739                 :             : 
    2740                 :          29 :       TREE_ASM_WRITTEN (olddecl) = 0;
    2741                 :             :     }
    2742                 :             : 
    2743                 :     4021927 :   DECL_ATTRIBUTES (newdecl)
    2744                 :     4021927 :     = targetm.merge_decl_attributes (olddecl, newdecl);
    2745                 :             : 
    2746                 :             :   /* For typedefs use the old type, as the new type's DECL_NAME points
    2747                 :             :      at newdecl, which will be ggc_freed.  */
    2748                 :     4021927 :   if (TREE_CODE (newdecl) == TYPE_DECL)
    2749                 :             :     {
    2750                 :             :       /* But NEWTYPE might have an attribute, honor that.  */
    2751                 :       95410 :       tree tem = newtype;
    2752                 :       95410 :       newtype = oldtype;
    2753                 :             : 
    2754                 :       95410 :       if (TYPE_USER_ALIGN (tem))
    2755                 :             :         {
    2756                 :           6 :           if (TYPE_ALIGN (tem) > TYPE_ALIGN (newtype))
    2757                 :           2 :             SET_TYPE_ALIGN (newtype, TYPE_ALIGN (tem));
    2758                 :           6 :           TYPE_USER_ALIGN (newtype) = true;
    2759                 :             :         }
    2760                 :             : 
    2761                 :             :       /* And remove the new type from the variants list.  */
    2762                 :       95410 :       if (TYPE_NAME (TREE_TYPE (newdecl)) == newdecl)
    2763                 :             :         {
    2764                 :           6 :           tree remove = TREE_TYPE (newdecl);
    2765                 :           6 :           if (TYPE_MAIN_VARIANT (remove) == remove)
    2766                 :             :             {
    2767                 :           2 :               gcc_assert (TYPE_NEXT_VARIANT (remove) == NULL_TREE);
    2768                 :             :               /* If remove is the main variant, no need to remove that
    2769                 :             :                  from the list.  One of the DECL_ORIGINAL_TYPE
    2770                 :             :                  variants, e.g. created for aligned attribute, might still
    2771                 :             :                  refer to the newdecl TYPE_DECL though, so remove that one
    2772                 :             :                  in that case.  */
    2773                 :           2 :               if (DECL_ORIGINAL_TYPE (newdecl)
    2774                 :           2 :                   && DECL_ORIGINAL_TYPE (newdecl) != remove)
    2775                 :           2 :                 for (tree t = TYPE_MAIN_VARIANT (DECL_ORIGINAL_TYPE (newdecl));
    2776                 :           2 :                      t; t = TYPE_MAIN_VARIANT (t))
    2777                 :           2 :                   if (TYPE_NAME (TYPE_NEXT_VARIANT (t)) == newdecl)
    2778                 :             :                     {
    2779                 :           4 :                       TYPE_NEXT_VARIANT (t)
    2780                 :           2 :                         = TYPE_NEXT_VARIANT (TYPE_NEXT_VARIANT (t));
    2781                 :           2 :                       break;
    2782                 :             :                     }
    2783                 :             :             }       
    2784                 :             :           else
    2785                 :           4 :             for (tree t = TYPE_MAIN_VARIANT (remove); ;
    2786                 :           0 :                  t = TYPE_NEXT_VARIANT (t))
    2787                 :           4 :               if (TYPE_NEXT_VARIANT (t) == remove)
    2788                 :             :                 {
    2789                 :           4 :                   TYPE_NEXT_VARIANT (t) = TYPE_NEXT_VARIANT (remove);
    2790                 :           4 :                   break;
    2791                 :             :                 }
    2792                 :             :         }
    2793                 :             :     }
    2794                 :             : 
    2795                 :             :   /* Merge the data types specified in the two decls.  */
    2796                 :     8043854 :   TREE_TYPE (newdecl)
    2797                 :     4021927 :     = TREE_TYPE (olddecl)
    2798                 :     8043854 :     = composite_type (newtype, oldtype);
    2799                 :             : 
    2800                 :             :   /* Lay the type out, unless already done.  */
    2801                 :     4021927 :   if (!comptypes (oldtype, TREE_TYPE (newdecl)))
    2802                 :             :     {
    2803                 :           2 :       if (TREE_TYPE (newdecl) != error_mark_node)
    2804                 :           2 :         layout_type (TREE_TYPE (newdecl));
    2805                 :           2 :       if (TREE_CODE (newdecl) != FUNCTION_DECL
    2806                 :             :           && TREE_CODE (newdecl) != TYPE_DECL
    2807                 :             :           && TREE_CODE (newdecl) != CONST_DECL)
    2808                 :           0 :         layout_decl (newdecl, 0);
    2809                 :             :     }
    2810                 :             :   else
    2811                 :             :     {
    2812                 :             :       /* Since the type is OLDDECL's, make OLDDECL's size go with.  */
    2813                 :     4021925 :       DECL_SIZE (newdecl) = DECL_SIZE (olddecl);
    2814                 :     4021925 :       DECL_SIZE_UNIT (newdecl) = DECL_SIZE_UNIT (olddecl);
    2815                 :     4021925 :       SET_DECL_MODE (newdecl, DECL_MODE (olddecl));
    2816                 :     4021925 :       if (DECL_ALIGN (olddecl) > DECL_ALIGN (newdecl))
    2817                 :             :         {
    2818                 :          44 :           SET_DECL_ALIGN (newdecl, DECL_ALIGN (olddecl));
    2819                 :          44 :           DECL_USER_ALIGN (newdecl) |= DECL_USER_ALIGN (olddecl);
    2820                 :             :         }
    2821                 :     4021881 :       else if (DECL_ALIGN (olddecl) == DECL_ALIGN (newdecl)
    2822                 :     4021881 :                && DECL_USER_ALIGN (olddecl) != DECL_USER_ALIGN (newdecl))
    2823                 :           3 :         DECL_USER_ALIGN (newdecl) = 1;
    2824                 :     8043850 :       if (DECL_WARN_IF_NOT_ALIGN (olddecl)
    2825                 :     4021925 :           > DECL_WARN_IF_NOT_ALIGN (newdecl))
    2826                 :           0 :         SET_DECL_WARN_IF_NOT_ALIGN (newdecl,
    2827                 :             :                                     DECL_WARN_IF_NOT_ALIGN (olddecl));
    2828                 :             :     }
    2829                 :             : 
    2830                 :             :   /* Keep the old rtl since we can safely use it.  */
    2831                 :     4021927 :   if (HAS_RTL_P (olddecl))
    2832                 :     4021927 :     COPY_DECL_RTL (olddecl, newdecl);
    2833                 :             : 
    2834                 :             :   /* Merge the type qualifiers.  */
    2835                 :     4021927 :   if (TREE_READONLY (newdecl))
    2836                 :      338960 :     TREE_READONLY (olddecl) = 1;
    2837                 :             : 
    2838                 :     4021927 :   if (TREE_THIS_VOLATILE (newdecl))
    2839                 :       46614 :     TREE_THIS_VOLATILE (olddecl) = 1;
    2840                 :             : 
    2841                 :             :   /* Merge deprecatedness.  */
    2842                 :     4021927 :   if (TREE_DEPRECATED (newdecl))
    2843                 :         331 :     TREE_DEPRECATED (olddecl) = 1;
    2844                 :             : 
    2845                 :             :   /* Merge unavailability.  */
    2846                 :     4021927 :   if (TREE_UNAVAILABLE (newdecl))
    2847                 :           2 :     TREE_UNAVAILABLE (olddecl) = 1;
    2848                 :             : 
    2849                 :             :   /* If a decl is in a system header and the other isn't, keep the one on the
    2850                 :             :      system header. Otherwise, keep source location of definition rather than
    2851                 :             :      declaration and of prototype rather than non-prototype unless that
    2852                 :             :      prototype is built-in.  */
    2853                 :     4021927 :   if (HAS_DECL_ASSEMBLER_NAME_P (olddecl)
    2854                 :     4021898 :       && DECL_IN_SYSTEM_HEADER (olddecl)
    2855                 :     4418113 :       && !DECL_IN_SYSTEM_HEADER (newdecl) )
    2856                 :         998 :     DECL_SOURCE_LOCATION (newdecl) = DECL_SOURCE_LOCATION (olddecl);
    2857                 :     4020929 :   else if (HAS_DECL_ASSEMBLER_NAME_P (olddecl)
    2858                 :     4020900 :            && DECL_IN_SYSTEM_HEADER (newdecl)
    2859                 :     7407951 :            && !DECL_IN_SYSTEM_HEADER (olddecl))
    2860                 :     2991834 :     DECL_SOURCE_LOCATION (olddecl) = DECL_SOURCE_LOCATION (newdecl);
    2861                 :     1029095 :   else if ((DECL_INITIAL (newdecl) == NULL_TREE
    2862                 :      810298 :             && DECL_INITIAL (olddecl) != NULL_TREE)
    2863                 :     1838492 :            || (old_is_prototype && !new_is_prototype
    2864                 :        1176 :                && !C_DECL_BUILTIN_PROTOTYPE (olddecl)))
    2865                 :        1000 :     DECL_SOURCE_LOCATION (newdecl) = DECL_SOURCE_LOCATION (olddecl);
    2866                 :             : 
    2867                 :             :   /* Merge the initialization information.  */
    2868                 :     4021927 :    if (DECL_INITIAL (newdecl) == NULL_TREE)
    2869                 :     3803058 :     DECL_INITIAL (newdecl) = DECL_INITIAL (olddecl);
    2870                 :             : 
    2871                 :             :   /* Merge 'constexpr' information.  */
    2872                 :     4021927 :   if (VAR_P (olddecl) && VAR_P (newdecl))
    2873                 :             :     {
    2874                 :       16789 :       if (C_DECL_DECLARED_CONSTEXPR (olddecl))
    2875                 :           2 :         C_DECL_DECLARED_CONSTEXPR (newdecl) = 1;
    2876                 :       16787 :       else if (C_DECL_DECLARED_CONSTEXPR (newdecl))
    2877                 :           1 :         C_DECL_DECLARED_CONSTEXPR (olddecl) = 1;
    2878                 :             :     }
    2879                 :             : 
    2880                 :             :   /* Merge the threadprivate attribute.  */
    2881                 :     4021927 :   if (VAR_P (olddecl) && C_DECL_THREADPRIVATE_P (olddecl))
    2882                 :           7 :     C_DECL_THREADPRIVATE_P (newdecl) = 1;
    2883                 :             : 
    2884                 :     4021927 :   if (HAS_DECL_ASSEMBLER_NAME_P (olddecl))
    2885                 :             :     {
    2886                 :             :       /* Copy the assembler name.
    2887                 :             :          Currently, it can only be defined in the prototype.  */
    2888                 :     4021898 :       COPY_DECL_ASSEMBLER_NAME (olddecl, newdecl);
    2889                 :             : 
    2890                 :             :       /* Use visibility of whichever declaration had it specified */
    2891                 :     4021898 :       if (DECL_VISIBILITY_SPECIFIED (olddecl))
    2892                 :             :         {
    2893                 :        4709 :           DECL_VISIBILITY (newdecl) = DECL_VISIBILITY (olddecl);
    2894                 :        4709 :           DECL_VISIBILITY_SPECIFIED (newdecl) = 1;
    2895                 :             :         }
    2896                 :             : 
    2897                 :     4021898 :       if (TREE_CODE (newdecl) == FUNCTION_DECL)
    2898                 :             :         {
    2899                 :     3909699 :           DECL_STATIC_CONSTRUCTOR(newdecl) |= DECL_STATIC_CONSTRUCTOR(olddecl);
    2900                 :     3909699 :           DECL_STATIC_DESTRUCTOR (newdecl) |= DECL_STATIC_DESTRUCTOR (olddecl);
    2901                 :     3909699 :           DECL_NO_LIMIT_STACK (newdecl) |= DECL_NO_LIMIT_STACK (olddecl);
    2902                 :     3909699 :           DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (newdecl)
    2903                 :     3909699 :             |= DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (olddecl);
    2904                 :     3909699 :           TREE_THIS_VOLATILE (newdecl) |= TREE_THIS_VOLATILE (olddecl);
    2905                 :     3909699 :           DECL_IS_MALLOC (newdecl) |= DECL_IS_MALLOC (olddecl);
    2906                 :     3909699 :           if (DECL_IS_OPERATOR_NEW_P (olddecl))
    2907                 :           0 :             DECL_SET_IS_OPERATOR_NEW (newdecl, true);
    2908                 :     3909699 :           if (DECL_IS_OPERATOR_DELETE_P (olddecl))
    2909                 :           0 :             DECL_SET_IS_OPERATOR_DELETE (newdecl, true);
    2910                 :     3909699 :           TREE_READONLY (newdecl) |= TREE_READONLY (olddecl);
    2911                 :     3909699 :           DECL_PURE_P (newdecl) |= DECL_PURE_P (olddecl);
    2912                 :     3909699 :           DECL_IS_NOVOPS (newdecl) |= DECL_IS_NOVOPS (olddecl);
    2913                 :             :         }
    2914                 :             : 
    2915                 :             :       /* Merge the storage class information.  */
    2916                 :     4021898 :       merge_weak (newdecl, olddecl);
    2917                 :             : 
    2918                 :             :       /* For functions, static overrides non-static.  */
    2919                 :     4021898 :       if (TREE_CODE (newdecl) == FUNCTION_DECL)
    2920                 :             :         {
    2921                 :     3909699 :           TREE_PUBLIC (newdecl) &= TREE_PUBLIC (olddecl);
    2922                 :             :           /* This is since we don't automatically
    2923                 :             :              copy the attributes of NEWDECL into OLDDECL.  */
    2924                 :     3909699 :           TREE_PUBLIC (olddecl) = TREE_PUBLIC (newdecl);
    2925                 :             :           /* If this clears `static', clear it in the identifier too.  */
    2926                 :     3909699 :           if (!TREE_PUBLIC (olddecl))
    2927                 :        7577 :             TREE_PUBLIC (DECL_NAME (olddecl)) = 0;
    2928                 :             :         }
    2929                 :             :     }
    2930                 :             : 
    2931                 :             :   /* In c99, 'extern' declaration before (or after) 'inline' means this
    2932                 :             :      function is not DECL_EXTERNAL, unless 'gnu_inline' attribute
    2933                 :             :      is present.  */
    2934                 :     4021927 :   if (TREE_CODE (newdecl) == FUNCTION_DECL
    2935                 :     3909699 :       && !flag_gnu89_inline
    2936                 :     3888745 :       && (DECL_DECLARED_INLINE_P (newdecl)
    2937                 :     3711441 :           || DECL_DECLARED_INLINE_P (olddecl))
    2938                 :      177498 :       && (!DECL_DECLARED_INLINE_P (newdecl)
    2939                 :      177304 :           || !DECL_DECLARED_INLINE_P (olddecl)
    2940                 :         789 :           || !DECL_EXTERNAL (olddecl))
    2941                 :      176727 :       && DECL_EXTERNAL (newdecl)
    2942                 :      176519 :       && !lookup_attribute ("gnu_inline", DECL_ATTRIBUTES (newdecl))
    2943                 :     4022024 :       && !current_function_decl)
    2944                 :          80 :     DECL_EXTERNAL (newdecl) = 0;
    2945                 :             : 
    2946                 :             :   /* An inline definition following a static declaration is not
    2947                 :             :      DECL_EXTERNAL.  */
    2948                 :     4021927 :   if (new_is_definition
    2949                 :      218275 :       && (DECL_DECLARED_INLINE_P (newdecl)
    2950                 :       40749 :           || DECL_DECLARED_INLINE_P (olddecl))
    2951                 :     4199667 :       && !TREE_PUBLIC (olddecl))
    2952                 :         882 :     DECL_EXTERNAL (newdecl) = 0;
    2953                 :             : 
    2954                 :     4021927 :   if (DECL_EXTERNAL (newdecl))
    2955                 :             :     {
    2956                 :     3882583 :       TREE_STATIC (newdecl) = TREE_STATIC (olddecl);
    2957                 :     3882583 :       DECL_EXTERNAL (newdecl) = DECL_EXTERNAL (olddecl);
    2958                 :             : 
    2959                 :             :       /* An extern decl does not override previous storage class.  */
    2960                 :     3882583 :       TREE_PUBLIC (newdecl) = TREE_PUBLIC (olddecl);
    2961                 :     3882583 :       if (!DECL_EXTERNAL (newdecl))
    2962                 :             :         {
    2963                 :        1394 :           DECL_CONTEXT (newdecl) = DECL_CONTEXT (olddecl);
    2964                 :        1394 :           DECL_COMMON (newdecl) = DECL_COMMON (olddecl);
    2965                 :             :         }
    2966                 :             :     }
    2967                 :             :   else
    2968                 :             :     {
    2969                 :      139344 :       TREE_STATIC (olddecl) = TREE_STATIC (newdecl);
    2970                 :      139344 :       TREE_PUBLIC (olddecl) = TREE_PUBLIC (newdecl);
    2971                 :             :     }
    2972                 :             : 
    2973                 :     4021927 :   if (TREE_CODE (newdecl) == FUNCTION_DECL)
    2974                 :             :     {
    2975                 :             :       /* If we're redefining a function previously defined as extern
    2976                 :             :          inline, make sure we emit debug info for the inline before we
    2977                 :             :          throw it away, in case it was inlined into a function that
    2978                 :             :          hasn't been written out yet.  */
    2979                 :     3909699 :       if (new_is_definition && DECL_INITIAL (olddecl))
    2980                 :             :         /* The new defn must not be inline.  */
    2981                 :          75 :         DECL_UNINLINABLE (newdecl) = 1;
    2982                 :             :       else
    2983                 :             :         {
    2984                 :             :           /* If either decl says `inline', this fn is inline, unless
    2985                 :             :              its definition was passed already.  */
    2986                 :     3909624 :           if (DECL_DECLARED_INLINE_P (newdecl)
    2987                 :     7641670 :               || DECL_DECLARED_INLINE_P (olddecl))
    2988                 :      177763 :             DECL_DECLARED_INLINE_P (newdecl) = 1;
    2989                 :             : 
    2990                 :    11728872 :           DECL_UNINLINABLE (newdecl) = DECL_UNINLINABLE (olddecl)
    2991                 :     7820734 :             = (DECL_UNINLINABLE (newdecl) || DECL_UNINLINABLE (olddecl));
    2992                 :             : 
    2993                 :     7819248 :           DECL_DISREGARD_INLINE_LIMITS (newdecl)
    2994                 :     3909624 :             = DECL_DISREGARD_INLINE_LIMITS (olddecl)
    2995                 :     3909624 :             = (DECL_DISREGARD_INLINE_LIMITS (newdecl)
    2996                 :     7819110 :                || DECL_DISREGARD_INLINE_LIMITS (olddecl));
    2997                 :             :         }
    2998                 :             : 
    2999                 :     3909699 :       if (fndecl_built_in_p (olddecl))
    3000                 :             :         {
    3001                 :             :           /* If redeclaring a builtin function, it stays built in.
    3002                 :             :              But it gets tagged as having been declared.  */
    3003                 :     3170849 :           copy_decl_built_in_function (newdecl, olddecl);
    3004                 :     3170849 :           C_DECL_DECLARED_BUILTIN (newdecl) = 1;
    3005                 :     3170849 :           if (new_is_prototype)
    3006                 :             :             {
    3007                 :     3169677 :               C_DECL_BUILTIN_PROTOTYPE (newdecl) = 0;
    3008                 :     3169677 :               if (DECL_BUILT_IN_CLASS (newdecl) == BUILT_IN_NORMAL)
    3009                 :             :                 {
    3010                 :     3169677 :                   enum built_in_function fncode = DECL_FUNCTION_CODE (newdecl);
    3011                 :     3169677 :                   switch (fncode)
    3012                 :             :                     {
    3013                 :             :                       /* If a compatible prototype of these builtin functions
    3014                 :             :                          is seen, assume the runtime implements it with the
    3015                 :             :                          expected semantics.  */
    3016                 :        6395 :                     case BUILT_IN_STPCPY:
    3017                 :        6395 :                       if (builtin_decl_explicit_p (fncode))
    3018                 :        6395 :                         set_builtin_decl_implicit_p (fncode, true);
    3019                 :             :                       break;
    3020                 :     3163282 :                     default:
    3021                 :     3163282 :                       if (builtin_decl_explicit_p (fncode))
    3022                 :     3163282 :                         set_builtin_decl_declared_p (fncode, true);
    3023                 :             :                       break;
    3024                 :             :                     }
    3025                 :             : 
    3026                 :     3169677 :                   copy_attributes_to_builtin (newdecl);
    3027                 :             :                 }
    3028                 :             :             }
    3029                 :             :           else
    3030                 :        2344 :             C_DECL_BUILTIN_PROTOTYPE (newdecl)
    3031                 :        2344 :               = C_DECL_BUILTIN_PROTOTYPE (olddecl);
    3032                 :             :         }
    3033                 :             : 
    3034                 :             :       /* Preserve function specific target and optimization options */
    3035                 :     3909699 :       if (DECL_FUNCTION_SPECIFIC_TARGET (olddecl)
    3036                 :     3910198 :           && !DECL_FUNCTION_SPECIFIC_TARGET (newdecl))
    3037                 :         474 :         DECL_FUNCTION_SPECIFIC_TARGET (newdecl)
    3038                 :         474 :           = DECL_FUNCTION_SPECIFIC_TARGET (olddecl);
    3039                 :             : 
    3040                 :     3909699 :       if (DECL_FUNCTION_SPECIFIC_OPTIMIZATION (olddecl)
    3041                 :     3924049 :           && !DECL_FUNCTION_SPECIFIC_OPTIMIZATION (newdecl))
    3042                 :           9 :         DECL_FUNCTION_SPECIFIC_OPTIMIZATION (newdecl)
    3043                 :           9 :           = DECL_FUNCTION_SPECIFIC_OPTIMIZATION (olddecl);
    3044                 :             : 
    3045                 :             :       /* Also preserve various other info from the definition.  */
    3046                 :     3909699 :       if (!new_is_definition)
    3047                 :             :         {
    3048                 :     3691424 :           tree t;
    3049                 :     3691424 :           DECL_RESULT (newdecl) = DECL_RESULT (olddecl);
    3050                 :     3691424 :           DECL_INITIAL (newdecl) = DECL_INITIAL (olddecl);
    3051                 :     3691424 :           DECL_STRUCT_FUNCTION (newdecl) = DECL_STRUCT_FUNCTION (olddecl);
    3052                 :     3691424 :           DECL_SAVED_TREE (newdecl) = DECL_SAVED_TREE (olddecl);
    3053                 :     3691424 :           DECL_ARGUMENTS (newdecl) = copy_list (DECL_ARGUMENTS (olddecl));
    3054                 :     5533394 :           for (t = DECL_ARGUMENTS (newdecl); t ; t = DECL_CHAIN (t))
    3055                 :     1841970 :             DECL_CONTEXT (t) = newdecl;
    3056                 :             : 
    3057                 :             :           /* See if we've got a function to instantiate from.  */
    3058                 :     3691424 :           if (DECL_SAVED_TREE (olddecl))
    3059                 :        1582 :             DECL_ABSTRACT_ORIGIN (newdecl)
    3060                 :         791 :               = DECL_ABSTRACT_ORIGIN (olddecl);
    3061                 :             :         }
    3062                 :             :     }
    3063                 :             : 
    3064                 :             :   /* Merge the USED information.  */
    3065                 :     4021927 :   if (TREE_USED (olddecl))
    3066                 :      665837 :     TREE_USED (newdecl) = 1;
    3067                 :     3356090 :   else if (TREE_USED (newdecl))
    3068                 :           4 :     TREE_USED (olddecl) = 1;
    3069                 :     4021927 :   if (VAR_P (olddecl) || TREE_CODE (olddecl) == PARM_DECL)
    3070                 :       16818 :     DECL_READ_P (newdecl) |= DECL_READ_P (olddecl);
    3071                 :     4021927 :   if (DECL_PRESERVE_P (olddecl))
    3072                 :          25 :     DECL_PRESERVE_P (newdecl) = 1;
    3073                 :     4021902 :   else if (DECL_PRESERVE_P (newdecl))
    3074                 :           4 :     DECL_PRESERVE_P (olddecl) = 1;
    3075                 :             : 
    3076                 :             :   /* Merge DECL_COMMON */
    3077                 :       16789 :   if (VAR_P (olddecl) && VAR_P (newdecl)
    3078                 :       16789 :       && !lookup_attribute ("common", DECL_ATTRIBUTES (newdecl))
    3079                 :     4038714 :       && !lookup_attribute ("nocommon", DECL_ATTRIBUTES (newdecl)))
    3080                 :       33570 :     DECL_COMMON (newdecl) = DECL_COMMON (newdecl) && DECL_COMMON (olddecl);
    3081                 :             : 
    3082                 :             :   /* Copy most of the decl-specific fields of NEWDECL into OLDDECL.
    3083                 :             :      But preserve OLDDECL's DECL_UID, DECL_CONTEXT and
    3084                 :             :      DECL_ARGUMENTS (if appropriate).  */
    3085                 :     4021927 :   {
    3086                 :     4021927 :     unsigned olddecl_uid = DECL_UID (olddecl);
    3087                 :     4021927 :     tree olddecl_context = DECL_CONTEXT (olddecl);
    3088                 :     4021927 :     tree olddecl_arguments = NULL;
    3089                 :     4021927 :     if (TREE_CODE (olddecl) == FUNCTION_DECL)
    3090                 :     3909699 :       olddecl_arguments = DECL_ARGUMENTS (olddecl);
    3091                 :             : 
    3092                 :     4021927 :     memcpy ((char *) olddecl + sizeof (struct tree_common),
    3093                 :             :             (char *) newdecl + sizeof (struct tree_common),
    3094                 :             :             sizeof (struct tree_decl_common) - sizeof (struct tree_common));
    3095                 :     4021927 :     DECL_USER_ALIGN (olddecl) = DECL_USER_ALIGN (newdecl);
    3096                 :     4021927 :     switch (TREE_CODE (olddecl))
    3097                 :             :       {
    3098                 :     3926488 :       case FUNCTION_DECL:
    3099                 :     3926488 :       case VAR_DECL:
    3100                 :     3926488 :         {
    3101                 :     3926488 :           struct symtab_node *snode = olddecl->decl_with_vis.symtab_node;
    3102                 :             : 
    3103                 :     7852976 :           memcpy ((char *) olddecl + sizeof (struct tree_decl_common),
    3104                 :             :                   (char *) newdecl + sizeof (struct tree_decl_common),
    3105                 :     3926488 :                   tree_code_size (TREE_CODE (olddecl)) - sizeof (struct tree_decl_common));
    3106                 :     3926488 :           olddecl->decl_with_vis.symtab_node = snode;
    3107                 :             : 
    3108                 :     3926488 :           if ((DECL_EXTERNAL (olddecl)
    3109                 :             :                || TREE_PUBLIC (olddecl)
    3110                 :       45299 :                || TREE_STATIC (olddecl))
    3111                 :     3971780 :               && DECL_SECTION_NAME (newdecl) != NULL)
    3112                 :           8 :             set_decl_section_name (olddecl, newdecl);
    3113                 :             : 
    3114                 :             :           /* This isn't quite correct for something like
    3115                 :             :                 int __thread x attribute ((tls_model ("local-exec")));
    3116                 :             :                 extern int __thread x;
    3117                 :             :              as we'll lose the "local-exec" model.  */
    3118                 :     3926488 :           if (VAR_P (olddecl) && DECL_THREAD_LOCAL_P (newdecl))
    3119                 :          89 :             set_decl_tls_model (olddecl, DECL_TLS_MODEL (newdecl));
    3120                 :             :           break;
    3121                 :             :         }
    3122                 :             : 
    3123                 :       95439 :       case FIELD_DECL:
    3124                 :       95439 :       case PARM_DECL:
    3125                 :       95439 :       case LABEL_DECL:
    3126                 :       95439 :       case RESULT_DECL:
    3127                 :       95439 :       case CONST_DECL:
    3128                 :       95439 :       case TYPE_DECL:
    3129                 :      190878 :         memcpy ((char *) olddecl + sizeof (struct tree_decl_common),
    3130                 :             :                 (char *) newdecl + sizeof (struct tree_decl_common),
    3131                 :       95439 :                 tree_code_size (TREE_CODE (olddecl)) - sizeof (struct tree_decl_common));
    3132                 :       95439 :         break;
    3133                 :             : 
    3134                 :           0 :       default:
    3135                 :             : 
    3136                 :           0 :         memcpy ((char *) olddecl + sizeof (struct tree_decl_common),
    3137                 :             :                 (char *) newdecl + sizeof (struct tree_decl_common),
    3138                 :             :                 sizeof (struct tree_decl_non_common) - sizeof (struct tree_decl_common));
    3139                 :             :       }
    3140                 :     4021927 :     DECL_UID (olddecl) = olddecl_uid;
    3141                 :     4021927 :     DECL_CONTEXT (olddecl) = olddecl_context;
    3142                 :     4021927 :     if (TREE_CODE (olddecl) == FUNCTION_DECL)
    3143                 :     3909699 :       DECL_ARGUMENTS (olddecl) = olddecl_arguments;
    3144                 :             :   }
    3145                 :             : 
    3146                 :             :   /* If OLDDECL had its DECL_RTL instantiated, re-invoke make_decl_rtl
    3147                 :             :      so that encode_section_info has a chance to look at the new decl
    3148                 :             :      flags and attributes.  */
    3149                 :     4021927 :   if (DECL_RTL_SET_P (olddecl)
    3150                 :     4021927 :       && (TREE_CODE (olddecl) == FUNCTION_DECL
    3151                 :           0 :           || (VAR_P (olddecl) && TREE_STATIC (olddecl))))
    3152                 :           0 :     make_decl_rtl (olddecl);
    3153                 :     4021927 : }
    3154                 :             : 
    3155                 :             : /* Handle when a new declaration NEWDECL has the same name as an old
    3156                 :             :    one OLDDECL in the same binding contour.  Prints an error message
    3157                 :             :    if appropriate.
    3158                 :             : 
    3159                 :             :    If safely possible, alter OLDDECL to look like NEWDECL, and return
    3160                 :             :    true.  Otherwise, return false.  */
    3161                 :             : 
    3162                 :             : static bool
    3163                 :     4022870 : duplicate_decls (tree newdecl, tree olddecl)
    3164                 :             : {
    3165                 :     4022870 :   tree newtype = NULL, oldtype = NULL;
    3166                 :             : 
    3167                 :     4022870 :   if (!diagnose_mismatched_decls (newdecl, olddecl, &newtype, &oldtype))
    3168                 :             :     {
    3169                 :             :       /* Avoid `unused variable' and other warnings for OLDDECL.  */
    3170                 :         943 :       suppress_warning (olddecl, OPT_Wunused);
    3171                 :             :       /* If the types are completely different, poison them both with
    3172                 :             :          error_mark_node.  */
    3173                 :         943 :       if (TREE_CODE (TREE_TYPE (newdecl)) != TREE_CODE (TREE_TYPE (olddecl))
    3174                 :          84 :           && olddecl != error_mark_node
    3175                 :        1012 :           && seen_error ())
    3176                 :             :         {
    3177                 :          53 :           if (TREE_CODE (olddecl) != FUNCTION_DECL)
    3178                 :          42 :             TREE_TYPE (olddecl) = error_mark_node;
    3179                 :          53 :           if (TREE_CODE (newdecl) != FUNCTION_DECL)
    3180                 :          51 :             TREE_TYPE (newdecl) = error_mark_node;
    3181                 :             :         }
    3182                 :         943 :       return false;
    3183                 :             :     }
    3184                 :             : 
    3185                 :     4021927 :   merge_decls (newdecl, olddecl, newtype, oldtype);
    3186                 :             : 
    3187                 :             :   /* The NEWDECL will no longer be needed.
    3188                 :             : 
    3189                 :             :      Before releasing the node, be sure to remove function from symbol
    3190                 :             :      table that might have been inserted there to record comdat group.
    3191                 :             :      Be sure to however do not free DECL_STRUCT_FUNCTION because this
    3192                 :             :      structure is shared in between NEWDECL and OLDECL.  */
    3193                 :     4021927 :   if (TREE_CODE (newdecl) == FUNCTION_DECL)
    3194                 :     3909699 :     DECL_STRUCT_FUNCTION (newdecl) = NULL;
    3195                 :     4021927 :   if (VAR_OR_FUNCTION_DECL_P (newdecl))
    3196                 :             :     {
    3197                 :     3926488 :       struct symtab_node *snode = symtab_node::get (newdecl);
    3198                 :     3926488 :       if (snode)
    3199                 :         104 :         snode->remove ();
    3200                 :             :     }
    3201                 :     4021927 :   ggc_free (newdecl);
    3202                 :     4021927 :   return true;
    3203                 :             : }
    3204                 :             : 
    3205                 :             : 
    3206                 :             : /* Check whether decl-node NEW_DECL shadows an existing declaration.  */
    3207                 :             : static void
    3208                 :   151277809 : warn_if_shadowing (tree new_decl)
    3209                 :             : {
    3210                 :   151277809 :   struct c_binding *b;
    3211                 :             : 
    3212                 :             :   /* Shadow warnings wanted?  */
    3213                 :   151277086 :   if (!(warn_shadow
    3214                 :             :         || warn_shadow_local
    3215                 :             :         || warn_shadow_compatible_local)
    3216                 :             :       /* No shadow warnings for internally generated vars.  */
    3217                 :   151278048 :       || DECL_IS_UNDECLARED_BUILTIN (new_decl))
    3218                 :             :     return;
    3219                 :             : 
    3220                 :             :   /* Is anything being shadowed?  Invisible decls do not count.  */
    3221                 :         253 :   for (b = I_SYMBOL_BINDING (DECL_NAME (new_decl)); b; b = b->shadowed)
    3222                 :         157 :     if (b->decl && b->decl != new_decl && !b->invisible
    3223                 :         214 :         && (b->decl == error_mark_node
    3224                 :          43 :             || diagnostic_report_warnings_p (global_dc,
    3225                 :             :                                              DECL_SOURCE_LOCATION (b->decl))))
    3226                 :             :       {
    3227                 :          57 :         tree old_decl = b->decl;
    3228                 :             : 
    3229                 :          57 :         if (old_decl == error_mark_node)
    3230                 :             :           {
    3231                 :          14 :             warning (OPT_Wshadow, "declaration of %q+D shadows previous "
    3232                 :             :                      "non-variable", new_decl);
    3233                 :          64 :             break;
    3234                 :             :           }
    3235                 :             : 
    3236                 :          43 :         bool warned = false;
    3237                 :          43 :         auto_diagnostic_group d;
    3238                 :          43 :         if (TREE_CODE (old_decl) == PARM_DECL)
    3239                 :             :           {
    3240                 :           5 :             enum opt_code warning_code;
    3241                 :             : 
    3242                 :             :             /* If '-Wshadow=compatible-local' is specified without other
    3243                 :             :                -Wshadow= flags, we will warn only when the types of the
    3244                 :             :                shadowing variable (i.e. new_decl) and the shadowed variable
    3245                 :             :                (old_decl) are compatible.  */
    3246                 :           5 :             if (warn_shadow)
    3247                 :             :               warning_code = OPT_Wshadow;
    3248                 :           2 :             else if (comptypes (TREE_TYPE (old_decl), TREE_TYPE (new_decl)))
    3249                 :             :               warning_code = OPT_Wshadow_compatible_local;
    3250                 :             :             else
    3251                 :           2 :               warning_code = OPT_Wshadow_local;
    3252                 :           5 :             warned = warning_at (DECL_SOURCE_LOCATION (new_decl), warning_code,
    3253                 :             :                                  "declaration of %qD shadows a parameter",
    3254                 :             :                                  new_decl);
    3255                 :             :           }
    3256                 :          38 :         else if (DECL_FILE_SCOPE_P (old_decl))
    3257                 :             :           {
    3258                 :             :             /* Do not warn if a variable shadows a function, unless
    3259                 :             :                the variable is a function or a pointer-to-function.  */
    3260                 :          34 :             if (TREE_CODE (old_decl) == FUNCTION_DECL
    3261                 :          11 :                 && TREE_CODE (new_decl) != FUNCTION_DECL
    3262                 :          36 :                 && !FUNCTION_POINTER_TYPE_P (TREE_TYPE (new_decl)))
    3263                 :           7 :                 continue;
    3264                 :             : 
    3265                 :          20 :             warned = warning_at (DECL_SOURCE_LOCATION (new_decl), OPT_Wshadow,
    3266                 :             :                                  "declaration of %qD shadows a global "
    3267                 :             :                                  "declaration",
    3268                 :             :                                  new_decl);
    3269                 :             :           }
    3270                 :          11 :         else if (TREE_CODE (old_decl) == FUNCTION_DECL
    3271                 :          11 :                  && fndecl_built_in_p (old_decl))
    3272                 :             :           {
    3273                 :           0 :             warning (OPT_Wshadow, "declaration of %q+D shadows "
    3274                 :             :                      "a built-in function", new_decl);
    3275                 :           0 :             break;
    3276                 :             :           }
    3277                 :             :         else
    3278                 :             :           {
    3279                 :          11 :             enum opt_code warning_code;
    3280                 :             : 
    3281                 :             :             /* If '-Wshadow=compatible-local' is specified without other
    3282                 :             :                -Wshadow= flags, we will warn only when the types of the
    3283                 :             :                shadowing variable (i.e. new_decl) and the shadowed variable
    3284                 :             :                (old_decl) are compatible.  */
    3285                 :          11 :             if (warn_shadow)
    3286                 :             :               warning_code = OPT_Wshadow;
    3287                 :           8 :             else if (comptypes (TREE_TYPE (old_decl), TREE_TYPE (new_decl)))
    3288                 :             :               warning_code = OPT_Wshadow_compatible_local;
    3289                 :             :             else
    3290                 :           2 :               warning_code = OPT_Wshadow_local;
    3291                 :          11 :             warned = warning_at (DECL_SOURCE_LOCATION (new_decl), warning_code,
    3292                 :             :                                  "declaration of %qD shadows a previous local",
    3293                 :             :                                  new_decl);
    3294                 :             :           }
    3295                 :             : 
    3296                 :          36 :         if (warned)
    3297                 :          26 :           inform (DECL_SOURCE_LOCATION (old_decl),
    3298                 :             :                   "shadowed declaration is here");
    3299                 :             : 
    3300                 :             :         break;
    3301                 :          43 :       }
    3302                 :             : }
    3303                 :             : 
    3304                 :             : /* Record a decl-node X as belonging to the current lexical scope.
    3305                 :             :    Check for errors (such as an incompatible declaration for the same
    3306                 :             :    name already seen in the same scope).
    3307                 :             : 
    3308                 :             :    Returns either X or an old decl for the same name.
    3309                 :             :    If an old decl is returned, it may have been smashed
    3310                 :             :    to agree with what X says.  */
    3311                 :             : 
    3312                 :             : tree
    3313                 :   178957327 : pushdecl (tree x)
    3314                 :             : {
    3315                 :   178957327 :   tree name = DECL_NAME (x);
    3316                 :   178957327 :   struct c_scope *scope = current_scope;
    3317                 :   178957327 :   struct c_binding *b;
    3318                 :   178957327 :   bool nested = false;
    3319                 :   178957327 :   location_t locus = DECL_SOURCE_LOCATION (x);
    3320                 :             : 
    3321                 :             :   /* Must set DECL_CONTEXT for everything not at file scope or
    3322                 :             :      DECL_FILE_SCOPE_P won't work.  Local externs don't count
    3323                 :             :      unless they have initializers (which generate code).  We
    3324                 :             :      also exclude CONST_DECLs because enumerators will get the
    3325                 :             :      type of the enum as context.  */
    3326                 :   178957327 :   if (current_function_decl
    3327                 :     8839281 :       && TREE_CODE (x) != CONST_DECL
    3328                 :   187644517 :       && (!VAR_OR_FUNCTION_DECL_P (x)
    3329                 :     8443717 :           || DECL_INITIAL (x) || !TREE_PUBLIC (x)))
    3330                 :     8675201 :     DECL_CONTEXT (x) = current_function_decl;
    3331                 :             : 
    3332                 :             :   /* Anonymous decls are just inserted in the scope.  */
    3333                 :   178957327 :   if (!name)
    3334                 :             :     {
    3335                 :     7105444 :       bind (name, x, scope, /*invisible=*/false, /*nested=*/false,
    3336                 :             :             locus);
    3337                 :     7105444 :       return x;
    3338                 :             :     }
    3339                 :             : 
    3340                 :             :   /* First, see if there is another declaration with the same name in
    3341                 :             :      the current scope.  If there is, duplicate_decls may do all the
    3342                 :             :      work for us.  If duplicate_decls returns false, that indicates
    3343                 :             :      two incompatible decls in the same scope; we are to silently
    3344                 :             :      replace the old one (duplicate_decls has issued all appropriate
    3345                 :             :      diagnostics).  In particular, we should not consider possible
    3346                 :             :      duplicates in the external scope, or shadowing.  */
    3347                 :   171851883 :   b = I_SYMBOL_BINDING (name);
    3348                 :   171851883 :   if (b && B_IN_SCOPE (b, scope))
    3349                 :             :     {
    3350                 :      999614 :       struct c_binding *b_ext, *b_use;
    3351                 :      999614 :       tree type = TREE_TYPE (x);
    3352                 :      999614 :       tree visdecl = b->decl;
    3353                 :      999614 :       tree vistype = TREE_TYPE (visdecl);
    3354                 :      999614 :       if (TREE_CODE (TREE_TYPE (x)) == ARRAY_TYPE
    3355                 :      999614 :           && COMPLETE_TYPE_P (TREE_TYPE (x)))
    3356                 :        1330 :         b->inner_comp = false;
    3357                 :      999614 :       b_use = b;
    3358                 :      999614 :       b_ext = b;
    3359                 :             :       /* If this is an external linkage declaration, we should check
    3360                 :             :          for compatibility with the type in the external scope before
    3361                 :             :          setting the type at this scope based on the visible
    3362                 :             :          information only.  */
    3363                 :      999614 :       if (TREE_PUBLIC (x) && TREE_PUBLIC (visdecl))
    3364                 :             :         {
    3365                 :     1792562 :           while (b_ext && !B_IN_EXTERNAL_SCOPE (b_ext))
    3366                 :      896290 :             b_ext = b_ext->shadowed;
    3367                 :      896272 :           if (b_ext)
    3368                 :             :             {
    3369                 :      896271 :               b_use = b_ext;
    3370                 :      896271 :               if (b_use->u.type)
    3371                 :      139933 :                 TREE_TYPE (b_use->decl) = b_use->u.type;
    3372                 :             :             }
    3373                 :             :         }
    3374                 :      999614 :       if (duplicate_decls (x, b_use->decl))
    3375                 :             :         {
    3376                 :      999293 :           if (b_use != b)
    3377                 :             :             {
    3378                 :             :               /* Save the updated type in the external scope and
    3379                 :             :                  restore the proper type for this scope.  */
    3380                 :      896078 :               tree thistype;
    3381                 :      896078 :               if (comptypes (vistype, type))
    3382                 :      896044 :                 thistype = composite_type (vistype, type);
    3383                 :             :               else
    3384                 :          34 :                 thistype = TREE_TYPE (b_use->decl);
    3385                 :      896078 :               b_use->u.type = TREE_TYPE (b_use->decl);
    3386                 :      896078 :               if (TREE_CODE (b_use->decl) == FUNCTION_DECL
    3387                 :      896078 :                   && fndecl_built_in_p (b_use->decl))
    3388                 :      149936 :                 thistype
    3389                 :      149936 :                   = build_type_attribute_variant (thistype,
    3390                 :      149936 :                                                   TYPE_ATTRIBUTES
    3391                 :             :                                                   (b_use->u.type));
    3392                 :      896078 :               TREE_TYPE (b_use->decl) = thistype;
    3393                 :             :             }
    3394                 :      999293 :           return b_use->decl;
    3395                 :             :         }
    3396                 :             :       else
    3397                 :         321 :         goto skip_external_and_shadow_checks;
    3398                 :             :     }
    3399                 :             : 
    3400                 :             :   /* All declarations with external linkage, and all external
    3401                 :             :      references, go in the external scope, no matter what scope is
    3402                 :             :      current.  However, the binding in that scope is ignored for
    3403                 :             :      purposes of normal name lookup.  A separate binding structure is
    3404                 :             :      created in the requested scope; this governs the normal
    3405                 :             :      visibility of the symbol.
    3406                 :             : 
    3407                 :             :      The binding in the externals scope is used exclusively for
    3408                 :             :      detecting duplicate declarations of the same object, no matter
    3409                 :             :      what scope they are in; this is what we do here.  (C99 6.2.7p2:
    3410                 :             :      All declarations that refer to the same object or function shall
    3411                 :             :      have compatible type; otherwise, the behavior is undefined.)
    3412                 :             :      However, in Objective-C, we also want to detect declarations
    3413                 :             :      conflicting with those of the basic types.  */
    3414                 :   299014180 :   if ((DECL_EXTERNAL (x) || scope == file_scope)
    3415                 :   181585834 :       && (VAR_OR_FUNCTION_DECL_P (x) || c_dialect_objc ()))
    3416                 :             :     {
    3417                 :    44426621 :       tree type = TREE_TYPE (x);
    3418                 :    44426621 :       tree vistype = NULL_TREE;
    3419                 :    44426621 :       tree visdecl = NULL_TREE;
    3420                 :    44426621 :       bool type_saved = false;
    3421                 :     3023281 :       if (b && !B_IN_EXTERNAL_SCOPE (b)
    3422                 :        1021 :           && VAR_OR_FUNCTION_DECL_P (b->decl)
    3423                 :    44427633 :           && DECL_FILE_SCOPE_P (b->decl))
    3424                 :             :         {
    3425                 :         788 :           visdecl = b->decl;
    3426                 :         788 :           vistype = TREE_TYPE (visdecl);
    3427                 :             :         }
    3428                 :    44426621 :       if (scope != file_scope
    3429                 :    44426621 :           && !DECL_IN_SYSTEM_HEADER (x))
    3430                 :       11434 :         warning_at (locus, OPT_Wnested_externs,
    3431                 :             :                     "nested extern declaration of %qD", x);
    3432                 :             : 
    3433                 :    44428026 :       while (b && !B_IN_EXTERNAL_SCOPE (b))
    3434                 :             :         {
    3435                 :             :           /* If this decl might be modified, save its type.  This is
    3436                 :             :              done here rather than when the decl is first bound
    3437                 :             :              because the type may change after first binding, through
    3438                 :             :              being completed or through attributes being added.  If we
    3439                 :             :              encounter multiple such decls, only the first should have
    3440                 :             :              its type saved; the others will already have had their
    3441                 :             :              proper types saved and the types will not have changed as
    3442                 :             :              their scopes will not have been re-entered.  */
    3443                 :        1405 :           if (DECL_P (b->decl) && DECL_FILE_SCOPE_P (b->decl) && !type_saved)
    3444                 :             :             {
    3445                 :        1005 :               b->u.type = TREE_TYPE (b->decl);
    3446                 :        1005 :               type_saved = true;
    3447                 :             :             }
    3448                 :        1405 :           if (B_IN_FILE_SCOPE (b)
    3449                 :             :               && VAR_P (b->decl)
    3450                 :         995 :               && TREE_STATIC (b->decl)
    3451                 :         280 :               && TREE_CODE (TREE_TYPE (b->decl)) == ARRAY_TYPE
    3452                 :         138 :               && !TYPE_DOMAIN (TREE_TYPE (b->decl))
    3453                 :          47 :               && TREE_CODE (type) == ARRAY_TYPE
    3454                 :          47 :               && TYPE_DOMAIN (type)
    3455                 :          28 :               && TYPE_MAX_VALUE (TYPE_DOMAIN (type))
    3456                 :        1433 :               && !integer_zerop (TYPE_MAX_VALUE (TYPE_DOMAIN (type))))
    3457                 :             :             {
    3458                 :             :               /* Array type completed in inner scope, which should be
    3459                 :             :                  diagnosed if the completion does not have size 1 and
    3460                 :             :                  it does not get completed in the file scope.  */
    3461                 :           6 :               b->inner_comp = true;
    3462                 :             :             }
    3463                 :        1405 :           b = b->shadowed;
    3464                 :             :         }
    3465                 :             : 
    3466                 :             :       /* If a matching external declaration has been found, set its
    3467                 :             :          type to the composite of all the types of that declaration.
    3468                 :             :          After the consistency checks, it will be reset to the
    3469                 :             :          composite of the visible types only.  */
    3470                 :    44426621 :       if (b && b->u.type)
    3471                 :         761 :         TREE_TYPE (b->decl) = b->u.type;
    3472                 :             : 
    3473                 :             :       /* the static does not go in the externals scope.  */
    3474                 :     3023139 :       if (b && duplicate_decls (x, b->decl))
    3475                 :             :         {
    3476                 :     3022517 :           tree thistype;
    3477                 :     3022517 :           if (vistype)
    3478                 :             :             {
    3479                 :         660 :               if (comptypes (vistype, type))
    3480                 :         623 :                 thistype = composite_type (vistype, type);
    3481                 :             :               else
    3482                 :          37 :                 thistype = TREE_TYPE (b->decl);
    3483                 :             :             }
    3484                 :             :           else
    3485                 :             :             thistype = type;
    3486                 :     3022517 :           b->u.type = TREE_TYPE (b->decl);
    3487                 :             :           /* Propagate the type attributes to the decl.  */
    3488                 :     3022517 :           thistype
    3489                 :     3022517 :             = build_type_attribute_variant (thistype,
    3490                 :     3022517 :                                             TYPE_ATTRIBUTES (b->u.type));
    3491                 :     3022517 :           TREE_TYPE (b->decl) = thistype;
    3492                 :     3022517 :           bind (name, b->decl, scope, /*invisible=*/false, /*nested=*/true,
    3493                 :             :                 locus);
    3494                 :     3022517 :           return b->decl;
    3495                 :             :         }
    3496                 :    41404104 :       else if (TREE_PUBLIC (x))
    3497                 :             :         {
    3498                 :    41048210 :           if (visdecl && !b && duplicate_decls (x, visdecl))
    3499                 :             :             {
    3500                 :             :               /* An external declaration at block scope referring to a
    3501                 :             :                  visible entity with internal linkage.  The composite
    3502                 :             :                  type will already be correct for this scope, so we
    3503                 :             :                  just need to fall through to make the declaration in
    3504                 :             :                  this scope.  */
    3505                 :             :               nested = true;
    3506                 :             :               x = visdecl;
    3507                 :             :             }
    3508                 :             :           else
    3509                 :             :             {
    3510                 :    41048093 :               bind (name, x, external_scope, /*invisible=*/true,
    3511                 :             :                     /*nested=*/false, locus);
    3512                 :    41048093 :               nested = true;
    3513                 :             :             }
    3514                 :             :         }
    3515                 :             :     }
    3516                 :             : 
    3517                 :   167829752 :   if (TREE_CODE (x) != PARM_DECL)
    3518                 :    63378878 :     warn_if_shadowing (x);
    3519                 :             : 
    3520                 :   104450874 :  skip_external_and_shadow_checks:
    3521                 :   167830073 :   if (TREE_CODE (x) == TYPE_DECL)
    3522                 :             :     {
    3523                 :             :       /* So this is a typedef, set its underlying type.  */
    3524                 :     9063564 :       set_underlying_type (x);
    3525                 :             : 
    3526                 :             :       /* If X is a typedef defined in the current function, record it
    3527                 :             :          for the purpose of implementing the -Wunused-local-typedefs
    3528                 :             :          warning.  */
    3529                 :     9063564 :       record_locally_defined_typedef (x);
    3530                 :             :     }
    3531                 :             : 
    3532                 :   167830073 :   bind (name, x, scope, /*invisible=*/false, nested, locus);
    3533                 :             : 
    3534                 :             :   /* If x's type is incomplete because it's based on a
    3535                 :             :      structure or union which has not yet been fully declared,
    3536                 :             :      attach it to that structure or union type, so we can go
    3537                 :             :      back and complete the variable declaration later, if the
    3538                 :             :      structure or union gets fully declared.
    3539                 :             : 
    3540                 :             :      If the input is erroneous, we can have error_mark in the type
    3541                 :             :      slot (e.g. "f(void a, ...)") - that doesn't count as an
    3542                 :             :      incomplete type.  */
    3543                 :   167830073 :   if (TREE_TYPE (x) != error_mark_node
    3544                 :   167830073 :       && !COMPLETE_TYPE_P (TREE_TYPE (x)))
    3545                 :             :     {
    3546                 :      176840 :       tree element = TREE_TYPE (x);
    3547                 :             : 
    3548                 :      196395 :       while (TREE_CODE (element) == ARRAY_TYPE)
    3549                 :       19555 :         element = TREE_TYPE (element);
    3550                 :      176840 :       element = TYPE_MAIN_VARIANT (element);
    3551                 :             : 
    3552                 :      176840 :       if ((RECORD_OR_UNION_TYPE_P (element)
    3553                 :      135616 :            || TREE_CODE (element) == ENUMERAL_TYPE)
    3554                 :       41288 :           && (TREE_CODE (x) != TYPE_DECL
    3555                 :       37911 :               || TREE_CODE (TREE_TYPE (x)) == ARRAY_TYPE)
    3556                 :      180224 :           && !COMPLETE_TYPE_P (element))
    3557                 :         265 :         C_TYPE_INCOMPLETE_VARS (element)
    3558                 :         530 :           = tree_cons (NULL_TREE, x, C_TYPE_INCOMPLETE_VARS (element));
    3559                 :             :     }
    3560                 :             :   return x;
    3561                 :             : }
    3562                 :             : 
    3563                 :             : 
    3564                 :             : /* Issue a permerror about implicit function declaration.  ID is the function
    3565                 :             :    identifier, OLDDECL is a declaration of the function in a different scope,
    3566                 :             :    or NULL_TREE.  */
    3567                 :             : 
    3568                 :             : static void
    3569                 :        3771 : implicit_decl_permerror (location_t loc, tree id, tree olddecl)
    3570                 :             : {
    3571                 :        3771 :   if (!warn_implicit_function_declaration)
    3572                 :        2617 :     return;
    3573                 :             : 
    3574                 :        1154 :   bool warned;
    3575                 :        1154 :   auto_diagnostic_group d;
    3576                 :        1154 :   name_hint hint;
    3577                 :        1154 :   if (!olddecl)
    3578                 :         548 :     hint = lookup_name_fuzzy (id, FUZZY_LOOKUP_FUNCTION_NAME, loc);
    3579                 :             : 
    3580                 :        1154 :   if (flag_isoc99)
    3581                 :             :     {
    3582                 :        1148 :       if (const char *suggestion = hint.suggestion ())
    3583                 :             :         {
    3584                 :         103 :           gcc_rich_location richloc (loc);
    3585                 :         103 :           richloc.add_fixit_replace (suggestion);
    3586                 :         103 :           warned = permerror_opt (&richloc, OPT_Wimplicit_function_declaration,
    3587                 :             :                                   "implicit declaration of function %qE;"
    3588                 :             :                                   " did you mean %qs?",
    3589                 :             :                                   id, suggestion);
    3590                 :         103 :         }
    3591                 :             :       else
    3592                 :        1045 :         warned = permerror_opt (loc, OPT_Wimplicit_function_declaration,
    3593                 :             :                                 "implicit declaration of function %qE", id);
    3594                 :             :     }
    3595                 :           6 :   else if (const char *suggestion = hint.suggestion ())
    3596                 :             :     {
    3597                 :           2 :       gcc_rich_location richloc (loc);
    3598                 :           2 :       richloc.add_fixit_replace (suggestion);
    3599                 :           2 :       warned = warning_at
    3600                 :           2 :         (&richloc, OPT_Wimplicit_function_declaration,
    3601                 :             :          G_("implicit declaration of function %qE; did you mean %qs?"),
    3602                 :             :          id, suggestion);
    3603                 :           2 :     }
    3604                 :             :   else
    3605                 :           4 :     warned = warning_at (loc, OPT_Wimplicit_function_declaration,
    3606                 :             :                          G_("implicit declaration of function %qE"), id);
    3607                 :             : 
    3608                 :        1154 :   if (warned)
    3609                 :             :     {
    3610                 :             :       /* Whether the olddecl is an undeclared builtin function.
    3611                 :             :          locate_old_decl will not generate a diagnostic for those,
    3612                 :             :          so in that case we want to look elsewhere.  */
    3613                 :          85 :       bool undeclared_builtin = (olddecl
    3614                 :          28 :                                  && TREE_CODE (olddecl) == FUNCTION_DECL
    3615                 :          28 :                                  && fndecl_built_in_p (olddecl)
    3616                 :         112 :                                  && !C_DECL_DECLARED_BUILTIN (olddecl));
    3617                 :          85 :       if (undeclared_builtin)
    3618                 :             :         {
    3619                 :          27 :           const char *header = header_for_builtin_fn (olddecl);
    3620                 :          27 :           if (header)
    3621                 :             :             {
    3622                 :          20 :               rich_location richloc (line_table, loc);
    3623                 :          20 :               maybe_add_include_fixit (&richloc, header, true);
    3624                 :          20 :               inform (&richloc,
    3625                 :             :                       "include %qs or provide a declaration of %qE",
    3626                 :             :                       header, id);
    3627                 :          20 :             }
    3628                 :             :         }
    3629                 :          58 :       else if (olddecl)
    3630                 :           1 :         locate_old_decl (olddecl);
    3631                 :             :     }
    3632                 :             : 
    3633                 :        1069 :   if (!warned)
    3634                 :        1154 :     hint.suppress ();
    3635                 :        1154 : }
    3636                 :             : 
    3637                 :             : /* Return the name of the header file that declares built-in function
    3638                 :             :    FNDECL, or null if either we don't know or don't expect to see an
    3639                 :             :    explicit declaration.  */
    3640                 :             : 
    3641                 :             : static const char *
    3642                 :        3051 : header_for_builtin_fn (tree fndecl)
    3643                 :             : {
    3644                 :        3051 :   if (DECL_BUILT_IN_CLASS (fndecl) != BUILT_IN_NORMAL)
    3645                 :             :     return NULL;
    3646                 :             : 
    3647                 :        3051 :   switch (DECL_FUNCTION_CODE (fndecl))
    3648                 :             :     {
    3649                 :             :     CASE_FLT_FN (BUILT_IN_ACOS):
    3650                 :             :     CASE_FLT_FN (BUILT_IN_ACOSH):
    3651                 :             :     CASE_FLT_FN (BUILT_IN_ASIN):
    3652                 :             :     CASE_FLT_FN (BUILT_IN_ASINH):
    3653                 :             :     CASE_FLT_FN (BUILT_IN_ATAN):
    3654                 :             :     CASE_FLT_FN (BUILT_IN_ATANH):
    3655                 :             :     CASE_FLT_FN (BUILT_IN_ATAN2):
    3656                 :             :     CASE_FLT_FN (BUILT_IN_CBRT):
    3657                 :             :     CASE_FLT_FN (BUILT_IN_CEIL):
    3658                 :             :     CASE_FLT_FN_FLOATN_NX (BUILT_IN_CEIL):
    3659                 :             :     CASE_FLT_FN (BUILT_IN_COPYSIGN):
    3660                 :             :     CASE_FLT_FN_FLOATN_NX (BUILT_IN_COPYSIGN):
    3661                 :             :     CASE_FLT_FN (BUILT_IN_COS):
    3662                 :             :     CASE_FLT_FN (BUILT_IN_COSH):
    3663                 :             :     CASE_FLT_FN (BUILT_IN_ERF):
    3664                 :             :     CASE_FLT_FN (BUILT_IN_ERFC):
    3665                 :             :     CASE_FLT_FN (BUILT_IN_EXP):
    3666                 :             :     CASE_FLT_FN (BUILT_IN_EXP2):
    3667                 :             :     CASE_FLT_FN (BUILT_IN_EXPM1):
    3668                 :             :     CASE_FLT_FN (BUILT_IN_FABS):
    3669                 :             :     CASE_FLT_FN_FLOATN_NX (BUILT_IN_FABS):
    3670                 :             :     CASE_FLT_FN (BUILT_IN_FDIM):
    3671                 :             :     CASE_FLT_FN (BUILT_IN_FLOOR):
    3672                 :             :     CASE_FLT_FN_FLOATN_NX (BUILT_IN_FLOOR):
    3673                 :             :     CASE_FLT_FN (BUILT_IN_FMA):
    3674                 :             :     CASE_FLT_FN_FLOATN_NX (BUILT_IN_FMA):
    3675                 :             :     CASE_FLT_FN (BUILT_IN_FMAX):
    3676                 :             :     CASE_FLT_FN_FLOATN_NX (BUILT_IN_FMAX):
    3677                 :             :     CASE_FLT_FN (BUILT_IN_FMIN):
    3678                 :             :     CASE_FLT_FN_FLOATN_NX (BUILT_IN_FMIN):
    3679                 :             :     CASE_FLT_FN (BUILT_IN_FMOD):
    3680                 :             :     CASE_FLT_FN (BUILT_IN_FREXP):
    3681                 :             :     CASE_FLT_FN (BUILT_IN_HYPOT):
    3682                 :             :     CASE_FLT_FN (BUILT_IN_ILOGB):
    3683                 :             :     CASE_FLT_FN (BUILT_IN_LDEXP):
    3684                 :             :     CASE_FLT_FN (BUILT_IN_LGAMMA):
    3685                 :             :     CASE_FLT_FN (BUILT_IN_LLRINT):
    3686                 :             :     CASE_FLT_FN (BUILT_IN_LLROUND):
    3687                 :             :     CASE_FLT_FN (BUILT_IN_LOG):
    3688                 :             :     CASE_FLT_FN (BUILT_IN_LOG10):
    3689                 :             :     CASE_FLT_FN (BUILT_IN_LOG1P):
    3690                 :             :     CASE_FLT_FN (BUILT_IN_LOG2):
    3691                 :             :     CASE_FLT_FN (BUILT_IN_LOGB):
    3692                 :             :     CASE_FLT_FN (BUILT_IN_LRINT):
    3693                 :             :     CASE_FLT_FN (BUILT_IN_LROUND):
    3694                 :             :     CASE_FLT_FN (BUILT_IN_MODF):
    3695                 :             :     CASE_FLT_FN (BUILT_IN_NAN):
    3696                 :             :     CASE_FLT_FN (BUILT_IN_NEARBYINT):
    3697                 :             :     CASE_FLT_FN_FLOATN_NX (BUILT_IN_NEARBYINT):
    3698                 :             :     CASE_FLT_FN (BUILT_IN_NEXTAFTER):
    3699                 :             :     CASE_FLT_FN (BUILT_IN_NEXTTOWARD):
    3700                 :             :     CASE_FLT_FN (BUILT_IN_POW):
    3701                 :             :     CASE_FLT_FN (BUILT_IN_REMAINDER):
    3702                 :             :     CASE_FLT_FN (BUILT_IN_REMQUO):
    3703                 :             :     CASE_FLT_FN (BUILT_IN_RINT):
    3704                 :             :     CASE_FLT_FN_FLOATN_NX (BUILT_IN_RINT):
    3705                 :             :     CASE_FLT_FN (BUILT_IN_ROUND):
    3706                 :             :     CASE_FLT_FN_FLOATN_NX (BUILT_IN_ROUND):
    3707                 :             :     CASE_FLT_FN (BUILT_IN_SCALBLN):
    3708                 :             :     CASE_FLT_FN (BUILT_IN_SCALBN):
    3709                 :             :     CASE_FLT_FN (BUILT_IN_SIN):
    3710                 :             :     CASE_FLT_FN (BUILT_IN_SINH):
    3711                 :             :     CASE_FLT_FN (BUILT_IN_SINCOS):
    3712                 :             :     CASE_FLT_FN (BUILT_IN_SQRT):
    3713                 :             :     CASE_FLT_FN_FLOATN_NX (BUILT_IN_SQRT):
    3714                 :             :     CASE_FLT_FN (BUILT_IN_TAN):
    3715                 :             :     CASE_FLT_FN (BUILT_IN_TANH):
    3716                 :             :     CASE_FLT_FN (BUILT_IN_TGAMMA):
    3717                 :             :     CASE_FLT_FN (BUILT_IN_TRUNC):
    3718                 :             :     CASE_FLT_FN_FLOATN_NX (BUILT_IN_TRUNC):
    3719                 :             :     case BUILT_IN_ISINF:
    3720                 :             :     case BUILT_IN_ISNAN:
    3721                 :             :       return "<math.h>";
    3722                 :          29 :     CASE_FLT_FN (BUILT_IN_CABS):
    3723                 :          29 :     CASE_FLT_FN (BUILT_IN_CACOS):
    3724                 :          29 :     CASE_FLT_FN (BUILT_IN_CACOSH):
    3725                 :          29 :     CASE_FLT_FN (BUILT_IN_CARG):
    3726                 :          29 :     CASE_FLT_FN (BUILT_IN_CASIN):
    3727                 :          29 :     CASE_FLT_FN (BUILT_IN_CASINH):
    3728                 :          29 :     CASE_FLT_FN (BUILT_IN_CATAN):
    3729                 :          29 :     CASE_FLT_FN (BUILT_IN_CATANH):
    3730                 :          29 :     CASE_FLT_FN (BUILT_IN_CCOS):
    3731                 :          29 :     CASE_FLT_FN (BUILT_IN_CCOSH):
    3732                 :          29 :     CASE_FLT_FN (BUILT_IN_CEXP):
    3733                 :          29 :     CASE_FLT_FN (BUILT_IN_CIMAG):
    3734                 :          29 :     CASE_FLT_FN (BUILT_IN_CLOG):
    3735                 :          29 :     CASE_FLT_FN (BUILT_IN_CONJ):
    3736                 :          29 :     CASE_FLT_FN (BUILT_IN_CPOW):
    3737                 :          29 :     CASE_FLT_FN (BUILT_IN_CPROJ):
    3738                 :          29 :     CASE_FLT_FN (BUILT_IN_CREAL):
    3739                 :          29 :     CASE_FLT_FN (BUILT_IN_CSIN):
    3740                 :          29 :     CASE_FLT_FN (BUILT_IN_CSINH):
    3741                 :          29 :     CASE_FLT_FN (BUILT_IN_CSQRT):
    3742                 :          29 :     CASE_FLT_FN (BUILT_IN_CTAN):
    3743                 :          29 :     CASE_FLT_FN (BUILT_IN_CTANH):
    3744                 :          29 :       return "<complex.h>";
    3745                 :         207 :     case BUILT_IN_MEMCHR:
    3746                 :         207 :     case BUILT_IN_MEMCMP:
    3747                 :         207 :     case BUILT_IN_MEMCPY:
    3748                 :         207 :     case BUILT_IN_MEMMOVE:
    3749                 :         207 :     case BUILT_IN_MEMSET:
    3750                 :         207 :     case BUILT_IN_STRCAT:
    3751                 :         207 :     case BUILT_IN_STRCHR:
    3752                 :         207 :     case BUILT_IN_STRCMP:
    3753                 :         207 :     case BUILT_IN_STRCPY:
    3754                 :         207 :     case BUILT_IN_STRCSPN:
    3755                 :         207 :     case BUILT_IN_STRLEN:
    3756                 :         207 :     case BUILT_IN_STRNCAT:
    3757                 :         207 :     case BUILT_IN_STRNCMP:
    3758                 :         207 :     case BUILT_IN_STRNCPY:
    3759                 :         207 :     case BUILT_IN_STRPBRK:
    3760                 :         207 :     case BUILT_IN_STRRCHR:
    3761                 :         207 :     case BUILT_IN_STRSPN:
    3762                 :         207 :     case BUILT_IN_STRSTR:
    3763                 :         207 :       return "<string.h>";
    3764                 :         544 :     case BUILT_IN_FPRINTF:
    3765                 :         544 :     case BUILT_IN_PUTC:
    3766                 :         544 :     case BUILT_IN_FPUTC:
    3767                 :         544 :     case BUILT_IN_FPUTS:
    3768                 :         544 :     case BUILT_IN_FSCANF:
    3769                 :         544 :     case BUILT_IN_FWRITE:
    3770                 :         544 :     case BUILT_IN_PRINTF:
    3771                 :         544 :     case BUILT_IN_PUTCHAR:
    3772                 :         544 :     case BUILT_IN_PUTS:
    3773                 :         544 :     case BUILT_IN_SCANF:
    3774                 :         544 :     case BUILT_IN_SNPRINTF:
    3775                 :         544 :     case BUILT_IN_SPRINTF:
    3776                 :         544 :     case BUILT_IN_SSCANF:
    3777                 :         544 :     case BUILT_IN_VFPRINTF:
    3778                 :         544 :     case BUILT_IN_VFSCANF:
    3779                 :         544 :     case BUILT_IN_VPRINTF:
    3780                 :         544 :     case BUILT_IN_VSCANF:
    3781                 :         544 :     case BUILT_IN_VSNPRINTF:
    3782                 :         544 :     case BUILT_IN_VSPRINTF:
    3783                 :         544 :     case BUILT_IN_VSSCANF:
    3784                 :         544 :       return "<stdio.h>";
    3785                 :           2 :     case BUILT_IN_ISALNUM:
    3786                 :           2 :     case BUILT_IN_ISALPHA:
    3787                 :           2 :     case BUILT_IN_ISBLANK:
    3788                 :           2 :     case BUILT_IN_ISCNTRL:
    3789                 :           2 :     case BUILT_IN_ISDIGIT:
    3790                 :           2 :     case BUILT_IN_ISGRAPH:
    3791                 :           2 :     case BUILT_IN_ISLOWER:
    3792                 :           2 :     case BUILT_IN_ISPRINT:
    3793                 :           2 :     case BUILT_IN_ISPUNCT:
    3794                 :           2 :     case BUILT_IN_ISSPACE:
    3795                 :           2 :     case BUILT_IN_ISUPPER:
    3796                 :           2 :     case BUILT_IN_ISXDIGIT:
    3797                 :           2 :     case BUILT_IN_TOLOWER:
    3798                 :           2 :     case BUILT_IN_TOUPPER:
    3799                 :           2 :       return "<ctype.h>";
    3800                 :           0 :     case BUILT_IN_ISWALNUM:
    3801                 :           0 :     case BUILT_IN_ISWALPHA:
    3802                 :           0 :     case BUILT_IN_ISWBLANK:
    3803                 :           0 :     case BUILT_IN_ISWCNTRL:
    3804                 :           0 :     case BUILT_IN_ISWDIGIT:
    3805                 :           0 :     case BUILT_IN_ISWGRAPH:
    3806                 :           0 :     case BUILT_IN_ISWLOWER:
    3807                 :           0 :     case BUILT_IN_ISWPRINT:
    3808                 :           0 :     case BUILT_IN_ISWPUNCT:
    3809                 :           0 :     case BUILT_IN_ISWSPACE:
    3810                 :           0 :     case BUILT_IN_ISWUPPER:
    3811                 :           0 :     case BUILT_IN_ISWXDIGIT:
    3812                 :           0 :     case BUILT_IN_TOWLOWER:
    3813                 :           0 :     case BUILT_IN_TOWUPPER:
    3814                 :           0 :       return "<wctype.h>";
    3815                 :        1818 :     case BUILT_IN_ABORT:
    3816                 :        1818 :     case BUILT_IN_ABS:
    3817                 :        1818 :     case BUILT_IN_CALLOC:
    3818                 :        1818 :     case BUILT_IN_EXIT:
    3819                 :        1818 :     case BUILT_IN_FREE:
    3820                 :        1818 :     case BUILT_IN_LABS:
    3821                 :        1818 :     case BUILT_IN_LLABS:
    3822                 :        1818 :     case BUILT_IN_MALLOC:
    3823                 :        1818 :     case BUILT_IN_REALLOC:
    3824                 :        1818 :     case BUILT_IN__EXIT2:
    3825                 :        1818 :     case BUILT_IN_ALIGNED_ALLOC:
    3826                 :        1818 :       return "<stdlib.h>";
    3827                 :           1 :     case BUILT_IN_IMAXABS:
    3828                 :           1 :       return "<inttypes.h>";
    3829                 :           3 :     case BUILT_IN_STRFTIME:
    3830                 :           3 :       return "<time.h>";
    3831                 :             :     default:
    3832                 :             :       return NULL;
    3833                 :             :     }
    3834                 :             : }
    3835                 :             : 
    3836                 :             : /* Generate an implicit declaration for identifier FUNCTIONID at LOC as a
    3837                 :             :    function of type int ().  */
    3838                 :             : 
    3839                 :             : tree
    3840                 :        4724 : implicitly_declare (location_t loc, tree functionid)
    3841                 :             : {
    3842                 :        4724 :   struct c_binding *b;
    3843                 :        4724 :   tree decl = NULL_TREE;
    3844                 :        4724 :   tree asmspec_tree;
    3845                 :             : 
    3846                 :        4738 :   for (b = I_SYMBOL_BINDING (functionid); b; b = b->shadowed)
    3847                 :             :     {
    3848                 :        3158 :       if (B_IN_SCOPE (b, external_scope))
    3849                 :             :         {
    3850                 :        3144 :           decl = b->decl;
    3851                 :        3144 :           break;
    3852                 :             :         }
    3853                 :             :     }
    3854                 :             : 
    3855                 :        4724 :   if (decl)
    3856                 :             :     {
    3857                 :        3144 :       if (TREE_CODE (decl) != FUNCTION_DECL)
    3858                 :             :         return decl;
    3859                 :             : 
    3860                 :             :       /* FIXME: Objective-C has weird not-really-builtin functions
    3861                 :             :          which are supposed to be visible automatically.  They wind up
    3862                 :             :          in the external scope because they're pushed before the file
    3863                 :             :          scope gets created.  Catch this here and rebind them into the
    3864                 :             :          file scope.  */
    3865                 :        3137 :       if (!fndecl_built_in_p (decl) && DECL_IS_UNDECLARED_BUILTIN (decl))
    3866                 :             :         {
    3867                 :           0 :           bind (functionid, decl, file_scope,
    3868                 :             :                 /*invisible=*/false, /*nested=*/true,
    3869                 :           0 :                 DECL_SOURCE_LOCATION (decl));
    3870                 :           0 :           return decl;
    3871                 :             :         }
    3872                 :             :       else
    3873                 :             :         {
    3874                 :        3137 :           tree newtype = default_function_type;
    3875                 :        3137 :           if (b->u.type)
    3876                 :         753 :             TREE_TYPE (decl) = b->u.type;
    3877                 :             :           /* Implicit declaration of a function already declared
    3878                 :             :              (somehow) in a different scope, or as a built-in.
    3879                 :             :              If this is the first time this has happened, warn;
    3880                 :             :              then recycle the old declaration but with the new type.  */
    3881                 :        3137 :           if (!C_DECL_IMPLICIT (decl))
    3882                 :             :             {
    3883                 :        2191 :               implicit_decl_permerror (loc, functionid, decl);
    3884                 :        2191 :               C_DECL_IMPLICIT (decl) = 1;
    3885                 :             :             }
    3886                 :        3137 :           if (fndecl_built_in_p (decl))
    3887                 :             :             {
    3888                 :        2705 :               newtype = build_type_attribute_variant (newtype,
    3889                 :        2705 :                                                       TYPE_ATTRIBUTES
    3890                 :             :                                                       (TREE_TYPE (decl)));
    3891                 :        2705 :               if (!comptypes (newtype, TREE_TYPE (decl)))
    3892                 :             :                 {
    3893                 :        2528 :                   auto_diagnostic_group d;
    3894                 :        2528 :                   bool warned = warning_at (loc,
    3895                 :             :                                             OPT_Wbuiltin_declaration_mismatch,
    3896                 :             :                                             "incompatible implicit "
    3897                 :             :                                             "declaration of built-in "
    3898                 :             :                                             "function %qD", decl);
    3899                 :             :                   /* See if we can hint which header to include.  */
    3900                 :        2528 :                   const char *header = header_for_builtin_fn (decl);
    3901                 :        2528 :                   if (header != NULL && warned)
    3902                 :             :                     {
    3903                 :         133 :                       rich_location richloc (line_table, loc);
    3904                 :         133 :                       maybe_add_include_fixit (&richloc, header, true);
    3905                 :         133 :                       inform (&richloc,
    3906                 :             :                               "include %qs or provide a declaration of %qD",
    3907                 :             :                               header, decl);
    3908                 :         133 :                     }
    3909                 :        2528 :                   newtype = TREE_TYPE (decl);
    3910                 :        2528 :                 }
    3911                 :             :             }
    3912                 :             :           else
    3913                 :             :             {
    3914                 :         432 :               if (!comptypes (newtype, TREE_TYPE (decl)))
    3915                 :             :                 {
    3916                 :           2 :                   auto_diagnostic_group d;
    3917                 :           2 :                   error_at (loc, "incompatible implicit declaration of "
    3918                 :             :                             "function %qD", decl);
    3919                 :           2 :                   locate_old_decl (decl);
    3920                 :           2 :                 }
    3921                 :             :             }
    3922                 :        3137 :           b->u.type = TREE_TYPE (decl);
    3923                 :        3137 :           TREE_TYPE (decl) = newtype;
    3924                 :        3137 :           bind (functionid, decl, current_scope,
    3925                 :             :                 /*invisible=*/false, /*nested=*/true,
    3926                 :        3137 :                 DECL_SOURCE_LOCATION (decl));
    3927                 :        3137 :           return decl;
    3928                 :             :         }
    3929                 :             :     }
    3930                 :             : 
    3931                 :             :   /* Not seen before.  */
    3932                 :        1580 :   decl = build_decl (loc, FUNCTION_DECL, functionid, default_function_type);
    3933                 :        1580 :   DECL_EXTERNAL (decl) = 1;
    3934                 :        1580 :   TREE_PUBLIC (decl) = 1;
    3935                 :        1580 :   C_DECL_IMPLICIT (decl) = 1;
    3936                 :        1580 :   implicit_decl_permerror (loc, functionid, 0);
    3937                 :        1580 :   asmspec_tree = maybe_apply_renaming_pragma (decl, /*asmname=*/NULL);
    3938                 :        1580 :   if (asmspec_tree)
    3939                 :           1 :     set_user_assembler_name (decl, TREE_STRING_POINTER (asmspec_tree));
    3940                 :             : 
    3941                 :             :   /* C89 says implicit declarations are in the innermost block.
    3942                 :             :      So we record the decl in the standard fashion.  */
    3943                 :        1580 :   decl = pushdecl (decl);
    3944                 :             : 
    3945                 :             :   /* No need to call objc_check_decl here - it's a function type.  */
    3946                 :        1580 :   rest_of_decl_compilation (decl, 0, 0);
    3947                 :             : 
    3948                 :             :   /* Write a record describing this implicit function declaration
    3949                 :             :      to the prototypes file (if requested).  */
    3950                 :        1580 :   gen_aux_info_record (decl, 0, 1, 0);
    3951                 :             : 
    3952                 :             :   /* Possibly apply some default attributes to this implicit declaration.  */
    3953                 :        1580 :   decl_attributes (&decl, NULL_TREE, 0);
    3954                 :             : 
    3955                 :        1580 :   return decl;
    3956                 :             : }
    3957                 :             : 
    3958                 :             : /* Issue an error message for a reference to an undeclared variable
    3959                 :             :    ID, including a reference to a builtin outside of function-call
    3960                 :             :    context.  Establish a binding of the identifier to error_mark_node
    3961                 :             :    in an appropriate scope, which will suppress further errors for the
    3962                 :             :    same identifier.  The error message should be given location LOC.  */
    3963                 :             : void
    3964                 :        1463 : undeclared_variable (location_t loc, tree id)
    3965                 :             : {
    3966                 :        1463 :   static bool already = false;
    3967                 :        1463 :   struct c_scope *scope;
    3968                 :             : 
    3969                 :        1463 :   auto_diagnostic_group d;
    3970                 :        1463 :   if (current_function_decl == NULL_TREE)
    3971                 :             :     {
    3972                 :         657 :       name_hint guessed_id = lookup_name_fuzzy (id, FUZZY_LOOKUP_NAME, loc);
    3973                 :         657 :       if (const char *suggestion = guessed_id.suggestion ())
    3974                 :             :         {
    3975                 :          86 :           gcc_rich_location richloc (loc);
    3976                 :          86 :           richloc.add_fixit_replace (suggestion);
    3977                 :          86 :           error_at (&richloc,
    3978                 :             :                     "%qE undeclared here (not in a function);"
    3979                 :             :                     " did you mean %qs?",
    3980                 :             :                     id, suggestion);
    3981                 :          86 :         }
    3982                 :             :       else
    3983                 :         571 :         error_at (loc, "%qE undeclared here (not in a function)", id);
    3984                 :         657 :       scope = current_scope;
    3985                 :         657 :     }
    3986                 :             :   else
    3987                 :             :     {
    3988                 :         806 :       if (!objc_diagnose_private_ivar (id))
    3989                 :             :         {
    3990                 :         806 :           name_hint guessed_id = lookup_name_fuzzy (id, FUZZY_LOOKUP_NAME, loc);
    3991                 :         806 :           if (const char *suggestion = guessed_id.suggestion ())
    3992                 :             :             {
    3993                 :          37 :               gcc_rich_location richloc (loc);
    3994                 :          37 :               richloc.add_fixit_replace (suggestion);
    3995                 :          37 :               error_at (&richloc,
    3996                 :             :                         "%qE undeclared (first use in this function);"
    3997                 :             :                         " did you mean %qs?",
    3998                 :             :                         id, suggestion);
    3999                 :          37 :             }
    4000                 :             :           else
    4001                 :         769 :             error_at (loc, "%qE undeclared (first use in this function)", id);
    4002                 :         806 :         }
    4003                 :         806 :       if (!already)
    4004                 :             :         {
    4005                 :         190 :           inform (loc, "each undeclared identifier is reported only"
    4006                 :             :                   " once for each function it appears in");
    4007                 :         190 :           already = true;
    4008                 :             :         }
    4009                 :             : 
    4010                 :             :       /* If we are parsing old-style parameter decls, current_function_decl
    4011                 :             :          will be nonnull but current_function_scope will be null.  */
    4012                 :         806 :       scope = current_function_scope ? current_function_scope : current_scope;
    4013                 :             :     }
    4014                 :        1463 :   bind (id, error_mark_node, scope, /*invisible=*/false, /*nested=*/false,
    4015                 :             :         UNKNOWN_LOCATION);
    4016                 :        1463 : }
    4017                 :             : 
    4018                 :             : /* Subroutine of lookup_label, declare_label, define_label: construct a
    4019                 :             :    LABEL_DECL with all the proper frills.  Also create a struct
    4020                 :             :    c_label_vars initialized for the current scope.  */
    4021                 :             : 
    4022                 :             : static tree
    4023                 :       22645 : make_label (location_t location, tree name, bool defining,
    4024                 :             :             struct c_label_vars **p_label_vars)
    4025                 :             : {
    4026                 :       22645 :   tree label = build_decl (location, LABEL_DECL, name, void_type_node);
    4027                 :       22645 :   DECL_CONTEXT (label) = current_function_decl;
    4028                 :       22645 :   SET_DECL_MODE (label, VOIDmode);
    4029                 :             : 
    4030                 :       22645 :   c_label_vars *label_vars = ggc_alloc<c_label_vars> ();
    4031                 :       22645 :   label_vars->shadowed = NULL;
    4032                 :       22645 :   set_spot_bindings (&label_vars->label_bindings, defining);
    4033                 :       22645 :   label_vars->decls_in_scope = make_tree_vector ();
    4034                 :       22645 :   label_vars->gotos = NULL;
    4035                 :       22645 :   *p_label_vars = label_vars;
    4036                 :             : 
    4037                 :       22645 :   return label;
    4038                 :             : }
    4039                 :             : 
    4040                 :             : /* Get the LABEL_DECL corresponding to identifier NAME as a label.
    4041                 :             :    Create one if none exists so far for the current function.
    4042                 :             :    This is called when a label is used in a goto expression or
    4043                 :             :    has its address taken.  */
    4044                 :             : 
    4045                 :             : tree
    4046                 :       84486 : lookup_label (tree name)
    4047                 :             : {
    4048                 :       84486 :   tree label;
    4049                 :       84486 :   struct c_label_vars *label_vars;
    4050                 :             : 
    4051                 :       84486 :   if (current_function_scope == 0)
    4052                 :             :     {
    4053                 :           2 :       error ("label %qE referenced outside of any function", name);
    4054                 :           2 :       return NULL_TREE;
    4055                 :             :     }
    4056                 :             : 
    4057                 :             :   /* Use a label already defined or ref'd with this name, but not if
    4058                 :             :      it is inherited from a containing function and wasn't declared
    4059                 :             :      using __label__.  */
    4060                 :       84484 :   label = I_LABEL_DECL (name);
    4061                 :       79151 :   if (label && (DECL_CONTEXT (label) == current_function_decl
    4062                 :         605 :                 || C_DECLARED_LABEL_FLAG (label)))
    4063                 :             :     {
    4064                 :             :       /* If the label has only been declared, update its apparent
    4065                 :             :          location to point here, for better diagnostics if it
    4066                 :             :          turns out not to have been defined.  */
    4067                 :       79144 :       if (DECL_INITIAL (label) == NULL_TREE)
    4068                 :       62624 :         DECL_SOURCE_LOCATION (label) = input_location;
    4069                 :       79144 :       return label;
    4070                 :             :     }
    4071                 :             : 
    4072                 :             :   /* No label binding for that identifier; make one.  */
    4073                 :        5340 :   label = make_label (input_location, name, false, &label_vars);
    4074                 :             : 
    4075                 :             :   /* Ordinary labels go in the current function scope.  */
    4076                 :        5340 :   bind_label (name, label, current_function_scope, label_vars);
    4077                 :             : 
    4078                 :        5340 :   return label;
    4079                 :             : }
    4080                 :             : 
    4081                 :             : /* Issue a warning about DECL for a goto statement at GOTO_LOC going
    4082                 :             :    to LABEL.  */
    4083                 :             : 
    4084                 :             : static void
    4085                 :        1469 : warn_about_goto (location_t goto_loc, tree label, tree decl)
    4086                 :             : {
    4087                 :        1469 :   auto_diagnostic_group d;
    4088                 :        1469 :   if (c_type_variably_modified_p (TREE_TYPE (decl)))
    4089                 :        1464 :     error_at (goto_loc,
    4090                 :             :               "jump into scope of identifier with variably modified type");
    4091                 :           5 :   else if (flag_openmp
    4092                 :           5 :            && lookup_attribute ("omp allocate", DECL_ATTRIBUTES (decl)))
    4093                 :           2 :     error_at (goto_loc, "jump skips OpenMP %<allocate%> allocation");
    4094                 :             :   else
    4095                 :           3 :     if (!warning_at (goto_loc, OPT_Wjump_misses_init,
    4096                 :             :                      "jump skips variable initialization"))
    4097                 :           0 :       return;
    4098                 :        1469 :   inform (DECL_SOURCE_LOCATION (label), "label %qD defined here", label);
    4099                 :        1469 :   inform (DECL_SOURCE_LOCATION (decl), "%qD declared here", decl);
    4100                 :        1469 : }
    4101                 :             : 
    4102                 :             : /* Look up a label because of a goto statement.  This is like
    4103                 :             :    lookup_label, but also issues any appropriate warnings.  */
    4104                 :             : 
    4105                 :             : tree
    4106                 :       82677 : lookup_label_for_goto (location_t loc, tree name)
    4107                 :             : {
    4108                 :       82677 :   tree label;
    4109                 :       82677 :   struct c_label_vars *label_vars;
    4110                 :       82677 :   unsigned int ix;
    4111                 :       82677 :   tree decl;
    4112                 :             : 
    4113                 :       82677 :   label = lookup_label (name);
    4114                 :       82677 :   if (label == NULL_TREE)
    4115                 :             :     return NULL_TREE;
    4116                 :             : 
    4117                 :             :   /* If we are jumping to a different function, we can't issue any
    4118                 :             :      useful warnings.  */
    4119                 :       82677 :   if (DECL_CONTEXT (label) != current_function_decl)
    4120                 :             :     {
    4121                 :         519 :       gcc_assert (C_DECLARED_LABEL_FLAG (label));
    4122                 :             :       return label;
    4123                 :             :     }
    4124                 :             : 
    4125                 :       82158 :   label_vars = I_LABEL_BINDING (name)->u.label;
    4126                 :             : 
    4127                 :             :   /* If the label has not yet been defined, then push this goto on a
    4128                 :             :      list for possible later warnings.  */
    4129                 :       82158 :   if (label_vars->label_bindings.scope == NULL)
    4130                 :             :     {
    4131                 :       65854 :       c_goto_bindings *g = ggc_alloc<c_goto_bindings> ();
    4132                 :             : 
    4133                 :       65854 :       g->loc = loc;
    4134                 :       65854 :       set_spot_bindings (&g->goto_bindings, true);
    4135                 :       65854 :       vec_safe_push (label_vars->gotos, g);
    4136                 :       65854 :       return label;
    4137                 :             :     }
    4138                 :             : 
    4139                 :             :   /* If there are any decls in label_vars->decls_in_scope, then this
    4140                 :             :      goto has missed the declaration of the decl.  This happens for a
    4141                 :             :      case like
    4142                 :             :        int i = 1;
    4143                 :             :       lab:
    4144                 :             :        ...
    4145                 :             :        goto lab;
    4146                 :             :      Issue a warning or error.  */
    4147                 :       17079 :   FOR_EACH_VEC_SAFE_ELT (label_vars->decls_in_scope, ix, decl)
    4148                 :         775 :     warn_about_goto (loc, label, decl);
    4149                 :             : 
    4150                 :       16304 :   if (label_vars->label_bindings.left_stmt_expr)
    4151                 :             :     {
    4152                 :         120 :       auto_diagnostic_group d;
    4153                 :         120 :       error_at (loc, "jump into statement expression");
    4154                 :         120 :       inform (DECL_SOURCE_LOCATION (label), "label %qD defined here", label);
    4155                 :         120 :     }
    4156                 :             : 
    4157                 :             :   return label;
    4158                 :             : }
    4159                 :             : 
    4160                 :             : /* Make a label named NAME in the current function, shadowing silently
    4161                 :             :    any that may be inherited from containing functions or containing
    4162                 :             :    scopes.  This is called for __label__ declarations.  */
    4163                 :             : 
    4164                 :             : tree
    4165                 :        1176 : declare_label (tree name)
    4166                 :             : {
    4167                 :        1176 :   struct c_binding *b = I_LABEL_BINDING (name);
    4168                 :        1176 :   tree label;
    4169                 :        1176 :   struct c_label_vars *label_vars;
    4170                 :             : 
    4171                 :             :   /* Check to make sure that the label hasn't already been declared
    4172                 :             :      at this scope */
    4173                 :        1176 :   if (b && B_IN_CURRENT_SCOPE (b))
    4174                 :             :     {
    4175                 :           2 :       auto_diagnostic_group d;
    4176                 :           2 :       error ("duplicate label declaration %qE", name);
    4177                 :           2 :       locate_old_decl (b->decl);
    4178                 :             : 
    4179                 :             :       /* Just use the previous declaration.  */
    4180                 :           2 :       return b->decl;
    4181                 :           2 :     }
    4182                 :             : 
    4183                 :        1174 :   label = make_label (input_location, name, false, &label_vars);
    4184                 :        1174 :   C_DECLARED_LABEL_FLAG (label) = 1;
    4185                 :             : 
    4186                 :             :   /* Declared labels go in the current scope.  */
    4187                 :        1174 :   bind_label (name, label, current_scope, label_vars);
    4188                 :             : 
    4189                 :        1174 :   return label;
    4190                 :             : }
    4191                 :             : 
    4192                 :             : /* When we define a label, issue any appropriate warnings if there are
    4193                 :             :    any gotos earlier in the function which jump to this label.  */
    4194                 :             : 
    4195                 :             : static void
    4196                 :        6434 : check_earlier_gotos (tree label, struct c_label_vars* label_vars)
    4197                 :             : {
    4198                 :        6434 :   unsigned int ix;
    4199                 :        6434 :   struct c_goto_bindings *g;
    4200                 :             : 
    4201                 :       72222 :   FOR_EACH_VEC_SAFE_ELT (label_vars->gotos, ix, g)
    4202                 :             :     {
    4203                 :       65788 :       struct c_binding *b;
    4204                 :       65788 :       struct c_scope *scope;
    4205                 :             : 
    4206                 :             :       /* We have a goto to this label.  The goto is going forward.  In
    4207                 :             :          g->scope, the goto is going to skip any binding which was
    4208                 :             :          defined after g->bindings_in_scope.  */
    4209                 :       65788 :       if (g->goto_bindings.scope->has_jump_unsafe_decl)
    4210                 :             :         {
    4211                 :         239 :           for (b = g->goto_bindings.scope->bindings;
    4212                 :         557 :                b != g->goto_bindings.bindings_in_scope;
    4213                 :         318 :                b = b->prev)
    4214                 :             :             {
    4215                 :         318 :               if (decl_jump_unsafe (b->decl))
    4216                 :         159 :                 warn_about_goto (g->loc, label, b->decl);
    4217                 :             :             }
    4218                 :             :         }
    4219                 :             : 
    4220                 :             :       /* We also need to warn about decls defined in any scopes
    4221                 :             :          between the scope of the label and the scope of the goto.  */
    4222                 :       65788 :       for (scope = label_vars->label_bindings.scope;
    4223                 :       68281 :            scope != g->goto_bindings.scope;
    4224                 :        2493 :            scope = scope->outer)
    4225                 :             :         {
    4226                 :        2493 :           gcc_assert (scope != NULL);
    4227                 :        2493 :           if (scope->has_jump_unsafe_decl)
    4228                 :             :             {
    4229                 :         321 :               if (scope == label_vars->label_bindings.scope)
    4230                 :         249 :                 b = label_vars->label_bindings.bindings_in_scope;
    4231                 :             :               else
    4232                 :          72 :                 b = scope->bindings;
    4233                 :         856 :               for (; b != NULL; b = b->prev)
    4234                 :             :                 {
    4235                 :         535 :                   if (decl_jump_unsafe (b->decl))
    4236                 :         535 :                     warn_about_goto (g->loc, label, b->decl);
    4237                 :             :                 }
    4238                 :             :             }
    4239                 :             :         }
    4240                 :             : 
    4241                 :       65788 :       if (g->goto_bindings.stmt_exprs > 0)
    4242                 :             :         {
    4243                 :         100 :           auto_diagnostic_group d;
    4244                 :         100 :           error_at (g->loc, "jump into statement expression");
    4245                 :         100 :           inform (DECL_SOURCE_LOCATION (label), "label %qD defined here",
    4246                 :             :                   label);
    4247                 :         100 :         }
    4248                 :             :     }
    4249                 :             : 
    4250                 :             :   /* Now that the label is defined, we will issue warnings about
    4251                 :             :      subsequent gotos to this label when we see them.  */
    4252                 :        6434 :   vec_safe_truncate (label_vars->gotos, 0);
    4253                 :        6434 :   label_vars->gotos = NULL;
    4254                 :        6434 : }
    4255                 :             : 
    4256                 :             : /* Define a label, specifying the location in the source file.
    4257                 :             :    Return the LABEL_DECL node for the label, if the definition is valid.
    4258                 :             :    Otherwise return NULL_TREE.  */
    4259                 :             : 
    4260                 :             : tree
    4261                 :       22594 : define_label (location_t location, tree name)
    4262                 :             : {
    4263                 :             :   /* Find any preexisting label with this name.  It is an error
    4264                 :             :      if that label has already been defined in this function, or
    4265                 :             :      if there is a containing function with a declared label with
    4266                 :             :      the same name.  */
    4267                 :       22594 :   tree label = I_LABEL_DECL (name);
    4268                 :             : 
    4269                 :        6470 :   if (label
    4270                 :        6470 :       && ((DECL_CONTEXT (label) == current_function_decl
    4271                 :        6456 :            && DECL_INITIAL (label) != NULL_TREE)
    4272                 :        6448 :           || (DECL_CONTEXT (label) != current_function_decl
    4273                 :          14 :               && C_DECLARED_LABEL_FLAG (label))))
    4274                 :             :     {
    4275                 :          29 :       auto_diagnostic_group d;
    4276                 :          29 :       error_at (location, "duplicate label %qD", label);
    4277                 :          29 :       locate_old_decl (label);
    4278                 :          29 :       return NULL_TREE;
    4279                 :          29 :     }
    4280                 :       22565 :   else if (label && DECL_CONTEXT (label) == current_function_decl)
    4281                 :             :     {
    4282                 :        6434 :       struct c_label_vars *label_vars = I_LABEL_BINDING (name)->u.label;
    4283                 :             : 
    4284                 :             :       /* The label has been used or declared already in this function,
    4285                 :             :          but not defined.  Update its location to point to this
    4286                 :             :          definition.  */
    4287                 :        6434 :       DECL_SOURCE_LOCATION (label) = location;
    4288                 :        6434 :       set_spot_bindings (&label_vars->label_bindings, true);
    4289                 :             : 
    4290                 :             :       /* Issue warnings as required about any goto statements from
    4291                 :             :          earlier in the function.  */
    4292                 :        6434 :       check_earlier_gotos (label, label_vars);
    4293                 :             :     }
    4294                 :             :   else
    4295                 :             :     {
    4296                 :       16131 :       struct c_label_vars *label_vars;
    4297                 :             : 
    4298                 :             :       /* No label binding for that identifier; make one.  */
    4299                 :       16131 :       label = make_label (location, name, true, &label_vars);
    4300                 :             : 
    4301                 :             :       /* Ordinary labels go in the current function scope.  */
    4302                 :       16131 :       bind_label (name, label, current_function_scope, label_vars);
    4303                 :             :     }
    4304                 :             : 
    4305                 :       22565 :   if (!in_system_header_at (input_location) && lookup_name (name))
    4306                 :         113 :     warning_at (location, OPT_Wtraditional,
    4307                 :             :                 "traditional C lacks a separate namespace "
    4308                 :             :                 "for labels, identifier %qE conflicts", name);
    4309                 :             : 
    4310                 :             :   /* Mark label as having been defined.  */
    4311                 :       22565 :   DECL_INITIAL (label) = error_mark_node;
    4312                 :       22565 :   return label;
    4313                 :             : }
    4314                 :             : 
    4315                 :             : /* Get the bindings for a new switch statement.  This is used to issue
    4316                 :             :    warnings as appropriate for jumps from the switch to case or
    4317                 :             :    default labels.  */
    4318                 :             : 
    4319                 :             : struct c_spot_bindings *
    4320                 :       36196 : c_get_switch_bindings (void)
    4321                 :             : {
    4322                 :       36196 :   struct c_spot_bindings *switch_bindings;
    4323                 :             : 
    4324                 :       36196 :   switch_bindings = XNEW (struct c_spot_bindings);
    4325                 :       36196 :   set_spot_bindings (switch_bindings, true);
    4326                 :       36196 :   return switch_bindings;
    4327                 :             : }
    4328                 :             : 
    4329                 :             : void
    4330                 :       36196 : c_release_switch_bindings (struct c_spot_bindings *bindings)
    4331                 :             : {
    4332                 :       36196 :   gcc_assert (bindings->stmt_exprs == 0 && !bindings->left_stmt_expr);
    4333                 :       36196 :   XDELETE (bindings);
    4334                 :       36196 : }
    4335                 :             : 
    4336                 :             : /* This is called at the point of a case or default label to issue
    4337                 :             :    warnings about decls as needed.  It returns true if it found an
    4338                 :             :    error, not just a warning.  */
    4339                 :             : 
    4340                 :             : bool
    4341                 :     1021507 : c_check_switch_jump_warnings (struct c_spot_bindings *switch_bindings,
    4342                 :             :                               location_t switch_loc, location_t case_loc)
    4343                 :             : {
    4344                 :     1021507 :   bool saw_error;
    4345                 :     1021507 :   struct c_scope *scope;
    4346                 :             : 
    4347                 :     1021507 :   saw_error = false;
    4348                 :     1021507 :   for (scope = current_scope;
    4349                 :     3064608 :        scope != switch_bindings->scope;
    4350                 :     2043101 :        scope = scope->outer)
    4351                 :             :     {
    4352                 :     2043101 :       struct c_binding *b;
    4353                 :             : 
    4354                 :     2043101 :       gcc_assert (scope != NULL);
    4355                 :             : 
    4356                 :     2043101 :       if (!scope->has_jump_unsafe_decl)
    4357                 :     2043093 :         continue;
    4358                 :             : 
    4359                 :          16 :       for (b = scope->bindings; b != NULL; b = b->prev)
    4360                 :             :         {
    4361                 :           8 :           if (decl_jump_unsafe (b->decl))
    4362                 :             :             {
    4363                 :           8 :               auto_diagnostic_group d;
    4364                 :           8 :               bool emitted;
    4365                 :           8 :               if (c_type_variably_modified_p (TREE_TYPE (b->decl)))
    4366                 :             :                 {
    4367                 :           3 :                   saw_error = true;
    4368                 :           3 :                   error_at (case_loc,
    4369                 :             :                             ("switch jumps into scope of identifier with "
    4370                 :             :                              "variably modified type"));
    4371                 :           3 :                   emitted = true;
    4372                 :             :                 }
    4373                 :           5 :               else if (flag_openmp
    4374                 :           7 :                        && lookup_attribute ("omp allocate",
    4375                 :           2 :                                             DECL_ATTRIBUTES (b->decl)))
    4376                 :             :                 {
    4377                 :           2 :                   saw_error = true;
    4378                 :           2 :                   error_at (case_loc,
    4379                 :             :                             "switch jumps over OpenMP %<allocate%> allocation");
    4380                 :           2 :                   emitted = true;
    4381                 :             :                 }
    4382                 :             :               else
    4383                 :           3 :                 emitted
    4384                 :           3 :                   = warning_at (case_loc, OPT_Wjump_misses_init,
    4385                 :             :                                 "switch jumps over variable initialization");
    4386                 :           8 :               if (emitted)
    4387                 :             :                 {
    4388                 :           8 :                   inform (switch_loc, "switch starts here");
    4389                 :           8 :                   inform (DECL_SOURCE_LOCATION (b->decl), "%qD declared here",
    4390                 :             :                           b->decl);
    4391                 :             :                 }
    4392                 :           8 :             }
    4393                 :             :         }
    4394                 :             :     }
    4395                 :             : 
    4396                 :     1021507 :   if (switch_bindings->stmt_exprs > 0)
    4397                 :             :     {
    4398                 :           4 :       saw_error = true;
    4399                 :           4 :       auto_diagnostic_group d;
    4400                 :           4 :       error_at (case_loc, "switch jumps into statement expression");
    4401                 :           4 :       inform (switch_loc, "switch starts here");
    4402                 :           4 :     }
    4403                 :             : 
    4404                 :     1021507 :   return saw_error;
    4405                 :             : }
    4406                 :             : 
    4407                 :             : /* Given NAME, an IDENTIFIER_NODE,
    4408                 :             :    return the structure (or union or enum) definition for that name.
    4409                 :             :    If THISLEVEL_ONLY is nonzero, searches only the current_scope.
    4410                 :             :    CODE says which kind of type the caller wants;
    4411                 :             :    it is RECORD_TYPE or UNION_TYPE or ENUMERAL_TYPE.
    4412                 :             :    If PLOC is not NULL and this returns non-null, it sets *PLOC to the
    4413                 :             :    location where the tag was defined.
    4414                 :             :    If the wrong kind of type is found, an error is reported.  */
    4415                 :             : 
    4416                 :             : static tree
    4417                 :     1949516 : lookup_tag (enum tree_code code, tree name, bool thislevel_only,
    4418                 :             :             location_t *ploc)
    4419                 :             : {
    4420                 :     1949516 :   struct c_binding *b = I_TAG_BINDING (name);
    4421                 :     1949516 :   bool thislevel = false;
    4422                 :             : 
    4423                 :     1949516 :   if (!b || !b->decl)
    4424                 :             :     return NULL_TREE;
    4425                 :             : 
    4426                 :             :   /* We only care about whether it's in this level if
    4427                 :             :      thislevel_only was set or it might be a type clash.  */
    4428                 :     1363649 :   if (thislevel_only || TREE_CODE (b->decl) != code)
    4429                 :             :     {
    4430                 :             :       /* For our purposes, a tag in the external scope is the same as
    4431                 :             :          a tag in the file scope.  (Primarily relevant to Objective-C
    4432                 :             :          and its builtin structure tags, which get pushed before the
    4433                 :             :          file scope is created.)  */
    4434                 :      441368 :       if (B_IN_CURRENT_SCOPE (b)
    4435                 :         153 :           || (current_scope == file_scope && B_IN_EXTERNAL_SCOPE (b)))
    4436                 :     1363649 :         thislevel = true;
    4437                 :             :     }
    4438                 :             : 
    4439                 :     1363649 :   if (thislevel_only && !thislevel)
    4440                 :             :     return NULL_TREE;
    4441                 :             : 
    4442                 :     1363517 :   if (TREE_CODE (b->decl) != code)
    4443                 :             :     {
    4444                 :             :       /* Definition isn't the kind we were looking for.  */
    4445                 :          39 :       pending_invalid_xref = name;
    4446                 :          39 :       pending_invalid_xref_location = input_location;
    4447                 :             : 
    4448                 :             :       /* If in the same binding level as a declaration as a tag
    4449                 :             :          of a different type, this must not be allowed to
    4450                 :             :          shadow that tag, so give the error immediately.
    4451                 :             :          (For example, "struct foo; union foo;" is invalid.)  */
    4452                 :          39 :       if (thislevel)
    4453                 :          18 :         pending_xref_error ();
    4454                 :             :     }
    4455                 :             : 
    4456                 :     1363517 :   if (ploc != NULL)
    4457                 :      946601 :     *ploc = b->locus;
    4458                 :             : 
    4459                 :     1363517 :   return b->decl;
    4460                 :             : }
    4461                 :             : 
    4462                 :             : /* Return true if a definition exists for NAME with code CODE.  */
    4463                 :             : 
    4464                 :             : bool
    4465                 :         321 : tag_exists_p (enum tree_code code, tree name)
    4466                 :             : {
    4467                 :         321 :   struct c_binding *b = I_TAG_BINDING (name);
    4468                 :             : 
    4469                 :         321 :   if (b == NULL || b->decl == NULL_TREE)
    4470                 :             :     return false;
    4471                 :          18 :   return TREE_CODE (b->decl) == code;
    4472                 :             : }
    4473                 :             : 
    4474                 :             : /* Print an error message now
    4475                 :             :    for a recent invalid struct, union or enum cross reference.
    4476                 :             :    We don't print them immediately because they are not invalid
    4477                 :             :    when used in the `struct foo;' construct for shadowing.  */
    4478                 :             : 
    4479                 :             : void
    4480                 :   273926910 : pending_xref_error (void)
    4481                 :             : {
    4482                 :   273926910 :   if (pending_invalid_xref != NULL_TREE)
    4483                 :          27 :     error_at (pending_invalid_xref_location, "%qE defined as wrong kind of tag",
    4484                 :             :               pending_invalid_xref);
    4485                 :   273926910 :   pending_invalid_xref = NULL_TREE;
    4486                 :   273926910 : }
    4487                 :             : 
    4488                 :             : 
    4489                 :             : /* Look up NAME in the current scope and its superiors
    4490                 :             :    in the namespace of variables, functions and typedefs.
    4491                 :             :    Return a ..._DECL node of some kind representing its definition,
    4492                 :             :    or return NULL_TREE if it is undefined.  */
    4493                 :             : 
    4494                 :             : tree
    4495                 :  1111721209 : lookup_name (tree name)
    4496                 :             : {
    4497                 :  1111721209 :   struct c_binding *b = I_SYMBOL_BINDING (name);
    4498                 :  1111721209 :   if (b && !b->invisible)
    4499                 :             :     {
    4500                 :   740930273 :       maybe_record_typedef_use (b->decl);
    4501                 :   740930273 :       return b->decl;
    4502                 :             :     }
    4503                 :             :   return NULL_TREE;
    4504                 :             : }
    4505                 :             : 
    4506                 :             : /* Similar to `lookup_name' but look only at the indicated scope.  */
    4507                 :             : 
    4508                 :             : static tree
    4509                 :   112010779 : lookup_name_in_scope (tree name, struct c_scope *scope)
    4510                 :             : {
    4511                 :   112010779 :   struct c_binding *b;
    4512                 :             : 
    4513                 :   112013684 :   for (b = I_SYMBOL_BINDING (name); b; b = b->shadowed)
    4514                 :     6261844 :     if (B_IN_SCOPE (b, scope))
    4515                 :     6258939 :       return b->decl;
    4516                 :             :   return NULL_TREE;
    4517                 :             : }
    4518                 :             : 
    4519                 :             : /* Look for the closest match for NAME within the currently valid
    4520                 :             :    scopes.
    4521                 :             : 
    4522                 :             :    This finds the identifier with the lowest Levenshtein distance to
    4523                 :             :    NAME.  If there are multiple candidates with equal minimal distance,
    4524                 :             :    the first one found is returned.  Scopes are searched from innermost
    4525                 :             :    outwards, and within a scope in reverse order of declaration, thus
    4526                 :             :    benefiting candidates "near" to the current scope.
    4527                 :             : 
    4528                 :             :    The function also looks for similar macro names to NAME, since a
    4529                 :             :    misspelled macro name will not be expanded, and hence looks like an
    4530                 :             :    identifier to the C frontend.
    4531                 :             : 
    4532                 :             :    It also looks for start_typename keywords, to detect "singed" vs "signed"
    4533                 :             :    typos.
    4534                 :             : 
    4535                 :             :    Use LOC for any deferred diagnostics.  */
    4536                 :             : 
    4537                 :             : name_hint
    4538                 :        2241 : lookup_name_fuzzy (tree name, enum lookup_name_fuzzy_kind kind, location_t loc)
    4539                 :             : {
    4540                 :        2241 :   gcc_assert (TREE_CODE (name) == IDENTIFIER_NODE);
    4541                 :             : 
    4542                 :             :   /* First, try some well-known names in the C standard library, in case
    4543                 :             :      the user forgot a #include.  */
    4544                 :        2241 :   const char *header_hint
    4545                 :        2241 :     = get_c_stdlib_header_for_name (IDENTIFIER_POINTER (name));
    4546                 :             : 
    4547                 :        2241 :   if (header_hint)
    4548                 :          55 :     return name_hint (NULL,
    4549                 :             :                       new suggest_missing_header (loc,
    4550                 :          55 :                                                   IDENTIFIER_POINTER (name),
    4551                 :          55 :                                                   header_hint));
    4552                 :             : 
    4553                 :             :   /* Only suggest names reserved for the implementation if NAME begins
    4554                 :             :      with an underscore.  */
    4555                 :        2186 :   bool consider_implementation_names = (IDENTIFIER_POINTER (name)[0] == '_');
    4556                 :             : 
    4557                 :        2186 :   best_match<tree, tree> bm (name);
    4558                 :             : 
    4559                 :             :   /* Look within currently valid scopes.  */
    4560                 :        9614 :   for (c_scope *scope = current_scope; scope; scope = scope->outer)
    4561                 :    11430182 :     for (c_binding *binding = scope->bindings; binding; binding = binding->prev)
    4562                 :             :       {
    4563                 :    11422754 :         if (!binding->id || binding->invisible)
    4564                 :     6473365 :           continue;
    4565                 :     4949389 :         if (binding->decl == error_mark_node)
    4566                 :         353 :           continue;
    4567                 :             :         /* Don't use bindings from implicitly declared functions,
    4568                 :             :            as they were likely misspellings themselves.  */
    4569                 :     4949036 :         if (TREE_CODE (binding->decl) == FUNCTION_DECL)
    4570                 :     4540576 :           if (C_DECL_IMPLICIT (binding->decl))
    4571                 :         229 :             continue;
    4572                 :             :         /* Don't suggest names that are reserved for use by the
    4573                 :             :            implementation, unless NAME began with an underscore.  */
    4574                 :     4948807 :         if (!consider_implementation_names)
    4575                 :             :           {
    4576                 :     2088938 :             const char *suggestion_str = IDENTIFIER_POINTER (binding->id);
    4577                 :     2088938 :             if (name_reserved_for_implementation_p (suggestion_str))
    4578                 :     2033356 :               continue;
    4579                 :             :           }
    4580                 :     2915451 :         switch (kind)
    4581                 :             :           {
    4582                 :       29127 :           case FUZZY_LOOKUP_TYPENAME:
    4583                 :       29127 :             if (TREE_CODE (binding->decl) != TYPE_DECL)
    4584                 :       22334 :               continue;
    4585                 :             :             break;
    4586                 :             : 
    4587                 :      115557 :           case FUZZY_LOOKUP_FUNCTION_NAME:
    4588                 :      115557 :             if (TREE_CODE (binding->decl) != FUNCTION_DECL)
    4589                 :             :               {
    4590                 :             :                 /* Allow function pointers.  */
    4591                 :       26259 :                 if ((VAR_P (binding->decl)
    4592                 :       21734 :                      || TREE_CODE (binding->decl) == PARM_DECL)
    4593                 :        5400 :                     && TREE_CODE (TREE_TYPE (binding->decl)) == POINTER_TYPE
    4594                 :       27539 :                     && (TREE_CODE (TREE_TYPE (TREE_TYPE (binding->decl)))
    4595                 :             :                         == FUNCTION_TYPE))
    4596                 :             :                   break;
    4597                 :       26240 :                 continue;
    4598                 :             :               }
    4599                 :             :             break;
    4600                 :             : 
    4601                 :             :           default:
    4602                 :             :             break;
    4603                 :             :           }
    4604                 :     2866877 :         bm.consider (binding->id);
    4605                 :             :       }
    4606                 :             : 
    4607                 :             :   /* Consider macros: if the user misspelled a macro name e.g. "SOME_MACRO"
    4608                 :             :      as:
    4609                 :             :        x = SOME_OTHER_MACRO (y);
    4610                 :             :      then "SOME_OTHER_MACRO" will survive to the frontend and show up
    4611                 :             :      as a misspelled identifier.
    4612                 :             : 
    4613                 :             :      Use the best distance so far so that a candidate is only set if
    4614                 :             :      a macro is better than anything so far.  This allows early rejection
    4615                 :             :      (without calculating the edit distance) of macro names that must have
    4616                 :             :      distance >= bm.get_best_distance (), and means that we only get a
    4617                 :             :      non-NULL result for best_macro_match if it's better than any of
    4618                 :             :      the identifiers already checked, which avoids needless creation
    4619                 :             :      of identifiers for macro hashnodes.  */
    4620                 :        2186 :   best_macro_match bmm (name, bm.get_best_distance (), parse_in);
    4621                 :        2186 :   cpp_hashnode *best_macro = bmm.get_best_meaningful_candidate ();
    4622                 :             :   /* If a macro is the closest so far to NAME, use it, creating an
    4623                 :             :      identifier tree node for it.  */
    4624                 :        2186 :   if (best_macro)
    4625                 :             :     {
    4626                 :          11 :       const char *id = (const char *)best_macro->ident.str;
    4627                 :          11 :       tree macro_as_identifier
    4628                 :          11 :         = get_identifier_with_length (id, best_macro->ident.len);
    4629                 :          11 :       bm.set_best_so_far (macro_as_identifier,
    4630                 :             :                           bmm.get_best_distance (),
    4631                 :             :                           bmm.get_best_candidate_length ());
    4632                 :             :     }
    4633                 :             : 
    4634                 :             :   /* Try the "start_typename" keywords to detect
    4635                 :             :      "singed" vs "signed" typos.  */
    4636                 :        2186 :   if (kind == FUZZY_LOOKUP_TYPENAME)
    4637                 :             :     {
    4638                 :       47957 :       for (unsigned i = 0; i < num_c_common_reswords; i++)
    4639                 :             :         {
    4640                 :       47740 :           const c_common_resword *resword = &c_common_reswords[i];
    4641                 :       47740 :           if (!c_keyword_starts_typename (resword->rid))
    4642                 :       36022 :             continue;
    4643                 :       11718 :           tree resword_identifier = ridpointers [resword->rid];
    4644                 :       11718 :           if (!resword_identifier)
    4645                 :          30 :             continue;
    4646                 :       11688 :           gcc_assert (TREE_CODE (resword_identifier) == IDENTIFIER_NODE);
    4647                 :       11688 :           bm.consider (resword_identifier);
    4648                 :             :         }
    4649                 :             :     }
    4650                 :             : 
    4651                 :        2186 :   tree best = bm.get_best_meaningful_candidate ();
    4652                 :        2186 :   if (best)
    4653                 :         272 :     return name_hint (IDENTIFIER_POINTER (best), NULL);
    4654                 :             :   else
    4655                 :        1914 :     return name_hint (NULL, NULL);
    4656                 :             : }
    4657                 :             : 
    4658                 :             : 
    4659                 :             : /* Handle the standard [[nodiscard]] attribute.  */
    4660                 :             : 
    4661                 :             : static tree
    4662                 :          26 : handle_nodiscard_attribute (tree *node, tree name, tree /*args*/,
    4663                 :             :                             int /*flags*/, bool *no_add_attrs)
    4664                 :             : {
    4665                 :          26 :   if (TREE_CODE (*node) == FUNCTION_DECL)
    4666                 :             :     {
    4667                 :          10 :       if (VOID_TYPE_P (TREE_TYPE (TREE_TYPE (*node))))
    4668                 :           1 :         warning_at (DECL_SOURCE_LOCATION (*node),
    4669                 :             :                     OPT_Wattributes, "%qE attribute applied to %qD with void "
    4670                 :             :                     "return type", name, *node);
    4671                 :             :     }
    4672                 :          16 :   else if (RECORD_OR_UNION_TYPE_P (*node)
    4673                 :          12 :            || TREE_CODE (*node) == ENUMERAL_TYPE)
    4674                 :             :     /* OK */;
    4675                 :             :   else
    4676                 :             :     {
    4677                 :          10 :       pedwarn (input_location,
    4678                 :             :                OPT_Wattributes, "%qE attribute can only be applied to "
    4679                 :             :                "functions or to structure, union or enumeration types", name);
    4680                 :          10 :       *no_add_attrs = true;
    4681                 :             :     }
    4682                 :          26 :   return NULL_TREE;
    4683                 :             : }
    4684                 :             : 
    4685                 :             : /* Handle the standard [[noreturn]] attribute.  */
    4686                 :             : 
    4687                 :             : static tree
    4688                 :          42 : handle_std_noreturn_attribute (tree *node, tree name, tree args,
    4689                 :             :                                int flags, bool *no_add_attrs)
    4690                 :             : {
    4691                 :             :   /* Unlike GNU __attribute__ ((noreturn)), the standard [[noreturn]]
    4692                 :             :      only applies to functions, not function pointers.  */
    4693                 :          42 :   if (TREE_CODE (*node) == FUNCTION_DECL)
    4694                 :          20 :     return handle_noreturn_attribute (node, name, args, flags, no_add_attrs);
    4695                 :             :   else
    4696                 :             :     {
    4697                 :          22 :       pedwarn (input_location, OPT_Wattributes,
    4698                 :             :                "standard %qE attribute can only be applied to functions",
    4699                 :             :                name);
    4700                 :          22 :       *no_add_attrs = true;
    4701                 :          22 :       return NULL_TREE;
    4702                 :             :     }
    4703                 :             : }
    4704                 :             : 
    4705                 :             : /* Table of supported standard (C23) attributes.  */
    4706                 :             : static const attribute_spec std_attributes[] =
    4707                 :             : {
    4708                 :             :   /* { name, min_len, max_len, decl_req, type_req, fn_type_req,
    4709                 :             :        affects_type_identity, handler, exclude } */
    4710                 :             :   { "_Noreturn", 0, 0, false, false, false, false,
    4711                 :             :     handle_std_noreturn_attribute, NULL },
    4712                 :             :   { "deprecated", 0, 1, false, false, false, false,
    4713                 :             :     handle_deprecated_attribute, NULL },
    4714                 :             :   { "fallthrough", 0, 0, false, false, false, false,
    4715                 :             :     handle_fallthrough_attribute, NULL },
    4716                 :             :   { "maybe_unused", 0, 0, false, false, false, false,
    4717                 :             :     handle_unused_attribute, NULL },
    4718                 :             :   { "nodiscard", 0, 1, false, false, false, false,
    4719                 :             :     handle_nodiscard_attribute, NULL },
    4720                 :             :   { "noreturn", 0, 0, false, false, false, false,
    4721                 :             :     handle_std_noreturn_attribute, NULL }
    4722                 :             : };
    4723                 :             : 
    4724                 :             : const scoped_attribute_specs std_attribute_table =
    4725                 :             : {
    4726                 :             :   nullptr, { std_attributes }
    4727                 :             : };
    4728                 :             : 
    4729                 :             : /* Create the predefined scalar types of C,
    4730                 :             :    and some nodes representing standard constants (0, 1, (void *) 0).
    4731                 :             :    Initialize the global scope.
    4732                 :             :    Make definitions for built-in primitive functions.  */
    4733                 :             : 
    4734                 :             : void
    4735                 :      107978 : c_init_decl_processing (void)
    4736                 :             : {
    4737                 :      107978 :   location_t save_loc = input_location;
    4738                 :             : 
    4739                 :             :   /* Initialize reserved words for parser.  */
    4740                 :      107978 :   c_parse_init ();
    4741                 :             : 
    4742                 :      107978 :   current_function_decl = NULL_TREE;
    4743                 :             : 
    4744                 :      107978 :   gcc_obstack_init (&parser_obstack);
    4745                 :             : 
    4746                 :             :   /* Make the externals scope.  */
    4747                 :      107978 :   push_scope ();
    4748                 :      107978 :   external_scope = current_scope;
    4749                 :             : 
    4750                 :             :   /* Declarations from c_common_nodes_and_builtins must not be associated
    4751                 :             :      with this input file, lest we get differences between using and not
    4752                 :             :      using preprocessed headers.  */
    4753                 :      107978 :   input_location = BUILTINS_LOCATION;
    4754                 :             : 
    4755                 :      107978 :   c_common_nodes_and_builtins ();
    4756                 :             : 
    4757                 :             :   /* In C, comparisons and TRUTH_* expressions have type int.  */
    4758                 :      107978 :   truthvalue_type_node = integer_type_node;
    4759                 :      107978 :   truthvalue_true_node = integer_one_node;
    4760                 :      107978 :   truthvalue_false_node = integer_zero_node;
    4761                 :             : 
    4762                 :             :   /* Even in C99, which has a real boolean type.  */
    4763                 :      107978 :   pushdecl (build_decl (UNKNOWN_LOCATION, TYPE_DECL, get_identifier ("_Bool"),
    4764                 :             :                         boolean_type_node));
    4765                 :             : 
    4766                 :             :   /* C-specific nullptr initialization.  */
    4767                 :      107978 :   record_builtin_type (RID_MAX, "nullptr_t", nullptr_type_node);
    4768                 :             :   /* The size and alignment of nullptr_t is the same as for a pointer to
    4769                 :             :      character type.  */
    4770                 :      107978 :   SET_TYPE_ALIGN (nullptr_type_node, GET_MODE_ALIGNMENT (ptr_mode));
    4771                 :             : 
    4772                 :      107978 :   input_location = save_loc;
    4773                 :             : 
    4774                 :      107978 :   make_fname_decl = c_make_fname_decl;
    4775                 :      107978 :   start_fname_decls ();
    4776                 :      107978 : }
    4777                 :             : 
    4778                 :             : /* Create the VAR_DECL at LOC for __FUNCTION__ etc. ID is the name to
    4779                 :             :    give the decl, NAME is the initialization string and TYPE_DEP
    4780                 :             :    indicates whether NAME depended on the type of the function.  As we
    4781                 :             :    don't yet implement delayed emission of static data, we mark the
    4782                 :             :    decl as emitted so it is not placed in the output.  Anything using
    4783                 :             :    it must therefore pull out the STRING_CST initializer directly.
    4784                 :             :    FIXME.  */
    4785                 :             : 
    4786                 :             : static tree
    4787                 :        2520 : c_make_fname_decl (location_t loc, tree id, int type_dep)
    4788                 :             : {
    4789                 :        2520 :   const char *name = fname_as_string (type_dep);
    4790                 :        2520 :   tree decl, type, init;
    4791                 :        2520 :   size_t length = strlen (name);
    4792                 :             : 
    4793                 :        2520 :   type = build_array_type (char_type_node,
    4794                 :             :                            build_index_type (size_int (length)));
    4795                 :        2520 :   type = c_build_qualified_type (type, TYPE_QUAL_CONST);
    4796                 :             : 
    4797                 :        2520 :   decl = build_decl (loc, VAR_DECL, id, type);
    4798                 :             : 
    4799                 :        2520 :   TREE_STATIC (decl) = 1;
    4800                 :        2520 :   TREE_READONLY (decl) = 1;
    4801                 :        2520 :   DECL_ARTIFICIAL (decl) = 1;
    4802                 :             : 
    4803                 :        2520 :   init = build_string (length + 1, name);
    4804                 :        2520 :   free (CONST_CAST (char *, name));
    4805                 :        2520 :   TREE_TYPE (init) = type;
    4806                 :        2520 :   DECL_INITIAL (decl) = init;
    4807                 :             : 
    4808                 :        2520 :   TREE_USED (decl) = 1;
    4809                 :             : 
    4810                 :        2520 :   if (current_function_decl
    4811                 :             :       /* For invalid programs like this:
    4812                 :             : 
    4813                 :             :          void foo()
    4814                 :             :          const char* p = __FUNCTION__;
    4815                 :             : 
    4816                 :             :          the __FUNCTION__ is believed to appear in K&R style function
    4817                 :             :          parameter declarator.  In that case we still don't have
    4818                 :             :          function_scope.  */
    4819                 :        2513 :       && current_function_scope)
    4820                 :             :     {
    4821                 :        2505 :       DECL_CONTEXT (decl) = current_function_decl;
    4822                 :        2505 :       bind (id, decl, current_function_scope,
    4823                 :             :             /*invisible=*/false, /*nested=*/false, UNKNOWN_LOCATION);
    4824                 :             :     }
    4825                 :             : 
    4826                 :        2520 :   finish_decl (decl, loc, init, NULL_TREE, NULL_TREE);
    4827                 :             : 
    4828                 :        2520 :   return decl;
    4829                 :             : }
    4830                 :             : 
    4831                 :             : tree
    4832                 :   296450936 : c_builtin_function (tree decl)
    4833                 :             : {
    4834                 :   296450936 :   tree type = TREE_TYPE (decl);
    4835                 :   296450936 :   tree   id = DECL_NAME (decl);
    4836                 :             : 
    4837                 :   296450936 :   const char *name = IDENTIFIER_POINTER (id);
    4838                 :   296450936 :   C_DECL_BUILTIN_PROTOTYPE (decl) = prototype_p (type);
    4839                 :             : 
    4840                 :             :   /* Should never be called on a symbol with a preexisting meaning.  */
    4841                 :   296450936 :   gcc_assert (!I_SYMBOL_BINDING (id));
    4842                 :             : 
    4843                 :   296450936 :   bind (id, decl, external_scope, /*invisible=*/true, /*nested=*/false,
    4844                 :             :         UNKNOWN_LOCATION);
    4845                 :             : 
    4846                 :             :   /* Builtins in the implementation namespace are made visible without
    4847                 :             :      needing to be explicitly declared.  See push_file_scope.  */
    4848                 :   296450936 :   if (name[0] == '_' && (name[1] == '_' || ISUPPER (name[1])))
    4849                 :             :     {
    4850                 :   202381638 :       DECL_CHAIN (decl) = visible_builtins;
    4851                 :   202381638 :       visible_builtins = decl;
    4852                 :             :     }
    4853                 :             : 
    4854                 :   296450936 :   return decl;
    4855                 :             : }
    4856                 :             : 
    4857                 :             : tree
    4858                 :     8738287 : c_builtin_function_ext_scope (tree decl)
    4859                 :             : {
    4860                 :     8738287 :   tree type = TREE_TYPE (decl);
    4861                 :     8738287 :   tree   id = DECL_NAME (decl);
    4862                 :             : 
    4863                 :     8738287 :   const char *name = IDENTIFIER_POINTER (id);
    4864                 :     8738287 :   C_DECL_BUILTIN_PROTOTYPE (decl) = prototype_p (type);
    4865                 :             : 
    4866                 :     8738287 :   if (external_scope)
    4867                 :     8497057 :     bind (id, decl, external_scope, /*invisible=*/false, /*nested=*/false,
    4868                 :             :           UNKNOWN_LOCATION);
    4869                 :             : 
    4870                 :             :   /* Builtins in the implementation namespace are made visible without
    4871                 :             :      needing to be explicitly declared.  See push_file_scope.  */
    4872                 :     8738287 :   if (name[0] == '_' && (name[1] == '_' || ISUPPER (name[1])))
    4873                 :             :     {
    4874                 :     8738287 :       DECL_CHAIN (decl) = visible_builtins;
    4875                 :     8738287 :       visible_builtins = decl;
    4876                 :             :     }
    4877                 :             : 
    4878                 :     8738287 :   return decl;
    4879                 :             : }
    4880                 :             : 
    4881                 :             : /* Implement LANG_HOOKS_SIMULATE_BUILTIN_FUNCTION_DECL.  */
    4882                 :             : 
    4883                 :             : tree
    4884                 :           0 : c_simulate_builtin_function_decl (tree decl)
    4885                 :             : {
    4886                 :           0 :   tree type = TREE_TYPE (decl);
    4887                 :           0 :   C_DECL_BUILTIN_PROTOTYPE (decl) = prototype_p (type);
    4888                 :           0 :   return pushdecl (decl);
    4889                 :             : }
    4890                 :             : 
    4891                 :             : /* Warn about attributes in a context where they are unused
    4892                 :             :    (attribute-declarations, except for the "fallthrough" case, and
    4893                 :             :    attributes on statements).  */
    4894                 :             : 
    4895                 :             : void
    4896                 :    36836644 : c_warn_unused_attributes (tree attrs)
    4897                 :             : {
    4898                 :    36836674 :   for (tree t = attrs; t != NULL_TREE; t = TREE_CHAIN (t))
    4899                 :          30 :     if (get_attribute_namespace (t) == NULL_TREE)
    4900                 :             :       /* The specifications of standard attributes mean this is a
    4901                 :             :          constraint violation.  */
    4902                 :          17 :       pedwarn (input_location, OPT_Wattributes, "%qE attribute ignored",
    4903                 :             :                get_attribute_name (t));
    4904                 :          13 :     else if (!attribute_ignored_p (t))
    4905                 :           9 :       warning (OPT_Wattributes, "%qE attribute ignored",
    4906                 :             :                get_attribute_name (t));
    4907                 :    36836644 : }
    4908                 :             : 
    4909                 :             : /* Warn for standard attributes being applied to a type that is not
    4910                 :             :    being defined, where that is a constraint violation, and return a
    4911                 :             :    list of attributes with them removed.  */
    4912                 :             : 
    4913                 :             : tree
    4914                 :   379608721 : c_warn_type_attributes (tree attrs)
    4915                 :             : {
    4916                 :   379608721 :   tree *attr_ptr = &attrs;
    4917                 :   379631053 :   while (*attr_ptr)
    4918                 :       22332 :     if (get_attribute_namespace (*attr_ptr) == NULL_TREE)
    4919                 :             :       {
    4920                 :          21 :         pedwarn (input_location, OPT_Wattributes, "%qE attribute ignored",
    4921                 :             :                  get_attribute_name (*attr_ptr));
    4922                 :          21 :         *attr_ptr = TREE_CHAIN (*attr_ptr);
    4923                 :             :       }
    4924                 :             :     else
    4925                 :       22311 :       attr_ptr = &TREE_CHAIN (*attr_ptr);
    4926                 :   379608721 :   return attrs;
    4927                 :             : }
    4928                 :             : 
    4929                 :             : /* Called when a declaration is seen that contains no names to declare.
    4930                 :             :    If its type is a reference to a structure, union or enum inherited
    4931                 :             :    from a containing scope, shadow that tag name for the current scope
    4932                 :             :    with a forward reference.
    4933                 :             :    If its type defines a new named structure or union
    4934                 :             :    or defines an enum, it is valid but we need not do anything here.
    4935                 :             :    Otherwise, it is an error.  */
    4936                 :             : 
    4937                 :             : void
    4938                 :      471085 : shadow_tag (const struct c_declspecs *declspecs)
    4939                 :             : {
    4940                 :      471085 :   shadow_tag_warned (declspecs, 0);
    4941                 :      471085 : }
    4942                 :             : 
    4943                 :             : /* WARNED is 1 if we have done a pedwarn, 2 if we have done a warning,
    4944                 :             :    but no pedwarn.  */
    4945                 :             : void
    4946                 :      471144 : shadow_tag_warned (const struct c_declspecs *declspecs, int warned)
    4947                 :             : {
    4948                 :      471144 :   bool found_tag = false;
    4949                 :             : 
    4950                 :      471144 :   if (declspecs->type && !declspecs->default_int_p && !declspecs->typedef_p)
    4951                 :             :     {
    4952                 :      471041 :       tree value = declspecs->type;
    4953                 :      471041 :       enum tree_code code = TREE_CODE (value);
    4954                 :             : 
    4955                 :      471041 :       if (code == RECORD_TYPE || code == UNION_TYPE || code == ENUMERAL_TYPE)
    4956                 :             :         /* Used to test also that TYPE_SIZE (value) != 0.
    4957                 :             :            That caused warning for `struct foo;' at top level in the file.  */
    4958                 :             :         {
    4959                 :      471000 :           tree name = TYPE_NAME (value);
    4960                 :      471000 :           tree t;
    4961                 :             : 
    4962                 :      471000 :           found_tag = true;
    4963                 :             : 
    4964                 :      471000 :           if (declspecs->restrict_p)
    4965                 :             :             {
    4966                 :           2 :               error ("invalid use of %<restrict%>");
    4967                 :           2 :               warned = 1;
    4968                 :             :             }
    4969                 :             : 
    4970                 :      471000 :           if (in_underspecified_init)
    4971                 :             :             {
    4972                 :             :               /* This can only occur with extensions such as statement
    4973                 :             :                  expressions, but is still appropriate as an error to
    4974                 :             :                  avoid types declared in such a context escaping to
    4975                 :             :                  the type of an auto variable.  */
    4976                 :           1 :               error ("%qT declared in underspecified object initializer",
    4977                 :             :                      value);
    4978                 :           1 :               warned = 1;
    4979                 :             :             }
    4980                 :             : 
    4981                 :      471000 :           if (name == NULL_TREE)
    4982                 :             :             {
    4983                 :       54075 :               if (warned != 1 && code != ENUMERAL_TYPE)
    4984                 :             :                 /* Empty unnamed enum OK */
    4985                 :             :                 {
    4986                 :          17 :                   pedwarn (input_location, 0,
    4987                 :             :                            "unnamed struct/union that defines no instances");
    4988                 :          17 :                   warned = 1;
    4989                 :             :                 }
    4990                 :             :             }
    4991                 :      416925 :           else if (declspecs->typespec_kind != ctsk_tagdef
    4992                 :       83575 :                    && declspecs->typespec_kind != ctsk_tagfirstref
    4993                 :       24776 :                    && declspecs->typespec_kind != ctsk_tagfirstref_attrs
    4994                 :       24768 :                    && declspecs->storage_class != csc_none)
    4995                 :             :             {
    4996                 :           1 :               if (warned != 1)
    4997                 :           1 :                 pedwarn (input_location, 0,
    4998                 :             :                          "empty declaration with storage class specifier "
    4999                 :             :                          "does not redeclare tag");
    5000                 :           1 :               warned = 1;
    5001                 :           1 :               pending_xref_error ();
    5002                 :             :             }
    5003                 :      416924 :           else if (declspecs->typespec_kind != ctsk_tagdef
    5004                 :       83574 :                    && declspecs->typespec_kind != ctsk_tagfirstref
    5005                 :       24775 :                    && declspecs->typespec_kind != ctsk_tagfirstref_attrs
    5006                 :       24767 :                    && (declspecs->const_p
    5007                 :             :                        || declspecs->volatile_p
    5008                 :             :                        || declspecs->atomic_p
    5009                 :             :                        || declspecs->restrict_p
    5010                 :       24767 :                        || declspecs->address_space))
    5011                 :             :             {
    5012                 :           3 :               if (warned != 1)
    5013                 :           3 :                 pedwarn (input_location, 0,
    5014                 :             :                          "empty declaration with type qualifier "
    5015                 :             :                           "does not redeclare tag");
    5016                 :           3 :               warned = 1;
    5017                 :           3 :               pending_xref_error ();
    5018                 :             :             }
    5019                 :      416921 :           else if (declspecs->typespec_kind != ctsk_tagdef
    5020                 :       83571 :                    && declspecs->typespec_kind != ctsk_tagfirstref
    5021                 :       24772 :                    && declspecs->typespec_kind != ctsk_tagfirstref_attrs
    5022                 :       24764 :                    && declspecs->alignas_p)
    5023                 :             :             {
    5024                 :           1 :               if (warned != 1)
    5025                 :           1 :                 pedwarn (input_location, 0,
    5026                 :             :                          "empty declaration with %<_Alignas%> "
    5027                 :             :                           "does not redeclare tag");
    5028                 :           1 :               warned = 1;
    5029                 :           1 :               pending_xref_error ();
    5030                 :             :             }
    5031                 :      416920 :           else if (declspecs->typespec_kind != ctsk_tagdef
    5032                 :       83570 :                    && declspecs->typespec_kind != ctsk_tagfirstref
    5033                 :       24771 :                    && declspecs->typespec_kind != ctsk_tagfirstref_attrs
    5034                 :       24763 :                    && code == ENUMERAL_TYPE
    5035                 :          15 :                    && !declspecs->enum_type_specifier_ref_p)
    5036                 :             :             {
    5037                 :           3 :               bool warned_enum = false;
    5038                 :           3 :               if (warned != 1)
    5039                 :           3 :                 warned_enum = pedwarn (input_location, OPT_Wpedantic,
    5040                 :             :                                        "empty declaration of %<enum%> type "
    5041                 :             :                                        "does not redeclare tag");
    5042                 :           3 :               if (warned_enum)
    5043                 :           2 :                 warned = 1;
    5044                 :           3 :               pending_xref_error ();
    5045                 :           3 :             }
    5046                 :             :           else
    5047                 :             :             {
    5048                 :      416917 :               pending_invalid_xref = NULL_TREE;
    5049                 :      416917 :               t = lookup_tag (code, name, true, NULL);
    5050                 :             : 
    5051                 :      416917 :               if (t == NULL_TREE)
    5052                 :             :                 {
    5053                 :           1 :                   t = make_node (code);
    5054                 :           1 :                   pushtag (input_location, name, t);
    5055                 :             :                 }
    5056                 :             :             }
    5057                 :             :         }
    5058                 :             :       else
    5059                 :             :         {
    5060                 :          41 :           if (warned != 1 && !in_system_header_at (input_location))
    5061                 :             :             {
    5062                 :          38 :               pedwarn (input_location, 0,
    5063                 :             :                        "useless type name in empty declaration");
    5064                 :          38 :               warned = 1;
    5065                 :             :             }
    5066                 :             :         }
    5067                 :             :     }
    5068                 :          64 :   else if (warned != 1 && !in_system_header_at (input_location)
    5069                 :         167 :            && declspecs->typedef_p)
    5070                 :             :     {
    5071                 :          11 :       pedwarn (input_location, 0, "useless type name in empty declaration");
    5072                 :          11 :       warned = 1;
    5073                 :             :     }
    5074                 :             : 
    5075                 :      471144 :   pending_invalid_xref = NULL_TREE;
    5076                 :             : 
    5077                 :      471144 :   if (declspecs->inline_p)
    5078                 :             :     {
    5079                 :           5 :       error ("%<inline%> in empty declaration");
    5080                 :           5 :       warned = 1;
    5081                 :             :     }
    5082                 :             : 
    5083                 :      471144 :   if (declspecs->noreturn_p)
    5084                 :             :     {
    5085                 :           2 :       error ("%<_Noreturn%> in empty declaration");
    5086                 :           2 :       warned = 1;
    5087                 :             :     }
    5088                 :             : 
    5089                 :      471144 :   if (declspecs->constexpr_p)
    5090                 :             :     {
    5091                 :           7 :       error ("%<constexpr%> in empty declaration");
    5092                 :           7 :       warned = 1;
    5093                 :             :     }
    5094                 :             : 
    5095                 :      471144 :   if (current_scope == file_scope && declspecs->storage_class == csc_auto)
    5096                 :             :     {
    5097                 :           2 :       error ("%<auto%> in file-scope empty declaration");
    5098                 :           2 :       warned = 1;
    5099                 :             :     }
    5100                 :             : 
    5101                 :      471144 :   if (current_scope == file_scope && declspecs->storage_class == csc_register)
    5102                 :             :     {
    5103                 :           2 :       error ("%<register%> in file-scope empty declaration");
    5104                 :           2 :       warned = 1;
    5105                 :             :     }
    5106                 :             : 
    5107                 :      471144 :   if (declspecs->enum_type_specifier_ref_p && !warned)
    5108                 :             :     {
    5109                 :          39 :       if (declspecs->storage_class != csc_none)
    5110                 :             :         {
    5111                 :           1 :           error ("storage class specifier in empty declaration with %<enum%> "
    5112                 :             :                  "underlying type");
    5113                 :           1 :           warned = 1;
    5114                 :             :         }
    5115                 :          38 :       else if (declspecs->thread_p)
    5116                 :             :         {
    5117                 :           2 :           error ("%qs in empty declaration with %<enum%> underlying type",
    5118                 :           1 :                  declspecs->thread_gnu_p ? "__thread" : "_Thread_local");
    5119                 :           1 :           warned = 1;
    5120                 :             :         }
    5121                 :          37 :       else if (declspecs->const_p
    5122                 :             :                || declspecs->volatile_p
    5123                 :             :                || declspecs->atomic_p
    5124                 :             :                || declspecs->restrict_p
    5125                 :          37 :                || declspecs->address_space)
    5126                 :             :         {
    5127                 :           1 :           error ("type qualifier in empty declaration with %<enum%> "
    5128                 :             :                  "underlying type");
    5129                 :           1 :           warned = 1;
    5130                 :             :         }
    5131                 :          36 :       else if (declspecs->alignas_p)
    5132                 :             :         {
    5133                 :           1 :           error ("%<alignas%> in empty declaration with %<enum%> "
    5134                 :             :                  "underlying type");
    5135                 :           1 :           warned = 1;
    5136                 :             :         }
    5137                 :             :     }
    5138                 :             : 
    5139                 :      470996 :   if (!warned && !in_system_header_at (input_location)
    5140                 :      585366 :       && declspecs->storage_class != csc_none)
    5141                 :             :     {
    5142                 :          11 :       warning (0, "useless storage class specifier in empty declaration");
    5143                 :          11 :       warned = 2;
    5144                 :             :     }
    5145                 :             : 
    5146                 :      471144 :   if (!warned && !in_system_header_at (input_location) && declspecs->thread_p)
    5147                 :             :     {
    5148                 :           6 :       warning (0, "useless %qs in empty declaration",
    5149                 :           3 :                declspecs->thread_gnu_p ? "__thread" : "_Thread_local");
    5150                 :           3 :       warned = 2;
    5151                 :             :     }
    5152                 :             : 
    5153                 :           3 :   if (!warned
    5154                 :      470978 :       && !in_system_header_at (input_location)
    5155                 :      471141 :       && (declspecs->const_p
    5156                 :             :           || declspecs->volatile_p
    5157                 :             :           || declspecs->atomic_p
    5158                 :             :           || declspecs->restrict_p
    5159                 :      114216 :           || declspecs->address_space))
    5160                 :             :     {
    5161                 :           8 :       warning (0, "useless type qualifier in empty declaration");
    5162                 :           8 :       warned = 2;
    5163                 :             :     }
    5164                 :             : 
    5165                 :      470978 :   if (!warned && !in_system_header_at (input_location)
    5166                 :      585344 :       && declspecs->alignas_p)
    5167                 :             :     {
    5168                 :           4 :       warning (0, "useless %<_Alignas%> in empty declaration");
    5169                 :           4 :       warned = 2;
    5170                 :             :     }
    5171                 :             : 
    5172                 :      471144 :   if (found_tag
    5173                 :      471144 :       && warned == 2
    5174                 :          22 :       && (declspecs->typespec_kind == ctsk_tagref_attrs
    5175                 :          22 :           || declspecs->typespec_kind == ctsk_tagfirstref_attrs))
    5176                 :             :     {
    5177                 :             :       /* Standard attributes after the "struct" or "union" keyword are
    5178                 :             :          only permitted when the contents of the type are defined, or
    5179                 :             :          in the form "struct-or-union attribute-specifier-sequence
    5180                 :             :          identifier;".  If the ';' was not present, attributes were
    5181                 :             :          diagnosed in the parser.  Here, ensure that any other useless
    5182                 :             :          elements of the declaration result in a pedwarn, not just a
    5183                 :             :          warning.  Forward declarations of enum types are not part of
    5184                 :             :          standard C, but handle them the same.  */
    5185                 :           2 :       pedwarn (input_location, 0,
    5186                 :             :                "invalid use of attributes in empty declaration");
    5187                 :           2 :       warned = 1;
    5188                 :             :     }
    5189                 :             : 
    5190                 :      471144 :   if (warned != 1)
    5191                 :             :     {
    5192                 :      470990 :       if (declspecs->declspecs_seen_p
    5193                 :      470990 :           && !declspecs->non_std_attrs_seen_p)
    5194                 :             :         /* An attribute declaration (but not a fallthrough attribute
    5195                 :             :            declaration, which was handled separately); warn if there
    5196                 :             :            are any attributes being ignored (but not if the attributes
    5197                 :             :            were empty).  */
    5198                 :          42 :         c_warn_unused_attributes (declspecs->attrs);
    5199                 :      470948 :       else if (!found_tag)
    5200                 :           9 :         pedwarn (input_location, 0, "empty declaration");
    5201                 :             :     }
    5202                 :      471144 : }
    5203                 :             : 
    5204                 :             : 
    5205                 :             : /* Return the qualifiers from SPECS as a bitwise OR of TYPE_QUAL_*
    5206                 :             :    bits.  SPECS represents declaration specifiers that the grammar
    5207                 :             :    only permits to contain type qualifiers and attributes.  */
    5208                 :             : 
    5209                 :             : int
    5210                 :    16599146 : quals_from_declspecs (const struct c_declspecs *specs)
    5211                 :             : {
    5212                 :    16599146 :   int quals = ((specs->const_p ? TYPE_QUAL_CONST : 0)
    5213                 :             :                | (specs->volatile_p ? TYPE_QUAL_VOLATILE : 0)
    5214                 :             :                | (specs->restrict_p ? TYPE_QUAL_RESTRICT : 0)
    5215                 :    16599146 :                | (specs->atomic_p ? TYPE_QUAL_ATOMIC : 0)
    5216                 :    16599146 :                | (ENCODE_QUAL_ADDR_SPACE (specs->address_space)));
    5217                 :    16599146 :   gcc_assert (!specs->type
    5218                 :             :               && !specs->decl_attr
    5219                 :             :               && specs->typespec_word == cts_none
    5220                 :             :               && specs->storage_class == csc_none
    5221                 :             :               && !specs->typedef_p
    5222                 :             :               && !specs->explicit_signed_p
    5223                 :             :               && !specs->deprecated_p
    5224                 :             :               && !specs->unavailable_p
    5225                 :             :               && !specs->long_p
    5226                 :             :               && !specs->long_long_p
    5227                 :             :               && !specs->short_p
    5228                 :             :               && !specs->signed_p
    5229                 :             :               && !specs->unsigned_p
    5230                 :             :               && !specs->complex_p
    5231                 :             :               && !specs->inline_p
    5232                 :             :               && !specs->noreturn_p
    5233                 :             :               && !specs->thread_p);
    5234                 :    16599146 :   return quals;
    5235                 :             : }
    5236                 :             : 
    5237                 :             : /* Construct an array declarator.  LOC is the location of the
    5238                 :             :    beginning of the array (usually the opening brace).  EXPR is the
    5239                 :             :    expression inside [], or NULL_TREE.  QUALS are the type qualifiers
    5240                 :             :    inside the [] (to be applied to the pointer to which a parameter
    5241                 :             :    array is converted).  STATIC_P is true if "static" is inside the
    5242                 :             :    [], false otherwise.  VLA_UNSPEC_P is true if the array is [*], a
    5243                 :             :    VLA of unspecified length which is nevertheless a complete type,
    5244                 :             :    false otherwise.  The field for the contained declarator is left to
    5245                 :             :    be filled in by set_array_declarator_inner.  */
    5246                 :             : 
    5247                 :             : struct c_declarator *
    5248                 :     1062908 : build_array_declarator (location_t loc,
    5249                 :             :                         tree expr, struct c_declspecs *quals, bool static_p,
    5250                 :             :                         bool vla_unspec_p)
    5251                 :             : {
    5252                 :     1062908 :   struct c_declarator *declarator = XOBNEW (&parser_obstack,
    5253                 :             :                                             struct c_declarator);
    5254                 :     1062908 :   declarator->id_loc = loc;
    5255                 :     1062908 :   declarator->kind = cdk_array;
    5256                 :     1062908 :   declarator->declarator = 0;
    5257                 :     1062908 :   declarator->u.array.dimen = expr;
    5258                 :     1062908 :   if (quals)
    5259                 :             :     {
    5260                 :         742 :       declarator->u.array.attrs = quals->attrs;
    5261                 :         742 :       declarator->u.array.quals = quals_from_declspecs (quals);
    5262                 :             :     }
    5263                 :             :   else
    5264                 :             :     {
    5265                 :     1062166 :       declarator->u.array.attrs = NULL_TREE;
    5266                 :     1062166 :       declarator->u.array.quals = 0;
    5267                 :             :     }
    5268                 :     1062908 :   declarator->u.array.static_p = static_p;
    5269                 :     1062908 :   declarator->u.array.vla_unspec_p = vla_unspec_p;
    5270                 :     1062908 :   if (static_p || quals != NULL)
    5271                 :         837 :     pedwarn_c90 (loc, OPT_Wpedantic,
    5272                 :             :                  "ISO C90 does not support %<static%> or type "
    5273                 :             :                  "qualifiers in parameter array declarators");
    5274                 :     1062908 :   if (vla_unspec_p)
    5275                 :         137 :     pedwarn_c90 (loc, OPT_Wpedantic,
    5276                 :             :                  "ISO C90 does not support %<[*]%> array declarators");
    5277                 :         137 :   if (vla_unspec_p)
    5278                 :             :     {
    5279                 :         137 :       if (!current_scope->parm_flag)
    5280                 :             :         {
    5281                 :             :           /* C99 6.7.5.2p4 */
    5282                 :           4 :           error_at (loc, "%<[*]%> not allowed in other than "
    5283                 :             :                     "function prototype scope");
    5284                 :           4 :           declarator->u.array.vla_unspec_p = false;
    5285                 :           4 :           return NULL;
    5286                 :             :         }
    5287                 :         133 :       current_scope->had_vla_unspec = true;
    5288                 :             :     }
    5289                 :             :   return declarator;
    5290                 :             : }
    5291                 :             : 
    5292                 :             : /* Set the contained declarator of an array declarator.  DECL is the
    5293                 :             :    declarator, as constructed by build_array_declarator; INNER is what
    5294                 :             :    appears on the left of the [].  */
    5295                 :             : 
    5296                 :             : struct c_declarator *
    5297                 :     1062904 : set_array_declarator_inner (struct c_declarator *decl,
    5298                 :             :                             struct c_declarator *inner)
    5299                 :             : {
    5300                 :     1062904 :   decl->declarator = inner;
    5301                 :     1062904 :   return decl;
    5302                 :             : }
    5303                 :             : 
    5304                 :             : /* Determine whether TYPE is a ISO C99 flexible array memeber type "[]".  */
    5305                 :             : static bool
    5306                 :     4925495 : flexible_array_member_type_p (const_tree type)
    5307                 :             : {
    5308                 :     4925495 :   if (TREE_CODE (type) == ARRAY_TYPE
    5309                 :     1615999 :       && TYPE_SIZE (type) == NULL_TREE
    5310                 :      179160 :       && TYPE_DOMAIN (type) != NULL_TREE
    5311                 :     5104655 :       && TYPE_MAX_VALUE (TYPE_DOMAIN (type)) == NULL_TREE)
    5312                 :      179160 :     return true;
    5313                 :             : 
    5314                 :             :   return false;
    5315                 :             : }
    5316                 :             : 
    5317                 :             : /* Determine whether TYPE is a one-element array type "[1]".  */
    5318                 :             : static bool
    5319                 :      487486 : one_element_array_type_p (const_tree type)
    5320                 :             : {
    5321                 :      487486 :   if (TREE_CODE (type) != ARRAY_TYPE)
    5322                 :             :     return false;
    5323                 :      487486 :   return integer_zerop (array_type_nelts (type));
    5324                 :             : }
    5325                 :             : 
    5326                 :             : /* Determine whether TYPE is a zero-length array type "[0]".  */
    5327                 :             : static bool
    5328                 :      487486 : zero_length_array_type_p (const_tree type)
    5329                 :             : {
    5330                 :      487486 :   if (TREE_CODE (type) == ARRAY_TYPE)
    5331                 :      487486 :     if (tree type_size = TYPE_SIZE_UNIT (type))
    5332                 :      427830 :       if ((integer_zerop (type_size))
    5333                 :        1816 :            && TYPE_DOMAIN (type) != NULL_TREE
    5334                 :      429646 :            && TYPE_MAX_VALUE (TYPE_DOMAIN (type)) == NULL_TREE)
    5335                 :             :         return true;
    5336                 :             :   return false;
    5337                 :             : }
    5338                 :             : 
    5339                 :             : /* INIT is a constructor that forms DECL's initializer.  If the final
    5340                 :             :    element initializes a flexible array field, add the size of that
    5341                 :             :    initializer to DECL's size.  */
    5342                 :             : 
    5343                 :             : static void
    5344                 :      101629 : add_flexible_array_elts_to_size (tree decl, tree init)
    5345                 :             : {
    5346                 :      101629 :   tree elt, type;
    5347                 :             : 
    5348                 :      101629 :   if (vec_safe_is_empty (CONSTRUCTOR_ELTS (init)))
    5349                 :        1310 :     return;
    5350                 :             : 
    5351                 :      100319 :   elt = CONSTRUCTOR_ELTS (init)->last ().value;
    5352                 :      100319 :   type = TREE_TYPE (elt);
    5353                 :      100319 :   if (flexible_array_member_type_p (type))
    5354                 :             :     {
    5355                 :         180 :       complete_array_type (&type, elt, false);
    5356                 :         180 :       DECL_SIZE (decl)
    5357                 :         180 :         = size_binop (PLUS_EXPR, DECL_SIZE (decl), TYPE_SIZE (type));
    5358                 :         180 :       DECL_SIZE_UNIT (decl)
    5359                 :         360 :         = size_binop (PLUS_EXPR, DECL_SIZE_UNIT (decl), TYPE_SIZE_UNIT (type));
    5360                 :             :     }
    5361                 :             : }
    5362                 :             : 
    5363                 :             : /* Decode a "typename", such as "int **", returning a ..._TYPE node.
    5364                 :             :    Set *EXPR, if EXPR not NULL, to any expression to be evaluated
    5365                 :             :    before the type name, and set *EXPR_CONST_OPERANDS, if
    5366                 :             :    EXPR_CONST_OPERANDS not NULL, to indicate whether the type name may
    5367                 :             :    appear in a constant expression.  */
    5368                 :             : 
    5369                 :             : tree
    5370                 :   105194718 : groktypename (struct c_type_name *type_name, tree *expr,
    5371                 :             :               bool *expr_const_operands)
    5372                 :             : {
    5373                 :   105194718 :   tree type;
    5374                 :   105194718 :   tree attrs = type_name->specs->attrs;
    5375                 :             : 
    5376                 :   105194718 :   type_name->specs->attrs = NULL_TREE;
    5377                 :             : 
    5378                 :   105194718 :   type = grokdeclarator (type_name->declarator, type_name->specs, TYPENAME,
    5379                 :             :                          false, NULL, &attrs, expr, expr_const_operands,
    5380                 :             :                          DEPRECATED_NORMAL);
    5381                 :             : 
    5382                 :             :   /* Apply attributes.  */
    5383                 :   105194718 :   attrs = c_warn_type_attributes (attrs);
    5384                 :   105194718 :   decl_attributes (&type, attrs, 0);
    5385                 :             : 
    5386                 :   105194718 :   return type;
    5387                 :             : }
    5388                 :             : 
    5389                 :             : /* Looks up the most recent pushed declaration corresponding to DECL.  */
    5390                 :             : 
    5391                 :             : static tree
    5392                 :    82044548 : lookup_last_decl (tree decl)
    5393                 :             : {
    5394                 :    82044548 :   tree last_decl = lookup_name (DECL_NAME (decl));
    5395                 :    82044548 :   if (!last_decl)
    5396                 :    80248879 :     last_decl = lookup_name_in_scope (DECL_NAME (decl), external_scope);
    5397                 :    82044548 :   return last_decl;
    5398                 :             : }
    5399                 :             : 
    5400                 :             : /* Wrapper for decl_attributes that adds some implicit attributes
    5401                 :             :    to VAR_DECLs or FUNCTION_DECLs.  */
    5402                 :             : 
    5403                 :             : static tree
    5404                 :    56903224 : c_decl_attributes (tree *node, tree attributes, int flags)
    5405                 :             : {
    5406                 :             :   /* Add implicit "omp declare target" attribute if requested.  */
    5407                 :    56903224 :   if (vec_safe_length (current_omp_declare_target_attribute)
    5408                 :        9061 :       && ((VAR_P (*node) && is_global_var (*node))
    5409                 :        2649 :           || TREE_CODE (*node) == FUNCTION_DECL))
    5410                 :             :     {
    5411                 :        1067 :       if (VAR_P (*node) && !omp_mappable_type (TREE_TYPE (*node)))
    5412                 :          13 :         attributes = tree_cons (get_identifier ("omp declare target implicit"),
    5413                 :             :                                 NULL_TREE, attributes);
    5414                 :             :       else
    5415                 :             :         {
    5416                 :        1054 :           attributes = tree_cons (get_identifier ("omp declare target"),
    5417                 :             :                                   NULL_TREE, attributes);
    5418                 :        1054 :           attributes = tree_cons (get_identifier ("omp declare target block"),
    5419                 :             :                                   NULL_TREE, attributes);
    5420                 :             :         }
    5421                 :        1067 :       if (TREE_CODE (*node) == FUNCTION_DECL)
    5422                 :             :         {
    5423                 :         939 :           int device_type
    5424                 :         939 :             = current_omp_declare_target_attribute->last ().device_type;
    5425                 :         939 :           device_type = MAX (device_type, 0);
    5426                 :         939 :           if ((device_type & OMP_CLAUSE_DEVICE_TYPE_HOST) != 0
    5427                 :         939 :               && !lookup_attribute ("omp declare target host", attributes))
    5428                 :           2 :             attributes
    5429                 :           2 :               = tree_cons (get_identifier ("omp declare target host"),
    5430                 :             :                            NULL_TREE, attributes);
    5431                 :         939 :           if ((device_type & OMP_CLAUSE_DEVICE_TYPE_NOHOST) != 0
    5432                 :         939 :               && !lookup_attribute ("omp declare target nohost", attributes))
    5433                 :           2 :             attributes
    5434                 :           2 :               = tree_cons (get_identifier ("omp declare target nohost"),
    5435                 :             :                            NULL_TREE, attributes);
    5436                 :             : 
    5437                 :         939 :           int indirect
    5438                 :         939 :             = current_omp_declare_target_attribute->last ().indirect;
    5439                 :         939 :           if (indirect && !lookup_attribute ("omp declare target indirect",
    5440                 :             :                                              attributes))
    5441                 :          10 :             attributes
    5442                 :          10 :               = tree_cons (get_identifier ("omp declare target indirect"),
    5443                 :             :                            NULL_TREE, attributes);
    5444                 :             :         }
    5445                 :             :     }
    5446                 :             : 
    5447                 :    56903224 :   if (flag_openmp || flag_openmp_simd)
    5448                 :             :     {
    5449                 :             :       bool diagnosed = false;
    5450                 :     1158575 :       for (tree *pa = &attributes; *pa; )
    5451                 :             :         {
    5452                 :      749902 :           if (is_attribute_namespace_p ("omp", *pa))
    5453                 :             :             {
    5454                 :          58 :               tree name = get_attribute_name (*pa);
    5455                 :          58 :               if (is_attribute_p ("directive", name)
    5456                 :           0 :                   || is_attribute_p ("sequence", name)
    5457                 :          58 :                   || is_attribute_p ("decl", name))
    5458                 :             :                 {
    5459                 :          58 :                   const char *p = NULL;
    5460                 :          58 :                   if (TREE_VALUE (*pa) == NULL_TREE)
    5461                 :          12 :                     p = IDENTIFIER_POINTER (name);
    5462                 :         104 :                   for (tree a = TREE_VALUE (*pa); a; a = TREE_CHAIN (a))
    5463                 :             :                     {
    5464                 :          46 :                       tree d = TREE_VALUE (a);
    5465                 :          46 :                       gcc_assert (TREE_CODE (d) == C_TOKEN_VEC);
    5466                 :          82 :                       if (TREE_PUBLIC (d)
    5467                 :          36 :                           && (VAR_P (*node)
    5468                 :           2 :                               || TREE_CODE (*node) == FUNCTION_DECL)
    5469                 :          82 :                           && c_maybe_parse_omp_decl (*node, d))
    5470                 :          36 :                         continue;
    5471                 :          10 :                       p = TREE_PUBLIC (d) ? "decl" : "directive";
    5472                 :             :                     }
    5473                 :          58 :                   if (p && !diagnosed)
    5474                 :             :                     {
    5475                 :          22 :                       error ("%<omp::%s%> not allowed to be specified in "
    5476                 :             :                              "this context", p);
    5477                 :          22 :                       diagnosed = true;
    5478                 :             :                     }
    5479                 :          58 :                   if (p)
    5480                 :             :                     {
    5481                 :          22 :                       *pa = TREE_CHAIN (*pa);
    5482                 :          22 :                       continue;
    5483                 :             :                     }
    5484                 :             :                 }
    5485                 :             :             }
    5486                 :      749880 :           pa = &TREE_CHAIN (*pa);
    5487                 :             :         }
    5488                 :             :     }
    5489                 :             : 
    5490                 :             :   /* Look up the current declaration with all the attributes merged
    5491                 :             :      so far so that attributes on the current declaration that's
    5492                 :             :      about to be pushed that conflict with the former can be detected,
    5493                 :             :      diagnosed, and rejected as appropriate.  */
    5494                 :    56903224 :   tree last_decl = lookup_last_decl (*node);
    5495                 :    56903224 :   return decl_attributes (node, attributes, flags, last_decl);
    5496                 :             : }
    5497                 :             : 
    5498                 :             : 
    5499                 :             : /* Decode a declarator in an ordinary declaration or data definition.
    5500                 :             :    This is called as soon as the type information and variable name
    5501                 :             :    have been parsed, before parsing the initializer if any.
    5502                 :             :    Here we create the ..._DECL node, fill in its type,
    5503                 :             :    and (if DO_PUSH) put it on the list of decls for the current context.
    5504                 :             :    When nonnull, set *LASTLOC to the location of the prior declaration
    5505                 :             :    of the same entity if one exists.
    5506                 :             :    The ..._DECL node is returned as the value.
    5507                 :             : 
    5508                 :             :    Exception: for arrays where the length is not specified,
    5509                 :             :    the type is left null, to be filled in by `finish_decl'.
    5510                 :             : 
    5511                 :             :    Function definitions do not come here; they go to start_function
    5512                 :             :    instead.  However, external and forward declarations of functions
    5513                 :             :    do go through here.  Structure field declarations are done by
    5514                 :             :    grokfield and not through here.  */
    5515                 :             : 
    5516                 :             : tree
    5517                 :    25141347 : start_decl (struct c_declarator *declarator, struct c_declspecs *declspecs,
    5518                 :             :             bool initialized, tree attributes, bool do_push /* = true */,
    5519                 :             :             location_t *lastloc /* = NULL */)
    5520                 :             : {
    5521                 :    25141347 :   tree decl;
    5522                 :    25141347 :   tree old_decl;
    5523                 :    25141347 :   tree tem;
    5524                 :    25141347 :   tree expr = NULL_TREE;
    5525                 :    25141347 :   enum deprecated_states deprecated_state = DEPRECATED_NORMAL;
    5526                 :             : 
    5527                 :             :   /* An object declared as __attribute__((unavailable)) suppresses
    5528                 :             :      warnings and errors from __attribute__((deprecated/unavailable))
    5529                 :             :      components.
    5530                 :             :      An object declared as __attribute__((deprecated)) suppresses
    5531                 :             :      warnings of uses of other deprecated items.  */
    5532                 :    25141347 :   if (lookup_attribute ("unavailable", attributes))
    5533                 :             :     deprecated_state = UNAVAILABLE_DEPRECATED_SUPPRESS;
    5534                 :    25141323 :   else if (lookup_attribute ("deprecated", attributes))
    5535                 :       29007 :     deprecated_state = DEPRECATED_SUPPRESS;
    5536                 :             : 
    5537                 :    25141347 :   decl = grokdeclarator (declarator, declspecs,
    5538                 :             :                          NORMAL, initialized, NULL, &attributes, &expr, NULL,
    5539                 :             :                          deprecated_state);
    5540                 :    25141347 :   if (!decl || decl == error_mark_node)
    5541                 :             :     return NULL_TREE;
    5542                 :             : 
    5543                 :    25141324 :   old_decl = lookup_last_decl (decl);
    5544                 :             : 
    5545                 :    25141324 :   if (tree lastdecl = lastloc ? old_decl : NULL_TREE)
    5546                 :     3807069 :     if (lastdecl != error_mark_node)
    5547                 :     3807060 :       *lastloc = DECL_SOURCE_LOCATION (lastdecl);
    5548                 :             : 
    5549                 :             :   /* Make sure the size expression is evaluated at this point.  */
    5550                 :    25141324 :   if (expr && !current_scope->parm_flag)
    5551                 :       12810 :     add_stmt (fold_convert (void_type_node, expr));
    5552                 :             : 
    5553                 :    12711486 :   if (TREE_CODE (decl) != FUNCTION_DECL && MAIN_NAME_P (DECL_NAME (decl))
    5554                 :    25141326 :       && TREE_PUBLIC (decl))
    5555                 :           1 :     warning (OPT_Wmain, "%q+D is usually a function", decl);
    5556                 :             : 
    5557                 :          14 :   if (warn_missing_variable_declarations && VAR_P (decl)
    5558                 :    25141337 :       && !DECL_EXTERNAL (decl) && TREE_PUBLIC (decl) && old_decl == NULL_TREE)
    5559                 :           5 :     warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wmissing_variable_declarations,
    5560                 :             :                 "no previous declaration for %qD", decl);
    5561                 :             : 
    5562                 :    25141324 :   if (initialized)
    5563                 :             :     /* Is it valid for this decl to have an initializer at all?
    5564                 :             :        If not, set INITIALIZED to zero, which will indirectly
    5565                 :             :        tell 'finish_decl' to ignore the initializer once it is parsed.  */
    5566                 :     6132171 :     switch (TREE_CODE (decl))
    5567                 :             :       {
    5568                 :           2 :       case TYPE_DECL:
    5569                 :           2 :         error ("typedef %qD is initialized (use %<__typeof__%> instead)", decl);
    5570                 :           2 :         initialized = false;
    5571                 :           2 :         break;
    5572                 :             : 
    5573                 :           9 :       case FUNCTION_DECL:
    5574                 :           9 :         error ("function %qD is initialized like a variable", decl);
    5575                 :           9 :         initialized = false;
    5576                 :           9 :         break;
    5577                 :             : 
    5578                 :          49 :       case PARM_DECL:
    5579                 :             :         /* DECL_INITIAL in a PARM_DECL is really DECL_ARG_TYPE.  */
    5580                 :          49 :         error ("parameter %qD is initialized", decl);
    5581                 :          49 :         initialized = false;
    5582                 :          49 :         break;
    5583                 :             : 
    5584                 :     6132111 :       default:
    5585                 :             :         /* Don't allow initializations for incomplete types except for
    5586                 :             :            arrays which might be completed by the initialization.  */
    5587                 :             : 
    5588                 :             :         /* This can happen if the array size is an undefined macro.
    5589                 :             :            We already gave a warning, so we don't need another one.  */
    5590                 :     6132111 :         if (TREE_TYPE (decl) == error_mark_node)
    5591                 :             :           initialized = false;
    5592                 :     6132089 :         else if (COMPLETE_TYPE_P (TREE_TYPE (decl)))
    5593                 :             :           {
    5594                 :             :             /* A complete type is ok if size is fixed.  If the size is
    5595                 :             :                variable, an empty initializer is OK and nonempty
    5596                 :             :                initializers will be diagnosed in the parser.  */
    5597                 :             :           }
    5598                 :       11882 :         else if (TREE_CODE (TREE_TYPE (decl)) != ARRAY_TYPE)
    5599                 :             :           {
    5600                 :           3 :             error ("variable %qD has initializer but incomplete type", decl);
    5601                 :           3 :             initialized = false;
    5602                 :             :           }
    5603                 :             :       }
    5604                 :             : 
    5605                 :          63 :   if (initialized)
    5606                 :             :     {
    5607                 :     6132086 :       if (current_scope == file_scope)
    5608                 :      152754 :         TREE_STATIC (decl) = 1;
    5609                 :             : 
    5610                 :             :       /* Tell 'pushdecl' this is an initialized decl
    5611                 :             :          even though we don't yet have the initializer expression.
    5612                 :             :          Also tell 'finish_decl' it may store the real initializer.  */
    5613                 :     6132086 :       DECL_INITIAL (decl) = error_mark_node;
    5614                 :             :     }
    5615                 :             : 
    5616                 :             :   /* If this is a function declaration, write a record describing it to the
    5617                 :             :      prototypes file (if requested).  */
    5618                 :             : 
    5619                 :    25141324 :   if (TREE_CODE (decl) == FUNCTION_DECL)
    5620                 :    12429838 :     gen_aux_info_record (decl, 0, 0, prototype_p (TREE_TYPE (decl)));
    5621                 :             : 
    5622                 :             :   /* ANSI specifies that a tentative definition which is not merged with
    5623                 :             :      a non-tentative definition behaves exactly like a definition with an
    5624                 :             :      initializer equal to zero.  (Section 3.7.2)
    5625                 :             : 
    5626                 :             :      -fno-common gives strict ANSI behavior, though this tends to break
    5627                 :             :      a large body of code that grew up without this rule.
    5628                 :             : 
    5629                 :             :      Thread-local variables are never common, since there's no entrenched
    5630                 :             :      body of code to break, and it allows more efficient variable references
    5631                 :             :      in the presence of dynamic linking.  */
    5632                 :             : 
    5633                 :    25141324 :   if (VAR_P (decl)
    5634                 :     8695527 :       && !initialized
    5635                 :     2563441 :       && TREE_PUBLIC (decl)
    5636                 :      977647 :       && !DECL_THREAD_LOCAL_P (decl)
    5637                 :    26116667 :       && !flag_no_common)
    5638                 :         126 :     DECL_COMMON (decl) = 1;
    5639                 :             : 
    5640                 :             :   /* Set attributes here so if duplicate decl, will have proper attributes.  */
    5641                 :    25141324 :   c_decl_attributes (&decl, attributes, 0);
    5642                 :             : 
    5643                 :             :   /* Handle gnu_inline attribute.  */
    5644                 :    25141324 :   if (declspecs->inline_p
    5645                 :        1009 :       && !flag_gnu89_inline
    5646                 :         977 :       && TREE_CODE (decl) == FUNCTION_DECL
    5647                 :    25142293 :       && (lookup_attribute ("gnu_inline", DECL_ATTRIBUTES (decl))
    5648                 :         946 :           || current_function_decl))
    5649                 :             :     {
    5650                 :          46 :       if (declspecs->storage_class == csc_auto && current_scope != file_scope)
    5651                 :             :         ;
    5652                 :          37 :       else if (declspecs->storage_class != csc_static)
    5653                 :          37 :         DECL_EXTERNAL (decl) = !DECL_EXTERNAL (decl);
    5654                 :             :     }
    5655                 :             : 
    5656                 :    25141324 :   if (TREE_CODE (decl) == FUNCTION_DECL
    5657                 :    25141324 :       && targetm.calls.promote_prototypes (TREE_TYPE (decl)))
    5658                 :             :     {
    5659                 :    12429838 :       struct c_declarator *ce = declarator;
    5660                 :             : 
    5661                 :    12429838 :       if (ce->kind == cdk_pointer)
    5662                 :      898096 :         ce = declarator->declarator;
    5663                 :    12429838 :       if (ce->kind == cdk_function)
    5664                 :             :         {
    5665                 :    11893234 :           tree args = ce->u.arg_info->parms;
    5666                 :    31286805 :           for (; args; args = DECL_CHAIN (args))
    5667                 :             :             {
    5668                 :    19393571 :               tree type = TREE_TYPE (args);
    5669                 :    19393571 :               if (type && INTEGRAL_TYPE_P (type)
    5670                 :    23335328 :                   && TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node))
    5671                 :       28432 :                 DECL_ARG_TYPE (args) = c_type_promotes_to (type);
    5672                 :             :             }
    5673                 :             :         }
    5674                 :             :     }
    5675                 :             : 
    5676                 :    25141324 :   if (TREE_CODE (decl) == FUNCTION_DECL
    5677                 :    12429838 :       && DECL_DECLARED_INLINE_P (decl)
    5678                 :         999 :       && DECL_UNINLINABLE (decl)
    5679                 :    25141326 :       && lookup_attribute ("noinline", DECL_ATTRIBUTES (decl)))
    5680                 :           2 :     warning (OPT_Wattributes, "inline function %q+D given attribute %qs",
    5681                 :             :              decl, "noinline");
    5682                 :             : 
    5683                 :             :   /* C99 6.7.4p3: An inline definition of a function with external
    5684                 :             :      linkage shall not contain a definition of a modifiable object
    5685                 :             :      with static storage duration...  */
    5686                 :    25141324 :   if (VAR_P (decl)
    5687                 :     8695527 :       && current_scope != file_scope
    5688                 :     7558414 :       && TREE_STATIC (decl)
    5689                 :       78067 :       && !TREE_READONLY (decl)
    5690                 :       75725 :       && DECL_DECLARED_INLINE_P (current_function_decl)
    5691                 :    25141387 :       && DECL_EXTERNAL (current_function_decl))
    5692                 :           7 :     record_inline_static (input_location, current_function_decl,
    5693                 :             :                           decl, csi_modifiable);
    5694                 :             : 
    5695                 :    25141324 :   if (c_dialect_objc ()
    5696                 :           0 :       && VAR_OR_FUNCTION_DECL_P (decl))
    5697                 :           0 :       objc_check_global_decl (decl);
    5698                 :             : 
    5699                 :             :   /* Add this decl to the current scope.
    5700                 :             :      TEM may equal DECL or it may be a previous decl of the same name.  */
    5701                 :    25141324 :   if (do_push)
    5702                 :             :     {
    5703                 :    25141013 :       tem = pushdecl (decl);
    5704                 :             : 
    5705                 :    25141013 :       if (initialized && DECL_EXTERNAL (tem))
    5706                 :             :         {
    5707                 :          23 :           DECL_EXTERNAL (tem) = 0;
    5708                 :          23 :           TREE_STATIC (tem) = 1;
    5709                 :             :         }
    5710                 :             : 
    5711                 :    25141013 :       return tem;
    5712                 :             :     }
    5713                 :             :   else
    5714                 :         311 :     return decl;
    5715                 :             : }
    5716                 :             : 
    5717                 :             : /* Subroutine of finish_decl. TYPE is the type of an uninitialized object
    5718                 :             :    DECL or the non-array element type if DECL is an uninitialized array.
    5719                 :             :    If that type has a const member, diagnose this. */
    5720                 :             : 
    5721                 :             : static void
    5722                 :           7 : diagnose_uninitialized_cst_member (tree decl, tree type)
    5723                 :             : {
    5724                 :           7 :   tree field;
    5725                 :          17 :   for (field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field))
    5726                 :             :     {
    5727                 :          10 :       tree field_type;
    5728                 :          10 :       if (TREE_CODE (field) != FIELD_DECL)
    5729                 :           0 :         continue;
    5730                 :          10 :       field_type = strip_array_types (TREE_TYPE (field));
    5731                 :             : 
    5732                 :          10 :       if (TYPE_QUALS (field_type) & TYPE_QUAL_CONST)
    5733                 :             :         {
    5734                 :           5 :           auto_diagnostic_group d;
    5735                 :           5 :           if (warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wc___compat,
    5736                 :             :                           "uninitialized const member in %qT is invalid in C++",
    5737                 :           5 :                           strip_array_types (TREE_TYPE (decl))))
    5738                 :           5 :             inform (DECL_SOURCE_LOCATION (field), "%qD should be initialized", field);
    5739                 :           5 :         }
    5740                 :             : 
    5741                 :          10 :       if (RECORD_OR_UNION_TYPE_P (field_type))
    5742                 :           2 :         diagnose_uninitialized_cst_member (decl, field_type);
    5743                 :             :     }
    5744                 :           7 : }
    5745                 :             : 
    5746                 :             : /* Finish processing of a declaration;
    5747                 :             :    install its initial value.
    5748                 :             :    If ORIGTYPE is not NULL_TREE, it is the original type of INIT.
    5749                 :             :    If the length of an array type is not known before,
    5750                 :             :    it must be determined now, from the initial value, or it is an error.
    5751                 :             : 
    5752                 :             :    INIT_LOC is the location of the initial value.  */
    5753                 :             : 
    5754                 :             : void
    5755                 :   137480315 : finish_decl (tree decl, location_t init_loc, tree init,
    5756                 :             :              tree origtype, tree asmspec_tree)
    5757                 :             : {
    5758                 :   137480315 :   tree type;
    5759                 :   137480315 :   bool was_incomplete = (DECL_SIZE (decl) == NULL_TREE);
    5760                 :   137480315 :   const char *asmspec = 0;
    5761                 :             : 
    5762                 :             :   /* If a name was specified, get the string.  */
    5763                 :   128782215 :   if (VAR_OR_FUNCTION_DECL_P (decl)
    5764                 :   149910153 :       && DECL_FILE_SCOPE_P (decl))
    5765                 :    13568463 :     asmspec_tree = maybe_apply_renaming_pragma (decl, asmspec_tree);
    5766                 :   137480315 :   if (asmspec_tree)
    5767                 :      687979 :     asmspec = TREE_STRING_POINTER (asmspec_tree);
    5768                 :             : 
    5769                 :   137480315 :   if (VAR_P (decl)
    5770                 :   137480315 :       && TREE_STATIC (decl)
    5771                 :   137480315 :       && global_bindings_p ())
    5772                 :             :     /* So decl is a global variable. Record the types it uses
    5773                 :             :        so that we can decide later to emit debug info for them.  */
    5774                 :      970814 :     record_types_used_by_current_var_decl (decl);
    5775                 :             : 
    5776                 :             :   /* If `start_decl' didn't like having an initialization, ignore it now.  */
    5777                 :   137480315 :   if (init != NULL_TREE && DECL_INITIAL (decl) == NULL_TREE)
    5778                 :             :     init = NULL_TREE;
    5779                 :             : 
    5780                 :             :   /* Don't crash if parm is initialized.  */
    5781                 :   137480315 :   if (TREE_CODE (decl) == PARM_DECL)
    5782                 :             :     init = NULL_TREE;
    5783                 :             : 
    5784                 :    28971427 :   if (init)
    5785                 :     6134660 :     store_init_value (init_loc, decl, init, origtype);
    5786                 :             : 
    5787                 :   137480315 :   if (c_dialect_objc () && (VAR_OR_FUNCTION_DECL_P (decl)
    5788                 :           0 :                             || TREE_CODE (decl) == FIELD_DECL))
    5789                 :           0 :     objc_check_decl (decl);
    5790                 :             : 
    5791                 :   137480315 :   type = TREE_TYPE (decl);
    5792                 :             : 
    5793                 :             :   /* Deduce size of array from initialization, if not already known.
    5794                 :             :      This is only needed for an initialization in the current scope;
    5795                 :             :      it must not be done for a file-scope initialization of a
    5796                 :             :      declaration with external linkage, redeclared in an inner scope
    5797                 :             :      with the outer declaration shadowed in an intermediate scope.  */
    5798                 :   137480315 :   if (TREE_CODE (type) == ARRAY_TYPE
    5799                 :      791526 :       && TYPE_DOMAIN (type) == NULL_TREE
    5800                 :       19424 :       && TREE_CODE (decl) != TYPE_DECL
    5801                 :   137499644 :       && !(TREE_PUBLIC (decl) && current_scope != file_scope))
    5802                 :             :     {
    5803                 :       19143 :       bool do_default
    5804                 :       19143 :         = (TREE_STATIC (decl)
    5805                 :             :            /* Even if pedantic, an external linkage array
    5806                 :             :               may have incomplete type at first.  */
    5807                 :       19143 :            ? pedantic && !TREE_PUBLIC (decl)
    5808                 :       12247 :            : !DECL_EXTERNAL (decl));
    5809                 :       19143 :       int failure
    5810                 :       19143 :         = complete_array_type (&TREE_TYPE (decl), DECL_INITIAL (decl),
    5811                 :             :                                do_default);
    5812                 :             : 
    5813                 :             :       /* Get the completed type made by complete_array_type.  */
    5814                 :       19143 :       type = TREE_TYPE (decl);
    5815                 :             : 
    5816                 :       19143 :       switch (failure)
    5817                 :             :         {
    5818                 :           0 :         case 1:
    5819                 :           0 :           error ("initializer fails to determine size of %q+D", decl);
    5820                 :           0 :           break;
    5821                 :             : 
    5822                 :        7289 :         case 2:
    5823                 :        7289 :           if (do_default)
    5824                 :           1 :             error ("array size missing in %q+D", decl);
    5825                 :             :           break;
    5826                 :             : 
    5827                 :           3 :         case 3:
    5828                 :           3 :           error ("zero or negative size array %q+D", decl);
    5829                 :           3 :           break;
    5830                 :             : 
    5831                 :       11851 :         case 0:
    5832                 :             :           /* For global variables, update the copy of the type that
    5833                 :             :              exists in the binding.  */
    5834                 :       11851 :           if (TREE_PUBLIC (decl))
    5835                 :             :             {
    5836                 :        3590 :               struct c_binding *b_ext = I_SYMBOL_BINDING (DECL_NAME (decl));
    5837                 :        7180 :               while (b_ext && !B_IN_EXTERNAL_SCOPE (b_ext))
    5838                 :        3590 :                 b_ext = b_ext->shadowed;
    5839                 :        3590 :               if (b_ext && TREE_CODE (decl) == TREE_CODE (b_ext->decl))
    5840                 :             :                 {
    5841                 :        3590 :                   if (b_ext->u.type && comptypes (b_ext->u.type, type))
    5842                 :         176 :                     b_ext->u.type = composite_type (b_ext->u.type, type);
    5843                 :             :                   else
    5844                 :        3414 :                     b_ext->u.type = type;
    5845                 :             :                 }
    5846                 :             :             }
    5847                 :             :           break;
    5848                 :             : 
    5849                 :           0 :         default:
    5850                 :           0 :           gcc_unreachable ();
    5851                 :             :         }
    5852                 :             : 
    5853                 :       19143 :       if (DECL_INITIAL (decl) && DECL_INITIAL (decl) != error_mark_node)
    5854                 :       11014 :         TREE_TYPE (DECL_INITIAL (decl)) = type;
    5855                 :             : 
    5856                 :       19143 :       relayout_decl (decl);
    5857                 :             :     }
    5858                 :             : 
    5859                 :             :   /* Look for braced array initializers for character arrays and
    5860                 :             :      recursively convert them into STRING_CSTs.  */
    5861                 :   137480315 :   if (tree init = DECL_INITIAL (decl))
    5862                 :   114649992 :     DECL_INITIAL (decl) = braced_lists_to_strings (type, init);
    5863                 :             : 
    5864                 :   137480315 :   if (VAR_P (decl))
    5865                 :             :     {
    5866                 :     8698100 :       if (init && TREE_CODE (init) == CONSTRUCTOR)
    5867                 :      101629 :         add_flexible_array_elts_to_size (decl, init);
    5868                 :             : 
    5869                 :     8698100 :       complete_flexible_array_elts (DECL_INITIAL (decl));
    5870                 :             : 
    5871                 :     8698100 :       if (is_global_var (decl))
    5872                 :             :         {
    5873                 :     1219265 :           type_context_kind context = (DECL_THREAD_LOCAL_P (decl)
    5874                 :     1219265 :                                        ? TCTX_THREAD_STORAGE
    5875                 :     1219265 :                                        : TCTX_STATIC_STORAGE);
    5876                 :     1219265 :           if (!verify_type_context (input_location, context, TREE_TYPE (decl)))
    5877                 :           0 :             TREE_TYPE (decl) = error_mark_node;
    5878                 :             :         }
    5879                 :             : 
    5880                 :     8706056 :       if (DECL_SIZE (decl) == NULL_TREE && TREE_TYPE (decl) != error_mark_node
    5881                 :     8705957 :           && COMPLETE_TYPE_P (TREE_TYPE (decl)))
    5882                 :          97 :         layout_decl (decl, 0);
    5883                 :             : 
    5884                 :     8698100 :       if (DECL_SIZE (decl) == NULL_TREE
    5885                 :             :           /* Don't give an error if we already gave one earlier.  */
    5886                 :        7859 :           && TREE_TYPE (decl) != error_mark_node
    5887                 :     8705860 :           && (TREE_STATIC (decl)
    5888                 :             :               /* A static variable with an incomplete type
    5889                 :             :                  is an error if it is initialized.
    5890                 :             :                  Also if it is not file scope.
    5891                 :             :                  Also if it is thread-local (in C23).
    5892                 :             :                  Otherwise, let it through, but if it is not `extern'
    5893                 :             :                  then it may cause an error message later.  */
    5894                 :         243 :               ? (DECL_INITIAL (decl) != NULL_TREE
    5895                 :         243 :                  || !DECL_FILE_SCOPE_P (decl)
    5896                 :         243 :                  || (flag_isoc23 && DECL_THREAD_LOCAL_P (decl)))
    5897                 :             :               /* An automatic variable with an incomplete type
    5898                 :             :                  is an error.  */
    5899                 :        7517 :               : !DECL_EXTERNAL (decl)))
    5900                 :             :          {
    5901                 :          13 :            error ("storage size of %q+D isn%'t known", decl);
    5902                 :          13 :            TREE_TYPE (decl) = error_mark_node;
    5903                 :             :          }
    5904                 :             : 
    5905                 :    17210080 :       if ((RECORD_OR_UNION_TYPE_P (TREE_TYPE (decl))
    5906                 :     8432856 :           || TREE_CODE (TREE_TYPE (decl)) == ENUMERAL_TYPE)
    5907                 :      278185 :           && DECL_SIZE (decl) == NULL_TREE
    5908                 :     8698337 :           && TREE_STATIC (decl))
    5909                 :          94 :         incomplete_record_decls.safe_push (decl);
    5910                 :             : 
    5911                 :     8698100 :       if (is_global_var (decl)
    5912                 :     1219265 :           && DECL_SIZE (decl) != NULL_TREE
    5913                 :     9909545 :           && TREE_TYPE (decl) != error_mark_node)
    5914                 :             :         {
    5915                 :     1211428 :           if (TREE_CODE (DECL_SIZE (decl)) == INTEGER_CST)
    5916                 :     1211425 :             constant_expression_warning (DECL_SIZE (decl));
    5917                 :             :           else
    5918                 :             :             {
    5919                 :           3 :               error ("storage size of %q+D isn%'t constant", decl);
    5920                 :           3 :               TREE_TYPE (decl) = error_mark_node;
    5921                 :             :             }
    5922                 :             :         }
    5923                 :             : 
    5924                 :     8698100 :       if (TREE_USED (type))
    5925                 :             :         {
    5926                 :           4 :           TREE_USED (decl) = 1;
    5927                 :           4 :           DECL_READ_P (decl) = 1;
    5928                 :             :         }
    5929                 :             :     }
    5930                 :             : 
    5931                 :             :   /* If this is a function and an assembler name is specified, reset DECL_RTL
    5932                 :             :      so we can give it its new name.  Also, update builtin_decl if it
    5933                 :             :      was a normal built-in.  */
    5934                 :   137480315 :   if (TREE_CODE (decl) == FUNCTION_DECL && asmspec)
    5935                 :             :     {
    5936                 :      676557 :       if (DECL_BUILT_IN_CLASS (decl) == BUILT_IN_NORMAL)
    5937                 :       68230 :         set_builtin_user_assembler_name (decl, asmspec);
    5938                 :      676557 :       set_user_assembler_name (decl, asmspec);
    5939                 :             :     }
    5940                 :             : 
    5941                 :             :   /* If #pragma weak was used, mark the decl weak now.  */
    5942                 :   137480315 :   maybe_apply_pragma_weak (decl);
    5943                 :             : 
    5944                 :             :   /* Output the assembler code and/or RTL code for variables and functions,
    5945                 :             :      unless the type is an undefined structure or union.
    5946                 :             :      If not, it will get done when the type is completed.  */
    5947                 :             : 
    5948                 :   137480315 :   if (VAR_OR_FUNCTION_DECL_P (decl))
    5949                 :             :     {
    5950                 :             :       /* Determine the ELF visibility.  */
    5951                 :    21127938 :       if (TREE_PUBLIC (decl))
    5952                 :    13540040 :         c_determine_visibility (decl);
    5953                 :             : 
    5954                 :             :       /* This is a no-op in c-lang.cc or something real in objc-act.cc.  */
    5955                 :    21127938 :       if (c_dialect_objc ())
    5956                 :           0 :         objc_check_decl (decl);
    5957                 :             : 
    5958                 :    21127938 :       if (asmspec)
    5959                 :             :         {
    5960                 :             :           /* If this is not a static variable, issue a warning.
    5961                 :             :              It doesn't make any sense to give an ASMSPEC for an
    5962                 :             :              ordinary, non-register local variable.  Historically,
    5963                 :             :              GCC has accepted -- but ignored -- the ASMSPEC in
    5964                 :             :              this case.  */
    5965                 :      688996 :           if (!DECL_FILE_SCOPE_P (decl)
    5966                 :        1017 :               && VAR_P (decl)
    5967                 :        1017 :               && !C_DECL_REGISTER (decl)
    5968                 :      687987 :               && !TREE_STATIC (decl))
    5969                 :           1 :             warning (0, "ignoring %<asm%> specifier for non-static local "
    5970                 :             :                      "variable %q+D", decl);
    5971                 :             :           else
    5972                 :      687978 :             set_user_assembler_name (decl, asmspec);
    5973                 :             :         }
    5974                 :             : 
    5975                 :    21127938 :       if (DECL_FILE_SCOPE_P (decl))
    5976                 :             :         {
    5977                 :    13568463 :           if (DECL_INITIAL (decl) == NULL_TREE
    5978                 :    13568463 :               || DECL_INITIAL (decl) == error_mark_node)
    5979                 :             :             /* Don't output anything
    5980                 :             :                when a tentative file-scope definition is seen.
    5981                 :             :                But at end of compilation, do output code for them.  */
    5982                 :    13415728 :             DECL_DEFER_OUTPUT (decl) = 1;
    5983                 :    13568463 :           if (asmspec && VAR_P (decl) && C_DECL_REGISTER (decl))
    5984                 :          68 :             DECL_HARD_REGISTER (decl) = 1;
    5985                 :    13568463 :           rest_of_decl_compilation (decl, true, 0);
    5986                 :             : 
    5987                 :    13568463 :           if (TREE_CODE (decl) == FUNCTION_DECL)
    5988                 :             :             {
    5989                 :    12429775 :               tree parms = DECL_ARGUMENTS (decl);
    5990                 :    12429775 :               const bool builtin = fndecl_built_in_p (decl);
    5991                 :    12429775 :               if (tree access = build_attr_access_from_parms (parms, !builtin))
    5992                 :      327548 :                 decl_attributes (&decl, access, 0);
    5993                 :             :             }
    5994                 :             :         }
    5995                 :             :       else
    5996                 :             :         {
    5997                 :             :           /* In conjunction with an ASMSPEC, the `register'
    5998                 :             :              keyword indicates that we should place the variable
    5999                 :             :              in a particular register.  */
    6000                 :     7559475 :           if (asmspec && C_DECL_REGISTER (decl))
    6001                 :             :             {
    6002                 :        1009 :               DECL_HARD_REGISTER (decl) = 1;
    6003                 :             :               /* This cannot be done for a structure with volatile
    6004                 :             :                  fields, on which DECL_REGISTER will have been
    6005                 :             :                  reset.  */
    6006                 :        1009 :               if (!DECL_REGISTER (decl))
    6007                 :           1 :                 error ("cannot put object with volatile field into register");
    6008                 :             :             }
    6009                 :             : 
    6010                 :     7559475 :           if (TREE_CODE (decl) != FUNCTION_DECL)
    6011                 :             :             {
    6012                 :             :               /* If we're building a variable sized type, and we might be
    6013                 :             :                  reachable other than via the top of the current binding
    6014                 :             :                  level, then create a new BIND_EXPR so that we deallocate
    6015                 :             :                  the object at the right time.  */
    6016                 :             :               /* Note that DECL_SIZE can be null due to errors.  */
    6017                 :     7559412 :               if (DECL_SIZE (decl)
    6018                 :     7559373 :                   && !TREE_CONSTANT (DECL_SIZE (decl))
    6019                 :     7566701 :                   && STATEMENT_LIST_HAS_LABEL (cur_stmt_list))
    6020                 :             :                 {
    6021                 :        1336 :                   tree bind;
    6022                 :        1336 :                   bind = build3 (BIND_EXPR, void_type_node, NULL, NULL, NULL);
    6023                 :        1336 :                   TREE_SIDE_EFFECTS (bind) = 1;
    6024                 :        1336 :                   add_stmt (bind);
    6025                 :        1336 :                   BIND_EXPR_BODY (bind) = push_stmt_list ();
    6026                 :             :                 }
    6027                 :     7559412 :               add_stmt (build_stmt (DECL_SOURCE_LOCATION (decl),
    6028                 :             :                                     DECL_EXPR, decl));
    6029                 :             :             }
    6030                 :             :         }
    6031                 :             : 
    6032                 :             : 
    6033                 :    21127938 :       if (!DECL_FILE_SCOPE_P (decl))
    6034                 :             :         {
    6035                 :             :           /* Recompute the RTL of a local array now
    6036                 :             :              if it used to be an incomplete type.  */
    6037                 :     7559475 :           if (was_incomplete && !is_global_var (decl))
    6038                 :             :             {
    6039                 :             :               /* If we used it already as memory, it must stay in memory.  */
    6040                 :        5184 :               TREE_ADDRESSABLE (decl) = TREE_USED (decl);
    6041                 :             :               /* If it's still incomplete now, no init will save it.  */
    6042                 :        5184 :               if (DECL_SIZE (decl) == NULL_TREE)
    6043                 :         102 :                 DECL_INITIAL (decl) = NULL_TREE;
    6044                 :             :             }
    6045                 :             :         }
    6046                 :             :     }
    6047                 :             : 
    6048                 :   137480315 :   if (TREE_CODE (decl) == TYPE_DECL)
    6049                 :             :     {
    6050                 :     4090584 :       if (!DECL_FILE_SCOPE_P (decl)
    6051                 :     4090584 :           && c_type_variably_modified_p (TREE_TYPE (decl)))
    6052                 :        5309 :         add_stmt (build_stmt (DECL_SOURCE_LOCATION (decl), DECL_EXPR, decl));
    6053                 :             : 
    6054                 :     7889166 :       rest_of_decl_compilation (decl, DECL_FILE_SCOPE_P (decl), 0);
    6055                 :             :     }
    6056                 :             : 
    6057                 :             :   /* Install a cleanup (aka destructor) if one was given.  */
    6058                 :   137480315 :   if (VAR_P (decl) && !TREE_STATIC (decl))
    6059                 :             :     {
    6060                 :     7646430 :       tree attr = lookup_attribute ("cleanup", DECL_ATTRIBUTES (decl));
    6061                 :     7646430 :       if (attr)
    6062                 :             :         {
    6063                 :          95 :           tree cleanup_id = TREE_VALUE (TREE_VALUE (attr));
    6064                 :          95 :           tree cleanup_decl = lookup_name (cleanup_id);
    6065                 :          95 :           tree cleanup;
    6066                 :          95 :           vec<tree, va_gc> *v;
    6067                 :             : 
    6068                 :             :           /* Build "cleanup(&decl)" for the destructor.  */
    6069                 :          95 :           cleanup = build_unary_op (input_location, ADDR_EXPR, decl, false);
    6070                 :          95 :           vec_alloc (v, 1);
    6071                 :          95 :           v->quick_push (cleanup);
    6072                 :          95 :           cleanup = c_build_function_call_vec (DECL_SOURCE_LOCATION (decl),
    6073                 :             :                                                vNULL, cleanup_decl, v, NULL);
    6074                 :          95 :           vec_free (v);
    6075                 :             : 
    6076                 :             :           /* Don't warn about decl unused; the cleanup uses it.  */
    6077                 :          95 :           TREE_USED (decl) = 1;
    6078                 :          95 :           TREE_USED (cleanup_decl) = 1;
    6079                 :          95 :           DECL_READ_P (decl) = 1;
    6080                 :             : 
    6081                 :          95 :           push_cleanup (decl, cleanup, false);
    6082                 :             :         }
    6083                 :             :     }
    6084                 :             : 
    6085                 :   137480315 :   if (warn_cxx_compat
    6086                 :       19203 :       && VAR_P (decl)
    6087                 :        6729 :       && !DECL_EXTERNAL (decl)
    6088                 :   137486696 :       && DECL_INITIAL (decl) == NULL_TREE)
    6089                 :             :     {
    6090                 :        2058 :       type = strip_array_types (type);
    6091                 :        2058 :       if (TREE_READONLY (decl))
    6092                 :           6 :         warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wc___compat,
    6093                 :             :                     "uninitialized %<const %D%> is invalid in C++", decl);
    6094                 :        2052 :       else if (RECORD_OR_UNION_TYPE_P (type)
    6095                 :        2052 :                && C_TYPE_FIELDS_READONLY (type))
    6096                 :           5 :         diagnose_uninitialized_cst_member (decl, type);
    6097                 :             :     }
    6098                 :             : 
    6099                 :   137480315 :   if (flag_openmp
    6100                 :      321083 :       && VAR_P (decl)
    6101                 :   137501390 :       && lookup_attribute ("omp declare target implicit",
    6102                 :       21075 :                            DECL_ATTRIBUTES (decl)))
    6103                 :             :     {
    6104                 :          13 :       DECL_ATTRIBUTES (decl)
    6105                 :          13 :         = remove_attribute ("omp declare target implicit",
    6106                 :          13 :                             DECL_ATTRIBUTES (decl));
    6107                 :          13 :       if (!omp_mappable_type (TREE_TYPE (decl)))
    6108                 :           9 :         error ("%q+D in declare target directive does not have mappable type",
    6109                 :             :                decl);
    6110                 :           4 :       else if (!lookup_attribute ("omp declare target",
    6111                 :           4 :                                   DECL_ATTRIBUTES (decl))
    6112                 :           8 :                && !lookup_attribute ("omp declare target link",
    6113                 :           4 :                                      DECL_ATTRIBUTES (decl)))
    6114                 :             :         {
    6115                 :           4 :           DECL_ATTRIBUTES (decl)
    6116                 :           4 :             = tree_cons (get_identifier ("omp declare target"),
    6117                 :           4 :                          NULL_TREE, DECL_ATTRIBUTES (decl));
    6118                 :           4 :             symtab_node *node = symtab_node::get (decl);
    6119                 :           4 :             if (node != NULL)
    6120                 :             :               {
    6121                 :           4 :                 node->offloadable = 1;
    6122                 :           4 :                 if (ENABLE_OFFLOADING)
    6123                 :             :                   {
    6124                 :             :                     g->have_offload = true;
    6125                 :             :                     if (is_a <varpool_node *> (node))
    6126                 :             :                       vec_safe_push (offload_vars, decl);
    6127                 :             :                   }
    6128                 :             :               }
    6129                 :             :         }
    6130                 :             :     }
    6131                 :             : 
    6132                 :             :   /* This is the last point we can lower alignment so give the target the
    6133                 :             :      chance to do so.  */
    6134                 :   137480315 :   if (VAR_P (decl)
    6135                 :     8698100 :       && !is_global_var (decl)
    6136                 :   144959150 :       && !DECL_HARD_REGISTER (decl))
    6137                 :     7477826 :     targetm.lower_local_decl_alignment (decl);
    6138                 :             : 
    6139                 :   137480315 :   invoke_plugin_callbacks (PLUGIN_FINISH_DECL, decl);
    6140                 :   137480315 : }
    6141                 :             : 
    6142                 :             : /* Given a parsed parameter declaration, decode it into a PARM_DECL.
    6143                 :             :    EXPR is NULL or a pointer to an expression that needs to be
    6144                 :             :    evaluated for the side effects of array size expressions in the
    6145                 :             :    parameters.  */
    6146                 :             : 
    6147                 :             : tree
    6148                 :           0 : grokparm (const struct c_parm *parm, tree *expr)
    6149                 :             : {
    6150                 :           0 :   tree attrs = parm->attrs;
    6151                 :           0 :   tree decl = grokdeclarator (parm->declarator, parm->specs, PARM, false,
    6152                 :           0 :                               NULL, &attrs, expr, NULL, DEPRECATED_NORMAL);
    6153                 :             : 
    6154                 :           0 :   decl_attributes (&decl, attrs, 0);
    6155                 :             : 
    6156                 :           0 :   return decl;
    6157                 :             : }
    6158                 :             : 
    6159                 :             : /* Return attribute "arg spec" corresponding to an array/VLA parameter
    6160                 :             :    described by PARM, concatenated onto attributes ATTRS.
    6161                 :             :    The spec consists of one dollar symbol for each specified variable
    6162                 :             :    bound, one asterisk for each unspecified variable bound, followed
    6163                 :             :    by at most one specification of the most significant bound of
    6164                 :             :    an ordinary array parameter.  For ordinary arrays the specification
    6165                 :             :    is either the constant bound itself, or the space character for
    6166                 :             :    an array with an unspecified bound (the [] form).  Finally, a chain
    6167                 :             :    of specified variable bounds is appended to the spec, starting with
    6168                 :             :    the most significant bound.  For example, the PARM T a[2][m][3][n]
    6169                 :             :    will produce __attribute__((arg spec ("[$$2]", m, n)).
    6170                 :             :    For T a typedef for an array with variable bounds, the bounds are
    6171                 :             :    included in the specification in the expected order.
    6172                 :             :    No "arg spec"  is created for parameters of pointer types, making
    6173                 :             :    a distinction between T(*)[N] (or, equivalently, T[][N]) and
    6174                 :             :    the T[M][N] form, all of which have the same type and are represented
    6175                 :             :    the same, but only the last of which gets an "arg spec" describing
    6176                 :             :    the most significant bound M.  */
    6177                 :             : 
    6178                 :             : static tree
    6179                 :   108486179 : get_parm_array_spec (const struct c_parm *parm, tree attrs)
    6180                 :             : {
    6181                 :             :   /* The attribute specification string, minor bound first.  */
    6182                 :   108486179 :   std::string spec;
    6183                 :             : 
    6184                 :             :   /* A list of VLA variable bounds, major first, or null if unspecified
    6185                 :             :      or not a VLA.  */
    6186                 :   108486179 :   tree vbchain = NULL_TREE;
    6187                 :             :   /* True for a pointer parameter.  */
    6188                 :   108486179 :   bool pointer = false;
    6189                 :             :   /* True for an ordinary array with an unpecified bound.  */
    6190                 :   108486179 :   bool nobound = false;
    6191                 :             : 
    6192                 :             :   /* Create a string representation for the bounds of the array/VLA.  */
    6193                 :   206542039 :   for (c_declarator *pd = parm->declarator, *next; pd; pd = next)
    6194                 :             :     {
    6195                 :   109140776 :       next = pd->declarator;
    6196                 :   109140804 :       while (next && next->kind == cdk_attrs)
    6197                 :          28 :         next = next->declarator;
    6198                 :             : 
    6199                 :             :       /* Remember if a pointer has been seen to avoid storing the constant
    6200                 :             :          bound.  */
    6201                 :   109140776 :       if (pd->kind == cdk_pointer)
    6202                 :    11361318 :         pointer = true;
    6203                 :             : 
    6204                 :   109140776 :       if ((pd->kind == cdk_pointer || pd->kind == cdk_function)
    6205                 :    11435685 :           && (!next || next->kind == cdk_id))
    6206                 :             :         {
    6207                 :             :           /* Do nothing for the common case of a pointer.  The fact that
    6208                 :             :              the parameter is one can be deduced from the absence of
    6209                 :             :              an arg spec for it.  */
    6210                 :             :           return attrs;
    6211                 :             :         }
    6212                 :             : 
    6213                 :    98284524 :       if (pd->kind == cdk_id)
    6214                 :             :         {
    6215                 :   194677868 :           if (pointer
    6216                 :    97383263 :               || !parm->specs->type
    6217                 :    97383263 :               || TREE_CODE (parm->specs->type) != ARRAY_TYPE
    6218                 :      124677 :               || !TYPE_DOMAIN (parm->specs->type)
    6219                 :    97525923 :               || !TYPE_MAX_VALUE (TYPE_DOMAIN (parm->specs->type)))
    6220                 :    97276605 :             continue;
    6221                 :             : 
    6222                 :      124658 :           tree max = TYPE_MAX_VALUE (TYPE_DOMAIN (parm->specs->type));
    6223                 :      124658 :           if (!vbchain
    6224                 :      124644 :               && TREE_CODE (max) == INTEGER_CST)
    6225                 :             :             {
    6226                 :             :               /* Extract the upper bound from a parameter of an array type
    6227                 :             :                  unless the parameter is an ordinary array of unspecified
    6228                 :             :                  bound in which case a next iteration of the loop will
    6229                 :             :                  exit.  */
    6230                 :      124410 :               if (spec.empty () || spec.end ()[-1] != ' ')
    6231                 :             :                 {
    6232                 :      124410 :                   if (!tree_fits_shwi_p (max))
    6233                 :           0 :                     continue;
    6234                 :             : 
    6235                 :             :                   /* The upper bound is the value of the largest valid
    6236                 :             :                      index.  */
    6237                 :      124410 :                   HOST_WIDE_INT n = tree_to_shwi (max) + 1;
    6238                 :      124410 :                   char buf[40];
    6239                 :      124410 :                   sprintf (buf, HOST_WIDE_INT_PRINT_UNSIGNED, n);
    6240                 :      124410 :                   spec += buf;
    6241                 :             :                 }
    6242                 :      124410 :               continue;
    6243                 :      124410 :             }
    6244                 :             : 
    6245                 :             :           /* For a VLA typedef, create a list of its variable bounds and
    6246                 :             :              append it in the expected order to VBCHAIN.  */
    6247                 :             :           tree tpbnds = NULL_TREE;
    6248                 :        1188 :           for (tree type = parm->specs->type; TREE_CODE (type) == ARRAY_TYPE;
    6249                 :         940 :                type = TREE_TYPE (type))
    6250                 :             :             {
    6251                 :         940 :               tree nelts = array_type_nelts (type);
    6252                 :         940 :               if (error_operand_p (nelts))
    6253                 :             :                 return attrs;
    6254                 :         940 :               if (TREE_CODE (nelts) != INTEGER_CST)
    6255                 :             :                 {
    6256                 :             :                   /* Each variable VLA bound is represented by the dollar
    6257                 :             :                      sign.  */
    6258                 :         908 :                   spec += "$";
    6259                 :         908 :                   tpbnds = tree_cons (NULL_TREE, nelts, tpbnds);
    6260                 :             :                 }
    6261                 :             :             }
    6262                 :         248 :           tpbnds = nreverse (tpbnds);
    6263                 :         248 :           vbchain = chainon (vbchain, tpbnds);
    6264                 :         248 :           continue;
    6265                 :         248 :         }
    6266                 :             : 
    6267                 :      883261 :       if (pd->kind != cdk_array)
    6268                 :      579433 :         continue;
    6269                 :             : 
    6270                 :      303828 :       if (pd->u.array.vla_unspec_p)
    6271                 :             :         {
    6272                 :             :           /* Each unspecified bound is represented by a star.  There
    6273                 :             :              can be any number of these in a declaration (but none in
    6274                 :             :              a definition).  */
    6275                 :         124 :           spec += '*';
    6276                 :         124 :           continue;
    6277                 :             :         }
    6278                 :             : 
    6279                 :      303704 :       tree nelts = pd->u.array.dimen;
    6280                 :      303704 :       if (!nelts)
    6281                 :             :         {
    6282                 :             :           /* Ordinary array of unspecified size.  There can be at most
    6283                 :             :              one for the most significant bound.  Exit on the next
    6284                 :             :              iteration which determines whether or not PARM is declared
    6285                 :             :              as a pointer or an array.  */
    6286                 :       62454 :           nobound = true;
    6287                 :       62454 :           continue;
    6288                 :             :         }
    6289                 :             : 
    6290                 :      241250 :       if (pd->u.array.static_p)
    6291                 :         113 :         spec += 's';
    6292                 :             : 
    6293                 :      241250 :       if (!INTEGRAL_TYPE_P (TREE_TYPE (nelts)))
    6294                 :             :         /* Avoid invalid NELTS.  */
    6295                 :             :         return attrs;
    6296                 :             : 
    6297                 :      241207 :       STRIP_NOPS (nelts);
    6298                 :      241207 :       nelts = c_fully_fold (nelts, false, nullptr);
    6299                 :      241207 :       if (TREE_CODE (nelts) == INTEGER_CST)
    6300                 :             :         {
    6301                 :             :           /* Skip all constant bounds except the most significant one.
    6302                 :             :              The interior ones are included in the array type.  */
    6303                 :      232522 :           if (next && (next->kind == cdk_array || next->kind == cdk_pointer))
    6304                 :        3901 :             continue;
    6305                 :             : 
    6306                 :      228621 :           if (!tree_fits_uhwi_p (nelts))
    6307                 :             :             /* Bail completely on invalid bounds.  */
    6308                 :           2 :             return attrs;
    6309                 :             : 
    6310                 :      228619 :           char buf[40];
    6311                 :      228619 :           unsigned HOST_WIDE_INT n = tree_to_uhwi (nelts);
    6312                 :      228619 :           sprintf (buf, HOST_WIDE_INT_PRINT_UNSIGNED, n);
    6313                 :      228619 :           spec += buf;
    6314                 :      228619 :           break;
    6315                 :             :         }
    6316                 :             : 
    6317                 :             :       /* Each variable VLA bound is represented by a dollar sign.  */
    6318                 :        8685 :       spec += "$";
    6319                 :        8685 :       vbchain = tree_cons (NULL_TREE, nelts, vbchain);
    6320                 :             :     }
    6321                 :             : 
    6322                 :    97629882 :   if (spec.empty () && !nobound)
    6323                 :             :     return attrs;
    6324                 :             : 
    6325                 :      416407 :   spec.insert (0, "[");
    6326                 :      416407 :   if (nobound)
    6327                 :             :     /* Ordinary array of unspecified bound is represented by a space.
    6328                 :             :        It must be last in the spec.  */
    6329                 :       62399 :     spec += ' ';
    6330                 :      416407 :   spec += ']';
    6331                 :             : 
    6332                 :      416407 :   tree acsstr = build_string (spec.length () + 1, spec.c_str ());
    6333                 :      416407 :   tree args = tree_cons (NULL_TREE, acsstr, vbchain);
    6334                 :      416407 :   tree name = get_identifier ("arg spec");
    6335                 :      416407 :   return tree_cons (name, args, attrs);
    6336                 :   108486179 : }
    6337                 :             : 
    6338                 :             : /* Given a parsed parameter declaration, decode it into a PARM_DECL
    6339                 :             :    and push that on the current scope.  EXPR is a pointer to an
    6340                 :             :    expression that needs to be evaluated for the side effects of array
    6341                 :             :    size expressions in the parameters.  */
    6342                 :             : 
    6343                 :             : void
    6344                 :   108486179 : push_parm_decl (const struct c_parm *parm, tree *expr)
    6345                 :             : {
    6346                 :   108486179 :   tree attrs = parm->attrs;
    6347                 :   108486179 :   tree decl = grokdeclarator (parm->declarator, parm->specs, PARM, false, NULL,
    6348                 :   108486179 :                               &attrs, expr, NULL, DEPRECATED_NORMAL);
    6349                 :   108486179 :   if (decl && DECL_P (decl))
    6350                 :   108486179 :     DECL_SOURCE_LOCATION (decl) = parm->loc;
    6351                 :             : 
    6352                 :   108486179 :   attrs = get_parm_array_spec (parm, attrs);
    6353                 :   108486179 :   decl_attributes (&decl, attrs, 0);
    6354                 :             : 
    6355                 :   108486179 :   decl = pushdecl (decl);
    6356                 :             : 
    6357                 :   108486179 :   finish_decl (decl, input_location, NULL_TREE, NULL_TREE, NULL_TREE);
    6358                 :   108486179 : }
    6359                 :             : 
    6360                 :             : /* Mark all the parameter declarations to date as forward decls.
    6361                 :             :    Also diagnose use of this extension.  */
    6362                 :             : 
    6363                 :             : void
    6364                 :          37 : mark_forward_parm_decls (void)
    6365                 :             : {
    6366                 :          37 :   struct c_binding *b;
    6367                 :             : 
    6368                 :          37 :   if (pedantic && !current_scope->warned_forward_parm_decls)
    6369                 :             :     {
    6370                 :           4 :       pedwarn (input_location, OPT_Wpedantic,
    6371                 :             :                "ISO C forbids forward parameter declarations");
    6372                 :           4 :       current_scope->warned_forward_parm_decls = true;
    6373                 :             :     }
    6374                 :             : 
    6375                 :          83 :   for (b = current_scope->bindings; b; b = b->prev)
    6376                 :          46 :     if (TREE_CODE (b->decl) == PARM_DECL)
    6377                 :          46 :       TREE_ASM_WRITTEN (b->decl) = 1;
    6378                 :          37 : }
    6379                 :             : 
    6380                 :             : /* Build a COMPOUND_LITERAL_EXPR.  TYPE is the type given in the compound
    6381                 :             :    literal, which may be an incomplete array type completed by the
    6382                 :             :    initializer; INIT is a CONSTRUCTOR at LOC that initializes the compound
    6383                 :             :    literal.  NON_CONST is true if the initializers contain something
    6384                 :             :    that cannot occur in a constant expression.  If ALIGNAS_ALIGN is nonzero,
    6385                 :             :    it is the (valid) alignment for this compound literal, as specified
    6386                 :             :    with _Alignas.  SCSPECS are the storage class specifiers (C23) from the
    6387                 :             :    compound literal.  */
    6388                 :             : 
    6389                 :             : tree
    6390                 :      869039 : build_compound_literal (location_t loc, tree type, tree init, bool non_const,
    6391                 :             :                         unsigned int alignas_align,
    6392                 :             :                         struct c_declspecs *scspecs)
    6393                 :             : {
    6394                 :             :   /* We do not use start_decl here because we have a type, not a declarator;
    6395                 :             :      and do not use finish_decl because the decl should be stored inside
    6396                 :             :      the COMPOUND_LITERAL_EXPR rather than added elsewhere as a DECL_EXPR.  */
    6397                 :      869039 :   tree decl;
    6398                 :      869039 :   tree complit;
    6399                 :      869039 :   tree stmt;
    6400                 :      869039 :   bool threadp = scspecs ? scspecs->thread_p : false;
    6401                 :     1738078 :   enum c_storage_class storage_class = (scspecs
    6402                 :      869039 :                                         ? scspecs->storage_class
    6403                 :             :                                         : csc_none);
    6404                 :             : 
    6405                 :      869039 :   if (type == error_mark_node
    6406                 :      869023 :       || init == error_mark_node)
    6407                 :             :     return error_mark_node;
    6408                 :             : 
    6409                 :      868970 :   if (current_scope == file_scope && storage_class == csc_register)
    6410                 :             :     {
    6411                 :           1 :       error_at (loc, "file-scope compound literal specifies %<register%>");
    6412                 :           1 :       storage_class = csc_none;
    6413                 :             :     }
    6414                 :             : 
    6415                 :      868970 :   if (current_scope != file_scope && threadp && storage_class == csc_none)
    6416                 :             :     {
    6417                 :           2 :       error_at (loc, "compound literal implicitly auto and declared %qs",
    6418                 :           1 :                 scspecs->thread_gnu_p ? "__thread" : "_Thread_local");
    6419                 :           1 :       threadp = false;
    6420                 :             :     }
    6421                 :             : 
    6422                 :      868970 :   decl = build_decl (loc, VAR_DECL, NULL_TREE, type);
    6423                 :      868970 :   DECL_EXTERNAL (decl) = 0;
    6424                 :      868970 :   TREE_PUBLIC (decl) = 0;
    6425                 :     1737940 :   TREE_STATIC (decl) = (current_scope == file_scope
    6426                 :      868970 :                         || storage_class == csc_static);
    6427                 :      868970 :   DECL_CONTEXT (decl) = current_function_decl;
    6428                 :      868970 :   TREE_USED (decl) = 1;
    6429                 :      868970 :   DECL_READ_P (decl) = 1;
    6430                 :      868970 :   DECL_ARTIFICIAL (decl) = 1;
    6431                 :      868970 :   DECL_IGNORED_P (decl) = 1;
    6432                 :      868970 :   C_DECL_COMPOUND_LITERAL_P (decl) = 1;
    6433                 :     1737711 :   C_DECL_DECLARED_CONSTEXPR (decl) = scspecs && scspecs->constexpr_p;
    6434                 :      868970 :   TREE_TYPE (decl) = type;
    6435                 :      868970 :   if (threadp)
    6436                 :          16 :     set_decl_tls_model (decl, decl_default_tls_model (decl));
    6437                 :      868970 :   if (storage_class == csc_register)
    6438                 :             :     {
    6439                 :          10 :       C_DECL_REGISTER (decl) = 1;
    6440                 :          10 :       DECL_REGISTER (decl) = 1;
    6441                 :             :     }
    6442                 :      868970 :   c_apply_type_quals_to_decl (TYPE_QUALS (strip_array_types (type)), decl);
    6443                 :      868970 :   if (alignas_align)
    6444                 :             :     {
    6445                 :           3 :       SET_DECL_ALIGN (decl, alignas_align * BITS_PER_UNIT);
    6446                 :           3 :       DECL_USER_ALIGN (decl) = 1;
    6447                 :             :     }
    6448                 :      868970 :   store_init_value (loc, decl, init, NULL_TREE);
    6449                 :      868970 :   if (current_scope != file_scope
    6450                 :      868725 :       && TREE_STATIC (decl)
    6451                 :          26 :       && !TREE_READONLY (decl)
    6452                 :          15 :       && DECL_DECLARED_INLINE_P (current_function_decl)
    6453                 :      868976 :       && DECL_EXTERNAL (current_function_decl))
    6454                 :           4 :     record_inline_static (input_location, current_function_decl,
    6455                 :             :                           decl, csi_modifiable);
    6456                 :             : 
    6457                 :      868970 :   if (TREE_CODE (type) == ARRAY_TYPE && !COMPLETE_TYPE_P (type))
    6458                 :             :     {
    6459                 :         250 :       int failure = complete_array_type (&TREE_TYPE (decl),
    6460                 :         250 :                                          DECL_INITIAL (decl), true);
    6461                 :             :       /* If complete_array_type returns 3, it means that the
    6462                 :             :          initial value of the compound literal is empty.  Allow it.  */
    6463                 :         250 :       gcc_assert (failure == 0 || failure == 3);
    6464                 :             : 
    6465                 :         250 :       type = TREE_TYPE (decl);
    6466                 :         250 :       TREE_TYPE (DECL_INITIAL (decl)) = type;
    6467                 :             :     }
    6468                 :             : 
    6469                 :      868970 :   if (type == error_mark_node || !COMPLETE_TYPE_P (type))
    6470                 :             :     {
    6471                 :          19 :       c_incomplete_type_error (loc, NULL_TREE, type);
    6472                 :          19 :       return error_mark_node;
    6473                 :             :     }
    6474                 :             : 
    6475                 :      868951 :   if (TREE_STATIC (decl)
    6476                 :      868951 :       && !verify_type_context (loc, TCTX_STATIC_STORAGE, type))
    6477                 :           0 :     return error_mark_node;
    6478                 :             : 
    6479                 :      868951 :   stmt = build_stmt (DECL_SOURCE_LOCATION (decl), DECL_EXPR, decl);
    6480                 :      868951 :   complit = build1 (COMPOUND_LITERAL_EXPR, type, stmt);
    6481                 :      868951 :   TREE_SIDE_EFFECTS (complit) = 1;
    6482                 :             : 
    6483                 :      868951 :   layout_decl (decl, 0);
    6484                 :             : 
    6485                 :      868951 :   if (TREE_STATIC (decl))
    6486                 :             :     {
    6487                 :             :       /* This decl needs a name for the assembler output.  */
    6488                 :         271 :       set_compound_literal_name (decl);
    6489                 :         271 :       DECL_DEFER_OUTPUT (decl) = 1;
    6490                 :         271 :       DECL_COMDAT (decl) = 1;
    6491                 :         271 :       pushdecl (decl);
    6492                 :         271 :       rest_of_decl_compilation (decl, 1, 0);
    6493                 :             :     }
    6494                 :      868680 :   else if (current_function_decl && !current_scope->parm_flag)
    6495                 :      868671 :     pushdecl (decl);
    6496                 :             : 
    6497                 :      868951 :   if (non_const)
    6498                 :             :     {
    6499                 :         174 :       complit = build2 (C_MAYBE_CONST_EXPR, type, NULL, complit);
    6500                 :         174 :       C_MAYBE_CONST_EXPR_NON_CONST (complit) = 1;
    6501                 :             :     }
    6502                 :             : 
    6503                 :             :   return complit;
    6504                 :             : }
    6505                 :             : 
    6506                 :             : /* Check the type of a compound literal.  Here we just check that it
    6507                 :             :    is valid for C++.  */
    6508                 :             : 
    6509                 :             : void
    6510                 :      869039 : check_compound_literal_type (location_t loc, struct c_type_name *type_name)
    6511                 :             : {
    6512                 :      869039 :   if (warn_cxx_compat
    6513                 :         159 :       && (type_name->specs->typespec_kind == ctsk_tagdef
    6514                 :         158 :           || type_name->specs->typespec_kind == ctsk_tagfirstref
    6515                 :         157 :           || type_name->specs->typespec_kind == ctsk_tagfirstref_attrs))
    6516                 :           2 :     warning_at (loc, OPT_Wc___compat,
    6517                 :             :                 "defining a type in a compound literal is invalid in C++");
    6518                 :      869039 : }
    6519                 :             : 
    6520                 :             : /* Performs sanity checks on the TYPE and WIDTH of the bit-field NAME,
    6521                 :             :    replacing with appropriate values if they are invalid.  */
    6522                 :             : 
    6523                 :             : static void
    6524                 :       39375 : check_bitfield_type_and_width (location_t loc, tree *type, tree *width,
    6525                 :             :                                tree orig_name)
    6526                 :             : {
    6527                 :       39375 :   tree type_mv;
    6528                 :       39375 :   unsigned int max_width;
    6529                 :       39375 :   unsigned HOST_WIDE_INT w;
    6530                 :       39375 :   const char *name = (orig_name
    6531                 :       69864 :                       ? identifier_to_locale (IDENTIFIER_POINTER (orig_name))
    6532                 :        8886 :                       : _("<anonymous>"));
    6533                 :             : 
    6534                 :             :   /* Detect and ignore out of range field width and process valid
    6535                 :             :      field widths.  */
    6536                 :       39375 :   if (!INTEGRAL_TYPE_P (TREE_TYPE (*width)))
    6537                 :             :     {
    6538                 :           4 :       error_at (loc, "bit-field %qs width not an integer constant", name);
    6539                 :           4 :       *width = integer_one_node;
    6540                 :             :     }
    6541                 :             :   else
    6542                 :             :     {
    6543                 :       39371 :       if (TREE_CODE (*width) != INTEGER_CST)
    6544                 :             :         {
    6545                 :          12 :           *width = c_fully_fold (*width, false, NULL);
    6546                 :          12 :           if (TREE_CODE (*width) == INTEGER_CST)
    6547                 :           6 :             pedwarn (loc, OPT_Wpedantic,
    6548                 :             :                      "bit-field %qs width not an integer constant expression",
    6549                 :             :                      name);
    6550                 :             :         }
    6551                 :       39371 :       if (TREE_CODE (*width) != INTEGER_CST)
    6552                 :             :         {
    6553                 :           6 :           error_at (loc, "bit-field %qs width not an integer constant", name);
    6554                 :           6 :           *width = integer_one_node;
    6555                 :             :         }
    6556                 :       39371 :       constant_expression_warning (*width);
    6557                 :       39371 :       if (tree_int_cst_sgn (*width) < 0)
    6558                 :             :         {
    6559                 :           2 :           error_at (loc, "negative width in bit-field %qs", name);
    6560                 :           2 :           *width = integer_one_node;
    6561                 :             :         }
    6562                 :       39369 :       else if (integer_zerop (*width) && orig_name)
    6563                 :             :         {
    6564                 :           4 :           error_at (loc, "zero width for bit-field %qs", name);
    6565                 :           4 :           *width = integer_one_node;
    6566                 :             :         }
    6567                 :             :     }
    6568                 :             : 
    6569                 :             :   /* Detect invalid bit-field type.  */
    6570                 :       39375 :   if (TREE_CODE (*type) != INTEGER_TYPE
    6571                 :             :       && TREE_CODE (*type) != BOOLEAN_TYPE
    6572                 :             :       && TREE_CODE (*type) != ENUMERAL_TYPE
    6573                 :       39375 :       && TREE_CODE (*type) != BITINT_TYPE)
    6574                 :             :     {
    6575                 :           6 :       error_at (loc, "bit-field %qs has invalid type", name);
    6576                 :           6 :       *type = unsigned_type_node;
    6577                 :             :     }
    6578                 :             : 
    6579                 :       39375 :   if (TYPE_WARN_IF_NOT_ALIGN (*type))
    6580                 :             :     {
    6581                 :           1 :       error_at (loc, "cannot declare bit-field %qs with %<warn_if_not_aligned%> type",
    6582                 :             :                 name);
    6583                 :           1 :       *type = unsigned_type_node;
    6584                 :             :     }
    6585                 :             : 
    6586                 :       39375 :   type_mv = TYPE_MAIN_VARIANT (*type);
    6587                 :       39375 :   if (!in_system_header_at (input_location)
    6588                 :       28989 :       && type_mv != integer_type_node
    6589                 :       26363 :       && type_mv != unsigned_type_node
    6590                 :       51759 :       && type_mv != boolean_type_node)
    6591                 :       11802 :     pedwarn_c90 (loc, OPT_Wpedantic,
    6592                 :             :                  "type of bit-field %qs is a GCC extension", name);
    6593                 :             : 
    6594                 :       39375 :   max_width = TYPE_PRECISION (*type);
    6595                 :             : 
    6596                 :       39375 :   if (compare_tree_int (*width, max_width) > 0)
    6597                 :             :     {
    6598                 :           4 :       error_at (loc, "width of %qs exceeds its type", name);
    6599                 :           4 :       w = max_width;
    6600                 :           4 :       *width = build_int_cst (integer_type_node, w);
    6601                 :             :     }
    6602                 :             :   else
    6603                 :       39371 :     w = tree_to_uhwi (*width);
    6604                 :             : 
    6605                 :             :   /* Truncation of hardbool false and true representation values is always safe:
    6606                 :             :      either the values remain different, or we'll report a problem when creating
    6607                 :             :      the narrower type.  */
    6608                 :       39375 :   if (c_hardbool_type_attr (*type))
    6609                 :       39375 :     return;
    6610                 :             : 
    6611                 :       39122 :   if (TREE_CODE (*type) == ENUMERAL_TYPE)
    6612                 :             :     {
    6613                 :        4128 :       struct lang_type *lt = TYPE_LANG_SPECIFIC (*type);
    6614                 :        4128 :       if (!lt
    6615                 :        4120 :           || w < tree_int_cst_min_precision (lt->enum_min, TYPE_SIGN (*type))
    6616                 :        8244 :           || w < tree_int_cst_min_precision (lt->enum_max, TYPE_SIGN (*type)))
    6617                 :          13 :         warning_at (loc, 0, "%qs is narrower than values of its type", name);
    6618                 :             :     }
    6619                 :             : }
    6620                 :             : 
    6621                 :             : 
    6622                 :             : 
    6623                 :             : /* Print warning about variable length array if necessary.  */
    6624                 :             : 
    6625                 :             : static void
    6626                 :       22137 : warn_variable_length_array (tree name, tree size)
    6627                 :             : {
    6628                 :       22137 :   if (TREE_CONSTANT (size))
    6629                 :             :     {
    6630                 :         171 :       if (name)
    6631                 :         160 :         pedwarn_c90 (input_location, OPT_Wvla,
    6632                 :             :                      "ISO C90 forbids array %qE whose size "
    6633                 :             :                      "cannot be evaluated", name);
    6634                 :             :       else
    6635                 :          11 :         pedwarn_c90 (input_location, OPT_Wvla, "ISO C90 forbids array "
    6636                 :             :                      "whose size cannot be evaluated");
    6637                 :             :     }
    6638                 :             :   else
    6639                 :             :     {
    6640                 :       21966 :       if (name)
    6641                 :       13629 :         pedwarn_c90 (input_location, OPT_Wvla,
    6642                 :             :                      "ISO C90 forbids variable length array %qE", name);
    6643                 :             :       else
    6644                 :        8337 :         pedwarn_c90 (input_location, OPT_Wvla, "ISO C90 forbids variable "
    6645                 :             :                      "length array");
    6646                 :             :     }
    6647                 :       22137 : }
    6648                 :             : 
    6649                 :             : /* Returns the smallest location != UNKNOWN_LOCATION in LOCATIONS,
    6650                 :             :    considering only those c_declspec_words found in LIST, which
    6651                 :             :    must be terminated by cdw_number_of_elements.  */
    6652                 :             : 
    6653                 :             : static location_t
    6654                 :         122 : smallest_type_quals_location (const location_t *locations,
    6655                 :             :                               const c_declspec_word *list)
    6656                 :             : {
    6657                 :         122 :   location_t loc = UNKNOWN_LOCATION;
    6658                 :         732 :   while (*list != cdw_number_of_elements)
    6659                 :             :     {
    6660                 :         610 :       location_t newloc = locations[*list];
    6661                 :         610 :       if (loc == UNKNOWN_LOCATION
    6662                 :         284 :           || (newloc != UNKNOWN_LOCATION && newloc < loc))
    6663                 :         326 :         loc = newloc;
    6664                 :         610 :       list++;
    6665                 :             :     }
    6666                 :             : 
    6667                 :         122 :   return loc;
    6668                 :             : }
    6669                 :             : 
    6670                 :             : 
    6671                 :             : /* We attach an artificial TYPE_DECL to pointed-to type
    6672                 :             :    and arrange for it to be included in a DECL_EXPR.  This
    6673                 :             :    forces the sizes evaluation at a safe point and ensures it
    6674                 :             :    is not deferred until e.g. within a deeper conditional context.
    6675                 :             : 
    6676                 :             :    PARM contexts have no enclosing statement list that
    6677                 :             :    can hold the DECL_EXPR, so we need to use a BIND_EXPR
    6678                 :             :    instead, and add it to the list of expressions that
    6679                 :             :    need to be evaluated.
    6680                 :             : 
    6681                 :             :    TYPENAME contexts do have an enclosing statement list,
    6682                 :             :    but it would be incorrect to use it, as the size should
    6683                 :             :    only be evaluated if the containing expression is
    6684                 :             :    evaluated.  We might also be in the middle of an
    6685                 :             :    expression with side effects on the pointed-to type size
    6686                 :             :    "arguments" prior to the pointer declaration point and
    6687                 :             :    the fake TYPE_DECL in the enclosing context would force
    6688                 :             :    the size evaluation prior to the side effects.  We therefore
    6689                 :             :    use BIND_EXPRs in TYPENAME contexts too.  */
    6690                 :             : static void
    6691                 :        6794 : add_decl_expr (location_t loc, tree type, tree *expr, bool set_name_p)
    6692                 :             : {
    6693                 :        6794 :   tree bind = NULL_TREE;
    6694                 :        6794 :   if (expr)
    6695                 :             :     {
    6696                 :        1369 :       bind = build3 (BIND_EXPR, void_type_node, NULL_TREE, NULL_TREE,
    6697                 :             :                      NULL_TREE);
    6698                 :        1369 :       TREE_SIDE_EFFECTS (bind) = 1;
    6699                 :        1369 :       BIND_EXPR_BODY (bind) = push_stmt_list ();
    6700                 :        1369 :       push_scope ();
    6701                 :             :     }
    6702                 :             : 
    6703                 :        6794 :   tree decl = build_decl (loc, TYPE_DECL, NULL_TREE, type);
    6704                 :        6794 :   pushdecl (decl);
    6705                 :        6794 :   DECL_ARTIFICIAL (decl) = 1;
    6706                 :        6794 :   add_stmt (build_stmt (DECL_SOURCE_LOCATION (decl), DECL_EXPR, decl));
    6707                 :        6794 :   if (set_name_p)
    6708                 :        6196 :     TYPE_NAME (type) = decl;
    6709                 :             : 
    6710                 :        6794 :   if (bind)
    6711                 :             :     {
    6712                 :        1369 :       pop_scope ();
    6713                 :        1369 :       BIND_EXPR_BODY (bind) = pop_stmt_list (BIND_EXPR_BODY (bind));
    6714                 :        1369 :       if (*expr)
    6715                 :        1317 :         *expr = build2 (COMPOUND_EXPR, void_type_node, *expr, bind);
    6716                 :             :       else
    6717                 :          52 :         *expr = bind;
    6718                 :             :     }
    6719                 :        6794 : }
    6720                 :             : 
    6721                 :             : /* Given declspecs and a declarator,
    6722                 :             :    determine the name and type of the object declared
    6723                 :             :    and construct a ..._DECL node for it.
    6724                 :             :    (In one case we can return a ..._TYPE node instead.
    6725                 :             :     For invalid input we sometimes return NULL_TREE.)
    6726                 :             : 
    6727                 :             :    DECLSPECS is a c_declspecs structure for the declaration specifiers.
    6728                 :             : 
    6729                 :             :    DECL_CONTEXT says which syntactic context this declaration is in:
    6730                 :             :      NORMAL for most contexts.  Make a VAR_DECL or FUNCTION_DECL or TYPE_DECL.
    6731                 :             :      FUNCDEF for a function definition.  Like NORMAL but a few different
    6732                 :             :       error messages in each case.  Return value may be zero meaning
    6733                 :             :       this definition is too screwy to try to parse.
    6734                 :             :      PARM for a parameter declaration (either within a function prototype
    6735                 :             :       or before a function body).  Make a PARM_DECL, or return void_type_node.
    6736                 :             :      TYPENAME if for a typename (in a cast or sizeof).
    6737                 :             :       Don't make a DECL node; just return the ..._TYPE node.
    6738                 :             :      FIELD for a struct or union field; make a FIELD_DECL.
    6739                 :             :    INITIALIZED is true if the decl has an initializer.
    6740                 :             :    WIDTH is non-NULL for bit-fields, and is a pointer to an INTEGER_CST node
    6741                 :             :    representing the width of the bit-field.
    6742                 :             :    DECL_ATTRS points to the list of attributes that should be added to this
    6743                 :             :      decl.  Any nested attributes that belong on the decl itself will be
    6744                 :             :      added to this list.
    6745                 :             :    If EXPR is not NULL, any expressions that need to be evaluated as
    6746                 :             :      part of evaluating variably modified types will be stored in *EXPR.
    6747                 :             :    If EXPR_CONST_OPERANDS is not NULL, *EXPR_CONST_OPERANDS will be
    6748                 :             :      set to indicate whether operands in *EXPR can be used in constant
    6749                 :             :      expressions.
    6750                 :             :    DEPRECATED_STATE is a deprecated_states value indicating whether
    6751                 :             :    deprecation/unavailability warnings should be suppressed.
    6752                 :             : 
    6753                 :             :    In the TYPENAME case, DECLARATOR is really an absolute declarator.
    6754                 :             :    It may also be so in the PARM case, for a prototype where the
    6755                 :             :    argument type is specified but not the name.
    6756                 :             : 
    6757                 :             :    This function is where the complicated C meanings of `static'
    6758                 :             :    and `extern' are interpreted.  */
    6759                 :             : 
    6760                 :             : static tree
    6761                 :   274434329 : grokdeclarator (const struct c_declarator *declarator,
    6762                 :             :                 struct c_declspecs *declspecs,
    6763                 :             :                 enum decl_context decl_context, bool initialized, tree *width,
    6764                 :             :                 tree *decl_attrs, tree *expr, bool *expr_const_operands,
    6765                 :             :                 enum deprecated_states deprecated_state)
    6766                 :             : {
    6767                 :   274434329 :   tree type = declspecs->type;
    6768                 :   274434329 :   bool threadp = declspecs->thread_p;
    6769                 :   274434329 :   bool constexprp = declspecs->constexpr_p;
    6770                 :   274434329 :   enum c_storage_class storage_class = declspecs->storage_class;
    6771                 :   274434329 :   int constp;
    6772                 :   274434329 :   int restrictp;
    6773                 :   274434329 :   int volatilep;
    6774                 :   274434329 :   int atomicp;
    6775                 :   274434329 :   int type_quals = TYPE_UNQUALIFIED;
    6776                 :   274434329 :   tree name = NULL_TREE;
    6777                 :   274434329 :   bool funcdef_flag = false;
    6778                 :   274434329 :   bool funcdef_syntax = false;
    6779                 :   274434329 :   bool size_varies = false;
    6780                 :   274434329 :   tree decl_attr = declspecs->decl_attr;
    6781                 :   274434329 :   int array_ptr_quals = TYPE_UNQUALIFIED;
    6782                 :   274434329 :   tree array_ptr_attrs = NULL_TREE;
    6783                 :   274434329 :   bool array_parm_static = false;
    6784                 :   274434329 :   bool array_parm_vla_unspec_p = false;
    6785                 :   274434329 :   tree returned_attrs = NULL_TREE;
    6786                 :   274434329 :   tree decl_id_attrs = NULL_TREE;
    6787                 :   274434329 :   bool bitfield = width != NULL;
    6788                 :   274434329 :   tree element_type;
    6789                 :   274434329 :   tree orig_qual_type = NULL;
    6790                 :   274434329 :   size_t orig_qual_indirect = 0;
    6791                 :   274434329 :   struct c_arg_info *arg_info = 0;
    6792                 :   274434329 :   addr_space_t as1, as2, address_space;
    6793                 :   274434329 :   location_t loc = UNKNOWN_LOCATION;
    6794                 :   274434329 :   tree expr_dummy;
    6795                 :   274434329 :   bool expr_const_operands_dummy;
    6796                 :   274434329 :   enum c_declarator_kind first_non_attr_kind;
    6797                 :   274434329 :   unsigned int alignas_align = 0;
    6798                 :             : 
    6799                 :   274434329 :   if (type == NULL_TREE)
    6800                 :             :     {
    6801                 :             :       /* This can occur for auto on a parameter in C23 mode.  Set a
    6802                 :             :          dummy type here so subsequent code can give diagnostics for
    6803                 :             :          this case.  */
    6804                 :           2 :       gcc_assert (declspecs->c23_auto_p);
    6805                 :           2 :       gcc_assert (decl_context == PARM);
    6806                 :           2 :       type = declspecs->type = integer_type_node;
    6807                 :             :     }
    6808                 :   274434329 :   if (TREE_CODE (type) == ERROR_MARK)
    6809                 :          26 :     return error_mark_node;
    6810                 :   274434303 :   if (expr == NULL)
    6811                 :             :     {
    6812                 :       36190 :       expr = &expr_dummy;
    6813                 :       36190 :       expr_dummy = NULL_TREE;
    6814                 :             :     }
    6815                 :   274434303 :   if (expr_const_operands == NULL)
    6816                 :   169296268 :     expr_const_operands = &expr_const_operands_dummy;
    6817                 :             : 
    6818                 :   274434303 :   if (declspecs->expr)
    6819                 :             :     {
    6820                 :         839 :       if (*expr)
    6821                 :           7 :         *expr = build2 (COMPOUND_EXPR, TREE_TYPE (declspecs->expr), *expr,
    6822                 :             :                         declspecs->expr);
    6823                 :             :       else
    6824                 :         832 :         *expr = declspecs->expr;
    6825                 :             :     }
    6826                 :   274434303 :   *expr_const_operands = declspecs->expr_const_operands;
    6827                 :             : 
    6828                 :   274434303 :   if (decl_context == FUNCDEF)
    6829                 :    31761938 :     funcdef_flag = true, decl_context = NORMAL;
    6830                 :             : 
    6831                 :             :   /* Look inside a declarator for the name being declared
    6832                 :             :      and get it as an IDENTIFIER_NODE, for an error message.  */
    6833                 :   274434303 :   {
    6834                 :   274434303 :     const struct c_declarator *decl = declarator;
    6835                 :             : 
    6836                 :   274434303 :     first_non_attr_kind = cdk_attrs;
    6837                 :   610378575 :     while (decl)
    6838                 :   335944272 :       switch (decl->kind)
    6839                 :             :         {
    6840                 :     1062904 :         case cdk_array:
    6841                 :     1062904 :           loc = decl->id_loc;
    6842                 :             :           /* FALL THRU.  */
    6843                 :             : 
    6844                 :    61503441 :         case cdk_function:
    6845                 :    61503441 :         case cdk_pointer:
    6846                 :    61503441 :           funcdef_syntax = (decl->kind == cdk_function);
    6847                 :    61503441 :           if (first_non_attr_kind == cdk_attrs)
    6848                 :    59618879 :             first_non_attr_kind = decl->kind;
    6849                 :    61503441 :           decl = decl->declarator;
    6850                 :    61503441 :           break;
    6851                 :             : 
    6852                 :        6528 :         case cdk_attrs:
    6853                 :        6528 :           decl = decl->declarator;
    6854                 :        6528 :           break;
    6855                 :             : 
    6856                 :   274434303 :         case cdk_id:
    6857                 :   274434303 :           loc = decl->id_loc;
    6858                 :   274434303 :           if (decl->u.id.id)
    6859                 :   165151063 :             name = decl->u.id.id;
    6860                 :   274434303 :           decl_id_attrs = decl->u.id.attrs;
    6861                 :   274434303 :           if (first_non_attr_kind == cdk_attrs)
    6862                 :   214815424 :             first_non_attr_kind = decl->kind;
    6863                 :             :           decl = 0;
    6864                 :             :           break;
    6865                 :             : 
    6866                 :           0 :         default:
    6867                 :           0 :           gcc_unreachable ();
    6868                 :             :         }
    6869                 :   274434303 :     if (name == NULL_TREE)
    6870                 :             :       {
    6871                 :   109283240 :         gcc_assert (decl_context == PARM
    6872                 :             :                     || decl_context == TYPENAME
    6873                 :             :                     || (decl_context == FIELD
    6874                 :             :                         && declarator->kind == cdk_id));
    6875                 :   109283240 :         gcc_assert (!initialized);
    6876                 :             :       }
    6877                 :             :   }
    6878                 :             : 
    6879                 :             :   /* An enum type specifier (": specifier-qualifier-list") may only be
    6880                 :             :      specified when the enum is being defined or in an empty
    6881                 :             :      declaration of the form "enum identifier enum-type-specifier;".
    6882                 :             :      Except for the case of an empty declaration that has additional
    6883                 :             :      declaration specifiers, all invalid contexts (declarations that
    6884                 :             :      aren't empty, type names, parameter declarations, member
    6885                 :             :      declarations) pass through grokdeclarator.  */
    6886                 :   274434303 :   if (declspecs->enum_type_specifier_ref_p)
    6887                 :           6 :     error_at (loc, "%<enum%> underlying type may not be specified here");
    6888                 :             : 
    6889                 :             :   /* A function definition's declarator must have the form of
    6890                 :             :      a function declarator.  */
    6891                 :             : 
    6892                 :   274434303 :   if (funcdef_flag && !funcdef_syntax)
    6893                 :             :     return NULL_TREE;
    6894                 :             : 
    6895                 :             :   /* If this looks like a function definition, make it one,
    6896                 :             :      even if it occurs where parms are expected.
    6897                 :             :      Then store_parm_decls will reject it and not use it as a parm.  */
    6898                 :   274434272 :   if (decl_context == NORMAL && !funcdef_flag && current_scope->parm_flag)
    6899                 :       22709 :     decl_context = PARM;
    6900                 :             : 
    6901                 :   274434272 :   if (deprecated_state != UNAVAILABLE_DEPRECATED_SUPPRESS)
    6902                 :             :     {
    6903                 :   274434248 :       if (declspecs->unavailable_p)
    6904                 :          28 :         error_unavailable_use (declspecs->type, declspecs->decl_attr);
    6905                 :   274434220 :       else if (declspecs->deprecated_p
    6906                 :          46 :                 && deprecated_state != DEPRECATED_SUPPRESS)
    6907                 :          38 :         warn_deprecated_use (declspecs->type, declspecs->decl_attr);
    6908                 :             :     }
    6909                 :             : 
    6910                 :   274434272 :   if ((decl_context == NORMAL || decl_context == FIELD)
    6911                 :    60730680 :       && current_scope == file_scope
    6912                 :   327342579 :       && c_type_variably_modified_p (type))
    6913                 :             :     {
    6914                 :           3 :       if (name)
    6915                 :           3 :         error_at (loc, "variably modified %qE at file scope", name);
    6916                 :             :       else
    6917                 :           0 :         error_at (loc, "variably modified field at file scope");
    6918                 :           3 :       type = integer_type_node;
    6919                 :             :     }
    6920                 :             : 
    6921                 :   274434272 :   size_varies = C_TYPE_VARIABLE_SIZE (type) != 0;
    6922                 :             : 
    6923                 :             :   /* Diagnose defaulting to "int".  */
    6924                 :             : 
    6925                 :   274434272 :   if (declspecs->default_int_p)
    6926                 :             :     {
    6927                 :             :       /* Issue a warning if this is an ISO C 99 program or if
    6928                 :             :          -Wreturn-type and this is a function, or if -Wimplicit;
    6929                 :             :          prefer the former warning since it is more explicit.  */
    6930                 :        9758 :       if ((warn_implicit_int || warn_return_type > 0 || flag_isoc99)
    6931                 :        1225 :           && funcdef_flag)
    6932                 :         702 :         warn_about_return_type = 1;
    6933                 :             :       else
    6934                 :             :         {
    6935                 :        9056 :           if (name)
    6936                 :        9046 :             permerror_opt (loc, OPT_Wimplicit_int,
    6937                 :             :                            "type defaults to %<int%> in declaration "
    6938                 :             :                            "of %qE", name);
    6939                 :             :           else
    6940                 :          10 :             permerror_opt (loc, OPT_Wimplicit_int,
    6941                 :             :                            "type defaults to %<int%> in type name");
    6942                 :             :         }
    6943                 :             :     }
    6944                 :             : 
    6945                 :             :   /* Adjust the type if a bit-field is being declared,
    6946                 :             :      -funsigned-bitfields applied and the type is not explicitly
    6947                 :             :      "signed".  */
    6948                 :   274434272 :   if (bitfield && !flag_signed_bitfields && !declspecs->explicit_signed_p
    6949                 :          40 :       && TREE_CODE (type) == INTEGER_TYPE)
    6950                 :          38 :     type = c_common_unsigned_type (type);
    6951                 :             : 
    6952                 :             :   /* Figure out the type qualifiers for the declaration.  There are
    6953                 :             :      two ways a declaration can become qualified.  One is something
    6954                 :             :      like `const int i' where the `const' is explicit.  Another is
    6955                 :             :      something like `typedef const int CI; CI i' where the type of the
    6956                 :             :      declaration contains the `const'.  A third possibility is that
    6957                 :             :      there is a type qualifier on the element type of a typedefed
    6958                 :             :      array type, in which case we should extract that qualifier so
    6959                 :             :      that c_apply_type_quals_to_decl receives the full list of
    6960                 :             :      qualifiers to work with (C90 is not entirely clear about whether
    6961                 :             :      duplicate qualifiers should be diagnosed in this case, but it
    6962                 :             :      seems most appropriate to do so).  */
    6963                 :   274434272 :   element_type = strip_array_types (type);
    6964                 :   274434272 :   constp = declspecs->const_p + TYPE_READONLY (element_type);
    6965                 :   274434272 :   restrictp = declspecs->restrict_p + TYPE_RESTRICT (element_type);
    6966                 :   274434272 :   volatilep = declspecs->volatile_p + TYPE_VOLATILE (element_type);
    6967                 :   274434272 :   atomicp = declspecs->atomic_p + TYPE_ATOMIC (element_type);
    6968                 :   274434272 :   as1 = declspecs->address_space;
    6969                 :   274434272 :   as2 = TYPE_ADDR_SPACE (element_type);
    6970                 :   274434272 :   address_space = ADDR_SPACE_GENERIC_P (as1)? as2 : as1;
    6971                 :             : 
    6972                 :   274434272 :   if (constp > 1)
    6973                 :          25 :     pedwarn_c90 (loc, OPT_Wpedantic, "duplicate %<const%>");
    6974                 :   274434272 :   if (restrictp > 1)
    6975                 :           6 :     pedwarn_c90 (loc, OPT_Wpedantic, "duplicate %<restrict%>");
    6976                 :   274434272 :   if (volatilep > 1)
    6977                 :          15 :     pedwarn_c90 (loc, OPT_Wpedantic, "duplicate %<volatile%>");
    6978                 :   274434272 :   if (atomicp > 1)
    6979                 :           9 :     pedwarn_c90 (loc, OPT_Wpedantic, "duplicate %<_Atomic%>");
    6980                 :             : 
    6981                 :   274434272 :   if (!ADDR_SPACE_GENERIC_P (as1) && !ADDR_SPACE_GENERIC_P (as2) && as1 != as2)
    6982                 :           0 :     error_at (loc, "conflicting named address spaces (%s vs %s)",
    6983                 :             :               c_addr_space_name (as1), c_addr_space_name (as2));
    6984                 :             : 
    6985                 :   274434272 :   if ((TREE_CODE (type) == ARRAY_TYPE
    6986                 :   274265854 :        || first_non_attr_kind == cdk_array)
    6987                 :   275431413 :       && TYPE_QUALS (element_type))
    6988                 :             :     {
    6989                 :          44 :       orig_qual_type = type;
    6990                 :          44 :       type = TYPE_MAIN_VARIANT (type);
    6991                 :             :     }
    6992                 :   274434272 :   type_quals = ((constp ? TYPE_QUAL_CONST : 0)
    6993                 :   274434272 :                 | (restrictp ? TYPE_QUAL_RESTRICT : 0)
    6994                 :   274434272 :                 | (volatilep ? TYPE_QUAL_VOLATILE : 0)
    6995                 :   274434272 :                 | (atomicp ? TYPE_QUAL_ATOMIC : 0)
    6996                 :   274434272 :                 | ENCODE_QUAL_ADDR_SPACE (address_space));
    6997                 :   274434272 :   if (type_quals != TYPE_QUALS (element_type))
    6998                 :    11114460 :     orig_qual_type = NULL_TREE;
    6999                 :             : 
    7000                 :             :   /* Applying the _Atomic qualifier to an array type (through the use
    7001                 :             :      of typedefs or typeof) must be detected here.  If the qualifier
    7002                 :             :      is introduced later, any appearance of applying it to an array is
    7003                 :             :      actually applying it to an element of that array.  */
    7004                 :   274434272 :   if (declspecs->atomic_p && TREE_CODE (type) == ARRAY_TYPE)
    7005                 :           6 :     error_at (loc, "%<_Atomic%>-qualified array type");
    7006                 :             : 
    7007                 :             :   /* Warn about storage classes that are invalid for certain
    7008                 :             :      kinds of declarations (parameters, typenames, etc.).  */
    7009                 :             : 
    7010                 :   274434272 :   if (funcdef_flag
    7011                 :    31761907 :       && (threadp
    7012                 :             :           || constexprp
    7013                 :    31761905 :           || storage_class == csc_auto
    7014                 :    31761905 :           || storage_class == csc_register
    7015                 :    31761862 :           || storage_class == csc_typedef))
    7016                 :             :     {
    7017                 :          45 :       if (storage_class == csc_auto)
    7018                 :          40 :         pedwarn (loc,
    7019                 :          40 :                  (current_scope == file_scope) ? 0 : OPT_Wpedantic,
    7020                 :             :                  "function definition declared %<auto%>");
    7021                 :          48 :       if (storage_class == csc_register)
    7022                 :           3 :         error_at (loc, "function definition declared %<register%>");
    7023                 :          48 :       if (storage_class == csc_typedef)
    7024                 :           3 :         error_at (loc, "function definition declared %<typedef%>");
    7025                 :          48 :       if (threadp)
    7026                 :           2 :         error_at (loc, "function definition declared %qs",
    7027                 :           2 :                   declspecs->thread_gnu_p ? "__thread" : "_Thread_local");
    7028                 :          48 :       threadp = false;
    7029                 :             :       /* The parser ensures a constexpr function definition never
    7030                 :             :          reaches here.  */
    7031                 :          48 :       gcc_assert (!constexprp);
    7032                 :          48 :       if (storage_class == csc_auto
    7033                 :          48 :           || storage_class == csc_register
    7034                 :             :           || storage_class == csc_typedef)
    7035                 :          53 :         storage_class = csc_none;
    7036                 :             :     }
    7037                 :   274434224 :   else if (decl_context != NORMAL && (storage_class != csc_none
    7038                 :   217553739 :                                       || threadp
    7039                 :   217553153 :                                       || constexprp
    7040                 :   217553151 :                                       || declspecs->c23_auto_p))
    7041                 :             :     {
    7042                 :         590 :       if (decl_context == PARM
    7043                 :         590 :           && storage_class == csc_register
    7044                 :         571 :           && !constexprp
    7045                 :         569 :           && !declspecs->c23_auto_p)
    7046                 :             :         ;
    7047                 :             :       else
    7048                 :             :         {
    7049                 :          21 :           switch (decl_context)
    7050                 :             :             {
    7051                 :           0 :             case FIELD:
    7052                 :           0 :               if (name)
    7053                 :           0 :                 error_at (loc, "storage class specified for structure "
    7054                 :             :                           "field %qE", name);
    7055                 :             :               else
    7056                 :           0 :                 error_at (loc, "storage class specified for structure field");
    7057                 :             :               break;
    7058                 :          21 :             case PARM:
    7059                 :          21 :               if (name)
    7060                 :           7 :                 error_at (loc, "storage class specified for parameter %qE",
    7061                 :             :                           name);
    7062                 :             :               else
    7063                 :          14 :                 error_at (loc, "storage class specified for unnamed parameter");
    7064                 :             :               break;
    7065                 :           0 :             default:
    7066                 :           0 :               error_at (loc, "storage class specified for typename");
    7067                 :           0 :               break;
    7068                 :             :             }
    7069                 :   274434272 :           storage_class = csc_none;
    7070                 :   274434272 :           threadp = false;
    7071                 :   274434272 :           constexprp = false;
    7072                 :             :         }
    7073                 :             :     }
    7074                 :   274433634 :   else if (storage_class == csc_extern
    7075                 :   274433634 :            && initialized
    7076                 :    30954788 :            && !funcdef_flag)
    7077                 :             :     {
    7078                 :             :       /* 'extern' with initialization is invalid if not at file scope.  */
    7079                 :          24 :        if (current_scope == file_scope)
    7080                 :             :          {
    7081                 :             :            /* It is fine to have 'extern const' when compiling at C
    7082                 :             :               and C++ intersection.  */
    7083                 :          19 :            if (!(warn_cxx_compat && constp))
    7084                 :          18 :              warning_at (loc, 0, "%qE initialized and declared %<extern%>",
    7085                 :             :                          name);
    7086                 :             :          }
    7087                 :             :       else
    7088                 :           5 :         error_at (loc, "%qE has both %<extern%> and initializer", name);
    7089                 :             :     }
    7090                 :   274433610 :   else if (current_scope == file_scope)
    7091                 :             :     {
    7092                 :    53787118 :       if (storage_class == csc_auto)
    7093                 :           7 :         error_at (loc, "file-scope declaration of %qE specifies %<auto%>",
    7094                 :             :                   name);
    7095                 :    53787118 :       if (pedantic && storage_class == csc_register)
    7096                 :           4 :         pedwarn (input_location, OPT_Wpedantic,
    7097                 :             :                  "file-scope declaration of %qE specifies %<register%>", name);
    7098                 :             :     }
    7099                 :             :   else
    7100                 :             :     {
    7101                 :   220646492 :       if (storage_class == csc_extern && funcdef_flag)
    7102                 :           3 :         error_at (loc, "nested function %qE declared %<extern%>", name);
    7103                 :   220646489 :       else if (threadp && storage_class == csc_none)
    7104                 :             :         {
    7105                 :           4 :           error_at (loc, "function-scope %qE implicitly auto and declared "
    7106                 :             :                     "%qs", name,
    7107                 :           2 :                     declspecs->thread_gnu_p ? "__thread" : "_Thread_local");
    7108                 :           2 :           threadp = false;
    7109                 :             :         }
    7110                 :             :     }
    7111                 :             : 
    7112                 :             :   /* Now figure out the structure of the declarator proper.
    7113                 :             :      Descend through it, creating more complex types, until we reach
    7114                 :             :      the declared identifier (or NULL_TREE, in an absolute declarator).
    7115                 :             :      At each stage we maintain an unqualified version of the type
    7116                 :             :      together with any qualifiers that should be applied to it with
    7117                 :             :      c_build_qualified_type; this way, array types including
    7118                 :             :      multidimensional array types are first built up in unqualified
    7119                 :             :      form and then the qualified form is created with
    7120                 :             :      TYPE_MAIN_VARIANT pointing to the unqualified form.  */
    7121                 :             : 
    7122                 :   335944240 :   while (declarator && declarator->kind != cdk_id)
    7123                 :             :     {
    7124                 :    61509968 :       if (type == error_mark_node)
    7125                 :             :         {
    7126                 :          38 :           declarator = declarator->declarator;
    7127                 :          38 :           continue;
    7128                 :             :         }
    7129                 :             : 
    7130                 :             :       /* Each level of DECLARATOR is either a cdk_array (for ...[..]),
    7131                 :             :          a cdk_pointer (for *...),
    7132                 :             :          a cdk_function (for ...(...)),
    7133                 :             :          a cdk_attrs (for nested attributes),
    7134                 :             :          or a cdk_id (for the name being declared
    7135                 :             :          or the place in an absolute declarator
    7136                 :             :          where the name was omitted).
    7137                 :             :          For the last case, we have just exited the loop.
    7138                 :             : 
    7139                 :             :          At this point, TYPE is the type of elements of an array,
    7140                 :             :          or for a function to return, or for a pointer to point to.
    7141                 :             :          After this sequence of ifs, TYPE is the type of the
    7142                 :             :          array or function or pointer, and DECLARATOR has had its
    7143                 :             :          outermost layer removed.  */
    7144                 :             : 
    7145                 :    61509930 :       if (array_ptr_quals != TYPE_UNQUALIFIED
    7146                 :    61509930 :           || array_ptr_attrs != NULL_TREE
    7147                 :    61509930 :           || array_parm_static)
    7148                 :             :         {
    7149                 :             :           /* Only the innermost declarator (making a parameter be of
    7150                 :             :              array type which is converted to pointer type)
    7151                 :             :              may have static or type qualifiers.  */
    7152                 :           1 :           error_at (loc, "static or type qualifiers in non-parameter array declarator");
    7153                 :           1 :           array_ptr_quals = TYPE_UNQUALIFIED;
    7154                 :           1 :           array_ptr_attrs = NULL_TREE;
    7155                 :           1 :           array_parm_static = false;
    7156                 :             :         }
    7157                 :             : 
    7158                 :    61509930 :       bool varmod = C_TYPE_VARIABLY_MODIFIED (type);
    7159                 :             : 
    7160                 :    61509930 :       switch (declarator->kind)
    7161                 :             :         {
    7162                 :        6528 :         case cdk_attrs:
    7163                 :        6528 :           {
    7164                 :             :             /* A declarator with embedded attributes.  */
    7165                 :        6528 :             tree attrs = declarator->u.attrs;
    7166                 :        6528 :             const struct c_declarator *inner_decl;
    7167                 :        6528 :             int attr_flags = 0;
    7168                 :        6528 :             declarator = declarator->declarator;
    7169                 :             :             /* Standard attribute syntax precisely defines what entity
    7170                 :             :                an attribute in each position appertains to, so only
    7171                 :             :                apply laxity about positioning to GNU attribute syntax.
    7172                 :             :                Standard attributes applied to a function or array
    7173                 :             :                declarator apply exactly to that type; standard
    7174                 :             :                attributes applied to the identifier apply to the
    7175                 :             :                declaration rather than to the type, and are specified
    7176                 :             :                using a cdk_id declarator rather than using
    7177                 :             :                cdk_attrs.  */
    7178                 :        6528 :             inner_decl = declarator;
    7179                 :        6528 :             while (inner_decl->kind == cdk_attrs)
    7180                 :           0 :               inner_decl = inner_decl->declarator;
    7181                 :        6528 :             if (!cxx11_attribute_p (attrs))
    7182                 :             :               {
    7183                 :        6504 :                 if (inner_decl->kind == cdk_id)
    7184                 :             :                   attr_flags |= (int) ATTR_FLAG_DECL_NEXT;
    7185                 :             :                 else if (inner_decl->kind == cdk_function)
    7186                 :             :                   attr_flags |= (int) ATTR_FLAG_FUNCTION_NEXT;
    7187                 :             :                 else if (inner_decl->kind == cdk_array)
    7188                 :        6528 :                   attr_flags |= (int) ATTR_FLAG_ARRAY_NEXT;
    7189                 :             :               }
    7190                 :        6528 :             attrs = c_warn_type_attributes (attrs);
    7191                 :        6528 :             returned_attrs = decl_attributes (&type,
    7192                 :             :                                               chainon (returned_attrs, attrs),
    7193                 :             :                                               attr_flags);
    7194                 :        6528 :             break;
    7195                 :             :           }
    7196                 :     1062894 :         case cdk_array:
    7197                 :     1062894 :           {
    7198                 :     1062894 :             tree itype = NULL_TREE;
    7199                 :     1062894 :             tree size = declarator->u.array.dimen;
    7200                 :             :             /* The index is a signed object `sizetype' bits wide.  */
    7201                 :     1062894 :             tree index_type = c_common_signed_type (sizetype);
    7202                 :             : 
    7203                 :     1062894 :             array_ptr_quals = declarator->u.array.quals;
    7204                 :     1062894 :             array_ptr_attrs = declarator->u.array.attrs;
    7205                 :     1062894 :             array_parm_static = declarator->u.array.static_p;
    7206                 :     1062894 :             array_parm_vla_unspec_p = declarator->u.array.vla_unspec_p;
    7207                 :             : 
    7208                 :     1062894 :             declarator = declarator->declarator;
    7209                 :             : 
    7210                 :             :             /* Check for some types that there cannot be arrays of.  */
    7211                 :             : 
    7212                 :     1062894 :             if (VOID_TYPE_P (type))
    7213                 :             :               {
    7214                 :          11 :                 if (name)
    7215                 :           9 :                   error_at (loc, "declaration of %qE as array of voids", name);
    7216                 :             :                 else
    7217                 :           2 :                   error_at (loc, "declaration of type name as array of voids");
    7218                 :          11 :                 type = error_mark_node;
    7219                 :             :               }
    7220                 :             : 
    7221                 :     1062894 :             if (TREE_CODE (type) == FUNCTION_TYPE)
    7222                 :             :               {
    7223                 :           3 :                 if (name)
    7224                 :           2 :                   error_at (loc, "declaration of %qE as array of functions",
    7225                 :             :                             name);
    7226                 :             :                 else
    7227                 :           1 :                   error_at (loc, "declaration of type name as array of "
    7228                 :             :                             "functions");
    7229                 :           3 :                 type = error_mark_node;
    7230                 :             :               }
    7231                 :             : 
    7232                 :       21654 :             if (pedantic && !in_system_header_at (input_location)
    7233                 :     1077389 :                 && flexible_array_type_p (type))
    7234                 :          20 :               pedwarn (loc, OPT_Wpedantic,
    7235                 :             :                        "invalid use of structure with flexible array member");
    7236                 :             : 
    7237                 :     1062894 :             if (size == error_mark_node)
    7238                 :         114 :               type = error_mark_node;
    7239                 :             : 
    7240                 :     1062894 :             if (type == error_mark_node)
    7241                 :         128 :               continue;
    7242                 :             : 
    7243                 :     1062766 :             if (!verify_type_context (loc, TCTX_ARRAY_ELEMENT, type))
    7244                 :             :               {
    7245                 :           0 :                 type = error_mark_node;
    7246                 :           0 :                 continue;
    7247                 :             :               }
    7248                 :             : 
    7249                 :             :             /* If size was specified, set ITYPE to a range-type for
    7250                 :             :                that size.  Otherwise, ITYPE remains null.  finish_decl
    7251                 :             :                may figure it out from an initial value.  */
    7252                 :             : 
    7253                 :     1062766 :             if (size)
    7254                 :             :               {
    7255                 :      920628 :                 bool size_maybe_const = true;
    7256                 :      920628 :                 bool size_int_const = (TREE_CODE (size) == INTEGER_CST
    7257                 :      920628 :                                        && !TREE_OVERFLOW (size));
    7258                 :      920628 :                 bool this_size_varies = false;
    7259                 :             : 
    7260                 :             :                 /* Strip NON_LVALUE_EXPRs since we aren't using as an
    7261                 :             :                    lvalue.  */
    7262                 :      920637 :                 STRIP_TYPE_NOPS (size);
    7263                 :             : 
    7264                 :      920628 :                 if (!INTEGRAL_TYPE_P (TREE_TYPE (size)))
    7265                 :             :                   {
    7266                 :          16 :                     if (name)
    7267                 :          14 :                       error_at (loc, "size of array %qE has non-integer type",
    7268                 :             :                                 name);
    7269                 :             :                     else
    7270                 :           2 :                       error_at (loc,
    7271                 :             :                                 "size of unnamed array has non-integer type");
    7272                 :          16 :                     size = integer_one_node;
    7273                 :          16 :                     size_int_const = true;
    7274                 :             :                   }
    7275                 :             :                 /* This can happen with enum forward declaration.  */
    7276                 :      920612 :                 else if (!COMPLETE_TYPE_P (TREE_TYPE (size)))
    7277                 :             :                   {
    7278                 :           0 :                     if (name)
    7279                 :           0 :                       error_at (loc, "size of array %qE has incomplete type",
    7280                 :             :                                 name);
    7281                 :             :                     else
    7282                 :           0 :                       error_at (loc, "size of unnamed array has incomplete "
    7283                 :             :                                 "type");
    7284                 :           0 :                     size = integer_one_node;
    7285                 :           0 :                     size_int_const = true;
    7286                 :             :                   }
    7287                 :             : 
    7288                 :      920628 :                 size = c_fully_fold (size, false, &size_maybe_const);
    7289                 :             : 
    7290                 :      920628 :                 if (pedantic && size_maybe_const && integer_zerop (size))
    7291                 :             :                   {
    7292                 :           3 :                     if (name)
    7293                 :           3 :                       pedwarn (loc, OPT_Wpedantic,
    7294                 :             :                                "ISO C forbids zero-size array %qE", name);
    7295                 :             :                     else
    7296                 :           0 :                       pedwarn (loc, OPT_Wpedantic,
    7297                 :             :                                "ISO C forbids zero-size array");
    7298                 :             :                   }
    7299                 :             : 
    7300                 :      920628 :                 if (TREE_CODE (size) == INTEGER_CST && size_maybe_const)
    7301                 :             :                   {
    7302                 :      898615 :                     constant_expression_warning (size);
    7303                 :      898615 :                     if (tree_int_cst_sgn (size) < 0)
    7304                 :             :                       {
    7305                 :         772 :                         if (name)
    7306                 :         769 :                           error_at (loc, "size of array %qE is negative", name);
    7307                 :             :                         else
    7308                 :           3 :                           error_at (loc, "size of unnamed array is negative");
    7309                 :         772 :                         size = integer_one_node;
    7310                 :         772 :                         size_int_const = true;
    7311                 :             :                       }
    7312                 :             :                     /* Handle a size folded to an integer constant but
    7313                 :             :                        not an integer constant expression.  */
    7314                 :      898615 :                     if (!size_int_const)
    7315                 :             :                       {
    7316                 :             :                         /* If this is a file scope declaration of an
    7317                 :             :                            ordinary identifier, this is invalid code;
    7318                 :             :                            diagnosing it here and not subsequently
    7319                 :             :                            treating the type as variable-length avoids
    7320                 :             :                            more confusing diagnostics later.  */
    7321                 :         145 :                         if ((decl_context == NORMAL || decl_context == FIELD)
    7322                 :         134 :                             && current_scope == file_scope)
    7323                 :          14 :                           pedwarn (input_location, 0,
    7324                 :             :                                    "variably modified %qE at file scope",
    7325                 :             :                                    name);
    7326                 :             :                         else
    7327                 :             :                           this_size_varies = size_varies = true;
    7328                 :         145 :                         warn_variable_length_array (name, size);
    7329                 :             :                       }
    7330                 :             :                   }
    7331                 :       22013 :                 else if ((decl_context == NORMAL || decl_context == FIELD)
    7332                 :       13083 :                          && current_scope == file_scope)
    7333                 :             :                   {
    7334                 :          21 :                     error_at (loc, "variably modified %qE at file scope", name);
    7335                 :          21 :                     size = integer_one_node;
    7336                 :             :                   }
    7337                 :             :                 else
    7338                 :             :                   {
    7339                 :             :                     /* Make sure the array size remains visibly
    7340                 :             :                        nonconstant even if it is (eg) a const variable
    7341                 :             :                        with known value.  */
    7342                 :       21992 :                     this_size_varies = size_varies = true;
    7343                 :       21992 :                     warn_variable_length_array (name, size);
    7344                 :       21992 :                     if (sanitize_flags_p (SANITIZE_VLA)
    7345                 :         178 :                         && current_function_decl != NULL_TREE
    7346                 :       22152 :                         && decl_context == NORMAL)
    7347                 :             :                       {
    7348                 :             :                         /* Evaluate the array size only once.  */
    7349                 :         152 :                         size = save_expr (size);
    7350                 :         152 :                         size = c_fully_fold (size, false, NULL);
    7351                 :         152 :                         size = fold_build2 (COMPOUND_EXPR, TREE_TYPE (size),
    7352                 :             :                                             ubsan_instrument_vla (loc, size),
    7353                 :             :                                             size);
    7354                 :             :                       }
    7355                 :             :                   }
    7356                 :             : 
    7357                 :      920628 :                 if (integer_zerop (size) && !this_size_varies)
    7358                 :             :                   {
    7359                 :             :                     /* A zero-length array cannot be represented with
    7360                 :             :                        an unsigned index type, which is what we'll
    7361                 :             :                        get with build_index_type.  Create an
    7362                 :             :                        open-ended range instead.  */
    7363                 :        2519 :                     itype = build_range_type (sizetype, size, NULL_TREE);
    7364                 :             :                   }
    7365                 :             :                 else
    7366                 :             :                   {
    7367                 :             :                     /* Arrange for the SAVE_EXPR on the inside of the
    7368                 :             :                        MINUS_EXPR, which allows the -1 to get folded
    7369                 :             :                        with the +1 that happens when building TYPE_SIZE.  */
    7370                 :      918109 :                     if (size_varies)
    7371                 :       22468 :                       size = save_expr (size);
    7372                 :      918109 :                     if (this_size_varies && TREE_CODE (size) == INTEGER_CST)
    7373                 :         131 :                       size = build2 (COMPOUND_EXPR, TREE_TYPE (size),
    7374                 :             :                                      integer_zero_node, size);
    7375                 :             : 
    7376                 :             :                     /* Compute the maximum valid index, that is, size
    7377                 :             :                        - 1.  Do the calculation in index_type, so that
    7378                 :             :                        if it is a variable the computations will be
    7379                 :             :                        done in the proper mode.  */
    7380                 :      918109 :                     itype = fold_build2_loc (loc, MINUS_EXPR, index_type,
    7381                 :             :                                              convert (index_type, size),
    7382                 :             :                                              convert (index_type,
    7383                 :             :                                                       size_one_node));
    7384                 :             : 
    7385                 :             :                     /* The above overflows when size does not fit
    7386                 :             :                        in index_type.
    7387                 :             :                        ???  While a size of INT_MAX+1 technically shouldn't
    7388                 :             :                        cause an overflow (because we subtract 1), handling
    7389                 :             :                        this case seems like an unnecessary complication.  */
    7390                 :      918109 :                     if (TREE_CODE (size) == INTEGER_CST
    7391                 :      895986 :                         && !int_fits_type_p (size, index_type))
    7392                 :             :                       {
    7393                 :           6 :                         if (name)
    7394                 :           5 :                           error_at (loc, "size of array %qE is too large",
    7395                 :             :                                     name);
    7396                 :             :                         else
    7397                 :           1 :                           error_at (loc, "size of unnamed array is too large");
    7398                 :           6 :                         type = error_mark_node;
    7399                 :           6 :                         continue;
    7400                 :             :                       }
    7401                 :             : 
    7402                 :      918103 :                     itype = build_index_type (itype);
    7403                 :             :                   }
    7404                 :      920622 :                 if (this_size_varies)
    7405                 :             :                   {
    7406                 :       22123 :                     if (TREE_SIDE_EFFECTS (size))
    7407                 :             :                       {
    7408                 :       21846 :                         if (*expr)
    7409                 :        8148 :                           *expr = build2 (COMPOUND_EXPR, TREE_TYPE (size),
    7410                 :             :                                           *expr, size);
    7411                 :             :                         else
    7412                 :       13698 :                           *expr = size;
    7413                 :             :                       }
    7414                 :       22123 :                     *expr_const_operands &= size_maybe_const;
    7415                 :             :                   }
    7416                 :             :               }
    7417                 :      142138 :             else if (decl_context == FIELD)
    7418                 :             :               {
    7419                 :       59677 :                 bool flexible_array_member = false;
    7420                 :       59677 :                 if (array_parm_vla_unspec_p)
    7421                 :             :                   /* Field names can in fact have function prototype
    7422                 :             :                      scope so [*] is disallowed here through making
    7423                 :             :                      the field variably modified, not through being
    7424                 :             :                      something other than a declaration with function
    7425                 :             :                      prototype scope.  */
    7426                 :             :                   size_varies = true;
    7427                 :             :                 else
    7428                 :             :                   {
    7429                 :             :                     const struct c_declarator *t = declarator;
    7430                 :       59675 :                     while (t->kind == cdk_attrs)
    7431                 :           0 :                       t = t->declarator;
    7432                 :       59675 :                     flexible_array_member = (t->kind == cdk_id);
    7433                 :             :                   }
    7434                 :       59675 :                 if (flexible_array_member
    7435                 :       59675 :                     && !in_system_header_at (input_location))
    7436                 :       58651 :                   pedwarn_c90 (loc, OPT_Wpedantic, "ISO C90 does not "
    7437                 :             :                                "support flexible array members");
    7438                 :             : 
    7439                 :             :                 /* ISO C99 Flexible array members are effectively
    7440                 :             :                    identical to GCC's zero-length array extension.  */
    7441                 :       59677 :                 if (flexible_array_member || array_parm_vla_unspec_p)
    7442                 :       59657 :                   itype = build_range_type (sizetype, size_zero_node,
    7443                 :             :                                             NULL_TREE);
    7444                 :             :               }
    7445                 :       82461 :             else if (decl_context == PARM)
    7446                 :             :               {
    7447                 :       62611 :                 if (array_parm_vla_unspec_p)
    7448                 :             :                   {
    7449                 :         125 :                     itype = build_range_type (sizetype, size_zero_node, NULL_TREE);
    7450                 :         125 :                     size_varies = true;
    7451                 :             :                   }
    7452                 :             :               }
    7453                 :       19850 :             else if (decl_context == TYPENAME)
    7454                 :             :               {
    7455                 :         316 :                 if (array_parm_vla_unspec_p)
    7456                 :             :                   {
    7457                 :             :                     /* C99 6.7.5.2p4 */
    7458                 :           5 :                     warning (0, "%<[*]%> not in a declaration");
    7459                 :             :                     /* We use this to avoid messing up with incomplete
    7460                 :             :                        array types of the same type, that would
    7461                 :             :                        otherwise be modified below.  */
    7462                 :           5 :                     itype = build_range_type (sizetype, size_zero_node,
    7463                 :             :                                               NULL_TREE);
    7464                 :           5 :                     size_varies = true;
    7465                 :             :                   }
    7466                 :             :               }
    7467                 :             : 
    7468                 :             :             /* Complain about arrays of incomplete types.  */
    7469                 :     1062760 :             if (!COMPLETE_TYPE_P (type))
    7470                 :             :               {
    7471                 :          57 :                 auto_diagnostic_group d;
    7472                 :          57 :                 error_at (loc, "array type has incomplete element type %qT",
    7473                 :             :                           type);
    7474                 :             :                 /* See if we can be more helpful.  */
    7475                 :          57 :                 if (TREE_CODE (type) == ARRAY_TYPE)
    7476                 :             :                   {
    7477                 :          29 :                     if (name)
    7478                 :          24 :                       inform (loc, "declaration of %qE as multidimensional "
    7479                 :             :                               "array must have bounds for all dimensions "
    7480                 :             :                               "except the first", name);
    7481                 :             :                     else
    7482                 :           5 :                       inform (loc, "declaration of multidimensional array "
    7483                 :             :                               "must have bounds for all dimensions except "
    7484                 :             :                               "the first");
    7485                 :             :                   }
    7486                 :          57 :                 type = error_mark_node;
    7487                 :          57 :               }
    7488                 :             :             else
    7489                 :             :             /* When itype is NULL, a shared incomplete array type is
    7490                 :             :                returned for all array of a given type.  Elsewhere we
    7491                 :             :                make sure we don't complete that type before copying
    7492                 :             :                it, but here we want to make sure we don't ever
    7493                 :             :                modify the shared type, so we gcc_assert (itype)
    7494                 :             :                below.  */
    7495                 :             :               {
    7496                 :     1062703 :                 addr_space_t as = DECODE_QUAL_ADDR_SPACE (type_quals);
    7497                 :     1062703 :                 if (!ADDR_SPACE_GENERIC_P (as) && as != TYPE_ADDR_SPACE (type))
    7498                 :           0 :                   type = build_qualified_type (type,
    7499                 :             :                                                ENCODE_QUAL_ADDR_SPACE (as));
    7500                 :             : 
    7501                 :     1062703 :                 type = build_array_type (type, itype);
    7502                 :             :               }
    7503                 :             : 
    7504                 :     1062760 :             if (type != error_mark_node)
    7505                 :             :               {
    7506                 :     1062703 :                 if (size_varies)
    7507                 :             :                   {
    7508                 :             :                     /* It is ok to modify type here even if itype is
    7509                 :             :                        NULL: if size_varies, we're in a
    7510                 :             :                        multi-dimensional array and the inner type has
    7511                 :             :                        variable size, so the enclosing shared array type
    7512                 :             :                        must too.  */
    7513                 :       22740 :                     if (size && TREE_CODE (size) == INTEGER_CST)
    7514                 :         361 :                       type = build_distinct_type_copy (TYPE_MAIN_VARIANT (type));
    7515                 :       22740 :                     C_TYPE_VARIABLE_SIZE (type) = 1;
    7516                 :             :                   }
    7517                 :             : 
    7518                 :             :                 /* The GCC extension for zero-length arrays differs from
    7519                 :             :                    ISO flexible array members in that sizeof yields
    7520                 :             :                    zero.  */
    7521                 :     1062703 :                 if (size && integer_zerop (size))
    7522                 :             :                   {
    7523                 :        2512 :                     gcc_assert (itype);
    7524                 :        2512 :                     type = build_distinct_type_copy (TYPE_MAIN_VARIANT (type));
    7525                 :        2512 :                     TYPE_SIZE (type) = bitsize_zero_node;
    7526                 :        2512 :                     TYPE_SIZE_UNIT (type) = size_zero_node;
    7527                 :        2512 :                     SET_TYPE_STRUCTURAL_EQUALITY (type);
    7528                 :             :                   }
    7529                 :     1062703 :                 if (array_parm_vla_unspec_p)
    7530                 :             :                   {
    7531                 :         132 :                     gcc_assert (itype);
    7532                 :             :                     /* The type is complete.  C99 6.7.5.2p4  */
    7533                 :         132 :                     type = build_distinct_type_copy (TYPE_MAIN_VARIANT (type));
    7534                 :         132 :                     TYPE_SIZE (type) = bitsize_zero_node;
    7535                 :         132 :                     TYPE_SIZE_UNIT (type) = size_zero_node;
    7536                 :         132 :                     SET_TYPE_STRUCTURAL_EQUALITY (type);
    7537                 :             :                   }
    7538                 :             : 
    7539                 :     1062703 :                 if (!valid_array_size_p (loc, type, name))
    7540                 :          33 :                   type = error_mark_node;
    7541                 :             :               }
    7542                 :             : 
    7543                 :     1062760 :             if (decl_context != PARM
    7544                 :      758902 :                 && (array_ptr_quals != TYPE_UNQUALIFIED
    7545                 :      758902 :                     || array_ptr_attrs != NULL_TREE
    7546                 :      758901 :                     || array_parm_static))
    7547                 :             :               {
    7548                 :           2 :                 error_at (loc, "static or type qualifiers in non-parameter "
    7549                 :             :                           "array declarator");
    7550                 :           2 :                 array_ptr_quals = TYPE_UNQUALIFIED;
    7551                 :           2 :                 array_ptr_attrs = NULL_TREE;
    7552                 :           2 :                 array_parm_static = false;
    7553                 :             :               }
    7554                 :     1062760 :             orig_qual_indirect++;
    7555                 :     1062760 :             break;
    7556                 :             :           }
    7557                 :    43842178 :         case cdk_function:
    7558                 :    43842178 :           {
    7559                 :             :             /* Say it's a definition only for the declarator closest
    7560                 :             :                to the identifier, apart possibly from some
    7561                 :             :                attributes.  */
    7562                 :    43842178 :             bool really_funcdef = false;
    7563                 :    43842178 :             tree arg_types;
    7564                 :    43842178 :             orig_qual_type = NULL_TREE;
    7565                 :    43842178 :             if (funcdef_flag)
    7566                 :             :               {
    7567                 :    31761927 :                 const struct c_declarator *t = declarator->declarator;
    7568                 :    31761931 :                 while (t->kind == cdk_attrs)
    7569                 :           4 :                   t = t->declarator;
    7570                 :    31761927 :                 really_funcdef = (t->kind == cdk_id);
    7571                 :             :               }
    7572                 :             : 
    7573                 :             :             /* Declaring a function type.  Make sure we have a valid
    7574                 :             :                type for the function to return.  */
    7575                 :    43842178 :             if (type == error_mark_node)
    7576                 :           0 :               continue;
    7577                 :             : 
    7578                 :    43842178 :             size_varies = false;
    7579                 :             : 
    7580                 :             :             /* Warn about some types functions can't return.  */
    7581                 :    43842178 :             if (TREE_CODE (type) == FUNCTION_TYPE)
    7582                 :             :               {
    7583                 :           0 :                 if (name)
    7584                 :           0 :                   error_at (loc, "%qE declared as function returning a "
    7585                 :             :                                  "function", name);
    7586                 :             :                 else
    7587                 :           0 :                   error_at (loc, "type name declared as function "
    7588                 :             :                             "returning a function");
    7589                 :           0 :                 type = integer_type_node;
    7590                 :             :               }
    7591                 :    43842178 :             if (TREE_CODE (type) == ARRAY_TYPE)
    7592                 :             :               {
    7593                 :           0 :                 if (name)
    7594                 :           0 :                   error_at (loc, "%qE declared as function returning an array",
    7595                 :             :                             name);
    7596                 :             :                 else
    7597                 :           0 :                   error_at (loc, "type name declared as function returning "
    7598                 :             :                             "an array");
    7599                 :           0 :                 type = integer_type_node;
    7600                 :             :               }
    7601                 :             : 
    7602                 :             :             /* Construct the function type and go to the next
    7603                 :             :                inner layer of declarator.  */
    7604                 :    43842178 :             arg_info = declarator->u.arg_info;
    7605                 :    43842178 :             arg_types = grokparms (arg_info, really_funcdef);
    7606                 :             : 
    7607                 :             :             /* Type qualifiers before the return type of the function
    7608                 :             :                qualify the return type, not the function type.  */
    7609                 :    43842178 :             if (type_quals)
    7610                 :             :               {
    7611                 :         122 :                 const enum c_declspec_word ignored_quals_list[] =
    7612                 :             :                   {
    7613                 :             :                     cdw_const, cdw_volatile, cdw_restrict, cdw_address_space,
    7614                 :             :                     cdw_atomic, cdw_number_of_elements
    7615                 :             :                   };
    7616                 :         122 :                 location_t specs_loc
    7617                 :         122 :                   = smallest_type_quals_location (declspecs->locations,
    7618                 :             :                                                   ignored_quals_list);
    7619                 :         122 :                 if (specs_loc == UNKNOWN_LOCATION)
    7620                 :          27 :                   specs_loc = declspecs->locations[cdw_typedef];
    7621                 :          27 :                 if (specs_loc == UNKNOWN_LOCATION)
    7622                 :          15 :                   specs_loc = loc;
    7623                 :             : 
    7624                 :             :                 /* Type qualifiers on a function return type are
    7625                 :             :                    normally permitted by the standard but have no
    7626                 :             :                    effect, so give a warning at -Wreturn-type.
    7627                 :             :                    Qualifiers on a void return type are banned on
    7628                 :             :                    function definitions in ISO C; GCC used to used
    7629                 :             :                    them for noreturn functions.  The resolution of C11
    7630                 :             :                    DR#423 means qualifiers (other than _Atomic) are
    7631                 :             :                    actually removed from the return type when
    7632                 :             :                    determining the function type.  For C23, _Atomic is
    7633                 :             :                    removed as well.  */
    7634                 :         122 :                 int quals_used = type_quals;
    7635                 :         122 :                 if (flag_isoc23)
    7636                 :             :                   quals_used = 0;
    7637                 :         105 :                 else if (flag_isoc11)
    7638                 :          71 :                   quals_used &= TYPE_QUAL_ATOMIC;
    7639                 :         105 :                 if (quals_used && VOID_TYPE_P (type) && really_funcdef)
    7640                 :           5 :                   pedwarn (specs_loc, 0,
    7641                 :             :                            "function definition has qualified void "
    7642                 :             :                            "return type");
    7643                 :             :                 else
    7644                 :         117 :                   warning_at (specs_loc, OPT_Wignored_qualifiers,
    7645                 :             :                               "type qualifiers ignored on function "
    7646                 :             :                               "return type");
    7647                 :             : 
    7648                 :             :                 /* Ensure an error for restrict on invalid types; the
    7649                 :             :                    DR#423 resolution is not entirely clear about
    7650                 :             :                    this.  */
    7651                 :         122 :                 if (flag_isoc11
    7652                 :          88 :                     && (type_quals & TYPE_QUAL_RESTRICT)
    7653                 :         128 :                     && (!POINTER_TYPE_P (type)
    7654                 :           4 :                         || !C_TYPE_OBJECT_OR_INCOMPLETE_P (TREE_TYPE (type))))
    7655                 :           4 :                   error_at (loc, "invalid use of %<restrict%>");
    7656                 :         122 :                 type = c_build_qualified_type (type, quals_used);
    7657                 :             :               }
    7658                 :    43842178 :             type_quals = TYPE_UNQUALIFIED;
    7659                 :             : 
    7660                 :    87684356 :             type = build_function_type (type, arg_types,
    7661                 :    43842178 :                                         arg_info->no_named_args_stdarg_p);
    7662                 :    43842178 :             declarator = declarator->declarator;
    7663                 :             : 
    7664                 :             :             /* Set the TYPE_CONTEXTs for each tagged type which is local to
    7665                 :             :                the formal parameter list of this FUNCTION_TYPE to point to
    7666                 :             :                the FUNCTION_TYPE node itself.  */
    7667                 :    43842178 :             {
    7668                 :    43842178 :               c_arg_tag *tag;
    7669                 :    43842178 :               unsigned ix;
    7670                 :             : 
    7671                 :    43842434 :               FOR_EACH_VEC_SAFE_ELT_REVERSE (arg_info->tags, ix, tag)
    7672                 :         129 :                 TYPE_CONTEXT (tag->type) = type;
    7673                 :             :             }
    7674                 :             :             break;
    7675                 :             :           }
    7676                 :    16598330 :         case cdk_pointer:
    7677                 :    16598330 :           {
    7678                 :             :             /* Merge any constancy or volatility into the target type
    7679                 :             :                for the pointer.  */
    7680                 :    16598330 :             if ((type_quals & TYPE_QUAL_ATOMIC)
    7681                 :        1749 :                 && TREE_CODE (type) == FUNCTION_TYPE)
    7682                 :             :               {
    7683                 :           2 :                 error_at (loc,
    7684                 :             :                           "%<_Atomic%>-qualified function type");
    7685                 :           2 :                 type_quals &= ~TYPE_QUAL_ATOMIC;
    7686                 :             :               }
    7687                 :    16598328 :             else if (pedantic && TREE_CODE (type) == FUNCTION_TYPE
    7688                 :        1670 :                      && type_quals)
    7689                 :           0 :               pedwarn (loc, OPT_Wpedantic,
    7690                 :             :                        "ISO C forbids qualified function types");
    7691                 :    16596660 :             if (type_quals)
    7692                 :     5251058 :               type = c_build_qualified_type (type, type_quals, orig_qual_type,
    7693                 :             :                                              orig_qual_indirect);
    7694                 :    16598330 :             orig_qual_type = NULL_TREE;
    7695                 :    16598330 :             size_varies = false;
    7696                 :             : 
    7697                 :             :             /* When the pointed-to type involves components of variable size,
    7698                 :             :                care must be taken to ensure that the size evaluation code is
    7699                 :             :                emitted early enough to dominate all the possible later uses
    7700                 :             :                and late enough for the variables on which it depends to have
    7701                 :             :                been assigned.
    7702                 :             : 
    7703                 :             :                This is expected to happen automatically when the pointed-to
    7704                 :             :                type has a name/declaration of it's own, but special attention
    7705                 :             :                is required if the type is anonymous. */
    7706                 :    16598330 :             if (!TYPE_NAME (type) && c_type_variably_modified_p (type))
    7707                 :             :               {
    7708                 :        5823 :                 bool bind_p = decl_context == TYPENAME
    7709                 :             :                               || decl_context == FIELD
    7710                 :        5823 :                               || decl_context == PARM;
    7711                 :       11248 :                 add_decl_expr (loc, type, bind_p ? expr : NULL, true);
    7712                 :             :               }
    7713                 :             : 
    7714                 :    16598330 :             type = c_build_pointer_type (type);
    7715                 :             : 
    7716                 :             :             /* Process type qualifiers (such as const or volatile)
    7717                 :             :                that were given inside the `*'.  */
    7718                 :    16598330 :             type_quals = declarator->u.pointer_quals;
    7719                 :             : 
    7720                 :    16598330 :             declarator = declarator->declarator;
    7721                 :    16598330 :             break;
    7722                 :             :           }
    7723                 :           0 :         default:
    7724                 :           0 :           gcc_unreachable ();
    7725                 :             :         }
    7726                 :    61509796 :       if (type != error_mark_node)
    7727                 :    61509706 :         C_TYPE_VARIABLY_MODIFIED (type) = varmod || size_varies;
    7728                 :             :     }
    7729                 :   274434272 :   *decl_attrs = chainon (returned_attrs, *decl_attrs);
    7730                 :   274434272 :   *decl_attrs = chainon (decl_id_attrs, *decl_attrs);
    7731                 :             : 
    7732                 :             :   /* Now TYPE has the actual type, apart from any qualifiers in
    7733                 :             :      TYPE_QUALS.  */
    7734                 :             : 
    7735                 :             :   /* Warn about address space used for things other than static memory or
    7736                 :             :      pointers.  */
    7737                 :   274434272 :   address_space = DECODE_QUAL_ADDR_SPACE (type_quals);
    7738                 :   274434272 :   if (!ADDR_SPACE_GENERIC_P (address_space))
    7739                 :             :     {
    7740                 :           7 :       if (decl_context == NORMAL)
    7741                 :             :         {
    7742                 :           7 :           switch (storage_class)
    7743                 :             :             {
    7744                 :           0 :             case csc_auto:
    7745                 :           0 :               error ("%qs combined with %<auto%> qualifier for %qE",
    7746                 :             :                      c_addr_space_name (address_space), name);
    7747                 :           0 :               break;
    7748                 :           0 :             case csc_register:
    7749                 :           0 :               error ("%qs combined with %<register%> qualifier for %qE",
    7750                 :             :                      c_addr_space_name (address_space), name);
    7751                 :           0 :               break;
    7752                 :           3 :             case csc_none:
    7753                 :           3 :               if (current_function_scope)
    7754                 :             :                 {
    7755                 :           0 :                   error ("%qs specified for auto variable %qE",
    7756                 :             :                          c_addr_space_name (address_space), name);
    7757                 :           0 :                   break;
    7758                 :             :                 }
    7759                 :             :               break;
    7760                 :             :             case csc_static:
    7761                 :             :             case csc_extern:
    7762                 :             :             case csc_typedef:
    7763                 :             :               break;
    7764                 :           0 :             default:
    7765                 :           0 :               gcc_unreachable ();
    7766                 :             :             }
    7767                 :             :         }
    7768                 :           0 :       else if (decl_context == PARM && TREE_CODE (type) != ARRAY_TYPE)
    7769                 :             :         {
    7770                 :           0 :           if (name)
    7771                 :           0 :             error ("%qs specified for parameter %qE",
    7772                 :             :                    c_addr_space_name (address_space), name);
    7773                 :             :           else
    7774                 :           0 :             error ("%qs specified for unnamed parameter",
    7775                 :             :                    c_addr_space_name (address_space));
    7776                 :             :         }
    7777                 :           0 :       else if (decl_context == FIELD)
    7778                 :             :         {
    7779                 :           0 :           if (name)
    7780                 :           0 :             error ("%qs specified for structure field %qE",
    7781                 :             :                    c_addr_space_name (address_space), name);
    7782                 :             :           else
    7783                 :           0 :             error ("%qs specified for structure field",
    7784                 :             :                    c_addr_space_name (address_space));
    7785                 :             :         }
    7786                 :             :     }
    7787                 :             : 
    7788                 :             :   /* Check the type and width of a bit-field.  */
    7789                 :   274434272 :   if (bitfield)
    7790                 :             :     {
    7791                 :       39375 :       check_bitfield_type_and_width (loc, &type, width, name);
    7792                 :             :       /* C11 makes it implementation-defined (6.7.2.1#5) whether
    7793                 :             :          atomic types are permitted for bit-fields; we have no code to
    7794                 :             :          make bit-field accesses atomic, so disallow them.  */
    7795                 :       39375 :       if (type_quals & TYPE_QUAL_ATOMIC)
    7796                 :             :         {
    7797                 :           2 :           if (name)
    7798                 :           1 :             error_at (loc, "bit-field %qE has atomic type", name);
    7799                 :             :           else
    7800                 :           1 :             error_at (loc, "bit-field has atomic type");
    7801                 :           2 :           type_quals &= ~TYPE_QUAL_ATOMIC;
    7802                 :             :         }
    7803                 :             :     }
    7804                 :             : 
    7805                 :             :   /* Reject invalid uses of _Alignas.  */
    7806                 :   274434272 :   if (declspecs->alignas_p)
    7807                 :             :     {
    7808                 :         182 :       if (storage_class == csc_typedef)
    7809                 :           1 :         error_at (loc, "alignment specified for typedef %qE", name);
    7810                 :         181 :       else if (storage_class == csc_register)
    7811                 :           1 :         error_at (loc, "alignment specified for %<register%> object %qE",
    7812                 :             :                   name);
    7813                 :         180 :       else if (decl_context == PARM)
    7814                 :             :         {
    7815                 :           2 :           if (name)
    7816                 :           1 :             error_at (loc, "alignment specified for parameter %qE", name);
    7817                 :             :           else
    7818                 :           1 :             error_at (loc, "alignment specified for unnamed parameter");
    7819                 :             :         }
    7820                 :         178 :       else if (bitfield)
    7821                 :             :         {
    7822                 :           0 :           if (name)
    7823                 :           0 :             error_at (loc, "alignment specified for bit-field %qE", name);
    7824                 :             :           else
    7825                 :           0 :             error_at (loc, "alignment specified for unnamed bit-field");
    7826                 :             :         }
    7827                 :         178 :       else if (TREE_CODE (type) == FUNCTION_TYPE)
    7828                 :           1 :         error_at (loc, "alignment specified for function %qE", name);
    7829                 :         177 :       else if (declspecs->align_log != -1 && TYPE_P (type))
    7830                 :             :         {
    7831                 :         150 :           alignas_align = 1U << declspecs->align_log;
    7832                 :         150 :           if (alignas_align < min_align_of_type (type))
    7833                 :             :             {
    7834                 :          26 :               if (name)
    7835                 :          25 :                 error_at (loc, "%<_Alignas%> specifiers cannot reduce "
    7836                 :             :                           "alignment of %qE", name);
    7837                 :             :               else
    7838                 :           1 :                 error_at (loc, "%<_Alignas%> specifiers cannot reduce "
    7839                 :             :                           "alignment of unnamed field");
    7840                 :             :               alignas_align = 0;
    7841                 :             :             }
    7842                 :             :         }
    7843                 :             :     }
    7844                 :             : 
    7845                 :             :   /* If this is declaring a typedef name, return a TYPE_DECL.  */
    7846                 :             : 
    7847                 :   274434272 :   if (storage_class == csc_typedef)
    7848                 :             :     {
    7849                 :     3993250 :       tree decl;
    7850                 :     3993250 :       if ((type_quals & TYPE_QUAL_ATOMIC)
    7851                 :       11148 :           && TREE_CODE (type) == FUNCTION_TYPE)
    7852                 :             :         {
    7853                 :           0 :           error_at (loc,
    7854                 :             :                     "%<_Atomic%>-qualified function type");
    7855                 :           0 :           type_quals &= ~TYPE_QUAL_ATOMIC;
    7856                 :             :         }
    7857                 :     3993250 :       else if (pedantic && TREE_CODE (type) == FUNCTION_TYPE
    7858                 :         604 :                && type_quals)
    7859                 :           0 :         pedwarn (loc, OPT_Wpedantic,
    7860                 :             :                  "ISO C forbids qualified function types");
    7861                 :     3992646 :       if (type_quals)
    7862                 :       28752 :         type = c_build_qualified_type (type, type_quals, orig_qual_type,
    7863                 :             :                                        orig_qual_indirect);
    7864                 :     7986500 :       decl = build_decl (declarator->id_loc,
    7865                 :     3993250 :                          TYPE_DECL, declarator->u.id.id, type);
    7866                 :     3993250 :       if (declspecs->explicit_signed_p)
    7867                 :      326705 :         C_TYPEDEF_EXPLICITLY_SIGNED (decl) = 1;
    7868                 :     3993250 :       if (declspecs->inline_p)
    7869                 :           4 :         pedwarn (loc, 0,"typedef %q+D declared %<inline%>", decl);
    7870                 :     3993250 :       if (declspecs->noreturn_p)
    7871                 :           1 :         pedwarn (loc, 0,"typedef %q+D declared %<_Noreturn%>", decl);
    7872                 :             : 
    7873                 :     3993250 :       if (warn_cxx_compat && declarator->u.id.id != NULL_TREE)
    7874                 :             :         {
    7875                 :        1646 :           struct c_binding *b = I_TAG_BINDING (declarator->u.id.id);
    7876                 :             : 
    7877                 :        1646 :           if (b != NULL
    7878                 :          39 :               && b->decl != NULL_TREE
    7879                 :          39 :               && (B_IN_CURRENT_SCOPE (b)
    7880                 :           4 :                   || (current_scope == file_scope && B_IN_EXTERNAL_SCOPE (b)))
    7881                 :        1681 :               && TYPE_MAIN_VARIANT (b->decl) != TYPE_MAIN_VARIANT (type))
    7882                 :             :             {
    7883                 :           7 :               auto_diagnostic_group d;
    7884                 :           7 :               if (warning_at (declarator->id_loc, OPT_Wc___compat,
    7885                 :             :                               ("using %qD as both a typedef and a tag is "
    7886                 :             :                                "invalid in C++"), decl)
    7887                 :           7 :                   && b->locus != UNKNOWN_LOCATION)
    7888                 :           6 :                 inform (b->locus, "originally defined here");
    7889                 :           7 :             }
    7890                 :             :         }
    7891                 :             : 
    7892                 :     3993250 :       return decl;
    7893                 :             :     }
    7894                 :             : 
    7895                 :             :   /* If this is a type name (such as, in a cast or sizeof),
    7896                 :             :      compute the type and return it now.  */
    7897                 :             : 
    7898                 :   270441022 :   if (decl_context == TYPENAME)
    7899                 :             :     {
    7900                 :             :       /* Note that the grammar rejects storage classes in typenames
    7901                 :             :          and fields.  */
    7902                 :   105194704 :       gcc_assert (storage_class == csc_none && !threadp
    7903                 :             :                   && !declspecs->inline_p && !declspecs->noreturn_p);
    7904                 :   105194704 :       if ((type_quals & TYPE_QUAL_ATOMIC)
    7905                 :         184 :           && TREE_CODE (type) == FUNCTION_TYPE)
    7906                 :             :         {
    7907                 :           0 :           error_at (loc,
    7908                 :             :                     "%<_Atomic%>-qualified function type");
    7909                 :           0 :           type_quals &= ~TYPE_QUAL_ATOMIC;
    7910                 :             :         }
    7911                 :   105194704 :       else if (pedantic && TREE_CODE (type) == FUNCTION_TYPE
    7912                 :          10 :                && type_quals)
    7913                 :           0 :         pedwarn (loc, OPT_Wpedantic,
    7914                 :             :                  "ISO C forbids const or volatile function types");
    7915                 :   105194694 :       if (type_quals)
    7916                 :         708 :         type = c_build_qualified_type (type, type_quals, orig_qual_type,
    7917                 :             :                                        orig_qual_indirect);
    7918                 :   105194704 :       return type;
    7919                 :             :     }
    7920                 :             : 
    7921                 :      346213 :   if (pedantic && decl_context == FIELD
    7922                 :   165270179 :       && c_type_variably_modified_p (type))
    7923                 :             :     {
    7924                 :             :       /* C99 6.7.2.1p8 */
    7925                 :           6 :       pedwarn (loc, OPT_Wpedantic, "a member of a structure or union cannot "
    7926                 :             :                "have a variably modified type");
    7927                 :             :     }
    7928                 :             : 
    7929                 :             :   /* Aside from typedefs and type names (handle above),
    7930                 :             :      `void' at top level (not within pointer)
    7931                 :             :      is allowed only in public variables.
    7932                 :             :      We don't complain about parms either, but that is because
    7933                 :             :      a better error message can be made later.  */
    7934                 :             : 
    7935                 :   165246318 :   if (VOID_TYPE_P (type) && decl_context != PARM
    7936                 :          59 :       && !((decl_context != FIELD && TREE_CODE (type) != FUNCTION_TYPE)
    7937                 :             :             && (storage_class == csc_extern
    7938                 :          27 :                 || (current_scope == file_scope
    7939                 :          18 :                     && !(storage_class == csc_static
    7940                 :             :                          || storage_class == csc_register)))))
    7941                 :             :     {
    7942                 :          15 :       error_at (loc, "variable or field %qE declared void", name);
    7943                 :          15 :       type = integer_type_node;
    7944                 :             :     }
    7945                 :             : 
    7946                 :             :   /* Now create the decl, which may be a VAR_DECL, a PARM_DECL
    7947                 :             :      or a FUNCTION_DECL, depending on DECL_CONTEXT and TYPE.  */
    7948                 :             : 
    7949                 :   164340851 :   {
    7950                 :   164340851 :     tree decl;
    7951                 :             : 
    7952                 :   164340851 :     if (decl_context == PARM)
    7953                 :             :       {
    7954                 :   108508888 :         tree promoted_type;
    7955                 :   108508888 :         bool array_parameter_p = false;
    7956                 :             : 
    7957                 :             :         /* A parameter declared as an array of T is really a pointer to T.
    7958                 :             :            One declared as a function is really a pointer to a function.  */
    7959                 :             : 
    7960                 :   108508888 :         if (TREE_CODE (type) == ARRAY_TYPE)
    7961                 :             :           {
    7962                 :             :             /* Transfer const-ness of array into that of type pointed to.  */
    7963                 :      416476 :             type = TREE_TYPE (type);
    7964                 :      416476 :             if (orig_qual_type != NULL_TREE)
    7965                 :             :               {
    7966                 :           7 :                 if (orig_qual_indirect == 0)
    7967                 :           5 :                   orig_qual_type = TREE_TYPE (orig_qual_type);
    7968                 :             :                 else
    7969                 :           2 :                   orig_qual_indirect--;
    7970                 :             :               }
    7971                 :      416476 :             if (type_quals)
    7972                 :       46865 :               type = c_build_qualified_type (type, type_quals, orig_qual_type,
    7973                 :             :                                              orig_qual_indirect);
    7974                 :             : 
    7975                 :             :             /* The pointed-to type may need a decl expr (see above).  */
    7976                 :      416476 :             if (!TYPE_NAME (type) && c_type_variably_modified_p (type))
    7977                 :             :               {
    7978                 :         373 :                 bool bind_p = decl_context == TYPENAME
    7979                 :             :                               || decl_context == FIELD
    7980                 :             :                               || decl_context == PARM;
    7981                 :         373 :                 add_decl_expr (loc, type, bind_p ? expr : NULL, true);
    7982                 :             :               }
    7983                 :             : 
    7984                 :      416476 :             type = c_build_pointer_type (type);
    7985                 :      416476 :             type_quals = array_ptr_quals;
    7986                 :      416476 :             if (type_quals)
    7987                 :         741 :               type = c_build_qualified_type (type, type_quals);
    7988                 :             : 
    7989                 :             :             /* We don't yet implement attributes in this context.  */
    7990                 :      416476 :             if (array_ptr_attrs != NULL_TREE)
    7991                 :           0 :               warning_at (loc, OPT_Wattributes,
    7992                 :             :                           "attributes in parameter array declarator ignored");
    7993                 :             : 
    7994                 :             :             size_varies = false;
    7995                 :             :             array_parameter_p = true;
    7996                 :             :           }
    7997                 :   108092412 :         else if (TREE_CODE (type) == FUNCTION_TYPE)
    7998                 :             :           {
    7999                 :         300 :             if (type_quals & TYPE_QUAL_ATOMIC)
    8000                 :             :               {
    8001                 :           1 :                 error_at (loc,
    8002                 :             :                           "%<_Atomic%>-qualified function type");
    8003                 :           1 :                 type_quals &= ~TYPE_QUAL_ATOMIC;
    8004                 :             :               }
    8005                 :         299 :             else if (type_quals)
    8006                 :           0 :               pedwarn (loc, OPT_Wpedantic,
    8007                 :             :                        "ISO C forbids qualified function types");
    8008                 :           1 :             if (type_quals)
    8009                 :           0 :               type = c_build_qualified_type (type, type_quals);
    8010                 :         300 :             type = c_build_pointer_type (type);
    8011                 :         300 :             type_quals = TYPE_UNQUALIFIED;
    8012                 :             :           }
    8013                 :   108092112 :         else if (type_quals)
    8014                 :     8636323 :           type = c_build_qualified_type (type, type_quals);
    8015                 :             : 
    8016                 :   217017776 :         decl = build_decl (declarator->id_loc,
    8017                 :   108508888 :                            PARM_DECL, declarator->u.id.id, type);
    8018                 :   108508888 :         if (size_varies)
    8019                 :          42 :           C_DECL_VARIABLE_SIZE (decl) = 1;
    8020                 :   108508888 :         C_ARRAY_PARAMETER (decl) = array_parameter_p;
    8021                 :             : 
    8022                 :             :         /* Compute the type actually passed in the parmlist,
    8023                 :             :            for the case where there is no prototype.
    8024                 :             :            (For example, shorts and chars are passed as ints.)
    8025                 :             :            When there is a prototype, this is overridden later.  */
    8026                 :             : 
    8027                 :   108508888 :         if (type == error_mark_node)
    8028                 :             :           promoted_type = type;
    8029                 :             :         else
    8030                 :   108508807 :           promoted_type = c_type_promotes_to (type);
    8031                 :             : 
    8032                 :   108508888 :         DECL_ARG_TYPE (decl) = promoted_type;
    8033                 :   108508888 :         if (declspecs->inline_p)
    8034                 :           4 :           pedwarn (loc, 0, "parameter %q+D declared %<inline%>", decl);
    8035                 :   108508888 :         if (declspecs->noreturn_p)
    8036                 :           1 :           pedwarn (loc, 0, "parameter %q+D declared %<_Noreturn%>", decl);
    8037                 :             :       }
    8038                 :    56737430 :     else if (decl_context == FIELD)
    8039                 :             :       {
    8040                 :             :         /* Note that the grammar rejects storage classes in typenames
    8041                 :             :            and fields.  */
    8042                 :     3850147 :         gcc_assert (storage_class == csc_none && !threadp
    8043                 :             :                     && !declspecs->inline_p && !declspecs->noreturn_p);
    8044                 :             : 
    8045                 :             :         /* Structure field.  It may not be a function.  */
    8046                 :             : 
    8047                 :     3850147 :         if (TREE_CODE (type) == FUNCTION_TYPE)
    8048                 :             :           {
    8049                 :           0 :             error_at (loc, "field %qE declared as a function", name);
    8050                 :           0 :             type = build_pointer_type (type);
    8051                 :             :           }
    8052                 :     3850147 :         else if (TREE_CODE (type) != ERROR_MARK
    8053                 :     3850147 :                  && !COMPLETE_OR_UNBOUND_ARRAY_TYPE_P (type))
    8054                 :             :           {
    8055                 :          21 :             if (name)
    8056                 :          14 :               error_at (loc, "field %qE has incomplete type", name);
    8057                 :             :             else
    8058                 :           7 :               error_at (loc, "unnamed field has incomplete type");
    8059                 :          21 :             type = error_mark_node;
    8060                 :             :           }
    8061                 :     3850126 :         else if (TREE_CODE (type) == ARRAY_TYPE
    8062                 :     3850126 :                  && TYPE_DOMAIN (type) == NULL_TREE)
    8063                 :             :           {
    8064                 :             :             /* We have a flexible array member through a typedef.
    8065                 :             :                Set suitable range.  Whether this is a correct position
    8066                 :             :                for a flexible array member will be determined elsewhere.  */
    8067                 :          14 :             if (!in_system_header_at (input_location))
    8068                 :          14 :               pedwarn_c90 (loc, OPT_Wpedantic, "ISO C90 does not "
    8069                 :             :                            "support flexible array members");
    8070                 :          14 :             type = build_distinct_type_copy (TYPE_MAIN_VARIANT (type));
    8071                 :          14 :             TYPE_DOMAIN (type) = build_range_type (sizetype, size_zero_node,
    8072                 :             :                                                    NULL_TREE);
    8073                 :          14 :             if (orig_qual_indirect == 0)
    8074                 :     3850147 :               orig_qual_type = NULL_TREE;
    8075                 :             :           }
    8076                 :     3850147 :         if (type != error_mark_node
    8077                 :     3850147 :             && !verify_type_context (loc, TCTX_FIELD, type))
    8078                 :           0 :           type = error_mark_node;
    8079                 :             : 
    8080                 :     3850147 :         type = c_build_qualified_type (type, type_quals, orig_qual_type,
    8081                 :             :                                        orig_qual_indirect);
    8082                 :     7700294 :         decl = build_decl (declarator->id_loc,
    8083                 :     3850147 :                            FIELD_DECL, declarator->u.id.id, type);
    8084                 :     3850147 :         DECL_NONADDRESSABLE_P (decl) = bitfield;
    8085                 :     3850147 :         if (bitfield && !declarator->u.id.id)
    8086                 :        8886 :           DECL_PADDING_P (decl) = 1;
    8087                 :             : 
    8088                 :     3850147 :         if (size_varies)
    8089                 :         613 :           C_DECL_VARIABLE_SIZE (decl) = 1;
    8090                 :             :       }
    8091                 :    52887283 :     else if (TREE_CODE (type) == FUNCTION_TYPE)
    8092                 :             :       {
    8093                 :    44191749 :         if (storage_class == csc_register || threadp || constexprp)
    8094                 :             :           {
    8095                 :          10 :             error_at (loc, "invalid storage class for function %qE", name);
    8096                 :             :           }
    8097                 :    44191739 :         else if (current_scope != file_scope)
    8098                 :             :           {
    8099                 :             :             /* Function declaration not at file scope.  Storage
    8100                 :             :                classes other than `extern' are not allowed, C99
    8101                 :             :                6.7.1p5, and `extern' makes no difference.  However,
    8102                 :             :                GCC allows 'auto', perhaps with 'inline', to support
    8103                 :             :                nested functions.  */
    8104                 :       10452 :             if (storage_class == csc_auto)
    8105                 :          63 :                 pedwarn (loc, OPT_Wpedantic,
    8106                 :             :                          "invalid storage class for function %qE", name);
    8107                 :       10389 :             else if (storage_class == csc_static)
    8108                 :             :               {
    8109                 :          19 :                 error_at (loc, "invalid storage class for function %qE", name);
    8110                 :          19 :                 if (funcdef_flag)
    8111                 :           8 :                   storage_class = declspecs->storage_class = csc_none;
    8112                 :             :                 else
    8113                 :             :                   return NULL_TREE;
    8114                 :             :               }
    8115                 :             :           }
    8116                 :             : 
    8117                 :    88383476 :         decl = build_decl (declarator->id_loc,
    8118                 :    44191738 :                            FUNCTION_DECL, declarator->u.id.id, type);
    8119                 :    44191738 :         decl = build_decl_attribute_variant (decl, decl_attr);
    8120                 :             : 
    8121                 :    44191738 :         if (type_quals & TYPE_QUAL_ATOMIC)
    8122                 :             :           {
    8123                 :           1 :             error_at (loc,
    8124                 :             :                       "%<_Atomic%>-qualified function type");
    8125                 :           1 :             type_quals &= ~TYPE_QUAL_ATOMIC;
    8126                 :             :           }
    8127                 :    44191737 :         else if (pedantic && type_quals && !DECL_IN_SYSTEM_HEADER (decl))
    8128                 :           6 :           pedwarn (loc, OPT_Wpedantic,
    8129                 :             :                    "ISO C forbids qualified function types");
    8130                 :             : 
    8131                 :             :         /* Every function declaration is an external reference
    8132                 :             :            (DECL_EXTERNAL) except for those which are not at file
    8133                 :             :            scope and are explicitly declared "auto".  This is
    8134                 :             :            forbidden by standard C (C99 6.7.1p5) and is interpreted by
    8135                 :             :            GCC to signify a forward declaration of a nested function.  */
    8136                 :    44191738 :         if (storage_class == csc_auto && current_scope != file_scope)
    8137                 :          63 :           DECL_EXTERNAL (decl) = 0;
    8138                 :             :         /* In C99, a function which is declared 'inline' with 'extern'
    8139                 :             :            is not an external reference (which is confusing).  It
    8140                 :             :            means that the later definition of the function must be output
    8141                 :             :            in this file, C99 6.7.4p6.  In GNU C89, a function declared
    8142                 :             :            'extern inline' is an external reference.  */
    8143                 :    44191675 :         else if (declspecs->inline_p && storage_class != csc_static)
    8144                 :    30955545 :           DECL_EXTERNAL (decl) = ((storage_class == csc_extern)
    8145                 :    30955545 :                                   == flag_gnu89_inline);
    8146                 :             :         else
    8147                 :    13236130 :           DECL_EXTERNAL (decl) = !initialized;
    8148                 :             : 
    8149                 :             :         /* Record absence of global scope for `static' or `auto'.  */
    8150                 :    44191738 :         TREE_PUBLIC (decl)
    8151                 :    44191738 :           = !(storage_class == csc_static || storage_class == csc_auto);
    8152                 :             : 
    8153                 :             :         /* For a function definition, record the argument information
    8154                 :             :            block where store_parm_decls will look for it.  */
    8155                 :    44191738 :         if (funcdef_flag)
    8156                 :    31761900 :           current_function_arg_info = arg_info;
    8157                 :             : 
    8158                 :    44191738 :         if (declspecs->default_int_p)
    8159                 :        9215 :           C_FUNCTION_IMPLICIT_INT (decl) = 1;
    8160                 :             : 
    8161                 :             :         /* Record presence of `inline' and `_Noreturn', if it is
    8162                 :             :            reasonable.  */
    8163                 :    44191738 :         if (flag_hosted && MAIN_NAME_P (declarator->u.id.id))
    8164                 :             :           {
    8165                 :       47064 :             if (declspecs->inline_p)
    8166                 :           5 :               pedwarn (loc, 0, "cannot inline function %<main%>");
    8167                 :       47064 :             if (declspecs->noreturn_p)
    8168                 :           1 :               pedwarn (loc, 0, "%<main%> declared %<_Noreturn%>");
    8169                 :             :           }
    8170                 :             :         else
    8171                 :             :           {
    8172                 :    44144674 :             if (declspecs->inline_p)
    8173                 :             :               /* Record that the function is declared `inline'.  */
    8174                 :    31106398 :               DECL_DECLARED_INLINE_P (decl) = 1;
    8175                 :    44144674 :             if (declspecs->noreturn_p)
    8176                 :             :               {
    8177                 :       19819 :                 if (flag_isoc99)
    8178                 :       19816 :                   pedwarn_c99 (loc, OPT_Wpedantic,
    8179                 :             :                                "ISO C99 does not support %<_Noreturn%>");
    8180                 :             :                 else
    8181                 :           3 :                   pedwarn_c99 (loc, OPT_Wpedantic,
    8182                 :             :                                "ISO C90 does not support %<_Noreturn%>");
    8183                 :       19819 :                 TREE_THIS_VOLATILE (decl) = 1;
    8184                 :             :               }
    8185                 :             :           }
    8186                 :             : 
    8187                 :             :         /* C99 6.2.2p7: It is invalid (compile-time undefined
    8188                 :             :            behavior) to create an 'extern' declaration for a
    8189                 :             :            function if there is a global declaration that is
    8190                 :             :            'static' and the global declaration is not visible.
    8191                 :             :            (If the static declaration _is_ currently visible,
    8192                 :             :            the 'extern' declaration is taken to refer to that decl.) */
    8193                 :    44191738 :         if (!initialized
    8194                 :    12429829 :             && TREE_PUBLIC (decl)
    8195                 :    12418054 :             && current_scope != file_scope)
    8196                 :             :           {
    8197                 :        8865 :             tree global_decl  = identifier_global_value (declarator->u.id.id);
    8198                 :        8865 :             tree visible_decl = lookup_name (declarator->u.id.id);
    8199                 :             : 
    8200                 :        8865 :             if (global_decl
    8201                 :        8865 :                 && global_decl != visible_decl
    8202                 :        1712 :                 && VAR_OR_FUNCTION_DECL_P (global_decl)
    8203                 :        1712 :                 && !TREE_PUBLIC (global_decl))
    8204                 :           1 :               error_at (loc, "function previously declared %<static%> "
    8205                 :             :                         "redeclared %<extern%>");
    8206                 :             :           }
    8207                 :             :       }
    8208                 :             :     else
    8209                 :             :       {
    8210                 :             :         /* It's a variable.  */
    8211                 :             :         /* An uninitialized decl with `extern' is a reference.  */
    8212                 :     8695534 :         int extern_ref = !initialized && storage_class == csc_extern;
    8213                 :             : 
    8214                 :     8695534 :         if (constexprp)
    8215                 :             :           {
    8216                 :             :             /* The type of a constexpr variable must not be variably
    8217                 :             :                modified, volatile, atomic or restrict qualified or
    8218                 :             :                have a member with such a qualifier.  const
    8219                 :             :                qualification is implicitly added, and, at file scope,
    8220                 :             :                has internal linkage.  */
    8221                 :         319 :             if (c_type_variably_modified_p (type))
    8222                 :           1 :               error_at (loc, "%<constexpr%> object has variably modified "
    8223                 :             :                         "type");
    8224                 :         319 :             if (type_quals
    8225                 :         319 :                 & (TYPE_QUAL_VOLATILE | TYPE_QUAL_RESTRICT | TYPE_QUAL_ATOMIC))
    8226                 :           9 :               error_at (loc, "invalid qualifiers for %<constexpr%> object");
    8227                 :             :             else
    8228                 :             :               {
    8229                 :         310 :                 tree type_no_array = strip_array_types (type);
    8230                 :         310 :                 if (RECORD_OR_UNION_TYPE_P (type_no_array)
    8231                 :         310 :                     && C_TYPE_FIELDS_NON_CONSTEXPR (type_no_array))
    8232                 :           8 :                   error_at (loc, "invalid qualifiers for field of "
    8233                 :             :                             "%<constexpr%> object");
    8234                 :             :               }
    8235                 :         319 :             type_quals |= TYPE_QUAL_CONST;
    8236                 :         319 :             if (current_scope == file_scope)
    8237                 :         281 :               storage_class = csc_static;
    8238                 :             :           }
    8239                 :             : 
    8240                 :     8695534 :         type = c_build_qualified_type (type, type_quals, orig_qual_type,
    8241                 :             :                                        orig_qual_indirect);
    8242                 :             : 
    8243                 :             :         /* C99 6.2.2p7: It is invalid (compile-time undefined
    8244                 :             :            behavior) to create an 'extern' declaration for a
    8245                 :             :            variable if there is a global declaration that is
    8246                 :             :            'static' and the global declaration is not visible.
    8247                 :             :            (If the static declaration _is_ currently visible,
    8248                 :             :            the 'extern' declaration is taken to refer to that decl.) */
    8249                 :     8695534 :         if (extern_ref && current_scope != file_scope)
    8250                 :             :           {
    8251                 :        1562 :             tree global_decl  = identifier_global_value (declarator->u.id.id);
    8252                 :        1562 :             tree visible_decl = lookup_name (declarator->u.id.id);
    8253                 :             : 
    8254                 :        1562 :             if (global_decl
    8255                 :        1562 :                 && global_decl != visible_decl
    8256                 :             :                 && VAR_P (global_decl)
    8257                 :         281 :                 && !TREE_PUBLIC (global_decl))
    8258                 :           7 :               error_at (loc, "variable previously declared %<static%> "
    8259                 :             :                         "redeclared %<extern%>");
    8260                 :             :           }
    8261                 :             : 
    8262                 :    17391068 :         decl = build_decl (declarator->id_loc,
    8263                 :     8695534 :                            VAR_DECL, declarator->u.id.id, type);
    8264                 :     8695534 :         if (size_varies)
    8265                 :        7345 :           C_DECL_VARIABLE_SIZE (decl) = 1;
    8266                 :     8695534 :         if (constexprp)
    8267                 :         319 :           C_DECL_DECLARED_CONSTEXPR (decl) = 1;
    8268                 :             : 
    8269                 :     8695534 :         if (declspecs->inline_p)
    8270                 :           4 :           pedwarn (loc, 0, "variable %q+D declared %<inline%>", decl);
    8271                 :     8695534 :         if (declspecs->noreturn_p)
    8272                 :           1 :           pedwarn (loc, 0, "variable %q+D declared %<_Noreturn%>", decl);
    8273                 :             : 
    8274                 :             :         /* At file scope, an initialized extern declaration may follow
    8275                 :             :            a static declaration.  In that case, DECL_EXTERNAL will be
    8276                 :             :            reset later in start_decl.  */
    8277                 :     8695534 :         DECL_EXTERNAL (decl) = (storage_class == csc_extern);
    8278                 :             : 
    8279                 :             :         /* At file scope, the presence of a `static' or `register' storage
    8280                 :             :            class specifier, or the absence of all storage class specifiers
    8281                 :             :            makes this declaration a definition (perhaps tentative).  Also,
    8282                 :             :            the absence of `static' makes it public.  */
    8283                 :     8695534 :         if (current_scope == file_scope)
    8284                 :             :           {
    8285                 :     1137120 :             TREE_PUBLIC (decl) = storage_class != csc_static;
    8286                 :     1137120 :             TREE_STATIC (decl) = !extern_ref;
    8287                 :             :           }
    8288                 :             :         /* Not at file scope, only `static' makes a static definition.  */
    8289                 :             :         else
    8290                 :             :           {
    8291                 :     7558414 :             TREE_STATIC (decl) = (storage_class == csc_static);
    8292                 :     7558414 :             TREE_PUBLIC (decl) = extern_ref;
    8293                 :             :           }
    8294                 :             : 
    8295                 :     8695534 :         if (threadp)
    8296                 :        2784 :           set_decl_tls_model (decl, decl_default_tls_model (decl));
    8297                 :             :       }
    8298                 :             : 
    8299                 :   165246307 :     if ((storage_class == csc_extern
    8300                 :   121983947 :          || (storage_class == csc_none
    8301                 :   121540953 :              && TREE_CODE (type) == FUNCTION_TYPE
    8302                 :      752871 :              && !funcdef_flag))
    8303                 :   165525148 :         && c_type_variably_modified_p (type))
    8304                 :             :       {
    8305                 :             :         /* C99 6.7.5.2p2 */
    8306                 :           6 :         if (TREE_CODE (type) == FUNCTION_TYPE)
    8307                 :           4 :           error_at (loc, "non-nested function with variably modified type");
    8308                 :             :         else
    8309                 :           2 :           error_at (loc, "object with variably modified type must have "
    8310                 :             :                     "no linkage");
    8311                 :             :       }
    8312                 :             : 
    8313                 :             :     /* For nested functions disqualify ones taking VLAs by value
    8314                 :             :        from inlining since the middle-end cannot deal with this.
    8315                 :             :        ???  We should arrange for those to be passed by reference
    8316                 :             :        with emitting the copy on the caller side in the frontend.  */
    8317                 :   165246307 :     if (storage_class == csc_none
    8318                 :   121540953 :         && TREE_CODE (type) == FUNCTION_TYPE)
    8319                 :     3883848 :       for (tree al = TYPE_ARG_TYPES (type); al; al = TREE_CHAIN (al))
    8320                 :             :         {
    8321                 :     3131017 :           tree arg = TREE_VALUE (al);
    8322                 :     3131017 :           if (arg != error_mark_node
    8323                 :     3131017 :               && C_TYPE_VARIABLE_SIZE (arg))
    8324                 :             :             {
    8325                 :          40 :               DECL_UNINLINABLE (decl) = 1;
    8326                 :          40 :               break;
    8327                 :             :             }
    8328                 :             :         }
    8329                 :             : 
    8330                 :             :     /* Record `register' declaration for warnings on &
    8331                 :             :        and in case doing stupid register allocation.  */
    8332                 :             : 
    8333                 :   165246307 :     if (storage_class == csc_register)
    8334                 :             :       {
    8335                 :        3533 :         C_DECL_REGISTER (decl) = 1;
    8336                 :        3533 :         DECL_REGISTER (decl) = 1;
    8337                 :             :       }
    8338                 :             : 
    8339                 :             :     /* Record constancy and volatility.  */
    8340                 :   165246307 :     c_apply_type_quals_to_decl (type_quals, decl);
    8341                 :             : 
    8342                 :             :     /* Apply _Alignas specifiers.  */
    8343                 :   165246307 :     if (alignas_align)
    8344                 :             :       {
    8345                 :         117 :         SET_DECL_ALIGN (decl, alignas_align * BITS_PER_UNIT);
    8346                 :         117 :         DECL_USER_ALIGN (decl) = 1;
    8347                 :             :       }
    8348                 :             : 
    8349                 :             :     /* If a type has volatile components, it should be stored in memory.
    8350                 :             :        Otherwise, the fact that those components are volatile
    8351                 :             :        will be ignored, and would even crash the compiler.
    8352                 :             :        Of course, this only makes sense on  VAR,PARM, and RESULT decl's.   */
    8353                 :   165246307 :     if (C_TYPE_FIELDS_VOLATILE (TREE_TYPE (decl))
    8354                 :   165246307 :         && (VAR_P (decl) ||  TREE_CODE (decl) == PARM_DECL
    8355                 :             :           || TREE_CODE (decl) == RESULT_DECL))
    8356                 :             :       {
    8357                 :             :         /* It is not an error for a structure with volatile fields to
    8358                 :             :            be declared register, but reset DECL_REGISTER since it
    8359                 :             :            cannot actually go in a register.  */
    8360                 :         154 :         int was_reg = C_DECL_REGISTER (decl);
    8361                 :         154 :         C_DECL_REGISTER (decl) = 0;
    8362                 :         154 :         DECL_REGISTER (decl) = 0;
    8363                 :         154 :         c_mark_addressable (decl);
    8364                 :         154 :         C_DECL_REGISTER (decl) = was_reg;
    8365                 :             :       }
    8366                 :             : 
    8367                 :             :   /* This is the earliest point at which we might know the assembler
    8368                 :             :      name of a variable.  Thus, if it's known before this, die horribly.  */
    8369                 :   165246307 :     gcc_assert (!HAS_DECL_ASSEMBLER_NAME_P (decl)
    8370                 :             :                 || !DECL_ASSEMBLER_NAME_SET_P (decl));
    8371                 :             : 
    8372                 :   165246307 :     if (warn_cxx_compat
    8373                 :             :         && VAR_P (decl)
    8374                 :             :         && TREE_PUBLIC (decl)
    8375                 :       21142 :         && TREE_STATIC (decl)
    8376                 :        2003 :         && (RECORD_OR_UNION_TYPE_P (TREE_TYPE (decl))
    8377                 :        1915 :             || TREE_CODE (TREE_TYPE (decl)) == ENUMERAL_TYPE)
    8378                 :   165246410 :         && TYPE_NAME (TREE_TYPE (decl)) == NULL_TREE)
    8379                 :           4 :       warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wc___compat,
    8380                 :             :                   ("non-local variable %qD with anonymous type is "
    8381                 :             :                    "questionable in C++"),
    8382                 :             :                   decl);
    8383                 :             : 
    8384                 :             :     return decl;
    8385                 :             :   }
    8386                 :             : }
    8387                 :             : 
    8388                 :             : /* Decode the parameter-list info for a function type or function definition.
    8389                 :             :    The argument is the value returned by `get_parm_info' (or made in c-parse.c
    8390                 :             :    if there is an identifier list instead of a parameter decl list).
    8391                 :             :    These two functions are separate because when a function returns
    8392                 :             :    or receives functions then each is called multiple times but the order
    8393                 :             :    of calls is different.  The last call to `grokparms' is always the one
    8394                 :             :    that contains the formal parameter names of a function definition.
    8395                 :             : 
    8396                 :             :    Return a list of arg types to use in the FUNCTION_TYPE for this function.
    8397                 :             : 
    8398                 :             :    FUNCDEF_FLAG is true for a function definition, false for
    8399                 :             :    a mere declaration.  A nonempty identifier-list gets an error message
    8400                 :             :    when FUNCDEF_FLAG is false.  */
    8401                 :             : 
    8402                 :             : static tree
    8403                 :    43842178 : grokparms (struct c_arg_info *arg_info, bool funcdef_flag)
    8404                 :             : {
    8405                 :    43842178 :   tree arg_types = arg_info->types;
    8406                 :             : 
    8407                 :    43842178 :   if (funcdef_flag && arg_info->had_vla_unspec)
    8408                 :             :     {
    8409                 :             :       /* A function definition isn't function prototype scope C99 6.2.1p4.  */
    8410                 :             :       /* C99 6.7.5.2p4 */
    8411                 :           2 :       error ("%<[*]%> not allowed in other than function prototype scope");
    8412                 :             :     }
    8413                 :             : 
    8414                 :      714879 :   if (arg_types == NULL_TREE && !funcdef_flag && !flag_isoc23
    8415                 :    44556942 :       && !in_system_header_at (input_location))
    8416                 :      714761 :     warning (OPT_Wstrict_prototypes,
    8417                 :             :              "function declaration isn%'t a prototype");
    8418                 :             : 
    8419                 :    43842178 :   if (arg_types == error_mark_node)
    8420                 :             :     /* Don't set TYPE_ARG_TYPES in this case.  */
    8421                 :             :     return NULL_TREE;
    8422                 :             : 
    8423                 :    86916444 :   else if (arg_types && TREE_CODE (TREE_VALUE (arg_types)) == IDENTIFIER_NODE)
    8424                 :             :     {
    8425                 :        8691 :       if (!funcdef_flag)
    8426                 :             :         {
    8427                 :          11 :           permerror_opt (input_location,
    8428                 :             :                          OPT_Wdeclaration_missing_parameter_type,
    8429                 :             :                          "parameter names (without types) in "
    8430                 :             :                          "function declaration");
    8431                 :          11 :           arg_info->parms = NULL_TREE;
    8432                 :             :         }
    8433                 :             :       else
    8434                 :        8680 :         arg_info->parms = arg_info->types;
    8435                 :             : 
    8436                 :        8691 :       arg_info->types = NULL_TREE;
    8437                 :        8691 :       return NULL_TREE;
    8438                 :             :     }
    8439                 :             :   else
    8440                 :             :     {
    8441                 :    43833487 :       tree parm, type, typelt;
    8442                 :    43833487 :       unsigned int parmno;
    8443                 :             : 
    8444                 :             :       /* In C23, convert () to (void).  */
    8445                 :    43833487 :       if (flag_isoc23
    8446                 :       12503 :           && !arg_types
    8447                 :         704 :           && !arg_info->parms
    8448                 :         704 :           && !arg_info->no_named_args_stdarg_p)
    8449                 :         612 :         arg_types = arg_info->types = void_list_node;
    8450                 :             : 
    8451                 :             :       /* If there is a parameter of incomplete type in a definition,
    8452                 :             :          this is an error.  In a declaration this is valid, and a
    8453                 :             :          struct or union type may be completed later, before any calls
    8454                 :             :          or definition of the function.  In the case where the tag was
    8455                 :             :          first declared within the parameter list, a warning has
    8456                 :             :          already been given.  If a parameter has void type, then
    8457                 :             :          however the function cannot be defined or called, so
    8458                 :             :          warn.  */
    8459                 :             : 
    8460                 :    43833487 :       for (parm = arg_info->parms, typelt = arg_types, parmno = 1;
    8461                 :   151414053 :            parm;
    8462                 :   107580566 :            parm = DECL_CHAIN (parm), typelt = TREE_CHAIN (typelt), parmno++)
    8463                 :             :         {
    8464                 :   107580566 :           type = TREE_VALUE (typelt);
    8465                 :   107580566 :           if (type == error_mark_node)
    8466                 :          58 :             continue;
    8467                 :             : 
    8468                 :   107580508 :           if (!COMPLETE_TYPE_P (type))
    8469                 :             :             {
    8470                 :          55 :               if (funcdef_flag)
    8471                 :             :                 {
    8472                 :          27 :                   if (DECL_NAME (parm))
    8473                 :          27 :                     error_at (input_location,
    8474                 :             :                               "parameter %u (%q+D) has incomplete type",
    8475                 :             :                               parmno, parm);
    8476                 :             :                   else
    8477                 :           0 :                     error_at (DECL_SOURCE_LOCATION (parm),
    8478                 :             :                               "parameter %u has incomplete type",
    8479                 :             :                               parmno);
    8480                 :             : 
    8481                 :          27 :                   TREE_VALUE (typelt) = error_mark_node;
    8482                 :          27 :                   TREE_TYPE (parm) = error_mark_node;
    8483                 :          27 :                   arg_types = NULL_TREE;
    8484                 :             :                 }
    8485                 :          28 :               else if (VOID_TYPE_P (type))
    8486                 :             :                 {
    8487                 :           2 :                   if (DECL_NAME (parm))
    8488                 :           2 :                     warning_at (input_location, 0,
    8489                 :             :                                 "parameter %u (%q+D) has void type",
    8490                 :             :                                 parmno, parm);
    8491                 :             :                   else
    8492                 :           0 :                     warning_at (DECL_SOURCE_LOCATION (parm), 0,
    8493                 :             :                                 "parameter %u has void type",
    8494                 :             :                                 parmno);
    8495                 :             :                 }
    8496                 :             :             }
    8497                 :             : 
    8498                 :   107580508 :           if (DECL_NAME (parm) && TREE_USED (parm))
    8499                 :       17406 :             warn_if_shadowing (parm);
    8500                 :             :         }
    8501                 :    43833487 :       return arg_types;
    8502                 :             :     }
    8503                 :             : }
    8504                 :             : 
    8505                 :             : /* Allocate and initialize a c_arg_info structure from the parser's
    8506                 :             :    obstack.  */
    8507                 :             : 
    8508                 :             : struct c_arg_info *
    8509                 :    43842191 : build_arg_info (void)
    8510                 :             : {
    8511                 :    43842191 :   struct c_arg_info *ret = XOBNEW (&parser_obstack, struct c_arg_info);
    8512                 :    43842191 :   ret->parms = NULL_TREE;
    8513                 :    43842191 :   ret->tags = NULL;
    8514                 :    43842191 :   ret->types = NULL_TREE;
    8515                 :    43842191 :   ret->others = NULL_TREE;
    8516                 :    43842191 :   ret->pending_sizes = NULL;
    8517                 :    43842191 :   ret->had_vla_unspec = 0;
    8518                 :    43842191 :   ret->no_named_args_stdarg_p = 0;
    8519                 :    43842191 :   return ret;
    8520                 :             : }
    8521                 :             : 
    8522                 :             : /* Take apart the current scope and return a c_arg_info structure with
    8523                 :             :    info on a parameter list just parsed.
    8524                 :             : 
    8525                 :             :    This structure is later fed to 'grokparms' and 'store_parm_decls'.
    8526                 :             : 
    8527                 :             :    ELLIPSIS being true means the argument list ended in '...' so don't
    8528                 :             :    append a sentinel (void_list_node) to the end of the type-list.
    8529                 :             : 
    8530                 :             :    EXPR is NULL or an expression that needs to be evaluated for the
    8531                 :             :    side effects of array size expressions in the parameters.  */
    8532                 :             : 
    8533                 :             : struct c_arg_info *
    8534                 :    43065577 : get_parm_info (bool ellipsis, tree expr)
    8535                 :             : {
    8536                 :    43065577 :   struct c_binding *b = current_scope->bindings;
    8537                 :    43065577 :   struct c_arg_info *arg_info = build_arg_info ();
    8538                 :             : 
    8539                 :    43065577 :   tree parms = NULL_TREE;
    8540                 :    43065577 :   vec<c_arg_tag, va_gc> *tags = NULL;
    8541                 :    43065577 :   tree types = NULL_TREE;
    8542                 :    43065577 :   tree others = NULL_TREE;
    8543                 :             : 
    8544                 :    43065577 :   bool gave_void_only_once_err = false;
    8545                 :             : 
    8546                 :    43065577 :   arg_info->had_vla_unspec = current_scope->had_vla_unspec;
    8547                 :             : 
    8548                 :             :   /* The bindings in this scope must not get put into a block.
    8549                 :             :      We will take care of deleting the binding nodes.  */
    8550                 :    43065577 :   current_scope->bindings = 0;
    8551                 :             : 
    8552                 :             :   /* This function is only called if there was *something* on the
    8553                 :             :      parameter list.  */
    8554                 :    43065577 :   gcc_assert (b);
    8555                 :             : 
    8556                 :             :   /* A parameter list consisting solely of 'void' indicates that the
    8557                 :             :      function takes no arguments.  But if the 'void' is qualified
    8558                 :             :      (by 'const' or 'volatile'), or has a storage class specifier
    8559                 :             :      ('register'), then the behavior is undefined; issue an error.
    8560                 :             :      Typedefs for 'void' are OK (see DR#157).  */
    8561                 :    43065577 :   if (b->prev == 0                       /* one binding */
    8562                 :    11044680 :       && TREE_CODE (b->decl) == PARM_DECL   /* which is a parameter */
    8563                 :    11044680 :       && !DECL_NAME (b->decl)               /* anonymous */
    8564                 :    44732154 :       && VOID_TYPE_P (TREE_TYPE (b->decl))) /* of void type */
    8565                 :             :     {
    8566                 :      905449 :       if (TYPE_QUALS (TREE_TYPE (b->decl)) != TYPE_UNQUALIFIED
    8567                 :      905449 :           || C_DECL_REGISTER (b->decl))
    8568                 :          72 :         error_at (b->locus, "%<void%> as only parameter may not be qualified");
    8569                 :             : 
    8570                 :             :       /* There cannot be an ellipsis.  */
    8571                 :      905449 :       if (ellipsis)
    8572                 :           1 :         error_at (b->locus, "%<void%> must be the only parameter");
    8573                 :             : 
    8574                 :      905449 :       arg_info->types = void_list_node;
    8575                 :      905449 :       return arg_info;
    8576                 :             :     }
    8577                 :             : 
    8578                 :    42160128 :   if (!ellipsis)
    8579                 :    41958609 :     types = void_list_node;
    8580                 :             : 
    8581                 :             :   /* Break up the bindings list into parms, tags, types, and others;
    8582                 :             :      apply sanity checks; purge the name-to-decl bindings.  */
    8583                 :   149741015 :   while (b)
    8584                 :             :     {
    8585                 :   107580887 :       tree decl = b->decl;
    8586                 :   107580887 :       tree type = TREE_TYPE (decl);
    8587                 :   107580887 :       c_arg_tag tag;
    8588                 :   107580887 :       const char *keyword;
    8589                 :             : 
    8590                 :   107580887 :       switch (TREE_CODE (decl))
    8591                 :             :         {
    8592                 :   107580573 :         case PARM_DECL:
    8593                 :   107580573 :           if (b->id)
    8594                 :             :             {
    8595                 :   104416441 :               gcc_assert (I_SYMBOL_BINDING (b->id) == b);
    8596                 :   104416441 :               I_SYMBOL_BINDING (b->id) = b->shadowed;
    8597                 :             :             }
    8598                 :             : 
    8599                 :             :           /* Check for forward decls that never got their actual decl.  */
    8600                 :   107580573 :           if (TREE_ASM_WRITTEN (decl))
    8601                 :           4 :             error_at (b->locus,
    8602                 :             :                       "parameter %q+D has just a forward declaration", decl);
    8603                 :             :           /* Check for (..., void, ...) and issue an error.  */
    8604                 :   107580569 :           else if (VOID_TYPE_P (type) && !DECL_NAME (decl))
    8605                 :             :             {
    8606                 :           2 :               if (!gave_void_only_once_err)
    8607                 :             :                 {
    8608                 :           2 :                   error_at (b->locus, "%<void%> must be the only parameter");
    8609                 :           2 :                   gave_void_only_once_err = true;
    8610                 :             :                 }
    8611                 :             :             }
    8612                 :             :           else
    8613                 :             :             {
    8614                 :             :               /* Valid parameter, add it to the list.  */
    8615                 :   107580567 :               DECL_CHAIN (decl) = parms;
    8616                 :   107580567 :               parms = decl;
    8617                 :             : 
    8618                 :             :               /* Since there is a prototype, args are passed in their
    8619                 :             :                  declared types.  The back end may override this later.  */
    8620                 :   107580567 :               DECL_ARG_TYPE (decl) = type;
    8621                 :   107580567 :               types = tree_cons (0, type, types);
    8622                 :             :             }
    8623                 :             :           break;
    8624                 :             : 
    8625                 :          21 :         case ENUMERAL_TYPE: keyword = "enum"; goto tag;
    8626                 :          19 :         case UNION_TYPE:    keyword = "union"; goto tag;
    8627                 :          89 :         case RECORD_TYPE:   keyword = "struct"; goto tag;
    8628                 :         129 :         tag:
    8629                 :             :           /* Types may not have tag-names, in which case the type
    8630                 :             :              appears in the bindings list with b->id NULL.  */
    8631                 :         129 :           if (b->id)
    8632                 :             :             {
    8633                 :          89 :               gcc_assert (I_TAG_BINDING (b->id) == b);
    8634                 :          89 :               I_TAG_BINDING (b->id) = b->shadowed;
    8635                 :             :             }
    8636                 :             : 
    8637                 :             :           /* Warn about any struct, union or enum tags defined in a
    8638                 :             :              parameter list.  The scope of such types is limited to
    8639                 :             :              the parameter list, which is rarely if ever desirable
    8640                 :             :              (it's impossible to call such a function with type-
    8641                 :             :              correct arguments).  An anonymous union parm type is
    8642                 :             :              meaningful as a GNU extension, so don't warn for that.  */
    8643                 :         129 :           if (TREE_CODE (decl) != UNION_TYPE || b->id != NULL_TREE)
    8644                 :             :             {
    8645                 :         110 :               if (b->id)
    8646                 :             :                 {
    8647                 :             :                   /* The %s will be one of 'struct', 'union', or 'enum'.  */
    8648                 :          89 :                   if (!flag_isoc23)
    8649                 :          78 :                     warning_at (b->locus, 0,
    8650                 :             :                                 "%<%s %E%> declared inside parameter list"
    8651                 :             :                                 " will not be visible outside of this definition or"
    8652                 :             :                                 " declaration", keyword, b->id);
    8653                 :             :                 }
    8654                 :             :               else
    8655                 :             :                 /* The %s will be one of 'struct', 'union', or 'enum'.  */
    8656                 :          21 :                 warning_at (b->locus, 0,
    8657                 :             :                             "anonymous %s declared inside parameter list"
    8658                 :             :                             " will not be visible outside of this definition or"
    8659                 :             :                             " declaration", keyword);
    8660                 :             :             }
    8661                 :             : 
    8662                 :         129 :           tag.id = b->id;
    8663                 :         129 :           tag.type = decl;
    8664                 :         129 :           vec_safe_push (tags, tag);
    8665                 :         129 :           break;
    8666                 :             : 
    8667                 :          20 :         case FUNCTION_DECL:
    8668                 :             :           /* FUNCTION_DECLs appear when there is an implicit function
    8669                 :             :              declaration in the parameter list.  */
    8670                 :          20 :           gcc_assert (b->nested || seen_error ());
    8671                 :          20 :           goto set_shadowed;
    8672                 :             : 
    8673                 :         131 :         case CONST_DECL:
    8674                 :         131 :         case TYPE_DECL:
    8675                 :             :           /* CONST_DECLs appear here when we have an embedded enum,
    8676                 :             :              and TYPE_DECLs appear here when we have an embedded struct
    8677                 :             :              or union.  No warnings for this - we already warned about the
    8678                 :             :              type itself.  */
    8679                 :             : 
    8680                 :             :           /* When we reinsert this decl in the function body, we need
    8681                 :             :              to reconstruct whether it was marked as nested.  */
    8682                 :         131 :           gcc_assert (!b->nested);
    8683                 :         131 :           DECL_CHAIN (decl) = others;
    8684                 :         131 :           others = decl;
    8685                 :             :           /* fall through */
    8686                 :             : 
    8687                 :         185 :         case ERROR_MARK:
    8688                 :         185 :         set_shadowed:
    8689                 :             :           /* error_mark_node appears here when we have an undeclared
    8690                 :             :              variable.  Just throw it away.  */
    8691                 :         185 :           if (b->id)
    8692                 :             :             {
    8693                 :          56 :               gcc_assert (I_SYMBOL_BINDING (b->id) == b);
    8694                 :          56 :               I_SYMBOL_BINDING (b->id) = b->shadowed;
    8695                 :             :             }
    8696                 :             :           break;
    8697                 :             : 
    8698                 :             :           /* Other things that might be encountered.  */
    8699                 :           0 :         case LABEL_DECL:
    8700                 :           0 :         case VAR_DECL:
    8701                 :           0 :         default:
    8702                 :           0 :           gcc_unreachable ();
    8703                 :             :         }
    8704                 :             : 
    8705                 :   107580887 :       b = free_binding_and_advance (b);
    8706                 :             :     }
    8707                 :             : 
    8708                 :    42160128 :   arg_info->parms = parms;
    8709                 :    42160128 :   arg_info->tags = tags;
    8710                 :    42160128 :   arg_info->types = types;
    8711                 :    42160128 :   arg_info->others = others;
    8712                 :    42160128 :   arg_info->pending_sizes = expr;
    8713                 :    42160128 :   arg_info->no_named_args_stdarg_p = ellipsis && !types;
    8714                 :    42160128 :   return arg_info;
    8715                 :             : }
    8716                 :             : 
    8717                 :             : /* Get the struct, enum or union (CODE says which) with tag NAME.
    8718                 :             :    Define the tag as a forward-reference with location LOC if it is
    8719                 :             :    not defined.  HAVE_STD_ATTRS says whether any standard attributes
    8720                 :             :    were present after the struct, union or enum keyword; ATTRS are the
    8721                 :             :    standard attributes present there.  HAS_ENUM_TYPE_SPECIFIER says
    8722                 :             :    whether an enum type specifier (": specifier-qualifier-list") is
    8723                 :             :    present; if so, this is called before that specifier is parsed, so
    8724                 :             :    that the tag is in scope for that specifier.  Return a c_typespec
    8725                 :             :    structure for the type specifier.  */
    8726                 :             : 
    8727                 :             : struct c_typespec
    8728                 :     1008891 : parser_xref_tag (location_t loc, enum tree_code code, tree name,
    8729                 :             :                  bool have_std_attrs, tree attrs, bool has_enum_type_specifier)
    8730                 :             : {
    8731                 :     1008891 :   struct c_typespec ret;
    8732                 :     1008891 :   tree ref;
    8733                 :     1008891 :   location_t refloc;
    8734                 :             : 
    8735                 :     1008891 :   ret.expr = NULL_TREE;
    8736                 :     1008891 :   ret.expr_const_operands = true;
    8737                 :     1008891 :   ret.has_enum_type_specifier = has_enum_type_specifier;
    8738                 :             : 
    8739                 :             :   /* If a cross reference is requested, look up the type already
    8740                 :             :      defined for this tag and return it.  If an enum type specifier is
    8741                 :             :      present, only a definition in the current scope is relevant.  */
    8742                 :             : 
    8743                 :     1008891 :   ref = lookup_tag (code, name, has_enum_type_specifier, &refloc);
    8744                 :             : 
    8745                 :             :   /* If the visble type is still being defined, see if there is
    8746                 :             :      an earlier definition (which may be complete).  We do not
    8747                 :             :      have to loop because nested redefinitions are not allowed.  */
    8748                 :     1008891 :   if (flag_isoc23 && ref && C_TYPE_BEING_DEFINED (ref))
    8749                 :             :     {
    8750                 :          28 :       tree vis = previous_tag (ref);
    8751                 :          28 :       if (vis)
    8752                 :           9 :         ref = vis;
    8753                 :             :     }
    8754                 :             : 
    8755                 :             :   /* If this is the right type of tag, return what we found.
    8756                 :             :      (This reference will be shadowed by shadow_tag later if appropriate.)
    8757                 :             :      If this is the wrong type of tag, do not return it.  If it was the
    8758                 :             :      wrong type in the same scope, we will have had an error
    8759                 :             :      message already; if in a different scope and declaring
    8760                 :             :      a name, pending_xref_error will give an error message; but if in a
    8761                 :             :      different scope and not declaring a name, this tag should
    8762                 :             :      shadow the previous declaration of a different type of tag, and
    8763                 :             :      this would not work properly if we return the reference found.
    8764                 :             :      (For example, with "struct foo" in an outer scope, "union foo;"
    8765                 :             :      must shadow that tag with a new one of union type.)  */
    8766                 :     2017782 :   ret.kind = (ref
    8767                 :     1008891 :               ? (have_std_attrs ? ctsk_tagref_attrs : ctsk_tagref)
    8768                 :       86560 :               : (have_std_attrs ? ctsk_tagfirstref_attrs : ctsk_tagfirstref));
    8769                 :     1008891 :   if (ref && TREE_CODE (ref) == code)
    8770                 :             :     {
    8771                 :      922297 :       decl_attributes (&ref, attrs, (int) ATTR_FLAG_TYPE_IN_PLACE);
    8772                 :      922297 :       if (C_TYPE_DEFINED_IN_STRUCT (ref)
    8773                 :           5 :           && loc != UNKNOWN_LOCATION
    8774                 :      922302 :           && warn_cxx_compat)
    8775                 :             :         {
    8776                 :           5 :           auto_diagnostic_group d;
    8777                 :           5 :           switch (code)
    8778                 :             :             {
    8779                 :           2 :             case ENUMERAL_TYPE:
    8780                 :           2 :               if (warning_at (loc, OPT_Wc___compat,
    8781                 :             :                               ("enum type defined in struct or union "
    8782                 :             :                                "is not visible in C++")))
    8783                 :           2 :                   inform (refloc, "enum type defined here");
    8784                 :             :               break;
    8785                 :           2 :             case RECORD_TYPE:
    8786                 :           2 :               if (warning_at (loc, OPT_Wc___compat,
    8787                 :             :                               ("struct defined in struct or union "
    8788                 :             :                                "is not visible in C++")))
    8789                 :           2 :                 inform (refloc, "struct defined here");
    8790                 :             :               break;
    8791                 :           1 :             case UNION_TYPE:
    8792                 :           1 :               if (warning_at (loc, OPT_Wc___compat,
    8793                 :             :                               ("union defined in struct or union "
    8794                 :             :                                "is not visible in C++")))
    8795                 :           1 :                 inform (refloc, "union defined here");
    8796                 :             :               break;
    8797                 :           0 :             default:
    8798                 :           0 :               gcc_unreachable();
    8799                 :             :             }
    8800                 :           5 :         }
    8801                 :             : 
    8802                 :      922297 :       ret.spec = ref;
    8803                 :      922297 :       return ret;
    8804                 :             :     }
    8805                 :             : 
    8806                 :             :   /* If no such tag is yet defined, create a forward-reference node
    8807                 :             :      and record it as the "definition".
    8808                 :             :      When a real declaration of this type is found,
    8809                 :             :      the forward-reference will be altered into a real type.  */
    8810                 :             : 
    8811                 :       86594 :   ref = make_node (code);
    8812                 :       86594 :   if (code == ENUMERAL_TYPE)
    8813                 :             :     {
    8814                 :             :       /* Give the type a default layout like unsigned int
    8815                 :             :          to avoid crashing if it does not get defined.  */
    8816                 :         237 :       SET_TYPE_MODE (ref, TYPE_MODE (unsigned_type_node));
    8817                 :         237 :       SET_TYPE_ALIGN (ref, TYPE_ALIGN (unsigned_type_node));
    8818                 :         237 :       TYPE_USER_ALIGN (ref) = 0;
    8819                 :         237 :       TYPE_UNSIGNED (ref) = 1;
    8820                 :         237 :       TYPE_PRECISION (ref) = TYPE_PRECISION (unsigned_type_node);
    8821                 :         237 :       TYPE_MIN_VALUE (ref) = TYPE_MIN_VALUE (unsigned_type_node);
    8822                 :         237 :       TYPE_MAX_VALUE (ref) = TYPE_MAX_VALUE (unsigned_type_node);
    8823                 :         237 :       ENUM_FIXED_UNDERLYING_TYPE_P (ref) = has_enum_type_specifier;
    8824                 :             :     }
    8825                 :             : 
    8826                 :       86594 :   pushtag (loc, name, ref);
    8827                 :       86594 :   decl_attributes (&ref, attrs, (int) ATTR_FLAG_TYPE_IN_PLACE);
    8828                 :       86594 :   if (in_underspecified_init)
    8829                 :           9 :     error_at (loc, "%qT declared in underspecified object initializer",
    8830                 :             :               ref);
    8831                 :             : 
    8832                 :       86594 :   ret.spec = ref;
    8833                 :       86594 :   return ret;
    8834                 :             : }
    8835                 :             : 
    8836                 :             : /* Get the struct, enum or union (CODE says which) with tag NAME.
    8837                 :             :    Define the tag as a forward-reference if it is not defined.
    8838                 :             :    Return a tree for the type.  */
    8839                 :             : 
    8840                 :             : tree
    8841                 :           0 : xref_tag (enum tree_code code, tree name)
    8842                 :             : {
    8843                 :           0 :   return parser_xref_tag (input_location, code, name, false, NULL_TREE,
    8844                 :           0 :                           false).spec;
    8845                 :             : }
    8846                 :             : 
    8847                 :             : /* Make sure that the tag NAME is defined *in the current scope*
    8848                 :             :    at least as a forward reference.
    8849                 :             :    LOC is the location of the struct's definition.
    8850                 :             :    CODE says which kind of tag NAME ought to be.
    8851                 :             : 
    8852                 :             :    This stores the current value of the file static STRUCT_PARSE_INFO
    8853                 :             :    in *ENCLOSING_STRUCT_PARSE_INFO, and points STRUCT_PARSE_INFO at a
    8854                 :             :    new c_struct_parse_info structure.  The old value of
    8855                 :             :    STRUCT_PARSE_INFO is restored in finish_struct.  */
    8856                 :             : 
    8857                 :             : tree
    8858                 :     1072866 : start_struct (location_t loc, enum tree_code code, tree name,
    8859                 :             :               class c_struct_parse_info **enclosing_struct_parse_info)
    8860                 :             : {
    8861                 :             :   /* If there is already a tag defined at this scope
    8862                 :             :      (as a forward reference), just return it.  */
    8863                 :             : 
    8864                 :     1072866 :   tree ref = NULL_TREE;
    8865                 :     1072866 :   location_t refloc = UNKNOWN_LOCATION;
    8866                 :             : 
    8867                 :     1072866 :   if (name != NULL_TREE)
    8868                 :      458940 :     ref = lookup_tag (code, name, true, &refloc);
    8869                 :             : 
    8870                 :             :   /* For C23, even if we already have a completed definition,
    8871                 :             :      we do not use it. We will check for consistency later.
    8872                 :             :      If we are in a nested redefinition the type is not
    8873                 :             :      complete. We will then detect this below.  */
    8874                 :     1072866 :   if (flag_isoc23 && ref && TYPE_SIZE (ref))
    8875                 :             :     ref = NULL_TREE;
    8876                 :             : 
    8877                 :     1072813 :   if (ref && TREE_CODE (ref) == code)
    8878                 :             :     {
    8879                 :       24061 :       if (TYPE_STUB_DECL (ref))
    8880                 :       24061 :         refloc = DECL_SOURCE_LOCATION (TYPE_STUB_DECL (ref));
    8881                 :             : 
    8882                 :       24061 :       if (TYPE_SIZE (ref))
    8883                 :             :         {
    8884                 :          10 :           auto_diagnostic_group d;
    8885                 :          10 :           if (code == UNION_TYPE)
    8886                 :           2 :             error_at (loc, "redefinition of %<union %E%>", name);
    8887                 :             :           else
    8888                 :           8 :             error_at (loc, "redefinition of %<struct %E%>", name);
    8889                 :          10 :           if (refloc != UNKNOWN_LOCATION)
    8890                 :          10 :             inform (refloc, "originally defined here");
    8891                 :             :           /* Don't create structures using a name already in use.  */
    8892                 :          10 :           ref = NULL_TREE;
    8893                 :          10 :         }
    8894                 :       24051 :       else if (C_TYPE_BEING_DEFINED (ref))
    8895                 :             :         {
    8896                 :          14 :           if (code == UNION_TYPE)
    8897                 :           1 :             error_at (loc, "nested redefinition of %<union %E%>", name);
    8898                 :             :           else
    8899                 :          13 :             error_at (loc, "nested redefinition of %<struct %E%>", name);
    8900                 :             :           /* Don't bother to report "originally defined here" for a
    8901                 :             :              nested redefinition; the original definition should be
    8902                 :             :              obvious.  */
    8903                 :             :           /* Don't create structures that contain themselves.  */
    8904                 :             :           ref = NULL_TREE;
    8905                 :             :         }
    8906                 :             :     }
    8907                 :             : 
    8908                 :             :   /* Otherwise create a forward-reference just so the tag is in scope.  */
    8909                 :             : 
    8910                 :       24050 :   if (ref == NULL_TREE || TREE_CODE (ref) != code)
    8911                 :             :     {
    8912                 :     1048829 :       ref = make_node (code);
    8913                 :     1048829 :       pushtag (loc, name, ref);
    8914                 :             :     }
    8915                 :             : 
    8916                 :     1072866 :   C_TYPE_BEING_DEFINED (ref) = 1;
    8917                 :     2174724 :   for (tree v = TYPE_MAIN_VARIANT (ref); v; v = TYPE_NEXT_VARIANT (v))
    8918                 :     1101858 :     TYPE_PACKED (v) = flag_pack_struct;
    8919                 :             : 
    8920                 :     1072866 :   *enclosing_struct_parse_info = struct_parse_info;
    8921                 :     1072866 :   struct_parse_info = new c_struct_parse_info ();
    8922                 :             : 
    8923                 :             :   /* FIXME: This will issue a warning for a use of a type defined
    8924                 :             :      within a statement expr used within sizeof, et. al.  This is not
    8925                 :             :      terribly serious as C++ doesn't permit statement exprs within
    8926                 :             :      sizeof anyhow.  */
    8927                 :     1072866 :   if (warn_cxx_compat && (in_sizeof || in_typeof || in_alignof))
    8928                 :          10 :     warning_at (loc, OPT_Wc___compat,
    8929                 :             :                 "defining type in %qs expression is invalid in C++",
    8930                 :             :                 (in_sizeof
    8931                 :             :                  ? "sizeof"
    8932                 :           4 :                  : (in_typeof ? "typeof" : "alignof")));
    8933                 :             : 
    8934                 :     1072866 :   if (in_underspecified_init)
    8935                 :          18 :     error_at (loc, "%qT defined in underspecified object initializer", ref);
    8936                 :             : 
    8937                 :     1072866 :   return ref;
    8938                 :             : }
    8939                 :             : 
    8940                 :             : /* Process the specs, declarator and width (NULL if omitted)
    8941                 :             :    of a structure component, returning a FIELD_DECL node.
    8942                 :             :    WIDTH is non-NULL for bit-fields only, and is an INTEGER_CST node.
    8943                 :             :    DECL_ATTRS is as for grokdeclarator.
    8944                 :             : 
    8945                 :             :    LOC is the location of the structure component.
    8946                 :             : 
    8947                 :             :    This is done during the parsing of the struct declaration.
    8948                 :             :    The FIELD_DECL nodes are chained together and the lot of them
    8949                 :             :    are ultimately passed to `build_struct' to make the RECORD_TYPE node.  */
    8950                 :             : 
    8951                 :             : tree
    8952                 :     3850174 : grokfield (location_t loc,
    8953                 :             :            struct c_declarator *declarator, struct c_declspecs *declspecs,
    8954                 :             :            tree width, tree *decl_attrs, tree *expr)
    8955                 :             : {
    8956                 :     3850174 :   tree value;
    8957                 :             : 
    8958                 :     3850174 :   if (declarator->kind == cdk_id && declarator->u.id.id == NULL_TREE
    8959                 :       18971 :       && width == NULL_TREE)
    8960                 :             :     {
    8961                 :             :       /* This is an unnamed decl.
    8962                 :             : 
    8963                 :             :          If we have something of the form "union { list } ;" then this
    8964                 :             :          is the anonymous union extension.  Similarly for struct.
    8965                 :             : 
    8966                 :             :          If this is something of the form "struct foo;", then
    8967                 :             :            If MS or Plan 9 extensions are enabled, this is handled as
    8968                 :             :              an anonymous struct.
    8969                 :             :            Otherwise this is a forward declaration of a structure tag.
    8970                 :             : 
    8971                 :             :          If this is something of the form "foo;" and foo is a TYPE_DECL, then
    8972                 :             :            If foo names a structure or union without a tag, then this
    8973                 :             :              is an anonymous struct (this is permitted by C11).
    8974                 :             :            If MS or Plan 9 extensions are enabled and foo names a
    8975                 :             :              structure, then again this is an anonymous struct.
    8976                 :             :            Otherwise this is an error.
    8977                 :             : 
    8978                 :             :          Oh what a horrid tangled web we weave.  I wonder if MS consciously
    8979                 :             :          took this from Plan 9 or if it was an accident of implementation
    8980                 :             :          that took root before someone noticed the bug...  */
    8981                 :             : 
    8982                 :       10085 :       tree type = declspecs->type;
    8983                 :       10085 :       bool ok = false;
    8984                 :             : 
    8985                 :       10085 :       if (RECORD_OR_UNION_TYPE_P (type)
    8986                 :       10079 :           && (flag_ms_extensions
    8987                 :       10069 :               || flag_plan9_extensions
    8988                 :       10054 :               || !declspecs->typedef_p))
    8989                 :             :         {
    8990                 :       10072 :           if (flag_ms_extensions || flag_plan9_extensions)
    8991                 :             :             ok = true;
    8992                 :       10047 :           else if (TYPE_NAME (type) == NULL)
    8993                 :             :             ok = true;
    8994                 :             :           else
    8995                 :             :             ok = false;
    8996                 :             :         }
    8997                 :             :       if (!ok)
    8998                 :             :         {
    8999                 :          27 :           pedwarn (loc, 0, "declaration does not declare anything");
    9000                 :          27 :           return NULL_TREE;
    9001                 :             :         }
    9002                 :       10058 :       if (flag_isoc99)
    9003                 :       10036 :         pedwarn_c99 (loc, OPT_Wpedantic,
    9004                 :             :                      "ISO C99 doesn%'t support unnamed structs/unions");
    9005                 :             :       else
    9006                 :          22 :         pedwarn_c99 (loc, OPT_Wpedantic,
    9007                 :             :                      "ISO C90 doesn%'t support unnamed structs/unions");
    9008                 :             :     }
    9009                 :             : 
    9010                 :     3850147 :   value = grokdeclarator (declarator, declspecs, FIELD, false,
    9011                 :     3850147 :                           width ? &width : NULL, decl_attrs, expr, NULL,
    9012                 :             :                           DEPRECATED_NORMAL);
    9013                 :             : 
    9014                 :     3850147 :   finish_decl (value, loc, NULL_TREE, NULL_TREE, NULL_TREE);
    9015                 :     3850147 :   DECL_INITIAL (value) = width;
    9016                 :     3850147 :   if (width)
    9017                 :       39375 :     SET_DECL_C_BIT_FIELD (value);
    9018                 :             : 
    9019                 :     3850147 :   if (warn_cxx_compat && DECL_NAME (value) != NULL_TREE)
    9020                 :             :     {
    9021                 :             :       /* If we currently have a binding for this field, set the
    9022                 :             :          in_struct field in the binding, so that we warn about lookups
    9023                 :             :          which find it.  */
    9024                 :         938 :       struct c_binding *b = I_SYMBOL_BINDING (DECL_NAME (value));
    9025                 :         938 :       if (b != NULL)
    9026                 :             :         {
    9027                 :             :           /* If the in_struct field is not yet set, push it on a list
    9028                 :             :              to be cleared when this struct is finished.  */
    9029                 :          19 :           if (!b->in_struct)
    9030                 :             :             {
    9031                 :          17 :               struct_parse_info->fields.safe_push (b);
    9032                 :          17 :               b->in_struct = 1;
    9033                 :             :             }
    9034                 :             :         }
    9035                 :             :     }
    9036                 :             : 
    9037                 :             :   return value;
    9038                 :             : }
    9039                 :             : 
    9040                 :             : /* Subroutine of detect_field_duplicates: return whether X and Y,
    9041                 :             :    which are both fields in the same struct, have duplicate field
    9042                 :             :    names.  */
    9043                 :             : 
    9044                 :             : static bool
    9045                 :     3632509 : is_duplicate_field (tree x, tree y)
    9046                 :             : {
    9047                 :     3632509 :   if (DECL_NAME (x) != NULL_TREE && DECL_NAME (x) == DECL_NAME (y))
    9048                 :             :     return true;
    9049                 :             : 
    9050                 :             :   /* When using -fplan9-extensions, an anonymous field whose name is a
    9051                 :             :      typedef can duplicate a field name.  */
    9052                 :     3632508 :   if (flag_plan9_extensions
    9053                 :     3632508 :       && (DECL_NAME (x) == NULL_TREE || DECL_NAME (y) == NULL_TREE))
    9054                 :             :     {
    9055                 :           0 :       tree xt, xn, yt, yn;
    9056                 :             : 
    9057                 :           0 :       xt = TREE_TYPE (x);
    9058                 :           0 :       if (DECL_NAME (x) != NULL_TREE)
    9059                 :           0 :         xn = DECL_NAME (x);
    9060                 :           0 :       else if (RECORD_OR_UNION_TYPE_P (xt)
    9061                 :           0 :                && TYPE_NAME (xt) != NULL_TREE
    9062                 :           0 :                && TREE_CODE (TYPE_NAME (xt)) == TYPE_DECL)
    9063                 :           0 :         xn = DECL_NAME (TYPE_NAME (xt));
    9064                 :             :       else
    9065                 :             :         xn = NULL_TREE;
    9066                 :             : 
    9067                 :           0 :       yt = TREE_TYPE (y);
    9068                 :           0 :       if (DECL_NAME (y) != NULL_TREE)
    9069                 :           0 :         yn = DECL_NAME (y);
    9070                 :           0 :       else if (RECORD_OR_UNION_TYPE_P (yt)
    9071                 :           0 :                && TYPE_NAME (yt) != NULL_TREE
    9072                 :           0 :                && TREE_CODE (TYPE_NAME (yt)) == TYPE_DECL)
    9073                 :           0 :         yn = DECL_NAME (TYPE_NAME (yt));
    9074                 :             :       else
    9075                 :             :         yn = NULL_TREE;
    9076                 :             : 
    9077                 :           0 :       if (xn != NULL_TREE && xn == yn)
    9078                 :             :         return true;
    9079                 :             :     }
    9080                 :             : 
    9081                 :             :   return false;
    9082                 :             : }
    9083                 :             : 
    9084                 :             : /* Subroutine of detect_field_duplicates: add the fields of FIELDLIST
    9085                 :             :    to HTAB, giving errors for any duplicates.  */
    9086                 :             : 
    9087                 :             : static void
    9088                 :       75084 : detect_field_duplicates_hash (tree fieldlist,
    9089                 :             :                               hash_table<nofree_ptr_hash <tree_node> > *htab)
    9090                 :             : {
    9091                 :       75084 :   tree x, y;
    9092                 :       75084 :   tree_node **slot;
    9093                 :             : 
    9094                 :     1289792 :   for (x = fieldlist; x ; x = DECL_CHAIN (x))
    9095                 :     1214708 :     if ((y = DECL_NAME (x)) != NULL_TREE)
    9096                 :             :       {
    9097                 :     1195753 :         slot = htab->find_slot (y, INSERT);
    9098                 :     1195753 :         if (*slot)
    9099                 :             :           {
    9100                 :          15 :             error ("duplicate member %q+D", x);
    9101                 :          15 :             DECL_NAME (x) = NULL_TREE;
    9102                 :             :           }
    9103                 :     1195753 :         *slot = y;
    9104                 :             :       }
    9105                 :       18955 :     else if (RECORD_OR_UNION_TYPE_P (TREE_TYPE (x)))
    9106                 :             :       {
    9107                 :       10745 :         detect_field_duplicates_hash (TYPE_FIELDS (TREE_TYPE (x)), htab);
    9108                 :             : 
    9109                 :             :         /* When using -fplan9-extensions, an anonymous field whose
    9110                 :             :            name is a typedef can duplicate a field name.  */
    9111                 :       10745 :         if (flag_plan9_extensions
    9112                 :          15 :             && TYPE_NAME (TREE_TYPE (x)) != NULL_TREE
    9113                 :       10759 :             && TREE_CODE (TYPE_NAME (TREE_TYPE (x))) == TYPE_DECL)
    9114                 :             :           {
    9115                 :           2 :             tree xn = DECL_NAME (TYPE_NAME (TREE_TYPE (x)));
    9116                 :           2 :             slot = htab->find_slot (xn, INSERT);
    9117                 :           2 :             if (*slot)
    9118                 :           0 :               error ("duplicate member %q+D", TYPE_NAME (TREE_TYPE (x)));
    9119                 :           2 :             *slot = xn;
    9120                 :             :           }
    9121                 :             :       }
    9122                 :       75084 : }
    9123                 :             : 
    9124                 :             : /* Generate an error for any duplicate field names in FIELDLIST.  Munge
    9125                 :             :    the list such that this does not present a problem later.  */
    9126                 :             : 
    9127                 :             : static void
    9128                 :     1072932 : detect_field_duplicates (tree fieldlist)
    9129                 :             : {
    9130                 :     1072932 :   tree x, y;
    9131                 :     1072932 :   int timeout = 10;
    9132                 :             : 
    9133                 :             :   /* If the struct is the list of instance variables of an Objective-C
    9134                 :             :      class, then we need to check all the instance variables of
    9135                 :             :      superclasses when checking for duplicates (since you can't have
    9136                 :             :      an instance variable in a subclass with the same name as an
    9137                 :             :      instance variable in a superclass).  We pass on this job to the
    9138                 :             :      Objective-C compiler.  objc_detect_field_duplicates() will return
    9139                 :             :      false if we are not checking the list of instance variables and
    9140                 :             :      the C frontend should proceed with the standard field duplicate
    9141                 :             :      checks.  If we are checking the list of instance variables, the
    9142                 :             :      ObjC frontend will do the check, emit the errors if needed, and
    9143                 :             :      then return true.  */
    9144                 :     1072932 :   if (c_dialect_objc ())
    9145                 :           0 :     if (objc_detect_field_duplicates (false))
    9146                 :             :       return;
    9147                 :             : 
    9148                 :             :   /* First, see if there are more than "a few" fields.
    9149                 :             :      This is trivially true if there are zero or one fields.  */
    9150                 :     1072932 :   if (!fieldlist || !DECL_CHAIN (fieldlist))
    9151                 :             :     return;
    9152                 :             :   x = fieldlist;
    9153                 :     3085287 :   do {
    9154                 :     3085287 :     timeout--;
    9155                 :     3085287 :     if (DECL_NAME (x) == NULL_TREE
    9156                 :     3085287 :         && RECORD_OR_UNION_TYPE_P (TREE_TYPE (x)))
    9157                 :             :       timeout = 0;
    9158                 :     3085287 :     x = DECL_CHAIN (x);
    9159                 :     3085287 :   } while (timeout > 0 && x);
    9160                 :             : 
    9161                 :             :   /* If there were "few" fields and no anonymous structures or unions,
    9162                 :             :      avoid the overhead of allocating a hash table.  Instead just do
    9163                 :             :      the nested traversal thing.  */
    9164                 :      876775 :   if (timeout > 0)
    9165                 :             :     {
    9166                 :     2476031 :       for (x = DECL_CHAIN (fieldlist); x; x = DECL_CHAIN (x))
    9167                 :             :         /* When using -fplan9-extensions, we can have duplicates
    9168                 :             :            between typedef names and fields.  */
    9169                 :     1663595 :         if (DECL_NAME (x)
    9170                 :     1663595 :             || (flag_plan9_extensions
    9171                 :           0 :                 && DECL_NAME (x) == NULL_TREE
    9172                 :           0 :                 && RECORD_OR_UNION_TYPE_P (TREE_TYPE (x))
    9173                 :           0 :                 && TYPE_NAME (TREE_TYPE (x)) != NULL_TREE
    9174                 :           0 :                 && TREE_CODE (TYPE_NAME (TREE_TYPE (x))) == TYPE_DECL))
    9175                 :             :           {
    9176                 :     5295597 :             for (y = fieldlist; y != x; y = TREE_CHAIN (y))
    9177                 :     3632509 :               if (is_duplicate_field (y, x))
    9178                 :             :                 {
    9179                 :           1 :                   error ("duplicate member %q+D", x);
    9180                 :           1 :                   DECL_NAME (x) = NULL_TREE;
    9181                 :             :                 }
    9182                 :             :           }
    9183                 :             :     }
    9184                 :             :   else
    9185                 :             :     {
    9186                 :       64339 :       hash_table<nofree_ptr_hash <tree_node> > htab (37);
    9187                 :       64339 :       detect_field_duplicates_hash (fieldlist, &htab);
    9188                 :       64339 :     }
    9189                 :             : }
    9190                 :             : 
    9191                 :             : /* Finish up struct info used by -Wc++-compat.  */
    9192                 :             : 
    9193                 :             : static void
    9194                 :         447 : warn_cxx_compat_finish_struct (tree fieldlist, enum tree_code code,
    9195                 :             :                                location_t record_loc)
    9196                 :             : {
    9197                 :         447 :   unsigned int ix;
    9198                 :         447 :   tree x;
    9199                 :         447 :   struct c_binding *b;
    9200                 :             : 
    9201                 :         447 :   if (fieldlist == NULL_TREE)
    9202                 :             :     {
    9203                 :           9 :       if (code == RECORD_TYPE)
    9204                 :           6 :         warning_at (record_loc, OPT_Wc___compat,
    9205                 :             :                     "empty struct has size 0 in C, size 1 in C++");
    9206                 :             :       else
    9207                 :           3 :         warning_at (record_loc, OPT_Wc___compat,
    9208                 :             :                     "empty union has size 0 in C, size 1 in C++");
    9209                 :             :     }
    9210                 :             : 
    9211                 :             :   /* Set the C_TYPE_DEFINED_IN_STRUCT flag for each type defined in
    9212                 :             :      the current struct.  We do this now at the end of the struct
    9213                 :             :      because the flag is used to issue visibility warnings, and we
    9214                 :             :      only want to issue those warnings if the type is referenced
    9215                 :             :      outside of the struct declaration.  */
    9216                 :         493 :   FOR_EACH_VEC_ELT (struct_parse_info->struct_types, ix, x)
    9217                 :          46 :     C_TYPE_DEFINED_IN_STRUCT (x) = 1;
    9218                 :             : 
    9219                 :             :   /* The TYPEDEFS_SEEN field of STRUCT_PARSE_INFO is a list of
    9220                 :             :      typedefs used when declaring fields in this struct.  If the name
    9221                 :             :      of any of the fields is also a typedef name then the struct would
    9222                 :             :      not parse in C++, because the C++ lookup rules say that the
    9223                 :             :      typedef name would be looked up in the context of the struct, and
    9224                 :             :      would thus be the field rather than the typedef.  */
    9225                 :         447 :   if (!struct_parse_info->typedefs_seen.is_empty ()
    9226                 :          56 :       && fieldlist != NULL_TREE)
    9227                 :             :     {
    9228                 :             :       /* Use a hash_set<tree> using the name of the typedef.  We can use
    9229                 :             :          a hash_set<tree> because identifiers are interned.  */
    9230                 :          56 :       hash_set<tree> tset;
    9231                 :             : 
    9232                 :         210 :       FOR_EACH_VEC_ELT (struct_parse_info->typedefs_seen, ix, x)
    9233                 :          98 :         tset.add (DECL_NAME (x));
    9234                 :             : 
    9235                 :         292 :       for (x = fieldlist; x != NULL_TREE; x = DECL_CHAIN (x))
    9236                 :             :         {
    9237                 :         236 :           if (DECL_NAME (x) != NULL_TREE
    9238                 :         236 :               && tset.contains (DECL_NAME (x)))
    9239                 :             :             {
    9240                 :           2 :               warning_at (DECL_SOURCE_LOCATION (x), OPT_Wc___compat,
    9241                 :             :                           ("using %qD as both field and typedef name is "
    9242                 :             :                            "invalid in C++"),
    9243                 :             :                           x);
    9244                 :             :               /* FIXME: It would be nice to report the location where
    9245                 :             :                  the typedef name is used.  */
    9246                 :             :             }
    9247                 :             :         }
    9248                 :          56 :     }
    9249                 :             : 
    9250                 :             :   /* For each field which has a binding and which was not defined in
    9251                 :             :      an enclosing struct, clear the in_struct field.  */
    9252                 :         464 :   FOR_EACH_VEC_ELT (struct_parse_info->fields, ix, b)
    9253                 :          17 :     b->in_struct = 0;
    9254                 :         447 : }
    9255                 :             : 
    9256                 :             : /* Function to help qsort sort FIELD_DECLs by name order.  */
    9257                 :             : 
    9258                 :             : static int
    9259                 :    17828462 : field_decl_cmp (const void *x_p, const void *y_p)
    9260                 :             : {
    9261                 :    17828462 :   const tree *const x = (const tree *) x_p;
    9262                 :    17828462 :   const tree *const y = (const tree *) y_p;
    9263                 :             : 
    9264                 :    17828462 :   if (DECL_NAME (*x) == DECL_NAME (*y))
    9265                 :             :     /* A nontype is "greater" than a type.  */
    9266                 :           0 :     return (TREE_CODE (*y) == TYPE_DECL) - (TREE_CODE (*x) == TYPE_DECL);
    9267                 :    17828462 :   if (DECL_NAME (*x) == NULL_TREE)
    9268                 :             :     return -1;
    9269                 :    17828462 :   if (DECL_NAME (*y) == NULL_TREE)
    9270                 :             :     return 1;
    9271                 :    17828462 :   if (DECL_NAME (*x) < DECL_NAME (*y))
    9272                 :     8784479 :     return -1;
    9273                 :             :   return 1;
    9274                 :             : }
    9275                 :             : 
    9276                 :             : /* If this structure or union completes the type of any previous
    9277                 :             :    variable declaration, lay it out and output its rtl.  */
    9278                 :             : static void
    9279                 :     1234144 : finish_incomplete_vars (tree incomplete_vars, bool toplevel)
    9280                 :             : {
    9281                 :     1234265 :   for (tree x = incomplete_vars; x; x = TREE_CHAIN (x))
    9282                 :             :     {
    9283                 :         121 :       tree decl = TREE_VALUE (x);
    9284                 :         121 :       if (TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE)
    9285                 :           0 :         layout_array_type (TREE_TYPE (decl));
    9286                 :         121 :       if (TREE_CODE (decl) != TYPE_DECL)
    9287                 :             :         {
    9288                 :         121 :           relayout_decl (decl);
    9289                 :         121 :           if (c_dialect_objc ())
    9290                 :           0 :             objc_check_decl (decl);
    9291                 :         121 :           rest_of_decl_compilation (decl, toplevel, 0);
    9292                 :             :         }
    9293                 :             :     }
    9294                 :     1234144 : }
    9295                 :             : 
    9296                 :             : /* Determine whether the FIELD_DECL X is a flexible array member according to
    9297                 :             :    the following info:
    9298                 :             :   A. whether the FIELD_DECL X is the last field of the DECL_CONTEXT;
    9299                 :             :   B. whether the FIELD_DECL is an array that is declared as "[]", "[0]",
    9300                 :             :      or "[1]";
    9301                 :             :   C. flag_strict_flex_arrays;
    9302                 :             :   D. the attribute strict_flex_array that is attached to the field
    9303                 :             :      if presenting.
    9304                 :             :   Return TRUE when it's a flexible array member, FALSE otherwise.  */
    9305                 :             : 
    9306                 :             : static bool
    9307                 :     3850204 : is_flexible_array_member_p (bool is_last_field,
    9308                 :             :                             tree x)
    9309                 :             : {
    9310                 :             :   /* If not the last field, return false.  */
    9311                 :     3850204 :   if (!is_last_field)
    9312                 :             :     return false;
    9313                 :             : 
    9314                 :             :   /* If not an array field, return false.  */
    9315                 :     1510020 :   if (TREE_CODE (TREE_TYPE (x)) != ARRAY_TYPE)
    9316                 :             :     return false;
    9317                 :             : 
    9318                 :      487486 :   bool is_zero_length_array = zero_length_array_type_p (TREE_TYPE (x));
    9319                 :      487486 :   bool is_one_element_array = one_element_array_type_p (TREE_TYPE (x));
    9320                 :      487486 :   bool is_flexible_array = flexible_array_member_type_p (TREE_TYPE (x));
    9321                 :             : 
    9322                 :      487486 :   unsigned int strict_flex_array_level = c_strict_flex_array_level_of (x);
    9323                 :             : 
    9324                 :      487486 :   switch (strict_flex_array_level)
    9325                 :             :     {
    9326                 :             :       case 0:
    9327                 :             :         /* Default, all trailing arrays are flexible array members.  */
    9328                 :             :         return true;
    9329                 :          77 :       case 1:
    9330                 :             :         /* Level 1: all "[1]", "[0]", and "[]" are flexible array members.  */
    9331                 :          77 :         if (is_one_element_array)
    9332                 :             :           return true;
    9333                 :             :         /* FALLTHROUGH.  */
    9334                 :         141 :       case 2:
    9335                 :             :         /* Level 2: all "[0]", and "[]" are flexible array members.  */
    9336                 :         141 :         if (is_zero_length_array)
    9337                 :             :           return true;
    9338                 :             :         /* FALLTHROUGH.  */
    9339                 :         200 :       case 3:
    9340                 :             :         /* Level 3: Only "[]" are flexible array members.  */
    9341                 :         200 :         if (is_flexible_array)
    9342                 :             :           return true;
    9343                 :             :         break;
    9344                 :           0 :       default:
    9345                 :           0 :         gcc_unreachable ();
    9346                 :             :     }
    9347                 :             :   return false;
    9348                 :             : }
    9349                 :             : 
    9350                 :             : 
    9351                 :             : /* Fill in the fields of a RECORD_TYPE or UNION_TYPE node, T.
    9352                 :             :    LOC is the location of the RECORD_TYPE or UNION_TYPE's definition.
    9353                 :             :    FIELDLIST is a chain of FIELD_DECL nodes for the fields.
    9354                 :             :    ATTRIBUTES are attributes to be applied to the structure.
    9355                 :             : 
    9356                 :             :    ENCLOSING_STRUCT_PARSE_INFO is the value of STRUCT_PARSE_INFO when
    9357                 :             :    the struct was started.  */
    9358                 :             : 
    9359                 :             : tree
    9360                 :     1072932 : finish_struct (location_t loc, tree t, tree fieldlist, tree attributes,
    9361                 :             :                class c_struct_parse_info *enclosing_struct_parse_info,
    9362                 :             :                tree *expr)
    9363                 :             : {
    9364                 :     1072932 :   tree x;
    9365                 :     1072932 :   bool toplevel = file_scope == current_scope;
    9366                 :             : 
    9367                 :             :   /* If this type was previously laid out as a forward reference,
    9368                 :             :      make sure we lay it out again.  */
    9369                 :             : 
    9370                 :     1072932 :   TYPE_SIZE (t) = NULL_TREE;
    9371                 :             : 
    9372                 :     1072932 :   decl_attributes (&t, attributes, (int) ATTR_FLAG_TYPE_IN_PLACE);
    9373                 :             : 
    9374                 :     1072932 :   if (pedantic)
    9375                 :             :     {
    9376                 :        7222 :       for (x = fieldlist; x; x = DECL_CHAIN (x))
    9377                 :             :         {
    9378                 :        7209 :           if (DECL_NAME (x) != NULL_TREE)
    9379                 :             :             break;
    9380                 :          14 :           if (flag_isoc11 && RECORD_OR_UNION_TYPE_P (TREE_TYPE (x)))
    9381                 :             :             break;
    9382                 :             :         }
    9383                 :             : 
    9384                 :        7212 :       if (x == NULL_TREE)
    9385                 :             :         {
    9386                 :          13 :           if (TREE_CODE (t) == UNION_TYPE)
    9387                 :             :             {
    9388                 :           4 :               if (fieldlist)
    9389                 :           2 :                 pedwarn (loc, OPT_Wpedantic, "union has no named members");
    9390                 :             :               else
    9391                 :           2 :                 pedwarn (loc, OPT_Wpedantic, "union has no members");
    9392                 :             :             }
    9393                 :             :           else
    9394                 :             :             {
    9395                 :           9 :               if (fieldlist)
    9396                 :           2 :                 pedwarn (loc, OPT_Wpedantic, "struct has no named members");
    9397                 :             :               else
    9398                 :           7 :                 pedwarn (loc, OPT_Wpedantic, "struct has no members");
    9399                 :             :             }
    9400                 :             :         }
    9401                 :             :     }
    9402                 :             : 
    9403                 :             :   /* Install struct as DECL_CONTEXT of each field decl.
    9404                 :             :      Also process specified field sizes, found in the DECL_INITIAL,
    9405                 :             :      storing 0 there after the type has been changed to precision equal
    9406                 :             :      to its width, rather than the precision of the specified standard
    9407                 :             :      type.  (Correct layout requires the original type to have been preserved
    9408                 :             :      until now.)  */
    9409                 :             : 
    9410                 :             :   bool saw_named_field = false;
    9411                 :     4923171 :   for (x = fieldlist; x; x = DECL_CHAIN (x))
    9412                 :             :     {
    9413                 :             :       /* Whether this field is the last field of the structure or union.
    9414                 :             :          for UNION, any field is the last field of it.  */
    9415                 :     3850239 :       bool is_last_field = (DECL_CHAIN (x) == NULL_TREE)
    9416                 :     3850239 :                             || (TREE_CODE (t) == UNION_TYPE);
    9417                 :             : 
    9418                 :     3850239 :       if (TREE_TYPE (x) == error_mark_node)
    9419                 :          35 :         continue;
    9420                 :             : 
    9421                 :     3850204 :       DECL_CONTEXT (x) = t;
    9422                 :             : 
    9423                 :     3850204 :       tree t1 = strip_array_types (TREE_TYPE (x));
    9424                 :             :       /* If any field is const, the structure type is pseudo-const.  */
    9425                 :     3850204 :       if (TREE_READONLY (x))
    9426                 :       57216 :         C_TYPE_FIELDS_READONLY (t) = 1;
    9427                 :             :       else
    9428                 :             :         {
    9429                 :             :           /* A field that is pseudo-const makes the structure likewise.  */
    9430                 :     3792988 :           if (RECORD_OR_UNION_TYPE_P (t1) && C_TYPE_FIELDS_READONLY (t1))
    9431                 :         641 :             C_TYPE_FIELDS_READONLY (t) = 1;
    9432                 :             :         }
    9433                 :             : 
    9434                 :             :       /* Any field that is volatile means variables of this type must be
    9435                 :             :          treated in some ways as volatile.  */
    9436                 :     3850204 :       if (TREE_THIS_VOLATILE (x))
    9437                 :             :         {
    9438                 :         321 :           C_TYPE_FIELDS_VOLATILE (t) = 1;
    9439                 :         321 :           C_TYPE_FIELDS_NON_CONSTEXPR (t) = 1;
    9440                 :             :         }
    9441                 :             : 
    9442                 :             :       /* Any field that is volatile, restrict-qualified or atomic
    9443                 :             :          means the type cannot be used for a constexpr object.  */
    9444                 :     3850204 :       if (TYPE_QUALS (t1)
    9445                 :     3850204 :           & (TYPE_QUAL_VOLATILE | TYPE_QUAL_RESTRICT | TYPE_QUAL_ATOMIC))
    9446                 :        1212 :         C_TYPE_FIELDS_NON_CONSTEXPR (t) = 1;
    9447                 :     3848992 :       else if (RECORD_OR_UNION_TYPE_P (t1) && C_TYPE_FIELDS_NON_CONSTEXPR (t1))
    9448                 :          30 :             C_TYPE_FIELDS_NON_CONSTEXPR (t) = 1;
    9449                 :             : 
    9450                 :             :       /* Any field of nominal variable size implies structure is too.  */
    9451                 :     3850204 :       if (C_DECL_VARIABLE_SIZE (x))
    9452                 :         616 :         C_TYPE_VARIABLE_SIZE (t) = 1;
    9453                 :             : 
    9454                 :             :       /* If any field is variably modified, record this fact. */
    9455                 :     3850204 :       if (C_TYPE_VARIABLY_MODIFIED (TREE_TYPE (x)))
    9456                 :         638 :         C_TYPE_VARIABLY_MODIFIED (t) = 1;
    9457                 :             : 
    9458                 :     3850204 :       if (DECL_C_BIT_FIELD (x))
    9459                 :             :         {
    9460                 :       39386 :           unsigned HOST_WIDE_INT width = tree_to_uhwi (DECL_INITIAL (x));
    9461                 :       39386 :           DECL_SIZE (x) = bitsize_int (width);
    9462                 :       39386 :           DECL_BIT_FIELD (x) = 1;
    9463                 :             :         }
    9464                 :             : 
    9465                 :     3850204 :       if (TYPE_PACKED (t)
    9466                 :     3855019 :           && (DECL_BIT_FIELD (x)
    9467                 :        2497 :               || TYPE_ALIGN (TREE_TYPE (x)) > BITS_PER_UNIT))
    9468                 :        4063 :         DECL_PACKED (x) = 1;
    9469                 :             : 
    9470                 :             :       /* Detect flexible array member in an invalid context.  */
    9471                 :     3850204 :       if (flexible_array_member_type_p (TREE_TYPE (x)))
    9472                 :             :         {
    9473                 :       59668 :           if (TREE_CODE (t) == UNION_TYPE)
    9474                 :             :             {
    9475                 :           3 :               error_at (DECL_SOURCE_LOCATION (x),
    9476                 :             :                         "flexible array member in union");
    9477                 :           3 :               TREE_TYPE (x) = error_mark_node;
    9478                 :             :             }
    9479                 :       59665 :           else if (!is_last_field)
    9480                 :             :             {
    9481                 :           3 :               error_at (DECL_SOURCE_LOCATION (x),
    9482                 :             :                         "flexible array member not at end of struct");
    9483                 :           3 :               TREE_TYPE (x) = error_mark_node;
    9484                 :             :             }
    9485                 :       59662 :           else if (!saw_named_field)
    9486                 :             :             {
    9487                 :           6 :               error_at (DECL_SOURCE_LOCATION (x),
    9488                 :             :                         "flexible array member in a struct with no named "
    9489                 :             :                         "members");
    9490                 :           6 :               TREE_TYPE (x) = error_mark_node;
    9491                 :             :             }
    9492                 :             :         }
    9493                 :             : 
    9494                 :       24406 :       if (pedantic && TREE_CODE (t) == RECORD_TYPE
    9495                 :     3870405 :           && flexible_array_type_p (TREE_TYPE (x)))
    9496                 :          16 :         pedwarn (DECL_SOURCE_LOCATION (x), OPT_Wpedantic,
    9497                 :             :                  "invalid use of structure with flexible array member");
    9498                 :             : 
    9499                 :             :       /* Set DECL_NOT_FLEXARRAY flag for FIELD_DECL x.  */
    9500                 :     3850204 :       DECL_NOT_FLEXARRAY (x) = !is_flexible_array_member_p (is_last_field, x);
    9501                 :             : 
    9502                 :             :       /* Set TYPE_INCLUDES_FLEXARRAY for the context of x, t.
    9503                 :             :          when x is an array and is the last field.  */
    9504                 :     3850204 :       if (TREE_CODE (TREE_TYPE (x)) == ARRAY_TYPE)
    9505                 :      637069 :         TYPE_INCLUDES_FLEXARRAY (t)
    9506                 :     1274138 :           = is_last_field && flexible_array_member_type_p (TREE_TYPE (x));
    9507                 :             :       /* Recursively set TYPE_INCLUDES_FLEXARRAY for the context of x, t
    9508                 :             :          when x is an union or record and is the last field.  */
    9509                 :     3213135 :       else if (RECORD_OR_UNION_TYPE_P (TREE_TYPE (x)))
    9510                 :      415578 :         TYPE_INCLUDES_FLEXARRAY (t)
    9511                 :      831156 :           = is_last_field && TYPE_INCLUDES_FLEXARRAY (TREE_TYPE (x));
    9512                 :             : 
    9513                 :     3850204 :       if (warn_flex_array_member_not_at_end
    9514                 :          40 :           && !is_last_field
    9515                 :          16 :           && RECORD_OR_UNION_TYPE_P (TREE_TYPE (x))
    9516                 :     3850212 :           && TYPE_INCLUDES_FLEXARRAY (TREE_TYPE (x)))
    9517                 :           1 :         warning_at (DECL_SOURCE_LOCATION (x),
    9518                 :             :                     OPT_Wflex_array_member_not_at_end,
    9519                 :             :                     "structure containing a flexible array member"
    9520                 :             :                     " is not at the end of another structure");
    9521                 :             : 
    9522                 :     3850204 :       if (DECL_NAME (x)
    9523                 :     3850204 :           || RECORD_OR_UNION_TYPE_P (TREE_TYPE (x)))
    9524                 :             :         saw_named_field = true;
    9525                 :             :     }
    9526                 :             : 
    9527                 :     1072932 :   detect_field_duplicates (fieldlist);
    9528                 :             : 
    9529                 :             :   /* Now we have the nearly final fieldlist.  Record it,
    9530                 :             :      then lay out the structure or union (including the fields).  */
    9531                 :             : 
    9532                 :     1072932 :   TYPE_FIELDS (t) = fieldlist;
    9533                 :             : 
    9534                 :     1072932 :   maybe_apply_pragma_scalar_storage_order (t);
    9535                 :             : 
    9536                 :     1072932 :   layout_type (t);
    9537                 :             : 
    9538                 :     1072932 :   if (TYPE_SIZE_UNIT (t)
    9539                 :     1072932 :       && TREE_CODE (TYPE_SIZE_UNIT (t)) == INTEGER_CST
    9540                 :     1072354 :       && !TREE_OVERFLOW (TYPE_SIZE_UNIT (t))
    9541                 :     2145286 :       && !valid_constant_size_p (TYPE_SIZE_UNIT (t)))
    9542                 :           1 :     error ("type %qT is too large", t);
    9543                 :             : 
    9544                 :             :   /* Give bit-fields their proper types and rewrite the type of array fields
    9545                 :             :      with scalar component if the enclosing type has reverse storage order.  */
    9546                 :     4923171 :   for (tree field = fieldlist; field; field = DECL_CHAIN (field))
    9547                 :             :     {
    9548                 :     3850239 :       if (TREE_CODE (field) == FIELD_DECL
    9549                 :     3850239 :           && DECL_INITIAL (field)
    9550                 :     3889633 :           && TREE_TYPE (field) != error_mark_node)
    9551                 :             :         {
    9552                 :       39386 :           unsigned HOST_WIDE_INT width
    9553                 :       39386 :             = tree_to_uhwi (DECL_INITIAL (field));
    9554                 :       39386 :           tree type = TREE_TYPE (field);
    9555                 :       39386 :           if (width != TYPE_PRECISION (type))
    9556                 :             :             {
    9557                 :       25561 :               if (TREE_CODE (type) == BITINT_TYPE
    9558                 :       25597 :                   && width >= (TYPE_UNSIGNED (type) ? 1 : 2))
    9559                 :          77 :                 TREE_TYPE (field)
    9560                 :         154 :                   = build_bitint_type (width, TYPE_UNSIGNED (type));
    9561                 :             :               else
    9562                 :       25484 :                 TREE_TYPE (field)
    9563                 :       25484 :                   = c_build_bitfield_integer_type (width,
    9564                 :       25484 :                                                    TYPE_UNSIGNED (type));
    9565                 :       25561 :               if (tree attr = c_hardbool_type_attr (type))
    9566                 :         253 :                 decl_attributes (&TREE_TYPE (field),
    9567                 :             :                                  copy_list (attr),
    9568                 :             :                                  0, NULL_TREE);
    9569                 :       25561 :               SET_DECL_MODE (field, TYPE_MODE (TREE_TYPE (field)));
    9570                 :             :             }
    9571                 :       39386 :           DECL_INITIAL (field) = NULL_TREE;
    9572                 :             :         }
    9573                 :     3810853 :       else if (TYPE_REVERSE_STORAGE_ORDER (t)
    9574                 :         686 :                && TREE_CODE (field) == FIELD_DECL
    9575                 :     3811539 :                && TREE_CODE (TREE_TYPE (field)) == ARRAY_TYPE)
    9576                 :             :         {
    9577                 :         106 :           tree ftype = TREE_TYPE (field);
    9578                 :         106 :           tree ctype = strip_array_types (ftype);
    9579                 :         106 :           if (!RECORD_OR_UNION_TYPE_P (ctype) && TYPE_MODE (ctype) != QImode)
    9580                 :             :             {
    9581                 :          93 :               tree fmain_type = TYPE_MAIN_VARIANT (ftype);
    9582                 :          93 :               tree *typep = &fmain_type;
    9583                 :          95 :               do {
    9584                 :          95 :                 *typep = build_distinct_type_copy (*typep);
    9585                 :          95 :                 TYPE_REVERSE_STORAGE_ORDER (*typep) = 1;
    9586                 :          95 :                 typep = &TREE_TYPE (*typep);
    9587                 :          95 :               } while (TREE_CODE (*typep) == ARRAY_TYPE);
    9588                 :          93 :               TREE_TYPE (field)
    9589                 :         186 :                 = c_build_qualified_type (fmain_type, TYPE_QUALS (ftype));
    9590                 :             :             }
    9591                 :             :         }
    9592                 :             : 
    9593                 :             :       /* Warn on problematic type punning for storage order purposes.  */
    9594                 :     3850239 :       if (TREE_CODE (t) == UNION_TYPE
    9595                 :      785645 :           && TREE_CODE (field) == FIELD_DECL
    9596                 :     4635884 :           && AGGREGATE_TYPE_P (TREE_TYPE (field)))
    9597                 :             :         {
    9598                 :      388241 :           tree ftype = TREE_TYPE (field);
    9599                 :      388241 :           if (TREE_CODE (ftype) == ARRAY_TYPE)
    9600                 :      285497 :             ftype = strip_array_types (ftype);
    9601                 :      388241 :           if (RECORD_OR_UNION_TYPE_P (ftype)
    9602                 :      388241 :               && TYPE_REVERSE_STORAGE_ORDER (ftype)
    9603                 :      103238 :                  != TYPE_REVERSE_STORAGE_ORDER (t))
    9604                 :           1 :             warning_at (DECL_SOURCE_LOCATION (field),
    9605                 :             :                         OPT_Wscalar_storage_order,
    9606                 :             :                         "type punning toggles scalar storage order");
    9607                 :             :         }
    9608                 :             :     }
    9609                 :             : 
    9610                 :             :   /* Now we have the truly final field list.
    9611                 :             :      Store it in this type and in the variants.  */
    9612                 :             : 
    9613                 :     1072932 :   TYPE_FIELDS (t) = fieldlist;
    9614                 :             : 
    9615                 :             :   /* If there are lots of fields, sort so we can look through them fast.
    9616                 :             :      We arbitrarily consider 16 or more elts to be "a lot".  */
    9617                 :             : 
    9618                 :     1072932 :   {
    9619                 :     1072932 :     int len = 0;
    9620                 :             : 
    9621                 :     4544624 :     for (x = fieldlist; x; x = DECL_CHAIN (x))
    9622                 :             :       {
    9623                 :     3498007 :         if (len > 15 || DECL_NAME (x) == NULL)
    9624                 :             :           break;
    9625                 :     3471692 :         len += 1;
    9626                 :             :       }
    9627                 :             : 
    9628                 :     1072932 :     if (len > 15)
    9629                 :             :       {
    9630                 :       21594 :         tree *field_array;
    9631                 :       21594 :         struct lang_type *space;
    9632                 :       21594 :         struct sorted_fields_type *space2;
    9633                 :             : 
    9634                 :       21594 :         len += list_length (x);
    9635                 :             : 
    9636                 :             :         /* Use the same allocation policy here that make_node uses, to
    9637                 :             :           ensure that this lives as long as the rest of the struct decl.
    9638                 :             :           All decls in an inline function need to be saved.  */
    9639                 :             : 
    9640                 :       21594 :         space = ggc_cleared_alloc<struct lang_type> ();
    9641                 :       21594 :         space2 = (sorted_fields_type *) ggc_internal_alloc
    9642                 :       21594 :           (sizeof (struct sorted_fields_type) + len * sizeof (tree));
    9643                 :             : 
    9644                 :       21594 :         len = 0;
    9645                 :       21594 :         space->s = space2;
    9646                 :       21594 :         field_array = &space2->elts[0];
    9647                 :      713172 :         for (x = fieldlist; x; x = DECL_CHAIN (x))
    9648                 :             :           {
    9649                 :      694558 :             field_array[len++] = x;
    9650                 :             : 
    9651                 :             :             /* If there is anonymous struct or union, break out of the loop.  */
    9652                 :      694558 :             if (DECL_NAME (x) == NULL)
    9653                 :             :               break;
    9654                 :             :           }
    9655                 :             :         /* Found no anonymous struct/union.  Add the TYPE_LANG_SPECIFIC.  */
    9656                 :       21594 :         if (x == NULL)
    9657                 :             :           {
    9658                 :       18614 :             TYPE_LANG_SPECIFIC (t) = space;
    9659                 :       18614 :             TYPE_LANG_SPECIFIC (t)->s->len = len;
    9660                 :       18614 :             field_array = TYPE_LANG_SPECIFIC (t)->s->elts;
    9661                 :       18614 :             qsort (field_array, len, sizeof (tree), field_decl_cmp);
    9662                 :             :           }
    9663                 :             :       }
    9664                 :             :   }
    9665                 :             : 
    9666                 :             :   /* If this was supposed to be a transparent union, but we can't
    9667                 :             :      make it one, warn and turn off the flag.  */
    9668                 :     1072932 :   if (TREE_CODE (t) == UNION_TYPE
    9669                 :      346359 :       && TYPE_TRANSPARENT_AGGR (t)
    9670                 :     1072975 :       && (!TYPE_FIELDS (t) || TYPE_MODE (t) != DECL_MODE (TYPE_FIELDS (t))))
    9671                 :             :     {
    9672                 :          13 :       TYPE_TRANSPARENT_AGGR (t) = 0;
    9673                 :          13 :       warning_at (loc, 0, "union cannot be made transparent");
    9674                 :             :     }
    9675                 :             : 
    9676                 :             :   /* Check for consistency with previous definition.  */
    9677                 :     1072932 :   if (flag_isoc23 && NULL != enclosing_struct_parse_info)
    9678                 :             :     {
    9679                 :         485 :       tree vistype = previous_tag (t);
    9680                 :         485 :       if (vistype
    9681                 :          56 :           && TREE_CODE (vistype) == TREE_CODE (t)
    9682                 :         541 :           && !C_TYPE_BEING_DEFINED (vistype))
    9683                 :             :         {
    9684                 :          52 :           TYPE_STUB_DECL (vistype) = TYPE_STUB_DECL (t);
    9685                 :          52 :           if (c_type_variably_modified_p (t))
    9686                 :           6 :             error ("redefinition of struct or union %qT with variably "
    9687                 :             :                    "modified type", t);
    9688                 :          46 :           else if (!comptypes_same_p (t, vistype))
    9689                 :          19 :             error ("redefinition of struct or union %qT", t);
    9690                 :             :         }
    9691                 :             :     }
    9692                 :             : 
    9693                 :     1072932 :   C_TYPE_BEING_DEFINED (t) = 0;
    9694                 :             : 
    9695                 :             :   /* Set type canonical based on equivalence class.  */
    9696                 :     1072932 :   if (flag_isoc23)
    9697                 :             :     {
    9698                 :         820 :       if (NULL == c_struct_htab)
    9699                 :         269 :         c_struct_htab = hash_table<c_struct_hasher>::create_ggc (61);
    9700                 :             : 
    9701                 :         820 :       hashval_t hash = c_struct_hasher::hash (t);
    9702                 :             : 
    9703                 :         820 :       tree *e = c_struct_htab->find_slot_with_hash (t, hash, INSERT);
    9704                 :         820 :       if (*e)
    9705                 :         148 :         TYPE_CANONICAL (t) = *e;
    9706                 :             :       else
    9707                 :             :         {
    9708                 :         672 :           TYPE_CANONICAL (t) = t;
    9709                 :         672 :           *e = t;
    9710                 :             :         }
    9711                 :             :     }
    9712                 :             : 
    9713                 :     1072932 :   tree incomplete_vars = C_TYPE_INCOMPLETE_VARS (TYPE_MAIN_VARIANT (t));
    9714                 :     2175031 :   for (x = TYPE_MAIN_VARIANT (t); x; x = TYPE_NEXT_VARIANT (x))
    9715                 :             :     {
    9716                 :     1102099 :       TYPE_FIELDS (x) = TYPE_FIELDS (t);
    9717                 :     1102099 :       TYPE_LANG_SPECIFIC (x) = TYPE_LANG_SPECIFIC (t);
    9718                 :     1102099 :       TYPE_TRANSPARENT_AGGR (x) = TYPE_TRANSPARENT_AGGR (t);
    9719                 :     1102099 :       C_TYPE_FIELDS_READONLY (x) = C_TYPE_FIELDS_READONLY (t);
    9720                 :     1102099 :       C_TYPE_FIELDS_VOLATILE (x) = C_TYPE_FIELDS_VOLATILE (t);
    9721                 :     1102099 :       C_TYPE_FIELDS_NON_CONSTEXPR (x) = C_TYPE_FIELDS_NON_CONSTEXPR (t);
    9722                 :     1102099 :       C_TYPE_VARIABLE_SIZE (x) = C_TYPE_VARIABLE_SIZE (t);
    9723                 :     1102099 :       C_TYPE_VARIABLY_MODIFIED (x) = C_TYPE_VARIABLY_MODIFIED (t);
    9724                 :     1102099 :       C_TYPE_INCOMPLETE_VARS (x) = NULL_TREE;
    9725                 :             :     }
    9726                 :             : 
    9727                 :             :   /* Update type location to the one of the definition, instead of e.g.
    9728                 :             :      a forward declaration.  */
    9729                 :     1072932 :   if (TYPE_STUB_DECL (t))
    9730                 :     1072932 :     DECL_SOURCE_LOCATION (TYPE_STUB_DECL (t)) = loc;
    9731                 :             : 
    9732                 :             :   /* Finish debugging output for this type.  */
    9733                 :     1072932 :   rest_of_type_compilation (t, toplevel);
    9734                 :             : 
    9735                 :     1072932 :   finish_incomplete_vars (incomplete_vars, toplevel);
    9736                 :             : 
    9737                 :             :   /* Make sure a DECL_EXPR is created for structs with VLA members.
    9738                 :             :      Because we do not know the context, we always pass expr
    9739                 :             :      to force creation of a BIND_EXPR which is required in some
    9740                 :             :      contexts.  */
    9741                 :     1072932 :   if (c_type_variably_modified_p (t))
    9742                 :         598 :     add_decl_expr (loc, t, expr, false);
    9743                 :             : 
    9744                 :     1072932 :   if (warn_cxx_compat)
    9745                 :         447 :     warn_cxx_compat_finish_struct (fieldlist, TREE_CODE (t), loc);
    9746                 :             : 
    9747                 :     1072932 :   if (NULL != enclosing_struct_parse_info)
    9748                 :             :     {
    9749                 :     1034292 :       delete struct_parse_info;
    9750                 :             : 
    9751                 :     1034292 :       struct_parse_info = enclosing_struct_parse_info;
    9752                 :             : 
    9753                 :             :       /* If this struct is defined inside a struct, add it to
    9754                 :             :          struct_types.  */
    9755                 :     1034292 :       if (warn_cxx_compat
    9756                 :             :           && struct_parse_info != NULL
    9757                 :         263 :           && !in_sizeof && !in_typeof && !in_alignof)
    9758                 :         258 :         struct_parse_info->struct_types.safe_push (t);
    9759                 :             :      }
    9760                 :             : 
    9761                 :     1072932 :   return t;
    9762                 :             : }
    9763                 :             : 
    9764                 :             : static struct {
    9765                 :             :   gt_pointer_operator new_value;
    9766                 :             :   void *cookie;
    9767                 :             : } resort_data;
    9768                 :             : 
    9769                 :             : /* This routine compares two fields like field_decl_cmp but using the
    9770                 :             : pointer operator in resort_data.  */
    9771                 :             : 
    9772                 :             : static int
    9773                 :        4580 : resort_field_decl_cmp (const void *x_p, const void *y_p)
    9774                 :             : {
    9775                 :        4580 :   const tree *const x = (const tree *) x_p;
    9776                 :        4580 :   const tree *const y = (const tree *) y_p;
    9777                 :             : 
    9778                 :        4580 :   if (DECL_NAME (*x) == DECL_NAME (*y))
    9779                 :             :     /* A nontype is "greater" than a type.  */
    9780                 :           0 :     return (TREE_CODE (*y) == TYPE_DECL) - (TREE_CODE (*x) == TYPE_DECL);
    9781                 :        4580 :   if (DECL_NAME (*x) == NULL_TREE)
    9782                 :             :     return -1;
    9783                 :        4580 :   if (DECL_NAME (*y) == NULL_TREE)
    9784                 :             :     return 1;
    9785                 :        4580 :   {
    9786                 :        4580 :     tree d1 = DECL_NAME (*x);
    9787                 :        4580 :     tree d2 = DECL_NAME (*y);
    9788                 :        4580 :     resort_data.new_value (&d1, &d1, resort_data.cookie);
    9789                 :        4580 :     resort_data.new_value (&d2, &d2, resort_data.cookie);
    9790                 :        4580 :     if (d1 < d2)
    9791                 :        2282 :       return -1;
    9792                 :             :   }
    9793                 :        2298 :   return 1;
    9794                 :             : }
    9795                 :             : 
    9796                 :             : /* Resort DECL_SORTED_FIELDS because pointers have been reordered.  */
    9797                 :             : 
    9798                 :             : void
    9799                 :           6 : resort_sorted_fields (void *obj,
    9800                 :             :                       void * ARG_UNUSED (orig_obj),
    9801                 :             :                       gt_pointer_operator new_value,
    9802                 :             :                       void *cookie)
    9803                 :             : {
    9804                 :           6 :   struct sorted_fields_type *sf = (struct sorted_fields_type *) obj;
    9805                 :           6 :   resort_data.new_value = new_value;
    9806                 :           6 :   resort_data.cookie = cookie;
    9807                 :           6 :   qsort (&sf->elts[0], sf->len, sizeof (tree),
    9808                 :             :          resort_field_decl_cmp);
    9809                 :           6 : }
    9810                 :             : 
    9811                 :             : /* Lay out the type T, and its element type, and so on.  */
    9812                 :             : 
    9813                 :             : static void
    9814                 :           0 : layout_array_type (tree t)
    9815                 :             : {
    9816                 :           0 :   if (TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE)
    9817                 :           0 :     layout_array_type (TREE_TYPE (t));
    9818                 :           0 :   layout_type (t);
    9819                 :           0 : }
    9820                 :             : 
    9821                 :             : /* Begin compiling the definition of an enumeration type.
    9822                 :             :    NAME is its name (or null if anonymous).
    9823                 :             :    LOC is the enum's location.
    9824                 :             :    FIXED_UNDERLYING_TYPE is the (C23) underlying type specified in the
    9825                 :             :    definition.
    9826                 :             :    Returns the type object, as yet incomplete.
    9827                 :             :    Also records info about it so that build_enumerator
    9828                 :             :    may be used to declare the individual values as they are read.  */
    9829                 :             : 
    9830                 :             : tree
    9831                 :      161212 : start_enum (location_t loc, struct c_enum_contents *the_enum, tree name,
    9832                 :             :             tree fixed_underlying_type, bool potential_nesting_p)
    9833                 :             : {
    9834                 :      161212 :   tree enumtype = NULL_TREE;
    9835                 :      161212 :   location_t enumloc = UNKNOWN_LOCATION;
    9836                 :             : 
    9837                 :             :   /* If this is the real definition for a previous forward reference,
    9838                 :             :      fill in the contents in the same object that used to be the
    9839                 :             :      forward reference.  */
    9840                 :             : 
    9841                 :      161212 :   if (name != NULL_TREE)
    9842                 :       64768 :     enumtype = lookup_tag (ENUMERAL_TYPE, name, true, &enumloc);
    9843                 :             : 
    9844                 :       64768 :   if (enumtype != NULL_TREE && TREE_CODE (enumtype) == ENUMERAL_TYPE)
    9845                 :             :     {
    9846                 :             :       /* If the type is currently being defined or if we have seen an
    9847                 :             :          incomplete version which is now complete, this is a nested
    9848                 :             :          redefinition.  The later happens if the redefinition occurs
    9849                 :             :          inside the enum specifier itself.  */
    9850                 :         151 :       if (C_TYPE_BEING_DEFINED (enumtype)
    9851                 :         151 :           || (potential_nesting_p && TYPE_VALUES (enumtype) != NULL_TREE))
    9852                 :           9 :         error_at (loc, "nested redefinition of %<enum %E%>", name);
    9853                 :             : 
    9854                 :             :       /* For C23 we allow redefinitions.  We set to zero and check for
    9855                 :             :          consistency later.  */
    9856                 :         266 :       if (flag_isoc23 && TYPE_VALUES (enumtype) != NULL_TREE)
    9857                 :             :         enumtype = NULL_TREE;
    9858                 :             :     }
    9859                 :             : 
    9860                 :       96585 :   if (enumtype == NULL_TREE || TREE_CODE (enumtype) != ENUMERAL_TYPE)
    9861                 :             :     {
    9862                 :      161073 :       enumtype = make_node (ENUMERAL_TYPE);
    9863                 :      161073 :       TYPE_SIZE (enumtype) = NULL_TREE;
    9864                 :      161073 :       pushtag (loc, name, enumtype);
    9865                 :      161073 :       if (fixed_underlying_type != NULL_TREE)
    9866                 :             :         {
    9867                 :             :           /* For an enum definition with a fixed underlying type, the
    9868                 :             :              type is complete during the definition and the
    9869                 :             :              enumeration constants have that type.  If there was a
    9870                 :             :              tag, the type was completed in c_parser_enum_specifier.
    9871                 :             :              If not, it must be completed here.  */
    9872                 :           9 :           ENUM_FIXED_UNDERLYING_TYPE_P (enumtype) = true;
    9873                 :           9 :           TYPE_MIN_VALUE (enumtype) = TYPE_MIN_VALUE (fixed_underlying_type);
    9874                 :           9 :           TYPE_MAX_VALUE (enumtype) = TYPE_MAX_VALUE (fixed_underlying_type);
    9875                 :           9 :           TYPE_UNSIGNED (enumtype) = TYPE_UNSIGNED (fixed_underlying_type);
    9876                 :           9 :           SET_TYPE_ALIGN (enumtype, TYPE_ALIGN (fixed_underlying_type));
    9877                 :           9 :           TYPE_SIZE (enumtype) = NULL_TREE;
    9878                 :           9 :           TYPE_PRECISION (enumtype) = TYPE_PRECISION (fixed_underlying_type);
    9879                 :           9 :           ENUM_UNDERLYING_TYPE (enumtype) = fixed_underlying_type;
    9880                 :           9 :           layout_type (enumtype);
    9881                 :             :         }
    9882                 :             :     }
    9883                 :             :   /* Update type location to the one of the definition, instead of e.g.
    9884                 :             :      a forward declaration.  */
    9885                 :         139 :   else if (TYPE_STUB_DECL (enumtype))
    9886                 :             :     {
    9887                 :         139 :       enumloc = DECL_SOURCE_LOCATION (TYPE_STUB_DECL (enumtype));
    9888                 :         139 :       DECL_SOURCE_LOCATION (TYPE_STUB_DECL (enumtype)) = loc;
    9889                 :             :     }
    9890                 :             : 
    9891                 :      161212 :   C_TYPE_BEING_DEFINED (enumtype) = 1;
    9892                 :             : 
    9893                 :      161212 :   if (TYPE_VALUES (enumtype) != NULL_TREE)
    9894                 :             :     {
    9895                 :             :       /* This enum is a named one that has been declared already.  */
    9896                 :           6 :       auto_diagnostic_group d;
    9897                 :           6 :       error_at (loc, "redeclaration of %<enum %E%>", name);
    9898                 :           6 :       if (enumloc != UNKNOWN_LOCATION)
    9899                 :           6 :         inform (enumloc, "originally defined here");
    9900                 :             : 
    9901                 :             :       /* Completely replace its old definition.
    9902                 :             :          The old enumerators remain defined, however.  */
    9903                 :           6 :       TYPE_VALUES (enumtype) = NULL_TREE;
    9904                 :           6 :     }
    9905                 :             : 
    9906                 :      161212 :   if (ENUM_FIXED_UNDERLYING_TYPE_P (enumtype)
    9907                 :      161212 :       && fixed_underlying_type == NULL_TREE)
    9908                 :             :     {
    9909                 :           3 :       error_at (loc, "%<enum%> declared with but defined without "
    9910                 :             :                 "fixed underlying type");
    9911                 :           3 :       ENUM_FIXED_UNDERLYING_TYPE_P (enumtype) = false;
    9912                 :             :     }
    9913                 :             : 
    9914                 :      161212 :   the_enum->enum_next_value = integer_zero_node;
    9915                 :      161212 :   the_enum->enum_type = enumtype;
    9916                 :      161212 :   the_enum->enum_overflow = 0;
    9917                 :             : 
    9918                 :      161212 :   if (flag_short_enums && !ENUM_FIXED_UNDERLYING_TYPE_P (enumtype))
    9919                 :         106 :     for (tree v = TYPE_MAIN_VARIANT (enumtype); v; v = TYPE_NEXT_VARIANT (v))
    9920                 :          53 :       TYPE_PACKED (v) = 1;
    9921                 :             : 
    9922                 :             :   /* FIXME: This will issue a warning for a use of a type defined
    9923                 :             :      within sizeof in a statement expr.  This is not terribly serious
    9924                 :             :      as C++ doesn't permit statement exprs within sizeof anyhow.  */
    9925                 :      161212 :   if (warn_cxx_compat && (in_sizeof || in_typeof || in_alignof))
    9926                 :           0 :     warning_at (loc, OPT_Wc___compat,
    9927                 :             :                 "defining type in %qs expression is invalid in C++",
    9928                 :             :                 (in_sizeof
    9929                 :             :                  ? "sizeof"
    9930                 :           0 :                  : (in_typeof ? "typeof" : "alignof")));
    9931                 :             : 
    9932                 :      161212 :   if (in_underspecified_init)
    9933                 :           6 :     error_at (loc, "%qT defined in underspecified object initializer",
    9934                 :             :               enumtype);
    9935                 :             : 
    9936                 :      161212 :   return enumtype;
    9937                 :             : }
    9938                 :             : 
    9939                 :             : /* After processing and defining all the values of an enumeration type,
    9940                 :             :    install their decls in the enumeration type and finish it off.
    9941                 :             :    ENUMTYPE is the type object, VALUES a list of decl-value pairs,
    9942                 :             :    and ATTRIBUTES are the specified attributes.
    9943                 :             :    Returns ENUMTYPE.  */
    9944                 :             : 
    9945                 :             : tree
    9946                 :      161212 : finish_enum (tree enumtype, tree values, tree attributes)
    9947                 :             : {
    9948                 :      161212 :   tree pair, tem;
    9949                 :      161212 :   tree minnode = NULL_TREE, maxnode = NULL_TREE;
    9950                 :      161212 :   int precision;
    9951                 :      161212 :   signop sign;
    9952                 :      161212 :   bool toplevel = (file_scope == current_scope);
    9953                 :      161212 :   struct lang_type *lt;
    9954                 :             : 
    9955                 :      161212 :   decl_attributes (&enumtype, attributes, (int) ATTR_FLAG_TYPE_IN_PLACE);
    9956                 :             : 
    9957                 :             :   /* Calculate the maximum value of any enumerator in this type.  */
    9958                 :             : 
    9959                 :      161212 :   if (values == error_mark_node)
    9960                 :          24 :     minnode = maxnode = integer_zero_node;
    9961                 :             :   else
    9962                 :             :     {
    9963                 :      161188 :       minnode = maxnode = TREE_VALUE (values);
    9964                 :     5348258 :       for (pair = TREE_CHAIN (values); pair; pair = TREE_CHAIN (pair))
    9965                 :             :         {
    9966                 :     5187070 :           tree value = TREE_VALUE (pair);
    9967                 :     5187070 :           if (tree_int_cst_lt (maxnode, value))
    9968                 :     5060723 :             maxnode = value;
    9969                 :     5187070 :           if (tree_int_cst_lt (value, minnode))
    9970                 :       52498 :             minnode = value;
    9971                 :             :         }
    9972                 :             :     }
    9973                 :             : 
    9974                 :             :   /* Construct the final type of this enumeration.  It is the same
    9975                 :             :      as one of the integral types - the narrowest one that fits, except
    9976                 :             :      that normally we only go as narrow as int - and signed iff any of
    9977                 :             :      the values are negative.  */
    9978                 :      161212 :   sign = (tree_int_cst_sgn (minnode) >= 0) ? UNSIGNED : SIGNED;
    9979                 :      161212 :   precision = MAX (tree_int_cst_min_precision (minnode, sign),
    9980                 :             :                    tree_int_cst_min_precision (maxnode, sign));
    9981                 :             : 
    9982                 :      161212 :   bool wider_than_int =
    9983                 :      161212 :     (tree_int_cst_lt (minnode, TYPE_MIN_VALUE (integer_type_node))
    9984                 :      161212 :      || tree_int_cst_lt (TYPE_MAX_VALUE (integer_type_node), maxnode));
    9985                 :             : 
    9986                 :             : 
    9987                 :      161212 :   if (!ENUM_FIXED_UNDERLYING_TYPE_P (enumtype))
    9988                 :             :     {
    9989                 :             :       /* If the precision of the type was specified with an attribute and it
    9990                 :             :          was too small, give an error.  Otherwise, use it.  */
    9991                 :      161104 :       if (TYPE_PRECISION (enumtype) && lookup_attribute ("mode", attributes))
    9992                 :             :         {
    9993                 :          23 :           if (precision > TYPE_PRECISION (enumtype))
    9994                 :             :             {
    9995                 :           6 :               TYPE_PRECISION (enumtype) = 0;
    9996                 :           6 :               error ("specified mode too small for enumerated values");
    9997                 :             :             }
    9998                 :             :           else
    9999                 :          17 :             precision = TYPE_PRECISION (enumtype);
   10000                 :             :         }
   10001                 :             :       else
   10002                 :      161081 :         TYPE_PRECISION (enumtype) = 0;
   10003                 :             : 
   10004                 :      161104 :       if (TYPE_PACKED (enumtype)
   10005                 :      161030 :           || precision > TYPE_PRECISION (integer_type_node)
   10006                 :      320477 :           || TYPE_PRECISION (enumtype))
   10007                 :             :         {
   10008                 :        1858 :           tem = c_common_type_for_size (precision, sign == UNSIGNED ? 1 : 0);
   10009                 :        1743 :           if (tem == NULL)
   10010                 :             :             {
   10011                 :             :               /* This should only occur when both signed and unsigned
   10012                 :             :                  values of maximum precision occur among the
   10013                 :             :                  enumerators.  */
   10014                 :           3 :               pedwarn (input_location, 0,
   10015                 :             :                        "enumeration values exceed range of largest integer");
   10016                 :           3 :               tem = widest_integer_literal_type_node;
   10017                 :             :             }
   10018                 :        1740 :           else if (precision > TYPE_PRECISION (intmax_type_node)
   10019                 :           4 :                    && !tree_int_cst_lt (minnode,
   10020                 :           4 :                                         TYPE_MIN_VALUE (intmax_type_node))
   10021                 :        1743 :                    && !tree_int_cst_lt (TYPE_MAX_VALUE (uintmax_type_node),
   10022                 :             :                                         maxnode))
   10023                 :           2 :             pedwarn (input_location, OPT_Wpedantic,
   10024                 :             :                      "enumeration values exceed range of %qs",
   10025                 :             :                      sign == UNSIGNED ? "uintmax_t" : "intmax_t");
   10026                 :             :         }
   10027                 :             :       else
   10028                 :      159361 :         tem = sign == UNSIGNED ? unsigned_type_node : integer_type_node;
   10029                 :             : 
   10030                 :      161104 :       TYPE_MIN_VALUE (enumtype) = TYPE_MIN_VALUE (tem);
   10031                 :      161104 :       TYPE_MAX_VALUE (enumtype) = TYPE_MAX_VALUE (tem);
   10032                 :      161104 :       TYPE_UNSIGNED (enumtype) = TYPE_UNSIGNED (tem);
   10033                 :      161104 :       SET_TYPE_ALIGN (enumtype, TYPE_ALIGN (tem));
   10034                 :      161104 :       TYPE_SIZE (enumtype) = NULL_TREE;
   10035                 :      161104 :       TYPE_PRECISION (enumtype) = TYPE_PRECISION (tem);
   10036                 :      161104 :       ENUM_UNDERLYING_TYPE (enumtype) =
   10037                 :      161104 :         c_common_type_for_size (TYPE_PRECISION (tem), TYPE_UNSIGNED (tem));
   10038                 :             : 
   10039                 :      161104 :       layout_type (enumtype);
   10040                 :             :     }
   10041                 :             : 
   10042                 :      161212 :   if (values != error_mark_node)
   10043                 :             :     {
   10044                 :             :       /* Change the type of the enumerators to be the enum type.  We
   10045                 :             :          need to do this irrespective of the size of the enum, for
   10046                 :             :          proper type checking.  Replace the DECL_INITIALs of the
   10047                 :             :          enumerators, and the value slots of the list, with copies
   10048                 :             :          that have the enum type; they cannot be modified in place
   10049                 :             :          because they may be shared (e.g.  integer_zero_node) Finally,
   10050                 :             :          change the purpose slots to point to the names of the decls.  */
   10051                 :     5509446 :       for (pair = values; pair; pair = TREE_CHAIN (pair))
   10052                 :             :         {
   10053                 :     5348258 :           tree enu = TREE_PURPOSE (pair);
   10054                 :     5348258 :           tree ini = DECL_INITIAL (enu);
   10055                 :             : 
   10056                 :     5348258 :           TREE_TYPE (enu) = enumtype;
   10057                 :             : 
   10058                 :             :           /* Before C23, the ISO C Standard mandates enumerators to
   10059                 :             :              have type int, even though the underlying type of an enum
   10060                 :             :              type is unspecified.  However, C23 allows enumerators of
   10061                 :             :              any integer type, and if an enumeration has any
   10062                 :             :              enumerators wider than int, all enumerators have the
   10063                 :             :              enumerated type after it is parsed.  Any enumerators that
   10064                 :             :              fit in int are given type int in build_enumerator (which
   10065                 :             :              is the correct type while the enumeration is being
   10066                 :             :              parsed), so no conversions are needed here if all
   10067                 :             :              enumerators fit in int.  If the enum has a fixed
   10068                 :             :              underlying type, the correct type was also given in
   10069                 :             :              build_enumerator.  */
   10070                 :     5348258 :           if (!ENUM_FIXED_UNDERLYING_TYPE_P (enumtype) && wider_than_int)
   10071                 :       22296 :             ini = convert (enumtype, ini);
   10072                 :             : 
   10073                 :     5348258 :           DECL_INITIAL (enu) = ini;
   10074                 :     5348258 :           TREE_PURPOSE (pair) = DECL_NAME (enu);
   10075                 :             :           /* To match the C++ FE, store the CONST_DECL rather than just its
   10076                 :             :              value.  */
   10077                 :     5348258 :           TREE_VALUE (pair) = enu;
   10078                 :             :         }
   10079                 :             : 
   10080                 :      161188 :       TYPE_VALUES (enumtype) = values;
   10081                 :             :     }
   10082                 :             : 
   10083                 :             :   /* Record the min/max values so that we can warn about bit-field
   10084                 :             :      enumerations that are too small for the values.  */
   10085                 :      161212 :   lt = ggc_cleared_alloc<struct lang_type> ();
   10086                 :      161212 :   lt->enum_min = minnode;
   10087                 :      161212 :   lt->enum_max = maxnode;
   10088                 :      161212 :   TYPE_LANG_SPECIFIC (enumtype) = lt;
   10089                 :             : 
   10090                 :             :   /* Fix up all variant types of this enum type.  */
   10091                 :      161212 :   tree incomplete_vars = C_TYPE_INCOMPLETE_VARS (TYPE_MAIN_VARIANT (enumtype));
   10092                 :      322432 :   for (tem = TYPE_MAIN_VARIANT (enumtype); tem; tem = TYPE_NEXT_VARIANT (tem))
   10093                 :             :     {
   10094                 :      161220 :       C_TYPE_INCOMPLETE_VARS (tem) = NULL_TREE;
   10095                 :      161220 :       if (tem == enumtype)
   10096                 :      161212 :         continue;
   10097                 :           8 :       TYPE_VALUES (tem) = TYPE_VALUES (enumtype);
   10098                 :           8 :       TYPE_MIN_VALUE (tem) = TYPE_MIN_VALUE (enumtype);
   10099                 :           8 :       TYPE_MAX_VALUE (tem) = TYPE_MAX_VALUE (enumtype);
   10100                 :           8 :       TYPE_SIZE (tem) = TYPE_SIZE (enumtype);
   10101                 :           8 :       TYPE_SIZE_UNIT (tem) = TYPE_SIZE_UNIT (enumtype);
   10102                 :           8 :       SET_TYPE_MODE (tem, TYPE_MODE (enumtype));
   10103                 :           8 :       TYPE_PRECISION (tem) = TYPE_PRECISION (enumtype);
   10104                 :           8 :       SET_TYPE_ALIGN (tem, TYPE_ALIGN (enumtype));
   10105                 :           8 :       TYPE_USER_ALIGN (tem) = TYPE_USER_ALIGN (enumtype);
   10106                 :           8 :       TYPE_UNSIGNED (tem) = TYPE_UNSIGNED (enumtype);
   10107                 :           8 :       TYPE_LANG_SPECIFIC (tem) = TYPE_LANG_SPECIFIC (enumtype);
   10108                 :           8 :       ENUM_UNDERLYING_TYPE (tem) = ENUM_UNDERLYING_TYPE (enumtype);
   10109                 :             :     }
   10110                 :             : 
   10111                 :             :   /* Finish debugging output for this type.  */
   10112                 :      161212 :   rest_of_type_compilation (enumtype, toplevel);
   10113                 :             : 
   10114                 :      161212 :   finish_incomplete_vars (incomplete_vars, toplevel);
   10115                 :             : 
   10116                 :             :   /* If this enum is defined inside a struct, add it to
   10117                 :             :      struct_types.  */
   10118                 :      161212 :   if (warn_cxx_compat
   10119                 :         113 :       && struct_parse_info != NULL
   10120                 :          37 :       && !in_sizeof && !in_typeof && !in_alignof)
   10121                 :          37 :     struct_parse_info->struct_types.safe_push (enumtype);
   10122                 :             : 
   10123                 :             :   /* Check for consistency with previous definition */
   10124                 :      161212 :   if (flag_isoc23)
   10125                 :             :     {
   10126                 :         398 :       tree vistype = previous_tag (enumtype);
   10127                 :         398 :       if (vistype
   10128                 :          17 :           && TREE_CODE (vistype) == TREE_CODE (enumtype)
   10129                 :         411 :           && !C_TYPE_BEING_DEFINED (vistype))
   10130                 :             :         {
   10131                 :          13 :           TYPE_STUB_DECL (vistype) = TYPE_STUB_DECL (enumtype);
   10132                 :          13 :           if (!comptypes_same_p (enumtype, vistype))
   10133                 :           3 :             error("conflicting redefinition of enum %qT", enumtype);
   10134                 :             :         }
   10135                 :             :     }
   10136                 :             : 
   10137                 :      161212 :   C_TYPE_BEING_DEFINED (enumtype) = 0;
   10138                 :             : 
   10139                 :      161212 :   return enumtype;
   10140                 :             : }
   10141                 :             : 
   10142                 :             : /* Build and install a CONST_DECL for one value of the
   10143                 :             :    current enumeration type (one that was begun with start_enum).
   10144                 :             :    DECL_LOC is the location of the enumerator.
   10145                 :             :    LOC is the location of the '=' operator if any, DECL_LOC otherwise.
   10146                 :             :    Return a tree-list containing the CONST_DECL and its value.
   10147                 :             :    Assignment of sequential values by default is handled here.  */
   10148                 :             : 
   10149                 :             : tree
   10150                 :     5348275 : build_enumerator (location_t decl_loc, location_t loc,
   10151                 :             :                   struct c_enum_contents *the_enum, tree name, tree value)
   10152                 :             : {
   10153                 :     5348275 :   tree decl;
   10154                 :             : 
   10155                 :             :   /* Validate and default VALUE.  */
   10156                 :             : 
   10157                 :     5348275 :   if (value != NULL_TREE)
   10158                 :             :     {
   10159                 :             :       /* Don't issue more errors for error_mark_node (i.e. an
   10160                 :             :          undeclared identifier) - just ignore the value expression.  */
   10161                 :     3279230 :       if (value == error_mark_node)
   10162                 :             :         value = NULL_TREE;
   10163                 :     3278565 :       else if (!INTEGRAL_TYPE_P (TREE_TYPE (value)))
   10164                 :             :         {
   10165                 :           6 :           error_at (loc, "enumerator value for %qE is not an integer constant",
   10166                 :             :                     name);
   10167                 :           6 :           value = NULL_TREE;
   10168                 :             :         }
   10169                 :             :       else
   10170                 :             :         {
   10171                 :     3278559 :           if (TREE_CODE (value) != INTEGER_CST)
   10172                 :             :             {
   10173                 :         101 :               value = c_fully_fold (value, false, NULL);
   10174                 :         101 :               if (TREE_CODE (value) == INTEGER_CST)
   10175                 :          52 :                 pedwarn (loc, OPT_Wpedantic,
   10176                 :             :                          "enumerator value for %qE is not an integer "
   10177                 :             :                          "constant expression", name);
   10178                 :             :             }
   10179                 :     3278559 :           if (TREE_CODE (value) != INTEGER_CST)
   10180                 :             :             {
   10181                 :          49 :               error ("enumerator value for %qE is not an integer constant",
   10182                 :             :                      name);
   10183                 :          49 :               value = NULL_TREE;
   10184                 :             :             }
   10185                 :             :           else
   10186                 :             :             {
   10187                 :     3278510 :               value = default_conversion (value);
   10188                 :     3278510 :               constant_expression_warning (value);
   10189                 :             :             }
   10190                 :             :         }
   10191                 :             :     }
   10192                 :             : 
   10193                 :             :   /* Default based on previous value.  */
   10194                 :             :   /* It should no longer be possible to have NON_LVALUE_EXPR
   10195                 :             :      in the default.  */
   10196                 :     3278565 :   if (value == NULL_TREE)
   10197                 :             :     {
   10198                 :     2069765 :       value = the_enum->enum_next_value;
   10199                 :     2069765 :       if (the_enum->enum_overflow)
   10200                 :           7 :         error_at (loc, "overflow in enumeration values");
   10201                 :             :     }
   10202                 :     5348275 :   if (ENUM_FIXED_UNDERLYING_TYPE_P (the_enum->enum_type))
   10203                 :             :     {
   10204                 :             :       /* Enumeration constants must fit in the fixed underlying type.  */
   10205                 :         149 :       if (!int_fits_type_p (value, ENUM_UNDERLYING_TYPE (the_enum->enum_type)))
   10206                 :           3 :         error_at (loc,
   10207                 :             :                   "enumerator value outside the range of underlying type");
   10208                 :             :       /* Enumeration constants for an enum with fixed underlying type
   10209                 :             :          have the enum type, both inside and outside the
   10210                 :             :          definition.  */
   10211                 :         149 :       value = convert (the_enum->enum_type, value);
   10212                 :             :     }
   10213                 :             :   else
   10214                 :             :     {
   10215                 :             :       /* Even though the underlying type of an enum is unspecified, the
   10216                 :             :          type of enumeration constants is explicitly defined as int
   10217                 :             :          (6.4.4.3/2 in the C99 Standard).  C23 allows any integer type, and
   10218                 :             :          GCC allows such types for older standards as an extension.  */
   10219                 :     5348126 :       bool warned_range = false;
   10220                 :     5348126 :       if (!int_fits_type_p (value,
   10221                 :     5348126 :                             (TYPE_UNSIGNED (TREE_TYPE (value))
   10222                 :             :                              ? uintmax_type_node
   10223                 :             :                              : intmax_type_node)))
   10224                 :             :         /* GCC does not consider its types larger than intmax_t to be
   10225                 :             :            extended integer types (although C23 would permit such types to
   10226                 :             :            be considered extended integer types if all the features
   10227                 :             :            required by <stdint.h> and <inttypes.h> macros, such as support
   10228                 :             :            for integer constants and I/O, were present), so diagnose if
   10229                 :             :            such a wider type is used.  (If the wider type arose from a
   10230                 :             :            constant of such a type, that will also have been diagnosed,
   10231                 :             :            but this is the only diagnostic in the case where it arises
   10232                 :             :            from choosing a wider type automatically when adding 1
   10233                 :             :            overflows.)  */
   10234                 :          11 :         warned_range = pedwarn (loc, OPT_Wpedantic,
   10235                 :             :                                 "enumerator value outside the range of %qs",
   10236                 :          11 :                                 (TYPE_UNSIGNED (TREE_TYPE (value))
   10237                 :             :                                  ? "uintmax_t"
   10238                 :             :                                  : "intmax_t"));
   10239                 :     5348126 :       if (!warned_range && !int_fits_type_p (value, integer_type_node))
   10240                 :        3547 :         pedwarn_c11 (loc, OPT_Wpedantic,
   10241                 :             :                      "ISO C restricts enumerator values to range of %<int%> "
   10242                 :             :                      "before C23");
   10243                 :             : 
   10244                 :             :       /* The ISO C Standard mandates enumerators to have type int before
   10245                 :             :          C23, even though the underlying type of an enum type is
   10246                 :             :          unspecified.  C23 allows enumerators of any integer type.  During
   10247                 :             :          the parsing of the enumeration, C23 specifies that constants
   10248                 :             :          representable in int have type int, constants not representable
   10249                 :             :          in int have the type of the given expression if any, and
   10250                 :             :          constants not representable in int and derived by adding 1 to the
   10251                 :             :          previous constant have the type of that constant unless the
   10252                 :             :          addition would overflow or wraparound, in which case a wider type
   10253                 :             :          of the same signedness is chosen automatically; after the
   10254                 :             :          enumeration is parsed, all the constants have the type of the
   10255                 :             :          enumeration if any do not fit in int.  */
   10256                 :     5348126 :       if (int_fits_type_p (value, integer_type_node))
   10257                 :     5344575 :         value = convert (integer_type_node, value);
   10258                 :             :     }
   10259                 :             : 
   10260                 :             :   /* Set basis for default for next value.  */
   10261                 :     5348275 :   if (ENUM_FIXED_UNDERLYING_TYPE_P (the_enum->enum_type))
   10262                 :             :     {
   10263                 :         149 :       tree underlying_type = ENUM_UNDERLYING_TYPE (the_enum->enum_type);
   10264                 :         149 :       if (TREE_CODE (underlying_type) == BOOLEAN_TYPE)
   10265                 :             :         /* A value of 2 following a value of 1 overflows bool, but we
   10266                 :             :            cannot carry out addition directly on bool without
   10267                 :             :            promotion, and converting the result of arithmetic in a
   10268                 :             :            wider type back to bool would not produce the right result
   10269                 :             :            for this overflow check.  */
   10270                 :          60 :         the_enum->enum_next_value = invert_truthvalue_loc (loc, value);
   10271                 :             :       else
   10272                 :          89 :         the_enum->enum_next_value
   10273                 :          89 :           = build_binary_op (EXPR_LOC_OR_LOC (value, input_location),
   10274                 :             :                              PLUS_EXPR, convert (underlying_type, value),
   10275                 :             :                              convert (underlying_type, integer_one_node),
   10276                 :             :                              false);
   10277                 :             :     }
   10278                 :             :   else
   10279                 :     5348126 :     the_enum->enum_next_value
   10280                 :     5348126 :       = build_binary_op (EXPR_LOC_OR_LOC (value, input_location),
   10281                 :             :                          PLUS_EXPR, value, integer_one_node, false);
   10282                 :     5348275 :   the_enum->enum_overflow = tree_int_cst_lt (the_enum->enum_next_value, value);
   10283                 :     5348275 :   if (the_enum->enum_overflow
   10284                 :     5348275 :       && !ENUM_FIXED_UNDERLYING_TYPE_P (the_enum->enum_type))
   10285                 :             :     {
   10286                 :             :       /* Choose a wider type with the same signedness if
   10287                 :             :          available.  */
   10288                 :        2279 :       int prec = TYPE_PRECISION (TREE_TYPE (value)) + 1;
   10289                 :        2279 :       bool unsignedp = TYPE_UNSIGNED (TREE_TYPE (value));
   10290                 :        4558 :       tree new_type = (unsignedp
   10291                 :        2279 :                        ? long_unsigned_type_node
   10292                 :             :                        : long_integer_type_node);
   10293                 :        2279 :       if (prec > TYPE_PRECISION (new_type))
   10294                 :        1920 :         new_type = (unsignedp
   10295                 :        1920 :                     ? long_long_unsigned_type_node
   10296                 :             :                     : long_long_integer_type_node);
   10297                 :        2279 :       if (prec > TYPE_PRECISION (new_type))
   10298                 :        1546 :         new_type = (unsignedp
   10299                 :        1546 :                     ? widest_unsigned_literal_type_node
   10300                 :             :                     : widest_integer_literal_type_node);
   10301                 :        2279 :       if (prec <= TYPE_PRECISION (new_type))
   10302                 :             :         {
   10303                 :        2274 :           the_enum->enum_overflow = false;
   10304                 :        2274 :           the_enum->enum_next_value
   10305                 :        2274 :             = build_binary_op (EXPR_LOC_OR_LOC (value, input_location),
   10306                 :             :                                PLUS_EXPR, convert (new_type, value),
   10307                 :             :                                integer_one_node, false);
   10308                 :        2274 :           gcc_assert (!tree_int_cst_lt (the_enum->enum_next_value, value));
   10309                 :             :         }
   10310                 :             :     }
   10311                 :             : 
   10312                 :             :   /* Now create a declaration for the enum value name.  */
   10313                 :             : 
   10314                 :     5348275 :   decl = build_decl (decl_loc, CONST_DECL, name, TREE_TYPE (value));
   10315                 :     5348275 :   DECL_INITIAL (decl) = value;
   10316                 :     5348275 :   DECL_CONTEXT (decl) = the_enum->enum_type;
   10317                 :     5348275 :   pushdecl (decl);
   10318                 :             : 
   10319                 :     5348275 :   return tree_cons (decl, value, NULL_TREE);
   10320                 :             : }
   10321                 :             : 
   10322                 :             : /* Implement LANG_HOOKS_SIMULATE_ENUM_DECL.  */
   10323                 :             : 
   10324                 :             : tree
   10325                 :           0 : c_simulate_enum_decl (location_t loc, const char *name,
   10326                 :             :                       vec<string_int_pair> *values_ptr)
   10327                 :             : {
   10328                 :           0 :   location_t saved_loc = input_location;
   10329                 :           0 :   input_location = loc;
   10330                 :             : 
   10331                 :           0 :   struct c_enum_contents the_enum;
   10332                 :           0 :   tree enumtype = start_enum (loc, &the_enum, get_identifier (name),
   10333                 :             :                               NULL_TREE, false);
   10334                 :             : 
   10335                 :           0 :   tree value_chain = NULL_TREE;
   10336                 :           0 :   string_int_pair *value;
   10337                 :           0 :   vec<string_int_pair> values = *values_ptr;
   10338                 :           0 :   unsigned int i;
   10339                 :           0 :   FOR_EACH_VEC_ELT (values, i, value)
   10340                 :             :     {
   10341                 :           0 :       tree decl = build_enumerator (loc, loc, &the_enum,
   10342                 :             :                                     get_identifier (value->first),
   10343                 :             :                                     build_int_cst (integer_type_node,
   10344                 :           0 :                                                    value->second));
   10345                 :           0 :       TREE_CHAIN (decl) = value_chain;
   10346                 :           0 :       value_chain = decl;
   10347                 :             :     }
   10348                 :             : 
   10349                 :           0 :   finish_enum (enumtype, nreverse (value_chain), NULL_TREE);
   10350                 :             : 
   10351                 :           0 :   input_location = saved_loc;
   10352                 :           0 :   return enumtype;
   10353                 :             : }
   10354                 :             : 
   10355                 :             : /* Implement LANG_HOOKS_SIMULATE_RECORD_DECL.  */
   10356                 :             : 
   10357                 :             : tree
   10358                 :           0 : c_simulate_record_decl (location_t loc, const char *name,
   10359                 :             :                         array_slice<const tree> fields)
   10360                 :             : {
   10361                 :           0 :   location_t saved_loc = input_location;
   10362                 :           0 :   input_location = loc;
   10363                 :             : 
   10364                 :           0 :   class c_struct_parse_info *struct_info;
   10365                 :           0 :   tree ident = get_identifier (name);
   10366                 :           0 :   tree type = start_struct (loc, RECORD_TYPE, ident, &struct_info);
   10367                 :             : 
   10368                 :           0 :   for (unsigned int i = 0; i < fields.size (); ++i)
   10369                 :             :     {
   10370                 :           0 :       DECL_FIELD_CONTEXT (fields[i]) = type;
   10371                 :           0 :       if (i > 0)
   10372                 :           0 :         DECL_CHAIN (fields[i - 1]) = fields[i];
   10373                 :             :     }
   10374                 :             : 
   10375                 :           0 :   finish_struct (loc, type, fields[0], NULL_TREE, struct_info);
   10376                 :             : 
   10377                 :           0 :   tree decl = build_decl (loc, TYPE_DECL, ident, type);
   10378                 :           0 :   set_underlying_type (decl);
   10379                 :           0 :   lang_hooks.decls.pushdecl (decl);
   10380                 :             : 
   10381                 :           0 :   input_location = saved_loc;
   10382                 :           0 :   return type;
   10383                 :             : }
   10384                 :             : 
   10385                 :             : /* Create the FUNCTION_DECL for a function definition.
   10386                 :             :    DECLSPECS, DECLARATOR and ATTRIBUTES are the parts of
   10387                 :             :    the declaration; they describe the function's name and the type it returns,
   10388                 :             :    but twisted together in a fashion that parallels the syntax of C.
   10389                 :             : 
   10390                 :             :    This function creates a binding context for the function body
   10391                 :             :    as well as setting up the FUNCTION_DECL in current_function_decl.
   10392                 :             : 
   10393                 :             :    Returns true on success.  If the DECLARATOR is not suitable for a function
   10394                 :             :    (it defines a datum instead), we return false to report a parse error.  */
   10395                 :             : 
   10396                 :             : bool
   10397                 :    31761938 : start_function (struct c_declspecs *declspecs, struct c_declarator *declarator,
   10398                 :             :                 tree attributes)
   10399                 :             : {
   10400                 :    31761938 :   tree decl1, old_decl;
   10401                 :    31761938 :   tree restype, resdecl;
   10402                 :    31761938 :   location_t loc;
   10403                 :    31761938 :   location_t result_loc;
   10404                 :    31761938 :   tree expr = NULL;
   10405                 :             : 
   10406                 :    31761938 :   current_function_returns_value = 0;  /* Assume, until we see it does.  */
   10407                 :    31761938 :   current_function_returns_null = 0;
   10408                 :    31761938 :   current_function_returns_abnormally = 0;
   10409                 :    31761938 :   warn_about_return_type = 0;
   10410                 :    31761938 :   c_switch_stack = NULL;
   10411                 :             : 
   10412                 :             :   /* Indicate no valid break/continue context.  */
   10413                 :    31761938 :   in_statement = 0;
   10414                 :             : 
   10415                 :    31761938 :   decl1 = grokdeclarator (declarator, declspecs, FUNCDEF, true, NULL,
   10416                 :             :                           &attributes, &expr, NULL, DEPRECATED_NORMAL);
   10417                 :    31761938 :   invoke_plugin_callbacks (PLUGIN_START_PARSE_FUNCTION, decl1);
   10418                 :             : 
   10419                 :             :   /* If the declarator is not suitable for a function definition,
   10420                 :             :      cause a syntax error.  */
   10421                 :    31761938 :   if (decl1 == NULL_TREE
   10422                 :    31761907 :       || TREE_CODE (decl1) != FUNCTION_DECL)
   10423                 :             :     return false;
   10424                 :             : 
   10425                 :             :   /* Nested functions may have variably modified (return) type.
   10426                 :             :      Make sure the size expression is evaluated at this point.  */
   10427                 :    31761900 :   if (expr && !current_scope->parm_flag)
   10428                 :           6 :     add_stmt (fold_convert (void_type_node, expr));
   10429                 :             : 
   10430                 :    31761900 :   loc = DECL_SOURCE_LOCATION (decl1);
   10431                 :             : 
   10432                 :             :   /* A nested function is not global.  */
   10433                 :    31761900 :   if (current_function_decl != NULL_TREE)
   10434                 :        1511 :     TREE_PUBLIC (decl1) = 0;
   10435                 :             : 
   10436                 :    31761900 :   c_decl_attributes (&decl1, attributes, 0);
   10437                 :             : 
   10438                 :    31761900 :   if (DECL_DECLARED_INLINE_P (decl1)
   10439                 :    31105399 :       && DECL_UNINLINABLE (decl1)
   10440                 :    31761910 :       && lookup_attribute ("noinline", DECL_ATTRIBUTES (decl1)))
   10441                 :           3 :     warning_at (loc, OPT_Wattributes,
   10442                 :             :                 "inline function %qD given attribute %qs",
   10443                 :             :                 decl1, "noinline");
   10444                 :             : 
   10445                 :             :   /* Handle gnu_inline attribute.  */
   10446                 :    31761900 :   if (declspecs->inline_p
   10447                 :    31105402 :       && !flag_gnu89_inline
   10448                 :    31094750 :       && TREE_CODE (decl1) == FUNCTION_DECL
   10449                 :    62856650 :       && (lookup_attribute ("gnu_inline", DECL_ATTRIBUTES (decl1))
   10450                 :      149583 :           || current_function_decl))
   10451                 :             :     {
   10452                 :    30945239 :       if (declspecs->storage_class != csc_static)
   10453                 :    30945233 :         DECL_EXTERNAL (decl1) = !DECL_EXTERNAL (decl1);
   10454                 :             :     }
   10455                 :             : 
   10456                 :    31761900 :   announce_function (decl1);
   10457                 :             : 
   10458                 :    31761900 :   if (!COMPLETE_OR_VOID_TYPE_P (TREE_TYPE (TREE_TYPE (decl1))))
   10459                 :             :     {
   10460                 :           1 :       error_at (loc, "return type is an incomplete type");
   10461                 :             :       /* Make it return void instead.  */
   10462                 :           1 :       TREE_TYPE (decl1)
   10463                 :           2 :         = build_function_type (void_type_node,
   10464                 :           1 :                                TYPE_ARG_TYPES (TREE_TYPE (decl1)),
   10465                 :           1 :                                TYPE_NO_NAMED_ARGS_STDARG_P (TREE_TYPE (decl1)));
   10466                 :             :     }
   10467                 :             : 
   10468                 :    31761900 :   if (warn_about_return_type)
   10469                 :        1404 :     permerror_opt (loc, flag_isoc99 ? OPT_Wimplicit_int
   10470                 :           0 :                    : (warn_return_type > 0 ? OPT_Wreturn_type
   10471                 :             :                       : OPT_Wimplicit_int),
   10472                 :             :                    "return type defaults to %<int%>");
   10473                 :             : 
   10474                 :             :   /* Make the init_value nonzero so pushdecl knows this is not tentative.
   10475                 :             :      error_mark_node is replaced below (in pop_scope) with the BLOCK.  */
   10476                 :    31761900 :   DECL_INITIAL (decl1) = error_mark_node;
   10477                 :             : 
   10478                 :             :   /* If this definition isn't a prototype and we had a prototype declaration
   10479                 :             :      before, copy the arg type info from that prototype.  */
   10480                 :    31761900 :   old_decl = lookup_name_in_scope (DECL_NAME (decl1), current_scope);
   10481                 :    31761900 :   if (old_decl && TREE_CODE (old_decl) != FUNCTION_DECL)
   10482                 :    31546520 :     old_decl = NULL_TREE;
   10483                 :             : 
   10484                 :    31761900 :   current_function_prototype_locus = UNKNOWN_LOCATION;
   10485                 :    31761900 :   current_function_prototype_built_in = false;
   10486                 :    31761900 :   current_function_prototype_arg_types = NULL_TREE;
   10487                 :    31761900 :   tree newtype = TREE_TYPE (decl1);
   10488                 :    31761900 :   tree oldtype = old_decl ? TREE_TYPE (old_decl) : newtype;
   10489                 :    31761900 :   if (!prototype_p (newtype))
   10490                 :             :     {
   10491                 :       61147 :       tree oldrt = TREE_TYPE (oldtype);
   10492                 :       61147 :       tree newrt = TREE_TYPE (newtype);
   10493                 :       61147 :       if (old_decl != NULL_TREE
   10494                 :        5115 :           && TREE_CODE (oldtype) == FUNCTION_TYPE
   10495                 :       66262 :           && comptypes (oldrt, newrt))
   10496                 :             :         {
   10497                 :        5097 :           if (stdarg_p (oldtype))
   10498                 :             :             {
   10499                 :           1 :               auto_diagnostic_group d;
   10500                 :           1 :               warning_at (loc, 0, "%q+D defined as variadic function "
   10501                 :             :                           "without prototype", decl1);
   10502                 :           1 :               locate_old_decl (old_decl);
   10503                 :           1 :             }
   10504                 :        5097 :           TREE_TYPE (decl1) = composite_type (oldtype, newtype);
   10505                 :        5097 :           current_function_prototype_locus = DECL_SOURCE_LOCATION (old_decl);
   10506                 :        5097 :           current_function_prototype_built_in
   10507                 :        5097 :             = C_DECL_BUILTIN_PROTOTYPE (old_decl);
   10508                 :        5097 :           current_function_prototype_arg_types
   10509                 :        5097 :             = TYPE_ARG_TYPES (newtype);
   10510                 :             :         }
   10511                 :       61147 :       if (TREE_PUBLIC (decl1))
   10512                 :             :         {
   10513                 :             :           /* If there is an external prototype declaration of this
   10514                 :             :              function, record its location but do not copy information
   10515                 :             :              to this decl.  This may be an invisible declaration
   10516                 :             :              (built-in or in a scope which has finished) or simply
   10517                 :             :              have more refined argument types than any declaration
   10518                 :             :              found above.  */
   10519                 :       58980 :           struct c_binding *b;
   10520                 :       63841 :           for (b = I_SYMBOL_BINDING (DECL_NAME (decl1)); b; b = b->shadowed)
   10521                 :        9766 :             if (B_IN_SCOPE (b, external_scope))
   10522                 :             :               break;
   10523                 :       58980 :           if (b)
   10524                 :             :             {
   10525                 :        4905 :               tree ext_decl, ext_type;
   10526                 :        4905 :               ext_decl = b->decl;
   10527                 :        4905 :               ext_type = b->u.type ? b->u.type : TREE_TYPE (ext_decl);
   10528                 :        4905 :               if (TREE_CODE (ext_type) == FUNCTION_TYPE
   10529                 :        9809 :                   && comptypes (TREE_TYPE (TREE_TYPE (decl1)),
   10530                 :        4904 :                                 TREE_TYPE (ext_type)))
   10531                 :             :                 {
   10532                 :        4885 :                   current_function_prototype_locus
   10533                 :        4885 :                     = DECL_SOURCE_LOCATION (ext_decl);
   10534                 :        4885 :                   current_function_prototype_built_in
   10535                 :        4885 :                     = C_DECL_BUILTIN_PROTOTYPE (ext_decl);
   10536                 :        4885 :                   current_function_prototype_arg_types
   10537                 :        4885 :                     = TYPE_ARG_TYPES (ext_type);
   10538                 :             :                 }
   10539                 :             :             }
   10540                 :             :         }
   10541                 :             :     }
   10542                 :             : 
   10543                 :             :   /* Optionally warn of old-fashioned def with no previous prototype.  */
   10544                 :    31761900 :   if (warn_strict_prototypes
   10545                 :       96455 :       && old_decl != error_mark_node
   10546                 :       96455 :       && !prototype_p (TREE_TYPE (decl1))
   10547                 :    31761903 :       && C_DECL_ISNT_PROTOTYPE (old_decl))
   10548                 :           3 :     warning_at (loc, OPT_Wstrict_prototypes,
   10549                 :             :                 "function declaration isn%'t a prototype");
   10550                 :             :   /* Optionally warn of any global def with no previous prototype.  */
   10551                 :    31761897 :   else if (warn_missing_prototypes
   10552                 :       96156 :            && old_decl != error_mark_node
   10553                 :       96156 :            && TREE_PUBLIC (decl1)
   10554                 :       65562 :            && !MAIN_NAME_P (DECL_NAME (decl1))
   10555                 :       65527 :            && C_DECL_ISNT_PROTOTYPE (old_decl)
   10556                 :    31762538 :            && !DECL_DECLARED_INLINE_P (decl1))
   10557                 :           4 :     warning_at (loc, OPT_Wmissing_prototypes,
   10558                 :             :                 "no previous prototype for %qD", decl1);
   10559                 :             :   /* Optionally warn of any def with no previous prototype
   10560                 :             :      if the function has already been used.  */
   10561                 :    31761893 :   else if (warn_missing_prototypes
   10562                 :       96152 :            && old_decl != NULL_TREE
   10563                 :       65869 :            && old_decl != error_mark_node
   10564                 :       65869 :            && TREE_USED (old_decl)
   10565                 :    31768123 :            && !prototype_p (TREE_TYPE (old_decl)))
   10566                 :           0 :     warning_at (loc, OPT_Wmissing_prototypes,
   10567                 :             :                 "%qD was used with no prototype before its definition", decl1);
   10568                 :             :   /* Optionally warn of any global def with no previous declaration.  */
   10569                 :    31761893 :   else if (warn_missing_declarations
   10570                 :           4 :            && TREE_PUBLIC (decl1)
   10571                 :           3 :            && old_decl == NULL_TREE
   10572                 :           3 :            && !MAIN_NAME_P (DECL_NAME (decl1))
   10573                 :    31761896 :            && !DECL_DECLARED_INLINE_P (decl1))
   10574                 :           2 :     warning_at (loc, OPT_Wmissing_declarations,
   10575                 :             :                 "no previous declaration for %qD",
   10576                 :             :                 decl1);
   10577                 :             :   /* Optionally warn of any def with no previous declaration
   10578                 :             :      if the function has already been used.  */
   10579                 :    31761891 :   else if (warn_missing_declarations
   10580                 :           2 :            && old_decl != NULL_TREE
   10581                 :           0 :            && old_decl != error_mark_node
   10582                 :           0 :            && TREE_USED (old_decl)
   10583                 :    31761891 :            && C_DECL_IMPLICIT (old_decl))
   10584                 :           0 :     warning_at (loc, OPT_Wmissing_declarations,
   10585                 :             :                 "%qD was used with no declaration before its definition", decl1);
   10586                 :             : 
   10587                 :             :   /* This function exists in static storage.
   10588                 :             :      (This does not mean `static' in the C sense!)  */
   10589                 :    31761900 :   TREE_STATIC (decl1) = 1;
   10590                 :             : 
   10591                 :             :   /* This is the earliest point at which we might know the assembler
   10592                 :             :      name of the function.  Thus, if it's set before this, die horribly.  */
   10593                 :    31761900 :   gcc_assert (!DECL_ASSEMBLER_NAME_SET_P (decl1));
   10594                 :             : 
   10595                 :             :   /* If #pragma weak was used, mark the decl weak now.  */
   10596                 :    31761900 :   if (current_scope == file_scope)
   10597                 :    31760389 :     maybe_apply_pragma_weak (decl1);
   10598                 :             : 
   10599                 :             :   /* Warn for unlikely, improbable, or stupid declarations of `main'.  */
   10600                 :    31761900 :   if (warn_main && MAIN_NAME_P (DECL_NAME (decl1)))
   10601                 :             :     {
   10602                 :        3101 :       if (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (decl1)))
   10603                 :        3101 :           != integer_type_node)
   10604                 :           5 :         pedwarn (loc, OPT_Wmain, "return type of %qD is not %<int%>", decl1);
   10605                 :        3096 :       else if (TYPE_ATOMIC (TREE_TYPE (TREE_TYPE (decl1))))
   10606                 :           1 :         pedwarn (loc, OPT_Wmain, "%<_Atomic%>-qualified return type of %qD",
   10607                 :             :                  decl1);
   10608                 :             : 
   10609                 :        3101 :       check_main_parameter_types (decl1);
   10610                 :             : 
   10611                 :        3101 :       if (!TREE_PUBLIC (decl1))
   10612                 :           0 :         pedwarn (loc, OPT_Wmain,
   10613                 :             :                  "%qD is normally a non-static function", decl1);
   10614                 :             :     }
   10615                 :             : 
   10616                 :    31761900 :   tree parms = current_function_arg_info->parms;
   10617                 :    31761900 :   if (old_decl)
   10618                 :             :     {
   10619                 :      215380 :       location_t origloc = DECL_SOURCE_LOCATION (old_decl);
   10620                 :      215380 :       warn_parm_array_mismatch (origloc, old_decl, parms);
   10621                 :             :     }
   10622                 :             : 
   10623                 :             :   /* Record the decl so that the function name is defined.
   10624                 :             :      If we already have a decl for this name, and it is a FUNCTION_DECL,
   10625                 :             :      use the old decl.  */
   10626                 :             : 
   10627                 :    31761900 :   current_function_decl = pushdecl (decl1);
   10628                 :             : 
   10629                 :    31761900 :   if (tree access = build_attr_access_from_parms (parms, false))
   10630                 :       55432 :     decl_attributes (&current_function_decl, access, ATTR_FLAG_INTERNAL,
   10631                 :             :                      old_decl);
   10632                 :             : 
   10633                 :    31761900 :   push_scope ();
   10634                 :    31761900 :   declare_parm_level ();
   10635                 :             : 
   10636                 :             :   /* Set the result decl source location to the location of the typespec.  */
   10637                 :    63523800 :   result_loc = (declspecs->locations[cdw_typespec] == UNKNOWN_LOCATION
   10638                 :    31761900 :                 ? loc : declspecs->locations[cdw_typespec]);
   10639                 :    31761900 :   restype = TREE_TYPE (TREE_TYPE (current_function_decl));
   10640                 :    31761900 :   resdecl = build_decl (result_loc, RESULT_DECL, NULL_TREE, restype);
   10641                 :    31761900 :   DECL_ARTIFICIAL (resdecl) = 1;
   10642                 :    31761900 :   DECL_IGNORED_P (resdecl) = 1;
   10643                 :    31761900 :   DECL_RESULT (current_function_decl) = resdecl;
   10644                 :             : 
   10645                 :    31761900 :   start_fname_decls ();
   10646                 :             : 
   10647                 :    31761900 :   return true;
   10648                 :             : }
   10649                 :             : 
   10650                 :             : /* Subroutine of store_parm_decls which handles new-style function
   10651                 :             :    definitions (prototype format). The parms already have decls, so we
   10652                 :             :    need only record them as in effect and complain if any redundant
   10653                 :             :    old-style parm decls were written.  */
   10654                 :             : static void
   10655                 :    31700780 : store_parm_decls_newstyle (tree fndecl, const struct c_arg_info *arg_info)
   10656                 :             : {
   10657                 :    31700780 :   tree decl;
   10658                 :    31700780 :   c_arg_tag *tag;
   10659                 :    31700780 :   unsigned ix;
   10660                 :             : 
   10661                 :    31700780 :   if (current_scope->bindings)
   10662                 :             :     {
   10663                 :           7 :       error_at (DECL_SOURCE_LOCATION (fndecl),
   10664                 :             :                 "old-style parameter declarations in prototyped "
   10665                 :             :                 "function definition");
   10666                 :             : 
   10667                 :             :       /* Get rid of the old-style declarations.  */
   10668                 :           7 :       pop_scope ();
   10669                 :           7 :       push_scope ();
   10670                 :             :     }
   10671                 :             :   /* Don't issue this warning for nested functions, and don't issue this
   10672                 :             :      warning if we got here because ARG_INFO_TYPES was error_mark_node
   10673                 :             :      (this happens when a function definition has just an ellipsis in
   10674                 :             :      its parameter list).  */
   10675                 :    31700773 :   else if (!in_system_header_at (input_location)
   10676                 :      561670 :            && !current_function_scope
   10677                 :    32261336 :            && arg_info->types != error_mark_node)
   10678                 :      560563 :     warning_at (DECL_SOURCE_LOCATION (fndecl), OPT_Wtraditional,
   10679                 :             :                 "traditional C rejects ISO C style function definitions");
   10680                 :             : 
   10681                 :             :   /* Now make all the parameter declarations visible in the function body.
   10682                 :             :      We can bypass most of the grunt work of pushdecl.  */
   10683                 :   119565684 :   for (decl = arg_info->parms; decl; decl = DECL_CHAIN (decl))
   10684                 :             :     {
   10685                 :    87864904 :       DECL_CONTEXT (decl) = current_function_decl;
   10686                 :    87864904 :       if (DECL_NAME (decl))
   10687                 :             :         {
   10688                 :    87864399 :           bind (DECL_NAME (decl), decl, current_scope,
   10689                 :             :                 /*invisible=*/false, /*nested=*/false,
   10690                 :             :                 UNKNOWN_LOCATION);
   10691                 :    87864399 :           if (!TREE_USED (decl))
   10692                 :    87847215 :             warn_if_shadowing (decl);
   10693                 :             :         }
   10694                 :             :       else
   10695                 :         505 :         pedwarn_c11 (DECL_SOURCE_LOCATION (decl), OPT_Wpedantic,
   10696                 :             :                      "ISO C does not support omitting parameter names in "
   10697                 :             :                      "function definitions before C23");
   10698                 :             :     }
   10699                 :             : 
   10700                 :             :   /* Record the parameter list in the function declaration.  */
   10701                 :    31700780 :   DECL_ARGUMENTS (fndecl) = arg_info->parms;
   10702                 :             : 
   10703                 :             :   /* Now make all the ancillary declarations visible, likewise.  */
   10704                 :    31700834 :   for (decl = arg_info->others; decl; decl = DECL_CHAIN (decl))
   10705                 :             :     {
   10706                 :          54 :       DECL_CONTEXT (decl) = current_function_decl;
   10707                 :          54 :       if (DECL_NAME (decl))
   10708                 :           0 :         bind (DECL_NAME (decl), decl, current_scope,
   10709                 :             :               /*invisible=*/false,
   10710                 :           0 :               /*nested=*/(TREE_CODE (decl) == FUNCTION_DECL),
   10711                 :             :               UNKNOWN_LOCATION);
   10712                 :             :     }
   10713                 :             : 
   10714                 :             :   /* And all the tag declarations.  */
   10715                 :    31700886 :   FOR_EACH_VEC_SAFE_ELT_REVERSE (arg_info->tags, ix, tag)
   10716                 :          54 :     if (tag->id)
   10717                 :          21 :       bind (tag->id, tag->type, current_scope,
   10718                 :             :             /*invisible=*/false, /*nested=*/false, UNKNOWN_LOCATION);
   10719                 :    31700780 : }
   10720                 :             : 
   10721                 :             : /* Subroutine of store_parm_decls which handles old-style function
   10722                 :             :    definitions (separate parameter list and declarations).  */
   10723                 :             : 
   10724                 :             : static void
   10725                 :       61120 : store_parm_decls_oldstyle (tree fndecl, const struct c_arg_info *arg_info)
   10726                 :             : {
   10727                 :       61120 :   struct c_binding *b;
   10728                 :       61120 :   tree parm, decl, last;
   10729                 :       61120 :   tree parmids = arg_info->parms;
   10730                 :       61120 :   hash_set<tree> seen_args;
   10731                 :             : 
   10732                 :       61120 :   if (!in_system_header_at (input_location))
   10733                 :             :     {
   10734                 :       61113 :       if (flag_isoc23)
   10735                 :           5 :         pedwarn (DECL_SOURCE_LOCATION (fndecl),
   10736                 :             :                  OPT_Wold_style_definition, "old-style function definition");
   10737                 :             :       else
   10738                 :       61108 :         warning_at (DECL_SOURCE_LOCATION (fndecl),
   10739                 :             :                     OPT_Wold_style_definition,
   10740                 :             :                     "old-style function definition");
   10741                 :             :     }
   10742                 :             : 
   10743                 :       61120 :   if (current_scope->had_vla_unspec)
   10744                 :           1 :     error ("%<[*]%> not allowed in other than function prototype scope");
   10745                 :             : 
   10746                 :             :   /* Match each formal parameter name with its declaration.  Save each
   10747                 :             :      decl in the appropriate TREE_PURPOSE slot of the parmids chain.  */
   10748                 :       95439 :   for (parm = parmids; parm; parm = TREE_CHAIN (parm))
   10749                 :             :     {
   10750                 :       34319 :       if (TREE_VALUE (parm) == NULL_TREE)
   10751                 :             :         {
   10752                 :           0 :           error_at (DECL_SOURCE_LOCATION (fndecl),
   10753                 :             :                     "parameter name missing from parameter list");
   10754                 :           0 :           TREE_PURPOSE (parm) = NULL_TREE;
   10755                 :           0 :           continue;
   10756                 :             :         }
   10757                 :             : 
   10758                 :       34319 :       b = I_SYMBOL_BINDING (TREE_VALUE (parm));
   10759                 :       34319 :       if (b && B_IN_CURRENT_SCOPE (b))
   10760                 :             :         {
   10761                 :       22702 :           decl = b->decl;
   10762                 :             :           /* Skip erroneous parameters.  */
   10763                 :       22702 :           if (decl == error_mark_node)
   10764                 :           2 :             continue;
   10765                 :             :           /* If we got something other than a PARM_DECL it is an error.  */
   10766                 :       22700 :           if (TREE_CODE (decl) != PARM_DECL)
   10767                 :             :             {
   10768                 :           7 :               error_at (DECL_SOURCE_LOCATION (decl),
   10769                 :             :                         "%qD declared as a non-parameter", decl);
   10770                 :           7 :               continue;
   10771                 :             :             }
   10772                 :             :           /* If the declaration is already marked, we have a duplicate
   10773                 :             :              name.  Complain and ignore the duplicate.  */
   10774                 :       22693 :           else if (seen_args.contains (decl))
   10775                 :             :             {
   10776                 :           0 :               error_at (DECL_SOURCE_LOCATION (decl),
   10777                 :             :                         "multiple parameters named %qD", decl);
   10778                 :           0 :               TREE_PURPOSE (parm) = NULL_TREE;
   10779                 :           0 :               continue;
   10780                 :             :             }
   10781                 :             :           /* If the declaration says "void", complain and turn it into
   10782                 :             :              an int.  */
   10783                 :       22693 :           else if (VOID_TYPE_P (TREE_TYPE (decl)))
   10784                 :             :             {
   10785                 :           0 :               error_at (DECL_SOURCE_LOCATION (decl),
   10786                 :             :                         "parameter %qD declared with void type", decl);
   10787                 :           0 :               TREE_TYPE (decl) = integer_type_node;
   10788                 :           0 :               DECL_ARG_TYPE (decl) = integer_type_node;
   10789                 :           0 :               layout_decl (decl, 0);
   10790                 :             :             }
   10791                 :       22693 :           warn_if_shadowing (decl);
   10792                 :             :         }
   10793                 :             :       /* If no declaration found, default to int.  */
   10794                 :             :       else
   10795                 :             :         {
   10796                 :             :           /* FIXME diagnostics: This should be the location of the argument,
   10797                 :             :              not the FNDECL.  E.g., for an old-style declaration
   10798                 :             : 
   10799                 :             :                int f10(v) { blah; }
   10800                 :             : 
   10801                 :             :              We should use the location of the V, not the F10.
   10802                 :             :              Unfortunately, the V is an IDENTIFIER_NODE which has no
   10803                 :             :              location.  In the future we need locations for c_arg_info
   10804                 :             :              entries.
   10805                 :             : 
   10806                 :             :              See gcc.dg/Wshadow-3.c for an example of this problem. */
   10807                 :       11617 :           decl = build_decl (DECL_SOURCE_LOCATION (fndecl),
   10808                 :       11617 :                              PARM_DECL, TREE_VALUE (parm), integer_type_node);
   10809                 :       11617 :           DECL_ARG_TYPE (decl) = TREE_TYPE (decl);
   10810                 :       11617 :           pushdecl (decl);
   10811                 :       11617 :           warn_if_shadowing (decl);
   10812                 :             : 
   10813                 :       11617 :           if (flag_isoc99)
   10814                 :         116 :             permerror_opt (DECL_SOURCE_LOCATION (decl),
   10815                 :             :                            OPT_Wimplicit_int, "type of %qD defaults to %<int%>",
   10816                 :             :                            decl);
   10817                 :             :           else
   10818                 :       11501 :             warning_at (DECL_SOURCE_LOCATION (decl),
   10819                 :             :                         OPT_Wmissing_parameter_type,
   10820                 :             :                         "type of %qD defaults to %<int%>", decl);
   10821                 :             :         }
   10822                 :             : 
   10823                 :       34310 :       TREE_PURPOSE (parm) = decl;
   10824                 :       34310 :       seen_args.add (decl);
   10825                 :             :     }
   10826                 :             : 
   10827                 :             :   /* Now examine the parms chain for incomplete declarations
   10828                 :             :      and declarations with no corresponding names.  */
   10829                 :             : 
   10830                 :       95518 :   for (b = current_scope->bindings; b; b = b->prev)
   10831                 :             :     {
   10832                 :       34398 :       parm = b->decl;
   10833                 :       34398 :       if (TREE_CODE (parm) != PARM_DECL)
   10834                 :          79 :         continue;
   10835                 :             : 
   10836                 :       34319 :       if (TREE_TYPE (parm) != error_mark_node
   10837                 :       34319 :           && !COMPLETE_TYPE_P (TREE_TYPE (parm)))
   10838                 :             :         {
   10839                 :           0 :           error_at (DECL_SOURCE_LOCATION (parm),
   10840                 :             :                     "parameter %qD has incomplete type", parm);
   10841                 :           0 :           TREE_TYPE (parm) = error_mark_node;
   10842                 :             :         }
   10843                 :             : 
   10844                 :       34319 :       if (!seen_args.contains (parm))
   10845                 :             :         {
   10846                 :           9 :           error_at (DECL_SOURCE_LOCATION (parm),
   10847                 :             :                     "declaration for parameter %qD but no such parameter",
   10848                 :             :                     parm);
   10849                 :             : 
   10850                 :             :           /* Pretend the parameter was not missing.
   10851                 :             :              This gets us to a standard state and minimizes
   10852                 :             :              further error messages.  */
   10853                 :           9 :           parmids = chainon (parmids, tree_cons (parm, 0, 0));
   10854                 :             :         }
   10855                 :             :     }
   10856                 :             : 
   10857                 :             :   /* Chain the declarations together in the order of the list of
   10858                 :             :      names.  Store that chain in the function decl, replacing the
   10859                 :             :      list of names.  Update the current scope to match.  */
   10860                 :       61120 :   DECL_ARGUMENTS (fndecl) = NULL_TREE;
   10861                 :             : 
   10862                 :       61128 :   for (parm = parmids; parm; parm = TREE_CHAIN (parm))
   10863                 :        8689 :     if (TREE_PURPOSE (parm))
   10864                 :             :       break;
   10865                 :       61120 :   if (parm && TREE_PURPOSE (parm))
   10866                 :             :     {
   10867                 :        8681 :       last = TREE_PURPOSE (parm);
   10868                 :        8681 :       DECL_ARGUMENTS (fndecl) = last;
   10869                 :             : 
   10870                 :       34320 :       for (parm = TREE_CHAIN (parm); parm; parm = TREE_CHAIN (parm))
   10871                 :       25639 :         if (TREE_PURPOSE (parm))
   10872                 :             :           {
   10873                 :       25638 :             DECL_CHAIN (last) = TREE_PURPOSE (parm);
   10874                 :       25639 :             last = TREE_PURPOSE (parm);
   10875                 :             :           }
   10876                 :        8681 :       DECL_CHAIN (last) = NULL_TREE;
   10877                 :             :     }
   10878                 :             : 
   10879                 :             :   /* If there was a previous prototype,
   10880                 :             :      set the DECL_ARG_TYPE of each argument according to
   10881                 :             :      the type previously specified, and report any mismatches.  */
   10882                 :             : 
   10883                 :       61120 :   if (current_function_prototype_arg_types)
   10884                 :             :     {
   10885                 :         416 :       tree type;
   10886                 :         416 :       for (parm = DECL_ARGUMENTS (fndecl),
   10887                 :         416 :              type = current_function_prototype_arg_types;
   10888                 :         662 :            parm || (type != NULL_TREE
   10889                 :         411 :                     && TREE_VALUE (type) != error_mark_node
   10890                 :         411 :                     && TYPE_MAIN_VARIANT (TREE_VALUE (type)) != void_type_node);
   10891                 :         246 :            parm = DECL_CHAIN (parm), type = TREE_CHAIN (type))
   10892                 :             :         {
   10893                 :         267 :           if (parm == NULL_TREE
   10894                 :         250 :               || type == NULL_TREE
   10895                 :         517 :               || (TREE_VALUE (type) != error_mark_node
   10896                 :         236 :                   && TYPE_MAIN_VARIANT (TREE_VALUE (type)) == void_type_node))
   10897                 :             :             {
   10898                 :          21 :               if (current_function_prototype_built_in)
   10899                 :          17 :                 warning_at (DECL_SOURCE_LOCATION (fndecl),
   10900                 :             :                             0, "number of arguments doesn%'t match "
   10901                 :             :                             "built-in prototype");
   10902                 :             :               else
   10903                 :             :                 {
   10904                 :             :                   /* FIXME diagnostics: This should be the location of
   10905                 :             :                      FNDECL, but there is bug when a prototype is
   10906                 :             :                      declared inside function context, but defined
   10907                 :             :                      outside of it (e.g., gcc.dg/pr15698-2.c).  In
   10908                 :             :                      which case FNDECL gets the location of the
   10909                 :             :                      prototype, not the definition.  */
   10910                 :           4 :                   error_at (input_location,
   10911                 :             :                             "number of arguments doesn%'t match prototype");
   10912                 :             : 
   10913                 :           4 :                   error_at (current_function_prototype_locus,
   10914                 :             :                             "prototype declaration");
   10915                 :             :                 }
   10916                 :             :               break;
   10917                 :             :             }
   10918                 :             :           /* Type for passing arg must be consistent with that
   10919                 :             :              declared for the arg.  ISO C says we take the unqualified
   10920                 :             :              type for parameters declared with qualified type.  */
   10921                 :         246 :           if (TREE_TYPE (parm) != error_mark_node
   10922                 :         245 :               && TREE_VALUE (type) != error_mark_node
   10923                 :         477 :               && ((TYPE_ATOMIC (DECL_ARG_TYPE (parm))
   10924                 :         231 :                    != TYPE_ATOMIC (TREE_VALUE (type)))
   10925                 :         229 :                   || !comptypes (TYPE_MAIN_VARIANT (DECL_ARG_TYPE (parm)),
   10926                 :         229 :                                  TYPE_MAIN_VARIANT (TREE_VALUE (type)))))
   10927                 :             :             {
   10928                 :          32 :               if ((TYPE_ATOMIC (DECL_ARG_TYPE (parm))
   10929                 :          32 :                    == TYPE_ATOMIC (TREE_VALUE (type)))
   10930                 :          32 :                   && (TYPE_MAIN_VARIANT (TREE_TYPE (parm))
   10931                 :          30 :                       == TYPE_MAIN_VARIANT (TREE_VALUE (type))))
   10932                 :             :                 {
   10933                 :             :                   /* Adjust argument to match prototype.  E.g. a previous
   10934                 :             :                      `int foo(float);' prototype causes
   10935                 :             :                      `int foo(x) float x; {...}' to be treated like
   10936                 :             :                      `int foo(float x) {...}'.  This is particularly
   10937                 :             :                      useful for argument types like uid_t.  */
   10938                 :          14 :                   DECL_ARG_TYPE (parm) = TREE_TYPE (parm);
   10939                 :             : 
   10940                 :          14 :                   if (targetm.calls.promote_prototypes (TREE_TYPE (current_function_decl))
   10941                 :          14 :                       && INTEGRAL_TYPE_P (TREE_TYPE (parm))
   10942                 :          14 :                       && (TYPE_PRECISION (TREE_TYPE (parm))
   10943                 :           0 :                           < TYPE_PRECISION (integer_type_node)))
   10944                 :           0 :                     DECL_ARG_TYPE (parm)
   10945                 :           0 :                       = c_type_promotes_to (TREE_TYPE (parm));
   10946                 :             : 
   10947                 :             :                   /* ??? Is it possible to get here with a
   10948                 :             :                      built-in prototype or will it always have
   10949                 :             :                      been diagnosed as conflicting with an
   10950                 :             :                      old-style definition and discarded?  */
   10951                 :          14 :                   if (current_function_prototype_built_in)
   10952                 :           2 :                     warning_at (DECL_SOURCE_LOCATION (parm),
   10953                 :             :                                 OPT_Wpedantic, "promoted argument %qD "
   10954                 :             :                                 "doesn%'t match built-in prototype", parm);
   10955                 :             :                   else
   10956                 :             :                     {
   10957                 :          12 :                       pedwarn (DECL_SOURCE_LOCATION (parm),
   10958                 :             :                                OPT_Wpedantic, "promoted argument %qD "
   10959                 :             :                                "doesn%'t match prototype", parm);
   10960                 :          12 :                       pedwarn (current_function_prototype_locus, OPT_Wpedantic,
   10961                 :             :                                "prototype declaration");
   10962                 :             :                     }
   10963                 :             :                 }
   10964                 :             :               else
   10965                 :             :                 {
   10966                 :          18 :                   if (current_function_prototype_built_in)
   10967                 :          10 :                     warning_at (DECL_SOURCE_LOCATION (parm),
   10968                 :             :                                 0, "argument %qD doesn%'t match "
   10969                 :             :                                 "built-in prototype", parm);
   10970                 :             :                   else
   10971                 :             :                     {
   10972                 :           8 :                       error_at (DECL_SOURCE_LOCATION (parm),
   10973                 :             :                                 "argument %qD doesn%'t match prototype", parm);
   10974                 :           8 :                       error_at (current_function_prototype_locus,
   10975                 :             :                                 "prototype declaration");
   10976                 :             :                     }
   10977                 :             :                 }
   10978                 :             :             }
   10979                 :             :         }
   10980                 :         416 :       TYPE_ACTUAL_ARG_TYPES (TREE_TYPE (fndecl)) = NULL_TREE;
   10981                 :             :     }
   10982                 :             : 
   10983                 :             :   /* Otherwise, create a prototype that would match.  */
   10984                 :             : 
   10985                 :             :   else
   10986                 :             :     {
   10987                 :       60704 :       tree actual = NULL_TREE, last = NULL_TREE, type;
   10988                 :             : 
   10989                 :       94773 :       for (parm = DECL_ARGUMENTS (fndecl); parm; parm = DECL_CHAIN (parm))
   10990                 :             :         {
   10991                 :       34069 :           type = tree_cons (NULL_TREE, DECL_ARG_TYPE (parm), NULL_TREE);
   10992                 :       34069 :           if (last)
   10993                 :       25554 :             TREE_CHAIN (last) = type;
   10994                 :             :           else
   10995                 :             :             actual = type;
   10996                 :       34069 :           last = type;
   10997                 :             :         }
   10998                 :       60704 :       type = tree_cons (NULL_TREE, void_type_node, NULL_TREE);
   10999                 :       60704 :       if (last)
   11000                 :        8515 :         TREE_CHAIN (last) = type;
   11001                 :             :       else
   11002                 :             :         actual = type;
   11003                 :             : 
   11004                 :             :       /* We are going to assign a new value for the TYPE_ACTUAL_ARG_TYPES
   11005                 :             :          of the type of this function, but we need to avoid having this
   11006                 :             :          affect the types of other similarly-typed functions, so we must
   11007                 :             :          first force the generation of an identical (but separate) type
   11008                 :             :          node for the relevant function type.  The new node we create
   11009                 :             :          will be a variant of the main variant of the original function
   11010                 :             :          type.  */
   11011                 :             : 
   11012                 :       60704 :       TREE_TYPE (fndecl) = build_variant_type_copy (TREE_TYPE (fndecl));
   11013                 :             : 
   11014                 :       60704 :       TYPE_ACTUAL_ARG_TYPES (TREE_TYPE (fndecl)) = actual;
   11015                 :             :     }
   11016                 :       61120 : }
   11017                 :             : 
   11018                 :             : /* Store parameter declarations passed in ARG_INFO into the current
   11019                 :             :    function declaration.  */
   11020                 :             : 
   11021                 :             : void
   11022                 :           0 : store_parm_decls_from (struct c_arg_info *arg_info)
   11023                 :             : {
   11024                 :           0 :   current_function_arg_info = arg_info;
   11025                 :           0 :   store_parm_decls ();
   11026                 :           0 : }
   11027                 :             : 
   11028                 :             : /* Called by walk_tree to look for and update context-less labels
   11029                 :             :    or labels with context in the parent function.  */
   11030                 :             : 
   11031                 :             : static tree
   11032                 :        8109 : set_labels_context_r (tree *tp, int *walk_subtrees, void *data)
   11033                 :             : {
   11034                 :        8109 :   tree ctx = static_cast<tree>(data);
   11035                 :        8109 :   if (TREE_CODE (*tp) == LABEL_EXPR
   11036                 :        8109 :       && (DECL_CONTEXT (LABEL_EXPR_LABEL (*tp)) == NULL_TREE
   11037                 :           2 :           || DECL_CONTEXT (LABEL_EXPR_LABEL (*tp)) == DECL_CONTEXT (ctx)))
   11038                 :             :     {
   11039                 :          72 :       DECL_CONTEXT (LABEL_EXPR_LABEL (*tp)) = ctx;
   11040                 :          72 :       *walk_subtrees = 0;
   11041                 :             :     }
   11042                 :             : 
   11043                 :        8109 :   return NULL_TREE;
   11044                 :             : }
   11045                 :             : 
   11046                 :             : /* Store the parameter declarations into the current function declaration.
   11047                 :             :    This is called after parsing the parameter declarations, before
   11048                 :             :    digesting the body of the function.
   11049                 :             : 
   11050                 :             :    For an old-style definition, construct a prototype out of the old-style
   11051                 :             :    parameter declarations and inject it into the function's type.  */
   11052                 :             : 
   11053                 :             : void
   11054                 :    31761900 : store_parm_decls (void)
   11055                 :             : {
   11056                 :    31761900 :   tree fndecl = current_function_decl;
   11057                 :    31761900 :   bool proto;
   11058                 :             : 
   11059                 :             :   /* The argument information block for FNDECL.  */
   11060                 :    31761900 :   struct c_arg_info *arg_info = current_function_arg_info;
   11061                 :    31761900 :   current_function_arg_info = 0;
   11062                 :             : 
   11063                 :             :   /* True if this definition is written with a prototype.  In C23, an
   11064                 :             :      empty argument list was converted to (void) in grokparms; in
   11065                 :             :      older C standard versions, it does not give the function a type
   11066                 :             :      with a prototype for future calls.  */
   11067                 :    31761900 :   proto = arg_info->types != 0 || arg_info->no_named_args_stdarg_p;
   11068                 :             : 
   11069                 :       61120 :   if (proto)
   11070                 :    31700780 :     store_parm_decls_newstyle (fndecl, arg_info);
   11071                 :             :   else
   11072                 :       61120 :     store_parm_decls_oldstyle (fndecl, arg_info);
   11073                 :             : 
   11074                 :             :   /* The next call to push_scope will be a function body.  */
   11075                 :             : 
   11076                 :    31761900 :   next_is_function_body = true;
   11077                 :             : 
   11078                 :             :   /* Write a record describing this function definition to the prototypes
   11079                 :             :      file (if requested).  */
   11080                 :             : 
   11081                 :    31761900 :   gen_aux_info_record (fndecl, 1, 0, proto);
   11082                 :             : 
   11083                 :             :   /* Initialize the RTL code for the function.  */
   11084                 :    31761900 :   allocate_struct_function (fndecl, false);
   11085                 :             : 
   11086                 :    31761900 :   if (warn_unused_local_typedefs)
   11087                 :     2804436 :     cfun->language = ggc_cleared_alloc<language_function> ();
   11088                 :             : 
   11089                 :             :   /* Begin the statement tree for this function.  */
   11090                 :    31761900 :   DECL_SAVED_TREE (fndecl) = push_stmt_list ();
   11091                 :             : 
   11092                 :             :   /* ??? Insert the contents of the pending sizes list into the function
   11093                 :             :      to be evaluated.  The only reason left to have this is
   11094                 :             :         void foo(int n, int array[n++])
   11095                 :             :      because we throw away the array type in favor of a pointer type, and
   11096                 :             :      thus won't naturally see the SAVE_EXPR containing the increment.  All
   11097                 :             :      other pending sizes would be handled by gimplify_parameters.  */
   11098                 :    31761900 :   if (arg_info->pending_sizes)
   11099                 :             :     {
   11100                 :             :       /* In very special circumstances, e.g. for code like
   11101                 :             :            _Atomic int i = 5;
   11102                 :             :            void f (int a[i += 2]) {}
   11103                 :             :          we need to execute the atomic assignment on function entry.
   11104                 :             :          But in this case, it is not just a straight store, it has the
   11105                 :             :          op= form, which means that build_atomic_assign has generated
   11106                 :             :          gotos, labels, etc.  Because at that time the function decl
   11107                 :             :          for F has not been created yet, those labels do not have any
   11108                 :             :          function context.  But we have the fndecl now, so update the
   11109                 :             :          labels accordingly.  gimplify_expr would crash otherwise.
   11110                 :             :          Or with nested functions the labels could be created with parent
   11111                 :             :          function's context, while when the statement is emitted at the
   11112                 :             :          start of the nested function, it needs the nested function's
   11113                 :             :          context.  */
   11114                 :         292 :       walk_tree_without_duplicates (&arg_info->pending_sizes,
   11115                 :             :                                     set_labels_context_r, fndecl);
   11116                 :         292 :       add_stmt (arg_info->pending_sizes);
   11117                 :             :     }
   11118                 :    31761900 : }
   11119                 :             : 
   11120                 :             : /* Store PARM_DECLs in PARMS into scope temporarily.  Used for
   11121                 :             :    c_finish_omp_declare_simd for function prototypes.  No diagnostics
   11122                 :             :    should be done.  */
   11123                 :             : 
   11124                 :             : void
   11125                 :         187 : temp_store_parm_decls (tree fndecl, tree parms)
   11126                 :             : {
   11127                 :         187 :   push_scope ();
   11128                 :         537 :   for (tree p = parms; p; p = DECL_CHAIN (p))
   11129                 :             :     {
   11130                 :         350 :       DECL_CONTEXT (p) = fndecl;
   11131                 :         350 :       if (DECL_NAME (p))
   11132                 :         246 :         bind (DECL_NAME (p), p, current_scope,
   11133                 :             :               /*invisible=*/false, /*nested=*/false,
   11134                 :             :               UNKNOWN_LOCATION);
   11135                 :             :     }
   11136                 :         187 : }
   11137                 :             : 
   11138                 :             : /* Undo what temp_store_parm_decls did.  */
   11139                 :             : 
   11140                 :             : void
   11141                 :         187 : temp_pop_parm_decls (void)
   11142                 :             : {
   11143                 :             :   /* Clear all bindings in this temporary scope, so that
   11144                 :             :      pop_scope doesn't create a BLOCK.  */
   11145                 :         187 :   struct c_binding *b = current_scope->bindings;
   11146                 :         187 :   current_scope->bindings = NULL;
   11147                 :         435 :   for (; b; b = free_binding_and_advance (b))
   11148                 :             :     {
   11149                 :         248 :       gcc_assert (TREE_CODE (b->decl) == PARM_DECL
   11150                 :             :                   || b->decl == error_mark_node);
   11151                 :         248 :       gcc_assert (I_SYMBOL_BINDING (b->id) == b);
   11152                 :         248 :       I_SYMBOL_BINDING (b->id) = b->shadowed;
   11153                 :         248 :       if (b->shadowed && b->shadowed->u.type)
   11154                 :           0 :         TREE_TYPE (b->shadowed->decl) = b->shadowed->u.type;
   11155                 :             :     }
   11156                 :         187 :   pop_scope ();
   11157                 :         187 : }
   11158                 :             : 
   11159                 :             : 
   11160                 :             : /* Finish up a function declaration and compile that function
   11161                 :             :    all the way to assembler language output.  Then free the storage
   11162                 :             :    for the function definition.
   11163                 :             : 
   11164                 :             :    This is called after parsing the body of the function definition.  */
   11165                 :             : 
   11166                 :             : void
   11167                 :    31761898 : finish_function (location_t end_loc)
   11168                 :             : {
   11169                 :    31761898 :   tree fndecl = current_function_decl;
   11170                 :             :   
   11171                 :    31761898 :   if (c_dialect_objc ())
   11172                 :           0 :     objc_finish_function ();
   11173                 :             : 
   11174                 :    31761898 :   if (TREE_CODE (fndecl) == FUNCTION_DECL
   11175                 :    31761898 :       && targetm.calls.promote_prototypes (TREE_TYPE (fndecl)))
   11176                 :             :     {
   11177                 :    31761898 :       tree args = DECL_ARGUMENTS (fndecl);
   11178                 :   119661119 :       for (; args; args = DECL_CHAIN (args))
   11179                 :             :         {
   11180                 :    87899221 :           tree type = TREE_TYPE (args);
   11181                 :    87899221 :           if (INTEGRAL_TYPE_P (type)
   11182                 :    87899221 :               && TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node))
   11183                 :    16355303 :             DECL_ARG_TYPE (args) = c_type_promotes_to (type);
   11184                 :             :         }
   11185                 :             :     }
   11186                 :             : 
   11187                 :    31761898 :   if (DECL_INITIAL (fndecl) && DECL_INITIAL (fndecl) != error_mark_node)
   11188                 :    31761898 :     BLOCK_SUPERCONTEXT (DECL_INITIAL (fndecl)) = fndecl;
   11189                 :             : 
   11190                 :             :   /* Must mark the RESULT_DECL as being in this function.  */
   11191                 :             : 
   11192                 :    31761898 :   if (DECL_RESULT (fndecl) && DECL_RESULT (fndecl) != error_mark_node)
   11193                 :    31761898 :     DECL_CONTEXT (DECL_RESULT (fndecl)) = fndecl;
   11194                 :             : 
   11195                 :    31808933 :   if (MAIN_NAME_P (DECL_NAME (fndecl)) && !TREE_THIS_VOLATILE (fndecl)
   11196                 :       47034 :       && TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (fndecl)))
   11197                 :    31808932 :       == integer_type_node && flag_isoc99)
   11198                 :             :     {
   11199                 :             :       /* Hack.  We don't want the middle-end to warn that this return
   11200                 :             :          is unreachable, so we mark its location as special.  Using
   11201                 :             :          UNKNOWN_LOCATION has the problem that it gets clobbered in
   11202                 :             :          annotate_one_with_locus.  A cleaner solution might be to
   11203                 :             :          ensure ! should_carry_locus_p (stmt), but that needs a flag.
   11204                 :             :       */
   11205                 :       45690 :       c_finish_return (BUILTINS_LOCATION, integer_zero_node, NULL_TREE);
   11206                 :             :     }
   11207                 :             : 
   11208                 :             :   /* Tie off the statement tree for this function.  */
   11209                 :    31761898 :   DECL_SAVED_TREE (fndecl) = pop_stmt_list (DECL_SAVED_TREE (fndecl));
   11210                 :             : 
   11211                 :    31761898 :   finish_fname_decls ();
   11212                 :             : 
   11213                 :             :   /* Complain if there's no return statement only if option specified on
   11214                 :             :      command line.  */
   11215                 :    31761898 :   if (warn_return_type > 0
   11216                 :     2804462 :       && TREE_CODE (TREE_TYPE (TREE_TYPE (fndecl))) != VOID_TYPE
   11217                 :     2605955 :       && !current_function_returns_value && !current_function_returns_null
   11218                 :             :       /* Don't complain if we are no-return.  */
   11219                 :          72 :       && !current_function_returns_abnormally
   11220                 :             :       /* Don't complain if we are declared noreturn.  */
   11221                 :          21 :       && !TREE_THIS_VOLATILE (fndecl)
   11222                 :             :       /* Don't warn for main().  */
   11223                 :          18 :       && !MAIN_NAME_P (DECL_NAME (fndecl))
   11224                 :             :       /* Or if they didn't actually specify a return type.  */
   11225                 :          17 :       && !C_FUNCTION_IMPLICIT_INT (fndecl)
   11226                 :             :       /* Normally, with -Wreturn-type, flow will complain, but we might
   11227                 :             :          optimize out static functions.  */
   11228                 :          17 :       && !TREE_PUBLIC (fndecl)
   11229                 :           6 :       && targetm.warn_func_return (fndecl)
   11230                 :    31761903 :       && warning (OPT_Wreturn_type,
   11231                 :             :                   "no return statement in function returning non-void"))
   11232                 :           5 :     suppress_warning (fndecl, OPT_Wreturn_type);
   11233                 :             : 
   11234                 :             :   /* Complain about parameters that are only set, but never otherwise used.  */
   11235                 :    31761898 :   if (warn_unused_but_set_parameter)
   11236                 :             :     {
   11237                 :     2759554 :       tree decl;
   11238                 :             : 
   11239                 :     2759554 :       for (decl = DECL_ARGUMENTS (fndecl);
   11240                 :    10351895 :            decl;
   11241                 :     7592341 :            decl = DECL_CHAIN (decl))
   11242                 :     7592341 :         if (TREE_USED (decl)
   11243                 :     7592341 :             && TREE_CODE (decl) == PARM_DECL
   11244                 :     7531640 :             && !DECL_READ_P (decl)
   11245                 :           1 :             && DECL_NAME (decl)
   11246                 :           1 :             && !DECL_ARTIFICIAL (decl)
   11247                 :     7592342 :             && !warning_suppressed_p (decl, OPT_Wunused_but_set_parameter))
   11248                 :           1 :           warning_at (DECL_SOURCE_LOCATION (decl),
   11249                 :             :                       OPT_Wunused_but_set_parameter,
   11250                 :             :                       "parameter %qD set but not used", decl);
   11251                 :             :     }
   11252                 :             : 
   11253                 :             :   /* Complain about locally defined typedefs that are not used in this
   11254                 :             :      function.  */
   11255                 :    31761898 :   maybe_warn_unused_local_typedefs ();
   11256                 :             : 
   11257                 :             :   /* Possibly warn about unused parameters.  */
   11258                 :    31761898 :   if (warn_unused_parameter)
   11259                 :     2665673 :     do_warn_unused_parameter (fndecl);
   11260                 :             : 
   11261                 :             :   /* Store the end of the function, so that we get good line number
   11262                 :             :      info for the epilogue.  */
   11263                 :    31761898 :   cfun->function_end_locus = end_loc;
   11264                 :             : 
   11265                 :             :   /* Finalize the ELF visibility for the function.  */
   11266                 :    31761898 :   c_determine_visibility (fndecl);
   11267                 :             : 
   11268                 :             :   /* For GNU C extern inline functions disregard inline limits.  */
   11269                 :    31761898 :   if (DECL_EXTERNAL (fndecl)
   11270                 :    30953445 :       && DECL_DECLARED_INLINE_P (fndecl)
   11271                 :    62715340 :       && (flag_gnu89_inline
   11272                 :    30945609 :           || lookup_attribute ("gnu_inline", DECL_ATTRIBUTES (fndecl))))
   11273                 :    30952978 :     DECL_DISREGARD_INLINE_LIMITS (fndecl) = 1;
   11274                 :             : 
   11275                 :             :   /* Genericize before inlining.  Delay genericizing nested functions
   11276                 :             :      until their parent function is genericized.  Since finalizing
   11277                 :             :      requires GENERIC, delay that as well.  */
   11278                 :             : 
   11279                 :    63523796 :   if (DECL_INITIAL (fndecl) && DECL_INITIAL (fndecl) != error_mark_node
   11280                 :    63523796 :       && !undef_nested_function)
   11281                 :             :     {
   11282                 :    31761893 :       if (!decl_function_context (fndecl))
   11283                 :             :         {
   11284                 :    31760382 :           invoke_plugin_callbacks (PLUGIN_PRE_GENERICIZE, fndecl);
   11285                 :    31760382 :           c_genericize (fndecl);
   11286                 :             : 
   11287                 :             :           /* ??? Objc emits functions after finalizing the compilation unit.
   11288                 :             :              This should be cleaned up later and this conditional removed.  */
   11289                 :    31760382 :           if (symtab->global_info_ready)
   11290                 :             :             {
   11291                 :           0 :               cgraph_node::add_new_function (fndecl, false);
   11292                 :           0 :               return;
   11293                 :             :             }
   11294                 :    31760382 :           cgraph_node::finalize_function (fndecl, false);
   11295                 :             :         }
   11296                 :             :       else
   11297                 :             :         {
   11298                 :             :           /* Register this function with cgraph just far enough to get it
   11299                 :             :             added to our parent's nested function list.  Handy, since the
   11300                 :             :             C front end doesn't have such a list.  */
   11301                 :        1511 :           (void) cgraph_node::get_create (fndecl);
   11302                 :             :         }
   11303                 :             :     }
   11304                 :             : 
   11305                 :    31761898 :   if (!decl_function_context (fndecl))
   11306                 :    31760387 :     undef_nested_function = false;
   11307                 :             : 
   11308                 :    31761898 :   if (cfun->language != NULL)
   11309                 :             :     {
   11310                 :     2804435 :       ggc_free (cfun->language);
   11311                 :     2804435 :       cfun->language = NULL;
   11312                 :             :     }
   11313                 :             : 
   11314                 :             :   /* We're leaving the context of this function, so zap cfun.
   11315                 :             :      It's still in DECL_STRUCT_FUNCTION, and we'll restore it in
   11316                 :             :      tree_rest_of_compilation.  */
   11317                 :    31761898 :   set_cfun (NULL);
   11318                 :    31761898 :   invoke_plugin_callbacks (PLUGIN_FINISH_PARSE_FUNCTION, current_function_decl);
   11319                 :    31761898 :   current_function_decl = NULL;
   11320                 :             : }
   11321                 :             : 
   11322                 :             : /* Check the declarations given in a for-loop for satisfying the C99
   11323                 :             :    constraints.  If exactly one such decl is found, return it.  LOC is
   11324                 :             :    the location of the opening parenthesis of the for loop.  The last
   11325                 :             :    parameter allows you to control the "for loop initial declarations
   11326                 :             :    are only allowed in C99 mode".  Normally, you should pass
   11327                 :             :    flag_isoc99 as that parameter.  But in some cases (Objective-C
   11328                 :             :    foreach loop, for example) we want to run the checks in this
   11329                 :             :    function even if not in C99 mode, so we allow the caller to turn
   11330                 :             :    off the error about not being in C99 mode.
   11331                 :             : */
   11332                 :             : 
   11333                 :             : tree
   11334                 :       21526 : check_for_loop_decls (location_t loc, bool turn_off_iso_c99_error)
   11335                 :             : {
   11336                 :       21526 :   struct c_binding *b;
   11337                 :       21526 :   tree one_decl = NULL_TREE;
   11338                 :       21526 :   int n_decls = 0;
   11339                 :             : 
   11340                 :       21526 :   if (!turn_off_iso_c99_error)
   11341                 :             :     {
   11342                 :           1 :       static bool hint = true;
   11343                 :             :       /* If we get here, declarations have been used in a for loop without
   11344                 :             :          the C99 for loop scope.  This doesn't make much sense, so don't
   11345                 :             :          allow it.  */
   11346                 :           1 :       auto_diagnostic_group d;
   11347                 :           1 :       error_at (loc, "%<for%> loop initial declarations "
   11348                 :             :                 "are only allowed in C99 or C11 mode");
   11349                 :           1 :       if (hint)
   11350                 :             :         {
   11351                 :           1 :           inform (loc,
   11352                 :             :                   "use option %<-std=c99%>, %<-std=gnu99%>, %<-std=c11%> or "
   11353                 :             :                   "%<-std=gnu11%> to compile your code");
   11354                 :           1 :           hint = false;
   11355                 :             :         }
   11356                 :           1 :       return NULL_TREE;
   11357                 :           1 :     }
   11358                 :             :   else
   11359                 :       21525 :     pedwarn_c90 (loc, OPT_Wpedantic, "ISO C90 does not support %<for%> loop "
   11360                 :             :                  "initial declarations");
   11361                 :             : 
   11362                 :             :   /* C99 subclause 6.8.5 paragraph 3:
   11363                 :             : 
   11364                 :             :        [#3]  The  declaration  part  of  a for statement shall only
   11365                 :             :        declare identifiers for objects having storage class auto or
   11366                 :             :        register.
   11367                 :             : 
   11368                 :             :      It isn't clear whether, in this sentence, "identifiers" binds to
   11369                 :             :      "shall only declare" or to "objects" - that is, whether all identifiers
   11370                 :             :      declared must be identifiers for objects, or whether the restriction
   11371                 :             :      only applies to those that are.  (A question on this in comp.std.c
   11372                 :             :      in November 2000 received no answer.)  We implement the strictest
   11373                 :             :      interpretation, to avoid creating an extension which later causes
   11374                 :             :      problems.
   11375                 :             : 
   11376                 :             :      This constraint was removed in C23.  */
   11377                 :             : 
   11378                 :       43124 :   for (b = current_scope->bindings; b; b = b->prev)
   11379                 :             :     {
   11380                 :       21599 :       tree id = b->id;
   11381                 :       21599 :       tree decl = b->decl;
   11382                 :             : 
   11383                 :       21599 :       if (!id)
   11384                 :          27 :         continue;
   11385                 :             : 
   11386                 :       21572 :       switch (TREE_CODE (decl))
   11387                 :             :         {
   11388                 :       21524 :         case VAR_DECL:
   11389                 :       21524 :           {
   11390                 :       21524 :             location_t decl_loc = DECL_SOURCE_LOCATION (decl);
   11391                 :       21524 :             if (TREE_STATIC (decl))
   11392                 :           5 :               pedwarn_c11 (decl_loc, OPT_Wpedantic,
   11393                 :             :                            "declaration of static variable %qD in %<for%> "
   11394                 :             :                            "loop initial declaration", decl);
   11395                 :       21519 :             else if (DECL_EXTERNAL (decl))
   11396                 :           5 :               pedwarn_c11 (decl_loc, OPT_Wpedantic,
   11397                 :             :                            "declaration of %<extern%> variable %qD in %<for%> "
   11398                 :             :                            "loop initial declaration", decl);
   11399                 :             :           }
   11400                 :             :           break;
   11401                 :             : 
   11402                 :           6 :         case RECORD_TYPE:
   11403                 :           6 :           pedwarn_c11 (loc, OPT_Wpedantic,
   11404                 :             :                        "%<struct %E%> declared in %<for%> loop initial "
   11405                 :             :                        "declaration", id);
   11406                 :           6 :           break;
   11407                 :           5 :         case UNION_TYPE:
   11408                 :           5 :           pedwarn_c11 (loc, OPT_Wpedantic,
   11409                 :             :                        "%<union %E%> declared in %<for%> loop initial "
   11410                 :             :                        "declaration",
   11411                 :             :                        id);
   11412                 :           5 :           break;
   11413                 :           5 :         case ENUMERAL_TYPE:
   11414                 :           5 :           pedwarn_c11 (loc, OPT_Wpedantic,
   11415                 :             :                        "%<enum %E%> declared in %<for%> loop "
   11416                 :             :                        "initial declaration", id);
   11417                 :           5 :           break;
   11418                 :          32 :         default:
   11419                 :          32 :           pedwarn_c11 (loc, OPT_Wpedantic, "declaration of non-variable "
   11420                 :             :                        "%qD in %<for%> loop initial declaration", decl);
   11421                 :             :         }
   11422                 :             : 
   11423                 :       21572 :       n_decls++;
   11424                 :       21572 :       one_decl = decl;
   11425                 :             :     }
   11426                 :             : 
   11427                 :       21525 :   return n_decls == 1 ? one_decl : NULL_TREE;
   11428                 :             : }
   11429                 :             : 
   11430                 :             : /* Save and reinitialize the variables
   11431                 :             :    used during compilation of a C function.  */
   11432                 :             : 
   11433                 :             : void
   11434                 :        1539 : c_push_function_context (void)
   11435                 :             : {
   11436                 :        1539 :   struct language_function *p = cfun->language;
   11437                 :             :   /* cfun->language might have been already allocated by the use of
   11438                 :             :      -Wunused-local-typedefs.  In that case, just re-use it.  */
   11439                 :        1539 :   if (p == NULL)
   11440                 :        1483 :     cfun->language = p = ggc_cleared_alloc<language_function> ();
   11441                 :             : 
   11442                 :        1539 :   p->base.x_stmt_tree = c_stmt_tree;
   11443                 :        1539 :   c_stmt_tree.x_cur_stmt_list = vec_safe_copy (c_stmt_tree.x_cur_stmt_list);
   11444                 :        1539 :   p->x_in_statement = in_statement;
   11445                 :        1539 :   p->x_switch_stack = c_switch_stack;
   11446                 :        1539 :   p->arg_info = current_function_arg_info;
   11447                 :        1539 :   p->returns_value = current_function_returns_value;
   11448                 :        1539 :   p->returns_null = current_function_returns_null;
   11449                 :        1539 :   p->returns_abnormally = current_function_returns_abnormally;
   11450                 :        1539 :   p->warn_about_return_type = warn_about_return_type;
   11451                 :             : 
   11452                 :        1539 :   push_function_context ();
   11453                 :        1539 : }
   11454                 :             : 
   11455                 :             : /* Restore the variables used during compilation of a C function.  */
   11456                 :             : 
   11457                 :             : void
   11458                 :        1539 : c_pop_function_context (void)
   11459                 :             : {
   11460                 :        1539 :   struct language_function *p;
   11461                 :             : 
   11462                 :        1539 :   pop_function_context ();
   11463                 :        1539 :   p = cfun->language;
   11464                 :             : 
   11465                 :             :   /* When -Wunused-local-typedefs is in effect, cfun->languages is
   11466                 :             :      used to store data throughout the life time of the current cfun,
   11467                 :             :      So don't deallocate it.  */
   11468                 :        1539 :   if (!warn_unused_local_typedefs)
   11469                 :        1483 :     cfun->language = NULL;
   11470                 :             : 
   11471                 :        1539 :   if (DECL_STRUCT_FUNCTION (current_function_decl) == 0
   11472                 :        1539 :       && DECL_SAVED_TREE (current_function_decl) == NULL_TREE)
   11473                 :             :     {
   11474                 :             :       /* Stop pointing to the local nodes about to be freed.  */
   11475                 :             :       /* But DECL_INITIAL must remain nonzero so we know this
   11476                 :             :          was an actual function definition.  */
   11477                 :           0 :       DECL_INITIAL (current_function_decl) = error_mark_node;
   11478                 :           0 :       DECL_ARGUMENTS (current_function_decl) = NULL_TREE;
   11479                 :             :     }
   11480                 :             : 
   11481                 :        1539 :   c_stmt_tree = p->base.x_stmt_tree;
   11482                 :        1539 :   p->base.x_stmt_tree.x_cur_stmt_list = NULL;
   11483                 :        1539 :   in_statement = p->x_in_statement;
   11484                 :        1539 :   c_switch_stack = p->x_switch_stack;
   11485                 :        1539 :   current_function_arg_info = p->arg_info;
   11486                 :        1539 :   current_function_returns_value = p->returns_value;
   11487                 :        1539 :   current_function_returns_null = p->returns_null;
   11488                 :        1539 :   current_function_returns_abnormally = p->returns_abnormally;
   11489                 :        1539 :   warn_about_return_type = p->warn_about_return_type;
   11490                 :        1539 : }
   11491                 :             : 
   11492                 :             : /* The functions below are required for functionality of doing
   11493                 :             :    function at once processing in the C front end. Currently these
   11494                 :             :    functions are not called from anywhere in the C front end, but as
   11495                 :             :    these changes continue, that will change.  */
   11496                 :             : 
   11497                 :             : /* Returns the stmt_tree (if any) to which statements are currently
   11498                 :             :    being added.  If there is no active statement-tree, NULL is
   11499                 :             :    returned.  */
   11500                 :             : 
   11501                 :             : stmt_tree
   11502                 :   636347725 : current_stmt_tree (void)
   11503                 :             : {
   11504                 :   636347725 :   return &c_stmt_tree;
   11505                 :             : }
   11506                 :             : 
   11507                 :             : /* Return the global value of T as a symbol.  */
   11508                 :             : 
   11509                 :             : tree
   11510                 :     3813423 : identifier_global_value (tree t)
   11511                 :             : {
   11512                 :     3813423 :   struct c_binding *b;
   11513                 :             : 
   11514                 :     3814388 :   for (b = I_SYMBOL_BINDING (t); b; b = b->shadowed)
   11515                 :     3807179 :     if (B_IN_FILE_SCOPE (b) || B_IN_EXTERNAL_SCOPE (b))
   11516                 :     3806214 :       return b->decl;
   11517                 :             : 
   11518                 :             :   return NULL_TREE;
   11519                 :             : }
   11520                 :             : 
   11521                 :             : /* Return the global value of tag T as a symbol.  */
   11522                 :             : 
   11523                 :             : tree
   11524                 :          12 : identifier_global_tag (tree t)
   11525                 :             : {
   11526                 :          12 :   struct c_binding *b;
   11527                 :             : 
   11528                 :          12 :   for (b = I_TAG_BINDING (t); b; b = b->shadowed)
   11529                 :          11 :     if (B_IN_FILE_SCOPE (b) || B_IN_EXTERNAL_SCOPE (b))
   11530                 :          11 :       return b->decl;
   11531                 :             : 
   11532                 :             :   return NULL_TREE;
   11533                 :             : }
   11534                 :             : 
   11535                 :             : /* Returns true if NAME refers to a built-in function or function-like
   11536                 :             :    operator.  */
   11537                 :             : 
   11538                 :             : bool
   11539                 :       23598 : names_builtin_p (const char *name)
   11540                 :             : {
   11541                 :       23598 :   tree id = get_identifier (name);
   11542                 :       23598 :   if (tree decl = identifier_global_value (id))
   11543                 :       23516 :     return TREE_CODE (decl) == FUNCTION_DECL && DECL_IS_UNDECLARED_BUILTIN (decl);
   11544                 :             : 
   11545                 :             :   /* Also detect common reserved C words that aren't strictly built-in
   11546                 :             :      functions.  */
   11547                 :          82 :   switch (C_RID_CODE (id))
   11548                 :             :     {
   11549                 :             :     case RID_BUILTIN_ASSOC_BARRIER:
   11550                 :             :     case RID_BUILTIN_CONVERTVECTOR:
   11551                 :             :     case RID_BUILTIN_HAS_ATTRIBUTE:
   11552                 :             :     case RID_BUILTIN_SHUFFLE:
   11553                 :             :     case RID_BUILTIN_SHUFFLEVECTOR:
   11554                 :             :     case RID_BUILTIN_STDC:
   11555                 :             :     case RID_CHOOSE_EXPR:
   11556                 :             :     case RID_OFFSETOF:
   11557                 :             :     case RID_TYPES_COMPATIBLE_P:
   11558                 :             :       return true;
   11559                 :             :     default:
   11560                 :             :       break;
   11561                 :             :     }
   11562                 :             : 
   11563                 :             :   return false;
   11564                 :             : }
   11565                 :             : 
   11566                 :             : /* In C, the only C-linkage public declaration is at file scope.  */
   11567                 :             : 
   11568                 :             : tree
   11569                 :           5 : c_linkage_bindings (tree name)
   11570                 :             : {
   11571                 :           5 :   return identifier_global_value (name);
   11572                 :             : }
   11573                 :             : 
   11574                 :             : /* Record a builtin type for C.  If NAME is non-NULL, it is the name used;
   11575                 :             :    otherwise the name is found in ridpointers from RID_INDEX.  */
   11576                 :             : 
   11577                 :             : void
   11578                 :     3131362 : record_builtin_type (enum rid rid_index, const char *name, tree type)
   11579                 :             : {
   11580                 :     3131362 :   tree id, decl;
   11581                 :     3131362 :   if (name == 0)
   11582                 :     1403714 :     id = ridpointers[(int) rid_index];
   11583                 :             :   else
   11584                 :     1727648 :     id = get_identifier (name);
   11585                 :     3131362 :   decl = build_decl (UNKNOWN_LOCATION, TYPE_DECL, id, type);
   11586                 :     3131362 :   pushdecl (decl);
   11587                 :     3131362 :   if (debug_hooks->type_decl)
   11588                 :     3131362 :     debug_hooks->type_decl (decl, false);
   11589                 :     3131362 : }
   11590                 :             : 
   11591                 :             : /* Return a c_parm structure with the given SPECS, ATTRS and DECLARATOR.  */
   11592                 :             : 
   11593                 :             : struct c_parm *
   11594                 :   108486179 : build_c_parm (struct c_declspecs *specs, tree attrs,
   11595                 :             :               struct c_declarator *declarator,
   11596                 :             :               location_t loc)
   11597                 :             : {
   11598                 :   108486179 :   struct c_parm *ret = XOBNEW (&parser_obstack, struct c_parm);
   11599                 :   108486179 :   ret->specs = specs;
   11600                 :   108486179 :   ret->attrs = attrs;
   11601                 :   108486179 :   ret->declarator = declarator;
   11602                 :   108486179 :   ret->loc = loc;
   11603                 :   108486179 :   return ret;
   11604                 :             : }
   11605                 :             : 
   11606                 :             : /* Return a declarator with nested attributes.  TARGET is the inner
   11607                 :             :    declarator to which these attributes apply.  ATTRS are the
   11608                 :             :    attributes.  */
   11609                 :             : 
   11610                 :             : struct c_declarator *
   11611                 :        6528 : build_attrs_declarator (tree attrs, struct c_declarator *target)
   11612                 :             : {
   11613                 :        6528 :   struct c_declarator *ret = XOBNEW (&parser_obstack, struct c_declarator);
   11614                 :        6528 :   ret->kind = cdk_attrs;
   11615                 :        6528 :   ret->declarator = target;
   11616                 :        6528 :   ret->u.attrs = attrs;
   11617                 :        6528 :   return ret;
   11618                 :             : }
   11619                 :             : 
   11620                 :             : /* Return a declarator for a function with arguments specified by ARGS
   11621                 :             :    and return type specified by TARGET.  */
   11622                 :             : 
   11623                 :             : struct c_declarator *
   11624                 :    43842191 : build_function_declarator (struct c_arg_info *args,
   11625                 :             :                            struct c_declarator *target)
   11626                 :             : {
   11627                 :    43842191 :   struct c_declarator *ret = XOBNEW (&parser_obstack, struct c_declarator);
   11628                 :    43842191 :   ret->kind = cdk_function;
   11629                 :    43842191 :   ret->declarator = target;
   11630                 :    43842191 :   ret->u.arg_info = args;
   11631                 :    43842191 :   return ret;
   11632                 :             : }
   11633                 :             : 
   11634                 :             : /* Return a declarator for the identifier IDENT (which may be
   11635                 :             :    NULL_TREE for an abstract declarator).  */
   11636                 :             : 
   11637                 :             : struct c_declarator *
   11638                 :   274435063 : build_id_declarator (tree ident)
   11639                 :             : {
   11640                 :   274435063 :   struct c_declarator *ret = XOBNEW (&parser_obstack, struct c_declarator);
   11641                 :   274435063 :   ret->kind = cdk_id;
   11642                 :   274435063 :   ret->declarator = 0;
   11643                 :   274435063 :   ret->u.id.id = ident;
   11644                 :   274435063 :   ret->u.id.attrs = NULL_TREE;
   11645                 :             :   /* Default value - may get reset to a more precise location. */
   11646                 :   274435063 :   ret->id_loc = input_location;
   11647                 :   274435063 :   return ret;
   11648                 :             : }
   11649                 :             : 
   11650                 :             : /* Return something to represent absolute declarators containing a *.
   11651                 :             :    TARGET is the absolute declarator that the * contains.
   11652                 :             :    TYPE_QUALS_ATTRS is a structure for type qualifiers and attributes
   11653                 :             :    to apply to the pointer type.  */
   11654                 :             : 
   11655                 :             : struct c_declarator *
   11656                 :    16598404 : make_pointer_declarator (struct c_declspecs *type_quals_attrs,
   11657                 :             :                          struct c_declarator *target)
   11658                 :             : {
   11659                 :    16598404 :   tree attrs;
   11660                 :    16598404 :   int quals = 0;
   11661                 :    16598404 :   struct c_declarator *itarget = target;
   11662                 :    16598404 :   struct c_declarator *ret = XOBNEW (&parser_obstack, struct c_declarator);
   11663                 :    16598404 :   if (type_quals_attrs)
   11664                 :             :     {
   11665                 :    16598404 :       attrs = type_quals_attrs->attrs;
   11666                 :    16598404 :       quals = quals_from_declspecs (type_quals_attrs);
   11667                 :    16598404 :       if (attrs != NULL_TREE)
   11668                 :        6325 :         itarget = build_attrs_declarator (attrs, target);
   11669                 :             :     }
   11670                 :    16598404 :   ret->kind = cdk_pointer;
   11671                 :    16598404 :   ret->declarator = itarget;
   11672                 :    16598404 :   ret->u.pointer_quals = quals;
   11673                 :    16598404 :   return ret;
   11674                 :             : }
   11675                 :             : 
   11676                 :             : /* Return a pointer to a structure for an empty list of declaration
   11677                 :             :    specifiers.  */
   11678                 :             : 
   11679                 :             : struct c_declspecs *
   11680                 :   397224953 : build_null_declspecs (void)
   11681                 :             : {
   11682                 :   397224953 :   struct c_declspecs *ret = XOBNEW (&parser_obstack, struct c_declspecs);
   11683                 :   397224953 :   memset (ret, 0, sizeof *ret);
   11684                 :   397224953 :   ret->align_log = -1;
   11685                 :   397224953 :   ret->typespec_word = cts_none;
   11686                 :   397224953 :   ret->storage_class = csc_none;
   11687                 :   397224953 :   ret->expr_const_operands = true;
   11688                 :   397224953 :   ret->typespec_kind = ctsk_none;
   11689                 :   397224953 :   ret->address_space = ADDR_SPACE_GENERIC;
   11690                 :   397224953 :   return ret;
   11691                 :             : }
   11692                 :             : 
   11693                 :             : /* Add the address space ADDRSPACE to the declaration specifiers
   11694                 :             :    SPECS, returning SPECS.  */
   11695                 :             : 
   11696                 :             : struct c_declspecs *
   11697                 :         160 : declspecs_add_addrspace (location_t location,
   11698                 :             :                          struct c_declspecs *specs, addr_space_t as)
   11699                 :             : {
   11700                 :         160 :   specs->non_sc_seen_p = true;
   11701                 :         160 :   specs->declspecs_seen_p = true;
   11702                 :         160 :   specs->non_std_attrs_seen_p = true;
   11703                 :             : 
   11704                 :         160 :   if (!ADDR_SPACE_GENERIC_P (specs->address_space)
   11705                 :           0 :       && specs->address_space != as)
   11706                 :           0 :     error ("incompatible address space qualifiers %qs and %qs",
   11707                 :             :            c_addr_space_name (as),
   11708                 :             :            c_addr_space_name (specs->address_space));
   11709                 :             :   else
   11710                 :             :     {
   11711                 :         160 :       specs->address_space = as;
   11712                 :         160 :       specs->locations[cdw_address_space] = location;
   11713                 :             :     }
   11714                 :         160 :   return specs;
   11715                 :             : }
   11716                 :             : 
   11717                 :             : /* Add the type qualifier QUAL to the declaration specifiers SPECS,
   11718                 :             :    returning SPECS.  */
   11719                 :             : 
   11720                 :             : struct c_declspecs *
   11721                 :    14456659 : declspecs_add_qual (location_t loc,
   11722                 :             :                     struct c_declspecs *specs, tree qual)
   11723                 :             : {
   11724                 :    14456659 :   enum rid i;
   11725                 :    14456659 :   bool dupe = false;
   11726                 :    14456659 :   specs->non_sc_seen_p = true;
   11727                 :    14456659 :   specs->declspecs_seen_p = true;
   11728                 :    14456659 :   specs->non_std_attrs_seen_p = true;
   11729                 :    14456659 :   gcc_assert (TREE_CODE (qual) == IDENTIFIER_NODE
   11730                 :             :               && C_IS_RESERVED_WORD (qual));
   11731                 :    14456659 :   i = C_RID_CODE (qual);
   11732                 :    14456659 :   location_t prev_loc = UNKNOWN_LOCATION;
   11733                 :    14456659 :   switch (i)
   11734                 :             :     {
   11735                 :    11329982 :     case RID_CONST:
   11736                 :    11329982 :       dupe = specs->const_p;
   11737                 :    11329982 :       specs->const_p = true;
   11738                 :    11329982 :       prev_loc = specs->locations[cdw_const];
   11739                 :    11329982 :       specs->locations[cdw_const] = loc;
   11740                 :    11329982 :       break;
   11741                 :       94060 :     case RID_VOLATILE:
   11742                 :       94060 :       dupe = specs->volatile_p;
   11743                 :       94060 :       specs->volatile_p = true;
   11744                 :       94060 :       prev_loc = specs->locations[cdw_volatile];
   11745                 :       94060 :       specs->locations[cdw_volatile] = loc;
   11746                 :       94060 :       break;
   11747                 :     3013798 :     case RID_RESTRICT:
   11748                 :     3013798 :       dupe = specs->restrict_p;
   11749                 :     3013798 :       specs->restrict_p = true;
   11750                 :     3013798 :       prev_loc = specs->locations[cdw_restrict];
   11751                 :     3013798 :       specs->locations[cdw_restrict] = loc;
   11752                 :     3013798 :       break;
   11753                 :       18819 :     case RID_ATOMIC:
   11754                 :       18819 :       dupe = specs->atomic_p;
   11755                 :       18819 :       specs->atomic_p = true;
   11756                 :       18819 :       prev_loc = specs->locations[cdw_atomic];
   11757                 :       18819 :       specs->locations[cdw_atomic] = loc;
   11758                 :       18819 :       break;
   11759                 :           0 :     default:
   11760                 :           0 :       gcc_unreachable ();
   11761                 :             :     }
   11762                 :    14456659 :   if (dupe)
   11763                 :             :     {
   11764                 :          56 :       bool warned = pedwarn_c90 (loc, OPT_Wpedantic,
   11765                 :             :                                  "duplicate %qE declaration specifier", qual);
   11766                 :          56 :       if (!warned
   11767                 :          52 :           && warn_duplicate_decl_specifier
   11768                 :          33 :           && prev_loc >= RESERVED_LOCATION_COUNT
   11769                 :          33 :           && !from_macro_expansion_at (prev_loc)
   11770                 :          77 :           && !from_macro_expansion_at (loc))
   11771                 :          12 :         warning_at (loc, OPT_Wduplicate_decl_specifier,
   11772                 :             :                     "duplicate %qE declaration specifier", qual);
   11773                 :             :     }
   11774                 :    14456659 :   return specs;
   11775                 :             : }
   11776                 :             : 
   11777                 :             : /* Add the type specifier TYPE to the declaration specifiers SPECS,
   11778                 :             :    returning SPECS.  */
   11779                 :             : 
   11780                 :             : struct c_declspecs *
   11781                 :   289772154 : declspecs_add_type (location_t loc, struct c_declspecs *specs,
   11782                 :             :                     struct c_typespec spec)
   11783                 :             : {
   11784                 :   289772154 :   tree type = spec.spec;
   11785                 :   289772154 :   specs->non_sc_seen_p = true;
   11786                 :   289772154 :   specs->declspecs_seen_p = true;
   11787                 :   289772154 :   specs->non_std_attrs_seen_p = true;
   11788                 :   289772154 :   specs->typespec_kind = spec.kind;
   11789                 :   289772154 :   if (TREE_DEPRECATED (type))
   11790                 :          56 :     specs->deprecated_p = true;
   11791                 :   289772154 :   if (TREE_UNAVAILABLE (type))
   11792                 :          40 :     specs->unavailable_p = true;
   11793                 :             : 
   11794                 :             :   /* As a type specifier is present, "auto" must be used as a storage
   11795                 :             :      class specifier, not for type deduction.  */
   11796                 :   289772154 :   if (specs->c23_auto_p)
   11797                 :             :     {
   11798                 :          10 :       specs->c23_auto_p = false;
   11799                 :          10 :       if (specs->storage_class != csc_none)
   11800                 :           1 :         error ("multiple storage classes in declaration specifiers");
   11801                 :           9 :       else if (specs->thread_p)
   11802                 :           1 :         error ("%qs used with %<auto%>",
   11803                 :           1 :                specs->thread_gnu_p ? "__thread" : "_Thread_local");
   11804                 :           8 :       else if (specs->constexpr_p)
   11805                 :             :         /* auto may only be used with another storage class specifier,
   11806                 :             :            such as constexpr, if the type is inferred.  */
   11807                 :           2 :         error ("%<auto%> used with %<constexpr%>");
   11808                 :             :       else
   11809                 :           6 :         specs->storage_class = csc_auto;
   11810                 :             :     }
   11811                 :             : 
   11812                 :             :   /* Handle type specifier keywords.  */
   11813                 :   289772154 :   if (TREE_CODE (type) == IDENTIFIER_NODE
   11814                 :    73337245 :       && C_IS_RESERVED_WORD (type)
   11815                 :   363109399 :       && C_RID_CODE (type) != RID_CXX_COMPAT_WARN)
   11816                 :             :     {
   11817                 :    73337245 :       enum rid i = C_RID_CODE (type);
   11818                 :    73337245 :       if (specs->type)
   11819                 :             :         {
   11820                 :          58 :           error_at (loc, "two or more data types in declaration specifiers");
   11821                 :          58 :           return specs;
   11822                 :             :         }
   11823                 :    73337187 :       if ((int) i <= (int) RID_LAST_MODIFIER)
   11824                 :             :         {
   11825                 :             :           /* "long", "short", "signed", "unsigned", "_Complex" or "_Sat".  */
   11826                 :    19323985 :           bool dupe = false;
   11827                 :    19323985 :           switch (i)
   11828                 :             :             {
   11829                 :     9148409 :             case RID_LONG:
   11830                 :     9148409 :               if (specs->long_long_p)
   11831                 :             :                 {
   11832                 :         104 :                   error_at (loc, "%<long long long%> is too long for GCC");
   11833                 :         104 :                   break;
   11834                 :             :                 }
   11835                 :     9148305 :               if (specs->long_p)
   11836                 :             :                 {
   11837                 :     2516195 :                   if (specs->typespec_word == cts_double)
   11838                 :             :                     {
   11839                 :          15 :                       error_at (loc,
   11840                 :             :                                 ("both %<long long%> and %<double%> in "
   11841                 :             :                                  "declaration specifiers"));
   11842                 :          15 :                       break;
   11843                 :             :                     }
   11844                 :     2516180 :                   pedwarn_c90 (loc, OPT_Wlong_long,
   11845                 :             :                                "ISO C90 does not support %<long long%>");
   11846                 :     2516180 :                   specs->long_long_p = 1;
   11847                 :     2516180 :                   specs->locations[cdw_long_long] = loc;
   11848                 :     2516180 :                   break;
   11849                 :             :                 }
   11850                 :     6632110 :               if (specs->short_p)
   11851                 :          77 :                 error_at (loc,
   11852                 :             :                           ("both %<long%> and %<short%> in "
   11853                 :             :                            "declaration specifiers"));
   11854                 :     6632033 :               else if (specs->typespec_word == cts_auto_type)
   11855                 :           1 :                 error_at (loc,
   11856                 :             :                           ("both %<long%> and %<__auto_type%> in "
   11857                 :             :                            "declaration specifiers"));
   11858                 :             :               else if (specs->typespec_word == cts_void)
   11859                 :           5 :                 error_at (loc,
   11860                 :             :                           ("both %<long%> and %<void%> in "
   11861                 :             :                            "declaration specifiers"));
   11862                 :             :               else if (specs->typespec_word == cts_int_n)
   11863                 :          19 :                 error_at (loc,
   11864                 :             :                           ("both %<long%> and %<__int%d%> in "
   11865                 :             :                            "declaration specifiers"),
   11866                 :          19 :                           int_n_data[specs->u.int_n_idx].bitsize);
   11867                 :             :               else if (specs->typespec_word == cts_bool)
   11868                 :           3 :                 error_at (loc,
   11869                 :             :                           ("both %<long%> and %<_Bool%> in "
   11870                 :             :                            "declaration specifiers"));
   11871                 :             :               else if (specs->typespec_word == cts_bitint)
   11872                 :           3 :                 error_at (loc,
   11873                 :             :                           ("both %<long%> and %<_BitInt%> in "
   11874                 :             :                            "declaration specifiers"));
   11875                 :             :               else if (specs->typespec_word == cts_char)
   11876                 :          21 :                 error_at (loc,
   11877                 :             :                           ("both %<long%> and %<char%> in "
   11878                 :             :                            "declaration specifiers"));
   11879                 :             :               else if (specs->typespec_word == cts_float)
   11880                 :           7 :                 error_at (loc,
   11881                 :             :                           ("both %<long%> and %<float%> in "
   11882                 :             :                            "declaration specifiers"));
   11883                 :             :               else if (specs->typespec_word == cts_floatn_nx)
   11884                 :           0 :                 error_at (loc,
   11885                 :             :                           ("both %<long%> and %<_Float%d%s%> in "
   11886                 :             :                            "declaration specifiers"),
   11887                 :           0 :                           floatn_nx_types[specs->u.floatn_nx_idx].n,
   11888                 :           0 :                           (floatn_nx_types[specs->u.floatn_nx_idx].extended
   11889                 :             :                            ? "x"
   11890                 :             :                            : ""));
   11891                 :             :               else if (specs->typespec_word == cts_dfloat32)
   11892                 :           4 :                 error_at (loc,
   11893                 :             :                           ("both %<long%> and %<_Decimal32%> in "
   11894                 :             :                            "declaration specifiers"));
   11895                 :             :               else if (specs->typespec_word == cts_dfloat64)
   11896                 :           4 :                 error_at (loc,
   11897                 :             :                           ("both %<long%> and %<_Decimal64%> in "
   11898                 :             :                            "declaration specifiers"));
   11899                 :             :               else if (specs->typespec_word == cts_dfloat128)
   11900                 :           4 :                 error_at (loc,
   11901                 :             :                           ("both %<long%> and %<_Decimal128%> in "
   11902                 :             :                            "declaration specifiers"));
   11903                 :             :               else
   11904                 :             :                 {
   11905                 :     6631962 :                   specs->long_p = true;
   11906                 :     6631962 :                   specs->locations[cdw_long] = loc;
   11907                 :             :                 }
   11908                 :             :               break;
   11909                 :     1623401 :             case RID_SHORT:
   11910                 :     1623401 :               dupe = specs->short_p;
   11911                 :     1623401 :               if (specs->long_p)
   11912                 :         197 :                 error_at (loc,
   11913                 :             :                           ("both %<long%> and %<short%> in "
   11914                 :             :                            "declaration specifiers"));
   11915                 :     1623204 :               else if (specs->typespec_word == cts_auto_type)
   11916                 :           1 :                 error_at (loc,
   11917                 :             :                           ("both %<short%> and %<__auto_type%> in "
   11918                 :             :                            "declaration specifiers"));
   11919                 :             :               else if (specs->typespec_word == cts_void)
   11920                 :           5 :                 error_at (loc,
   11921                 :             :                           ("both %<short%> and %<void%> in "
   11922                 :             :                            "declaration specifiers"));
   11923                 :             :               else if (specs->typespec_word == cts_int_n)
   11924                 :          19 :                 error_at (loc,
   11925                 :             :                           ("both %<short%> and %<__int%d%> in "
   11926                 :             :                            "declaration specifiers"),
   11927                 :          19 :                           int_n_data[specs->u.int_n_idx].bitsize);
   11928                 :             :               else if (specs->typespec_word == cts_bool)
   11929                 :           3 :                 error_at (loc,
   11930                 :             :                           ("both %<short%> and %<_Bool%> in "
   11931                 :             :                            "declaration specifiers"));
   11932                 :             :               else if (specs->typespec_word == cts_bitint)
   11933                 :           1 :                 error_at (loc,
   11934                 :             :                           ("both %<short%> and %<_BitInt%> in "
   11935                 :             :                            "declaration specifiers"));
   11936                 :             :               else if (specs->typespec_word == cts_char)
   11937                 :          21 :                 error_at (loc,
   11938                 :             :                           ("both %<short%> and %<char%> in "
   11939                 :             :                            "declaration specifiers"));
   11940                 :             :               else if (specs->typespec_word == cts_float)
   11941                 :           7 :                 error_at (loc,
   11942                 :             :                           ("both %<short%> and %<float%> in "
   11943                 :             :                            "declaration specifiers"));
   11944                 :             :               else if (specs->typespec_word == cts_double)
   11945                 :           7 :                 error_at (loc,
   11946                 :             :                           ("both %<short%> and %<double%> in "
   11947                 :             :                            "declaration specifiers"));
   11948                 :             :               else if (specs->typespec_word == cts_floatn_nx)
   11949                 :           0 :                 error_at (loc,
   11950                 :             :                           ("both %<short%> and %<_Float%d%s%> in "
   11951                 :             :                            "declaration specifiers"),
   11952                 :           0 :                           floatn_nx_types[specs->u.floatn_nx_idx].n,
   11953                 :           0 :                           (floatn_nx_types[specs->u.floatn_nx_idx].extended
   11954                 :             :                            ? "x"
   11955                 :             :                            : ""));
   11956                 :             :               else if (specs->typespec_word == cts_dfloat32)
   11957                 :           4 :                 error_at (loc,
   11958                 :             :                           ("both %<short%> and %<_Decimal32%> in "
   11959                 :             :                            "declaration specifiers"));
   11960                 :             :               else if (specs->typespec_word == cts_dfloat64)
   11961                 :           4 :                 error_at (loc,
   11962                 :             :                           ("both %<short%> and %<_Decimal64%> in "
   11963                 :             :                            "declaration specifiers"));
   11964                 :             :               else if (specs->typespec_word == cts_dfloat128)
   11965                 :           4 :                 error_at (loc,
   11966                 :             :                           ("both %<short%> and %<_Decimal128%> in "
   11967                 :             :                            "declaration specifiers"));
   11968                 :             :               else
   11969                 :             :                 {
   11970                 :     1623128 :                   specs->short_p = true;
   11971                 :     1623128 :                   specs->locations[cdw_short] = loc;
   11972                 :             :                 }
   11973                 :             :               break;
   11974                 :      560514 :             case RID_SIGNED:
   11975                 :      560514 :               dupe = specs->signed_p;
   11976                 :      560514 :               if (specs->unsigned_p)
   11977                 :         138 :                 error_at (loc,
   11978                 :             :                           ("both %<signed%> and %<unsigned%> in "
   11979                 :             :                            "declaration specifiers"));
   11980                 :      560376 :               else if (specs->typespec_word == cts_auto_type)
   11981                 :           1 :                 error_at (loc,
   11982                 :             :                           ("both %<signed%> and %<__auto_type%> in "
   11983                 :             :                            "declaration specifiers"));
   11984                 :             :               else if (specs->typespec_word == cts_void)
   11985                 :           5 :                 error_at (loc,
   11986                 :             :                           ("both %<signed%> and %<void%> in "
   11987                 :             :                            "declaration specifiers"));
   11988                 :             :               else if (specs->typespec_word == cts_bool)
   11989                 :           3 :                 error_at (loc,
   11990                 :             :                           ("both %<signed%> and %<_Bool%> in "
   11991                 :             :                            "declaration specifiers"));
   11992                 :             :               else if (specs->typespec_word == cts_float)
   11993                 :           7 :                 error_at (loc,
   11994                 :             :                           ("both %<signed%> and %<float%> in "
   11995                 :             :                            "declaration specifiers"));
   11996                 :             :               else if (specs->typespec_word == cts_double)
   11997                 :          21 :                 error_at (loc,
   11998                 :             :                           ("both %<signed%> and %<double%> in "
   11999                 :             :                            "declaration specifiers"));
   12000                 :             :               else if (specs->typespec_word == cts_floatn_nx)
   12001                 :           0 :                 error_at (loc,
   12002                 :             :                           ("both %<signed%> and %<_Float%d%s%> in "
   12003                 :             :                            "declaration specifiers"),
   12004                 :           0 :                           floatn_nx_types[specs->u.floatn_nx_idx].n,
   12005                 :           0 :                           (floatn_nx_types[specs->u.floatn_nx_idx].extended
   12006                 :             :                            ? "x"
   12007                 :             :                            : ""));
   12008                 :             :               else if (specs->typespec_word == cts_dfloat32)
   12009                 :           4 :                 error_at (loc,
   12010                 :             :                           ("both %<signed%> and %<_Decimal32%> in "
   12011                 :             :                            "declaration specifiers"));
   12012                 :             :               else if (specs->typespec_word == cts_dfloat64)
   12013                 :           4 :                 error_at (loc,
   12014                 :             :                           ("both %<signed%> and %<_Decimal64%> in "
   12015                 :             :                            "declaration specifiers"));
   12016                 :             :               else if (specs->typespec_word == cts_dfloat128)
   12017                 :           4 :                 error_at (loc,
   12018                 :             :                           ("both %<signed%> and %<_Decimal128%> in "
   12019                 :             :                            "declaration specifiers"));
   12020                 :             :               else
   12021                 :             :                 {
   12022                 :      560327 :                   specs->signed_p = true;
   12023                 :      560327 :                   specs->locations[cdw_signed] = loc;
   12024                 :             :                 }
   12025                 :             :               break;
   12026                 :     5717683 :             case RID_UNSIGNED:
   12027                 :     5717683 :               dupe = specs->unsigned_p;
   12028                 :     5717683 :               if (specs->signed_p)
   12029                 :         139 :                 error_at (loc,
   12030                 :             :                           ("both %<signed%> and %<unsigned%> in "
   12031                 :             :                            "declaration specifiers"));
   12032                 :     5717544 :               else if (specs->typespec_word == cts_auto_type)
   12033                 :           1 :                 error_at (loc,
   12034                 :             :                           ("both %<unsigned%> and %<__auto_type%> in "
   12035                 :             :                            "declaration specifiers"));
   12036                 :             :               else if (specs->typespec_word == cts_void)
   12037                 :           5 :                 error_at (loc,
   12038                 :             :                           ("both %<unsigned%> and %<void%> in "
   12039                 :             :                            "declaration specifiers"));
   12040                 :             :               else if (specs->typespec_word == cts_bool)
   12041                 :           3 :                 error_at (loc,
   12042                 :             :                           ("both %<unsigned%> and %<_Bool%> in "
   12043                 :             :                            "declaration specifiers"));
   12044                 :             :               else if (specs->typespec_word == cts_float)
   12045                 :           7 :                 error_at (loc,
   12046                 :             :                           ("both %<unsigned%> and %<float%> in "
   12047                 :             :                            "declaration specifiers"));
   12048                 :             :               else if (specs->typespec_word == cts_double)
   12049                 :          21 :                 error_at (loc,
   12050                 :             :                           ("both %<unsigned%> and %<double%> in "
   12051                 :             :                            "declaration specifiers"));
   12052                 :             :               else if (specs->typespec_word == cts_floatn_nx)
   12053                 :           0 :                 error_at (loc,
   12054                 :             :                           ("both %<unsigned%> and %<_Float%d%s%> in "
   12055                 :             :                            "declaration specifiers"),
   12056                 :           0 :                           floatn_nx_types[specs->u.floatn_nx_idx].n,
   12057                 :           0 :                           (floatn_nx_types[specs->u.floatn_nx_idx].extended
   12058                 :             :                            ? "x"
   12059                 :             :                            : ""));
   12060                 :             :               else if (specs->typespec_word == cts_dfloat32)
   12061                 :           2 :                 error_at (loc,
   12062                 :             :                           ("both %<unsigned%> and %<_Decimal32%> in "
   12063                 :             :                            "declaration specifiers"));
   12064                 :             :               else if (specs->typespec_word == cts_dfloat64)
   12065                 :           2 :                 error_at (loc,
   12066                 :             :                           ("both %<unsigned%> and %<_Decimal64%> in "
   12067                 :             :                            "declaration specifiers"));
   12068                 :             :               else if (specs->typespec_word == cts_dfloat128)
   12069                 :           2 :                 error_at (loc,
   12070                 :             :                           ("both %<unsigned%> and %<_Decimal128%> in "
   12071                 :             :                            "declaration specifiers"));
   12072                 :             :               else
   12073                 :             :                 {
   12074                 :     5717501 :                   specs->unsigned_p = true;
   12075                 :     5717501 :                   specs->locations[cdw_unsigned] = loc;
   12076                 :             :                 }
   12077                 :             :               break;
   12078                 :     2273845 :             case RID_COMPLEX:
   12079                 :     2273845 :               dupe = specs->complex_p;
   12080                 :     2273845 :               if (!in_system_header_at (loc))
   12081                 :       68129 :                 pedwarn_c90 (loc, OPT_Wpedantic,
   12082                 :             :                              "ISO C90 does not support complex types");
   12083                 :     2273845 :               if (specs->typespec_word == cts_auto_type)
   12084                 :           1 :                 error_at (loc,
   12085                 :             :                           ("both %<complex%> and %<__auto_type%> in "
   12086                 :             :                            "declaration specifiers"));
   12087                 :             :               else if (specs->typespec_word == cts_void)
   12088                 :           2 :                 error_at (loc,
   12089                 :             :                           ("both %<complex%> and %<void%> in "
   12090                 :             :                            "declaration specifiers"));
   12091                 :             :               else if (specs->typespec_word == cts_bool)
   12092                 :           2 :                 error_at (loc,
   12093                 :             :                           ("both %<complex%> and %<_Bool%> in "
   12094                 :             :                            "declaration specifiers"));
   12095                 :             :               else if (specs->typespec_word == cts_bitint)
   12096                 :           1 :                 error_at (loc,
   12097                 :             :                           ("both %<complex%> and %<_BitInt%> in "
   12098                 :             :                            "declaration specifiers"));
   12099                 :             :               else if (specs->typespec_word == cts_dfloat32)
   12100                 :           1 :                 error_at (loc,
   12101                 :             :                           ("both %<complex%> and %<_Decimal32%> in "
   12102                 :             :                            "declaration specifiers"));
   12103                 :             :               else if (specs->typespec_word == cts_dfloat64)
   12104                 :           1 :                 error_at (loc,
   12105                 :             :                           ("both %<complex%> and %<_Decimal64%> in "
   12106                 :             :                            "declaration specifiers"));
   12107                 :             :               else if (specs->typespec_word == cts_dfloat128)
   12108                 :           1 :                 error_at (loc,
   12109                 :             :                           ("both %<complex%> and %<_Decimal128%> in "
   12110                 :             :                            "declaration specifiers"));
   12111                 :             :               else if (specs->typespec_word == cts_fract)
   12112                 :           0 :                 error_at (loc,
   12113                 :             :                           ("both %<complex%> and %<_Fract%> in "
   12114                 :             :                            "declaration specifiers"));
   12115                 :             :               else if (specs->typespec_word == cts_accum)
   12116                 :           0 :                 error_at (loc,
   12117                 :             :                           ("both %<complex%> and %<_Accum%> in "
   12118                 :             :                            "declaration specifiers"));
   12119                 :     2273836 :               else if (specs->saturating_p)
   12120                 :           0 :                 error_at (loc,
   12121                 :             :                           ("both %<complex%> and %<_Sat%> in "
   12122                 :             :                            "declaration specifiers"));
   12123                 :             :               else
   12124                 :             :                 {
   12125                 :     2273836 :                   specs->complex_p = true;
   12126                 :     2273836 :                   specs->locations[cdw_complex] = loc;
   12127                 :             :                 }
   12128                 :             :               break;
   12129                 :         133 :             case RID_SAT:
   12130                 :         133 :               dupe = specs->saturating_p;
   12131                 :         133 :               pedwarn (loc, OPT_Wpedantic,
   12132                 :             :                        "ISO C does not support saturating types");
   12133                 :         133 :               if (specs->typespec_word == cts_int_n)
   12134                 :             :                 {
   12135                 :           0 :                   error_at (loc,
   12136                 :             :                             ("both %<_Sat%> and %<__int%d%> in "
   12137                 :             :                              "declaration specifiers"),
   12138                 :           0 :                             int_n_data[specs->u.int_n_idx].bitsize);
   12139                 :             :                 }
   12140                 :             :               else if (specs->typespec_word == cts_auto_type)
   12141                 :           0 :                 error_at (loc,
   12142                 :             :                           ("both %<_Sat%> and %<__auto_type%> in "
   12143                 :             :                            "declaration specifiers"));
   12144                 :             :               else if (specs->typespec_word == cts_void)
   12145                 :           0 :                 error_at (loc,
   12146                 :             :                           ("both %<_Sat%> and %<void%> in "
   12147                 :             :                            "declaration specifiers"));
   12148                 :             :               else if (specs->typespec_word == cts_bool)
   12149                 :           0 :                 error_at (loc,
   12150                 :             :                           ("both %<_Sat%> and %<_Bool%> in "
   12151                 :             :                            "declaration specifiers"));
   12152                 :             :               else if (specs->typespec_word == cts_bitint)
   12153                 :           0 :                 error_at (loc,
   12154                 :             :                           ("both %<_Sat%> and %<_BitInt%> in "
   12155                 :             :                            "declaration specifiers"));
   12156                 :             :               else if (specs->typespec_word == cts_char)
   12157                 :           0 :                 error_at (loc,
   12158                 :             :                           ("both %<_Sat%> and %<char%> in "
   12159                 :             :                            "declaration specifiers"));
   12160                 :             :               else if (specs->typespec_word == cts_int)
   12161                 :           0 :                 error_at (loc,
   12162                 :             :                           ("both %<_Sat%> and %<int%> in "
   12163                 :             :                            "declaration specifiers"));
   12164                 :             :               else if (specs->typespec_word == cts_float)
   12165                 :           0 :                 error_at (loc,
   12166                 :             :                           ("both %<_Sat%> and %<float%> in "
   12167                 :             :                            "declaration specifiers"));
   12168                 :             :               else if (specs->typespec_word == cts_double)
   12169                 :           0 :                 error_at (loc,
   12170                 :             :                           ("both %<_Sat%> and %<double%> in "
   12171                 :             :                            "declaration specifiers"));
   12172                 :             :               else if (specs->typespec_word == cts_floatn_nx)
   12173                 :           0 :                 error_at (loc,
   12174                 :             :                           ("both %<_Sat%> and %<_Float%d%s%> in "
   12175                 :             :                            "declaration specifiers"),
   12176                 :           0 :                           floatn_nx_types[specs->u.floatn_nx_idx].n,
   12177                 :           0 :                           (floatn_nx_types[specs->u.floatn_nx_idx].extended
   12178                 :             :                            ? "x"
   12179                 :             :                            : ""));
   12180                 :             :               else if (specs->typespec_word == cts_dfloat32)
   12181                 :           0 :                 error_at (loc,
   12182                 :             :                           ("both %<_Sat%> and %<_Decimal32%> in "
   12183                 :             :                            "declaration specifiers"));
   12184                 :             :               else if (specs->typespec_word == cts_dfloat64)
   12185                 :           0 :                 error_at (loc,
   12186                 :             :                           ("both %<_Sat%> and %<_Decimal64%> in "
   12187                 :             :                            "declaration specifiers"));
   12188                 :             :               else if (specs->typespec_word == cts_dfloat128)
   12189                 :           0 :                 error_at (loc,
   12190                 :             :                           ("both %<_Sat%> and %<_Decimal128%> in "
   12191                 :             :                            "declaration specifiers"));
   12192                 :         133 :               else if (specs->complex_p)
   12193                 :           0 :                 error_at (loc,
   12194                 :             :                           ("both %<_Sat%> and %<complex%> in "
   12195                 :             :                            "declaration specifiers"));
   12196                 :             :               else
   12197                 :             :                 {
   12198                 :         133 :                   specs->saturating_p = true;
   12199                 :         133 :                   specs->locations[cdw_saturating] = loc;
   12200                 :             :                 }
   12201                 :             :               break;
   12202                 :           0 :             default:
   12203                 :           0 :               gcc_unreachable ();
   12204                 :             :             }
   12205                 :             : 
   12206                 :    19323985 :           if (dupe)
   12207                 :         378 :             error_at (loc, "duplicate %qE", type);
   12208                 :             : 
   12209                 :    19323985 :           return specs;
   12210                 :             :         }
   12211                 :             :       else
   12212                 :             :         {
   12213                 :             :           /* "void", "_Bool", "char", "int", "float", "double",
   12214                 :             :              "_FloatN", "_FloatNx", "_Decimal32", "__intN",
   12215                 :             :              "_Decimal64", "_Decimal128", "_Fract", "_Accum", "_BitInt(N)" or
   12216                 :             :              "__auto_type".  */
   12217                 :    54013202 :           if (specs->typespec_word != cts_none)
   12218                 :             :             {
   12219                 :        2168 :               error_at (loc,
   12220                 :             :                         "two or more data types in declaration specifiers");
   12221                 :        2168 :               return specs;
   12222                 :             :             }
   12223                 :    54011034 :           switch (i)
   12224                 :             :             {
   12225                 :        1793 :             case RID_AUTO_TYPE:
   12226                 :        1793 :               if (specs->long_p)
   12227                 :           1 :                 error_at (loc,
   12228                 :             :                           ("both %<long%> and %<__auto_type%> in "
   12229                 :             :                            "declaration specifiers"));
   12230                 :        1792 :               else if (specs->short_p)
   12231                 :           1 :                 error_at (loc,
   12232                 :             :                           ("both %<short%> and %<__auto_type%> in "
   12233                 :             :                            "declaration specifiers"));
   12234                 :        1791 :               else if (specs->signed_p)
   12235                 :           1 :                 error_at (loc,
   12236                 :             :                           ("both %<signed%> and %<__auto_type%> in "
   12237                 :             :                            "declaration specifiers"));
   12238                 :        1790 :               else if (specs->unsigned_p)
   12239                 :           1 :                 error_at (loc,
   12240                 :             :                           ("both %<unsigned%> and %<__auto_type%> in "
   12241                 :             :                            "declaration specifiers"));
   12242                 :        1789 :               else if (specs->complex_p)
   12243                 :           1 :                 error_at (loc,
   12244                 :             :                           ("both %<complex%> and %<__auto_type%> in "
   12245                 :             :                            "declaration specifiers"));
   12246                 :        1788 :               else if (specs->saturating_p)
   12247                 :           0 :                 error_at (loc,
   12248                 :             :                           ("both %<_Sat%> and %<__auto_type%> in "
   12249                 :             :                            "declaration specifiers"));
   12250                 :             :               else
   12251                 :             :                 {
   12252                 :        1788 :                   specs->typespec_word = cts_auto_type;
   12253                 :        1788 :                   specs->locations[cdw_typespec] = loc;
   12254                 :             :                 }
   12255                 :        1793 :               return specs;
   12256                 :       50967 :             case RID_INT_N_0:
   12257                 :       50967 :             case RID_INT_N_1:
   12258                 :       50967 :             case RID_INT_N_2:
   12259                 :       50967 :             case RID_INT_N_3:
   12260                 :       50967 :               specs->u.int_n_idx = i - RID_INT_N_0;
   12261                 :       50967 :               if (!in_system_header_at (input_location)
   12262                 :             :                   /* If the INT_N type ends in "__", and so is of the format
   12263                 :             :                      "__intN__", don't pedwarn.  */
   12264                 :       50967 :                   && (strncmp (IDENTIFIER_POINTER (type)
   12265                 :       40811 :                                + (IDENTIFIER_LENGTH (type) - 2), "__", 2) != 0))
   12266                 :       40811 :                 pedwarn (loc, OPT_Wpedantic,
   12267                 :             :                          "ISO C does not support %<__int%d%> types",
   12268                 :       40811 :                          int_n_data[specs->u.int_n_idx].bitsize);
   12269                 :             : 
   12270                 :       50967 :               if (specs->long_p)
   12271                 :          53 :                 error_at (loc,
   12272                 :             :                           ("both %<__int%d%> and %<long%> in "
   12273                 :             :                            "declaration specifiers"),
   12274                 :          53 :                           int_n_data[specs->u.int_n_idx].bitsize);
   12275                 :       50914 :               else if (specs->saturating_p)
   12276                 :           0 :                 error_at (loc,
   12277                 :             :                           ("both %<_Sat%> and %<__int%d%> in "
   12278                 :             :                            "declaration specifiers"),
   12279                 :           0 :                           int_n_data[specs->u.int_n_idx].bitsize);
   12280                 :       50914 :               else if (specs->short_p)
   12281                 :          19 :                 error_at (loc,
   12282                 :             :                           ("both %<__int%d%> and %<short%> in "
   12283                 :             :                            "declaration specifiers"),
   12284                 :          19 :                           int_n_data[specs->u.int_n_idx].bitsize);
   12285                 :       50895 :               else if (! int_n_enabled_p[specs->u.int_n_idx])
   12286                 :             :                 {
   12287                 :           0 :                   specs->typespec_word = cts_int_n;
   12288                 :           0 :                   error_at (loc,
   12289                 :             :                             "%<__int%d%> is not supported on this target",
   12290                 :           0 :                             int_n_data[specs->u.int_n_idx].bitsize);
   12291                 :             :                 }
   12292                 :             :               else
   12293                 :             :                 {
   12294                 :       50895 :                   specs->typespec_word = cts_int_n;
   12295                 :       50895 :                   specs->locations[cdw_typespec] = loc;
   12296                 :             :                 }
   12297                 :       50967 :               return specs;
   12298                 :     7366827 :             case RID_VOID:
   12299                 :     7366827 :               if (specs->long_p)
   12300                 :          44 :                 error_at (loc,
   12301                 :             :                           ("both %<long%> and %<void%> in "
   12302                 :             :                            "declaration specifiers"));
   12303                 :     7366783 :               else if (specs->short_p)
   12304                 :          21 :                 error_at (loc,
   12305                 :             :                           ("both %<short%> and %<void%> in "
   12306                 :             :                            "declaration specifiers"));
   12307                 :     7366762 :               else if (specs->signed_p)
   12308                 :           5 :                 error_at (loc,
   12309                 :             :                           ("both %<signed%> and %<void%> in "
   12310                 :             :                            "declaration specifiers"));
   12311                 :     7366757 :               else if (specs->unsigned_p)
   12312                 :           5 :                 error_at (loc,
   12313                 :             :                           ("both %<unsigned%> and %<void%> in "
   12314                 :             :                            "declaration specifiers"));
   12315                 :     7366752 :               else if (specs->complex_p)
   12316                 :           2 :                 error_at (loc,
   12317                 :             :                           ("both %<complex%> and %<void%> in "
   12318                 :             :                            "declaration specifiers"));
   12319                 :     7366750 :               else if (specs->saturating_p)
   12320                 :           0 :                 error_at (loc,
   12321                 :             :                           ("both %<_Sat%> and %<void%> in "
   12322                 :             :                            "declaration specifiers"));
   12323                 :             :               else
   12324                 :             :                 {
   12325                 :     7366750 :                   specs->typespec_word = cts_void;
   12326                 :     7366750 :                   specs->locations[cdw_typespec] = loc;
   12327                 :             :                 }
   12328                 :     7366827 :               return specs;
   12329                 :       75588 :             case RID_BOOL:
   12330                 :       75588 :               if (!in_system_header_at (loc))
   12331                 :       22694 :                 pedwarn_c90 (loc, OPT_Wpedantic,
   12332                 :             :                              "ISO C90 does not support boolean types");
   12333                 :       75588 :               if (specs->long_p)
   12334                 :          27 :                 error_at (loc,
   12335                 :             :                           ("both %<long%> and %<_Bool%> in "
   12336                 :             :                            "declaration specifiers"));
   12337                 :       75561 :               else if (specs->short_p)
   12338                 :          11 :                 error_at (loc,
   12339                 :             :                           ("both %<short%> and %<_Bool%> in "
   12340                 :             :                            "declaration specifiers"));
   12341                 :       75550 :               else if (specs->signed_p)
   12342                 :           3 :                 error_at (loc,
   12343                 :             :                           ("both %<signed%> and %<_Bool%> in "
   12344                 :             :                            "declaration specifiers"));
   12345                 :       75547 :               else if (specs->unsigned_p)
   12346                 :           3 :                 error_at (loc,
   12347                 :             :                           ("both %<unsigned%> and %<_Bool%> in "
   12348                 :             :                            "declaration specifiers"));
   12349                 :       75544 :               else if (specs->complex_p)
   12350                 :           2 :                 error_at (loc,
   12351                 :             :                           ("both %<complex%> and %<_Bool%> in "
   12352                 :             :                            "declaration specifiers"));
   12353                 :       75542 :               else if (specs->saturating_p)
   12354                 :           0 :                 error_at (loc,
   12355                 :             :                           ("both %<_Sat%> and %<_Bool%> in "
   12356                 :             :                            "declaration specifiers"));
   12357                 :             :               else
   12358                 :             :                 {
   12359                 :       75542 :                   specs->typespec_word = cts_bool;
   12360                 :       75542 :                   specs->locations[cdw_typespec] = loc;
   12361                 :             :                 }
   12362                 :       75588 :               return specs;
   12363                 :     8484055 :             case RID_CHAR:
   12364                 :     8484055 :               if (specs->long_p)
   12365                 :          44 :                 error_at (loc,
   12366                 :             :                           ("both %<long%> and %<char%> in "
   12367                 :             :                            "declaration specifiers"));
   12368                 :     8484011 :               else if (specs->short_p)
   12369                 :          21 :                 error_at (loc,
   12370                 :             :                           ("both %<short%> and %<char%> in "
   12371                 :             :                            "declaration specifiers"));
   12372                 :     8483990 :               else if (specs->saturating_p)
   12373                 :           0 :                 error_at (loc,
   12374                 :             :                           ("both %<_Sat%> and %<char%> in "
   12375                 :             :                            "declaration specifiers"));
   12376                 :             :               else
   12377                 :             :                 {
   12378                 :     8483990 :                   specs->typespec_word = cts_char;
   12379                 :     8483990 :                   specs->locations[cdw_typespec] = loc;
   12380                 :             :                 }
   12381                 :     8484055 :               return specs;
   12382                 :    21558431 :             case RID_INT:
   12383                 :    21558431 :               if (specs->saturating_p)
   12384                 :           0 :                 error_at (loc,
   12385                 :             :                           ("both %<_Sat%> and %<int%> in "
   12386                 :             :                            "declaration specifiers"));
   12387                 :             :               else
   12388                 :             :                 {
   12389                 :    21558431 :                   specs->typespec_word = cts_int;
   12390                 :    21558431 :                   specs->locations[cdw_typespec] = loc;
   12391                 :             :                 }
   12392                 :    21558431 :               return specs;
   12393                 :     2862973 :             case RID_FLOAT:
   12394                 :     2862973 :               if (specs->long_p)
   12395                 :          44 :                 error_at (loc,
   12396                 :             :                           ("both %<long%> and %<float%> in "
   12397                 :             :                            "declaration specifiers"));
   12398                 :     2862929 :               else if (specs->short_p)
   12399                 :          21 :                 error_at (loc,
   12400                 :             :                           ("both %<short%> and %<float%> in "
   12401                 :             :                            "declaration specifiers"));
   12402                 :     2862908 :               else if (specs->signed_p)
   12403                 :           5 :                 error_at (loc,
   12404                 :             :                           ("both %<signed%> and %<float%> in "
   12405                 :             :                            "declaration specifiers"));
   12406                 :     2862903 :               else if (specs->unsigned_p)
   12407                 :           5 :                 error_at (loc,
   12408                 :             :                           ("both %<unsigned%> and %<float%> in "
   12409                 :             :                            "declaration specifiers"));
   12410                 :     2862898 :               else if (specs->saturating_p)
   12411                 :           0 :                 error_at (loc,
   12412                 :             :                           ("both %<_Sat%> and %<float%> in "
   12413                 :             :                            "declaration specifiers"));
   12414                 :             :               else
   12415                 :             :                 {
   12416                 :     2862898 :                   specs->typespec_word = cts_float;
   12417                 :     2862898 :                   specs->locations[cdw_typespec] = loc;
   12418                 :             :                 }
   12419                 :     2862973 :               return specs;
   12420                 :     5032271 :             case RID_DOUBLE:
   12421                 :     5032271 :               if (specs->long_long_p)
   12422                 :          22 :                 error_at (loc,
   12423                 :             :                           ("both %<long long%> and %<double%> in "
   12424                 :             :                            "declaration specifiers"));
   12425                 :     5032249 :               else if (specs->short_p)
   12426                 :          21 :                 error_at (loc,
   12427                 :             :                           ("both %<short%> and %<double%> in "
   12428                 :             :                            "declaration specifiers"));
   12429                 :     5032228 :               else if (specs->signed_p)
   12430                 :          13 :                 error_at (loc,
   12431                 :             :                           ("both %<signed%> and %<double%> in "
   12432                 :             :                            "declaration specifiers"));
   12433                 :     5032215 :               else if (specs->unsigned_p)
   12434                 :          13 :                 error_at (loc,
   12435                 :             :                           ("both %<unsigned%> and %<double%> in "
   12436                 :             :                            "declaration specifiers"));
   12437                 :     5032202 :               else if (specs->saturating_p)
   12438                 :           0 :                 error_at (loc,
   12439                 :             :                           ("both %<_Sat%> and %<double%> in "
   12440                 :             :                            "declaration specifiers"));
   12441                 :             :               else
   12442                 :             :                 {
   12443                 :     5032202 :                   specs->typespec_word = cts_double;
   12444                 :     5032202 :                   specs->locations[cdw_typespec] = loc;
   12445                 :             :                 }
   12446                 :     5032271 :               return specs;
   12447                 :     8485658 :             CASE_RID_FLOATN_NX:
   12448                 :     8485658 :               specs->u.floatn_nx_idx = i - RID_FLOATN_NX_FIRST;
   12449                 :     8485658 :               if (!in_system_header_at (input_location))
   12450                 :       95808 :                 pedwarn_c11 (loc, OPT_Wpedantic,
   12451                 :             :                              "ISO C does not support the %<_Float%d%s%> type"
   12452                 :             :                              " before C23",
   12453                 :       47904 :                              floatn_nx_types[specs->u.floatn_nx_idx].n,
   12454                 :       47904 :                              (floatn_nx_types[specs->u.floatn_nx_idx].extended
   12455                 :             :                               ? "x"
   12456                 :             :                               : ""));
   12457                 :             : 
   12458                 :     8485658 :               if (specs->long_p)
   12459                 :           0 :                 error_at (loc,
   12460                 :             :                           ("both %<long%> and %<_Float%d%s%> in "
   12461                 :             :                            "declaration specifiers"),
   12462                 :           0 :                           floatn_nx_types[specs->u.floatn_nx_idx].n,
   12463                 :           0 :                           (floatn_nx_types[specs->u.floatn_nx_idx].extended
   12464                 :             :                            ? "x"
   12465                 :             :                            : ""));
   12466                 :     8485658 :               else if (specs->short_p)
   12467                 :           0 :                 error_at (loc,
   12468                 :             :                           ("both %<short%> and %<_Float%d%s%> in "
   12469                 :             :                            "declaration specifiers"),
   12470                 :           0 :                           floatn_nx_types[specs->u.floatn_nx_idx].n,
   12471                 :           0 :                           (floatn_nx_types[specs->u.floatn_nx_idx].extended
   12472                 :             :                            ? "x"
   12473                 :             :                            : ""));
   12474                 :     8485658 :               else if (specs->signed_p)
   12475                 :           0 :                 error_at (loc,
   12476                 :             :                           ("both %<signed%> and %<_Float%d%s%> in "
   12477                 :             :                            "declaration specifiers"),
   12478                 :           0 :                           floatn_nx_types[specs->u.floatn_nx_idx].n,
   12479                 :           0 :                           (floatn_nx_types[specs->u.floatn_nx_idx].extended
   12480                 :             :                            ? "x"
   12481                 :             :                            : ""));
   12482                 :     8485658 :               else if (specs->unsigned_p)
   12483                 :           0 :                 error_at (loc,
   12484                 :             :                           ("both %<unsigned%> and %<_Float%d%s%> in "
   12485                 :             :                            "declaration specifiers"),
   12486                 :           0 :                           floatn_nx_types[specs->u.floatn_nx_idx].n,
   12487                 :           0 :                           (floatn_nx_types[specs->u.floatn_nx_idx].extended
   12488                 :             :                            ? "x"
   12489                 :             :                            : ""));
   12490                 :     8485658 :               else if (specs->saturating_p)
   12491                 :           0 :                 error_at (loc,
   12492                 :             :                           ("both %<_Sat%> and %<_Float%d%s%> in "
   12493                 :             :                            "declaration specifiers"),
   12494                 :           0 :                           floatn_nx_types[specs->u.floatn_nx_idx].n,
   12495                 :           0 :                           (floatn_nx_types[specs->u.floatn_nx_idx].extended
   12496                 :             :                            ? "x"
   12497                 :             :                            : ""));
   12498                 :     8485658 :               else if (FLOATN_NX_TYPE_NODE (specs->u.floatn_nx_idx) == NULL_TREE)
   12499                 :             :                 {
   12500                 :          88 :                   specs->typespec_word = cts_floatn_nx;
   12501                 :         176 :                   error_at (loc,
   12502                 :             :                             "%<_Float%d%s%> is not supported on this target",
   12503                 :          88 :                             floatn_nx_types[specs->u.floatn_nx_idx].n,
   12504                 :          88 :                             (floatn_nx_types[specs->u.floatn_nx_idx].extended
   12505                 :             :                              ? "x"
   12506                 :             :                              : ""));
   12507                 :             :                 }
   12508                 :             :               else
   12509                 :             :                 {
   12510                 :     8485570 :                   specs->typespec_word = cts_floatn_nx;
   12511                 :     8485570 :                   specs->locations[cdw_typespec] = loc;
   12512                 :             :                 }
   12513                 :     8485658 :               return specs;
   12514                 :       47499 :             case RID_DFLOAT32:
   12515                 :       47499 :             case RID_DFLOAT64:
   12516                 :       47499 :             case RID_DFLOAT128:
   12517                 :       47499 :               {
   12518                 :       47499 :                 const char *str;
   12519                 :       47499 :                 if (i == RID_DFLOAT32)
   12520                 :             :                   str = "_Decimal32";
   12521                 :       31597 :                 else if (i == RID_DFLOAT64)
   12522                 :             :                   str = "_Decimal64";
   12523                 :             :                 else
   12524                 :       15749 :                   str = "_Decimal128";
   12525                 :       47499 :                 if (specs->long_long_p)
   12526                 :          18 :                   error_at (loc,
   12527                 :             :                             ("both %<long long%> and %qs in "
   12528                 :             :                              "declaration specifiers"),
   12529                 :             :                             str);
   12530                 :       47499 :                 if (specs->long_p)
   12531                 :          33 :                   error_at (loc,
   12532                 :             :                             ("both %<long%> and %qs in "
   12533                 :             :                              "declaration specifiers"),
   12534                 :             :                             str);
   12535                 :       47466 :                 else if (specs->short_p)
   12536                 :          18 :                   error_at (loc,
   12537                 :             :                             ("both %<short%> and %qs in "
   12538                 :             :                              "declaration specifiers"),
   12539                 :             :                             str);
   12540                 :       47448 :                 else if (specs->signed_p)
   12541                 :           6 :                   error_at (loc,
   12542                 :             :                             ("both %<signed%> and %qs in "
   12543                 :             :                              "declaration specifiers"),
   12544                 :             :                             str);
   12545                 :       47442 :                 else if (specs->unsigned_p)
   12546                 :           3 :                   error_at (loc,
   12547                 :             :                             ("both %<unsigned%> and %qs in "
   12548                 :             :                              "declaration specifiers"),
   12549                 :             :                             str);
   12550                 :       47439 :                 else if (specs->complex_p)
   12551                 :           3 :                   error_at (loc,
   12552                 :             :                             ("both %<complex%> and %qs in "
   12553                 :             :                              "declaration specifiers"),
   12554                 :             :                             str);
   12555                 :       47436 :                 else if (specs->saturating_p)
   12556                 :           0 :                   error_at (loc,
   12557                 :             :                             ("both %<_Sat%> and %qs in "
   12558                 :             :                              "declaration specifiers"),
   12559                 :             :                             str);
   12560                 :       47436 :                 else if (i == RID_DFLOAT32)
   12561                 :       15881 :                   specs->typespec_word = cts_dfloat32;
   12562                 :       31555 :                 else if (i == RID_DFLOAT64)
   12563                 :       15827 :                   specs->typespec_word = cts_dfloat64;
   12564                 :             :                 else
   12565                 :       15728 :                   specs->typespec_word = cts_dfloat128;
   12566                 :       47499 :                 specs->locations[cdw_typespec] = loc;
   12567                 :             :               }
   12568                 :       47499 :               if (!targetm.decimal_float_supported_p ())
   12569                 :           0 :                 error_at (loc,
   12570                 :             :                           ("decimal floating-point not supported "
   12571                 :             :                            "for this target"));
   12572                 :       47499 :               pedwarn_c11 (loc, OPT_Wpedantic,
   12573                 :             :                            "ISO C does not support decimal floating-point "
   12574                 :             :                            "before C23");
   12575                 :       47499 :               return specs;
   12576                 :         135 :             case RID_FRACT:
   12577                 :         135 :             case RID_ACCUM:
   12578                 :         135 :               {
   12579                 :         135 :                 const char *str;
   12580                 :         135 :                 if (i == RID_FRACT)
   12581                 :             :                   str = "_Fract";
   12582                 :             :                 else
   12583                 :          67 :                   str = "_Accum";
   12584                 :         135 :                 if (specs->complex_p)
   12585                 :           0 :                   error_at (loc,
   12586                 :             :                             ("both %<complex%> and %qs in "
   12587                 :             :                              "declaration specifiers"),
   12588                 :             :                             str);
   12589                 :         135 :                 else if (i == RID_FRACT)
   12590                 :          68 :                     specs->typespec_word = cts_fract;
   12591                 :             :                 else
   12592                 :          67 :                     specs->typespec_word = cts_accum;
   12593                 :         135 :                 specs->locations[cdw_typespec] = loc;
   12594                 :             :               }
   12595                 :         135 :               if (!targetm.fixed_point_supported_p ())
   12596                 :         135 :                 error_at (loc,
   12597                 :             :                           "fixed-point types not supported for this target");
   12598                 :         135 :               pedwarn (loc, OPT_Wpedantic,
   12599                 :             :                        "ISO C does not support fixed-point types");
   12600                 :         135 :               return specs;
   12601                 :       44837 :             case RID_BITINT:
   12602                 :       44837 :               if (specs->long_p)
   12603                 :           2 :                 error_at (loc,
   12604                 :             :                           ("both %<long%> and %<_BitInt%> in "
   12605                 :             :                            "declaration specifiers"));
   12606                 :       44835 :               else if (specs->short_p)
   12607                 :           1 :                 error_at (loc,
   12608                 :             :                           ("both %<short%> and %<_BitInt%> in "
   12609                 :             :                            "declaration specifiers"));
   12610                 :       44834 :               else if (specs->complex_p)
   12611                 :           1 :                 error_at (loc,
   12612                 :             :                           ("both %<complex%> and %<_BitInt%> in "
   12613                 :             :                            "declaration specifiers"));
   12614                 :       44833 :               else if (specs->saturating_p)
   12615                 :           0 :                 error_at (loc,
   12616                 :             :                           ("both %<_Sat%> and %<_BitInt%> in "
   12617                 :             :                            "declaration specifiers"));
   12618                 :             :               else
   12619                 :             :                 {
   12620                 :       44833 :                   specs->typespec_word = cts_bitint;
   12621                 :       44833 :                   specs->locations[cdw_typespec] = loc;
   12622                 :       44833 :                   specs->u.bitint_prec = -1;
   12623                 :       44833 :                   if (error_operand_p (spec.expr))
   12624                 :           7 :                     return specs;
   12625                 :       44833 :                   if (TREE_CODE (spec.expr) != INTEGER_CST
   12626                 :       44833 :                       || !INTEGRAL_TYPE_P (TREE_TYPE (spec.expr)))
   12627                 :             :                     {
   12628                 :           1 :                       error_at (loc, "%<_BitInt%> argument is not an integer "
   12629                 :             :                                      "constant expression");
   12630                 :           1 :                       return specs;
   12631                 :             :                     }
   12632                 :       44832 :                   if (tree_int_cst_sgn (spec.expr) <= 0)
   12633                 :             :                     {
   12634                 :           4 :                       error_at (loc, "%<_BitInt%> argument %qE is not a "
   12635                 :             :                                      "positive integer constant expression",
   12636                 :             :                                 spec.expr);
   12637                 :           4 :                       return specs;
   12638                 :             :                     }
   12639                 :       44828 :                   if (wi::to_widest (spec.expr) > WIDE_INT_MAX_PRECISION - 1)
   12640                 :             :                     {
   12641                 :           2 :                       error_at (loc, "%<_BitInt%> argument %qE is larger than "
   12642                 :             :                                      "%<BITINT_MAXWIDTH%> %qd",
   12643                 :             :                                 spec.expr, (int) WIDE_INT_MAX_PRECISION - 1);
   12644                 :           2 :                       return specs;
   12645                 :             :                     }
   12646                 :       44826 :                   specs->u.bitint_prec = tree_to_uhwi (spec.expr);
   12647                 :       44826 :                   struct bitint_info info;
   12648                 :       44826 :                   if (!targetm.c.bitint_type_info (specs->u.bitint_prec,
   12649                 :             :                                                    &info))
   12650                 :             :                     {
   12651                 :           0 :                       sorry_at (loc, "%<_BitInt(%d)%> is not supported on "
   12652                 :             :                                      "this target", specs->u.bitint_prec);
   12653                 :           0 :                       specs->u.bitint_prec = -1;
   12654                 :           0 :                       return specs;
   12655                 :             :                     }
   12656                 :             :                 }
   12657                 :       44830 :               return specs;
   12658                 :             :             default:
   12659                 :             :               /* ObjC reserved word "id", handled below.  */
   12660                 :             :               break;
   12661                 :             :             }
   12662                 :             :         }
   12663                 :             :     }
   12664                 :             : 
   12665                 :             :   /* Now we have a typedef (a TYPE_DECL node), an identifier (some
   12666                 :             :      form of ObjC type, cases such as "int" and "long" being handled
   12667                 :             :      above), a TYPE (struct, union, enum and typeof specifiers) or an
   12668                 :             :      ERROR_MARK.  In none of these cases may there have previously
   12669                 :             :      been any type specifiers.  */
   12670                 :   216434909 :   if (specs->type || specs->typespec_word != cts_none
   12671                 :             :       || specs->long_p || specs->short_p || specs->signed_p
   12672                 :   216434904 :       || specs->unsigned_p || specs->complex_p)
   12673                 :          21 :     error_at (loc, "two or more data types in declaration specifiers");
   12674                 :   216434888 :   else if (TREE_CODE (type) == TYPE_DECL)
   12675                 :             :     {
   12676                 :   213506646 :       specs->type = TREE_TYPE (type);
   12677                 :   213506646 :       if (TREE_TYPE (type) != error_mark_node)
   12678                 :             :         {
   12679                 :   213506633 :           specs->decl_attr = DECL_ATTRIBUTES (type);
   12680                 :   213506633 :           specs->typedef_p = true;
   12681                 :   213506633 :           specs->explicit_signed_p = C_TYPEDEF_EXPLICITLY_SIGNED (type);
   12682                 :   213506633 :           specs->locations[cdw_typedef] = loc;
   12683                 :             : 
   12684                 :             :           /* If this typedef name is defined in a struct, then a C++
   12685                 :             :              lookup would return a different value.  */
   12686                 :   213506633 :           if (warn_cxx_compat
   12687                 :   213506633 :               && I_SYMBOL_BINDING (DECL_NAME (type))->in_struct)
   12688                 :           2 :             warning_at (loc, OPT_Wc___compat,
   12689                 :             :                         "C++ lookup of %qD would return a field, not a type",
   12690                 :             :                         type);
   12691                 :             : 
   12692                 :             :           /* If we are parsing a struct, record that a struct field
   12693                 :             :              used a typedef.  */
   12694                 :   213506633 :           if (warn_cxx_compat && struct_parse_info != NULL)
   12695                 :        1444 :             struct_parse_info->typedefs_seen.safe_push (type);
   12696                 :             :         }
   12697                 :             :     }
   12698                 :     2928242 :   else if (TREE_CODE (type) == IDENTIFIER_NODE)
   12699                 :             :     {
   12700                 :           0 :       tree t = lookup_name (type);
   12701                 :           0 :       if (!t || TREE_CODE (t) != TYPE_DECL)
   12702                 :           0 :         error_at (loc, "%qE fails to be a typedef or built in type", type);
   12703                 :           0 :       else if (TREE_TYPE (t) == error_mark_node)
   12704                 :             :         ;
   12705                 :             :       else
   12706                 :             :         {
   12707                 :           0 :           specs->type = TREE_TYPE (t);
   12708                 :           0 :           specs->locations[cdw_typespec] = loc;
   12709                 :             :         }
   12710                 :             :     }
   12711                 :             :   else
   12712                 :             :     {
   12713                 :     2928242 :       if (TREE_CODE (type) != ERROR_MARK)
   12714                 :             :         {
   12715                 :     2928061 :           if (spec.kind == ctsk_typeof)
   12716                 :             :             {
   12717                 :      685218 :               specs->typedef_p = true;
   12718                 :      685218 :               specs->locations[cdw_typedef] = loc;
   12719                 :             :             }
   12720                 :     2928061 :           if (spec.expr)
   12721                 :             :             {
   12722                 :         826 :               if (specs->expr)
   12723                 :           0 :                 specs->expr = build2 (COMPOUND_EXPR, TREE_TYPE (spec.expr),
   12724                 :             :                                       specs->expr, spec.expr);
   12725                 :             :               else
   12726                 :         826 :                 specs->expr = spec.expr;
   12727                 :         826 :               specs->expr_const_operands &= spec.expr_const_operands;
   12728                 :             :             }
   12729                 :             :         }
   12730                 :     2928242 :       specs->type = type;
   12731                 :     2928242 :       if (spec.has_enum_type_specifier
   12732                 :         158 :           && spec.kind != ctsk_tagdef)
   12733                 :          49 :         specs->enum_type_specifier_ref_p = true;
   12734                 :             :     }
   12735                 :             : 
   12736                 :             :   return specs;
   12737                 :             : }
   12738                 :             : 
   12739                 :             : /* Add the storage class specifier or function specifier SCSPEC to the
   12740                 :             :    declaration specifiers SPECS, returning SPECS.  */
   12741                 :             : 
   12742                 :             : struct c_declspecs *
   12743                 :    78780584 : declspecs_add_scspec (location_t loc,
   12744                 :             :                       struct c_declspecs *specs,
   12745                 :             :                       tree scspec)
   12746                 :             : {
   12747                 :    78780584 :   enum rid i;
   12748                 :    78780584 :   enum c_storage_class n = csc_none;
   12749                 :    78780584 :   bool dupe = false;
   12750                 :    78780584 :   specs->declspecs_seen_p = true;
   12751                 :    78780584 :   specs->non_std_attrs_seen_p = true;
   12752                 :    78780584 :   gcc_assert (TREE_CODE (scspec) == IDENTIFIER_NODE
   12753                 :             :               && C_IS_RESERVED_WORD (scspec));
   12754                 :    78780584 :   i = C_RID_CODE (scspec);
   12755                 :    78780584 :   if (specs->non_sc_seen_p)
   12756                 :        2076 :     warning (OPT_Wold_style_declaration,
   12757                 :             :              "%qE is not at beginning of declaration", scspec);
   12758                 :    78780584 :   switch (i)
   12759                 :             :     {
   12760                 :    31106422 :     case RID_INLINE:
   12761                 :             :       /* C99 permits duplicate inline.  Although of doubtful utility,
   12762                 :             :          it seems simplest to permit it in gnu89 mode as well, as
   12763                 :             :          there is also little utility in maintaining this as a
   12764                 :             :          difference between gnu89 and C99 inline.  */
   12765                 :    31106422 :       dupe = false;
   12766                 :    31106422 :       specs->inline_p = true;
   12767                 :    31106422 :       specs->locations[cdw_inline] = loc;
   12768                 :    31106422 :       break;
   12769                 :       19829 :     case RID_NORETURN:
   12770                 :             :       /* Duplicate _Noreturn is permitted.  */
   12771                 :       19829 :       dupe = false;
   12772                 :       19829 :       specs->noreturn_p = true;
   12773                 :       19829 :       specs->locations[cdw_noreturn] = loc;
   12774                 :       19829 :       break;
   12775                 :        2826 :     case RID_THREAD:
   12776                 :        2826 :       dupe = specs->thread_p;
   12777                 :        2826 :       if (specs->storage_class == csc_auto)
   12778                 :           2 :         error ("%qE used with %<auto%>", scspec);
   12779                 :        2824 :       else if (specs->storage_class == csc_register)
   12780                 :           3 :         error ("%qE used with %<register%>", scspec);
   12781                 :        2821 :       else if (specs->storage_class == csc_typedef)
   12782                 :           2 :         error ("%qE used with %<typedef%>", scspec);
   12783                 :        2819 :       else if (specs->constexpr_p)
   12784                 :           2 :         error ("%qE used with %<constexpr%>", scspec);
   12785                 :             :       else
   12786                 :             :         {
   12787                 :        2817 :           specs->thread_p = true;
   12788                 :        2817 :           specs->thread_gnu_p = (strcmp (IDENTIFIER_POINTER (scspec),
   12789                 :        2817 :                                          "__thread") == 0);
   12790                 :             :           /* A diagnostic is not required for the use of this
   12791                 :             :              identifier in the implementation namespace; only diagnose
   12792                 :             :              it for the C11 spelling because of existing code using
   12793                 :             :              the other spelling.  */
   12794                 :        2817 :           if (!specs->thread_gnu_p)
   12795                 :             :             {
   12796                 :          91 :               if (flag_isoc99)
   12797                 :          88 :                 pedwarn_c99 (loc, OPT_Wpedantic,
   12798                 :             :                              "ISO C99 does not support %qE", scspec);
   12799                 :             :               else
   12800                 :           3 :                 pedwarn_c99 (loc, OPT_Wpedantic,
   12801                 :             :                              "ISO C90 does not support %qE", scspec);
   12802                 :             :             }
   12803                 :        2817 :           specs->locations[cdw_thread] = loc;
   12804                 :             :         }
   12805                 :             :       break;
   12806                 :         233 :     case RID_AUTO:
   12807                 :         233 :       if (flag_isoc23
   12808                 :          90 :           && specs->typespec_kind == ctsk_none
   12809                 :          82 :           && specs->storage_class != csc_typedef)
   12810                 :             :         {
   12811                 :             :           /* "auto" potentially used for type deduction.  */
   12812                 :          81 :           if (specs->c23_auto_p)
   12813                 :           1 :             error ("duplicate %qE", scspec);
   12814                 :          81 :           specs->c23_auto_p = true;
   12815                 :          81 :           return specs;
   12816                 :             :         }
   12817                 :         152 :       n = csc_auto;
   12818                 :             :       /* auto may only be used with another storage class specifier,
   12819                 :             :          such as constexpr, if the type is inferred.  */
   12820                 :         152 :       if (specs->constexpr_p)
   12821                 :           2 :         error ("%qE used with %<constexpr%>", scspec);
   12822                 :             :       break;
   12823                 :    43247051 :     case RID_EXTERN:
   12824                 :    43247051 :       n = csc_extern;
   12825                 :             :       /* Diagnose "__thread extern".  */
   12826                 :    43247051 :       if (specs->thread_p && specs->thread_gnu_p)
   12827                 :           2 :         error ("%<__thread%> before %<extern%>");
   12828                 :             :       break;
   12829                 :             :     case RID_REGISTER:
   12830                 :             :       n = csc_register;
   12831                 :             :       break;
   12832                 :      407581 :     case RID_STATIC:
   12833                 :      407581 :       n = csc_static;
   12834                 :             :       /* Diagnose "__thread static".  */
   12835                 :      407581 :       if (specs->thread_p && specs->thread_gnu_p)
   12836                 :           1 :         error ("%<__thread%> before %<static%>");
   12837                 :             :       break;
   12838                 :     3993001 :     case RID_TYPEDEF:
   12839                 :     3993001 :       n = csc_typedef;
   12840                 :     3993001 :       if (specs->c23_auto_p)
   12841                 :             :         {
   12842                 :           1 :           error ("%<typedef%> used with %<auto%>");
   12843                 :           1 :           specs->c23_auto_p = false;
   12844                 :             :         }
   12845                 :             :       break;
   12846                 :         576 :     case RID_CONSTEXPR:
   12847                 :         576 :       dupe = specs->constexpr_p;
   12848                 :         576 :       if (specs->storage_class == csc_extern)
   12849                 :           1 :         error ("%qE used with %<extern%>", scspec);
   12850                 :         575 :       else if (specs->storage_class == csc_typedef)
   12851                 :           1 :         error ("%qE used with %<typedef%>", scspec);
   12852                 :         574 :       else if (specs->storage_class == csc_auto)
   12853                 :             :         /* auto may only be used with another storage class specifier,
   12854                 :             :            such as constexpr, if the type is inferred.  */
   12855                 :           2 :         error ("%qE used with %<auto%>", scspec);
   12856                 :         572 :       else if (specs->thread_p)
   12857                 :           4 :         error ("%qE used with %qs", scspec,
   12858                 :           2 :                specs->thread_gnu_p ? "__thread" : "_Thread_local");
   12859                 :             :       else
   12860                 :         570 :         specs->constexpr_p = true;
   12861                 :             :       break;
   12862                 :           0 :     default:
   12863                 :           0 :       gcc_unreachable ();
   12864                 :             :     }
   12865                 :    78780509 :   if (n != csc_none && n == specs->storage_class)
   12866                 :             :     dupe = true;
   12867                 :    78780494 :   if (dupe)
   12868                 :             :     {
   12869                 :          13 :       if (i == RID_THREAD)
   12870                 :           2 :         error ("duplicate %<_Thread_local%> or %<__thread%>");
   12871                 :             :       else
   12872                 :          11 :         error ("duplicate %qE", scspec);
   12873                 :             :     }
   12874                 :    78780503 :   if (n != csc_none)
   12875                 :             :     {
   12876                 :    47650850 :       if (specs->storage_class != csc_none && n != specs->storage_class)
   12877                 :             :         {
   12878                 :           7 :           error ("multiple storage classes in declaration specifiers");
   12879                 :             :         }
   12880                 :             :       else
   12881                 :             :         {
   12882                 :    47650843 :           specs->storage_class = n;
   12883                 :    47650843 :           specs->locations[cdw_storage_class] = loc;
   12884                 :    47650843 :           if (n != csc_extern && n != csc_static && specs->thread_p)
   12885                 :             :             {
   12886                 :           8 :               error ("%qs used with %qE",
   12887                 :           8 :                      specs->thread_gnu_p ? "__thread" : "_Thread_local",
   12888                 :             :                      scspec);
   12889                 :           8 :               specs->thread_p = false;
   12890                 :             :             }
   12891                 :    47650843 :           if (n != csc_auto && n != csc_register && n != csc_static
   12892                 :    47240049 :               && specs->constexpr_p)
   12893                 :             :             {
   12894                 :           2 :               error ("%<constexpr%> used with %qE", scspec);
   12895                 :           2 :               specs->constexpr_p = false;
   12896                 :             :             }
   12897                 :             :         }
   12898                 :             :     }
   12899                 :             :   return specs;
   12900                 :             : }
   12901                 :             : 
   12902                 :             : /* Add the attributes ATTRS to the declaration specifiers SPECS,
   12903                 :             :    returning SPECS.  */
   12904                 :             : 
   12905                 :             : struct c_declspecs *
   12906                 :    31400789 : declspecs_add_attrs (location_t loc, struct c_declspecs *specs, tree attrs)
   12907                 :             : {
   12908                 :    31400789 :   specs->attrs = chainon (attrs, specs->attrs);
   12909                 :    31400789 :   specs->locations[cdw_attributes] = loc;
   12910                 :    31400789 :   specs->declspecs_seen_p = true;
   12911                 :             :   /* In the case of standard attributes at the start of the
   12912                 :             :      declaration, the caller will reset this.  */
   12913                 :    31400789 :   specs->non_std_attrs_seen_p = true;
   12914                 :    31400789 :   return specs;
   12915                 :             : }
   12916                 :             : 
   12917                 :             : /* Add an _Alignas specifier (expression ALIGN, or type whose
   12918                 :             :    alignment is ALIGN) to the declaration specifiers SPECS, returning
   12919                 :             :    SPECS.  */
   12920                 :             : struct c_declspecs *
   12921                 :         194 : declspecs_add_alignas (location_t loc,
   12922                 :             :                        struct c_declspecs *specs, tree align)
   12923                 :             : {
   12924                 :         194 :   specs->alignas_p = true;
   12925                 :         194 :   specs->locations[cdw_alignas] = loc;
   12926                 :         194 :   if (align == error_mark_node)
   12927                 :             :     return specs;
   12928                 :             : 
   12929                 :             :   /* Only accept the alignment if it's valid and greater than
   12930                 :             :      the current one.  Zero is invalid but by C11 required to
   12931                 :             :      be silently ignored.  */
   12932                 :         192 :   int align_log = check_user_alignment (align, false, /* warn_zero = */false);
   12933                 :         192 :   if (align_log > specs->align_log)
   12934                 :         159 :     specs->align_log = align_log;
   12935                 :             :   return specs;
   12936                 :             : }
   12937                 :             : 
   12938                 :             : /* Combine "long", "short", "signed", "unsigned" and "_Complex" type
   12939                 :             :    specifiers with any other type specifier to determine the resulting
   12940                 :             :    type.  This is where ISO C checks on complex types are made, since
   12941                 :             :    "_Complex long" is a prefix of the valid ISO C type "_Complex long
   12942                 :             :    double".  Also apply postfix standard attributes to modify the type.  */
   12943                 :             : 
   12944                 :             : struct c_declspecs *
   12945                 :   274409330 : finish_declspecs (struct c_declspecs *specs)
   12946                 :             : {
   12947                 :             :   /* If a type was specified as a whole, we have no modifiers and are
   12948                 :             :      done.  */
   12949                 :   274409330 :   if (specs->type != NULL_TREE)
   12950                 :             :     {
   12951                 :   216434845 :       gcc_assert (!specs->long_p && !specs->long_long_p && !specs->short_p
   12952                 :             :                   && !specs->signed_p && !specs->unsigned_p
   12953                 :             :                   && !specs->complex_p && !specs->c23_auto_p);
   12954                 :             : 
   12955                 :             :       /* Set a dummy type.  */
   12956                 :   216434845 :       if (TREE_CODE (specs->type) == ERROR_MARK)
   12957                 :         160 :         specs->type = integer_type_node;
   12958                 :   216434845 :       goto handle_postfix_attrs;
   12959                 :             :     }
   12960                 :             : 
   12961                 :             :   /* If none of "void", "_Bool", "char", "int", "float" or "double"
   12962                 :             :      has been specified, treat it as "int" unless "_Complex" is
   12963                 :             :      present and there are no other specifiers.  If we just have
   12964                 :             :      "_Complex", it is equivalent to "_Complex double", but e.g.
   12965                 :             :      "_Complex short" is equivalent to "_Complex short int".  */
   12966                 :    57974485 :   if (specs->typespec_word == cts_none)
   12967                 :             :     {
   12968                 :     3963929 :       if (specs->saturating_p)
   12969                 :             :         {
   12970                 :           1 :           error_at (specs->locations[cdw_saturating],
   12971                 :             :                     "%<_Sat%> is used without %<_Fract%> or %<_Accum%>");
   12972                 :           1 :           if (!targetm.fixed_point_supported_p ())
   12973                 :           1 :             error_at (specs->locations[cdw_saturating],
   12974                 :             :                       "fixed-point types not supported for this target");
   12975                 :           1 :           specs->typespec_word = cts_fract;
   12976                 :             :         }
   12977                 :     3963928 :       else if (specs->long_p || specs->short_p
   12978                 :     3963928 :                || specs->signed_p || specs->unsigned_p)
   12979                 :             :         {
   12980                 :     3953678 :           specs->typespec_word = cts_int;
   12981                 :             :         }
   12982                 :       10250 :       else if (specs->complex_p)
   12983                 :             :         {
   12984                 :         129 :           specs->typespec_word = cts_double;
   12985                 :         129 :           pedwarn (specs->locations[cdw_complex], OPT_Wpedantic,
   12986                 :             :                    "ISO C does not support plain %<complex%> meaning "
   12987                 :             :                    "%<double complex%>");
   12988                 :             :         }
   12989                 :       10121 :       else if (specs->c23_auto_p)
   12990                 :             :         {
   12991                 :             :           /* Type to be filled in later, including applying postfix
   12992                 :             :              attributes.  This warning only actually appears for
   12993                 :             :              -Wc11-c23-compat in C23 mode; in older modes, there may
   12994                 :             :              be a warning or pedwarn for implicit "int" instead, or
   12995                 :             :              other errors for use of auto at file scope.  */
   12996                 :          69 :           pedwarn_c11 (input_location, OPT_Wpedantic,
   12997                 :             :                        "ISO C does not support %<auto%> type deduction "
   12998                 :             :                        "before C23");
   12999                 :          69 :           return specs;
   13000                 :             :         }
   13001                 :             :       else
   13002                 :             :         {
   13003                 :       10052 :           specs->typespec_word = cts_int;
   13004                 :       10052 :           specs->default_int_p = true;
   13005                 :             :           /* We don't diagnose this here because grokdeclarator will
   13006                 :             :              give more specific diagnostics according to whether it is
   13007                 :             :              a function definition.  */
   13008                 :             :         }
   13009                 :             :     }
   13010                 :             : 
   13011                 :             :   /* If "signed" was specified, record this to distinguish "int" and
   13012                 :             :      "signed int" in the case of a bit-field with
   13013                 :             :      -funsigned-bitfields.  */
   13014                 :    57974416 :   specs->explicit_signed_p = specs->signed_p;
   13015                 :             : 
   13016                 :             :   /* Now compute the actual type.  */
   13017                 :    57974416 :   gcc_assert (!specs->c23_auto_p);
   13018                 :    57974416 :   switch (specs->typespec_word)
   13019                 :             :     {
   13020                 :        1788 :     case cts_auto_type:
   13021                 :        1788 :       gcc_assert (!specs->long_p && !specs->short_p
   13022                 :             :                   && !specs->signed_p && !specs->unsigned_p
   13023                 :             :                   && !specs->complex_p);
   13024                 :             :       /* Type to be filled in later.  */
   13025                 :        1788 :       if (specs->postfix_attrs)
   13026                 :           2 :         error ("%<__auto_type%> followed by %<[[]]%> attributes");
   13027                 :             :       break;
   13028                 :     7366750 :     case cts_void:
   13029                 :     7366750 :       gcc_assert (!specs->long_p && !specs->short_p
   13030                 :             :                   && !specs->signed_p && !specs->unsigned_p
   13031                 :             :                   && !specs->complex_p);
   13032                 :     7366750 :       specs->type = void_type_node;
   13033                 :     7366750 :       break;
   13034                 :       75542 :     case cts_bool:
   13035                 :       75542 :       gcc_assert (!specs->long_p && !specs->short_p
   13036                 :             :                   && !specs->signed_p && !specs->unsigned_p
   13037                 :             :                   && !specs->complex_p);
   13038                 :       75542 :       specs->type = boolean_type_node;
   13039                 :       75542 :       break;
   13040                 :     8483990 :     case cts_char:
   13041                 :     8483990 :       gcc_assert (!specs->long_p && !specs->short_p);
   13042                 :     8483990 :       gcc_assert (!(specs->signed_p && specs->unsigned_p));
   13043                 :     8483990 :       if (specs->signed_p)
   13044                 :      184012 :         specs->type = signed_char_type_node;
   13045                 :     8299978 :       else if (specs->unsigned_p)
   13046                 :      872251 :         specs->type = unsigned_char_type_node;
   13047                 :             :       else
   13048                 :     7427727 :         specs->type = char_type_node;
   13049                 :     8483990 :       if (specs->complex_p)
   13050                 :             :         {
   13051                 :        3844 :           pedwarn (specs->locations[cdw_complex], OPT_Wpedantic,
   13052                 :             :                    "ISO C does not support complex integer types");
   13053                 :        3844 :           specs->type = build_complex_type (specs->type);
   13054                 :             :         }
   13055                 :             :       break;
   13056                 :       50895 :     case cts_int_n:
   13057                 :       50895 :       gcc_assert (!specs->long_p && !specs->short_p && !specs->long_long_p);
   13058                 :       50895 :       gcc_assert (!(specs->signed_p && specs->unsigned_p));
   13059                 :       50895 :       if (! int_n_enabled_p[specs->u.int_n_idx])
   13060                 :           0 :         specs->type = integer_type_node;
   13061                 :             :       else
   13062                 :       50895 :         specs->type = (specs->unsigned_p
   13063                 :       50895 :                        ? int_n_trees[specs->u.int_n_idx].unsigned_type
   13064                 :             :                        : int_n_trees[specs->u.int_n_idx].signed_type);
   13065                 :       50895 :       if (specs->complex_p)
   13066                 :             :         {
   13067                 :         199 :           pedwarn (specs->locations[cdw_complex], OPT_Wpedantic,
   13068                 :             :                    "ISO C does not support complex integer types");
   13069                 :         199 :           specs->type = build_complex_type (specs->type);
   13070                 :             :         }
   13071                 :             :       break;
   13072                 :    25522159 :     case cts_int:
   13073                 :    25522159 :       gcc_assert (!(specs->long_p && specs->short_p));
   13074                 :    25522159 :       gcc_assert (!(specs->signed_p && specs->unsigned_p));
   13075                 :    25522159 :       if (specs->long_long_p)
   13076                 :     2516180 :         specs->type = (specs->unsigned_p
   13077                 :     2516180 :                        ? long_long_unsigned_type_node
   13078                 :             :                        : long_long_integer_type_node);
   13079                 :    23005979 :       else if (specs->long_p)
   13080                 :     2023059 :         specs->type = (specs->unsigned_p
   13081                 :     2023059 :                        ? long_unsigned_type_node
   13082                 :             :                        : long_integer_type_node);
   13083                 :    20982920 :       else if (specs->short_p)
   13084                 :     1623051 :         specs->type = (specs->unsigned_p
   13085                 :     1623051 :                        ? short_unsigned_type_node
   13086                 :             :                        : short_integer_type_node);
   13087                 :             :       else
   13088                 :    19359869 :         specs->type = (specs->unsigned_p
   13089                 :    19359869 :                        ? unsigned_type_node
   13090                 :             :                        : integer_type_node);
   13091                 :    25522159 :       if (specs->complex_p)
   13092                 :             :         {
   13093                 :       14889 :           pedwarn (specs->locations[cdw_complex], OPT_Wpedantic,
   13094                 :             :                    "ISO C does not support complex integer types");
   13095                 :       14889 :           specs->type = build_complex_type (specs->type);
   13096                 :             :         }
   13097                 :             :       break;
   13098                 :     2862898 :     case cts_float:
   13099                 :     2862898 :       gcc_assert (!specs->long_p && !specs->short_p
   13100                 :             :                   && !specs->signed_p && !specs->unsigned_p);
   13101                 :     5725796 :       specs->type = (specs->complex_p
   13102                 :     2862898 :                      ? complex_float_type_node
   13103                 :             :                      : float_type_node);
   13104                 :     2862898 :       break;
   13105                 :     5032331 :     case cts_double:
   13106                 :     5032331 :       gcc_assert (!specs->long_long_p && !specs->short_p
   13107                 :             :                   && !specs->signed_p && !specs->unsigned_p);
   13108                 :     5032331 :       if (specs->long_p)
   13109                 :             :         {
   13110                 :     2092723 :           specs->type = (specs->complex_p
   13111                 :     2092723 :                          ? complex_long_double_type_node
   13112                 :             :                          : long_double_type_node);
   13113                 :             :         }
   13114                 :             :       else
   13115                 :             :         {
   13116                 :     2939608 :           specs->type = (specs->complex_p
   13117                 :     2939608 :                          ? complex_double_type_node
   13118                 :             :                          : double_type_node);
   13119                 :             :         }
   13120                 :             :       break;
   13121                 :     8485658 :     case cts_floatn_nx:
   13122                 :     8485658 :       gcc_assert (!specs->long_p && !specs->short_p
   13123                 :             :                   && !specs->signed_p && !specs->unsigned_p);
   13124                 :     8485658 :       if (FLOATN_NX_TYPE_NODE (specs->u.floatn_nx_idx) == NULL_TREE)
   13125                 :          88 :         specs->type = integer_type_node;
   13126                 :     8485570 :       else if (specs->complex_p)
   13127                 :     1366461 :         specs->type = COMPLEX_FLOATN_NX_TYPE_NODE (specs->u.floatn_nx_idx);
   13128                 :             :       else
   13129                 :     7119109 :         specs->type = FLOATN_NX_TYPE_NODE (specs->u.floatn_nx_idx);
   13130                 :             :       break;
   13131                 :       47436 :     case cts_dfloat32:
   13132                 :       47436 :     case cts_dfloat64:
   13133                 :       47436 :     case cts_dfloat128:
   13134                 :       47436 :       gcc_assert (!specs->long_p && !specs->long_long_p && !specs->short_p
   13135                 :             :                   && !specs->signed_p && !specs->unsigned_p && !specs->complex_p);
   13136                 :       47436 :       if (!targetm.decimal_float_supported_p ())
   13137                 :           0 :         specs->type = integer_type_node;
   13138                 :       47436 :       else if (specs->typespec_word == cts_dfloat32)
   13139                 :       15881 :         specs->type = dfloat32_type_node;
   13140                 :       31555 :       else if (specs->typespec_word == cts_dfloat64)
   13141                 :       15827 :         specs->type = dfloat64_type_node;
   13142                 :             :       else
   13143                 :       15728 :         specs->type = dfloat128_type_node;
   13144                 :             :       break;
   13145                 :          69 :     case cts_fract:
   13146                 :          69 :       gcc_assert (!specs->complex_p);
   13147                 :          69 :       if (!targetm.fixed_point_supported_p ())
   13148                 :          69 :         specs->type = integer_type_node;
   13149                 :           0 :       else if (specs->saturating_p)
   13150                 :             :         {
   13151                 :           0 :           if (specs->long_long_p)
   13152                 :           0 :             specs->type = specs->unsigned_p
   13153                 :           0 :                           ? sat_unsigned_long_long_fract_type_node
   13154                 :             :                           : sat_long_long_fract_type_node;
   13155                 :           0 :           else if (specs->long_p)
   13156                 :           0 :             specs->type = specs->unsigned_p
   13157                 :           0 :                           ? sat_unsigned_long_fract_type_node
   13158                 :             :                           : sat_long_fract_type_node;
   13159                 :           0 :           else if (specs->short_p)
   13160                 :           0 :             specs->type = specs->unsigned_p
   13161                 :           0 :                           ? sat_unsigned_short_fract_type_node
   13162                 :             :                           : sat_short_fract_type_node;
   13163                 :             :           else
   13164                 :           0 :             specs->type = specs->unsigned_p
   13165                 :           0 :                           ? sat_unsigned_fract_type_node
   13166                 :             :                           : sat_fract_type_node;
   13167                 :             :         }
   13168                 :             :       else
   13169                 :             :         {
   13170                 :           0 :           if (specs->long_long_p)
   13171                 :           0 :             specs->type = specs->unsigned_p
   13172                 :           0 :                           ? unsigned_long_long_fract_type_node
   13173                 :             :                           : long_long_fract_type_node;
   13174                 :           0 :           else if (specs->long_p)
   13175                 :           0 :             specs->type = specs->unsigned_p
   13176                 :           0 :                           ? unsigned_long_fract_type_node
   13177                 :             :                           : long_fract_type_node;
   13178                 :           0 :           else if (specs->short_p)
   13179                 :           0 :             specs->type = specs->unsigned_p
   13180                 :           0 :                           ? unsigned_short_fract_type_node
   13181                 :             :                           : short_fract_type_node;
   13182                 :             :           else
   13183                 :           0 :             specs->type = specs->unsigned_p
   13184                 :           0 :                           ? unsigned_fract_type_node
   13185                 :             :                           : fract_type_node;
   13186                 :             :         }
   13187                 :             :       break;
   13188                 :          67 :     case cts_accum:
   13189                 :          67 :       gcc_assert (!specs->complex_p);
   13190                 :          67 :       if (!targetm.fixed_point_supported_p ())
   13191                 :          67 :         specs->type = integer_type_node;
   13192                 :           0 :       else if (specs->saturating_p)
   13193                 :             :         {
   13194                 :           0 :           if (specs->long_long_p)
   13195                 :           0 :             specs->type = specs->unsigned_p
   13196                 :           0 :                           ? sat_unsigned_long_long_accum_type_node
   13197                 :             :                           : sat_long_long_accum_type_node;
   13198                 :           0 :           else if (specs->long_p)
   13199                 :           0 :             specs->type = specs->unsigned_p
   13200                 :           0 :                           ? sat_unsigned_long_accum_type_node
   13201                 :             :                           : sat_long_accum_type_node;
   13202                 :           0 :           else if (specs->short_p)
   13203                 :           0 :             specs->type = specs->unsigned_p
   13204                 :           0 :                           ? sat_unsigned_short_accum_type_node
   13205                 :             :                           : sat_short_accum_type_node;
   13206                 :             :           else
   13207                 :           0 :             specs->type = specs->unsigned_p
   13208                 :           0 :                           ? sat_unsigned_accum_type_node
   13209                 :             :                           : sat_accum_type_node;
   13210                 :             :         }
   13211                 :             :       else
   13212                 :             :         {
   13213                 :           0 :           if (specs->long_long_p)
   13214                 :           0 :             specs->type = specs->unsigned_p
   13215                 :           0 :                           ? unsigned_long_long_accum_type_node
   13216                 :             :                           : long_long_accum_type_node;
   13217                 :           0 :           else if (specs->long_p)
   13218                 :           0 :             specs->type = specs->unsigned_p
   13219                 :           0 :                           ? unsigned_long_accum_type_node
   13220                 :             :                           : long_accum_type_node;
   13221                 :           0 :           else if (specs->short_p)
   13222                 :           0 :             specs->type = specs->unsigned_p
   13223                 :           0 :                           ? unsigned_short_accum_type_node
   13224                 :             :                           : short_accum_type_node;
   13225                 :             :           else
   13226                 :           0 :             specs->type = specs->unsigned_p
   13227                 :           0 :                           ? unsigned_accum_type_node
   13228                 :             :                           : accum_type_node;
   13229                 :             :         }
   13230                 :             :       break;
   13231                 :       44833 :     case cts_bitint:
   13232                 :       44833 :       gcc_assert (!specs->long_p && !specs->short_p
   13233                 :             :                   && !specs->complex_p);
   13234                 :       44833 :       if (!specs->unsigned_p && specs->u.bitint_prec == 1)
   13235                 :             :         {
   13236                 :           2 :           error_at (specs->locations[cdw_typespec],
   13237                 :             :                     "%<signed _BitInt%> argument must be at least 2");
   13238                 :           2 :           specs->type = integer_type_node;
   13239                 :           2 :           break;
   13240                 :             :         }
   13241                 :       44831 :       if (specs->u.bitint_prec == -1)
   13242                 :           7 :         specs->type = integer_type_node;
   13243                 :             :       else
   13244                 :             :         {
   13245                 :       66101 :           pedwarn_c11 (specs->locations[cdw_typespec], OPT_Wpedantic,
   13246                 :             :                        "ISO C does not support %<%s_BitInt(%d)%> before C23",
   13247                 :             :                        specs->unsigned_p ? "unsigned "
   13248                 :       21277 :                        : specs->signed_p ? "signed " : "",
   13249                 :             :                        specs->u.bitint_prec);
   13250                 :       44824 :           specs->type = build_bitint_type (specs->u.bitint_prec,
   13251                 :       44824 :                                            specs->unsigned_p);
   13252                 :             :         }
   13253                 :             :       break;
   13254                 :           0 :     default:
   13255                 :           0 :       gcc_unreachable ();
   13256                 :             :     }
   13257                 :   274409261 :  handle_postfix_attrs:
   13258                 :   274409261 :   if (specs->type != NULL)
   13259                 :             :     {
   13260                 :   274407473 :       specs->postfix_attrs = c_warn_type_attributes (specs->postfix_attrs);
   13261                 :   274407473 :       decl_attributes (&specs->type, specs->postfix_attrs, 0);
   13262                 :   274407473 :       specs->postfix_attrs = NULL_TREE;
   13263                 :             :     }
   13264                 :             : 
   13265                 :             :   return specs;
   13266                 :             : }
   13267                 :             : 
   13268                 :             : /* Perform final processing on one file scope's declarations (or the
   13269                 :             :    external scope's declarations), GLOBALS.  */
   13270                 :             : 
   13271                 :             : static void
   13272                 :      206100 : c_write_global_declarations_1 (tree globals)
   13273                 :             : {
   13274                 :      206100 :   tree decl;
   13275                 :      206100 :   bool reconsider;
   13276                 :             : 
   13277                 :             :   /* Process the decls in the order they were written.  */
   13278                 :   350613421 :   for (decl = globals; decl; decl = DECL_CHAIN (decl))
   13279                 :             :     {
   13280                 :             :       /* Check for used but undefined static functions using the C
   13281                 :             :          standard's definition of "used", and set TREE_NO_WARNING so
   13282                 :             :          that check_global_declaration doesn't repeat the check.  */
   13283                 :   350407321 :       if (TREE_CODE (decl) == FUNCTION_DECL
   13284                 :   333371176 :           && DECL_INITIAL (decl) == NULL_TREE
   13285                 :   301607125 :           && DECL_EXTERNAL (decl)
   13286                 :   652014441 :           && !TREE_PUBLIC (decl))
   13287                 :             :         {
   13288                 :         109 :           if (C_DECL_USED (decl))
   13289                 :             :             {
   13290                 :             :               /* TODO: Add OPT_Wundefined-inline.  */
   13291                 :          19 :               if (pedwarn (input_location, 0, "%q+F used but never defined",
   13292                 :             :                            decl))
   13293                 :          18 :                 suppress_warning (decl /* OPT_Wundefined-inline.  */);
   13294                 :             :             }
   13295                 :             :           /* For -Wunused-function warn about unused static prototypes.  */
   13296                 :          90 :           else if (warn_unused_function
   13297                 :           1 :                    && ! DECL_ARTIFICIAL (decl)
   13298                 :          91 :                    && ! warning_suppressed_p (decl, OPT_Wunused_function))
   13299                 :             :             {
   13300                 :           1 :               if (warning (OPT_Wunused_function,
   13301                 :             :                            "%q+F declared %<static%> but never defined",
   13302                 :             :                            decl))
   13303                 :           1 :                 suppress_warning (decl, OPT_Wunused_function);
   13304                 :             :             }
   13305                 :             :         }
   13306                 :             : 
   13307                 :   350407321 :       wrapup_global_declaration_1 (decl);
   13308                 :             :     }
   13309                 :             : 
   13310                 :      238018 :   do
   13311                 :             :     {
   13312                 :      238018 :       reconsider = false;
   13313                 :   450682404 :       for (decl = globals; decl; decl = DECL_CHAIN (decl))
   13314                 :   450444386 :         reconsider |= wrapup_global_declaration_2 (decl);
   13315                 :             :     }
   13316                 :             :   while (reconsider);
   13317                 :      206100 : }
   13318                 :             : 
   13319                 :             : /* Preserve the external declarations scope across a garbage collect.  */
   13320                 :             : static GTY(()) tree ext_block;
   13321                 :             : 
   13322                 :             : /* Collect all references relevant to SOURCE_FILE.  */
   13323                 :             : 
   13324                 :             : static void
   13325                 :          15 : collect_all_refs (const char *source_file)
   13326                 :             : {
   13327                 :          15 :   tree t;
   13328                 :          15 :   unsigned i;
   13329                 :             : 
   13330                 :          30 :   FOR_EACH_VEC_ELT (*all_translation_units, i, t)
   13331                 :          15 :     collect_ada_nodes (BLOCK_VARS (DECL_INITIAL (t)), source_file);
   13332                 :             : 
   13333                 :          15 :   collect_ada_nodes (BLOCK_VARS (ext_block), source_file);
   13334                 :          15 : }
   13335                 :             : 
   13336                 :             : /* Collect source file references at global level.  */
   13337                 :             : 
   13338                 :             : static void
   13339                 :          15 : collect_source_refs (void)
   13340                 :             : {
   13341                 :          15 :   tree t;
   13342                 :          15 :   tree decls;
   13343                 :          15 :   tree decl;
   13344                 :          15 :   unsigned i;
   13345                 :             : 
   13346                 :          30 :   FOR_EACH_VEC_ELT (*all_translation_units, i, t)
   13347                 :             :     { 
   13348                 :          15 :       decls = DECL_INITIAL (t);
   13349                 :          82 :       for (decl = BLOCK_VARS (decls); decl; decl = TREE_CHAIN (decl))
   13350                 :          67 :         if (!DECL_IS_UNDECLARED_BUILTIN (decl))
   13351                 :          67 :           collect_source_ref (DECL_SOURCE_FILE (decl));
   13352                 :             :     }
   13353                 :             : 
   13354                 :       41336 :   for (decl = BLOCK_VARS (ext_block); decl; decl = TREE_CHAIN (decl))
   13355                 :       41321 :     if (!DECL_IS_UNDECLARED_BUILTIN (decl))
   13356                 :          11 :       collect_source_ref (DECL_SOURCE_FILE (decl));
   13357                 :          15 : }
   13358                 :             : 
   13359                 :             : /* Free attribute access data that are not needed by the middle end. */
   13360                 :             : 
   13361                 :             : static void
   13362                 :      103050 : free_attr_access_data ()
   13363                 :             : {
   13364                 :      103050 :   struct cgraph_node *n;
   13365                 :             : 
   13366                 :             :   /* Iterate over all functions declared in the translation unit.  */
   13367                 :    63737304 :   FOR_EACH_FUNCTION (n)
   13368                 :             :     {
   13369                 :   119663508 :       for (tree parm = DECL_ARGUMENTS (n->decl); parm; parm = TREE_CHAIN (parm))
   13370                 :    87897906 :         if (tree attrs = DECL_ATTRIBUTES (parm))
   13371                 :       94272 :           attr_access::free_lang_data (attrs);
   13372                 :             : 
   13373                 :    31765602 :       tree fntype = TREE_TYPE (n->decl);
   13374                 :    31765602 :       if (!fntype || fntype == error_mark_node)
   13375                 :           0 :         continue;
   13376                 :    31765602 :       tree attrs = TYPE_ATTRIBUTES (fntype);
   13377                 :    31765602 :       if (!attrs)
   13378                 :    31538476 :         continue;
   13379                 :             : 
   13380                 :      227126 :       attr_access::free_lang_data (attrs);
   13381                 :             :     }
   13382                 :      103050 : }
   13383                 :             : 
   13384                 :             : /* Perform any final parser cleanups and generate initial debugging
   13385                 :             :    information.  */
   13386                 :             : 
   13387                 :             : void
   13388                 :      103411 : c_parse_final_cleanups (void)
   13389                 :             : {
   13390                 :      103411 :   tree t;
   13391                 :      103411 :   unsigned i;
   13392                 :             : 
   13393                 :             :   /* We don't want to do this if generating a PCH.  */
   13394                 :      103411 :   if (pch_file)
   13395                 :      103411 :     return;
   13396                 :             : 
   13397                 :      103050 :   timevar_stop (TV_PHASE_PARSING);
   13398                 :      103050 :   timevar_start (TV_PHASE_DEFERRED);
   13399                 :             : 
   13400                 :             :   /* Do the Objective-C stuff.  This is where all the Objective-C
   13401                 :             :      module stuff gets generated (symtab, class/protocol/selector
   13402                 :             :      lists etc).  */
   13403                 :      103050 :   if (c_dialect_objc ())
   13404                 :           0 :     objc_write_global_declarations ();
   13405                 :             : 
   13406                 :             :   /* Close the external scope.  */
   13407                 :      103050 :   ext_block = pop_scope ();
   13408                 :      103050 :   external_scope = 0;
   13409                 :      103050 :   gcc_assert (!current_scope);
   13410                 :             : 
   13411                 :             :   /* Handle -fdump-ada-spec[-slim]. */
   13412                 :      103050 :   if (flag_dump_ada_spec || flag_dump_ada_spec_slim)
   13413                 :             :     {
   13414                 :             :       /* Build a table of files to generate specs for */
   13415                 :          15 :       collect_source_ref (main_input_filename);
   13416                 :          15 :       if (!flag_dump_ada_spec_slim)
   13417                 :          15 :         collect_source_refs ();
   13418                 :             : 
   13419                 :          15 :       dump_ada_specs (collect_all_refs, NULL);
   13420                 :             :     }
   13421                 :             : 
   13422                 :             :   /* Process all file scopes in this compilation, and the external_scope,
   13423                 :             :      through wrapup_global_declarations.  */
   13424                 :      206100 :   FOR_EACH_VEC_ELT (*all_translation_units, i, t)
   13425                 :      103050 :     c_write_global_declarations_1 (BLOCK_VARS (DECL_INITIAL (t)));
   13426                 :      103050 :   c_write_global_declarations_1 (BLOCK_VARS (ext_block));
   13427                 :             : 
   13428                 :      103050 :   if (!in_lto_p)
   13429                 :      103050 :     free_attr_access_data ();
   13430                 :             : 
   13431                 :      103050 :   timevar_stop (TV_PHASE_DEFERRED);
   13432                 :      103050 :   timevar_start (TV_PHASE_PARSING);
   13433                 :             : 
   13434                 :      103050 :   ext_block = NULL;
   13435                 :             : }
   13436                 :             : 
   13437                 :             : /* Register reserved keyword WORD as qualifier for address space AS.  */
   13438                 :             : 
   13439                 :             : void
   13440                 :      215956 : c_register_addr_space (const char *word, addr_space_t as)
   13441                 :             : {
   13442                 :      215956 :   int rid = RID_FIRST_ADDR_SPACE + as;
   13443                 :      215956 :   tree id;
   13444                 :             : 
   13445                 :             :   /* Address space qualifiers are only supported
   13446                 :             :      in C with GNU extensions enabled.  */
   13447                 :      215956 :   if (c_dialect_objc () || flag_no_asm)
   13448                 :             :     return;
   13449                 :             : 
   13450                 :      206484 :   id = get_identifier (word);
   13451                 :      206484 :   C_SET_RID_CODE (id, rid);
   13452                 :      206484 :   C_IS_RESERVED_WORD (id) = 1;
   13453                 :      206484 :   ridpointers [rid] = id;
   13454                 :             : }
   13455                 :             : 
   13456                 :             : /* Return identifier to look up for omp declare reduction.  */
   13457                 :             : 
   13458                 :             : tree
   13459                 :        3028 : c_omp_reduction_id (enum tree_code reduction_code, tree reduction_id)
   13460                 :             : {
   13461                 :        3028 :   const char *p = NULL;
   13462                 :        3028 :   switch (reduction_code)
   13463                 :             :     {
   13464                 :             :     case PLUS_EXPR: p = "+"; break;
   13465                 :         254 :     case MULT_EXPR: p = "*"; break;
   13466                 :         105 :     case MINUS_EXPR: p = "-"; break;
   13467                 :          29 :     case BIT_AND_EXPR: p = "&"; break;
   13468                 :          12 :     case BIT_XOR_EXPR: p = "^"; break;
   13469                 :          90 :     case BIT_IOR_EXPR: p = "|"; break;
   13470                 :          65 :     case TRUTH_ANDIF_EXPR: p = "&&"; break;
   13471                 :          76 :     case TRUTH_ORIF_EXPR: p = "||"; break;
   13472                 :          44 :     case MIN_EXPR: p = "min"; break;
   13473                 :          77 :     case MAX_EXPR: p = "max"; break;
   13474                 :             :     default:
   13475                 :             :       break;
   13476                 :             :     }
   13477                 :             : 
   13478                 :         752 :   if (p == NULL)
   13479                 :             :     {
   13480                 :         213 :       if (TREE_CODE (reduction_id) != IDENTIFIER_NODE)
   13481                 :           0 :         return error_mark_node;
   13482                 :         213 :       p = IDENTIFIER_POINTER (reduction_id);
   13483                 :             :     }
   13484                 :             : 
   13485                 :        3028 :   const char prefix[] = "omp declare reduction ";
   13486                 :        3028 :   size_t lenp = sizeof (prefix);
   13487                 :        3028 :   size_t len = strlen (p);
   13488                 :        3028 :   char *name = XALLOCAVEC (char, lenp + len);
   13489                 :        3028 :   memcpy (name, prefix, lenp - 1);
   13490                 :        3028 :   memcpy (name + lenp - 1, p, len + 1);
   13491                 :        3028 :   return get_identifier (name);
   13492                 :             : }
   13493                 :             : 
   13494                 :             : /* Lookup REDUCTION_ID in the current scope, or create an artificial
   13495                 :             :    VAR_DECL, bind it into the current scope and return it.  */
   13496                 :             : 
   13497                 :             : tree
   13498                 :         161 : c_omp_reduction_decl (tree reduction_id)
   13499                 :             : {
   13500                 :         161 :   struct c_binding *b = I_SYMBOL_BINDING (reduction_id);
   13501                 :         161 :   if (b != NULL && B_IN_CURRENT_SCOPE (b))
   13502                 :          47 :     return b->decl;
   13503                 :             : 
   13504                 :         114 :   tree decl = build_decl (BUILTINS_LOCATION, VAR_DECL,
   13505                 :             :                           reduction_id, integer_type_node);
   13506                 :         114 :   DECL_ARTIFICIAL (decl) = 1;
   13507                 :         114 :   DECL_EXTERNAL (decl) = 1;
   13508                 :         114 :   TREE_STATIC (decl) = 1;
   13509                 :         114 :   TREE_PUBLIC (decl) = 0;
   13510                 :         114 :   bind (reduction_id, decl, current_scope, true, false, BUILTINS_LOCATION);
   13511                 :         114 :   return decl;
   13512                 :             : }
   13513                 :             : 
   13514                 :             : /* Lookup REDUCTION_ID in the first scope where it has entry for TYPE.  */
   13515                 :             : 
   13516                 :             : tree
   13517                 :         273 : c_omp_reduction_lookup (tree reduction_id, tree type)
   13518                 :             : {
   13519                 :         273 :   struct c_binding *b = I_SYMBOL_BINDING (reduction_id);
   13520                 :         276 :   while (b)
   13521                 :             :     {
   13522                 :         274 :       tree t;
   13523                 :         294 :       for (t = DECL_INITIAL (b->decl); t; t = TREE_CHAIN (t))
   13524                 :         291 :         if (comptypes (TREE_PURPOSE (t), type))
   13525                 :         271 :           return TREE_VALUE (t);
   13526                 :           3 :       b = b->shadowed;
   13527                 :             :     }
   13528                 :           2 :   return error_mark_node;
   13529                 :             : }
   13530                 :             : 
   13531                 :             : /* Helper function called via walk_tree, to diagnose invalid
   13532                 :             :    #pragma omp declare reduction combiners or initializers.  */
   13533                 :             : 
   13534                 :             : tree
   13535                 :        1401 : c_check_omp_declare_reduction_r (tree *tp, int *, void *data)
   13536                 :             : {
   13537                 :        1401 :   tree *vars = (tree *) data;
   13538                 :        1401 :   if (SSA_VAR_P (*tp)
   13539                 :         413 :       && !DECL_ARTIFICIAL (*tp)
   13540                 :          24 :       && *tp != vars[0]
   13541                 :          24 :       && *tp != vars[1])
   13542                 :             :     {
   13543                 :          24 :       location_t loc = DECL_SOURCE_LOCATION (vars[0]);
   13544                 :          24 :       if (strcmp (IDENTIFIER_POINTER (DECL_NAME (vars[0])), "omp_out") == 0)
   13545                 :          10 :         error_at (loc, "%<#pragma omp declare reduction%> combiner refers to "
   13546                 :             :                        "variable %qD which is not %<omp_out%> nor %<omp_in%>",
   13547                 :             :                   *tp);
   13548                 :             :       else
   13549                 :          14 :         error_at (loc, "%<#pragma omp declare reduction%> initializer refers "
   13550                 :             :                        "to variable %qD which is not %<omp_priv%> nor "
   13551                 :             :                        "%<omp_orig%>",
   13552                 :             :                   *tp);
   13553                 :          24 :       return *tp;
   13554                 :             :     }
   13555                 :             :   return NULL_TREE;
   13556                 :             : }
   13557                 :             : 
   13558                 :             : 
   13559                 :             : bool
   13560                 :         210 : c_check_in_current_scope (tree decl)
   13561                 :             : {
   13562                 :         210 :   struct c_binding *b = I_SYMBOL_BINDING (DECL_NAME (decl));
   13563                 :         210 :   return b != NULL && B_IN_CURRENT_SCOPE (b);
   13564                 :             : }
   13565                 :             : 
   13566                 :             : #include "gt-c-c-decl.h"
        

Generated by: LCOV version 2.0-1

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.