LCOV - code coverage report
Current view: top level - gcc/c - c-decl.cc (source / functions) Coverage Total Hit
Test: gcc.info Lines: 92.3 % 6401 5907
Test Date: 2026-05-11 19:44:49 Functions: 93.1 % 188 175
Legend: Lines:     hit not hit

            Line data    Source code
       1              : /* Process declarations and variables for C compiler.
       2              :    Copyright (C) 1988-2026 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              : #include "system.h"
      30              : #include "coretypes.h"
      31              : #include "target.h"
      32              : #include "function.h"
      33              : #include "c-tree.h"
      34              : #include "timevar.h"
      35              : #include "stringpool.h"
      36              : #include "cgraph.h"
      37              : #include "intl.h"
      38              : #include "print-tree.h"
      39              : #include "stor-layout.h"
      40              : #include "varasm.h"
      41              : #include "attribs.h"
      42              : #include "toplev.h"
      43              : #include "debug.h"
      44              : #include "c-family/c-objc.h"
      45              : #include "c-family/c-pragma.h"
      46              : #include "c-family/c-ubsan.h"
      47              : #include "c-lang.h"
      48              : #include "langhooks.h"
      49              : #include "tree-iterator.h"
      50              : #include "dumpfile.h"
      51              : #include "plugin.h"
      52              : #include "c-family/c-ada-spec.h"
      53              : #include "builtins.h"
      54              : #include "spellcheck-tree.h"
      55              : #include "gcc-rich-location.h"
      56              : #include "asan.h"
      57              : #include "c-family/name-hint.h"
      58              : #include "c-family/known-headers.h"
      59              : #include "c-family/c-spellcheck.h"
      60              : #include "context.h"  /* For 'g'.  */
      61              : #include "omp-general.h"
      62              : #include "omp-offload.h"  /* For offload_vars.  */
      63              : #include "c-parser.h"
      64              : #include "gcc-urlifier.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              :   GENERIC_ASSOC };              /* Typename in generic association  */
      76              : 
      77              : /* States indicating how grokdeclarator() should handle declspecs marked
      78              :    with __attribute__((deprecated)) or __attribute__((unavailable)).
      79              :    An object declared as __attribute__((unavailable)) should suppress
      80              :    any reports of being declared  with unavailable or deprecated items.
      81              :    An object declared as __attribute__((deprecated)) should suppress
      82              :    warnings of uses of other deprecated items.  */
      83              : 
      84              : enum deprecated_states {
      85              :   DEPRECATED_NORMAL,
      86              :   DEPRECATED_SUPPRESS,
      87              :   UNAVAILABLE_DEPRECATED_SUPPRESS
      88              : };
      89              : 
      90              : 
      91              : /* Nonzero if we have seen an invalid cross reference
      92              :    to a struct, union, or enum, but not yet printed the message.  */
      93              : tree pending_invalid_xref;
      94              : 
      95              : /* File and line to appear in the eventual error message.  */
      96              : location_t pending_invalid_xref_location;
      97              : 
      98              : /* The file and line that the prototype came from if this is an
      99              :    old-style definition; used for diagnostics in
     100              :    store_parm_decls_oldstyle.  */
     101              : 
     102              : static location_t current_function_prototype_locus;
     103              : 
     104              : /* Whether this prototype was built-in.  */
     105              : 
     106              : static bool current_function_prototype_built_in;
     107              : 
     108              : /* The argument type information of this prototype.  */
     109              : 
     110              : static tree current_function_prototype_arg_types;
     111              : 
     112              : /* The argument information structure for the function currently being
     113              :    defined.  */
     114              : 
     115              : static struct c_arg_info *current_function_arg_info;
     116              : 
     117              : /* The obstack on which parser and related data structures, which are
     118              :    not live beyond their top-level declaration or definition, are
     119              :    allocated.  */
     120              : struct obstack parser_obstack;
     121              : 
     122              : /* The current statement tree.  */
     123              : 
     124              : static GTY(()) struct stmt_tree_s c_stmt_tree;
     125              : 
     126              : /* Zero if we are not in an iteration or switch statement, otherwise
     127              :    a bitmask.  See bitmask definitions in c-tree.h.  */
     128              : unsigned char in_statement;
     129              : 
     130              : /* A list of decls to be made automatically visible in each file scope.  */
     131              : static GTY(()) tree visible_builtins;
     132              : 
     133              : /* Set to 0 at beginning of a function definition, set to 1 if
     134              :    a return statement that specifies a return value is seen.  */
     135              : 
     136              : int current_function_returns_value;
     137              : 
     138              : /* Set to 0 at beginning of a function definition, set to 1 if
     139              :    a return statement with no argument is seen.  */
     140              : 
     141              : int current_function_returns_null;
     142              : 
     143              : /* Set to 0 at beginning of a function definition, set to 1 if
     144              :    a call to a noreturn function is seen.  */
     145              : 
     146              : int current_function_returns_abnormally;
     147              : 
     148              : /* Set to nonzero by `grokdeclarator' for a function
     149              :    whose return type is defaulted, if warnings for this are desired.  */
     150              : 
     151              : static int warn_about_return_type;
     152              : 
     153              : /* Nonzero when the current toplevel function contains a declaration
     154              :    of a nested function which is never defined.  */
     155              : 
     156              : static bool undef_nested_function;
     157              : 
     158              : /* Vector of implicit "omp declare target" attributes to be added into
     159              :    the attribute lists.  */
     160              : vec<c_omp_declare_target_attr, va_gc> *current_omp_declare_target_attribute;
     161              : 
     162              : /* Vector of
     163              :    #pragma omp begin assumes ... #pragma omp end assumes regions
     164              :    we are in.  */
     165              : vec<c_omp_begin_assumes_data, va_gc> *current_omp_begin_assumes;
     166              : 
     167              : /* Vector of "omp begin/end declare variant" blocks we are in.  */
     168              : vec<c_omp_declare_variant_attr, va_gc> *current_omp_declare_variant_attribute;
     169              : 
     170              : /* Vector of loop names with C_DECL_LOOP_NAME or C_DECL_SWITCH_NAME marked
     171              :    LABEL_DECL as the last and canonical for each loop or switch.  */
     172              : static vec<tree> loop_names;
     173              : 
     174              : /* Hash table mapping LABEL_DECLs to the canonical LABEL_DECLs if LOOP_NAMES
     175              :    vector becomes too long.  */
     176              : static decl_tree_map *loop_names_hash;
     177              : 
     178              : /* Each c_binding structure describes one binding of an identifier to
     179              :    a decl.  All the decls in a scope - irrespective of namespace - are
     180              :    chained together by the ->prev field, which (as the name implies)
     181              :    runs in reverse order.  All the decls in a given namespace bound to
     182              :    a given identifier are chained by the ->shadowed field, which runs
     183              :    from inner to outer scopes.
     184              : 
     185              :    The ->decl field usually points to a DECL node, but there are two
     186              :    exceptions.  In the namespace of type tags, the bound entity is a
     187              :    RECORD_TYPE, UNION_TYPE, or ENUMERAL_TYPE node.  If an undeclared
     188              :    identifier is encountered, it is bound to error_mark_node to
     189              :    suppress further errors about that identifier in the current
     190              :    function.
     191              : 
     192              :    The ->u.type field stores the type of the declaration in this scope;
     193              :    if NULL, the type is the type of the ->decl field.  This is only of
     194              :    relevance for objects with external or internal linkage which may
     195              :    be redeclared in inner scopes, forming composite types that only
     196              :    persist for the duration of those scopes.  In the external scope,
     197              :    this stores the composite of all the types declared for this
     198              :    object, visible or not.  The ->inner_comp field (used only at file
     199              :    scope) stores whether an incomplete array type at file scope was
     200              :    completed at an inner scope to an array size other than 1.
     201              : 
     202              :    The ->u.label field is used for labels.  It points to a structure
     203              :    which stores additional information used for warnings.
     204              : 
     205              :    The depth field is copied from the scope structure that holds this
     206              :    decl.  It is used to preserve the proper ordering of the ->shadowed
     207              :    field (see bind()) and also for a handful of special-case checks.
     208              :    Finally, the invisible bit is true for a decl which should be
     209              :    ignored for purposes of normal name lookup, and the nested bit is
     210              :    true for a decl that's been bound a second time in an inner scope;
     211              :    in all such cases, the binding in the outer scope will have its
     212              :    invisible bit true.  */
     213              : 
     214              : struct GTY((chain_next ("%h.prev"))) c_binding {
     215              :   union GTY(()) {               /* first so GTY desc can use decl */
     216              :     tree GTY((tag ("0"))) type; /* the type in this scope */
     217              :     struct c_label_vars * GTY((tag ("1"))) label; /* for warnings */
     218              :   } GTY((desc ("TREE_CODE (%0.decl) == LABEL_DECL"))) u;
     219              :   tree decl;                    /* the decl bound */
     220              :   tree id;                      /* the identifier it's bound to */
     221              :   struct c_binding *prev;       /* the previous decl in this scope */
     222              :   struct c_binding *shadowed;   /* the innermost decl shadowed by this one */
     223              :   unsigned int depth : 28;      /* depth of this scope */
     224              :   BOOL_BITFIELD invisible : 1;  /* normal lookup should ignore this binding */
     225              :   BOOL_BITFIELD nested : 1;     /* do not set DECL_CONTEXT when popping */
     226              :   BOOL_BITFIELD inner_comp : 1; /* incomplete array completed in inner scope */
     227              :   BOOL_BITFIELD in_struct : 1;  /* currently defined as struct field */
     228              :   location_t locus;             /* location for nested bindings */
     229              : };
     230              : #define B_IN_SCOPE(b1, b2) ((b1)->depth == (b2)->depth)
     231              : #define B_IN_CURRENT_SCOPE(b) ((b)->depth == current_scope->depth)
     232              : #define B_IN_FILE_SCOPE(b) ((b)->depth == 1 /*file_scope->depth*/)
     233              : #define B_IN_EXTERNAL_SCOPE(b) ((b)->depth == 0 /*external_scope->depth*/)
     234              : 
     235              : /* Each C symbol points to three linked lists of c_binding structures.
     236              :    These describe the values of the identifier in the three different
     237              :    namespaces defined by the language.  */
     238              : 
     239              : struct GTY(()) lang_identifier {
     240              :   struct c_common_identifier common_id;
     241              :   struct c_binding *symbol_binding; /* vars, funcs, constants, typedefs */
     242              :   struct c_binding *tag_binding;    /* struct/union/enum tags */
     243              :   struct c_binding *label_binding;  /* labels */
     244              : };
     245              : 
     246              : /* Validate c-lang.cc's assumptions.  */
     247              : extern char C_SIZEOF_STRUCT_LANG_IDENTIFIER_isnt_accurate
     248              : [(sizeof(struct lang_identifier) == C_SIZEOF_STRUCT_LANG_IDENTIFIER) ? 1 : -1];
     249              : 
     250              : /* The binding oracle; see c-tree.h.  */
     251              : void (*c_binding_oracle) (enum c_oracle_request, tree identifier);
     252              : 
     253              : /* This flag is set on an identifier if we have previously asked the
     254              :    binding oracle for this identifier's symbol binding.  */
     255              : #define I_SYMBOL_CHECKED(node) \
     256              :   (TREE_LANG_FLAG_4 (IDENTIFIER_NODE_CHECK (node)))
     257              : 
     258              : static inline struct c_binding* *
     259   4550891161 : i_symbol_binding (tree node)
     260              : {
     261   4550891161 :   struct lang_identifier *lid
     262   4550891161 :     = (struct lang_identifier *) IDENTIFIER_NODE_CHECK (node);
     263              : 
     264   4550891161 :   if (lid->symbol_binding == NULL
     265   1674457623 :       && c_binding_oracle != NULL
     266   4550891161 :       && !I_SYMBOL_CHECKED (node))
     267              :     {
     268              :       /* Set the "checked" flag first, to avoid infinite recursion
     269              :          when the binding oracle calls back into gcc.  */
     270            0 :       I_SYMBOL_CHECKED (node) = 1;
     271            0 :       c_binding_oracle (C_ORACLE_SYMBOL, node);
     272              :     }
     273              : 
     274   4550891161 :   return &lid->symbol_binding;
     275              : }
     276              : 
     277              : #define I_SYMBOL_BINDING(node) (*i_symbol_binding (node))
     278              : 
     279              : #define I_SYMBOL_DECL(node) \
     280              :  (I_SYMBOL_BINDING(node) ? I_SYMBOL_BINDING(node)->decl : 0)
     281              : 
     282              : /* This flag is set on an identifier if we have previously asked the
     283              :    binding oracle for this identifier's tag binding.  */
     284              : #define I_TAG_CHECKED(node) \
     285              :   (TREE_LANG_FLAG_5 (IDENTIFIER_NODE_CHECK (node)))
     286              : 
     287              : static inline struct c_binding **
     288      4530013 : i_tag_binding (tree node)
     289              : {
     290      4530013 :   struct lang_identifier *lid
     291      4530013 :     = (struct lang_identifier *) IDENTIFIER_NODE_CHECK (node);
     292              : 
     293      4530013 :   if (lid->tag_binding == NULL
     294      1254567 :       && c_binding_oracle != NULL
     295      4530013 :       && !I_TAG_CHECKED (node))
     296              :     {
     297              :       /* Set the "checked" flag first, to avoid infinite recursion
     298              :          when the binding oracle calls back into gcc.  */
     299            0 :       I_TAG_CHECKED (node) = 1;
     300            0 :       c_binding_oracle (C_ORACLE_TAG, node);
     301              :     }
     302              : 
     303      4530013 :   return &lid->tag_binding;
     304              : }
     305              : 
     306              : #define I_TAG_BINDING(node) (*i_tag_binding (node))
     307              : 
     308              : #define I_TAG_DECL(node) \
     309              :  (I_TAG_BINDING(node) ? I_TAG_BINDING(node)->decl : 0)
     310              : 
     311              : /* This flag is set on an identifier if we have previously asked the
     312              :    binding oracle for this identifier's label binding.  */
     313              : #define I_LABEL_CHECKED(node) \
     314              :   (TREE_LANG_FLAG_6 (IDENTIFIER_NODE_CHECK (node)))
     315              : 
     316              : static inline struct c_binding **
     317       360069 : i_label_binding (tree node)
     318              : {
     319       360069 :   struct lang_identifier *lid
     320       360069 :     = (struct lang_identifier *) IDENTIFIER_NODE_CHECK (node);
     321              : 
     322       360069 :   if (lid->label_binding == NULL
     323        47968 :       && c_binding_oracle != NULL
     324       360069 :       && !I_LABEL_CHECKED (node))
     325              :     {
     326              :       /* Set the "checked" flag first, to avoid infinite recursion
     327              :          when the binding oracle calls back into gcc.  */
     328            0 :       I_LABEL_CHECKED (node) = 1;
     329            0 :       c_binding_oracle (C_ORACLE_LABEL, node);
     330              :     }
     331              : 
     332       360069 :   return &lid->label_binding;
     333              : }
     334              : 
     335              : #define I_LABEL_BINDING(node) (*i_label_binding (node))
     336              : 
     337              : #define I_LABEL_DECL(node) \
     338              :  (I_LABEL_BINDING(node) ? I_LABEL_BINDING(node)->decl : 0)
     339              : 
     340              : /* Used by C_TOKEN_VEC tree.  */
     341              : struct GTY (()) c_tree_token_vec {
     342              :   struct tree_base base;
     343              :   vec<c_token, va_gc> *tokens;
     344              : };
     345              : 
     346              : STATIC_ASSERT (sizeof (c_tree_token_vec) == sizeof (c_tree_token_vec_struct));
     347              : STATIC_ASSERT (offsetof (c_tree_token_vec, tokens)
     348              :                == offsetof (c_tree_token_vec_struct, tokens));
     349              : 
     350              : /* The resulting tree type.  */
     351              : 
     352              : union GTY((desc ("TREE_CODE (&%h.generic) == IDENTIFIER_NODE + 2 * (TREE_CODE (&%h.generic) == C_TOKEN_VEC)"),
     353              :        chain_next ("(union lang_tree_node *) c_tree_chain_next (&%h.generic)"))) lang_tree_node
     354              :  {
     355              :   union tree_node GTY ((tag ("0"),
     356              :                         desc ("tree_node_structure (&%h)")))
     357              :     generic;
     358              :   struct lang_identifier GTY ((tag ("1"))) identifier;
     359              :   struct c_tree_token_vec GTY ((tag ("2"))) c_token_vec;
     360              : };
     361              : 
     362              : /* Langhook for tree_size.  */
     363              : size_t
     364          911 : c_tree_size (enum tree_code code)
     365              : {
     366          911 :   gcc_checking_assert (code >= NUM_TREE_CODES);
     367          911 :   switch (code)
     368              :     {
     369              :     case C_TOKEN_VEC: return sizeof (c_tree_token_vec);
     370            0 :     default:
     371            0 :       switch (TREE_CODE_CLASS (code))
     372              :         {
     373              :         case tcc_declaration: return sizeof (tree_decl_non_common);
     374            0 :         case tcc_type: return sizeof (tree_type_non_common);
     375            0 :         default: gcc_unreachable ();
     376              :         }
     377              :     }
     378              : }
     379              : 
     380              : /* Track bindings and other things that matter for goto warnings.  For
     381              :    efficiency, we do not gather all the decls at the point of
     382              :    definition.  Instead, we point into the bindings structure.  As
     383              :    scopes are popped, we update these structures and gather the decls
     384              :    that matter at that time.  */
     385              : 
     386              : struct GTY(()) c_spot_bindings {
     387              :   /* The currently open scope which holds bindings defined when the
     388              :      label was defined or the goto statement was found.  */
     389              :   struct c_scope *scope;
     390              :   /* The bindings in the scope field which were defined at the point
     391              :      of the label or goto.  This lets us look at older or newer
     392              :      bindings in the scope, as appropriate.  */
     393              :   struct c_binding *bindings_in_scope;
     394              :   /* The number of statement expressions that have started since this
     395              :      label or goto statement was defined.  This is zero if we are at
     396              :      the same statement expression level.  It is positive if we are in
     397              :      a statement expression started since this spot.  It is negative
     398              :      if this spot was in a statement expression and we have left
     399              :      it.  */
     400              :   int stmt_exprs;
     401              :   /* Whether we started in a statement expression but are no longer in
     402              :      it.  This is set to true if stmt_exprs ever goes negative.  */
     403              :   bool left_stmt_expr;
     404              : };
     405              : 
     406              : /* This structure is used to keep track of bindings seen when a goto
     407              :    statement is defined.  This is only used if we see the goto
     408              :    statement before we see the label.  */
     409              : 
     410              : struct GTY(()) c_goto_bindings {
     411              :   /* The location of the goto statement.  */
     412              :   location_t loc;
     413              :   /* The bindings of the goto statement.  */
     414              :   struct c_spot_bindings goto_bindings;
     415              : };
     416              : 
     417              : typedef struct c_goto_bindings *c_goto_bindings_p;
     418              : 
     419              : /* The additional information we keep track of for a label binding.
     420              :    These fields are updated as scopes are popped.  */
     421              : 
     422              : struct GTY(()) c_label_vars {
     423              :   /* The shadowed c_label_vars, when one label shadows another (which
     424              :      can only happen using a __label__ declaration).  */
     425              :   struct c_label_vars *shadowed;
     426              :   /* The bindings when the label was defined.  */
     427              :   struct c_spot_bindings label_bindings;
     428              :   /* A list of decls that we care about: decls about which we should
     429              :      warn if a goto branches to this label from later in the function.
     430              :      Decls are added to this list as scopes are popped.  We only add
     431              :      the decls that matter.  */
     432              :   vec<tree, va_gc> *decls_in_scope;
     433              :   /* A list of goto statements to this label.  This is only used for
     434              :      goto statements seen before the label was defined, so that we can
     435              :      issue appropriate warnings for them.  */
     436              :   vec<c_goto_bindings_p, va_gc> *gotos;
     437              : };
     438              : 
     439              : /* Each c_scope structure describes the complete contents of one
     440              :    scope.  Four scopes are distinguished specially: the innermost or
     441              :    current scope, the innermost function scope, the file scope (always
     442              :    the second to outermost) and the outermost or external scope.
     443              : 
     444              :    Most declarations are recorded in the current scope.
     445              : 
     446              :    All normal label declarations are recorded in the innermost
     447              :    function scope, as are bindings of undeclared identifiers to
     448              :    error_mark_node.  (GCC permits nested functions as an extension,
     449              :    hence the 'innermost' qualifier.)  Explicitly declared labels
     450              :    (using the __label__ extension) appear in the current scope.
     451              : 
     452              :    Being in the file scope (current_scope == file_scope) causes
     453              :    special behavior in several places below.  Also, under some
     454              :    conditions the Objective-C front end records declarations in the
     455              :    file scope even though that isn't the current scope.
     456              : 
     457              :    All declarations with external linkage are recorded in the external
     458              :    scope, even if they aren't visible there; this models the fact that
     459              :    such declarations are visible to the entire program, and (with a
     460              :    bit of cleverness, see pushdecl) allows diagnosis of some violations
     461              :    of C99 6.2.2p7 and 6.2.7p2:
     462              : 
     463              :      If, within the same translation unit, the same identifier appears
     464              :      with both internal and external linkage, the behavior is
     465              :      undefined.
     466              : 
     467              :      All declarations that refer to the same object or function shall
     468              :      have compatible type; otherwise, the behavior is undefined.
     469              : 
     470              :    Initially only the built-in declarations, which describe compiler
     471              :    intrinsic functions plus a subset of the standard library, are in
     472              :    this scope.
     473              : 
     474              :    The order of the blocks list matters, and it is frequently appended
     475              :    to.  To avoid having to walk all the way to the end of the list on
     476              :    each insertion, or reverse the list later, we maintain a pointer to
     477              :    the last list entry.  (FIXME: It should be feasible to use a reversed
     478              :    list here.)
     479              : 
     480              :    The bindings list is strictly in reverse order of declarations;
     481              :    pop_scope relies on this.  */
     482              : 
     483              : 
     484              : struct GTY((chain_next ("%h.outer"))) c_scope {
     485              :   /* The scope containing this one.  */
     486              :   struct c_scope *outer;
     487              : 
     488              :   /* The next outermost function scope.  */
     489              :   struct c_scope *outer_function;
     490              : 
     491              :   /* All bindings in this scope.  */
     492              :   struct c_binding *bindings;
     493              : 
     494              :   /* For each scope (except the global one), a chain of BLOCK nodes
     495              :      for all the scopes that were entered and exited one level down.  */
     496              :   tree blocks;
     497              :   tree blocks_last;
     498              : 
     499              :   /* The depth of this scope.  Used to keep the ->shadowed chain of
     500              :      bindings sorted innermost to outermost.  */
     501              :   unsigned int depth : 28;
     502              : 
     503              :   /* True if we are currently filling this scope with parameter
     504              :      declarations.  */
     505              :   BOOL_BITFIELD parm_flag : 1;
     506              : 
     507              :   /* True if we saw [*] in this scope.  Used to give an error messages
     508              :      if these appears in a function definition.  */
     509              :   BOOL_BITFIELD had_vla_unspec : 1;
     510              : 
     511              :   /* True if we parsed a list of forward parameter decls in this scope.  */
     512              :   BOOL_BITFIELD had_forward_parm_decls : 1;
     513              : 
     514              :   /* True if this is the outermost block scope of a function body.
     515              :      This scope contains the parameters, the local variables declared
     516              :      in the outermost block, and all the labels (except those in
     517              :      nested functions, or declared at block scope with __label__).  */
     518              :   BOOL_BITFIELD function_body : 1;
     519              : 
     520              :   /* True means make a BLOCK for this scope no matter what.  */
     521              :   BOOL_BITFIELD keep : 1;
     522              : 
     523              :   /* True means that an unsuffixed float constant is _Decimal64.  */
     524              :   BOOL_BITFIELD float_const_decimal64 : 1;
     525              : 
     526              :   /* True if this scope has any label bindings.  This is used to speed
     527              :      up searching for labels when popping scopes, particularly since
     528              :      labels are normally only found at function scope.  */
     529              :   BOOL_BITFIELD has_label_bindings : 1;
     530              : 
     531              :   /* True if we should issue a warning if a goto statement crosses any
     532              :      of the bindings.  We still need to check the list of bindings to
     533              :      find the specific ones we need to warn about.  This is true if
     534              :      decl_jump_unsafe would return true for any of the bindings.  This
     535              :      is used to avoid looping over all the bindings unnecessarily.  */
     536              :   BOOL_BITFIELD has_jump_unsafe_decl : 1;
     537              : };
     538              : 
     539              : /* The scope currently in effect.  */
     540              : 
     541              : static GTY(()) struct c_scope *current_scope;
     542              : 
     543              : /* The innermost function scope.  Ordinary (not explicitly declared)
     544              :    labels, bindings to error_mark_node, and the lazily-created
     545              :    bindings of __func__ and its friends get this scope.  */
     546              : 
     547              : static GTY(()) struct c_scope *current_function_scope;
     548              : 
     549              : /* The C file scope.  This is reset for each input translation unit.  */
     550              : 
     551              : static GTY(()) struct c_scope *file_scope;
     552              : 
     553              : /* The outermost scope.  This is used for all declarations with
     554              :    external linkage, and only these, hence the name.  */
     555              : 
     556              : static GTY(()) struct c_scope *external_scope;
     557              : 
     558              : /* A chain of c_scope structures awaiting reuse.  */
     559              : 
     560              : static GTY((deletable)) struct c_scope *scope_freelist;
     561              : 
     562              : /* A chain of c_binding structures awaiting reuse.  */
     563              : 
     564              : static GTY((deletable)) struct c_binding *binding_freelist;
     565              : 
     566              : /* Append VAR to LIST in scope SCOPE.  */
     567              : #define SCOPE_LIST_APPEND(scope, list, decl) do {       \
     568              :   struct c_scope *s_ = (scope);                         \
     569              :   tree d_ = (decl);                                     \
     570              :   if (s_->list##_last)                                       \
     571              :     BLOCK_CHAIN (s_->list##_last) = d_;                      \
     572              :   else                                                  \
     573              :     s_->list = d_;                                   \
     574              :   s_->list##_last = d_;                                      \
     575              : } while (0)
     576              : 
     577              : /* Concatenate FROM in scope FSCOPE onto TO in scope TSCOPE.  */
     578              : #define SCOPE_LIST_CONCAT(tscope, to, fscope, from) do {        \
     579              :   struct c_scope *t_ = (tscope);                                \
     580              :   struct c_scope *f_ = (fscope);                                \
     581              :   if (t_->to##_last)                                         \
     582              :     BLOCK_CHAIN (t_->to##_last) = f_->from;                       \
     583              :   else                                                          \
     584              :     t_->to = f_->from;                                            \
     585              :   t_->to##_last = f_->from##_last;                                \
     586              : } while (0)
     587              : 
     588              : /* A c_inline_static structure stores details of a static identifier
     589              :    referenced in a definition of a function that may be an inline
     590              :    definition if no subsequent declaration of that function uses
     591              :    "extern" or does not use "inline".  */
     592              : 
     593              : struct GTY((chain_next ("%h.next"))) c_inline_static {
     594              :   /* The location for a diagnostic.  */
     595              :   location_t location;
     596              : 
     597              :   /* The function that may be an inline definition.  */
     598              :   tree function;
     599              : 
     600              :   /* The object or function referenced.  */
     601              :   tree static_decl;
     602              : 
     603              :   /* What sort of reference this is.  */
     604              :   enum c_inline_static_type type;
     605              : 
     606              :   /* The next such structure or NULL.  */
     607              :   struct c_inline_static *next;
     608              : };
     609              : 
     610              : /* List of static identifiers used or referenced in functions that may
     611              :    be inline definitions.  */
     612              : static GTY(()) struct c_inline_static *c_inline_statics;
     613              : 
     614              : /* True means unconditionally make a BLOCK for the next scope pushed.  */
     615              : 
     616              : static bool keep_next_level_flag;
     617              : 
     618              : /* True means the next call to push_scope will be the outermost scope
     619              :    of a function body, so do not push a new scope, merely cease
     620              :    expecting parameter decls.  */
     621              : 
     622              : static bool next_is_function_body;
     623              : 
     624              : /* A vector of pointers to c_binding structures.  */
     625              : 
     626              : typedef struct c_binding *c_binding_ptr;
     627              : 
     628              : /* Information that we keep for a struct or union while it is being
     629              :    parsed.  */
     630              : 
     631      1180158 : class c_struct_parse_info
     632              : {
     633              : public:
     634              :   /* If warn_cxx_compat, a list of types defined within this
     635              :      struct.  */
     636              :   auto_vec<tree> struct_types;
     637              :   /* If warn_cxx_compat, a list of field names which have bindings,
     638              :      and which are defined in this struct, but which are not defined
     639              :      in any enclosing struct.  This is used to clear the in_struct
     640              :      field of the c_bindings structure.  */
     641              :   auto_vec<c_binding_ptr> fields;
     642              :   /* If warn_cxx_compat, a list of typedef names used when defining
     643              :      fields in this struct.  */
     644              :   auto_vec<tree> typedefs_seen;
     645              :   /* The location of a previous definition of this struct.  */
     646              :   location_t refloc;
     647              : };
     648              : 
     649              : 
     650              : /* Hash table for structs and unions.  */
     651              : struct c_struct_hasher : ggc_ptr_hash<tree_node>
     652              : {
     653              :   static hashval_t hash (tree t);
     654              :   static bool equal (tree, tree);
     655              : };
     656              : 
     657              : /* Hash an RECORD OR UNION.  */
     658              : hashval_t
     659      4338306 : c_struct_hasher::hash (tree type)
     660              : {
     661      4338306 :   inchash::hash hstate;
     662              : 
     663      4338306 :   hstate.add_int (TREE_CODE (type));
     664      4338306 :   tree tag = c_type_tag (type);
     665      4338306 :   hstate.add_object (tag);
     666              : 
     667      4338306 :   return hstate.end ();
     668              : }
     669              : 
     670              : /* Compare two RECORD or UNION types.  */
     671              : bool
     672     14623505 : c_struct_hasher::equal (tree t1,  tree t2)
     673              : {
     674     14623505 :   return comptypes_equiv_p (t1, t2);
     675              : }
     676              : 
     677              : /* All tagged typed so that TYPE_CANONICAL can be set correctly.  */
     678              : static GTY (()) hash_table<c_struct_hasher> *c_struct_htab;
     679              : 
     680              : /* Information for the struct or union currently being parsed, or
     681              :    NULL if not parsing a struct or union.  */
     682              : static class c_struct_parse_info *struct_parse_info;
     683              : 
     684              : /* Forward declarations.  */
     685              : static tree lookup_name_in_scope (tree, struct c_scope *);
     686              : static tree c_make_fname_decl (location_t, tree, int);
     687              : static tree grokdeclarator (const struct c_declarator *,
     688              :                             struct c_declspecs *,
     689              :                             enum decl_context, bool, tree *, tree *, tree *,
     690              :                             bool *, enum deprecated_states);
     691              : static tree grokparms (struct c_arg_info *, bool);
     692              : static void layout_array_type (tree);
     693              : static const char *header_for_builtin_fn (tree);
     694              : 
     695              : /* T is a statement.  Add it to the statement-tree.  This is the
     696              :    C/ObjC version--C++ has a slightly different version of this
     697              :    function.  */
     698              : 
     699              : tree
     700     93752418 : add_stmt (tree t)
     701              : {
     702     93752418 :   enum tree_code code = TREE_CODE (t);
     703              : 
     704     93752418 :   if (CAN_HAVE_LOCATION_P (t) && code != LABEL_EXPR)
     705              :     {
     706     93038533 :       if (!EXPR_HAS_LOCATION (t))
     707       155230 :         SET_EXPR_LOCATION (t, input_location);
     708              :     }
     709              : 
     710              :   /* Add T to the statement-tree.  Non-side-effect statements need to be
     711              :      recorded during statement expressions.  */
     712     93752418 :   if (!building_stmt_list_p ())
     713            1 :     push_stmt_list ();
     714              : 
     715     93752418 :   if (code == LABEL_EXPR || code == CASE_LABEL_EXPR)
     716      1079786 :     STATEMENT_LIST_HAS_LABEL (cur_stmt_list) = 1;
     717              : 
     718     93752418 :   append_to_statement_list_force (t, &cur_stmt_list);
     719              : 
     720     93752418 :   return t;
     721              : }
     722              : 
     723              : 
     724              : 
     725              : 
     726              : 
     727              : /* Return true if we will want to say something if a goto statement
     728              :    crosses DECL.  */
     729              : 
     730              : static bool
     731    896087859 : decl_jump_unsafe (tree decl)
     732              : {
     733    896087859 :   if (error_operand_p (decl))
     734              :     return false;
     735              : 
     736              :   /* Don't warn for compound literals.  If a goto statement crosses
     737              :      their initialization, it should cross also all the places where
     738              :      the complit is used or where the complit address might be saved
     739              :      into some variable, so code after the label to which goto jumps
     740              :      should not be able to refer to the compound literal.  */
     741    896085819 :   if (VAR_P (decl) && C_DECL_COMPOUND_LITERAL_P (decl))
     742              :     return false;
     743              : 
     744    895166156 :   if (flag_openmp
     745     12449283 :       && VAR_P (decl)
     746    895197527 :       && lookup_attribute ("omp allocate", DECL_ATTRIBUTES (decl)))
     747              :     return true;
     748              : 
     749              :   /* Always warn about crossing variably modified types.  */
     750    885125052 :   if ((VAR_P (decl) || TREE_CODE (decl) == TYPE_DECL)
     751    907212426 :       && c_type_variably_modified_p (TREE_TYPE (decl)))
     752              :     return true;
     753              : 
     754              :   /* Otherwise, only warn if -Wgoto-misses-init and this is an
     755              :      initialized automatic decl.  */
     756    895125630 :   if (warn_jump_misses_init
     757      6000501 :       && VAR_P (decl)
     758        10211 :       && !TREE_STATIC (decl)
     759    895131075 :       && DECL_INITIAL (decl) != NULL_TREE)
     760              :     return true;
     761              : 
     762              :   return false;
     763              : }
     764              : 
     765              : 
     766              : void
     767            0 : c_print_identifier (FILE *file, tree node, int indent)
     768              : {
     769            0 :   void (*save) (enum c_oracle_request, tree identifier);
     770              : 
     771              :   /* Temporarily hide any binding oracle.  Without this, calls to
     772              :      debug_tree from the debugger will end up calling into the oracle,
     773              :      making for a confusing debug session.  As the oracle isn't needed
     774              :      here for normal operation, it's simplest to suppress it.  */
     775            0 :   save = c_binding_oracle;
     776            0 :   c_binding_oracle = NULL;
     777              : 
     778            0 :   print_node (file, "symbol", I_SYMBOL_DECL (node), indent + 4);
     779            0 :   print_node (file, "tag", I_TAG_DECL (node), indent + 4);
     780            0 :   print_node (file, "label", I_LABEL_DECL (node), indent + 4);
     781            0 :   if (C_IS_RESERVED_WORD (node) && C_RID_CODE (node) != RID_CXX_COMPAT_WARN)
     782              :     {
     783            0 :       tree rid = ridpointers[C_RID_CODE (node)];
     784            0 :       indent_to (file, indent + 4);
     785            0 :       fprintf (file, "rid " HOST_PTR_PRINTF " \"%s\"",
     786            0 :                (void *) rid, IDENTIFIER_POINTER (rid));
     787              :     }
     788              : 
     789            0 :   c_binding_oracle = save;
     790            0 : }
     791              : 
     792              : /* Establish that the scope contains declarations that are sensitive to
     793              :    jumps that cross a binding.  Together with decl_jump_unsafe, this is
     794              :    used to diagnose such jumps.  */
     795              : void
     796           71 : c_mark_decl_jump_unsafe_in_current_scope ()
     797              : {
     798           71 :   current_scope->has_jump_unsafe_decl = 1;
     799           71 : }
     800              : 
     801              : /* Establish a binding between NAME, an IDENTIFIER_NODE, and DECL,
     802              :    which may be any of several kinds of DECL or TYPE or error_mark_node,
     803              :    in the scope SCOPE.  */
     804              : static void
     805    895938704 : bind (tree name, tree decl, struct c_scope *scope, bool invisible,
     806              :       bool nested, location_t locus)
     807              : {
     808    895938704 :   struct c_binding *b, **here;
     809              : 
     810    895938704 :   if (binding_freelist)
     811              :     {
     812    230527050 :       b = binding_freelist;
     813    230527050 :       binding_freelist = b->prev;
     814              :     }
     815              :   else
     816    665411654 :     b = ggc_alloc<c_binding> ();
     817              : 
     818    895938704 :   b->shadowed = 0;
     819    895938704 :   b->decl = decl;
     820    895938704 :   b->id = name;
     821    895938704 :   b->depth = scope->depth;
     822    895938704 :   b->invisible = invisible;
     823    895938704 :   b->nested = nested;
     824    895938704 :   b->inner_comp = 0;
     825    895938704 :   b->in_struct = 0;
     826    895938704 :   b->locus = locus;
     827              : 
     828    895938704 :   b->u.type = NULL;
     829              : 
     830    895938704 :   b->prev = scope->bindings;
     831    895938704 :   scope->bindings = b;
     832              : 
     833    895938704 :   if (decl_jump_unsafe (decl))
     834        24210 :     scope->has_jump_unsafe_decl = 1;
     835              : 
     836    895938704 :   if (!name)
     837              :     return;
     838              : 
     839    887300066 :   switch (TREE_CODE (decl))
     840              :     {
     841        24013 :     case LABEL_DECL:     here = &I_LABEL_BINDING (name);   break;
     842       626602 :     case ENUMERAL_TYPE:
     843       626602 :     case UNION_TYPE:
     844       626602 :     case RECORD_TYPE:    here = &I_TAG_BINDING (name);     break;
     845    886649451 :     case VAR_DECL:
     846    886649451 :     case FUNCTION_DECL:
     847    886649451 :     case TYPE_DECL:
     848    886649451 :     case CONST_DECL:
     849    886649451 :     case PARM_DECL:
     850    886649451 :     case ERROR_MARK:     here = &I_SYMBOL_BINDING (name);  break;
     851              : 
     852            0 :     default:
     853            0 :       gcc_unreachable ();
     854              :     }
     855              : 
     856              :   /* Locate the appropriate place in the chain of shadowed decls
     857              :      to insert this binding.  Normally, scope == current_scope and
     858              :      this does nothing.  */
     859    887300110 :   while (*here && (*here)->depth > scope->depth)
     860           44 :     here = &(*here)->shadowed;
     861              : 
     862    887300066 :   b->shadowed = *here;
     863    887300066 :   *here = b;
     864              : }
     865              : 
     866              : /* Clear the binding structure B, stick it on the binding_freelist,
     867              :    and return the former value of b->prev.  This is used by pop_scope
     868              :    and get_parm_info to iterate destructively over all the bindings
     869              :    from a given scope.  */
     870              : static struct c_binding *
     871    878986348 : free_binding_and_advance (struct c_binding *b)
     872              : {
     873    878986348 :   struct c_binding *prev = b->prev;
     874              : 
     875    878986348 :   memset (b, 0, sizeof (struct c_binding));
     876    878986348 :   b->prev = binding_freelist;
     877    878986348 :   binding_freelist = b;
     878              : 
     879    878986348 :   return prev;
     880              : }
     881              : 
     882              : /* Bind a label.  Like bind, but skip fields which aren't used for
     883              :    labels, and add the LABEL_VARS value.  */
     884              : static void
     885        24013 : bind_label (tree name, tree label, struct c_scope *scope,
     886              :             struct c_label_vars *label_vars)
     887              : {
     888        24013 :   struct c_binding *b;
     889              : 
     890        24013 :   bind (name, label, scope, /*invisible=*/false, /*nested=*/false,
     891              :         UNKNOWN_LOCATION);
     892              : 
     893        24013 :   scope->has_label_bindings = true;
     894              : 
     895        24013 :   b = scope->bindings;
     896        24013 :   gcc_assert (b->decl == label);
     897        24013 :   label_vars->shadowed = b->u.label;
     898        24013 :   b->u.label = label_vars;
     899        24013 : }
     900              : 
     901              : /* Hook called at end of compilation to assume 1 elt
     902              :    for a file-scope tentative array defn that wasn't complete before.  */
     903              : 
     904              : void
     905         7498 : c_finish_incomplete_decl (tree decl)
     906              : {
     907         7498 :   if (VAR_P (decl))
     908              :     {
     909         7498 :       tree type = TREE_TYPE (decl);
     910         7498 :       if (type != error_mark_node
     911         7421 :           && TREE_CODE (type) == ARRAY_TYPE
     912         7226 :           && !DECL_EXTERNAL (decl)
     913         7587 :           && TYPE_DOMAIN (type) == NULL_TREE)
     914              :         {
     915           89 :           if (flag_isoc2y && !TREE_PUBLIC (decl))
     916            2 :             error_at (DECL_SOURCE_LOCATION (decl),
     917              :                       "array size missing in %q+D", decl);
     918              :           else
     919           87 :             warning_at (DECL_SOURCE_LOCATION (decl),
     920           87 :                         0, "array %q+D assumed to have one element", decl);
     921              : 
     922           89 :           complete_array_type (&TREE_TYPE (decl), NULL_TREE, true);
     923              : 
     924           89 :           relayout_decl (decl);
     925              :         }
     926              :     }
     927         7498 : }
     928              : 
     929              : /* Record that inline function FUNC contains a reference (location
     930              :    LOC) to static DECL (file-scope or function-local according to
     931              :    TYPE).  */
     932              : 
     933              : void
     934           36 : record_inline_static (location_t loc, tree func, tree decl,
     935              :                       enum c_inline_static_type type)
     936              : {
     937           36 :   c_inline_static *csi = ggc_alloc<c_inline_static> ();
     938           36 :   csi->location = loc;
     939           36 :   csi->function = func;
     940           36 :   csi->static_decl = decl;
     941           36 :   csi->type = type;
     942           36 :   csi->next = c_inline_statics;
     943           36 :   c_inline_statics = csi;
     944           36 : }
     945              : 
     946              : /* Check for references to static declarations in inline functions at
     947              :    the end of the translation unit and diagnose them if the functions
     948              :    are still inline definitions.  */
     949              : 
     950              : static void
     951       105642 : check_inline_statics (void)
     952              : {
     953       105642 :   struct c_inline_static *csi;
     954       105678 :   for (csi = c_inline_statics; csi; csi = csi->next)
     955              :     {
     956           36 :       if (DECL_EXTERNAL (csi->function))
     957           30 :         switch (csi->type)
     958              :           {
     959           23 :           case csi_internal:
     960           23 :             pedwarn (csi->location, 0,
     961              :                      "%qD is static but used in inline function %qD "
     962              :                      "which is not static", csi->static_decl, csi->function);
     963           23 :             break;
     964            7 :           case csi_modifiable:
     965            7 :             pedwarn (csi->location, 0,
     966              :                      "%q+D is static but declared in inline function %qD "
     967              :                      "which is not static", csi->static_decl, csi->function);
     968            7 :             break;
     969            0 :           default:
     970            0 :             gcc_unreachable ();
     971              :           }
     972              :     }
     973       105642 :   c_inline_statics = NULL;
     974       105642 : }
     975              : 
     976              : /* Fill in a c_spot_bindings structure.  If DEFINING is true, set it
     977              :    for the current state, otherwise set it to uninitialized.  */
     978              : 
     979              : static void
     980       134922 : set_spot_bindings (struct c_spot_bindings *p, bool defining)
     981              : {
     982            0 :   if (defining)
     983              :     {
     984       127769 :       p->scope = current_scope;
     985        16860 :       p->bindings_in_scope = current_scope->bindings;
     986              :     }
     987              :   else
     988              :     {
     989         7153 :       p->scope = NULL;
     990         7153 :       p->bindings_in_scope = NULL;
     991              :     }
     992       134922 :   p->stmt_exprs = 0;
     993       134922 :   p->left_stmt_expr = false;
     994            0 : }
     995              : 
     996              : /* Update spot bindings P as we pop out of SCOPE.  Return true if we
     997              :    should push decls for a label.  */
     998              : 
     999              : static bool
    1000    470610213 : update_spot_bindings (struct c_scope *scope, struct c_spot_bindings *p)
    1001              : {
    1002            0 :   if (p->scope != scope)
    1003              :     {
    1004              :       /* This label or goto is defined in some other scope, or it is a
    1005              :          label which is not yet defined.  There is nothing to
    1006              :          update.  */
    1007              :       return false;
    1008              :     }
    1009              : 
    1010              :   /* Adjust the spot bindings to refer to the bindings already defined
    1011              :      in the enclosing scope.  */
    1012       205704 :   p->scope = scope->outer;
    1013       205704 :   p->bindings_in_scope = p->scope->bindings;
    1014              : 
    1015       151511 :   return true;
    1016              : }
    1017              : 
    1018              : /* The Objective-C front-end often needs to determine the current scope.  */
    1019              : 
    1020              : void *
    1021            0 : objc_get_current_scope (void)
    1022              : {
    1023            0 :   return current_scope;
    1024              : }
    1025              : 
    1026              : /* The following function is used only by Objective-C.  It needs to live here
    1027              :    because it accesses the innards of c_scope.  */
    1028              : 
    1029              : void
    1030            0 : objc_mark_locals_volatile (void *enclosing_blk)
    1031              : {
    1032            0 :   struct c_scope *scope;
    1033            0 :   struct c_binding *b;
    1034              : 
    1035            0 :   for (scope = current_scope;
    1036            0 :        scope && scope != enclosing_blk;
    1037            0 :        scope = scope->outer)
    1038              :     {
    1039            0 :       for (b = scope->bindings; b; b = b->prev)
    1040            0 :         objc_volatilize_decl (b->decl);
    1041              : 
    1042              :       /* Do not climb up past the current function.  */
    1043            0 :       if (scope->function_body)
    1044              :         break;
    1045              :     }
    1046            0 : }
    1047              : 
    1048              : /* Return true if we are in the global binding level.  */
    1049              : 
    1050              : bool
    1051      2091402 : global_bindings_p (void)
    1052              : {
    1053      2091402 :   return current_scope == file_scope;
    1054              : }
    1055              : 
    1056              : /* Return true if we're declaring parameters in an old-style function
    1057              :    declaration.  */
    1058              : 
    1059              : bool
    1060        34896 : old_style_parameter_scope (void)
    1061              : {
    1062              :   /* If processing parameters and there is no function statement list, we
    1063              :    * have an old-style function declaration.  */
    1064        34896 :   return (current_scope->parm_flag && !DECL_SAVED_TREE (current_function_decl));
    1065              : }
    1066              : 
    1067              : void
    1068        52250 : keep_next_level (void)
    1069              : {
    1070        52250 :   keep_next_level_flag = true;
    1071        52250 : }
    1072              : 
    1073              : /* Set the flag for the FLOAT_CONST_DECIMAL64 pragma being ON.  */
    1074              : 
    1075              : void
    1076           20 : set_float_const_decimal64 (void)
    1077              : {
    1078           20 :   current_scope->float_const_decimal64 = true;
    1079           20 : }
    1080              : 
    1081              : /* Clear the flag for the FLOAT_CONST_DECIMAL64 pragma.  */
    1082              : 
    1083              : void
    1084           28 : clear_float_const_decimal64 (void)
    1085              : {
    1086           28 :   current_scope->float_const_decimal64 = false;
    1087           28 : }
    1088              : 
    1089              : /* Return nonzero if an unsuffixed float constant is _Decimal64.  */
    1090              : 
    1091              : bool
    1092       602171 : float_const_decimal64_p (void)
    1093              : {
    1094       602171 :   return current_scope->float_const_decimal64;
    1095              : }
    1096              : 
    1097              : /* Identify this scope as currently being filled with parameters.  */
    1098              : 
    1099              : void
    1100     86907015 : declare_parm_level (void)
    1101              : {
    1102     86907015 :   current_scope->parm_flag = true;
    1103     86907015 : }
    1104              : 
    1105              : void
    1106    128199726 : push_scope (void)
    1107              : {
    1108    128199726 :   if (next_is_function_body)
    1109              :     {
    1110              :       /* This is the transition from the parameters to the top level
    1111              :          of the function body.  These are the same scope
    1112              :          (C99 6.2.1p4,6) so we do not push another scope structure.
    1113              :          next_is_function_body is set only by store_parm_decls, which
    1114              :          in turn is called when and only when we are about to
    1115              :          encounter the opening curly brace for the function body.
    1116              : 
    1117              :          The outermost block of a function always gets a BLOCK node,
    1118              :          because the debugging output routines expect that each
    1119              :          function has at least one BLOCK.  */
    1120     36324545 :       current_scope->parm_flag         = false;
    1121     36324545 :       current_scope->function_body     = true;
    1122     36324545 :       current_scope->keep              = true;
    1123     36324545 :       current_scope->outer_function    = current_function_scope;
    1124     36324545 :       current_function_scope           = current_scope;
    1125              : 
    1126     36324545 :       keep_next_level_flag = false;
    1127     36324545 :       next_is_function_body = false;
    1128              : 
    1129              :       /* The FLOAT_CONST_DECIMAL64 pragma applies to nested scopes.  */
    1130     36324545 :       if (current_scope->outer)
    1131     36324545 :         current_scope->float_const_decimal64
    1132     36324545 :           = current_scope->outer->float_const_decimal64;
    1133              :       else
    1134            0 :         current_scope->float_const_decimal64 = false;
    1135              :     }
    1136              :   else
    1137              :     {
    1138     91875181 :       struct c_scope *scope;
    1139     91875181 :       if (scope_freelist)
    1140              :         {
    1141     91027287 :           scope = scope_freelist;
    1142     91027287 :           scope_freelist = scope->outer;
    1143              :         }
    1144              :       else
    1145       847894 :         scope = ggc_cleared_alloc<c_scope> ();
    1146              : 
    1147              :       /* The FLOAT_CONST_DECIMAL64 pragma applies to nested scopes.  */
    1148     91875181 :       if (current_scope)
    1149     91763976 :         scope->float_const_decimal64 = current_scope->float_const_decimal64;
    1150              :       else
    1151       111205 :         scope->float_const_decimal64 = false;
    1152              : 
    1153     91875181 :       scope->keep          = keep_next_level_flag;
    1154     91875181 :       scope->outer         = current_scope;
    1155     91875181 :       scope->depth      = current_scope ? (current_scope->depth + 1) : 0;
    1156              : 
    1157              :       /* Check for scope depth overflow.  Unlikely (2^28 == 268,435,456) but
    1158              :          possible.  */
    1159     91875181 :       if (current_scope && scope->depth == 0)
    1160              :         {
    1161            0 :           scope->depth--;
    1162            0 :           sorry ("GCC supports only %u nested scopes", scope->depth);
    1163              :         }
    1164              : 
    1165     91875181 :       current_scope        = scope;
    1166     91875181 :       keep_next_level_flag = false;
    1167              :     }
    1168    128199726 : }
    1169              : 
    1170              : /* This is called when we are leaving SCOPE.  For each label defined
    1171              :    in SCOPE, add any appropriate decls to its decls_in_scope fields.
    1172              :    These are the decls whose initialization will be skipped by a goto
    1173              :    later in the function.  */
    1174              : 
    1175              : static void
    1176     91868774 : update_label_decls (struct c_scope *scope)
    1177              : {
    1178     91868774 :   struct c_scope *s;
    1179              : 
    1180     91868774 :   s = scope;
    1181    331430428 :   while (s != NULL)
    1182              :     {
    1183    280652742 :       if (s->has_label_bindings)
    1184              :         {
    1185       232575 :           struct c_binding *b;
    1186              : 
    1187      2149649 :           for (b = s->bindings; b != NULL; b = b->prev)
    1188              :             {
    1189      1917074 :               struct c_label_vars *label_vars;
    1190      1917074 :               struct c_binding *b1;
    1191      1917074 :               bool hjud;
    1192      1917074 :               unsigned int ix;
    1193      1917074 :               struct c_goto_bindings *g;
    1194              : 
    1195      1917074 :               if (TREE_CODE (b->decl) != LABEL_DECL)
    1196      1411197 :                 continue;
    1197       505877 :               label_vars = b->u.label;
    1198              : 
    1199       505877 :               b1 = label_vars->label_bindings.bindings_in_scope;
    1200       505877 :               if (label_vars->label_bindings.scope == NULL)
    1201              :                 hjud = false;
    1202              :               else
    1203       196394 :                 hjud = label_vars->label_bindings.scope->has_jump_unsafe_decl;
    1204       505877 :               if (update_spot_bindings (scope, &label_vars->label_bindings))
    1205              :                 {
    1206              :                   /* This label is defined in this scope.  */
    1207        54193 :                   if (hjud)
    1208              :                     {
    1209       169690 :                       for (; b1 != NULL; b1 = b1->prev)
    1210              :                         {
    1211              :                           /* A goto from later in the function to this
    1212              :                              label will never see the initialization
    1213              :                              of B1, if any.  Save it to issue a
    1214              :                              warning if needed.  */
    1215       148267 :                           if (decl_jump_unsafe (b1->decl))
    1216        19464 :                             vec_safe_push(label_vars->decls_in_scope, b1->decl);
    1217              :                         }
    1218              :                     }
    1219              :                 }
    1220              : 
    1221              :               /* Update the bindings of any goto statements associated
    1222              :                  with this label.  */
    1223    472314596 :               FOR_EACH_VEC_SAFE_ELT (label_vars->gotos, ix, g)
    1224    470255847 :                 update_spot_bindings (scope, &g->goto_bindings);
    1225              :             }
    1226              :         }
    1227              : 
    1228              :       /* Don't search beyond the current function.  */
    1229    280652742 :       if (s == current_function_scope)
    1230              :         break;
    1231              : 
    1232    239561654 :       s = s->outer;
    1233              :     }
    1234     91868774 : }
    1235              : 
    1236              : /* Exit a scope.  Restore the state of the identifier-decl mappings
    1237              :    that were in effect when this scope was entered.  Return a BLOCK
    1238              :    node containing all the DECLs in this scope that are of interest
    1239              :    to debug info generation.  */
    1240              : 
    1241              : tree
    1242     91868774 : pop_scope (void)
    1243              : {
    1244     91868774 :   struct c_scope *scope = current_scope;
    1245     91868774 :   tree block, context, p;
    1246     91868774 :   struct c_binding *b;
    1247              : 
    1248     91868774 :   bool functionbody = scope->function_body;
    1249     91868774 :   bool keep = functionbody || scope->keep || scope->bindings;
    1250              : 
    1251     91868774 :   update_label_decls (scope);
    1252              : 
    1253              :   /* If appropriate, create a BLOCK to record the decls for the life
    1254              :      of this function.  */
    1255     91868774 :   block = NULL_TREE;
    1256     91868774 :   if (keep)
    1257              :     {
    1258     36814658 :       block = make_node (BLOCK);
    1259     36814658 :       BLOCK_SUBBLOCKS (block) = scope->blocks;
    1260     36814658 :       TREE_USED (block) = 1;
    1261              : 
    1262              :       /* In each subblock, record that this is its superior.  */
    1263     37094168 :       for (p = scope->blocks; p; p = BLOCK_CHAIN (p))
    1264       279510 :         BLOCK_SUPERCONTEXT (p) = block;
    1265              : 
    1266     36814658 :       BLOCK_VARS (block) = NULL_TREE;
    1267              :     }
    1268              : 
    1269              :   /* The TYPE_CONTEXTs for all of the tagged types belonging to this
    1270              :      scope must be set so that they point to the appropriate
    1271              :      construct, i.e.  either to the current FUNCTION_DECL node, or
    1272              :      else to the BLOCK node we just constructed.
    1273              : 
    1274              :      Note that for tagged types whose scope is just the formal
    1275              :      parameter list for some function type specification, we can't
    1276              :      properly set their TYPE_CONTEXTs here, because we don't have a
    1277              :      pointer to the appropriate FUNCTION_TYPE node readily available
    1278              :      to us.  For those cases, the TYPE_CONTEXTs of the relevant tagged
    1279              :      type nodes get set in `grokdeclarator' as soon as we have created
    1280              :      the FUNCTION_TYPE node which will represent the "scope" for these
    1281              :      "parameter list local" tagged types.  */
    1282     91868774 :   if (scope->function_body)
    1283     36324544 :     context = current_function_decl;
    1284     55544230 :   else if (scope == file_scope)
    1285              :     {
    1286       105303 :       tree file_decl
    1287       105303 :         = build_translation_unit_decl (get_identifier (main_input_filename));
    1288       105303 :       context = file_decl;
    1289       105303 :       debug_hooks->register_main_translation_unit (file_decl);
    1290              :     }
    1291              :   else
    1292              :     context = block;
    1293              : 
    1294              :   /* Clear all bindings in this scope.  */
    1295    847718867 :   for (b = scope->bindings; b; b = free_binding_and_advance (b))
    1296              :     {
    1297    755850093 :       p = b->decl;
    1298    755850093 :       switch (TREE_CODE (p))
    1299              :         {
    1300        24013 :         case LABEL_DECL:
    1301              :           /* Warnings for unused labels, errors for undefined labels.  */
    1302        24013 :           if (TREE_USED (p) && !DECL_INITIAL (p))
    1303              :             {
    1304           63 :               error ("label %q+D used but not defined", p);
    1305           63 :               DECL_INITIAL (p) = error_mark_node;
    1306              :             }
    1307              :           else
    1308        23950 :             warn_for_unused_label (p);
    1309              : 
    1310              :           /* Labels go in BLOCK_VARS.  */
    1311        24013 :           DECL_CHAIN (p) = BLOCK_VARS (block);
    1312        24013 :           BLOCK_VARS (block) = p;
    1313        24013 :           gcc_assert (I_LABEL_BINDING (b->id) == b);
    1314        24013 :           I_LABEL_BINDING (b->id) = b->shadowed;
    1315              : 
    1316              :           /* Also pop back to the shadowed label_vars.  */
    1317        24013 :           release_tree_vector (b->u.label->decls_in_scope);
    1318        24013 :           b->u.label = b->u.label->shadowed;
    1319        24013 :           break;
    1320              : 
    1321      1426291 :         case ENUMERAL_TYPE:
    1322      1426291 :         case UNION_TYPE:
    1323      1426291 :         case RECORD_TYPE:
    1324              : 
    1325              :           /* Types may not have tag-names, in which case the type
    1326              :              appears in the bindings list with b->id NULL.  */
    1327      1426291 :           if (b->id)
    1328              :             {
    1329       624776 :               gcc_assert (I_TAG_BINDING (b->id) == b);
    1330       624776 :               I_TAG_BINDING (b->id) = b->shadowed;
    1331              :             }
    1332              :           break;
    1333              : 
    1334    625989784 :         case FUNCTION_DECL:
    1335              :           /* Propagate TREE_ADDRESSABLE from nested functions to their
    1336              :              containing functions.  */
    1337    625989784 :           if (!TREE_ASM_WRITTEN (p)
    1338    625989784 :               && DECL_INITIAL (p) != NULL_TREE
    1339     72290336 :               && TREE_ADDRESSABLE (p)
    1340      3691732 :               && DECL_ABSTRACT_ORIGIN (p) != NULL_TREE
    1341    625989784 :               && DECL_ABSTRACT_ORIGIN (p) != p)
    1342            0 :             TREE_ADDRESSABLE (DECL_ABSTRACT_ORIGIN (p)) = 1;
    1343    625989784 :           if (!TREE_PUBLIC (p)
    1344       358165 :               && !DECL_INITIAL (p)
    1345          163 :               && !b->nested
    1346          132 :               && scope != file_scope
    1347    625989792 :               && scope != external_scope)
    1348              :             {
    1349            8 :               error ("nested function %q+D declared but never defined", p);
    1350            8 :               undef_nested_function = true;
    1351              :             }
    1352    625989776 :           else if (DECL_DECLARED_INLINE_P (p)
    1353     71105191 :                    && TREE_PUBLIC (p)
    1354    696936100 :                    && !DECL_INITIAL (p))
    1355              :             {
    1356              :               /* C99 6.7.4p6: "a function with external linkage... declared
    1357              :                  with an inline function specifier ... shall also be defined
    1358              :                  in the same translation unit."  */
    1359           76 :               if (!flag_gnu89_inline
    1360           51 :                   && !lookup_attribute ("gnu_inline", DECL_ATTRIBUTES (p))
    1361          111 :                   && scope == external_scope)
    1362           13 :                 pedwarn (input_location, 0,
    1363              :                          "inline function %q+D declared but never defined", p);
    1364           76 :               DECL_EXTERNAL (p) = 1;
    1365              :             }
    1366              : 
    1367    625989784 :           goto common_symbol;
    1368              : 
    1369     10952608 :         case VAR_DECL:
    1370              :           /* Warnings for unused variables.  */
    1371      8389064 :           if ((!TREE_USED (p) || !DECL_READ_P (p))
    1372      2592594 :               && !warning_suppressed_p (p, OPT_Wunused_but_set_variable_)
    1373      2592082 :               && !DECL_IN_SYSTEM_HEADER (p)
    1374      2512923 :               && DECL_NAME (p)
    1375      2512923 :               && !DECL_ARTIFICIAL (p)
    1376      2512538 :               && scope != file_scope
    1377     12577307 :               && scope != external_scope)
    1378              :             {
    1379       738493 :               if (!TREE_USED (p))
    1380              :                 {
    1381       732822 :                   warning (OPT_Wunused_variable, "unused variable %q+D", p);
    1382       732822 :                   suppress_warning (p, OPT_Wunused_variable);
    1383              :                 }
    1384         5671 :               else if (DECL_CONTEXT (p) == current_function_decl)
    1385         5650 :                 warning_at (DECL_SOURCE_LOCATION (p),
    1386         5650 :                             OPT_Wunused_but_set_variable_,
    1387              :                             "variable %qD set but not used", p);
    1388              :             }
    1389              : 
    1390     10952608 :           if (b->inner_comp)
    1391              :             {
    1392            2 :               error ("type of array %q+D completed incompatibly with"
    1393              :                      " implicit initialization", p);
    1394              :             }
    1395              : 
    1396              :           /* Fall through.  */
    1397    654317398 :         case TYPE_DECL:
    1398    654317398 :         case CONST_DECL:
    1399     10952606 :         common_symbol:
    1400              :           /* All of these go in BLOCK_VARS, but only if this is the
    1401              :              binding in the home scope.  */
    1402    654317398 :           if (!b->nested)
    1403              :             {
    1404    393785469 :               DECL_CHAIN (p) = BLOCK_VARS (block);
    1405    393785469 :               BLOCK_VARS (block) = p;
    1406              :             }
    1407    260531929 :           else if (VAR_OR_FUNCTION_DECL_P (p) && scope != file_scope)
    1408              :             {
    1409              :               /* For block local externs add a special
    1410              :                  DECL_EXTERNAL decl for debug info generation.  */
    1411        14611 :               tree extp = copy_node (p);
    1412              : 
    1413        14611 :               DECL_EXTERNAL (extp) = 1;
    1414        14611 :               TREE_STATIC (extp) = 0;
    1415        14611 :               TREE_PUBLIC (extp) = 1;
    1416        14611 :               DECL_INITIAL (extp) = NULL_TREE;
    1417        14611 :               DECL_LANG_SPECIFIC (extp) = NULL;
    1418        14611 :               DECL_CONTEXT (extp) = current_function_decl;
    1419        14611 :               if (TREE_CODE (p) == FUNCTION_DECL)
    1420              :                 {
    1421        13057 :                   DECL_RESULT (extp) = NULL_TREE;
    1422        13057 :                   DECL_SAVED_TREE (extp) = NULL_TREE;
    1423        13057 :                   DECL_STRUCT_FUNCTION (extp) = NULL;
    1424              :                 }
    1425        14611 :               if (b->locus != UNKNOWN_LOCATION)
    1426        14596 :                 DECL_SOURCE_LOCATION (extp) = b->locus;
    1427        14611 :               DECL_CHAIN (extp) = BLOCK_VARS (block);
    1428        14611 :               BLOCK_VARS (block) = extp;
    1429              :             }
    1430              :           /* If this is the file scope set DECL_CONTEXT of each decl to
    1431              :              the TRANSLATION_UNIT_DECL.  This makes same_translation_unit_p
    1432              :              work.  */
    1433    654317398 :           if (scope == file_scope)
    1434    271895621 :               DECL_CONTEXT (p) = context;
    1435              : 
    1436    754399789 :           gcc_fallthrough ();
    1437              :           /* Parameters go in DECL_ARGUMENTS, not BLOCK_VARS, and have
    1438              :              already been put there by store_parm_decls.  Unused-
    1439              :              parameter warnings are handled by function.cc.
    1440              :              error_mark_node obviously does not go in BLOCK_VARS and
    1441              :              does not get unused-variable warnings.  */
    1442    754399789 :         case PARM_DECL:
    1443    754399789 :         case ERROR_MARK:
    1444              :           /* It is possible for a decl not to have a name.  We get
    1445              :              here with b->id NULL in this case.  */
    1446    754399789 :           if (b->id)
    1447              :             {
    1448    751204549 :               gcc_assert (I_SYMBOL_BINDING (b->id) == b);
    1449    751204549 :               I_SYMBOL_BINDING (b->id) = b->shadowed;
    1450    751204549 :               if (b->shadowed && b->shadowed->u.type)
    1451      4653686 :                 TREE_TYPE (b->shadowed->decl) = b->shadowed->u.type;
    1452              :             }
    1453              :           break;
    1454              : 
    1455            0 :         default:
    1456            0 :           gcc_unreachable ();
    1457              :         }
    1458              :     }
    1459              : 
    1460              : 
    1461              :   /* Dispose of the block that we just made inside some higher level.  */
    1462     91868774 :   if ((scope->function_body || scope == file_scope) && context)
    1463              :     {
    1464     36429845 :       DECL_INITIAL (context) = block;
    1465     36429845 :       BLOCK_SUPERCONTEXT (block) = context;
    1466              :     }
    1467     55438929 :   else if (scope->outer)
    1468              :     {
    1469     55333626 :       if (block)
    1470       279510 :         SCOPE_LIST_APPEND (scope->outer, blocks, block);
    1471              :       /* If we did not make a block for the scope just exited, any
    1472              :          blocks made for inner scopes must be carried forward so they
    1473              :          will later become subblocks of something else.  */
    1474     55054116 :       else if (scope->blocks)
    1475       358862 :         SCOPE_LIST_CONCAT (scope->outer, blocks, scope, blocks);
    1476              :     }
    1477              : 
    1478              :   /* Pop the current scope, and free the structure for reuse.  */
    1479     91868774 :   current_scope = scope->outer;
    1480     91868774 :   if (scope->function_body)
    1481     36324544 :     current_function_scope = scope->outer_function;
    1482              : 
    1483     91868774 :   memset (scope, 0, sizeof (struct c_scope));
    1484     91868774 :   scope->outer = scope_freelist;
    1485     91868774 :   scope_freelist = scope;
    1486              : 
    1487     91868774 :   return block;
    1488              : }
    1489              : 
    1490              : void
    1491       105806 : push_file_scope (void)
    1492              : {
    1493       105806 :   tree decl;
    1494              : 
    1495       105806 :   if (file_scope)
    1496              :     return;
    1497              : 
    1498       105806 :   push_scope ();
    1499       105806 :   file_scope = current_scope;
    1500              : 
    1501       105806 :   start_fname_decls ();
    1502              : 
    1503    211191485 :   for (decl = visible_builtins; decl; decl = DECL_CHAIN (decl))
    1504    211085679 :     bind (DECL_NAME (decl), decl, file_scope,
    1505    211085679 :           /*invisible=*/false, /*nested=*/true, DECL_SOURCE_LOCATION (decl));
    1506              : }
    1507              : 
    1508              : void
    1509       105642 : pop_file_scope (void)
    1510              : {
    1511              :   /* In case there were missing closebraces, get us back to the global
    1512              :      binding level.  */
    1513       105647 :   while (current_scope != file_scope)
    1514            5 :     pop_scope ();
    1515              : 
    1516              :   /* __FUNCTION__ is defined at file scope ("").  This
    1517              :      call may not be necessary as my tests indicate it
    1518              :      still works without it.  */
    1519       105642 :   finish_fname_decls ();
    1520              : 
    1521       105642 :   check_inline_statics ();
    1522              : 
    1523              :   /* This is the point to write out a PCH if we're doing that.
    1524              :      In that case we do not want to do anything else.  */
    1525       105642 :   if (pch_file)
    1526              :     {
    1527          339 :       c_common_write_pch ();
    1528              :       /* Ensure even the callers don't try to finalize the CU.  */
    1529          339 :       flag_syntax_only = 1;
    1530          339 :       return;
    1531              :     }
    1532              : 
    1533              :   /* Pop off the file scope and close this translation unit.  */
    1534       105303 :   pop_scope ();
    1535       105303 :   file_scope = 0;
    1536              : 
    1537       105303 :   maybe_apply_pending_pragma_weaks ();
    1538              : }
    1539              : 
    1540              : /* Whether we are curently inside the initializer for an
    1541              :    underspecified object definition (C23 auto or constexpr).  */
    1542              : static bool in_underspecified_init;
    1543              : 
    1544              : /* Start an underspecified object definition for NAME at LOC.  This
    1545              :    means that NAME is shadowed inside its initializer, so neither the
    1546              :    definition being initialized, nor any definition from an outer
    1547              :    scope, may be referenced during that initializer.  Return state to
    1548              :    be passed to finish_underspecified_init.  If NAME is NULL_TREE, the
    1549              :    underspecified object is a (constexpr) compound literal; there is
    1550              :    no shadowing in that case, but all the other restrictions on
    1551              :    underspecified object definitions still apply.  */
    1552              : unsigned int
    1553          661 : start_underspecified_init (location_t loc, tree name)
    1554              : {
    1555          661 :   bool prev = in_underspecified_init;
    1556          661 :   bool ok;
    1557          661 :   if (name == NULL_TREE)
    1558              :     ok = true;
    1559              :   else
    1560              :     {
    1561          427 :       tree decl = build_decl (loc, VAR_DECL, name, error_mark_node);
    1562          427 :       C_DECL_UNDERSPECIFIED (decl) = 1;
    1563          427 :       struct c_scope *scope = current_scope;
    1564          427 :       struct c_binding *b = I_SYMBOL_BINDING (name);
    1565          427 :       if (b && B_IN_SCOPE (b, scope))
    1566              :         {
    1567            4 :           error_at (loc, "underspecified declaration of %qE, which is already "
    1568              :                     "declared in this scope", name);
    1569            4 :           ok = false;
    1570              :         }
    1571              :       else
    1572              :         {
    1573          423 :           bind (name, decl, scope, false, false, loc);
    1574          423 :           ok = true;
    1575              :         }
    1576              :     }
    1577          661 :   in_underspecified_init = true;
    1578          661 :   return ok | (prev << 1);
    1579              : }
    1580              : 
    1581              : /* Finish an underspecified object definition for NAME, before that
    1582              :    name is bound to the real declaration instead of a placeholder.
    1583              :    PREV_STATE is the value returned by the call to
    1584              :    start_underspecified_init.  If NAME is NULL_TREE, this means a
    1585              :    compound literal, as for start_underspecified_init.  */
    1586              : void
    1587          661 : finish_underspecified_init (tree name, unsigned int prev_state)
    1588              : {
    1589          661 :   if (name != NULL_TREE && (prev_state & 1))
    1590              :     {
    1591              :       /* A VAR_DECL was bound to the name to shadow any previous
    1592              :          declarations for the name; remove that binding now.  */
    1593          423 :       struct c_scope *scope = current_scope;
    1594          423 :       struct c_binding *b = I_SYMBOL_BINDING (name);
    1595          423 :       gcc_assert (b);
    1596          423 :       gcc_assert (B_IN_SCOPE (b, scope));
    1597          423 :       gcc_assert (VAR_P (b->decl));
    1598          423 :       gcc_assert (C_DECL_UNDERSPECIFIED (b->decl));
    1599          423 :       I_SYMBOL_BINDING (name) = b->shadowed;
    1600              :       /* In erroneous cases there may be other bindings added to this
    1601              :          scope during the initializer.  */
    1602          423 :       struct c_binding **p = &scope->bindings;
    1603          478 :       while (*p != b)
    1604           55 :         p = &((*p)->prev);
    1605          423 :       *p = free_binding_and_advance (*p);
    1606              :     }
    1607          661 :   in_underspecified_init = (prev_state & (1u << 1)) >> 1;
    1608          661 : }
    1609              : 
    1610              : /* Adjust the bindings for the start of a statement expression.  */
    1611              : 
    1612              : void
    1613        34875 : c_bindings_start_stmt_expr (struct c_spot_bindings* switch_bindings)
    1614              : {
    1615        34875 :   struct c_scope *scope;
    1616              : 
    1617       235546 :   for (scope = current_scope; scope != NULL; scope = scope->outer)
    1618              :     {
    1619       200671 :       struct c_binding *b;
    1620              : 
    1621       200671 :       if (!scope->has_label_bindings)
    1622       198260 :         continue;
    1623              : 
    1624        12792 :       for (b = scope->bindings; b != NULL; b = b->prev)
    1625              :         {
    1626        10381 :           struct c_label_vars *label_vars;
    1627        10381 :           unsigned int ix;
    1628        10381 :           struct c_goto_bindings *g;
    1629              : 
    1630        10381 :           if (TREE_CODE (b->decl) != LABEL_DECL)
    1631         1612 :             continue;
    1632         8769 :           label_vars = b->u.label;
    1633         8769 :           ++label_vars->label_bindings.stmt_exprs;
    1634        12917 :           FOR_EACH_VEC_SAFE_ELT (label_vars->gotos, ix, g)
    1635         1795 :             ++g->goto_bindings.stmt_exprs;
    1636              :         }
    1637              :     }
    1638              : 
    1639        34875 :   if (switch_bindings != NULL)
    1640          173 :     ++switch_bindings->stmt_exprs;
    1641        34875 : }
    1642              : 
    1643              : /* Adjust the bindings for the end of a statement expression.  */
    1644              : 
    1645              : void
    1646        34875 : c_bindings_end_stmt_expr (struct c_spot_bindings *switch_bindings)
    1647              : {
    1648        34875 :   struct c_scope *scope;
    1649              : 
    1650       200671 :   for (scope = current_scope; scope != NULL; scope = scope->outer)
    1651              :     {
    1652       165796 :       struct c_binding *b;
    1653              : 
    1654       165796 :       if (!scope->has_label_bindings)
    1655       163150 :         continue;
    1656              : 
    1657        16268 :       for (b = scope->bindings; b != NULL; b = b->prev)
    1658              :         {
    1659        13622 :           struct c_label_vars *label_vars;
    1660        13622 :           unsigned int ix;
    1661        13622 :           struct c_goto_bindings *g;
    1662              : 
    1663        13622 :           if (TREE_CODE (b->decl) != LABEL_DECL)
    1664         1672 :             continue;
    1665        11950 :           label_vars = b->u.label;
    1666        11950 :           --label_vars->label_bindings.stmt_exprs;
    1667        11950 :           if (label_vars->label_bindings.stmt_exprs < 0)
    1668              :             {
    1669         3322 :               label_vars->label_bindings.left_stmt_expr = true;
    1670         3322 :               label_vars->label_bindings.stmt_exprs = 0;
    1671              :             }
    1672        16150 :           FOR_EACH_VEC_SAFE_ELT (label_vars->gotos, ix, g)
    1673              :             {
    1674         1791 :               --g->goto_bindings.stmt_exprs;
    1675         1791 :               if (g->goto_bindings.stmt_exprs < 0)
    1676              :                 {
    1677          128 :                   g->goto_bindings.left_stmt_expr = true;
    1678          128 :                   g->goto_bindings.stmt_exprs = 0;
    1679              :                 }
    1680              :             }
    1681              :         }
    1682              :     }
    1683              : 
    1684        34875 :   if (switch_bindings != NULL)
    1685              :     {
    1686          173 :       --switch_bindings->stmt_exprs;
    1687          173 :       gcc_assert (switch_bindings->stmt_exprs >= 0);
    1688              :     }
    1689        34875 : }
    1690              : 
    1691              : /* Push a definition or a declaration of struct, union or enum tag "name".
    1692              :    "type" should be the type node.
    1693              :    We assume that the tag "name" is not already defined, and has a location
    1694              :    of LOC.
    1695              : 
    1696              :    Note that the definition may really be just a forward reference.
    1697              :    In that case, the TYPE_SIZE will be zero.  */
    1698              : 
    1699              : static void
    1700      1430248 : pushtag (location_t loc, tree name, tree type)
    1701              : {
    1702              :   /* Record the identifier as the type's name if it has none.  */
    1703      1430248 :   if (name && !TYPE_NAME (type))
    1704       626574 :     TYPE_NAME (type) = name;
    1705      1430248 :   bind (name, type, current_scope, /*invisible=*/false, /*nested=*/false, loc);
    1706              : 
    1707              :   /* Create a fake NULL-named TYPE_DECL node whose TREE_TYPE will be the
    1708              :      tagged type we just added to the current scope.  This fake
    1709              :      NULL-named TYPE_DECL node helps dwarfout.c to know when it needs
    1710              :      to output a representation of a tagged type, and it also gives
    1711              :      us a convenient place to record the "scope start" address for the
    1712              :      tagged type, and it is used to track whether the type is used
    1713              :      in a non-local context via mark_decl_used.  */
    1714              : 
    1715      1430248 :   TYPE_STUB_DECL (type) = pushdecl (build_decl (loc,
    1716              :                                                 TYPE_DECL, NULL_TREE, type));
    1717              : 
    1718              :   /* An approximation for now, so we can tell this is a function-scope tag.
    1719              :      This will be updated in pop_scope.  */
    1720      1430248 :   TYPE_CONTEXT (type) = DECL_CONTEXT (TYPE_STUB_DECL (type));
    1721              : 
    1722      1430248 :   if (warn_cxx_compat && name != NULL_TREE)
    1723              :     {
    1724          629 :       struct c_binding *b = I_SYMBOL_BINDING (name);
    1725              : 
    1726          629 :       if (b != NULL
    1727           12 :           && b->decl != NULL_TREE
    1728           12 :           && TREE_CODE (b->decl) == TYPE_DECL
    1729           11 :           && (B_IN_CURRENT_SCOPE (b)
    1730            6 :               || (current_scope == file_scope && B_IN_EXTERNAL_SCOPE (b)))
    1731          634 :           && (TYPE_MAIN_VARIANT (TREE_TYPE (b->decl))
    1732            5 :               != TYPE_MAIN_VARIANT (type)))
    1733              :         {
    1734            5 :           auto_diagnostic_group d;
    1735            6 :           if (warning_at (loc, OPT_Wc___compat,
    1736              :                           "using %qD as both a typedef and a tag is "
    1737              :                           "invalid in C++", b->decl)
    1738            5 :               && b->locus != UNKNOWN_LOCATION)
    1739            4 :             inform (b->locus, "originally defined here");
    1740            5 :         }
    1741              :     }
    1742      1430248 : }
    1743              : 
    1744              : /* An exported interface to pushtag.  This is used by the gdb plugin's
    1745              :    binding oracle to introduce a new tag binding.  */
    1746              : 
    1747              : void
    1748            0 : c_pushtag (location_t loc, tree name, tree type)
    1749              : {
    1750            0 :   pushtag (loc, name, type);
    1751            0 : }
    1752              : 
    1753              : /* An exported interface to bind a declaration.  LOC is the location
    1754              :    to use.  DECL is the declaration to bind.  The decl's name is used
    1755              :    to determine how it is bound.  If DECL is a VAR_DECL, then
    1756              :    IS_GLOBAL determines whether the decl is put into the global (file
    1757              :    and external) scope or the current function's scope; if DECL is not
    1758              :    a VAR_DECL then it is always put into the file scope.  */
    1759              : 
    1760              : void
    1761            0 : c_bind (location_t loc, tree decl, bool is_global)
    1762              : {
    1763            0 :   struct c_scope *scope;
    1764            0 :   bool nested = false;
    1765              : 
    1766            0 :   if (!VAR_P (decl) || current_function_scope == NULL)
    1767              :     {
    1768              :       /* Types and functions are always considered to be global.  */
    1769            0 :       scope = file_scope;
    1770            0 :       DECL_EXTERNAL (decl) = 1;
    1771            0 :       TREE_PUBLIC (decl) = 1;
    1772              :     }
    1773            0 :   else if (is_global)
    1774              :     {
    1775              :       /* Also bind it into the external scope.  */
    1776            0 :       bind (DECL_NAME (decl), decl, external_scope, true, false, loc);
    1777            0 :       nested = true;
    1778            0 :       scope = file_scope;
    1779            0 :       DECL_EXTERNAL (decl) = 1;
    1780            0 :       TREE_PUBLIC (decl) = 1;
    1781              :     }
    1782              :   else
    1783              :     {
    1784            0 :       DECL_CONTEXT (decl) = current_function_decl;
    1785            0 :       TREE_PUBLIC (decl) = 0;
    1786            0 :       scope = current_function_scope;
    1787              :     }
    1788              : 
    1789            0 :   bind (DECL_NAME (decl), decl, scope, false, nested, loc);
    1790            0 : }
    1791              : 
    1792              : 
    1793              : /* Stores the first FILE*, const struct tm* etc. argument type (whatever
    1794              :    it is) seen in a declaration of a file I/O etc. built-in, corresponding
    1795              :    to the builtin_structptr_types array.  Subsequent declarations of such
    1796              :    built-ins are expected to refer to it rather than to fileptr_type_node,
    1797              :    etc. which is just void* (or to any other type).
    1798              :    Used only by match_builtin_function_types.  */
    1799              : 
    1800              : static const unsigned builtin_structptr_type_count
    1801              :   = ARRAY_SIZE (builtin_structptr_types);
    1802              : 
    1803              : static GTY(()) tree last_structptr_types[builtin_structptr_type_count];
    1804              : 
    1805              : /* Returns true if types T1 and T2 representing return types or types
    1806              :    of function arguments are close enough to be considered interchangeable
    1807              :    in redeclarations of built-in functions.  */
    1808              : 
    1809              : static bool
    1810       623467 : types_close_enough_to_match (tree t1, tree t2)
    1811              : {
    1812       623467 :   return (TYPE_MODE (t1) == TYPE_MODE (t2)
    1813       623013 :           && POINTER_TYPE_P (t1) == POINTER_TYPE_P (t2)
    1814      2492353 :           && FUNCTION_POINTER_TYPE_P (t1) == FUNCTION_POINTER_TYPE_P (t2));
    1815              : }
    1816              : 
    1817              : /* Subroutine of compare_decls.  Allow harmless mismatches in return
    1818              :    and argument types provided that the type modes match.  Set *STRICT
    1819              :    and *ARGNO to the expected argument type and number in case of
    1820              :    an argument type mismatch or null and zero otherwise.  Return
    1821              :    a unified type given a suitable match, and 0 otherwise.  */
    1822              : 
    1823              : static tree
    1824       144605 : match_builtin_function_types (tree newtype, tree oldtype,
    1825              :                               tree *strict, unsigned *argno)
    1826              : {
    1827       144605 :   *argno = 0;
    1828       144605 :   *strict = NULL_TREE;
    1829              : 
    1830              :   /* Accept the return type of the new declaration if it has the same
    1831              :      mode and if they're both pointers or if neither is.  */
    1832       144605 :   tree oldrettype = TREE_TYPE (oldtype);
    1833       144605 :   tree newrettype = TREE_TYPE (newtype);
    1834              : 
    1835       144605 :   if (!types_close_enough_to_match (oldrettype, newrettype))
    1836              :     return NULL_TREE;
    1837              : 
    1838              :   /* Check that the return types are compatible but don't fail if they
    1839              :      are not (e.g., int vs long in ILP32) and just let the caller know.  */
    1840       144243 :   if (!comptypes (TYPE_MAIN_VARIANT (oldrettype),
    1841       144243 :                   TYPE_MAIN_VARIANT (newrettype)))
    1842           46 :     *strict = oldrettype;
    1843              : 
    1844       144243 :   tree oldargs = TYPE_ARG_TYPES (oldtype);
    1845       144243 :   tree newargs = TYPE_ARG_TYPES (newtype);
    1846       144243 :   tree tryargs = newargs;
    1847              : 
    1848       144243 :   const unsigned nlst = ARRAY_SIZE (last_structptr_types);
    1849       144243 :   const unsigned nbst = ARRAY_SIZE (builtin_structptr_types);
    1850              : 
    1851       144243 :   gcc_checking_assert (nlst == nbst);
    1852              : 
    1853       622909 :   for (unsigned i = 1; oldargs || newargs; ++i)
    1854              :     {
    1855       478921 :       if (!oldargs
    1856       478921 :           || !newargs
    1857       478866 :           || !TREE_VALUE (oldargs)
    1858       957787 :           || !TREE_VALUE (newargs))
    1859              :         return NULL_TREE;
    1860              : 
    1861       478866 :       tree oldtype = TYPE_MAIN_VARIANT (TREE_VALUE (oldargs));
    1862       478866 :       tree newtype = TREE_VALUE (newargs);
    1863       478866 :       if (newtype == error_mark_node)
    1864              :        return NULL_TREE;
    1865       478862 :       newtype = TYPE_MAIN_VARIANT (newtype);
    1866              : 
    1867       478862 :       if (!types_close_enough_to_match (oldtype, newtype))
    1868              :         return NULL_TREE;
    1869              : 
    1870       478719 :       unsigned j = nbst;
    1871       478719 :       if (POINTER_TYPE_P (oldtype))
    1872              :         /* Iterate over well-known struct types like FILE (whose types
    1873              :            aren't known to us) and compare the pointer to each to
    1874              :            the pointer argument.  */
    1875       977926 :         for (j = 0; j < nbst; ++j)
    1876              :           {
    1877       861547 :             if (TREE_VALUE (oldargs) != builtin_structptr_types[j].node)
    1878       717774 :               continue;
    1879              :             /* Store the first FILE* etc. argument type (whatever it is), and
    1880              :                expect any subsequent declarations of file I/O etc. built-ins
    1881              :                to refer to it rather than to fileptr_type_node etc. which is
    1882              :                just void* (or const void*).  */
    1883       143773 :             if (last_structptr_types[j])
    1884              :               {
    1885       126287 :                 if (!comptypes (last_structptr_types[j], newtype))
    1886              :                   {
    1887            2 :                     *argno = i;
    1888            2 :                     *strict = last_structptr_types[j];
    1889              :                   }
    1890              :               }
    1891              :             else
    1892        17486 :               last_structptr_types[j] = newtype;
    1893              :             break;
    1894              :           }
    1895              : 
    1896       478719 :       if (j == nbst && !comptypes (oldtype, newtype))
    1897              :         {
    1898          243 :           if (POINTER_TYPE_P (oldtype))
    1899              :             {
    1900              :               /* For incompatible pointers, only reject differences in
    1901              :                  the unqualified variants of the referenced types but
    1902              :                  consider differences in qualifiers as benign (report
    1903              :                  those to caller via *STRICT below).  */
    1904          204 :               tree oldref = TYPE_MAIN_VARIANT (TREE_TYPE (oldtype));
    1905          204 :               tree newref = TYPE_MAIN_VARIANT (TREE_TYPE (newtype));
    1906          204 :               if (!comptypes (oldref, newref))
    1907              :                 return NULL_TREE;
    1908              :             }
    1909              : 
    1910          190 :           if (!*strict)
    1911              :             {
    1912          186 :               *argno = i;
    1913          186 :               *strict = oldtype;
    1914              :             }
    1915              :         }
    1916              : 
    1917       478666 :       oldargs = TREE_CHAIN (oldargs);
    1918       478666 :       newargs = TREE_CHAIN (newargs);
    1919              :     }
    1920              : 
    1921       143988 :   tree trytype = c_build_function_type (newrettype, tryargs);
    1922              : 
    1923              :   /* Allow declaration to change transaction_safe attribute.  */
    1924       143988 :   tree oldattrs = TYPE_ATTRIBUTES (oldtype);
    1925       143988 :   tree oldtsafe = lookup_attribute ("transaction_safe", oldattrs);
    1926       143988 :   tree newattrs = TYPE_ATTRIBUTES (newtype);
    1927       143988 :   tree newtsafe = lookup_attribute ("transaction_safe", newattrs);
    1928       143988 :   if (oldtsafe && !newtsafe)
    1929            0 :     oldattrs = remove_attribute ("transaction_safe", oldattrs);
    1930       143988 :   else if (newtsafe && !oldtsafe)
    1931            7 :     oldattrs = tree_cons (get_identifier ("transaction_safe"),
    1932              :                           NULL_TREE, oldattrs);
    1933              : 
    1934       143988 :   return c_build_type_attribute_variant (trytype, oldattrs);
    1935              : }
    1936              : 
    1937              : /* Subroutine of diagnose_mismatched_decls.  Check for function type
    1938              :    mismatch involving an empty arglist vs a nonempty one and give clearer
    1939              :    diagnostics.  */
    1940              : static void
    1941          178 : diagnose_arglist_conflict (tree newdecl, tree olddecl,
    1942              :                            tree newtype, tree oldtype)
    1943              : {
    1944          178 :   tree t;
    1945              : 
    1946          178 :   if (TREE_CODE (olddecl) != FUNCTION_DECL
    1947           98 :       || !comptypes (TREE_TYPE (oldtype), TREE_TYPE (newtype))
    1948          305 :       || !((!prototype_p (oldtype) && DECL_INITIAL (olddecl) == NULL_TREE)
    1949           68 :            || (!prototype_p (newtype) && DECL_INITIAL (newdecl) == NULL_TREE)))
    1950          161 :     return;
    1951              : 
    1952           17 :   t = TYPE_ARG_TYPES (oldtype);
    1953           17 :   if (t == NULL_TREE)
    1954            9 :     t = TYPE_ARG_TYPES (newtype);
    1955           18 :   for (; t; t = TREE_CHAIN (t))
    1956              :     {
    1957           18 :       tree type = TREE_VALUE (t);
    1958              : 
    1959           18 :       if (TREE_CHAIN (t) == NULL_TREE
    1960           18 :           && TYPE_MAIN_VARIANT (type) != void_type_node)
    1961              :         {
    1962           10 :           inform (input_location, "a parameter list with an ellipsis "
    1963              :                   "cannot match an empty parameter name list declaration");
    1964           10 :           break;
    1965              :         }
    1966              : 
    1967            8 :       if (!error_operand_p (type)
    1968            8 :           && c_type_promotes_to (type) != type)
    1969              :         {
    1970            7 :           inform (input_location, "an argument type that has a default "
    1971              :                   "promotion cannot match an empty parameter name list "
    1972              :                   "declaration");
    1973            7 :           break;
    1974              :         }
    1975              :     }
    1976              : }
    1977              : 
    1978              : /* Another subroutine of diagnose_mismatched_decls.  OLDDECL is an
    1979              :    old-style function definition, NEWDECL is a prototype declaration.
    1980              :    Diagnose inconsistencies in the argument list.  Returns TRUE if
    1981              :    the prototype is compatible, FALSE if not.  */
    1982              : static bool
    1983           19 : validate_proto_after_old_defn (tree newdecl, tree newtype, tree oldtype)
    1984              : {
    1985           19 :   tree newargs, oldargs;
    1986           19 :   int i;
    1987              : 
    1988              : #define END_OF_ARGLIST(t) ((t) == void_type_node)
    1989              : 
    1990           19 :   oldargs = TYPE_ACTUAL_ARG_TYPES (oldtype);
    1991           19 :   newargs = TYPE_ARG_TYPES (newtype);
    1992           19 :   i = 1;
    1993              : 
    1994           45 :   for (;;)
    1995              :     {
    1996           32 :       tree oldargtype = TREE_VALUE (oldargs);
    1997           32 :       tree newargtype = TREE_VALUE (newargs);
    1998              : 
    1999           32 :       if (oldargtype == error_mark_node || newargtype == error_mark_node)
    2000              :         return false;
    2001              : 
    2002           58 :       oldargtype = (TYPE_ATOMIC (oldargtype)
    2003           31 :                     ? c_build_qualified_type (TYPE_MAIN_VARIANT (oldargtype),
    2004              :                                               TYPE_QUAL_ATOMIC)
    2005           27 :                     : TYPE_MAIN_VARIANT (oldargtype));
    2006           60 :       newargtype = (TYPE_ATOMIC (newargtype)
    2007           31 :                     ? c_build_qualified_type (TYPE_MAIN_VARIANT (newargtype),
    2008              :                                               TYPE_QUAL_ATOMIC)
    2009           29 :                     : TYPE_MAIN_VARIANT (newargtype));
    2010              : 
    2011           31 :       if (END_OF_ARGLIST (oldargtype) && END_OF_ARGLIST (newargtype))
    2012              :         break;
    2013              : 
    2014              :       /* Reaching the end of just one list means the two decls don't
    2015              :          agree on the number of arguments.  */
    2016           22 :       if (END_OF_ARGLIST (oldargtype))
    2017              :         {
    2018            2 :           error ("prototype for %q+D declares more arguments "
    2019              :                  "than previous old-style definition", newdecl);
    2020            2 :           return false;
    2021              :         }
    2022           20 :       else if (END_OF_ARGLIST (newargtype))
    2023              :         {
    2024            2 :           error ("prototype for %q+D declares fewer arguments "
    2025              :                  "than previous old-style definition", newdecl);
    2026            2 :           return false;
    2027              :         }
    2028              : 
    2029              :       /* Type for passing arg must be consistent with that declared
    2030              :          for the arg.  */
    2031           18 :       else if (!comptypes (oldargtype, newargtype))
    2032              :         {
    2033            5 :           error ("prototype for %q+D declares argument %d"
    2034              :                  " with incompatible type",
    2035              :                  newdecl, i);
    2036            5 :           return false;
    2037              :         }
    2038              : 
    2039           13 :       oldargs = TREE_CHAIN (oldargs);
    2040           13 :       newargs = TREE_CHAIN (newargs);
    2041           13 :       i++;
    2042           13 :     }
    2043              : 
    2044              :   /* If we get here, no errors were found, but do issue a warning
    2045              :      for this poor-style construct.  */
    2046            9 :   warning (0, "prototype for %q+D follows non-prototype definition",
    2047              :            newdecl);
    2048            9 :   return true;
    2049              : #undef END_OF_ARGLIST
    2050              : }
    2051              : 
    2052              : /* Subroutine of diagnose_mismatched_decls.  Report the location of DECL,
    2053              :    first in a pair of mismatched declarations, using the diagnostic
    2054              :    function DIAG.  */
    2055              : static void
    2056          418 : locate_old_decl (tree decl)
    2057              : {
    2058          418 :   if (TREE_CODE (decl) == FUNCTION_DECL
    2059          198 :       && fndecl_built_in_p (decl)
    2060          421 :       && !C_DECL_DECLARED_BUILTIN (decl))
    2061              :     ;
    2062          418 :   else if (DECL_INITIAL (decl))
    2063          119 :     inform (input_location,
    2064              :             "previous definition of %q+D with type %qT",
    2065          119 :             decl, TREE_TYPE (decl));
    2066          299 :   else if (C_DECL_IMPLICIT (decl))
    2067           16 :     inform (input_location,
    2068              :             "previous implicit declaration of %q+D with type %qT",
    2069           16 :             decl, TREE_TYPE (decl));
    2070              :   else
    2071          283 :     inform (input_location,
    2072              :             "previous declaration of %q+D with type %qT",
    2073          283 :             decl, TREE_TYPE (decl));
    2074          418 : }
    2075              : 
    2076              : 
    2077              : /* Helper function.  For a tagged type, it finds the declaration
    2078              :    for a visible tag declared in the same scope if such a
    2079              :    declaration exists.  */
    2080              : static tree
    2081      1140299 : previous_tag (tree type)
    2082              : {
    2083      1140299 :   struct c_binding *b = NULL;
    2084      1140299 :   tree name = c_type_tag (type);
    2085              : 
    2086      1140299 :   if (name)
    2087       566477 :     b = I_TAG_BINDING (name);
    2088              : 
    2089       566477 :   if (b)
    2090       566477 :     b = b->shadowed;
    2091              : 
    2092      1140299 :   if (b && B_IN_CURRENT_SCOPE (b))
    2093          177 :     return b->decl;
    2094              : 
    2095              :   return NULL_TREE;
    2096              : }
    2097              : 
    2098              : /* Subroutine to mark functions as versioned when using the attribute
    2099              :    'target_version'.  */
    2100              : 
    2101              : static void
    2102            0 : maybe_mark_function_versioned (tree decl)
    2103              : {
    2104            0 :   if (!DECL_FUNCTION_VERSIONED (decl))
    2105              :     {
    2106              :       /* Check if the name of the function has been overridden.  */
    2107            0 :       if (DECL_ASSEMBLER_NAME_SET_P (decl)
    2108            0 :           && IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl))[0] == '*')
    2109            0 :         error_at (DECL_SOURCE_LOCATION (decl),
    2110              :                   "cannot use function multiversioning on a renamed function");
    2111              : 
    2112              :       /* We need to insert function version now to make sure the correct
    2113              :          pre-mangled assembler name is recorded.  */
    2114            0 :       cgraph_node *node = cgraph_node::get_create (decl);
    2115              : 
    2116            0 :       if (!node->function_version ())
    2117            0 :         node->insert_new_function_version ();
    2118              : 
    2119            0 :       DECL_FUNCTION_VERSIONED (decl) = 1;
    2120              : 
    2121            0 :       tree mangled_name
    2122            0 :         = targetm.mangle_decl_assembler_name (decl, DECL_NAME (decl));
    2123            0 :       SET_DECL_ASSEMBLER_NAME (decl, mangled_name);
    2124              :     }
    2125            0 : }
    2126              : 
    2127              : /* Subroutine of duplicate_decls.  Compare NEWDECL to OLDDECL.
    2128              :    Returns true if the caller should proceed to merge the two, false
    2129              :    if OLDDECL should simply be discarded.  As a side effect, issues
    2130              :    all necessary diagnostics for invalid or poor-style combinations.
    2131              :    If it returns true, writes the types of NEWDECL and OLDDECL to
    2132              :    *NEWTYPEP and *OLDTYPEP - these may have been adjusted from
    2133              :    TREE_TYPE (NEWDECL, OLDDECL) respectively.  */
    2134              : 
    2135              : static bool
    2136      4980059 : diagnose_mismatched_decls (tree newdecl, tree olddecl,
    2137              :                            tree *newtypep, tree *oldtypep)
    2138              : {
    2139      4980059 :   tree newtype, oldtype;
    2140      4980059 :   bool retval = true;
    2141              : 
    2142              : #define DECL_EXTERN_INLINE(DECL) (DECL_DECLARED_INLINE_P (DECL)  \
    2143              :                                   && DECL_EXTERNAL (DECL))
    2144              : 
    2145              :   /* If we have error_mark_node for either decl or type, just discard
    2146              :      the previous decl - we're in an error cascade already.  */
    2147      4980059 :   if (olddecl == error_mark_node || newdecl == error_mark_node)
    2148              :     return false;
    2149      4980039 :   *oldtypep = oldtype = TREE_TYPE (olddecl);
    2150      4980039 :   *newtypep = newtype = TREE_TYPE (newdecl);
    2151      4980039 :   if (oldtype == error_mark_node || newtype == error_mark_node)
    2152              :     return false;
    2153              : 
    2154              :   /* Two different categories of symbol altogether.  This is an error
    2155              :      unless OLDDECL is a builtin.  OLDDECL will be discarded in any case.  */
    2156      4980031 :   if (TREE_CODE (olddecl) != TREE_CODE (newdecl))
    2157              :     {
    2158           29 :       if (!(TREE_CODE (olddecl) == FUNCTION_DECL
    2159           17 :             && fndecl_built_in_p (olddecl)
    2160           14 :             && !C_DECL_DECLARED_BUILTIN (olddecl)))
    2161              :         {
    2162           16 :           auto_diagnostic_group d;
    2163           16 :           error ("%q+D redeclared as different kind of symbol", newdecl);
    2164           16 :           locate_old_decl (olddecl);
    2165           16 :         }
    2166           13 :       else if (TREE_PUBLIC (newdecl))
    2167            3 :         warning (OPT_Wbuiltin_declaration_mismatch,
    2168              :                  "built-in function %q+D declared as non-function",
    2169              :                  newdecl);
    2170              :       else
    2171           10 :         warning (OPT_Wshadow, "declaration of %q+D shadows "
    2172              :                  "a built-in function", newdecl);
    2173           29 :       return false;
    2174              :     }
    2175              : 
    2176              :   /* Enumerators have no linkage, so may only be declared once in a
    2177              :      given scope.  */
    2178      4980002 :   if (TREE_CODE (olddecl) == CONST_DECL)
    2179              :     {
    2180           46 :       if (flag_isoc23
    2181           45 :           && TYPE_NAME (DECL_CONTEXT (newdecl))
    2182           43 :           && DECL_CONTEXT (newdecl) != DECL_CONTEXT (olddecl)
    2183           87 :           && TYPE_NAME (DECL_CONTEXT (newdecl)) == TYPE_NAME (DECL_CONTEXT (olddecl)))
    2184              :         {
    2185           38 :           if (!simple_cst_equal (DECL_INITIAL (olddecl), DECL_INITIAL (newdecl)))
    2186              :             {
    2187            1 :               auto_diagnostic_group d;
    2188            1 :               error ("conflicting redeclaration of enumerator %q+D", newdecl);
    2189            1 :               locate_old_decl (olddecl);
    2190            1 :             }
    2191              :         }
    2192              :       else
    2193              :         {
    2194            8 :           auto_diagnostic_group d;
    2195            8 :           error ("redeclaration of enumerator %q+D", newdecl);
    2196            8 :           locate_old_decl (olddecl);
    2197            8 :         }
    2198           46 :       return false;
    2199              :     }
    2200              : 
    2201      4979956 :   bool pedwarned = false;
    2202      4979956 :   bool warned = false;
    2203      4979956 :   bool enum_and_int_p = false;
    2204      4979956 :   auto_diagnostic_group d;
    2205              : 
    2206      4979956 :   int comptypes_result = comptypes_check_enum_int (oldtype, newtype,
    2207              :                                                    &enum_and_int_p);
    2208      4979956 :   if (!comptypes_result)
    2209              :     {
    2210       144814 :       if (TREE_CODE (olddecl) == FUNCTION_DECL
    2211       144734 :           && fndecl_built_in_p (olddecl, BUILT_IN_NORMAL)
    2212       289420 :           && !C_DECL_DECLARED_BUILTIN (olddecl))
    2213              :         {
    2214              :           /* Accept "harmless" mismatches in function types such
    2215              :              as missing qualifiers or int vs long when they're the same
    2216              :              size.  However, diagnose return and argument types that are
    2217              :              incompatible according to language rules.  */
    2218       144605 :           tree mismatch_expect;
    2219       144605 :           unsigned mismatch_argno;
    2220              : 
    2221       144605 :           tree trytype = match_builtin_function_types (newtype, oldtype,
    2222              :                                                        &mismatch_expect,
    2223              :                                                        &mismatch_argno);
    2224              : 
    2225       144605 :           if (trytype && comptypes (newtype, trytype))
    2226       143988 :             *oldtypep = oldtype = trytype;
    2227              :           else
    2228              :             {
    2229              :               /* If types don't match for a built-in, throw away the
    2230              :                  built-in.  No point in calling locate_old_decl here, it
    2231              :                  won't print anything.  */
    2232          617 :               const char *header = header_for_builtin_fn (olddecl);
    2233          617 :               location_t loc = DECL_SOURCE_LOCATION (newdecl);
    2234         1017 :               if (warning_at (loc, OPT_Wbuiltin_declaration_mismatch,
    2235              :                               "conflicting types for built-in function %q+D; "
    2236              :                               "expected %qT",
    2237              :                               newdecl, oldtype)
    2238          617 :                   && header)
    2239              :                 {
    2240              :                   /* Suggest the right header to include as the preferred
    2241              :                      solution rather than the spelling of the declaration.  */
    2242          217 :                   rich_location richloc (line_table, loc);
    2243          217 :                   maybe_add_include_fixit (&richloc, header, true);
    2244          217 :                   inform (&richloc,
    2245              :                           "%qD is declared in header %qs", olddecl, header);
    2246          217 :                 }
    2247          617 :               return false;
    2248              :             }
    2249              : 
    2250       143988 :           if (mismatch_expect && extra_warnings)
    2251              :             {
    2252            5 :               location_t newloc = DECL_SOURCE_LOCATION (newdecl);
    2253            5 :               bool warned = false;
    2254            5 :               if (mismatch_argno)
    2255            5 :                 warned = warning_at (newloc, OPT_Wbuiltin_declaration_mismatch,
    2256              :                                      "mismatch in argument %u type of built-in "
    2257              :                                      "function %qD; expected %qT",
    2258              :                                      mismatch_argno, newdecl, mismatch_expect);
    2259              :               else
    2260            0 :                 warned = warning_at (newloc, OPT_Wbuiltin_declaration_mismatch,
    2261              :                                      "mismatch in return type of built-in "
    2262              :                                      "function %qD; expected %qT",
    2263              :                                      newdecl, mismatch_expect);
    2264            5 :               const char *header = header_for_builtin_fn (olddecl);
    2265            5 :               if (warned && header)
    2266              :                 {
    2267            5 :                   rich_location richloc (line_table, newloc);
    2268            5 :                   maybe_add_include_fixit (&richloc, header, true);
    2269            5 :                   inform (&richloc,
    2270              :                           "%qD is declared in header %qs", olddecl, header);
    2271            5 :                 }
    2272              :             }
    2273              :         }
    2274          209 :       else if (TREE_CODE (olddecl) == FUNCTION_DECL
    2275          209 :                && DECL_IS_UNDECLARED_BUILTIN (olddecl))
    2276              :         {
    2277              :           /* A conflicting function declaration for a predeclared
    2278              :              function that isn't actually built in.  Objective C uses
    2279              :              these.  The new declaration silently overrides everything
    2280              :              but the volatility (i.e. noreturn) indication.  See also
    2281              :              below.  FIXME: Make Objective C use normal builtins.  */
    2282            0 :           TREE_THIS_VOLATILE (newdecl) |= TREE_THIS_VOLATILE (olddecl);
    2283            0 :           return false;
    2284              :         }
    2285              :       /* Permit void foo (...) to match int foo (...) if the latter is
    2286              :          the definition and implicit int was used.  See
    2287              :          c-torture/compile/920625-2.c.  */
    2288          129 :       else if (TREE_CODE (newdecl) == FUNCTION_DECL && DECL_INITIAL (newdecl)
    2289           64 :                && TYPE_MAIN_VARIANT (TREE_TYPE (oldtype)) == void_type_node
    2290           32 :                && TYPE_MAIN_VARIANT (TREE_TYPE (newtype)) == integer_type_node
    2291          215 :                && C_FUNCTION_IMPLICIT_INT (newdecl) && !DECL_INITIAL (olddecl))
    2292              :         {
    2293            5 :           pedwarned = pedwarn (input_location, 0,
    2294              :                                "conflicting types for %q+D", newdecl);
    2295              :           /* Make sure we keep void as the return type.  */
    2296            5 :           TREE_TYPE (newdecl) = *newtypep = newtype = oldtype;
    2297            5 :           C_FUNCTION_IMPLICIT_INT (newdecl) = 0;
    2298              :         }
    2299              :       /* Permit void foo (...) to match an earlier call to foo (...) with
    2300              :          no declared type (thus, implicitly int).  */
    2301          204 :       else if (TREE_CODE (newdecl) == FUNCTION_DECL
    2302          124 :                && TYPE_MAIN_VARIANT (TREE_TYPE (newtype)) == void_type_node
    2303           92 :                && TYPE_MAIN_VARIANT (TREE_TYPE (oldtype)) == integer_type_node
    2304          227 :                && C_DECL_IMPLICIT (olddecl) && !DECL_INITIAL (olddecl))
    2305              :         {
    2306           19 :           pedwarned = pedwarn (input_location, 0,
    2307              :                                "conflicting types for %q+D; have %qT",
    2308              :                                newdecl, newtype);
    2309              :           /* Make sure we keep void as the return type.  */
    2310           19 :           TREE_TYPE (olddecl) = *oldtypep = oldtype = newtype;
    2311              :         }
    2312              :       else
    2313              :         {
    2314          185 :           int new_quals = TYPE_QUALS (newtype);
    2315          185 :           int old_quals = TYPE_QUALS (oldtype);
    2316              : 
    2317          185 :           if (new_quals != old_quals)
    2318              :             {
    2319           21 :               addr_space_t new_addr = DECODE_QUAL_ADDR_SPACE (new_quals);
    2320           21 :               addr_space_t old_addr = DECODE_QUAL_ADDR_SPACE (old_quals);
    2321           21 :               if (new_addr != old_addr)
    2322              :                 {
    2323            0 :                   if (ADDR_SPACE_GENERIC_P (new_addr))
    2324            0 :                     error ("conflicting named address spaces (generic vs %s) "
    2325              :                            "for %q+D",
    2326              :                            c_addr_space_name (old_addr), newdecl);
    2327            0 :                   else if (ADDR_SPACE_GENERIC_P (old_addr))
    2328            0 :                     error ("conflicting named address spaces (%s vs generic) "
    2329              :                            "for %q+D",
    2330              :                            c_addr_space_name (new_addr), newdecl);
    2331              :                   else
    2332            0 :                     error ("conflicting named address spaces (%s vs %s) "
    2333              :                            "for %q+D",
    2334              :                            c_addr_space_name (new_addr),
    2335              :                            c_addr_space_name (old_addr),
    2336              :                            newdecl);
    2337              :                 }
    2338              : 
    2339           21 :               if (CLEAR_QUAL_ADDR_SPACE (new_quals)
    2340           21 :                   != CLEAR_QUAL_ADDR_SPACE (old_quals))
    2341           21 :                 error ("conflicting type qualifiers for %q+D", newdecl);
    2342              :             }
    2343              :           else
    2344              :             {
    2345          164 :               if (TREE_CODE (olddecl) == FUNCTION_DECL)
    2346              :                 {
    2347           93 :                   tree attrs = TYPE_ATTRIBUTES (TREE_TYPE (olddecl));
    2348           93 :                   if (attrs && !TYPE_ATTRIBUTES (TREE_TYPE (newdecl)))
    2349              :                     {
    2350              :                       /* Similar to the C++ front-end, for FUNCTION_DECL,
    2351              :                          if OLDDECL has attributes and NEWDECL doesn't,
    2352              :                          try the type with OLDDECL attributes.  */
    2353           12 :                       tree rettype = TREE_TYPE (newtype);
    2354           12 :                       tree tryargs = TYPE_ARG_TYPES (newtype);
    2355           12 :                       tree trytype = c_build_function_type (rettype,
    2356              :                                                             tryargs);
    2357           12 :                       trytype = c_build_type_attribute_variant (trytype,
    2358              :                                                                 attrs);
    2359           12 :                       if (comptypes (oldtype, trytype))
    2360              :                         {
    2361            7 :                           *newtypep = newtype = trytype;
    2362            7 :                           comptypes_result = 1;
    2363              :                         }
    2364              :                     }
    2365              :                 }
    2366              : 
    2367          164 :               if (!comptypes_result)
    2368          157 :                 error ("conflicting types for %q+D; have %qT", newdecl,
    2369              :                        newtype);
    2370              :             }
    2371            7 :           if (!comptypes_result)
    2372              :             {
    2373          178 :               diagnose_arglist_conflict (newdecl, olddecl, newtype,
    2374              :                                          oldtype);
    2375          178 :               locate_old_decl (olddecl);
    2376          178 :               return false;
    2377              :             }
    2378              :         }
    2379              :     }
    2380              :   /* Warn about enum/integer type mismatches.  They are compatible types
    2381              :      (C23 6.7.2.2/5), but may pose portability problems.  */
    2382      4835142 :   else if (enum_and_int_p
    2383          197 :            && TREE_CODE (newdecl) != TYPE_DECL
    2384              :            /* Don't warn about acc_on_device built-in redeclaration,
    2385              :               the built-in is declared with int rather than enum because
    2386              :               the enum isn't intrinsic.  */
    2387      4835335 :            && !(TREE_CODE (olddecl) == FUNCTION_DECL
    2388          156 :                 && fndecl_built_in_p (olddecl, BUILT_IN_ACC_ON_DEVICE)
    2389          126 :                 && !C_DECL_DECLARED_BUILTIN (olddecl)))
    2390           67 :     warned = warning_at (DECL_SOURCE_LOCATION (newdecl),
    2391           67 :                          OPT_Wenum_int_mismatch,
    2392              :                          "conflicting types for %q+D due to enum/integer "
    2393              :                          "mismatch; have %qT", newdecl, newtype);
    2394              : 
    2395              :   /* Redeclaration of a type is a constraint violation (6.7.2.3p1),
    2396              :      but silently ignore the redeclaration if either is in a system
    2397              :      header.  (Conflicting redeclarations were handled above.)  This
    2398              :      is allowed for C11 if the types are the same, not just
    2399              :      compatible.  */
    2400      4979161 :   if (TREE_CODE (newdecl) == TYPE_DECL)
    2401              :     {
    2402        45869 :       bool types_different = false;
    2403              : 
    2404        45869 :       comptypes_result
    2405        45869 :         = comptypes_check_different_types (oldtype, newtype, &types_different);
    2406              : 
    2407        45869 :       if (comptypes_result != 1 || types_different)
    2408              :         {
    2409           11 :           error ("redefinition of typedef %q+D with different type", newdecl);
    2410           11 :           locate_old_decl (olddecl);
    2411           11 :           return false;
    2412              :         }
    2413              : 
    2414        45858 :       if (DECL_IN_SYSTEM_HEADER (newdecl)
    2415         2495 :           || DECL_IN_SYSTEM_HEADER (olddecl)
    2416         2273 :           || warning_suppressed_p (newdecl, OPT_Wpedantic)
    2417        48131 :           || warning_suppressed_p (olddecl, OPT_Wpedantic))
    2418        43585 :         return true;  /* Allow OLDDECL to continue in use.  */
    2419              : 
    2420         2273 :       if (c_type_variably_modified_p (newtype))
    2421              :         {
    2422            3 :           error ("redefinition of typedef %q+D with variably modified type",
    2423              :                  newdecl);
    2424            3 :           locate_old_decl (olddecl);
    2425              :         }
    2426         2270 :       else if (pedwarn_c99 (input_location, OPT_Wpedantic,
    2427              :                             "redefinition of typedef %q+D", newdecl))
    2428            8 :         locate_old_decl (olddecl);
    2429              : 
    2430         2273 :       return true;
    2431              :     }
    2432              : 
    2433              :   /* Function declarations can either be 'static' or 'extern' (no
    2434              :      qualifier is equivalent to 'extern' - C99 6.2.2p5) and therefore
    2435              :      can never conflict with each other on account of linkage
    2436              :      (6.2.2p4).  Multiple definitions are not allowed (6.9p3,5) but
    2437              :      gnu89 mode permits two definitions if one is 'extern inline' and
    2438              :      one is not.  The non- extern-inline definition supersedes the
    2439              :      extern-inline definition.  */
    2440              : 
    2441      4933292 :   else if (TREE_CODE (newdecl) == FUNCTION_DECL)
    2442              :     {
    2443              :       /* If you declare a built-in function name as static, or
    2444              :          define the built-in with an old-style definition (so we
    2445              :          can't validate the argument list) the built-in definition is
    2446              :          overridden, but optionally warn this was a bad choice of name.  */
    2447      4914635 :       if (fndecl_built_in_p (olddecl)
    2448      8783652 :           && !C_DECL_DECLARED_BUILTIN (olddecl))
    2449              :         {
    2450      3610374 :           if (!TREE_PUBLIC (newdecl)
    2451      3610374 :               || (DECL_INITIAL (newdecl)
    2452         4861 :                   && !prototype_p (TREE_TYPE (newdecl))))
    2453              :             {
    2454          103 :               warning_at (DECL_SOURCE_LOCATION (newdecl),
    2455          103 :                           OPT_Wshadow, "declaration of %qD shadows "
    2456              :                           "a built-in function", newdecl);
    2457              :               /* Discard the old built-in function.  */
    2458          103 :               return false;
    2459              :             }
    2460              : 
    2461      3610271 :           if (!prototype_p (TREE_TYPE (newdecl)))
    2462              :             {
    2463              :               /* Set for built-ins that take no arguments.  */
    2464          342 :               bool func_void_args = false;
    2465          342 :               if (tree at = TYPE_ARG_TYPES (oldtype))
    2466          342 :                 func_void_args = VOID_TYPE_P (TREE_VALUE (at));
    2467              : 
    2468          342 :               if (extra_warnings && !func_void_args)
    2469           47 :                 warning_at (DECL_SOURCE_LOCATION (newdecl),
    2470           47 :                             OPT_Wbuiltin_declaration_mismatch,
    2471              :                             "declaration of built-in function %qD without "
    2472              :                             "a prototype; expected %qT",
    2473           47 :                             newdecl, TREE_TYPE (olddecl));
    2474              :             }
    2475              :         }
    2476              : 
    2477      4914532 :       if (DECL_INITIAL (newdecl))
    2478              :         {
    2479       232561 :           if (DECL_INITIAL (olddecl))
    2480              :             {
    2481              :               /* If the new declaration isn't overriding an extern inline
    2482              :                  reject the new decl. In c99, no overriding is allowed
    2483              :                  in the same translation unit.  */
    2484          209 :               if (!DECL_EXTERN_INLINE (olddecl)
    2485           91 :                   || DECL_EXTERN_INLINE (newdecl)
    2486          204 :                   || (!flag_gnu89_inline
    2487           15 :                       && (!DECL_DECLARED_INLINE_P (olddecl)
    2488           15 :                           || !lookup_attribute ("gnu_inline",
    2489           15 :                                                 DECL_ATTRIBUTES (olddecl)))
    2490            0 :                       && (!DECL_DECLARED_INLINE_P (newdecl)
    2491            0 :                           || !lookup_attribute ("gnu_inline",
    2492            0 :                                                 DECL_ATTRIBUTES (newdecl)))))
    2493              :                 {
    2494           26 :                   auto_diagnostic_group d;
    2495           26 :                   error ("redefinition of %q+D", newdecl);
    2496           26 :                   locate_old_decl (olddecl);
    2497           26 :                   return false;
    2498           26 :                 }
    2499              :             }
    2500              :         }
    2501              :       /* If we have a prototype after an old-style function definition,
    2502              :          the argument types must be checked specially.  */
    2503      4681971 :       else if (DECL_INITIAL (olddecl)
    2504          824 :                && !prototype_p (oldtype) && prototype_p (newtype)
    2505      4681991 :                && TYPE_ACTUAL_ARG_TYPES (oldtype))
    2506              :         {
    2507           19 :           auto_diagnostic_group d;
    2508           19 :           if (!validate_proto_after_old_defn (newdecl, newtype, oldtype))
    2509              :             {
    2510           10 :               locate_old_decl (olddecl);
    2511           10 :               return false;
    2512              :             }
    2513           19 :         }
    2514              :       /* A non-static declaration (even an "extern") followed by a
    2515              :          static declaration is undefined behavior per C99 6.2.2p3-5,7.
    2516              :          The same is true for a static forward declaration at block
    2517              :          scope followed by a non-static declaration/definition at file
    2518              :          scope.  Static followed by non-static at the same scope is
    2519              :          not undefined behavior, and is the most convenient way to get
    2520              :          some effects (see e.g.  what unwind-dw2-fde-glibc.c does to
    2521              :          the definition of _Unwind_Find_FDE in unwind-dw2-fde.c), but
    2522              :          we do diagnose it if -Wtraditional.  */
    2523      4914496 :       if (TREE_PUBLIC (olddecl) && !TREE_PUBLIC (newdecl))
    2524              :         {
    2525              :           /* Two exceptions to the rule.  If olddecl is an extern
    2526              :              inline, or a predeclared function that isn't actually
    2527              :              built in, newdecl silently overrides olddecl.  The latter
    2528              :              occur only in Objective C; see also above.  (FIXME: Make
    2529              :              Objective C use normal builtins.)  */
    2530           19 :           if (!DECL_IS_UNDECLARED_BUILTIN (olddecl)
    2531           38 :               && !DECL_EXTERN_INLINE (olddecl))
    2532              :             {
    2533            5 :               auto_diagnostic_group d;
    2534            5 :               error ("static declaration of %q+D follows "
    2535              :                      "non-static declaration", newdecl);
    2536            5 :               locate_old_decl (olddecl);
    2537            5 :             }
    2538           19 :           return false;
    2539              :         }
    2540      4914477 :       else if (TREE_PUBLIC (newdecl) && !TREE_PUBLIC (olddecl))
    2541              :         {
    2542         2329 :           if (DECL_CONTEXT (olddecl))
    2543              :             {
    2544            0 :               auto_diagnostic_group d;
    2545            0 :               error ("non-static declaration of %q+D follows "
    2546              :                      "static declaration", newdecl);
    2547            0 :               locate_old_decl (olddecl);
    2548            0 :               return false;
    2549            0 :             }
    2550         2329 :           else if (warn_traditional)
    2551              :             {
    2552            2 :               warned |= warning (OPT_Wtraditional,
    2553              :                                  "non-static declaration of %q+D "
    2554              :                                  "follows static declaration", newdecl);
    2555              :             }
    2556              :         }
    2557              : 
    2558              :       /* Make sure gnu_inline attribute is either not present, or
    2559              :          present on all inline decls.  */
    2560      4914477 :       if (DECL_DECLARED_INLINE_P (olddecl)
    2561      4915552 :           && DECL_DECLARED_INLINE_P (newdecl))
    2562              :         {
    2563          820 :           bool newa = lookup_attribute ("gnu_inline",
    2564          820 :                                         DECL_ATTRIBUTES (newdecl)) != NULL;
    2565          820 :           bool olda = lookup_attribute ("gnu_inline",
    2566          820 :                                         DECL_ATTRIBUTES (olddecl)) != NULL;
    2567          820 :           if (newa != olda)
    2568              :             {
    2569            0 :               auto_diagnostic_group d;
    2570            0 :               error_at (input_location, "%<gnu_inline%> attribute present on %q+D",
    2571              :                         newa ? newdecl : olddecl);
    2572            0 :               error_at (DECL_SOURCE_LOCATION (newa ? olddecl : newdecl),
    2573              :                         "but not here");
    2574            0 :             }
    2575              :         }
    2576              :       /* Check if these are unmergable overlapping FMV declarations.  */
    2577              :       if (!TARGET_HAS_FMV_TARGET_ATTRIBUTE
    2578              :           && diagnose_versioned_decls (olddecl, newdecl))
    2579              :         return false;
    2580              :     }
    2581        18657 :   else if (VAR_P (newdecl))
    2582              :     {
    2583              :       /* Only variables can be thread-local, and all declarations must
    2584              :          agree on this property.  */
    2585        18620 :       if (C_DECL_THREADPRIVATE_P (olddecl) && !DECL_THREAD_LOCAL_P (newdecl))
    2586              :         {
    2587              :           /* Nothing to check.  Since OLDDECL is marked threadprivate
    2588              :              and NEWDECL does not have a thread-local attribute, we
    2589              :              will merge the threadprivate attribute into NEWDECL.  */
    2590              :           ;
    2591              :         }
    2592        55647 :       else if (DECL_THREAD_LOCAL_P (newdecl) != DECL_THREAD_LOCAL_P (olddecl))
    2593              :         {
    2594            6 :           auto_diagnostic_group d;
    2595            6 :           if (DECL_THREAD_LOCAL_P (newdecl))
    2596            3 :             error ("thread-local declaration of %q+D follows "
    2597              :                    "non-thread-local declaration", newdecl);
    2598              :           else
    2599            3 :             error ("non-thread-local declaration of %q+D follows "
    2600              :                    "thread-local declaration", newdecl);
    2601              : 
    2602            6 :           locate_old_decl (olddecl);
    2603            6 :           return false;
    2604            6 :         }
    2605              : 
    2606              :       /* Multiple initialized definitions are not allowed (6.9p3,5).
    2607              :          For this purpose, C23 makes it clear that thread-local
    2608              :          declarations without extern are definitions, not tentative
    2609              :          definitions, whether or not they have initializers.  The
    2610              :          wording before C23 was unclear; literally it would have made
    2611              :          uninitialized thread-local declarations into tentative
    2612              :          definitions only if they also used static, but without saying
    2613              :          explicitly whether or not other cases count as
    2614              :          definitions at all.  */
    2615        19163 :       if ((DECL_INITIAL (newdecl) && DECL_INITIAL (olddecl))
    2616        19162 :           || (flag_isoc23
    2617         6446 :               && DECL_THREAD_LOCAL_P (newdecl)
    2618           25 :               && !DECL_EXTERNAL (newdecl)
    2619           21 :               && !DECL_EXTERNAL (olddecl)))
    2620              :         {
    2621            7 :           auto_diagnostic_group d;
    2622            7 :           error ("redefinition of %q+D", newdecl);
    2623            7 :           locate_old_decl (olddecl);
    2624            7 :           return false;
    2625            7 :         }
    2626              : 
    2627              :       /* Objects declared at file scope: if the first declaration had
    2628              :          external linkage (even if it was an external reference) the
    2629              :          second must have external linkage as well, or the behavior is
    2630              :          undefined.  If the first declaration had internal linkage, then
    2631              :          the second must too, or else be an external reference (in which
    2632              :          case the composite declaration still has internal linkage).
    2633              :          As for function declarations, we warn about the static-then-
    2634              :          extern case only for -Wtraditional.  See generally 6.2.2p3-5,7.  */
    2635        18624 :       if (DECL_FILE_SCOPE_P (newdecl)
    2636        18607 :           && TREE_PUBLIC (newdecl) != TREE_PUBLIC (olddecl))
    2637              :         {
    2638          147 :           if (DECL_EXTERNAL (newdecl))
    2639              :             {
    2640          144 :               if (!DECL_FILE_SCOPE_P (olddecl))
    2641              :                 {
    2642            2 :                   auto_diagnostic_group d;
    2643            2 :                   error ("extern declaration of %q+D follows "
    2644              :                          "declaration with no linkage", newdecl);
    2645            2 :                   locate_old_decl (olddecl);
    2646            2 :                   return false;
    2647            2 :                 }
    2648          142 :               else if (warn_traditional)
    2649              :                 {
    2650            0 :                   warned |= warning (OPT_Wtraditional,
    2651              :                                      "non-static declaration of %q+D "
    2652              :                                      "follows static declaration", newdecl);
    2653              :                 }
    2654              :             }
    2655              :           else
    2656              :             {
    2657            3 :               auto_diagnostic_group d;
    2658            3 :               if (TREE_PUBLIC (newdecl))
    2659            2 :                 error ("non-static declaration of %q+D follows "
    2660              :                        "static declaration", newdecl);
    2661              :               else
    2662            1 :                 error ("static declaration of %q+D follows "
    2663              :                        "non-static declaration", newdecl);
    2664              : 
    2665            3 :               locate_old_decl (olddecl);
    2666            3 :               return false;
    2667            3 :             }
    2668              :         }
    2669              :       /* Two objects with the same name declared at the same block
    2670              :          scope must both be external references (6.7p3).  */
    2671        18460 :       else if (!DECL_FILE_SCOPE_P (newdecl))
    2672              :         {
    2673           17 :           if (DECL_EXTERNAL (newdecl))
    2674              :             {
    2675              :               /* Extern with initializer at block scope, which will
    2676              :                  already have received an error.  */
    2677              :             }
    2678           15 :           else if (DECL_EXTERNAL (olddecl))
    2679              :             {
    2680            4 :               auto_diagnostic_group d;
    2681            4 :               error ("declaration of %q+D with no linkage follows "
    2682              :                      "extern declaration", newdecl);
    2683            4 :               locate_old_decl (olddecl);
    2684            4 :             }
    2685              :           else
    2686              :             {
    2687           11 :               auto_diagnostic_group d;
    2688           11 :               error ("redeclaration of %q+D with no linkage", newdecl);
    2689           11 :               locate_old_decl (olddecl);
    2690           11 :             }
    2691              : 
    2692           17 :           return false;
    2693              :         }
    2694              : 
    2695              :       /* C++ does not permit a decl to appear multiple times at file
    2696              :          scope.  */
    2697        18585 :       if (warn_cxx_compat
    2698           68 :           && DECL_FILE_SCOPE_P (newdecl)
    2699           68 :           && !DECL_EXTERNAL (newdecl)
    2700        18603 :           && !DECL_EXTERNAL (olddecl))
    2701            5 :         warned |= warning_at (DECL_SOURCE_LOCATION (newdecl),
    2702            5 :                               OPT_Wc___compat,
    2703              :                               "duplicate declaration of %qD is "
    2704              :                               "invalid in C++", newdecl);
    2705              :     }
    2706              : 
    2707              :   /* warnings */
    2708              :   /* All decls must agree on a visibility.  */
    2709      4933099 :   if (CODE_CONTAINS_STRUCT (TREE_CODE (newdecl), TS_DECL_WITH_VIS)
    2710      4933062 :       && DECL_VISIBILITY_SPECIFIED (newdecl) && DECL_VISIBILITY_SPECIFIED (olddecl)
    2711      4933842 :       && DECL_VISIBILITY (newdecl) != DECL_VISIBILITY (olddecl))
    2712              :     {
    2713            1 :       warned |= warning (0, "redeclaration of %q+D with different visibility "
    2714              :                          "(old visibility preserved)", newdecl);
    2715              :     }
    2716              : 
    2717      4933099 :   if (TREE_CODE (newdecl) == FUNCTION_DECL)
    2718      4914477 :     warned |= diagnose_mismatched_attributes (olddecl, newdecl);
    2719              :   else /* PARM_DECL, VAR_DECL */
    2720              :     {
    2721              :       /* Redeclaration of a parameter is a constraint violation (this is
    2722              :          not explicitly stated, but follows from C99 6.7p3 [no more than
    2723              :          one declaration of the same identifier with no linkage in the
    2724              :          same scope, except type tags] and 6.2.2p6 [parameters have no
    2725              :          linkage]).  We must check for a forward parameter declaration,
    2726              :          indicated by TREE_ASM_WRITTEN on the old declaration - this is
    2727              :          an extension, the mandatory diagnostic for which is handled by
    2728              :          mark_forward_parm_decls.  */
    2729              : 
    2730        18622 :       if (TREE_CODE (newdecl) == PARM_DECL
    2731           37 :           && (!TREE_ASM_WRITTEN (olddecl) || TREE_ASM_WRITTEN (newdecl)))
    2732              :         {
    2733            2 :           auto_diagnostic_group d;
    2734            2 :           error ("redefinition of parameter %q+D", newdecl);
    2735            2 :           locate_old_decl (olddecl);
    2736            2 :           return false;
    2737            2 :         }
    2738              :     }
    2739              : 
    2740              :   /* Optional warning for completely redundant decls.  */
    2741      4933097 :   if (!warned && !pedwarned
    2742      4933023 :       && warn_redundant_decls
    2743              :       /* Don't warn about a function declaration followed by a
    2744              :          definition.  */
    2745           18 :       && !(TREE_CODE (newdecl) == FUNCTION_DECL
    2746            2 :            && DECL_INITIAL (newdecl) && !DECL_INITIAL (olddecl))
    2747              :       /* Don't warn about redundant redeclarations of builtins.  */
    2748           18 :       && !(TREE_CODE (newdecl) == FUNCTION_DECL
    2749            2 :            && !fndecl_built_in_p (newdecl)
    2750            2 :            && fndecl_built_in_p (olddecl)
    2751            2 :            && !C_DECL_DECLARED_BUILTIN (olddecl))
    2752              :       /* Don't warn about an extern followed by a definition.  */
    2753           17 :       && !(DECL_EXTERNAL (olddecl) && !DECL_EXTERNAL (newdecl))
    2754              :       /* Don't warn about forward parameter decls.  */
    2755           17 :       && !(TREE_CODE (newdecl) == PARM_DECL
    2756            6 :            && TREE_ASM_WRITTEN (olddecl) && !TREE_ASM_WRITTEN (newdecl))
    2757              :       /* Don't warn about a variable definition following a declaration.  */
    2758      4933108 :       && !(VAR_P (newdecl)
    2759           10 :            && DECL_INITIAL (newdecl) && !DECL_INITIAL (olddecl)))
    2760              :     {
    2761            6 :       warned = warning (OPT_Wredundant_decls, "redundant redeclaration of %q+D",
    2762              :                         newdecl);
    2763              :     }
    2764              : 
    2765              :   /* Report location of previous decl/defn.  */
    2766      4933097 :   if (warned || pedwarned)
    2767           80 :     locate_old_decl (olddecl);
    2768              : 
    2769              : #undef DECL_EXTERN_INLINE
    2770              : 
    2771              :   return retval;
    2772      4979956 : }
    2773              : 
    2774              : /* Subroutine of duplicate_decls.  NEWDECL has been found to be
    2775              :    consistent with OLDDECL, but carries new information.  Merge the
    2776              :    new information into OLDDECL.  This function issues no
    2777              :    diagnostics.  */
    2778              : 
    2779              : static void
    2780      4978955 : merge_decls (tree newdecl, tree olddecl, tree newtype, tree oldtype)
    2781              : {
    2782      4978955 :   bool new_is_definition = (TREE_CODE (newdecl) == FUNCTION_DECL
    2783      4978955 :                             && DECL_INITIAL (newdecl) != NULL_TREE);
    2784      4978955 :   bool new_is_prototype = (TREE_CODE (newdecl) == FUNCTION_DECL
    2785      4978955 :                            && prototype_p (TREE_TYPE (newdecl)));
    2786      4978955 :   bool old_is_prototype = (TREE_CODE (olddecl) == FUNCTION_DECL
    2787      4978955 :                            && prototype_p (TREE_TYPE (olddecl)));
    2788              : 
    2789              :   /* For real parm decl following a forward decl, rechain the old decl
    2790              :      in its new location and clear TREE_ASM_WRITTEN (it's not a
    2791              :      forward decl anymore).  */
    2792      4978955 :   if (TREE_CODE (newdecl) == PARM_DECL
    2793           35 :       && TREE_ASM_WRITTEN (olddecl) && !TREE_ASM_WRITTEN (newdecl))
    2794              :     {
    2795           35 :       struct c_binding *b, **here;
    2796              : 
    2797           54 :       for (here = &current_scope->bindings; *here; here = &(*here)->prev)
    2798           54 :         if ((*here)->decl == olddecl)
    2799           35 :           goto found;
    2800            0 :       gcc_unreachable ();
    2801              : 
    2802           35 :     found:
    2803           35 :       b = *here;
    2804           35 :       *here = b->prev;
    2805           35 :       b->prev = current_scope->bindings;
    2806           35 :       current_scope->bindings = b;
    2807              : 
    2808           35 :       TREE_ASM_WRITTEN (olddecl) = 0;
    2809              :     }
    2810              : 
    2811      4978955 :   DECL_ATTRIBUTES (newdecl)
    2812      4978955 :     = targetm.merge_decl_attributes (olddecl, newdecl);
    2813              : 
    2814              :   /* For typedefs use the old type, as the new type's DECL_NAME points
    2815              :      at newdecl, which will be ggc_freed.  */
    2816      4978955 :   if (TREE_CODE (newdecl) == TYPE_DECL)
    2817              :     {
    2818              :       /* But NEWTYPE might have an attribute, honor that.  */
    2819        45858 :       tree tem = newtype;
    2820        45858 :       newtype = oldtype;
    2821              : 
    2822        45858 :       if (TYPE_USER_ALIGN (tem))
    2823              :         {
    2824           15 :           if (TYPE_ALIGN (tem) > TYPE_ALIGN (newtype))
    2825            6 :             SET_TYPE_ALIGN (newtype, TYPE_ALIGN (tem));
    2826           15 :           TYPE_USER_ALIGN (newtype) = true;
    2827              :         }
    2828              : 
    2829              :       /* And remove the new type from the variants list.  */
    2830        45858 :       if (TYPE_NAME (TREE_TYPE (newdecl)) == newdecl)
    2831              :         {
    2832           15 :           tree remove = TREE_TYPE (newdecl);
    2833           15 :           if (TYPE_MAIN_VARIANT (remove) == remove)
    2834              :             {
    2835            2 :               gcc_assert (TYPE_NEXT_VARIANT (remove) == NULL_TREE);
    2836              :               /* If remove is the main variant, no need to remove that
    2837              :                  from the list.  One of the DECL_ORIGINAL_TYPE
    2838              :                  variants, e.g. created for aligned attribute, might still
    2839              :                  refer to the newdecl TYPE_DECL though, so remove that one
    2840              :                  in that case.  */
    2841            2 :               if (DECL_ORIGINAL_TYPE (newdecl)
    2842            2 :                   && DECL_ORIGINAL_TYPE (newdecl) != remove)
    2843            2 :                 for (tree t = TYPE_MAIN_VARIANT (DECL_ORIGINAL_TYPE (newdecl));
    2844            2 :                      t; t = TYPE_MAIN_VARIANT (t))
    2845            2 :                   if (TYPE_NAME (TYPE_NEXT_VARIANT (t)) == newdecl)
    2846              :                     {
    2847            4 :                       TYPE_NEXT_VARIANT (t)
    2848            2 :                         = TYPE_NEXT_VARIANT (TYPE_NEXT_VARIANT (t));
    2849            2 :                       break;
    2850              :                     }
    2851              :             }
    2852              :           else
    2853           13 :             for (tree t = TYPE_MAIN_VARIANT (remove); ;
    2854            0 :                  t = TYPE_NEXT_VARIANT (t))
    2855           13 :               if (TYPE_NEXT_VARIANT (t) == remove)
    2856              :                 {
    2857           13 :                   TYPE_NEXT_VARIANT (t) = TYPE_NEXT_VARIANT (remove);
    2858           13 :                   break;
    2859              :                 }
    2860              :         }
    2861              : 
    2862              :       /* Make sure we refer to the same type as the olddecl.  */
    2863        45858 :       DECL_ORIGINAL_TYPE (newdecl) = DECL_ORIGINAL_TYPE (olddecl);
    2864              :     }
    2865              : 
    2866              :   /* Merge the data types specified in the two decls.  */
    2867      9957910 :   TREE_TYPE (newdecl)
    2868      4978955 :     = TREE_TYPE (olddecl)
    2869      9957910 :     = composite_type (newtype, oldtype);
    2870              : 
    2871              :   /* Lay the type out, unless already done.  */
    2872      4978955 :   if (!comptypes (oldtype, TREE_TYPE (newdecl)))
    2873              :     {
    2874            0 :       if (TREE_TYPE (newdecl) != error_mark_node)
    2875            0 :         layout_type (TREE_TYPE (newdecl));
    2876            0 :       if (TREE_CODE (newdecl) != FUNCTION_DECL
    2877              :           && TREE_CODE (newdecl) != TYPE_DECL
    2878              :           && TREE_CODE (newdecl) != CONST_DECL)
    2879            0 :         layout_decl (newdecl, 0);
    2880              :     }
    2881              :   else
    2882              :     {
    2883              :       /* Since the type is OLDDECL's, make OLDDECL's size go with.  */
    2884      4978955 :       DECL_SIZE (newdecl) = DECL_SIZE (olddecl);
    2885      4978955 :       DECL_SIZE_UNIT (newdecl) = DECL_SIZE_UNIT (olddecl);
    2886      4978955 :       SET_DECL_MODE (newdecl, DECL_MODE (olddecl));
    2887      4978955 :       if (DECL_ALIGN (olddecl) > DECL_ALIGN (newdecl))
    2888              :         {
    2889           44 :           SET_DECL_ALIGN (newdecl, DECL_ALIGN (olddecl));
    2890           44 :           DECL_USER_ALIGN (newdecl) |= DECL_USER_ALIGN (olddecl);
    2891              :         }
    2892      4978911 :       else if (DECL_ALIGN (olddecl) == DECL_ALIGN (newdecl)
    2893      4978911 :                && DECL_USER_ALIGN (olddecl) != DECL_USER_ALIGN (newdecl))
    2894            3 :         DECL_USER_ALIGN (newdecl) = 1;
    2895      9957910 :       if (DECL_WARN_IF_NOT_ALIGN (olddecl)
    2896      4978955 :           > DECL_WARN_IF_NOT_ALIGN (newdecl))
    2897            0 :         SET_DECL_WARN_IF_NOT_ALIGN (newdecl,
    2898              :                                     DECL_WARN_IF_NOT_ALIGN (olddecl));
    2899              :     }
    2900              : 
    2901              :   /* Keep the old rtl since we can safely use it.  */
    2902      4978955 :   if (HAS_RTL_P (olddecl))
    2903      4978955 :     COPY_DECL_RTL (olddecl, newdecl);
    2904              : 
    2905              :   /* Merge the type qualifiers.  */
    2906      4978955 :   if (TREE_READONLY (newdecl))
    2907       392637 :     TREE_READONLY (olddecl) = 1;
    2908              : 
    2909      4978955 :   if (TREE_THIS_VOLATILE (newdecl))
    2910        49402 :     TREE_THIS_VOLATILE (olddecl) = 1;
    2911              : 
    2912              :   /* Merge deprecatedness.  */
    2913      4978955 :   if (TREE_DEPRECATED (newdecl))
    2914          383 :     TREE_DEPRECATED (olddecl) = 1;
    2915              : 
    2916              :   /* Merge unavailability.  */
    2917      4978955 :   if (TREE_UNAVAILABLE (newdecl))
    2918            2 :     TREE_UNAVAILABLE (olddecl) = 1;
    2919              : 
    2920              :   /* If a decl is in a system header and the other isn't, keep the one on the
    2921              :      system header. Otherwise, keep source location of definition rather than
    2922              :      declaration and of prototype rather than non-prototype unless that
    2923              :      prototype is built-in.  */
    2924      4978955 :   if (HAS_DECL_ASSEMBLER_NAME_P (olddecl)
    2925      4978920 :       && DECL_IN_SYSTEM_HEADER (olddecl)
    2926      5663102 :       && !DECL_IN_SYSTEM_HEADER (newdecl) )
    2927         1046 :     DECL_SOURCE_LOCATION (newdecl) = DECL_SOURCE_LOCATION (olddecl);
    2928      4977909 :   else if (HAS_DECL_ASSEMBLER_NAME_P (olddecl)
    2929      4977874 :            && DECL_IN_SYSTEM_HEADER (newdecl)
    2930      9218589 :            && !DECL_IN_SYSTEM_HEADER (olddecl))
    2931      3557579 :     DECL_SOURCE_LOCATION (olddecl) = DECL_SOURCE_LOCATION (newdecl);
    2932      1420330 :   else if ((DECL_INITIAL (newdecl) == NULL_TREE
    2933      1187315 :             && DECL_INITIAL (olddecl) != NULL_TREE)
    2934      2606723 :            || (old_is_prototype && !new_is_prototype
    2935          372 :                && !C_DECL_BUILTIN_PROTOTYPE (olddecl)))
    2936          950 :     DECL_SOURCE_LOCATION (newdecl) = DECL_SOURCE_LOCATION (olddecl);
    2937              : 
    2938              :   /* Merge the initialization information.  */
    2939      4978955 :    if (DECL_INITIAL (newdecl) == NULL_TREE)
    2940      4745868 :     DECL_INITIAL (newdecl) = DECL_INITIAL (olddecl);
    2941              : 
    2942              :   /* Merge 'constexpr' information.  */
    2943      4978955 :   if (VAR_P (olddecl) && VAR_P (newdecl))
    2944              :     {
    2945        18585 :       if (C_DECL_DECLARED_CONSTEXPR (olddecl))
    2946            2 :         C_DECL_DECLARED_CONSTEXPR (newdecl) = 1;
    2947        18583 :       else if (C_DECL_DECLARED_CONSTEXPR (newdecl))
    2948            1 :         C_DECL_DECLARED_CONSTEXPR (olddecl) = 1;
    2949              :     }
    2950              : 
    2951              :   /* Merge the threadprivate attribute.  */
    2952      4978955 :   if (VAR_P (olddecl) && C_DECL_THREADPRIVATE_P (olddecl))
    2953            7 :     C_DECL_THREADPRIVATE_P (newdecl) = 1;
    2954              : 
    2955      4978955 :   if (HAS_DECL_ASSEMBLER_NAME_P (olddecl))
    2956              :     {
    2957              :       /* Copy the assembler name.
    2958              :          Currently, it can only be defined in the prototype.  */
    2959      4978920 :       COPY_DECL_ASSEMBLER_NAME (olddecl, newdecl);
    2960              : 
    2961              :       /* Use visibility of whichever declaration had it specified */
    2962      4978920 :       if (DECL_VISIBILITY_SPECIFIED (olddecl))
    2963              :         {
    2964         4756 :           DECL_VISIBILITY (newdecl) = DECL_VISIBILITY (olddecl);
    2965         4756 :           DECL_VISIBILITY_SPECIFIED (newdecl) = 1;
    2966              :         }
    2967              : 
    2968      4978920 :       if (TREE_CODE (newdecl) == FUNCTION_DECL)
    2969              :         {
    2970      4914477 :           DECL_STATIC_CONSTRUCTOR(newdecl) |= DECL_STATIC_CONSTRUCTOR(olddecl);
    2971      4914477 :           DECL_STATIC_DESTRUCTOR (newdecl) |= DECL_STATIC_DESTRUCTOR (olddecl);
    2972      4914477 :           DECL_NO_LIMIT_STACK (newdecl) |= DECL_NO_LIMIT_STACK (olddecl);
    2973      4914477 :           DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (newdecl)
    2974      4914477 :             |= DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (olddecl);
    2975      4914477 :           TREE_THIS_VOLATILE (newdecl) |= TREE_THIS_VOLATILE (olddecl);
    2976      4914477 :           DECL_IS_MALLOC (newdecl) |= DECL_IS_MALLOC (olddecl);
    2977      4914477 :           if (DECL_IS_OPERATOR_NEW_P (olddecl))
    2978            0 :             DECL_SET_IS_OPERATOR_NEW (newdecl, true);
    2979      4914477 :           if (DECL_IS_OPERATOR_DELETE_P (olddecl))
    2980            0 :             DECL_SET_IS_OPERATOR_DELETE (newdecl, true);
    2981      4914477 :           TREE_READONLY (newdecl) |= TREE_READONLY (olddecl);
    2982      4914477 :           DECL_PURE_P (newdecl) |= DECL_PURE_P (olddecl);
    2983      4914477 :           DECL_IS_NOVOPS (newdecl) |= DECL_IS_NOVOPS (olddecl);
    2984              :         }
    2985              : 
    2986              :       /* Merge the storage class information.  */
    2987      4978920 :       merge_weak (newdecl, olddecl);
    2988              : 
    2989              :       /* For functions, static overrides non-static.  */
    2990      4978920 :       if (TREE_CODE (newdecl) == FUNCTION_DECL)
    2991              :         {
    2992      4914477 :           TREE_PUBLIC (newdecl) &= TREE_PUBLIC (olddecl);
    2993              :           /* This is since we don't automatically
    2994              :              copy the attributes of NEWDECL into OLDDECL.  */
    2995      4914477 :           TREE_PUBLIC (olddecl) = TREE_PUBLIC (newdecl);
    2996              :           /* If this clears `static', clear it in the identifier too.  */
    2997      4914477 :           if (!TREE_PUBLIC (olddecl))
    2998         7734 :             TREE_PUBLIC (DECL_NAME (olddecl)) = 0;
    2999              :         }
    3000              :     }
    3001              : 
    3002              :   /* In c99, 'extern' declaration before (or after) 'inline' means this
    3003              :      function is not DECL_EXTERNAL, unless 'gnu_inline' attribute
    3004              :      is present.  */
    3005      4978955 :   if (TREE_CODE (newdecl) == FUNCTION_DECL
    3006      4914477 :       && !flag_gnu89_inline
    3007      4890083 :       && (DECL_DECLARED_INLINE_P (newdecl)
    3008      4700089 :           || DECL_DECLARED_INLINE_P (olddecl))
    3009       190188 :       && (!DECL_DECLARED_INLINE_P (newdecl)
    3010       189994 :           || !DECL_DECLARED_INLINE_P (olddecl)
    3011          807 :           || !DECL_EXTERNAL (olddecl))
    3012       189399 :       && DECL_EXTERNAL (newdecl)
    3013       189191 :       && !lookup_attribute ("gnu_inline", DECL_ATTRIBUTES (newdecl))
    3014      4979053 :       && !current_function_decl)
    3015           81 :     DECL_EXTERNAL (newdecl) = 0;
    3016              : 
    3017              :   /* An inline definition following a static declaration is not
    3018              :      DECL_EXTERNAL.  */
    3019      4978955 :   if (new_is_definition
    3020       232518 :       && (DECL_DECLARED_INLINE_P (newdecl)
    3021        42302 :           || DECL_DECLARED_INLINE_P (olddecl))
    3022      5169385 :       && !TREE_PUBLIC (olddecl))
    3023          900 :     DECL_EXTERNAL (newdecl) = 0;
    3024              : 
    3025      4978955 :   if (DECL_EXTERNAL (newdecl))
    3026              :     {
    3027      4887600 :       TREE_STATIC (newdecl) = TREE_STATIC (olddecl);
    3028      4887600 :       DECL_EXTERNAL (newdecl) = DECL_EXTERNAL (olddecl);
    3029              : 
    3030              :       /* An extern decl does not override previous storage class.  */
    3031      4887600 :       TREE_PUBLIC (newdecl) = TREE_PUBLIC (olddecl);
    3032      4887600 :       if (!DECL_EXTERNAL (newdecl))
    3033              :         {
    3034         1437 :           DECL_CONTEXT (newdecl) = DECL_CONTEXT (olddecl);
    3035         1437 :           DECL_COMMON (newdecl) = DECL_COMMON (olddecl);
    3036              :         }
    3037              :     }
    3038              :   else
    3039              :     {
    3040        91355 :       TREE_STATIC (olddecl) = TREE_STATIC (newdecl);
    3041        91355 :       TREE_PUBLIC (olddecl) = TREE_PUBLIC (newdecl);
    3042              :     }
    3043              : 
    3044      4978955 :   if (TREE_CODE (newdecl) == FUNCTION_DECL)
    3045              :     {
    3046      4914477 :       if (DECL_FUNCTION_VERSIONED (olddecl)
    3047      4914477 :           || DECL_FUNCTION_VERSIONED (newdecl))
    3048              :         {
    3049            0 :           maybe_mark_function_versioned (olddecl);
    3050            0 :           maybe_mark_function_versioned (newdecl);
    3051              :         }
    3052              :       /* If we're redefining a function previously defined as extern
    3053              :          inline, make sure we emit debug info for the inline before we
    3054              :          throw it away, in case it was inlined into a function that
    3055              :          hasn't been written out yet.  */
    3056      4914477 :       if (new_is_definition && DECL_INITIAL (olddecl))
    3057              :         /* The new defn must not be inline.  */
    3058           75 :         DECL_UNINLINABLE (newdecl) = 1;
    3059              :       else
    3060              :         {
    3061              :           /* If either decl says `inline', this fn is inline, unless
    3062              :              its definition was passed already.  */
    3063      4914402 :           if (DECL_DECLARED_INLINE_P (newdecl)
    3064      9638536 :               || DECL_DECLARED_INLINE_P (olddecl))
    3065       190453 :             DECL_DECLARED_INLINE_P (newdecl) = 1;
    3066              : 
    3067     14743206 :           DECL_UNINLINABLE (newdecl) = DECL_UNINLINABLE (olddecl)
    3068      9830439 :             = (DECL_UNINLINABLE (newdecl) || DECL_UNINLINABLE (olddecl));
    3069              : 
    3070      9828804 :           DECL_DISREGARD_INLINE_LIMITS (newdecl)
    3071      4914402 :             = DECL_DISREGARD_INLINE_LIMITS (olddecl)
    3072      4914402 :             = (DECL_DISREGARD_INLINE_LIMITS (newdecl)
    3073      9828666 :                || DECL_DISREGARD_INLINE_LIMITS (olddecl));
    3074              :         }
    3075              : 
    3076      4914477 :       if (fndecl_built_in_p (olddecl))
    3077              :         {
    3078              :           /* If redeclaring a builtin function, it stays built in.
    3079              :              But it gets tagged as having been declared.  */
    3080      3868914 :           copy_decl_built_in_function (newdecl, olddecl);
    3081      3868914 :           C_DECL_DECLARED_BUILTIN (newdecl) = 1;
    3082      3868914 :           if (new_is_prototype)
    3083              :             {
    3084      3868555 :               C_DECL_BUILTIN_PROTOTYPE (newdecl) = 0;
    3085      3868555 :               if (DECL_BUILT_IN_CLASS (newdecl) == BUILT_IN_NORMAL)
    3086              :                 {
    3087      3868555 :                   enum built_in_function fncode = DECL_FUNCTION_CODE (newdecl);
    3088      3868555 :                   switch (fncode)
    3089              :                     {
    3090              :                       /* If a compatible prototype of these builtin functions
    3091              :                          is seen, assume the runtime implements it with the
    3092              :                          expected semantics.  */
    3093         6481 :                     case BUILT_IN_STPCPY:
    3094         6481 :                       if (builtin_decl_explicit_p (fncode))
    3095         6481 :                         set_builtin_decl_implicit_p (fncode, true);
    3096              :                       break;
    3097      3862074 :                     default:
    3098      3862074 :                       if (builtin_decl_explicit_p (fncode))
    3099      3862074 :                         set_builtin_decl_declared_p (fncode, true);
    3100              :                       break;
    3101              :                     }
    3102              : 
    3103      3868555 :                   copy_attributes_to_builtin (newdecl);
    3104              :                 }
    3105              :             }
    3106              :           else
    3107          718 :             C_DECL_BUILTIN_PROTOTYPE (newdecl)
    3108          718 :               = C_DECL_BUILTIN_PROTOTYPE (olddecl);
    3109              :         }
    3110              : 
    3111              :       /* Preserve function specific target and optimization options */
    3112      4914477 :       if (DECL_FUNCTION_SPECIFIC_TARGET (olddecl)
    3113      4914983 :           && !DECL_FUNCTION_SPECIFIC_TARGET (newdecl))
    3114          470 :         DECL_FUNCTION_SPECIFIC_TARGET (newdecl)
    3115          470 :           = DECL_FUNCTION_SPECIFIC_TARGET (olddecl);
    3116              : 
    3117      4914477 :       if (DECL_FUNCTION_SPECIFIC_OPTIMIZATION (olddecl)
    3118      4937899 :           && !DECL_FUNCTION_SPECIFIC_OPTIMIZATION (newdecl))
    3119            9 :         DECL_FUNCTION_SPECIFIC_OPTIMIZATION (newdecl)
    3120            9 :           = DECL_FUNCTION_SPECIFIC_OPTIMIZATION (olddecl);
    3121              : 
    3122              :       /* Also preserve various other info from the definition.  */
    3123      4914477 :       if (!new_is_definition)
    3124              :         {
    3125      4681959 :           tree t;
    3126      4681959 :           DECL_RESULT (newdecl) = DECL_RESULT (olddecl);
    3127      4681959 :           DECL_INITIAL (newdecl) = DECL_INITIAL (olddecl);
    3128      4681959 :           DECL_STRUCT_FUNCTION (newdecl) = DECL_STRUCT_FUNCTION (olddecl);
    3129      4681959 :           DECL_SAVED_TREE (newdecl) = DECL_SAVED_TREE (olddecl);
    3130      4681959 :           DECL_ARGUMENTS (newdecl) = copy_list (DECL_ARGUMENTS (olddecl));
    3131      7344633 :           for (t = DECL_ARGUMENTS (newdecl); t ; t = DECL_CHAIN (t))
    3132      2662674 :             DECL_CONTEXT (t) = newdecl;
    3133              : 
    3134              :           /* See if we've got a function to instantiate from.  */
    3135      4681959 :           if (DECL_SAVED_TREE (olddecl))
    3136         1620 :             DECL_ABSTRACT_ORIGIN (newdecl)
    3137          810 :               = DECL_ABSTRACT_ORIGIN (olddecl);
    3138              :         }
    3139              :     }
    3140              : 
    3141              :   /* Merge the USED information.  */
    3142      4978955 :   if (TREE_USED (olddecl))
    3143       717000 :     TREE_USED (newdecl) = 1;
    3144      4261955 :   else if (TREE_USED (newdecl))
    3145            4 :     TREE_USED (olddecl) = 1;
    3146      4978955 :   if (VAR_P (olddecl) || TREE_CODE (olddecl) == PARM_DECL)
    3147        18620 :     DECL_READ_P (newdecl) |= DECL_READ_P (olddecl);
    3148      4978955 :   if (DECL_PRESERVE_P (olddecl))
    3149           25 :     DECL_PRESERVE_P (newdecl) = 1;
    3150      4978930 :   else if (DECL_PRESERVE_P (newdecl))
    3151            4 :     DECL_PRESERVE_P (olddecl) = 1;
    3152              : 
    3153              :   /* Merge DECL_COMMON */
    3154        18585 :   if (VAR_P (olddecl) && VAR_P (newdecl)
    3155        18585 :       && !lookup_attribute ("common", DECL_ATTRIBUTES (newdecl))
    3156      4997538 :       && !lookup_attribute ("nocommon", DECL_ATTRIBUTES (newdecl)))
    3157        37162 :     DECL_COMMON (newdecl) = DECL_COMMON (newdecl) && DECL_COMMON (olddecl);
    3158              : 
    3159              :   /* Copy most of the decl-specific fields of NEWDECL into OLDDECL.
    3160              :      But preserve OLDDECL's DECL_UID, DECL_CONTEXT and
    3161              :      DECL_ARGUMENTS (if appropriate).  */
    3162      4978955 :   {
    3163      4978955 :     unsigned olddecl_uid = DECL_UID (olddecl);
    3164      4978955 :     tree olddecl_context = DECL_CONTEXT (olddecl);
    3165      4978955 :     tree olddecl_arguments = NULL;
    3166      4978955 :     if (TREE_CODE (olddecl) == FUNCTION_DECL)
    3167      4914477 :       olddecl_arguments = DECL_ARGUMENTS (olddecl);
    3168              : 
    3169      4978955 :     memcpy ((char *) olddecl + sizeof (struct tree_common),
    3170              :             (char *) newdecl + sizeof (struct tree_common),
    3171              :             sizeof (struct tree_decl_common) - sizeof (struct tree_common));
    3172      4978955 :     DECL_USER_ALIGN (olddecl) = DECL_USER_ALIGN (newdecl);
    3173      4978955 :     switch (TREE_CODE (olddecl))
    3174              :       {
    3175      4933062 :       case FUNCTION_DECL:
    3176      4933062 :       case VAR_DECL:
    3177      4933062 :         {
    3178      4933062 :           struct symtab_node *snode = olddecl->decl_with_vis.symtab_node;
    3179              : 
    3180      9866124 :           memcpy ((char *) olddecl + sizeof (struct tree_decl_common),
    3181              :                   (char *) newdecl + sizeof (struct tree_decl_common),
    3182      4933062 :                   tree_code_size (TREE_CODE (olddecl)) - sizeof (struct tree_decl_common));
    3183      4933062 :           olddecl->decl_with_vis.symtab_node = snode;
    3184              : 
    3185      4933062 :           if ((DECL_EXTERNAL (olddecl)
    3186        46899 :                || TREE_PUBLIC (olddecl)
    3187         8005 :                || TREE_STATIC (olddecl))
    3188      4979954 :               && DECL_SECTION_NAME (newdecl) != NULL)
    3189            8 :             set_decl_section_name (olddecl, newdecl);
    3190              : 
    3191              :           /* This isn't quite correct for something like
    3192              :                 int __thread x attribute ((tls_model ("local-exec")));
    3193              :                 extern int __thread x;
    3194              :              as we'll lose the "local-exec" model.  */
    3195      4933062 :           if (VAR_P (olddecl) && DECL_THREAD_LOCAL_P (newdecl))
    3196           89 :             set_decl_tls_model (olddecl, DECL_TLS_MODEL (newdecl));
    3197              :           break;
    3198              :         }
    3199              : 
    3200        45893 :       case FIELD_DECL:
    3201        45893 :       case PARM_DECL:
    3202        45893 :       case LABEL_DECL:
    3203        45893 :       case RESULT_DECL:
    3204        45893 :       case CONST_DECL:
    3205        45893 :       case TYPE_DECL:
    3206        91786 :         memcpy ((char *) olddecl + sizeof (struct tree_decl_common),
    3207              :                 (char *) newdecl + sizeof (struct tree_decl_common),
    3208        45893 :                 tree_code_size (TREE_CODE (olddecl)) - sizeof (struct tree_decl_common));
    3209        45893 :         break;
    3210              : 
    3211            0 :       default:
    3212              : 
    3213            0 :         memcpy ((char *) olddecl + sizeof (struct tree_decl_common),
    3214              :                 (char *) newdecl + sizeof (struct tree_decl_common),
    3215              :                 sizeof (struct tree_decl_non_common) - sizeof (struct tree_decl_common));
    3216              :       }
    3217      4978955 :     DECL_UID (olddecl) = olddecl_uid;
    3218      4978955 :     DECL_CONTEXT (olddecl) = olddecl_context;
    3219      4978955 :     if (TREE_CODE (olddecl) == FUNCTION_DECL)
    3220      4914477 :       DECL_ARGUMENTS (olddecl) = olddecl_arguments;
    3221              :   }
    3222              : 
    3223              :   /* If OLDDECL had its DECL_RTL instantiated, re-invoke make_decl_rtl
    3224              :      so that encode_section_info has a chance to look at the new decl
    3225              :      flags and attributes.  */
    3226      4978955 :   if (DECL_RTL_SET_P (olddecl)
    3227      4978961 :       && (TREE_CODE (olddecl) == FUNCTION_DECL
    3228            6 :           || (VAR_P (olddecl) && TREE_STATIC (olddecl))))
    3229            6 :     make_decl_rtl (olddecl);
    3230      4978955 : }
    3231              : 
    3232              : /* Handle when a new declaration NEWDECL has the same name as an old
    3233              :    one OLDDECL in the same binding contour.  Prints an error message
    3234              :    if appropriate.
    3235              : 
    3236              :    If safely possible, alter OLDDECL to look like NEWDECL, and return
    3237              :    true.  Otherwise, return false.  */
    3238              : 
    3239              : static bool
    3240      4980059 : duplicate_decls (tree newdecl, tree olddecl)
    3241              : {
    3242      4980059 :   tree newtype = NULL, oldtype = NULL;
    3243              : 
    3244      4980059 :   if (!diagnose_mismatched_decls (newdecl, olddecl, &newtype, &oldtype))
    3245              :     {
    3246              :       /* Avoid `unused variable' and other warnings for OLDDECL.  */
    3247         1104 :       suppress_warning (olddecl, OPT_Wunused);
    3248              :       /* If the types are completely different, poison them both with
    3249              :          error_mark_node.  */
    3250         1104 :       if (TREE_CODE (TREE_TYPE (newdecl)) != TREE_CODE (TREE_TYPE (olddecl))
    3251          118 :           && olddecl != error_mark_node
    3252         1202 :           && seen_error ())
    3253              :         {
    3254           65 :           if (TREE_CODE (olddecl) != FUNCTION_DECL)
    3255           53 :             TREE_TYPE (olddecl) = error_mark_node;
    3256           65 :           if (TREE_CODE (newdecl) != FUNCTION_DECL)
    3257           61 :             TREE_TYPE (newdecl) = error_mark_node;
    3258              :         }
    3259         1104 :       return false;
    3260              :     }
    3261              : 
    3262      4978955 :   merge_decls (newdecl, olddecl, newtype, oldtype);
    3263              : 
    3264              :   /* The NEWDECL will no longer be needed.
    3265              : 
    3266              :      Before releasing the node, be sure to remove function from symbol
    3267              :      table that might have been inserted there to record comdat group.
    3268              :      Be sure to however do not free DECL_STRUCT_FUNCTION because this
    3269              :      structure is shared in between NEWDECL and OLDECL.  */
    3270      4978955 :   if (TREE_CODE (newdecl) == FUNCTION_DECL)
    3271      4914477 :     DECL_STRUCT_FUNCTION (newdecl) = NULL;
    3272      4978955 :   if (VAR_OR_FUNCTION_DECL_P (newdecl))
    3273              :     {
    3274      4933062 :       struct symtab_node *snode = symtab_node::get (newdecl);
    3275      4933062 :       if (snode)
    3276          104 :         snode->remove ();
    3277              :     }
    3278      4978955 :   ggc_free (newdecl);
    3279      4978955 :   return true;
    3280              : }
    3281              : 
    3282              : 
    3283              : /* Check whether decl-node NEW_DECL shadows an existing declaration.  */
    3284              : static void
    3285    170513515 : warn_if_shadowing (tree new_decl)
    3286              : {
    3287    170513515 :   struct c_binding *b;
    3288              : 
    3289              :   /* Shadow warnings wanted?  */
    3290    341026114 :   if (!(warn_shadow
    3291    170512779 :         || warn_shadow_local
    3292    170512599 :         || warn_shadow_compatible_local)
    3293              :       /* No shadow warnings for internally generated vars.  */
    3294    170513758 :       || DECL_IS_UNDECLARED_BUILTIN (new_decl))
    3295              :     return;
    3296              : 
    3297              :   /* Is anything being shadowed?  Invisible decls do not count.  */
    3298          253 :   for (b = I_SYMBOL_BINDING (DECL_NAME (new_decl)); b; b = b->shadowed)
    3299          157 :     if (b->decl && b->decl != new_decl && !b->invisible
    3300          214 :         && (b->decl == error_mark_node
    3301           43 :             || diagnostic_report_warnings_p (global_dc,
    3302              :                                              DECL_SOURCE_LOCATION (b->decl))))
    3303              :       {
    3304           57 :         tree old_decl = b->decl;
    3305              : 
    3306           57 :         if (old_decl == error_mark_node)
    3307              :           {
    3308           14 :             warning (OPT_Wshadow, "declaration of %q+D shadows previous "
    3309              :                      "non-variable", new_decl);
    3310           50 :             break;
    3311              :           }
    3312              : 
    3313           43 :         bool warned = false;
    3314           43 :         auto_diagnostic_group d;
    3315           43 :         if (TREE_CODE (old_decl) == PARM_DECL)
    3316              :           {
    3317            5 :             enum opt_code warning_code;
    3318              : 
    3319              :             /* If '-Wshadow=compatible-local' is specified without other
    3320              :                -Wshadow= flags, we will warn only when the types of the
    3321              :                shadowing variable (i.e. new_decl) and the shadowed variable
    3322              :                (old_decl) are compatible.  */
    3323            5 :             if (warn_shadow)
    3324              :               warning_code = OPT_Wshadow;
    3325            2 :             else if (comptypes (TREE_TYPE (old_decl), TREE_TYPE (new_decl)))
    3326              :               warning_code = OPT_Wshadow_compatible_local;
    3327              :             else
    3328            2 :               warning_code = OPT_Wshadow_local;
    3329            5 :             warned = warning_at (DECL_SOURCE_LOCATION (new_decl), warning_code,
    3330              :                                  "declaration of %qD shadows a parameter",
    3331              :                                  new_decl);
    3332              :           }
    3333           38 :         else if (DECL_FILE_SCOPE_P (old_decl))
    3334              :           {
    3335              :             /* Do not warn if a variable shadows a function, unless
    3336              :                the variable is a function or a pointer-to-function.  */
    3337           34 :             if (TREE_CODE (old_decl) == FUNCTION_DECL
    3338           11 :                 && TREE_CODE (new_decl) != FUNCTION_DECL
    3339           36 :                 && !FUNCTION_POINTER_TYPE_P (TREE_TYPE (new_decl)))
    3340            7 :                 continue;
    3341              : 
    3342           20 :             warned = warning_at (DECL_SOURCE_LOCATION (new_decl), OPT_Wshadow,
    3343              :                                  "declaration of %qD shadows a global "
    3344              :                                  "declaration",
    3345              :                                  new_decl);
    3346              :           }
    3347           11 :         else if (TREE_CODE (old_decl) == FUNCTION_DECL
    3348           11 :                  && fndecl_built_in_p (old_decl))
    3349              :           {
    3350            0 :             warning (OPT_Wshadow, "declaration of %q+D shadows "
    3351              :                      "a built-in function", new_decl);
    3352            0 :             break;
    3353              :           }
    3354              :         else
    3355              :           {
    3356           11 :             enum opt_code warning_code;
    3357              : 
    3358              :             /* If '-Wshadow=compatible-local' is specified without other
    3359              :                -Wshadow= flags, we will warn only when the types of the
    3360              :                shadowing variable (i.e. new_decl) and the shadowed variable
    3361              :                (old_decl) are compatible.  */
    3362           11 :             if (warn_shadow)
    3363              :               warning_code = OPT_Wshadow;
    3364            8 :             else if (comptypes (TREE_TYPE (old_decl), TREE_TYPE (new_decl)))
    3365              :               warning_code = OPT_Wshadow_compatible_local;
    3366              :             else
    3367            2 :               warning_code = OPT_Wshadow_local;
    3368           11 :             warned = warning_at (DECL_SOURCE_LOCATION (new_decl), warning_code,
    3369              :                                  "declaration of %qD shadows a previous local",
    3370              :                                  new_decl);
    3371              :           }
    3372              : 
    3373           36 :         if (warned)
    3374           26 :           inform (DECL_SOURCE_LOCATION (old_decl),
    3375              :                   "shadowed declaration is here");
    3376              : 
    3377              :         break;
    3378           43 :       }
    3379              : }
    3380              : 
    3381              : /* Record a decl-node X as belonging to the current lexical scope.
    3382              :    Check for errors (such as an incompatible declaration for the same
    3383              :    name already seen in the same scope).
    3384              : 
    3385              :    Returns either X or an old decl for the same name.
    3386              :    If an old decl is returned, it may have been smashed
    3387              :    to agree with what X says.  */
    3388              : 
    3389              : tree
    3390    202782166 : pushdecl (tree x)
    3391              : {
    3392    202782166 :   tree name = DECL_NAME (x);
    3393    202782166 :   struct c_scope *scope = current_scope;
    3394    202782166 :   struct c_binding *b;
    3395    202782166 :   bool nested = false;
    3396    202782166 :   location_t locus = DECL_SOURCE_LOCATION (x);
    3397              : 
    3398              :   /* Must set DECL_CONTEXT for everything not at file scope or
    3399              :      DECL_FILE_SCOPE_P won't work.  Local externs don't count
    3400              :      unless they have initializers (which generate code).  We
    3401              :      also exclude CONST_DECLs because enumerators will get the
    3402              :      type of the enum as context.  */
    3403    202782166 :   if (current_function_decl
    3404      9141686 :       && TREE_CODE (x) != CONST_DECL
    3405    211766719 :       && (!VAR_OR_FUNCTION_DECL_P (x)
    3406      8706339 :           || DECL_INITIAL (x) || !TREE_PUBLIC (x)))
    3407      8972525 :     DECL_CONTEXT (x) = current_function_decl;
    3408              : 
    3409              :   /* Anonymous decls are just inserted in the scope.  */
    3410    202782166 :   if (!name)
    3411              :     {
    3412      7834964 :       bind (name, x, scope, /*invisible=*/false, /*nested=*/false,
    3413              :             locus);
    3414      7834964 :       return x;
    3415              :     }
    3416              : 
    3417              :   /* First, see if there is another declaration with the same name in
    3418              :      the current scope.  If there is, duplicate_decls may do all the
    3419              :      work for us.  If duplicate_decls returns false, that indicates
    3420              :      two incompatible decls in the same scope; we are to silently
    3421              :      replace the old one (duplicate_decls has issued all appropriate
    3422              :      diagnostics).  In particular, we should not consider possible
    3423              :      duplicates in the external scope, or shadowing.  */
    3424    194947202 :   b = I_SYMBOL_BINDING (name);
    3425    194947202 :   if (b && B_IN_SCOPE (b, scope))
    3426              :     {
    3427      1389035 :       struct c_binding *b_ext, *b_use;
    3428      1389035 :       tree type = TREE_TYPE (x);
    3429      1389035 :       tree visdecl = b->decl;
    3430      1389035 :       tree vistype = TREE_TYPE (visdecl);
    3431      1389035 :       if (TREE_CODE (TREE_TYPE (x)) == ARRAY_TYPE
    3432      1389035 :           && COMPLETE_TYPE_P (TREE_TYPE (x)))
    3433         1370 :         b->inner_comp = false;
    3434      1389035 :       b_use = b;
    3435      1389035 :       b_ext = b;
    3436              :       /* If this is an external linkage declaration, we should check
    3437              :          for compatibility with the type in the external scope before
    3438              :          setting the type at this scope based on the visible
    3439              :          information only.  */
    3440      1389035 :       if (TREE_PUBLIC (x) && TREE_PUBLIC (visdecl))
    3441              :         {
    3442      2670074 :           while (b_ext && !B_IN_EXTERNAL_SCOPE (b_ext))
    3443      1335047 :             b_ext = b_ext->shadowed;
    3444      1335027 :           if (b_ext)
    3445              :             {
    3446      1335026 :               b_use = b_ext;
    3447      1335026 :               if (b_use->u.type)
    3448       270396 :                 TREE_TYPE (b_use->decl) = b_use->u.type;
    3449              :             }
    3450              :         }
    3451              : 
    3452              :       /* Check if x is part of a FMV set with b_use.
    3453              :          FMV is only supported in c for targets with target_version
    3454              :          attributes.  */
    3455      1389035 :       if (!TARGET_HAS_FMV_TARGET_ATTRIBUTE
    3456              :           && b_use && TREE_CODE (b_use->decl) == FUNCTION_DECL
    3457              :           && TREE_CODE (x) == FUNCTION_DECL && DECL_FILE_SCOPE_P (b_use->decl)
    3458              :           && DECL_FILE_SCOPE_P (x)
    3459              :           && disjoint_version_decls (x, b_use->decl)
    3460              :           && comptypes (vistype, type) != 0)
    3461              :         {
    3462              :           maybe_mark_function_versioned (b_use->decl);
    3463              :           maybe_mark_function_versioned (b->decl);
    3464              :           maybe_mark_function_versioned (x);
    3465              : 
    3466              :           cgraph_node *b_node = cgraph_node::get_create (b_use->decl);
    3467              :           cgraph_function_version_info *b_v = b_node->function_version ();
    3468              :           if (!b_v)
    3469              :             b_v = b_node->insert_new_function_version ();
    3470              : 
    3471              :           /* Check if this new node conflicts with any previous functions
    3472              :              in the set.  */
    3473              :           cgraph_function_version_info *version = b_v;
    3474              :           for (; version; version = version->next)
    3475              :             if (!disjoint_version_decls (version->this_node->decl, x))
    3476              :               {
    3477              :                 /* The decls define overlapping version, so attempt to merge
    3478              :                    or diagnose the conflict.  */
    3479              :                 if (duplicate_decls (x, version->this_node->decl))
    3480              :                   return version->this_node->decl;
    3481              :                 else
    3482              :                   return error_mark_node;
    3483              :               }
    3484              : 
    3485              :           /* This is a new version to be added to FMV structure.  */
    3486              :           cgraph_node::add_function_version (b_v, x);
    3487              : 
    3488              :           /* Get the first node from the structure.  */
    3489              :           cgraph_function_version_info *default_v = b_v;
    3490              :           while (default_v->prev)
    3491              :             default_v = default_v->prev;
    3492              :           /* Always use the default node for the bindings.  */
    3493              :           b_use->decl = default_v->this_node->decl;
    3494              :           b->decl = default_v->this_node->decl;
    3495              : 
    3496              :           /* Node is not a duplicate, so no need to do the rest of the
    3497              :              checks.  */
    3498              :           return x;
    3499              :         }
    3500              : 
    3501      1389035 :       if (duplicate_decls (x, b_use->decl))
    3502              :         {
    3503      1388665 :           if (b_use != b)
    3504              :             {
    3505              :               /* Save the updated type in the external scope and
    3506              :                  restore the proper type for this scope.  */
    3507      1334820 :               tree thistype;
    3508      1334820 :               if (comptypes (vistype, type))
    3509      1334778 :                 thistype = composite_type (vistype, type);
    3510              :               else
    3511           42 :                 thistype = TREE_TYPE (b_use->decl);
    3512      1334820 :               b_use->u.type = TREE_TYPE (b_use->decl);
    3513      1334820 :               if (TREE_CODE (b_use->decl) == FUNCTION_DECL
    3514      1334820 :                   && fndecl_built_in_p (b_use->decl))
    3515       280366 :                 thistype
    3516       280366 :                   = c_build_type_attribute_variant (thistype,
    3517       280366 :                                                     TYPE_ATTRIBUTES
    3518              :                                                     (b_use->u.type));
    3519      1334820 :               TREE_TYPE (b_use->decl) = thistype;
    3520              :             }
    3521      1388665 :           return b_use->decl;
    3522              :         }
    3523              :       else
    3524          370 :         goto skip_external_and_shadow_checks;
    3525              :     }
    3526              : 
    3527              :   /* All declarations with external linkage, and all external
    3528              :      references, go in the external scope, no matter what scope is
    3529              :      current.  However, the binding in that scope is ignored for
    3530              :      purposes of normal name lookup.  A separate binding structure is
    3531              :      created in the requested scope; this governs the normal
    3532              :      visibility of the symbol.
    3533              : 
    3534              :      The binding in the externals scope is used exclusively for
    3535              :      detecting duplicate declarations of the same object, no matter
    3536              :      what scope they are in; this is what we do here.  (C99 6.2.7p2:
    3537              :      All declarations that refer to the same object or function shall
    3538              :      have compatible type; otherwise, the behavior is undefined.)
    3539              :      However, in Objective-C, we also want to detect declarations
    3540              :      conflicting with those of the basic types.  */
    3541    338087146 :   if ((DECL_EXTERNAL (x) || scope == file_scope)
    3542    205061085 :       && (VAR_OR_FUNCTION_DECL_P (x) || c_dialect_objc ()))
    3543              :     {
    3544     50819975 :       tree type = TREE_TYPE (x);
    3545     50819975 :       tree vistype = NULL_TREE;
    3546     50819975 :       tree visdecl = NULL_TREE;
    3547     50819975 :       bool type_saved = false;
    3548      3591051 :       if (b && !B_IN_EXTERNAL_SCOPE (b)
    3549         1038 :           && VAR_OR_FUNCTION_DECL_P (b->decl)
    3550     50821004 :           && DECL_FILE_SCOPE_P (b->decl))
    3551              :         {
    3552          803 :           visdecl = b->decl;
    3553          803 :           vistype = TREE_TYPE (visdecl);
    3554              :         }
    3555     50819975 :       if (scope != file_scope
    3556     50819975 :           && !DECL_IN_SYSTEM_HEADER (x))
    3557        11495 :         warning_at (locus, OPT_Wnested_externs,
    3558              :                     "nested extern declaration of %qD", x);
    3559              : 
    3560     50821399 :       while (b && !B_IN_EXTERNAL_SCOPE (b))
    3561              :         {
    3562              :           /* If this decl might be modified, save its type.  This is
    3563              :              done here rather than when the decl is first bound
    3564              :              because the type may change after first binding, through
    3565              :              being completed or through attributes being added.  If we
    3566              :              encounter multiple such decls, only the first should have
    3567              :              its type saved; the others will already have had their
    3568              :              proper types saved and the types will not have changed as
    3569              :              their scopes will not have been re-entered.  */
    3570         1424 :           if (DECL_P (b->decl) && DECL_FILE_SCOPE_P (b->decl) && !type_saved)
    3571              :             {
    3572         1022 :               b->u.type = TREE_TYPE (b->decl);
    3573         1022 :               type_saved = true;
    3574              :             }
    3575         1424 :           if (B_IN_FILE_SCOPE (b)
    3576         1012 :               && VAR_P (b->decl)
    3577          572 :               && TREE_STATIC (b->decl)
    3578          281 :               && TREE_CODE (TREE_TYPE (b->decl)) == ARRAY_TYPE
    3579          138 :               && !TYPE_DOMAIN (TREE_TYPE (b->decl))
    3580           47 :               && TREE_CODE (type) == ARRAY_TYPE
    3581           47 :               && TYPE_DOMAIN (type)
    3582           28 :               && TYPE_MAX_VALUE (TYPE_DOMAIN (type))
    3583         1452 :               && !integer_zerop (TYPE_MAX_VALUE (TYPE_DOMAIN (type))))
    3584              :             {
    3585              :               /* Array type completed in inner scope, which should be
    3586              :                  diagnosed if the completion does not have size 1 and
    3587              :                  it does not get completed in the file scope.  */
    3588            6 :               b->inner_comp = true;
    3589              :             }
    3590         1424 :           b = b->shadowed;
    3591              :         }
    3592              : 
    3593              :       /* If a matching external declaration has been found, set its
    3594              :          type to the composite of all the types of that declaration.
    3595              :          After the consistency checks, it will be reset to the
    3596              :          composite of the visible types only.  */
    3597     50819975 :       if (b && b->u.type)
    3598          768 :         TREE_TYPE (b->decl) = b->u.type;
    3599              : 
    3600              :       /* the static does not go in the externals scope.  */
    3601      3590907 :       if (b && duplicate_decls (x, b->decl))
    3602              :         {
    3603      3590173 :           tree thistype;
    3604      3590173 :           if (vistype)
    3605              :             {
    3606          675 :               if (comptypes (vistype, type))
    3607          638 :                 thistype = composite_type (vistype, type);
    3608              :               else
    3609           37 :                 thistype = TREE_TYPE (b->decl);
    3610              :             }
    3611              :           else
    3612              :             thistype = type;
    3613      3590173 :           b->u.type = TREE_TYPE (b->decl);
    3614              :           /* Propagate the type attributes to the decl.  */
    3615      3590173 :           thistype
    3616      3590173 :             = c_build_type_attribute_variant (thistype,
    3617      3590173 :                                               TYPE_ATTRIBUTES (b->u.type));
    3618      3590173 :           TREE_TYPE (b->decl) = thistype;
    3619      3590173 :           bind (name, b->decl, scope, /*invisible=*/false, /*nested=*/true,
    3620              :                 locus);
    3621      3590173 :           return b->decl;
    3622              :         }
    3623     47229802 :       else if (TREE_PUBLIC (x))
    3624              :         {
    3625     46856095 :           if (visdecl && !b && duplicate_decls (x, visdecl))
    3626              :             {
    3627              :               /* An external declaration at block scope referring to a
    3628              :                  visible entity with internal linkage.  The composite
    3629              :                  type will already be correct for this scope, so we
    3630              :                  just need to fall through to make the declaration in
    3631              :                  this scope.  */
    3632              :               nested = true;
    3633              :               x = visdecl;
    3634              :             }
    3635              :           else
    3636              :             {
    3637     46855978 :               bind (name, x, external_scope, /*invisible=*/true,
    3638              :                     /*nested=*/false, locus);
    3639     46855978 :               nested = true;
    3640              :             }
    3641              :         }
    3642              :     }
    3643              : 
    3644    189967994 :   if (TREE_CODE (x) != PARM_DECL)
    3645     70432229 :     warn_if_shadowing (x);
    3646              : 
    3647    119535765 :  skip_external_and_shadow_checks:
    3648    189968364 :   if (TREE_CODE (x) == TYPE_DECL)
    3649              :     {
    3650              :       /* So this is a typedef, set its underlying type.  */
    3651      9705836 :       set_underlying_type (x);
    3652              : 
    3653              :       /* If X is a typedef defined in the current function, record it
    3654              :          for the purpose of implementing the -Wunused-local-typedefs
    3655              :          warning.  */
    3656      9705836 :       record_locally_defined_typedef (x);
    3657              :     }
    3658              : 
    3659    189968364 :   bind (name, x, scope, /*invisible=*/false, nested, locus);
    3660              : 
    3661              :   /* If x's type is incomplete because it's based on a
    3662              :      structure or union which has not yet been fully declared,
    3663              :      attach it to that structure or union type, so we can go
    3664              :      back and complete the variable declaration later, if the
    3665              :      structure or union gets fully declared.
    3666              : 
    3667              :      If the input is erroneous, we can have error_mark in the type
    3668              :      slot (e.g. "f(void a, ...)") - that doesn't count as an
    3669              :      incomplete type.  */
    3670    189968364 :   if (TREE_TYPE (x) != error_mark_node
    3671    189968364 :       && !COMPLETE_TYPE_P (TREE_TYPE (x)))
    3672              :     {
    3673       183899 :       tree element = TREE_TYPE (x);
    3674              : 
    3675       203972 :       while (TREE_CODE (element) == ARRAY_TYPE)
    3676        20073 :         element = TREE_TYPE (element);
    3677       183899 :       element = TYPE_MAIN_VARIANT (element);
    3678              : 
    3679       183899 :       if ((RECORD_OR_UNION_TYPE_P (element)
    3680       140012 :            || TREE_CODE (element) == ENUMERAL_TYPE)
    3681        43958 :           && (TREE_CODE (x) != TYPE_DECL
    3682        40508 :               || TREE_CODE (TREE_TYPE (x)) == ARRAY_TYPE)
    3683       187359 :           && !COMPLETE_TYPE_P (element))
    3684          321 :         C_TYPE_INCOMPLETE_VARS (element)
    3685          642 :           = tree_cons (NULL_TREE, x, C_TYPE_INCOMPLETE_VARS (element));
    3686              :     }
    3687              :   return x;
    3688              : }
    3689              : 
    3690              : 
    3691              : /* Issue a permerror about implicit function declaration.  ID is the function
    3692              :    identifier, OLDDECL is a declaration of the function in a different scope,
    3693              :    or NULL_TREE.  */
    3694              : 
    3695              : static void
    3696         3776 : implicit_decl_permerror (location_t loc, tree id, tree olddecl)
    3697              : {
    3698         3776 :   if (!warn_implicit_function_declaration)
    3699         2617 :     return;
    3700              : 
    3701         1159 :   bool warned;
    3702         1159 :   auto_diagnostic_group d;
    3703         1159 :   name_hint hint;
    3704         1159 :   if (!olddecl)
    3705          553 :     hint = lookup_name_fuzzy (id, FUZZY_LOOKUP_FUNCTION_NAME, loc);
    3706              : 
    3707         1159 :   if (flag_isoc99)
    3708              :     {
    3709         1153 :       if (const char *suggestion = hint.suggestion ())
    3710              :         {
    3711          107 :           gcc_rich_location richloc (loc);
    3712          107 :           richloc.add_fixit_replace (suggestion);
    3713          107 :           warned = permerror_opt (&richloc, OPT_Wimplicit_function_declaration,
    3714              :                                   "implicit declaration of function %qE;"
    3715              :                                   " did you mean %qs?",
    3716              :                                   id, suggestion);
    3717          107 :         }
    3718              :       else
    3719         1046 :         warned = permerror_opt (loc, OPT_Wimplicit_function_declaration,
    3720              :                                 "implicit declaration of function %qE", id);
    3721              :     }
    3722            6 :   else if (const char *suggestion = hint.suggestion ())
    3723              :     {
    3724            2 :       gcc_rich_location richloc (loc);
    3725            2 :       richloc.add_fixit_replace (suggestion);
    3726            2 :       warned = warning_at
    3727            2 :         (&richloc, OPT_Wimplicit_function_declaration,
    3728              :          G_("implicit declaration of function %qE; did you mean %qs?"),
    3729              :          id, suggestion);
    3730            2 :     }
    3731              :   else
    3732            4 :     warned = warning_at (loc, OPT_Wimplicit_function_declaration,
    3733              :                          G_("implicit declaration of function %qE"), id);
    3734              : 
    3735         1159 :   if (warned)
    3736              :     {
    3737              :       /* Whether the olddecl is an undeclared builtin function.
    3738              :          locate_old_decl will not generate a diagnostic for those,
    3739              :          so in that case we want to look elsewhere.  */
    3740           90 :       bool undeclared_builtin = (olddecl
    3741           28 :                                  && TREE_CODE (olddecl) == FUNCTION_DECL
    3742           28 :                                  && fndecl_built_in_p (olddecl)
    3743          117 :                                  && !C_DECL_DECLARED_BUILTIN (olddecl));
    3744           90 :       if (undeclared_builtin)
    3745              :         {
    3746           27 :           const char *header = header_for_builtin_fn (olddecl);
    3747           27 :           if (header)
    3748              :             {
    3749           20 :               rich_location richloc (line_table, loc);
    3750           20 :               maybe_add_include_fixit (&richloc, header, true);
    3751           20 :               inform (&richloc,
    3752              :                       "include %qs or provide a declaration of %qE",
    3753              :                       header, id);
    3754           20 :             }
    3755              :         }
    3756           63 :       else if (olddecl)
    3757            1 :         locate_old_decl (olddecl);
    3758              :     }
    3759              : 
    3760         1069 :   if (!warned)
    3761         1159 :     hint.suppress ();
    3762         1159 : }
    3763              : 
    3764              : /* Return the name of the header file that declares built-in function
    3765              :    FNDECL, or null if either we don't know or don't expect to see an
    3766              :    explicit declaration.  */
    3767              : 
    3768              : static const char *
    3769         3177 : header_for_builtin_fn (tree fndecl)
    3770              : {
    3771         3177 :   if (DECL_BUILT_IN_CLASS (fndecl) != BUILT_IN_NORMAL)
    3772              :     return NULL;
    3773              : 
    3774         3177 :   switch (DECL_FUNCTION_CODE (fndecl))
    3775              :     {
    3776              :     CASE_FLT_FN (BUILT_IN_ACOS):
    3777              :     CASE_FLT_FN (BUILT_IN_ACOSH):
    3778              :     CASE_FLT_FN (BUILT_IN_ASIN):
    3779              :     CASE_FLT_FN (BUILT_IN_ASINH):
    3780              :     CASE_FLT_FN (BUILT_IN_ATAN):
    3781              :     CASE_FLT_FN (BUILT_IN_ATANH):
    3782              :     CASE_FLT_FN (BUILT_IN_ATAN2):
    3783              :     CASE_FLT_FN (BUILT_IN_CBRT):
    3784              :     CASE_FLT_FN (BUILT_IN_CEIL):
    3785              :     CASE_FLT_FN_FLOATN_NX (BUILT_IN_CEIL):
    3786              :     CASE_FLT_FN (BUILT_IN_COPYSIGN):
    3787              :     CASE_FLT_FN_FLOATN_NX (BUILT_IN_COPYSIGN):
    3788              :     CASE_FLT_FN (BUILT_IN_COS):
    3789              :     CASE_FLT_FN (BUILT_IN_COSH):
    3790              :     CASE_FLT_FN (BUILT_IN_ERF):
    3791              :     CASE_FLT_FN (BUILT_IN_ERFC):
    3792              :     CASE_FLT_FN (BUILT_IN_EXP):
    3793              :     CASE_FLT_FN (BUILT_IN_EXP2):
    3794              :     CASE_FLT_FN (BUILT_IN_EXPM1):
    3795              :     CASE_FLT_FN (BUILT_IN_FABS):
    3796              :     CASE_FLT_FN_FLOATN_NX (BUILT_IN_FABS):
    3797              :     CASE_FLT_FN (BUILT_IN_FDIM):
    3798              :     CASE_FLT_FN (BUILT_IN_FLOOR):
    3799              :     CASE_FLT_FN_FLOATN_NX (BUILT_IN_FLOOR):
    3800              :     CASE_FLT_FN (BUILT_IN_FMA):
    3801              :     CASE_FLT_FN_FLOATN_NX (BUILT_IN_FMA):
    3802              :     CASE_FLT_FN (BUILT_IN_FMAX):
    3803              :     CASE_FLT_FN_FLOATN_NX (BUILT_IN_FMAX):
    3804              :     CASE_FLT_FN (BUILT_IN_FMIN):
    3805              :     CASE_FLT_FN_FLOATN_NX (BUILT_IN_FMIN):
    3806              :     CASE_FLT_FN (BUILT_IN_FMOD):
    3807              :     CASE_FLT_FN (BUILT_IN_FREXP):
    3808              :     CASE_FLT_FN (BUILT_IN_HYPOT):
    3809              :     CASE_FLT_FN (BUILT_IN_ILOGB):
    3810              :     CASE_FLT_FN (BUILT_IN_LDEXP):
    3811              :     CASE_FLT_FN (BUILT_IN_LGAMMA):
    3812              :     CASE_FLT_FN (BUILT_IN_LLRINT):
    3813              :     CASE_FLT_FN (BUILT_IN_LLROUND):
    3814              :     CASE_FLT_FN (BUILT_IN_LOG):
    3815              :     CASE_FLT_FN (BUILT_IN_LOG10):
    3816              :     CASE_FLT_FN (BUILT_IN_LOG1P):
    3817              :     CASE_FLT_FN (BUILT_IN_LOG2):
    3818              :     CASE_FLT_FN (BUILT_IN_LOGB):
    3819              :     CASE_FLT_FN (BUILT_IN_LRINT):
    3820              :     CASE_FLT_FN (BUILT_IN_LROUND):
    3821              :     CASE_FLT_FN (BUILT_IN_MODF):
    3822              :     CASE_FLT_FN (BUILT_IN_NAN):
    3823              :     CASE_FLT_FN (BUILT_IN_NEARBYINT):
    3824              :     CASE_FLT_FN_FLOATN_NX (BUILT_IN_NEARBYINT):
    3825              :     CASE_FLT_FN (BUILT_IN_NEXTAFTER):
    3826              :     CASE_FLT_FN (BUILT_IN_NEXTTOWARD):
    3827              :     CASE_FLT_FN (BUILT_IN_POW):
    3828              :     CASE_FLT_FN (BUILT_IN_REMAINDER):
    3829              :     CASE_FLT_FN (BUILT_IN_REMQUO):
    3830              :     CASE_FLT_FN (BUILT_IN_RINT):
    3831              :     CASE_FLT_FN_FLOATN_NX (BUILT_IN_RINT):
    3832              :     CASE_FLT_FN (BUILT_IN_ROUND):
    3833              :     CASE_FLT_FN_FLOATN_NX (BUILT_IN_ROUND):
    3834              :     CASE_FLT_FN (BUILT_IN_SCALBLN):
    3835              :     CASE_FLT_FN (BUILT_IN_SCALBN):
    3836              :     CASE_FLT_FN (BUILT_IN_SIN):
    3837              :     CASE_FLT_FN (BUILT_IN_SINH):
    3838              :     CASE_FLT_FN (BUILT_IN_SINCOS):
    3839              :     CASE_FLT_FN (BUILT_IN_SQRT):
    3840              :     CASE_FLT_FN_FLOATN_NX (BUILT_IN_SQRT):
    3841              :     CASE_FLT_FN (BUILT_IN_TAN):
    3842              :     CASE_FLT_FN (BUILT_IN_TANH):
    3843              :     CASE_FLT_FN (BUILT_IN_TGAMMA):
    3844              :     CASE_FLT_FN (BUILT_IN_TRUNC):
    3845              :     CASE_FLT_FN_FLOATN_NX (BUILT_IN_TRUNC):
    3846              :     case BUILT_IN_ISINF:
    3847              :     case BUILT_IN_ISNAN:
    3848              :       return "<math.h>";
    3849           29 :     CASE_FLT_FN (BUILT_IN_CABS):
    3850           29 :     CASE_FLT_FN (BUILT_IN_CACOS):
    3851           29 :     CASE_FLT_FN (BUILT_IN_CACOSH):
    3852           29 :     CASE_FLT_FN (BUILT_IN_CARG):
    3853           29 :     CASE_FLT_FN (BUILT_IN_CASIN):
    3854           29 :     CASE_FLT_FN (BUILT_IN_CASINH):
    3855           29 :     CASE_FLT_FN (BUILT_IN_CATAN):
    3856           29 :     CASE_FLT_FN (BUILT_IN_CATANH):
    3857           29 :     CASE_FLT_FN (BUILT_IN_CCOS):
    3858           29 :     CASE_FLT_FN (BUILT_IN_CCOSH):
    3859           29 :     CASE_FLT_FN (BUILT_IN_CEXP):
    3860           29 :     CASE_FLT_FN (BUILT_IN_CIMAG):
    3861           29 :     CASE_FLT_FN (BUILT_IN_CLOG):
    3862           29 :     CASE_FLT_FN (BUILT_IN_CONJ):
    3863           29 :     CASE_FLT_FN (BUILT_IN_CPOW):
    3864           29 :     CASE_FLT_FN (BUILT_IN_CPROJ):
    3865           29 :     CASE_FLT_FN (BUILT_IN_CREAL):
    3866           29 :     CASE_FLT_FN (BUILT_IN_CSIN):
    3867           29 :     CASE_FLT_FN (BUILT_IN_CSINH):
    3868           29 :     CASE_FLT_FN (BUILT_IN_CSQRT):
    3869           29 :     CASE_FLT_FN (BUILT_IN_CTAN):
    3870           29 :     CASE_FLT_FN (BUILT_IN_CTANH):
    3871           29 :       return "<complex.h>";
    3872          228 :     case BUILT_IN_MEMCHR:
    3873          228 :     case BUILT_IN_MEMCMP:
    3874          228 :     case BUILT_IN_MEMCPY:
    3875          228 :     case BUILT_IN_MEMMOVE:
    3876          228 :     case BUILT_IN_MEMSET:
    3877          228 :     case BUILT_IN_STRCAT:
    3878          228 :     case BUILT_IN_STRCHR:
    3879          228 :     case BUILT_IN_STRCMP:
    3880          228 :     case BUILT_IN_STRCPY:
    3881          228 :     case BUILT_IN_STRCSPN:
    3882          228 :     case BUILT_IN_STRLEN:
    3883          228 :     case BUILT_IN_STRNCAT:
    3884          228 :     case BUILT_IN_STRNCMP:
    3885          228 :     case BUILT_IN_STRNCPY:
    3886          228 :     case BUILT_IN_STRPBRK:
    3887          228 :     case BUILT_IN_STRRCHR:
    3888          228 :     case BUILT_IN_STRSPN:
    3889          228 :     case BUILT_IN_STRSTR:
    3890          228 :       return "<string.h>";
    3891          544 :     case BUILT_IN_FPRINTF:
    3892          544 :     case BUILT_IN_PUTC:
    3893          544 :     case BUILT_IN_FPUTC:
    3894          544 :     case BUILT_IN_FPUTS:
    3895          544 :     case BUILT_IN_FSCANF:
    3896          544 :     case BUILT_IN_FWRITE:
    3897          544 :     case BUILT_IN_PRINTF:
    3898          544 :     case BUILT_IN_PUTCHAR:
    3899          544 :     case BUILT_IN_PUTS:
    3900          544 :     case BUILT_IN_SCANF:
    3901          544 :     case BUILT_IN_SNPRINTF:
    3902          544 :     case BUILT_IN_SPRINTF:
    3903          544 :     case BUILT_IN_SSCANF:
    3904          544 :     case BUILT_IN_VFPRINTF:
    3905          544 :     case BUILT_IN_VFSCANF:
    3906          544 :     case BUILT_IN_VPRINTF:
    3907          544 :     case BUILT_IN_VSCANF:
    3908          544 :     case BUILT_IN_VSNPRINTF:
    3909          544 :     case BUILT_IN_VSPRINTF:
    3910          544 :     case BUILT_IN_VSSCANF:
    3911          544 :       return "<stdio.h>";
    3912            2 :     case BUILT_IN_ISALNUM:
    3913            2 :     case BUILT_IN_ISALPHA:
    3914            2 :     case BUILT_IN_ISBLANK:
    3915            2 :     case BUILT_IN_ISCNTRL:
    3916            2 :     case BUILT_IN_ISDIGIT:
    3917            2 :     case BUILT_IN_ISGRAPH:
    3918            2 :     case BUILT_IN_ISLOWER:
    3919            2 :     case BUILT_IN_ISPRINT:
    3920            2 :     case BUILT_IN_ISPUNCT:
    3921            2 :     case BUILT_IN_ISSPACE:
    3922            2 :     case BUILT_IN_ISUPPER:
    3923            2 :     case BUILT_IN_ISXDIGIT:
    3924            2 :     case BUILT_IN_TOLOWER:
    3925            2 :     case BUILT_IN_TOUPPER:
    3926            2 :       return "<ctype.h>";
    3927            0 :     case BUILT_IN_ISWALNUM:
    3928            0 :     case BUILT_IN_ISWALPHA:
    3929            0 :     case BUILT_IN_ISWBLANK:
    3930            0 :     case BUILT_IN_ISWCNTRL:
    3931            0 :     case BUILT_IN_ISWDIGIT:
    3932            0 :     case BUILT_IN_ISWGRAPH:
    3933            0 :     case BUILT_IN_ISWLOWER:
    3934            0 :     case BUILT_IN_ISWPRINT:
    3935            0 :     case BUILT_IN_ISWPUNCT:
    3936            0 :     case BUILT_IN_ISWSPACE:
    3937            0 :     case BUILT_IN_ISWUPPER:
    3938            0 :     case BUILT_IN_ISWXDIGIT:
    3939            0 :     case BUILT_IN_TOWLOWER:
    3940            0 :     case BUILT_IN_TOWUPPER:
    3941            0 :       return "<wctype.h>";
    3942         1818 :     case BUILT_IN_ABORT:
    3943         1818 :     case BUILT_IN_ABS:
    3944         1818 :     case BUILT_IN_CALLOC:
    3945         1818 :     case BUILT_IN_EXIT:
    3946         1818 :     case BUILT_IN_FREE:
    3947         1818 :     case BUILT_IN_LABS:
    3948         1818 :     case BUILT_IN_LLABS:
    3949         1818 :     case BUILT_IN_MALLOC:
    3950         1818 :     case BUILT_IN_REALLOC:
    3951         1818 :     case BUILT_IN__EXIT2:
    3952         1818 :     case BUILT_IN_ALIGNED_ALLOC:
    3953         1818 :       return "<stdlib.h>";
    3954            1 :     case BUILT_IN_IMAXABS:
    3955            1 :       return "<inttypes.h>";
    3956            3 :     case BUILT_IN_STRFTIME:
    3957            3 :       return "<time.h>";
    3958              :     default:
    3959              :       return NULL;
    3960              :     }
    3961              : }
    3962              : 
    3963              : /* Generate an implicit declaration for identifier FUNCTIONID at LOC as a
    3964              :    function of type int ().  */
    3965              : 
    3966              : tree
    3967         4729 : implicitly_declare (location_t loc, tree functionid)
    3968              : {
    3969         4729 :   struct c_binding *b;
    3970         4729 :   tree decl = NULL_TREE;
    3971         4729 :   tree asmspec_tree;
    3972              : 
    3973         4743 :   for (b = I_SYMBOL_BINDING (functionid); b; b = b->shadowed)
    3974              :     {
    3975         3158 :       if (B_IN_SCOPE (b, external_scope))
    3976              :         {
    3977         3144 :           decl = b->decl;
    3978         3144 :           break;
    3979              :         }
    3980              :     }
    3981              : 
    3982         4729 :   if (decl)
    3983              :     {
    3984         3144 :       if (TREE_CODE (decl) != FUNCTION_DECL)
    3985              :         return decl;
    3986              : 
    3987              :       /* FIXME: Objective-C has weird not-really-builtin functions
    3988              :          which are supposed to be visible automatically.  They wind up
    3989              :          in the external scope because they're pushed before the file
    3990              :          scope gets created.  Catch this here and rebind them into the
    3991              :          file scope.  */
    3992         3137 :       if (!fndecl_built_in_p (decl) && DECL_IS_UNDECLARED_BUILTIN (decl))
    3993              :         {
    3994            0 :           bind (functionid, decl, file_scope,
    3995              :                 /*invisible=*/false, /*nested=*/true,
    3996            0 :                 DECL_SOURCE_LOCATION (decl));
    3997            0 :           return decl;
    3998              :         }
    3999              :       else
    4000              :         {
    4001         3137 :           tree newtype = default_function_type;
    4002         3137 :           if (b->u.type)
    4003          753 :             TREE_TYPE (decl) = b->u.type;
    4004              :           /* Implicit declaration of a function already declared
    4005              :              (somehow) in a different scope, or as a built-in.
    4006              :              If this is the first time this has happened, warn;
    4007              :              then recycle the old declaration but with the new type.  */
    4008         3137 :           if (!C_DECL_IMPLICIT (decl))
    4009              :             {
    4010         2191 :               implicit_decl_permerror (loc, functionid, decl);
    4011         2191 :               C_DECL_IMPLICIT (decl) = 1;
    4012              :             }
    4013         3137 :           if (fndecl_built_in_p (decl))
    4014              :             {
    4015         2705 :               newtype = c_build_type_attribute_variant (newtype,
    4016         2705 :                                                         TYPE_ATTRIBUTES
    4017              :                                                         (TREE_TYPE (decl)));
    4018         2705 :               if (!comptypes (newtype, TREE_TYPE (decl)))
    4019              :                 {
    4020         2528 :                   auto_diagnostic_group d;
    4021         2528 :                   bool warned = warning_at (loc,
    4022         2528 :                                             OPT_Wbuiltin_declaration_mismatch,
    4023              :                                             "incompatible implicit "
    4024              :                                             "declaration of built-in "
    4025              :                                             "function %qD", decl);
    4026              :                   /* See if we can hint which header to include.  */
    4027         2528 :                   const char *header = header_for_builtin_fn (decl);
    4028         2528 :                   if (header != NULL && warned)
    4029              :                     {
    4030          133 :                       rich_location richloc (line_table, loc);
    4031          133 :                       maybe_add_include_fixit (&richloc, header, true);
    4032          133 :                       inform (&richloc,
    4033              :                               "include %qs or provide a declaration of %qD",
    4034              :                               header, decl);
    4035          133 :                     }
    4036         2528 :                   newtype = TREE_TYPE (decl);
    4037         2528 :                 }
    4038              :             }
    4039              :           else
    4040              :             {
    4041          432 :               if (!comptypes (newtype, TREE_TYPE (decl)))
    4042              :                 {
    4043            2 :                   auto_diagnostic_group d;
    4044            2 :                   error_at (loc, "incompatible implicit declaration of "
    4045              :                             "function %qD", decl);
    4046            2 :                   locate_old_decl (decl);
    4047            2 :                 }
    4048              :             }
    4049         3137 :           b->u.type = TREE_TYPE (decl);
    4050         3137 :           TREE_TYPE (decl) = newtype;
    4051         3137 :           bind (functionid, decl, current_scope,
    4052              :                 /*invisible=*/false, /*nested=*/true,
    4053         3137 :                 DECL_SOURCE_LOCATION (decl));
    4054         3137 :           return decl;
    4055              :         }
    4056              :     }
    4057              : 
    4058              :   /* Not seen before.  */
    4059         1585 :   decl = build_decl (loc, FUNCTION_DECL, functionid, default_function_type);
    4060         1585 :   DECL_EXTERNAL (decl) = 1;
    4061         1585 :   TREE_PUBLIC (decl) = 1;
    4062         1585 :   C_DECL_IMPLICIT (decl) = 1;
    4063         1585 :   implicit_decl_permerror (loc, functionid, 0);
    4064         1585 :   asmspec_tree = maybe_apply_renaming_pragma (decl, /*asmname=*/NULL);
    4065         1585 :   if (asmspec_tree)
    4066            1 :     set_user_assembler_name (decl, TREE_STRING_POINTER (asmspec_tree));
    4067              : 
    4068              :   /* C89 says implicit declarations are in the innermost block.
    4069              :      So we record the decl in the standard fashion.  */
    4070         1585 :   decl = pushdecl (decl);
    4071              : 
    4072              :   /* No need to call objc_check_decl here - it's a function type.  */
    4073         1585 :   rest_of_decl_compilation (decl, 0, 0);
    4074              : 
    4075              :   /* Write a record describing this implicit function declaration
    4076              :      to the prototypes file (if requested).  */
    4077         1585 :   gen_aux_info_record (decl, 0, 1, 0);
    4078              : 
    4079              :   /* Possibly apply some default attributes to this implicit declaration.  */
    4080         1585 :   decl_attributes (&decl, NULL_TREE, 0);
    4081              : 
    4082         1585 :   return decl;
    4083              : }
    4084              : 
    4085              : /* Issue an error message for a reference to an undeclared variable
    4086              :    ID, including a reference to a builtin outside of function-call
    4087              :    context.  Establish a binding of the identifier to error_mark_node
    4088              :    in an appropriate scope, which will suppress further errors for the
    4089              :    same identifier.  The error message should be given location LOC.  */
    4090              : void
    4091         1260 : undeclared_variable (location_t loc, tree id)
    4092              : {
    4093         1260 :   static bool already = false;
    4094         1260 :   struct c_scope *scope;
    4095              : 
    4096         1260 :   auto_diagnostic_group d;
    4097         1260 :   if (current_function_decl == NULL_TREE)
    4098              :     {
    4099          436 :       name_hint guessed_id = lookup_name_fuzzy (id, FUZZY_LOOKUP_NAME, loc);
    4100          436 :       if (const char *suggestion = guessed_id.suggestion ())
    4101              :         {
    4102           86 :           gcc_rich_location richloc (loc);
    4103           86 :           richloc.add_fixit_replace (suggestion);
    4104           86 :           error_at (&richloc,
    4105              :                     "%qE undeclared here (not in a function);"
    4106              :                     " did you mean %qs?",
    4107              :                     id, suggestion);
    4108           86 :         }
    4109              :       else
    4110          350 :         error_at (loc, "%qE undeclared here (not in a function)", id);
    4111          436 :       scope = current_scope;
    4112          436 :     }
    4113              :   else
    4114              :     {
    4115          824 :       if (!objc_diagnose_private_ivar (id))
    4116              :         {
    4117          824 :           name_hint guessed_id = lookup_name_fuzzy (id, FUZZY_LOOKUP_NAME, loc);
    4118          824 :           if (const char *suggestion = guessed_id.suggestion ())
    4119              :             {
    4120           39 :               gcc_rich_location richloc (loc);
    4121           39 :               richloc.add_fixit_replace (suggestion);
    4122           39 :               error_at (&richloc,
    4123              :                         "%qE undeclared (first use in this function);"
    4124              :                         " did you mean %qs?",
    4125              :                         id, suggestion);
    4126           39 :             }
    4127              :           else
    4128          785 :             error_at (loc, "%qE undeclared (first use in this function)", id);
    4129          824 :         }
    4130          824 :       if (!already)
    4131              :         {
    4132          201 :           inform (loc, "each undeclared identifier is reported only"
    4133              :                   " once for each function it appears in");
    4134          201 :           already = true;
    4135              :         }
    4136              : 
    4137              :       /* If we are parsing old-style parameter decls, current_function_decl
    4138              :          will be nonnull but current_function_scope will be null.  */
    4139          824 :       scope = current_function_scope ? current_function_scope : current_scope;
    4140              :     }
    4141         1260 :   bind (id, error_mark_node, scope, /*invisible=*/false, /*nested=*/false,
    4142              :         UNKNOWN_LOCATION);
    4143         1260 : }
    4144              : 
    4145              : /* Subroutine of lookup_label, declare_label, define_label: construct a
    4146              :    LABEL_DECL with all the proper frills.  Also create a struct
    4147              :    c_label_vars initialized for the current scope.  */
    4148              : 
    4149              : static tree
    4150        24013 : make_label (location_t location, tree name, bool defining,
    4151              :             struct c_label_vars **p_label_vars)
    4152              : {
    4153        24013 :   tree label = build_decl (location, LABEL_DECL, name, void_type_node);
    4154        24013 :   DECL_CONTEXT (label) = current_function_decl;
    4155        24013 :   SET_DECL_MODE (label, VOIDmode);
    4156              : 
    4157        24013 :   c_label_vars *label_vars = ggc_alloc<c_label_vars> ();
    4158        24013 :   label_vars->shadowed = NULL;
    4159        24013 :   set_spot_bindings (&label_vars->label_bindings, defining);
    4160        24013 :   label_vars->decls_in_scope = make_tree_vector ();
    4161        24013 :   label_vars->gotos = NULL;
    4162        24013 :   *p_label_vars = label_vars;
    4163              : 
    4164        24013 :   return label;
    4165              : }
    4166              : 
    4167              : /* Get the LABEL_DECL corresponding to identifier NAME as a label.
    4168              :    Create one if none exists so far for the current function.
    4169              :    This is called when a label is used in a goto expression or
    4170              :    has its address taken.  */
    4171              : 
    4172              : tree
    4173        85477 : lookup_label (tree name)
    4174              : {
    4175        85477 :   tree label;
    4176        85477 :   struct c_label_vars *label_vars;
    4177              : 
    4178        85477 :   if (current_function_scope == 0)
    4179              :     {
    4180            2 :       error ("label %qE referenced outside of any function", name);
    4181            2 :       return NULL_TREE;
    4182              :     }
    4183              : 
    4184              :   /* Use a label already defined or ref'd with this name, but not if
    4185              :      it is inherited from a containing function and wasn't declared
    4186              :      using __label__.  */
    4187        85475 :   label = I_LABEL_DECL (name);
    4188        79519 :   if (label && (DECL_CONTEXT (label) == current_function_decl
    4189          608 :                 || C_DECLARED_LABEL_FLAG (label)))
    4190              :     {
    4191              :       /* If the label has only been declared, update its apparent
    4192              :          location to point here, for better diagnostics if it
    4193              :          turns out not to have been defined.  */
    4194        79512 :       if (DECL_INITIAL (label) == NULL_TREE)
    4195        62685 :         DECL_SOURCE_LOCATION (label) = input_location;
    4196        79512 :       return label;
    4197              :     }
    4198              : 
    4199              :   /* No label binding for that identifier; make one.  */
    4200         5963 :   label = make_label (input_location, name, false, &label_vars);
    4201              : 
    4202              :   /* Ordinary labels go in the current function scope.  */
    4203         5963 :   bind_label (name, label, current_function_scope, label_vars);
    4204              : 
    4205         5963 :   return label;
    4206              : }
    4207              : 
    4208              : /* Issue a warning about DECL for a goto statement at GOTO_LOC going
    4209              :    to LABEL.  */
    4210              : 
    4211              : static void
    4212         1490 : warn_about_goto (location_t goto_loc, tree label, tree decl)
    4213              : {
    4214         1490 :   auto_diagnostic_group d;
    4215         1490 :   if (c_type_variably_modified_p (TREE_TYPE (decl)))
    4216         1484 :     error_at (goto_loc,
    4217              :               "jump into scope of identifier with variably modified type");
    4218            6 :   else if (flag_openmp
    4219            6 :            && lookup_attribute ("omp allocate", DECL_ATTRIBUTES (decl)))
    4220            2 :     error_at (goto_loc, "jump skips OpenMP %<allocate%> allocation");
    4221              :   else
    4222            4 :     if (!warning_at (goto_loc, OPT_Wjump_misses_init,
    4223              :                      "jump skips variable initialization"))
    4224            0 :       return;
    4225         1490 :   inform (DECL_SOURCE_LOCATION (label), "label %qD defined here", label);
    4226         1490 :   inform (DECL_SOURCE_LOCATION (decl), "%qD declared here", decl);
    4227         1490 : }
    4228              : 
    4229              : /* Look up a label because of a goto statement.  This is like
    4230              :    lookup_label, but also issues any appropriate warnings.  */
    4231              : 
    4232              : tree
    4233        83636 : lookup_label_for_goto (location_t loc, tree name)
    4234              : {
    4235        83636 :   tree label;
    4236        83636 :   struct c_label_vars *label_vars;
    4237        83636 :   unsigned int ix;
    4238        83636 :   tree decl;
    4239              : 
    4240        83636 :   label = lookup_label (name);
    4241        83636 :   if (label == NULL_TREE)
    4242              :     return NULL_TREE;
    4243              : 
    4244              :   /* If we are jumping to a different function, we can't issue any
    4245              :      useful warnings.  */
    4246        83636 :   if (DECL_CONTEXT (label) != current_function_decl)
    4247              :     {
    4248          522 :       gcc_assert (C_DECLARED_LABEL_FLAG (label));
    4249              :       return label;
    4250              :     }
    4251              : 
    4252        83114 :   label_vars = I_LABEL_BINDING (name)->u.label;
    4253              : 
    4254              :   /* If the label has not yet been defined, then push this goto on a
    4255              :      list for possible later warnings.  */
    4256        83114 :   if (label_vars->label_bindings.scope == NULL)
    4257              :     {
    4258        66512 :       c_goto_bindings *g = ggc_alloc<c_goto_bindings> ();
    4259              : 
    4260        66512 :       g->loc = loc;
    4261        66512 :       set_spot_bindings (&g->goto_bindings, true);
    4262        66512 :       vec_safe_push (label_vars->gotos, g);
    4263        66512 :       return label;
    4264              :     }
    4265              : 
    4266              :   /* If there are any decls in label_vars->decls_in_scope, then this
    4267              :      goto has missed the declaration of the decl.  This happens for a
    4268              :      case like
    4269              :        int i = 1;
    4270              :       lab:
    4271              :        ...
    4272              :        goto lab;
    4273              :      Issue a warning or error.  */
    4274        17377 :   FOR_EACH_VEC_SAFE_ELT (label_vars->decls_in_scope, ix, decl)
    4275          775 :     warn_about_goto (loc, label, decl);
    4276              : 
    4277        16602 :   if (label_vars->label_bindings.left_stmt_expr)
    4278              :     {
    4279          120 :       auto_diagnostic_group d;
    4280          120 :       error_at (loc, "jump into statement expression");
    4281          120 :       inform (DECL_SOURCE_LOCATION (label), "label %qD defined here", label);
    4282          120 :     }
    4283              : 
    4284              :   return label;
    4285              : }
    4286              : 
    4287              : /* Make a label named NAME in the current function, shadowing silently
    4288              :    any that may be inherited from containing functions or containing
    4289              :    scopes.  This is called for __label__ declarations.  */
    4290              : 
    4291              : tree
    4292         1192 : declare_label (tree name)
    4293              : {
    4294         1192 :   struct c_binding *b = I_LABEL_BINDING (name);
    4295         1192 :   tree label;
    4296         1192 :   struct c_label_vars *label_vars;
    4297              : 
    4298              :   /* Check to make sure that the label hasn't already been declared
    4299              :      at this scope */
    4300         1192 :   if (b && B_IN_CURRENT_SCOPE (b))
    4301              :     {
    4302            2 :       auto_diagnostic_group d;
    4303            2 :       error ("duplicate label declaration %qE", name);
    4304            2 :       locate_old_decl (b->decl);
    4305              : 
    4306              :       /* Just use the previous declaration.  */
    4307            2 :       return b->decl;
    4308            2 :     }
    4309              : 
    4310         1190 :   label = make_label (input_location, name, false, &label_vars);
    4311         1190 :   C_DECLARED_LABEL_FLAG (label) = 1;
    4312              : 
    4313              :   /* Declared labels go in the current scope.  */
    4314         1190 :   bind_label (name, label, current_scope, label_vars);
    4315              : 
    4316         1190 :   return label;
    4317              : }
    4318              : 
    4319              : /* When we define a label, issue any appropriate warnings if there are
    4320              :    any gotos earlier in the function which jump to this label.  */
    4321              : 
    4322              : static void
    4323         7073 : check_earlier_gotos (tree label, struct c_label_vars* label_vars)
    4324              : {
    4325         7073 :   unsigned int ix;
    4326         7073 :   struct c_goto_bindings *g;
    4327              : 
    4328        73519 :   FOR_EACH_VEC_SAFE_ELT (label_vars->gotos, ix, g)
    4329              :     {
    4330        66446 :       struct c_binding *b;
    4331        66446 :       struct c_scope *scope;
    4332              : 
    4333              :       /* We have a goto to this label.  The goto is going forward.  In
    4334              :          g->scope, the goto is going to skip any binding which was
    4335              :          defined after g->bindings_in_scope.  */
    4336        66446 :       if (g->goto_bindings.scope->has_jump_unsafe_decl)
    4337              :         {
    4338          255 :           for (b = g->goto_bindings.scope->bindings;
    4339          593 :                b != g->goto_bindings.bindings_in_scope;
    4340          338 :                b = b->prev)
    4341              :             {
    4342          338 :               if (decl_jump_unsafe (b->decl))
    4343          176 :                 warn_about_goto (g->loc, label, b->decl);
    4344              :             }
    4345              :         }
    4346              : 
    4347              :       /* We also need to warn about decls defined in any scopes
    4348              :          between the scope of the label and the scope of the goto.  */
    4349        66446 :       for (scope = label_vars->label_bindings.scope;
    4350        69140 :            scope != g->goto_bindings.scope;
    4351         2694 :            scope = scope->outer)
    4352              :         {
    4353         2694 :           gcc_assert (scope != NULL);
    4354         2694 :           if (scope->has_jump_unsafe_decl)
    4355              :             {
    4356          325 :               if (scope == label_vars->label_bindings.scope)
    4357          249 :                 b = label_vars->label_bindings.bindings_in_scope;
    4358              :               else
    4359           76 :                 b = scope->bindings;
    4360          864 :               for (; b != NULL; b = b->prev)
    4361              :                 {
    4362          539 :                   if (decl_jump_unsafe (b->decl))
    4363          539 :                     warn_about_goto (g->loc, label, b->decl);
    4364              :                 }
    4365              :             }
    4366              :         }
    4367              : 
    4368        66446 :       if (g->goto_bindings.stmt_exprs > 0)
    4369              :         {
    4370          100 :           auto_diagnostic_group d;
    4371          100 :           error_at (g->loc, "jump into statement expression");
    4372          100 :           inform (DECL_SOURCE_LOCATION (label), "label %qD defined here",
    4373              :                   label);
    4374          100 :         }
    4375              :     }
    4376              : 
    4377              :   /* Now that the label is defined, we will issue warnings about
    4378              :      subsequent gotos to this label when we see them.  */
    4379         7073 :   vec_safe_truncate (label_vars->gotos, 0);
    4380         7073 :   label_vars->gotos = NULL;
    4381         7073 : }
    4382              : 
    4383              : /* Define a label, specifying the location in the source file.
    4384              :    Return the LABEL_DECL node for the label, if the definition is valid.
    4385              :    Otherwise return NULL_TREE.  */
    4386              : 
    4387              : tree
    4388        23962 : define_label (location_t location, tree name)
    4389              : {
    4390              :   /* Find any preexisting label with this name.  It is an error
    4391              :      if that label has already been defined in this function, or
    4392              :      if there is a containing function with a declared label with
    4393              :      the same name.  */
    4394        23962 :   tree label = I_LABEL_DECL (name);
    4395              : 
    4396         7109 :   if (label
    4397         7109 :       && ((DECL_CONTEXT (label) == current_function_decl
    4398         7095 :            && DECL_INITIAL (label) != NULL_TREE)
    4399         7087 :           || (DECL_CONTEXT (label) != current_function_decl
    4400           14 :               && C_DECLARED_LABEL_FLAG (label))))
    4401              :     {
    4402           29 :       auto_diagnostic_group d;
    4403           29 :       error_at (location, "duplicate label %qD", label);
    4404           29 :       locate_old_decl (label);
    4405           29 :       return NULL_TREE;
    4406           29 :     }
    4407        23933 :   else if (label && DECL_CONTEXT (label) == current_function_decl)
    4408              :     {
    4409         7073 :       struct c_label_vars *label_vars = I_LABEL_BINDING (name)->u.label;
    4410              : 
    4411              :       /* The label has been used or declared already in this function,
    4412              :          but not defined.  Update its location to point to this
    4413              :          definition.  */
    4414         7073 :       DECL_SOURCE_LOCATION (label) = location;
    4415         7073 :       set_spot_bindings (&label_vars->label_bindings, true);
    4416              : 
    4417              :       /* Issue warnings as required about any goto statements from
    4418              :          earlier in the function.  */
    4419         7073 :       check_earlier_gotos (label, label_vars);
    4420              :     }
    4421              :   else
    4422              :     {
    4423        16860 :       struct c_label_vars *label_vars;
    4424              : 
    4425              :       /* No label binding for that identifier; make one.  */
    4426        16860 :       label = make_label (location, name, true, &label_vars);
    4427              : 
    4428              :       /* Ordinary labels go in the current function scope.  */
    4429        16860 :       bind_label (name, label, current_function_scope, label_vars);
    4430              :     }
    4431              : 
    4432        23933 :   if (!in_system_header_at (input_location) && lookup_name (name))
    4433          139 :     warning_at (location, OPT_Wtraditional,
    4434              :                 "traditional C lacks a separate namespace "
    4435              :                 "for labels, identifier %qE conflicts", name);
    4436              : 
    4437              :   /* Mark label as having been defined.  */
    4438        23933 :   DECL_INITIAL (label) = error_mark_node;
    4439        23933 :   return label;
    4440              : }
    4441              : 
    4442              : /* Get the bindings for a new switch statement.  This is used to issue
    4443              :    warnings as appropriate for jumps from the switch to case or
    4444              :    default labels.  */
    4445              : 
    4446              : struct c_spot_bindings *
    4447        37324 : c_get_switch_bindings (void)
    4448              : {
    4449        37324 :   struct c_spot_bindings *switch_bindings;
    4450              : 
    4451        37324 :   switch_bindings = XNEW (struct c_spot_bindings);
    4452        37324 :   set_spot_bindings (switch_bindings, true);
    4453        37324 :   return switch_bindings;
    4454              : }
    4455              : 
    4456              : void
    4457        37324 : c_release_switch_bindings (struct c_spot_bindings *bindings)
    4458              : {
    4459        37324 :   gcc_assert (bindings->stmt_exprs == 0 && !bindings->left_stmt_expr);
    4460        37324 :   XDELETE (bindings);
    4461        37324 : }
    4462              : 
    4463              : /* This is called at the point of a case or default label to issue
    4464              :    warnings about decls as needed.  It returns true if it found an
    4465              :    error, not just a warning.  */
    4466              : 
    4467              : bool
    4468      1030363 : c_check_switch_jump_warnings (struct c_spot_bindings *switch_bindings,
    4469              :                               location_t switch_loc, location_t case_loc)
    4470              : {
    4471      1030363 :   bool saw_error;
    4472      1030363 :   struct c_scope *scope;
    4473              : 
    4474      1030363 :   saw_error = false;
    4475      1030363 :   for (scope = current_scope;
    4476      3091100 :        scope != switch_bindings->scope;
    4477      2060737 :        scope = scope->outer)
    4478              :     {
    4479      2060737 :       struct c_binding *b;
    4480              : 
    4481      2060737 :       gcc_assert (scope != NULL);
    4482              : 
    4483      2060737 :       if (!scope->has_jump_unsafe_decl)
    4484      2060726 :         continue;
    4485              : 
    4486           22 :       for (b = scope->bindings; b != NULL; b = b->prev)
    4487              :         {
    4488           11 :           if (decl_jump_unsafe (b->decl))
    4489              :             {
    4490           11 :               auto_diagnostic_group d;
    4491           11 :               bool emitted;
    4492           11 :               if (c_type_variably_modified_p (TREE_TYPE (b->decl)))
    4493              :                 {
    4494            6 :                   saw_error = true;
    4495            6 :                   error_at (case_loc,
    4496              :                             "switch jumps into scope of identifier with "
    4497              :                             "variably modified type");
    4498            6 :                   emitted = true;
    4499              :                 }
    4500            5 :               else if (flag_openmp
    4501            7 :                        && lookup_attribute ("omp allocate",
    4502            2 :                                             DECL_ATTRIBUTES (b->decl)))
    4503              :                 {
    4504            2 :                   saw_error = true;
    4505            2 :                   error_at (case_loc,
    4506              :                             "switch jumps over OpenMP %<allocate%> allocation");
    4507            2 :                   emitted = true;
    4508              :                 }
    4509              :               else
    4510            3 :                 emitted
    4511            3 :                   = warning_at (case_loc, OPT_Wjump_misses_init,
    4512              :                                 "switch jumps over variable initialization");
    4513           11 :               if (emitted)
    4514              :                 {
    4515           11 :                   inform (switch_loc, "switch starts here");
    4516           11 :                   inform (DECL_SOURCE_LOCATION (b->decl), "%qD declared here",
    4517              :                           b->decl);
    4518              :                 }
    4519           11 :             }
    4520              :         }
    4521              :     }
    4522              : 
    4523      1030363 :   if (switch_bindings->stmt_exprs > 0)
    4524              :     {
    4525            4 :       saw_error = true;
    4526            4 :       auto_diagnostic_group d;
    4527            4 :       error_at (case_loc, "switch jumps into statement expression");
    4528            4 :       inform (switch_loc, "switch starts here");
    4529            4 :     }
    4530              : 
    4531      1030363 :   return saw_error;
    4532              : }
    4533              : 
    4534              : /* Given NAME, an IDENTIFIER_NODE,
    4535              :    return the structure (or union or enum) definition for that name.
    4536              :    If THISLEVEL_ONLY is nonzero, searches only the current_scope.
    4537              :    CODE says which kind of type the caller wants;
    4538              :    it is RECORD_TYPE or UNION_TYPE or ENUMERAL_TYPE.
    4539              :    If PLOC is not NULL and this returns non-null, it sets *PLOC to the
    4540              :    location where the tag was defined.
    4541              :    If the wrong kind of type is found, an error is reported.  */
    4542              : 
    4543              : static tree
    4544      2084966 : lookup_tag (enum tree_code code, tree name, bool thislevel_only,
    4545              :             location_t *ploc)
    4546              : {
    4547      2084966 :   struct c_binding *b = I_TAG_BINDING (name);
    4548      2084966 :   bool thislevel = false;
    4549              : 
    4550      2084966 :   if (!b || !b->decl)
    4551              :     return NULL_TREE;
    4552              : 
    4553              :   /* We only care about whether it's in this level if
    4554              :      thislevel_only was set or it might be a type clash.  */
    4555      1458771 :   if (thislevel_only || TREE_CODE (b->decl) != code)
    4556              :     {
    4557              :       /* For our purposes, a tag in the external scope is the same as
    4558              :          a tag in the file scope.  (Primarily relevant to Objective-C
    4559              :          and its builtin structure tags, which get pushed before the
    4560              :          file scope is created.)  */
    4561       467977 :       if (B_IN_CURRENT_SCOPE (b)
    4562          196 :           || (current_scope == file_scope && B_IN_EXTERNAL_SCOPE (b)))
    4563      1458771 :         thislevel = true;
    4564              :     }
    4565              : 
    4566      1458771 :   if (thislevel_only && !thislevel)
    4567              :     return NULL_TREE;
    4568              : 
    4569      1458596 :   if (TREE_CODE (b->decl) != code)
    4570              :     {
    4571              :       /* Definition isn't the kind we were looking for.  */
    4572           39 :       pending_invalid_xref = name;
    4573           39 :       pending_invalid_xref_location = input_location;
    4574              : 
    4575              :       /* If in the same binding level as a declaration as a tag
    4576              :          of a different type, this must not be allowed to
    4577              :          shadow that tag, so give the error immediately.
    4578              :          (For example, "struct foo; union foo;" is invalid.)  */
    4579           39 :       if (thislevel)
    4580           18 :         pending_xref_error ();
    4581              :     }
    4582              : 
    4583      1458596 :   if (ploc != NULL)
    4584      1016275 :     *ploc = b->locus;
    4585              : 
    4586      1458596 :   return b->decl;
    4587              : }
    4588              : 
    4589              : /* Return true if a definition exists for NAME with code CODE.  */
    4590              : 
    4591              : bool
    4592          384 : tag_exists_p (enum tree_code code, tree name)
    4593              : {
    4594          384 :   struct c_binding *b = I_TAG_BINDING (name);
    4595              : 
    4596          384 :   if (b == NULL || b->decl == NULL_TREE)
    4597              :     return false;
    4598           18 :   return TREE_CODE (b->decl) == code;
    4599              : }
    4600              : 
    4601              : /* Print an error message now
    4602              :    for a recent invalid struct, union or enum cross reference.
    4603              :    We don't print them immediately because they are not invalid
    4604              :    when used in the `struct foo;' construct for shadowing.  */
    4605              : 
    4606              : void
    4607    313770325 : pending_xref_error (void)
    4608              : {
    4609    313770325 :   if (pending_invalid_xref != NULL_TREE)
    4610           27 :     error_at (pending_invalid_xref_location, "%qE defined as wrong kind of tag",
    4611              :               pending_invalid_xref);
    4612    313770325 :   pending_invalid_xref = NULL_TREE;
    4613    313770325 : }
    4614              : 
    4615              : 
    4616              : /* Look up NAME in the current scope and its superiors
    4617              :    in the namespace of variables, functions and typedefs.
    4618              :    Return a ..._DECL node of some kind representing its definition,
    4619              :    or return NULL_TREE if it is undefined.  */
    4620              : 
    4621              : tree
    4622   1267820834 : lookup_name (tree name)
    4623              : {
    4624   1267820834 :   struct c_binding *b = I_SYMBOL_BINDING (name);
    4625              :   /* Do not resolve non-default function versions.  */
    4626   1267820834 :   if (b
    4627    857101109 :       && TREE_CODE (b->decl) == FUNCTION_DECL
    4628    117213968 :       && DECL_FUNCTION_VERSIONED (b->decl)
    4629   1267820834 :       && !is_function_default_version (b->decl))
    4630              :     return NULL_TREE;
    4631   1267820834 :   if (b && !b->invisible)
    4632              :     {
    4633    846307792 :       maybe_record_typedef_use (b->decl);
    4634    846307792 :       return b->decl;
    4635              :     }
    4636              :   return NULL_TREE;
    4637              : }
    4638              : 
    4639              : /* Similar to `lookup_name' but look only at the indicated scope.  */
    4640              : 
    4641              : static tree
    4642    131292711 : lookup_name_in_scope (tree name, struct c_scope *scope)
    4643              : {
    4644    131292711 :   struct c_binding *b;
    4645              : 
    4646    131295943 :   for (b = I_SYMBOL_BINDING (name); b; b = b->shadowed)
    4647      7411526 :     if (B_IN_SCOPE (b, scope))
    4648      7408294 :       return b->decl;
    4649              :   return NULL_TREE;
    4650              : }
    4651              : 
    4652              : /* Look for the closest match for NAME within the currently valid
    4653              :    scopes.
    4654              : 
    4655              :    This finds the identifier with the lowest Levenshtein distance to
    4656              :    NAME.  If there are multiple candidates with equal minimal distance,
    4657              :    the first one found is returned.  Scopes are searched from innermost
    4658              :    outwards, and within a scope in reverse order of declaration, thus
    4659              :    benefiting candidates "near" to the current scope.
    4660              : 
    4661              :    The function also looks for similar macro names to NAME, since a
    4662              :    misspelled macro name will not be expanded, and hence looks like an
    4663              :    identifier to the C frontend.
    4664              : 
    4665              :    It also looks for start_typename keywords, to detect "singed" vs "signed"
    4666              :    typos.
    4667              : 
    4668              :    Use LOC for any deferred diagnostics.  */
    4669              : 
    4670              : name_hint
    4671         2065 : lookup_name_fuzzy (tree name, enum lookup_name_fuzzy_kind kind, location_t loc)
    4672              : {
    4673         2065 :   gcc_assert (TREE_CODE (name) == IDENTIFIER_NODE);
    4674              : 
    4675              :   /* Look up function-like macros first; maybe misusing them. */
    4676         4130 :   auto cpp_node = cpp_lookup (parse_in,
    4677         2065 :                               (const unsigned char*)IDENTIFIER_POINTER (name),
    4678         2065 :                               IDENTIFIER_LENGTH (name));
    4679         2065 :   if (cpp_node && cpp_fun_like_macro_p (cpp_node))
    4680            5 :     return name_hint
    4681              :       (nullptr,
    4682            5 :        std::make_unique<macro_like_function_used> (loc,
    4683           10 :                                                    IDENTIFIER_POINTER (name)));
    4684              : 
    4685              :   /* Next, try some well-known names in the C standard library, in case
    4686              :      the user forgot a #include.  */
    4687         2060 :   const char *header_hint
    4688         2060 :     = get_c_stdlib_header_for_name (IDENTIFIER_POINTER (name));
    4689              : 
    4690         2060 :   if (header_hint)
    4691           56 :     return name_hint
    4692              :       (nullptr,
    4693           56 :        std::make_unique<suggest_missing_header> (loc,
    4694          112 :                                                  IDENTIFIER_POINTER (name),
    4695           56 :                                                  header_hint));
    4696              : 
    4697              :   /* Next, look for exact matches for builtin defines that would have been
    4698              :      defined if the user had passed a command-line option (e.g. -fopenmp
    4699              :      for "_OPENMP").  */
    4700         2004 :   diagnostics::option_id option_id
    4701         2004 :     = get_option_for_builtin_define (IDENTIFIER_POINTER (name));
    4702         2004 :   if (option_id.m_idx > 0)
    4703            2 :     return name_hint
    4704              :       (nullptr,
    4705            2 :        std::make_unique<suggest_missing_option> (loc,
    4706            4 :                                                  IDENTIFIER_POINTER (name),
    4707            2 :                                                  option_id));
    4708              : 
    4709              :   /* Only suggest names reserved for the implementation if NAME begins
    4710              :      with an underscore.  */
    4711         2002 :   bool consider_implementation_names = (IDENTIFIER_POINTER (name)[0] == '_');
    4712              : 
    4713         2002 :   best_match<tree, tree> bm (name);
    4714              : 
    4715              :   /* Look within currently valid scopes.  */
    4716         9106 :   for (c_scope *scope = current_scope; scope; scope = scope->outer)
    4717     11361188 :     for (c_binding *binding = scope->bindings; binding; binding = binding->prev)
    4718              :       {
    4719     11354084 :         if (!binding->id || binding->invisible)
    4720      6419156 :           continue;
    4721      4934928 :         if (binding->decl == error_mark_node)
    4722          374 :           continue;
    4723              :         /* Don't use bindings from implicitly declared functions,
    4724              :            as they were likely misspellings themselves.  */
    4725      4934554 :         if (TREE_CODE (binding->decl) == FUNCTION_DECL)
    4726      4530565 :           if (C_DECL_IMPLICIT (binding->decl))
    4727          229 :             continue;
    4728              :         /* Don't suggest names that are reserved for use by the
    4729              :            implementation, unless NAME began with an underscore.  */
    4730      4934325 :         if (!consider_implementation_names)
    4731              :           {
    4732      2338547 :             const char *suggestion_str = IDENTIFIER_POINTER (binding->id);
    4733      2338547 :             if (name_reserved_for_implementation_p (suggestion_str))
    4734      2280147 :               continue;
    4735              :           }
    4736      2654178 :         switch (kind)
    4737              :           {
    4738        24317 :           case FUZZY_LOOKUP_TYPENAME:
    4739        24317 :             if (TREE_CODE (binding->decl) != TYPE_DECL)
    4740        17012 :               continue;
    4741              :             break;
    4742              : 
    4743       128923 :           case FUZZY_LOOKUP_FUNCTION_NAME:
    4744       128923 :             if (TREE_CODE (binding->decl) != FUNCTION_DECL)
    4745              :               {
    4746              :                 /* Allow function pointers.  */
    4747        26502 :                 if ((VAR_P (binding->decl)
    4748        21977 :                      || TREE_CODE (binding->decl) == PARM_DECL)
    4749         5400 :                     && TREE_CODE (TREE_TYPE (binding->decl)) == POINTER_TYPE
    4750        27782 :                     && (TREE_CODE (TREE_TYPE (TREE_TYPE (binding->decl)))
    4751              :                         == FUNCTION_TYPE))
    4752              :                   break;
    4753        26483 :                 continue;
    4754              :               }
    4755              :             break;
    4756              : 
    4757              :           default:
    4758              :             break;
    4759              :           }
    4760      2610683 :         bm.consider (binding->id);
    4761              :       }
    4762              : 
    4763              :   /* Consider macros: if the user misspelled a macro name e.g. "SOME_MACRO"
    4764              :      as:
    4765              :        x = SOME_OTHER_MACRO (y);
    4766              :      then "SOME_OTHER_MACRO" will survive to the frontend and show up
    4767              :      as a misspelled identifier.
    4768              : 
    4769              :      Use the best distance so far so that a candidate is only set if
    4770              :      a macro is better than anything so far.  This allows early rejection
    4771              :      (without calculating the edit distance) of macro names that must have
    4772              :      distance >= bm.get_best_distance (), and means that we only get a
    4773              :      non-NULL result for best_macro_match if it's better than any of
    4774              :      the identifiers already checked, which avoids needless creation
    4775              :      of identifiers for macro hashnodes.  */
    4776         2002 :   best_macro_match bmm (name, bm.get_best_distance (), parse_in);
    4777         2002 :   cpp_hashnode *best_macro = bmm.get_best_meaningful_candidate ();
    4778              :   /* If a macro is the closest so far to NAME, use it, creating an
    4779              :      identifier tree node for it.  */
    4780         2002 :   if (best_macro)
    4781              :     {
    4782           11 :       const char *id = (const char *)best_macro->ident.str;
    4783           11 :       tree macro_as_identifier
    4784           11 :         = get_identifier_with_length (id, best_macro->ident.len);
    4785           11 :       bm.set_best_so_far (macro_as_identifier,
    4786              :                           bmm.get_best_distance (),
    4787              :                           bmm.get_best_candidate_length ());
    4788              :     }
    4789              : 
    4790              :   /* Try the "start_typename" keywords to detect
    4791              :      "singed" vs "signed" typos.  */
    4792         2002 :   if (kind == FUZZY_LOOKUP_TYPENAME)
    4793              :     {
    4794        55687 :       for (unsigned i = 0; i < num_c_common_reswords; i++)
    4795              :         {
    4796        55448 :           const c_common_resword *resword = &c_common_reswords[i];
    4797        55448 :           if (!c_keyword_starts_typename (resword->rid))
    4798        42303 :             continue;
    4799        13145 :           tree resword_identifier = ridpointers [resword->rid];
    4800        13145 :           if (!resword_identifier)
    4801           30 :             continue;
    4802        13115 :           gcc_assert (TREE_CODE (resword_identifier) == IDENTIFIER_NODE);
    4803        13115 :           bm.consider (resword_identifier);
    4804              :         }
    4805              :     }
    4806              : 
    4807         2002 :   tree best = bm.get_best_meaningful_candidate ();
    4808         2002 :   if (best)
    4809          278 :     return name_hint (IDENTIFIER_POINTER (best), NULL);
    4810              :   else
    4811         1724 :     return name_hint (NULL, NULL);
    4812              : }
    4813              : 
    4814              : 
    4815              : /* Handle the standard [[nodiscard]] attribute.  */
    4816              : 
    4817              : static tree
    4818           34 : handle_nodiscard_attribute (tree *node, tree name, tree /*args*/,
    4819              :                             int /*flags*/, bool *no_add_attrs)
    4820              : {
    4821           34 :   if (TREE_CODE (*node) == FUNCTION_DECL)
    4822              :     {
    4823           18 :       if (VOID_TYPE_P (TREE_TYPE (TREE_TYPE (*node))))
    4824            1 :         warning_at (DECL_SOURCE_LOCATION (*node),
    4825            1 :                     OPT_Wattributes, "%qE attribute applied to %qD with void "
    4826              :                     "return type", name, *node);
    4827              :     }
    4828           16 :   else if (RECORD_OR_UNION_TYPE_P (*node)
    4829           12 :            || TREE_CODE (*node) == ENUMERAL_TYPE)
    4830              :     /* OK */;
    4831              :   else
    4832              :     {
    4833           10 :       pedwarn (input_location,
    4834           10 :                OPT_Wattributes, "%qE attribute can only be applied to "
    4835              :                "functions or to structure, union or enumeration types", name);
    4836           10 :       *no_add_attrs = true;
    4837              :     }
    4838           34 :   return NULL_TREE;
    4839              : }
    4840              : 
    4841              : /* Handle the standard [[noreturn]] attribute.  */
    4842              : 
    4843              : static tree
    4844           44 : handle_std_noreturn_attribute (tree *node, tree name, tree args,
    4845              :                                int flags, bool *no_add_attrs)
    4846              : {
    4847              :   /* Unlike GNU __attribute__ ((noreturn)), the standard [[noreturn]]
    4848              :      only applies to functions, not function pointers.  */
    4849           44 :   if (TREE_CODE (*node) == FUNCTION_DECL)
    4850           22 :     return handle_noreturn_attribute (node, name, args, flags, no_add_attrs);
    4851              :   else
    4852              :     {
    4853           22 :       pedwarn (input_location, OPT_Wattributes,
    4854              :                "standard %qE attribute can only be applied to functions",
    4855              :                name);
    4856           22 :       *no_add_attrs = true;
    4857           22 :       return NULL_TREE;
    4858              :     }
    4859              : }
    4860              : 
    4861              : /* Handle the standard [[unsequenced]] attribute.  */
    4862              : 
    4863              : static tree
    4864           68 : handle_std_unsequenced_attribute (tree *node, tree name, tree args,
    4865              :                                   int flags, bool *no_add_attrs)
    4866              : {
    4867              :   /* Unlike GNU __attribute__ ((unsequenced)), the standard [[unsequenced]]
    4868              :      should be only applied to function declarators or type specifiers which
    4869              :      have function type.  */
    4870           68 :   if (node[2])
    4871              :     {
    4872            8 :       auto_diagnostic_group d;
    4873            8 :       if (pedwarn (input_location, OPT_Wattributes,
    4874              :                    "standard %qE attribute can only be applied to function "
    4875              :                    "declarators or type specifiers with function type", name))
    4876            8 :         inform (input_location, "did you mean to specify it after %<)%> "
    4877              :                                 "following function parameters?");
    4878            8 :       *no_add_attrs = true;
    4879            8 :       return NULL_TREE;
    4880            8 :     }
    4881           60 :   return handle_unsequenced_attribute (node, name, args, flags, no_add_attrs);
    4882              : }
    4883              : 
    4884              : /* Handle the standard [[reproducible]] attribute.  */
    4885              : 
    4886              : static tree
    4887           34 : handle_std_reproducible_attribute (tree *node, tree name, tree args,
    4888              :                                    int flags, bool *no_add_attrs)
    4889              : {
    4890           34 :   return handle_std_unsequenced_attribute (node, name, args, flags,
    4891           34 :                                            no_add_attrs);
    4892              : }
    4893              : 
    4894              : /* Table of supported standard (C23) attributes.  */
    4895              : static const attribute_spec std_attributes[] =
    4896              : {
    4897              :   /* { name, min_len, max_len, decl_req, type_req, fn_type_req,
    4898              :        affects_type_identity, handler, exclude } */
    4899              :   { "_Noreturn", 0, 0, false, false, false, false,
    4900              :     handle_std_noreturn_attribute, NULL },
    4901              :   { "deprecated", 0, 1, false, false, false, false,
    4902              :     handle_deprecated_attribute, NULL },
    4903              :   { "fallthrough", 0, 0, false, false, false, false,
    4904              :     handle_fallthrough_attribute, NULL },
    4905              :   { "maybe_unused", 0, 0, false, false, false, false,
    4906              :     handle_unused_attribute, NULL },
    4907              :   { "nodiscard", 0, 1, false, false, false, false,
    4908              :     handle_nodiscard_attribute, NULL },
    4909              :   { "noreturn", 0, 0, false, false, false, false,
    4910              :     handle_std_noreturn_attribute, NULL },
    4911              :   { "reproducible", 0, 0, false, true, true, false,
    4912              :     handle_std_reproducible_attribute, NULL },
    4913              :   { "unsequenced", 0, 0, false, true, true, false,
    4914              :     handle_std_unsequenced_attribute, NULL }
    4915              : };
    4916              : 
    4917              : const scoped_attribute_specs std_attribute_table =
    4918              : {
    4919              :   nullptr, { std_attributes }
    4920              : };
    4921              : 
    4922              : /* Create the predefined scalar types of C,
    4923              :    and some nodes representing standard constants (0, 1, (void *) 0).
    4924              :    Initialize the global scope.
    4925              :    Make definitions for built-in primitive functions.  */
    4926              : 
    4927              : void
    4928       111205 : c_init_decl_processing (void)
    4929              : {
    4930       111205 :   location_t save_loc = input_location;
    4931              : 
    4932              :   /* Initialize reserved words for parser.  */
    4933       111205 :   c_parse_init ();
    4934              : 
    4935       111205 :   current_function_decl = NULL_TREE;
    4936              : 
    4937       111205 :   gcc_obstack_init (&parser_obstack);
    4938              : 
    4939              :   /* Make the externals scope.  */
    4940       111205 :   push_scope ();
    4941       111205 :   external_scope = current_scope;
    4942              : 
    4943              :   /* Declarations from c_common_nodes_and_builtins must not be associated
    4944              :      with this input file, lest we get differences between using and not
    4945              :      using preprocessed headers.  */
    4946       111205 :   input_location = BUILTINS_LOCATION;
    4947              : 
    4948       111205 :   c_common_nodes_and_builtins ();
    4949              : 
    4950              :   /* In C, comparisons and TRUTH_* expressions have type int.  */
    4951       111205 :   truthvalue_type_node = integer_type_node;
    4952       111205 :   truthvalue_true_node = integer_one_node;
    4953       111205 :   truthvalue_false_node = integer_zero_node;
    4954              : 
    4955              :   /* Even in C99, which has a real boolean type.  */
    4956       111205 :   pushdecl (build_decl (UNKNOWN_LOCATION, TYPE_DECL, get_identifier ("_Bool"),
    4957              :                         boolean_type_node));
    4958              : 
    4959              :   /* C-specific nullptr initialization.  */
    4960       111205 :   record_builtin_type (RID_MAX, "typeof (nullptr)", nullptr_type_node);
    4961              :   /* The size and alignment of nullptr_t is the same as for a pointer to
    4962              :      character type.  */
    4963       111205 :   SET_TYPE_ALIGN (nullptr_type_node, GET_MODE_ALIGNMENT (ptr_mode));
    4964              : 
    4965       111205 :   input_location = save_loc;
    4966              : 
    4967       111205 :   make_fname_decl = c_make_fname_decl;
    4968       111205 :   start_fname_decls ();
    4969              : 
    4970       111205 :   if (warn_keyword_macro)
    4971              :     {
    4972         1165 :       for (unsigned int i = 0; i < num_c_common_reswords; ++i)
    4973              :         /* For C register keywords which don't start with underscore
    4974              :            or start with just single underscore.  Don't complain about
    4975              :            ObjC or Transactional Memory keywords.  */
    4976         1160 :         if (c_common_reswords[i].word[0] == '_'
    4977          530 :             && c_common_reswords[i].word[1] == '_')
    4978          390 :           continue;
    4979          995 :         else if (c_common_reswords[i].disable
    4980          770 :                  & (D_TRANSMEM | D_OBJC | D_CXX_OBJC))
    4981          225 :           continue;
    4982              :         else
    4983              :           {
    4984          545 :             tree id = get_identifier (c_common_reswords[i].word);
    4985          545 :             if (C_IS_RESERVED_WORD (id)
    4986          545 :                 && C_RID_CODE (id) != RID_CXX_COMPAT_WARN)
    4987          332 :               cpp_warn (parse_in, IDENTIFIER_POINTER (id),
    4988          332 :                         IDENTIFIER_LENGTH (id));
    4989              :           }
    4990              :     }
    4991       111205 : }
    4992              : 
    4993              : /* Create the VAR_DECL at LOC for __FUNCTION__ etc. ID is the name to
    4994              :    give the decl, NAME is the initialization string and TYPE_DEP
    4995              :    indicates whether NAME depended on the type of the function.  As we
    4996              :    don't yet implement delayed emission of static data, we mark the
    4997              :    decl as emitted so it is not placed in the output.  Anything using
    4998              :    it must therefore pull out the STRING_CST initializer directly.
    4999              :    FIXME.  */
    5000              : 
    5001              : static tree
    5002         2936 : c_make_fname_decl (location_t loc, tree id, int type_dep)
    5003              : {
    5004         2936 :   const char *name = fname_as_string (type_dep);
    5005         2936 :   tree decl, type, init;
    5006         2936 :   size_t length = strlen (name);
    5007              : 
    5008         2936 :   type = c_build_array_type (char_type_node,
    5009         2936 :                              build_index_type (size_int (length)));
    5010         2936 :   type = c_build_qualified_type (type, TYPE_QUAL_CONST);
    5011              : 
    5012         2936 :   decl = build_decl (loc, VAR_DECL, id, type);
    5013              : 
    5014         2936 :   TREE_STATIC (decl) = 1;
    5015         2936 :   TREE_READONLY (decl) = 1;
    5016         2936 :   DECL_ARTIFICIAL (decl) = 1;
    5017              : 
    5018         2936 :   init = build_string (length + 1, name);
    5019         2936 :   free (const_cast<char *> (name));
    5020         2936 :   TREE_TYPE (init) = type;
    5021         2936 :   DECL_INITIAL (decl) = init;
    5022              : 
    5023         2936 :   TREE_USED (decl) = 1;
    5024              : 
    5025         2936 :   if (current_function_decl
    5026              :       /* For invalid programs like this:
    5027              : 
    5028              :          void foo()
    5029              :          const char* p = __FUNCTION__;
    5030              : 
    5031              :          the __FUNCTION__ is believed to appear in K&R style function
    5032              :          parameter declarator.  In that case we still don't have
    5033              :          function_scope.  */
    5034         2929 :       && current_function_scope)
    5035              :     {
    5036         2921 :       DECL_CONTEXT (decl) = current_function_decl;
    5037         2921 :       bind (id, decl, current_function_scope,
    5038              :             /*invisible=*/false, /*nested=*/false, UNKNOWN_LOCATION);
    5039              :     }
    5040              : 
    5041         2936 :   finish_decl (decl, loc, init, NULL_TREE, NULL_TREE);
    5042              : 
    5043         2936 :   return decl;
    5044              : }
    5045              : 
    5046              : tree
    5047    324777813 : c_builtin_function (tree decl)
    5048              : {
    5049    324777813 :   tree type = TREE_TYPE (decl);
    5050    324777813 :   tree   id = DECL_NAME (decl);
    5051              : 
    5052    324777813 :   const char *name = IDENTIFIER_POINTER (id);
    5053    324777813 :   C_DECL_BUILTIN_PROTOTYPE (decl) = prototype_p (type);
    5054              : 
    5055              :   /* Should never be called on a symbol with a preexisting meaning.  */
    5056    324777813 :   gcc_assert (!I_SYMBOL_BINDING (id));
    5057              : 
    5058    324777813 :   bind (id, decl, external_scope, /*invisible=*/true, /*nested=*/false,
    5059              :         UNKNOWN_LOCATION);
    5060              : 
    5061              :   /* Builtins in the implementation namespace are made visible without
    5062              :      needing to be explicitly declared.  See push_file_scope.  */
    5063    324777813 :   if (name[0] == '_' && (name[1] == '_' || ISUPPER (name[1])))
    5064              :     {
    5065    221631652 :       DECL_CHAIN (decl) = visible_builtins;
    5066    221631652 :       visible_builtins = decl;
    5067              :     }
    5068              : 
    5069    324777813 :   return decl;
    5070              : }
    5071              : 
    5072              : tree
    5073     10503465 : c_builtin_function_ext_scope (tree decl)
    5074              : {
    5075     10503465 :   tree type = TREE_TYPE (decl);
    5076     10503465 :   tree   id = DECL_NAME (decl);
    5077              : 
    5078     10503465 :   const char *name = IDENTIFIER_POINTER (id);
    5079     10503465 :   C_DECL_BUILTIN_PROTOTYPE (decl) = prototype_p (type);
    5080              : 
    5081     10503465 :   if (external_scope)
    5082     10316455 :     bind (id, decl, external_scope, /*invisible=*/false, /*nested=*/false,
    5083              :           UNKNOWN_LOCATION);
    5084              : 
    5085              :   /* Builtins in the implementation namespace are made visible without
    5086              :      needing to be explicitly declared.  See push_file_scope.  */
    5087     10503465 :   if (name[0] == '_' && (name[1] == '_' || ISUPPER (name[1])))
    5088              :     {
    5089     10503465 :       DECL_CHAIN (decl) = visible_builtins;
    5090     10503465 :       visible_builtins = decl;
    5091              :     }
    5092              : 
    5093     10503465 :   return decl;
    5094              : }
    5095              : 
    5096              : /* Implement LANG_HOOKS_SIMULATE_BUILTIN_FUNCTION_DECL.  */
    5097              : 
    5098              : tree
    5099            0 : c_simulate_builtin_function_decl (tree decl)
    5100              : {
    5101            0 :   tree type = TREE_TYPE (decl);
    5102            0 :   C_DECL_BUILTIN_PROTOTYPE (decl) = prototype_p (type);
    5103            0 :   return pushdecl (decl);
    5104              : }
    5105              : 
    5106              : /* Warn about attributes in a context where they are unused
    5107              :    (attribute-declarations, except for the "fallthrough" case, and
    5108              :    attributes on statements).  */
    5109              : 
    5110              : void
    5111     41598620 : c_warn_unused_attributes (tree attrs)
    5112              : {
    5113     41598665 :   for (tree t = attrs; t != NULL_TREE; t = TREE_CHAIN (t))
    5114           45 :     if (get_attribute_namespace (t) == NULL_TREE)
    5115              :       /* The specifications of standard attributes mean this is a
    5116              :          constraint violation.  */
    5117           29 :       pedwarn (input_location, OPT_Wattributes, "%qE attribute ignored",
    5118              :                get_attribute_name (t));
    5119           16 :     else if (!attribute_ignored_p (t))
    5120           12 :       warning (OPT_Wattributes, "%qE attribute ignored",
    5121              :                get_attribute_name (t));
    5122     41598620 : }
    5123              : 
    5124              : /* Warn for standard attributes being applied to a type that is not
    5125              :    being defined, where that is a constraint violation, and return a
    5126              :    list of attributes with them removed.  */
    5127              : 
    5128              : tree
    5129    435865506 : c_warn_type_attributes (tree type, tree attrs)
    5130              : {
    5131    435865506 :   tree *attr_ptr = &attrs;
    5132    435888766 :   while (*attr_ptr)
    5133        23260 :     if (get_attribute_namespace (*attr_ptr) == NULL_TREE)
    5134              :       {
    5135           89 :         if (TREE_CODE (type) == FUNCTION_TYPE)
    5136              :           {
    5137           65 :             tree name = get_attribute_name (*attr_ptr);
    5138              :             /* [[unsequenced]] and [[reproducible]] is fine on function
    5139              :                types that aren't being defined.  */
    5140           65 :             if (is_attribute_p ("unsequenced", name)
    5141           65 :                 || is_attribute_p ("reproducible", name))
    5142              :               {
    5143           60 :                 attr_ptr = &TREE_CHAIN (*attr_ptr);
    5144           60 :                 continue;
    5145              :               }
    5146              :           }
    5147           29 :         pedwarn (input_location, OPT_Wattributes, "%qE attribute ignored",
    5148              :                  get_attribute_name (*attr_ptr));
    5149           29 :         *attr_ptr = TREE_CHAIN (*attr_ptr);
    5150              :       }
    5151              :     else
    5152        23171 :       attr_ptr = &TREE_CHAIN (*attr_ptr);
    5153    435865506 :   return attrs;
    5154              : }
    5155              : 
    5156              : /* Called when a declaration is seen that contains no names to declare.
    5157              :    If its type is a reference to a structure, union or enum inherited
    5158              :    from a containing scope, shadow that tag name for the current scope
    5159              :    with a forward reference.
    5160              :    If its type defines a new named structure or union
    5161              :    or defines an enum, it is valid but we need not do anything here.
    5162              :    Otherwise, it is an error.  */
    5163              : 
    5164              : void
    5165       502432 : shadow_tag (const struct c_declspecs *declspecs)
    5166              : {
    5167       502432 :   shadow_tag_warned (declspecs, 0);
    5168       502432 : }
    5169              : 
    5170              : /* WARNED is 1 if we have done a pedwarn, 2 if we have done a warning,
    5171              :    but no pedwarn.  */
    5172              : void
    5173       502502 : shadow_tag_warned (const struct c_declspecs *declspecs, int warned)
    5174              : {
    5175       502502 :   bool found_tag = false;
    5176              : 
    5177       502502 :   if (declspecs->type && !declspecs->default_int_p && !declspecs->typedef_p)
    5178              :     {
    5179       502388 :       tree value = declspecs->type;
    5180       502388 :       enum tree_code code = TREE_CODE (value);
    5181              : 
    5182       502388 :       if (code == RECORD_TYPE || code == UNION_TYPE || code == ENUMERAL_TYPE)
    5183              :         /* Used to test also that TYPE_SIZE (value) != 0.
    5184              :            That caused warning for `struct foo;' at top level in the file.  */
    5185              :         {
    5186       502337 :           tree name = TYPE_NAME (value);
    5187       502337 :           tree t;
    5188              : 
    5189       502337 :           found_tag = true;
    5190              : 
    5191       502337 :           if (declspecs->restrict_p)
    5192              :             {
    5193            2 :               error ("invalid use of %<restrict%>");
    5194            2 :               warned = 1;
    5195              :             }
    5196              : 
    5197       502337 :           if (in_underspecified_init)
    5198              :             {
    5199              :               /* This can only occur with extensions such as statement
    5200              :                  expressions, but is still appropriate as an error to
    5201              :                  avoid types declared in such a context escaping to
    5202              :                  the type of an auto variable.  */
    5203            1 :               error ("%qT declared in underspecified object initializer",
    5204              :                      value);
    5205            1 :               warned = 1;
    5206              :             }
    5207              : 
    5208       502337 :           if (name == NULL_TREE)
    5209              :             {
    5210        60005 :               if (warned != 1 && code != ENUMERAL_TYPE)
    5211              :                 /* Empty unnamed enum OK */
    5212              :                 {
    5213           19 :                   pedwarn (input_location, 0,
    5214              :                            "unnamed struct/union that defines no instances");
    5215           19 :                   warned = 1;
    5216              :                 }
    5217              :             }
    5218       442332 :           else if (declspecs->typespec_kind != ctsk_tagdef
    5219        88130 :                    && declspecs->typespec_kind != ctsk_tagfirstref
    5220        26213 :                    && declspecs->typespec_kind != ctsk_tagfirstref_attrs
    5221        26205 :                    && declspecs->storage_class != csc_none)
    5222              :             {
    5223            2 :               if (warned != 1)
    5224            2 :                 pedwarn (input_location, 0,
    5225              :                          "empty declaration with storage class specifier "
    5226              :                          "does not redeclare tag");
    5227            2 :               warned = 1;
    5228            2 :               pending_xref_error ();
    5229              :             }
    5230       442330 :           else if (declspecs->typespec_kind != ctsk_tagdef
    5231        88128 :                    && declspecs->typespec_kind != ctsk_tagfirstref
    5232        26211 :                    && declspecs->typespec_kind != ctsk_tagfirstref_attrs
    5233        26203 :                    && (declspecs->const_p
    5234        26200 :                        || declspecs->volatile_p
    5235        26200 :                        || declspecs->atomic_p
    5236        26200 :                        || declspecs->restrict_p
    5237        26200 :                        || declspecs->address_space))
    5238              :             {
    5239            3 :               if (warned != 1)
    5240            3 :                 pedwarn (input_location, 0,
    5241              :                          "empty declaration with type qualifier "
    5242              :                           "does not redeclare tag");
    5243            3 :               warned = 1;
    5244            3 :               pending_xref_error ();
    5245              :             }
    5246       442327 :           else if (declspecs->typespec_kind != ctsk_tagdef
    5247        88125 :                    && declspecs->typespec_kind != ctsk_tagfirstref
    5248        26208 :                    && declspecs->typespec_kind != ctsk_tagfirstref_attrs
    5249        26200 :                    && declspecs->alignas_p)
    5250              :             {
    5251            1 :               if (warned != 1)
    5252            1 :                 pedwarn (input_location, 0,
    5253              :                          "empty declaration with %<_Alignas%> "
    5254              :                           "does not redeclare tag");
    5255            1 :               warned = 1;
    5256            1 :               pending_xref_error ();
    5257              :             }
    5258       442326 :           else if (declspecs->typespec_kind != ctsk_tagdef
    5259        88124 :                    && declspecs->typespec_kind != ctsk_tagfirstref
    5260        26207 :                    && declspecs->typespec_kind != ctsk_tagfirstref_attrs
    5261        26199 :                    && code == ENUMERAL_TYPE
    5262           15 :                    && !declspecs->enum_type_specifier_ref_p)
    5263              :             {
    5264            3 :               bool warned_enum = false;
    5265            3 :               if (warned != 1)
    5266            3 :                 warned_enum = pedwarn (input_location, OPT_Wpedantic,
    5267              :                                        "empty declaration of %<enum%> type "
    5268              :                                        "does not redeclare tag");
    5269            3 :               if (warned_enum)
    5270            2 :                 warned = 1;
    5271            3 :               pending_xref_error ();
    5272            3 :             }
    5273              :           else
    5274              :             {
    5275       442323 :               pending_invalid_xref = NULL_TREE;
    5276       442323 :               t = lookup_tag (code, name, true, NULL);
    5277              : 
    5278       442323 :               if (t == NULL_TREE)
    5279              :                 {
    5280            2 :                   t = make_node (code);
    5281            2 :                   if (flag_isoc23 || code == ENUMERAL_TYPE)
    5282            1 :                     SET_TYPE_STRUCTURAL_EQUALITY (t);
    5283            2 :                   pushtag (input_location, name, t);
    5284              :                 }
    5285              :             }
    5286              :         }
    5287              :       else
    5288              :         {
    5289           51 :           if (warned != 1 && !in_system_header_at (input_location))
    5290              :             {
    5291           44 :               pedwarn (input_location, 0,
    5292              :                        "useless type name in empty declaration");
    5293           44 :               warned = 1;
    5294              :             }
    5295              :         }
    5296              :     }
    5297           71 :   else if (warned != 1 && !in_system_header_at (input_location)
    5298          185 :            && declspecs->typedef_p)
    5299              :     {
    5300           11 :       pedwarn (input_location, 0, "useless type name in empty declaration");
    5301           11 :       warned = 1;
    5302              :     }
    5303              : 
    5304       502502 :   pending_invalid_xref = NULL_TREE;
    5305              : 
    5306       502502 :   if (declspecs->inline_p)
    5307              :     {
    5308            5 :       error ("%<inline%> in empty declaration");
    5309            5 :       warned = 1;
    5310              :     }
    5311              : 
    5312       502502 :   if (declspecs->noreturn_p)
    5313              :     {
    5314            2 :       error ("%<_Noreturn%> in empty declaration");
    5315            2 :       warned = 1;
    5316              :     }
    5317              : 
    5318       502502 :   if (declspecs->constexpr_p)
    5319              :     {
    5320            7 :       error ("%<constexpr%> in empty declaration");
    5321            7 :       warned = 1;
    5322              :     }
    5323              : 
    5324       502502 :   if (current_scope == file_scope && declspecs->storage_class == csc_auto)
    5325              :     {
    5326            2 :       error ("%<auto%> in file-scope empty declaration");
    5327            2 :       warned = 1;
    5328              :     }
    5329              : 
    5330       502502 :   if (current_scope == file_scope && declspecs->storage_class == csc_register)
    5331              :     {
    5332            2 :       error ("%<register%> in file-scope empty declaration");
    5333            2 :       warned = 1;
    5334              :     }
    5335              : 
    5336       502502 :   if (declspecs->enum_type_specifier_ref_p && !warned)
    5337              :     {
    5338           39 :       if (declspecs->storage_class != csc_none)
    5339              :         {
    5340            1 :           error ("storage class specifier in empty declaration with %<enum%> "
    5341              :                  "underlying type");
    5342            1 :           warned = 1;
    5343              :         }
    5344           38 :       else if (declspecs->thread_p)
    5345              :         {
    5346            2 :           error ("%qs in empty declaration with %<enum%> underlying type",
    5347            1 :                  declspecs->thread_gnu_p ? "__thread" : "_Thread_local");
    5348            1 :           warned = 1;
    5349              :         }
    5350           37 :       else if (declspecs->const_p
    5351           36 :                || declspecs->volatile_p
    5352           36 :                || declspecs->atomic_p
    5353           36 :                || declspecs->restrict_p
    5354           36 :                || declspecs->address_space)
    5355              :         {
    5356            1 :           error ("type qualifier in empty declaration with %<enum%> "
    5357              :                  "underlying type");
    5358            1 :           warned = 1;
    5359              :         }
    5360           36 :       else if (declspecs->alignas_p)
    5361              :         {
    5362            1 :           error ("%<alignas%> in empty declaration with %<enum%> "
    5363              :                  "underlying type");
    5364            1 :           warned = 1;
    5365              :         }
    5366              :     }
    5367              : 
    5368       502334 :   if (!warned && !in_system_header_at (input_location)
    5369       620706 :       && declspecs->storage_class != csc_none)
    5370              :     {
    5371           12 :       warning (0, "useless storage class specifier in empty declaration");
    5372           12 :       warned = 2;
    5373              :     }
    5374              : 
    5375       502502 :   if (!warned && !in_system_header_at (input_location) && declspecs->thread_p)
    5376              :     {
    5377            3 :       warning (0, "useless %qs in empty declaration",
    5378            3 :                declspecs->thread_gnu_p ? "__thread" : "_Thread_local");
    5379            3 :       warned = 2;
    5380              :     }
    5381              : 
    5382            3 :   if (!warned
    5383       502315 :       && !in_system_header_at (input_location)
    5384       620696 :       && (declspecs->const_p
    5385       118189 :           || declspecs->volatile_p
    5386       118189 :           || declspecs->atomic_p
    5387       118189 :           || declspecs->restrict_p
    5388       118189 :           || declspecs->address_space))
    5389              :     {
    5390            8 :       warning (0, "useless type qualifier in empty declaration");
    5391            8 :       warned = 2;
    5392              :     }
    5393              : 
    5394       502315 :   if (!warned && !in_system_header_at (input_location)
    5395       620683 :       && declspecs->alignas_p)
    5396              :     {
    5397            4 :       warning (0, "useless %<_Alignas%> in empty declaration");
    5398            4 :       warned = 2;
    5399              :     }
    5400              : 
    5401       502502 :   if (found_tag
    5402       502502 :       && warned == 2
    5403           23 :       && (declspecs->typespec_kind == ctsk_tagref_attrs
    5404           23 :           || declspecs->typespec_kind == ctsk_tagfirstref_attrs))
    5405              :     {
    5406              :       /* Standard attributes after the "struct" or "union" keyword are
    5407              :          only permitted when the contents of the type are defined, or
    5408              :          in the form "struct-or-union attribute-specifier-sequence
    5409              :          identifier;".  If the ';' was not present, attributes were
    5410              :          diagnosed in the parser.  Here, ensure that any other useless
    5411              :          elements of the declaration result in a pedwarn, not just a
    5412              :          warning.  Forward declarations of enum types are not part of
    5413              :          standard C, but handle them the same.  */
    5414            2 :       pedwarn (input_location, 0,
    5415              :                "invalid use of attributes in empty declaration");
    5416            2 :       warned = 1;
    5417              :     }
    5418              : 
    5419       502502 :   if (warned != 1)
    5420              :     {
    5421       502328 :       if (declspecs->declspecs_seen_p
    5422       502328 :           && !declspecs->non_std_attrs_seen_p)
    5423              :         /* An attribute declaration (but not a fallthrough attribute
    5424              :            declaration, which was handled separately); warn if there
    5425              :            are any attributes being ignored (but not if the attributes
    5426              :            were empty).  */
    5427           48 :         c_warn_unused_attributes (declspecs->attrs);
    5428       502280 :       else if (!found_tag)
    5429           10 :         pedwarn (input_location, 0, "empty declaration");
    5430              :     }
    5431       502502 : }
    5432              : 
    5433              : 
    5434              : /* Return the qualifiers from SPECS as a bitwise OR of TYPE_QUAL_*
    5435              :    bits.  SPECS represents declaration specifiers that the grammar
    5436              :    only permits to contain type qualifiers and attributes.  */
    5437              : 
    5438              : int
    5439     18242673 : quals_from_declspecs (const struct c_declspecs *specs)
    5440              : {
    5441     18242673 :   int quals = ((specs->const_p ? TYPE_QUAL_CONST : 0)
    5442              :                | (specs->volatile_p ? TYPE_QUAL_VOLATILE : 0)
    5443              :                | (specs->restrict_p ? TYPE_QUAL_RESTRICT : 0)
    5444     18242673 :                | (specs->atomic_p ? TYPE_QUAL_ATOMIC : 0)
    5445     18242673 :                | (ENCODE_QUAL_ADDR_SPACE (specs->address_space)));
    5446     18242673 :   gcc_assert (!specs->type
    5447              :               && !specs->decl_attr
    5448              :               && specs->typespec_word == cts_none
    5449              :               && specs->storage_class == csc_none
    5450              :               && !specs->typedef_p
    5451              :               && !specs->explicit_signed_p
    5452              :               && !specs->deprecated_p
    5453              :               && !specs->unavailable_p
    5454              :               && !specs->long_p
    5455              :               && !specs->long_long_p
    5456              :               && !specs->short_p
    5457              :               && !specs->signed_p
    5458              :               && !specs->unsigned_p
    5459              :               && !specs->complex_p
    5460              :               && !specs->inline_p
    5461              :               && !specs->noreturn_p
    5462              :               && !specs->thread_p);
    5463     18242673 :   return quals;
    5464              : }
    5465              : 
    5466              : /* Construct an array declarator.  LOC is the location of the
    5467              :    beginning of the array (usually the opening brace).  EXPR is the
    5468              :    expression inside [], or NULL_TREE.  QUALS are the type qualifiers
    5469              :    inside the [] (to be applied to the pointer to which a parameter
    5470              :    array is converted).  STATIC_P is true if "static" is inside the
    5471              :    [], false otherwise.  VLA_UNSPEC_P is true if the array is [*], a
    5472              :    VLA of unspecified length which is nevertheless a complete type,
    5473              :    false otherwise.  The field for the contained declarator is left to
    5474              :    be filled in by set_array_declarator_inner.  */
    5475              : 
    5476              : struct c_declarator *
    5477      1154381 : build_array_declarator (location_t loc,
    5478              :                         tree expr, struct c_declspecs *quals, bool static_p,
    5479              :                         bool vla_unspec_p)
    5480              : {
    5481      1154381 :   struct c_declarator *declarator = XOBNEW (&parser_obstack,
    5482              :                                             struct c_declarator);
    5483      1154381 :   declarator->id_loc = loc;
    5484      1154381 :   declarator->kind = cdk_array;
    5485      1154381 :   declarator->declarator = 0;
    5486      1154381 :   declarator->u.array.dimen = expr;
    5487      1154381 :   if (quals)
    5488              :     {
    5489          966 :       declarator->u.array.attrs = quals->attrs;
    5490          966 :       declarator->u.array.quals = quals_from_declspecs (quals);
    5491              :     }
    5492              :   else
    5493              :     {
    5494      1153415 :       declarator->u.array.attrs = NULL_TREE;
    5495      1153415 :       declarator->u.array.quals = 0;
    5496              :     }
    5497      1154381 :   declarator->u.array.static_p = static_p;
    5498      1154381 :   declarator->u.array.vla_unspec_p = vla_unspec_p;
    5499      1154381 :   if (static_p || quals != NULL)
    5500         1069 :     pedwarn_c90 (loc, OPT_Wpedantic,
    5501              :                  "ISO C90 does not support %<static%> or type "
    5502              :                  "qualifiers in parameter array declarators");
    5503      1154381 :   if (vla_unspec_p)
    5504              :     {
    5505          151 :       pedwarn_c90 (loc, OPT_Wpedantic,
    5506              :                    "ISO C90 does not support %<[*]%> array declarators");
    5507          151 :       if (current_scope->parm_flag)
    5508          143 :         current_scope->had_vla_unspec = true;
    5509              :     }
    5510      1154381 :   return declarator;
    5511              : }
    5512              : 
    5513              : /* Set the contained declarator of an array declarator.  DECL is the
    5514              :    declarator, as constructed by build_array_declarator; INNER is what
    5515              :    appears on the left of the [].  */
    5516              : 
    5517              : struct c_declarator *
    5518      1154381 : set_array_declarator_inner (struct c_declarator *decl,
    5519              :                             struct c_declarator *inner)
    5520              : {
    5521      1154381 :   decl->declarator = inner;
    5522      1154381 :   return decl;
    5523              : }
    5524              : 
    5525              : /* Determine whether TYPE is a one-element array type "[1]".  */
    5526              : static bool
    5527       534517 : one_element_array_type_p (const_tree type)
    5528              : {
    5529       534517 :   if (TREE_CODE (type) != ARRAY_TYPE)
    5530              :     return false;
    5531       534517 :   return integer_zerop (array_type_nelts_minus_one (type));
    5532              : }
    5533              : 
    5534              : /* Determine whether TYPE is a zero-length array type "[0]".  */
    5535              : static bool
    5536       534517 : zero_length_array_type_p (const_tree type)
    5537              : {
    5538       534517 :   if (TREE_CODE (type) == ARRAY_TYPE)
    5539       534517 :     if (tree type_size = TYPE_SIZE_UNIT (type))
    5540       448528 :       if ((integer_zerop (type_size))
    5541         1824 :            && TYPE_DOMAIN (type) != NULL_TREE
    5542       450352 :            && TYPE_MAX_VALUE (TYPE_DOMAIN (type)) == NULL_TREE)
    5543              :         return true;
    5544              :   return false;
    5545              : }
    5546              : 
    5547              : /* INIT is a constructor that forms DECL's initializer.  If the final
    5548              :    element initializes a flexible array field, adjust the size of the
    5549              :    DECL with the initializer based on whether the DECL is a union or
    5550              :    a structure.  */
    5551              : 
    5552              : static void
    5553       105013 : add_flexible_array_elts_to_size (tree decl, tree init)
    5554              : {
    5555       105013 :   tree elt, type;
    5556              : 
    5557       105013 :   if (vec_safe_is_empty (CONSTRUCTOR_ELTS (init)))
    5558         1462 :     return;
    5559              : 
    5560       103551 :   elt = CONSTRUCTOR_ELTS (init)->last ().value;
    5561       103551 :   type = TREE_TYPE (elt);
    5562       103551 :   if (c_flexible_array_member_type_p (type))
    5563              :     {
    5564          221 :       complete_array_type (&type, elt, false);
    5565              :       /* For a structure, add the size of the initializer to the DECL's
    5566              :          size.  */
    5567          221 :       if (TREE_CODE (TREE_TYPE (decl)) == RECORD_TYPE)
    5568              :         {
    5569          211 :           DECL_SIZE (decl)
    5570          211 :             = size_binop (PLUS_EXPR, DECL_SIZE (decl), TYPE_SIZE (type));
    5571          211 :           DECL_SIZE_UNIT (decl)
    5572          422 :             = size_binop (PLUS_EXPR, DECL_SIZE_UNIT (decl),
    5573              :                           TYPE_SIZE_UNIT (type));
    5574              :         }
    5575              :       /* For a union, the DECL's size is the maximum of the current size
    5576              :          and the size of the initializer.  */
    5577              :       else
    5578              :         {
    5579           10 :           DECL_SIZE (decl)
    5580           10 :             = size_binop (MAX_EXPR, DECL_SIZE (decl), TYPE_SIZE (type));
    5581           10 :           DECL_SIZE_UNIT (decl)
    5582           20 :             = size_binop (MAX_EXPR, DECL_SIZE_UNIT (decl),
    5583              :                           TYPE_SIZE_UNIT (type));
    5584              :         }
    5585              :     }
    5586              : }
    5587              : 
    5588              : /* Decode a "typename", such as "int **", returning a ..._TYPE node.
    5589              :    Set *EXPR, if EXPR not NULL, to any expression to be evaluated
    5590              :    before the type name, and set *EXPR_CONST_OPERANDS, if
    5591              :    EXPR_CONST_OPERANDS not NULL, to indicate whether the type name may
    5592              :    appear in a constant expression.  */
    5593              : 
    5594              : tree
    5595    121573269 : groktypename (struct c_type_name *type_name, tree *expr,
    5596              :               bool *expr_const_operands)
    5597              : {
    5598    121573269 :   tree type;
    5599    121573269 :   tree attrs = type_name->specs->attrs;
    5600              : 
    5601    121573269 :   type_name->specs->attrs = NULL_TREE;
    5602              : 
    5603    121573269 :   type = grokdeclarator (type_name->declarator, type_name->specs, TYPENAME,
    5604              :                          false, NULL, &attrs, expr, expr_const_operands,
    5605              :                          DEPRECATED_NORMAL);
    5606              : 
    5607              :   /* Apply attributes.  */
    5608    121573269 :   attrs = c_warn_type_attributes (type, attrs);
    5609    121573269 :   decl_attributes (&type, attrs, 0);
    5610              : 
    5611    121573269 :   return type;
    5612              : }
    5613              : 
    5614              : 
    5615              : /* Decode a "typename", such as "int **", returning a ..._TYPE node,
    5616              :    as for groktypename but setting the context to GENERIC_ASSOC.  */
    5617              : 
    5618              : tree
    5619          908 : grokgenassoc (struct c_type_name *type_name)
    5620              : {
    5621          908 :   tree type;
    5622          908 :   tree attrs = type_name->specs->attrs;
    5623              : 
    5624          908 :   type_name->specs->attrs = NULL_TREE;
    5625              : 
    5626          908 :   type = grokdeclarator (type_name->declarator, type_name->specs, GENERIC_ASSOC,
    5627              :                          false, NULL, &attrs, NULL, NULL, DEPRECATED_NORMAL);
    5628              : 
    5629              :   /* Apply attributes.  */
    5630          908 :   attrs = c_warn_type_attributes (type, attrs);
    5631          908 :   decl_attributes (&type, attrs, 0);
    5632              : 
    5633          908 :   return type;
    5634              : }
    5635              : 
    5636              : 
    5637              : /* Looks up the most recent pushed declaration corresponding to DECL.  */
    5638              : 
    5639              : static tree
    5640     92223968 : lookup_last_decl (tree decl)
    5641              : {
    5642     92223968 :   tree last_decl = lookup_name (DECL_NAME (decl));
    5643     92223968 :   if (!last_decl)
    5644     89662900 :     last_decl = lookup_name_in_scope (DECL_NAME (decl), external_scope);
    5645     92223968 :   return last_decl;
    5646              : }
    5647              : 
    5648              : /* Wrapper for decl_attributes that adds some implicit attributes
    5649              :    to VAR_DECLs or FUNCTION_DECLs.  */
    5650              : 
    5651              : static tree
    5652     64274257 : c_decl_attributes (tree *node, tree attributes, int flags)
    5653              : {
    5654              :   /* Add implicit "omp declare target" attribute if requested.  */
    5655     64274257 :   if (vec_safe_length (current_omp_declare_target_attribute)
    5656         9167 :       && ((VAR_P (*node) && is_global_var (*node))
    5657         2729 :           || TREE_CODE (*node) == FUNCTION_DECL))
    5658              :     {
    5659         1131 :       if (VAR_P (*node) && !omp_mappable_type (TREE_TYPE (*node)))
    5660           13 :         attributes = tree_cons (get_identifier ("omp declare target implicit"),
    5661              :                                 NULL_TREE, attributes);
    5662              :       else
    5663         1118 :         attributes = tree_cons (get_identifier ("omp declare target"),
    5664              :                                 NULL_TREE, attributes);
    5665         1131 :       if (TREE_CODE (*node) == FUNCTION_DECL)
    5666              :         {
    5667         1001 :           int device_type
    5668         1001 :             = current_omp_declare_target_attribute->last ().device_type;
    5669         1001 :           device_type = MAX (device_type, 0);
    5670         1001 :           if ((device_type & OMP_CLAUSE_DEVICE_TYPE_HOST) != 0
    5671         1001 :               && !lookup_attribute ("omp declare target host", attributes))
    5672            2 :             attributes
    5673            2 :               = tree_cons (get_identifier ("omp declare target host"),
    5674              :                            NULL_TREE, attributes);
    5675         1001 :           if ((device_type & OMP_CLAUSE_DEVICE_TYPE_NOHOST) != 0
    5676         1001 :               && !lookup_attribute ("omp declare target nohost", attributes))
    5677            2 :             attributes
    5678            2 :               = tree_cons (get_identifier ("omp declare target nohost"),
    5679              :                            NULL_TREE, attributes);
    5680              : 
    5681         1001 :           int indirect
    5682         1001 :             = current_omp_declare_target_attribute->last ().indirect;
    5683         1001 :           if (indirect && !lookup_attribute ("omp declare target indirect",
    5684              :                                              attributes))
    5685           10 :             attributes
    5686           10 :               = tree_cons (get_identifier ("omp declare target indirect"),
    5687              :                            NULL_TREE, attributes);
    5688              :         }
    5689              :     }
    5690              : 
    5691     64274257 :   if (flag_openmp || flag_openmp_simd)
    5692              :     {
    5693              :       bool diagnosed = false;
    5694      1367148 :       for (tree *pa = &attributes; *pa; )
    5695              :         {
    5696       881592 :           if (is_attribute_namespace_p ("omp", *pa))
    5697              :             {
    5698           65 :               tree name = get_attribute_name (*pa);
    5699           65 :               if (is_attribute_p ("directive", name)
    5700            0 :                   || is_attribute_p ("sequence", name)
    5701           65 :                   || is_attribute_p ("decl", name))
    5702              :                 {
    5703           65 :                   const char *p = NULL;
    5704           65 :                   if (TREE_VALUE (*pa) == NULL_TREE)
    5705           12 :                     p = IDENTIFIER_POINTER (name);
    5706          118 :                   for (tree a = TREE_VALUE (*pa); a; a = TREE_CHAIN (a))
    5707              :                     {
    5708           53 :                       tree d = TREE_VALUE (a);
    5709           53 :                       gcc_assert (TREE_CODE (d) == C_TOKEN_VEC);
    5710           96 :                       if (TREE_PUBLIC (d)
    5711           43 :                           && (VAR_P (*node)
    5712            2 :                               || TREE_CODE (*node) == FUNCTION_DECL)
    5713           96 :                           && c_maybe_parse_omp_decl (*node, d))
    5714           43 :                         continue;
    5715           10 :                       p = TREE_PUBLIC (d) ? "decl" : "directive";
    5716              :                     }
    5717           65 :                   if (p && !diagnosed)
    5718              :                     {
    5719           22 :                       error ("%<omp::%s%> not allowed to be specified in "
    5720              :                              "this context", p);
    5721           22 :                       diagnosed = true;
    5722              :                     }
    5723           65 :                   if (p)
    5724              :                     {
    5725           22 :                       *pa = TREE_CHAIN (*pa);
    5726           22 :                       continue;
    5727              :                     }
    5728              :                 }
    5729              :             }
    5730       881570 :           pa = &TREE_CHAIN (*pa);
    5731              :         }
    5732              :     }
    5733              : 
    5734              :   /* Look up the current declaration with all the attributes merged
    5735              :      so far so that attributes on the current declaration that's
    5736              :      about to be pushed that conflict with the former can be detected,
    5737              :      diagnosed, and rejected as appropriate.  To match the C++ FE, do
    5738              :      not pass an error_mark_node when we found an undeclared variable.  */
    5739     64274257 :   tree last_decl = lookup_last_decl (*node);
    5740     64274257 :   if (last_decl == error_mark_node)
    5741           20 :     last_decl = NULL_TREE;
    5742     64274257 :   tree attr = decl_attributes (node, attributes, flags, last_decl);
    5743     64274256 :   if (VAR_P (*node) && DECL_THREAD_LOCAL_P (*node))
    5744              :     {
    5745              :       // tls_model attribute can set a stronger TLS access model.
    5746         2838 :       tls_model model = DECL_TLS_MODEL (*node);
    5747         2838 :       tls_model default_model = decl_default_tls_model (*node);
    5748         2838 :       if (default_model > model)
    5749         1583 :         set_decl_tls_model (*node, default_model);
    5750              :     }
    5751     64274256 :   return attr;
    5752              : }
    5753              : 
    5754              : 
    5755              : /* Decode a declarator in an ordinary declaration or data definition.
    5756              :    This is called as soon as the type information and variable name
    5757              :    have been parsed, before parsing the initializer if any.
    5758              :    Here we create the ..._DECL node, fill in its type,
    5759              :    and (if DO_PUSH) put it on the list of decls for the current context.
    5760              :    When nonnull, set *LASTLOC to the location of the prior declaration
    5761              :    of the same entity if one exists.
    5762              :    The ..._DECL node is returned as the value.
    5763              : 
    5764              :    Exception: for arrays where the length is not specified,
    5765              :    the type is left null, to be filled in by `finish_decl'.
    5766              : 
    5767              :    Function definitions do not come here; they go to start_function
    5768              :    instead.  However, external and forward declarations of functions
    5769              :    do go through here.  Structure field declarations are done by
    5770              :    grokfield and not through here.  */
    5771              : 
    5772              : tree
    5773     27949735 : start_decl (struct c_declarator *declarator, struct c_declspecs *declspecs,
    5774              :             bool initialized, tree attributes, bool do_push /* = true */,
    5775              :             location_t *lastloc /* = NULL */)
    5776              : {
    5777     27949735 :   tree decl;
    5778     27949735 :   tree old_decl;
    5779     27949735 :   tree tem;
    5780     27949735 :   tree expr = NULL_TREE;
    5781     27949735 :   enum deprecated_states deprecated_state = DEPRECATED_NORMAL;
    5782              : 
    5783              :   /* An object declared as __attribute__((unavailable)) suppresses
    5784              :      warnings and errors from __attribute__((deprecated/unavailable))
    5785              :      components.
    5786              :      An object declared as __attribute__((deprecated)) suppresses
    5787              :      warnings of uses of other deprecated items.  */
    5788     27949735 :   if (lookup_attribute ("unavailable", attributes))
    5789              :     deprecated_state = UNAVAILABLE_DEPRECATED_SUPPRESS;
    5790     27949711 :   else if (lookup_attribute ("deprecated", attributes))
    5791        32301 :     deprecated_state = DEPRECATED_SUPPRESS;
    5792              : 
    5793     27949735 :   decl = grokdeclarator (declarator, declspecs,
    5794              :                          NORMAL, initialized, NULL, &attributes, &expr, NULL,
    5795              :                          deprecated_state);
    5796     27949735 :   if (!decl || decl == error_mark_node)
    5797              :     return NULL_TREE;
    5798              : 
    5799     27949711 :   old_decl = lookup_last_decl (decl);
    5800              : 
    5801     27949711 :   if (tree lastdecl = lastloc ? old_decl : NULL_TREE)
    5802      4750006 :     if (lastdecl != error_mark_node)
    5803      4749997 :       *lastloc = DECL_SOURCE_LOCATION (lastdecl);
    5804              : 
    5805              :   /* Make sure the size expression is evaluated at this point.  */
    5806     27949711 :   if (expr && !current_scope->parm_flag)
    5807        12974 :     add_stmt (fold_convert (void_type_node, expr));
    5808              : 
    5809     13267035 :   if (TREE_CODE (decl) != FUNCTION_DECL && MAIN_NAME_P (DECL_NAME (decl))
    5810     27949713 :       && TREE_PUBLIC (decl))
    5811            1 :     warning (OPT_Wmain, "%q+D is usually a function", decl);
    5812              : 
    5813           14 :   if (warn_missing_variable_declarations && VAR_P (decl)
    5814     27949724 :       && !DECL_EXTERNAL (decl) && TREE_PUBLIC (decl) && old_decl == NULL_TREE)
    5815            5 :     warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wmissing_variable_declarations,
    5816              :                 "no previous declaration for %qD", decl);
    5817              : 
    5818     27949711 :   if (initialized)
    5819              :     /* Is it valid for this decl to have an initializer at all?
    5820              :        If not, set INITIALIZED to zero, which will indirectly
    5821              :        tell 'finish_decl' to ignore the initializer once it is parsed.  */
    5822      6349269 :     switch (TREE_CODE (decl))
    5823              :       {
    5824            6 :       case TYPE_DECL:
    5825            6 :         error ("typedef %qD is initialized (use %<__typeof__%> instead)", decl);
    5826            6 :         initialized = false;
    5827            6 :         break;
    5828              : 
    5829            9 :       case FUNCTION_DECL:
    5830            9 :         error ("function %qD is initialized like a variable", decl);
    5831            9 :         initialized = false;
    5832            9 :         break;
    5833              : 
    5834           49 :       case PARM_DECL:
    5835              :         /* DECL_INITIAL in a PARM_DECL is really DECL_ARG_TYPE.  */
    5836           49 :         error ("parameter %qD is initialized", decl);
    5837           49 :         initialized = false;
    5838           49 :         break;
    5839              : 
    5840      6349205 :       default:
    5841              :         /* Don't allow initializations for incomplete types except for
    5842              :            arrays which might be completed by the initialization.  */
    5843              : 
    5844              :         /* This can happen if the array size is an undefined macro.
    5845              :            We already gave a warning, so we don't need another one.  */
    5846      6349205 :         if (TREE_TYPE (decl) == error_mark_node)
    5847              :           initialized = false;
    5848      6349183 :         else if (COMPLETE_TYPE_P (TREE_TYPE (decl)))
    5849              :           {
    5850              :             /* A complete type is ok if size is fixed.  If the size is
    5851              :                variable, an empty initializer is OK and nonempty
    5852              :                initializers will be diagnosed in the parser.  */
    5853              :           }
    5854        12282 :         else if (TREE_CODE (TREE_TYPE (decl)) != ARRAY_TYPE)
    5855              :           {
    5856            3 :             error ("variable %qD has initializer but incomplete type", decl);
    5857            3 :             initialized = false;
    5858              :           }
    5859              :       }
    5860              : 
    5861           67 :   if (initialized)
    5862              :     {
    5863      6349180 :       if (current_scope == file_scope)
    5864       155626 :         TREE_STATIC (decl) = 1;
    5865              : 
    5866              :       /* Tell 'pushdecl' this is an initialized decl
    5867              :          even though we don't yet have the initializer expression.
    5868              :          Also tell 'finish_decl' it may store the real initializer.  */
    5869      6349180 :       DECL_INITIAL (decl) = error_mark_node;
    5870              :     }
    5871              : 
    5872              :   /* If this is a function declaration, write a record describing it to the
    5873              :      prototypes file (if requested).  */
    5874              : 
    5875     27949711 :   if (TREE_CODE (decl) == FUNCTION_DECL)
    5876     14682676 :     gen_aux_info_record (decl, 0, 0, prototype_p (TREE_TYPE (decl)));
    5877              : 
    5878              :   /* ANSI specifies that a tentative definition which is not merged with
    5879              :      a non-tentative definition behaves exactly like a definition with an
    5880              :      initializer equal to zero.  (Section 3.7.2)
    5881              : 
    5882              :      -fno-common gives strict ANSI behavior, though this tends to break
    5883              :      a large body of code that grew up without this rule.
    5884              : 
    5885              :      Thread-local variables are never common, since there's no entrenched
    5886              :      body of code to break, and it allows more efficient variable references
    5887              :      in the presence of dynamic linking.  */
    5888              : 
    5889     27949711 :   if (VAR_P (decl)
    5890      8923416 :       && !initialized
    5891      2574236 :       && TREE_PUBLIC (decl)
    5892       991405 :       && !DECL_THREAD_LOCAL_P (decl)
    5893     28938750 :       && !flag_no_common)
    5894          128 :     DECL_COMMON (decl) = 1;
    5895              : 
    5896              :   /* Set attributes here so if duplicate decl, will have proper attributes.  */
    5897     27949711 :   c_decl_attributes (&decl, attributes, 0);
    5898              : 
    5899              :   /* Handle gnu_inline attribute.  */
    5900     27949710 :   if (declspecs->inline_p
    5901         1029 :       && !flag_gnu89_inline
    5902          997 :       && TREE_CODE (decl) == FUNCTION_DECL
    5903     27950699 :       && (lookup_attribute ("gnu_inline", DECL_ATTRIBUTES (decl))
    5904          966 :           || current_function_decl))
    5905              :     {
    5906           46 :       if (declspecs->storage_class == csc_auto && current_scope != file_scope)
    5907              :         ;
    5908           37 :       else if (declspecs->storage_class != csc_static)
    5909           37 :         DECL_EXTERNAL (decl) = !DECL_EXTERNAL (decl);
    5910              :     }
    5911              : 
    5912     27949710 :   if (TREE_CODE (decl) == FUNCTION_DECL
    5913     14682675 :       && DECL_DECLARED_INLINE_P (decl)
    5914         1019 :       && DECL_UNINLINABLE (decl)
    5915     27949712 :       && lookup_attribute ("noinline", DECL_ATTRIBUTES (decl)))
    5916              :     {
    5917            2 :       auto_urlify_attributes sentinel;
    5918            2 :       warning (OPT_Wattributes, "inline function %q+D given attribute %qs",
    5919              :                decl, "noinline");
    5920            2 :     }
    5921              : 
    5922              :   /* C99 6.7.4p3: An inline definition of a function with external
    5923              :      linkage shall not contain a definition of a modifiable object
    5924              :      with static storage duration...  */
    5925     27949710 :   if (VAR_P (decl)
    5926      8923416 :       && current_scope != file_scope
    5927      7769453 :       && TREE_STATIC (decl)
    5928        78792 :       && !TREE_READONLY (decl)
    5929        76235 :       && DECL_DECLARED_INLINE_P (current_function_decl)
    5930     27949780 :       && DECL_EXTERNAL (current_function_decl))
    5931            7 :     record_inline_static (input_location, current_function_decl,
    5932              :                           decl, csi_modifiable);
    5933              : 
    5934     27949710 :   if (c_dialect_objc ()
    5935            0 :       && VAR_OR_FUNCTION_DECL_P (decl))
    5936            0 :       objc_check_global_decl (decl);
    5937              : 
    5938              :   /* To enable versions to be created across TU's we mark and mangle all
    5939              :      non-default versioned functions.  */
    5940     27949710 :   if (TREE_CODE (decl) == FUNCTION_DECL
    5941              :       && !TARGET_HAS_FMV_TARGET_ATTRIBUTE
    5942              :       && get_target_version (decl).is_valid ())
    5943              :     {
    5944              :       maybe_mark_function_versioned (decl);
    5945              :       if (current_scope != file_scope)
    5946              :         error ("versioned declarations are only allowed at file scope");
    5947              :     }
    5948              : 
    5949              :   /* Add this decl to the current scope.
    5950              :      TEM may equal DECL or it may be a previous decl of the same name.  */
    5951     27949710 :   if (do_push)
    5952              :     {
    5953     27949362 :       tem = pushdecl (decl);
    5954              : 
    5955     27949362 :       if (initialized && DECL_EXTERNAL (tem))
    5956              :         {
    5957           27 :           DECL_EXTERNAL (tem) = 0;
    5958           27 :           TREE_STATIC (tem) = 1;
    5959              :         }
    5960              : 
    5961     27949362 :       return tem;
    5962              :     }
    5963              :   else
    5964          348 :     return decl;
    5965              : }
    5966              : 
    5967              : /* Subroutine of finish_decl. TYPE is the type of an uninitialized object
    5968              :    DECL or the non-array element type if DECL is an uninitialized array.
    5969              :    If that type has a const member, diagnose this. */
    5970              : 
    5971              : static void
    5972            7 : diagnose_uninitialized_cst_member (tree decl, tree type)
    5973              : {
    5974            7 :   tree field;
    5975           17 :   for (field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field))
    5976              :     {
    5977           10 :       tree field_type;
    5978           10 :       if (TREE_CODE (field) != FIELD_DECL)
    5979            0 :         continue;
    5980           10 :       field_type = strip_array_types (TREE_TYPE (field));
    5981              : 
    5982           10 :       if (TYPE_QUALS (field_type) & TYPE_QUAL_CONST)
    5983              :         {
    5984            5 :           auto_diagnostic_group d;
    5985            5 :           if (warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wc___compat,
    5986              :                           "uninitialized const member in %qT is invalid in C++",
    5987            5 :                           strip_array_types (TREE_TYPE (decl))))
    5988            5 :             inform (DECL_SOURCE_LOCATION (field), "%qD should be initialized", field);
    5989            5 :         }
    5990              : 
    5991           10 :       if (RECORD_OR_UNION_TYPE_P (field_type))
    5992            2 :         diagnose_uninitialized_cst_member (decl, field_type);
    5993              :     }
    5994            7 : }
    5995              : 
    5996              : /* Finish processing of a declaration;
    5997              :    install its initial value.
    5998              :    If ORIGTYPE is not NULL_TREE, it is the original type of INIT.
    5999              :    If the length of an array type is not known before,
    6000              :    it must be determined now, from the initial value, or it is an error.
    6001              : 
    6002              :    INIT_LOC is the location of the initial value.  */
    6003              : 
    6004              : void
    6005    156369571 : finish_decl (tree decl, location_t init_loc, tree init,
    6006              :              tree origtype, tree asmspec_tree)
    6007              : {
    6008    156369571 :   tree type;
    6009    156369571 :   bool was_incomplete = (DECL_SIZE (decl) == NULL_TREE);
    6010    156369571 :   const char *asmspec = 0;
    6011              : 
    6012              :   /* If a name was specified, get the string.  */
    6013    147443166 :   if (VAR_OR_FUNCTION_DECL_P (decl)
    6014    171052246 :       && DECL_FILE_SCOPE_P (decl))
    6015     15838155 :     asmspec_tree = maybe_apply_renaming_pragma (decl, asmspec_tree);
    6016    156369571 :   if (asmspec_tree)
    6017       871288 :     asmspec = TREE_STRING_POINTER (asmspec_tree);
    6018              : 
    6019    156369571 :   if (VAR_P (decl)
    6020      8926405 :       && TREE_STATIC (decl)
    6021    157431852 :       && global_bindings_p ())
    6022              :     /* So decl is a global variable. Record the types it uses
    6023              :        so that we can decide later to emit debug info for them.  */
    6024       980283 :     record_types_used_by_current_var_decl (decl);
    6025              : 
    6026              :   /* If `start_decl' didn't like having an initialization, ignore it now.  */
    6027    156369571 :   if (init != NULL_TREE && DECL_INITIAL (decl) == NULL_TREE)
    6028              :     init = NULL_TREE;
    6029              : 
    6030              :   /* Don't crash if parm is initialized.  */
    6031    156369571 :   if (TREE_CODE (decl) == PARM_DECL)
    6032              :     init = NULL_TREE;
    6033              : 
    6034     32256847 :   if (init)
    6035      6352170 :     store_init_value (init_loc, decl, init, origtype);
    6036              : 
    6037    156369571 :   if (c_dialect_objc () && (VAR_OR_FUNCTION_DECL_P (decl)
    6038            0 :                             || TREE_CODE (decl) == FIELD_DECL))
    6039            0 :     objc_check_decl (decl);
    6040              : 
    6041    156369571 :   type = TREE_TYPE (decl);
    6042              : 
    6043              :   /* Deduce size of array from initialization, if not already known.
    6044              :      This is only needed for an initialization in the current scope;
    6045              :      it must not be done for a file-scope initialization of a
    6046              :      declaration with external linkage, redeclared in an inner scope
    6047              :      with the outer declaration shadowed in an intermediate scope.  */
    6048    156369571 :   if (TREE_CODE (type) == ARRAY_TYPE
    6049       869309 :       && TYPE_DOMAIN (type) == NULL_TREE
    6050        19910 :       && TREE_CODE (decl) != TYPE_DECL
    6051    156389383 :       && !(TREE_PUBLIC (decl) && current_scope != file_scope))
    6052              :     {
    6053        19625 :       bool do_default
    6054        19625 :         = !TREE_STATIC (decl) && !DECL_EXTERNAL (decl);
    6055        19625 :       int failure
    6056        19625 :         = complete_array_type (&TREE_TYPE (decl), DECL_INITIAL (decl),
    6057              :                                do_default);
    6058              : 
    6059              :       /* Get the completed type made by complete_array_type.  */
    6060        19625 :       type = TREE_TYPE (decl);
    6061              : 
    6062        19625 :       switch (failure)
    6063              :         {
    6064            0 :         case 1:
    6065            0 :           error ("initializer fails to determine size of %q+D", decl);
    6066            0 :           break;
    6067              : 
    6068         7371 :         case 2:
    6069         7371 :           if (do_default)
    6070            1 :             error ("array size missing in %q+D", decl);
    6071         7370 :           else if (!TREE_PUBLIC (decl))
    6072           37 :             pedwarn_c23 (DECL_SOURCE_LOCATION (decl), OPT_Wpedantic,
    6073              :                          "array size missing in %q+D", decl);
    6074              :           break;
    6075              : 
    6076            3 :         case 3:
    6077            3 :           error ("zero or negative size array %q+D", decl);
    6078            3 :           break;
    6079              : 
    6080        12251 :         case 0:
    6081              :           /* For global variables, update the copy of the type that
    6082              :              exists in the binding.  */
    6083        12251 :           if (TREE_PUBLIC (decl))
    6084              :             {
    6085         3822 :               struct c_binding *b_ext = I_SYMBOL_BINDING (DECL_NAME (decl));
    6086         7644 :               while (b_ext && !B_IN_EXTERNAL_SCOPE (b_ext))
    6087         3822 :                 b_ext = b_ext->shadowed;
    6088         3822 :               if (b_ext && TREE_CODE (decl) == TREE_CODE (b_ext->decl))
    6089              :                 {
    6090         3822 :                   if (b_ext->u.type && comptypes (b_ext->u.type, type))
    6091          176 :                     b_ext->u.type = composite_type (b_ext->u.type, type);
    6092              :                   else
    6093         3646 :                     b_ext->u.type = type;
    6094              :                 }
    6095              :             }
    6096              :           break;
    6097              : 
    6098            0 :         default:
    6099            0 :           gcc_unreachable ();
    6100              :         }
    6101              : 
    6102        19625 :       if (DECL_INITIAL (decl) && DECL_INITIAL (decl) != error_mark_node)
    6103        11382 :         TREE_TYPE (DECL_INITIAL (decl)) = type;
    6104              : 
    6105        19625 :       relayout_decl (decl);
    6106              :     }
    6107              : 
    6108              :   /* Look for braced array initializers for character arrays and
    6109              :      recursively convert them into STRING_CSTs.  */
    6110    156369571 :   if (tree init = DECL_INITIAL (decl))
    6111    130467305 :     DECL_INITIAL (decl) = braced_lists_to_strings (type, init);
    6112              : 
    6113    156369571 :   if (VAR_P (decl))
    6114              :     {
    6115      8926405 :       if (init && TREE_CODE (init) == CONSTRUCTOR)
    6116       105013 :         add_flexible_array_elts_to_size (decl, init);
    6117              : 
    6118      8926405 :       complete_flexible_array_elts (DECL_INITIAL (decl));
    6119              : 
    6120      8926405 :       if (is_global_var (decl))
    6121              :         {
    6122      1237269 :           type_context_kind context = (DECL_THREAD_LOCAL_P (decl)
    6123      1237269 :                                        ? TCTX_THREAD_STORAGE
    6124              :                                        : TCTX_STATIC_STORAGE);
    6125      1237269 :           if (!verify_type_context (input_location, context, TREE_TYPE (decl)))
    6126            0 :             TREE_TYPE (decl) = error_mark_node;
    6127              :         }
    6128              : 
    6129      8934518 :       if (DECL_SIZE (decl) == NULL_TREE && TREE_TYPE (decl) != error_mark_node
    6130      8934415 :           && COMPLETE_TYPE_P (TREE_TYPE (decl)))
    6131          107 :         layout_decl (decl, 0);
    6132              : 
    6133      8926405 :       if (DECL_SIZE (decl) == NULL_TREE
    6134              :           /* Don't give an error if we already gave one earlier.  */
    6135         8006 :           && TREE_TYPE (decl) != error_mark_node
    6136      8934308 :           && (TREE_STATIC (decl)
    6137              :               /* A static variable with an incomplete type
    6138              :                  is an error if it is initialized.
    6139              :                  Also if it is not file scope.
    6140              :                  Also if it is thread-local (in C23).
    6141              :                  Otherwise, let it through, but if it is not `extern'
    6142              :                  then it may cause an error message later.  */
    6143          309 :               ? (DECL_INITIAL (decl) != NULL_TREE
    6144          309 :                  || !DECL_FILE_SCOPE_P (decl)
    6145          306 :                  || (flag_isoc23 && DECL_THREAD_LOCAL_P (decl)))
    6146              :               /* An automatic variable with an incomplete type
    6147              :                  is an error.  */
    6148         7594 :               : !DECL_EXTERNAL (decl)))
    6149              :          {
    6150           19 :            error ("storage size of %q+D isn%'t known", decl);
    6151           19 :            TREE_TYPE (decl) = error_mark_node;
    6152              :          }
    6153              : 
    6154     17663131 :       if ((RECORD_OR_UNION_TYPE_P (TREE_TYPE (decl))
    6155      8652543 :           || TREE_CODE (TREE_TYPE (decl)) == ENUMERAL_TYPE)
    6156       287446 :           && DECL_SIZE (decl) == NULL_TREE
    6157      8926693 :           && TREE_STATIC (decl))
    6158          135 :         incomplete_record_decls.safe_push (decl);
    6159              : 
    6160      8926405 :       if (is_global_var (decl)
    6161      1237269 :           && DECL_SIZE (decl) != NULL_TREE
    6162     10155711 :           && TREE_TYPE (decl) != error_mark_node)
    6163              :         {
    6164      1229286 :           if (TREE_CODE (DECL_SIZE (decl)) == INTEGER_CST)
    6165      1229283 :             constant_expression_warning (DECL_SIZE (decl));
    6166              :           else
    6167              :             {
    6168            3 :               error ("storage size of %q+D isn%'t constant", decl);
    6169            3 :               TREE_TYPE (decl) = error_mark_node;
    6170              :             }
    6171              :         }
    6172              : 
    6173      8926405 :       if (TREE_USED (type))
    6174              :         {
    6175            4 :           TREE_USED (decl) = 1;
    6176            4 :           DECL_READ_P (decl) = 1;
    6177              :         }
    6178              :     }
    6179              : 
    6180              :   /* If this is a function and an assembler name is specified, reset DECL_RTL
    6181              :      so we can give it its new name.  Also, update builtin_decl if it
    6182              :      was a normal built-in.  */
    6183    156369571 :   if (TREE_CODE (decl) == FUNCTION_DECL && asmspec)
    6184              :     {
    6185       858101 :       if (DECL_BUILT_IN_CLASS (decl) == BUILT_IN_NORMAL)
    6186        71968 :         set_builtin_user_assembler_name (decl, asmspec);
    6187       858101 :       set_user_assembler_name (decl, asmspec);
    6188              :     }
    6189              : 
    6190              :   /* If #pragma weak was used, mark the decl weak now.  */
    6191    156369571 :   maybe_apply_pragma_weak (decl);
    6192              : 
    6193              :   /* Output the assembler code and/or RTL code for variables and functions,
    6194              :      unless the type is an undefined structure or union.
    6195              :      If not, it will get done when the type is completed.  */
    6196              : 
    6197    156369571 :   if (VAR_OR_FUNCTION_DECL_P (decl))
    6198              :     {
    6199              :       /* Determine the ELF visibility.  */
    6200     23609080 :       if (TREE_PUBLIC (decl))
    6201     15813433 :         c_determine_visibility (decl);
    6202              : 
    6203              :       /* This is a no-op in c-lang.cc or something real in objc-act.cc.  */
    6204     23609080 :       if (c_dialect_objc ())
    6205            0 :         objc_check_decl (decl);
    6206              : 
    6207     23609080 :       if (asmspec)
    6208              :         {
    6209              :           /* If this is not a static variable, issue a warning.
    6210              :              It doesn't make any sense to give an ASMSPEC for an
    6211              :              ordinary, non-register local variable.  Historically,
    6212              :              GCC has accepted -- but ignored -- the ASMSPEC in
    6213              :              this case.  */
    6214       872326 :           if (!DECL_FILE_SCOPE_P (decl)
    6215         1038 :               && VAR_P (decl)
    6216         1038 :               && !C_DECL_REGISTER (decl)
    6217       871296 :               && !TREE_STATIC (decl))
    6218            1 :             warning (0, "ignoring %<asm%> specifier for non-static local "
    6219              :                      "variable %q+D", decl);
    6220              :           else
    6221       871287 :             set_user_assembler_name (decl, asmspec);
    6222              :         }
    6223              : 
    6224     23609080 :       if (DECL_FILE_SCOPE_P (decl))
    6225              :         {
    6226     15838155 :           if (DECL_INITIAL (decl) == NULL_TREE
    6227     15838155 :               || DECL_INITIAL (decl) == error_mark_node)
    6228              :             /* Don't output anything
    6229              :                when a tentative file-scope definition is seen.
    6230              :                But at end of compilation, do output code for them.  */
    6231     15682335 :             DECL_DEFER_OUTPUT (decl) = 1;
    6232     15838155 :           if (asmspec && VAR_P (decl) && C_DECL_REGISTER (decl))
    6233           68 :             DECL_HARD_REGISTER (decl) = 1;
    6234     15838155 :           rest_of_decl_compilation (decl, true, 0);
    6235              : 
    6236     15838155 :           if (TREE_CODE (decl) == FUNCTION_DECL)
    6237              :             {
    6238     14682608 :               tree parms = DECL_ARGUMENTS (decl);
    6239     14682608 :               const bool builtin = fndecl_built_in_p (decl);
    6240     14682608 :               if (tree access = build_attr_access_from_parms (parms, !builtin))
    6241       344528 :                 decl_attributes (&decl, access, 0);
    6242              :             }
    6243              :         }
    6244              :       else
    6245              :         {
    6246              :           /* In conjunction with an ASMSPEC, the `register'
    6247              :              keyword indicates that we should place the variable
    6248              :              in a particular register.  */
    6249      7770925 :           if (asmspec && C_DECL_REGISTER (decl))
    6250              :             {
    6251         1030 :               DECL_HARD_REGISTER (decl) = 1;
    6252              :               /* This cannot be done for a structure with volatile
    6253              :                  fields, on which DECL_REGISTER will have been
    6254              :                  reset.  */
    6255         1030 :               if (!DECL_REGISTER (decl))
    6256            1 :                 error ("cannot put object with volatile field into register");
    6257              :             }
    6258              : 
    6259      7770925 :           if (TREE_CODE (decl) != FUNCTION_DECL)
    6260              :             {
    6261              :               /* If we're building a variable sized type, and we might be
    6262              :                  reachable other than via the top of the current binding
    6263              :                  level, then create a new BIND_EXPR so that we deallocate
    6264              :                  the object at the right time.  */
    6265              :               /* Note that DECL_SIZE can be null due to errors.  */
    6266      7770858 :               if (DECL_SIZE (decl)
    6267      7770812 :                   && !TREE_CONSTANT (DECL_SIZE (decl))
    6268      7778242 :                   && STATEMENT_LIST_HAS_LABEL (cur_stmt_list))
    6269              :                 {
    6270         1337 :                   tree bind;
    6271         1337 :                   bind = build3 (BIND_EXPR, void_type_node, NULL, NULL, NULL);
    6272         1337 :                   TREE_SIDE_EFFECTS (bind) = 1;
    6273         1337 :                   add_stmt (bind);
    6274         1337 :                   BIND_EXPR_BODY (bind) = push_stmt_list ();
    6275              :                 }
    6276      7770858 :               add_stmt (build_stmt (DECL_SOURCE_LOCATION (decl),
    6277              :                                     DECL_EXPR, decl));
    6278              :             }
    6279              :         }
    6280              : 
    6281              : 
    6282     23609080 :       if (!DECL_FILE_SCOPE_P (decl))
    6283              :         {
    6284              :           /* Recompute the RTL of a local array now
    6285              :              if it used to be an incomplete type.  */
    6286      7770925 :           if (was_incomplete && !is_global_var (decl))
    6287              :             {
    6288              :               /* If we used it already as memory, it must stay in memory.  */
    6289         5350 :               TREE_ADDRESSABLE (decl) = TREE_USED (decl);
    6290              :               /* If it's still incomplete now, no init will save it.  */
    6291         5350 :               if (DECL_SIZE (decl) == NULL_TREE)
    6292          109 :                 DECL_INITIAL (decl) = NULL_TREE;
    6293              :             }
    6294              :         }
    6295              :     }
    6296              : 
    6297    156369571 :   if (TREE_CODE (decl) == TYPE_DECL)
    6298              :     {
    6299      4449163 :       if (!DECL_FILE_SCOPE_P (decl)
    6300      4449163 :           && c_type_variably_modified_p (TREE_TYPE (decl)))
    6301         5321 :         add_stmt (build_stmt (DECL_SOURCE_LOCATION (decl), DECL_EXPR, decl));
    6302              : 
    6303      8513708 :       rest_of_decl_compilation (decl, DECL_FILE_SCOPE_P (decl), 0);
    6304              :     }
    6305              : 
    6306              :   /* Install a cleanup (aka destructor) if one was given.  */
    6307    156369571 :   if (VAR_P (decl) && !TREE_STATIC (decl))
    6308              :     {
    6309      7864121 :       tree attr = lookup_attribute ("cleanup", DECL_ATTRIBUTES (decl));
    6310      7864121 :       if (attr)
    6311              :         {
    6312          131 :           tree cleanup_id = TREE_VALUE (TREE_VALUE (attr));
    6313          131 :           tree cleanup_decl = lookup_name (cleanup_id);
    6314          131 :           tree cleanup;
    6315          131 :           vec<tree, va_gc> *v;
    6316              : 
    6317              :           /* Build "cleanup(&decl)" for the destructor.  */
    6318          131 :           cleanup = build_unary_op (input_location, ADDR_EXPR, decl, false);
    6319          131 :           vec_alloc (v, 1);
    6320          131 :           v->quick_push (cleanup);
    6321          131 :           cleanup = c_build_function_call_vec (DECL_SOURCE_LOCATION (decl),
    6322          131 :                                                vNULL, cleanup_decl, v, NULL);
    6323          131 :           vec_free (v);
    6324              : 
    6325              :           /* Don't warn about decl unused; the cleanup uses it.  */
    6326          131 :           TREE_USED (decl) = 1;
    6327          131 :           TREE_USED (cleanup_decl) = 1;
    6328          131 :           DECL_READ_P (decl) = 1;
    6329              : 
    6330          131 :           push_cleanup (decl, cleanup, false);
    6331              :         }
    6332              :     }
    6333              : 
    6334    156369571 :   if (warn_cxx_compat
    6335        22413 :       && VAR_P (decl)
    6336         7549 :       && !DECL_EXTERNAL (decl)
    6337    156376677 :       && DECL_INITIAL (decl) == NULL_TREE)
    6338              :     {
    6339         2333 :       type = strip_array_types (type);
    6340         2333 :       if (TREE_READONLY (decl))
    6341            6 :         warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wc___compat,
    6342              :                     "uninitialized %<const %D%> is invalid in C++", decl);
    6343         2327 :       else if (RECORD_OR_UNION_TYPE_P (type)
    6344         2327 :                && C_TYPE_FIELDS_READONLY (type))
    6345            5 :         diagnose_uninitialized_cst_member (decl, type);
    6346              :     }
    6347              : 
    6348    156369571 :   if (flag_openmp
    6349       459607 :       && VAR_P (decl)
    6350    156393576 :       && lookup_attribute ("omp declare target implicit",
    6351        24005 :                            DECL_ATTRIBUTES (decl)))
    6352              :     {
    6353           13 :       DECL_ATTRIBUTES (decl)
    6354           13 :         = remove_attribute ("omp declare target implicit",
    6355           13 :                             DECL_ATTRIBUTES (decl));
    6356           13 :       if (!omp_mappable_type (TREE_TYPE (decl)))
    6357            9 :         error ("%q+D in declare target directive does not have mappable type",
    6358              :                decl);
    6359            4 :       else if (!lookup_attribute ("omp declare target",
    6360            4 :                                   DECL_ATTRIBUTES (decl))
    6361            8 :                && !lookup_attribute ("omp declare target link",
    6362            4 :                                      DECL_ATTRIBUTES (decl)))
    6363              :         {
    6364            4 :           DECL_ATTRIBUTES (decl)
    6365            4 :             = tree_cons (get_identifier ("omp declare target"),
    6366            4 :                          NULL_TREE, DECL_ATTRIBUTES (decl));
    6367            4 :             symtab_node *node = symtab_node::get (decl);
    6368            4 :             if (node != NULL)
    6369              :               {
    6370            4 :                 node->offloadable = 1;
    6371            4 :                 if (ENABLE_OFFLOADING)
    6372              :                   {
    6373              :                     g->have_offload = true;
    6374              :                     if (is_a <varpool_node *> (node))
    6375              :                       vec_safe_push (offload_vars, decl);
    6376              :                   }
    6377              :               }
    6378              :         }
    6379              :     }
    6380              : 
    6381              :   /* This is the last point we can lower alignment so give the target the
    6382              :      chance to do so.  */
    6383    156369571 :   if (VAR_P (decl)
    6384      8926405 :       && !is_global_var (decl)
    6385    164058707 :       && !DECL_HARD_REGISTER (decl))
    6386      7688106 :     targetm.lower_local_decl_alignment (decl);
    6387              : 
    6388    156369571 :   invoke_plugin_callbacks (PLUGIN_FINISH_DECL, decl);
    6389    156369571 : }
    6390              : 
    6391              : /* Given a parsed parameter declaration, decode it into a PARM_DECL.
    6392              :    EXPR is NULL or a pointer to an expression that needs to be
    6393              :    evaluated for the side effects of array size expressions in the
    6394              :    parameters.  */
    6395              : 
    6396              : tree
    6397            0 : grokparm (const struct c_parm *parm, tree *expr)
    6398              : {
    6399            0 :   tree attrs = parm->attrs;
    6400            0 :   tree decl = grokdeclarator (parm->declarator, parm->specs, PARM, false,
    6401            0 :                               NULL, &attrs, expr, NULL, DEPRECATED_NORMAL);
    6402              : 
    6403            0 :   decl_attributes (&decl, attrs, 0);
    6404              : 
    6405            0 :   return decl;
    6406              : }
    6407              : 
    6408              : 
    6409              : 
    6410              : /* Given a parsed parameter declaration, decode it into a PARM_DECL
    6411              :    and push that on the current scope.  EXPR is a pointer to an
    6412              :    expression that needs to be evaluated for the side effects of array
    6413              :    size expressions in the parameters.  */
    6414              : 
    6415              : void
    6416    124090062 : push_parm_decl (const struct c_parm *parm, tree *expr)
    6417              : {
    6418    124090062 :   tree attrs = parm->attrs;
    6419    124090062 :   tree decl = grokdeclarator (parm->declarator, parm->specs, PARM, false, NULL,
    6420    124090062 :                               &attrs, expr, NULL, DEPRECATED_NORMAL);
    6421    124090062 :   if (decl && DECL_P (decl))
    6422    124090062 :     DECL_SOURCE_LOCATION (decl) = parm->loc;
    6423              : 
    6424    124090062 :   decl_attributes (&decl, attrs, 0);
    6425              : 
    6426    124090062 :   decl = pushdecl (decl);
    6427              : 
    6428    124090062 :   finish_decl (decl, input_location, NULL_TREE, NULL_TREE, NULL_TREE);
    6429    124090062 : }
    6430              : 
    6431              : /* Mark all the parameter declarations to date as forward decls.
    6432              :    Also diagnose use of this extension.  */
    6433              : 
    6434              : void
    6435           42 : mark_forward_parm_decls (void)
    6436              : {
    6437           42 :   struct c_binding *b;
    6438              : 
    6439           42 :   if (current_scope->had_forward_parm_decls)
    6440           12 :     warning_at (input_location, OPT_Wmultiple_parameter_fwd_decl_lists,
    6441              :                 "more than one list of forward declarations of parameters");
    6442           42 :   if (pedantic && !current_scope->had_forward_parm_decls)
    6443            4 :     pedwarn (input_location, OPT_Wpedantic,
    6444              :              "ISO C forbids forward parameter declarations");
    6445              : 
    6446           42 :   current_scope->had_forward_parm_decls = true;
    6447              : 
    6448           95 :   for (b = current_scope->bindings; b; b = b->prev)
    6449           53 :     if (TREE_CODE (b->decl) == PARM_DECL)
    6450           53 :       TREE_ASM_WRITTEN (b->decl) = 1;
    6451           42 : }
    6452              : 
    6453              : /* Build a COMPOUND_LITERAL_EXPR.  TYPE is the type given in the compound
    6454              :    literal, which may be an incomplete array type completed by the
    6455              :    initializer; INIT is a CONSTRUCTOR at LOC that initializes the compound
    6456              :    literal.  NON_CONST is true if the initializers contain something
    6457              :    that cannot occur in a constant expression.  If ALIGNAS_ALIGN is nonzero,
    6458              :    it is the (valid) alignment for this compound literal, as specified
    6459              :    with _Alignas.  SCSPECS are the storage class specifiers (C23) from the
    6460              :    compound literal.  */
    6461              : 
    6462              : tree
    6463       919741 : build_compound_literal (location_t loc, tree type, tree init, bool non_const,
    6464              :                         unsigned int alignas_align,
    6465              :                         struct c_declspecs *scspecs)
    6466              : {
    6467              :   /* We do not use start_decl here because we have a type, not a declarator;
    6468              :      and do not use finish_decl because the decl should be stored inside
    6469              :      the COMPOUND_LITERAL_EXPR rather than added elsewhere as a DECL_EXPR.  */
    6470       919741 :   tree decl;
    6471       919741 :   tree complit;
    6472       919741 :   tree stmt;
    6473       919741 :   bool threadp = scspecs ? scspecs->thread_p : false;
    6474          307 :   enum c_storage_class storage_class = (scspecs
    6475              :                                         ? scspecs->storage_class
    6476              :                                         : csc_none);
    6477              : 
    6478       919741 :   if (type == error_mark_node
    6479       919734 :       || init == error_mark_node)
    6480              :     return error_mark_node;
    6481              : 
    6482       919681 :   if (current_scope == file_scope && storage_class == csc_register)
    6483              :     {
    6484            1 :       error_at (loc, "file-scope compound literal specifies %<register%>");
    6485            1 :       storage_class = csc_none;
    6486              :     }
    6487              : 
    6488       919681 :   if (current_scope != file_scope && threadp && storage_class == csc_none)
    6489              :     {
    6490            6 :       error_at (loc, "compound literal implicitly auto and declared %qs",
    6491            3 :                 scspecs->thread_gnu_p ? "__thread" : "_Thread_local");
    6492            3 :       threadp = false;
    6493              :     }
    6494              : 
    6495       919681 :   decl = build_decl (loc, VAR_DECL, NULL_TREE, type);
    6496       919681 :   DECL_EXTERNAL (decl) = 0;
    6497       919681 :   TREE_PUBLIC (decl) = 0;
    6498      1839362 :   TREE_STATIC (decl) = (current_scope == file_scope
    6499       919681 :                         || storage_class == csc_static);
    6500       919681 :   DECL_CONTEXT (decl) = current_function_decl;
    6501       919681 :   TREE_USED (decl) = 1;
    6502       919681 :   DECL_READ_P (decl) = 1;
    6503       919681 :   DECL_ARTIFICIAL (decl) = 1;
    6504       919681 :   DECL_IGNORED_P (decl) = 1;
    6505       919681 :   C_DECL_COMPOUND_LITERAL_P (decl) = 1;
    6506      1839131 :   C_DECL_DECLARED_CONSTEXPR (decl) = scspecs && scspecs->constexpr_p;
    6507       919681 :   TREE_TYPE (decl) = type;
    6508       919681 :   if (threadp)
    6509           16 :     set_decl_tls_model (decl, decl_default_tls_model (decl));
    6510       919681 :   if (storage_class == csc_register)
    6511              :     {
    6512           25 :       C_DECL_REGISTER (decl) = 1;
    6513           25 :       DECL_REGISTER (decl) = 1;
    6514              :     }
    6515       919681 :   c_apply_type_quals_to_decl (TYPE_QUALS (strip_array_types (type)), decl);
    6516       919681 :   if (alignas_align)
    6517              :     {
    6518            3 :       SET_DECL_ALIGN (decl, alignas_align * BITS_PER_UNIT);
    6519            3 :       DECL_USER_ALIGN (decl) = 1;
    6520              :     }
    6521       919681 :   store_init_value (loc, decl, init, NULL_TREE);
    6522       919681 :   if (current_scope != file_scope
    6523       919430 :       && TREE_STATIC (decl)
    6524           28 :       && !TREE_READONLY (decl)
    6525           17 :       && DECL_DECLARED_INLINE_P (current_function_decl)
    6526       919687 :       && DECL_EXTERNAL (current_function_decl))
    6527            4 :     record_inline_static (input_location, current_function_decl,
    6528              :                           decl, csi_modifiable);
    6529              : 
    6530       919681 :   if (TREE_CODE (type) == ARRAY_TYPE && !COMPLETE_TYPE_P (type))
    6531              :     {
    6532          267 :       int failure = complete_array_type (&TREE_TYPE (decl),
    6533          267 :                                          DECL_INITIAL (decl), true);
    6534              :       /* If complete_array_type returns 3, it means that the initial value of
    6535              :          the compound literal is empty.  Allow it with a pedwarn; in pre-C23
    6536              :          modes, the empty initializer itself has been diagnosed if pedantic so
    6537              :          does not need to be diagnosed again here.  */
    6538          267 :       gcc_assert (failure == 0 || failure == 3);
    6539          267 :       if (failure == 3 && flag_isoc23)
    6540            1 :         pedwarn (loc, OPT_Wpedantic,
    6541              :                  "array of unknown size with empty initializer");
    6542              : 
    6543          267 :       type = TREE_TYPE (decl);
    6544          267 :       TREE_TYPE (DECL_INITIAL (decl)) = type;
    6545          267 :       relayout_decl (decl);
    6546              :     }
    6547              : 
    6548       919681 :   if (type == error_mark_node || !COMPLETE_TYPE_P (type))
    6549              :     {
    6550           19 :       c_incomplete_type_error (loc, NULL_TREE, type);
    6551           19 :       return error_mark_node;
    6552              :     }
    6553              : 
    6554       919383 :   if ((TREE_STATIC (decl) || C_DECL_DECLARED_CONSTEXPR (decl))
    6555       919883 :       && C_TYPE_VARIABLE_SIZE (type))
    6556            2 :     error_at (loc, "storage size isn%'t constant");
    6557              : 
    6558       919662 :   if (TREE_STATIC (decl)
    6559       919662 :       && !verify_type_context (loc, TCTX_STATIC_STORAGE, type))
    6560            0 :     return error_mark_node;
    6561              : 
    6562       919662 :   stmt = build_stmt (DECL_SOURCE_LOCATION (decl), DECL_EXPR, decl);
    6563       919662 :   complit = build1 (COMPOUND_LITERAL_EXPR, type, stmt);
    6564       919662 :   TREE_SIDE_EFFECTS (complit) = 1;
    6565              : 
    6566       919662 :   layout_decl (decl, 0);
    6567              : 
    6568       919662 :   if (TREE_STATIC (decl))
    6569              :     {
    6570              :       /* This decl needs a name for the assembler output.  */
    6571          279 :       set_compound_literal_name (decl);
    6572          279 :       DECL_DEFER_OUTPUT (decl) = 1;
    6573          279 :       DECL_COMDAT (decl) = 1;
    6574          279 :       pushdecl (decl);
    6575          279 :       rest_of_decl_compilation (decl, 1, 0);
    6576              :     }
    6577       919383 :   else if (current_function_decl && !current_scope->parm_flag)
    6578       919374 :     pushdecl (decl);
    6579              : 
    6580       919662 :   if (non_const)
    6581              :     {
    6582          221 :       complit = build2 (C_MAYBE_CONST_EXPR, type, NULL, complit);
    6583          221 :       C_MAYBE_CONST_EXPR_NON_CONST (complit) = 1;
    6584              :     }
    6585              : 
    6586              :   return complit;
    6587              : }
    6588              : 
    6589              : /* Check the type of a compound literal.  Here we just check that it
    6590              :    is valid for C++.  */
    6591              : 
    6592              : void
    6593       919738 : check_compound_literal_type (location_t loc, struct c_type_name *type_name)
    6594              : {
    6595       919738 :   if (warn_cxx_compat
    6596          165 :       && (type_name->specs->typespec_kind == ctsk_tagdef
    6597          164 :           || type_name->specs->typespec_kind == ctsk_tagfirstref
    6598          163 :           || type_name->specs->typespec_kind == ctsk_tagfirstref_attrs))
    6599            2 :     warning_at (loc, OPT_Wc___compat,
    6600              :                 "defining a type in a compound literal is invalid in C++");
    6601       919738 : }
    6602              : 
    6603              : /* Performs sanity checks on the TYPE and WIDTH of the bit-field NAME,
    6604              :    replacing with appropriate values if they are invalid.  */
    6605              : 
    6606              : static void
    6607        52597 : check_bitfield_type_and_width (location_t loc, tree *type, tree *width,
    6608              :                                tree orig_name)
    6609              : {
    6610        52597 :   tree type_mv;
    6611        52597 :   unsigned int max_width;
    6612        52597 :   unsigned HOST_WIDE_INT w;
    6613        52597 :   const char *name = (orig_name
    6614        95432 :                       ? identifier_to_locale (IDENTIFIER_POINTER (orig_name))
    6615         9762 :                       : _("<anonymous>"));
    6616              : 
    6617              :   /* Detect and ignore out of range field width and process valid
    6618              :      field widths.  */
    6619        52597 :   if (!INTEGRAL_TYPE_P (TREE_TYPE (*width)))
    6620              :     {
    6621            8 :       error_at (loc, "bit-field %qs width not an integer constant", name);
    6622            8 :       *width = integer_one_node;
    6623              :     }
    6624              :   else
    6625              :     {
    6626        52589 :       if (TREE_CODE (*width) != INTEGER_CST)
    6627              :         {
    6628           12 :           *width = c_fully_fold (*width, false, NULL);
    6629           12 :           if (TREE_CODE (*width) == INTEGER_CST)
    6630            6 :             pedwarn (loc, OPT_Wpedantic,
    6631              :                      "bit-field %qs width not an integer constant expression",
    6632              :                      name);
    6633              :         }
    6634        52589 :       if (TREE_CODE (*width) != INTEGER_CST)
    6635              :         {
    6636            6 :           error_at (loc, "bit-field %qs width not an integer constant", name);
    6637            6 :           *width = integer_one_node;
    6638              :         }
    6639        52589 :       constant_expression_warning (*width);
    6640        52589 :       if (tree_int_cst_sgn (*width) < 0)
    6641              :         {
    6642            2 :           error_at (loc, "negative width in bit-field %qs", name);
    6643            2 :           *width = integer_one_node;
    6644              :         }
    6645        52587 :       else if (integer_zerop (*width) && orig_name)
    6646              :         {
    6647            4 :           error_at (loc, "zero width for bit-field %qs", name);
    6648            4 :           *width = integer_one_node;
    6649              :         }
    6650              :     }
    6651              : 
    6652              :   /* Detect invalid bit-field type.  */
    6653        52597 :   if (TREE_CODE (*type) != INTEGER_TYPE
    6654              :       && TREE_CODE (*type) != BOOLEAN_TYPE
    6655              :       && TREE_CODE (*type) != ENUMERAL_TYPE
    6656        52597 :       && TREE_CODE (*type) != BITINT_TYPE)
    6657              :     {
    6658            8 :       error_at (loc, "bit-field %qs has invalid type", name);
    6659            8 :       *type = unsigned_type_node;
    6660              :     }
    6661              : 
    6662        52597 :   if (TYPE_WARN_IF_NOT_ALIGN (*type))
    6663              :     {
    6664            1 :       error_at (loc, "cannot declare bit-field %qs with %<warn_if_not_aligned%> type",
    6665              :                 name);
    6666            1 :       *type = unsigned_type_node;
    6667              :     }
    6668              : 
    6669        52597 :   type_mv = TYPE_MAIN_VARIANT (*type);
    6670        52597 :   if (!in_system_header_at (input_location)
    6671        29356 :       && type_mv != integer_type_node
    6672        26617 :       && type_mv != unsigned_type_node
    6673        65202 :       && type_mv != boolean_type_node)
    6674        12023 :     pedwarn_c90 (loc, OPT_Wpedantic,
    6675              :                  "type of bit-field %qs is a GCC extension", name);
    6676              : 
    6677        52597 :   max_width = TYPE_PRECISION (*type);
    6678              : 
    6679        52597 :   if (compare_tree_int (*width, max_width) > 0)
    6680              :     {
    6681            4 :       error_at (loc, "width of %qs exceeds its type", name);
    6682            4 :       w = max_width;
    6683            4 :       *width = build_int_cst (integer_type_node, w);
    6684              :     }
    6685              :   else
    6686        52593 :     w = tree_to_uhwi (*width);
    6687              : 
    6688              :   /* Truncation of hardbool false and true representation values is always safe:
    6689              :      either the values remain different, or we'll report a problem when creating
    6690              :      the narrower type.  */
    6691        52597 :   if (c_hardbool_type_attr (*type))
    6692        52597 :     return;
    6693              : 
    6694        52316 :   if (TREE_CODE (*type) == ENUMERAL_TYPE)
    6695              :     {
    6696         4130 :       struct lang_type *lt = TYPE_LANG_SPECIFIC (*type);
    6697         4130 :       if (!lt
    6698         4120 :           || w < tree_int_cst_min_precision (lt->enum_min, TYPE_SIGN (*type))
    6699         8246 :           || w < tree_int_cst_min_precision (lt->enum_max, TYPE_SIGN (*type)))
    6700           15 :         warning_at (loc, 0, "%qs is narrower than values of its type", name);
    6701              :     }
    6702              : }
    6703              : 
    6704              : 
    6705              : 
    6706              : /* Print warning about variable length array if necessary.  */
    6707              : 
    6708              : static void
    6709        22493 : warn_variable_length_array (tree name, tree size)
    6710              : {
    6711        22493 :   if (TREE_CONSTANT (size))
    6712              :     {
    6713          181 :       if (name)
    6714          168 :         pedwarn_c90 (input_location, OPT_Wvla,
    6715              :                      "ISO C90 forbids array %qE whose size "
    6716              :                      "cannot be evaluated", name);
    6717              :       else
    6718           13 :         pedwarn_c90 (input_location, OPT_Wvla, "ISO C90 forbids array "
    6719              :                      "whose size cannot be evaluated");
    6720              :     }
    6721              :   else
    6722              :     {
    6723        22312 :       if (name)
    6724        13828 :         pedwarn_c90 (input_location, OPT_Wvla,
    6725              :                      "ISO C90 forbids variable length array %qE", name);
    6726              :       else
    6727         8484 :         pedwarn_c90 (input_location, OPT_Wvla, "ISO C90 forbids variable "
    6728              :                      "length array");
    6729              :     }
    6730        22493 : }
    6731              : 
    6732              : /* Returns the smallest location != UNKNOWN_LOCATION in LOCATIONS,
    6733              :    considering only those c_declspec_words found in LIST, which
    6734              :    must be terminated by cdw_number_of_elements.  */
    6735              : 
    6736              : static location_t
    6737          235 : smallest_type_quals_location (const location_t *locations,
    6738              :                               const c_declspec_word *list)
    6739              : {
    6740          235 :   location_t loc = UNKNOWN_LOCATION;
    6741         1410 :   while (*list != cdw_number_of_elements)
    6742              :     {
    6743         1175 :       location_t newloc = locations[*list];
    6744         1175 :       if (loc == UNKNOWN_LOCATION
    6745          288 :           || (newloc != UNKNOWN_LOCATION && newloc < loc))
    6746          887 :         loc = newloc;
    6747         1175 :       list++;
    6748              :     }
    6749              : 
    6750          235 :   return loc;
    6751              : }
    6752              : 
    6753              : 
    6754              : /* We attach an artificial TYPE_DECL to pointed-to type
    6755              :    and arrange for it to be included in a DECL_EXPR.  This
    6756              :    forces the sizes evaluation at a safe point and ensures it
    6757              :    is not deferred until e.g. within a deeper conditional context.
    6758              : 
    6759              :    PARM contexts have no enclosing statement list that
    6760              :    can hold the DECL_EXPR, so we need to use a BIND_EXPR
    6761              :    instead, and add it to the list of expressions that
    6762              :    need to be evaluated.
    6763              : 
    6764              :    TYPENAME contexts do have an enclosing statement list,
    6765              :    but it would be incorrect to use it, as the size should
    6766              :    only be evaluated if the containing expression is
    6767              :    evaluated.  We might also be in the middle of an
    6768              :    expression with side effects on the pointed-to type size
    6769              :    "arguments" prior to the pointer declaration point and
    6770              :    the fake TYPE_DECL in the enclosing context would force
    6771              :    the size evaluation prior to the side effects.  We therefore
    6772              :    use BIND_EXPRs in TYPENAME contexts too.  */
    6773              : static void
    6774         7038 : add_decl_expr (location_t loc, tree type, tree *expr, bool set_name_p)
    6775              : {
    6776         7038 :   tree bind = NULL_TREE;
    6777         7038 :   if (expr)
    6778              :     {
    6779         1596 :       bind = build3 (BIND_EXPR, void_type_node, NULL_TREE, NULL_TREE,
    6780              :                      NULL_TREE);
    6781         1596 :       TREE_SIDE_EFFECTS (bind) = 1;
    6782         1596 :       BIND_EXPR_BODY (bind) = push_stmt_list ();
    6783         1596 :       push_scope ();
    6784              :     }
    6785              : 
    6786         7038 :   tree decl = build_decl (loc, TYPE_DECL, NULL_TREE, type);
    6787         7038 :   pushdecl (decl);
    6788         7038 :   DECL_ARTIFICIAL (decl) = 1;
    6789         7038 :   add_stmt (build_stmt (DECL_SOURCE_LOCATION (decl), DECL_EXPR, decl));
    6790         7038 :   if (set_name_p)
    6791         6322 :     TYPE_NAME (type) = decl;
    6792              : 
    6793         7038 :   if (bind)
    6794              :     {
    6795         1596 :       pop_scope ();
    6796         1596 :       BIND_EXPR_BODY (bind) = pop_stmt_list (BIND_EXPR_BODY (bind));
    6797         1596 :       if (*expr)
    6798         1475 :         *expr = build2 (COMPOUND_EXPR, void_type_node, *expr, bind);
    6799              :       else
    6800          121 :         *expr = bind;
    6801              :     }
    6802         7038 : }
    6803              : 
    6804              : 
    6805              : /* Add attribute "arg spec" to ATTRS corresponding to an array/VLA parameter
    6806              :    declared with type TYPE.  The attribute has two arguments.  The first is
    6807              :    a string that encodes the presence of the static keyword.  The second is
    6808              :    the declared type of the array before adjustment, i.e. as an array type
    6809              :    including the outermost bound.  */
    6810              : 
    6811              : static tree
    6812       436774 : build_arg_spec_attribute (tree type, bool static_p, tree attrs)
    6813              : {
    6814       436774 :   tree vbchain = tree_cons (NULL_TREE, type, NULL_TREE);
    6815       436774 :   tree acsstr = static_p ? build_string (7, "static") :
    6816       436652 :                            build_string (1, "");
    6817       436774 :   tree args = tree_cons (NULL_TREE, acsstr, vbchain);
    6818       436774 :   tree name = get_identifier ("arg spec");
    6819       436774 :   return tree_cons (name, args, attrs);
    6820              : }
    6821              : 
    6822              : 
    6823              : /* Given declspecs and a declarator,
    6824              :    determine the name and type of the object declared
    6825              :    and construct a ..._DECL node for it.
    6826              :    (In one case we can return a ..._TYPE node instead.
    6827              :     For invalid input we sometimes return NULL_TREE.)
    6828              : 
    6829              :    DECLSPECS is a c_declspecs structure for the declaration specifiers.
    6830              : 
    6831              :    DECL_CONTEXT says which syntactic context this declaration is in:
    6832              :      NORMAL for most contexts.  Make a VAR_DECL or FUNCTION_DECL or TYPE_DECL.
    6833              :      FUNCDEF for a function definition.  Like NORMAL but a few different
    6834              :       error messages in each case.  Return value may be zero meaning
    6835              :       this definition is too screwy to try to parse.
    6836              :      PARM for a parameter declaration (either within a function prototype
    6837              :       or before a function body).  Make a PARM_DECL, or return void_type_node.
    6838              :      TYPENAME if for a typename (in a cast or sizeof).
    6839              :       Don't make a DECL node; just return the ..._TYPE node.
    6840              :      GENERIC_ASSOC for typenames in a generic association.
    6841              :      FIELD for a struct or union field; make a FIELD_DECL.
    6842              :    INITIALIZED is true if the decl has an initializer.
    6843              :    WIDTH is non-NULL for bit-fields, and is a pointer to an INTEGER_CST node
    6844              :    representing the width of the bit-field.
    6845              :    DECL_ATTRS points to the list of attributes that should be added to this
    6846              :      decl.  Any nested attributes that belong on the decl itself will be
    6847              :      added to this list.
    6848              :    If EXPR is not NULL, any expressions that need to be evaluated as
    6849              :      part of evaluating variably modified types will be stored in *EXPR.
    6850              :    If EXPR_CONST_OPERANDS is not NULL, *EXPR_CONST_OPERANDS will be
    6851              :      set to indicate whether operands in *EXPR can be used in constant
    6852              :      expressions.
    6853              :    DEPRECATED_STATE is a deprecated_states value indicating whether
    6854              :    deprecation/unavailability warnings should be suppressed.
    6855              : 
    6856              :    In the TYPENAME case, DECLARATOR is really an absolute declarator.
    6857              :    It may also be so in the PARM case, for a prototype where the
    6858              :    argument type is specified but not the name.
    6859              : 
    6860              :    This function is where the complicated C meanings of `static'
    6861              :    and `extern' are interpreted.  */
    6862              : 
    6863              : static tree
    6864    314265177 : grokdeclarator (const struct c_declarator *declarator,
    6865              :                 struct c_declspecs *declspecs,
    6866              :                 enum decl_context decl_context, bool initialized, tree *width,
    6867              :                 tree *decl_attrs, tree *expr, bool *expr_const_operands,
    6868              :                 enum deprecated_states deprecated_state)
    6869              : {
    6870    314265177 :   tree type = declspecs->type;
    6871    314265177 :   bool threadp = declspecs->thread_p;
    6872    314265177 :   bool constexprp = declspecs->constexpr_p;
    6873    314265177 :   enum c_storage_class storage_class = declspecs->storage_class;
    6874    314265177 :   int constp;
    6875    314265177 :   int restrictp;
    6876    314265177 :   int volatilep;
    6877    314265177 :   int atomicp;
    6878    314265177 :   int type_quals = TYPE_UNQUALIFIED;
    6879    314265177 :   tree name = NULL_TREE;
    6880    314265177 :   bool funcdef_flag = false;
    6881    314265177 :   bool funcdef_syntax = false;
    6882    314265177 :   bool size_varies = false;
    6883    314265177 :   bool size_error = false;
    6884    314265177 :   tree decl_attr = declspecs->decl_attr;
    6885    314265177 :   int array_ptr_quals = TYPE_UNQUALIFIED;
    6886    314265177 :   tree array_ptr_attrs = NULL_TREE;
    6887    314265177 :   bool array_parm_static = false;
    6888    314265177 :   bool array_parm_vla_unspec_p = false;
    6889    314265177 :   tree returned_attrs = NULL_TREE;
    6890    314265177 :   tree decl_id_attrs = NULL_TREE;
    6891    314265177 :   bool bitfield = width != NULL;
    6892    314265177 :   tree element_type;
    6893    314265177 :   tree orig_qual_type = NULL;
    6894    314265177 :   size_t orig_qual_indirect = 0;
    6895    314265177 :   struct c_arg_info *arg_info = 0;
    6896    314265177 :   addr_space_t as1, as2, address_space;
    6897    314265177 :   location_t loc = UNKNOWN_LOCATION;
    6898    314265177 :   tree expr_dummy;
    6899    314265177 :   bool expr_const_operands_dummy;
    6900    314265177 :   enum c_declarator_kind first_non_attr_kind;
    6901    314265177 :   unsigned int alignas_align = 0;
    6902              : 
    6903    314265177 :   if (type == NULL_TREE)
    6904              :     {
    6905              :       /* This can occur for auto on a parameter in C23 mode.  Set a
    6906              :          dummy type here so subsequent code can give diagnostics for
    6907              :          this case.  */
    6908            2 :       gcc_assert (declspecs->c23_auto_p);
    6909            2 :       gcc_assert (decl_context == PARM);
    6910            2 :       type = declspecs->type = integer_type_node;
    6911              :     }
    6912    314265177 :   if (TREE_CODE (type) == ERROR_MARK)
    6913           29 :     return error_mark_node;
    6914    314265148 :   if (expr == NULL)
    6915              :     {
    6916        38345 :       expr = &expr_dummy;
    6917        38345 :       expr_dummy = NULL_TREE;
    6918              :     }
    6919    314265148 :   if (expr_const_operands == NULL)
    6920    192750482 :     expr_const_operands = &expr_const_operands_dummy;
    6921              : 
    6922    314265148 :   if (declspecs->expr)
    6923              :     {
    6924          953 :       if (*expr)
    6925            7 :         *expr = build2 (COMPOUND_EXPR, TREE_TYPE (declspecs->expr), *expr,
    6926              :                         declspecs->expr);
    6927              :       else
    6928          946 :         *expr = declspecs->expr;
    6929              :     }
    6930    314265148 :   *expr_const_operands = declspecs->expr_const_operands;
    6931              : 
    6932    314265148 :   if (decl_context == FUNCDEF)
    6933     36324584 :     funcdef_flag = true, decl_context = NORMAL;
    6934              : 
    6935              :   /* Look inside a declarator for the name being declared
    6936              :      and get it as an IDENTIFIER_NODE, for an error message.  */
    6937    314265148 :   {
    6938    314265148 :     const struct c_declarator *decl = declarator;
    6939              : 
    6940    314265148 :     first_non_attr_kind = cdk_attrs;
    6941    384250246 :     while (decl)
    6942    384250246 :       switch (decl->kind)
    6943              :         {
    6944      1154381 :         case cdk_array:
    6945      1154381 :           loc = decl->id_loc;
    6946              :           /* FALL THRU.  */
    6947              : 
    6948     69978310 :         case cdk_function:
    6949     69978310 :         case cdk_pointer:
    6950     69978310 :           funcdef_syntax = (decl->kind == cdk_function);
    6951     69978310 :           if (first_non_attr_kind == cdk_attrs)
    6952     67869124 :             first_non_attr_kind = decl->kind;
    6953     69978310 :           decl = decl->declarator;
    6954     69978310 :           break;
    6955              : 
    6956         6788 :         case cdk_attrs:
    6957         6788 :           decl = decl->declarator;
    6958         6788 :           break;
    6959              : 
    6960    314265148 :         case cdk_id:
    6961    314265148 :           loc = decl->id_loc;
    6962    314265148 :           if (decl->u.id.id)
    6963              :             name = decl->u.id.id;
    6964    314265148 :           decl_id_attrs = decl->u.id.attrs;
    6965    314265148 :           if (first_non_attr_kind == cdk_attrs)
    6966    246396024 :             first_non_attr_kind = decl->kind;
    6967              :           decl = 0;
    6968              :           break;
    6969              : 
    6970            0 :         default:
    6971            0 :           gcc_unreachable ();
    6972              :         }
    6973    314265148 :     if (name == NULL_TREE)
    6974              :       {
    6975    126183417 :         gcc_assert (decl_context == PARM
    6976              :                     || decl_context == TYPENAME
    6977              :                     || decl_context == GENERIC_ASSOC
    6978              :                     || (decl_context == FIELD
    6979              :                         && declarator->kind == cdk_id));
    6980    126183417 :         gcc_assert (!initialized);
    6981              :       }
    6982              :   }
    6983              : 
    6984              :   /* An enum type specifier (": specifier-qualifier-list") may only be
    6985              :      specified when the enum is being defined or in an empty
    6986              :      declaration of the form "enum identifier enum-type-specifier;".
    6987              :      Except for the case of an empty declaration that has additional
    6988              :      declaration specifiers, all invalid contexts (declarations that
    6989              :      aren't empty, type names, parameter declarations, member
    6990              :      declarations) pass through grokdeclarator.  */
    6991    314265148 :   if (declspecs->enum_type_specifier_ref_p)
    6992            6 :     error_at (loc, "%<enum%> underlying type may not be specified here");
    6993              : 
    6994              :   /* A function definition's declarator must have the form of
    6995              :      a function declarator.  */
    6996              : 
    6997    314265148 :   if (funcdef_flag && !funcdef_syntax)
    6998              :     return NULL_TREE;
    6999              : 
    7000              :   /* If this looks like a function definition, make it one,
    7001              :      even if it occurs where parms are expected.
    7002              :      Then store_parm_decls will reject it and not use it as a parm.  */
    7003    314265117 :   if (decl_context == NORMAL && !funcdef_flag && current_scope->parm_flag)
    7004        22662 :     decl_context = PARM;
    7005              : 
    7006    314265117 :   if (deprecated_state != UNAVAILABLE_DEPRECATED_SUPPRESS)
    7007              :     {
    7008    314265093 :       if (declspecs->unavailable_p)
    7009           28 :         error_unavailable_use (declspecs->type, declspecs->decl_attr);
    7010    314265065 :       else if (declspecs->deprecated_p
    7011           46 :                 && deprecated_state != DEPRECATED_SUPPRESS)
    7012           38 :         warn_deprecated_use (declspecs->type, declspecs->decl_attr);
    7013              :     }
    7014              : 
    7015    314265117 :   if ((decl_context == NORMAL || decl_context == FIELD)
    7016     68578233 :       && current_scope == file_scope
    7017    374773106 :       && c_type_variably_modified_p (type))
    7018              :     {
    7019            3 :       if (name)
    7020            3 :         error_at (loc, "variably modified %qE at file scope", name);
    7021              :       else
    7022            0 :         error_at (loc, "variably modified field at file scope");
    7023            3 :       type = integer_type_node;
    7024              :     }
    7025              : 
    7026    314265117 :   size_varies = C_TYPE_VARIABLE_SIZE (type) != 0;
    7027              : 
    7028              :   /* Diagnose defaulting to "int".  */
    7029              : 
    7030    314265117 :   if (declspecs->default_int_p)
    7031              :     {
    7032              :       /* Issue a warning if this is an ISO C 99 program or if
    7033              :          -Wreturn-type and this is a function, or if -Wimplicit;
    7034              :          prefer the former warning since it is more explicit.  */
    7035         9764 :       if ((warn_implicit_int || warn_return_type > 0 || flag_isoc99)
    7036         1229 :           && funcdef_flag)
    7037          702 :         warn_about_return_type = 1;
    7038              :       else
    7039              :         {
    7040         9062 :           if (name)
    7041         9052 :             permerror_opt (loc, OPT_Wimplicit_int,
    7042              :                            "type defaults to %<int%> in declaration "
    7043              :                            "of %qE", name);
    7044              :           else
    7045           10 :             permerror_opt (loc, OPT_Wimplicit_int,
    7046              :                            "type defaults to %<int%> in type name");
    7047              :         }
    7048              :     }
    7049              : 
    7050              :   /* Adjust the type if a bit-field is being declared,
    7051              :      -funsigned-bitfields applied and the type is not explicitly
    7052              :      "signed".  */
    7053    314265117 :   if (bitfield && !flag_signed_bitfields && !declspecs->explicit_signed_p
    7054           40 :       && TREE_CODE (type) == INTEGER_TYPE)
    7055           38 :     type = c_common_unsigned_type (type);
    7056              : 
    7057              :   /* Figure out the type qualifiers for the declaration.  There are
    7058              :      two ways a declaration can become qualified.  One is something
    7059              :      like `const int i' where the `const' is explicit.  Another is
    7060              :      something like `typedef const int CI; CI i' where the type of the
    7061              :      declaration contains the `const'.  A third possibility is that
    7062              :      there is a type qualifier on the element type of a typedefed
    7063              :      array type, in which case we should extract that qualifier so
    7064              :      that c_apply_type_quals_to_decl receives the full list of
    7065              :      qualifiers to work with (C90 is not entirely clear about whether
    7066              :      duplicate qualifiers should be diagnosed in this case, but it
    7067              :      seems most appropriate to do so).  */
    7068    314265117 :   element_type = strip_array_types (type);
    7069    314265117 :   constp = declspecs->const_p + TYPE_READONLY (element_type);
    7070    314265117 :   restrictp = declspecs->restrict_p + TYPE_RESTRICT (element_type);
    7071    314265117 :   volatilep = declspecs->volatile_p + TYPE_VOLATILE (element_type);
    7072    314265117 :   atomicp = declspecs->atomic_p + TYPE_ATOMIC (element_type);
    7073    314265117 :   as1 = declspecs->address_space;
    7074    314265117 :   as2 = TYPE_ADDR_SPACE (element_type);
    7075    314265117 :   address_space = ADDR_SPACE_GENERIC_P (as1)? as2 : as1;
    7076              : 
    7077    314265117 :   if (constp > 1)
    7078           25 :     pedwarn_c90 (loc, OPT_Wpedantic, "duplicate %<const%>");
    7079    314265117 :   if (restrictp > 1)
    7080            6 :     pedwarn_c90 (loc, OPT_Wpedantic, "duplicate %<restrict%>");
    7081    314265117 :   if (volatilep > 1)
    7082           15 :     pedwarn_c90 (loc, OPT_Wpedantic, "duplicate %<volatile%>");
    7083    314265117 :   if (atomicp > 1)
    7084            9 :     pedwarn_c90 (loc, OPT_Wpedantic, "duplicate %<_Atomic%>");
    7085              : 
    7086    314265117 :   if (!ADDR_SPACE_GENERIC_P (as1) && !ADDR_SPACE_GENERIC_P (as2) && as1 != as2)
    7087            0 :     error_at (loc, "conflicting named address spaces (%s vs %s)",
    7088              :               c_addr_space_name (as1), c_addr_space_name (as2));
    7089              : 
    7090    314265117 :   if ((TREE_CODE (type) == ARRAY_TYPE
    7091    314089635 :        || first_non_attr_kind == cdk_array)
    7092    315351589 :       && TYPE_QUALS (element_type))
    7093              :     {
    7094           73 :       orig_qual_type = type;
    7095           73 :       type = c_build_qualified_type (type, TYPE_UNQUALIFIED);
    7096              :     }
    7097    314265117 :   type_quals = ((constp ? TYPE_QUAL_CONST : 0)
    7098    314265117 :                 | (restrictp ? TYPE_QUAL_RESTRICT : 0)
    7099    314265117 :                 | (volatilep ? TYPE_QUAL_VOLATILE : 0)
    7100    314265117 :                 | (atomicp ? TYPE_QUAL_ATOMIC : 0)
    7101    314265117 :                 | ENCODE_QUAL_ADDR_SPACE (address_space));
    7102    314265117 :   if (type_quals != TYPE_QUALS (element_type))
    7103     12817965 :     orig_qual_type = NULL_TREE;
    7104              : 
    7105              :   /* Applying the _Atomic qualifier to an array type (through the use
    7106              :      of typedefs or typeof) must be detected here.  If the qualifier
    7107              :      is introduced later, any appearance of applying it to an array is
    7108              :      actually applying it to an element of that array.  */
    7109    314265117 :   if (declspecs->atomic_p && TREE_CODE (type) == ARRAY_TYPE)
    7110            6 :     error_at (loc, "%<_Atomic%>-qualified array type");
    7111              : 
    7112              :   /* Warn about storage classes that are invalid for certain
    7113              :      kinds of declarations (parameters, typenames, etc.).  */
    7114              : 
    7115    314265117 :   if (funcdef_flag
    7116     36324553 :       && (threadp
    7117              :           || constexprp
    7118     36324551 :           || storage_class == csc_auto
    7119     36324551 :           || storage_class == csc_register
    7120     36324506 :           || storage_class == csc_typedef))
    7121              :     {
    7122           47 :       if (storage_class == csc_auto)
    7123           42 :         pedwarn (loc,
    7124           81 :                  (current_scope == file_scope) ? 0 : OPT_Wpedantic,
    7125              :                  "function definition declared %<auto%>");
    7126           50 :       if (storage_class == csc_register)
    7127            3 :         error_at (loc, "function definition declared %<register%>");
    7128           50 :       if (storage_class == csc_typedef)
    7129            3 :         error_at (loc, "function definition declared %<typedef%>");
    7130           50 :       if (threadp)
    7131            2 :         error_at (loc, "function definition declared %qs",
    7132            2 :                   declspecs->thread_gnu_p ? "__thread" : "_Thread_local");
    7133           50 :       threadp = false;
    7134              :       /* The parser ensures a constexpr function definition never
    7135              :          reaches here.  */
    7136           50 :       gcc_assert (!constexprp);
    7137           50 :       if (storage_class == csc_auto
    7138           50 :           || storage_class == csc_register
    7139              :           || storage_class == csc_typedef)
    7140           55 :         storage_class = csc_none;
    7141              :     }
    7142    314265067 :   else if (decl_context != NORMAL && (storage_class != csc_none
    7143    250013503 :                                       || threadp
    7144    250012920 :                                       || constexprp
    7145    250012918 :                                       || declspecs->c23_auto_p))
    7146              :     {
    7147          587 :       if (decl_context == PARM
    7148          587 :           && storage_class == csc_register
    7149          568 :           && !constexprp
    7150          566 :           && !declspecs->c23_auto_p)
    7151              :         ;
    7152              :       else
    7153              :         {
    7154           21 :           switch (decl_context)
    7155              :             {
    7156            0 :             case FIELD:
    7157            0 :               if (name)
    7158            0 :                 error_at (loc, "storage class specified for structure "
    7159              :                           "field %qE", name);
    7160              :               else
    7161            0 :                 error_at (loc, "storage class specified for structure field");
    7162              :               break;
    7163           21 :             case PARM:
    7164           21 :               if (name)
    7165            7 :                 error_at (loc, "storage class specified for parameter %qE",
    7166              :                           name);
    7167              :               else
    7168           14 :                 error_at (loc, "storage class specified for unnamed parameter");
    7169              :               break;
    7170            0 :             default:
    7171            0 :               error_at (loc, "storage class specified for typename");
    7172            0 :               break;
    7173              :             }
    7174    314265117 :           storage_class = csc_none;
    7175    314265117 :           threadp = false;
    7176    314265117 :           constexprp = false;
    7177              :         }
    7178              :     }
    7179    314264480 :   else if (storage_class == csc_extern
    7180    314264480 :            && initialized
    7181     35470991 :            && !funcdef_flag)
    7182              :     {
    7183              :       /* 'extern' with initialization is invalid if not at file scope.  */
    7184           28 :        if (current_scope == file_scope)
    7185              :          {
    7186              :            /* It is fine to have 'extern const' when compiling at C
    7187              :               and C++ intersection.  */
    7188           19 :            if (!(warn_cxx_compat && constp))
    7189           18 :              warning_at (loc, 0, "%qE initialized and declared %<extern%>",
    7190              :                          name);
    7191              :          }
    7192              :       else
    7193            9 :         error_at (loc, "%qE has both %<extern%> and initializer", name);
    7194              :     }
    7195    314264452 :   else if (current_scope == file_scope)
    7196              :     {
    7197     61382207 :       if (storage_class == csc_auto)
    7198            7 :         error_at (loc, "file-scope declaration of %qE specifies %<auto%>",
    7199              :                   name);
    7200     61382207 :       if (pedantic && storage_class == csc_register)
    7201            4 :         pedwarn (input_location, OPT_Wpedantic,
    7202              :                  "file-scope declaration of %qE specifies %<register%>", name);
    7203              :     }
    7204              :   else
    7205              :     {
    7206    252882245 :       if (storage_class == csc_extern && funcdef_flag)
    7207            3 :         error_at (loc, "nested function %qE declared %<extern%>", name);
    7208    252882242 :       else if (threadp && storage_class == csc_none)
    7209              :         {
    7210           14 :           error_at (loc, "function-scope %qE implicitly auto and declared "
    7211              :                     "%qs", name,
    7212            7 :                     declspecs->thread_gnu_p ? "__thread" : "_Thread_local");
    7213            7 :           threadp = false;
    7214              :         }
    7215              :     }
    7216              : 
    7217              :   /* Now figure out the structure of the declarator proper.
    7218              :      Descend through it, creating more complex types, until we reach
    7219              :      the declared identifier (or NULL_TREE, in an absolute declarator).
    7220              :      At each stage we maintain an unqualified version of the type
    7221              :      together with any qualifiers that should be applied to it with
    7222              :      c_build_qualified_type; this way, array types including
    7223              :      multidimensional array types are first built up in unqualified
    7224              :      form and then the qualified form is created with
    7225              :      TYPE_MAIN_VARIANT pointing to the unqualified form.  */
    7226              : 
    7227    384250214 :   while (declarator && declarator->kind != cdk_id)
    7228              :     {
    7229     69985097 :       if (type == error_mark_node)
    7230              :         {
    7231           39 :           declarator = declarator->declarator;
    7232           39 :           continue;
    7233              :         }
    7234              : 
    7235              :       /* Each level of DECLARATOR is either a cdk_array (for ...[..]),
    7236              :          a cdk_pointer (for *...),
    7237              :          a cdk_function (for ...(...)),
    7238              :          a cdk_attrs (for nested attributes),
    7239              :          or a cdk_id (for the name being declared
    7240              :          or the place in an absolute declarator
    7241              :          where the name was omitted).
    7242              :          For the last case, we have just exited the loop.
    7243              : 
    7244              :          At this point, TYPE is the type of elements of an array,
    7245              :          or for a function to return, or for a pointer to point to.
    7246              :          After this sequence of ifs, TYPE is the type of the
    7247              :          array or function or pointer, and DECLARATOR has had its
    7248              :          outermost layer removed.  */
    7249              : 
    7250     69985058 :       if (array_ptr_quals != TYPE_UNQUALIFIED
    7251     69985058 :           || array_ptr_attrs != NULL_TREE
    7252     69985058 :           || array_parm_static)
    7253              :         {
    7254              :           /* Only the innermost declarator (making a parameter be of
    7255              :              array type which is converted to pointer type)
    7256              :              may have static or type qualifiers.  */
    7257            1 :           error_at (loc, "static or type qualifiers in non-parameter array declarator");
    7258            1 :           array_ptr_quals = TYPE_UNQUALIFIED;
    7259            1 :           array_ptr_attrs = NULL_TREE;
    7260            1 :           array_parm_static = false;
    7261              :         }
    7262              : 
    7263     69985058 :       switch (declarator->kind)
    7264              :         {
    7265         6788 :         case cdk_attrs:
    7266         6788 :           {
    7267              :             /* A declarator with embedded attributes.  */
    7268         6788 :             tree attrs = declarator->u.attrs;
    7269         6788 :             const struct c_declarator *inner_decl;
    7270         6788 :             int attr_flags = 0;
    7271         6788 :             declarator = declarator->declarator;
    7272              :             /* Standard attribute syntax precisely defines what entity
    7273              :                an attribute in each position appertains to, so only
    7274              :                apply laxity about positioning to GNU attribute syntax.
    7275              :                Standard attributes applied to a function or array
    7276              :                declarator apply exactly to that type; standard
    7277              :                attributes applied to the identifier apply to the
    7278              :                declaration rather than to the type, and are specified
    7279              :                using a cdk_id declarator rather than using
    7280              :                cdk_attrs.  */
    7281         6788 :             inner_decl = declarator;
    7282         6788 :             while (inner_decl->kind == cdk_attrs)
    7283            0 :               inner_decl = inner_decl->declarator;
    7284         6788 :             if (!cxx11_attribute_p (attrs))
    7285              :               {
    7286         6690 :                 if (inner_decl->kind == cdk_id)
    7287              :                   attr_flags |= (int) ATTR_FLAG_DECL_NEXT;
    7288              :                 else if (inner_decl->kind == cdk_function)
    7289              :                   attr_flags |= (int) ATTR_FLAG_FUNCTION_NEXT;
    7290              :                 else if (inner_decl->kind == cdk_array)
    7291         6788 :                   attr_flags |= (int) ATTR_FLAG_ARRAY_NEXT;
    7292              :               }
    7293         6788 :             attrs = c_warn_type_attributes (type, attrs);
    7294         6788 :             returned_attrs = decl_attributes (&type,
    7295              :                                               chainon (returned_attrs, attrs),
    7296              :                                               attr_flags);
    7297         6788 :             break;
    7298              :           }
    7299      1154371 :         case cdk_array:
    7300      1154371 :           {
    7301      1154371 :             tree itype = NULL_TREE;
    7302      1154371 :             tree size = declarator->u.array.dimen;
    7303              :             /* The index is a signed object `sizetype' bits wide.  */
    7304      1154371 :             tree index_type = c_common_signed_type (sizetype);
    7305              : 
    7306      1154371 :             array_ptr_quals = declarator->u.array.quals;
    7307      1154371 :             array_ptr_attrs = declarator->u.array.attrs;
    7308      1154371 :             array_parm_static = declarator->u.array.static_p;
    7309      1154371 :             array_parm_vla_unspec_p = declarator->u.array.vla_unspec_p;
    7310              : 
    7311      1154371 :             declarator = declarator->declarator;
    7312              : 
    7313              :             /* Check for some types that there cannot be arrays of.  */
    7314              : 
    7315      1154371 :             if (VOID_TYPE_P (type))
    7316              :               {
    7317           11 :                 if (name)
    7318            9 :                   error_at (loc, "declaration of %qE as array of voids", name);
    7319              :                 else
    7320            2 :                   error_at (loc, "declaration of type name as array of voids");
    7321           11 :                 type = error_mark_node;
    7322              :               }
    7323              : 
    7324      1154371 :             if (TREE_CODE (type) == FUNCTION_TYPE)
    7325              :               {
    7326            3 :                 if (name)
    7327            2 :                   error_at (loc, "declaration of %qE as array of functions",
    7328              :                             name);
    7329              :                 else
    7330            1 :                   error_at (loc, "declaration of type name as array of "
    7331              :                             "functions");
    7332            3 :                 type = error_mark_node;
    7333              :               }
    7334              : 
    7335        22212 :             if (pedantic && !in_system_header_at (input_location)
    7336      1169412 :                 && flexible_array_type_p (type))
    7337           20 :               pedwarn (loc, OPT_Wpedantic,
    7338              :                        "invalid use of structure with flexible array member");
    7339              : 
    7340      1154371 :             if (size == error_mark_node)
    7341          119 :               type = error_mark_node;
    7342              : 
    7343      1154371 :             if (type == error_mark_node)
    7344          133 :               continue;
    7345              : 
    7346      1154238 :             if (!verify_type_context (loc, TCTX_ARRAY_ELEMENT, type))
    7347              :               {
    7348            0 :                 type = error_mark_node;
    7349            0 :                 continue;
    7350              :               }
    7351              : 
    7352              :             /* If size was specified, set ITYPE to a range-type for
    7353              :                that size.  Otherwise, ITYPE remains null.  finish_decl
    7354              :                may figure it out from an initial value.  */
    7355              : 
    7356      1154238 :             if (size)
    7357              :               {
    7358       982895 :                 bool size_maybe_const = true;
    7359       982895 :                 bool size_int_const = (TREE_CODE (size) == INTEGER_CST
    7360       982895 :                                        && !TREE_OVERFLOW (size));
    7361       982895 :                 bool this_size_varies = false;
    7362              : 
    7363              :                 /* Strip NON_LVALUE_EXPRs since we aren't using as an
    7364              :                    lvalue.  */
    7365       982904 :                 STRIP_TYPE_NOPS (size);
    7366              : 
    7367       982895 :                 if (!INTEGRAL_TYPE_P (TREE_TYPE (size)))
    7368              :                   {
    7369           16 :                     if (name)
    7370           14 :                       error_at (loc, "size of array %qE has non-integer type",
    7371              :                                 name);
    7372              :                     else
    7373            2 :                       error_at (loc,
    7374              :                                 "size of unnamed array has non-integer type");
    7375           16 :                     size = integer_one_node;
    7376           16 :                     size_int_const = true;
    7377           16 :                     size_error = true;
    7378              :                   }
    7379              :                 /* This can happen with enum forward declaration.  */
    7380       982879 :                 else if (!COMPLETE_TYPE_P (TREE_TYPE (size)))
    7381              :                   {
    7382            0 :                     if (name)
    7383            0 :                       error_at (loc, "size of array %qE has incomplete type",
    7384              :                                 name);
    7385              :                     else
    7386            0 :                       error_at (loc, "size of unnamed array has incomplete "
    7387              :                                 "type");
    7388            0 :                     size = integer_one_node;
    7389            0 :                     size_int_const = true;
    7390            0 :                     size_error = true;
    7391              :                   }
    7392              : 
    7393       982895 :                 size = c_fully_fold (size, false, &size_maybe_const);
    7394              : 
    7395       982895 :                 if (pedantic && size_maybe_const && integer_zerop (size))
    7396              :                   {
    7397            3 :                     if (name)
    7398            3 :                       pedwarn (loc, OPT_Wpedantic,
    7399              :                                "ISO C forbids zero-size array %qE", name);
    7400              :                     else
    7401            0 :                       pedwarn (loc, OPT_Wpedantic,
    7402              :                                "ISO C forbids zero-size array");
    7403              :                   }
    7404              : 
    7405       982895 :                 if (TREE_CODE (size) == INTEGER_CST && size_maybe_const)
    7406              :                   {
    7407       960536 :                     constant_expression_warning (size);
    7408       960536 :                     if (tree_int_cst_sgn (size) < 0)
    7409              :                       {
    7410          464 :                         if (name)
    7411          461 :                           error_at (loc, "size of array %qE is negative", name);
    7412              :                         else
    7413            3 :                           error_at (loc, "size of unnamed array is negative");
    7414          464 :                         size = integer_one_node;
    7415          464 :                         size_int_const = true;
    7416          464 :                         size_error = true;
    7417              :                       }
    7418              :                     /* Handle a size folded to an integer constant but
    7419              :                        not an integer constant expression.  */
    7420       960536 :                     if (!size_int_const)
    7421              :                       {
    7422              :                         /* If this is a file scope declaration of an
    7423              :                            ordinary identifier, this is invalid code;
    7424              :                            diagnosing it here and not subsequently
    7425              :                            treating the type as variable-length avoids
    7426              :                            more confusing diagnostics later.  */
    7427          155 :                         if ((decl_context == NORMAL || decl_context == FIELD)
    7428          142 :                             && current_scope == file_scope)
    7429           14 :                           pedwarn (input_location, 0,
    7430              :                                    "variably modified %qE at file scope",
    7431              :                                    name);
    7432              :                         else
    7433              :                           this_size_varies = size_varies = true;
    7434          155 :                         warn_variable_length_array (name, size);
    7435              :                       }
    7436              :                   }
    7437        22359 :                 else if ((decl_context == NORMAL || decl_context == FIELD)
    7438        13258 :                          && current_scope == file_scope)
    7439              :                   {
    7440           21 :                     error_at (loc, "variably modified %qE at file scope", name);
    7441           21 :                     size = integer_one_node;
    7442              :                   }
    7443              :                 else
    7444              :                   {
    7445              :                     /* Make sure the array size remains visibly
    7446              :                        nonconstant even if it is (eg) a const variable
    7447              :                        with known value.  */
    7448        22338 :                     this_size_varies = size_varies = true;
    7449        22338 :                     warn_variable_length_array (name, size);
    7450        22338 :                     if (sanitize_flags_p (SANITIZE_VLA)
    7451          181 :                         && current_function_decl != NULL_TREE
    7452        22501 :                         && decl_context == NORMAL)
    7453              :                       {
    7454              :                         /* Evaluate the array size only once.  */
    7455          155 :                         size = save_expr (size);
    7456          155 :                         size = c_fully_fold (size, false, NULL);
    7457          155 :                         size = fold_build2 (COMPOUND_EXPR, TREE_TYPE (size),
    7458              :                                             ubsan_instrument_vla (loc, size),
    7459              :                                             size);
    7460              :                       }
    7461              :                   }
    7462              : 
    7463       982895 :                 if (integer_zerop (size) && !this_size_varies)
    7464              :                   {
    7465              :                     /* A zero-length array cannot be represented with
    7466              :                        an unsigned index type, which is what we'll
    7467              :                        get with build_index_type.  Create an
    7468              :                        open-ended range instead.  */
    7469         2603 :                     itype = build_range_type (sizetype, size, NULL_TREE);
    7470              :                   }
    7471              :                 else
    7472              :                   {
    7473              :                     /* Arrange for the SAVE_EXPR on the inside of the
    7474              :                        MINUS_EXPR, which allows the -1 to get folded
    7475              :                        with the +1 that happens when building TYPE_SIZE.  */
    7476       980292 :                     if (size_varies)
    7477        22852 :                       size = save_expr (size);
    7478       980292 :                     if (this_size_varies && TREE_CODE (size) == INTEGER_CST)
    7479          141 :                       size = build2 (COMPOUND_EXPR, TREE_TYPE (size),
    7480              :                                      integer_zero_node, size);
    7481              : 
    7482              :                     /* Compute the maximum valid index, that is, size
    7483              :                        - 1.  Do the calculation in index_type, so that
    7484              :                        if it is a variable the computations will be
    7485              :                        done in the proper mode.  */
    7486       980292 :                     itype = fold_build2_loc (loc, MINUS_EXPR, index_type,
    7487              :                                              convert (index_type, size),
    7488              :                                              convert (index_type,
    7489              :                                                       size_one_node));
    7490              : 
    7491              :                     /* The above overflows when size does not fit
    7492              :                        in index_type.
    7493              :                        ???  While a size of INT_MAX+1 technically shouldn't
    7494              :                        cause an overflow (because we subtract 1), handling
    7495              :                        this case seems like an unnecessary complication.  */
    7496       980292 :                     if (TREE_CODE (size) == INTEGER_CST
    7497       957813 :                         && !int_fits_type_p (size, index_type))
    7498              :                       {
    7499            6 :                         if (name)
    7500            5 :                           error_at (loc, "size of array %qE is too large",
    7501              :                                     name);
    7502              :                         else
    7503            1 :                           error_at (loc, "size of unnamed array is too large");
    7504            6 :                         type = error_mark_node;
    7505            6 :                         continue;
    7506              :                       }
    7507              : 
    7508       980286 :                     itype = build_index_type (itype);
    7509              :                   }
    7510       982889 :                 if (this_size_varies)
    7511              :                   {
    7512        22479 :                     if (TREE_SIDE_EFFECTS (size))
    7513              :                       {
    7514        22116 :                         if (*expr)
    7515         8178 :                           *expr = build2 (COMPOUND_EXPR, TREE_TYPE (size),
    7516              :                                           *expr, size);
    7517              :                         else
    7518        13938 :                           *expr = size;
    7519              :                       }
    7520        22479 :                     *expr_const_operands &= size_maybe_const;
    7521              :                   }
    7522              :               }
    7523       171343 :             else if (decl_context == FIELD)
    7524              :               {
    7525        86000 :                 bool flexible_array_member = false;
    7526        86000 :                 if (array_parm_vla_unspec_p)
    7527              :                   /* Field names can in fact have function prototype
    7528              :                      scope so [*] is disallowed here through making
    7529              :                      the field variably modified, not through being
    7530              :                      something other than a declaration with function
    7531              :                      prototype scope.  */
    7532              :                   size_varies = true;
    7533              :                 else
    7534              :                   {
    7535              :                     const struct c_declarator *t = declarator;
    7536        85997 :                     while (t->kind == cdk_attrs)
    7537            0 :                       t = t->declarator;
    7538        85997 :                     flexible_array_member = (t->kind == cdk_id);
    7539              :                   }
    7540        85997 :                 if (flexible_array_member
    7541        85997 :                     && !in_system_header_at (input_location))
    7542        84966 :                   pedwarn_c90 (loc, OPT_Wpedantic, "ISO C90 does not "
    7543              :                                "support flexible array members");
    7544              : 
    7545              :                 /* ISO C99 Flexible array members are effectively
    7546              :                    identical to GCC's zero-length array extension.  */
    7547        86000 :                 if (flexible_array_member)
    7548        85977 :                   itype = build_index_type (NULL_TREE);
    7549              :               }
    7550              : 
    7551              :             /* Complain about arrays of incomplete types.  */
    7552      1154232 :             if (!COMPLETE_TYPE_P (type))
    7553              :               {
    7554           58 :                 auto_diagnostic_group d;
    7555           58 :                 error_at (loc, "array type has incomplete element type %qT",
    7556              :                           type);
    7557              :                 /* See if we can be more helpful.  */
    7558           58 :                 if (TREE_CODE (type) == ARRAY_TYPE)
    7559              :                   {
    7560           29 :                     if (name)
    7561           24 :                       inform (loc, "declaration of %qE as multidimensional "
    7562              :                               "array must have bounds for all dimensions "
    7563              :                               "except the first", name);
    7564              :                     else
    7565            5 :                       inform (loc, "declaration of multidimensional array "
    7566              :                               "must have bounds for all dimensions except "
    7567              :                               "the first");
    7568              :                   }
    7569           58 :                 type = error_mark_node;
    7570           58 :               }
    7571              :             else
    7572              :             /* When itype is NULL, a shared incomplete array type is
    7573              :                returned for all array of a given type.  Elsewhere we
    7574              :                make sure we don't complete that type before copying
    7575              :                it, but here we want to make sure we don't ever
    7576              :                modify the shared type, so we gcc_assert (itype)
    7577              :                below.  */
    7578              :               {
    7579      1154174 :                 addr_space_t as = DECODE_QUAL_ADDR_SPACE (type_quals);
    7580      1154174 :                 if (!ADDR_SPACE_GENERIC_P (as) && as != TYPE_ADDR_SPACE (type))
    7581            0 :                   type = c_build_qualified_type (type,
    7582              :                                                  ENCODE_QUAL_ADDR_SPACE (as));
    7583      1154174 :                 if (array_parm_vla_unspec_p)
    7584          150 :                   type = c_build_array_type_unspecified (type);
    7585              :                 else
    7586      1154024 :                   type = c_build_array_type (type, itype);
    7587              :               }
    7588              : 
    7589      1154232 :             if (array_parm_vla_unspec_p)
    7590              :               {
    7591              :                 /* C99 6.7.5.2p4 */
    7592          150 :                 if (decl_context == TYPENAME)
    7593            6 :                   warning (0, "%<[*]%> not in a declaration");
    7594          144 :                 else if (decl_context != GENERIC_ASSOC
    7595          144 :                          && decl_context != PARM
    7596            7 :                          && decl_context != FIELD)
    7597              :                   {
    7598            4 :                     error ("%<[*]%> not allowed in other than function prototype scope "
    7599              :                            "or generic association");
    7600            4 :                     type = error_mark_node;
    7601              :                   }
    7602              :                 size_varies = true;
    7603              :               }
    7604              : 
    7605      1154232 :             if (type != error_mark_node)
    7606              :               {
    7607              :                 /* The GCC extension for zero-length arrays differs from
    7608              :                    ISO flexible array members in that sizeof yields
    7609              :                    zero.  */
    7610      1154170 :                 if (size && integer_zerop (size))
    7611              :                   {
    7612         2596 :                     gcc_assert (itype);
    7613         2596 :                     type = build_distinct_type_copy (TYPE_MAIN_VARIANT (type));
    7614         2596 :                     TYPE_SIZE (type) = bitsize_zero_node;
    7615         2596 :                     TYPE_SIZE_UNIT (type) = size_zero_node;
    7616         2596 :                     SET_TYPE_STRUCTURAL_EQUALITY (type);
    7617              :                   }
    7618              : 
    7619      1154170 :                 if (!valid_array_size_p (loc, type, name))
    7620           33 :                   type = error_mark_node;
    7621              :               }
    7622              : 
    7623      1154232 :             if (decl_context != PARM
    7624       835364 :                 && (array_ptr_quals != TYPE_UNQUALIFIED
    7625       835364 :                     || array_ptr_attrs != NULL_TREE
    7626       835363 :                     || array_parm_static))
    7627              :               {
    7628            2 :                 error_at (loc, "static or type qualifiers in non-parameter "
    7629              :                           "array declarator");
    7630            2 :                 array_ptr_quals = TYPE_UNQUALIFIED;
    7631            2 :                 array_ptr_attrs = NULL_TREE;
    7632            2 :                 array_parm_static = false;
    7633              :               }
    7634      1154232 :             orig_qual_indirect++;
    7635      1154232 :             break;
    7636              :           }
    7637     50582343 :         case cdk_function:
    7638     50582343 :           {
    7639              :             /* Say it's a definition only for the declarator closest
    7640              :                to the identifier, apart possibly from some
    7641              :                attributes.  */
    7642     50582343 :             bool really_funcdef = false;
    7643     50582343 :             tree arg_types;
    7644     50582343 :             orig_qual_type = NULL_TREE;
    7645     50582343 :             if (funcdef_flag)
    7646              :               {
    7647     36324576 :                 const struct c_declarator *t = declarator->declarator;
    7648     36324594 :                 while (t->kind == cdk_attrs)
    7649           18 :                   t = t->declarator;
    7650     36324576 :                 really_funcdef = (t->kind == cdk_id);
    7651              :               }
    7652              : 
    7653              :             /* Declaring a function type.  Make sure we have a valid
    7654              :                type for the function to return.  */
    7655     50582343 :             if (type == error_mark_node)
    7656            0 :               continue;
    7657              : 
    7658     50582343 :             size_varies = false;
    7659              : 
    7660              :             /* Warn about some types functions can't return.  */
    7661     50582343 :             if (TREE_CODE (type) == FUNCTION_TYPE)
    7662              :               {
    7663            0 :                 if (name)
    7664            0 :                   error_at (loc, "%qE declared as function returning a "
    7665              :                                  "function", name);
    7666              :                 else
    7667            0 :                   error_at (loc, "type name declared as function "
    7668              :                             "returning a function");
    7669            0 :                 type = integer_type_node;
    7670              :               }
    7671     50582343 :             if (TREE_CODE (type) == ARRAY_TYPE)
    7672              :               {
    7673            0 :                 if (name)
    7674            0 :                   error_at (loc, "%qE declared as function returning an array",
    7675              :                             name);
    7676              :                 else
    7677            0 :                   error_at (loc, "type name declared as function returning "
    7678              :                             "an array");
    7679            0 :                 type = integer_type_node;
    7680              :               }
    7681              : 
    7682              :             /* Construct the function type and go to the next
    7683              :                inner layer of declarator.  */
    7684     50582343 :             arg_info = declarator->u.arg_info;
    7685     50582343 :             arg_types = grokparms (arg_info, really_funcdef);
    7686              : 
    7687              :             /* Type qualifiers before the return type of the function
    7688              :                qualify the return type, not the function type.  */
    7689     50582343 :             if (type_quals)
    7690              :               {
    7691          235 :                 const enum c_declspec_word ignored_quals_list[] =
    7692              :                   {
    7693              :                     cdw_const, cdw_volatile, cdw_restrict, cdw_address_space,
    7694              :                     cdw_atomic, cdw_number_of_elements
    7695              :                   };
    7696          235 :                 location_t specs_loc
    7697          235 :                   = smallest_type_quals_location (declspecs->locations,
    7698              :                                                   ignored_quals_list);
    7699          235 :                 if (specs_loc == UNKNOWN_LOCATION)
    7700          139 :                   specs_loc = declspecs->locations[cdw_typedef];
    7701          139 :                 if (specs_loc == UNKNOWN_LOCATION)
    7702           15 :                   specs_loc = loc;
    7703              : 
    7704              :                 /* Type qualifiers on a function return type are
    7705              :                    normally permitted by the standard but have no
    7706              :                    effect, so give a warning at -Wreturn-type.
    7707              :                    Qualifiers on a void return type are banned on
    7708              :                    function definitions in ISO C; GCC used to used
    7709              :                    them for noreturn functions.  The resolution of C11
    7710              :                    DR#423 means qualifiers (other than _Atomic) are
    7711              :                    actually removed from the return type when
    7712              :                    determining the function type.  For C23, _Atomic is
    7713              :                    removed as well.  */
    7714          235 :                 int quals_used = type_quals;
    7715          235 :                 if (flag_isoc23)
    7716              :                   quals_used = 0;
    7717           65 :                 else if (flag_isoc11)
    7718           31 :                   quals_used &= TYPE_QUAL_ATOMIC;
    7719           65 :                 if (quals_used && VOID_TYPE_P (type) && really_funcdef)
    7720            5 :                   pedwarn (specs_loc, 0,
    7721              :                            "function definition has qualified void "
    7722              :                            "return type");
    7723              :                 else
    7724          230 :                   warning_at (specs_loc, OPT_Wignored_qualifiers,
    7725              :                               "type qualifiers ignored on function "
    7726              :                               "return type");
    7727              : 
    7728              :                 /* Ensure an error for restrict on invalid types; the
    7729              :                    DR#423 resolution is not entirely clear about
    7730              :                    this.  */
    7731          235 :                 if (flag_isoc11
    7732          201 :                     && (type_quals & TYPE_QUAL_RESTRICT)
    7733          241 :                     && (!POINTER_TYPE_P (type)
    7734            4 :                         || !C_TYPE_OBJECT_OR_INCOMPLETE_P (TREE_TYPE (type))))
    7735            4 :                   error_at (loc, "invalid use of %<restrict%>");
    7736          235 :                 type = c_build_qualified_type (type, quals_used);
    7737              :               }
    7738     50582343 :             type_quals = TYPE_UNQUALIFIED;
    7739              : 
    7740    101164686 :             type = c_build_function_type (type, arg_types,
    7741     50582343 :                                           arg_info->no_named_args_stdarg_p);
    7742     50582343 :             declarator = declarator->declarator;
    7743              : 
    7744              :             /* Set the TYPE_CONTEXTs for each tagged type which is local to
    7745              :                the formal parameter list of this FUNCTION_TYPE to point to
    7746              :                the FUNCTION_TYPE node itself.  */
    7747     50582343 :             {
    7748     50582343 :               c_arg_tag *tag;
    7749     50582343 :               unsigned ix;
    7750              : 
    7751    434832836 :               FOR_EACH_VEC_SAFE_ELT_REVERSE (arg_info->tags, ix, tag)
    7752          142 :                 TYPE_CONTEXT (tag->type) = type;
    7753              :             }
    7754              :             break;
    7755              :           }
    7756     18241556 :         case cdk_pointer:
    7757     18241556 :           {
    7758              :             /* Merge any constancy or volatility into the target type
    7759              :                for the pointer.  */
    7760     18241556 :             if ((type_quals & TYPE_QUAL_ATOMIC)
    7761         1988 :                 && TREE_CODE (type) == FUNCTION_TYPE)
    7762              :               {
    7763            2 :                 error_at (loc,
    7764              :                           "%<_Atomic%>-qualified function type");
    7765            2 :                 type_quals &= ~TYPE_QUAL_ATOMIC;
    7766              :               }
    7767     18241554 :             else if (pedantic && TREE_CODE (type) == FUNCTION_TYPE
    7768         1701 :                      && type_quals)
    7769            0 :               pedwarn (loc, OPT_Wpedantic,
    7770              :                        "ISO C forbids qualified function types");
    7771     18239855 :             if (type_quals)
    7772      6005574 :               type = c_build_qualified_type (type, type_quals, orig_qual_type,
    7773              :                                              orig_qual_indirect);
    7774     18241556 :             orig_qual_type = NULL_TREE;
    7775     18241556 :             size_varies = false;
    7776              : 
    7777              :             /* When the pointed-to type involves components of variable size,
    7778              :                care must be taken to ensure that the size evaluation code is
    7779              :                emitted early enough to dominate all the possible later uses
    7780              :                and late enough for the variables on which it depends to have
    7781              :                been assigned.
    7782              : 
    7783              :                This is expected to happen automatically when the pointed-to
    7784              :                type has a name/declaration of it's own, but special attention
    7785              :                is required if the type is anonymous. */
    7786     18241556 :             if (!TYPE_NAME (type) && c_type_variably_modified_p (type))
    7787              :               {
    7788         5949 :                 bool bind_p = decl_context == TYPENAME
    7789              :                               || decl_context == FIELD
    7790         5949 :                               || decl_context == PARM;
    7791        11391 :                 add_decl_expr (loc, type, bind_p ? expr : NULL, true);
    7792              :               }
    7793              : 
    7794     18241556 :             type = c_build_pointer_type (type);
    7795              : 
    7796              :             /* Process type qualifiers (such as const or volatile)
    7797              :                that were given inside the `*'.  */
    7798     18241556 :             type_quals = declarator->u.pointer_quals;
    7799              : 
    7800     18241556 :             declarator = declarator->declarator;
    7801     18241556 :             break;
    7802              :           }
    7803            0 :         default:
    7804            0 :           gcc_unreachable ();
    7805              :         }
    7806              :     }
    7807    314265117 :   *decl_attrs = chainon (returned_attrs, *decl_attrs);
    7808    314265117 :   *decl_attrs = chainon (decl_id_attrs, *decl_attrs);
    7809              : 
    7810              :   /* Now TYPE has the actual type, apart from any qualifiers in
    7811              :      TYPE_QUALS.  */
    7812              : 
    7813              :   /* Warn about address space used for things other than static memory or
    7814              :      pointers.  */
    7815    314265117 :   address_space = DECODE_QUAL_ADDR_SPACE (type_quals);
    7816    314265117 :   if (!ADDR_SPACE_GENERIC_P (address_space))
    7817              :     {
    7818           10 :       if (decl_context == NORMAL)
    7819              :         {
    7820           10 :           switch (storage_class)
    7821              :             {
    7822            0 :             case csc_auto:
    7823            0 :               error ("%qs combined with %<auto%> qualifier for %qE",
    7824              :                      c_addr_space_name (address_space), name);
    7825            0 :               break;
    7826            0 :             case csc_register:
    7827            0 :               error ("%qs combined with %<register%> qualifier for %qE",
    7828              :                      c_addr_space_name (address_space), name);
    7829            0 :               break;
    7830            6 :             case csc_none:
    7831            6 :               if (current_function_scope)
    7832              :                 {
    7833            0 :                   error ("%qs specified for auto variable %qE",
    7834              :                          c_addr_space_name (address_space), name);
    7835            0 :                   break;
    7836              :                 }
    7837              :               break;
    7838              :             case csc_static:
    7839              :             case csc_extern:
    7840              :             case csc_typedef:
    7841              :               break;
    7842            0 :             default:
    7843            0 :               gcc_unreachable ();
    7844              :             }
    7845              :         }
    7846            0 :       else if (decl_context == PARM && TREE_CODE (type) != ARRAY_TYPE)
    7847              :         {
    7848            0 :           if (name)
    7849            0 :             error ("%qs specified for parameter %qE",
    7850              :                    c_addr_space_name (address_space), name);
    7851              :           else
    7852            0 :             error ("%qs specified for unnamed parameter",
    7853              :                    c_addr_space_name (address_space));
    7854              :         }
    7855            0 :       else if (decl_context == FIELD)
    7856              :         {
    7857            0 :           if (name)
    7858            0 :             error ("%qs specified for structure field %qE",
    7859              :                    c_addr_space_name (address_space), name);
    7860              :           else
    7861            0 :             error ("%qs specified for structure field",
    7862              :                    c_addr_space_name (address_space));
    7863              :         }
    7864              :     }
    7865              : 
    7866              :   /* Check the type and width of a bit-field.  */
    7867    314265117 :   if (bitfield)
    7868              :     {
    7869        52597 :       check_bitfield_type_and_width (loc, &type, width, name);
    7870              :       /* C11 makes it implementation-defined (6.7.2.1#5) whether
    7871              :          atomic types are permitted for bit-fields; we have no code to
    7872              :          make bit-field accesses atomic, so disallow them.  */
    7873        52597 :       if (type_quals & TYPE_QUAL_ATOMIC)
    7874              :         {
    7875            2 :           if (name)
    7876            1 :             error_at (loc, "bit-field %qE has atomic type", name);
    7877              :           else
    7878            1 :             error_at (loc, "bit-field has atomic type");
    7879            2 :           type_quals &= ~TYPE_QUAL_ATOMIC;
    7880              :         }
    7881              :     }
    7882              : 
    7883              :   /* Reject invalid uses of _Alignas.  */
    7884    314265117 :   if (declspecs->alignas_p)
    7885              :     {
    7886          190 :       if (storage_class == csc_typedef)
    7887            1 :         error_at (loc, "alignment specified for typedef %qE", name);
    7888          189 :       else if (storage_class == csc_register)
    7889            1 :         error_at (loc, "alignment specified for %<register%> object %qE",
    7890              :                   name);
    7891          188 :       else if (decl_context == PARM)
    7892              :         {
    7893            2 :           if (name)
    7894            1 :             error_at (loc, "alignment specified for parameter %qE", name);
    7895              :           else
    7896            1 :             error_at (loc, "alignment specified for unnamed parameter");
    7897              :         }
    7898          186 :       else if (bitfield)
    7899              :         {
    7900            0 :           if (name)
    7901            0 :             error_at (loc, "alignment specified for bit-field %qE", name);
    7902              :           else
    7903            0 :             error_at (loc, "alignment specified for unnamed bit-field");
    7904              :         }
    7905          186 :       else if (TREE_CODE (type) == FUNCTION_TYPE)
    7906            1 :         error_at (loc, "alignment specified for function %qE", name);
    7907          185 :       else if (declspecs->align_log != -1 && TYPE_P (type))
    7908              :         {
    7909          158 :           alignas_align = 1U << declspecs->align_log;
    7910          158 :           if (alignas_align < min_align_of_type (type))
    7911              :             {
    7912           26 :               if (name)
    7913           25 :                 error_at (loc, "%<_Alignas%> specifiers cannot reduce "
    7914              :                           "alignment of %qE", name);
    7915              :               else
    7916            1 :                 error_at (loc, "%<_Alignas%> specifiers cannot reduce "
    7917              :                           "alignment of unnamed field");
    7918              :               alignas_align = 0;
    7919              :             }
    7920              :         }
    7921              :     }
    7922              : 
    7923              :   /* If this is declaring a typedef name, return a TYPE_DECL.  */
    7924              : 
    7925    314265117 :   if (storage_class == csc_typedef)
    7926              :     {
    7927      4320957 :       tree decl;
    7928      4320957 :       if ((type_quals & TYPE_QUAL_ATOMIC)
    7929        12630 :           && TREE_CODE (type) == FUNCTION_TYPE)
    7930              :         {
    7931            0 :           error_at (loc,
    7932              :                     "%<_Atomic%>-qualified function type");
    7933            0 :           type_quals &= ~TYPE_QUAL_ATOMIC;
    7934              :         }
    7935      4320957 :       else if (pedantic && TREE_CODE (type) == FUNCTION_TYPE
    7936          609 :                && type_quals)
    7937            0 :         pedwarn (loc, OPT_Wpedantic,
    7938              :                  "ISO C forbids qualified function types");
    7939      4320348 :       if (type_quals)
    7940        31608 :         type = c_build_qualified_type (type, type_quals, orig_qual_type,
    7941              :                                        orig_qual_indirect);
    7942      8641914 :       decl = build_decl (declarator->id_loc,
    7943      4320957 :                          TYPE_DECL, declarator->u.id.id, type);
    7944      4320957 :       if (declspecs->explicit_signed_p)
    7945       356770 :         C_TYPEDEF_EXPLICITLY_SIGNED (decl) = 1;
    7946      4320957 :       if (declspecs->inline_p)
    7947            4 :         pedwarn (loc, 0,"typedef %q+D declared %<inline%>", decl);
    7948      4320957 :       if (declspecs->noreturn_p)
    7949            1 :         pedwarn (loc, 0,"typedef %q+D declared %<_Noreturn%>", decl);
    7950              : 
    7951      4320957 :       if (warn_cxx_compat && declarator->u.id.id != NULL_TREE)
    7952              :         {
    7953         1826 :           struct c_binding *b = I_TAG_BINDING (declarator->u.id.id);
    7954              : 
    7955         1826 :           if (b != NULL
    7956           40 :               && b->decl != NULL_TREE
    7957           40 :               && (B_IN_CURRENT_SCOPE (b)
    7958            4 :                   || (current_scope == file_scope && B_IN_EXTERNAL_SCOPE (b)))
    7959         1862 :               && TYPE_MAIN_VARIANT (b->decl) != TYPE_MAIN_VARIANT (type))
    7960              :             {
    7961            7 :               auto_diagnostic_group d;
    7962            8 :               if (warning_at (declarator->id_loc, OPT_Wc___compat,
    7963              :                               "using %qD as both a typedef and a tag is "
    7964              :                               "invalid in C++", decl)
    7965            7 :                   && b->locus != UNKNOWN_LOCATION)
    7966            6 :                 inform (b->locus, "originally defined here");
    7967            7 :             }
    7968              :         }
    7969              : 
    7970      4320957 :       return decl;
    7971              :     }
    7972              : 
    7973              :   /* If this is a type name (such as, in a cast or sizeof),
    7974              :      compute the type and return it now.  */
    7975              : 
    7976    309944160 :   if (decl_context == TYPENAME || decl_context == GENERIC_ASSOC)
    7977              :     {
    7978              :       /* Note that the grammar rejects storage classes in typenames
    7979              :          and fields.  */
    7980    121574160 :       gcc_assert (storage_class == csc_none && !threadp
    7981              :                   && !declspecs->inline_p && !declspecs->noreturn_p);
    7982    121574160 :       if ((type_quals & TYPE_QUAL_ATOMIC)
    7983          257 :           && TREE_CODE (type) == FUNCTION_TYPE)
    7984              :         {
    7985            0 :           error_at (loc,
    7986              :                     "%<_Atomic%>-qualified function type");
    7987            0 :           type_quals &= ~TYPE_QUAL_ATOMIC;
    7988              :         }
    7989    121574160 :       else if (pedantic && TREE_CODE (type) == FUNCTION_TYPE
    7990           22 :                && type_quals)
    7991            0 :         pedwarn (loc, OPT_Wpedantic,
    7992              :                  "ISO C forbids const or volatile function types");
    7993    121574138 :       if (type_quals)
    7994          855 :         type = c_build_qualified_type (type, type_quals, orig_qual_type,
    7995              :                                        orig_qual_indirect);
    7996    121574160 :       return type;
    7997              :     }
    7998              : 
    7999       376552 :   if (pedantic && decl_context == FIELD
    8000    188394810 :       && c_type_variably_modified_p (type))
    8001              :     {
    8002              :       /* C99 6.7.2.1p8 */
    8003            7 :       pedwarn (loc, OPT_Wpedantic, "a member of a structure or union cannot "
    8004              :                "have a variably modified type");
    8005              :     }
    8006              : 
    8007              :   /* Aside from typedefs and type names (handle above),
    8008              :      `void' at top level (not within pointer)
    8009              :      is allowed only in public variables.
    8010              :      We don't complain about parms either, but that is because
    8011              :      a better error message can be made later.  */
    8012              : 
    8013    188370000 :   if (VOID_TYPE_P (type) && decl_context != PARM
    8014           64 :       && !((decl_context != FIELD && TREE_CODE (type) != FUNCTION_TYPE)
    8015              :             && (storage_class == csc_extern
    8016           27 :                 || (current_scope == file_scope
    8017           18 :                     && !(storage_class == csc_static
    8018              :                          || storage_class == csc_register)))))
    8019              :     {
    8020           15 :       error_at (loc, "variable or field %qE declared void", name);
    8021           15 :       type = integer_type_node;
    8022              :     }
    8023              : 
    8024              :   /* Now create the decl, which may be a VAR_DECL, a PARM_DECL
    8025              :      or a FUNCTION_DECL, depending on DECL_CONTEXT and TYPE.  */
    8026              : 
    8027    187415146 :   {
    8028    187415146 :     tree decl;
    8029              : 
    8030    187415146 :     if (decl_context == PARM)
    8031              :       {
    8032    124112724 :         tree promoted_type;
    8033    124112724 :         bool array_parameter_p = false;
    8034              : 
    8035              :         /* A parameter declared as an array of T is really a pointer to T.
    8036              :            One declared as a function is really a pointer to a function.  */
    8037              : 
    8038    124112724 :         if (TREE_CODE (type) == ARRAY_TYPE)
    8039              :           {
    8040       436788 :             if (!size_error)
    8041       436774 :               *decl_attrs = build_arg_spec_attribute (type, array_parm_static,
    8042              :                                                       *decl_attrs);
    8043              : 
    8044              :             /* Transfer const-ness of array into that of type pointed to.  */
    8045       436788 :             type = TREE_TYPE (type);
    8046       436788 :             if (orig_qual_type != NULL_TREE)
    8047              :               {
    8048            7 :                 if (orig_qual_indirect == 0)
    8049            5 :                   orig_qual_type = TREE_TYPE (orig_qual_type);
    8050              :                 else
    8051            2 :                   orig_qual_indirect--;
    8052              :               }
    8053       436788 :             if (type_quals)
    8054        48198 :               type = c_build_qualified_type (type, type_quals, orig_qual_type,
    8055              :                                              orig_qual_indirect);
    8056              : 
    8057              :             /* The pointed-to type may need a decl expr (see above).  */
    8058       436788 :             if (!TYPE_NAME (type) && c_type_variably_modified_p (type))
    8059              :               {
    8060          373 :                 bool bind_p = decl_context == TYPENAME
    8061              :                               || decl_context == FIELD
    8062              :                               || decl_context == PARM;
    8063          373 :                 add_decl_expr (loc, type, bind_p ? expr : NULL, true);
    8064              :               }
    8065              : 
    8066       436788 :             type = c_build_pointer_type (type);
    8067       436788 :             type_quals = array_ptr_quals;
    8068       436788 :             if (type_quals)
    8069          965 :               type = c_build_qualified_type (type, type_quals);
    8070              : 
    8071              :             /* We don't yet implement attributes in this context.  */
    8072       436788 :             if (array_ptr_attrs != NULL_TREE)
    8073            0 :               warning_at (loc, OPT_Wattributes,
    8074              :                           "attributes in parameter array declarator ignored");
    8075              : 
    8076              :             size_varies = false;
    8077              :             array_parameter_p = true;
    8078              :           }
    8079    123675936 :         else if (TREE_CODE (type) == FUNCTION_TYPE)
    8080              :           {
    8081          301 :             if (type_quals & TYPE_QUAL_ATOMIC)
    8082              :               {
    8083            1 :                 error_at (loc,
    8084              :                           "%<_Atomic%>-qualified function type");
    8085            1 :                 type_quals &= ~TYPE_QUAL_ATOMIC;
    8086              :               }
    8087          300 :             else if (type_quals)
    8088            0 :               pedwarn (loc, OPT_Wpedantic,
    8089              :                        "ISO C forbids qualified function types");
    8090            1 :             if (type_quals)
    8091            0 :               type = c_build_qualified_type (type, type_quals);
    8092          301 :             type = c_build_pointer_type (type);
    8093          301 :             type_quals = TYPE_UNQUALIFIED;
    8094              :           }
    8095    123675635 :         else if (type_quals)
    8096      9942238 :           type = c_build_qualified_type (type, type_quals);
    8097              : 
    8098    248225448 :         decl = build_decl (declarator->id_loc,
    8099    124112724 :                            PARM_DECL, declarator->u.id.id, type);
    8100    124112724 :         if (size_varies)
    8101           42 :           C_DECL_VARIABLE_SIZE (decl) = 1;
    8102    124112724 :         C_ARRAY_PARAMETER (decl) = array_parameter_p;
    8103              : 
    8104              :         /* Compute the type actually passed in the parmlist,
    8105              :            for the case where there is no prototype.
    8106              :            (For example, shorts and chars are passed as ints.)
    8107              :            When there is a prototype, this is overridden later.  */
    8108              : 
    8109    124112724 :         if (type == error_mark_node)
    8110              :           promoted_type = type;
    8111              :         else
    8112    124112640 :           promoted_type = c_type_promotes_to (type);
    8113              : 
    8114    124112724 :         DECL_ARG_TYPE (decl) = promoted_type;
    8115    124112724 :         if (declspecs->inline_p)
    8116            4 :           pedwarn (loc, 0, "parameter %q+D declared %<inline%>", decl);
    8117    124112724 :         if (declspecs->noreturn_p)
    8118            1 :           pedwarn (loc, 0, "parameter %q+D declared %<_Noreturn%>", decl);
    8119              :       }
    8120     64257276 :     else if (decl_context == FIELD)
    8121              :       {
    8122              :         /* Note that the grammar rejects storage classes in typenames
    8123              :            and fields.  */
    8124      4326619 :         gcc_assert (storage_class == csc_none && !threadp
    8125              :                     && !declspecs->inline_p && !declspecs->noreturn_p);
    8126              : 
    8127              :         /* Structure field.  It may not be a function.  */
    8128              : 
    8129      4326619 :         if (TREE_CODE (type) == FUNCTION_TYPE)
    8130              :           {
    8131            0 :             error_at (loc, "field %qE declared as a function", name);
    8132            0 :             type = c_build_pointer_type (type);
    8133              :           }
    8134      4326619 :         else if (TREE_CODE (type) != ERROR_MARK
    8135      4326619 :                  && !COMPLETE_OR_UNBOUND_ARRAY_TYPE_P (type))
    8136              :           {
    8137           24 :             if (name)
    8138           17 :               error_at (loc, "field %qE has incomplete type", name);
    8139              :             else
    8140            7 :               error_at (loc, "unnamed field has incomplete type");
    8141           24 :             type = error_mark_node;
    8142              :           }
    8143      4326595 :         else if (TREE_CODE (type) == ARRAY_TYPE
    8144      4326595 :                  && TYPE_DOMAIN (type) == NULL_TREE)
    8145              :           {
    8146              :             /* We have a flexible array member through a typedef.
    8147              :                Set suitable range.  Whether this is a correct position
    8148              :                for a flexible array member will be determined elsewhere.  */
    8149           14 :             if (!in_system_header_at (input_location))
    8150           14 :               pedwarn_c90 (loc, OPT_Wpedantic, "ISO C90 does not "
    8151              :                            "support flexible array members");
    8152           14 :             type = build_distinct_type_copy (TYPE_MAIN_VARIANT (type));
    8153           14 :             TYPE_DOMAIN (type) = build_range_type (sizetype, size_zero_node,
    8154              :                                                    NULL_TREE);
    8155           14 :             if (orig_qual_indirect == 0)
    8156      4326619 :               orig_qual_type = NULL_TREE;
    8157              :           }
    8158      4326619 :         if (type != error_mark_node
    8159      4326619 :             && !verify_type_context (loc, TCTX_FIELD, type))
    8160            0 :           type = error_mark_node;
    8161              : 
    8162      4326619 :         type = c_build_qualified_type (type, type_quals, orig_qual_type,
    8163              :                                        orig_qual_indirect);
    8164      8653238 :         decl = build_decl (declarator->id_loc,
    8165      4326619 :                            FIELD_DECL, declarator->u.id.id, type);
    8166      4326619 :         DECL_NONADDRESSABLE_P (decl) = bitfield;
    8167      4326619 :         if (bitfield && !declarator->u.id.id)
    8168         9762 :           DECL_PADDING_P (decl) = 1;
    8169              : 
    8170      4326619 :         if (size_varies)
    8171          669 :           C_DECL_VARIABLE_SIZE (decl) = 1;
    8172              :       }
    8173     59930657 :     else if (TREE_CODE (type) == FUNCTION_TYPE)
    8174              :       {
    8175     51007234 :         if (storage_class == csc_register || threadp || constexprp)
    8176              :           {
    8177           12 :             error_at (loc, "invalid storage class for function %qE", name);
    8178              :           }
    8179     51007222 :         else if (current_scope != file_scope)
    8180              :           {
    8181              :             /* Function declaration not at file scope.  Storage
    8182              :                classes other than `extern' are not allowed, C99
    8183              :                6.7.1p5, and `extern' makes no difference.  However,
    8184              :                GCC allows 'auto', perhaps with 'inline', to support
    8185              :                nested functions.  */
    8186        10563 :             if (storage_class == csc_auto)
    8187           66 :                 pedwarn (loc, OPT_Wpedantic,
    8188              :                          "invalid storage class for function %qE", name);
    8189        10497 :             else if (storage_class == csc_static)
    8190              :               {
    8191           20 :                 error_at (loc, "invalid storage class for function %qE", name);
    8192           20 :                 if (funcdef_flag)
    8193            8 :                   storage_class = declspecs->storage_class = csc_none;
    8194              :                 else
    8195              :                   return NULL_TREE;
    8196              :               }
    8197              :           }
    8198              : 
    8199    102014444 :         decl = build_decl (declarator->id_loc,
    8200     51007222 :                            FUNCTION_DECL, declarator->u.id.id, type);
    8201     51007222 :         decl = build_decl_attribute_variant (decl, decl_attr);
    8202              : 
    8203     51007222 :         if (type_quals & TYPE_QUAL_ATOMIC)
    8204              :           {
    8205            2 :             error_at (loc,
    8206              :                       "%<_Atomic%>-qualified function type");
    8207            2 :             type_quals &= ~TYPE_QUAL_ATOMIC;
    8208              :           }
    8209     51007220 :         else if (pedantic && type_quals && !DECL_IN_SYSTEM_HEADER (decl))
    8210            9 :           pedwarn (loc, OPT_Wpedantic,
    8211              :                    "ISO C forbids qualified function types");
    8212              : 
    8213              :         /* Every function declaration is an external reference
    8214              :            (DECL_EXTERNAL) except for those which are not at file
    8215              :            scope and are explicitly declared "auto".  This is
    8216              :            forbidden by standard C (C99 6.7.1p5) and is interpreted by
    8217              :            GCC to signify a forward declaration of a nested function.  */
    8218     51007222 :         if (storage_class == csc_auto && current_scope != file_scope)
    8219           66 :           DECL_EXTERNAL (decl) = 0;
    8220              :         /* In C99, a function which is declared 'inline' with 'extern'
    8221              :            is not an external reference (which is confusing).  It
    8222              :            means that the later definition of the function must be output
    8223              :            in this file, C99 6.7.4p6.  In GNU C89, a function declared
    8224              :            'extern inline' is an external reference.  */
    8225     51007156 :         else if (declspecs->inline_p && storage_class != csc_static)
    8226     35474711 :           DECL_EXTERNAL (decl) = ((storage_class == csc_extern)
    8227     35474711 :                                   == flag_gnu89_inline);
    8228              :         else
    8229     15532445 :           DECL_EXTERNAL (decl) = !initialized;
    8230              : 
    8231              :         /* Record absence of global scope for `static' or `auto'.  */
    8232     51007222 :         TREE_PUBLIC (decl)
    8233     51007222 :           = !(storage_class == csc_static || storage_class == csc_auto);
    8234              : 
    8235              :         /* For a function definition, record the argument information
    8236              :            block where store_parm_decls will look for it.  */
    8237     51007222 :         if (funcdef_flag)
    8238     36324546 :           current_function_arg_info = arg_info;
    8239              : 
    8240     51007222 :         if (declspecs->default_int_p)
    8241         9220 :           C_FUNCTION_IMPLICIT_INT (decl) = 1;
    8242              : 
    8243              :         /* Record presence of `inline' and `_Noreturn', if it is
    8244              :            reasonable.  */
    8245     51007222 :         if (flag_hosted && MAIN_NAME_P (declarator->u.id.id))
    8246              :           {
    8247        47614 :             if (declspecs->inline_p)
    8248            5 :               pedwarn (loc, 0, "cannot inline function %<main%>");
    8249        47614 :             if (declspecs->noreturn_p)
    8250            1 :               pedwarn (loc, 0, "%<main%> declared %<_Noreturn%>");
    8251              :           }
    8252              :         else
    8253              :           {
    8254     50959608 :             if (declspecs->inline_p)
    8255              :               /* Record that the function is declared `inline'.  */
    8256     35634719 :               DECL_DECLARED_INLINE_P (decl) = 1;
    8257     50959608 :             if (declspecs->noreturn_p)
    8258              :               {
    8259        23307 :                 if (flag_isoc99)
    8260        23304 :                   pedwarn_c99 (loc, OPT_Wpedantic,
    8261              :                                "ISO C99 does not support %<_Noreturn%>");
    8262              :                 else
    8263            3 :                   pedwarn_c99 (loc, OPT_Wpedantic,
    8264              :                                "ISO C90 does not support %<_Noreturn%>");
    8265        23307 :                 TREE_THIS_VOLATILE (decl) = 1;
    8266              :               }
    8267              :           }
    8268              : 
    8269              :         /* C99 6.2.2p7: It is invalid (compile-time undefined
    8270              :            behavior) to create an 'extern' declaration for a
    8271              :            function if there is a global declaration that is
    8272              :            'static' and the global declaration is not visible.
    8273              :            (If the static declaration _is_ currently visible,
    8274              :            the 'extern' declaration is taken to refer to that decl.) */
    8275     51007222 :         if (!initialized
    8276     14682667 :             && TREE_PUBLIC (decl)
    8277     14674810 :             && current_scope != file_scope)
    8278              :           {
    8279         8890 :             tree global_decl  = identifier_global_value (declarator->u.id.id);
    8280         8890 :             tree visible_decl = lookup_name (declarator->u.id.id);
    8281              : 
    8282         8890 :             if (global_decl
    8283         8890 :                 && global_decl != visible_decl
    8284         1713 :                 && VAR_OR_FUNCTION_DECL_P (global_decl)
    8285         1713 :                 && !TREE_PUBLIC (global_decl))
    8286            2 :               error_at (loc, "function previously declared %<static%> "
    8287              :                         "redeclared %<extern%>");
    8288              :           }
    8289              :       }
    8290              :     else
    8291              :       {
    8292              :         /* It's a variable.  */
    8293              :         /* An uninitialized decl with `extern' is a reference.  */
    8294      8923423 :         int extern_ref = !initialized && storage_class == csc_extern;
    8295              : 
    8296      8923423 :         if (constexprp)
    8297              :           {
    8298              :             /* The type of a constexpr variable must not be variably
    8299              :                modified, volatile, atomic or restrict qualified or
    8300              :                have a member with such a qualifier.  const
    8301              :                qualification is implicitly added, and, at file scope,
    8302              :                has internal linkage.  */
    8303          356 :             if (c_type_variably_modified_p (type))
    8304            1 :               error_at (loc, "%<constexpr%> object has variably modified "
    8305              :                         "type");
    8306          356 :             if (type_quals
    8307          356 :                 & (TYPE_QUAL_VOLATILE | TYPE_QUAL_RESTRICT | TYPE_QUAL_ATOMIC))
    8308            9 :               error_at (loc, "invalid qualifiers for %<constexpr%> object");
    8309              :             else
    8310              :               {
    8311          347 :                 tree type_no_array = strip_array_types (type);
    8312          347 :                 if (RECORD_OR_UNION_TYPE_P (type_no_array)
    8313          347 :                     && C_TYPE_FIELDS_NON_CONSTEXPR (type_no_array))
    8314            8 :                   error_at (loc, "invalid qualifiers for field of "
    8315              :                             "%<constexpr%> object");
    8316              :               }
    8317          356 :             type_quals |= TYPE_QUAL_CONST;
    8318          356 :             if (current_scope == file_scope)
    8319          294 :               storage_class = csc_static;
    8320              :           }
    8321              : 
    8322      8923423 :         type = c_build_qualified_type (type, type_quals, orig_qual_type,
    8323              :                                        orig_qual_indirect);
    8324              : 
    8325              :         /* C99 6.2.2p7: It is invalid (compile-time undefined
    8326              :            behavior) to create an 'extern' declaration for a
    8327              :            variable if there is a global declaration that is
    8328              :            'static' and the global declaration is not visible.
    8329              :            (If the static declaration _is_ currently visible,
    8330              :            the 'extern' declaration is taken to refer to that decl.) */
    8331      8923423 :         if (extern_ref && current_scope != file_scope)
    8332              :           {
    8333         1571 :             tree global_decl  = identifier_global_value (declarator->u.id.id);
    8334         1571 :             tree visible_decl = lookup_name (declarator->u.id.id);
    8335              : 
    8336         1571 :             if (global_decl
    8337         1571 :                 && global_decl != visible_decl
    8338          282 :                 && VAR_P (global_decl)
    8339          282 :                 && !TREE_PUBLIC (global_decl))
    8340            8 :               error_at (loc, "variable previously declared %<static%> "
    8341              :                         "redeclared %<extern%>");
    8342              :           }
    8343              : 
    8344     17846846 :         decl = build_decl (declarator->id_loc,
    8345      8923423 :                            VAR_DECL, declarator->u.id.id, type);
    8346      8923423 :         if (size_varies)
    8347         7444 :           C_DECL_VARIABLE_SIZE (decl) = 1;
    8348      8923423 :         if (constexprp)
    8349          356 :           C_DECL_DECLARED_CONSTEXPR (decl) = 1;
    8350              : 
    8351      8923423 :         if (declspecs->inline_p)
    8352            4 :           pedwarn (loc, 0, "variable %q+D declared %<inline%>", decl);
    8353      8923423 :         if (declspecs->noreturn_p)
    8354            1 :           pedwarn (loc, 0, "variable %q+D declared %<_Noreturn%>", decl);
    8355              : 
    8356              :         /* At file scope, an initialized extern declaration may follow
    8357              :            a static declaration.  In that case, DECL_EXTERNAL will be
    8358              :            reset later in start_decl.  */
    8359      8923423 :         DECL_EXTERNAL (decl) = (storage_class == csc_extern);
    8360              : 
    8361              :         /* At file scope, the presence of a `static' or `register' storage
    8362              :            class specifier, or the absence of all storage class specifiers
    8363              :            makes this declaration a definition (perhaps tentative).  Also,
    8364              :            the absence of `static' makes it public.  */
    8365      8923423 :         if (current_scope == file_scope)
    8366              :           {
    8367      1153970 :             TREE_PUBLIC (decl) = storage_class != csc_static;
    8368      1153970 :             TREE_STATIC (decl) = !extern_ref;
    8369              :           }
    8370              :         /* Not at file scope, only `static' makes a static definition.  */
    8371              :         else
    8372              :           {
    8373      7769453 :             TREE_STATIC (decl) = (storage_class == csc_static);
    8374      7769453 :             TREE_PUBLIC (decl) = extern_ref;
    8375              :           }
    8376              : 
    8377              :         // NB: Set a tentative TLS model to avoid tls_model attribute
    8378              :         // warnings due to lack of thread storage duration.  It will
    8379              :         // be updated by c_decl_attributes later.
    8380      8923423 :         if (threadp)
    8381         2823 :           set_decl_tls_model (decl, TLS_MODEL_REAL);
    8382              :       }
    8383              : 
    8384    188369988 :     if ((storage_class == csc_extern
    8385    138360025 :          || (storage_class == csc_none
    8386    137898506 :              && TREE_CODE (type) == FUNCTION_TYPE
    8387       810660 :              && !funcdef_flag))
    8388    188681600 :         && c_type_variably_modified_p (type))
    8389              :       {
    8390              :         /* C99 6.7.5.2p2 */
    8391            6 :         if (TREE_CODE (type) == FUNCTION_TYPE)
    8392            4 :           error_at (loc, "non-nested function with variably modified type");
    8393              :         else
    8394            2 :           error_at (loc, "object with variably modified type must have "
    8395              :                     "no linkage");
    8396              :       }
    8397              : 
    8398              :     /* For nested functions disqualify ones taking VLAs by value
    8399              :        from inlining since the middle-end cannot deal with this.
    8400              :        ???  We should arrange for those to be passed by reference
    8401              :        with emitting the copy on the caller side in the frontend.  */
    8402    188369988 :     if (storage_class == csc_none
    8403    137898506 :         && TREE_CODE (type) == FUNCTION_TYPE)
    8404      4206332 :       for (tree al = TYPE_ARG_TYPES (type); al; al = TREE_CHAIN (al))
    8405              :         {
    8406      3395712 :           tree arg = TREE_VALUE (al);
    8407      3395712 :           if (arg != error_mark_node
    8408      3395712 :               && C_TYPE_VARIABLE_SIZE (arg))
    8409              :             {
    8410           40 :               DECL_UNINLINABLE (decl) = 1;
    8411           40 :               break;
    8412              :             }
    8413              :         }
    8414              : 
    8415              :     /* Record `register' declaration for warnings on &
    8416              :        and in case doing stupid register allocation.  */
    8417              : 
    8418    188369988 :     if (storage_class == csc_register
    8419         3606 :         && TREE_CODE (type) != FUNCTION_TYPE)
    8420              :       {
    8421         3600 :         C_DECL_REGISTER (decl) = 1;
    8422         3600 :         DECL_REGISTER (decl) = 1;
    8423              :       }
    8424              : 
    8425              :     /* Record constancy and volatility.  */
    8426    188369988 :     c_apply_type_quals_to_decl (type_quals, decl);
    8427              : 
    8428              :     /* Apply _Alignas specifiers.  */
    8429    188369988 :     if (alignas_align)
    8430              :       {
    8431          123 :         SET_DECL_ALIGN (decl, alignas_align * BITS_PER_UNIT);
    8432          123 :         DECL_USER_ALIGN (decl) = 1;
    8433              :       }
    8434              : 
    8435              :     /* If a type has volatile components, it should be stored in memory.
    8436              :        Otherwise, the fact that those components are volatile
    8437              :        will be ignored, and would even crash the compiler.
    8438              :        Of course, this only makes sense on  VAR,PARM, and RESULT decl's.   */
    8439    188369988 :     if (C_TYPE_FIELDS_VOLATILE (TREE_TYPE (decl))
    8440    188369988 :         && (VAR_P (decl) ||  TREE_CODE (decl) == PARM_DECL
    8441              :           || TREE_CODE (decl) == RESULT_DECL))
    8442              :       {
    8443              :         /* It is not an error for a structure with volatile fields to
    8444              :            be declared register, but reset DECL_REGISTER since it
    8445              :            cannot actually go in a register.  */
    8446          184 :         int was_reg = C_DECL_REGISTER (decl);
    8447          184 :         C_DECL_REGISTER (decl) = 0;
    8448          184 :         DECL_REGISTER (decl) = 0;
    8449          184 :         c_mark_addressable (decl);
    8450          184 :         C_DECL_REGISTER (decl) = was_reg;
    8451              :       }
    8452              : 
    8453              :   /* This is the earliest point at which we might know the assembler
    8454              :      name of a variable.  Thus, if it's known before this, die horribly.  */
    8455    188369988 :     gcc_assert (!HAS_DECL_ASSEMBLER_NAME_P (decl)
    8456              :                 || !DECL_ASSEMBLER_NAME_SET_P (decl));
    8457              : 
    8458    188369988 :     if (warn_cxx_compat
    8459        24549 :         && VAR_P (decl)
    8460         7548 :         && TREE_PUBLIC (decl)
    8461         2805 :         && TREE_STATIC (decl)
    8462         2356 :         && (RECORD_OR_UNION_TYPE_P (TREE_TYPE (decl))
    8463         2224 :             || TREE_CODE (TREE_TYPE (decl)) == ENUMERAL_TYPE)
    8464    188370135 :         && TYPE_NAME (TREE_TYPE (decl)) == NULL_TREE)
    8465            4 :       warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wc___compat,
    8466              :                   "non-local variable %qD with anonymous type is "
    8467              :                   "questionable in C++", decl);
    8468              : 
    8469              :     return decl;
    8470              :   }
    8471              : }
    8472              : 
    8473              : /* Decode the parameter-list info for a function type or function definition.
    8474              :    The argument is the value returned by `get_parm_info' (or made in c-parse.c
    8475              :    if there is an identifier list instead of a parameter decl list).
    8476              :    These two functions are separate because when a function returns
    8477              :    or receives functions then each is called multiple times but the order
    8478              :    of calls is different.  The last call to `grokparms' is always the one
    8479              :    that contains the formal parameter names of a function definition.
    8480              : 
    8481              :    Return a list of arg types to use in the FUNCTION_TYPE for this function.
    8482              : 
    8483              :    FUNCDEF_FLAG is true for a function definition, false for
    8484              :    a mere declaration.  A nonempty identifier-list gets an error message
    8485              :    when FUNCDEF_FLAG is false.  */
    8486              : 
    8487              : static tree
    8488     50582343 : grokparms (struct c_arg_info *arg_info, bool funcdef_flag)
    8489              : {
    8490     50582343 :   tree arg_types = arg_info->types;
    8491              : 
    8492     50582343 :   if (funcdef_flag && arg_info->had_vla_unspec)
    8493              :     {
    8494              :       /* A function definition isn't function prototype scope C99 6.2.1p4.  */
    8495              :       /* C99 6.7.5.2p4 */
    8496            2 :       error ("%<[*]%> not allowed in other than function prototype scope");
    8497              :     }
    8498              : 
    8499       715596 :   if (arg_types == NULL_TREE && !funcdef_flag && !flag_isoc23
    8500     50585386 :       && !in_system_header_at (input_location))
    8501         3043 :     warning (OPT_Wstrict_prototypes,
    8502              :              "function declaration isn%'t a prototype");
    8503              : 
    8504     50582343 :   if (arg_types == error_mark_node)
    8505              :     /* Don't set TYPE_ARG_TYPES in this case.  */
    8506              :     return NULL_TREE;
    8507              : 
    8508    100392199 :   else if (arg_types && TREE_CODE (TREE_VALUE (arg_types)) == IDENTIFIER_NODE)
    8509              :     {
    8510         8684 :       if (!funcdef_flag)
    8511              :         {
    8512           13 :           permerror_opt (input_location,
    8513           13 :                          OPT_Wdeclaration_missing_parameter_type,
    8514              :                          "parameter names (without types) in "
    8515              :                          "function declaration");
    8516           13 :           arg_info->parms = NULL_TREE;
    8517              :         }
    8518              :       else
    8519         8671 :         arg_info->parms = arg_info->types;
    8520              : 
    8521         8684 :       arg_info->types = NULL_TREE;
    8522         8684 :       return NULL_TREE;
    8523              :     }
    8524              :   else
    8525              :     {
    8526     50573659 :       tree parm, type, typelt;
    8527     50573659 :       unsigned int parmno;
    8528              : 
    8529              :       /* In C23, convert () to (void).  */
    8530     50573659 :       if (flag_isoc23
    8531     41525144 :           && !arg_types
    8532       764988 :           && !arg_info->parms
    8533       764988 :           && !arg_info->no_named_args_stdarg_p)
    8534              :         {
    8535       764845 :           arg_types = arg_info->types = void_list_node;
    8536       764845 :           arg_info->c23_empty_parens = 1;
    8537              :         }
    8538              : 
    8539              :       /* If there is a parameter of incomplete type in a definition,
    8540              :          this is an error.  In a declaration this is valid, and a
    8541              :          struct or union type may be completed later, before any calls
    8542              :          or definition of the function.  In the case where the tag was
    8543              :          first declared within the parameter list, a warning has
    8544              :          already been given.  If a parameter has void type, then
    8545              :          this has already received an error (constraint violation in C2Y,
    8546              :          previously implicitly undefined behavior).  */
    8547              : 
    8548     50573659 :       for (parm = arg_info->parms, typelt = arg_types, parmno = 1;
    8549    173708695 :            parm;
    8550    123135036 :            parm = DECL_CHAIN (parm), typelt = TREE_CHAIN (typelt), parmno++)
    8551              :         {
    8552    123135036 :           type = TREE_VALUE (typelt);
    8553    123135036 :           if (type == error_mark_node)
    8554           61 :             continue;
    8555              : 
    8556    123134975 :           if (!COMPLETE_TYPE_P (type))
    8557              :             {
    8558           40 :               if (funcdef_flag)
    8559              :                 {
    8560           13 :                   if (DECL_NAME (parm))
    8561           13 :                     error_at (input_location,
    8562              :                               "parameter %u (%q+D) has incomplete type",
    8563              :                               parmno, parm);
    8564              :                   else
    8565            0 :                     error_at (DECL_SOURCE_LOCATION (parm),
    8566              :                               "parameter %u has incomplete type",
    8567              :                               parmno);
    8568              : 
    8569           13 :                   TREE_VALUE (typelt) = error_mark_node;
    8570           13 :                   TREE_TYPE (parm) = error_mark_node;
    8571           13 :                   arg_types = NULL_TREE;
    8572              :                 }
    8573              :             }
    8574              : 
    8575    123134975 :           if (DECL_NAME (parm) && TREE_USED (parm))
    8576        17660 :             warn_if_shadowing (parm);
    8577              :         }
    8578              :       return arg_types;
    8579              :     }
    8580              : }
    8581              : 
    8582              : /* Allocate and initialize a c_arg_info structure from the parser's
    8583              :    obstack.  */
    8584              : 
    8585              : struct c_arg_info *
    8586     50582361 : build_arg_info (void)
    8587              : {
    8588     50582361 :   struct c_arg_info *ret = XOBNEW (&parser_obstack, struct c_arg_info);
    8589     50582361 :   ret->parms = NULL_TREE;
    8590     50582361 :   ret->tags = NULL;
    8591     50582361 :   ret->types = NULL_TREE;
    8592     50582361 :   ret->others = NULL_TREE;
    8593     50582361 :   ret->pending_sizes = NULL;
    8594     50582361 :   ret->had_vla_unspec = 0;
    8595     50582361 :   ret->no_named_args_stdarg_p = 0;
    8596     50582361 :   ret->c23_empty_parens = 0;
    8597     50582361 :   return ret;
    8598              : }
    8599              : 
    8600              : /* Take apart the current scope and return a c_arg_info structure with
    8601              :    info on a parameter list just parsed.
    8602              : 
    8603              :    This structure is later fed to 'grokparms' and 'store_parm_decls'.
    8604              : 
    8605              :    ELLIPSIS being true means the argument list ended in '...' so don't
    8606              :    append a sentinel (void_list_node) to the end of the type-list.
    8607              : 
    8608              :    EXPR is NULL or an expression that needs to be evaluated for the
    8609              :    side effects of array size expressions in the parameters.  */
    8610              : 
    8611              : struct c_arg_info *
    8612     49801201 : get_parm_info (bool ellipsis, tree expr)
    8613              : {
    8614     49801201 :   struct c_binding *b = current_scope->bindings;
    8615     49801201 :   struct c_arg_info *arg_info = build_arg_info ();
    8616              : 
    8617     49801201 :   tree parms = NULL_TREE;
    8618     49801201 :   vec<c_arg_tag, va_gc> *tags = NULL;
    8619     49801201 :   tree types = NULL_TREE;
    8620     49801201 :   tree others = NULL_TREE;
    8621              : 
    8622     49801201 :   bool gave_void_only_once_err = false;
    8623              : 
    8624     49801201 :   arg_info->had_vla_unspec = current_scope->had_vla_unspec;
    8625              : 
    8626              :   /* The bindings in this scope must not get put into a block.
    8627              :      We will take care of deleting the binding nodes.  */
    8628     49801201 :   current_scope->bindings = 0;
    8629              : 
    8630              :   /* This function is only called if there was *something* on the
    8631              :      parameter list.  */
    8632     49801201 :   gcc_assert (b);
    8633              : 
    8634              :   /* A parameter list consisting solely of 'void' indicates that the
    8635              :      function takes no arguments.  But if the 'void' is qualified
    8636              :      (by 'const' or 'volatile'), or has a storage class specifier
    8637              :      ('register'), then the behavior is undefined; issue an error.
    8638              :      Typedefs for 'void' are OK (see DR#157).  */
    8639     49801201 :   if (b->prev == 0                       /* one binding */
    8640     13248441 :       && TREE_CODE (b->decl) == PARM_DECL   /* which is a parameter */
    8641     13248441 :       && !DECL_NAME (b->decl)               /* anonymous */
    8642     51614717 :       && VOID_TYPE_P (TREE_TYPE (b->decl))) /* of void type */
    8643              :     {
    8644       954740 :       if (TYPE_QUALS (TREE_TYPE (b->decl)) != TYPE_UNQUALIFIED
    8645       954740 :           || C_DECL_REGISTER (b->decl))
    8646           96 :         error_at (b->locus, "%<void%> as only parameter may not be qualified");
    8647              : 
    8648              :       /* There cannot be an ellipsis.  */
    8649       954740 :       if (ellipsis)
    8650           17 :         error_at (b->locus, "%<void%> must be the only parameter");
    8651              : 
    8652       954740 :       arg_info->types = void_list_node;
    8653       954740 :       return arg_info;
    8654              :     }
    8655              : 
    8656     48846461 :   if (!ellipsis)
    8657     48633622 :     types = void_list_node;
    8658              : 
    8659              :   /* Break up the bindings list into parms, tags, types, and others;
    8660              :      apply sanity checks; purge the name-to-decl bindings.  */
    8661    171981960 :   while (b)
    8662              :     {
    8663    123135499 :       tree decl = b->decl;
    8664    123135499 :       tree type = TREE_TYPE (decl);
    8665    123135499 :       c_arg_tag tag;
    8666    123135499 :       const char *keyword;
    8667              : 
    8668    123135499 :       switch (TREE_CODE (decl))
    8669              :         {
    8670    123135159 :         case PARM_DECL:
    8671    123135159 :           if (b->id)
    8672              :             {
    8673    119501376 :               gcc_assert (I_SYMBOL_BINDING (b->id) == b);
    8674    119501376 :               I_SYMBOL_BINDING (b->id) = b->shadowed;
    8675              :             }
    8676              : 
    8677              :           /* Check for forward decls that never got their actual decl.  */
    8678    123135159 :           if (TREE_ASM_WRITTEN (decl))
    8679            4 :             error_at (b->locus,
    8680              :                       "parameter %q+D has just a forward declaration", decl);
    8681              :           /* Check for (..., void, ...) and named void parameters and issue an
    8682              :              error.  */
    8683    123135155 :           else if (VOID_TYPE_P (type))
    8684              :             {
    8685          114 :               if (!gave_void_only_once_err)
    8686              :                 {
    8687          114 :                   error_at (b->locus,
    8688              :                             "%<void%> must be the only parameter and unnamed");
    8689          114 :                   gave_void_only_once_err = true;
    8690              :                 }
    8691              :             }
    8692              :           else
    8693              :             {
    8694              :               /* Valid parameter, add it to the list.  */
    8695    123135041 :               DECL_CHAIN (decl) = parms;
    8696    123135041 :               parms = decl;
    8697              : 
    8698              :               /* Since there is a prototype, args are passed in their
    8699              :                  declared types.  The back end may override this later.  */
    8700    123135041 :               DECL_ARG_TYPE (decl) = type;
    8701    123135041 :               types = tree_cons (0, type, types);
    8702              :             }
    8703              :           break;
    8704              : 
    8705           21 :         case ENUMERAL_TYPE: keyword = "enum"; goto tag;
    8706           20 :         case UNION_TYPE:    keyword = "union"; goto tag;
    8707          101 :         case RECORD_TYPE:   keyword = "struct"; goto tag;
    8708          142 :         tag:
    8709              :           /* Types may not have tag-names, in which case the type
    8710              :              appears in the bindings list with b->id NULL.  */
    8711          142 :           if (b->id)
    8712              :             {
    8713           97 :               gcc_assert (I_TAG_BINDING (b->id) == b);
    8714           97 :               I_TAG_BINDING (b->id) = b->shadowed;
    8715              :             }
    8716              : 
    8717              :           /* Warn about any struct, union or enum tags defined in a
    8718              :              parameter list.  The scope of such types is limited to
    8719              :              the parameter list, which is rarely if ever desirable
    8720              :              (it's impossible to call such a function with type-
    8721              :              correct arguments).  An anonymous union parm type is
    8722              :              meaningful as a GNU extension, so don't warn for that.  */
    8723          142 :           if (TREE_CODE (decl) != UNION_TYPE || b->id != NULL_TREE)
    8724              :             {
    8725          122 :               if (b->id)
    8726              :                 {
    8727              :                   /* The %s will be one of 'struct', 'union', or 'enum'.  */
    8728           97 :                   if (!flag_isoc23 || !COMPLETE_TYPE_P (decl))
    8729           73 :                     warning_at (b->locus, 0,
    8730              :                                 "%<%s %E%> declared inside parameter list"
    8731              :                                 " will not be visible outside of this definition or"
    8732              :                                 " declaration", keyword, b->id);
    8733              :                 }
    8734              :               else
    8735              :                 /* The %s will be one of 'struct', 'union', or 'enum'.  */
    8736           25 :                 warning_at (b->locus, 0,
    8737              :                             "anonymous %s declared inside parameter list"
    8738              :                             " will not be visible outside of this definition or"
    8739              :                             " declaration", keyword);
    8740              :             }
    8741              : 
    8742          142 :           tag.id = b->id;
    8743          142 :           tag.type = decl;
    8744          142 :           vec_safe_push (tags, tag);
    8745          142 :           break;
    8746              : 
    8747           20 :         case FUNCTION_DECL:
    8748              :           /* FUNCTION_DECLs appear when there is an implicit function
    8749              :              declaration in the parameter list.  */
    8750           20 :           gcc_assert (b->nested || seen_error ());
    8751           20 :           goto set_shadowed;
    8752              : 
    8753          144 :         case CONST_DECL:
    8754          144 :         case TYPE_DECL:
    8755              :           /* CONST_DECLs appear here when we have an embedded enum,
    8756              :              and TYPE_DECLs appear here when we have an embedded struct
    8757              :              or union.  No warnings for this - we already warned about the
    8758              :              type itself.  */
    8759              : 
    8760              :           /* When we reinsert this decl in the function body, we need
    8761              :              to reconstruct whether it was marked as nested.  */
    8762          144 :           gcc_assert (!b->nested);
    8763          144 :           DECL_CHAIN (decl) = others;
    8764          144 :           others = decl;
    8765              :           /* fall through */
    8766              : 
    8767          198 :         case ERROR_MARK:
    8768          198 :         set_shadowed:
    8769              :           /* error_mark_node appears here when we have an undeclared
    8770              :              variable.  Just throw it away.  */
    8771          198 :           if (b->id)
    8772              :             {
    8773           56 :               gcc_assert (I_SYMBOL_BINDING (b->id) == b);
    8774           56 :               I_SYMBOL_BINDING (b->id) = b->shadowed;
    8775              :             }
    8776              :           break;
    8777              : 
    8778              :           /* Other things that might be encountered.  */
    8779            0 :         case LABEL_DECL:
    8780            0 :         case VAR_DECL:
    8781            0 :         default:
    8782            0 :           gcc_unreachable ();
    8783              :         }
    8784              : 
    8785    123135499 :       b = free_binding_and_advance (b);
    8786              :     }
    8787              : 
    8788     48846461 :   arg_info->parms = parms;
    8789     48846461 :   arg_info->tags = tags;
    8790     48846461 :   arg_info->types = types;
    8791     48846461 :   arg_info->others = others;
    8792     48846461 :   arg_info->pending_sizes = expr;
    8793     48846461 :   arg_info->no_named_args_stdarg_p = ellipsis && !types;
    8794     48846461 :   return arg_info;
    8795              : }
    8796              : 
    8797              : /* Get the struct, enum or union (CODE says which) with tag NAME.
    8798              :    Define the tag as a forward-reference with location LOC if it is
    8799              :    not defined.  HAVE_STD_ATTRS says whether any standard attributes
    8800              :    were present after the struct, union or enum keyword; ATTRS are the
    8801              :    standard attributes present there.  HAS_ENUM_TYPE_SPECIFIER says
    8802              :    whether an enum type specifier (": specifier-qualifier-list") is
    8803              :    present; if so, this is called before that specifier is parsed, so
    8804              :    that the tag is in scope for that specifier.  Return a c_typespec
    8805              :    structure for the type specifier.  */
    8806              : 
    8807              : struct c_typespec
    8808      1085510 : parser_xref_tag (location_t loc, enum tree_code code, tree name,
    8809              :                  bool have_std_attrs, tree attrs, bool has_enum_type_specifier)
    8810              : {
    8811      1085510 :   struct c_typespec ret;
    8812      1085510 :   tree ref;
    8813      1085510 :   location_t refloc;
    8814              : 
    8815      1085510 :   ret.expr = NULL_TREE;
    8816      1085510 :   ret.expr_const_operands = true;
    8817      1085510 :   ret.has_enum_type_specifier = has_enum_type_specifier;
    8818              : 
    8819              :   /* If a cross reference is requested, look up the type already
    8820              :      defined for this tag and return it.  If an enum type specifier is
    8821              :      present, only a definition in the current scope is relevant.  */
    8822              : 
    8823      1085510 :   ref = lookup_tag (code, name, has_enum_type_specifier, &refloc);
    8824              : 
    8825              :   /* If the visble type is still being defined, see if there is
    8826              :      an earlier definition (which may be complete).  We do not
    8827              :      have to loop because nested redefinitions are not allowed.  */
    8828      1085510 :   if (flag_isoc23 && ref && C_TYPE_BEING_DEFINED (ref))
    8829              :     {
    8830        86039 :       tree vis = previous_tag (ref);
    8831        86039 :       if (vis)
    8832           16 :         ref = vis;
    8833              :     }
    8834              : 
    8835              :   /* If this is the right type of tag, return what we found.
    8836              :      (This reference will be shadowed by shadow_tag later if appropriate.)
    8837              :      If this is the wrong type of tag, do not return it.  If it was the
    8838              :      wrong type in the same scope, we will have had an error
    8839              :      message already; if in a different scope and declaring
    8840              :      a name, pending_xref_error will give an error message; but if in a
    8841              :      different scope and not declaring a name, this tag should
    8842              :      shadow the previous declaration of a different type of tag, and
    8843              :      this would not work properly if we return the reference found.
    8844              :      (For example, with "struct foo" in an outer scope, "union foo;"
    8845              :      must shadow that tag with a new one of union type.)  */
    8846      2171020 :   ret.kind = (ref
    8847      1085510 :               ? (have_std_attrs ? ctsk_tagref_attrs : ctsk_tagref)
    8848        94663 :               : (have_std_attrs ? ctsk_tagfirstref_attrs : ctsk_tagfirstref));
    8849      1085510 :   if (ref && TREE_CODE (ref) == code)
    8850              :     {
    8851       990813 :       decl_attributes (&ref, attrs, (int) ATTR_FLAG_TYPE_IN_PLACE);
    8852       990813 :       if (C_TYPE_DEFINED_IN_STRUCT (ref)
    8853            5 :           && loc != UNKNOWN_LOCATION
    8854       990818 :           && warn_cxx_compat)
    8855              :         {
    8856            5 :           auto_diagnostic_group d;
    8857            5 :           switch (code)
    8858              :             {
    8859            2 :             case ENUMERAL_TYPE:
    8860            2 :               if (warning_at (loc, OPT_Wc___compat,
    8861              :                               ("enum type defined in struct or union "
    8862              :                                "is not visible in C++")))
    8863            2 :                   inform (refloc, "enum type defined here");
    8864              :               break;
    8865            2 :             case RECORD_TYPE:
    8866            2 :               if (warning_at (loc, OPT_Wc___compat,
    8867              :                               ("struct defined in struct or union "
    8868              :                                "is not visible in C++")))
    8869            2 :                 inform (refloc, "struct defined here");
    8870              :               break;
    8871            1 :             case UNION_TYPE:
    8872            1 :               if (warning_at (loc, OPT_Wc___compat,
    8873              :                               ("union defined in struct or union "
    8874              :                                "is not visible in C++")))
    8875            1 :                 inform (refloc, "union defined here");
    8876              :               break;
    8877            0 :             default:
    8878            0 :               gcc_unreachable();
    8879              :             }
    8880            5 :         }
    8881              : 
    8882       990813 :       ret.spec = ref;
    8883       990813 :       return ret;
    8884              :     }
    8885              : 
    8886              :   /* If no such tag is yet defined, create a forward-reference node
    8887              :      and record it as the "definition".
    8888              :      When a real declaration of this type is found,
    8889              :      the forward-reference will be altered into a real type.  */
    8890              : 
    8891        94697 :   ref = make_node (code);
    8892        94697 :   if (flag_isoc23 || code == ENUMERAL_TYPE)
    8893        72429 :     SET_TYPE_STRUCTURAL_EQUALITY (ref);
    8894        72429 :   if (code == ENUMERAL_TYPE)
    8895              :     {
    8896              :       /* Give the type a default layout like unsigned int
    8897              :          to avoid crashing if it does not get defined.  */
    8898          252 :       SET_TYPE_MODE (ref, TYPE_MODE (unsigned_type_node));
    8899          252 :       SET_TYPE_ALIGN (ref, TYPE_ALIGN (unsigned_type_node));
    8900          252 :       TYPE_USER_ALIGN (ref) = 0;
    8901          252 :       TYPE_UNSIGNED (ref) = 1;
    8902          252 :       TYPE_PRECISION (ref) = TYPE_PRECISION (unsigned_type_node);
    8903          252 :       TYPE_MIN_VALUE (ref) = TYPE_MIN_VALUE (unsigned_type_node);
    8904          252 :       TYPE_MAX_VALUE (ref) = TYPE_MAX_VALUE (unsigned_type_node);
    8905          252 :       ENUM_FIXED_UNDERLYING_TYPE_P (ref) = has_enum_type_specifier;
    8906              :     }
    8907              : 
    8908        94697 :   pushtag (loc, name, ref);
    8909        94697 :   decl_attributes (&ref, attrs, (int) ATTR_FLAG_TYPE_IN_PLACE);
    8910        94697 :   if (in_underspecified_init)
    8911            9 :     error_at (loc, "%qT declared in underspecified object initializer",
    8912              :               ref);
    8913              : 
    8914        94697 :   ret.spec = ref;
    8915        94697 :   return ret;
    8916              : }
    8917              : 
    8918              : /* Get the struct, enum or union (CODE says which) with tag NAME.
    8919              :    Define the tag as a forward-reference if it is not defined.
    8920              :    Return a tree for the type.  */
    8921              : 
    8922              : tree
    8923            0 : xref_tag (enum tree_code code, tree name)
    8924              : {
    8925            0 :   return parser_xref_tag (input_location, code, name, false, NULL_TREE,
    8926            0 :                           false).spec;
    8927              : }
    8928              : 
    8929              : /* Make sure that the tag NAME is defined *in the current scope*
    8930              :    at least as a forward reference.
    8931              :    LOC is the location of the struct's definition.
    8932              :    CODE says which kind of tag NAME ought to be.
    8933              : 
    8934              :    This stores the current value of the file static STRUCT_PARSE_INFO
    8935              :    in *ENCLOSING_STRUCT_PARSE_INFO, and points STRUCT_PARSE_INFO at a
    8936              :    new c_struct_parse_info structure.  The old value of
    8937              :    STRUCT_PARSE_INFO is restored in finish_struct.  */
    8938              : 
    8939              : tree
    8940      1180158 : start_struct (location_t loc, enum tree_code code, tree name,
    8941              :               class c_struct_parse_info **enclosing_struct_parse_info)
    8942              : {
    8943              :   /* If there is already a tag defined at this scope
    8944              :      (as a forward reference), just return it.  */
    8945              : 
    8946      1180158 :   tree ref = NULL_TREE;
    8947      1180158 :   location_t refloc = UNKNOWN_LOCATION;
    8948              : 
    8949      1180158 :   if (name != NULL_TREE)
    8950       485339 :     ref = lookup_tag (code, name, true, &refloc);
    8951              : 
    8952              :   /* For C23, even if we already have a completed definition,
    8953              :      we do not use it. We will check for consistency later.
    8954              :      If we are in a nested redefinition the type is not
    8955              :      complete. We will then detect this below.  */
    8956      1180158 :   if (flag_isoc23 && ref && TYPE_SIZE (ref))
    8957              :     ref = NULL_TREE;
    8958              : 
    8959      1180049 :   if (ref && TREE_CODE (ref) == code)
    8960              :     {
    8961        25136 :       if (TYPE_STUB_DECL (ref))
    8962        25136 :         refloc = DECL_SOURCE_LOCATION (TYPE_STUB_DECL (ref));
    8963              : 
    8964        25136 :       if (TYPE_SIZE (ref))
    8965              :         {
    8966           11 :           auto_diagnostic_group d;
    8967           11 :           if (code == UNION_TYPE)
    8968            2 :             error_at (loc, "redefinition of %<union %E%>", name);
    8969              :           else
    8970            9 :             error_at (loc, "redefinition of %<struct %E%>", name);
    8971           11 :           if (refloc != UNKNOWN_LOCATION)
    8972           11 :             inform (refloc, "originally defined here");
    8973              :           /* Don't create structures using a name already in use.  */
    8974           11 :           ref = NULL_TREE;
    8975           11 :         }
    8976        25125 :       else if (C_TYPE_BEING_DEFINED (ref))
    8977              :         {
    8978           17 :           if (code == UNION_TYPE)
    8979            1 :             error_at (loc, "nested redefinition of %<union %E%>", name);
    8980              :           else
    8981           16 :             error_at (loc, "nested redefinition of %<struct %E%>", name);
    8982              :           /* Don't bother to report "originally defined here" for a
    8983              :              nested redefinition; the original definition should be
    8984              :              obvious.  */
    8985              :           /* Don't create structures that contain themselves.  */
    8986              :           ref = NULL_TREE;
    8987              :         }
    8988              :     }
    8989              : 
    8990              :   /* Otherwise create a forward-reference just so the tag is in scope.  */
    8991              : 
    8992        25122 :   if (ref == NULL_TREE || TREE_CODE (ref) != code)
    8993              :     {
    8994      1155050 :       ref = make_node (code);
    8995      1155050 :       if (flag_isoc23)
    8996       926274 :         SET_TYPE_STRUCTURAL_EQUALITY (ref);
    8997      1155050 :       pushtag (loc, name, ref);
    8998              :     }
    8999              : 
    9000      1180158 :   C_TYPE_BEING_DEFINED (ref) = 1;
    9001      2390875 :   for (tree v = TYPE_MAIN_VARIANT (ref); v; v = TYPE_NEXT_VARIANT (v))
    9002      1210717 :     TYPE_PACKED (v) = flag_pack_struct;
    9003              : 
    9004      1180158 :   *enclosing_struct_parse_info = struct_parse_info;
    9005      1180158 :   struct_parse_info = new c_struct_parse_info ();
    9006      1180158 :   struct_parse_info->refloc = refloc;
    9007              : 
    9008              :   /* FIXME: This will issue a warning for a use of a type defined
    9009              :      within a statement expr used within sizeof, et. al.  This is not
    9010              :      terribly serious as C++ doesn't permit statement exprs within
    9011              :      sizeof anyhow.  */
    9012      1180158 :   if (warn_cxx_compat
    9013          574 :       && (in_sizeof || in_typeof || in_alignof || in_countof))
    9014           10 :     warning_at (loc, OPT_Wc___compat,
    9015              :                 "defining type in %qs expression is invalid in C++",
    9016              :                 (in_sizeof ? "sizeof"
    9017            4 :                  : in_typeof ? "typeof"
    9018            1 :                  : in_alignof ? "alignof"
    9019              :                  : "_Countof"));
    9020              : 
    9021      1180158 :   if (in_underspecified_init)
    9022           18 :     error_at (loc, "%qT defined in underspecified object initializer", ref);
    9023              : 
    9024      1180158 :   return ref;
    9025              : }
    9026              : 
    9027              : /* Process the specs, declarator and width (NULL if omitted)
    9028              :    of a structure component, returning a FIELD_DECL node.
    9029              :    WIDTH is non-NULL for bit-fields only, and is an INTEGER_CST node.
    9030              :    DECL_ATTRS is as for grokdeclarator.
    9031              : 
    9032              :    LOC is the location of the structure component.
    9033              : 
    9034              :    This is done during the parsing of the struct declaration.
    9035              :    The FIELD_DECL nodes are chained together and the lot of them
    9036              :    are ultimately passed to `build_struct' to make the RECORD_TYPE node.  */
    9037              : 
    9038              : tree
    9039      4326648 : grokfield (location_t loc,
    9040              :            struct c_declarator *declarator, struct c_declspecs *declspecs,
    9041              :            tree width, tree *decl_attrs, tree *expr)
    9042              : {
    9043      4326648 :   tree value;
    9044              : 
    9045      4326648 :   if (declarator->kind == cdk_id && declarator->u.id.id == NULL_TREE
    9046        20752 :       && width == NULL_TREE)
    9047              :     {
    9048              :       /* This is an unnamed decl.
    9049              : 
    9050              :          If we have something of the form "union { list } ;" then this
    9051              :          is the anonymous union extension.  Similarly for struct.
    9052              : 
    9053              :          If this is something of the form "struct foo;", then
    9054              :            If MS or Plan 9 extensions are enabled, this is handled as
    9055              :              an anonymous struct.
    9056              :            Otherwise this is a forward declaration of a structure tag.
    9057              : 
    9058              :          If this is something of the form "foo;" and foo is a TYPE_DECL, then
    9059              :            If foo names a structure or union without a tag, then this
    9060              :              is an anonymous struct (this is permitted by C11).
    9061              :            If MS or Plan 9 extensions are enabled and foo names a
    9062              :              structure, then again this is an anonymous struct.
    9063              :            Otherwise this is an error.
    9064              : 
    9065              :          Oh what a horrid tangled web we weave.  I wonder if MS consciously
    9066              :          took this from Plan 9 or if it was an accident of implementation
    9067              :          that took root before someone noticed the bug...  */
    9068              : 
    9069        10990 :       tree type = declspecs->type;
    9070        10990 :       bool ok = false;
    9071              : 
    9072        10990 :       if (RECORD_OR_UNION_TYPE_P (type)
    9073        10984 :           && (flag_ms_extensions
    9074        10955 :               || flag_plan9_extensions
    9075        10924 :               || !declspecs->typedef_p))
    9076              :         {
    9077        10977 :           if (flag_ms_extensions || flag_plan9_extensions)
    9078              :             ok = true;
    9079        10917 :           else if (TYPE_NAME (type) == NULL)
    9080              :             ok = true;
    9081              :           else
    9082              :             ok = false;
    9083              :         }
    9084              :       if (!ok)
    9085              :         {
    9086           29 :           pedwarn (loc, 0, "declaration does not declare anything");
    9087           29 :           return NULL_TREE;
    9088              :         }
    9089        10961 :       if (flag_isoc99)
    9090        10939 :         pedwarn_c99 (loc, OPT_Wpedantic,
    9091              :                      "ISO C99 doesn%'t support unnamed structs/unions");
    9092              :       else
    9093           22 :         pedwarn_c99 (loc, OPT_Wpedantic,
    9094              :                      "ISO C90 doesn%'t support unnamed structs/unions");
    9095              :     }
    9096              : 
    9097      4326619 :   value = grokdeclarator (declarator, declspecs, FIELD, false,
    9098      4326619 :                           width ? &width : NULL, decl_attrs, expr, NULL,
    9099              :                           DEPRECATED_NORMAL);
    9100              : 
    9101              :   /* When this field has name, its type is a top level type, we should
    9102              :      call verify_counted_by_for_top_anonymous_type.  */
    9103      4326619 :   if (DECL_NAME (value) != NULL_TREE
    9104      4326619 :       && declspecs->typespec_kind == ctsk_tagdef)
    9105       153118 :     verify_counted_by_for_top_anonymous_type (declspecs->type);
    9106              : 
    9107      4326619 :   finish_decl (value, loc, NULL_TREE, NULL_TREE, NULL_TREE);
    9108      4326619 :   DECL_INITIAL (value) = width;
    9109      4326619 :   if (width)
    9110        52597 :     SET_DECL_C_BIT_FIELD (value);
    9111              : 
    9112      4326619 :   if (warn_cxx_compat && DECL_NAME (value) != NULL_TREE)
    9113              :     {
    9114              :       /* If we currently have a binding for this field, set the
    9115              :          in_struct field in the binding, so that we warn about lookups
    9116              :          which find it.  */
    9117         1312 :       struct c_binding *b = I_SYMBOL_BINDING (DECL_NAME (value));
    9118         1312 :       if (b != NULL)
    9119              :         {
    9120              :           /* If the in_struct field is not yet set, push it on a list
    9121              :              to be cleared when this struct is finished.  */
    9122           93 :           if (!b->in_struct)
    9123              :             {
    9124           91 :               struct_parse_info->fields.safe_push (b);
    9125           91 :               b->in_struct = 1;
    9126              :             }
    9127              :         }
    9128              :     }
    9129              : 
    9130              :   return value;
    9131              : }
    9132              : 
    9133              : /* Subroutine of detect_field_duplicates: return whether X and Y,
    9134              :    which are both fields in the same struct, have duplicate field
    9135              :    names.  */
    9136              : 
    9137              : static bool
    9138      4314214 : is_duplicate_field (tree x, tree y)
    9139              : {
    9140      4314214 :   if (DECL_NAME (x) != NULL_TREE && DECL_NAME (x) == DECL_NAME (y))
    9141              :     return true;
    9142              : 
    9143              :   /* When using -fplan9-extensions, an anonymous field whose name is a
    9144              :      typedef can duplicate a field name.  */
    9145      4314213 :   if (flag_plan9_extensions
    9146      4314213 :       && (DECL_NAME (x) == NULL_TREE || DECL_NAME (y) == NULL_TREE))
    9147              :     {
    9148            0 :       tree xt, xn, yt, yn;
    9149              : 
    9150            0 :       xt = TREE_TYPE (x);
    9151            0 :       if (DECL_NAME (x) != NULL_TREE)
    9152            0 :         xn = DECL_NAME (x);
    9153            0 :       else if (RECORD_OR_UNION_TYPE_P (xt)
    9154            0 :                && TYPE_NAME (xt) != NULL_TREE
    9155            0 :                && TREE_CODE (TYPE_NAME (xt)) == TYPE_DECL)
    9156            0 :         xn = DECL_NAME (TYPE_NAME (xt));
    9157              :       else
    9158              :         xn = NULL_TREE;
    9159              : 
    9160            0 :       yt = TREE_TYPE (y);
    9161            0 :       if (DECL_NAME (y) != NULL_TREE)
    9162            0 :         yn = DECL_NAME (y);
    9163            0 :       else if (RECORD_OR_UNION_TYPE_P (yt)
    9164            0 :                && TYPE_NAME (yt) != NULL_TREE
    9165            0 :                && TREE_CODE (TYPE_NAME (yt)) == TYPE_DECL)
    9166            0 :         yn = DECL_NAME (TYPE_NAME (yt));
    9167              :       else
    9168              :         yn = NULL_TREE;
    9169              : 
    9170            0 :       if (xn != NULL_TREE && xn == yn)
    9171            0 :         return true;
    9172              :     }
    9173              : 
    9174              :   return false;
    9175              : }
    9176              : 
    9177              : /* Subroutine of detect_field_duplicates: add the fields of FIELDLIST
    9178              :    to HTAB, giving errors for any duplicates.  */
    9179              : 
    9180              : static void
    9181        80960 : detect_field_duplicates_hash (tree fieldlist,
    9182              :                               hash_table<nofree_ptr_hash <tree_node> > *htab)
    9183              : {
    9184        80960 :   tree x, y;
    9185        80960 :   tree_node **slot;
    9186              : 
    9187      1417272 :   for (x = fieldlist; x ; x = DECL_CHAIN (x))
    9188      1336312 :     if ((y = DECL_NAME (x)) != NULL_TREE)
    9189              :       {
    9190      1315538 :         slot = htab->find_slot (y, INSERT);
    9191      1315538 :         if (*slot)
    9192              :           {
    9193           15 :             error ("duplicate member %q+D", x);
    9194           15 :             DECL_NAME (x) = NULL_TREE;
    9195              :           }
    9196      1315538 :         *slot = y;
    9197              :       }
    9198        20774 :     else if (RECORD_OR_UNION_TYPE_P (TREE_TYPE (x)))
    9199              :       {
    9200        11728 :         detect_field_duplicates_hash (TYPE_FIELDS (TREE_TYPE (x)), htab);
    9201              : 
    9202              :         /* When using -fplan9-extensions, an anonymous field whose
    9203              :            name is a typedef can duplicate a field name.  */
    9204        11728 :         if (flag_plan9_extensions
    9205           31 :             && TYPE_NAME (TREE_TYPE (x)) != NULL_TREE
    9206        11758 :             && TREE_CODE (TYPE_NAME (TREE_TYPE (x))) == TYPE_DECL)
    9207              :           {
    9208           10 :             tree xn = DECL_NAME (TYPE_NAME (TREE_TYPE (x)));
    9209           10 :             slot = htab->find_slot (xn, INSERT);
    9210           10 :             if (*slot)
    9211            0 :               error ("duplicate member %q+D", TYPE_NAME (TREE_TYPE (x)));
    9212           10 :             *slot = xn;
    9213              :           }
    9214              :       }
    9215        80960 : }
    9216              : 
    9217              : /* Generate an error for any duplicate field names in FIELDLIST.  Munge
    9218              :    the list such that this does not present a problem later.  */
    9219              : 
    9220              : static void
    9221      1180288 : detect_field_duplicates (tree fieldlist)
    9222              : {
    9223      1180288 :   tree x, y;
    9224      1180288 :   int timeout = 10;
    9225              : 
    9226              :   /* If the struct is the list of instance variables of an Objective-C
    9227              :      class, then we need to check all the instance variables of
    9228              :      superclasses when checking for duplicates (since you can't have
    9229              :      an instance variable in a subclass with the same name as an
    9230              :      instance variable in a superclass).  We pass on this job to the
    9231              :      Objective-C compiler.  objc_detect_field_duplicates() will return
    9232              :      false if we are not checking the list of instance variables and
    9233              :      the C frontend should proceed with the standard field duplicate
    9234              :      checks.  If we are checking the list of instance variables, the
    9235              :      ObjC frontend will do the check, emit the errors if needed, and
    9236              :      then return true.  */
    9237      1180288 :   if (c_dialect_objc ())
    9238            0 :     if (objc_detect_field_duplicates (false))
    9239              :       return;
    9240              : 
    9241              :   /* First, see if there are more than "a few" fields.
    9242              :      This is trivially true if there are zero or one fields.  */
    9243      1180288 :   if (!fieldlist || !DECL_CHAIN (fieldlist))
    9244              :     return;
    9245              :   x = fieldlist;
    9246      3478519 :   do {
    9247      3478519 :     timeout--;
    9248      3478519 :     if (DECL_NAME (x) == NULL_TREE
    9249      3478519 :         && RECORD_OR_UNION_TYPE_P (TREE_TYPE (x)))
    9250              :       timeout = 0;
    9251      3478519 :     x = DECL_CHAIN (x);
    9252      3478519 :   } while (timeout > 0 && x);
    9253              : 
    9254              :   /* If there were "few" fields and no anonymous structures or unions,
    9255              :      avoid the overhead of allocating a hash table.  Instead just do
    9256              :      the nested traversal thing.  */
    9257       974374 :   if (timeout > 0)
    9258              :     {
    9259      2823292 :       for (x = DECL_CHAIN (fieldlist); x; x = DECL_CHAIN (x))
    9260              :         /* When using -fplan9-extensions, we can have duplicates
    9261              :            between typedef names and fields.  */
    9262      1918150 :         if (DECL_NAME (x)
    9263      1918150 :             || (flag_plan9_extensions
    9264            0 :                 && DECL_NAME (x) == NULL_TREE
    9265            0 :                 && RECORD_OR_UNION_TYPE_P (TREE_TYPE (x))
    9266            0 :                 && TYPE_NAME (TREE_TYPE (x)) != NULL_TREE
    9267            0 :                 && TREE_CODE (TYPE_NAME (TREE_TYPE (x))) == TYPE_DECL))
    9268              :           {
    9269      6231828 :             for (y = fieldlist; y != x; y = TREE_CHAIN (y))
    9270      4314214 :               if (is_duplicate_field (y, x))
    9271              :                 {
    9272            1 :                   error ("duplicate member %q+D", x);
    9273            1 :                   DECL_NAME (x) = NULL_TREE;
    9274              :                 }
    9275              :           }
    9276              :     }
    9277              :   else
    9278              :     {
    9279        69232 :       hash_table<nofree_ptr_hash <tree_node> > htab (37);
    9280        69232 :       detect_field_duplicates_hash (fieldlist, &htab);
    9281        69232 :     }
    9282              : }
    9283              : 
    9284              : /* Finish up struct info used by -Wc++-compat.  */
    9285              : 
    9286              : static void
    9287          575 : warn_cxx_compat_finish_struct (tree fieldlist, enum tree_code code,
    9288              :                                location_t record_loc)
    9289              : {
    9290          575 :   unsigned int ix;
    9291          575 :   tree x;
    9292          575 :   struct c_binding *b;
    9293              : 
    9294          575 :   if (fieldlist == NULL_TREE)
    9295              :     {
    9296            9 :       if (code == RECORD_TYPE)
    9297            6 :         warning_at (record_loc, OPT_Wc___compat,
    9298              :                     "empty struct has size 0 in C, size 1 in C++");
    9299              :       else
    9300            3 :         warning_at (record_loc, OPT_Wc___compat,
    9301              :                     "empty union has size 0 in C, size 1 in C++");
    9302              :     }
    9303              : 
    9304              :   /* Set the C_TYPE_DEFINED_IN_STRUCT flag for each type defined in
    9305              :      the current struct.  We do this now at the end of the struct
    9306              :      because the flag is used to issue visibility warnings, and we
    9307              :      only want to issue those warnings if the type is referenced
    9308              :      outside of the struct declaration.  */
    9309          623 :   FOR_EACH_VEC_ELT (struct_parse_info->struct_types, ix, x)
    9310           48 :     C_TYPE_DEFINED_IN_STRUCT (x) = 1;
    9311              : 
    9312              :   /* The TYPEDEFS_SEEN field of STRUCT_PARSE_INFO is a list of
    9313              :      typedefs used when declaring fields in this struct.  If the name
    9314              :      of any of the fields is also a typedef name then the struct would
    9315              :      not parse in C++, because the C++ lookup rules say that the
    9316              :      typedef name would be looked up in the context of the struct, and
    9317              :      would thus be the field rather than the typedef.  */
    9318          575 :   if (!struct_parse_info->typedefs_seen.is_empty ()
    9319           67 :       && fieldlist != NULL_TREE)
    9320              :     {
    9321              :       /* Use a hash_set<tree> using the name of the typedef.  We can use
    9322              :          a hash_set<tree> because identifiers are interned.  */
    9323           67 :       hash_set<tree> tset;
    9324              : 
    9325          254 :       FOR_EACH_VEC_ELT (struct_parse_info->typedefs_seen, ix, x)
    9326          120 :         tset.add (DECL_NAME (x));
    9327              : 
    9328          387 :       for (x = fieldlist; x != NULL_TREE; x = DECL_CHAIN (x))
    9329              :         {
    9330          320 :           if (DECL_NAME (x) != NULL_TREE
    9331          320 :               && tset.contains (DECL_NAME (x)))
    9332              :             {
    9333            2 :               warning_at (DECL_SOURCE_LOCATION (x), OPT_Wc___compat,
    9334              :                           "using %qD as both field and typedef name is "
    9335              :                           "invalid in C++", x);
    9336              :               /* FIXME: It would be nice to report the location where
    9337              :                  the typedef name is used.  */
    9338              :             }
    9339              :         }
    9340           67 :     }
    9341              : 
    9342              :   /* For each field which has a binding and which was not defined in
    9343              :      an enclosing struct, clear the in_struct field.  */
    9344          666 :   FOR_EACH_VEC_ELT (struct_parse_info->fields, ix, b)
    9345           91 :     b->in_struct = 0;
    9346          575 : }
    9347              : 
    9348              : /* Function to help qsort sort FIELD_DECLs by name order.  */
    9349              : 
    9350              : static int
    9351     20118823 : field_decl_cmp (const void *x_p, const void *y_p)
    9352              : {
    9353     20118823 :   const tree *const x = (const tree *) x_p;
    9354     20118823 :   const tree *const y = (const tree *) y_p;
    9355              : 
    9356     20118823 :   if (DECL_NAME (*x) == DECL_NAME (*y))
    9357              :     /* A nontype is "greater" than a type.  */
    9358            0 :     return (TREE_CODE (*y) == TYPE_DECL) - (TREE_CODE (*x) == TYPE_DECL);
    9359     20118823 :   if (DECL_NAME (*x) == NULL_TREE)
    9360              :     return -1;
    9361     20118823 :   if (DECL_NAME (*y) == NULL_TREE)
    9362              :     return 1;
    9363     20118823 :   if (DECL_NAME (*x) < DECL_NAME (*y))
    9364      9907643 :     return -1;
    9365              :   return 1;
    9366              : }
    9367              : 
    9368              : /* If this structure or union completes the type of any previous
    9369              :    variable declaration, lay it out and output its rtl.  */
    9370              : static void
    9371      1360937 : finish_incomplete_vars (tree incomplete_vars, bool toplevel)
    9372              : {
    9373      1361086 :   for (tree x = incomplete_vars; x; x = TREE_CHAIN (x))
    9374              :     {
    9375          149 :       tree decl = TREE_VALUE (x);
    9376          149 :       if (TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE)
    9377            0 :         layout_array_type (TREE_TYPE (decl));
    9378          149 :       if (TREE_CODE (decl) != TYPE_DECL)
    9379              :         {
    9380          149 :           relayout_decl (decl);
    9381          149 :           if (c_dialect_objc ())
    9382            0 :             objc_check_decl (decl);
    9383          149 :           rest_of_decl_compilation (decl, toplevel, 0);
    9384              :         }
    9385              :     }
    9386      1360937 : }
    9387              : 
    9388              : /* Determine whether the FIELD_DECL X is a flexible array member according to
    9389              :    the following info:
    9390              :   A. whether the FIELD_DECL X is the last field of the DECL_CONTEXT;
    9391              :   B. whether the FIELD_DECL is an array that is declared as "[]", "[0]",
    9392              :      or "[1]";
    9393              :   C. flag_strict_flex_arrays;
    9394              :   D. the attribute strict_flex_array that is attached to the field
    9395              :      if presenting.
    9396              :   Return TRUE when it's a flexible array member, FALSE otherwise.  */
    9397              : 
    9398              : static bool
    9399      4326770 : is_flexible_array_member_p (bool is_last_field,
    9400              :                             tree x)
    9401              : {
    9402              :   /* If not the last field, return false.  */
    9403      4326770 :   if (!is_last_field)
    9404              :     return false;
    9405              : 
    9406              :   /* If not an array field, return false.  */
    9407      1655454 :   if (TREE_CODE (TREE_TYPE (x)) != ARRAY_TYPE)
    9408              :     return false;
    9409              : 
    9410       534517 :   bool is_zero_length_array = zero_length_array_type_p (TREE_TYPE (x));
    9411       534517 :   bool is_one_element_array = one_element_array_type_p (TREE_TYPE (x));
    9412       534517 :   bool is_flexible_array = c_flexible_array_member_type_p (TREE_TYPE (x));
    9413              : 
    9414       534517 :   unsigned int strict_flex_array_level = c_strict_flex_array_level_of (x);
    9415              : 
    9416       534517 :   switch (strict_flex_array_level)
    9417              :     {
    9418              :       case 0:
    9419              :         /* Default, all trailing arrays are flexible array members.  */
    9420              :         return true;
    9421           77 :       case 1:
    9422              :         /* Level 1: all "[1]", "[0]", and "[]" are flexible array members.  */
    9423           77 :         if (is_one_element_array)
    9424              :           return true;
    9425              :         /* FALLTHROUGH.  */
    9426          141 :       case 2:
    9427              :         /* Level 2: all "[0]", and "[]" are flexible array members.  */
    9428          141 :         if (is_zero_length_array)
    9429              :           return true;
    9430              :         /* FALLTHROUGH.  */
    9431          201 :       case 3:
    9432              :         /* Level 3: Only "[]" are flexible array members.  */
    9433          201 :         if (is_flexible_array)
    9434              :           return true;
    9435              :         break;
    9436            0 :       default:
    9437            0 :         gcc_unreachable ();
    9438              :     }
    9439              :   return false;
    9440              : }
    9441              : 
    9442              : /* Recompute TYPE_CANONICAL for variants of the type including qualified
    9443              :    versions of the type and related pointer types after an aggregate type
    9444              :    has been finalized.
    9445              :    Will not update array types, pointers to array types, function
    9446              :    types and other derived types created while the type was still
    9447              :    incomplete, those will remain TYPE_STRUCTURAL_EQUALITY_P.  */
    9448              : 
    9449              : static void
    9450      1197089 : c_update_type_canonical (tree t)
    9451              : {
    9452      1197089 :   gcc_checking_assert (TYPE_MAIN_VARIANT (t) == t && !TYPE_QUALS (t));
    9453      2420858 :   for (tree x = t, l = NULL_TREE; x; l = x, x = TYPE_NEXT_VARIANT (x))
    9454              :     {
    9455      1223769 :       if (x != t && TYPE_STRUCTURAL_EQUALITY_P (x))
    9456              :         {
    9457        26680 :           if (!TYPE_QUALS (x))
    9458        26052 :             TYPE_CANONICAL (x) = TYPE_CANONICAL (t);
    9459              :           else
    9460              :             {
    9461          628 :               tree
    9462          628 :                 c = c_build_qualified_type (TYPE_CANONICAL (t), TYPE_QUALS (x));
    9463          628 :               if (TYPE_STRUCTURAL_EQUALITY_P (c))
    9464              :                 {
    9465          206 :                   gcc_checking_assert (TYPE_CANONICAL (t) == t);
    9466          206 :                   if (c == x)
    9467          206 :                     TYPE_CANONICAL (x) = x;
    9468              :                   else
    9469              :                     {
    9470              :                       /* build_qualified_type for this function unhelpfully
    9471              :                          moved c from some later spot in TYPE_MAIN_VARIANT (t)
    9472              :                          chain to right after t (or created it there).  Move
    9473              :                          it right before x and process c and then x.  */
    9474            0 :                       gcc_checking_assert (TYPE_NEXT_VARIANT (t) == c);
    9475            0 :                       if (l != t)
    9476              :                         {
    9477            0 :                           TYPE_NEXT_VARIANT (t) = TYPE_NEXT_VARIANT (c);
    9478            0 :                           TYPE_NEXT_VARIANT (l) = c;
    9479            0 :                           TYPE_NEXT_VARIANT (c) = x;
    9480              :                         }
    9481            0 :                       TYPE_CANONICAL (c) = c;
    9482            0 :                       x = c;
    9483              :                     }
    9484              :                 }
    9485              :               else
    9486          422 :                 TYPE_CANONICAL (x) = TYPE_CANONICAL (c);
    9487              :             }
    9488              :         }
    9489      1197089 :       else if (x != t)
    9490            0 :         continue;
    9491      1292879 :       for (tree p = TYPE_POINTER_TO (x); p; p = TYPE_NEXT_PTR_TO (p))
    9492              :         {
    9493        69110 :           if (!TYPE_STRUCTURAL_EQUALITY_P (p))
    9494            0 :             continue;
    9495        69110 :           if (TYPE_CANONICAL (x) != x || TYPE_REF_CAN_ALIAS_ALL (p))
    9496        67010 :             TYPE_CANONICAL (p)
    9497       134020 :               = c_build_pointer_type_for_mode (TYPE_CANONICAL (x), TYPE_MODE (p),
    9498              :                                                false);
    9499              :           else
    9500         2100 :             TYPE_CANONICAL (p) = p;
    9501        69110 :           c_update_type_canonical (p);
    9502              :         }
    9503              :     }
    9504      1197089 : }
    9505              : 
    9506              : 
    9507              : /* We set C_TYPE_VARIABLY_MODIFIED for derived types.  We will not update
    9508              :    array types, pointers to array types, function types and other derived
    9509              :    types created while the type was still incomplete.  We need to update
    9510              :    at least all types for which TYPE_CANONICAL will bet set, because for
    9511              :    those we later assume (in c_variably_modified_p) that the bit is
    9512              :    up-to-date.  */
    9513              : 
    9514              : static void
    9515          734 : c_update_variably_modified (tree t)
    9516              : {
    9517         1477 :   for (tree x = t; x; x = TYPE_NEXT_VARIANT (x))
    9518              :     {
    9519          743 :       C_TYPE_VARIABLY_MODIFIED (x) = 1;
    9520          761 :       for (tree p = TYPE_POINTER_TO (x); p; p = TYPE_NEXT_PTR_TO (p))
    9521           18 :         c_update_variably_modified (p);
    9522              :     }
    9523          734 : }
    9524              : 
    9525              : 
    9526              : /* Verify the argument of the counted_by attribute of each field of
    9527              :    the containing structure, OUTMOST_STRUCT_TYPE, including its inner
    9528              :    anonymous struct/union, Report error and remove the corresponding
    9529              :    attribute when it's not.  */
    9530              : 
    9531              : static void
    9532          528 : verify_counted_by_attribute (tree outmost_struct_type,
    9533              :                              tree cur_struct_type)
    9534              : {
    9535         1700 :   for (tree field = TYPE_FIELDS (cur_struct_type); field;
    9536         1172 :        field = TREE_CHAIN (field))
    9537              :     {
    9538         1172 :       if (c_flexible_array_member_type_p (TREE_TYPE (field))
    9539         1172 :            || TREE_CODE (TREE_TYPE (field)) == POINTER_TYPE)
    9540              :         {
    9541          398 :           tree attr_counted_by = lookup_attribute ("counted_by",
    9542          398 :                                                    DECL_ATTRIBUTES (field));
    9543              : 
    9544          398 :           if (!attr_counted_by)
    9545            1 :             continue;
    9546              : 
    9547              :           /* If there is an counted_by attribute attached to the field,
    9548              :              verify it.  */
    9549              : 
    9550          397 :           tree fieldname = TREE_VALUE (TREE_VALUE (attr_counted_by));
    9551              : 
    9552              :           /* Verify the argument of the attrbute is a valid field of the
    9553              :              containing structure.  */
    9554              : 
    9555          397 :           tree counted_by_field = lookup_field (outmost_struct_type,
    9556              :                                                 fieldname);
    9557              : 
    9558              :           /* Error when the field is not found in the containing structure
    9559              :              and remove the corresponding counted_by attribute from the
    9560              :              field_decl.  */
    9561          397 :           if (!counted_by_field)
    9562              :             {
    9563           24 :               error_at (DECL_SOURCE_LOCATION (field),
    9564              :                     "argument %qE to the %<counted_by%> attribute"
    9565              :                     " is not a field declaration in the same structure"
    9566              :                     " as %qD", fieldname, field);
    9567           24 :               DECL_ATTRIBUTES (field)
    9568           48 :                 = remove_attribute ("counted_by", DECL_ATTRIBUTES (field));
    9569              :             }
    9570              :           else
    9571              :           /* Error when the field is not with an integer type.  */
    9572              :             {
    9573          574 :               while (TREE_CHAIN (counted_by_field))
    9574          201 :                 counted_by_field = TREE_CHAIN (counted_by_field);
    9575          373 :               tree real_field = TREE_VALUE (counted_by_field);
    9576              : 
    9577          373 :               if (!INTEGRAL_TYPE_P (TREE_TYPE (real_field)))
    9578              :                 {
    9579            6 :                   error_at (DECL_SOURCE_LOCATION (field),
    9580              :                         "argument %qE to the %<counted_by%> attribute"
    9581              :                         " is not a field declaration with an integer type",
    9582              :                         fieldname);
    9583            6 :                   DECL_ATTRIBUTES (field)
    9584           12 :                     = remove_attribute ("counted_by",
    9585            6 :                                     DECL_ATTRIBUTES (field));
    9586              :                 }
    9587              :             }
    9588              :         }
    9589         1451 :       else if (RECORD_OR_UNION_TYPE_P (TREE_TYPE (field))
    9590          865 :                && (DECL_NAME (field) == NULL_TREE))
    9591          188 :         verify_counted_by_attribute (outmost_struct_type, TREE_TYPE (field));
    9592              :     }
    9593          528 : }
    9594              : 
    9595              : /* Caller should make sure the TYPE is a top-level type (i.e. not being
    9596              :    nested in other structure/uniona). For such type, verify its counted_by
    9597              :    if it is an anonymous structure/union.  */
    9598              : 
    9599              : void
    9600      1349879 : verify_counted_by_for_top_anonymous_type (tree type)
    9601              : {
    9602      1349879 :   if (!RECORD_OR_UNION_TYPE_P (type))
    9603              :     return;
    9604              : 
    9605      1169237 :   if (C_TYPE_FIELDS_HAS_COUNTED_BY (type)
    9606      1169237 :       && c_type_tag (type) == NULL_TREE)
    9607           48 :     verify_counted_by_attribute (type, type);
    9608              : }
    9609              : 
    9610              : /* TYPE is a struct or union that we're applying may_alias to after the body is
    9611              :    parsed.  Fixup any POINTER_TO types.  */
    9612              : 
    9613              : static void
    9614          358 : c_fixup_may_alias (tree type)
    9615              : {
    9616          423 :   for (tree t = TYPE_POINTER_TO (type); t; t = TYPE_NEXT_PTR_TO (t))
    9617          190 :     for (tree v = TYPE_MAIN_VARIANT (t); v; v = TYPE_NEXT_VARIANT (v))
    9618          125 :       TYPE_REF_CAN_ALIAS_ALL (v) = true;
    9619          358 : }
    9620              : 
    9621              : /* Fill in the fields of a RECORD_TYPE or UNION_TYPE node, T.
    9622              :    LOC is the location of the RECORD_TYPE or UNION_TYPE's definition.
    9623              :    FIELDLIST is a chain of FIELD_DECL nodes for the fields.
    9624              :    ATTRIBUTES are attributes to be applied to the structure.
    9625              : 
    9626              :    ENCLOSING_STRUCT_PARSE_INFO is the value of STRUCT_PARSE_INFO when
    9627              :    the struct was started.  */
    9628              : 
    9629              : tree
    9630      1180288 : finish_struct (location_t loc, tree t, tree fieldlist, tree attributes,
    9631              :                class c_struct_parse_info *enclosing_struct_parse_info,
    9632              :                tree *expr)
    9633              : {
    9634      1180288 :   tree x;
    9635      1180288 :   bool toplevel = file_scope == current_scope;
    9636              : 
    9637              :   /* If this type was previously laid out as a forward reference,
    9638              :      make sure we lay it out again.  */
    9639              : 
    9640      1180288 :   TYPE_SIZE (t) = NULL_TREE;
    9641              : 
    9642      1180288 :   decl_attributes (&t, attributes, (int) ATTR_FLAG_TYPE_IN_PLACE);
    9643              : 
    9644      1180288 :   if (pedantic)
    9645              :     {
    9646         7394 :       for (x = fieldlist; x; x = DECL_CHAIN (x))
    9647              :         {
    9648         7375 :           if (DECL_NAME (x) != NULL_TREE)
    9649              :             break;
    9650           25 :           if (flag_isoc11 && RECORD_OR_UNION_TYPE_P (TREE_TYPE (x)))
    9651              :             break;
    9652              :         }
    9653              : 
    9654         7376 :       if (x == NULL_TREE)
    9655              :         {
    9656           19 :           if (TREE_CODE (t) == UNION_TYPE)
    9657              :             {
    9658            5 :               if (fieldlist)
    9659            2 :                 pedwarn (loc, OPT_Wpedantic, "union has no named members");
    9660              :               else
    9661            3 :                 pedwarn (loc, OPT_Wpedantic, "union has no members");
    9662              :             }
    9663              :           else
    9664              :             {
    9665           14 :               if (fieldlist)
    9666            3 :                 pedwarn (loc, OPT_Wpedantic, "struct has no named members");
    9667              :               else
    9668           11 :                 pedwarn (loc, OPT_Wpedantic, "struct has no members");
    9669              :             }
    9670              :         }
    9671              :     }
    9672              : 
    9673              :   /* Install struct as DECL_CONTEXT of each field decl.
    9674              :      Also process specified field sizes, found in the DECL_INITIAL,
    9675              :      storing 0 there after the type has been changed to precision equal
    9676              :      to its width, rather than the precision of the specified standard
    9677              :      type.  (Correct layout requires the original type to have been preserved
    9678              :      until now.)  */
    9679              : 
    9680              :   bool saw_named_field = false;
    9681      5507098 :   for (x = fieldlist; x; x = DECL_CHAIN (x))
    9682              :     {
    9683              :       /* Whether this field is the last field of the structure or union.
    9684              :          for UNION, any field is the last field of it.  */
    9685      4326810 :       bool is_last_field = (DECL_CHAIN (x) == NULL_TREE)
    9686      4326810 :                             || (TREE_CODE (t) == UNION_TYPE);
    9687              : 
    9688      4326810 :       if (TREE_TYPE (x) == error_mark_node)
    9689           40 :         continue;
    9690              : 
    9691      4326770 :       DECL_CONTEXT (x) = t;
    9692              : 
    9693      4326770 :       tree t1 = strip_array_types (TREE_TYPE (x));
    9694              :       /* If any field is const, the structure type is pseudo-const.  */
    9695      4326770 :       if (TREE_READONLY (x))
    9696        64244 :         C_TYPE_FIELDS_READONLY (t) = 1;
    9697              :       else
    9698              :         {
    9699              :           /* A field that is pseudo-const makes the structure likewise.  */
    9700      4262526 :           if (RECORD_OR_UNION_TYPE_P (t1) && C_TYPE_FIELDS_READONLY (t1))
    9701          641 :             C_TYPE_FIELDS_READONLY (t) = 1;
    9702              :         }
    9703              : 
    9704              :       /* Any field that is volatile means variables of this type must be
    9705              :          treated in some ways as volatile.  */
    9706      4326770 :       if (TREE_THIS_VOLATILE (x))
    9707              :         {
    9708          475 :           C_TYPE_FIELDS_VOLATILE (t) = 1;
    9709          475 :           C_TYPE_FIELDS_NON_CONSTEXPR (t) = 1;
    9710              :         }
    9711              : 
    9712              :       /* Any field that is volatile, restrict-qualified or atomic
    9713              :          means the type cannot be used for a constexpr object.  */
    9714      4326770 :       if (TYPE_QUALS (t1)
    9715      4326770 :           & (TYPE_QUAL_VOLATILE | TYPE_QUAL_RESTRICT | TYPE_QUAL_ATOMIC))
    9716         1461 :         C_TYPE_FIELDS_NON_CONSTEXPR (t) = 1;
    9717      4325309 :       else if (RECORD_OR_UNION_TYPE_P (t1) && C_TYPE_FIELDS_NON_CONSTEXPR (t1))
    9718          179 :             C_TYPE_FIELDS_NON_CONSTEXPR (t) = 1;
    9719              : 
    9720              :       /* Any field of nominal variable size implies structure is too.  */
    9721      4326770 :       if (C_DECL_VARIABLE_SIZE (x))
    9722          698 :         C_TYPE_VARIABLE_SIZE (t) = 1;
    9723              : 
    9724              :       /* If any field is variably modified, record this fact. */
    9725      4326770 :       if (c_type_variably_modified_p (TREE_TYPE (x)))
    9726          777 :         C_TYPE_VARIABLY_MODIFIED (t) = 1;
    9727              : 
    9728      4326770 :       if (DECL_C_BIT_FIELD (x))
    9729              :         {
    9730        52606 :           unsigned HOST_WIDE_INT width = tree_to_uhwi (DECL_INITIAL (x));
    9731        52606 :           DECL_SIZE (x) = bitsize_int (width);
    9732        52606 :           DECL_BIT_FIELD (x) = 1;
    9733              :         }
    9734              : 
    9735      4326770 :       if (TYPE_PACKED (t)
    9736      4332323 :           && (DECL_BIT_FIELD (x)
    9737         3235 :               || TYPE_ALIGN (TREE_TYPE (x)) > BITS_PER_UNIT))
    9738         4442 :         DECL_PACKED (x) = 1;
    9739              : 
    9740              :       /* Detect flexible array member in an invalid context.  */
    9741      4326770 :       if (c_flexible_array_member_type_p (TREE_TYPE (x)))
    9742              :         {
    9743        85992 :           if (TREE_CODE (t) == UNION_TYPE)
    9744           31 :             pedwarn (DECL_SOURCE_LOCATION (x), OPT_Wpedantic,
    9745              :                      "flexible array member in union is a GCC extension");
    9746        85961 :           else if (!is_last_field)
    9747              :             {
    9748            3 :               error_at (DECL_SOURCE_LOCATION (x),
    9749              :                         "flexible array member not at end of struct");
    9750            3 :               TREE_TYPE (x) = error_mark_node;
    9751              :             }
    9752        85958 :           else if (!saw_named_field)
    9753           36 :             pedwarn (DECL_SOURCE_LOCATION (x), OPT_Wpedantic,
    9754              :                      "flexible array member in a struct with no named "
    9755              :                      "members is a GCC extension");
    9756        85992 :           if (lookup_attribute ("counted_by", DECL_ATTRIBUTES (x)))
    9757          133 :             C_TYPE_FIELDS_HAS_COUNTED_BY (t) = 1;
    9758              :         }
    9759              : 
    9760      4326770 :       if (TREE_CODE (TREE_TYPE (x)) == POINTER_TYPE
    9761      4326770 :           && lookup_attribute ("counted_by", DECL_ATTRIBUTES (x)))
    9762          264 :         C_TYPE_FIELDS_HAS_COUNTED_BY (t) = 1;
    9763              : 
    9764              :       /* If the field is an anonymous structure that includes a field
    9765              :          with counted_by attribute, this structure should also be marked
    9766              :          too.  */
    9767      8277243 :       if (RECORD_OR_UNION_TYPE_P (TREE_TYPE (x))
    9768       466874 :           && C_TYPE_FIELDS_HAS_COUNTED_BY (TREE_TYPE (x))
    9769           18 :           && DECL_NAME (x) == NULL_TREE
    9770      4326783 :           && c_type_tag (TREE_TYPE (x)) == NULL_TREE)
    9771           12 :         C_TYPE_FIELDS_HAS_COUNTED_BY (t) = 1;
    9772              : 
    9773        25355 :       if (pedantic && TREE_CODE (t) == RECORD_TYPE
    9774      4347860 :           && flexible_array_type_p (TREE_TYPE (x)))
    9775           18 :         pedwarn (DECL_SOURCE_LOCATION (x), OPT_Wpedantic,
    9776              :                  "invalid use of structure with flexible array member");
    9777              : 
    9778              :       /* Set DECL_NOT_FLEXARRAY flag for FIELD_DECL x.  */
    9779      4326770 :       DECL_NOT_FLEXARRAY (x) = !is_flexible_array_member_p (is_last_field, x);
    9780              : 
    9781              :       /* Set TYPE_INCLUDES_FLEXARRAY for the context of x, t.
    9782              :          when x is an array and is the last field.
    9783              :          There is only one last_field for a structure type, but there might
    9784              :          be multiple last_fields for a union type, therefore we should ORed
    9785              :          the result for multiple last_fields.  */
    9786      4326770 :       if (TREE_CODE (TREE_TYPE (x)) == ARRAY_TYPE)
    9787       707506 :         TYPE_INCLUDES_FLEXARRAY (t)
    9788      1415012 :           |= is_last_field && c_flexible_array_member_type_p (TREE_TYPE (x));
    9789              :       /* Recursively set TYPE_INCLUDES_FLEXARRAY for the context of x, t
    9790              :          when x is an union or record and is the last field.  */
    9791      3619264 :       else if (RECORD_OR_UNION_TYPE_P (TREE_TYPE (x)))
    9792       466874 :         TYPE_INCLUDES_FLEXARRAY (t)
    9793       933748 :           |= is_last_field && TYPE_INCLUDES_FLEXARRAY (TREE_TYPE (x));
    9794              : 
    9795      4326770 :       if (warn_flex_array_member_not_at_end
    9796           56 :           && !is_last_field
    9797           22 :           && RECORD_OR_UNION_TYPE_P (TREE_TYPE (x))
    9798      4326782 :           && TYPE_INCLUDES_FLEXARRAY (TREE_TYPE (x)))
    9799            5 :         warning_at (DECL_SOURCE_LOCATION (x),
    9800            5 :                     OPT_Wflex_array_member_not_at_end,
    9801              :                     "structure containing a flexible array member"
    9802              :                     " is not at the end of another structure");
    9803              : 
    9804      4326770 :       if (DECL_NAME (x)
    9805      4326770 :           || RECORD_OR_UNION_TYPE_P (TREE_TYPE (x)))
    9806              :         saw_named_field = true;
    9807              : 
    9808      7946034 :       if (AGGREGATE_TYPE_P (TREE_TYPE (x))
    9809      4793644 :           && TYPE_TYPELESS_STORAGE (TREE_TYPE (x)))
    9810       450110 :         TYPE_TYPELESS_STORAGE (t) = true;
    9811              :     }
    9812              : 
    9813      1180288 :   detect_field_duplicates (fieldlist);
    9814              : 
    9815              :   /* Now we have the nearly final fieldlist.  Record it,
    9816              :      then lay out the structure or union (including the fields).  */
    9817              : 
    9818      1180288 :   TYPE_FIELDS (t) = fieldlist;
    9819              : 
    9820      1180288 :   maybe_apply_pragma_scalar_storage_order (t);
    9821              : 
    9822      1180288 :   layout_type (t);
    9823              : 
    9824      1180288 :   if (TYPE_SIZE_UNIT (t)
    9825      1180288 :       && TREE_CODE (TYPE_SIZE_UNIT (t)) == INTEGER_CST
    9826      1179645 :       && !TREE_OVERFLOW (TYPE_SIZE_UNIT (t))
    9827      2359933 :       && !valid_constant_size_p (TYPE_SIZE_UNIT (t)))
    9828            1 :     error ("type %qT is too large", t);
    9829              : 
    9830              :   /* Give bit-fields their proper types and rewrite the type of array fields
    9831              :      with scalar component if the enclosing type has reverse storage order.  */
    9832      5507098 :   for (tree field = fieldlist; field; field = DECL_CHAIN (field))
    9833              :     {
    9834      4326810 :       if (TREE_CODE (field) == FIELD_DECL
    9835      4326810 :           && DECL_INITIAL (field)
    9836      4379426 :           && TREE_TYPE (field) != error_mark_node)
    9837              :         {
    9838        52606 :           unsigned HOST_WIDE_INT width
    9839        52606 :             = tree_to_uhwi (DECL_INITIAL (field));
    9840        52606 :           tree type = TREE_TYPE (field);
    9841        52606 :           if (VECTOR_TYPE_P (type))
    9842              :             {
    9843            2 :               error_at (DECL_SOURCE_LOCATION (field),
    9844              :                         "bit-field %qD has invalid type", field);
    9845            2 :               type = TREE_TYPE (type);
    9846            2 :               TREE_TYPE (field) = type;
    9847              :             }
    9848        52606 :           if (width != TYPE_PRECISION (type))
    9849              :             {
    9850        37884 :               if (TREE_CODE (type) == BITINT_TYPE
    9851        37954 :                   && width >= (TYPE_UNSIGNED (type) ? 1 : 2))
    9852          161 :                 TREE_TYPE (field)
    9853          322 :                   = build_bitint_type (width, TYPE_UNSIGNED (type));
    9854              :               else
    9855        37723 :                 TREE_TYPE (field)
    9856        37723 :                   = c_build_bitfield_integer_type (width,
    9857        37723 :                                                    TYPE_UNSIGNED (type));
    9858        37884 :               if (tree attr = c_hardbool_type_attr (type))
    9859          281 :                 decl_attributes (&TREE_TYPE (field),
    9860              :                                  copy_list (attr),
    9861              :                                  0, NULL_TREE);
    9862        37884 :               SET_DECL_MODE (field, TYPE_MODE (TREE_TYPE (field)));
    9863              :             }
    9864        52606 :           DECL_INITIAL (field) = NULL_TREE;
    9865              :         }
    9866      4274204 :       else if (TYPE_REVERSE_STORAGE_ORDER (t)
    9867          695 :                && TREE_CODE (field) == FIELD_DECL
    9868      4274899 :                && TREE_CODE (TREE_TYPE (field)) == ARRAY_TYPE)
    9869              :         {
    9870          107 :           tree ftype = TREE_TYPE (field);
    9871          107 :           tree ctype = strip_array_types (ftype);
    9872          107 :           if (!RECORD_OR_UNION_TYPE_P (ctype) && TYPE_MODE (ctype) != QImode)
    9873              :             {
    9874           94 :               tree fmain_type = TYPE_MAIN_VARIANT (ftype);
    9875           94 :               tree *typep = &fmain_type;
    9876           96 :               do {
    9877           96 :                 *typep = build_distinct_type_copy (*typep);
    9878           96 :                 TYPE_REVERSE_STORAGE_ORDER (*typep) = 1;
    9879           96 :                 typep = &TREE_TYPE (*typep);
    9880           96 :               } while (TREE_CODE (*typep) == ARRAY_TYPE);
    9881           94 :               TREE_TYPE (field)
    9882          188 :                 = c_build_qualified_type (fmain_type, TYPE_QUALS (ftype));
    9883              :             }
    9884              :         }
    9885              : 
    9886              :       /* Warn on problematic type punning for storage order purposes.  */
    9887      4326810 :       if (TREE_CODE (t) == UNION_TYPE
    9888       855260 :           && TREE_CODE (field) == FIELD_DECL
    9889      5182070 :           && AGGREGATE_TYPE_P (TREE_TYPE (field)))
    9890              :         {
    9891       424872 :           tree ftype = TREE_TYPE (field);
    9892       424872 :           if (TREE_CODE (ftype) == ARRAY_TYPE)
    9893       313009 :             ftype = strip_array_types (ftype);
    9894       424872 :           if (RECORD_OR_UNION_TYPE_P (ftype)
    9895       424872 :               && TYPE_REVERSE_STORAGE_ORDER (ftype)
    9896       112357 :                  != TYPE_REVERSE_STORAGE_ORDER (t))
    9897            1 :             warning_at (DECL_SOURCE_LOCATION (field),
    9898            1 :                         OPT_Wscalar_storage_order,
    9899              :                         "type punning toggles scalar storage order");
    9900              :         }
    9901              :     }
    9902              : 
    9903              :   /* Now we have the truly final field list.
    9904              :      Store it in this type and in the variants.  */
    9905              : 
    9906      1180288 :   TYPE_FIELDS (t) = fieldlist;
    9907              : 
    9908              :   /* If there are lots of fields, sort so we can look through them fast.
    9909              :      We arbitrarily consider 16 or more elts to be "a lot".  */
    9910              : 
    9911      1180288 :   {
    9912      1180288 :     int len = 0;
    9913              : 
    9914      5065243 :     for (x = fieldlist; x; x = DECL_CHAIN (x))
    9915              :       {
    9916      3912835 :         if (len > 15 || DECL_NAME (x) == NULL)
    9917              :           break;
    9918      3884955 :         len += 1;
    9919              :       }
    9920              : 
    9921      1180288 :     if (len > 15)
    9922              :       {
    9923        22642 :         tree *field_array;
    9924        22642 :         struct lang_type *space;
    9925        22642 :         struct sorted_fields_type *space2;
    9926              : 
    9927        22642 :         len += list_length (x);
    9928              : 
    9929              :         /* Use the same allocation policy here that make_node uses, to
    9930              :            ensure that this lives as long as the rest of the struct decl.
    9931              :            All decls in an inline function need to be saved.  */
    9932              : 
    9933        22642 :         space = ((struct lang_type *)
    9934        22642 :                  ggc_internal_cleared_alloc (c_dialect_objc ()
    9935              :                                              ? sizeof (struct lang_type)
    9936              :                                              : offsetof (struct lang_type,
    9937              :                                                          info)));
    9938        22642 :         space2 = ((sorted_fields_type *)
    9939        45284 :                   ggc_internal_alloc (sizeof (struct sorted_fields_type)
    9940        22642 :                                       + len * sizeof (tree)));
    9941              : 
    9942        22642 :         len = 0;
    9943        22642 :         space->s = space2;
    9944        22642 :         field_array = &space2->elts[0];
    9945       791898 :         for (x = fieldlist; x; x = DECL_CHAIN (x))
    9946              :           {
    9947       772623 :             field_array[len++] = x;
    9948              : 
    9949              :             /* If there is anonymous struct or union, break out of the loop.  */
    9950       772623 :             if (DECL_NAME (x) == NULL)
    9951              :               break;
    9952              :           }
    9953              :         /* Found no anonymous struct/union.  Add the TYPE_LANG_SPECIFIC.  */
    9954        22642 :         if (x == NULL)
    9955              :           {
    9956        19275 :             TYPE_LANG_SPECIFIC (t) = space;
    9957        19275 :             TYPE_LANG_SPECIFIC (t)->s->len = len;
    9958        19275 :             field_array = TYPE_LANG_SPECIFIC (t)->s->elts;
    9959        19275 :             qsort (field_array, len, sizeof (tree), field_decl_cmp);
    9960              :           }
    9961              :       }
    9962              :   }
    9963              : 
    9964              :   /* If this was supposed to be a transparent union, but we can't
    9965              :      make it one, warn and turn off the flag.  */
    9966      1180288 :   if (TREE_CODE (t) == UNION_TYPE
    9967       377868 :       && TYPE_TRANSPARENT_AGGR (t)
    9968      1180333 :       && (!TYPE_FIELDS (t) || TYPE_MODE (t) != DECL_MODE (TYPE_FIELDS (t))))
    9969              :     {
    9970           13 :       TYPE_TRANSPARENT_AGGR (t) = 0;
    9971           13 :       warning_at (loc, 0, "union cannot be made transparent");
    9972              :     }
    9973              : 
    9974      1180288 :   tree incomplete_vars = C_TYPE_INCOMPLETE_VARS (TYPE_MAIN_VARIANT (t));
    9975      2391312 :   for (x = TYPE_MAIN_VARIANT (t); x; x = TYPE_NEXT_VARIANT (x))
    9976              :     {
    9977      1211024 :       TYPE_FIELDS (x) = TYPE_FIELDS (t);
    9978      1211024 :       TYPE_LANG_SPECIFIC (x) = TYPE_LANG_SPECIFIC (t);
    9979      1211024 :       TYPE_TRANSPARENT_AGGR (x) = TYPE_TRANSPARENT_AGGR (t);
    9980      1211024 :       TYPE_TYPELESS_STORAGE (x) = TYPE_TYPELESS_STORAGE (t);
    9981      1211024 :       C_TYPE_FIELDS_READONLY (x) = C_TYPE_FIELDS_READONLY (t);
    9982      1211024 :       C_TYPE_FIELDS_VOLATILE (x) = C_TYPE_FIELDS_VOLATILE (t);
    9983      1211024 :       C_TYPE_FIELDS_NON_CONSTEXPR (x) = C_TYPE_FIELDS_NON_CONSTEXPR (t);
    9984      1211024 :       C_TYPE_FIELDS_HAS_COUNTED_BY (x) = C_TYPE_FIELDS_HAS_COUNTED_BY (t);
    9985      1211024 :       C_TYPE_VARIABLE_SIZE (x) = C_TYPE_VARIABLE_SIZE (t);
    9986      1211024 :       C_TYPE_VARIABLY_MODIFIED (x) = C_TYPE_VARIABLY_MODIFIED (t);
    9987      1211024 :       C_TYPE_INCOMPLETE_VARS (x) = NULL_TREE;
    9988      1211024 :       TYPE_INCLUDES_FLEXARRAY (x) = TYPE_INCLUDES_FLEXARRAY (t);
    9989              :     }
    9990              : 
    9991              :   /* Check for consistency with previous definition.  */
    9992      1180288 :   if (flag_isoc23 && NULL != enclosing_struct_parse_info)
    9993              :     {
    9994       911690 :       tree vistype = previous_tag (t);
    9995       911690 :       if (vistype
    9996          128 :           && TREE_CODE (vistype) == TREE_CODE (t)
    9997       911818 :           && !C_TYPE_BEING_DEFINED (vistype))
    9998              :         {
    9999          108 :           TYPE_STUB_DECL (t) = TYPE_STUB_DECL (vistype);
   10000          108 :           if (c_type_variably_modified_p (t))
   10001              :             {
   10002            7 :               error ("redefinition of struct or union %qT with variably "
   10003              :                      "modified type", t);
   10004            7 :               if (struct_parse_info->refloc != UNKNOWN_LOCATION)
   10005            7 :                 inform (struct_parse_info->refloc, "originally defined here");
   10006              :             }
   10007          101 :           else if (!comptypes_same_p (t, vistype))
   10008              :             {
   10009           38 :               error ("redefinition of struct or union %qT", t);
   10010           38 :               if (struct_parse_info->refloc != UNKNOWN_LOCATION)
   10011           38 :                 inform (struct_parse_info->refloc, "originally defined here");
   10012              :             }
   10013              :         }
   10014              :     }
   10015              : 
   10016      1180288 :   C_TYPE_BEING_DEFINED (t) = 0;
   10017              : 
   10018      1180288 :   if (lookup_attribute ("may_alias", TYPE_ATTRIBUTES (t)))
   10019          684 :     for (x = TYPE_MAIN_VARIANT (t); x; x = TYPE_NEXT_VARIANT (x))
   10020          358 :       c_fixup_may_alias (x);
   10021              : 
   10022              :   /* Set type canonical based on equivalence class.  */
   10023      1180288 :   if (flag_isoc23 && !C_TYPE_VARIABLE_SIZE (t))
   10024              :     {
   10025       947437 :       if (c_struct_htab == NULL)
   10026        35981 :         c_struct_htab = hash_table<c_struct_hasher>::create_ggc (61);
   10027              : 
   10028       947437 :       hashval_t hash = c_struct_hasher::hash (t);
   10029              : 
   10030       947437 :       gcc_checking_assert (TYPE_STRUCTURAL_EQUALITY_P (t));
   10031       947437 :       gcc_checking_assert (!TYPE_NAME (t)
   10032              :                            || TREE_CODE (TYPE_NAME (t)) == IDENTIFIER_NODE);
   10033              : 
   10034       947437 :       tree *e = c_struct_htab->find_slot_with_hash (t, hash, INSERT);
   10035       947437 :       if (*e)
   10036        62986 :         TYPE_CANONICAL (t) = TYPE_CANONICAL (*e);
   10037              :       else
   10038              :         {
   10039       884451 :           TYPE_CANONICAL (t) = c_type_canonical (t);
   10040       884451 :           *e = t;
   10041              :         }
   10042       947437 :       c_update_type_canonical (t);
   10043              :     }
   10044              : 
   10045              :   /* Update type location to the one of the definition, instead of e.g.
   10046              :      a forward declaration.  */
   10047      1180288 :   if (TYPE_STUB_DECL (t))
   10048      1180288 :     DECL_SOURCE_LOCATION (TYPE_STUB_DECL (t)) = loc;
   10049              : 
   10050              :   /* Finish debugging output for this type.  */
   10051      1180288 :   rest_of_type_compilation (t, toplevel);
   10052              : 
   10053      1180288 :   finish_incomplete_vars (incomplete_vars, toplevel);
   10054              : 
   10055              : 
   10056      1180288 :   if (c_type_variably_modified_p (t))
   10057              :     {
   10058          716 :       c_update_variably_modified (t);
   10059              :       /* Make sure a DECL_EXPR is created for structs with VLA members.
   10060              :          Because we do not know the context, we always pass expr
   10061              :          to force creation of a BIND_EXPR which is required in some
   10062              :          contexts.  */
   10063          716 :       add_decl_expr (loc, t, expr, false);
   10064              :     }
   10065              : 
   10066      1180288 :   if (warn_cxx_compat)
   10067          575 :     warn_cxx_compat_finish_struct (fieldlist, TREE_CODE (t), loc);
   10068              : 
   10069      1180288 :   if (NULL != enclosing_struct_parse_info)
   10070              :     {
   10071      1138833 :       delete struct_parse_info;
   10072              : 
   10073      1138833 :       struct_parse_info = enclosing_struct_parse_info;
   10074              : 
   10075              :       /* If this struct is defined inside a struct, add it to
   10076              :          struct_types.  */
   10077      1138833 :       if (warn_cxx_compat
   10078              :           && struct_parse_info != NULL
   10079          350 :           && !in_sizeof && !in_typeof && !in_alignof && !in_countof)
   10080          345 :         struct_parse_info->struct_types.safe_push (t);
   10081              :      }
   10082              : 
   10083              :   /* Only when the enclosing struct/union type is not anonymous, do more
   10084              :      verification on the fields with counted_by attributes.  */
   10085      1180288 :   if (C_TYPE_FIELDS_HAS_COUNTED_BY (t) && c_type_tag (t) != NULL_TREE)
   10086          292 :     verify_counted_by_attribute (t, t);
   10087              : 
   10088      1180288 :   return t;
   10089              : }
   10090              : 
   10091              : static struct {
   10092              :   gt_pointer_operator new_value;
   10093              :   void *cookie;
   10094              : } resort_data;
   10095              : 
   10096              : /* This routine compares two fields like field_decl_cmp but using the
   10097              : pointer operator in resort_data.  */
   10098              : 
   10099              : static int
   10100         5399 : resort_field_decl_cmp (const void *x_p, const void *y_p)
   10101              : {
   10102         5399 :   const tree *const x = (const tree *) x_p;
   10103         5399 :   const tree *const y = (const tree *) y_p;
   10104              : 
   10105         5399 :   if (DECL_NAME (*x) == DECL_NAME (*y))
   10106              :     /* A nontype is "greater" than a type.  */
   10107            0 :     return (TREE_CODE (*y) == TYPE_DECL) - (TREE_CODE (*x) == TYPE_DECL);
   10108         5399 :   if (DECL_NAME (*x) == NULL_TREE)
   10109              :     return -1;
   10110         5399 :   if (DECL_NAME (*y) == NULL_TREE)
   10111              :     return 1;
   10112         5399 :   {
   10113         5399 :     tree d1 = DECL_NAME (*x);
   10114         5399 :     tree d2 = DECL_NAME (*y);
   10115         5399 :     resort_data.new_value (&d1, &d1, resort_data.cookie);
   10116         5399 :     resort_data.new_value (&d2, &d2, resort_data.cookie);
   10117         5399 :     if (d1 < d2)
   10118         2716 :       return -1;
   10119              :   }
   10120         2683 :   return 1;
   10121              : }
   10122              : 
   10123              : /* Resort DECL_SORTED_FIELDS because pointers have been reordered.  */
   10124              : 
   10125              : void
   10126            6 : resort_sorted_fields (void *obj,
   10127              :                       void * ARG_UNUSED (orig_obj),
   10128              :                       gt_pointer_operator new_value,
   10129              :                       void *cookie)
   10130              : {
   10131            6 :   struct sorted_fields_type *sf = (struct sorted_fields_type *) obj;
   10132            6 :   resort_data.new_value = new_value;
   10133            6 :   resort_data.cookie = cookie;
   10134            6 :   qsort (&sf->elts[0], sf->len, sizeof (tree),
   10135              :          resort_field_decl_cmp);
   10136            6 : }
   10137              : 
   10138              : /* Lay out the type T, and its element type, and so on.  */
   10139              : 
   10140              : static void
   10141            0 : layout_array_type (tree t)
   10142              : {
   10143            0 :   if (TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE)
   10144            0 :     layout_array_type (TREE_TYPE (t));
   10145            0 :   layout_type (t);
   10146            0 : }
   10147              : 
   10148              : /* Begin compiling the definition of an enumeration type.
   10149              :    NAME is its name (or null if anonymous).
   10150              :    LOC is the enum's location.
   10151              :    FIXED_UNDERLYING_TYPE is the (C23) underlying type specified in the
   10152              :    definition.
   10153              :    Returns the type object, as yet incomplete.
   10154              :    Also records info about it so that build_enumerator
   10155              :    may be used to declare the individual values as they are read.  */
   10156              : 
   10157              : tree
   10158       180649 : start_enum (location_t loc, struct c_enum_contents *the_enum, tree name,
   10159              :             tree fixed_underlying_type, bool potential_nesting_p)
   10160              : {
   10161       180649 :   tree enumtype = NULL_TREE;
   10162       180649 :   location_t enumloc = UNKNOWN_LOCATION;
   10163              : 
   10164              :   /* If this is the real definition for a previous forward reference,
   10165              :      fill in the contents in the same object that used to be the
   10166              :      forward reference.  */
   10167              : 
   10168       180649 :   if (name != NULL_TREE)
   10169        71794 :     enumtype = lookup_tag (ENUMERAL_TYPE, name, true, &enumloc);
   10170              : 
   10171        71794 :   if (enumtype != NULL_TREE && TREE_CODE (enumtype) == ENUMERAL_TYPE)
   10172              :     {
   10173              :       /* If the type is currently being defined or if we have seen an
   10174              :          incomplete version which is now complete, this is a nested
   10175              :          redefinition.  The later happens if the redefinition occurs
   10176              :          inside the enum specifier itself.  */
   10177          178 :       if (C_TYPE_BEING_DEFINED (enumtype)
   10178          178 :           || (potential_nesting_p && TYPE_VALUES (enumtype) != NULL_TREE))
   10179            9 :         error_at (loc, "nested redefinition of %<enum %E%>", name);
   10180              : 
   10181              :       /* For C23 we allow redefinitions.  We set to zero and check for
   10182              :          consistency later.  */
   10183          339 :       if (flag_isoc23 && TYPE_VALUES (enumtype) != NULL_TREE)
   10184              :         enumtype = NULL_TREE;
   10185              :     }
   10186              : 
   10187       109007 :   if (enumtype == NULL_TREE || TREE_CODE (enumtype) != ENUMERAL_TYPE)
   10188              :     {
   10189       180499 :       enumtype = make_node (ENUMERAL_TYPE);
   10190       180499 :       TYPE_SIZE (enumtype) = NULL_TREE;
   10191       180499 :       SET_TYPE_STRUCTURAL_EQUALITY (enumtype);
   10192       180499 :       pushtag (loc, name, enumtype);
   10193       180499 :       if (fixed_underlying_type != NULL_TREE)
   10194              :         {
   10195              :           /* For an enum definition with a fixed underlying type, the
   10196              :              type is complete during the definition and the
   10197              :              enumeration constants have that type.  If there was a
   10198              :              tag, the type was completed in c_parser_enum_specifier.
   10199              :              If not, it must be completed here.  */
   10200           12 :           ENUM_FIXED_UNDERLYING_TYPE_P (enumtype) = true;
   10201           12 :           TYPE_MIN_VALUE (enumtype) = TYPE_MIN_VALUE (fixed_underlying_type);
   10202           12 :           TYPE_MAX_VALUE (enumtype) = TYPE_MAX_VALUE (fixed_underlying_type);
   10203           12 :           TYPE_UNSIGNED (enumtype) = TYPE_UNSIGNED (fixed_underlying_type);
   10204           12 :           SET_TYPE_ALIGN (enumtype, TYPE_ALIGN (fixed_underlying_type));
   10205           12 :           TYPE_SIZE (enumtype) = NULL_TREE;
   10206           12 :           TYPE_PRECISION (enumtype) = TYPE_PRECISION (fixed_underlying_type);
   10207           12 :           ENUM_UNDERLYING_TYPE (enumtype) = fixed_underlying_type;
   10208           12 :           TYPE_CANONICAL (enumtype) = TYPE_CANONICAL (fixed_underlying_type);
   10209           12 :           c_update_type_canonical (enumtype);
   10210           12 :           layout_type (enumtype);
   10211              :         }
   10212              :     }
   10213              :   /* Update type location to the one of the definition, instead of e.g.
   10214              :      a forward declaration.  */
   10215          150 :   else if (TYPE_STUB_DECL (enumtype))
   10216              :     {
   10217          150 :       enumloc = DECL_SOURCE_LOCATION (TYPE_STUB_DECL (enumtype));
   10218          150 :       DECL_SOURCE_LOCATION (TYPE_STUB_DECL (enumtype)) = loc;
   10219              :     }
   10220              : 
   10221       180649 :   C_TYPE_BEING_DEFINED (enumtype) = 1;
   10222              : 
   10223       180649 :   if (TYPE_VALUES (enumtype) != NULL_TREE)
   10224              :     {
   10225              :       /* This enum is a named one that has been declared already.  */
   10226            6 :       auto_diagnostic_group d;
   10227            6 :       error_at (loc, "redeclaration of %<enum %E%>", name);
   10228            6 :       if (enumloc != UNKNOWN_LOCATION)
   10229            6 :         inform (enumloc, "originally defined here");
   10230              : 
   10231              :       /* Completely replace its old definition.
   10232              :          The old enumerators remain defined, however.  */
   10233            6 :       TYPE_VALUES (enumtype) = NULL_TREE;
   10234            6 :     }
   10235              : 
   10236       180649 :   if (ENUM_FIXED_UNDERLYING_TYPE_P (enumtype)
   10237       180649 :       && fixed_underlying_type == NULL_TREE)
   10238              :     {
   10239            3 :       error_at (loc, "%<enum%> declared with but defined without "
   10240              :                 "fixed underlying type");
   10241            3 :       ENUM_FIXED_UNDERLYING_TYPE_P (enumtype) = false;
   10242              :     }
   10243              : 
   10244       180649 :   the_enum->enum_next_value = integer_zero_node;
   10245       180649 :   the_enum->enum_type = enumtype;
   10246       180649 :   the_enum->enum_overflow = 0;
   10247              : 
   10248       180649 :   if (flag_short_enums && !ENUM_FIXED_UNDERLYING_TYPE_P (enumtype))
   10249          106 :     for (tree v = TYPE_MAIN_VARIANT (enumtype); v; v = TYPE_NEXT_VARIANT (v))
   10250           53 :       TYPE_PACKED (v) = 1;
   10251              : 
   10252              :   /* FIXME: This will issue a warning for a use of a type defined
   10253              :      within sizeof in a statement expr.  This is not terribly serious
   10254              :      as C++ doesn't permit statement exprs within sizeof anyhow.  */
   10255       180649 :   if (warn_cxx_compat
   10256          127 :       && (in_sizeof || in_typeof || in_alignof || in_countof))
   10257            0 :     warning_at (loc, OPT_Wc___compat,
   10258              :                 "defining type in %qs expression is invalid in C++",
   10259              :                 (in_sizeof ? "sizeof"
   10260            0 :                  : in_typeof ? "typeof"
   10261            0 :                  : in_alignof ? "alignof"
   10262              :                  : "_Countof"));
   10263              : 
   10264       180649 :   if (in_underspecified_init)
   10265            6 :     error_at (loc, "%qT defined in underspecified object initializer",
   10266              :               enumtype);
   10267              : 
   10268       180649 :   return enumtype;
   10269              : }
   10270              : 
   10271              : /* After processing and defining all the values of an enumeration type,
   10272              :    install their decls in the enumeration type and finish it off.
   10273              :    ENUMTYPE is the type object, VALUES a list of decl-value pairs,
   10274              :    and ATTRIBUTES are the specified attributes.
   10275              :    Returns ENUMTYPE.  */
   10276              : 
   10277              : tree
   10278       180649 : finish_enum (tree enumtype, tree values, tree attributes)
   10279              : {
   10280       180649 :   tree pair, tem;
   10281       180649 :   tree minnode = NULL_TREE, maxnode = NULL_TREE;
   10282       180649 :   int precision;
   10283       180649 :   signop sign;
   10284       180649 :   bool toplevel = (file_scope == current_scope);
   10285       180649 :   struct lang_type *lt;
   10286              : 
   10287       180649 :   decl_attributes (&enumtype, attributes, (int) ATTR_FLAG_TYPE_IN_PLACE);
   10288              : 
   10289              :   /* Calculate the maximum value of any enumerator in this type.  */
   10290              : 
   10291       180649 :   if (values == error_mark_node)
   10292           26 :     minnode = maxnode = integer_zero_node;
   10293              :   else
   10294              :     {
   10295       180623 :       minnode = maxnode = TREE_VALUE (values);
   10296      5721768 :       for (pair = TREE_CHAIN (values); pair; pair = TREE_CHAIN (pair))
   10297              :         {
   10298      5541145 :           tree value = TREE_VALUE (pair);
   10299      5541145 :           if (tree_int_cst_lt (maxnode, value))
   10300      5392000 :             maxnode = value;
   10301      5541145 :           if (tree_int_cst_lt (value, minnode))
   10302        65178 :             minnode = value;
   10303              :         }
   10304              :     }
   10305              : 
   10306              :   /* Construct the final type of this enumeration.  It is the same
   10307              :      as one of the integral types - the narrowest one that fits, except
   10308              :      that normally we only go as narrow as int - and signed iff any of
   10309              :      the values are negative.  */
   10310       180649 :   sign = (tree_int_cst_sgn (minnode) >= 0) ? UNSIGNED : SIGNED;
   10311       180649 :   precision = MAX (tree_int_cst_min_precision (minnode, sign),
   10312              :                    tree_int_cst_min_precision (maxnode, sign));
   10313              : 
   10314       180649 :   bool wider_than_int =
   10315       180649 :     (tree_int_cst_lt (minnode, TYPE_MIN_VALUE (integer_type_node))
   10316       180649 :      || tree_int_cst_lt (TYPE_MAX_VALUE (integer_type_node), maxnode));
   10317              : 
   10318              : 
   10319       180649 :   if (!ENUM_FIXED_UNDERLYING_TYPE_P (enumtype))
   10320              :     {
   10321              :       /* If the precision of the type was specified with an attribute and it
   10322              :          was too small, give an error.  Otherwise, use it.  */
   10323       180530 :       if (TYPE_PRECISION (enumtype) && lookup_attribute ("mode", attributes))
   10324              :         {
   10325           23 :           if (precision > TYPE_PRECISION (enumtype))
   10326              :             {
   10327            6 :               TYPE_PRECISION (enumtype) = 0;
   10328            6 :               error ("specified mode too small for enumerated values");
   10329              :             }
   10330              :           else
   10331           17 :             precision = TYPE_PRECISION (enumtype);
   10332              :         }
   10333              :       else
   10334       180507 :         TYPE_PRECISION (enumtype) = 0;
   10335              : 
   10336       180530 :       if (TYPE_PACKED (enumtype)
   10337       180451 :           || precision > TYPE_PRECISION (integer_type_node)
   10338       357967 :           || TYPE_PRECISION (enumtype))
   10339              :         {
   10340         3220 :           tem = c_common_type_for_size (precision, sign == UNSIGNED ? 1 : 0);
   10341         3105 :           if (tem == NULL)
   10342              :             {
   10343              :               /* This should only occur when both signed and unsigned
   10344              :                  values of maximum precision occur among the
   10345              :                  enumerators.  */
   10346            3 :               pedwarn (input_location, 0,
   10347              :                        "enumeration values exceed range of largest integer");
   10348            3 :               tem = widest_integer_literal_type_node;
   10349              :             }
   10350         3102 :           else if (precision > TYPE_PRECISION (intmax_type_node)
   10351            4 :                    && !tree_int_cst_lt (minnode,
   10352            4 :                                         TYPE_MIN_VALUE (intmax_type_node))
   10353         3105 :                    && !tree_int_cst_lt (TYPE_MAX_VALUE (uintmax_type_node),
   10354              :                                         maxnode))
   10355            2 :             pedwarn (input_location, OPT_Wpedantic,
   10356              :                      "enumeration values exceed range of %qs",
   10357              :                      sign == UNSIGNED ? "uintmax_t" : "intmax_t");
   10358              :         }
   10359              :       else
   10360       177425 :         tem = sign == UNSIGNED ? unsigned_type_node : integer_type_node;
   10361              : 
   10362       180530 :       TYPE_MIN_VALUE (enumtype) = TYPE_MIN_VALUE (tem);
   10363       180530 :       TYPE_MAX_VALUE (enumtype) = TYPE_MAX_VALUE (tem);
   10364       180530 :       TYPE_UNSIGNED (enumtype) = TYPE_UNSIGNED (tem);
   10365       180530 :       SET_TYPE_ALIGN (enumtype, TYPE_ALIGN (tem));
   10366       180530 :       TYPE_SIZE (enumtype) = NULL_TREE;
   10367       180530 :       TYPE_PRECISION (enumtype) = TYPE_PRECISION (tem);
   10368       180530 :       ENUM_UNDERLYING_TYPE (enumtype) =
   10369       180530 :         c_common_type_for_size (TYPE_PRECISION (tem), TYPE_UNSIGNED (tem));
   10370              : 
   10371       541590 :       TYPE_CANONICAL (enumtype) =
   10372       180530 :         TYPE_CANONICAL (ENUM_UNDERLYING_TYPE (enumtype));
   10373       180530 :       c_update_type_canonical (enumtype);
   10374              : 
   10375       180530 :       layout_type (enumtype);
   10376              :     }
   10377              : 
   10378       180649 :   if (values != error_mark_node)
   10379              :     {
   10380              :       /* Change the type of the enumerators to be the enum type.  We
   10381              :          need to do this irrespective of the size of the enum, for
   10382              :          proper type checking.  Replace the DECL_INITIALs of the
   10383              :          enumerators, and the value slots of the list, with copies
   10384              :          that have the enum type; they cannot be modified in place
   10385              :          because they may be shared (e.g.  integer_zero_node) Finally,
   10386              :          change the purpose slots to point to the names of the decls.  */
   10387      5902391 :       for (pair = values; pair; pair = TREE_CHAIN (pair))
   10388              :         {
   10389      5721768 :           tree enu = TREE_PURPOSE (pair);
   10390      5721768 :           tree ini = DECL_INITIAL (enu);
   10391              : 
   10392      5721768 :           TREE_TYPE (enu) = enumtype;
   10393              : 
   10394              :           /* Before C23, the ISO C Standard mandates enumerators to
   10395              :              have type int, even though the underlying type of an enum
   10396              :              type is unspecified.  However, C23 allows enumerators of
   10397              :              any integer type, and if an enumeration has any
   10398              :              enumerators wider than int, all enumerators have the
   10399              :              enumerated type after it is parsed.  Any enumerators that
   10400              :              fit in int are given type int in build_enumerator (which
   10401              :              is the correct type while the enumeration is being
   10402              :              parsed), so no conversions are needed here if all
   10403              :              enumerators fit in int.  If the enum has a fixed
   10404              :              underlying type, the correct type was also given in
   10405              :              build_enumerator.  */
   10406      5721768 :           if (!ENUM_FIXED_UNDERLYING_TYPE_P (enumtype) && wider_than_int)
   10407        33875 :             ini = convert (enumtype, ini);
   10408              : 
   10409      5721768 :           DECL_INITIAL (enu) = ini;
   10410      5721768 :           TREE_PURPOSE (pair) = DECL_NAME (enu);
   10411              :           /* To match the C++ FE, store the CONST_DECL rather than just its
   10412              :              value.  */
   10413      5721768 :           TREE_VALUE (pair) = enu;
   10414              :         }
   10415              : 
   10416       180623 :       TYPE_VALUES (enumtype) = values;
   10417              :     }
   10418              : 
   10419              :   /* Record the min/max values so that we can warn about bit-field
   10420              :      enumerations that are too small for the values.  */
   10421       180649 :   lt = ((struct lang_type *)
   10422       180649 :         ggc_internal_cleared_alloc (c_dialect_objc ()
   10423              :                                     ? sizeof (struct lang_type)
   10424              :                                     : offsetof (struct lang_type, info)));
   10425       180649 :   lt->enum_min = minnode;
   10426       180649 :   lt->enum_max = maxnode;
   10427       180649 :   TYPE_LANG_SPECIFIC (enumtype) = lt;
   10428              : 
   10429              :   /* Fix up all variant types of this enum type.  */
   10430       180649 :   tree incomplete_vars = C_TYPE_INCOMPLETE_VARS (TYPE_MAIN_VARIANT (enumtype));
   10431       361308 :   for (tem = TYPE_MAIN_VARIANT (enumtype); tem; tem = TYPE_NEXT_VARIANT (tem))
   10432              :     {
   10433       180659 :       C_TYPE_INCOMPLETE_VARS (tem) = NULL_TREE;
   10434       180659 :       if (tem == enumtype)
   10435       180649 :         continue;
   10436           10 :       TYPE_VALUES (tem) = TYPE_VALUES (enumtype);
   10437           10 :       TYPE_MIN_VALUE (tem) = TYPE_MIN_VALUE (enumtype);
   10438           10 :       TYPE_MAX_VALUE (tem) = TYPE_MAX_VALUE (enumtype);
   10439           10 :       TYPE_SIZE (tem) = TYPE_SIZE (enumtype);
   10440           10 :       TYPE_SIZE_UNIT (tem) = TYPE_SIZE_UNIT (enumtype);
   10441           10 :       SET_TYPE_MODE (tem, TYPE_MODE (enumtype));
   10442           10 :       TYPE_PRECISION (tem) = TYPE_PRECISION (enumtype);
   10443           10 :       SET_TYPE_ALIGN (tem, TYPE_ALIGN (enumtype));
   10444           10 :       TYPE_USER_ALIGN (tem) = TYPE_USER_ALIGN (enumtype);
   10445           10 :       TYPE_UNSIGNED (tem) = TYPE_UNSIGNED (enumtype);
   10446           10 :       TYPE_LANG_SPECIFIC (tem) = TYPE_LANG_SPECIFIC (enumtype);
   10447           10 :       ENUM_UNDERLYING_TYPE (tem) = ENUM_UNDERLYING_TYPE (enumtype);
   10448           10 :       TYPE_PACKED (tem) = TYPE_PACKED (enumtype);
   10449              :     }
   10450              : 
   10451              :   /* Finish debugging output for this type.  */
   10452       180649 :   rest_of_type_compilation (enumtype, toplevel);
   10453              : 
   10454       180649 :   finish_incomplete_vars (incomplete_vars, toplevel);
   10455              : 
   10456              :   /* If this enum is defined inside a struct, add it to
   10457              :      struct_types.  */
   10458       180649 :   if (warn_cxx_compat
   10459          127 :       && struct_parse_info != NULL
   10460           42 :       && !in_sizeof && !in_typeof && !in_alignof && !in_countof)
   10461           42 :     struct_parse_info->struct_types.safe_push (enumtype);
   10462              : 
   10463              :   /* Check for consistency with previous definition */
   10464       180649 :   if (flag_isoc23)
   10465              :     {
   10466       142570 :       tree vistype = previous_tag (enumtype);
   10467       142570 :       if (vistype
   10468           33 :           && TREE_CODE (vistype) == TREE_CODE (enumtype)
   10469       142599 :           && !C_TYPE_BEING_DEFINED (vistype))
   10470              :         {
   10471           29 :           TYPE_STUB_DECL (enumtype) = TYPE_STUB_DECL (vistype);
   10472           29 :           if (!comptypes_same_p (enumtype, vistype))
   10473            3 :             error("conflicting redefinition of enum %qT", enumtype);
   10474              :         }
   10475              :     }
   10476              : 
   10477       180649 :   C_TYPE_BEING_DEFINED (enumtype) = 0;
   10478              : 
   10479       180649 :   return enumtype;
   10480              : }
   10481              : 
   10482              : /* Build and install a CONST_DECL for one value of the
   10483              :    current enumeration type (one that was begun with start_enum).
   10484              :    DECL_LOC is the location of the enumerator.
   10485              :    LOC is the location of the '=' operator if any, DECL_LOC otherwise.
   10486              :    Return a tree-list containing the CONST_DECL and its value.
   10487              :    Assignment of sequential values by default is handled here.  */
   10488              : 
   10489              : tree
   10490      5721785 : build_enumerator (location_t decl_loc, location_t loc,
   10491              :                   struct c_enum_contents *the_enum, tree name, tree value)
   10492              : {
   10493      5721785 :   tree decl;
   10494      5721785 :   tree old_decl;
   10495              : 
   10496              :   /* Validate and default VALUE.  */
   10497              : 
   10498      5721785 :   if (value != NULL_TREE)
   10499              :     {
   10500              :       /* Don't issue more errors for error_mark_node (i.e. an
   10501              :          undeclared identifier) - just ignore the value expression.  */
   10502      3557697 :       if (value == error_mark_node)
   10503              :         value = NULL_TREE;
   10504      3557032 :       else if (!INTEGRAL_TYPE_P (TREE_TYPE (value)))
   10505              :         {
   10506            6 :           error_at (loc, "enumerator value for %qE is not an integer constant",
   10507              :                     name);
   10508            6 :           value = NULL_TREE;
   10509              :         }
   10510              :       else
   10511              :         {
   10512      3557026 :           if (TREE_CODE (value) != INTEGER_CST)
   10513              :             {
   10514           97 :               value = c_fully_fold (value, false, NULL);
   10515           97 :               if (TREE_CODE (value) == INTEGER_CST)
   10516           48 :                 pedwarn (loc, OPT_Wpedantic,
   10517              :                          "enumerator value for %qE is not an integer "
   10518              :                          "constant expression", name);
   10519              :             }
   10520      3557026 :           if (TREE_CODE (value) != INTEGER_CST)
   10521              :             {
   10522           49 :               error ("enumerator value for %qE is not an integer constant",
   10523              :                      name);
   10524           49 :               value = NULL_TREE;
   10525              :             }
   10526              :           else
   10527              :             {
   10528      3556977 :               value = default_conversion (value);
   10529      3556977 :               constant_expression_warning (value);
   10530              :             }
   10531              :         }
   10532              :     }
   10533              : 
   10534              :   /* Default based on previous value.  */
   10535              :   /* It should no longer be possible to have NON_LVALUE_EXPR
   10536              :      in the default.  */
   10537      3557032 :   if (value == NULL_TREE)
   10538              :     {
   10539      2164808 :       value = the_enum->enum_next_value;
   10540      2164808 :       if (the_enum->enum_overflow)
   10541            8 :         error_at (loc, "overflow in enumeration values");
   10542              :     }
   10543      5721785 :   if (ENUM_FIXED_UNDERLYING_TYPE_P (the_enum->enum_type))
   10544              :     {
   10545              :       /* Enumeration constants must fit in the fixed underlying type.  */
   10546          164 :       if (!int_fits_type_p (value, ENUM_UNDERLYING_TYPE (the_enum->enum_type)))
   10547            4 :         error_at (loc,
   10548              :                   "enumerator value outside the range of underlying type");
   10549              :       /* Enumeration constants for an enum with fixed underlying type
   10550              :          have the enum type, both inside and outside the
   10551              :          definition.  */
   10552          164 :       value = convert (the_enum->enum_type, value);
   10553              :     }
   10554      5721621 :   else if (flag_isoc23
   10555      5305265 :            && (old_decl = lookup_name_in_scope (name, current_scope))
   10556           35 :            && old_decl != error_mark_node
   10557           35 :            && TREE_TYPE (old_decl)
   10558           35 :            && TREE_TYPE (TREE_TYPE (old_decl))
   10559      5721655 :            && TREE_CODE (old_decl) == CONST_DECL)
   10560              :     {
   10561              :       /* Enumeration constants in a redeclaration have the previous type.  */
   10562           34 :       tree previous_type = TREE_TYPE (DECL_INITIAL (old_decl));
   10563           34 :       if (!int_fits_type_p (value, previous_type))
   10564              :         {
   10565            2 :           error_at (loc, "value of redeclared enumerator outside the range "
   10566              :                          "of %qT", previous_type);
   10567            2 :           locate_old_decl (old_decl);
   10568              :         }
   10569           34 :       value = convert (previous_type, value);
   10570              :     }
   10571              :   else
   10572              :     {
   10573              :       /* Even though the underlying type of an enum is unspecified, the
   10574              :          type of enumeration constants is explicitly defined as int
   10575              :          (6.4.4.3/2 in the C99 Standard).  C23 allows any integer type, and
   10576              :          GCC allows such types for older standards as an extension.  */
   10577      5721587 :       bool warned_range = false;
   10578      5721587 :       if (!int_fits_type_p (value,
   10579      5721587 :                             (TYPE_UNSIGNED (TREE_TYPE (value))
   10580              :                              ? uintmax_type_node
   10581              :                              : intmax_type_node)))
   10582              :         /* GCC does not consider its types larger than intmax_t to be
   10583              :            extended integer types (although C23 would permit such types to
   10584              :            be considered extended integer types if all the features
   10585              :            required by <stdint.h> and <inttypes.h> macros, such as support
   10586              :            for integer constants and I/O, were present), so diagnose if
   10587              :            such a wider type is used.  (If the wider type arose from a
   10588              :            constant of such a type, that will also have been diagnosed,
   10589              :            but this is the only diagnostic in the case where it arises
   10590              :            from choosing a wider type automatically when adding 1
   10591              :            overflows.)  */
   10592           11 :         warned_range = pedwarn (loc, OPT_Wpedantic,
   10593              :                                 "enumerator value outside the range of %qs",
   10594           11 :                                 TYPE_UNSIGNED (TREE_TYPE (value))
   10595              :                                 ? "uintmax_t"
   10596              :                                 : "intmax_t");
   10597      5721587 :       if (!warned_range && !int_fits_type_p (value, integer_type_node))
   10598         5200 :         pedwarn_c11 (loc, OPT_Wpedantic,
   10599              :                      "ISO C restricts enumerator values to range of %<int%> "
   10600              :                      "before C23");
   10601              : 
   10602              :       /* The ISO C Standard mandates enumerators to have type int before
   10603              :          C23, even though the underlying type of an enum type is
   10604              :          unspecified.  C23 allows enumerators of any integer type.  During
   10605              :          the parsing of the enumeration, C23 specifies that constants
   10606              :          representable in int have type int, constants not representable
   10607              :          in int have the type of the given expression if any, and
   10608              :          constants not representable in int and derived by adding 1 to the
   10609              :          previous constant have the type of that constant unless the
   10610              :          addition would overflow or wraparound, in which case a wider type
   10611              :          of the same signedness is chosen automatically; after the
   10612              :          enumeration is parsed, all the constants have the type of the
   10613              :          enumeration if any do not fit in int.  */
   10614      5721587 :       if (int_fits_type_p (value, integer_type_node))
   10615      5716383 :         value = convert (integer_type_node, value);
   10616              :     }
   10617              : 
   10618              :   /* Set basis for default for next value.  */
   10619      5721785 :   if (ENUM_FIXED_UNDERLYING_TYPE_P (the_enum->enum_type))
   10620              :     {
   10621          164 :       tree underlying_type = ENUM_UNDERLYING_TYPE (the_enum->enum_type);
   10622          164 :       if (TREE_CODE (underlying_type) == BOOLEAN_TYPE)
   10623              :         /* A value of 2 following a value of 1 overflows bool, but we
   10624              :            cannot carry out addition directly on bool without
   10625              :            promotion, and converting the result of arithmetic in a
   10626              :            wider type back to bool would not produce the right result
   10627              :            for this overflow check.  */
   10628           61 :         the_enum->enum_next_value = invert_truthvalue_loc (loc, value);
   10629              :       else
   10630          103 :         the_enum->enum_next_value
   10631          103 :           = build_binary_op (EXPR_LOC_OR_LOC (value, input_location),
   10632              :                              PLUS_EXPR, convert (underlying_type, value),
   10633              :                              convert (underlying_type, integer_one_node),
   10634              :                              false);
   10635              :     }
   10636              :   else
   10637              :     {
   10638              :       /* In a redeclaration the type can already be the enumeral type.  */
   10639      5721621 :       if (TREE_CODE (TREE_TYPE (value)) == ENUMERAL_TYPE)
   10640           12 :         value = convert (ENUM_UNDERLYING_TYPE (TREE_TYPE (value)), value);
   10641      5721621 :       the_enum->enum_next_value
   10642      5721621 :         = build_binary_op (EXPR_LOC_OR_LOC (value, input_location),
   10643              :                            PLUS_EXPR, value, integer_one_node, false);
   10644              :     }
   10645      5721785 :   the_enum->enum_overflow = tree_int_cst_lt (the_enum->enum_next_value, value);
   10646      5721785 :   if (the_enum->enum_overflow
   10647      5721785 :       && !ENUM_FIXED_UNDERLYING_TYPE_P (the_enum->enum_type))
   10648              :     {
   10649              :       /* Choose a wider type with the same signedness if
   10650              :          available.  */
   10651         3743 :       int prec = TYPE_PRECISION (TREE_TYPE (value)) + 1;
   10652         3743 :       bool unsignedp = TYPE_UNSIGNED (TREE_TYPE (value));
   10653         3743 :       tree new_type = (unsignedp
   10654         3743 :                        ? long_unsigned_type_node
   10655              :                        : long_integer_type_node);
   10656         3743 :       if (prec > TYPE_PRECISION (new_type))
   10657         3369 :         new_type = (unsignedp
   10658         3369 :                     ? long_long_unsigned_type_node
   10659              :                     : long_long_integer_type_node);
   10660         3743 :       if (prec > TYPE_PRECISION (new_type))
   10661         2897 :         new_type = (unsignedp
   10662         2897 :                     ? widest_unsigned_literal_type_node
   10663              :                     : widest_integer_literal_type_node);
   10664         3743 :       if (prec <= TYPE_PRECISION (new_type))
   10665              :         {
   10666         3738 :           the_enum->enum_overflow = false;
   10667         3738 :           the_enum->enum_next_value
   10668         3738 :             = build_binary_op (EXPR_LOC_OR_LOC (value, input_location),
   10669              :                                PLUS_EXPR, convert (new_type, value),
   10670              :                                integer_one_node, false);
   10671         3738 :           gcc_assert (!tree_int_cst_lt (the_enum->enum_next_value, value));
   10672              :         }
   10673              :     }
   10674              : 
   10675              :   /* Now create a declaration for the enum value name.  */
   10676              : 
   10677      5721785 :   decl = build_decl (decl_loc, CONST_DECL, name, TREE_TYPE (value));
   10678      5721785 :   DECL_INITIAL (decl) = value;
   10679      5721785 :   DECL_CONTEXT (decl) = the_enum->enum_type;
   10680      5721785 :   pushdecl (decl);
   10681              : 
   10682      5721785 :   return tree_cons (decl, value, NULL_TREE);
   10683              : }
   10684              : 
   10685              : /* Implement LANG_HOOKS_SIMULATE_ENUM_DECL.  */
   10686              : 
   10687              : tree
   10688            0 : c_simulate_enum_decl (location_t loc, const char *name,
   10689              :                       vec<string_int_pair> *values_ptr)
   10690              : {
   10691            0 :   location_t saved_loc = input_location;
   10692            0 :   input_location = loc;
   10693              : 
   10694            0 :   struct c_enum_contents the_enum;
   10695            0 :   tree enumtype = start_enum (loc, &the_enum, get_identifier (name),
   10696              :                               NULL_TREE, false);
   10697              : 
   10698            0 :   tree value_chain = NULL_TREE;
   10699            0 :   string_int_pair *value;
   10700            0 :   vec<string_int_pair> values = *values_ptr;
   10701            0 :   unsigned int i;
   10702            0 :   FOR_EACH_VEC_ELT (values, i, value)
   10703              :     {
   10704            0 :       tree decl = build_enumerator (loc, loc, &the_enum,
   10705              :                                     get_identifier (value->first),
   10706              :                                     build_int_cst (integer_type_node,
   10707            0 :                                                    value->second));
   10708            0 :       TREE_CHAIN (decl) = value_chain;
   10709            0 :       value_chain = decl;
   10710              :     }
   10711              : 
   10712            0 :   finish_enum (enumtype, nreverse (value_chain), NULL_TREE);
   10713              : 
   10714            0 :   input_location = saved_loc;
   10715            0 :   return enumtype;
   10716              : }
   10717              : 
   10718              : /* Implement LANG_HOOKS_SIMULATE_RECORD_DECL.  */
   10719              : 
   10720              : tree
   10721            0 : c_simulate_record_decl (location_t loc, const char *name,
   10722              :                         array_slice<const tree> fields)
   10723              : {
   10724            0 :   location_t saved_loc = input_location;
   10725            0 :   input_location = loc;
   10726              : 
   10727            0 :   class c_struct_parse_info *struct_info;
   10728            0 :   tree ident = get_identifier (name);
   10729            0 :   tree type = start_struct (loc, RECORD_TYPE, ident, &struct_info);
   10730              : 
   10731            0 :   for (unsigned int i = 0; i < fields.size (); ++i)
   10732              :     {
   10733            0 :       DECL_FIELD_CONTEXT (fields[i]) = type;
   10734            0 :       if (i > 0)
   10735            0 :         DECL_CHAIN (fields[i - 1]) = fields[i];
   10736              :     }
   10737              : 
   10738            0 :   finish_struct (loc, type, fields[0], NULL_TREE, struct_info);
   10739              : 
   10740            0 :   tree decl = build_decl (loc, TYPE_DECL, ident, type);
   10741            0 :   set_underlying_type (decl);
   10742            0 :   lang_hooks.decls.pushdecl (decl);
   10743              : 
   10744            0 :   input_location = saved_loc;
   10745            0 :   return type;
   10746              : }
   10747              : 
   10748              : /* Create the FUNCTION_DECL for a function definition.
   10749              :    DECLSPECS, DECLARATOR and ATTRIBUTES are the parts of
   10750              :    the declaration; they describe the function's name and the type it returns,
   10751              :    but twisted together in a fashion that parallels the syntax of C.
   10752              : 
   10753              :    This function creates a binding context for the function body
   10754              :    as well as setting up the FUNCTION_DECL in current_function_decl.
   10755              : 
   10756              :    Returns true on success.  If the DECLARATOR is not suitable for a function
   10757              :    (it defines a datum instead), we return false to report a parse error.  */
   10758              : 
   10759              : bool
   10760     36324584 : start_function (struct c_declspecs *declspecs, struct c_declarator *declarator,
   10761              :                 tree attributes)
   10762              : {
   10763     36324584 :   tree decl1, old_decl;
   10764     36324584 :   tree restype, resdecl;
   10765     36324584 :   location_t loc;
   10766     36324584 :   location_t result_loc;
   10767     36324584 :   tree expr = NULL;
   10768              : 
   10769     36324584 :   current_function_returns_value = 0;  /* Assume, until we see it does.  */
   10770     36324584 :   current_function_returns_null = 0;
   10771     36324584 :   current_function_returns_abnormally = 0;
   10772     36324584 :   warn_about_return_type = 0;
   10773     36324584 :   c_switch_stack = NULL;
   10774              : 
   10775              :   /* Indicate no valid break/continue context.  */
   10776     36324584 :   in_statement = 0;
   10777              : 
   10778     36324584 :   decl1 = grokdeclarator (declarator, declspecs, FUNCDEF, true, NULL,
   10779              :                           &attributes, &expr, NULL, DEPRECATED_NORMAL);
   10780     36324584 :   invoke_plugin_callbacks (PLUGIN_START_PARSE_FUNCTION, decl1);
   10781              : 
   10782              :   /* If the declarator is not suitable for a function definition,
   10783              :      cause a syntax error.  */
   10784     36324584 :   if (decl1 == NULL_TREE
   10785     36324553 :       || TREE_CODE (decl1) != FUNCTION_DECL)
   10786              :     return false;
   10787              : 
   10788              :   /* Nested functions may have variably modified (return) type.
   10789              :      Make sure the size expression is evaluated at this point.  */
   10790     36324546 :   if (expr && !current_scope->parm_flag)
   10791           11 :     add_stmt (fold_convert (void_type_node, expr));
   10792              : 
   10793     36324546 :   loc = DECL_SOURCE_LOCATION (decl1);
   10794              : 
   10795              :   /* A nested function is not global.  */
   10796     36324546 :   if (current_function_decl != NULL_TREE)
   10797         1594 :     TREE_PUBLIC (decl1) = 0;
   10798              : 
   10799     36324546 :   c_decl_attributes (&decl1, attributes, 0);
   10800              : 
   10801     36324546 :   if (DECL_DECLARED_INLINE_P (decl1)
   10802     35633700 :       && DECL_UNINLINABLE (decl1)
   10803     36324557 :       && lookup_attribute ("noinline", DECL_ATTRIBUTES (decl1)))
   10804              :     {
   10805            3 :       auto_urlify_attributes sentinel;
   10806            3 :       warning_at (loc, OPT_Wattributes,
   10807              :                   "inline function %qD given attribute %qs",
   10808              :                   decl1, "noinline");
   10809            3 :     }
   10810              : 
   10811              :   /* Handle gnu_inline attribute.  */
   10812     36324546 :   if (declspecs->inline_p
   10813     35633703 :       && !flag_gnu89_inline
   10814     35599606 :       && TREE_CODE (decl1) == FUNCTION_DECL
   10815     71924152 :       && (lookup_attribute ("gnu_inline", DECL_ATTRIBUTES (decl1))
   10816       158618 :           || current_function_decl))
   10817              :     {
   10818     35441060 :       if (declspecs->storage_class != csc_static)
   10819     35441054 :         DECL_EXTERNAL (decl1) = !DECL_EXTERNAL (decl1);
   10820              :     }
   10821              : 
   10822     36324546 :   announce_function (decl1);
   10823              : 
   10824     36324546 :   if (!COMPLETE_OR_VOID_TYPE_P (TREE_TYPE (TREE_TYPE (decl1))))
   10825              :     {
   10826            1 :       error_at (loc, "return type is an incomplete type");
   10827              :       /* Make it return void instead.  */
   10828            1 :       TREE_TYPE (decl1)
   10829            2 :         = c_build_function_type (void_type_node,
   10830            1 :                                  TYPE_ARG_TYPES (TREE_TYPE (decl1)),
   10831            1 :                                  TYPE_NO_NAMED_ARGS_STDARG_P (TREE_TYPE (decl1)));
   10832              :     }
   10833              : 
   10834     36324546 :   if (warn_about_return_type)
   10835         1404 :     permerror_opt (loc, flag_isoc99 ? OPT_Wimplicit_int
   10836            0 :                    : (warn_return_type > 0 ? OPT_Wreturn_type
   10837              :                       : OPT_Wimplicit_int),
   10838              :                    "return type defaults to %<int%>");
   10839              : 
   10840              :   /* Make the init_value nonzero so pushdecl knows this is not tentative.
   10841              :      error_mark_node is replaced below (in pop_scope) with the BLOCK.  */
   10842     36324546 :   DECL_INITIAL (decl1) = error_mark_node;
   10843              : 
   10844              :   /* If this definition isn't a prototype and we had a prototype declaration
   10845              :      before, copy the arg type info from that prototype.  */
   10846     36324546 :   old_decl = lookup_name_in_scope (DECL_NAME (decl1), current_scope);
   10847     36324546 :   if (old_decl && TREE_CODE (old_decl) != FUNCTION_DECL)
   10848     36095202 :     old_decl = NULL_TREE;
   10849              : 
   10850     36324546 :   current_function_prototype_locus = UNKNOWN_LOCATION;
   10851     36324546 :   current_function_prototype_built_in = false;
   10852     36324546 :   current_function_prototype_arg_types = NULL_TREE;
   10853     36324546 :   tree newtype = TREE_TYPE (decl1);
   10854     36324546 :   tree oldtype = old_decl ? TREE_TYPE (old_decl) : newtype;
   10855     36324546 :   if (!prototype_p (newtype))
   10856              :     {
   10857        13137 :       tree oldrt = TREE_TYPE (oldtype);
   10858        13137 :       tree newrt = TREE_TYPE (newtype);
   10859        13137 :       if (old_decl != NULL_TREE
   10860          317 :           && TREE_CODE (oldtype) == FUNCTION_TYPE
   10861          317 :           && comptypes (oldrt, newrt)
   10862        13435 :           && !TYPE_NO_NAMED_ARGS_STDARG_P (oldtype))
   10863              :         {
   10864          297 :           if (stdarg_p (oldtype))
   10865              :             {
   10866            1 :               auto_diagnostic_group d;
   10867            1 :               warning_at (loc, 0, "%q+D defined as variadic function "
   10868              :                           "without prototype", decl1);
   10869            1 :               locate_old_decl (old_decl);
   10870            1 :             }
   10871          297 :           TREE_TYPE (decl1) = composite_type (oldtype, newtype);
   10872          297 :           current_function_prototype_locus = DECL_SOURCE_LOCATION (old_decl);
   10873          297 :           current_function_prototype_built_in
   10874          297 :             = C_DECL_BUILTIN_PROTOTYPE (old_decl);
   10875          297 :           current_function_prototype_arg_types
   10876          297 :             = TYPE_ARG_TYPES (newtype);
   10877              :         }
   10878        13137 :       if (TREE_PUBLIC (decl1))
   10879              :         {
   10880              :           /* If there is an external prototype declaration of this
   10881              :              function, record its location but do not copy information
   10882              :              to this decl.  This may be an invisible declaration
   10883              :              (built-in or in a scope which has finished) or simply
   10884              :              have more refined argument types than any declaration
   10885              :              found above.  */
   10886        12722 :           struct c_binding *b;
   10887        12998 :           for (b = I_SYMBOL_BINDING (DECL_NAME (decl1)); b; b = b->shadowed)
   10888          713 :             if (B_IN_SCOPE (b, external_scope))
   10889              :               break;
   10890        12722 :           if (b)
   10891              :             {
   10892          437 :               tree ext_decl, ext_type;
   10893          437 :               ext_decl = b->decl;
   10894          437 :               ext_type = b->u.type ? b->u.type : TREE_TYPE (ext_decl);
   10895          437 :               if (TREE_CODE (ext_type) == FUNCTION_TYPE
   10896          874 :                   && comptypes (TREE_TYPE (TREE_TYPE (decl1)),
   10897          437 :                                 TREE_TYPE (ext_type)))
   10898              :                 {
   10899          417 :                   current_function_prototype_locus
   10900          417 :                     = DECL_SOURCE_LOCATION (ext_decl);
   10901          417 :                   current_function_prototype_built_in
   10902          417 :                     = C_DECL_BUILTIN_PROTOTYPE (ext_decl);
   10903          417 :                   current_function_prototype_arg_types
   10904          417 :                     = TYPE_ARG_TYPES (ext_type);
   10905              :                 }
   10906              :             }
   10907              :         }
   10908              :     }
   10909              : 
   10910              :   /* Optionally warn about C23 compatibility.  */
   10911     36324546 :   if (warn_deprecated_non_prototype
   10912           34 :       && old_decl != NULL_TREE
   10913            5 :       && TREE_CODE (oldtype) == FUNCTION_TYPE
   10914            5 :       && !TYPE_ARG_TYPES (oldtype)
   10915            5 :       && !TYPE_NO_NAMED_ARGS_STDARG_P (oldtype)
   10916     36324551 :       && (TYPE_ARG_TYPES (newtype)
   10917            3 :           && TREE_VALUE (TYPE_ARG_TYPES (newtype)) != void_type_node))
   10918              :     {
   10919            3 :       bool warned = warning_at (loc, OPT_Wdeprecated_non_prototype,
   10920              :                                 "ISO C23 does not allow defining"
   10921              :                                 " parameters for function %qE declared"
   10922              :                                 " without parameters",
   10923              :                                 decl1);
   10924            3 :       if (warned)
   10925            3 :         inform (DECL_SOURCE_LOCATION (old_decl), "declared here");
   10926              :     }
   10927              : 
   10928              :   /* Optionally warn of old-fashioned def with no previous prototype.  */
   10929     36324546 :   if (warn_strict_prototypes
   10930       107540 :       && old_decl != error_mark_node
   10931       107540 :       && !prototype_p (TREE_TYPE (decl1))
   10932     36324547 :       && C_DECL_ISNT_PROTOTYPE (old_decl))
   10933            1 :     warning_at (loc, OPT_Wstrict_prototypes,
   10934              :                 "function declaration isn%'t a prototype");
   10935              :   /* Optionally warn of any global def with no previous prototype.  */
   10936     36324545 :   else if (warn_missing_prototypes
   10937       107241 :            && old_decl != error_mark_node
   10938       107241 :            && TREE_PUBLIC (decl1)
   10939        74072 :            && !MAIN_NAME_P (DECL_NAME (decl1))
   10940        74036 :            && C_DECL_ISNT_PROTOTYPE (old_decl)
   10941     36325186 :            && !DECL_DECLARED_INLINE_P (decl1))
   10942            4 :     warning_at (loc, OPT_Wmissing_prototypes,
   10943              :                 "no previous prototype for %qD", decl1);
   10944              :   /* Optionally warn of any def with no previous prototype
   10945              :      if the function has already been used.  */
   10946     36324541 :   else if (warn_missing_prototypes
   10947       107237 :            && old_decl != NULL_TREE
   10948        74399 :            && old_decl != error_mark_node
   10949        74399 :            && TREE_USED (old_decl)
   10950     36331638 :            && !prototype_p (TREE_TYPE (old_decl)))
   10951            0 :     warning_at (loc, OPT_Wmissing_prototypes,
   10952              :                 "%qD was used with no prototype before its definition", decl1);
   10953              :   /* Optionally warn of any global def with no previous declaration.  */
   10954     36324541 :   else if (warn_missing_declarations
   10955            4 :            && TREE_PUBLIC (decl1)
   10956            3 :            && old_decl == NULL_TREE
   10957            3 :            && !MAIN_NAME_P (DECL_NAME (decl1))
   10958     36324544 :            && !DECL_DECLARED_INLINE_P (decl1))
   10959            2 :     warning_at (loc, OPT_Wmissing_declarations,
   10960              :                 "no previous declaration for %qD",
   10961              :                 decl1);
   10962              :   /* Optionally warn of any def with no previous declaration
   10963              :      if the function has already been used.  */
   10964     36324539 :   else if (warn_missing_declarations
   10965            2 :            && old_decl != NULL_TREE
   10966            0 :            && old_decl != error_mark_node
   10967            0 :            && TREE_USED (old_decl)
   10968     36324539 :            && C_DECL_IMPLICIT (old_decl))
   10969            0 :     warning_at (loc, OPT_Wmissing_declarations,
   10970              :                 "%qD was used with no declaration before its definition", decl1);
   10971              : 
   10972              :   /* This function exists in static storage.
   10973              :      (This does not mean `static' in the C sense!)  */
   10974     36324546 :   TREE_STATIC (decl1) = 1;
   10975              : 
   10976              :   /* This is the earliest point at which we might know the assembler
   10977              :      name of the function.  Thus, if it's set before this, die horribly.  */
   10978     36324546 :   gcc_assert (!DECL_ASSEMBLER_NAME_SET_P (decl1));
   10979              : 
   10980              :   /* If #pragma weak was used, mark the decl weak now.  */
   10981     36324546 :   if (current_scope == file_scope)
   10982     36322952 :     maybe_apply_pragma_weak (decl1);
   10983              : 
   10984              :   /* Warn for unlikely, improbable, or stupid declarations of `main'.  */
   10985     36324546 :   if (warn_main && MAIN_NAME_P (DECL_NAME (decl1)))
   10986              :     {
   10987         3253 :       if (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (decl1)))
   10988         3253 :           != integer_type_node)
   10989            5 :         pedwarn (loc, OPT_Wmain, "return type of %qD is not %<int%>", decl1);
   10990         3248 :       else if (TYPE_ATOMIC (TREE_TYPE (TREE_TYPE (decl1))))
   10991            1 :         pedwarn (loc, OPT_Wmain, "%<_Atomic%>-qualified return type of %qD",
   10992              :                  decl1);
   10993              : 
   10994         3253 :       check_main_parameter_types (decl1);
   10995              : 
   10996         3253 :       if (!TREE_PUBLIC (decl1))
   10997            0 :         pedwarn (loc, OPT_Wmain,
   10998              :                  "%qD is normally a non-static function", decl1);
   10999              :     }
   11000              : 
   11001     36324546 :   tree parms = current_function_arg_info->parms;
   11002     36324546 :   if (old_decl)
   11003              :     {
   11004       229344 :       location_t origloc = DECL_SOURCE_LOCATION (old_decl);
   11005       229344 :       warn_parms_array_mismatch (origloc, old_decl, parms);
   11006              :     }
   11007              : 
   11008              :   /* To enable versions to be created across TU's we mark and mangle all
   11009              :      non-default versioned functions.  */
   11010     36324546 :   if (TREE_CODE (decl1) == FUNCTION_DECL
   11011              :       && !TARGET_HAS_FMV_TARGET_ATTRIBUTE
   11012              :       && get_target_version (decl1).is_valid ())
   11013              :     {
   11014              :       maybe_mark_function_versioned (decl1);
   11015              :       if (current_scope != file_scope)
   11016              :         error ("versioned definitions are only allowed at file scope");
   11017              :     }
   11018              : 
   11019              :   /* Record the decl so that the function name is defined.
   11020              :      If we already have a decl for this name, and it is a FUNCTION_DECL,
   11021              :      use the old decl.  */
   11022              : 
   11023     36324546 :   current_function_decl = pushdecl (decl1);
   11024              : 
   11025     36324546 :   if (tree access = build_attr_access_from_parms (parms, false))
   11026        57714 :     decl_attributes (&current_function_decl, access, ATTR_FLAG_INTERNAL,
   11027              :                      old_decl);
   11028              : 
   11029     36324546 :   push_scope ();
   11030     36324546 :   declare_parm_level ();
   11031              : 
   11032              :   /* Set the result decl source location to the location of the typespec.  */
   11033      4102052 :   result_loc = (declspecs->locations[cdw_typespec] == UNKNOWN_LOCATION
   11034     36324546 :                 ? loc : declspecs->locations[cdw_typespec]);
   11035     36324546 :   restype = TREE_TYPE (TREE_TYPE (current_function_decl));
   11036     36324546 :   resdecl = build_decl (result_loc, RESULT_DECL, NULL_TREE, restype);
   11037     36324546 :   DECL_ARTIFICIAL (resdecl) = 1;
   11038     36324546 :   DECL_IGNORED_P (resdecl) = 1;
   11039     36324546 :   DECL_RESULT (current_function_decl) = resdecl;
   11040              : 
   11041     36324546 :   start_fname_decls ();
   11042              : 
   11043     36324546 :   return true;
   11044              : }
   11045              : 
   11046              : /* Subroutine of store_parm_decls which handles new-style function
   11047              :    definitions (prototype format). The parms already have decls, so we
   11048              :    need only record them as in effect and complain if any redundant
   11049              :    old-style parm decls were written.  */
   11050              : static void
   11051     36311422 : store_parm_decls_newstyle (tree fndecl, const struct c_arg_info *arg_info)
   11052              : {
   11053     36311422 :   tree decl;
   11054     36311422 :   c_arg_tag *tag;
   11055     36311422 :   unsigned ix;
   11056              : 
   11057     36311422 :   if (current_scope->bindings)
   11058              :     {
   11059            8 :       error_at (DECL_SOURCE_LOCATION (fndecl),
   11060              :                 "old-style parameter declarations in prototyped "
   11061              :                 "function definition");
   11062              : 
   11063              :       /* Get rid of the old-style declarations.  */
   11064            8 :       pop_scope ();
   11065            8 :       push_scope ();
   11066              :     }
   11067              :   /* Don't issue this warning for nested functions, and don't issue this
   11068              :      warning if we got here because ARG_INFO_TYPES was error_mark_node
   11069              :      (this happens when a function definition has just an ellipsis in
   11070              :      its parameter list).  */
   11071     36311414 :   else if (!in_system_header_at (input_location)
   11072       641062 :            && !current_function_scope
   11073       639616 :            && arg_info->types != error_mark_node
   11074     36951030 :            && !arg_info->c23_empty_parens)
   11075       587600 :     warning_at (DECL_SOURCE_LOCATION (fndecl), OPT_Wtraditional,
   11076              :                 "traditional C rejects ISO C style function definitions");
   11077              : 
   11078              :   /* Now make all the parameter declarations visible in the function body.
   11079              :      We can bypass most of the grunt work of pushdecl.  */
   11080    136359686 :   for (decl = arg_info->parms; decl; decl = DECL_CHAIN (decl))
   11081              :     {
   11082    100048264 :       DECL_CONTEXT (decl) = current_function_decl;
   11083    100048264 :       if (DECL_NAME (decl))
   11084              :         {
   11085    100046763 :           bind (DECL_NAME (decl), decl, current_scope,
   11086              :                 /*invisible=*/false, /*nested=*/false,
   11087              :                 UNKNOWN_LOCATION);
   11088    100046763 :           if (!TREE_USED (decl))
   11089    100029361 :             warn_if_shadowing (decl);
   11090              :         }
   11091              :       else
   11092         1501 :         pedwarn_c11 (DECL_SOURCE_LOCATION (decl), OPT_Wmissing_parameter_name,
   11093              :                      "ISO C does not support omitting parameter names in "
   11094              :                      "function definitions before C23");
   11095              :     }
   11096              : 
   11097              :   /* Record the parameter list in the function declaration.  */
   11098     36311422 :   DECL_ARGUMENTS (fndecl) = arg_info->parms;
   11099              : 
   11100              :   /* Now make all the ancillary declarations visible, likewise.  */
   11101     36311483 :   for (decl = arg_info->others; decl; decl = DECL_CHAIN (decl))
   11102              :     {
   11103           61 :       DECL_CONTEXT (decl) = current_function_decl;
   11104           61 :       if (DECL_NAME (decl))
   11105            0 :         bind (DECL_NAME (decl), decl, current_scope,
   11106              :               /*invisible=*/false,
   11107            0 :               /*nested=*/(TREE_CODE (decl) == FUNCTION_DECL),
   11108              :               UNKNOWN_LOCATION);
   11109              :     }
   11110              : 
   11111              :   /* And all the tag declarations.  */
   11112     36311539 :   FOR_EACH_VEC_SAFE_ELT_REVERSE (arg_info->tags, ix, tag)
   11113           61 :     if (tag->id)
   11114           28 :       bind (tag->id, tag->type, current_scope,
   11115              :             /*invisible=*/false, /*nested=*/false, UNKNOWN_LOCATION);
   11116     36311422 : }
   11117              : 
   11118              : /* Subroutine of store_parm_decls which handles old-style function
   11119              :    definitions (separate parameter list and declarations).  */
   11120              : 
   11121              : static void
   11122        13124 : store_parm_decls_oldstyle (tree fndecl, const struct c_arg_info *arg_info)
   11123              : {
   11124        13124 :   struct c_binding *b;
   11125        13124 :   tree parm, decl, last;
   11126        13124 :   tree parmids = arg_info->parms;
   11127        13124 :   hash_set<tree> seen_args;
   11128              : 
   11129        13124 :   if (!in_system_header_at (input_location))
   11130              :     {
   11131        13121 :       if (flag_isoc23)
   11132         1348 :         pedwarn (DECL_SOURCE_LOCATION (fndecl),
   11133         1348 :                  OPT_Wold_style_definition, "old-style function definition");
   11134              :       else
   11135        11773 :         warning_at (DECL_SOURCE_LOCATION (fndecl),
   11136        11773 :                     OPT_Wold_style_definition,
   11137              :                     "old-style function definition");
   11138              :     }
   11139              : 
   11140        13124 :   if (current_scope->had_vla_unspec)
   11141            1 :     error ("%<[*]%> not allowed in other than function prototype scope");
   11142              : 
   11143              :   /* Match each formal parameter name with its declaration.  Save each
   11144              :      decl in the appropriate TREE_PURPOSE slot of the parmids chain.  */
   11145        47398 :   for (parm = parmids; parm; parm = TREE_CHAIN (parm))
   11146              :     {
   11147        34274 :       if (TREE_VALUE (parm) == NULL_TREE)
   11148              :         {
   11149            0 :           error_at (DECL_SOURCE_LOCATION (fndecl),
   11150              :                     "parameter name missing from parameter list");
   11151            0 :           TREE_PURPOSE (parm) = NULL_TREE;
   11152            0 :           continue;
   11153              :         }
   11154              : 
   11155        34274 :       b = I_SYMBOL_BINDING (TREE_VALUE (parm));
   11156        34274 :       if (b && B_IN_CURRENT_SCOPE (b))
   11157              :         {
   11158        22654 :           decl = b->decl;
   11159              :           /* Skip erroneous parameters.  */
   11160        22654 :           if (decl == error_mark_node)
   11161            2 :             continue;
   11162              :           /* If we got something other than a PARM_DECL it is an error.  */
   11163        22652 :           if (TREE_CODE (decl) != PARM_DECL)
   11164              :             {
   11165            7 :               error_at (DECL_SOURCE_LOCATION (decl),
   11166              :                         "%qD declared as a non-parameter", decl);
   11167            7 :               continue;
   11168              :             }
   11169              :           /* If the declaration is already marked, we have a duplicate
   11170              :              name.  Complain and ignore the duplicate.  */
   11171        22645 :           else if (seen_args.contains (decl))
   11172              :             {
   11173            0 :               error_at (DECL_SOURCE_LOCATION (decl),
   11174              :                         "multiple parameters named %qD", decl);
   11175            0 :               TREE_PURPOSE (parm) = NULL_TREE;
   11176            0 :               continue;
   11177              :             }
   11178              :           /* If the declaration says "void", complain and turn it into
   11179              :              an int.  */
   11180        22645 :           else if (VOID_TYPE_P (TREE_TYPE (decl)))
   11181              :             {
   11182            0 :               error_at (DECL_SOURCE_LOCATION (decl),
   11183              :                         "parameter %qD declared with void type", decl);
   11184            0 :               TREE_TYPE (decl) = integer_type_node;
   11185            0 :               DECL_ARG_TYPE (decl) = integer_type_node;
   11186            0 :               layout_decl (decl, 0);
   11187              :             }
   11188        22645 :           warn_if_shadowing (decl);
   11189              :         }
   11190              :       /* If no declaration found, default to int.  */
   11191              :       else
   11192              :         {
   11193              :           /* FIXME diagnostics: This should be the location of the argument,
   11194              :              not the FNDECL.  E.g., for an old-style declaration
   11195              : 
   11196              :                int f10(v) { blah; }
   11197              : 
   11198              :              We should use the location of the V, not the F10.
   11199              :              Unfortunately, the V is an IDENTIFIER_NODE which has no
   11200              :              location.  In the future we need locations for c_arg_info
   11201              :              entries.
   11202              : 
   11203              :              See gcc.dg/Wshadow-3.c for an example of this problem. */
   11204        11620 :           decl = build_decl (DECL_SOURCE_LOCATION (fndecl),
   11205        11620 :                              PARM_DECL, TREE_VALUE (parm), integer_type_node);
   11206        11620 :           DECL_ARG_TYPE (decl) = TREE_TYPE (decl);
   11207        11620 :           pushdecl (decl);
   11208        11620 :           warn_if_shadowing (decl);
   11209              : 
   11210        11620 :           if (flag_isoc99)
   11211          118 :             permerror_opt (DECL_SOURCE_LOCATION (decl),
   11212          118 :                            OPT_Wimplicit_int, "type of %qD defaults to %<int%>",
   11213              :                            decl);
   11214              :           else
   11215        11502 :             warning_at (DECL_SOURCE_LOCATION (decl),
   11216        11502 :                         OPT_Wmissing_parameter_type,
   11217              :                         "type of %qD defaults to %<int%>", decl);
   11218              :         }
   11219              : 
   11220        34265 :       TREE_PURPOSE (parm) = decl;
   11221        34265 :       seen_args.add (decl);
   11222              :     }
   11223              : 
   11224              :   /* Now examine the parms chain for incomplete declarations
   11225              :      and declarations with no corresponding names.  */
   11226              : 
   11227        47477 :   for (b = current_scope->bindings; b; b = b->prev)
   11228              :     {
   11229        34353 :       parm = b->decl;
   11230        34353 :       if (TREE_CODE (parm) != PARM_DECL)
   11231           79 :         continue;
   11232              : 
   11233        34274 :       if (TREE_TYPE (parm) != error_mark_node
   11234        34274 :           && !COMPLETE_TYPE_P (TREE_TYPE (parm)))
   11235              :         {
   11236            0 :           error_at (DECL_SOURCE_LOCATION (parm),
   11237              :                     "parameter %qD has incomplete type", parm);
   11238            0 :           TREE_TYPE (parm) = error_mark_node;
   11239              :         }
   11240              : 
   11241        34274 :       if (!seen_args.contains (parm))
   11242              :         {
   11243            9 :           error_at (DECL_SOURCE_LOCATION (parm),
   11244              :                     "declaration for parameter %qD but no such parameter",
   11245              :                     parm);
   11246              : 
   11247              :           /* Pretend the parameter was not missing.
   11248              :              This gets us to a standard state and minimizes
   11249              :              further error messages.  */
   11250            9 :           parmids = chainon (parmids, tree_cons (parm, 0, 0));
   11251              :         }
   11252              :     }
   11253              : 
   11254              :   /* Chain the declarations together in the order of the list of
   11255              :      names.  Store that chain in the function decl, replacing the
   11256              :      list of names.  Update the current scope to match.  */
   11257        13124 :   DECL_ARGUMENTS (fndecl) = NULL_TREE;
   11258              : 
   11259        13132 :   for (parm = parmids; parm; parm = TREE_CHAIN (parm))
   11260         8680 :     if (TREE_PURPOSE (parm))
   11261              :       break;
   11262        13124 :   if (parm && TREE_PURPOSE (parm))
   11263              :     {
   11264         8672 :       last = TREE_PURPOSE (parm);
   11265         8672 :       DECL_ARGUMENTS (fndecl) = last;
   11266              : 
   11267        34275 :       for (parm = TREE_CHAIN (parm); parm; parm = TREE_CHAIN (parm))
   11268        25603 :         if (TREE_PURPOSE (parm))
   11269              :           {
   11270        25602 :             DECL_CHAIN (last) = TREE_PURPOSE (parm);
   11271        25603 :             last = TREE_PURPOSE (parm);
   11272              :           }
   11273         8672 :       DECL_CHAIN (last) = NULL_TREE;
   11274              :     }
   11275              : 
   11276              :   /* If there was a previous prototype,
   11277              :      set the DECL_ARG_TYPE of each argument according to
   11278              :      the type previously specified, and report any mismatches.  */
   11279              : 
   11280        13124 :   if (current_function_prototype_arg_types)
   11281              :     {
   11282          171 :       tree type;
   11283          171 :       for (parm = DECL_ARGUMENTS (fndecl),
   11284          171 :              type = current_function_prototype_arg_types;
   11285          373 :            parm || (type != NULL_TREE
   11286          166 :                     && TREE_VALUE (type) != error_mark_node
   11287          166 :                     && TYPE_MAIN_VARIANT (TREE_VALUE (type)) != void_type_node);
   11288          202 :            parm = DECL_CHAIN (parm), type = TREE_CHAIN (type))
   11289              :         {
   11290          212 :           if (parm == NULL_TREE
   11291          206 :               || type == NULL_TREE
   11292          418 :               || (TREE_VALUE (type) != error_mark_node
   11293          192 :                   && TYPE_MAIN_VARIANT (TREE_VALUE (type)) == void_type_node))
   11294              :             {
   11295           10 :               if (current_function_prototype_built_in)
   11296            6 :                 warning_at (DECL_SOURCE_LOCATION (fndecl),
   11297            6 :                             0, "number of arguments doesn%'t match "
   11298              :                             "built-in prototype");
   11299              :               else
   11300              :                 {
   11301              :                   /* FIXME diagnostics: This should be the location of
   11302              :                      FNDECL, but there is bug when a prototype is
   11303              :                      declared inside function context, but defined
   11304              :                      outside of it (e.g., gcc.dg/pr15698-2.c).  In
   11305              :                      which case FNDECL gets the location of the
   11306              :                      prototype, not the definition.  */
   11307            4 :                   error_at (input_location,
   11308              :                             "number of arguments doesn%'t match prototype");
   11309              : 
   11310            4 :                   error_at (current_function_prototype_locus,
   11311              :                             "prototype declaration");
   11312              :                 }
   11313              :               break;
   11314              :             }
   11315              :           /* Type for passing arg must be consistent with that
   11316              :              declared for the arg.  ISO C says we take the unqualified
   11317              :              type for parameters declared with qualified type.  */
   11318          202 :           if (TREE_TYPE (parm) != error_mark_node
   11319          201 :               && TREE_VALUE (type) != error_mark_node
   11320          389 :               && ((TYPE_ATOMIC (DECL_ARG_TYPE (parm))
   11321          187 :                    != TYPE_ATOMIC (TREE_VALUE (type)))
   11322          185 :                   || !comptypes (TYPE_MAIN_VARIANT (DECL_ARG_TYPE (parm)),
   11323          185 :                                  TYPE_MAIN_VARIANT (TREE_VALUE (type)))))
   11324              :             {
   11325           36 :               if ((TYPE_ATOMIC (DECL_ARG_TYPE (parm))
   11326           36 :                    == TYPE_ATOMIC (TREE_VALUE (type)))
   11327           36 :                   && (TYPE_MAIN_VARIANT (TREE_TYPE (parm))
   11328           34 :                       == TYPE_MAIN_VARIANT (TREE_VALUE (type))))
   11329              :                 {
   11330              :                   /* Adjust argument to match prototype.  E.g. a previous
   11331              :                      `int foo(float);' prototype causes
   11332              :                      `int foo(x) float x; {...}' to be treated like
   11333              :                      `int foo(float x) {...}'.  This is particularly
   11334              :                      useful for argument types like uid_t.  */
   11335           17 :                   DECL_ARG_TYPE (parm) = TREE_TYPE (parm);
   11336              : 
   11337              :                   /* ??? Is it possible to get here with a
   11338              :                      built-in prototype or will it always have
   11339              :                      been diagnosed as conflicting with an
   11340              :                      old-style definition and discarded?  */
   11341           17 :                   if (current_function_prototype_built_in)
   11342            2 :                     warning_at (DECL_SOURCE_LOCATION (parm),
   11343            2 :                                 OPT_Wpedantic, "promoted argument %qD "
   11344              :                                 "doesn%'t match built-in prototype", parm);
   11345              :                   else
   11346              :                     {
   11347           15 :                       pedwarn (DECL_SOURCE_LOCATION (parm),
   11348           15 :                                OPT_Wpedantic, "promoted argument %qD "
   11349              :                                "doesn%'t match prototype", parm);
   11350           15 :                       pedwarn (current_function_prototype_locus, OPT_Wpedantic,
   11351              :                                "prototype declaration");
   11352              :                     }
   11353              :                 }
   11354              :               else
   11355              :                 {
   11356           19 :                   if (current_function_prototype_built_in)
   11357           10 :                     warning_at (DECL_SOURCE_LOCATION (parm),
   11358           10 :                                 0, "argument %qD doesn%'t match "
   11359              :                                 "built-in prototype", parm);
   11360              :                   else
   11361              :                     {
   11362            9 :                       error_at (DECL_SOURCE_LOCATION (parm),
   11363              :                                 "argument %qD doesn%'t match prototype", parm);
   11364            9 :                       error_at (current_function_prototype_locus,
   11365              :                                 "prototype declaration");
   11366              :                     }
   11367              :                 }
   11368              :             }
   11369              :         }
   11370          171 :       TYPE_ACTUAL_ARG_TYPES (TREE_TYPE (fndecl)) = NULL_TREE;
   11371              :     }
   11372              : 
   11373              :   /* Otherwise, create a prototype that would match.  */
   11374              : 
   11375              :   else
   11376              :     {
   11377        12953 :       tree actual = NULL_TREE, last = NULL_TREE, type;
   11378              : 
   11379        47021 :       for (parm = DECL_ARGUMENTS (fndecl); parm; parm = DECL_CHAIN (parm))
   11380              :         {
   11381        34068 :           type = tree_cons (NULL_TREE, DECL_ARG_TYPE (parm), NULL_TREE);
   11382        34068 :           if (last)
   11383        25552 :             TREE_CHAIN (last) = type;
   11384              :           else
   11385              :             actual = type;
   11386        34068 :           last = type;
   11387              :         }
   11388        12953 :       type = tree_cons (NULL_TREE, void_type_node, NULL_TREE);
   11389        12953 :       if (last)
   11390         8516 :         TREE_CHAIN (last) = type;
   11391              :       else
   11392              :         actual = type;
   11393              : 
   11394              :       /* We are going to assign a new value for the TYPE_ACTUAL_ARG_TYPES
   11395              :          of the type of this function, but we need to avoid having this
   11396              :          affect the types of other similarly-typed functions, so we must
   11397              :          first force the generation of an identical (but separate) type
   11398              :          node for the relevant function type.  The new node we create
   11399              :          will be a variant of the main variant of the original function
   11400              :          type.  */
   11401              : 
   11402        12953 :       TREE_TYPE (fndecl) = build_variant_type_copy (TREE_TYPE (fndecl));
   11403              : 
   11404        12953 :       TYPE_ACTUAL_ARG_TYPES (TREE_TYPE (fndecl)) = actual;
   11405              :     }
   11406        13124 : }
   11407              : 
   11408              : /* Store parameter declarations passed in ARG_INFO into the current
   11409              :    function declaration.  */
   11410              : 
   11411              : void
   11412            0 : store_parm_decls_from (struct c_arg_info *arg_info)
   11413              : {
   11414            0 :   current_function_arg_info = arg_info;
   11415            0 :   store_parm_decls ();
   11416            0 : }
   11417              : 
   11418              : /* Called by walk_tree to look for and update context-less labels
   11419              :    or labels with context in the parent function.  */
   11420              : 
   11421              : static tree
   11422         8160 : set_labels_context_r (tree *tp, int *walk_subtrees, void *data)
   11423              : {
   11424         8160 :   tree ctx = static_cast<tree>(data);
   11425         8160 :   if (TREE_CODE (*tp) == LABEL_EXPR
   11426         8160 :       && (DECL_CONTEXT (LABEL_EXPR_LABEL (*tp)) == NULL_TREE
   11427            2 :           || DECL_CONTEXT (LABEL_EXPR_LABEL (*tp)) == DECL_CONTEXT (ctx)))
   11428              :     {
   11429           72 :       DECL_CONTEXT (LABEL_EXPR_LABEL (*tp)) = ctx;
   11430           72 :       *walk_subtrees = 0;
   11431              :     }
   11432              : 
   11433         8160 :   return NULL_TREE;
   11434              : }
   11435              : 
   11436              : /* Store the parameter declarations into the current function declaration.
   11437              :    This is called after parsing the parameter declarations, before
   11438              :    digesting the body of the function.
   11439              : 
   11440              :    For an old-style definition, construct a prototype out of the old-style
   11441              :    parameter declarations and inject it into the function's type.  */
   11442              : 
   11443              : void
   11444     36324546 : store_parm_decls (void)
   11445              : {
   11446     36324546 :   tree fndecl = current_function_decl;
   11447     36324546 :   bool proto;
   11448              : 
   11449              :   /* The argument information block for FNDECL.  */
   11450     36324546 :   struct c_arg_info *arg_info = current_function_arg_info;
   11451     36324546 :   current_function_arg_info = 0;
   11452              : 
   11453              :   /* True if this definition is written with a prototype.  In C23, an
   11454              :      empty argument list was converted to (void) in grokparms; in
   11455              :      older C standard versions, it does not give the function a type
   11456              :      with a prototype for future calls.  */
   11457     36324546 :   proto = arg_info->types != 0 || arg_info->no_named_args_stdarg_p;
   11458              : 
   11459        13124 :   if (proto)
   11460     36311422 :     store_parm_decls_newstyle (fndecl, arg_info);
   11461              :   else
   11462        13124 :     store_parm_decls_oldstyle (fndecl, arg_info);
   11463              : 
   11464              :   /* The next call to push_scope will be a function body.  */
   11465              : 
   11466     36324546 :   next_is_function_body = true;
   11467              : 
   11468              :   /* Write a record describing this function definition to the prototypes
   11469              :      file (if requested).  */
   11470              : 
   11471     36324546 :   gen_aux_info_record (fndecl, 1, 0, proto);
   11472              : 
   11473              :   /* Initialize the RTL code for the function.  */
   11474     36324546 :   allocate_struct_function (fndecl, false);
   11475              : 
   11476     36324546 :   if (warn_unused_local_typedefs)
   11477      3115097 :     cfun->language = ggc_cleared_alloc<language_function> ();
   11478              : 
   11479              :   /* Begin the statement tree for this function.  */
   11480     36324546 :   DECL_SAVED_TREE (fndecl) = push_stmt_list ();
   11481              : 
   11482              :   /* ??? Insert the contents of the pending sizes list into the function
   11483              :      to be evaluated.  The only reason left to have this is
   11484              :         void foo(int n, int array[n++])
   11485              :      because we throw away the array type in favor of a pointer type, and
   11486              :      thus won't naturally see the SAVE_EXPR containing the increment.  All
   11487              :      other pending sizes would be handled by gimplify_parameters.  */
   11488     36324546 :   if (arg_info->pending_sizes)
   11489              :     {
   11490              :       /* In very special circumstances, e.g. for code like
   11491              :            _Atomic int i = 5;
   11492              :            void f (int a[i += 2]) {}
   11493              :          we need to execute the atomic assignment on function entry.
   11494              :          But in this case, it is not just a straight store, it has the
   11495              :          op= form, which means that build_atomic_assign has generated
   11496              :          gotos, labels, etc.  Because at that time the function decl
   11497              :          for F has not been created yet, those labels do not have any
   11498              :          function context.  But we have the fndecl now, so update the
   11499              :          labels accordingly.  gimplify_expr would crash otherwise.
   11500              :          Or with nested functions the labels could be created with parent
   11501              :          function's context, while when the statement is emitted at the
   11502              :          start of the nested function, it needs the nested function's
   11503              :          context.  */
   11504          297 :       walk_tree_without_duplicates (&arg_info->pending_sizes,
   11505              :                                     set_labels_context_r, fndecl);
   11506          297 :       add_stmt (arg_info->pending_sizes);
   11507              :     }
   11508     36324546 : }
   11509              : 
   11510              : /* Store PARM_DECLs in PARMS into scope temporarily.  Used for
   11511              :    c_finish_omp_declare_simd for function prototypes.  No diagnostics
   11512              :    should be done.  */
   11513              : 
   11514              : void
   11515          249 : temp_store_parm_decls (tree fndecl, tree parms)
   11516              : {
   11517          249 :   push_scope ();
   11518          699 :   for (tree p = parms; p; p = DECL_CHAIN (p))
   11519              :     {
   11520          450 :       DECL_CONTEXT (p) = fndecl;
   11521          450 :       if (DECL_NAME (p))
   11522          328 :         bind (DECL_NAME (p), p, current_scope,
   11523              :               /*invisible=*/false, /*nested=*/false,
   11524              :               UNKNOWN_LOCATION);
   11525              :     }
   11526          249 : }
   11527              : 
   11528              : /* Undo what temp_store_parm_decls did.  */
   11529              : 
   11530              : void
   11531          249 : temp_pop_parm_decls (void)
   11532              : {
   11533              :   /* Clear all bindings in this temporary scope, so that
   11534              :      pop_scope doesn't create a BLOCK.  */
   11535          249 :   struct c_binding *b = current_scope->bindings;
   11536          249 :   current_scope->bindings = NULL;
   11537          582 :   for (; b; b = free_binding_and_advance (b))
   11538              :     {
   11539          333 :       gcc_assert (TREE_CODE (b->decl) == PARM_DECL
   11540              :                   || b->decl == error_mark_node);
   11541          333 :       gcc_assert (I_SYMBOL_BINDING (b->id) == b);
   11542          333 :       I_SYMBOL_BINDING (b->id) = b->shadowed;
   11543          333 :       if (b->shadowed && b->shadowed->u.type)
   11544            0 :         TREE_TYPE (b->shadowed->decl) = b->shadowed->u.type;
   11545              :     }
   11546          249 :   pop_scope ();
   11547          249 : }
   11548              : 
   11549              : 
   11550              : /* Finish up a function declaration and compile that function
   11551              :    all the way to assembler language output.  Then free the storage
   11552              :    for the function definition.
   11553              : 
   11554              :    This is called after parsing the body of the function definition.  */
   11555              : 
   11556              : void
   11557     36324544 : finish_function (location_t end_loc)
   11558              : {
   11559     36324544 :   tree fndecl = current_function_decl;
   11560              : 
   11561     36324544 :   if (c_dialect_objc ())
   11562            0 :     objc_finish_function ();
   11563              : 
   11564     36324544 :   if (DECL_INITIAL (fndecl) && DECL_INITIAL (fndecl) != error_mark_node)
   11565     36324542 :     BLOCK_SUPERCONTEXT (DECL_INITIAL (fndecl)) = fndecl;
   11566              : 
   11567              :   /* Must mark the RESULT_DECL as being in this function.  */
   11568              : 
   11569     36324544 :   if (DECL_RESULT (fndecl) && DECL_RESULT (fndecl) != error_mark_node)
   11570     36324544 :     DECL_CONTEXT (DECL_RESULT (fndecl)) = fndecl;
   11571              : 
   11572     36372129 :   if (MAIN_NAME_P (DECL_NAME (fndecl)) && !TREE_THIS_VOLATILE (fndecl)
   11573        47584 :       && TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (fndecl)))
   11574     36372128 :       == integer_type_node && flag_isoc99)
   11575              :     {
   11576              :       /* Hack.  We don't want the middle-end to warn that this return
   11577              :          is unreachable, so we mark its location as special.  Using
   11578              :          UNKNOWN_LOCATION has the problem that it gets clobbered in
   11579              :          annotate_one_with_locus.  A cleaner solution might be to
   11580              :          ensure ! should_carry_locus_p (stmt), but that needs a flag.
   11581              :       */
   11582        46196 :       c_finish_return (BUILTINS_LOCATION, integer_zero_node, NULL_TREE);
   11583              :     }
   11584              : 
   11585              :   /* Tie off the statement tree for this function.  */
   11586     36324544 :   DECL_SAVED_TREE (fndecl) = pop_stmt_list (DECL_SAVED_TREE (fndecl));
   11587              : 
   11588     36324544 :   finish_fname_decls ();
   11589              : 
   11590              :   /* Complain if there's no return statement only if option specified on
   11591              :      command line.  */
   11592     36324544 :   if (warn_return_type > 0
   11593      3115120 :       && TREE_CODE (TREE_TYPE (TREE_TYPE (fndecl))) != VOID_TYPE
   11594      2919205 :       && !current_function_returns_value && !current_function_returns_null
   11595              :       /* Don't complain if we are no-return.  */
   11596           72 :       && !current_function_returns_abnormally
   11597              :       /* Don't complain if we are declared noreturn.  */
   11598           21 :       && !TREE_THIS_VOLATILE (fndecl)
   11599              :       /* Don't warn for main().  */
   11600           18 :       && !MAIN_NAME_P (DECL_NAME (fndecl))
   11601              :       /* Or if they didn't actually specify a return type.  */
   11602           17 :       && !C_FUNCTION_IMPLICIT_INT (fndecl)
   11603              :       /* Normally, with -Wreturn-type, flow will complain, but we might
   11604              :          optimize out static functions.  */
   11605           17 :       && !TREE_PUBLIC (fndecl)
   11606            6 :       && targetm.warn_func_return (fndecl)
   11607     39439664 :       && warning (OPT_Wreturn_type,
   11608              :                   "no return statement in function returning non-void"))
   11609            5 :     suppress_warning (fndecl, OPT_Wreturn_type);
   11610              : 
   11611              :   /* Complain about parameters that are only set, but never otherwise used.  */
   11612     36324544 :   if (warn_unused_but_set_parameter)
   11613              :     {
   11614      3050254 :       tree decl;
   11615              : 
   11616      3050254 :       for (decl = DECL_ARGUMENTS (fndecl);
   11617     11398032 :            decl;
   11618      8347778 :            decl = DECL_CHAIN (decl))
   11619      8347778 :         if (TREE_USED (decl)
   11620      8287075 :             && TREE_CODE (decl) == PARM_DECL
   11621      8287075 :             && !DECL_READ_P (decl)
   11622           47 :             && DECL_NAME (decl)
   11623           47 :             && !DECL_ARTIFICIAL (decl)
   11624      8347825 :             && !warning_suppressed_p (decl, OPT_Wunused_but_set_parameter_))
   11625           47 :           warning_at (DECL_SOURCE_LOCATION (decl),
   11626           47 :                       OPT_Wunused_but_set_parameter_,
   11627              :                       "parameter %qD set but not used", decl);
   11628              :     }
   11629              : 
   11630              :   /* Complain about locally defined typedefs that are not used in this
   11631              :      function.  */
   11632     36324544 :   maybe_warn_unused_local_typedefs ();
   11633              : 
   11634              :   /* Possibly warn about unused parameters.  */
   11635     36324544 :   if (warn_unused_parameter)
   11636      2956365 :     do_warn_unused_parameter (fndecl);
   11637              : 
   11638              :   /* Store the end of the function, so that we get good line number
   11639              :      info for the epilogue.  */
   11640     36324544 :   cfun->function_end_locus = end_loc;
   11641              : 
   11642              :   /* Finalize the ELF visibility for the function.  */
   11643     36324544 :   c_determine_visibility (fndecl);
   11644              : 
   11645              :   /* For GNU C extern inline functions disregard inline limits.  */
   11646     36324544 :   if (DECL_EXTERNAL (fndecl)
   11647     35469653 :       && DECL_DECLARED_INLINE_P (fndecl)
   11648     71794194 :       && (flag_gnu89_inline
   11649     35438646 :           || lookup_attribute ("gnu_inline", DECL_ATTRIBUTES (fndecl))))
   11650     35469168 :     DECL_DISREGARD_INLINE_LIMITS (fndecl) = 1;
   11651              : 
   11652              :   /* Genericize before inlining.  Delay genericizing nested functions
   11653              :      until their parent function is genericized.  Since finalizing
   11654              :      requires GENERIC, delay that as well.  */
   11655              : 
   11656     72649088 :   if (DECL_INITIAL (fndecl) && DECL_INITIAL (fndecl) != error_mark_node
   11657     72649086 :       && !undef_nested_function)
   11658              :     {
   11659     36324536 :       if (!decl_function_context (fndecl))
   11660              :         {
   11661     36322942 :           invoke_plugin_callbacks (PLUGIN_PRE_GENERICIZE, fndecl);
   11662     36322942 :           c_genericize (fndecl);
   11663              : 
   11664              :           /* ??? Objc emits functions after finalizing the compilation unit.
   11665              :              This should be cleaned up later and this conditional removed.  */
   11666     36322942 :           if (symtab->global_info_ready)
   11667              :             {
   11668            0 :               cgraph_node::add_new_function (fndecl, false);
   11669            0 :               return;
   11670              :             }
   11671     36322942 :           cgraph_node::finalize_function (fndecl, false);
   11672              :         }
   11673              :       else
   11674              :         {
   11675              :           /* Register this function with cgraph just far enough to get it
   11676              :             added to our parent's nested function list.  Handy, since the
   11677              :             C front end doesn't have such a list.  */
   11678         1594 :           (void) cgraph_node::get_create (fndecl);
   11679              :         }
   11680              :     }
   11681              : 
   11682     36324544 :   if (!decl_function_context (fndecl))
   11683     36322950 :     undef_nested_function = false;
   11684              : 
   11685     36324544 :   if (cfun->language != NULL)
   11686              :     {
   11687      3115096 :       ggc_free (cfun->language);
   11688      3115096 :       cfun->language = NULL;
   11689              :     }
   11690              : 
   11691              :   /* We're leaving the context of this function, so zap cfun.
   11692              :      It's still in DECL_STRUCT_FUNCTION, and we'll restore it in
   11693              :      tree_rest_of_compilation.  */
   11694     36324544 :   set_cfun (NULL);
   11695     36324544 :   invoke_plugin_callbacks (PLUGIN_FINISH_PARSE_FUNCTION, current_function_decl);
   11696     36324544 :   current_function_decl = NULL;
   11697              : }
   11698              : 
   11699              : /* Check the declarations given in a for-loop for satisfying the C99
   11700              :    constraints.  If exactly one such decl is found, return it.  LOC is
   11701              :    the location of the opening parenthesis of the for loop.  The last
   11702              :    parameter allows you to control the "for loop initial declarations
   11703              :    are only allowed in C99 mode".  Normally, you should pass
   11704              :    flag_isoc99 as that parameter.  But in some cases (Objective-C
   11705              :    foreach loop, for example) we want to run the checks in this
   11706              :    function even if not in C99 mode, so we allow the caller to turn
   11707              :    off the error about not being in C99 mode.
   11708              : */
   11709              : 
   11710              : tree
   11711        25861 : check_for_loop_decls (location_t loc, bool turn_off_iso_c99_error)
   11712              : {
   11713        25861 :   struct c_binding *b;
   11714        25861 :   tree one_decl = NULL_TREE;
   11715        25861 :   int n_decls = 0;
   11716              : 
   11717        25861 :   if (!turn_off_iso_c99_error)
   11718              :     {
   11719            1 :       static bool hint = true;
   11720              :       /* If we get here, declarations have been used in a for loop without
   11721              :          the C99 for loop scope.  This doesn't make much sense, so don't
   11722              :          allow it.  */
   11723            1 :       auto_diagnostic_group d;
   11724            1 :       error_at (loc, "%<for%> loop initial declarations "
   11725              :                 "are only allowed in C99 or C11 mode");
   11726            1 :       if (hint)
   11727              :         {
   11728            1 :           inform (loc,
   11729              :                   "use option %<-std=c99%>, %<-std=gnu99%>, %<-std=c11%> or "
   11730              :                   "%<-std=gnu11%> to compile your code");
   11731            1 :           hint = false;
   11732              :         }
   11733            1 :       return NULL_TREE;
   11734            1 :     }
   11735              :   else
   11736        25860 :     pedwarn_c90 (loc, OPT_Wpedantic, "ISO C90 does not support %<for%> loop "
   11737              :                  "initial declarations");
   11738              : 
   11739              :   /* C99 subclause 6.8.5 paragraph 3:
   11740              : 
   11741              :        [#3]  The  declaration  part  of  a for statement shall only
   11742              :        declare identifiers for objects having storage class auto or
   11743              :        register.
   11744              : 
   11745              :      It isn't clear whether, in this sentence, "identifiers" binds to
   11746              :      "shall only declare" or to "objects" - that is, whether all identifiers
   11747              :      declared must be identifiers for objects, or whether the restriction
   11748              :      only applies to those that are.  (A question on this in comp.std.c
   11749              :      in November 2000 received no answer.)  We implement the strictest
   11750              :      interpretation, to avoid creating an extension which later causes
   11751              :      problems.
   11752              : 
   11753              :      This constraint was removed in C23.  */
   11754              : 
   11755        51795 :   for (b = current_scope->bindings; b; b = b->prev)
   11756              :     {
   11757        25935 :       tree id = b->id;
   11758        25935 :       tree decl = b->decl;
   11759              : 
   11760        25935 :       if (!id)
   11761           27 :         continue;
   11762              : 
   11763        25908 :       switch (TREE_CODE (decl))
   11764              :         {
   11765        25860 :         case VAR_DECL:
   11766        25860 :           {
   11767        25860 :             location_t decl_loc = DECL_SOURCE_LOCATION (decl);
   11768        25860 :             if (TREE_STATIC (decl))
   11769            5 :               pedwarn_c11 (decl_loc, OPT_Wpedantic,
   11770              :                            "declaration of static variable %qD in %<for%> "
   11771              :                            "loop initial declaration", decl);
   11772        25855 :             else if (DECL_EXTERNAL (decl))
   11773            5 :               pedwarn_c11 (decl_loc, OPT_Wpedantic,
   11774              :                            "declaration of %<extern%> variable %qD in %<for%> "
   11775              :                            "loop initial declaration", decl);
   11776              :           }
   11777              :           break;
   11778              : 
   11779            6 :         case RECORD_TYPE:
   11780            6 :           pedwarn_c11 (loc, OPT_Wpedantic,
   11781              :                        "%<struct %E%> declared in %<for%> loop initial "
   11782              :                        "declaration", id);
   11783            6 :           break;
   11784            5 :         case UNION_TYPE:
   11785            5 :           pedwarn_c11 (loc, OPT_Wpedantic,
   11786              :                        "%<union %E%> declared in %<for%> loop initial "
   11787              :                        "declaration",
   11788              :                        id);
   11789            5 :           break;
   11790            5 :         case ENUMERAL_TYPE:
   11791            5 :           pedwarn_c11 (loc, OPT_Wpedantic,
   11792              :                        "%<enum %E%> declared in %<for%> loop "
   11793              :                        "initial declaration", id);
   11794            5 :           break;
   11795           32 :         default:
   11796           32 :           pedwarn_c11 (loc, OPT_Wpedantic, "declaration of non-variable "
   11797              :                        "%qD in %<for%> loop initial declaration", decl);
   11798              :         }
   11799              : 
   11800        25908 :       n_decls++;
   11801        25908 :       one_decl = decl;
   11802              :     }
   11803              : 
   11804        25860 :   return n_decls == 1 ? one_decl : NULL_TREE;
   11805              : }
   11806              : 
   11807              : /* Save and reinitialize the variables
   11808              :    used during compilation of a C function.  */
   11809              : 
   11810              : void
   11811         1622 : c_push_function_context (void)
   11812              : {
   11813         1622 :   struct language_function *p = cfun->language;
   11814              :   /* cfun->language might have been already allocated by the use of
   11815              :      -Wunused-local-typedefs.  In that case, just re-use it.  */
   11816         1622 :   if (p == NULL)
   11817         1566 :     cfun->language = p = ggc_cleared_alloc<language_function> ();
   11818              : 
   11819         1622 :   p->base.x_stmt_tree = c_stmt_tree;
   11820         1622 :   c_stmt_tree.x_cur_stmt_list = vec_safe_copy (c_stmt_tree.x_cur_stmt_list);
   11821         1622 :   p->x_in_statement = in_statement;
   11822         1622 :   p->x_switch_stack = c_switch_stack;
   11823         1622 :   p->loop_names = loop_names;
   11824         1622 :   loop_names = vNULL;
   11825         1622 :   p->loop_names_hash = loop_names_hash;
   11826         1622 :   loop_names_hash = NULL;
   11827         1622 :   p->arg_info = current_function_arg_info;
   11828         1622 :   p->returns_value = current_function_returns_value;
   11829         1622 :   p->returns_null = current_function_returns_null;
   11830         1622 :   p->returns_abnormally = current_function_returns_abnormally;
   11831         1622 :   p->warn_about_return_type = warn_about_return_type;
   11832              : 
   11833         1622 :   push_function_context ();
   11834         1622 : }
   11835              : 
   11836              : /* Restore the variables used during compilation of a C function.  */
   11837              : 
   11838              : void
   11839         1622 : c_pop_function_context (void)
   11840              : {
   11841         1622 :   struct language_function *p;
   11842              : 
   11843         1622 :   pop_function_context ();
   11844         1622 :   p = cfun->language;
   11845              : 
   11846              :   /* When -Wunused-local-typedefs is in effect, cfun->languages is
   11847              :      used to store data throughout the life time of the current cfun,
   11848              :      So don't deallocate it.  */
   11849         1622 :   if (!warn_unused_local_typedefs)
   11850         1566 :     cfun->language = NULL;
   11851              : 
   11852         1622 :   if (DECL_STRUCT_FUNCTION (current_function_decl) == 0
   11853         1622 :       && DECL_SAVED_TREE (current_function_decl) == NULL_TREE)
   11854              :     {
   11855              :       /* Stop pointing to the local nodes about to be freed.  */
   11856              :       /* But DECL_INITIAL must remain nonzero so we know this
   11857              :          was an actual function definition.  */
   11858            0 :       DECL_INITIAL (current_function_decl) = error_mark_node;
   11859            0 :       DECL_ARGUMENTS (current_function_decl) = NULL_TREE;
   11860              :     }
   11861              : 
   11862         1622 :   c_stmt_tree = p->base.x_stmt_tree;
   11863         1622 :   p->base.x_stmt_tree.x_cur_stmt_list = NULL;
   11864         1622 :   in_statement = p->x_in_statement;
   11865         1622 :   c_switch_stack = p->x_switch_stack;
   11866         1622 :   loop_names.release ();
   11867         1622 :   loop_names = p->loop_names;
   11868         1622 :   p->loop_names = vNULL;
   11869         1622 :   delete loop_names_hash;
   11870         1622 :   loop_names_hash = p->loop_names_hash;
   11871         1622 :   p->loop_names_hash = NULL;
   11872         1622 :   current_function_arg_info = p->arg_info;
   11873         1622 :   current_function_returns_value = p->returns_value;
   11874         1622 :   current_function_returns_null = p->returns_null;
   11875         1622 :   current_function_returns_abnormally = p->returns_abnormally;
   11876         1622 :   warn_about_return_type = p->warn_about_return_type;
   11877         1622 : }
   11878              : 
   11879              : /* The functions below are required for functionality of doing
   11880              :    function at once processing in the C front end. Currently these
   11881              :    functions are not called from anywhere in the C front end, but as
   11882              :    these changes continue, that will change.  */
   11883              : 
   11884              : /* Returns the stmt_tree (if any) to which statements are currently
   11885              :    being added.  If there is no active statement-tree, NULL is
   11886              :    returned.  */
   11887              : 
   11888              : stmt_tree
   11889    985755041 : current_stmt_tree (void)
   11890              : {
   11891    985755041 :   return &c_stmt_tree;
   11892              : }
   11893              : 
   11894              : /* Return the global value of T as a symbol.  */
   11895              : 
   11896              : tree
   11897      3927826 : identifier_global_value (tree t)
   11898              : {
   11899      3927826 :   struct c_binding *b;
   11900              : 
   11901      3928793 :   for (b = I_SYMBOL_BINDING (t); b; b = b->shadowed)
   11902      3921564 :     if (B_IN_FILE_SCOPE (b) || B_IN_EXTERNAL_SCOPE (b))
   11903      3920597 :       return b->decl;
   11904              : 
   11905              :   return NULL_TREE;
   11906              : }
   11907              : 
   11908              : /* Return the global value of tag T as a symbol.  */
   11909              : 
   11910              : tree
   11911           12 : identifier_global_tag (tree t)
   11912              : {
   11913           12 :   struct c_binding *b;
   11914              : 
   11915           12 :   for (b = I_TAG_BINDING (t); b; b = b->shadowed)
   11916           11 :     if (B_IN_FILE_SCOPE (b) || B_IN_EXTERNAL_SCOPE (b))
   11917           11 :       return b->decl;
   11918              : 
   11919              :   return NULL_TREE;
   11920              : }
   11921              : 
   11922              : /* Returns non-zero (result of __has_builtin) if NAME refers to a built-in
   11923              :    function or function-like operator.  */
   11924              : 
   11925              : int
   11926        25022 : names_builtin_p (const char *name)
   11927              : {
   11928        25022 :   tree id = get_identifier (name);
   11929        25022 :   if (tree decl = identifier_global_value (id))
   11930        24937 :     return TREE_CODE (decl) == FUNCTION_DECL && DECL_IS_UNDECLARED_BUILTIN (decl);
   11931              : 
   11932              :   /* Also detect common reserved C words that aren't strictly built-in
   11933              :      functions.  */
   11934           85 :   switch (C_RID_CODE (id))
   11935              :     {
   11936              :     case RID_BUILTIN_ASSOC_BARRIER:
   11937              :     case RID_BUILTIN_CONVERTVECTOR:
   11938              :     case RID_BUILTIN_HAS_ATTRIBUTE:
   11939              :     case RID_BUILTIN_SHUFFLE:
   11940              :     case RID_BUILTIN_SHUFFLEVECTOR:
   11941              :     case RID_BUILTIN_STDC:
   11942              :     case RID_BUILTIN_COUNTED_BY_REF:
   11943              :     case RID_CHOOSE_EXPR:
   11944              :     case RID_OFFSETOF:
   11945              :     case RID_TYPES_COMPATIBLE_P:
   11946              :     case RID_C23_VA_START:
   11947              :     case RID_VA_ARG:
   11948              :       return 1;
   11949           64 :     default:
   11950           64 :       break;
   11951              :     }
   11952              : 
   11953           64 :   return 0;
   11954              : }
   11955              : 
   11956              : /* In C, the only C-linkage public declaration is at file scope.  */
   11957              : 
   11958              : tree
   11959            5 : c_linkage_bindings (tree name)
   11960              : {
   11961            5 :   return identifier_global_value (name);
   11962              : }
   11963              : 
   11964              : /* Record a builtin type for C.  If NAME is non-NULL, it is the name used;
   11965              :    otherwise the name is found in ridpointers from RID_INDEX.  */
   11966              : 
   11967              : void
   11968      3336150 : record_builtin_type (enum rid rid_index, const char *name, tree type)
   11969              : {
   11970      3336150 :   tree id, decl;
   11971      3336150 :   if (name == 0)
   11972      1556870 :     id = ridpointers[(int) rid_index];
   11973              :   else
   11974      1779280 :     id = get_identifier (name);
   11975      3336150 :   decl = build_decl (UNKNOWN_LOCATION, TYPE_DECL, id, type);
   11976      3336150 :   pushdecl (decl);
   11977      3336150 :   if (debug_hooks->type_decl)
   11978      3336150 :     debug_hooks->type_decl (decl, false);
   11979      3336150 : }
   11980              : 
   11981              : /* Return a c_parm structure with the given SPECS, ATTRS and DECLARATOR.  */
   11982              : 
   11983              : struct c_parm *
   11984    124090062 : build_c_parm (struct c_declspecs *specs, tree attrs,
   11985              :               struct c_declarator *declarator,
   11986              :               location_t loc)
   11987              : {
   11988    124090062 :   struct c_parm *ret = XOBNEW (&parser_obstack, struct c_parm);
   11989    124090062 :   ret->specs = specs;
   11990    124090062 :   ret->attrs = attrs;
   11991    124090062 :   ret->declarator = declarator;
   11992    124090062 :   ret->loc = loc;
   11993    124090062 :   return ret;
   11994              : }
   11995              : 
   11996              : /* Return a declarator with nested attributes.  TARGET is the inner
   11997              :    declarator to which these attributes apply.  ATTRS are the
   11998              :    attributes.  */
   11999              : 
   12000              : struct c_declarator *
   12001         6788 : build_attrs_declarator (tree attrs, struct c_declarator *target)
   12002              : {
   12003         6788 :   struct c_declarator *ret = XOBNEW (&parser_obstack, struct c_declarator);
   12004         6788 :   ret->kind = cdk_attrs;
   12005         6788 :   ret->declarator = target;
   12006         6788 :   ret->u.attrs = attrs;
   12007         6788 :   return ret;
   12008              : }
   12009              : 
   12010              : /* Return a declarator for a function with arguments specified by ARGS
   12011              :    and return type specified by TARGET.  */
   12012              : 
   12013              : struct c_declarator *
   12014     50582361 : build_function_declarator (struct c_arg_info *args,
   12015              :                            struct c_declarator *target)
   12016              : {
   12017     50582361 :   struct c_declarator *ret = XOBNEW (&parser_obstack, struct c_declarator);
   12018     50582361 :   ret->kind = cdk_function;
   12019     50582361 :   ret->declarator = target;
   12020     50582361 :   ret->u.arg_info = args;
   12021     50582361 :   return ret;
   12022              : }
   12023              : 
   12024              : /* Return a declarator for the identifier IDENT (which may be
   12025              :    NULL_TREE for an abstract declarator).  */
   12026              : 
   12027              : struct c_declarator *
   12028    314266820 : build_id_declarator (tree ident)
   12029              : {
   12030    314266820 :   struct c_declarator *ret = XOBNEW (&parser_obstack, struct c_declarator);
   12031    314266820 :   ret->kind = cdk_id;
   12032    314266820 :   ret->declarator = 0;
   12033    314266820 :   ret->u.id.id = ident;
   12034    314266820 :   ret->u.id.attrs = NULL_TREE;
   12035              :   /* Default value - may get reset to a more precise location. */
   12036    314266820 :   ret->id_loc = input_location;
   12037    314266820 :   return ret;
   12038              : }
   12039              : 
   12040              : /* Return something to represent absolute declarators containing a *.
   12041              :    TARGET is the absolute declarator that the * contains.
   12042              :    TYPE_QUALS_ATTRS is a structure for type qualifiers and attributes
   12043              :    to apply to the pointer type.  */
   12044              : 
   12045              : struct c_declarator *
   12046     18241707 : make_pointer_declarator (struct c_declspecs *type_quals_attrs,
   12047              :                          struct c_declarator *target)
   12048              : {
   12049     18241707 :   tree attrs;
   12050     18241707 :   int quals = 0;
   12051     18241707 :   struct c_declarator *itarget = target;
   12052     18241707 :   struct c_declarator *ret = XOBNEW (&parser_obstack, struct c_declarator);
   12053     18241707 :   if (type_quals_attrs)
   12054              :     {
   12055     18241707 :       attrs = type_quals_attrs->attrs;
   12056     18241707 :       quals = quals_from_declspecs (type_quals_attrs);
   12057     18241707 :       if (attrs != NULL_TREE)
   12058         6516 :         itarget = build_attrs_declarator (attrs, target);
   12059              :     }
   12060     18241707 :   ret->kind = cdk_pointer;
   12061     18241707 :   ret->declarator = itarget;
   12062     18241707 :   ret->u.pointer_quals = quals;
   12063     18241707 :   return ret;
   12064              : }
   12065              : 
   12066              : /* Return a pointer to a structure for an empty list of declaration
   12067              :    specifiers.  */
   12068              : 
   12069              : struct c_declspecs *
   12070    455215116 : build_null_declspecs (void)
   12071              : {
   12072    455215116 :   struct c_declspecs *ret = XOBNEW (&parser_obstack, struct c_declspecs);
   12073    455215116 :   memset (ret, 0, sizeof *ret);
   12074    455215116 :   ret->align_log = -1;
   12075    455215116 :   ret->typespec_word = cts_none;
   12076    455215116 :   ret->storage_class = csc_none;
   12077    455215116 :   ret->expr_const_operands = true;
   12078    455215116 :   ret->typespec_kind = ctsk_none;
   12079    455215116 :   ret->address_space = ADDR_SPACE_GENERIC;
   12080    455215116 :   return ret;
   12081              : }
   12082              : 
   12083              : /* Add the address space ADDRSPACE to the declaration specifiers
   12084              :    SPECS, returning SPECS.  */
   12085              : 
   12086              : struct c_declspecs *
   12087          177 : declspecs_add_addrspace (location_t location,
   12088              :                          struct c_declspecs *specs, addr_space_t as)
   12089              : {
   12090          177 :   specs->non_sc_seen_p = true;
   12091          177 :   specs->declspecs_seen_p = true;
   12092          177 :   specs->non_std_attrs_seen_p = true;
   12093              : 
   12094          177 :   if (!ADDR_SPACE_GENERIC_P (specs->address_space)
   12095            0 :       && specs->address_space != as)
   12096            0 :     error ("incompatible address space qualifiers %qs and %qs",
   12097              :            c_addr_space_name (as),
   12098              :            c_addr_space_name (specs->address_space));
   12099              :   else
   12100              :     {
   12101          177 :       specs->address_space = as;
   12102          177 :       specs->locations[cdw_address_space] = location;
   12103              :     }
   12104          177 :   return specs;
   12105              : }
   12106              : 
   12107              : /* Add the type qualifier QUAL to the declaration specifiers SPECS,
   12108              :    returning SPECS.  */
   12109              : 
   12110              : struct c_declspecs *
   12111     16589852 : declspecs_add_qual (location_t loc,
   12112              :                     struct c_declspecs *specs, tree qual)
   12113              : {
   12114     16589852 :   enum rid i;
   12115     16589852 :   bool dupe = false;
   12116     16589852 :   specs->non_sc_seen_p = true;
   12117     16589852 :   specs->declspecs_seen_p = true;
   12118     16589852 :   specs->non_std_attrs_seen_p = true;
   12119     16589852 :   gcc_assert (TREE_CODE (qual) == IDENTIFIER_NODE
   12120              :               && C_IS_RESERVED_WORD (qual));
   12121     16589852 :   i = C_RID_CODE (qual);
   12122     16589852 :   location_t prev_loc = UNKNOWN_LOCATION;
   12123     16589852 :   switch (i)
   12124              :     {
   12125     13090117 :     case RID_CONST:
   12126     13090117 :       dupe = specs->const_p;
   12127     13090117 :       specs->const_p = true;
   12128     13090117 :       prev_loc = specs->locations[cdw_const];
   12129     13090117 :       specs->locations[cdw_const] = loc;
   12130     13090117 :       break;
   12131        96115 :     case RID_VOLATILE:
   12132        96115 :       dupe = specs->volatile_p;
   12133        96115 :       specs->volatile_p = true;
   12134        96115 :       prev_loc = specs->locations[cdw_volatile];
   12135        96115 :       specs->locations[cdw_volatile] = loc;
   12136        96115 :       break;
   12137      3383220 :     case RID_RESTRICT:
   12138      3383220 :       dupe = specs->restrict_p;
   12139      3383220 :       specs->restrict_p = true;
   12140      3383220 :       prev_loc = specs->locations[cdw_restrict];
   12141      3383220 :       specs->locations[cdw_restrict] = loc;
   12142      3383220 :       break;
   12143        20400 :     case RID_ATOMIC:
   12144        20400 :       dupe = specs->atomic_p;
   12145        20400 :       specs->atomic_p = true;
   12146        20400 :       prev_loc = specs->locations[cdw_atomic];
   12147        20400 :       specs->locations[cdw_atomic] = loc;
   12148        20400 :       break;
   12149            0 :     default:
   12150            0 :       gcc_unreachable ();
   12151              :     }
   12152     16589852 :   if (dupe)
   12153              :     {
   12154           56 :       bool warned = pedwarn_c90 (loc, OPT_Wpedantic,
   12155              :                                  "duplicate %qE declaration specifier", qual);
   12156           56 :       if (!warned
   12157           52 :           && warn_duplicate_decl_specifier
   12158           33 :           && prev_loc >= RESERVED_LOCATION_COUNT
   12159           33 :           && !from_macro_expansion_at (prev_loc)
   12160           77 :           && !from_macro_expansion_at (loc))
   12161           12 :         warning_at (loc, OPT_Wduplicate_decl_specifier,
   12162              :                     "duplicate %qE declaration specifier", qual);
   12163              :     }
   12164     16589852 :   return specs;
   12165              : }
   12166              : 
   12167              : /* Add the type specifier TYPE to the declaration specifiers SPECS,
   12168              :    returning SPECS.  */
   12169              : 
   12170              : struct c_declspecs *
   12171    331879358 : declspecs_add_type (location_t loc, struct c_declspecs *specs,
   12172              :                     struct c_typespec spec)
   12173              : {
   12174    331879358 :   tree type = spec.spec;
   12175    331879358 :   specs->non_sc_seen_p = true;
   12176    331879358 :   specs->declspecs_seen_p = true;
   12177    331879358 :   specs->non_std_attrs_seen_p = true;
   12178    331879358 :   specs->typespec_kind = spec.kind;
   12179    331879358 :   if (TREE_DEPRECATED (type))
   12180           56 :     specs->deprecated_p = true;
   12181    331879358 :   if (TREE_UNAVAILABLE (type))
   12182           40 :     specs->unavailable_p = true;
   12183              : 
   12184              :   /* As a type specifier is present, "auto" must be used as a storage
   12185              :      class specifier, not for type deduction.  */
   12186    331879358 :   if (specs->c23_auto_p)
   12187              :     {
   12188          115 :       specs->c23_auto_p = false;
   12189          115 :       if (specs->storage_class != csc_none)
   12190            1 :         error ("multiple storage classes in declaration specifiers");
   12191          114 :       else if (specs->thread_p)
   12192            1 :         error ("%qs used with %<auto%>",
   12193            1 :                specs->thread_gnu_p ? "__thread" : "_Thread_local");
   12194          113 :       else if (specs->constexpr_p)
   12195              :         /* auto may only be used with another storage class specifier,
   12196              :            such as constexpr, if the type is inferred.  */
   12197            2 :         error ("%<auto%> used with %<constexpr%>");
   12198              :       else
   12199          111 :         specs->storage_class = csc_auto;
   12200              :     }
   12201              : 
   12202              :   /* Handle type specifier keywords.  */
   12203    331879358 :   if (TREE_CODE (type) == IDENTIFIER_NODE
   12204     82577564 :       && C_IS_RESERVED_WORD (type)
   12205    414456922 :       && C_RID_CODE (type) != RID_CXX_COMPAT_WARN)
   12206              :     {
   12207     82577564 :       enum rid i = C_RID_CODE (type);
   12208     82577564 :       if (specs->type)
   12209              :         {
   12210           58 :           error_at (loc, "two or more data types in declaration specifiers");
   12211           58 :           return specs;
   12212              :         }
   12213     82577506 :       if ((int) i <= (int) RID_LAST_MODIFIER)
   12214              :         {
   12215              :           /* "long", "short", "signed", "unsigned", "_Complex" or "_Sat".  */
   12216     21777092 :           bool dupe = false;
   12217     21777092 :           switch (i)
   12218              :             {
   12219     10734230 :             case RID_LONG:
   12220     10734230 :               if (specs->long_long_p)
   12221              :                 {
   12222          104 :                   error_at (loc, "%<long long long%> is too long for GCC");
   12223          104 :                   break;
   12224              :                 }
   12225     10734126 :               if (specs->long_p)
   12226              :                 {
   12227      2951894 :                   if (specs->typespec_word == cts_double)
   12228              :                     {
   12229           15 :                       error_at (loc,
   12230              :                                 "both %qs and %qs in declaration specifiers",
   12231              :                                 "long long", "double");
   12232           15 :                       break;
   12233              :                     }
   12234      2951879 :                   pedwarn_c90 (loc, OPT_Wlong_long,
   12235              :                                "ISO C90 does not support %<long long%>");
   12236      2951879 :                   specs->long_long_p = 1;
   12237      2951879 :                   specs->locations[cdw_long_long] = loc;
   12238      2951879 :                   break;
   12239              :                 }
   12240      7782232 :               if (specs->short_p)
   12241           77 :                 error_at (loc,
   12242              :                           "both %qs and %qs in declaration specifiers",
   12243              :                           "long", "short");
   12244      7782155 :               else if (specs->typespec_word == cts_auto_type)
   12245            1 :                 error_at (loc,
   12246              :                           "both %qs and %qs in declaration specifiers",
   12247              :                           "long", "__auto_type");
   12248              :               else if (specs->typespec_word == cts_void)
   12249            5 :                 error_at (loc,
   12250              :                           "both %qs and %qs in declaration specifiers",
   12251              :                           "long", "void");
   12252              :               else if (specs->typespec_word == cts_int_n)
   12253           19 :                 error_at (loc,
   12254              :                           "both %qs and %<__int%d%> in declaration specifiers",
   12255           19 :                           "long", int_n_data[specs->u.int_n_idx].bitsize);
   12256              :               else if (specs->typespec_word == cts_bool)
   12257            3 :                 error_at (loc,
   12258              :                           "both %qs and %qs in declaration specifiers",
   12259              :                           "long", "_Bool");
   12260              :               else if (specs->typespec_word == cts_bitint)
   12261            3 :                 error_at (loc,
   12262              :                           "both %qs and %qs in declaration specifiers",
   12263              :                           "long", "_BitInt");
   12264              :               else if (specs->typespec_word == cts_char)
   12265           21 :                 error_at (loc,
   12266              :                           "both %qs and %qs in declaration specifiers",
   12267              :                           "long", "char");
   12268              :               else if (specs->typespec_word == cts_float)
   12269            7 :                 error_at (loc,
   12270              :                           "both %qs and %qs in declaration specifiers",
   12271              :                           "long", "float");
   12272              :               else if (specs->typespec_word == cts_floatn_nx)
   12273            0 :                 error_at (loc,
   12274              :                           "both %qs and %<_Float%d%s%> in declaration "
   12275              :                           "specifiers", "long",
   12276            0 :                           floatn_nx_types[specs->u.floatn_nx_idx].n,
   12277            0 :                           floatn_nx_types[specs->u.floatn_nx_idx].extended
   12278              :                           ? "x"
   12279              :                           : "");
   12280              :               else if (specs->typespec_word == cts_dfloat32)
   12281            4 :                 error_at (loc,
   12282              :                           "both %qs and %qs in declaration specifiers",
   12283              :                           "long", "_Decimal32");
   12284              :               else if (specs->typespec_word == cts_dfloat64)
   12285            4 :                 error_at (loc,
   12286              :                           "both %qs and %qs in declaration specifiers",
   12287              :                           "long", "_Decimal64");
   12288              :               else if (specs->typespec_word == cts_dfloat128)
   12289            4 :                 error_at (loc,
   12290              :                           "both %qs and %qs in declaration specifiers",
   12291              :                           "long", "_Decimal128");
   12292              :               else if (specs->typespec_word == cts_dfloat64x)
   12293            0 :                 error_at (loc,
   12294              :                           "both %qs and %qs in declaration specifiers",
   12295              :                           "long", "_Decimal64x");
   12296              :               else
   12297              :                 {
   12298      7782084 :                   specs->long_p = true;
   12299      7782084 :                   specs->locations[cdw_long] = loc;
   12300              :                 }
   12301              :               break;
   12302      1703629 :             case RID_SHORT:
   12303      1703629 :               dupe = specs->short_p;
   12304      1703629 :               if (specs->long_p)
   12305          197 :                 error_at (loc,
   12306              :                           "both %qs and %qs in declaration specifiers",
   12307              :                           "long", "short");
   12308      1703432 :               else if (specs->typespec_word == cts_auto_type)
   12309            1 :                 error_at (loc,
   12310              :                           "both %qs and %qs in declaration specifiers",
   12311              :                           "short", "__auto_type");
   12312              :               else if (specs->typespec_word == cts_void)
   12313            5 :                 error_at (loc,
   12314              :                           "both %qs and %qs in declaration specifiers",
   12315              :                           "short", "void");
   12316              :               else if (specs->typespec_word == cts_int_n)
   12317           19 :                 error_at (loc,
   12318              :                           "both %qs and %<__int%d%> in declaration specifiers",
   12319           19 :                           "short", int_n_data[specs->u.int_n_idx].bitsize);
   12320              :               else if (specs->typespec_word == cts_bool)
   12321            3 :                 error_at (loc,
   12322              :                           "both %qs and %qs in declaration specifiers",
   12323              :                           "short", "_Bool");
   12324              :               else if (specs->typespec_word == cts_bitint)
   12325            1 :                 error_at (loc,
   12326              :                           "both %qs and %qs in declaration specifiers",
   12327              :                           "short", "_BitInt");
   12328              :               else if (specs->typespec_word == cts_char)
   12329           21 :                 error_at (loc,
   12330              :                           "both %qs and %qs in declaration specifiers",
   12331              :                           "short", "char");
   12332              :               else if (specs->typespec_word == cts_float)
   12333            7 :                 error_at (loc,
   12334              :                           "both %qs and %qs in declaration specifiers",
   12335              :                           "short", "float");
   12336              :               else if (specs->typespec_word == cts_double)
   12337            7 :                 error_at (loc,
   12338              :                           "both %qs and %qs in declaration specifiers",
   12339              :                           "short", "double");
   12340              :               else if (specs->typespec_word == cts_floatn_nx)
   12341            0 :                 error_at (loc,
   12342              :                           "both %qs and %<_Float%d%s%> in declaration "
   12343              :                           "specifiers", "short",
   12344            0 :                           floatn_nx_types[specs->u.floatn_nx_idx].n,
   12345            0 :                           floatn_nx_types[specs->u.floatn_nx_idx].extended
   12346              :                           ? "x"
   12347              :                           : "");
   12348              :               else if (specs->typespec_word == cts_dfloat32)
   12349            4 :                 error_at (loc,
   12350              :                           "both %qs and %qs in declaration specifiers",
   12351              :                           "short", "_Decimal32");
   12352              :               else if (specs->typespec_word == cts_dfloat64)
   12353            4 :                 error_at (loc,
   12354              :                           "both %qs and %qs in declaration specifiers",
   12355              :                           "short", "_Decimal64");
   12356              :               else if (specs->typespec_word == cts_dfloat128)
   12357            4 :                 error_at (loc,
   12358              :                           "both %qs and %qs in declaration specifiers",
   12359              :                           "short", "_Decimal128");
   12360              :               else if (specs->typespec_word == cts_dfloat64x)
   12361            0 :                 error_at (loc,
   12362              :                           "both %qs and %qs in declaration specifiers",
   12363              :                           "short", "_Decimal64x");
   12364              :               else
   12365              :                 {
   12366      1703356 :                   specs->short_p = true;
   12367      1703356 :                   specs->locations[cdw_short] = loc;
   12368              :                 }
   12369              :               break;
   12370       574320 :             case RID_SIGNED:
   12371       574320 :               dupe = specs->signed_p;
   12372       574320 :               if (specs->unsigned_p)
   12373          138 :                 error_at (loc,
   12374              :                           "both %qs and %qs in declaration specifiers",
   12375              :                           "signed", "unsigned");
   12376       574182 :               else if (specs->typespec_word == cts_auto_type)
   12377            1 :                 error_at (loc,
   12378              :                           "both %qs and %qs in declaration specifiers",
   12379              :                           "signed", "__auto_type");
   12380              :               else if (specs->typespec_word == cts_void)
   12381            5 :                 error_at (loc,
   12382              :                           "both %qs and %qs in declaration specifiers",
   12383              :                           "signed", "void");
   12384              :               else if (specs->typespec_word == cts_bool)
   12385            3 :                 error_at (loc,
   12386              :                           "both %qs and %qs in declaration specifiers",
   12387              :                           "signed", "_Bool");
   12388              :               else if (specs->typespec_word == cts_float)
   12389            7 :                 error_at (loc,
   12390              :                           "both %qs and %qs in declaration specifiers",
   12391              :                           "signed", "float");
   12392              :               else if (specs->typespec_word == cts_double)
   12393           21 :                 error_at (loc,
   12394              :                           "both %qs and %qs in declaration specifiers",
   12395              :                           "signed", "double");
   12396              :               else if (specs->typespec_word == cts_floatn_nx)
   12397            0 :                 error_at (loc,
   12398              :                           "both %qs and %<_Float%d%s%> in declaration "
   12399              :                           "specifiers", "signed",
   12400            0 :                           floatn_nx_types[specs->u.floatn_nx_idx].n,
   12401            0 :                           floatn_nx_types[specs->u.floatn_nx_idx].extended
   12402              :                           ? "x"
   12403              :                           : "");
   12404              :               else if (specs->typespec_word == cts_dfloat32)
   12405            4 :                 error_at (loc,
   12406              :                           "both %qs and %qs in declaration specifiers",
   12407              :                           "signed", "_Decimal32");
   12408              :               else if (specs->typespec_word == cts_dfloat64)
   12409            4 :                 error_at (loc,
   12410              :                           "both %qs and %qs in declaration specifiers",
   12411              :                           "signed", "_Decimal64");
   12412              :               else if (specs->typespec_word == cts_dfloat128)
   12413            4 :                 error_at (loc,
   12414              :                           "both %qs and %qs in declaration specifiers",
   12415              :                           "signed", "_Decimal128");
   12416              :               else if (specs->typespec_word == cts_dfloat64x)
   12417            0 :                 error_at (loc,
   12418              :                           "both %qs and %qs in declaration specifiers",
   12419              :                           "signed", "_Decimal64x");
   12420              :               else
   12421              :                 {
   12422       574133 :                   specs->signed_p = true;
   12423       574133 :                   specs->locations[cdw_signed] = loc;
   12424              :                 }
   12425              :               break;
   12426      6186672 :             case RID_UNSIGNED:
   12427      6186672 :               dupe = specs->unsigned_p;
   12428      6186672 :               if (specs->signed_p)
   12429          139 :                 error_at (loc,
   12430              :                           "both %qs and %qs in declaration specifiers",
   12431              :                           "signed", "unsigned");
   12432      6186533 :               else if (specs->typespec_word == cts_auto_type)
   12433            1 :                 error_at (loc,
   12434              :                           "both %qs and %qs in declaration specifiers",
   12435              :                           "unsigned", "__auto_type");
   12436              :               else if (specs->typespec_word == cts_void)
   12437            5 :                 error_at (loc,
   12438              :                           "both %qs and %qs in declaration specifiers",
   12439              :                           "unsigned", "void");
   12440              :               else if (specs->typespec_word == cts_bool)
   12441            3 :                 error_at (loc,
   12442              :                           "both %qs and %qs in declaration specifiers",
   12443              :                           "unsigned", "_Bool");
   12444              :               else if (specs->typespec_word == cts_float)
   12445            7 :                 error_at (loc,
   12446              :                           "both %qs and %qs in declaration specifiers",
   12447              :                           "unsigned", "float");
   12448              :               else if (specs->typespec_word == cts_double)
   12449           21 :                 error_at (loc,
   12450              :                           "both %qs and %qs in declaration specifiers",
   12451              :                           "unsigned", "double");
   12452              :               else if (specs->typespec_word == cts_floatn_nx)
   12453            0 :                 error_at (loc,
   12454              :                           "both %qs and %<_Float%d%s%> in declaration "
   12455              :                           "specifiers", "unsigned",
   12456            0 :                           floatn_nx_types[specs->u.floatn_nx_idx].n,
   12457            0 :                           floatn_nx_types[specs->u.floatn_nx_idx].extended
   12458              :                           ? "x"
   12459              :                           : "");
   12460              :               else if (specs->typespec_word == cts_dfloat32)
   12461            2 :                 error_at (loc,
   12462              :                           "both %qs and %qs in declaration specifiers",
   12463              :                           "unsigned", "_Decimal32");
   12464              :               else if (specs->typespec_word == cts_dfloat64)
   12465            2 :                 error_at (loc,
   12466              :                           "both %qs and %qs in declaration specifiers",
   12467              :                           "unsigned", "_Decimal64");
   12468              :               else if (specs->typespec_word == cts_dfloat128)
   12469            2 :                 error_at (loc,
   12470              :                           "both %qs and %qs in declaration specifiers",
   12471              :                           "unsigned", "_Decimal128");
   12472              :               else if (specs->typespec_word == cts_dfloat64x)
   12473            0 :                 error_at (loc,
   12474              :                           "both %qs and %qs in declaration specifiers",
   12475              :                           "unsigned", "_Decimal64x");
   12476              :               else
   12477              :                 {
   12478      6186490 :                   specs->unsigned_p = true;
   12479      6186490 :                   specs->locations[cdw_unsigned] = loc;
   12480              :                 }
   12481              :               break;
   12482      2578182 :             case RID_COMPLEX:
   12483      2578182 :               dupe = specs->complex_p;
   12484      2578182 :               if (!in_system_header_at (loc))
   12485        69024 :                 pedwarn_c90 (loc, OPT_Wpedantic,
   12486              :                              "ISO C90 does not support complex types");
   12487      2578182 :               if (specs->typespec_word == cts_auto_type)
   12488            1 :                 error_at (loc,
   12489              :                           "both %qs and %qs in declaration specifiers",
   12490              :                           "complex", "__auto_type");
   12491              :               else if (specs->typespec_word == cts_void)
   12492            2 :                 error_at (loc,
   12493              :                           "both %qs and %qs in declaration specifiers",
   12494              :                           "complex", "void");
   12495              :               else if (specs->typespec_word == cts_bool)
   12496            2 :                 error_at (loc,
   12497              :                           "both %qs and %qs in declaration specifiers",
   12498              :                           "complex", "_Bool");
   12499              :               else if (specs->typespec_word == cts_bitint)
   12500            1 :                 error_at (loc,
   12501              :                           "both %qs and %qs in declaration specifiers",
   12502              :                           "complex", "_BitInt");
   12503              :               else if (specs->typespec_word == cts_dfloat32)
   12504            1 :                 error_at (loc,
   12505              :                           "both %qs and %qs in declaration specifiers",
   12506              :                           "complex", "_Decimal32");
   12507              :               else if (specs->typespec_word == cts_dfloat64)
   12508            1 :                 error_at (loc,
   12509              :                           "both %qs and %qs in declaration specifiers",
   12510              :                           "complex", "_Decimal64");
   12511              :               else if (specs->typespec_word == cts_dfloat128)
   12512            1 :                 error_at (loc,
   12513              :                           "both %qs and %qs in declaration specifiers",
   12514              :                           "complex", "_Decimal128");
   12515              :               else if (specs->typespec_word == cts_dfloat64x)
   12516            0 :                 error_at (loc,
   12517              :                           "both %qs and %qs in declaration specifiers",
   12518              :                           "complex", "_Decimal64x");
   12519              :               else if (specs->typespec_word == cts_fract)
   12520            0 :                 error_at (loc,
   12521              :                           "both %qs and %qs in declaration specifiers",
   12522              :                           "complex", "_Fract");
   12523              :               else if (specs->typespec_word == cts_accum)
   12524            0 :                 error_at (loc,
   12525              :                           "both %qs and %qs in declaration specifiers",
   12526              :                           "complex", "_Accum");
   12527      2578173 :               else if (specs->saturating_p)
   12528            0 :                 error_at (loc,
   12529              :                           "both %qs and %qs in declaration specifiers",
   12530              :                           "complex", "_Sat");
   12531              :               else
   12532              :                 {
   12533      2578173 :                   specs->complex_p = true;
   12534      2578173 :                   specs->locations[cdw_complex] = loc;
   12535              :                 }
   12536              :               break;
   12537           59 :             case RID_SAT:
   12538           59 :               dupe = specs->saturating_p;
   12539           59 :               pedwarn (loc, OPT_Wpedantic,
   12540              :                        "ISO C does not support saturating types");
   12541           59 :               if (specs->typespec_word == cts_int_n)
   12542            0 :                 error_at (loc,
   12543              :                           "both %qs and %<__int%d%> in declaration specifiers",
   12544            0 :                           "_Sat", int_n_data[specs->u.int_n_idx].bitsize);
   12545              :               else if (specs->typespec_word == cts_auto_type)
   12546            0 :                 error_at (loc,
   12547              :                           "both %qs and %qs in declaration specifiers",
   12548              :                           "_Sat", "__auto_type");
   12549              :               else if (specs->typespec_word == cts_void)
   12550            0 :                 error_at (loc,
   12551              :                           "both %qs and %qs in declaration specifiers",
   12552              :                           "_Sat", "void");
   12553              :               else if (specs->typespec_word == cts_bool)
   12554            0 :                 error_at (loc,
   12555              :                           "both %qs and %qs in declaration specifiers",
   12556              :                           "_Sat", "_Bool");
   12557              :               else if (specs->typespec_word == cts_bitint)
   12558            0 :                 error_at (loc,
   12559              :                           "both %qs and %qs in declaration specifiers",
   12560              :                           "_Sat", "_BitInt");
   12561              :               else if (specs->typespec_word == cts_char)
   12562            0 :                 error_at (loc,
   12563              :                           "both %qs and %qs in declaration specifiers",
   12564              :                           "_Sat", "char");
   12565              :               else if (specs->typespec_word == cts_int)
   12566            0 :                 error_at (loc,
   12567              :                           "both %qs and %qs in declaration specifiers",
   12568              :                           "_Sat", "int");
   12569              :               else if (specs->typespec_word == cts_float)
   12570            0 :                 error_at (loc,
   12571              :                           "both %qs and %qs in declaration specifiers",
   12572              :                           "_Sat", "float");
   12573              :               else if (specs->typespec_word == cts_double)
   12574            0 :                 error_at (loc,
   12575              :                           "both %qs and %qs in declaration specifiers",
   12576              :                           "_Sat", "double");
   12577              :               else if (specs->typespec_word == cts_floatn_nx)
   12578            0 :                 error_at (loc,
   12579              :                           "both %qs and %<_Float%d%s%> in declaration "
   12580              :                           "specifiers", "_Sat",
   12581            0 :                           floatn_nx_types[specs->u.floatn_nx_idx].n,
   12582            0 :                           floatn_nx_types[specs->u.floatn_nx_idx].extended
   12583              :                           ? "x"
   12584              :                           : "");
   12585              :               else if (specs->typespec_word == cts_dfloat32)
   12586            0 :                 error_at (loc,
   12587              :                           "both %qs and %qs in declaration specifiers",
   12588              :                           "_Sat", "_Decimal32");
   12589              :               else if (specs->typespec_word == cts_dfloat64)
   12590            0 :                 error_at (loc,
   12591              :                           "both %qs and %qs in declaration specifiers",
   12592              :                           "_Sat", "_Decimal64");
   12593              :               else if (specs->typespec_word == cts_dfloat128)
   12594            0 :                 error_at (loc,
   12595              :                           "both %qs and %qs in declaration specifiers",
   12596              :                           "_Sat", "_Decimal128");
   12597              :               else if (specs->typespec_word == cts_dfloat64x)
   12598            0 :                 error_at (loc,
   12599              :                           "both %qs and %qs in declaration specifiers",
   12600              :                           "_Sat", "_Decimal64x");
   12601           59 :               else if (specs->complex_p)
   12602            0 :                 error_at (loc,
   12603              :                           "both %qs and %qs in declaration specifiers",
   12604              :                           "_Sat", "complex");
   12605              :               else
   12606              :                 {
   12607           59 :                   specs->saturating_p = true;
   12608           59 :                   specs->locations[cdw_saturating] = loc;
   12609              :                 }
   12610              :               break;
   12611            0 :             default:
   12612            0 :               gcc_unreachable ();
   12613              :             }
   12614              : 
   12615     21777092 :           if (dupe)
   12616          378 :             error_at (loc, "duplicate %qE", type);
   12617              : 
   12618     21777092 :           return specs;
   12619              :         }
   12620              :       else
   12621              :         {
   12622              :           /* "void", "_Bool", "char", "int", "float", "double",
   12623              :              "_FloatN", "_FloatNx", "_Decimal32", "__intN",
   12624              :              "_Decimal64", "_Decimal128", "_Fract", "_Accum", "_BitInt(N)" or
   12625              :              "__auto_type".  */
   12626     60800414 :           if (specs->typespec_word != cts_none)
   12627              :             {
   12628         2171 :               if (i == RID_BOOL)
   12629              :                 {
   12630          175 :                   auto_diagnostic_group d;
   12631          175 :                   if (specs->storage_class == csc_typedef)
   12632            4 :                     error_at (loc,
   12633              :                               "%qs cannot be defined via %<typedef%>",
   12634            2 :                               IDENTIFIER_POINTER (type));
   12635              :                   else
   12636          346 :                     error_at (loc,
   12637              :                               "%qs cannot be used here",
   12638          173 :                               IDENTIFIER_POINTER (type));
   12639          175 :                   add_note_about_new_keyword (loc, type);
   12640          175 :                 }
   12641              :               else
   12642         1996 :                 error_at (loc,
   12643              :                           "two or more data types in declaration specifiers");
   12644         2171 :               return specs;
   12645              :             }
   12646     60798243 :           switch (i)
   12647              :             {
   12648         1890 :             case RID_AUTO_TYPE:
   12649         1890 :               if (specs->long_p)
   12650            1 :                 error_at (loc,
   12651              :                           "both %qs and %qs in declaration specifiers",
   12652              :                           "long", "__auto_type");
   12653         1889 :               else if (specs->short_p)
   12654            1 :                 error_at (loc,
   12655              :                           "both %qs and %qs in declaration specifiers",
   12656              :                           "short", "__auto_type");
   12657         1888 :               else if (specs->signed_p)
   12658            1 :                 error_at (loc,
   12659              :                           "both %qs and %qs in declaration specifiers",
   12660              :                           "signed", "__auto_type");
   12661         1887 :               else if (specs->unsigned_p)
   12662            1 :                 error_at (loc,
   12663              :                           "both %qs and %qs in declaration specifiers",
   12664              :                           "unsigned", "__auto_type");
   12665         1886 :               else if (specs->complex_p)
   12666            1 :                 error_at (loc,
   12667              :                           "both %qs and %qs in declaration specifiers",
   12668              :                           "complex", "__auto_type");
   12669         1885 :               else if (specs->saturating_p)
   12670            0 :                 error_at (loc,
   12671              :                           "both %qs and %qs in declaration specifiers",
   12672              :                           "_Sat", "__auto_type");
   12673              :               else
   12674              :                 {
   12675         1885 :                   specs->typespec_word = cts_auto_type;
   12676         1885 :                   specs->locations[cdw_typespec] = loc;
   12677              :                 }
   12678         1890 :               return specs;
   12679        51786 :             case RID_INT_N_0:
   12680        51786 :             case RID_INT_N_1:
   12681        51786 :             case RID_INT_N_2:
   12682        51786 :             case RID_INT_N_3:
   12683        51786 :               specs->u.int_n_idx = i - RID_INT_N_0;
   12684        51786 :               if (!in_system_header_at (input_location)
   12685              :                   /* If the INT_N type ends in "__", and so is of the format
   12686              :                      "__intN__", don't pedwarn.  */
   12687        51786 :                   && (strncmp (IDENTIFIER_POINTER (type)
   12688        41150 :                                + (IDENTIFIER_LENGTH (type) - 2), "__", 2) != 0))
   12689        41150 :                 pedwarn (loc, OPT_Wpedantic,
   12690              :                          "ISO C does not support %<__int%d%> types",
   12691        41150 :                          int_n_data[specs->u.int_n_idx].bitsize);
   12692              : 
   12693        51786 :               if (specs->long_p)
   12694           53 :                 error_at (loc,
   12695              :                           "both %<__int%d%> and %qs in declaration specifiers",
   12696           53 :                           int_n_data[specs->u.int_n_idx].bitsize, "long");
   12697        51733 :               else if (specs->saturating_p)
   12698            0 :                 error_at (loc,
   12699              :                           "both %qs and %<__int%d%> in declaration specifiers",
   12700            0 :                           "_Sat", int_n_data[specs->u.int_n_idx].bitsize);
   12701        51733 :               else if (specs->short_p)
   12702           19 :                 error_at (loc,
   12703              :                           "both %<__int%d%> and %qs in declaration specifiers",
   12704           19 :                           int_n_data[specs->u.int_n_idx].bitsize, "short");
   12705        51714 :               else if (! int_n_enabled_p[specs->u.int_n_idx])
   12706              :                 {
   12707            0 :                   specs->typespec_word = cts_int_n;
   12708            0 :                   error_at (loc,
   12709              :                             "%<__int%d%> is not supported on this target",
   12710            0 :                             int_n_data[specs->u.int_n_idx].bitsize);
   12711              :                 }
   12712              :               else
   12713              :                 {
   12714        51714 :                   specs->typespec_word = cts_int_n;
   12715        51714 :                   specs->locations[cdw_typespec] = loc;
   12716              :                 }
   12717        51786 :               return specs;
   12718      7856923 :             case RID_VOID:
   12719      7856923 :               if (specs->long_p)
   12720           44 :                 error_at (loc,
   12721              :                           "both %qs and %qs in declaration specifiers",
   12722              :                           "long", "void");
   12723      7856879 :               else if (specs->short_p)
   12724           21 :                 error_at (loc,
   12725              :                           "both %qs and %qs in declaration specifiers",
   12726              :                           "short", "void");
   12727      7856858 :               else if (specs->signed_p)
   12728            5 :                 error_at (loc,
   12729              :                           "both %qs and %qs in declaration specifiers",
   12730              :                           "signed", "void");
   12731      7856853 :               else if (specs->unsigned_p)
   12732            5 :                 error_at (loc,
   12733              :                           "both %qs and %qs in declaration specifiers",
   12734              :                           "unsigned", "void");
   12735      7856848 :               else if (specs->complex_p)
   12736            2 :                 error_at (loc,
   12737              :                           "both %qs and %qs in declaration specifiers",
   12738              :                           "complex", "void");
   12739      7856846 :               else if (specs->saturating_p)
   12740            0 :                 error_at (loc,
   12741              :                           "both %qs and %qs in declaration specifiers",
   12742              :                           "_Sat", "void");
   12743              :               else
   12744              :                 {
   12745      7856846 :                   specs->typespec_word = cts_void;
   12746      7856846 :                   specs->locations[cdw_typespec] = loc;
   12747              :                 }
   12748      7856923 :               return specs;
   12749        86033 :             case RID_BOOL:
   12750        86033 :               if (!in_system_header_at (loc))
   12751        71550 :                 pedwarn_c90 (loc, OPT_Wpedantic,
   12752              :                              "ISO C90 does not support boolean types");
   12753        86033 :               if (specs->long_p)
   12754           27 :                 error_at (loc,
   12755              :                           "both %qs and %qs in declaration specifiers",
   12756              :                           "long", "_Bool");
   12757        86006 :               else if (specs->short_p)
   12758           11 :                 error_at (loc,
   12759              :                           "both %qs and %qs in declaration specifiers",
   12760              :                           "short", "_Bool");
   12761        85995 :               else if (specs->signed_p)
   12762            3 :                 error_at (loc,
   12763              :                           "both %qs and %qs in declaration specifiers",
   12764              :                           "signed", "_Bool");
   12765        85992 :               else if (specs->unsigned_p)
   12766            3 :                 error_at (loc,
   12767              :                           "both %qs and %qs in declaration specifiers",
   12768              :                           "unsigned", "_Bool");
   12769        85989 :               else if (specs->complex_p)
   12770            2 :                 error_at (loc,
   12771              :                           "both %qs and %qs in declaration specifiers",
   12772              :                           "complex", "_Bool");
   12773        85987 :               else if (specs->saturating_p)
   12774            0 :                 error_at (loc,
   12775              :                           "both %qs and %qs in declaration specifiers",
   12776              :                           "_Sat", "_Bool");
   12777              :               else
   12778              :                 {
   12779        85987 :                   specs->typespec_word = cts_bool;
   12780        85987 :                   specs->locations[cdw_typespec] = loc;
   12781              :                 }
   12782        86033 :               return specs;
   12783      9056797 :             case RID_CHAR:
   12784      9056797 :               if (specs->long_p)
   12785           44 :                 error_at (loc,
   12786              :                           "both %qs and %qs in declaration specifiers",
   12787              :                           "long", "char");
   12788      9056753 :               else if (specs->short_p)
   12789           21 :                 error_at (loc,
   12790              :                           "both %qs and %qs in declaration specifiers",
   12791              :                           "short", "char");
   12792      9056732 :               else if (specs->saturating_p)
   12793            0 :                 error_at (loc,
   12794              :                           "both %qs and %qs in declaration specifiers",
   12795              :                           "_Sat", "char");
   12796              :               else
   12797              :                 {
   12798      9056732 :                   specs->typespec_word = cts_char;
   12799      9056732 :                   specs->locations[cdw_typespec] = loc;
   12800              :                 }
   12801      9056797 :               return specs;
   12802     23868652 :             case RID_INT:
   12803     23868652 :               if (specs->saturating_p)
   12804            0 :                 error_at (loc,
   12805              :                           "both %qs and %qs in declaration specifiers",
   12806              :                           "_Sat", "int");
   12807              :               else
   12808              :                 {
   12809     23868652 :                   specs->typespec_word = cts_int;
   12810     23868652 :                   specs->locations[cdw_typespec] = loc;
   12811              :                 }
   12812     23868652 :               return specs;
   12813      3392023 :             case RID_FLOAT:
   12814      3392023 :               if (specs->long_p)
   12815           44 :                 error_at (loc,
   12816              :                           "both %qs and %qs in declaration specifiers",
   12817              :                           "long", "float");
   12818      3391979 :               else if (specs->short_p)
   12819           21 :                 error_at (loc,
   12820              :                           "both %qs and %qs in declaration specifiers",
   12821              :                           "short", "float");
   12822      3391958 :               else if (specs->signed_p)
   12823            5 :                 error_at (loc,
   12824              :                           "both %qs and %qs in declaration specifiers",
   12825              :                           "signed", "float");
   12826      3391953 :               else if (specs->unsigned_p)
   12827            5 :                 error_at (loc,
   12828              :                           "both %qs and %qs in declaration specifiers",
   12829              :                           "unsigned", "float");
   12830      3391948 :               else if (specs->saturating_p)
   12831            0 :                 error_at (loc,
   12832              :                           "both %qs and %qs in declaration specifiers",
   12833              :                           "_Sat", "float");
   12834              :               else
   12835              :                 {
   12836      3391948 :                   specs->typespec_word = cts_float;
   12837      3391948 :                   specs->locations[cdw_typespec] = loc;
   12838              :                 }
   12839      3392023 :               return specs;
   12840      6108050 :             case RID_DOUBLE:
   12841      6108050 :               if (specs->long_long_p)
   12842           22 :                 error_at (loc,
   12843              :                           "both %qs and %qs in declaration specifiers",
   12844              :                           "long long", "double");
   12845      6108028 :               else if (specs->short_p)
   12846           21 :                 error_at (loc,
   12847              :                           "both %qs and %qs in declaration specifiers",
   12848              :                           "short", "double");
   12849      6108007 :               else if (specs->signed_p)
   12850           13 :                 error_at (loc,
   12851              :                           "both %qs and %qs in declaration specifiers",
   12852              :                           "signed", "double");
   12853      6107994 :               else if (specs->unsigned_p)
   12854           13 :                 error_at (loc,
   12855              :                           "both %qs and %qs in declaration specifiers",
   12856              :                           "unsigned", "double");
   12857      6107981 :               else if (specs->saturating_p)
   12858            0 :                 error_at (loc,
   12859              :                           "both %qs and %qs in declaration specifiers",
   12860              :                           "_Sat", "double");
   12861              :               else
   12862              :                 {
   12863      6107981 :                   specs->typespec_word = cts_double;
   12864      6107981 :                   specs->locations[cdw_typespec] = loc;
   12865              :                 }
   12866      6108050 :               return specs;
   12867     10281785 :             CASE_RID_FLOATN_NX:
   12868     10281785 :               specs->u.floatn_nx_idx = i - RID_FLOATN_NX_FIRST;
   12869     10281785 :               if (!in_system_header_at (input_location))
   12870        53763 :                 pedwarn_c11 (loc, OPT_Wpedantic,
   12871              :                              "ISO C does not support the %<_Float%d%s%> type"
   12872              :                              " before C23",
   12873        53763 :                              floatn_nx_types[specs->u.floatn_nx_idx].n,
   12874        53763 :                              floatn_nx_types[specs->u.floatn_nx_idx].extended
   12875              :                              ? "x"
   12876              :                              : "");
   12877              : 
   12878     10281785 :               if (specs->long_p)
   12879            0 :                 error_at (loc,
   12880              :                           "both %qs and %<_Float%d%s%> in declaration "
   12881              :                           "specifiers", "long",
   12882            0 :                           floatn_nx_types[specs->u.floatn_nx_idx].n,
   12883            0 :                           floatn_nx_types[specs->u.floatn_nx_idx].extended
   12884              :                           ? "x"
   12885              :                           : "");
   12886     10281785 :               else if (specs->short_p)
   12887            0 :                 error_at (loc,
   12888              :                           "both %qs and %<_Float%d%s%> in declaration "
   12889              :                           "specifiers", "short",
   12890            0 :                           floatn_nx_types[specs->u.floatn_nx_idx].n,
   12891            0 :                           floatn_nx_types[specs->u.floatn_nx_idx].extended
   12892              :                           ? "x"
   12893              :                           : "");
   12894     10281785 :               else if (specs->signed_p)
   12895            0 :                 error_at (loc,
   12896              :                           "both %qs and %<_Float%d%s%> in declaration "
   12897              :                           "specifiers", "signed",
   12898            0 :                           floatn_nx_types[specs->u.floatn_nx_idx].n,
   12899            0 :                           floatn_nx_types[specs->u.floatn_nx_idx].extended
   12900              :                           ? "x"
   12901              :                           : "");
   12902     10281785 :               else if (specs->unsigned_p)
   12903            0 :                 error_at (loc,
   12904              :                           "both %qs and %<_Float%d%s%> in declaration "
   12905              :                           "specifiers", "unsigned",
   12906            0 :                           floatn_nx_types[specs->u.floatn_nx_idx].n,
   12907            0 :                           floatn_nx_types[specs->u.floatn_nx_idx].extended
   12908              :                           ? "x"
   12909              :                           : "");
   12910     10281785 :               else if (specs->saturating_p)
   12911            0 :                 error_at (loc,
   12912              :                           "both %qs and %<_Float%d%s%> in declaration "
   12913              :                           "specifiers", "_Sat",
   12914            0 :                           floatn_nx_types[specs->u.floatn_nx_idx].n,
   12915            0 :                           floatn_nx_types[specs->u.floatn_nx_idx].extended
   12916              :                           ? "x"
   12917              :                           : "");
   12918     10281785 :               else if (FLOATN_NX_TYPE_NODE (specs->u.floatn_nx_idx) == NULL_TREE)
   12919              :                 {
   12920           88 :                   specs->typespec_word = cts_floatn_nx;
   12921          176 :                   error_at (loc,
   12922              :                             "%<_Float%d%s%> is not supported on this target",
   12923           88 :                             floatn_nx_types[specs->u.floatn_nx_idx].n,
   12924           88 :                             floatn_nx_types[specs->u.floatn_nx_idx].extended
   12925              :                             ? "x"
   12926              :                             : "");
   12927              :                 }
   12928              :               else
   12929              :                 {
   12930     10281697 :                   specs->typespec_word = cts_floatn_nx;
   12931     10281697 :                   specs->locations[cdw_typespec] = loc;
   12932              :                 }
   12933     10281785 :               return specs;
   12934        47640 :             case RID_DFLOAT32:
   12935        47640 :             case RID_DFLOAT64:
   12936        47640 :             case RID_DFLOAT128:
   12937        47640 :             case RID_DFLOAT64X:
   12938        47640 :               {
   12939        47640 :                 const char *str;
   12940        47640 :                 if (i == RID_DFLOAT32)
   12941              :                   str = "_Decimal32";
   12942              :                 else if (i == RID_DFLOAT64)
   12943              :                   str = "_Decimal64";
   12944              :                 else if (i == RID_DFLOAT128)
   12945              :                   str = "_Decimal128";
   12946              :                 else
   12947        47640 :                   str = "_Decimal64x";
   12948        47640 :                 if (specs->long_long_p)
   12949           18 :                   error_at (loc,
   12950              :                             "both %qs and %qs in declaration specifiers",
   12951              :                             "long long", str);
   12952        47640 :                 if (specs->long_p)
   12953           33 :                   error_at (loc,
   12954              :                             "both %qs and %qs in declaration specifiers",
   12955              :                             "long", str);
   12956        47607 :                 else if (specs->short_p)
   12957           18 :                   error_at (loc,
   12958              :                             "both %qs and %qs in declaration specifiers",
   12959              :                             "short", str);
   12960        47589 :                 else if (specs->signed_p)
   12961            6 :                   error_at (loc,
   12962              :                             "both %qs and %qs in declaration specifiers",
   12963              :                             "signed", str);
   12964        47583 :                 else if (specs->unsigned_p)
   12965            3 :                   error_at (loc,
   12966              :                             "both %qs and %qs in declaration specifiers",
   12967              :                             "unsigned", str);
   12968        47580 :                 else if (specs->complex_p)
   12969            3 :                   error_at (loc,
   12970              :                             "both %qs and %qs in declaration specifiers",
   12971              :                             "complex", str);
   12972        47577 :                 else if (specs->saturating_p)
   12973            0 :                   error_at (loc,
   12974              :                             "both %qs and %qs in declaration specifiers",
   12975              :                             "_Sat", str);
   12976        47577 :                 else if (i == RID_DFLOAT32)
   12977        15957 :                   specs->typespec_word = cts_dfloat32;
   12978        31620 :                 else if (i == RID_DFLOAT64)
   12979        15839 :                   specs->typespec_word = cts_dfloat64;
   12980        15781 :                 else if (i == RID_DFLOAT128)
   12981        15734 :                   specs->typespec_word = cts_dfloat128;
   12982              :                 else
   12983           47 :                   specs->typespec_word = cts_dfloat64x;
   12984        47640 :                 specs->locations[cdw_typespec] = loc;
   12985              :               }
   12986        47640 :               if (!targetm.decimal_float_supported_p ())
   12987            0 :                 error_at (loc,
   12988              :                           "decimal floating-point not supported "
   12989              :                           "for this target");
   12990        47640 :               pedwarn_c11 (loc, OPT_Wpedantic,
   12991              :                            "ISO C does not support decimal floating-point "
   12992              :                            "before C23");
   12993        47640 :               return specs;
   12994           61 :             case RID_FRACT:
   12995           61 :             case RID_ACCUM:
   12996           61 :               {
   12997           61 :                 const char *str;
   12998           61 :                 if (i == RID_FRACT)
   12999              :                   str = "_Fract";
   13000              :                 else
   13001           30 :                   str = "_Accum";
   13002           61 :                 if (specs->complex_p)
   13003            0 :                   error_at (loc,
   13004              :                             "both %qs and %qs in declaration specifiers",
   13005              :                             "complex", str);
   13006           61 :                 else if (i == RID_FRACT)
   13007           31 :                     specs->typespec_word = cts_fract;
   13008              :                 else
   13009           30 :                     specs->typespec_word = cts_accum;
   13010           61 :                 specs->locations[cdw_typespec] = loc;
   13011              :               }
   13012           61 :               if (!targetm.fixed_point_supported_p ())
   13013           61 :                 error_at (loc,
   13014              :                           "fixed-point types not supported for this target");
   13015           61 :               pedwarn (loc, OPT_Wpedantic,
   13016              :                        "ISO C does not support fixed-point types");
   13017           61 :               return specs;
   13018        46603 :             case RID_BITINT:
   13019        46603 :               if (specs->long_p)
   13020            2 :                 error_at (loc,
   13021              :                           "both %qs and %qs in declaration specifiers",
   13022              :                           "long", "_BitInt");
   13023        46601 :               else if (specs->short_p)
   13024            1 :                 error_at (loc,
   13025              :                           "both %qs and %qs in declaration specifiers",
   13026              :                           "short", "_BitInt");
   13027        46600 :               else if (specs->complex_p)
   13028            1 :                 error_at (loc,
   13029              :                           "both %qs and %qs in declaration specifiers",
   13030              :                           "complex", "_BitInt");
   13031        46599 :               else if (specs->saturating_p)
   13032            0 :                 error_at (loc,
   13033              :                           "both %qs and %qs in declaration specifiers",
   13034              :                           "_Sat", "_BitInt");
   13035              :               else
   13036              :                 {
   13037        46599 :                   specs->typespec_word = cts_bitint;
   13038        46599 :                   specs->locations[cdw_typespec] = loc;
   13039        46599 :                   specs->u.bitint_prec = -1;
   13040        46599 :                   if (error_operand_p (spec.expr))
   13041            7 :                     return specs;
   13042        46599 :                   if (TREE_CODE (spec.expr) != INTEGER_CST
   13043        46599 :                       || !INTEGRAL_TYPE_P (TREE_TYPE (spec.expr)))
   13044              :                     {
   13045            1 :                       error_at (loc, "%<_BitInt%> argument is not an integer "
   13046              :                                      "constant expression");
   13047            1 :                       return specs;
   13048              :                     }
   13049        46598 :                   if (tree_int_cst_sgn (spec.expr) <= 0)
   13050              :                     {
   13051            4 :                       error_at (loc, "%<_BitInt%> argument %qE is not a "
   13052              :                                      "positive integer constant expression",
   13053              :                                 spec.expr);
   13054            4 :                       return specs;
   13055              :                     }
   13056        46594 :                   if (wi::to_widest (spec.expr) > WIDE_INT_MAX_PRECISION - 1)
   13057              :                     {
   13058            2 :                       error_at (loc, "%<_BitInt%> argument %qE is larger than "
   13059              :                                      "%<BITINT_MAXWIDTH%> %qd",
   13060              :                                 spec.expr, (int) WIDE_INT_MAX_PRECISION - 1);
   13061            2 :                       return specs;
   13062              :                     }
   13063        46592 :                   specs->u.bitint_prec = tree_to_uhwi (spec.expr);
   13064        46592 :                   struct bitint_info info;
   13065        46592 :                   if (!targetm.c.bitint_type_info (specs->u.bitint_prec,
   13066              :                                                    &info))
   13067              :                     {
   13068            0 :                       sorry_at (loc, "%<_BitInt(%d)%> is not supported on "
   13069              :                                      "this target", specs->u.bitint_prec);
   13070            0 :                       specs->u.bitint_prec = -1;
   13071            0 :                       return specs;
   13072              :                     }
   13073              :                 }
   13074        46596 :               return specs;
   13075              :             default:
   13076              :               /* ObjC reserved word "id", handled below.  */
   13077              :               break;
   13078              :             }
   13079              :         }
   13080              :     }
   13081              : 
   13082              :   /* Now we have a typedef (a TYPE_DECL node), an identifier (some
   13083              :      form of ObjC type, cases such as "int" and "long" being handled
   13084              :      above), a TYPE (struct, union, enum and typeof specifiers) or an
   13085              :      ERROR_MARK.  In none of these cases may there have previously
   13086              :      been any type specifiers.  */
   13087    249301794 :   if (specs->type || specs->typespec_word != cts_none
   13088    249301782 :       || specs->long_p || specs->short_p || specs->signed_p
   13089    249301779 :       || specs->unsigned_p || specs->complex_p)
   13090           21 :     error_at (loc, "two or more data types in declaration specifiers");
   13091    249301773 :   else if (TREE_CODE (type) == TYPE_DECL)
   13092              :     {
   13093    246022108 :       specs->type = TREE_TYPE (type);
   13094    246022108 :       if (TREE_TYPE (type) != error_mark_node)
   13095              :         {
   13096    246022093 :           mark_decl_used (type, false);
   13097    246022093 :           specs->decl_attr = DECL_ATTRIBUTES (type);
   13098    246022093 :           specs->typedef_p = true;
   13099    246022093 :           specs->explicit_signed_p = C_TYPEDEF_EXPLICITLY_SIGNED (type);
   13100    246022093 :           specs->locations[cdw_typedef] = loc;
   13101              : 
   13102              :           /* If this typedef name is defined in a struct, then a C++
   13103              :              lookup would return a different value.  */
   13104    246022093 :           if (warn_cxx_compat
   13105    246022093 :               && I_SYMBOL_BINDING (DECL_NAME (type))->in_struct)
   13106            2 :             warning_at (loc, OPT_Wc___compat,
   13107              :                         "C++ lookup of %qD would return a field, not a type",
   13108              :                         type);
   13109              : 
   13110              :           /* If we are parsing a struct, record that a struct field
   13111              :              used a typedef.  */
   13112    246022093 :           if (warn_cxx_compat && struct_parse_info != NULL)
   13113         1751 :             struct_parse_info->typedefs_seen.safe_push (type);
   13114              :         }
   13115              :     }
   13116      3279665 :   else if (TREE_CODE (type) == IDENTIFIER_NODE)
   13117              :     {
   13118            0 :       tree t = lookup_name (type);
   13119            0 :       if (!t || TREE_CODE (t) != TYPE_DECL)
   13120            0 :         error_at (loc, "%qE fails to be a typedef or built in type", type);
   13121            0 :       else if (TREE_TYPE (t) == error_mark_node)
   13122              :         ;
   13123              :       else
   13124              :         {
   13125            0 :           specs->type = TREE_TYPE (t);
   13126            0 :           specs->locations[cdw_typespec] = loc;
   13127              :         }
   13128              :     }
   13129              :   else
   13130              :     {
   13131      3279665 :       if (TREE_CODE (type) != ERROR_MARK)
   13132              :         {
   13133      3279460 :           if (spec.kind == ctsk_typeof)
   13134              :             {
   13135       833280 :               specs->typedef_p = true;
   13136       833280 :               specs->locations[cdw_typedef] = loc;
   13137              :             }
   13138              : 
   13139      3279460 :           if (TREE_CODE (type) == RECORD_TYPE || TREE_CODE (type) == UNION_TYPE
   13140      1065268 :               || TREE_CODE (type) == ENUMERAL_TYPE)
   13141      2454775 :             mark_decl_used (TYPE_STUB_DECL (type), false);
   13142              : 
   13143      3279460 :           if (spec.expr)
   13144              :             {
   13145          957 :               tree expr = save_expr (fold_convert (void_type_node, spec.expr));
   13146          957 :               if (specs->expr)
   13147            0 :                 specs->expr = build2 (COMPOUND_EXPR, TREE_TYPE (expr),
   13148              :                                       specs->expr, expr);
   13149              :               else
   13150          957 :                 specs->expr = expr;
   13151          957 :               specs->expr_const_operands &= spec.expr_const_operands;
   13152              :             }
   13153              :         }
   13154      3279665 :       specs->type = type;
   13155      3279665 :       if (spec.has_enum_type_specifier
   13156          169 :           && spec.kind != ctsk_tagdef)
   13157           49 :         specs->enum_type_specifier_ref_p = true;
   13158              :     }
   13159              : 
   13160              :   return specs;
   13161              : }
   13162              : 
   13163              : /* Add the storage class specifier or function specifier SCSPEC to the
   13164              :    declaration specifiers SPECS, returning SPECS.  */
   13165              : 
   13166              : struct c_declspecs *
   13167     90406244 : declspecs_add_scspec (location_t loc,
   13168              :                       struct c_declspecs *specs,
   13169              :                       tree scspec)
   13170              : {
   13171     90406244 :   enum rid i;
   13172     90406244 :   enum c_storage_class n = csc_none;
   13173     90406244 :   bool dupe = false;
   13174     90406244 :   specs->declspecs_seen_p = true;
   13175     90406244 :   specs->non_std_attrs_seen_p = true;
   13176     90406244 :   gcc_assert (TREE_CODE (scspec) == IDENTIFIER_NODE
   13177              :               && C_IS_RESERVED_WORD (scspec));
   13178     90406244 :   i = C_RID_CODE (scspec);
   13179     90406244 :   if (specs->non_sc_seen_p)
   13180         2096 :     warning (OPT_Wold_style_declaration,
   13181              :              "%qE is not at beginning of declaration", scspec);
   13182     90406244 :   switch (i)
   13183              :     {
   13184     35634743 :     case RID_INLINE:
   13185              :       /* C99 permits duplicate inline.  Although of doubtful utility,
   13186              :          it seems simplest to permit it in gnu89 mode as well, as
   13187              :          there is also little utility in maintaining this as a
   13188              :          difference between gnu89 and C99 inline.  */
   13189     35634743 :       dupe = false;
   13190     35634743 :       specs->inline_p = true;
   13191     35634743 :       specs->locations[cdw_inline] = loc;
   13192     35634743 :       break;
   13193        23317 :     case RID_NORETURN:
   13194              :       /* Duplicate _Noreturn is permitted.  */
   13195        23317 :       dupe = false;
   13196        23317 :       specs->noreturn_p = true;
   13197        23317 :       specs->locations[cdw_noreturn] = loc;
   13198        23317 :       break;
   13199         2865 :     case RID_THREAD:
   13200         2865 :       dupe = specs->thread_p;
   13201         2865 :       if (specs->storage_class == csc_auto)
   13202            2 :         error ("%qE used with %<auto%>", scspec);
   13203         2863 :       else if (specs->storage_class == csc_register)
   13204            3 :         error ("%qE used with %<register%>", scspec);
   13205         2860 :       else if (specs->storage_class == csc_typedef)
   13206            2 :         error ("%qE used with %<typedef%>", scspec);
   13207         2858 :       else if (specs->constexpr_p)
   13208            2 :         error ("%qE used with %<constexpr%>", scspec);
   13209              :       else
   13210              :         {
   13211         2856 :           specs->thread_p = true;
   13212         2856 :           specs->thread_gnu_p = (strcmp (IDENTIFIER_POINTER (scspec),
   13213         2856 :                                          "__thread") == 0);
   13214              :           /* A diagnostic is not required for the use of this
   13215              :              identifier in the implementation namespace; only diagnose
   13216              :              it for the C11 spelling because of existing code using
   13217              :              the other spelling.  */
   13218         2856 :           if (!specs->thread_gnu_p)
   13219              :             {
   13220          116 :               if (flag_isoc99)
   13221          113 :                 pedwarn_c99 (loc, OPT_Wpedantic,
   13222              :                              "ISO C99 does not support %qE", scspec);
   13223              :               else
   13224            3 :                 pedwarn_c99 (loc, OPT_Wpedantic,
   13225              :                              "ISO C90 does not support %qE", scspec);
   13226              :             }
   13227         2856 :           specs->locations[cdw_thread] = loc;
   13228              :         }
   13229              :       break;
   13230          262 :     case RID_AUTO:
   13231          262 :       if (flag_isoc23
   13232          223 :           && specs->typespec_kind == ctsk_none
   13233          212 :           && specs->storage_class != csc_typedef)
   13234              :         {
   13235              :           /* "auto" potentially used for type deduction.  */
   13236          211 :           if (specs->c23_auto_p)
   13237            2 :             error ("duplicate %qE", scspec);
   13238          211 :           specs->c23_auto_p = true;
   13239          211 :           return specs;
   13240              :         }
   13241           51 :       n = csc_auto;
   13242              :       /* auto may only be used with another storage class specifier,
   13243              :          such as constexpr, if the type is inferred.  */
   13244           51 :       if (specs->constexpr_p)
   13245            2 :         error ("%qE used with %<constexpr%>", scspec);
   13246              :       break;
   13247     49994620 :     case RID_EXTERN:
   13248     49994620 :       n = csc_extern;
   13249              :       /* Diagnose "__thread extern".  */
   13250     49994620 :       if (specs->thread_p && specs->thread_gnu_p)
   13251            2 :         error ("%<__thread%> before %<extern%>");
   13252              :       break;
   13253              :     case RID_REGISTER:
   13254              :       n = csc_register;
   13255              :       break;
   13256       425973 :     case RID_STATIC:
   13257       425973 :       n = csc_static;
   13258              :       /* Diagnose "__thread static".  */
   13259       425973 :       if (specs->thread_p && specs->thread_gnu_p)
   13260            1 :         error ("%<__thread%> before %<static%>");
   13261              :       break;
   13262      4320718 :     case RID_TYPEDEF:
   13263      4320718 :       n = csc_typedef;
   13264      4320718 :       if (specs->c23_auto_p)
   13265              :         {
   13266            1 :           error ("%<typedef%> used with %<auto%>");
   13267            1 :           specs->c23_auto_p = false;
   13268              :         }
   13269              :       break;
   13270          616 :     case RID_CONSTEXPR:
   13271          616 :       dupe = specs->constexpr_p;
   13272          616 :       if (specs->storage_class == csc_extern)
   13273            1 :         error ("%qE used with %<extern%>", scspec);
   13274          615 :       else if (specs->storage_class == csc_typedef)
   13275            1 :         error ("%qE used with %<typedef%>", scspec);
   13276          614 :       else if (specs->storage_class == csc_auto)
   13277              :         /* auto may only be used with another storage class specifier,
   13278              :            such as constexpr, if the type is inferred.  */
   13279            2 :         error ("%qE used with %<auto%>", scspec);
   13280          612 :       else if (specs->thread_p)
   13281            4 :         error ("%qE used with %qs", scspec,
   13282            2 :                specs->thread_gnu_p ? "__thread" : "_Thread_local");
   13283              :       else
   13284          610 :         specs->constexpr_p = true;
   13285              :       break;
   13286            0 :     default:
   13287            0 :       gcc_unreachable ();
   13288              :     }
   13289     90406039 :   if (n != csc_none && n == specs->storage_class)
   13290              :     dupe = true;
   13291     90406025 :   if (dupe)
   13292              :     {
   13293           12 :       if (i == RID_THREAD)
   13294            2 :         error ("duplicate %<_Thread_local%> or %<__thread%>");
   13295              :       else
   13296           10 :         error ("duplicate %qE", scspec);
   13297              :     }
   13298     90406033 :   if (n != csc_none)
   13299              :     {
   13300     54744492 :       if (specs->storage_class != csc_none && n != specs->storage_class)
   13301              :         {
   13302            7 :           error ("multiple storage classes in declaration specifiers");
   13303              :         }
   13304              :       else
   13305              :         {
   13306     54744485 :           specs->storage_class = n;
   13307     54744485 :           specs->locations[cdw_storage_class] = loc;
   13308     54744485 :           if (n != csc_extern && n != csc_static && specs->thread_p)
   13309              :             {
   13310            8 :               error ("%qs used with %qE",
   13311            8 :                      specs->thread_gnu_p ? "__thread" : "_Thread_local",
   13312              :                      scspec);
   13313            8 :               specs->thread_p = false;
   13314              :             }
   13315     54744485 :           if (n != csc_auto && n != csc_register && n != csc_static
   13316     54315335 :               && specs->constexpr_p)
   13317              :             {
   13318            2 :               error ("%<constexpr%> used with %qE", scspec);
   13319            2 :               specs->constexpr_p = false;
   13320              :             }
   13321              :         }
   13322              :     }
   13323              :   return specs;
   13324              : }
   13325              : 
   13326              : /* Add the attributes ATTRS to the declaration specifiers SPECS,
   13327              :    returning SPECS.  */
   13328              : 
   13329              : struct c_declspecs *
   13330     35946699 : declspecs_add_attrs (location_t loc, struct c_declspecs *specs, tree attrs)
   13331              : {
   13332     35946699 :   specs->attrs = chainon (attrs, specs->attrs);
   13333     35946699 :   specs->locations[cdw_attributes] = loc;
   13334     35946699 :   specs->declspecs_seen_p = true;
   13335              :   /* In the case of standard attributes at the start of the
   13336              :      declaration, the caller will reset this.  */
   13337     35946699 :   specs->non_std_attrs_seen_p = true;
   13338     35946699 :   return specs;
   13339              : }
   13340              : 
   13341              : /* Add an _Alignas specifier (expression ALIGN, or type whose
   13342              :    alignment is ALIGN) to the declaration specifiers SPECS, returning
   13343              :    SPECS.  */
   13344              : struct c_declspecs *
   13345          202 : declspecs_add_alignas (location_t loc,
   13346              :                        struct c_declspecs *specs, tree align)
   13347              : {
   13348          202 :   specs->alignas_p = true;
   13349          202 :   specs->locations[cdw_alignas] = loc;
   13350          202 :   if (align == error_mark_node)
   13351              :     return specs;
   13352              : 
   13353              :   /* Only accept the alignment if it's valid and greater than
   13354              :      the current one.  Zero is invalid but by C11 required to
   13355              :      be silently ignored.  */
   13356          200 :   int align_log = check_user_alignment (align, false, /* warn_zero = */false);
   13357          200 :   if (align_log > specs->align_log)
   13358          167 :     specs->align_log = align_log;
   13359              :   return specs;
   13360              : }
   13361              : 
   13362              : /* Combine "long", "short", "signed", "unsigned" and "_Complex" type
   13363              :    specifiers with any other type specifier to determine the resulting
   13364              :    type.  This is where ISO C checks on complex types are made, since
   13365              :    "_Complex long" is a prefix of the valid ISO C type "_Complex long
   13366              :    double".  Also apply postfix standard attributes to modify the type.  */
   13367              : 
   13368              : struct c_declspecs *
   13369    314286517 : finish_declspecs (struct c_declspecs *specs)
   13370              : {
   13371              :   /* If a type was specified as a whole, we have no modifiers and are
   13372              :      done.  */
   13373    314286517 :   if (specs->type != NULL_TREE)
   13374              :     {
   13375    249301727 :       gcc_assert (!specs->long_p && !specs->long_long_p && !specs->short_p
   13376              :                   && !specs->signed_p && !specs->unsigned_p
   13377              :                   && !specs->complex_p && !specs->c23_auto_p);
   13378              : 
   13379              :       /* Set a dummy type.  */
   13380    249301727 :       if (TREE_CODE (specs->type) == ERROR_MARK)
   13381          183 :         specs->type = integer_type_node;
   13382    249301727 :       goto handle_postfix_attrs;
   13383              :     }
   13384              : 
   13385              :   /* If none of "void", "_Bool", "char", "int", "float" or "double"
   13386              :      has been specified, treat it as "int" unless "_Complex" is
   13387              :      present and there are no other specifiers.  If we just have
   13388              :      "_Complex", it is equivalent to "_Complex double", but e.g.
   13389              :      "_Complex short" is equivalent to "_Complex short int".  */
   13390     64984790 :   if (specs->typespec_word == cts_none)
   13391              :     {
   13392      4187025 :       if (specs->saturating_p)
   13393              :         {
   13394            1 :           error_at (specs->locations[cdw_saturating],
   13395              :                     "%<_Sat%> is used without %<_Fract%> or %<_Accum%>");
   13396            1 :           if (!targetm.fixed_point_supported_p ())
   13397            1 :             error_at (specs->locations[cdw_saturating],
   13398              :                       "fixed-point types not supported for this target");
   13399            1 :           specs->typespec_word = cts_fract;
   13400              :         }
   13401      4187024 :       else if (specs->long_p || specs->short_p
   13402       193890 :                || specs->signed_p || specs->unsigned_p)
   13403              :         {
   13404      4176584 :           specs->typespec_word = cts_int;
   13405              :         }
   13406        10440 :       else if (specs->complex_p)
   13407              :         {
   13408          130 :           specs->typespec_word = cts_double;
   13409          130 :           pedwarn (specs->locations[cdw_complex], OPT_Wpedantic,
   13410              :                    "ISO C does not support plain %<complex%> meaning "
   13411              :                    "%<double complex%>");
   13412              :         }
   13413        10310 :       else if (specs->c23_auto_p)
   13414              :         {
   13415              :           /* Type to be filled in later, including applying postfix
   13416              :              attributes.  This warning only actually appears for
   13417              :              -Wc11-c23-compat in C23 mode; in older modes, there may
   13418              :              be a warning or pedwarn for implicit "int" instead, or
   13419              :              other errors for use of auto at file scope.  */
   13420           93 :           pedwarn_c11 (input_location, OPT_Wpedantic,
   13421              :                        "ISO C does not support %<auto%> type deduction "
   13422              :                        "before C23");
   13423           93 :           return specs;
   13424              :         }
   13425              :       else
   13426              :         {
   13427        10217 :           specs->typespec_word = cts_int;
   13428        10217 :           specs->default_int_p = true;
   13429              :           /* We don't diagnose this here because grokdeclarator will
   13430              :              give more specific diagnostics according to whether it is
   13431              :              a function definition.  */
   13432              :         }
   13433              :     }
   13434              : 
   13435              :   /* If "signed" was specified, record this to distinguish "int" and
   13436              :      "signed int" in the case of a bit-field with
   13437              :      -funsigned-bitfields.  */
   13438     64984697 :   specs->explicit_signed_p = specs->signed_p;
   13439              : 
   13440              :   /* Now compute the actual type.  */
   13441     64984697 :   gcc_assert (!specs->c23_auto_p);
   13442     64984697 :   switch (specs->typespec_word)
   13443              :     {
   13444         1885 :     case cts_auto_type:
   13445         1885 :       gcc_assert (!specs->long_p && !specs->short_p
   13446              :                   && !specs->signed_p && !specs->unsigned_p
   13447              :                   && !specs->complex_p);
   13448              :       /* Type to be filled in later.  */
   13449         1885 :       if (specs->postfix_attrs)
   13450            2 :         error ("%<__auto_type%> followed by %<[[]]%> attributes");
   13451              :       break;
   13452      7856846 :     case cts_void:
   13453      7856846 :       gcc_assert (!specs->long_p && !specs->short_p
   13454              :                   && !specs->signed_p && !specs->unsigned_p
   13455              :                   && !specs->complex_p);
   13456      7856846 :       specs->type = void_type_node;
   13457      7856846 :       break;
   13458        85987 :     case cts_bool:
   13459        85987 :       gcc_assert (!specs->long_p && !specs->short_p
   13460              :                   && !specs->signed_p && !specs->unsigned_p
   13461              :                   && !specs->complex_p);
   13462        85987 :       specs->type = boolean_type_node;
   13463        85987 :       break;
   13464      9056732 :     case cts_char:
   13465      9056732 :       gcc_assert (!specs->long_p && !specs->short_p);
   13466      9056732 :       gcc_assert (!(specs->signed_p && specs->unsigned_p));
   13467      9056732 :       if (specs->signed_p)
   13468       192066 :         specs->type = signed_char_type_node;
   13469      8864666 :       else if (specs->unsigned_p)
   13470       897672 :         specs->type = unsigned_char_type_node;
   13471              :       else
   13472      7966994 :         specs->type = char_type_node;
   13473      9056732 :       if (specs->complex_p)
   13474              :         {
   13475         3855 :           pedwarn (specs->locations[cdw_complex], OPT_Wpedantic,
   13476              :                    "ISO C does not support complex integer types");
   13477         3855 :           specs->type = build_complex_type (specs->type);
   13478              :         }
   13479              :       break;
   13480        51714 :     case cts_int_n:
   13481        51714 :       gcc_assert (!specs->long_p && !specs->short_p && !specs->long_long_p);
   13482        51714 :       gcc_assert (!(specs->signed_p && specs->unsigned_p));
   13483        51714 :       if (! int_n_enabled_p[specs->u.int_n_idx])
   13484            0 :         specs->type = integer_type_node;
   13485              :       else
   13486        51714 :         specs->type = (specs->unsigned_p
   13487        51714 :                        ? int_n_trees[specs->u.int_n_idx].unsigned_type
   13488              :                        : int_n_trees[specs->u.int_n_idx].signed_type);
   13489        51714 :       if (specs->complex_p)
   13490              :         {
   13491          199 :           pedwarn (specs->locations[cdw_complex], OPT_Wpedantic,
   13492              :                    "ISO C does not support complex integer types");
   13493          199 :           specs->type = build_complex_type (specs->type);
   13494              :         }
   13495              :       break;
   13496     28055451 :     case cts_int:
   13497     28055451 :       gcc_assert (!(specs->long_p && specs->short_p));
   13498     28055451 :       gcc_assert (!(specs->signed_p && specs->unsigned_p));
   13499     28055451 :       if (specs->long_long_p)
   13500      2951879 :         specs->type = (specs->unsigned_p
   13501      2951879 :                        ? long_long_unsigned_type_node
   13502              :                        : long_long_integer_type_node);
   13503     25103572 :       else if (specs->long_p)
   13504      2202912 :         specs->type = (specs->unsigned_p
   13505      2202912 :                        ? long_unsigned_type_node
   13506              :                        : long_integer_type_node);
   13507     22900660 :       else if (specs->short_p)
   13508      1703279 :         specs->type = (specs->unsigned_p
   13509      1703279 :                        ? short_unsigned_type_node
   13510              :                        : short_integer_type_node);
   13511              :       else
   13512     21197381 :         specs->type = (specs->unsigned_p
   13513     21197381 :                        ? unsigned_type_node
   13514              :                        : integer_type_node);
   13515     28055451 :       if (specs->complex_p)
   13516              :         {
   13517        14933 :           pedwarn (specs->locations[cdw_complex], OPT_Wpedantic,
   13518              :                    "ISO C does not support complex integer types");
   13519        14933 :           specs->type = build_complex_type (specs->type);
   13520              :         }
   13521              :       break;
   13522      3391948 :     case cts_float:
   13523      3391948 :       gcc_assert (!specs->long_p && !specs->short_p
   13524              :                   && !specs->signed_p && !specs->unsigned_p);
   13525      6783896 :       specs->type = (specs->complex_p
   13526      3391948 :                      ? complex_float_type_node
   13527              :                      : float_type_node);
   13528      3391948 :       break;
   13529      6108111 :     case cts_double:
   13530      6108111 :       gcc_assert (!specs->long_long_p && !specs->short_p
   13531              :                   && !specs->signed_p && !specs->unsigned_p);
   13532      6108111 :       if (specs->long_p)
   13533              :         {
   13534      2627293 :           specs->type = (specs->complex_p
   13535      2627293 :                          ? complex_long_double_type_node
   13536              :                          : long_double_type_node);
   13537              :         }
   13538              :       else
   13539              :         {
   13540      3480818 :           specs->type = (specs->complex_p
   13541      3480818 :                          ? complex_double_type_node
   13542              :                          : double_type_node);
   13543              :         }
   13544              :       break;
   13545     10281785 :     case cts_floatn_nx:
   13546     10281785 :       gcc_assert (!specs->long_p && !specs->short_p
   13547              :                   && !specs->signed_p && !specs->unsigned_p);
   13548     10281785 :       if (FLOATN_NX_TYPE_NODE (specs->u.floatn_nx_idx) == NULL_TREE)
   13549           88 :         specs->type = integer_type_node;
   13550     10281697 :       else if (specs->complex_p)
   13551      1555507 :         specs->type = COMPLEX_FLOATN_NX_TYPE_NODE (specs->u.floatn_nx_idx);
   13552              :       else
   13553      8726190 :         specs->type = FLOATN_NX_TYPE_NODE (specs->u.floatn_nx_idx);
   13554              :       break;
   13555        47577 :     case cts_dfloat32:
   13556        47577 :     case cts_dfloat64:
   13557        47577 :     case cts_dfloat128:
   13558        47577 :     case cts_dfloat64x:
   13559        47577 :       gcc_assert (!specs->long_p && !specs->long_long_p && !specs->short_p
   13560              :                   && !specs->signed_p && !specs->unsigned_p && !specs->complex_p);
   13561        47577 :       if (!targetm.decimal_float_supported_p ())
   13562            0 :         specs->type = integer_type_node;
   13563        47577 :       else if (specs->typespec_word == cts_dfloat32)
   13564        15957 :         specs->type = dfloat32_type_node;
   13565        31620 :       else if (specs->typespec_word == cts_dfloat64)
   13566        15839 :         specs->type = dfloat64_type_node;
   13567        15781 :       else if (specs->typespec_word == cts_dfloat128)
   13568        15734 :         specs->type = dfloat128_type_node;
   13569              :       else
   13570           47 :         specs->type = dfloat64x_type_node;
   13571              :       break;
   13572           32 :     case cts_fract:
   13573           32 :       gcc_assert (!specs->complex_p);
   13574           32 :       if (!targetm.fixed_point_supported_p ())
   13575           32 :         specs->type = integer_type_node;
   13576            0 :       else if (specs->saturating_p)
   13577              :         {
   13578            0 :           if (specs->long_long_p)
   13579            0 :             specs->type = specs->unsigned_p
   13580            0 :                           ? sat_unsigned_long_long_fract_type_node
   13581              :                           : sat_long_long_fract_type_node;
   13582            0 :           else if (specs->long_p)
   13583            0 :             specs->type = specs->unsigned_p
   13584            0 :                           ? sat_unsigned_long_fract_type_node
   13585              :                           : sat_long_fract_type_node;
   13586            0 :           else if (specs->short_p)
   13587            0 :             specs->type = specs->unsigned_p
   13588            0 :                           ? sat_unsigned_short_fract_type_node
   13589              :                           : sat_short_fract_type_node;
   13590              :           else
   13591            0 :             specs->type = specs->unsigned_p
   13592            0 :                           ? sat_unsigned_fract_type_node
   13593              :                           : sat_fract_type_node;
   13594              :         }
   13595              :       else
   13596              :         {
   13597            0 :           if (specs->long_long_p)
   13598            0 :             specs->type = specs->unsigned_p
   13599            0 :                           ? unsigned_long_long_fract_type_node
   13600              :                           : long_long_fract_type_node;
   13601            0 :           else if (specs->long_p)
   13602            0 :             specs->type = specs->unsigned_p
   13603            0 :                           ? unsigned_long_fract_type_node
   13604              :                           : long_fract_type_node;
   13605            0 :           else if (specs->short_p)
   13606            0 :             specs->type = specs->unsigned_p
   13607            0 :                           ? unsigned_short_fract_type_node
   13608              :                           : short_fract_type_node;
   13609              :           else
   13610            0 :             specs->type = specs->unsigned_p
   13611            0 :                           ? unsigned_fract_type_node
   13612              :                           : fract_type_node;
   13613              :         }
   13614              :       break;
   13615           30 :     case cts_accum:
   13616           30 :       gcc_assert (!specs->complex_p);
   13617           30 :       if (!targetm.fixed_point_supported_p ())
   13618           30 :         specs->type = integer_type_node;
   13619            0 :       else if (specs->saturating_p)
   13620              :         {
   13621            0 :           if (specs->long_long_p)
   13622            0 :             specs->type = specs->unsigned_p
   13623            0 :                           ? sat_unsigned_long_long_accum_type_node
   13624              :                           : sat_long_long_accum_type_node;
   13625            0 :           else if (specs->long_p)
   13626            0 :             specs->type = specs->unsigned_p
   13627            0 :                           ? sat_unsigned_long_accum_type_node
   13628              :                           : sat_long_accum_type_node;
   13629            0 :           else if (specs->short_p)
   13630            0 :             specs->type = specs->unsigned_p
   13631            0 :                           ? sat_unsigned_short_accum_type_node
   13632              :                           : sat_short_accum_type_node;
   13633              :           else
   13634            0 :             specs->type = specs->unsigned_p
   13635            0 :                           ? sat_unsigned_accum_type_node
   13636              :                           : sat_accum_type_node;
   13637              :         }
   13638              :       else
   13639              :         {
   13640            0 :           if (specs->long_long_p)
   13641            0 :             specs->type = specs->unsigned_p
   13642            0 :                           ? unsigned_long_long_accum_type_node
   13643              :                           : long_long_accum_type_node;
   13644            0 :           else if (specs->long_p)
   13645            0 :             specs->type = specs->unsigned_p
   13646            0 :                           ? unsigned_long_accum_type_node
   13647              :                           : long_accum_type_node;
   13648            0 :           else if (specs->short_p)
   13649            0 :             specs->type = specs->unsigned_p
   13650            0 :                           ? unsigned_short_accum_type_node
   13651              :                           : short_accum_type_node;
   13652              :           else
   13653            0 :             specs->type = specs->unsigned_p
   13654            0 :                           ? unsigned_accum_type_node
   13655              :                           : accum_type_node;
   13656              :         }
   13657              :       break;
   13658        46599 :     case cts_bitint:
   13659        46599 :       gcc_assert (!specs->long_p && !specs->short_p
   13660              :                   && !specs->complex_p);
   13661        46599 :       if (!specs->unsigned_p && specs->u.bitint_prec == 1 && !flag_isoc2y)
   13662              :         {
   13663            2 :           error_at (specs->locations[cdw_typespec],
   13664              :                     "%<signed _BitInt%> argument must be at least 2 "
   13665              :                     "before C2Y");
   13666            2 :           specs->type = integer_type_node;
   13667            2 :           break;
   13668              :         }
   13669        46597 :       if (specs->u.bitint_prec == -1)
   13670            7 :         specs->type = integer_type_node;
   13671              :       else
   13672              :         {
   13673        68951 :           pedwarn_c11 (specs->locations[cdw_typespec], OPT_Wpedantic,
   13674              :                        "ISO C does not support %<%s_BitInt(%d)%> before C23",
   13675              :                        specs->unsigned_p ? "unsigned "
   13676        22361 :                        : specs->signed_p ? "signed " : "",
   13677              :                        specs->u.bitint_prec);
   13678        46590 :           specs->type = build_bitint_type (specs->u.bitint_prec,
   13679        46590 :                                            specs->unsigned_p);
   13680              :         }
   13681              :       break;
   13682            0 :     default:
   13683            0 :       gcc_unreachable ();
   13684              :     }
   13685    314286424 :  handle_postfix_attrs:
   13686    314286424 :   if (specs->type != NULL)
   13687              :     {
   13688    314284539 :       specs->postfix_attrs
   13689    314284539 :         = c_warn_type_attributes (specs->type, specs->postfix_attrs);
   13690    314284539 :       decl_attributes (&specs->type, specs->postfix_attrs, 0);
   13691    314284539 :       specs->postfix_attrs = NULL_TREE;
   13692              :     }
   13693              : 
   13694              :   return specs;
   13695              : }
   13696              : 
   13697              : /* Perform final processing on one file scope's declarations (or the
   13698              :    external scope's declarations), GLOBALS.  */
   13699              : 
   13700              : static void
   13701       210606 : c_write_global_declarations_1 (tree globals)
   13702              : {
   13703       210606 :   tree decl;
   13704       210606 :   bool reconsider;
   13705              : 
   13706              :   /* Process the decls in the order they were written.  */
   13707    384914038 :   for (decl = globals; decl; decl = DECL_CHAIN (decl))
   13708              :     {
   13709              :       /* Check for used but undefined static functions using the C
   13710              :          standard's definition of "used", and set TREE_NO_WARNING so
   13711              :          that check_global_declaration doesn't repeat the check.  */
   13712    384703432 :       if (TREE_CODE (decl) == FUNCTION_DECL
   13713    366576607 :           && DECL_INITIAL (decl) == NULL_TREE
   13714    330254047 :           && DECL_EXTERNAL (decl)
   13715    330254042 :           && !TREE_PUBLIC (decl)
   13716    384703556 :           && !warning_suppressed_p (decl, OPT_Wunused))
   13717              :         {
   13718          119 :           if (C_DECL_USED (decl))
   13719              :             {
   13720           30 :               if (pedwarn (input_location, 0, "%q+F used but never defined",
   13721              :                            decl))
   13722           29 :                 suppress_warning (decl, OPT_Wunused);
   13723              :             }
   13724              :           /* For -Wunused-function warn about unused static prototypes.  */
   13725           89 :           else if (warn_unused_function
   13726            2 :                    && ! DECL_ARTIFICIAL (decl)
   13727           91 :                    && warning (OPT_Wunused_function,
   13728              :                                "%q+F declared %<static%> but never defined",
   13729              :                                decl))
   13730            2 :             suppress_warning (decl, OPT_Wunused);
   13731              :         }
   13732              : 
   13733    384703432 :       wrapup_global_declaration_1 (decl);
   13734              :     }
   13735              : 
   13736       244673 :   do
   13737              :     {
   13738       244673 :       reconsider = false;
   13739    498693250 :       for (decl = globals; decl; decl = DECL_CHAIN (decl))
   13740    498448577 :         reconsider |= wrapup_global_declaration_2 (decl);
   13741              :     }
   13742              :   while (reconsider);
   13743       210606 : }
   13744              : 
   13745              : /* Preserve the external declarations scope across a garbage collect.  */
   13746              : static GTY(()) tree ext_block;
   13747              : 
   13748              : /* Collect all references relevant to SOURCE_FILE.  */
   13749              : 
   13750              : static void
   13751           15 : collect_all_refs (const char *source_file)
   13752              : {
   13753           15 :   tree t;
   13754           15 :   unsigned i;
   13755              : 
   13756           30 :   FOR_EACH_VEC_ELT (*all_translation_units, i, t)
   13757           15 :     collect_ada_nodes (BLOCK_VARS (DECL_INITIAL (t)), source_file);
   13758              : 
   13759           15 :   collect_ada_nodes (BLOCK_VARS (ext_block), source_file);
   13760           15 : }
   13761              : 
   13762              : /* Collect source file references at global level.  */
   13763              : 
   13764              : static void
   13765           15 : collect_source_refs (void)
   13766              : {
   13767           15 :   tree t;
   13768           15 :   tree decls;
   13769           15 :   tree decl;
   13770           15 :   unsigned i;
   13771              : 
   13772           30 :   FOR_EACH_VEC_ELT (*all_translation_units, i, t)
   13773              :     {
   13774           15 :       decls = DECL_INITIAL (t);
   13775           82 :       for (decl = BLOCK_VARS (decls); decl; decl = TREE_CHAIN (decl))
   13776           67 :         if (!DECL_IS_UNDECLARED_BUILTIN (decl))
   13777           67 :           collect_source_ref (DECL_SOURCE_FILE (decl));
   13778              :     }
   13779              : 
   13780        44186 :   for (decl = BLOCK_VARS (ext_block); decl; decl = TREE_CHAIN (decl))
   13781        44171 :     if (!DECL_IS_UNDECLARED_BUILTIN (decl))
   13782           11 :       collect_source_ref (DECL_SOURCE_FILE (decl));
   13783           15 : }
   13784              : 
   13785              : /* Free attribute access data that are not needed by the middle end. */
   13786              : 
   13787              : static void
   13788       105303 : free_attr_access_data ()
   13789              : {
   13790       105303 :   struct cgraph_node *n;
   13791              : 
   13792              :   /* Iterate over all functions declared in the translation unit.  */
   13793     36429506 :   FOR_EACH_FUNCTION (n)
   13794              :     {
   13795    136405420 :       for (tree parm = DECL_ARGUMENTS (n->decl); parm; parm = TREE_CHAIN (parm))
   13796    100081217 :         if (tree attrs = DECL_ATTRIBUTES (parm))
   13797        97708 :           attr_access::free_lang_data (attrs);
   13798              : 
   13799     36324203 :       tree fntype = TREE_TYPE (n->decl);
   13800     36324203 :       if (!fntype || fntype == error_mark_node)
   13801            0 :         continue;
   13802     36324203 :       tree attrs = TYPE_ATTRIBUTES (fntype);
   13803     36324203 :       if (!attrs)
   13804     36088956 :         continue;
   13805              : 
   13806       235247 :       attr_access::free_lang_data (attrs);
   13807              :     }
   13808       105303 : }
   13809              : 
   13810              : /* Perform any final parser cleanups and generate initial debugging
   13811              :    information.  */
   13812              : 
   13813              : void
   13814       105642 : c_parse_final_cleanups (void)
   13815              : {
   13816       105642 :   tree t;
   13817       105642 :   unsigned i;
   13818              : 
   13819              :   /* We don't want to do this if generating a PCH.  */
   13820       105642 :   if (pch_file)
   13821       105642 :     return;
   13822              : 
   13823       105303 :   timevar_stop (TV_PHASE_PARSING);
   13824       105303 :   timevar_start (TV_PHASE_DEFERRED);
   13825              : 
   13826              :   /* Do the Objective-C stuff.  This is where all the Objective-C
   13827              :      module stuff gets generated (symtab, class/protocol/selector
   13828              :      lists etc).  */
   13829       105303 :   if (c_dialect_objc ())
   13830            0 :     objc_write_global_declarations ();
   13831              : 
   13832              :   /* Close the external scope.  */
   13833       105303 :   ext_block = pop_scope ();
   13834       105303 :   external_scope = 0;
   13835       105303 :   gcc_assert (!current_scope);
   13836              : 
   13837              :   /* Handle -fdump-ada-spec[-slim]. */
   13838       105303 :   if (flag_dump_ada_spec || flag_dump_ada_spec_slim)
   13839              :     {
   13840              :       /* Build a table of files to generate specs for */
   13841           15 :       collect_source_ref (main_input_filename);
   13842           15 :       if (!flag_dump_ada_spec_slim)
   13843           15 :         collect_source_refs ();
   13844              : 
   13845           15 :       dump_ada_specs (collect_all_refs, NULL);
   13846              :     }
   13847              : 
   13848              :   /* Process all file scopes in this compilation, and the external_scope,
   13849              :      through wrapup_global_declarations.  */
   13850       210606 :   FOR_EACH_VEC_ELT (*all_translation_units, i, t)
   13851       105303 :     c_write_global_declarations_1 (BLOCK_VARS (DECL_INITIAL (t)));
   13852       105303 :   c_write_global_declarations_1 (BLOCK_VARS (ext_block));
   13853              : 
   13854              :   /* Call this to set cpp_implicit_aliases_done on all nodes.  This is
   13855              :      important for function multiversioning aliases to get resolved.  */
   13856       105303 :   symtab->process_same_body_aliases ();
   13857              : 
   13858       105303 :   if (!in_lto_p)
   13859       105303 :     free_attr_access_data ();
   13860              : 
   13861       105303 :   timevar_stop (TV_PHASE_DEFERRED);
   13862       105303 :   timevar_start (TV_PHASE_PARSING);
   13863              : 
   13864       105303 :   ext_block = NULL;
   13865              : }
   13866              : 
   13867              : /* Register reserved keyword WORD as qualifier for address space AS.  */
   13868              : 
   13869              : void
   13870       222410 : c_register_addr_space (const char *word, addr_space_t as)
   13871              : {
   13872       222410 :   int rid = RID_FIRST_ADDR_SPACE + as;
   13873       222410 :   tree id;
   13874              : 
   13875              :   /* Address space qualifiers are only supported
   13876              :      in C with GNU extensions enabled.  */
   13877       222410 :   if (c_dialect_objc () || flag_no_asm)
   13878              :     return;
   13879              : 
   13880       209958 :   id = get_identifier (word);
   13881       209958 :   C_SET_RID_CODE (id, rid);
   13882       209958 :   C_IS_RESERVED_WORD (id) = 1;
   13883       209958 :   ridpointers [rid] = id;
   13884              : }
   13885              : 
   13886              : /* Return identifier to look up for omp declare reduction.  */
   13887              : 
   13888              : tree
   13889         3254 : c_omp_reduction_id (enum tree_code reduction_code, tree reduction_id)
   13890              : {
   13891         3254 :   const char *p = NULL;
   13892         3254 :   switch (reduction_code)
   13893              :     {
   13894              :     case PLUS_EXPR: p = "+"; break;
   13895          267 :     case MULT_EXPR: p = "*"; break;
   13896          157 :     case MINUS_EXPR: p = "-"; break;
   13897           31 :     case BIT_AND_EXPR: p = "&"; break;
   13898           14 :     case BIT_XOR_EXPR: p = "^"; break;
   13899           92 :     case BIT_IOR_EXPR: p = "|"; break;
   13900           67 :     case TRUTH_ANDIF_EXPR: p = "&&"; break;
   13901           78 :     case TRUTH_ORIF_EXPR: p = "||"; break;
   13902           46 :     case MIN_EXPR: p = "min"; break;
   13903           83 :     case MAX_EXPR: p = "max"; break;
   13904              :     default:
   13905              :       break;
   13906              :     }
   13907              : 
   13908          835 :   if (p == NULL)
   13909              :     {
   13910          213 :       if (TREE_CODE (reduction_id) != IDENTIFIER_NODE)
   13911            0 :         return error_mark_node;
   13912          213 :       p = IDENTIFIER_POINTER (reduction_id);
   13913              :     }
   13914              : 
   13915         3254 :   const char prefix[] = "omp declare reduction ";
   13916         3254 :   size_t lenp = sizeof (prefix);
   13917         3254 :   size_t len = strlen (p);
   13918         3254 :   char *name = XALLOCAVEC (char, lenp + len);
   13919         3254 :   memcpy (name, prefix, lenp - 1);
   13920         3254 :   memcpy (name + lenp - 1, p, len + 1);
   13921         3254 :   return get_identifier (name);
   13922              : }
   13923              : 
   13924              : /* Lookup REDUCTION_ID in the current scope, or create an artificial
   13925              :    VAR_DECL, bind it into the current scope and return it.  */
   13926              : 
   13927              : tree
   13928          161 : c_omp_reduction_decl (tree reduction_id)
   13929              : {
   13930          161 :   struct c_binding *b = I_SYMBOL_BINDING (reduction_id);
   13931          161 :   if (b != NULL && B_IN_CURRENT_SCOPE (b))
   13932           47 :     return b->decl;
   13933              : 
   13934          114 :   tree decl = build_decl (BUILTINS_LOCATION, VAR_DECL,
   13935              :                           reduction_id, integer_type_node);
   13936          114 :   DECL_ARTIFICIAL (decl) = 1;
   13937          114 :   DECL_EXTERNAL (decl) = 1;
   13938          114 :   TREE_STATIC (decl) = 1;
   13939          114 :   TREE_PUBLIC (decl) = 0;
   13940          114 :   bind (reduction_id, decl, current_scope, true, false, BUILTINS_LOCATION);
   13941          114 :   return decl;
   13942              : }
   13943              : 
   13944              : /* Lookup REDUCTION_ID in the first scope where it has entry for TYPE.  */
   13945              : 
   13946              : tree
   13947          273 : c_omp_reduction_lookup (tree reduction_id, tree type)
   13948              : {
   13949          273 :   struct c_binding *b = I_SYMBOL_BINDING (reduction_id);
   13950          276 :   while (b)
   13951              :     {
   13952          274 :       tree t;
   13953          294 :       for (t = DECL_INITIAL (b->decl); t; t = TREE_CHAIN (t))
   13954          291 :         if (comptypes (TREE_PURPOSE (t), type))
   13955          271 :           return TREE_VALUE (t);
   13956            3 :       b = b->shadowed;
   13957              :     }
   13958            2 :   return error_mark_node;
   13959              : }
   13960              : 
   13961              : /* Helper function called via walk_tree, to diagnose invalid
   13962              :    #pragma omp declare reduction combiners or initializers.  */
   13963              : 
   13964              : tree
   13965         1401 : c_check_omp_declare_reduction_r (tree *tp, int *, void *data)
   13966              : {
   13967         1401 :   tree *vars = (tree *) data;
   13968         1401 :   if (SSA_VAR_P (*tp)
   13969          413 :       && !DECL_ARTIFICIAL (*tp)
   13970           24 :       && *tp != vars[0]
   13971           24 :       && *tp != vars[1])
   13972              :     {
   13973           24 :       location_t loc = DECL_SOURCE_LOCATION (vars[0]);
   13974           24 :       if (strcmp (IDENTIFIER_POINTER (DECL_NAME (vars[0])), "omp_out") == 0)
   13975           10 :         error_at (loc, "%<#pragma omp declare reduction%> combiner refers to "
   13976              :                        "variable %qD which is not %<omp_out%> nor %<omp_in%>",
   13977              :                   *tp);
   13978              :       else
   13979           14 :         error_at (loc, "%<#pragma omp declare reduction%> initializer refers "
   13980              :                        "to variable %qD which is not %<omp_priv%> nor "
   13981              :                        "%<omp_orig%>",
   13982              :                   *tp);
   13983           24 :       return *tp;
   13984              :     }
   13985              :   return NULL_TREE;
   13986              : }
   13987              : 
   13988              : /* Return identifier to look up for omp declare mapper.  */
   13989              : 
   13990              : tree
   13991          673 : c_omp_mapper_id (tree mapper_id)
   13992              : {
   13993          673 :   const char *p = NULL;
   13994              : 
   13995          673 :   const char prefix[] = "omp declare mapper ";
   13996              : 
   13997          673 :   if (mapper_id == NULL_TREE)
   13998              :     p = "<default>";
   13999           19 :   else if (TREE_CODE (mapper_id) == IDENTIFIER_NODE)
   14000           19 :     p = IDENTIFIER_POINTER (mapper_id);
   14001              :   else
   14002            0 :     return error_mark_node;
   14003              : 
   14004          673 :   size_t lenp = sizeof (prefix);
   14005          673 :   size_t len = strlen (p);
   14006          673 :   char *name = XALLOCAVEC (char, lenp + len);
   14007          673 :   memcpy (name, prefix, lenp - 1);
   14008          673 :   memcpy (name + lenp - 1, p, len + 1);
   14009          673 :   return get_identifier (name);
   14010              : }
   14011              : 
   14012              : /* Lookup MAPPER_ID in the current scope, or create an artificial
   14013              :    VAR_DECL, bind it into the current scope and return it.  */
   14014              : 
   14015              : tree
   14016           65 : c_omp_mapper_decl (tree mapper_id)
   14017              : {
   14018           65 :   struct c_binding *b = I_SYMBOL_BINDING (mapper_id);
   14019           65 :   if (b != NULL && B_IN_CURRENT_SCOPE (b))
   14020           22 :     return b->decl;
   14021              : 
   14022           43 :   tree decl = build_decl (BUILTINS_LOCATION, VAR_DECL,
   14023              :                           mapper_id, integer_type_node);
   14024           43 :   DECL_ARTIFICIAL (decl) = 1;
   14025           43 :   DECL_EXTERNAL (decl) = 1;
   14026           43 :   TREE_STATIC (decl) = 1;
   14027           43 :   TREE_PUBLIC (decl) = 0;
   14028           43 :   bind (mapper_id, decl, current_scope, true, false, BUILTINS_LOCATION);
   14029           43 :   return decl;
   14030              : }
   14031              : 
   14032              : /* Lookup MAPPER_ID in the first scope where it has entry for TYPE.  */
   14033              : 
   14034              : tree
   14035         2407 : c_omp_mapper_lookup (tree mapper_id, tree type)
   14036              : {
   14037         2407 :   if (!RECORD_OR_UNION_TYPE_P (type))
   14038              :     return NULL_TREE;
   14039              : 
   14040          608 :   mapper_id = c_omp_mapper_id (mapper_id);
   14041              : 
   14042          608 :   struct c_binding *b = I_SYMBOL_BINDING (mapper_id);
   14043          614 :   while (b)
   14044              :     {
   14045          114 :       tree t;
   14046          133 :       for (t = DECL_INITIAL (b->decl); t; t = TREE_CHAIN (t))
   14047          127 :         if (comptypes (TREE_PURPOSE (t), type))
   14048          108 :           return TREE_VALUE (t);
   14049            6 :       b = b->shadowed;
   14050              :     }
   14051              :   return NULL_TREE;
   14052              : }
   14053              : 
   14054              : /* For C, we record a pointer to the mapper itself without wrapping it in an
   14055              :    artificial function or similar.  So, just return it.  */
   14056              : 
   14057              : tree
   14058          100 : c_omp_extract_mapper_directive (tree mapper)
   14059              : {
   14060          100 :   return mapper;
   14061              : }
   14062              : 
   14063              : /* For now we can handle singleton OMP_ARRAY_SECTIONs with custom mappers, but
   14064              :    nothing more complicated.  */
   14065              : 
   14066              : tree
   14067          527 : c_omp_map_array_section (location_t loc, tree t)
   14068              : {
   14069          527 :   tree low = TREE_OPERAND (t, 1);
   14070          527 :   tree len = TREE_OPERAND (t, 2);
   14071              : 
   14072          527 :   if (len && integer_onep (len))
   14073              :     {
   14074           84 :       t = TREE_OPERAND (t, 0);
   14075              : 
   14076           84 :       if (!low)
   14077           14 :         low = integer_zero_node;
   14078              : 
   14079           84 :       t = build_array_ref (loc, t, low);
   14080              :     }
   14081              : 
   14082          527 :   return t;
   14083              : }
   14084              : 
   14085              : /* Helper function for below function.  */
   14086              : 
   14087              : static tree
   14088        51356 : c_omp_scan_mapper_bindings_r (tree *tp, int *walk_subtrees, void *ptr)
   14089              : {
   14090        51356 :   tree t = *tp;
   14091        51356 :   omp_mapper_list<tree> *mlist = (omp_mapper_list<tree> *) ptr;
   14092        51356 :   tree aggr_type = NULL_TREE;
   14093              : 
   14094        51356 :   if (TREE_CODE (t) == SIZEOF_EXPR
   14095        51356 :       || TREE_CODE (t) == ALIGNOF_EXPR)
   14096              :     {
   14097            0 :       *walk_subtrees = 0;
   14098            0 :       return NULL_TREE;
   14099              :     }
   14100              : 
   14101        51356 :   if (TREE_CODE (t) == OMP_CLAUSE)
   14102              :     return NULL_TREE;
   14103              : 
   14104        48067 :   if (TREE_CODE (t) == COMPONENT_REF
   14105        48067 :       && RECORD_OR_UNION_TYPE_P (TREE_TYPE (TREE_OPERAND (t, 0))))
   14106          370 :     aggr_type = TREE_TYPE (TREE_OPERAND (t, 0));
   14107        47697 :   else if ((TREE_CODE (t) == VAR_DECL
   14108              :             || TREE_CODE (t) == PARM_DECL
   14109              :             || TREE_CODE (t) == RESULT_DECL)
   14110         5329 :            && RECORD_OR_UNION_TYPE_P (TREE_TYPE (t)))
   14111          121 :     aggr_type = TREE_TYPE (t);
   14112              : 
   14113          491 :   if (aggr_type)
   14114              :     {
   14115          491 :       tree mapper_fn = c_omp_mapper_lookup (NULL_TREE, aggr_type);
   14116          491 :       if (mapper_fn)
   14117           76 :         mlist->add_mapper (NULL_TREE, aggr_type, mapper_fn);
   14118              :     }
   14119              : 
   14120              :   return NULL_TREE;
   14121              : }
   14122              : 
   14123              : /* Scan an offload region's body, and record uses of struct- or union-typed
   14124              :    variables.  Add _mapper_binding_ fake clauses to *CLAUSES_PTR.  */
   14125              : 
   14126              : void
   14127         2038 : c_omp_scan_mapper_bindings (location_t loc, tree *clauses_ptr, tree body)
   14128              : {
   14129         2038 :   hash_set<omp_name_type<tree>> seen_types;
   14130         2038 :   auto_vec<tree> mappers;
   14131         2038 :   omp_mapper_list<tree> mlist (&seen_types, &mappers);
   14132              : 
   14133         2038 :   walk_tree_without_duplicates (&body, c_omp_scan_mapper_bindings_r, &mlist);
   14134              : 
   14135         2038 :   unsigned int i;
   14136         2038 :   tree mapper;
   14137         4118 :   FOR_EACH_VEC_ELT (mappers, i, mapper)
   14138           42 :     c_omp_find_nested_mappers (&mlist, mapper);
   14139              : 
   14140         2109 :   FOR_EACH_VEC_ELT (mappers, i, mapper)
   14141              :     {
   14142           42 :       if (mapper == error_mark_node)
   14143            0 :         continue;
   14144           42 :       tree mapper_name = OMP_DECLARE_MAPPER_ID (mapper);
   14145           42 :       tree decl = OMP_DECLARE_MAPPER_DECL (mapper);
   14146              : 
   14147           42 :       tree c = build_omp_clause (loc, OMP_CLAUSE__MAPPER_BINDING_);
   14148           42 :       OMP_CLAUSE__MAPPER_BINDING__ID (c) = mapper_name;
   14149           42 :       OMP_CLAUSE__MAPPER_BINDING__DECL (c) = decl;
   14150           42 :       OMP_CLAUSE__MAPPER_BINDING__MAPPER (c) = mapper;
   14151              : 
   14152           42 :       OMP_CLAUSE_CHAIN (c) = *clauses_ptr;
   14153           42 :       *clauses_ptr = c;
   14154              :     }
   14155         2038 : }
   14156              : 
   14157              : bool
   14158          225 : c_check_in_current_scope (tree decl)
   14159              : {
   14160          225 :   struct c_binding *b = I_SYMBOL_BINDING (DECL_NAME (decl));
   14161          225 :   return b != NULL && B_IN_CURRENT_SCOPE (b);
   14162              : }
   14163              : 
   14164              : /* Search for loop or switch names.  BEFORE_LABELS is last statement before
   14165              :    possible labels and SWITCH_P true for a switch, false for loops.
   14166              :    Searches through last statements in cur_stmt_list, stops when seeing
   14167              :    BEFORE_LABELs, or statement other than LABEL_EXPR or CASE_LABEL_EXPR.
   14168              :    Returns number of loop/switch names found and if any are found, sets
   14169              :    *LAST_P to the canonical loop/switch name LABEL_DECL.  */
   14170              : 
   14171              : int
   14172       512525 : c_get_loop_names (tree before_labels, bool switch_p, tree *last_p)
   14173              : {
   14174       512525 :   *last_p = NULL_TREE;
   14175      1025050 :   if (!building_stmt_list_p ()
   14176       512525 :       || !STATEMENT_LIST_HAS_LABEL (cur_stmt_list)
   14177       533147 :       || before_labels == void_list_node)
   14178       491903 :     return 0;
   14179              : 
   14180        20622 :   int ret = 0;
   14181        20622 :   tree last = NULL_TREE;
   14182        20622 :   for (tree_stmt_iterator tsi = tsi_last (cur_stmt_list);
   14183        28830 :        !tsi_end_p (tsi); tsi_prev (&tsi))
   14184              :     {
   14185        27973 :       tree stmt = tsi_stmt (tsi);
   14186        27973 :       if (stmt == before_labels)
   14187              :         break;
   14188         8208 :       else if (TREE_CODE (stmt) == LABEL_EXPR)
   14189              :         {
   14190         1096 :           if (last == NULL_TREE)
   14191          902 :             last = LABEL_EXPR_LABEL (stmt);
   14192              :           else
   14193              :             {
   14194          194 :               loop_names.safe_push (LABEL_EXPR_LABEL (stmt));
   14195          194 :               ++ret;
   14196              :             }
   14197              :         }
   14198         7112 :       else if (TREE_CODE (stmt) != CASE_LABEL_EXPR
   14199         4791 :                && TREE_CODE (stmt) != DEBUG_BEGIN_STMT)
   14200              :         break;
   14201              :     }
   14202        20622 :   if (last)
   14203              :     {
   14204          902 :       if (switch_p)
   14205          130 :         C_DECL_SWITCH_NAME (last) = 1;
   14206              :       else
   14207          772 :         C_DECL_LOOP_NAME (last) = 1;
   14208          902 :       loop_names.safe_push (last);
   14209          902 :       ++ret;
   14210          902 :       if (loop_names.length () > 16)
   14211              :         {
   14212           20 :           unsigned int first = 0, i;
   14213           20 :           tree l, c = NULL_TREE;
   14214           20 :           if (loop_names_hash == NULL)
   14215            8 :             loop_names_hash = new decl_tree_map (ret);
   14216              :           else
   14217           12 :             first = loop_names.length () - ret;
   14218          210 :           FOR_EACH_VEC_ELT_REVERSE (loop_names, i, l)
   14219              :             {
   14220          170 :               if (C_DECL_LOOP_NAME (l) || C_DECL_SWITCH_NAME (l))
   14221           48 :                 c = l;
   14222          170 :               gcc_checking_assert (c);
   14223          170 :               loop_names_hash->put (l, c);
   14224          170 :               if (i == first)
   14225              :                 break;
   14226              :             }
   14227              :         }
   14228          902 :       *last_p = last;
   14229              :     }
   14230              :   return ret;
   14231              : }
   14232              : 
   14233              : /* Undoes what get_loop_names did when it returned NUM_NAMES.  */
   14234              : 
   14235              : void
   14236          902 : c_release_loop_names (int num_names)
   14237              : {
   14238          902 :   unsigned len = loop_names.length () - num_names;
   14239          902 :   if (loop_names_hash)
   14240              :     {
   14241           20 :       if (len <= 16)
   14242              :         {
   14243            8 :           delete loop_names_hash;
   14244            8 :           loop_names_hash = NULL;
   14245              :         }
   14246              :       else
   14247              :         {
   14248           12 :           unsigned int i;
   14249           12 :           tree l;
   14250           42 :           FOR_EACH_VEC_ELT_REVERSE (loop_names, i, l)
   14251              :             {
   14252           30 :               loop_names_hash->remove (l);
   14253           30 :               if (i == len)
   14254              :                 break;
   14255              :             }
   14256              :         }
   14257              :     }
   14258          902 :   loop_names.truncate (len);
   14259          902 : }
   14260              : 
   14261              : /* Finish processing of break or continue identifier operand.
   14262              :    NAME is the identifier operand of break or continue and
   14263              :    IS_BREAK is true iff it is break stmt.  Returns the operand
   14264              :    to use for BREAK_STMT or CONTINUE_STMT, either NULL_TREE or
   14265              :    canonical loop/switch name LABEL_DECL.  */
   14266              : 
   14267              : tree
   14268          316 : c_finish_bc_name (location_t loc, tree name, bool is_break)
   14269              : {
   14270          316 :   tree label = NULL_TREE, lab;
   14271          457 :   pedwarn_c23 (loc, OPT_Wpedantic,
   14272              :                "ISO C does not support %qs statement with an identifier "
   14273              :                "operand before C2Y", is_break ? "break" : "continue");
   14274              : 
   14275              :   /* If I_LABEL_DECL is NULL or not from current function, don't waste time
   14276              :      trying to find it among loop_names, it can't be there.  */
   14277          316 :   if (!loop_names.is_empty ()
   14278          296 :       && current_function_scope
   14279          296 :       && (lab = I_LABEL_DECL (name))
   14280          290 :       && DECL_CONTEXT (lab) == current_function_decl)
   14281              :     {
   14282          280 :       unsigned int i;
   14283          280 :       tree l, c = NULL_TREE;
   14284          280 :       if (loop_names_hash)
   14285              :         {
   14286           86 :           if (tree *val = loop_names_hash->get (lab))
   14287           86 :             label = *val;
   14288              :         }
   14289              :       else
   14290          565 :         FOR_EACH_VEC_ELT_REVERSE (loop_names, i, l)
   14291              :           {
   14292          363 :             if (C_DECL_LOOP_NAME (l) || C_DECL_SWITCH_NAME (l))
   14293              :               c = l;
   14294          363 :             gcc_checking_assert (c);
   14295          363 :             if (l == lab)
   14296              :               {
   14297              :                 label = c;
   14298              :                 break;
   14299              :               }
   14300              :           }
   14301          280 :       if (label)
   14302          272 :         TREE_USED (lab) = 1;
   14303              :     }
   14304          272 :   if (label == NULL_TREE)
   14305              :     {
   14306           44 :       auto_vec<const char *> candidates;
   14307           44 :       unsigned int i;
   14308           44 :       tree l, c = NULL_TREE;
   14309          115 :       FOR_EACH_VEC_ELT_REVERSE (loop_names, i, l)
   14310              :         {
   14311           28 :           if (C_DECL_LOOP_NAME (l) || C_DECL_SWITCH_NAME (l))
   14312              :             c = l;
   14313           28 :           gcc_checking_assert (c);
   14314           42 :           if (is_break || C_DECL_LOOP_NAME (c))
   14315           25 :             candidates.safe_push (IDENTIFIER_POINTER (DECL_NAME (l)));
   14316              :         }
   14317           44 :       const char *hint = find_closest_string (IDENTIFIER_POINTER (name),
   14318              :                                               &candidates);
   14319           44 :       if (hint)
   14320              :         {
   14321           22 :           gcc_rich_location richloc (loc);
   14322           22 :           richloc.add_fixit_replace (hint);
   14323           22 :           if (is_break)
   14324           11 :             error_at (&richloc, "%<break%> statement operand %qE does not "
   14325              :                                 "refer to a named loop or %<switch%>; "
   14326              :                                 "did you mean %qs?", name, hint);
   14327              :           else
   14328           11 :             error_at (&richloc, "%<continue%> statement operand %qE does not "
   14329              :                                 "refer to a named loop; did you mean %qs?",
   14330              :                       name, hint);
   14331           22 :         }
   14332           22 :       else if (is_break)
   14333           12 :         error_at (loc, "%<break%> statement operand %qE does not refer to a "
   14334              :                        "named loop or %<switch%>", name);
   14335              :       else
   14336           10 :         error_at (loc, "%<continue%> statement operand %qE does not refer to "
   14337              :                        "a named loop", name);
   14338           44 :     }
   14339          272 :   else if (!C_DECL_LOOP_NAME (label) && !is_break)
   14340              :     {
   14341            2 :       auto_diagnostic_group d;
   14342            2 :       error_at (loc, "%<continue%> statement operand %qE refers to a named "
   14343              :                      "%<switch%>", name);
   14344            2 :       inform (DECL_SOURCE_LOCATION (label), "%<switch%> name defined here");
   14345            2 :       label = NULL_TREE;
   14346            2 :     }
   14347          270 :   else if (!C_DECL_LOOP_SWITCH_NAME_VALID (label))
   14348              :     {
   14349           18 :       auto_diagnostic_group d;
   14350           18 :       if (C_DECL_LOOP_NAME (label))
   14351              :         {
   14352           16 :           error_at (loc, "%qs statement operand %qE refers to a loop outside "
   14353              :                          "of its body", is_break ? "break" : "continue", name);
   14354           16 :           inform (DECL_SOURCE_LOCATION (label), "loop name defined here");
   14355              :         }
   14356              :       else
   14357              :         {
   14358            2 :           error_at (loc, "%<break%> statement operand %qE refers to a "
   14359              :                          "%<switch%> outside of its body", name);
   14360            2 :           inform (DECL_SOURCE_LOCATION (label),
   14361              :                   "%<switch%> name defined here");
   14362              :         }
   14363           18 :       label = NULL_TREE;
   14364           18 :     }
   14365          252 :   else if (label == loop_names.last () && (in_statement & IN_NAMED_STMT) != 0)
   14366              :     /* If it is just a fancy reference to the innermost construct, handle it
   14367              :        just like break; or continue; though tracking cheaply what is the
   14368              :        innermost loop for continue when nested in switches would require
   14369              :        another global variable and updating it.  */
   14370              :     label = NULL_TREE;
   14371              :   else
   14372           98 :     C_DECL_LOOP_SWITCH_NAME_USED (label) = 1;
   14373          316 :   return label;
   14374              : }
   14375              : 
   14376              : #include "gt-c-c-decl.h"
        

Generated by: LCOV version 2.4-beta

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