LCOV - code coverage report
Current view: top level - gcc/c - c-decl.cc (source / functions) Coverage Total Hit
Test: gcc.info Lines: 92.3 % 6385 5892
Test Date: 2026-12-05 16:10:02 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 invisible : 1;  /* normal lookup should ignore this binding */
     225              :   bool nested : 1;     /* do not set DECL_CONTEXT when popping */
     226              :   bool inner_comp : 1; /* incomplete array completed in inner scope */
     227              :   bool 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   4732858448 : i_symbol_binding (tree node)
     260              : {
     261   4732858448 :   struct lang_identifier *lid
     262   4732858448 :     = (struct lang_identifier *) IDENTIFIER_NODE_CHECK (node);
     263              : 
     264   4732858448 :   if (lid->symbol_binding == NULL
     265   1741110729 :       && c_binding_oracle != NULL
     266   4732858448 :       && !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   4732858448 :   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      4683506 : i_tag_binding (tree node)
     289              : {
     290      4683506 :   struct lang_identifier *lid
     291      4683506 :     = (struct lang_identifier *) IDENTIFIER_NODE_CHECK (node);
     292              : 
     293      4683506 :   if (lid->tag_binding == NULL
     294      1322468 :       && c_binding_oracle != NULL
     295      4683506 :       && !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      4683506 :   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       367232 : i_label_binding (tree node)
     318              : {
     319       367232 :   struct lang_identifier *lid
     320       367232 :     = (struct lang_identifier *) IDENTIFIER_NODE_CHECK (node);
     321              : 
     322       367232 :   if (lid->label_binding == NULL
     323        49624 :       && c_binding_oracle != NULL
     324       367232 :       && !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       367232 :   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 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 had_vla_unspec : 1;
     510              : 
     511              :   /* True if we parsed a list of forward parameter decls in this scope.  */
     512              :   bool 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 function_body : 1;
     519              : 
     520              :   /* True means make a BLOCK for this scope no matter what.  */
     521              :   bool keep : 1;
     522              : 
     523              :   /* True means that an unsuffixed float constant is _Decimal64.  */
     524              :   bool 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 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 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      1199842 : 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      4457351 : c_struct_hasher::hash (tree type)
     660              : {
     661      4457351 :   inchash::hash hstate;
     662              : 
     663      4457351 :   hstate.add_int (TREE_CODE (type));
     664      4457351 :   tree tag = c_type_tag (type);
     665      4457351 :   hstate.add_object (tag);
     666              : 
     667      4457351 :   return hstate.end ();
     668              : }
     669              : 
     670              : /* Compare two RECORD or UNION types.  */
     671              : bool
     672     14843336 : c_struct_hasher::equal (tree t1,  tree t2)
     673              : {
     674     14843336 :   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     96944592 : add_stmt (tree t)
     701              : {
     702     96944592 :   enum tree_code code = TREE_CODE (t);
     703              : 
     704     96944592 :   if (CAN_HAVE_LOCATION_P (t) && code != LABEL_EXPR)
     705              :     {
     706     96212612 :       if (!EXPR_HAS_LOCATION (t))
     707       156612 :         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     96944592 :   if (!building_stmt_list_p ())
     713            1 :     push_stmt_list ();
     714              : 
     715     96944592 :   if (code == LABEL_EXPR || code == CASE_LABEL_EXPR)
     716      1090041 :     STATEMENT_LIST_HAS_LABEL (cur_stmt_list) = 1;
     717              : 
     718     96944592 :   append_to_statement_list_force (t, &cur_stmt_list);
     719              : 
     720     96944592 :   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    933932197 : decl_jump_unsafe (tree decl)
     732              : {
     733    933932197 :   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    933930097 :   if (VAR_P (decl) && C_DECL_COMPOUND_LITERAL_P (decl))
     742              :     return false;
     743              : 
     744    932999877 :   if (flag_openmp
     745     13545085 :       && VAR_P (decl)
     746    933034746 :       && lookup_attribute ("omp allocate", DECL_ATTRIBUTES (decl)))
     747              :     return true;
     748              : 
     749              :   /* Always warn about crossing variably modified types.  */
     750    922857055 :   if ((VAR_P (decl) || TREE_CODE (decl) == TYPE_DECL)
     751    945424393 :       && 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    932959336 :   if (warn_jump_misses_init
     757      8305390 :       && VAR_P (decl)
     758        46891 :       && !TREE_STATIC (decl)
     759    933000696 :       && DECL_INITIAL (decl) != NULL_TREE)
     760        17362 :     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          118 : c_mark_decl_jump_unsafe_in_current_scope ()
     797              : {
     798          118 :   current_scope->has_jump_unsafe_decl = 1;
     799          118 : }
     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    933779154 : bind (tree name, tree decl, struct c_scope *scope, bool invisible,
     806              :       bool nested, location_t locus)
     807              : {
     808    933779154 :   struct c_binding *b, **here;
     809              : 
     810    933779154 :   if (binding_freelist)
     811              :     {
     812    238255600 :       b = binding_freelist;
     813    238255600 :       binding_freelist = b->prev;
     814              :     }
     815              :   else
     816    695523554 :     b = ggc_alloc<c_binding> ();
     817              : 
     818    933779154 :   b->shadowed = 0;
     819    933779154 :   b->decl = decl;
     820    933779154 :   b->id = name;
     821    933779154 :   b->depth = scope->depth;
     822    933779154 :   b->invisible = invisible;
     823    933779154 :   b->nested = nested;
     824    933779154 :   b->inner_comp = 0;
     825    933779154 :   b->in_struct = 0;
     826    933779154 :   b->locus = locus;
     827              : 
     828    933779154 :   b->u.type = NULL;
     829              : 
     830    933779154 :   b->prev = scope->bindings;
     831    933779154 :   scope->bindings = b;
     832              : 
     833    933779154 :   if (decl_jump_unsafe (decl))
     834        36641 :     scope->has_jump_unsafe_decl = 1;
     835              : 
     836    933779154 :   if (!name)
     837              :     return;
     838              : 
     839    924936085 :   switch (TREE_CODE (decl))
     840              :     {
     841        24841 :     case LABEL_DECL:     here = &I_LABEL_BINDING (name);   break;
     842       641780 :     case ENUMERAL_TYPE:
     843       641780 :     case UNION_TYPE:
     844       641780 :     case RECORD_TYPE:    here = &I_TAG_BINDING (name);     break;
     845    924269464 :     case VAR_DECL:
     846    924269464 :     case FUNCTION_DECL:
     847    924269464 :     case TYPE_DECL:
     848    924269464 :     case CONST_DECL:
     849    924269464 :     case PARM_DECL:
     850    924269464 :     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    924936129 :   while (*here && (*here)->depth > scope->depth)
     860           44 :     here = &(*here)->shadowed;
     861              : 
     862    924936085 :   b->shadowed = *here;
     863    924936085 :   *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    915351394 : free_binding_and_advance (struct c_binding *b)
     872              : {
     873    915351394 :   struct c_binding *prev = b->prev;
     874              : 
     875    915351394 :   memset (b, 0, sizeof (struct c_binding));
     876    915351394 :   b->prev = binding_freelist;
     877    915351394 :   binding_freelist = b;
     878              : 
     879    915351394 :   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        24841 : bind_label (tree name, tree label, struct c_scope *scope,
     886              :             struct c_label_vars *label_vars)
     887              : {
     888        24841 :   struct c_binding *b;
     889              : 
     890        24841 :   bind (name, label, scope, /*invisible=*/false, /*nested=*/false,
     891              :         UNKNOWN_LOCATION);
     892              : 
     893        24841 :   scope->has_label_bindings = true;
     894              : 
     895        24841 :   b = scope->bindings;
     896        24841 :   gcc_assert (b->decl == label);
     897        24841 :   label_vars->shadowed = b->u.label;
     898        24841 :   b->u.label = label_vars;
     899        24841 : }
     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         7501 : c_finish_incomplete_decl (tree decl)
     906              : {
     907         7501 :   if (VAR_P (decl))
     908              :     {
     909         7501 :       tree type = TREE_TYPE (decl);
     910         7501 :       if (type != error_mark_node
     911         7424 :           && TREE_CODE (type) == ARRAY_TYPE
     912         7229 :           && !DECL_EXTERNAL (decl)
     913         7590 :           && 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         7501 : }
     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       110068 : check_inline_statics (void)
     952              : {
     953       110068 :   struct c_inline_static *csi;
     954       110104 :   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       110068 :   c_inline_statics = NULL;
     974       110068 : }
     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       138485 : set_spot_bindings (struct c_spot_bindings *p, bool defining)
     981              : {
     982            0 :   if (defining)
     983              :     {
     984       130756 :       p->scope = current_scope;
     985        17112 :       p->bindings_in_scope = current_scope->bindings;
     986              :     }
     987              :   else
     988              :     {
     989         7729 :       p->scope = NULL;
     990         7729 :       p->bindings_in_scope = NULL;
     991              :     }
     992       138485 :   p->stmt_exprs = 0;
     993       138485 :   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    470637824 : 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       209006 :   p->scope = scope->outer;
    1013       209006 :   p->bindings_in_scope = p->scope->bindings;
    1014              : 
    1015       153530 :   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      2109680 : global_bindings_p (void)
    1052              : {
    1053      2109680 :   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        35465 : 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        35465 :   return (current_scope->parm_flag && !DECL_SAVED_TREE (current_function_decl));
    1065              : }
    1066              : 
    1067              : void
    1068        54097 : keep_next_level (void)
    1069              : {
    1070        54097 :   keep_next_level_flag = true;
    1071        54097 : }
    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       606814 : float_const_decimal64_p (void)
    1093              : {
    1094       606814 :   return current_scope->float_const_decimal64;
    1095              : }
    1096              : 
    1097              : /* Identify this scope as currently being filled with parameters.  */
    1098              : 
    1099              : void
    1100     90375240 : declare_parm_level (void)
    1101              : {
    1102     90375240 :   current_scope->parm_flag = true;
    1103     90375240 : }
    1104              : 
    1105              : void
    1106    133178809 : push_scope (void)
    1107              : {
    1108    133178809 :   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     37713984 :       current_scope->parm_flag         = false;
    1121     37713984 :       current_scope->function_body     = true;
    1122     37713984 :       current_scope->keep              = true;
    1123     37713984 :       current_scope->outer_function    = current_function_scope;
    1124     37713984 :       current_function_scope           = current_scope;
    1125              : 
    1126     37713984 :       keep_next_level_flag = false;
    1127     37713984 :       next_is_function_body = false;
    1128              : 
    1129              :       /* The FLOAT_CONST_DECIMAL64 pragma applies to nested scopes.  */
    1130     37713984 :       if (current_scope->outer)
    1131     37713984 :         current_scope->float_const_decimal64
    1132     37713984 :           = current_scope->outer->float_const_decimal64;
    1133              :       else
    1134            0 :         current_scope->float_const_decimal64 = false;
    1135              :     }
    1136              :   else
    1137              :     {
    1138     95464825 :       struct c_scope *scope;
    1139     95464825 :       if (scope_freelist)
    1140              :         {
    1141     94576821 :           scope = scope_freelist;
    1142     94576821 :           scope_freelist = scope->outer;
    1143              :         }
    1144              :       else
    1145       888004 :         scope = ggc_cleared_alloc<c_scope> ();
    1146              : 
    1147              :       /* The FLOAT_CONST_DECIMAL64 pragma applies to nested scopes.  */
    1148     95464825 :       if (current_scope)
    1149     95348784 :         scope->float_const_decimal64 = current_scope->float_const_decimal64;
    1150              :       else
    1151              :         scope->float_const_decimal64 = false;
    1152              : 
    1153     95464825 :       scope->keep          = keep_next_level_flag;
    1154     95464825 :       scope->outer         = current_scope;
    1155     95464825 :       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     95464825 :       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     95464825 :       current_scope        = scope;
    1166     95464825 :       keep_next_level_flag = false;
    1167              :     }
    1168    133178809 : }
    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     95457946 : update_label_decls (struct c_scope *scope)
    1177              : {
    1178     95457946 :   struct c_scope *s;
    1179              : 
    1180     95457946 :   s = scope;
    1181    341675346 :   while (s != NULL)
    1182              :     {
    1183    288810234 :       if (s->has_label_bindings)
    1184              :         {
    1185       237795 :           struct c_binding *b;
    1186              : 
    1187      2228028 :           for (b = s->bindings; b != NULL; b = b->prev)
    1188              :             {
    1189      1990233 :               struct c_label_vars *label_vars;
    1190      1990233 :               struct c_binding *b1;
    1191      1990233 :               bool hjud;
    1192      1990233 :               unsigned int ix;
    1193      1990233 :               struct c_goto_bindings *g;
    1194              : 
    1195      1990233 :               if (TREE_CODE (b->decl) != LABEL_DECL)
    1196      1472518 :                 continue;
    1197       517715 :               label_vars = b->u.label;
    1198              : 
    1199       517715 :               b1 = label_vars->label_bindings.bindings_in_scope;
    1200       517715 :               if (label_vars->label_bindings.scope == NULL)
    1201              :                 hjud = false;
    1202              :               else
    1203       203190 :                 hjud = label_vars->label_bindings.scope->has_jump_unsafe_decl;
    1204       517715 :               if (update_spot_bindings (scope, &label_vars->label_bindings))
    1205              :                 {
    1206              :                   /* This label is defined in this scope.  */
    1207        55476 :                   if (hjud)
    1208              :                     {
    1209       173930 :                       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       152027 :                           if (decl_jump_unsafe (b1->decl))
    1216        20536 :                             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    472408492 :               FOR_EACH_VEC_SAFE_ELT (label_vars->gotos, ix, g)
    1224    470273639 :                 update_spot_bindings (scope, &g->goto_bindings);
    1225              :             }
    1226              :         }
    1227              : 
    1228              :       /* Don't search beyond the current function.  */
    1229    288810234 :       if (s == current_function_scope)
    1230              :         break;
    1231              : 
    1232    246217400 :       s = s->outer;
    1233              :     }
    1234     95457946 : }
    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     95457946 : pop_scope (void)
    1243              : {
    1244     95457946 :   struct c_scope *scope = current_scope;
    1245     95457946 :   tree block, context, p;
    1246     95457946 :   struct c_binding *b;
    1247              : 
    1248     95457946 :   bool functionbody = scope->function_body;
    1249     95457946 :   bool keep = functionbody || scope->keep || scope->bindings;
    1250              : 
    1251     95457946 :   update_label_decls (scope);
    1252              : 
    1253              :   /* If appropriate, create a BLOCK to record the decls for the life
    1254              :      of this function.  */
    1255     95457946 :   block = NULL_TREE;
    1256     95457946 :   if (keep)
    1257              :     {
    1258     38223245 :       block = make_node (BLOCK);
    1259     38223245 :       BLOCK_SUBBLOCKS (block) = scope->blocks;
    1260     38223245 :       TREE_USED (block) = 1;
    1261              : 
    1262              :       /* In each subblock, record that this is its superior.  */
    1263     38513119 :       for (p = scope->blocks; p; p = BLOCK_CHAIN (p))
    1264       289874 :         BLOCK_SUPERCONTEXT (p) = block;
    1265              : 
    1266     38223245 :       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     95457946 :   if (scope->function_body)
    1283     37713983 :     context = current_function_decl;
    1284     57743963 :   else if (scope == file_scope)
    1285              :     {
    1286       109695 :       tree file_decl
    1287       109695 :         = build_translation_unit_decl (get_identifier (main_input_filename));
    1288       109695 :       context = file_decl;
    1289       109695 :       debug_hooks->register_main_translation_unit (file_decl);
    1290              :     }
    1291              :   else
    1292              :     context = block;
    1293              : 
    1294              :   /* Clear all bindings in this scope.  */
    1295    883255180 :   for (b = scope->bindings; b; b = free_binding_and_advance (b))
    1296              :     {
    1297    787797234 :       p = b->decl;
    1298    787797234 :       switch (TREE_CODE (p))
    1299              :         {
    1300        24841 :         case LABEL_DECL:
    1301              :           /* Warnings for unused labels, errors for undefined labels.  */
    1302        24841 :           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        24778 :             warn_for_unused_label (p);
    1309              : 
    1310              :           /* Labels go in BLOCK_VARS.  */
    1311        24841 :           DECL_CHAIN (p) = BLOCK_VARS (block);
    1312        24841 :           BLOCK_VARS (block) = p;
    1313        24841 :           gcc_assert (I_LABEL_BINDING (b->id) == b);
    1314        24841 :           I_LABEL_BINDING (b->id) = b->shadowed;
    1315              : 
    1316              :           /* Also pop back to the shadowed label_vars.  */
    1317        24841 :           release_tree_vector (b->u.label->decls_in_scope);
    1318        24841 :           b->u.label = b->u.label->shadowed;
    1319        24841 :           break;
    1320              : 
    1321      1453939 :         case ENUMERAL_TYPE:
    1322      1453939 :         case UNION_TYPE:
    1323      1453939 :         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      1453939 :           if (b->id)
    1328              :             {
    1329       639954 :               gcc_assert (I_TAG_BINDING (b->id) == b);
    1330       639954 :               I_TAG_BINDING (b->id) = b->shadowed;
    1331              :             }
    1332              :           break;
    1333              : 
    1334    654083419 :         case FUNCTION_DECL:
    1335              :           /* Propagate TREE_ADDRESSABLE from nested functions to their
    1336              :              containing functions.  */
    1337    654083419 :           if (!TREE_ASM_WRITTEN (p)
    1338    654083419 :               && DECL_INITIAL (p) != NULL_TREE
    1339     75059740 :               && TREE_ADDRESSABLE (p)
    1340      3741625 :               && DECL_ABSTRACT_ORIGIN (p) != NULL_TREE
    1341    654083419 :               && DECL_ABSTRACT_ORIGIN (p) != p)
    1342            0 :             TREE_ADDRESSABLE (DECL_ABSTRACT_ORIGIN (p)) = 1;
    1343    654083419 :           if (!TREE_PUBLIC (p)
    1344       367690 :               && !DECL_INITIAL (p)
    1345          174 :               && !b->nested
    1346          143 :               && scope != file_scope
    1347    654083427 :               && scope != external_scope)
    1348              :             {
    1349            8 :               error ("nested function %q+D declared but never defined", p);
    1350            8 :               undef_nested_function = true;
    1351              :             }
    1352    654083411 :           else if (DECL_DECLARED_INLINE_P (p)
    1353     73840957 :                    && TREE_PUBLIC (p)
    1354    727759639 :                    && !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    654083419 :           goto common_symbol;
    1368              : 
    1369     11062874 :         case VAR_DECL:
    1370              :           /* Warnings for unused variables.  */
    1371      8503113 :           if ((!TREE_USED (p) || !DECL_READ_P (p))
    1372      2592253 :               && !warning_suppressed_p (p, OPT_Wunused_but_set_variable_)
    1373      2591743 :               && !DECL_IN_SYSTEM_HEADER (p)
    1374      2510498 :               && DECL_NAME (p)
    1375      2510498 :               && !DECL_ARTIFICIAL (p)
    1376      2510101 :               && scope != file_scope
    1377     12689228 :               && scope != external_scope)
    1378              :             {
    1379       744272 :               if (!TREE_USED (p))
    1380              :                 {
    1381       736957 :                   warning (OPT_Wunused_variable, "unused variable %q+D", p);
    1382       736957 :                   suppress_warning (p, OPT_Wunused_variable);
    1383              :                 }
    1384         7315 :               else if (DECL_CONTEXT (p) == current_function_decl)
    1385         7296 :                 warning_at (DECL_SOURCE_LOCATION (p),
    1386         7296 :                             OPT_Wunused_but_set_variable_,
    1387              :                             "variable %qD set but not used", p);
    1388              :             }
    1389              : 
    1390     11062874 :           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    682993578 :         case TYPE_DECL:
    1398    682993578 :         case CONST_DECL:
    1399     11062872 :         common_symbol:
    1400              :           /* All of these go in BLOCK_VARS, but only if this is the
    1401              :              binding in the home scope.  */
    1402    682993578 :           if (!b->nested)
    1403              :             {
    1404    410672416 :               DECL_CHAIN (p) = BLOCK_VARS (block);
    1405    410672416 :               BLOCK_VARS (block) = p;
    1406              :             }
    1407    272321162 :           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        14605 :               tree extp = copy_node (p);
    1412              : 
    1413        14605 :               DECL_EXTERNAL (extp) = 1;
    1414        14605 :               TREE_STATIC (extp) = 0;
    1415        14605 :               TREE_PUBLIC (extp) = 1;
    1416        14605 :               DECL_INITIAL (extp) = NULL_TREE;
    1417        14605 :               DECL_LANG_SPECIFIC (extp) = NULL;
    1418        14605 :               DECL_CONTEXT (extp) = current_function_decl;
    1419        14605 :               if (TREE_CODE (p) == FUNCTION_DECL)
    1420              :                 {
    1421        13066 :                   DECL_RESULT (extp) = NULL_TREE;
    1422        13066 :                   DECL_SAVED_TREE (extp) = NULL_TREE;
    1423        13066 :                   DECL_STRUCT_FUNCTION (extp) = NULL;
    1424              :                 }
    1425        14605 :               if (b->locus != UNKNOWN_LOCATION)
    1426        14605 :                 DECL_SOURCE_LOCATION (extp) = b->locus;
    1427        14605 :               DECL_CHAIN (extp) = BLOCK_VARS (block);
    1428        14605 :               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    682993578 :           if (scope == file_scope)
    1434    283914266 :               DECL_CONTEXT (p) = context;
    1435              : 
    1436    786318454 :           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    786318454 :         case PARM_DECL:
    1443    786318454 :         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    786318454 :           if (b->id)
    1447              :             {
    1448    783049868 :               gcc_assert (I_SYMBOL_BINDING (b->id) == b);
    1449    783049868 :               I_SYMBOL_BINDING (b->id) = b->shadowed;
    1450    783049868 :               if (b->shadowed && b->shadowed->u.type)
    1451      4921351 :                 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     95457946 :   if ((scope->function_body || scope == file_scope) && context)
    1463              :     {
    1464     37823676 :       DECL_INITIAL (context) = block;
    1465     37823676 :       BLOCK_SUPERCONTEXT (block) = context;
    1466              :     }
    1467     57634270 :   else if (scope->outer)
    1468              :     {
    1469     57524575 :       if (block)
    1470       289874 :         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     57234701 :       else if (scope->blocks)
    1475       365071 :         SCOPE_LIST_CONCAT (scope->outer, blocks, scope, blocks);
    1476              :     }
    1477              : 
    1478              :   /* Pop the current scope, and free the structure for reuse.  */
    1479     95457946 :   current_scope = scope->outer;
    1480     95457946 :   if (scope->function_body)
    1481     37713983 :     current_function_scope = scope->outer_function;
    1482              : 
    1483     95457946 :   memset (scope, 0, sizeof (struct c_scope));
    1484     95457946 :   scope->outer = scope_freelist;
    1485     95457946 :   scope_freelist = scope;
    1486              : 
    1487     95457946 :   return block;
    1488              : }
    1489              : 
    1490              : void
    1491       110226 : push_file_scope (void)
    1492              : {
    1493       110226 :   tree decl;
    1494              : 
    1495       110226 :   if (file_scope)
    1496              :     return;
    1497              : 
    1498              :   /* Call the target stack_protect_guard hook if the stack protection
    1499              :      guard is declared as a global symbol.  */
    1500       110226 :   if (targetm.stack_protect_guard_symbol_p ())
    1501              :     {
    1502           17 :       tree decl = targetm.stack_protect_guard ();
    1503           17 :       DECL_CHAIN (decl) = visible_builtins;
    1504           17 :       visible_builtins = decl;
    1505              :     }
    1506              : 
    1507       110226 :   push_scope ();
    1508       110226 :   file_scope = current_scope;
    1509              : 
    1510       110226 :   start_fname_decls ();
    1511              : 
    1512    221067040 :   for (decl = visible_builtins; decl; decl = DECL_CHAIN (decl))
    1513    220956814 :     bind (DECL_NAME (decl), decl, file_scope,
    1514    220956814 :           /*invisible=*/false, /*nested=*/true, DECL_SOURCE_LOCATION (decl));
    1515              : }
    1516              : 
    1517              : void
    1518       110068 : pop_file_scope (void)
    1519              : {
    1520              :   /* In case there were missing closebraces, get us back to the global
    1521              :      binding level.  */
    1522       110073 :   while (current_scope != file_scope)
    1523            5 :     pop_scope ();
    1524              : 
    1525              :   /* __FUNCTION__ is defined at file scope ("").  This
    1526              :      call may not be necessary as my tests indicate it
    1527              :      still works without it.  */
    1528       110068 :   finish_fname_decls ();
    1529              : 
    1530       110068 :   check_inline_statics ();
    1531              : 
    1532              :   /* This is the point to write out a PCH if we're doing that.
    1533              :      In that case we do not want to do anything else.  */
    1534       110068 :   if (pch_file)
    1535              :     {
    1536          373 :       c_common_write_pch ();
    1537              :       /* Ensure even the callers don't try to finalize the CU.  */
    1538          373 :       flag_syntax_only = 1;
    1539          373 :       return;
    1540              :     }
    1541              : 
    1542              :   /* Pop off the file scope and close this translation unit.  */
    1543       109695 :   pop_scope ();
    1544       109695 :   file_scope = 0;
    1545              : 
    1546       109695 :   maybe_apply_pending_pragma_weaks ();
    1547              : }
    1548              : 
    1549              : /* Whether we are currently inside the initializer for an
    1550              :    underspecified object definition (C23 auto or constexpr).  */
    1551              : static bool in_underspecified_init;
    1552              : 
    1553              : /* Start an underspecified object definition for NAME at LOC.  This
    1554              :    means that NAME is shadowed inside its initializer, so neither the
    1555              :    definition being initialized, nor any definition from an outer
    1556              :    scope, may be referenced during that initializer.  Return state to
    1557              :    be passed to finish_underspecified_init.  If NAME is NULL_TREE, the
    1558              :    underspecified object is a (constexpr) compound literal; there is
    1559              :    no shadowing in that case, but all the other restrictions on
    1560              :    underspecified object definitions still apply.  */
    1561              : unsigned int
    1562          693 : start_underspecified_init (location_t loc, tree name)
    1563              : {
    1564          693 :   bool prev = in_underspecified_init;
    1565          693 :   bool ok;
    1566          693 :   if (name == NULL_TREE)
    1567              :     ok = true;
    1568              :   else
    1569              :     {
    1570          459 :       tree decl = build_decl (loc, VAR_DECL, name, error_mark_node);
    1571          459 :       C_DECL_UNDERSPECIFIED (decl) = 1;
    1572          459 :       struct c_scope *scope = current_scope;
    1573          459 :       struct c_binding *b = I_SYMBOL_BINDING (name);
    1574          459 :       if (b && B_IN_SCOPE (b, scope))
    1575              :         {
    1576            4 :           error_at (loc, "underspecified declaration of %qE, which is already "
    1577              :                     "declared in this scope", name);
    1578            4 :           ok = false;
    1579              :         }
    1580              :       else
    1581              :         {
    1582          455 :           bind (name, decl, scope, false, false, loc);
    1583          455 :           ok = true;
    1584              :         }
    1585              :     }
    1586          693 :   in_underspecified_init = true;
    1587          693 :   return ok | (prev << 1);
    1588              : }
    1589              : 
    1590              : /* Finish an underspecified object definition for NAME, before that
    1591              :    name is bound to the real declaration instead of a placeholder.
    1592              :    PREV_STATE is the value returned by the call to
    1593              :    start_underspecified_init.  If NAME is NULL_TREE, this means a
    1594              :    compound literal, as for start_underspecified_init.  */
    1595              : void
    1596          693 : finish_underspecified_init (tree name, unsigned int prev_state)
    1597              : {
    1598          693 :   if (name != NULL_TREE && (prev_state & 1))
    1599              :     {
    1600              :       /* A VAR_DECL was bound to the name to shadow any previous
    1601              :          declarations for the name; remove that binding now.  */
    1602          455 :       struct c_scope *scope = current_scope;
    1603          455 :       struct c_binding *b = I_SYMBOL_BINDING (name);
    1604          455 :       gcc_assert (b);
    1605          455 :       gcc_assert (B_IN_SCOPE (b, scope));
    1606          455 :       gcc_assert (VAR_P (b->decl));
    1607          455 :       gcc_assert (C_DECL_UNDERSPECIFIED (b->decl));
    1608          455 :       I_SYMBOL_BINDING (name) = b->shadowed;
    1609              :       /* In erroneous cases there may be other bindings added to this
    1610              :          scope during the initializer.  */
    1611          455 :       struct c_binding **p = &scope->bindings;
    1612          510 :       while (*p != b)
    1613           55 :         p = &((*p)->prev);
    1614          455 :       *p = free_binding_and_advance (*p);
    1615              :     }
    1616          693 :   in_underspecified_init = (prev_state & (1u << 1)) >> 1;
    1617          693 : }
    1618              : 
    1619              : /* Adjust the bindings for the start of a statement expression.  */
    1620              : 
    1621              : void
    1622        35444 : c_bindings_start_stmt_expr (struct c_spot_bindings* switch_bindings)
    1623              : {
    1624        35444 :   struct c_scope *scope;
    1625              : 
    1626       239233 :   for (scope = current_scope; scope != NULL; scope = scope->outer)
    1627              :     {
    1628       203789 :       struct c_binding *b;
    1629              : 
    1630       203789 :       if (!scope->has_label_bindings)
    1631       201357 :         continue;
    1632              : 
    1633        13263 :       for (b = scope->bindings; b != NULL; b = b->prev)
    1634              :         {
    1635        10831 :           struct c_label_vars *label_vars;
    1636        10831 :           unsigned int ix;
    1637        10831 :           struct c_goto_bindings *g;
    1638              : 
    1639        10831 :           if (TREE_CODE (b->decl) != LABEL_DECL)
    1640         2025 :             continue;
    1641         8806 :           label_vars = b->u.label;
    1642         8806 :           ++label_vars->label_bindings.stmt_exprs;
    1643        13531 :           FOR_EACH_VEC_SAFE_ELT (label_vars->gotos, ix, g)
    1644         1931 :             ++g->goto_bindings.stmt_exprs;
    1645              :         }
    1646              :     }
    1647              : 
    1648        35444 :   if (switch_bindings != NULL)
    1649          361 :     ++switch_bindings->stmt_exprs;
    1650        35444 : }
    1651              : 
    1652              : /* Adjust the bindings for the end of a statement expression.  */
    1653              : 
    1654              : void
    1655        35444 : c_bindings_end_stmt_expr (struct c_spot_bindings *switch_bindings)
    1656              : {
    1657        35444 :   struct c_scope *scope;
    1658              : 
    1659       203789 :   for (scope = current_scope; scope != NULL; scope = scope->outer)
    1660              :     {
    1661       168345 :       struct c_binding *b;
    1662              : 
    1663       168345 :       if (!scope->has_label_bindings)
    1664       165678 :         continue;
    1665              : 
    1666        16747 :       for (b = scope->bindings; b != NULL; b = b->prev)
    1667              :         {
    1668        14080 :           struct c_label_vars *label_vars;
    1669        14080 :           unsigned int ix;
    1670        14080 :           struct c_goto_bindings *g;
    1671              : 
    1672        14080 :           if (TREE_CODE (b->decl) != LABEL_DECL)
    1673         2093 :             continue;
    1674        11987 :           label_vars = b->u.label;
    1675        11987 :           --label_vars->label_bindings.stmt_exprs;
    1676        11987 :           if (label_vars->label_bindings.stmt_exprs < 0)
    1677              :             {
    1678         3322 :               label_vars->label_bindings.left_stmt_expr = true;
    1679         3322 :               label_vars->label_bindings.stmt_exprs = 0;
    1680              :             }
    1681        16772 :           FOR_EACH_VEC_SAFE_ELT (label_vars->gotos, ix, g)
    1682              :             {
    1683         1927 :               --g->goto_bindings.stmt_exprs;
    1684         1927 :               if (g->goto_bindings.stmt_exprs < 0)
    1685              :                 {
    1686          128 :                   g->goto_bindings.left_stmt_expr = true;
    1687          128 :                   g->goto_bindings.stmt_exprs = 0;
    1688              :                 }
    1689              :             }
    1690              :         }
    1691              :     }
    1692              : 
    1693        35444 :   if (switch_bindings != NULL)
    1694              :     {
    1695          361 :       --switch_bindings->stmt_exprs;
    1696          361 :       gcc_assert (switch_bindings->stmt_exprs >= 0);
    1697              :     }
    1698        35444 : }
    1699              : 
    1700              : /* Push a definition or a declaration of struct, union or enum tag "name".
    1701              :    "type" should be the type node.
    1702              :    We assume that the tag "name" is not already defined, and has a location
    1703              :    of LOC.
    1704              : 
    1705              :    Note that the definition may really be just a forward reference.
    1706              :    In that case, the TYPE_SIZE will be zero.  */
    1707              : 
    1708              : static void
    1709      1457896 : pushtag (location_t loc, tree name, tree type)
    1710              : {
    1711              :   /* Record the identifier as the type's name if it has none.  */
    1712      1457896 :   if (name && !TYPE_NAME (type))
    1713       641752 :     TYPE_NAME (type) = name;
    1714      1457896 :   bind (name, type, current_scope, /*invisible=*/false, /*nested=*/false, loc);
    1715              : 
    1716              :   /* Create a fake NULL-named TYPE_DECL node whose TREE_TYPE will be the
    1717              :      tagged type we just added to the current scope.  This fake
    1718              :      NULL-named TYPE_DECL node helps dwarfout.c to know when it needs
    1719              :      to output a representation of a tagged type, and it also gives
    1720              :      us a convenient place to record the "scope start" address for the
    1721              :      tagged type, and it is used to track whether the type is used
    1722              :      in a non-local context via mark_decl_used.  */
    1723              : 
    1724      1457896 :   TYPE_STUB_DECL (type) = pushdecl (build_decl (loc,
    1725              :                                                 TYPE_DECL, NULL_TREE, type));
    1726              : 
    1727              :   /* An approximation for now, so we can tell this is a function-scope tag.
    1728              :      This will be updated in pop_scope.  */
    1729      1457896 :   TYPE_CONTEXT (type) = DECL_CONTEXT (TYPE_STUB_DECL (type));
    1730              : 
    1731      1457896 :   if (warn_cxx_compat && name != NULL_TREE)
    1732              :     {
    1733        22161 :       struct c_binding *b = I_SYMBOL_BINDING (name);
    1734              : 
    1735        22161 :       if (b != NULL
    1736           16 :           && b->decl != NULL_TREE
    1737           16 :           && TREE_CODE (b->decl) == TYPE_DECL
    1738           11 :           && (B_IN_CURRENT_SCOPE (b)
    1739            6 :               || (current_scope == file_scope && B_IN_EXTERNAL_SCOPE (b)))
    1740        22166 :           && (TYPE_MAIN_VARIANT (TREE_TYPE (b->decl))
    1741            5 :               != TYPE_MAIN_VARIANT (type)))
    1742              :         {
    1743            5 :           auto_diagnostic_group d;
    1744            6 :           if (warning_at (loc, OPT_Wc___compat,
    1745              :                           "using %qD as both a typedef and a tag is "
    1746              :                           "invalid in C++", b->decl)
    1747            5 :               && b->locus != UNKNOWN_LOCATION)
    1748            4 :             inform (b->locus, "originally defined here");
    1749            5 :         }
    1750              :     }
    1751      1457896 : }
    1752              : 
    1753              : /* An exported interface to pushtag.  This is used by the gdb plugin's
    1754              :    binding oracle to introduce a new tag binding.  */
    1755              : 
    1756              : void
    1757            0 : c_pushtag (location_t loc, tree name, tree type)
    1758              : {
    1759            0 :   pushtag (loc, name, type);
    1760            0 : }
    1761              : 
    1762              : /* An exported interface to bind a declaration.  LOC is the location
    1763              :    to use.  DECL is the declaration to bind.  The decl's name is used
    1764              :    to determine how it is bound.  If DECL is a VAR_DECL, then
    1765              :    IS_GLOBAL determines whether the decl is put into the global (file
    1766              :    and external) scope or the current function's scope; if DECL is not
    1767              :    a VAR_DECL then it is always put into the file scope.  */
    1768              : 
    1769              : void
    1770            0 : c_bind (location_t loc, tree decl, bool is_global)
    1771              : {
    1772            0 :   struct c_scope *scope;
    1773            0 :   bool nested = false;
    1774              : 
    1775            0 :   if (!VAR_P (decl) || current_function_scope == NULL)
    1776              :     {
    1777              :       /* Types and functions are always considered to be global.  */
    1778            0 :       scope = file_scope;
    1779            0 :       DECL_EXTERNAL (decl) = 1;
    1780            0 :       TREE_PUBLIC (decl) = 1;
    1781              :     }
    1782            0 :   else if (is_global)
    1783              :     {
    1784              :       /* Also bind it into the external scope.  */
    1785            0 :       bind (DECL_NAME (decl), decl, external_scope, true, false, loc);
    1786            0 :       nested = true;
    1787            0 :       scope = file_scope;
    1788            0 :       DECL_EXTERNAL (decl) = 1;
    1789            0 :       TREE_PUBLIC (decl) = 1;
    1790              :     }
    1791              :   else
    1792              :     {
    1793            0 :       DECL_CONTEXT (decl) = current_function_decl;
    1794            0 :       TREE_PUBLIC (decl) = 0;
    1795            0 :       scope = current_function_scope;
    1796              :     }
    1797              : 
    1798            0 :   bind (DECL_NAME (decl), decl, scope, false, nested, loc);
    1799            0 : }
    1800              : 
    1801              : 
    1802              : /* Stores the first FILE*, const struct tm* etc. argument type (whatever
    1803              :    it is) seen in a declaration of a file I/O etc. built-in, corresponding
    1804              :    to the builtin_structptr_types array.  Subsequent declarations of such
    1805              :    built-ins are expected to refer to it rather than to fileptr_type_node,
    1806              :    etc. which is just void* (or to any other type).
    1807              :    Used only by match_builtin_function_types.  */
    1808              : 
    1809              : static const unsigned builtin_structptr_type_count
    1810              :   = ARRAY_SIZE (builtin_structptr_types);
    1811              : 
    1812              : static GTY(()) tree last_structptr_types[builtin_structptr_type_count];
    1813              : 
    1814              : /* Returns true if types T1 and T2 representing return types or types
    1815              :    of function arguments are close enough to be considered interchangeable
    1816              :    in redeclarations of built-in functions.  */
    1817              : 
    1818              : static bool
    1819       631503 : types_close_enough_to_match (tree t1, tree t2)
    1820              : {
    1821       631503 :   return (TYPE_MODE (t1) == TYPE_MODE (t2)
    1822       631055 :           && POINTER_TYPE_P (t1) == POINTER_TYPE_P (t2)
    1823      2524515 :           && FUNCTION_POINTER_TYPE_P (t1) == FUNCTION_POINTER_TYPE_P (t2));
    1824              : }
    1825              : 
    1826              : /* Subroutine of compare_decls.  Allow harmless mismatches in return
    1827              :    and argument types provided that the type modes match.  Set *STRICT
    1828              :    and *ARGNO to the expected argument type and number in case of
    1829              :    an argument type mismatch or null and zero otherwise.  Return
    1830              :    a unified type given a suitable match, and 0 otherwise.  */
    1831              : 
    1832              : static tree
    1833       146519 : match_builtin_function_types (tree newtype, tree oldtype,
    1834              :                               tree *strict, unsigned *argno)
    1835              : {
    1836       146519 :   *argno = 0;
    1837       146519 :   *strict = NULL_TREE;
    1838              : 
    1839              :   /* Accept the return type of the new declaration if it has the same
    1840              :      mode and if they're both pointers or if neither is.  */
    1841       146519 :   tree oldrettype = TREE_TYPE (oldtype);
    1842       146519 :   tree newrettype = TREE_TYPE (newtype);
    1843              : 
    1844       146519 :   if (!types_close_enough_to_match (oldrettype, newrettype))
    1845              :     return NULL_TREE;
    1846              : 
    1847              :   /* Check that the return types are compatible but don't fail if they
    1848              :      are not (e.g., int vs long in ILP32) and just let the caller know.  */
    1849       146163 :   if (!comptypes (TYPE_MAIN_VARIANT (oldrettype),
    1850       146163 :                   TYPE_MAIN_VARIANT (newrettype)))
    1851           46 :     *strict = oldrettype;
    1852              : 
    1853       146163 :   tree oldargs = TYPE_ARG_TYPES (oldtype);
    1854       146163 :   tree newargs = TYPE_ARG_TYPES (newtype);
    1855       146163 :   tree tryargs = newargs;
    1856              : 
    1857       146163 :   const unsigned nlst = ARRAY_SIZE (last_structptr_types);
    1858       146163 :   const unsigned nbst = ARRAY_SIZE (builtin_structptr_types);
    1859              : 
    1860       146163 :   gcc_checking_assert (nlst == nbst);
    1861              : 
    1862       630951 :   for (unsigned i = 1; oldargs || newargs; ++i)
    1863              :     {
    1864       485043 :       if (!oldargs
    1865       485043 :           || !newargs
    1866       484988 :           || !TREE_VALUE (oldargs)
    1867       970031 :           || !TREE_VALUE (newargs))
    1868              :         return NULL_TREE;
    1869              : 
    1870       484988 :       tree oldtype = TYPE_MAIN_VARIANT (TREE_VALUE (oldargs));
    1871       484988 :       tree newtype = TREE_VALUE (newargs);
    1872       484988 :       if (newtype == error_mark_node)
    1873              :        return NULL_TREE;
    1874       484984 :       newtype = TYPE_MAIN_VARIANT (newtype);
    1875              : 
    1876       484984 :       if (!types_close_enough_to_match (oldtype, newtype))
    1877              :         return NULL_TREE;
    1878              : 
    1879       484841 :       unsigned j = nbst;
    1880       484841 :       if (POINTER_TYPE_P (oldtype))
    1881              :         /* Iterate over well-known struct types like FILE (whose types
    1882              :            aren't known to us) and compare the pointer to each to
    1883              :            the pointer argument.  */
    1884       990091 :         for (j = 0; j < nbst; ++j)
    1885              :           {
    1886       872411 :             if (TREE_VALUE (oldargs) != builtin_structptr_types[j].node)
    1887       726718 :               continue;
    1888              :             /* Store the first FILE* etc. argument type (whatever it is), and
    1889              :                expect any subsequent declarations of file I/O etc. built-ins
    1890              :                to refer to it rather than to fileptr_type_node etc. which is
    1891              :                just void* (or const void*).  */
    1892       145693 :             if (last_structptr_types[j])
    1893              :               {
    1894       127813 :                 if (!comptypes (last_structptr_types[j], newtype))
    1895              :                   {
    1896            2 :                     *argno = i;
    1897            2 :                     *strict = last_structptr_types[j];
    1898              :                   }
    1899              :               }
    1900              :             else
    1901        17880 :               last_structptr_types[j] = newtype;
    1902              :             break;
    1903              :           }
    1904              : 
    1905       484841 :       if (j == nbst && !comptypes (oldtype, newtype))
    1906              :         {
    1907          243 :           if (POINTER_TYPE_P (oldtype))
    1908              :             {
    1909              :               /* For incompatible pointers, only reject differences in
    1910              :                  the unqualified variants of the referenced types but
    1911              :                  consider differences in qualifiers as benign (report
    1912              :                  those to caller via *STRICT below).  */
    1913          204 :               tree oldref = TYPE_MAIN_VARIANT (TREE_TYPE (oldtype));
    1914          204 :               tree newref = TYPE_MAIN_VARIANT (TREE_TYPE (newtype));
    1915          204 :               if (!comptypes (oldref, newref))
    1916              :                 return NULL_TREE;
    1917              :             }
    1918              : 
    1919          190 :           if (!*strict)
    1920              :             {
    1921          186 :               *argno = i;
    1922          186 :               *strict = oldtype;
    1923              :             }
    1924              :         }
    1925              : 
    1926       484788 :       oldargs = TREE_CHAIN (oldargs);
    1927       484788 :       newargs = TREE_CHAIN (newargs);
    1928              :     }
    1929              : 
    1930       145908 :   tree trytype = c_build_function_type (newrettype, tryargs);
    1931              : 
    1932              :   /* Allow declaration to change transaction_safe attribute.  */
    1933       145908 :   tree oldattrs = TYPE_ATTRIBUTES (oldtype);
    1934       145908 :   tree oldtsafe = lookup_attribute ("transaction_safe", oldattrs);
    1935       145908 :   tree newattrs = TYPE_ATTRIBUTES (newtype);
    1936       145908 :   tree newtsafe = lookup_attribute ("transaction_safe", newattrs);
    1937       145908 :   if (oldtsafe && !newtsafe)
    1938            0 :     oldattrs = remove_attribute ("transaction_safe", oldattrs);
    1939       145908 :   else if (newtsafe && !oldtsafe)
    1940            7 :     oldattrs = tree_cons (get_identifier ("transaction_safe"),
    1941              :                           NULL_TREE, oldattrs);
    1942              : 
    1943       145908 :   return c_build_type_attribute_variant (trytype, oldattrs);
    1944              : }
    1945              : 
    1946              : /* Subroutine of diagnose_mismatched_decls.  Check for function type
    1947              :    mismatch involving an empty arglist vs a nonempty one and give clearer
    1948              :    diagnostics.  */
    1949              : static void
    1950          178 : diagnose_arglist_conflict (tree newdecl, tree olddecl,
    1951              :                            tree newtype, tree oldtype)
    1952              : {
    1953          178 :   tree t;
    1954              : 
    1955          178 :   if (TREE_CODE (olddecl) != FUNCTION_DECL
    1956           98 :       || !comptypes (TREE_TYPE (oldtype), TREE_TYPE (newtype))
    1957          305 :       || !((!prototype_p (oldtype) && DECL_INITIAL (olddecl) == NULL_TREE)
    1958           68 :            || (!prototype_p (newtype) && DECL_INITIAL (newdecl) == NULL_TREE)))
    1959              :     return;
    1960              : 
    1961           17 :   t = TYPE_ARG_TYPES (oldtype);
    1962           17 :   if (t == NULL_TREE)
    1963            9 :     t = TYPE_ARG_TYPES (newtype);
    1964           18 :   for (; t; t = TREE_CHAIN (t))
    1965              :     {
    1966           18 :       tree type = TREE_VALUE (t);
    1967              : 
    1968           18 :       if (TREE_CHAIN (t) == NULL_TREE
    1969           18 :           && TYPE_MAIN_VARIANT (type) != void_type_node)
    1970              :         {
    1971           10 :           inform (input_location, "a parameter list with an ellipsis "
    1972              :                   "cannot match an empty parameter name list declaration");
    1973           10 :           break;
    1974              :         }
    1975              : 
    1976            8 :       if (!error_operand_p (type)
    1977            8 :           && c_type_promotes_to (type) != type)
    1978              :         {
    1979            7 :           inform (input_location, "an argument type that has a default "
    1980              :                   "promotion cannot match an empty parameter name list "
    1981              :                   "declaration");
    1982            7 :           break;
    1983              :         }
    1984              :     }
    1985              : }
    1986              : 
    1987              : /* Another subroutine of diagnose_mismatched_decls.  OLDDECL is an
    1988              :    old-style function definition, NEWDECL is a prototype declaration.
    1989              :    Diagnose inconsistencies in the argument list.  Returns TRUE if
    1990              :    the prototype is compatible, FALSE if not.  */
    1991              : static bool
    1992           19 : validate_proto_after_old_defn (tree newdecl, tree newtype, tree oldtype)
    1993              : {
    1994           19 :   tree newargs, oldargs;
    1995           19 :   int i;
    1996              : 
    1997              : #define END_OF_ARGLIST(t) ((t) == void_type_node)
    1998              : 
    1999           19 :   oldargs = TYPE_ACTUAL_ARG_TYPES (oldtype);
    2000           19 :   newargs = TYPE_ARG_TYPES (newtype);
    2001           19 :   i = 1;
    2002              : 
    2003           45 :   for (;;)
    2004              :     {
    2005           32 :       tree oldargtype = TREE_VALUE (oldargs);
    2006           32 :       tree newargtype = TREE_VALUE (newargs);
    2007              : 
    2008           32 :       if (oldargtype == error_mark_node || newargtype == error_mark_node)
    2009              :         return false;
    2010              : 
    2011           58 :       oldargtype = (TYPE_ATOMIC (oldargtype)
    2012           31 :                     ? c_build_qualified_type (TYPE_MAIN_VARIANT (oldargtype),
    2013              :                                               TYPE_QUAL_ATOMIC)
    2014           27 :                     : TYPE_MAIN_VARIANT (oldargtype));
    2015           60 :       newargtype = (TYPE_ATOMIC (newargtype)
    2016           31 :                     ? c_build_qualified_type (TYPE_MAIN_VARIANT (newargtype),
    2017              :                                               TYPE_QUAL_ATOMIC)
    2018           29 :                     : TYPE_MAIN_VARIANT (newargtype));
    2019              : 
    2020           31 :       if (END_OF_ARGLIST (oldargtype) && END_OF_ARGLIST (newargtype))
    2021              :         break;
    2022              : 
    2023              :       /* Reaching the end of just one list means the two decls don't
    2024              :          agree on the number of arguments.  */
    2025           22 :       if (END_OF_ARGLIST (oldargtype))
    2026              :         {
    2027            2 :           error ("prototype for %q+D declares more arguments "
    2028              :                  "than previous old-style definition", newdecl);
    2029            2 :           return false;
    2030              :         }
    2031           20 :       else if (END_OF_ARGLIST (newargtype))
    2032              :         {
    2033            2 :           error ("prototype for %q+D declares fewer arguments "
    2034              :                  "than previous old-style definition", newdecl);
    2035            2 :           return false;
    2036              :         }
    2037              : 
    2038              :       /* Type for passing arg must be consistent with that declared
    2039              :          for the arg.  */
    2040           18 :       else if (!comptypes (oldargtype, newargtype))
    2041              :         {
    2042            5 :           error ("prototype for %q+D declares argument %d"
    2043              :                  " with incompatible type",
    2044              :                  newdecl, i);
    2045            5 :           return false;
    2046              :         }
    2047              : 
    2048           13 :       oldargs = TREE_CHAIN (oldargs);
    2049           13 :       newargs = TREE_CHAIN (newargs);
    2050           13 :       i++;
    2051           13 :     }
    2052              : 
    2053              :   /* If we get here, no errors were found, but do issue a warning
    2054              :      for this poor-style construct.  */
    2055            9 :   warning (0, "prototype for %q+D follows non-prototype definition",
    2056              :            newdecl);
    2057            9 :   return true;
    2058              : #undef END_OF_ARGLIST
    2059              : }
    2060              : 
    2061              : /* Subroutine of diagnose_mismatched_decls.  Report the location of DECL,
    2062              :    first in a pair of mismatched declarations, using the diagnostic
    2063              :    function DIAG.  */
    2064              : static void
    2065          418 : locate_old_decl (tree decl)
    2066              : {
    2067          418 :   if (TREE_CODE (decl) == FUNCTION_DECL
    2068          198 :       && fndecl_built_in_p (decl)
    2069          421 :       && !C_DECL_DECLARED_BUILTIN (decl))
    2070              :     ;
    2071          418 :   else if (DECL_INITIAL (decl))
    2072          119 :     inform (input_location,
    2073              :             "previous definition of %q+D with type %qT",
    2074          119 :             decl, TREE_TYPE (decl));
    2075          299 :   else if (C_DECL_IMPLICIT (decl))
    2076           16 :     inform (input_location,
    2077              :             "previous implicit declaration of %q+D with type %qT",
    2078           16 :             decl, TREE_TYPE (decl));
    2079              :   else
    2080          283 :     inform (input_location,
    2081              :             "previous declaration of %q+D with type %qT",
    2082          283 :             decl, TREE_TYPE (decl));
    2083          418 : }
    2084              : 
    2085              : 
    2086              : /* Helper function.  For a tagged type, it finds the declaration
    2087              :    for a visible tag declared in the same scope if such a
    2088              :    declaration exists.  */
    2089              : static tree
    2090      1168054 : previous_tag (tree type)
    2091              : {
    2092      1168054 :   struct c_binding *b = NULL;
    2093      1168054 :   tree name = c_type_tag (type);
    2094              : 
    2095      1168054 :   if (name)
    2096       581755 :     b = I_TAG_BINDING (name);
    2097              : 
    2098       581755 :   if (b)
    2099       581755 :     b = b->shadowed;
    2100              : 
    2101      1168054 :   if (b && B_IN_CURRENT_SCOPE (b))
    2102          180 :     return b->decl;
    2103              : 
    2104              :   return NULL_TREE;
    2105              : }
    2106              : 
    2107              : /* Subroutine to mark functions as versioned when using the attribute
    2108              :    'target_version'.  */
    2109              : 
    2110              : static void
    2111            0 : maybe_mark_function_versioned (tree decl)
    2112              : {
    2113            0 :   if (!DECL_FUNCTION_VERSIONED (decl))
    2114              :     {
    2115              :       /* Check if the name of the function has been overridden.  */
    2116            0 :       if (DECL_ASSEMBLER_NAME_SET_P (decl)
    2117            0 :           && IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl))[0] == '*')
    2118            0 :         error_at (DECL_SOURCE_LOCATION (decl),
    2119              :                   "cannot use function multiversioning on a renamed function");
    2120              : 
    2121              :       /* We need to insert function version now to make sure the correct
    2122              :          pre-mangled assembler name is recorded.  */
    2123            0 :       cgraph_node *node = cgraph_node::get_create (decl);
    2124              : 
    2125            0 :       if (!node->function_version ())
    2126            0 :         node->insert_new_function_version ();
    2127              : 
    2128            0 :       DECL_FUNCTION_VERSIONED (decl) = 1;
    2129              : 
    2130            0 :       tree mangled_name
    2131            0 :         = targetm.mangle_decl_assembler_name (decl, DECL_NAME (decl));
    2132            0 :       SET_DECL_ASSEMBLER_NAME (decl, mangled_name);
    2133              :     }
    2134            0 : }
    2135              : 
    2136              : /* Subroutine of duplicate_decls.  Compare NEWDECL to OLDDECL.
    2137              :    Returns true if the caller should proceed to merge the two, false
    2138              :    if OLDDECL should simply be discarded.  As a side effect, issues
    2139              :    all necessary diagnostics for invalid or poor-style combinations.
    2140              :    If it returns true, writes the types of NEWDECL and OLDDECL to
    2141              :    *NEWTYPEP and *OLDTYPEP - these may have been adjusted from
    2142              :    TREE_TYPE (NEWDECL, OLDDECL) respectively.  */
    2143              : 
    2144              : static bool
    2145      5255584 : diagnose_mismatched_decls (tree newdecl, tree olddecl,
    2146              :                            tree *newtypep, tree *oldtypep)
    2147              : {
    2148      5255584 :   tree newtype, oldtype;
    2149      5255584 :   bool retval = true;
    2150              : 
    2151              : #define DECL_EXTERN_INLINE(DECL) (DECL_DECLARED_INLINE_P (DECL)  \
    2152              :                                   && DECL_EXTERNAL (DECL))
    2153              : 
    2154              :   /* If we have error_mark_node for either decl or type, just discard
    2155              :      the previous decl - we're in an error cascade already.  */
    2156      5255584 :   if (olddecl == error_mark_node || newdecl == error_mark_node)
    2157              :     return false;
    2158      5255564 :   *oldtypep = oldtype = TREE_TYPE (olddecl);
    2159      5255564 :   *newtypep = newtype = TREE_TYPE (newdecl);
    2160      5255564 :   if (oldtype == error_mark_node || newtype == error_mark_node)
    2161              :     return false;
    2162              : 
    2163              :   /* Two different categories of symbol altogether.  This is an error
    2164              :      unless OLDDECL is a builtin.  OLDDECL will be discarded in any case.  */
    2165      5255556 :   if (TREE_CODE (olddecl) != TREE_CODE (newdecl))
    2166              :     {
    2167           29 :       if (!(TREE_CODE (olddecl) == FUNCTION_DECL
    2168           17 :             && fndecl_built_in_p (olddecl)
    2169           14 :             && !C_DECL_DECLARED_BUILTIN (olddecl)))
    2170              :         {
    2171           16 :           auto_diagnostic_group d;
    2172           16 :           error ("%q+D redeclared as different kind of symbol", newdecl);
    2173           16 :           locate_old_decl (olddecl);
    2174           16 :         }
    2175           13 :       else if (TREE_PUBLIC (newdecl))
    2176            3 :         warning (OPT_Wbuiltin_declaration_mismatch,
    2177              :                  "built-in function %q+D declared as non-function",
    2178              :                  newdecl);
    2179              :       else
    2180           10 :         warning (OPT_Wshadow, "declaration of %q+D shadows "
    2181              :                  "a built-in function", newdecl);
    2182              :       return false;
    2183              :     }
    2184              : 
    2185              :   /* Enumerators have no linkage, so may only be declared once in a
    2186              :      given scope.  */
    2187      5255527 :   if (TREE_CODE (olddecl) == CONST_DECL)
    2188              :     {
    2189           50 :       if (flag_isoc23
    2190           49 :           && TYPE_NAME (DECL_CONTEXT (newdecl))
    2191           47 :           && DECL_CONTEXT (newdecl) != DECL_CONTEXT (olddecl)
    2192           95 :           && TYPE_NAME (DECL_CONTEXT (newdecl)) == TYPE_NAME (DECL_CONTEXT (olddecl)))
    2193              :         {
    2194           42 :           if (!simple_cst_equal (DECL_INITIAL (olddecl), DECL_INITIAL (newdecl)))
    2195              :             {
    2196            1 :               auto_diagnostic_group d;
    2197            1 :               error ("conflicting redeclaration of enumerator %q+D", newdecl);
    2198            1 :               locate_old_decl (olddecl);
    2199            1 :             }
    2200              :         }
    2201              :       else
    2202              :         {
    2203            8 :           auto_diagnostic_group d;
    2204            8 :           error ("redeclaration of enumerator %q+D", newdecl);
    2205            8 :           locate_old_decl (olddecl);
    2206            8 :         }
    2207              :       return false;
    2208              :     }
    2209              : 
    2210      5255477 :   bool pedwarned = false;
    2211      5255477 :   bool warned = false;
    2212      5255477 :   bool enum_and_int_p = false;
    2213      5255477 :   auto_diagnostic_group d;
    2214              : 
    2215      5255477 :   bool comptypes_result = comptypes_check_enum_int (oldtype, newtype,
    2216              :                                                     &enum_and_int_p);
    2217      5255477 :   if (!comptypes_result)
    2218              :     {
    2219       146728 :       if (TREE_CODE (olddecl) == FUNCTION_DECL
    2220       146648 :           && fndecl_built_in_p (olddecl, BUILT_IN_NORMAL)
    2221       293248 :           && !C_DECL_DECLARED_BUILTIN (olddecl))
    2222              :         {
    2223              :           /* Accept "harmless" mismatches in function types such
    2224              :              as missing qualifiers or int vs long when they're the same
    2225              :              size.  However, diagnose return and argument types that are
    2226              :              incompatible according to language rules.  */
    2227       146519 :           tree mismatch_expect;
    2228       146519 :           unsigned mismatch_argno;
    2229              : 
    2230       146519 :           tree trytype = match_builtin_function_types (newtype, oldtype,
    2231              :                                                        &mismatch_expect,
    2232              :                                                        &mismatch_argno);
    2233              : 
    2234       146519 :           if (trytype && comptypes (newtype, trytype))
    2235       145908 :             *oldtypep = oldtype = trytype;
    2236              :           else
    2237              :             {
    2238              :               /* If types don't match for a built-in, throw away the
    2239              :                  built-in.  No point in calling locate_old_decl here, it
    2240              :                  won't print anything.  */
    2241          611 :               const char *header = header_for_builtin_fn (olddecl);
    2242          611 :               location_t loc = DECL_SOURCE_LOCATION (newdecl);
    2243         1011 :               if (warning_at (loc, OPT_Wbuiltin_declaration_mismatch,
    2244              :                               "conflicting types for built-in function %q+D; "
    2245              :                               "expected %qT",
    2246              :                               newdecl, oldtype)
    2247          611 :                   && header)
    2248              :                 {
    2249              :                   /* Suggest the right header to include as the preferred
    2250              :                      solution rather than the spelling of the declaration.  */
    2251          211 :                   rich_location richloc (line_table, loc);
    2252          211 :                   maybe_add_include_fixit (&richloc, header, true);
    2253          211 :                   inform (&richloc,
    2254              :                           "%qD is declared in header %qs", olddecl, header);
    2255          211 :                 }
    2256          611 :               return false;
    2257              :             }
    2258              : 
    2259       145908 :           if (mismatch_expect && extra_warnings)
    2260              :             {
    2261            5 :               location_t newloc = DECL_SOURCE_LOCATION (newdecl);
    2262            5 :               bool warned = false;
    2263            5 :               if (mismatch_argno)
    2264            5 :                 warned = warning_at (newloc, OPT_Wbuiltin_declaration_mismatch,
    2265              :                                      "mismatch in argument %u type of built-in "
    2266              :                                      "function %qD; expected %qT",
    2267              :                                      mismatch_argno, newdecl, mismatch_expect);
    2268              :               else
    2269            0 :                 warned = warning_at (newloc, OPT_Wbuiltin_declaration_mismatch,
    2270              :                                      "mismatch in return type of built-in "
    2271              :                                      "function %qD; expected %qT",
    2272              :                                      newdecl, mismatch_expect);
    2273            5 :               const char *header = header_for_builtin_fn (olddecl);
    2274            5 :               if (warned && header)
    2275              :                 {
    2276            5 :                   rich_location richloc (line_table, newloc);
    2277            5 :                   maybe_add_include_fixit (&richloc, header, true);
    2278            5 :                   inform (&richloc,
    2279              :                           "%qD is declared in header %qs", olddecl, header);
    2280            5 :                 }
    2281              :             }
    2282              :         }
    2283          209 :       else if (TREE_CODE (olddecl) == FUNCTION_DECL
    2284          209 :                && DECL_IS_UNDECLARED_BUILTIN (olddecl))
    2285              :         {
    2286              :           /* A conflicting function declaration for a predeclared
    2287              :              function that isn't actually built in.  Objective C uses
    2288              :              these.  The new declaration silently overrides everything
    2289              :              but the volatility (i.e. noreturn) indication.  See also
    2290              :              below.  FIXME: Make Objective C use normal builtins.  */
    2291            0 :           TREE_THIS_VOLATILE (newdecl) |= TREE_THIS_VOLATILE (olddecl);
    2292            0 :           return false;
    2293              :         }
    2294              :       /* Permit void foo (...) to match int foo (...) if the latter is
    2295              :          the definition and implicit int was used.  See
    2296              :          c-torture/compile/920625-2.c.  */
    2297          129 :       else if (TREE_CODE (newdecl) == FUNCTION_DECL && DECL_INITIAL (newdecl)
    2298           64 :                && TYPE_MAIN_VARIANT (TREE_TYPE (oldtype)) == void_type_node
    2299           32 :                && TYPE_MAIN_VARIANT (TREE_TYPE (newtype)) == integer_type_node
    2300          215 :                && C_FUNCTION_IMPLICIT_INT (newdecl) && !DECL_INITIAL (olddecl))
    2301              :         {
    2302            5 :           pedwarned = pedwarn (input_location, 0,
    2303              :                                "conflicting types for %q+D", newdecl);
    2304              :           /* Make sure we keep void as the return type.  */
    2305            5 :           TREE_TYPE (newdecl) = *newtypep = newtype = oldtype;
    2306            5 :           C_FUNCTION_IMPLICIT_INT (newdecl) = 0;
    2307              :         }
    2308              :       /* Permit void foo (...) to match an earlier call to foo (...) with
    2309              :          no declared type (thus, implicitly int).  */
    2310          204 :       else if (TREE_CODE (newdecl) == FUNCTION_DECL
    2311          124 :                && TYPE_MAIN_VARIANT (TREE_TYPE (newtype)) == void_type_node
    2312           92 :                && TYPE_MAIN_VARIANT (TREE_TYPE (oldtype)) == integer_type_node
    2313          227 :                && C_DECL_IMPLICIT (olddecl) && !DECL_INITIAL (olddecl))
    2314              :         {
    2315           19 :           pedwarned = pedwarn (input_location, 0,
    2316              :                                "conflicting types for %q+D; have %qT",
    2317              :                                newdecl, newtype);
    2318              :           /* Make sure we keep void as the return type.  */
    2319           19 :           TREE_TYPE (olddecl) = *oldtypep = oldtype = newtype;
    2320              :         }
    2321              :       else
    2322              :         {
    2323          185 :           auto new_quals = TYPE_QUALS (newtype);
    2324          185 :           auto old_quals = TYPE_QUALS (oldtype);
    2325              : 
    2326          185 :           if (new_quals != old_quals)
    2327              :             {
    2328           21 :               addr_space_t new_addr, old_addr;
    2329           21 :               cv_qualifier new_cv, old_cv;
    2330           21 :               std::tie (new_cv, new_addr) = new_quals.split ();
    2331           21 :               std::tie (old_cv, old_addr) = old_quals.split ();
    2332           21 :               if (new_addr != old_addr)
    2333              :                 {
    2334            0 :                   if (ADDR_SPACE_GENERIC_P (new_addr))
    2335            0 :                     error ("conflicting named address spaces (generic vs %s) "
    2336              :                            "for %q+D",
    2337              :                            c_addr_space_name (old_addr), newdecl);
    2338            0 :                   else if (ADDR_SPACE_GENERIC_P (old_addr))
    2339            0 :                     error ("conflicting named address spaces (%s vs generic) "
    2340              :                            "for %q+D",
    2341              :                            c_addr_space_name (new_addr), newdecl);
    2342              :                   else
    2343            0 :                     error ("conflicting named address spaces (%s vs %s) "
    2344              :                            "for %q+D",
    2345              :                            c_addr_space_name (new_addr),
    2346              :                            c_addr_space_name (old_addr),
    2347              :                            newdecl);
    2348              :                 }
    2349              : 
    2350           21 :               if (new_cv != old_cv)
    2351           21 :                 error ("conflicting type qualifiers for %q+D", newdecl);
    2352              :             }
    2353              :           else
    2354              :             {
    2355          164 :               if (TREE_CODE (olddecl) == FUNCTION_DECL)
    2356              :                 {
    2357           93 :                   tree attrs = TYPE_ATTRIBUTES (TREE_TYPE (olddecl));
    2358           93 :                   if (attrs && !TYPE_ATTRIBUTES (TREE_TYPE (newdecl)))
    2359              :                     {
    2360              :                       /* Similar to the C++ front-end, for FUNCTION_DECL,
    2361              :                          if OLDDECL has attributes and NEWDECL doesn't,
    2362              :                          try the type with OLDDECL attributes.  */
    2363           12 :                       tree rettype = TREE_TYPE (newtype);
    2364           12 :                       tree tryargs = TYPE_ARG_TYPES (newtype);
    2365           12 :                       tree trytype = c_build_function_type (rettype,
    2366              :                                                             tryargs);
    2367           12 :                       trytype = c_build_type_attribute_variant (trytype,
    2368              :                                                                 attrs);
    2369           12 :                       if (comptypes (oldtype, trytype))
    2370              :                         {
    2371            7 :                           *newtypep = newtype = trytype;
    2372            7 :                           comptypes_result = true;
    2373              :                         }
    2374              :                     }
    2375              :                 }
    2376              : 
    2377            7 :               if (!comptypes_result)
    2378          157 :                 error ("conflicting types for %q+D; have %qT", newdecl,
    2379              :                        newtype);
    2380              :             }
    2381          178 :           if (!comptypes_result)
    2382              :             {
    2383          178 :               diagnose_arglist_conflict (newdecl, olddecl, newtype,
    2384              :                                          oldtype);
    2385          178 :               locate_old_decl (olddecl);
    2386          178 :               return false;
    2387              :             }
    2388              :         }
    2389              :     }
    2390              :   /* Warn about enum/integer type mismatches.  They are compatible types
    2391              :      (C23 6.7.2.2/5), but may pose portability problems.  */
    2392      5108749 :   else if (enum_and_int_p
    2393          194 :            && TREE_CODE (newdecl) != TYPE_DECL
    2394              :            /* Don't warn about acc_on_device built-in redeclaration,
    2395              :               the built-in is declared with int rather than enum because
    2396              :               the enum isn't intrinsic.  */
    2397      5108939 :            && !(TREE_CODE (olddecl) == FUNCTION_DECL
    2398          153 :                 && fndecl_built_in_p (olddecl, BUILT_IN_ACC_ON_DEVICE)
    2399          123 :                 && !C_DECL_DECLARED_BUILTIN (olddecl)))
    2400           67 :     warned = warning_at (DECL_SOURCE_LOCATION (newdecl),
    2401           67 :                          OPT_Wenum_int_mismatch,
    2402              :                          "conflicting types for %q+D due to enum/integer "
    2403              :                          "mismatch; have %qT", newdecl, newtype);
    2404              : 
    2405              :   /* Redeclaration of a type is a constraint violation (6.7.2.3p1),
    2406              :      but silently ignore the redeclaration if either is in a system
    2407              :      header.  (Conflicting redeclarations were handled above.)  This
    2408              :      is allowed for C11 if the types are the same, not just
    2409              :      compatible.  */
    2410      5254688 :   if (TREE_CODE (newdecl) == TYPE_DECL)
    2411              :     {
    2412        46350 :       if (!comptypes_same_p (oldtype, newtype))
    2413              :         {
    2414           11 :           error ("redefinition of typedef %q+D with different type", newdecl);
    2415           11 :           locate_old_decl (olddecl);
    2416           11 :           return false;
    2417              :         }
    2418              : 
    2419        46339 :       if (DECL_IN_SYSTEM_HEADER (newdecl)
    2420         2499 :           || DECL_IN_SYSTEM_HEADER (olddecl)
    2421         2275 :           || warning_suppressed_p (newdecl, OPT_Wpedantic)
    2422        48614 :           || warning_suppressed_p (olddecl, OPT_Wpedantic))
    2423              :         return true;  /* Allow OLDDECL to continue in use.  */
    2424              : 
    2425         2275 :       if (c_type_variably_modified_p (newtype))
    2426              :         {
    2427            3 :           error ("redefinition of typedef %q+D with variably modified type",
    2428              :                  newdecl);
    2429            3 :           locate_old_decl (olddecl);
    2430              :         }
    2431         2272 :       else if (pedwarn_c99 (input_location, OPT_Wpedantic,
    2432              :                             "redefinition of typedef %q+D", newdecl))
    2433            8 :         locate_old_decl (olddecl);
    2434              : 
    2435              :       return true;
    2436              :     }
    2437              : 
    2438              :   /* Function declarations can either be 'static' or 'extern' (no
    2439              :      qualifier is equivalent to 'extern' - C99 6.2.2p5) and therefore
    2440              :      can never conflict with each other on account of linkage
    2441              :      (6.2.2p4).  Multiple definitions are not allowed (6.9p3,5) but
    2442              :      gnu89 mode permits two definitions if one is 'extern inline' and
    2443              :      one is not.  The non- extern-inline definition supersedes the
    2444              :      extern-inline definition.  */
    2445              : 
    2446      5208338 :   else if (TREE_CODE (newdecl) == FUNCTION_DECL)
    2447              :     {
    2448              :       /* If you declare a built-in function name as static, or
    2449              :          define the built-in with an old-style definition (so we
    2450              :          can't validate the argument list) the built-in definition is
    2451              :          overridden, but optionally warn this was a bad choice of name.  */
    2452      5189624 :       if (fndecl_built_in_p (olddecl)
    2453      9259158 :           && !C_DECL_DECLARED_BUILTIN (olddecl))
    2454              :         {
    2455      3803822 :           if (!TREE_PUBLIC (newdecl)
    2456      3803822 :               || (DECL_INITIAL (newdecl)
    2457         4862 :                   && !prototype_p (TREE_TYPE (newdecl))))
    2458              :             {
    2459          104 :               warning_at (DECL_SOURCE_LOCATION (newdecl),
    2460          104 :                           OPT_Wshadow, "declaration of %qD shadows "
    2461              :                           "a built-in function", newdecl);
    2462              :               /* Discard the old built-in function.  */
    2463          104 :               return false;
    2464              :             }
    2465              : 
    2466      3803718 :           if (!prototype_p (TREE_TYPE (newdecl)))
    2467              :             {
    2468              :               /* Set for built-ins that take no arguments.  */
    2469          350 :               bool func_void_args = false;
    2470          350 :               if (tree at = TYPE_ARG_TYPES (oldtype))
    2471          350 :                 func_void_args = VOID_TYPE_P (TREE_VALUE (at));
    2472              : 
    2473          350 :               if (extra_warnings && !func_void_args)
    2474           47 :                 warning_at (DECL_SOURCE_LOCATION (newdecl),
    2475           47 :                             OPT_Wbuiltin_declaration_mismatch,
    2476              :                             "declaration of built-in function %qD without "
    2477              :                             "a prototype; expected %qT",
    2478           47 :                             newdecl, TREE_TYPE (olddecl));
    2479              :             }
    2480              :         }
    2481              : 
    2482      5189520 :       if (DECL_INITIAL (newdecl))
    2483              :         {
    2484       235271 :           if (DECL_INITIAL (olddecl))
    2485              :             {
    2486              :               /* If the new declaration isn't overriding an extern inline
    2487              :                  reject the new decl. In c99, no overriding is allowed
    2488              :                  in the same translation unit.  */
    2489          209 :               if (!DECL_EXTERN_INLINE (olddecl)
    2490           91 :                   || DECL_EXTERN_INLINE (newdecl)
    2491          204 :                   || (!flag_gnu89_inline
    2492           15 :                       && (!DECL_DECLARED_INLINE_P (olddecl)
    2493           15 :                           || !lookup_attribute ("gnu_inline",
    2494           15 :                                                 DECL_ATTRIBUTES (olddecl)))
    2495            0 :                       && (!DECL_DECLARED_INLINE_P (newdecl)
    2496            0 :                           || !lookup_attribute ("gnu_inline",
    2497            0 :                                                 DECL_ATTRIBUTES (newdecl)))))
    2498              :                 {
    2499           26 :                   auto_diagnostic_group d;
    2500           26 :                   error ("redefinition of %q+D", newdecl);
    2501           26 :                   locate_old_decl (olddecl);
    2502           26 :                   return false;
    2503           26 :                 }
    2504              :             }
    2505              :         }
    2506              :       /* If we have a prototype after an old-style function definition,
    2507              :          the argument types must be checked specially.  */
    2508      4954249 :       else if (DECL_INITIAL (olddecl)
    2509          825 :                && !prototype_p (oldtype) && prototype_p (newtype)
    2510      4954269 :                && TYPE_ACTUAL_ARG_TYPES (oldtype))
    2511              :         {
    2512           19 :           auto_diagnostic_group d;
    2513           19 :           if (!validate_proto_after_old_defn (newdecl, newtype, oldtype))
    2514              :             {
    2515           10 :               locate_old_decl (olddecl);
    2516           10 :               return false;
    2517              :             }
    2518           19 :         }
    2519              :       /* A non-static declaration (even an "extern") followed by a
    2520              :          static declaration is undefined behavior per C99 6.2.2p3-5,7.
    2521              :          The same is true for a static forward declaration at block
    2522              :          scope followed by a non-static declaration/definition at file
    2523              :          scope.  Static followed by non-static at the same scope is
    2524              :          not undefined behavior, and is the most convenient way to get
    2525              :          some effects (see e.g.  what unwind-dw2-fde-glibc.c does to
    2526              :          the definition of _Unwind_Find_FDE in unwind-dw2-fde.c), but
    2527              :          we do diagnose it if -Wtraditional.  */
    2528      5189484 :       if (TREE_PUBLIC (olddecl) && !TREE_PUBLIC (newdecl))
    2529              :         {
    2530              :           /* Two exceptions to the rule.  If olddecl is an extern
    2531              :              inline, or a predeclared function that isn't actually
    2532              :              built in, newdecl silently overrides olddecl.  The latter
    2533              :              occur only in Objective C; see also above.  (FIXME: Make
    2534              :              Objective C use normal builtins.)  */
    2535           19 :           if (!DECL_IS_UNDECLARED_BUILTIN (olddecl)
    2536           38 :               && !DECL_EXTERN_INLINE (olddecl))
    2537              :             {
    2538            5 :               auto_diagnostic_group d;
    2539            5 :               error ("static declaration of %q+D follows "
    2540              :                      "non-static declaration", newdecl);
    2541            5 :               locate_old_decl (olddecl);
    2542            5 :             }
    2543              :           return false;
    2544              :         }
    2545      5189465 :       else if (TREE_PUBLIC (newdecl) && !TREE_PUBLIC (olddecl))
    2546              :         {
    2547         2330 :           if (DECL_CONTEXT (olddecl))
    2548              :             {
    2549            0 :               auto_diagnostic_group d;
    2550            0 :               error ("non-static declaration of %q+D follows "
    2551              :                      "static declaration", newdecl);
    2552            0 :               locate_old_decl (olddecl);
    2553            0 :               return false;
    2554            0 :             }
    2555         2330 :           else if (warn_traditional)
    2556              :             {
    2557            2 :               warned |= warning (OPT_Wtraditional,
    2558              :                                  "non-static declaration of %q+D "
    2559              :                                  "follows static declaration", newdecl);
    2560              :             }
    2561              :         }
    2562              : 
    2563              :       /* Make sure gnu_inline attribute is either not present, or
    2564              :          present on all inline decls.  */
    2565      5189465 :       if (DECL_DECLARED_INLINE_P (olddecl)
    2566      5190568 :           && DECL_DECLARED_INLINE_P (newdecl))
    2567              :         {
    2568          847 :           bool newa = lookup_attribute ("gnu_inline",
    2569          847 :                                         DECL_ATTRIBUTES (newdecl)) != NULL;
    2570          847 :           bool olda = lookup_attribute ("gnu_inline",
    2571          847 :                                         DECL_ATTRIBUTES (olddecl)) != NULL;
    2572          847 :           if (newa != olda)
    2573              :             {
    2574            0 :               auto_diagnostic_group d;
    2575            0 :               error_at (input_location, "%<gnu_inline%> attribute present on %q+D",
    2576              :                         newa ? newdecl : olddecl);
    2577            0 :               error_at (DECL_SOURCE_LOCATION (newa ? olddecl : newdecl),
    2578              :                         "but not here");
    2579            0 :             }
    2580              :         }
    2581              :       /* Check if these are unmergeable overlapping FMV declarations.  */
    2582              :       if (!TARGET_HAS_FMV_TARGET_ATTRIBUTE
    2583              :           && diagnose_versioned_decls (olddecl, newdecl))
    2584              :         return false;
    2585              :     }
    2586        18714 :   else if (VAR_P (newdecl))
    2587              :     {
    2588              :       /* Only variables can be thread-local, and all declarations must
    2589              :          agree on this property.  */
    2590        18677 :       if (C_DECL_THREADPRIVATE_P (olddecl) && !DECL_THREAD_LOCAL_P (newdecl))
    2591              :         {
    2592              :           /* Nothing to check.  Since OLDDECL is marked threadprivate
    2593              :              and NEWDECL does not have a thread-local attribute, we
    2594              :              will merge the threadprivate attribute into NEWDECL.  */
    2595              :           ;
    2596              :         }
    2597        55808 :       else if (DECL_THREAD_LOCAL_P (newdecl) != DECL_THREAD_LOCAL_P (olddecl))
    2598              :         {
    2599            6 :           auto_diagnostic_group d;
    2600            6 :           if (DECL_THREAD_LOCAL_P (newdecl))
    2601            3 :             error ("thread-local declaration of %q+D follows "
    2602              :                    "non-thread-local declaration", newdecl);
    2603              :           else
    2604            3 :             error ("non-thread-local declaration of %q+D follows "
    2605              :                    "thread-local declaration", newdecl);
    2606              : 
    2607            6 :           locate_old_decl (olddecl);
    2608            6 :           return false;
    2609            6 :         }
    2610              : 
    2611              :       /* Multiple initialized definitions are not allowed (6.9p3,5).
    2612              :          For this purpose, C23 makes it clear that thread-local
    2613              :          declarations without extern are definitions, not tentative
    2614              :          definitions, whether or not they have initializers.  The
    2615              :          wording before C23 was unclear; literally it would have made
    2616              :          uninitialized thread-local declarations into tentative
    2617              :          definitions only if they also used static, but without saying
    2618              :          explicitly whether or not other cases count as
    2619              :          definitions at all.  */
    2620        19252 :       if ((DECL_INITIAL (newdecl) && DECL_INITIAL (olddecl))
    2621        19251 :           || (flag_isoc23
    2622         6503 :               && DECL_THREAD_LOCAL_P (newdecl)
    2623           30 :               && !DECL_EXTERNAL (newdecl)
    2624           21 :               && !DECL_EXTERNAL (olddecl)))
    2625              :         {
    2626            7 :           auto_diagnostic_group d;
    2627            7 :           error ("redefinition of %q+D", newdecl);
    2628            7 :           locate_old_decl (olddecl);
    2629            7 :           return false;
    2630            7 :         }
    2631              : 
    2632              :       /* Objects declared at file scope: if the first declaration had
    2633              :          external linkage (even if it was an external reference) the
    2634              :          second must have external linkage as well, or the behavior is
    2635              :          undefined.  If the first declaration had internal linkage, then
    2636              :          the second must too, or else be an external reference (in which
    2637              :          case the composite declaration still has internal linkage).
    2638              :          As for function declarations, we warn about the static-then-
    2639              :          extern case only for -Wtraditional.  See generally 6.2.2p3-5,7.  */
    2640        18681 :       if (DECL_FILE_SCOPE_P (newdecl)
    2641        18664 :           && TREE_PUBLIC (newdecl) != TREE_PUBLIC (olddecl))
    2642              :         {
    2643          147 :           if (DECL_EXTERNAL (newdecl))
    2644              :             {
    2645          144 :               if (!DECL_FILE_SCOPE_P (olddecl))
    2646              :                 {
    2647            2 :                   auto_diagnostic_group d;
    2648            2 :                   error ("extern declaration of %q+D follows "
    2649              :                          "declaration with no linkage", newdecl);
    2650            2 :                   locate_old_decl (olddecl);
    2651            2 :                   return false;
    2652            2 :                 }
    2653          142 :               else if (warn_traditional)
    2654              :                 {
    2655            0 :                   warned |= warning (OPT_Wtraditional,
    2656              :                                      "non-static declaration of %q+D "
    2657              :                                      "follows static declaration", newdecl);
    2658              :                 }
    2659              :             }
    2660              :           else
    2661              :             {
    2662            3 :               auto_diagnostic_group d;
    2663            3 :               if (TREE_PUBLIC (newdecl))
    2664            2 :                 error ("non-static declaration of %q+D follows "
    2665              :                        "static declaration", newdecl);
    2666              :               else
    2667            1 :                 error ("static declaration of %q+D follows "
    2668              :                        "non-static declaration", newdecl);
    2669              : 
    2670            3 :               locate_old_decl (olddecl);
    2671            3 :               return false;
    2672            3 :             }
    2673              :         }
    2674              :       /* Two objects with the same name declared at the same block
    2675              :          scope must both be external references (6.7p3).  */
    2676        18517 :       else if (!DECL_FILE_SCOPE_P (newdecl))
    2677              :         {
    2678           17 :           if (DECL_EXTERNAL (newdecl))
    2679              :             {
    2680              :               /* Extern with initializer at block scope, which will
    2681              :                  already have received an error.  */
    2682              :             }
    2683           15 :           else if (DECL_EXTERNAL (olddecl))
    2684              :             {
    2685            4 :               auto_diagnostic_group d;
    2686            4 :               error ("declaration of %q+D with no linkage follows "
    2687              :                      "extern declaration", newdecl);
    2688            4 :               locate_old_decl (olddecl);
    2689            4 :             }
    2690              :           else
    2691              :             {
    2692           11 :               auto_diagnostic_group d;
    2693           11 :               error ("redeclaration of %q+D with no linkage", newdecl);
    2694           11 :               locate_old_decl (olddecl);
    2695           11 :             }
    2696              : 
    2697              :           return false;
    2698              :         }
    2699              : 
    2700              :       /* C++ does not permit a decl to appear multiple times at file
    2701              :          scope.  */
    2702        18642 :       if (warn_cxx_compat
    2703          240 :           && DECL_FILE_SCOPE_P (newdecl)
    2704          240 :           && !DECL_EXTERNAL (newdecl)
    2705        18824 :           && !DECL_EXTERNAL (olddecl))
    2706            5 :         warned |= warning_at (DECL_SOURCE_LOCATION (newdecl),
    2707            5 :                               OPT_Wc___compat,
    2708              :                               "duplicate declaration of %qD is "
    2709              :                               "invalid in C++", newdecl);
    2710              :     }
    2711              : 
    2712              :   /* warnings */
    2713              :   /* All decls must agree on a visibility.  */
    2714      5208144 :   if (CODE_CONTAINS_STRUCT (TREE_CODE (newdecl), TS_DECL_WITH_VIS)
    2715      5208107 :       && DECL_VISIBILITY_SPECIFIED (newdecl) && DECL_VISIBILITY_SPECIFIED (olddecl)
    2716      5208900 :       && DECL_VISIBILITY (newdecl) != DECL_VISIBILITY (olddecl))
    2717              :     {
    2718            1 :       warned |= warning (0, "redeclaration of %q+D with different visibility "
    2719              :                          "(old visibility preserved)", newdecl);
    2720              :     }
    2721              : 
    2722      5208144 :   if (TREE_CODE (newdecl) == FUNCTION_DECL)
    2723      5189465 :     warned |= diagnose_mismatched_attributes (olddecl, newdecl);
    2724              :   else /* PARM_DECL, VAR_DECL */
    2725              :     {
    2726              :       /* Redeclaration of a parameter is a constraint violation (this is
    2727              :          not explicitly stated, but follows from C99 6.7p3 [no more than
    2728              :          one declaration of the same identifier with no linkage in the
    2729              :          same scope, except type tags] and 6.2.2p6 [parameters have no
    2730              :          linkage]).  We must check for a forward parameter declaration,
    2731              :          indicated by TREE_ASM_WRITTEN on the old declaration - this is
    2732              :          an extension, the mandatory diagnostic for which is handled by
    2733              :          mark_forward_parm_decls.  */
    2734              : 
    2735        18679 :       if (TREE_CODE (newdecl) == PARM_DECL
    2736           37 :           && (!TREE_ASM_WRITTEN (olddecl) || TREE_ASM_WRITTEN (newdecl)))
    2737              :         {
    2738            2 :           auto_diagnostic_group d;
    2739            2 :           error ("redefinition of parameter %q+D", newdecl);
    2740            2 :           locate_old_decl (olddecl);
    2741            2 :           return false;
    2742            2 :         }
    2743              :     }
    2744              : 
    2745              :   /* Optional warning for completely redundant decls.  */
    2746      5208142 :   if (!warned && !pedwarned
    2747      5208068 :       && warn_redundant_decls
    2748              :       /* Don't warn about a function declaration followed by a
    2749              :          definition.  */
    2750           18 :       && !(TREE_CODE (newdecl) == FUNCTION_DECL
    2751            2 :            && DECL_INITIAL (newdecl) && !DECL_INITIAL (olddecl))
    2752              :       /* Don't warn about redundant redeclarations of builtins.  */
    2753           18 :       && !(TREE_CODE (newdecl) == FUNCTION_DECL
    2754            2 :            && !fndecl_built_in_p (newdecl)
    2755            2 :            && fndecl_built_in_p (olddecl)
    2756            2 :            && !C_DECL_DECLARED_BUILTIN (olddecl))
    2757              :       /* Don't warn about an extern followed by a definition.  */
    2758           17 :       && !(DECL_EXTERNAL (olddecl) && !DECL_EXTERNAL (newdecl))
    2759              :       /* Don't warn about forward parameter decls.  */
    2760           17 :       && !(TREE_CODE (newdecl) == PARM_DECL
    2761            6 :            && TREE_ASM_WRITTEN (olddecl) && !TREE_ASM_WRITTEN (newdecl))
    2762              :       /* Don't warn about a variable definition following a declaration.  */
    2763      5208153 :       && !(VAR_P (newdecl)
    2764           10 :            && DECL_INITIAL (newdecl) && !DECL_INITIAL (olddecl)))
    2765              :     {
    2766            6 :       warned = warning (OPT_Wredundant_decls, "redundant redeclaration of %q+D",
    2767              :                         newdecl);
    2768              :     }
    2769              : 
    2770              :   /* Report location of previous decl/defn.  */
    2771      5208142 :   if (warned || pedwarned)
    2772           80 :     locate_old_decl (olddecl);
    2773              : 
    2774              : #undef DECL_EXTERN_INLINE
    2775              : 
    2776              :   return retval;
    2777      5255477 : }
    2778              : 
    2779              : /* Subroutine of duplicate_decls.  NEWDECL has been found to be
    2780              :    consistent with OLDDECL, but carries new information.  Merge the
    2781              :    new information into OLDDECL.  This function issues no
    2782              :    diagnostics.  */
    2783              : 
    2784              : static void
    2785      5254481 : merge_decls (tree newdecl, tree olddecl, tree newtype, tree oldtype)
    2786              : {
    2787      5254481 :   bool new_is_definition = (TREE_CODE (newdecl) == FUNCTION_DECL
    2788      5254481 :                             && DECL_INITIAL (newdecl) != NULL_TREE);
    2789      5254481 :   bool new_is_prototype = (TREE_CODE (newdecl) == FUNCTION_DECL
    2790      5254481 :                            && prototype_p (TREE_TYPE (newdecl)));
    2791      5254481 :   bool old_is_prototype = (TREE_CODE (olddecl) == FUNCTION_DECL
    2792      5254481 :                            && prototype_p (TREE_TYPE (olddecl)));
    2793              : 
    2794              :   /* For real parm decl following a forward decl, rechain the old decl
    2795              :      in its new location and clear TREE_ASM_WRITTEN (it's not a
    2796              :      forward decl anymore).  */
    2797      5254481 :   if (TREE_CODE (newdecl) == PARM_DECL
    2798           35 :       && TREE_ASM_WRITTEN (olddecl) && !TREE_ASM_WRITTEN (newdecl))
    2799              :     {
    2800           35 :       struct c_binding *b, **here;
    2801              : 
    2802           54 :       for (here = &current_scope->bindings; *here; here = &(*here)->prev)
    2803           54 :         if ((*here)->decl == olddecl)
    2804           35 :           goto found;
    2805            0 :       gcc_unreachable ();
    2806              : 
    2807           35 :     found:
    2808           35 :       b = *here;
    2809           35 :       *here = b->prev;
    2810           35 :       b->prev = current_scope->bindings;
    2811           35 :       current_scope->bindings = b;
    2812              : 
    2813           35 :       TREE_ASM_WRITTEN (olddecl) = 0;
    2814              :     }
    2815              : 
    2816      5254481 :   DECL_ATTRIBUTES (newdecl)
    2817      5254481 :     = targetm.merge_decl_attributes (olddecl, newdecl);
    2818              : 
    2819              :   /* For typedefs use the old type, as the new type's DECL_NAME points
    2820              :      at newdecl, which will be ggc_freed.  */
    2821      5254481 :   if (TREE_CODE (newdecl) == TYPE_DECL)
    2822              :     {
    2823              :       /* But NEWTYPE might have an attribute, honor that.  */
    2824        46339 :       tree tem = newtype;
    2825        46339 :       newtype = oldtype;
    2826              : 
    2827        46339 :       if (TYPE_USER_ALIGN (tem))
    2828              :         {
    2829           15 :           if (TYPE_ALIGN (tem) > TYPE_ALIGN (newtype))
    2830            6 :             SET_TYPE_ALIGN (newtype, TYPE_ALIGN (tem));
    2831           15 :           TYPE_USER_ALIGN (newtype) = true;
    2832              :         }
    2833              : 
    2834              :       /* And remove the new type from the variants list.  */
    2835        46339 :       if (TYPE_NAME (TREE_TYPE (newdecl)) == newdecl)
    2836              :         {
    2837           15 :           tree remove = TREE_TYPE (newdecl);
    2838           15 :           if (TYPE_MAIN_VARIANT (remove) == remove)
    2839              :             {
    2840            2 :               gcc_assert (TYPE_NEXT_VARIANT (remove) == NULL_TREE);
    2841              :               /* If remove is the main variant, no need to remove that
    2842              :                  from the list.  One of the DECL_ORIGINAL_TYPE
    2843              :                  variants, e.g. created for aligned attribute, might still
    2844              :                  refer to the newdecl TYPE_DECL though, so remove that one
    2845              :                  in that case.  */
    2846            2 :               if (DECL_ORIGINAL_TYPE (newdecl)
    2847            2 :                   && DECL_ORIGINAL_TYPE (newdecl) != remove)
    2848            2 :                 for (tree t = TYPE_MAIN_VARIANT (DECL_ORIGINAL_TYPE (newdecl));
    2849            2 :                      t; t = TYPE_MAIN_VARIANT (t))
    2850            2 :                   if (TYPE_NAME (TYPE_NEXT_VARIANT (t)) == newdecl)
    2851              :                     {
    2852            4 :                       TYPE_NEXT_VARIANT (t)
    2853            2 :                         = TYPE_NEXT_VARIANT (TYPE_NEXT_VARIANT (t));
    2854            2 :                       break;
    2855              :                     }
    2856              :             }
    2857              :           else
    2858           13 :             for (tree t = TYPE_MAIN_VARIANT (remove); ;
    2859            0 :                  t = TYPE_NEXT_VARIANT (t))
    2860           13 :               if (TYPE_NEXT_VARIANT (t) == remove)
    2861              :                 {
    2862           13 :                   TYPE_NEXT_VARIANT (t) = TYPE_NEXT_VARIANT (remove);
    2863           13 :                   break;
    2864              :                 }
    2865              :         }
    2866              : 
    2867              :       /* Make sure we refer to the same type as the olddecl.  */
    2868        46339 :       DECL_ORIGINAL_TYPE (newdecl) = DECL_ORIGINAL_TYPE (olddecl);
    2869              :     }
    2870              : 
    2871              :   /* Merge the data types specified in the two decls.  */
    2872     10508962 :   TREE_TYPE (newdecl)
    2873      5254481 :     = TREE_TYPE (olddecl)
    2874     10508962 :     = composite_type (newtype, oldtype);
    2875              : 
    2876              :   /* Lay the type out, unless already done.  */
    2877      5254481 :   if (!comptypes (oldtype, TREE_TYPE (newdecl)))
    2878              :     {
    2879            0 :       if (TREE_TYPE (newdecl) != error_mark_node)
    2880            0 :         layout_type (TREE_TYPE (newdecl));
    2881            0 :       if (TREE_CODE (newdecl) != FUNCTION_DECL
    2882              :           && TREE_CODE (newdecl) != TYPE_DECL
    2883              :           && TREE_CODE (newdecl) != CONST_DECL)
    2884            0 :         layout_decl (newdecl, 0);
    2885              :     }
    2886              :   else
    2887              :     {
    2888              :       /* Since the type is OLDDECL's, make OLDDECL's size go with.  */
    2889      5254481 :       DECL_SIZE (newdecl) = DECL_SIZE (olddecl);
    2890      5254481 :       DECL_SIZE_UNIT (newdecl) = DECL_SIZE_UNIT (olddecl);
    2891      5254481 :       SET_DECL_MODE (newdecl, DECL_MODE (olddecl));
    2892      5254481 :       if (DECL_ALIGN (olddecl) > DECL_ALIGN (newdecl))
    2893              :         {
    2894           44 :           SET_DECL_ALIGN (newdecl, DECL_ALIGN (olddecl));
    2895           44 :           DECL_USER_ALIGN (newdecl) |= DECL_USER_ALIGN (olddecl);
    2896              :         }
    2897      5254437 :       else if (DECL_ALIGN (olddecl) == DECL_ALIGN (newdecl)
    2898      5254437 :                && DECL_USER_ALIGN (olddecl) != DECL_USER_ALIGN (newdecl))
    2899            3 :         DECL_USER_ALIGN (newdecl) = 1;
    2900     10508962 :       if (DECL_WARN_IF_NOT_ALIGN (olddecl)
    2901      5254481 :           > DECL_WARN_IF_NOT_ALIGN (newdecl))
    2902            0 :         SET_DECL_WARN_IF_NOT_ALIGN (newdecl,
    2903              :                                     DECL_WARN_IF_NOT_ALIGN (olddecl));
    2904              :     }
    2905              : 
    2906              :   /* Keep the old rtl since we can safely use it.  */
    2907      5254481 :   if (HAS_RTL_P (olddecl))
    2908      5254481 :     COPY_DECL_RTL (olddecl, newdecl);
    2909              : 
    2910              :   /* Merge the type qualifiers.  */
    2911      5254481 :   if (TREE_READONLY (newdecl))
    2912       417071 :     TREE_READONLY (olddecl) = 1;
    2913              : 
    2914      5254481 :   if (TREE_THIS_VOLATILE (newdecl))
    2915        50342 :     TREE_THIS_VOLATILE (olddecl) = 1;
    2916              : 
    2917              :   /* Merge deprecatedness.  */
    2918      5254481 :   if (TREE_DEPRECATED (newdecl))
    2919          387 :     TREE_DEPRECATED (olddecl) = 1;
    2920              : 
    2921              :   /* Merge unavailability.  */
    2922      5254481 :   if (TREE_UNAVAILABLE (newdecl))
    2923            2 :     TREE_UNAVAILABLE (olddecl) = 1;
    2924              : 
    2925              :   /* If a decl is in a system header and the other isn't, keep the one on the
    2926              :      system header. Otherwise, keep source location of definition rather than
    2927              :      declaration and of prototype rather than non-prototype unless that
    2928              :      prototype is built-in.  */
    2929      5254481 :   if (HAS_DECL_ASSEMBLER_NAME_P (olddecl)
    2930      5254446 :       && DECL_IN_SYSTEM_HEADER (olddecl)
    2931      6019562 :       && !DECL_IN_SYSTEM_HEADER (newdecl) )
    2932         1058 :     DECL_SOURCE_LOCATION (newdecl) = DECL_SOURCE_LOCATION (olddecl);
    2933      5253423 :   else if (HAS_DECL_ASSEMBLER_NAME_P (olddecl)
    2934      5253388 :            && DECL_IN_SYSTEM_HEADER (newdecl)
    2935      9767603 :            && !DECL_IN_SYSTEM_HEADER (olddecl))
    2936      3750157 :     DECL_SOURCE_LOCATION (olddecl) = DECL_SOURCE_LOCATION (newdecl);
    2937      1503266 :   else if ((DECL_INITIAL (newdecl) == NULL_TREE
    2938      1267509 :             && DECL_INITIAL (olddecl) != NULL_TREE)
    2939      2769853 :            || (old_is_prototype && !new_is_prototype
    2940          380 :                && !C_DECL_BUILTIN_PROTOTYPE (olddecl)))
    2941          950 :     DECL_SOURCE_LOCATION (newdecl) = DECL_SOURCE_LOCATION (olddecl);
    2942              : 
    2943              :   /* Merge the initialization information.  */
    2944      5254481 :    if (DECL_INITIAL (newdecl) == NULL_TREE)
    2945      5018652 :     DECL_INITIAL (newdecl) = DECL_INITIAL (olddecl);
    2946              : 
    2947              :   /* Merge 'constexpr' information.  */
    2948      5254481 :   if (VAR_P (olddecl) && VAR_P (newdecl))
    2949              :     {
    2950        18642 :       if (C_DECL_DECLARED_CONSTEXPR (olddecl))
    2951            2 :         C_DECL_DECLARED_CONSTEXPR (newdecl) = 1;
    2952        18640 :       else if (C_DECL_DECLARED_CONSTEXPR (newdecl))
    2953            1 :         C_DECL_DECLARED_CONSTEXPR (olddecl) = 1;
    2954              :     }
    2955              : 
    2956              :   /* Merge the threadprivate attribute.  */
    2957      5254481 :   if (VAR_P (olddecl) && C_DECL_THREADPRIVATE_P (olddecl))
    2958            7 :     C_DECL_THREADPRIVATE_P (newdecl) = 1;
    2959              : 
    2960      5254481 :   if (HAS_DECL_ASSEMBLER_NAME_P (olddecl))
    2961              :     {
    2962              :       /* Copy the assembler name.
    2963              :          Currently, it can only be defined in the prototype.  */
    2964      5254446 :       COPY_DECL_ASSEMBLER_NAME (olddecl, newdecl);
    2965              : 
    2966              :       /* Use visibility of whichever declaration had it specified */
    2967      5254446 :       if (DECL_VISIBILITY_SPECIFIED (olddecl))
    2968              :         {
    2969         4892 :           DECL_VISIBILITY (newdecl) = DECL_VISIBILITY (olddecl);
    2970         4892 :           DECL_VISIBILITY_SPECIFIED (newdecl) = 1;
    2971              :         }
    2972              : 
    2973      5254446 :       if (TREE_CODE (newdecl) == FUNCTION_DECL)
    2974              :         {
    2975      5189465 :           DECL_STATIC_CONSTRUCTOR(newdecl) |= DECL_STATIC_CONSTRUCTOR(olddecl);
    2976      5189465 :           DECL_STATIC_DESTRUCTOR (newdecl) |= DECL_STATIC_DESTRUCTOR (olddecl);
    2977      5189465 :           DECL_NO_LIMIT_STACK (newdecl) |= DECL_NO_LIMIT_STACK (olddecl);
    2978      5189465 :           DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (newdecl)
    2979      5189465 :             |= DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (olddecl);
    2980      5189465 :           TREE_THIS_VOLATILE (newdecl) |= TREE_THIS_VOLATILE (olddecl);
    2981      5189465 :           DECL_IS_MALLOC (newdecl) |= DECL_IS_MALLOC (olddecl);
    2982      5189465 :           if (DECL_IS_OPERATOR_NEW_P (olddecl))
    2983            0 :             DECL_SET_IS_OPERATOR_NEW (newdecl, true);
    2984      5189465 :           if (DECL_IS_OPERATOR_DELETE_P (olddecl))
    2985            0 :             DECL_SET_IS_OPERATOR_DELETE (newdecl, true);
    2986      5189465 :           TREE_READONLY (newdecl) |= TREE_READONLY (olddecl);
    2987      5189465 :           DECL_PURE_P (newdecl) |= DECL_PURE_P (olddecl);
    2988      5189465 :           DECL_IS_NOVOPS (newdecl) |= DECL_IS_NOVOPS (olddecl);
    2989              :         }
    2990              : 
    2991              :       /* Merge the storage class information.  */
    2992      5254446 :       merge_weak (newdecl, olddecl);
    2993              : 
    2994              :       /* For functions, static overrides non-static.  */
    2995      5254446 :       if (TREE_CODE (newdecl) == FUNCTION_DECL)
    2996              :         {
    2997      5189465 :           TREE_PUBLIC (newdecl) &= TREE_PUBLIC (olddecl);
    2998              :           /* This is since we don't automatically
    2999              :              copy the attributes of NEWDECL into OLDDECL.  */
    3000      5189465 :           TREE_PUBLIC (olddecl) = TREE_PUBLIC (newdecl);
    3001              :           /* If this clears `static', clear it in the identifier too.  */
    3002      5189465 :           if (!TREE_PUBLIC (olddecl))
    3003         8008 :             TREE_PUBLIC (DECL_NAME (olddecl)) = 0;
    3004              :         }
    3005              :     }
    3006              : 
    3007              :   /* In c99, 'extern' declaration before (or after) 'inline' means this
    3008              :      function is not DECL_EXTERNAL, unless 'gnu_inline' attribute
    3009              :      is present.  */
    3010      5254481 :   if (TREE_CODE (newdecl) == FUNCTION_DECL
    3011      5189465 :       && !flag_gnu89_inline
    3012      5164579 :       && (DECL_DECLARED_INLINE_P (newdecl)
    3013      4972632 :           || DECL_DECLARED_INLINE_P (olddecl))
    3014       192142 :       && (!DECL_DECLARED_INLINE_P (newdecl)
    3015       191947 :           || !DECL_DECLARED_INLINE_P (olddecl)
    3016          834 :           || !DECL_EXTERNAL (olddecl))
    3017       191326 :       && DECL_EXTERNAL (newdecl)
    3018       191118 :       && !lookup_attribute ("gnu_inline", DECL_ATTRIBUTES (newdecl))
    3019      5254579 :       && !current_function_decl)
    3020           81 :     DECL_EXTERNAL (newdecl) = 0;
    3021              : 
    3022              :   /* An inline definition following a static declaration is not
    3023              :      DECL_EXTERNAL.  */
    3024      5254481 :   if (new_is_definition
    3025       235228 :       && (DECL_DECLARED_INLINE_P (newdecl)
    3026        43047 :           || DECL_DECLARED_INLINE_P (olddecl))
    3027      5446876 :       && !TREE_PUBLIC (olddecl))
    3028          927 :     DECL_EXTERNAL (newdecl) = 0;
    3029              : 
    3030      5254481 :   if (DECL_EXTERNAL (newdecl))
    3031              :     {
    3032      5161824 :       TREE_STATIC (newdecl) = TREE_STATIC (olddecl);
    3033      5161824 :       DECL_EXTERNAL (newdecl) = DECL_EXTERNAL (olddecl);
    3034              : 
    3035              :       /* An extern decl does not override previous storage class.  */
    3036      5161824 :       TREE_PUBLIC (newdecl) = TREE_PUBLIC (olddecl);
    3037      5161824 :       if (!DECL_EXTERNAL (newdecl))
    3038              :         {
    3039         1442 :           DECL_CONTEXT (newdecl) = DECL_CONTEXT (olddecl);
    3040         1442 :           DECL_COMMON (newdecl) = DECL_COMMON (olddecl);
    3041              :         }
    3042              :     }
    3043              :   else
    3044              :     {
    3045        92657 :       TREE_STATIC (olddecl) = TREE_STATIC (newdecl);
    3046        92657 :       TREE_PUBLIC (olddecl) = TREE_PUBLIC (newdecl);
    3047              :     }
    3048              : 
    3049      5254481 :   if (TREE_CODE (newdecl) == FUNCTION_DECL)
    3050              :     {
    3051      5189465 :       if (DECL_FUNCTION_VERSIONED (olddecl)
    3052      5189465 :           || DECL_FUNCTION_VERSIONED (newdecl))
    3053              :         {
    3054            0 :           maybe_mark_function_versioned (olddecl);
    3055            0 :           maybe_mark_function_versioned (newdecl);
    3056              :         }
    3057              :       /* If we're redefining a function previously defined as extern
    3058              :          inline, make sure we emit debug info for the inline before we
    3059              :          throw it away, in case it was inlined into a function that
    3060              :          hasn't been written out yet.  */
    3061      5189465 :       if (new_is_definition && DECL_INITIAL (olddecl))
    3062              :         /* The new defn must not be inline.  */
    3063           75 :         DECL_UNINLINABLE (newdecl) = 1;
    3064              :       else
    3065              :         {
    3066              :           /* If either decl says `inline', this fn is inline, unless
    3067              :              its definition was passed already.  */
    3068      5189390 :           if (DECL_DECLARED_INLINE_P (newdecl)
    3069     10186547 :               || DECL_DECLARED_INLINE_P (olddecl))
    3070       192419 :             DECL_DECLARED_INLINE_P (newdecl) = 1;
    3071              : 
    3072     15568170 :           DECL_UNINLINABLE (newdecl) = DECL_UNINLINABLE (olddecl)
    3073     10380432 :             = (DECL_UNINLINABLE (newdecl) || DECL_UNINLINABLE (olddecl));
    3074              : 
    3075     10378780 :           DECL_DISREGARD_INLINE_LIMITS (newdecl)
    3076      5189390 :             = DECL_DISREGARD_INLINE_LIMITS (olddecl)
    3077      5189390 :             = (DECL_DISREGARD_INLINE_LIMITS (newdecl)
    3078     10378641 :                || DECL_DISREGARD_INLINE_LIMITS (olddecl));
    3079              :         }
    3080              : 
    3081      5189465 :       if (fndecl_built_in_p (olddecl))
    3082              :         {
    3083              :           /* If redeclaring a builtin function, it stays built in.
    3084              :              But it gets tagged as having been declared.  */
    3085      4069430 :           copy_decl_built_in_function (newdecl, olddecl);
    3086      4069430 :           C_DECL_DECLARED_BUILTIN (newdecl) = 1;
    3087      4069430 :           if (new_is_prototype)
    3088              :             {
    3089      4069063 :               C_DECL_BUILTIN_PROTOTYPE (newdecl) = 0;
    3090      4069063 :               if (DECL_BUILT_IN_CLASS (newdecl) == BUILT_IN_NORMAL)
    3091              :                 {
    3092      4069063 :                   enum built_in_function fncode = DECL_FUNCTION_CODE (newdecl);
    3093      4069063 :                   switch (fncode)
    3094              :                     {
    3095              :                       /* If a compatible prototype of these builtin functions
    3096              :                          is seen, assume the runtime implements it with the
    3097              :                          expected semantics.  */
    3098         8502 :                     case BUILT_IN_STPCPY:
    3099         8502 :                       if (builtin_decl_explicit_p (fncode))
    3100         8502 :                         set_builtin_decl_implicit_p (fncode, true);
    3101              :                       break;
    3102      4060561 :                     default:
    3103      4060561 :                       if (builtin_decl_explicit_p (fncode))
    3104      4060561 :                         set_builtin_decl_declared_p (fncode, true);
    3105              :                       break;
    3106              :                     }
    3107              : 
    3108      4069063 :                   copy_attributes_to_builtin (newdecl);
    3109              :                 }
    3110              :             }
    3111              :           else
    3112          734 :             C_DECL_BUILTIN_PROTOTYPE (newdecl)
    3113          734 :               = C_DECL_BUILTIN_PROTOTYPE (olddecl);
    3114              :         }
    3115              : 
    3116              :       /* Preserve function specific target and optimization options */
    3117      5189465 :       if (DECL_FUNCTION_SPECIFIC_TARGET (olddecl)
    3118      5189971 :           && !DECL_FUNCTION_SPECIFIC_TARGET (newdecl))
    3119          470 :         DECL_FUNCTION_SPECIFIC_TARGET (newdecl)
    3120          470 :           = DECL_FUNCTION_SPECIFIC_TARGET (olddecl);
    3121              : 
    3122      5189465 :       if (DECL_FUNCTION_SPECIFIC_OPTIMIZATION (olddecl)
    3123      5214699 :           && !DECL_FUNCTION_SPECIFIC_OPTIMIZATION (newdecl))
    3124            9 :         DECL_FUNCTION_SPECIFIC_OPTIMIZATION (newdecl)
    3125            9 :           = DECL_FUNCTION_SPECIFIC_OPTIMIZATION (olddecl);
    3126              : 
    3127              :       /* Also preserve various other info from the definition.  */
    3128      5189465 :       if (!new_is_definition)
    3129              :         {
    3130      4954237 :           tree t;
    3131      4954237 :           DECL_RESULT (newdecl) = DECL_RESULT (olddecl);
    3132      4954237 :           DECL_INITIAL (newdecl) = DECL_INITIAL (olddecl);
    3133      4954237 :           DECL_STRUCT_FUNCTION (newdecl) = DECL_STRUCT_FUNCTION (olddecl);
    3134      4954237 :           DECL_SAVED_TREE (newdecl) = DECL_SAVED_TREE (olddecl);
    3135      4954237 :           DECL_ARGUMENTS (newdecl) = copy_list (DECL_ARGUMENTS (olddecl));
    3136      7768615 :           for (t = DECL_ARGUMENTS (newdecl); t ; t = DECL_CHAIN (t))
    3137      2814378 :             DECL_CONTEXT (t) = newdecl;
    3138              : 
    3139              :           /* See if we've got a function to instantiate from.  */
    3140      4954237 :           if (DECL_SAVED_TREE (olddecl))
    3141         1622 :             DECL_ABSTRACT_ORIGIN (newdecl)
    3142          811 :               = DECL_ABSTRACT_ORIGIN (olddecl);
    3143              :         }
    3144              : 
    3145              :       /* If a new declaration requires a static chain, the old one must too. */
    3146      5189528 :       gcc_assert (!DECL_STATIC_CHAIN (newdecl) || DECL_STATIC_CHAIN (olddecl));
    3147              :     }
    3148              : 
    3149              :   /* Merge the USED information.  */
    3150      5254481 :   if (TREE_USED (olddecl))
    3151       718482 :     TREE_USED (newdecl) = 1;
    3152      4535999 :   else if (TREE_USED (newdecl))
    3153            4 :     TREE_USED (olddecl) = 1;
    3154      5254481 :   if (VAR_P (olddecl) || TREE_CODE (olddecl) == PARM_DECL)
    3155        18677 :     DECL_READ_P (newdecl) |= DECL_READ_P (olddecl);
    3156      5254481 :   if (DECL_PRESERVE_P (olddecl))
    3157           25 :     DECL_PRESERVE_P (newdecl) = 1;
    3158      5254456 :   else if (DECL_PRESERVE_P (newdecl))
    3159            4 :     DECL_PRESERVE_P (olddecl) = 1;
    3160              : 
    3161              :   /* Merge DECL_COMMON */
    3162        18642 :   if (VAR_P (olddecl) && VAR_P (newdecl)
    3163        18642 :       && !lookup_attribute ("common", DECL_ATTRIBUTES (newdecl))
    3164      5273121 :       && !lookup_attribute ("nocommon", DECL_ATTRIBUTES (newdecl)))
    3165        37276 :     DECL_COMMON (newdecl) = DECL_COMMON (newdecl) && DECL_COMMON (olddecl);
    3166              : 
    3167              :   /* Copy most of the decl-specific fields of NEWDECL into OLDDECL.
    3168              :      But preserve OLDDECL's DECL_UID, DECL_CONTEXT and
    3169              :      DECL_ARGUMENTS (if appropriate).  */
    3170      5254481 :   {
    3171      5254481 :     unsigned olddecl_uid = DECL_UID (olddecl);
    3172      5254481 :     tree olddecl_context = DECL_CONTEXT (olddecl);
    3173      5254481 :     tree olddecl_arguments = NULL;
    3174      5254481 :     if (TREE_CODE (olddecl) == FUNCTION_DECL)
    3175      5189465 :       olddecl_arguments = DECL_ARGUMENTS (olddecl);
    3176              : 
    3177      5254481 :     memcpy ((char *) olddecl + sizeof (struct tree_common),
    3178              :             (char *) newdecl + sizeof (struct tree_common),
    3179              :             sizeof (struct tree_decl_common) - sizeof (struct tree_common));
    3180      5254481 :     DECL_USER_ALIGN (olddecl) = DECL_USER_ALIGN (newdecl);
    3181      5254481 :     switch (TREE_CODE (olddecl))
    3182              :       {
    3183      5208107 :       case FUNCTION_DECL:
    3184      5208107 :       case VAR_DECL:
    3185      5208107 :         {
    3186      5208107 :           struct symtab_node *snode = olddecl->decl_with_vis.symtab_node;
    3187              : 
    3188     10416214 :           memcpy ((char *) olddecl + sizeof (struct tree_decl_common),
    3189              :                   (char *) newdecl + sizeof (struct tree_decl_common),
    3190      5208107 :                   tree_code_size (TREE_CODE (olddecl)) - sizeof (struct tree_decl_common));
    3191      5208107 :           olddecl->decl_with_vis.symtab_node = snode;
    3192              : 
    3193      5208107 :           if ((DECL_EXTERNAL (olddecl)
    3194        47725 :                || TREE_PUBLIC (olddecl)
    3195         8279 :                || TREE_STATIC (olddecl))
    3196      5255824 :               && DECL_SECTION_NAME (newdecl) != NULL)
    3197            8 :             set_decl_section_name (olddecl, newdecl);
    3198              : 
    3199              :           /* This isn't quite correct for something like
    3200              :                 int __thread x attribute ((tls_model ("local-exec")));
    3201              :                 extern int __thread x;
    3202              :              as we'll lose the "local-exec" model.  */
    3203      5208107 :           if (VAR_P (olddecl) && DECL_THREAD_LOCAL_P (newdecl))
    3204              :             {
    3205           94 :               set_decl_tls_model (olddecl, DECL_TLS_MODEL (newdecl));
    3206              :               /* NEWDECL's model was chosen for NEWDECL alone, which may not
    3207              :                  have been weak until merge_weak.  */
    3208           94 :               if (DECL_WEAK (olddecl))
    3209            5 :                 weak_decl_tls_model (olddecl);
    3210              :             }
    3211              :           break;
    3212              :         }
    3213              : 
    3214        46374 :       case FIELD_DECL:
    3215        46374 :       case PARM_DECL:
    3216        46374 :       case LABEL_DECL:
    3217        46374 :       case RESULT_DECL:
    3218        46374 :       case CONST_DECL:
    3219        46374 :       case TYPE_DECL:
    3220        92748 :         memcpy ((char *) olddecl + sizeof (struct tree_decl_common),
    3221              :                 (char *) newdecl + sizeof (struct tree_decl_common),
    3222        46374 :                 tree_code_size (TREE_CODE (olddecl)) - sizeof (struct tree_decl_common));
    3223        46374 :         break;
    3224              : 
    3225            0 :       default:
    3226              : 
    3227            0 :         memcpy ((char *) olddecl + sizeof (struct tree_decl_common),
    3228              :                 (char *) newdecl + sizeof (struct tree_decl_common),
    3229              :                 sizeof (struct tree_decl_non_common) - sizeof (struct tree_decl_common));
    3230              :       }
    3231      5254481 :     DECL_UID (olddecl) = olddecl_uid;
    3232      5254481 :     DECL_CONTEXT (olddecl) = olddecl_context;
    3233      5254481 :     if (TREE_CODE (olddecl) == FUNCTION_DECL)
    3234      5189465 :       DECL_ARGUMENTS (olddecl) = olddecl_arguments;
    3235              :   }
    3236              : 
    3237              :   /* If OLDDECL had its DECL_RTL instantiated, re-invoke make_decl_rtl
    3238              :      so that encode_section_info has a chance to look at the new decl
    3239              :      flags and attributes.  */
    3240      5254481 :   if (DECL_RTL_SET_P (olddecl)
    3241      5254487 :       && (TREE_CODE (olddecl) == FUNCTION_DECL
    3242            6 :           || (VAR_P (olddecl) && TREE_STATIC (olddecl))))
    3243            6 :     make_decl_rtl (olddecl);
    3244      5254481 : }
    3245              : 
    3246              : /* Handle when a new declaration NEWDECL has the same name as an old
    3247              :    one OLDDECL in the same binding contour.  Prints an error message
    3248              :    if appropriate.
    3249              : 
    3250              :    If safely possible, alter OLDDECL to look like NEWDECL, and return
    3251              :    true.  Otherwise, return false.  */
    3252              : 
    3253              : static bool
    3254      5255584 : duplicate_decls (tree newdecl, tree olddecl)
    3255              : {
    3256      5255584 :   tree newtype = NULL, oldtype = NULL;
    3257              : 
    3258      5255584 :   if (!diagnose_mismatched_decls (newdecl, olddecl, &newtype, &oldtype))
    3259              :     {
    3260              :       /* Avoid `unused variable' and other warnings for OLDDECL.  */
    3261         1103 :       suppress_warning (olddecl, OPT_Wunused);
    3262              :       /* If the types are completely different, poison them both with
    3263              :          error_mark_node.  */
    3264         1103 :       if (TREE_CODE (TREE_TYPE (newdecl)) != TREE_CODE (TREE_TYPE (olddecl))
    3265          108 :           && olddecl != error_mark_node
    3266         1191 :           && seen_error ())
    3267              :         {
    3268           63 :           if (TREE_CODE (olddecl) != FUNCTION_DECL)
    3269           51 :             TREE_TYPE (olddecl) = error_mark_node;
    3270           63 :           if (TREE_CODE (newdecl) != FUNCTION_DECL)
    3271           59 :             TREE_TYPE (newdecl) = error_mark_node;
    3272              :         }
    3273              :       return false;
    3274              :     }
    3275              : 
    3276      5254481 :   merge_decls (newdecl, olddecl, newtype, oldtype);
    3277              : 
    3278              :   /* The NEWDECL will no longer be needed.
    3279              : 
    3280              :      Before releasing the node, be sure to remove function from symbol
    3281              :      table that might have been inserted there to record comdat group.
    3282              :      Be sure to however do not free DECL_STRUCT_FUNCTION because this
    3283              :      structure is shared in between NEWDECL and OLDECL.  */
    3284      5254481 :   if (TREE_CODE (newdecl) == FUNCTION_DECL)
    3285      5189465 :     DECL_STRUCT_FUNCTION (newdecl) = NULL;
    3286      5254481 :   if (VAR_OR_FUNCTION_DECL_P (newdecl))
    3287              :     {
    3288      5208107 :       struct symtab_node *snode = symtab_node::get (newdecl);
    3289      5208107 :       if (snode)
    3290          109 :         snode->remove ();
    3291              :     }
    3292      5254481 :   ggc_free (newdecl);
    3293      5254481 :   return true;
    3294              : }
    3295              : 
    3296              : 
    3297              : /* Check whether decl-node NEW_DECL shadows an existing declaration.  */
    3298              : static void
    3299    176075579 : warn_if_shadowing (tree new_decl)
    3300              : {
    3301    176075579 :   struct c_binding *b;
    3302              : 
    3303              :   /* Shadow warnings wanted?  */
    3304    352150242 :   if (!(warn_shadow
    3305    176074843 :         || warn_shadow_local
    3306    176074663 :         || warn_shadow_compatible_local)
    3307              :       /* No shadow warnings for internally generated vars.  */
    3308    176075822 :       || DECL_IS_UNDECLARED_BUILTIN (new_decl))
    3309              :     return;
    3310              : 
    3311              :   /* Is anything being shadowed?  Invisible decls do not count.  */
    3312          253 :   for (b = I_SYMBOL_BINDING (DECL_NAME (new_decl)); b; b = b->shadowed)
    3313          157 :     if (b->decl && b->decl != new_decl && !b->invisible
    3314          214 :         && (b->decl == error_mark_node
    3315           43 :             || diagnostic_report_warnings_p (global_dc,
    3316              :                                              DECL_SOURCE_LOCATION (b->decl))))
    3317              :       {
    3318           57 :         tree old_decl = b->decl;
    3319              : 
    3320           57 :         if (old_decl == error_mark_node)
    3321              :           {
    3322           14 :             warning (OPT_Wshadow, "declaration of %q+D shadows previous "
    3323              :                      "non-variable", new_decl);
    3324           50 :             break;
    3325              :           }
    3326              : 
    3327           43 :         bool warned = false;
    3328           43 :         auto_diagnostic_group d;
    3329           43 :         if (TREE_CODE (old_decl) == PARM_DECL)
    3330              :           {
    3331            5 :             enum opt_code warning_code;
    3332              : 
    3333              :             /* If '-Wshadow=compatible-local' is specified without other
    3334              :                -Wshadow= flags, we will warn only when the types of the
    3335              :                shadowing variable (i.e. new_decl) and the shadowed variable
    3336              :                (old_decl) are compatible.  */
    3337            5 :             if (warn_shadow)
    3338              :               warning_code = OPT_Wshadow;
    3339            2 :             else if (comptypes (TREE_TYPE (old_decl), TREE_TYPE (new_decl)))
    3340              :               warning_code = OPT_Wshadow_compatible_local;
    3341              :             else
    3342            2 :               warning_code = OPT_Wshadow_local;
    3343            5 :             warned = warning_at (DECL_SOURCE_LOCATION (new_decl), warning_code,
    3344              :                                  "declaration of %qD shadows a parameter",
    3345              :                                  new_decl);
    3346              :           }
    3347           38 :         else if (DECL_FILE_SCOPE_P (old_decl))
    3348              :           {
    3349              :             /* Do not warn if a variable shadows a function, unless
    3350              :                the variable is a function or a pointer-to-function.  */
    3351           34 :             if (TREE_CODE (old_decl) == FUNCTION_DECL
    3352           11 :                 && TREE_CODE (new_decl) != FUNCTION_DECL
    3353           36 :                 && !FUNCTION_POINTER_TYPE_P (TREE_TYPE (new_decl)))
    3354            7 :                 continue;
    3355              : 
    3356           20 :             warned = warning_at (DECL_SOURCE_LOCATION (new_decl), OPT_Wshadow,
    3357              :                                  "declaration of %qD shadows a global "
    3358              :                                  "declaration",
    3359              :                                  new_decl);
    3360              :           }
    3361           11 :         else if (TREE_CODE (old_decl) == FUNCTION_DECL
    3362           11 :                  && fndecl_built_in_p (old_decl))
    3363              :           {
    3364            0 :             warning (OPT_Wshadow, "declaration of %q+D shadows "
    3365              :                      "a built-in function", new_decl);
    3366            0 :             break;
    3367              :           }
    3368              :         else
    3369              :           {
    3370           11 :             enum opt_code warning_code;
    3371              : 
    3372              :             /* If '-Wshadow=compatible-local' is specified without other
    3373              :                -Wshadow= flags, we will warn only when the types of the
    3374              :                shadowing variable (i.e. new_decl) and the shadowed variable
    3375              :                (old_decl) are compatible.  */
    3376           11 :             if (warn_shadow)
    3377              :               warning_code = OPT_Wshadow;
    3378            8 :             else if (comptypes (TREE_TYPE (old_decl), TREE_TYPE (new_decl)))
    3379              :               warning_code = OPT_Wshadow_compatible_local;
    3380              :             else
    3381            2 :               warning_code = OPT_Wshadow_local;
    3382           11 :             warned = warning_at (DECL_SOURCE_LOCATION (new_decl), warning_code,
    3383              :                                  "declaration of %qD shadows a previous local",
    3384              :                                  new_decl);
    3385              :           }
    3386              : 
    3387           36 :         if (warned)
    3388           26 :           inform (DECL_SOURCE_LOCATION (old_decl),
    3389              :                   "shadowed declaration is here");
    3390              : 
    3391              :         break;
    3392           43 :       }
    3393              : }
    3394              : 
    3395              : /* Record a decl-node X as belonging to the current lexical scope.
    3396              :    Check for errors (such as an incompatible declaration for the same
    3397              :    name already seen in the same scope).
    3398              : 
    3399              :    Returns either X or an old decl for the same name.
    3400              :    If an old decl is returned, it may have been smashed
    3401              :    to agree with what X says.  */
    3402              : 
    3403              : tree
    3404    209914535 : pushdecl (tree x)
    3405              : {
    3406    209914535 :   tree name = DECL_NAME (x);
    3407    209914535 :   struct c_scope *scope = current_scope;
    3408    209914535 :   struct c_binding *b;
    3409    209914535 :   bool nested = false;
    3410    209914535 :   location_t locus = DECL_SOURCE_LOCATION (x);
    3411              : 
    3412              :   /* Must set DECL_CONTEXT for everything not at file scope or
    3413              :      DECL_FILE_SCOPE_P won't work.  Local externs don't count
    3414              :      unless they have initializers (which generate code).  We
    3415              :      also exclude CONST_DECLs because enumerators will get the
    3416              :      type of the enum as context.  */
    3417    209914535 :   if (current_function_decl
    3418      9249531 :       && TREE_CODE (x) != CONST_DECL
    3419    219005184 :       && (!VAR_OR_FUNCTION_DECL_P (x)
    3420      8811299 :           || DECL_INITIAL (x) || !TREE_PUBLIC (x)))
    3421      9078612 :     DECL_CONTEXT (x) = current_function_decl;
    3422              : 
    3423              :   /* Anonymous decls are just inserted in the scope.  */
    3424    209914535 :   if (!name)
    3425              :     {
    3426      8026925 :       bind (name, x, scope, /*invisible=*/false, /*nested=*/false,
    3427              :             locus);
    3428      8026925 :       return x;
    3429              :     }
    3430              : 
    3431              :   /* First, see if there is another declaration with the same name in
    3432              :      the current scope.  If there is, duplicate_decls may do all the
    3433              :      work for us.  If duplicate_decls returns false, that indicates
    3434              :      two incompatible decls in the same scope; we are to silently
    3435              :      replace the old one (duplicate_decls has issued all appropriate
    3436              :      diagnostics).  In particular, we should not consider possible
    3437              :      duplicates in the external scope, or shadowing.  */
    3438    201887610 :   b = I_SYMBOL_BINDING (name);
    3439    201887610 :   if (b && B_IN_SCOPE (b, scope))
    3440              :     {
    3441      1471419 :       struct c_binding *b_ext, *b_use;
    3442      1471419 :       tree type = TREE_TYPE (x);
    3443      1471419 :       tree visdecl = b->decl;
    3444      1471419 :       tree vistype = TREE_TYPE (visdecl);
    3445      1471419 :       if (TREE_CODE (TREE_TYPE (x)) == ARRAY_TYPE
    3446      1471419 :           && COMPLETE_TYPE_P (TREE_TYPE (x)))
    3447         1374 :         b->inner_comp = false;
    3448      1471419 :       b_use = b;
    3449      1471419 :       b_ext = b;
    3450              :       /* If this is an external linkage declaration, we should check
    3451              :          for compatibility with the type in the external scope before
    3452              :          setting the type at this scope based on the visible
    3453              :          information only.  */
    3454      1471419 :       if (TREE_PUBLIC (x) && TREE_PUBLIC (visdecl))
    3455              :         {
    3456      2833324 :           while (b_ext && !B_IN_EXTERNAL_SCOPE (b_ext))
    3457      1416672 :             b_ext = b_ext->shadowed;
    3458      1416652 :           if (b_ext)
    3459              :             {
    3460      1416643 :               b_use = b_ext;
    3461      1416643 :               if (b_use->u.type)
    3462       277494 :                 TREE_TYPE (b_use->decl) = b_use->u.type;
    3463              :             }
    3464              :         }
    3465              : 
    3466              :       /* Check if x is part of a FMV set with b_use.
    3467              :          FMV is only supported in c for targets with target_version
    3468              :          attributes.  */
    3469      1471419 :       if (!TARGET_HAS_FMV_TARGET_ATTRIBUTE
    3470              :           && b_use && TREE_CODE (b_use->decl) == FUNCTION_DECL
    3471              :           && TREE_CODE (x) == FUNCTION_DECL && DECL_FILE_SCOPE_P (b_use->decl)
    3472              :           && DECL_FILE_SCOPE_P (x)
    3473              :           && disjoint_version_decls (x, b_use->decl)
    3474              :           && comptypes (vistype, type))
    3475              :         {
    3476              :           maybe_mark_function_versioned (b_use->decl);
    3477              :           maybe_mark_function_versioned (b->decl);
    3478              :           maybe_mark_function_versioned (x);
    3479              : 
    3480              :           cgraph_node *b_node = cgraph_node::get_create (b_use->decl);
    3481              :           cgraph_function_version_info *b_v = b_node->function_version ();
    3482              :           if (!b_v)
    3483              :             b_v = b_node->insert_new_function_version ();
    3484              : 
    3485              :           /* Check if this new node conflicts with any previous functions
    3486              :              in the set.  */
    3487              :           cgraph_function_version_info *version = b_v;
    3488              :           for (; version; version = version->next)
    3489              :             if (!disjoint_version_decls (version->this_node->decl, x))
    3490              :               {
    3491              :                 /* The decls define overlapping version, so attempt to merge
    3492              :                    or diagnose the conflict.  */
    3493              :                 if (duplicate_decls (x, version->this_node->decl))
    3494              :                   return version->this_node->decl;
    3495              :                 else
    3496              :                   return error_mark_node;
    3497              :               }
    3498              : 
    3499              :           /* This is a new version to be added to FMV structure.  */
    3500              :           cgraph_node::add_function_version (b_v, x);
    3501              : 
    3502              :           /* Get the first node from the structure.  */
    3503              :           cgraph_function_version_info *default_v = b_v;
    3504              :           while (default_v->prev)
    3505              :             default_v = default_v->prev;
    3506              :           /* Always use the default node for the bindings.  */
    3507              :           b_use->decl = default_v->this_node->decl;
    3508              :           b->decl = default_v->this_node->decl;
    3509              : 
    3510              :           /* Node is not a duplicate, so no need to do the rest of the
    3511              :              checks.  */
    3512              :           return x;
    3513              :         }
    3514              : 
    3515      1471419 :       if (duplicate_decls (x, b_use->decl))
    3516              :         {
    3517      1471043 :           if (b_use != b)
    3518              :             {
    3519              :               /* Save the updated type in the external scope and
    3520              :                  restore the proper type for this scope.  */
    3521      1416437 :               tree thistype;
    3522      1416437 :               if (comptypes (vistype, type))
    3523      1416395 :                 thistype = composite_type (vistype, type);
    3524              :               else
    3525           42 :                 thistype = TREE_TYPE (b_use->decl);
    3526      1416437 :               b_use->u.type = TREE_TYPE (b_use->decl);
    3527      1416437 :               if (TREE_CODE (b_use->decl) == FUNCTION_DECL
    3528      1416437 :                   && fndecl_built_in_p (b_use->decl))
    3529       287729 :                 thistype
    3530       287729 :                   = c_build_type_attribute_variant (thistype,
    3531       287729 :                                                     TYPE_ATTRIBUTES
    3532              :                                                     (b_use->u.type));
    3533      1416437 :               TREE_TYPE (b_use->decl) = thistype;
    3534              :             }
    3535      1471043 :           return b_use->decl;
    3536              :         }
    3537              :       else
    3538          376 :         goto skip_external_and_shadow_checks;
    3539              :     }
    3540              : 
    3541              :   /* All declarations with external linkage, and all external
    3542              :      references, go in the external scope, no matter what scope is
    3543              :      current.  However, the binding in that scope is ignored for
    3544              :      purposes of normal name lookup.  A separate binding structure is
    3545              :      created in the requested scope; this governs the normal
    3546              :      visibility of the symbol.
    3547              : 
    3548              :      The binding in the externals scope is used exclusively for
    3549              :      detecting duplicate declarations of the same object, no matter
    3550              :      what scope they are in; this is what we do here.  (C99 6.2.7p2:
    3551              :      All declarations that refer to the same object or function shall
    3552              :      have compatible type; otherwise, the behavior is undefined.)
    3553              :      However, in Objective-C, we also want to detect declarations
    3554              :      conflicting with those of the basic types.  */
    3555    349845616 :   if ((DECL_EXTERNAL (x) || scope == file_scope)
    3556    212140942 :       && (VAR_OR_FUNCTION_DECL_P (x) || c_dialect_objc ()))
    3557              :     {
    3558     52806946 :       tree type = TREE_TYPE (x);
    3559     52806946 :       tree vistype = NULL_TREE;
    3560     52806946 :       tree visdecl = NULL_TREE;
    3561     52806946 :       bool type_saved = false;
    3562      3784192 :       if (b && !B_IN_EXTERNAL_SCOPE (b)
    3563         1038 :           && VAR_OR_FUNCTION_DECL_P (b->decl)
    3564     52807975 :           && DECL_FILE_SCOPE_P (b->decl))
    3565              :         {
    3566          803 :           visdecl = b->decl;
    3567          803 :           vistype = TREE_TYPE (visdecl);
    3568              :         }
    3569     52806946 :       if (scope != file_scope
    3570     52806946 :           && !DECL_IN_SYSTEM_HEADER (x))
    3571        11487 :         warning_at (locus, OPT_Wnested_externs,
    3572              :                     "nested extern declaration of %qD", x);
    3573              : 
    3574     52808370 :       while (b && !B_IN_EXTERNAL_SCOPE (b))
    3575              :         {
    3576              :           /* If this decl might be modified, save its type.  This is
    3577              :              done here rather than when the decl is first bound
    3578              :              because the type may change after first binding, through
    3579              :              being completed or through attributes being added.  If we
    3580              :              encounter multiple such decls, only the first should have
    3581              :              its type saved; the others will already have had their
    3582              :              proper types saved and the types will not have changed as
    3583              :              their scopes will not have been re-entered.  */
    3584         1424 :           if (DECL_P (b->decl) && DECL_FILE_SCOPE_P (b->decl) && !type_saved)
    3585              :             {
    3586         1022 :               b->u.type = TREE_TYPE (b->decl);
    3587         1022 :               type_saved = true;
    3588              :             }
    3589         1424 :           if (B_IN_FILE_SCOPE (b)
    3590         1012 :               && VAR_P (b->decl)
    3591          572 :               && TREE_STATIC (b->decl)
    3592          281 :               && TREE_CODE (TREE_TYPE (b->decl)) == ARRAY_TYPE
    3593          138 :               && !TYPE_DOMAIN (TREE_TYPE (b->decl))
    3594           47 :               && TREE_CODE (type) == ARRAY_TYPE
    3595           47 :               && TYPE_DOMAIN (type)
    3596           28 :               && TYPE_MAX_VALUE (TYPE_DOMAIN (type))
    3597         1452 :               && !integer_zerop (TYPE_MAX_VALUE (TYPE_DOMAIN (type))))
    3598              :             {
    3599              :               /* Array type completed in inner scope, which should be
    3600              :                  diagnosed if the completion does not have size 1 and
    3601              :                  it does not get completed in the file scope.  */
    3602            6 :               b->inner_comp = true;
    3603              :             }
    3604         1424 :           b = b->shadowed;
    3605              :         }
    3606              : 
    3607              :       /* If a matching external declaration has been found, set its
    3608              :          type to the composite of all the types of that declaration.
    3609              :          After the consistency checks, it will be reset to the
    3610              :          composite of the visible types only.  */
    3611     52806946 :       if (b && b->u.type)
    3612          768 :         TREE_TYPE (b->decl) = b->u.type;
    3613              : 
    3614              :       /* the static does not go in the externals scope.  */
    3615      3784048 :       if (b && duplicate_decls (x, b->decl))
    3616              :         {
    3617      3783321 :           tree thistype;
    3618      3783321 :           if (vistype)
    3619              :             {
    3620          675 :               if (comptypes (vistype, type))
    3621          638 :                 thistype = composite_type (vistype, type);
    3622              :               else
    3623           37 :                 thistype = TREE_TYPE (b->decl);
    3624              :             }
    3625              :           else
    3626              :             thistype = type;
    3627      3783321 :           b->u.type = TREE_TYPE (b->decl);
    3628              :           /* Propagate the type attributes to the decl.  */
    3629      3783321 :           thistype
    3630      3783321 :             = c_build_type_attribute_variant (thistype,
    3631      3783321 :                                               TYPE_ATTRIBUTES (b->u.type));
    3632      3783321 :           TREE_TYPE (b->decl) = thistype;
    3633      3783321 :           bind (name, b->decl, scope, /*invisible=*/false, /*nested=*/true,
    3634              :                 locus);
    3635      3783321 :           return b->decl;
    3636              :         }
    3637     49023625 :       else if (TREE_PUBLIC (x))
    3638              :         {
    3639     48639696 :           if (visdecl && !b && duplicate_decls (x, visdecl))
    3640              :             {
    3641              :               /* An external declaration at block scope referring to a
    3642              :                  visible entity with internal linkage.  The composite
    3643              :                  type will already be correct for this scope, so we
    3644              :                  just need to fall through to make the declaration in
    3645              :                  this scope.  */
    3646              :               nested = true;
    3647              :               x = visdecl;
    3648              :             }
    3649              :           else
    3650              :             {
    3651     48639579 :               bind (name, x, external_scope, /*invisible=*/true,
    3652              :                     /*nested=*/false, locus);
    3653     48639579 :               nested = true;
    3654              :             }
    3655              :         }
    3656              :     }
    3657              : 
    3658    196632870 :   if (TREE_CODE (x) != PARM_DECL)
    3659     72751839 :     warn_if_shadowing (x);
    3660              : 
    3661    123881031 :  skip_external_and_shadow_checks:
    3662    196633246 :   if (TREE_CODE (x) == TYPE_DECL)
    3663              :     {
    3664              :       /* So this is a typedef, set its underlying type.  */
    3665     10017737 :       set_underlying_type (x);
    3666              : 
    3667              :       /* If X is a typedef defined in the current function, record it
    3668              :          for the purpose of implementing the -Wunused-local-typedefs
    3669              :          warning.  */
    3670     10017737 :       record_locally_defined_typedef (x);
    3671              :     }
    3672              : 
    3673    196633246 :   bind (name, x, scope, /*invisible=*/false, nested, locus);
    3674              : 
    3675              :   /* If x's type is incomplete because it's based on a
    3676              :      structure or union which has not yet been fully declared,
    3677              :      attach it to that structure or union type, so we can go
    3678              :      back and complete the variable declaration later, if the
    3679              :      structure or union gets fully declared.
    3680              : 
    3681              :      If the input is erroneous, we can have error_mark in the type
    3682              :      slot (e.g. "f(void a, ...)") - that doesn't count as an
    3683              :      incomplete type.  */
    3684    196633246 :   if (TREE_TYPE (x) != error_mark_node
    3685    196633246 :       && !COMPLETE_TYPE_P (TREE_TYPE (x)))
    3686              :     {
    3687       190184 :       tree element = TREE_TYPE (x);
    3688              : 
    3689       210949 :       while (TREE_CODE (element) == ARRAY_TYPE)
    3690        20765 :         element = TREE_TYPE (element);
    3691       190184 :       element = TYPE_MAIN_VARIANT (element);
    3692              : 
    3693       190184 :       if ((RECORD_OR_UNION_TYPE_P (element)
    3694       145637 :            || TREE_CODE (element) == ENUMERAL_TYPE)
    3695        44618 :           && (TREE_CODE (x) != TYPE_DECL
    3696        41131 :               || TREE_CODE (TREE_TYPE (x)) == ARRAY_TYPE)
    3697       193681 :           && !COMPLETE_TYPE_P (element))
    3698          321 :         C_TYPE_INCOMPLETE_VARS (element)
    3699          642 :           = tree_cons (NULL_TREE, x, C_TYPE_INCOMPLETE_VARS (element));
    3700              :     }
    3701              :   return x;
    3702              : }
    3703              : 
    3704              : 
    3705              : /* Issue a permerror about implicit function declaration.  ID is the function
    3706              :    identifier, OLDDECL is a declaration of the function in a different scope,
    3707              :    or NULL_TREE.  */
    3708              : 
    3709              : static void
    3710         3777 : implicit_decl_permerror (location_t loc, tree id, tree olddecl)
    3711              : {
    3712         3777 :   if (!warn_implicit_function_declaration)
    3713         2617 :     return;
    3714              : 
    3715         1160 :   bool warned;
    3716         1160 :   auto_diagnostic_group d;
    3717         1160 :   name_hint hint;
    3718         1160 :   if (!olddecl)
    3719          554 :     hint = lookup_name_fuzzy (id, FUZZY_LOOKUP_FUNCTION_NAME, loc);
    3720              : 
    3721         1160 :   if (flag_isoc99)
    3722              :     {
    3723         1154 :       if (const char *suggestion = hint.suggestion ())
    3724              :         {
    3725          107 :           gcc_rich_location richloc (loc);
    3726          107 :           richloc.add_fixit_replace (suggestion);
    3727          107 :           warned = permerror_opt (&richloc, OPT_Wimplicit_function_declaration,
    3728              :                                   "implicit declaration of function %qE;"
    3729              :                                   " did you mean %qs?",
    3730              :                                   id, suggestion);
    3731          107 :         }
    3732              :       else
    3733         1047 :         warned = permerror_opt (loc, OPT_Wimplicit_function_declaration,
    3734              :                                 "implicit declaration of function %qE", id);
    3735              :     }
    3736            6 :   else if (const char *suggestion = hint.suggestion ())
    3737              :     {
    3738            2 :       gcc_rich_location richloc (loc);
    3739            2 :       richloc.add_fixit_replace (suggestion);
    3740            2 :       warned = warning_at
    3741            2 :         (&richloc, OPT_Wimplicit_function_declaration,
    3742              :          G_("implicit declaration of function %qE; did you mean %qs?"),
    3743              :          id, suggestion);
    3744            2 :     }
    3745              :   else
    3746            4 :     warned = warning_at (loc, OPT_Wimplicit_function_declaration,
    3747              :                          G_("implicit declaration of function %qE"), id);
    3748              : 
    3749         1160 :   if (warned)
    3750              :     {
    3751              :       /* Whether the olddecl is an undeclared builtin function.
    3752              :          locate_old_decl will not generate a diagnostic for those,
    3753              :          so in that case we want to look elsewhere.  */
    3754           91 :       bool undeclared_builtin = (olddecl
    3755           28 :                                  && TREE_CODE (olddecl) == FUNCTION_DECL
    3756           28 :                                  && fndecl_built_in_p (olddecl)
    3757          118 :                                  && !C_DECL_DECLARED_BUILTIN (olddecl));
    3758           91 :       if (undeclared_builtin)
    3759              :         {
    3760           27 :           const char *header = header_for_builtin_fn (olddecl);
    3761           27 :           if (header)
    3762              :             {
    3763           20 :               rich_location richloc (line_table, loc);
    3764           20 :               maybe_add_include_fixit (&richloc, header, true);
    3765           20 :               inform (&richloc,
    3766              :                       "include %qs or provide a declaration of %qE",
    3767              :                       header, id);
    3768           20 :             }
    3769              :         }
    3770           64 :       else if (olddecl)
    3771            1 :         locate_old_decl (olddecl);
    3772              :     }
    3773              : 
    3774              :   if (!warned)
    3775         1160 :     hint.suppress ();
    3776         1160 : }
    3777              : 
    3778              : /* Return the name of the header file that declares built-in function
    3779              :    FNDECL, or null if either we don't know or don't expect to see an
    3780              :    explicit declaration.  */
    3781              : 
    3782              : static const char *
    3783         3171 : header_for_builtin_fn (tree fndecl)
    3784              : {
    3785         3171 :   if (DECL_BUILT_IN_CLASS (fndecl) != BUILT_IN_NORMAL)
    3786              :     return NULL;
    3787              : 
    3788         3171 :   switch (DECL_FUNCTION_CODE (fndecl))
    3789              :     {
    3790              :     CASE_FLT_FN (BUILT_IN_ACOS):
    3791              :     CASE_FLT_FN (BUILT_IN_ACOSH):
    3792              :     CASE_FLT_FN (BUILT_IN_ASIN):
    3793              :     CASE_FLT_FN (BUILT_IN_ASINH):
    3794              :     CASE_FLT_FN (BUILT_IN_ATAN):
    3795              :     CASE_FLT_FN (BUILT_IN_ATANH):
    3796              :     CASE_FLT_FN (BUILT_IN_ATAN2):
    3797              :     CASE_FLT_FN (BUILT_IN_CBRT):
    3798              :     CASE_FLT_FN (BUILT_IN_CEIL):
    3799              :     CASE_FLT_FN_FLOATN_NX (BUILT_IN_CEIL):
    3800              :     CASE_FLT_FN (BUILT_IN_COPYSIGN):
    3801              :     CASE_FLT_FN_FLOATN_NX (BUILT_IN_COPYSIGN):
    3802              :     CASE_FLT_FN (BUILT_IN_COS):
    3803              :     CASE_FLT_FN (BUILT_IN_COSH):
    3804              :     CASE_FLT_FN (BUILT_IN_ERF):
    3805              :     CASE_FLT_FN (BUILT_IN_ERFC):
    3806              :     CASE_FLT_FN (BUILT_IN_EXP):
    3807              :     CASE_FLT_FN (BUILT_IN_EXP2):
    3808              :     CASE_FLT_FN (BUILT_IN_EXPM1):
    3809              :     CASE_FLT_FN (BUILT_IN_FABS):
    3810              :     CASE_FLT_FN_FLOATN_NX (BUILT_IN_FABS):
    3811              :     CASE_FLT_FN (BUILT_IN_FDIM):
    3812              :     CASE_FLT_FN (BUILT_IN_FLOOR):
    3813              :     CASE_FLT_FN_FLOATN_NX (BUILT_IN_FLOOR):
    3814              :     CASE_FLT_FN (BUILT_IN_FMA):
    3815              :     CASE_FLT_FN_FLOATN_NX (BUILT_IN_FMA):
    3816              :     CASE_FLT_FN (BUILT_IN_FMAX):
    3817              :     CASE_FLT_FN_FLOATN_NX (BUILT_IN_FMAX):
    3818              :     CASE_FLT_FN (BUILT_IN_FMIN):
    3819              :     CASE_FLT_FN_FLOATN_NX (BUILT_IN_FMIN):
    3820              :     CASE_FLT_FN (BUILT_IN_FMOD):
    3821              :     CASE_FLT_FN (BUILT_IN_FREXP):
    3822              :     CASE_FLT_FN (BUILT_IN_HYPOT):
    3823              :     CASE_FLT_FN (BUILT_IN_ILOGB):
    3824              :     CASE_FLT_FN (BUILT_IN_LDEXP):
    3825              :     CASE_FLT_FN (BUILT_IN_LGAMMA):
    3826              :     CASE_FLT_FN (BUILT_IN_LLRINT):
    3827              :     CASE_FLT_FN (BUILT_IN_LLROUND):
    3828              :     CASE_FLT_FN (BUILT_IN_LOG):
    3829              :     CASE_FLT_FN (BUILT_IN_LOG10):
    3830              :     CASE_FLT_FN (BUILT_IN_LOG1P):
    3831              :     CASE_FLT_FN (BUILT_IN_LOG2):
    3832              :     CASE_FLT_FN (BUILT_IN_LOGB):
    3833              :     CASE_FLT_FN (BUILT_IN_LRINT):
    3834              :     CASE_FLT_FN (BUILT_IN_LROUND):
    3835              :     CASE_FLT_FN (BUILT_IN_MODF):
    3836              :     CASE_FLT_FN (BUILT_IN_NAN):
    3837              :     CASE_FLT_FN (BUILT_IN_NEARBYINT):
    3838              :     CASE_FLT_FN_FLOATN_NX (BUILT_IN_NEARBYINT):
    3839              :     CASE_FLT_FN (BUILT_IN_NEXTAFTER):
    3840              :     CASE_FLT_FN (BUILT_IN_NEXTTOWARD):
    3841              :     CASE_FLT_FN (BUILT_IN_POW):
    3842              :     CASE_FLT_FN (BUILT_IN_REMAINDER):
    3843              :     CASE_FLT_FN (BUILT_IN_REMQUO):
    3844              :     CASE_FLT_FN (BUILT_IN_RINT):
    3845              :     CASE_FLT_FN_FLOATN_NX (BUILT_IN_RINT):
    3846              :     CASE_FLT_FN (BUILT_IN_ROUND):
    3847              :     CASE_FLT_FN_FLOATN_NX (BUILT_IN_ROUND):
    3848              :     CASE_FLT_FN (BUILT_IN_SCALBLN):
    3849              :     CASE_FLT_FN (BUILT_IN_SCALBN):
    3850              :     CASE_FLT_FN (BUILT_IN_SIN):
    3851              :     CASE_FLT_FN (BUILT_IN_SINH):
    3852              :     CASE_FLT_FN (BUILT_IN_SINCOS):
    3853              :     CASE_FLT_FN (BUILT_IN_SQRT):
    3854              :     CASE_FLT_FN_FLOATN_NX (BUILT_IN_SQRT):
    3855              :     CASE_FLT_FN (BUILT_IN_TAN):
    3856              :     CASE_FLT_FN (BUILT_IN_TANH):
    3857              :     CASE_FLT_FN (BUILT_IN_TGAMMA):
    3858              :     CASE_FLT_FN (BUILT_IN_TRUNC):
    3859              :     CASE_FLT_FN_FLOATN_NX (BUILT_IN_TRUNC):
    3860              :     case BUILT_IN_ISINF:
    3861              :     case BUILT_IN_ISNAN:
    3862              :       return "<math.h>";
    3863           29 :     CASE_FLT_FN (BUILT_IN_CABS):
    3864           29 :     CASE_FLT_FN (BUILT_IN_CACOS):
    3865           29 :     CASE_FLT_FN (BUILT_IN_CACOSH):
    3866           29 :     CASE_FLT_FN (BUILT_IN_CARG):
    3867           29 :     CASE_FLT_FN (BUILT_IN_CASIN):
    3868           29 :     CASE_FLT_FN (BUILT_IN_CASINH):
    3869           29 :     CASE_FLT_FN (BUILT_IN_CATAN):
    3870           29 :     CASE_FLT_FN (BUILT_IN_CATANH):
    3871           29 :     CASE_FLT_FN (BUILT_IN_CCOS):
    3872           29 :     CASE_FLT_FN (BUILT_IN_CCOSH):
    3873           29 :     CASE_FLT_FN (BUILT_IN_CEXP):
    3874           29 :     CASE_FLT_FN (BUILT_IN_CIMAG):
    3875           29 :     CASE_FLT_FN (BUILT_IN_CLOG):
    3876           29 :     CASE_FLT_FN (BUILT_IN_CONJ):
    3877           29 :     CASE_FLT_FN (BUILT_IN_CPOW):
    3878           29 :     CASE_FLT_FN (BUILT_IN_CPROJ):
    3879           29 :     CASE_FLT_FN (BUILT_IN_CREAL):
    3880           29 :     CASE_FLT_FN (BUILT_IN_CSIN):
    3881           29 :     CASE_FLT_FN (BUILT_IN_CSINH):
    3882           29 :     CASE_FLT_FN (BUILT_IN_CSQRT):
    3883           29 :     CASE_FLT_FN (BUILT_IN_CTAN):
    3884           29 :     CASE_FLT_FN (BUILT_IN_CTANH):
    3885           29 :       return "<complex.h>";
    3886          222 :     case BUILT_IN_MEMCHR:
    3887          222 :     case BUILT_IN_MEMCMP:
    3888          222 :     case BUILT_IN_MEMCPY:
    3889          222 :     case BUILT_IN_MEMMOVE:
    3890          222 :     case BUILT_IN_MEMSET:
    3891          222 :     case BUILT_IN_STRCAT:
    3892          222 :     case BUILT_IN_STRCHR:
    3893          222 :     case BUILT_IN_STRCMP:
    3894          222 :     case BUILT_IN_STRCPY:
    3895          222 :     case BUILT_IN_STRCSPN:
    3896          222 :     case BUILT_IN_STRLEN:
    3897          222 :     case BUILT_IN_STRNCAT:
    3898          222 :     case BUILT_IN_STRNCMP:
    3899          222 :     case BUILT_IN_STRNCPY:
    3900          222 :     case BUILT_IN_STRPBRK:
    3901          222 :     case BUILT_IN_STRRCHR:
    3902          222 :     case BUILT_IN_STRSPN:
    3903          222 :     case BUILT_IN_STRSTR:
    3904          222 :       return "<string.h>";
    3905          544 :     case BUILT_IN_FPRINTF:
    3906          544 :     case BUILT_IN_PUTC:
    3907          544 :     case BUILT_IN_FPUTC:
    3908          544 :     case BUILT_IN_FPUTS:
    3909          544 :     case BUILT_IN_FSCANF:
    3910          544 :     case BUILT_IN_FWRITE:
    3911          544 :     case BUILT_IN_PRINTF:
    3912          544 :     case BUILT_IN_PUTCHAR:
    3913          544 :     case BUILT_IN_PUTS:
    3914          544 :     case BUILT_IN_SCANF:
    3915          544 :     case BUILT_IN_SNPRINTF:
    3916          544 :     case BUILT_IN_SPRINTF:
    3917          544 :     case BUILT_IN_SSCANF:
    3918          544 :     case BUILT_IN_VFPRINTF:
    3919          544 :     case BUILT_IN_VFSCANF:
    3920          544 :     case BUILT_IN_VPRINTF:
    3921          544 :     case BUILT_IN_VSCANF:
    3922          544 :     case BUILT_IN_VSNPRINTF:
    3923          544 :     case BUILT_IN_VSPRINTF:
    3924          544 :     case BUILT_IN_VSSCANF:
    3925          544 :       return "<stdio.h>";
    3926            2 :     case BUILT_IN_ISALNUM:
    3927            2 :     case BUILT_IN_ISALPHA:
    3928            2 :     case BUILT_IN_ISBLANK:
    3929            2 :     case BUILT_IN_ISCNTRL:
    3930            2 :     case BUILT_IN_ISDIGIT:
    3931            2 :     case BUILT_IN_ISGRAPH:
    3932            2 :     case BUILT_IN_ISLOWER:
    3933            2 :     case BUILT_IN_ISPRINT:
    3934            2 :     case BUILT_IN_ISPUNCT:
    3935            2 :     case BUILT_IN_ISSPACE:
    3936            2 :     case BUILT_IN_ISUPPER:
    3937            2 :     case BUILT_IN_ISXDIGIT:
    3938            2 :     case BUILT_IN_TOLOWER:
    3939            2 :     case BUILT_IN_TOUPPER:
    3940            2 :       return "<ctype.h>";
    3941            0 :     case BUILT_IN_ISWALNUM:
    3942            0 :     case BUILT_IN_ISWALPHA:
    3943            0 :     case BUILT_IN_ISWBLANK:
    3944            0 :     case BUILT_IN_ISWCNTRL:
    3945            0 :     case BUILT_IN_ISWDIGIT:
    3946            0 :     case BUILT_IN_ISWGRAPH:
    3947            0 :     case BUILT_IN_ISWLOWER:
    3948            0 :     case BUILT_IN_ISWPRINT:
    3949            0 :     case BUILT_IN_ISWPUNCT:
    3950            0 :     case BUILT_IN_ISWSPACE:
    3951            0 :     case BUILT_IN_ISWUPPER:
    3952            0 :     case BUILT_IN_ISWXDIGIT:
    3953            0 :     case BUILT_IN_TOWLOWER:
    3954            0 :     case BUILT_IN_TOWUPPER:
    3955            0 :       return "<wctype.h>";
    3956         1818 :     case BUILT_IN_ABORT:
    3957         1818 :     case BUILT_IN_ABS:
    3958         1818 :     case BUILT_IN_CALLOC:
    3959         1818 :     case BUILT_IN_EXIT:
    3960         1818 :     case BUILT_IN_FREE:
    3961         1818 :     case BUILT_IN_LABS:
    3962         1818 :     case BUILT_IN_LLABS:
    3963         1818 :     case BUILT_IN_MALLOC:
    3964         1818 :     case BUILT_IN_REALLOC:
    3965         1818 :     case BUILT_IN__EXIT2:
    3966         1818 :     case BUILT_IN_ALIGNED_ALLOC:
    3967         1818 :       return "<stdlib.h>";
    3968            1 :     case BUILT_IN_IMAXABS:
    3969            1 :       return "<inttypes.h>";
    3970            3 :     case BUILT_IN_STRFTIME:
    3971            3 :       return "<time.h>";
    3972              :     default:
    3973              :       return NULL;
    3974              :     }
    3975              : }
    3976              : 
    3977              : /* Generate an implicit declaration for identifier FUNCTIONID at LOC as a
    3978              :    function of type int ().  */
    3979              : 
    3980              : tree
    3981         4730 : implicitly_declare (location_t loc, tree functionid)
    3982              : {
    3983         4730 :   struct c_binding *b;
    3984         4730 :   tree decl = NULL_TREE;
    3985         4730 :   tree asmspec_tree;
    3986              : 
    3987         4744 :   for (b = I_SYMBOL_BINDING (functionid); b; b = b->shadowed)
    3988              :     {
    3989         3158 :       if (B_IN_SCOPE (b, external_scope))
    3990              :         {
    3991         3144 :           decl = b->decl;
    3992         3144 :           break;
    3993              :         }
    3994              :     }
    3995              : 
    3996         4730 :   if (decl)
    3997              :     {
    3998         3144 :       if (TREE_CODE (decl) != FUNCTION_DECL)
    3999              :         return decl;
    4000              : 
    4001              :       /* FIXME: Objective-C has weird not-really-builtin functions
    4002              :          which are supposed to be visible automatically.  They wind up
    4003              :          in the external scope because they're pushed before the file
    4004              :          scope gets created.  Catch this here and rebind them into the
    4005              :          file scope.  */
    4006         3137 :       if (!fndecl_built_in_p (decl) && DECL_IS_UNDECLARED_BUILTIN (decl))
    4007              :         {
    4008            0 :           bind (functionid, decl, file_scope,
    4009              :                 /*invisible=*/false, /*nested=*/true,
    4010            0 :                 DECL_SOURCE_LOCATION (decl));
    4011            0 :           return decl;
    4012              :         }
    4013              :       else
    4014              :         {
    4015         3137 :           tree newtype = default_function_type;
    4016         3137 :           if (b->u.type)
    4017          753 :             TREE_TYPE (decl) = b->u.type;
    4018              :           /* Implicit declaration of a function already declared
    4019              :              (somehow) in a different scope, or as a built-in.
    4020              :              If this is the first time this has happened, warn;
    4021              :              then recycle the old declaration but with the new type.  */
    4022         3137 :           if (!C_DECL_IMPLICIT (decl))
    4023              :             {
    4024         2191 :               implicit_decl_permerror (loc, functionid, decl);
    4025         2191 :               C_DECL_IMPLICIT (decl) = 1;
    4026              :             }
    4027         3137 :           if (fndecl_built_in_p (decl))
    4028              :             {
    4029         2705 :               newtype = c_build_type_attribute_variant (newtype,
    4030         2705 :                                                         TYPE_ATTRIBUTES
    4031              :                                                         (TREE_TYPE (decl)));
    4032         2705 :               if (!comptypes (newtype, TREE_TYPE (decl)))
    4033              :                 {
    4034         2528 :                   auto_diagnostic_group d;
    4035         2528 :                   bool warned = warning_at (loc,
    4036         2528 :                                             OPT_Wbuiltin_declaration_mismatch,
    4037              :                                             "incompatible implicit "
    4038              :                                             "declaration of built-in "
    4039              :                                             "function %qD", decl);
    4040              :                   /* See if we can hint which header to include.  */
    4041         2528 :                   const char *header = header_for_builtin_fn (decl);
    4042         2528 :                   if (header != NULL && warned)
    4043              :                     {
    4044          133 :                       rich_location richloc (line_table, loc);
    4045          133 :                       maybe_add_include_fixit (&richloc, header, true);
    4046          133 :                       inform (&richloc,
    4047              :                               "include %qs or provide a declaration of %qD",
    4048              :                               header, decl);
    4049          133 :                     }
    4050         2528 :                   newtype = TREE_TYPE (decl);
    4051         2528 :                 }
    4052              :             }
    4053              :           else
    4054              :             {
    4055          432 :               if (!comptypes (newtype, TREE_TYPE (decl)))
    4056              :                 {
    4057            2 :                   auto_diagnostic_group d;
    4058            2 :                   error_at (loc, "incompatible implicit declaration of "
    4059              :                             "function %qD", decl);
    4060            2 :                   locate_old_decl (decl);
    4061            2 :                 }
    4062              :             }
    4063         3137 :           b->u.type = TREE_TYPE (decl);
    4064         3137 :           TREE_TYPE (decl) = newtype;
    4065         3137 :           bind (functionid, decl, current_scope,
    4066              :                 /*invisible=*/false, /*nested=*/true,
    4067         3137 :                 DECL_SOURCE_LOCATION (decl));
    4068         3137 :           return decl;
    4069              :         }
    4070              :     }
    4071              : 
    4072              :   /* Not seen before.  */
    4073         1586 :   decl = build_decl (loc, FUNCTION_DECL, functionid, default_function_type);
    4074         1586 :   DECL_EXTERNAL (decl) = 1;
    4075         1586 :   TREE_PUBLIC (decl) = 1;
    4076         1586 :   C_DECL_IMPLICIT (decl) = 1;
    4077         1586 :   implicit_decl_permerror (loc, functionid, 0);
    4078         1586 :   asmspec_tree = maybe_apply_renaming_pragma (decl, /*asmname=*/NULL);
    4079         1586 :   if (asmspec_tree)
    4080            1 :     set_user_assembler_name (decl, TREE_STRING_POINTER (asmspec_tree));
    4081              : 
    4082              :   /* C89 says implicit declarations are in the innermost block.
    4083              :      So we record the decl in the standard fashion.  */
    4084         1586 :   decl = pushdecl (decl);
    4085              : 
    4086              :   /* No need to call objc_check_decl here - it's a function type.  */
    4087         1586 :   rest_of_decl_compilation (decl, 0, 0);
    4088              : 
    4089              :   /* Write a record describing this implicit function declaration
    4090              :      to the prototypes file (if requested).  */
    4091         1586 :   gen_aux_info_record (decl, 0, 1, 0);
    4092              : 
    4093              :   /* Possibly apply some default attributes to this implicit declaration.  */
    4094         1586 :   decl_attributes (&decl, NULL_TREE, 0);
    4095              : 
    4096         1586 :   return decl;
    4097              : }
    4098              : 
    4099              : /* Issue an error message for a reference to an undeclared variable
    4100              :    ID, including a reference to a builtin outside of function-call
    4101              :    context.  Establish a binding of the identifier to error_mark_node
    4102              :    in an appropriate scope, which will suppress further errors for the
    4103              :    same identifier.  The error message should be given location LOC.  */
    4104              : void
    4105         1291 : undeclared_variable (location_t loc, tree id)
    4106              : {
    4107         1291 :   static bool already = false;
    4108         1291 :   struct c_scope *scope;
    4109              : 
    4110         1291 :   auto_diagnostic_group d;
    4111         1291 :   if (current_function_decl == NULL_TREE)
    4112              :     {
    4113          465 :       name_hint guessed_id = lookup_name_fuzzy (id, FUZZY_LOOKUP_NAME, loc);
    4114          465 :       if (const char *suggestion = guessed_id.suggestion ())
    4115              :         {
    4116           86 :           gcc_rich_location richloc (loc);
    4117           86 :           richloc.add_fixit_replace (suggestion);
    4118           86 :           error_at (&richloc,
    4119              :                     "%qE undeclared here (not in a function);"
    4120              :                     " did you mean %qs?",
    4121              :                     id, suggestion);
    4122           86 :         }
    4123              :       else
    4124          379 :         error_at (loc, "%qE undeclared here (not in a function)", id);
    4125          465 :       scope = current_scope;
    4126          465 :     }
    4127              :   else
    4128              :     {
    4129          826 :       if (!objc_diagnose_private_ivar (id))
    4130              :         {
    4131          826 :           name_hint guessed_id = lookup_name_fuzzy (id, FUZZY_LOOKUP_NAME, loc);
    4132          826 :           if (const char *suggestion = guessed_id.suggestion ())
    4133              :             {
    4134           39 :               gcc_rich_location richloc (loc);
    4135           39 :               richloc.add_fixit_replace (suggestion);
    4136           39 :               error_at (&richloc,
    4137              :                         "%qE undeclared (first use in this function);"
    4138              :                         " did you mean %qs?",
    4139              :                         id, suggestion);
    4140           39 :             }
    4141              :           else
    4142          787 :             error_at (loc, "%qE undeclared (first use in this function)", id);
    4143          826 :         }
    4144          826 :       if (!already)
    4145              :         {
    4146          203 :           inform (loc, "each undeclared identifier is reported only"
    4147              :                   " once for each function it appears in");
    4148          203 :           already = true;
    4149              :         }
    4150              : 
    4151              :       /* If we are parsing old-style parameter decls, current_function_decl
    4152              :          will be nonnull but current_function_scope will be null.  */
    4153          826 :       scope = current_function_scope ? current_function_scope : current_scope;
    4154              :     }
    4155         1291 :   bind (id, error_mark_node, scope, /*invisible=*/false, /*nested=*/false,
    4156              :         UNKNOWN_LOCATION);
    4157         1291 : }
    4158              : 
    4159              : /* Subroutine of lookup_label, declare_label, define_label: construct a
    4160              :    LABEL_DECL with all the proper frills.  Also create a struct
    4161              :    c_label_vars initialized for the current scope.  */
    4162              : 
    4163              : static tree
    4164        24841 : make_label (location_t location, tree name, bool defining,
    4165              :             struct c_label_vars **p_label_vars)
    4166              : {
    4167        24841 :   tree label = build_decl (location, LABEL_DECL, name, void_type_node);
    4168        24841 :   DECL_CONTEXT (label) = current_function_decl;
    4169        24841 :   SET_DECL_MODE (label, VOIDmode);
    4170              : 
    4171        24841 :   c_label_vars *label_vars = ggc_alloc<c_label_vars> ();
    4172        24841 :   label_vars->shadowed = NULL;
    4173        24841 :   set_spot_bindings (&label_vars->label_bindings, defining);
    4174        24841 :   label_vars->decls_in_scope = make_tree_vector ();
    4175        24841 :   label_vars->gotos = NULL;
    4176        24841 :   *p_label_vars = label_vars;
    4177              : 
    4178        24841 :   return label;
    4179              : }
    4180              : 
    4181              : /* Get the LABEL_DECL corresponding to identifier NAME as a label.
    4182              :    Create one if none exists so far for the current function.
    4183              :    This is called when a label is used in a goto expression or
    4184              :    has its address taken.  */
    4185              : 
    4186              : tree
    4187        86606 : lookup_label (tree name)
    4188              : {
    4189        86606 :   tree label;
    4190        86606 :   struct c_label_vars *label_vars;
    4191              : 
    4192        86606 :   if (current_function_scope == 0)
    4193              :     {
    4194            2 :       error ("label %qE referenced outside of any function", name);
    4195            2 :       return NULL_TREE;
    4196              :     }
    4197              : 
    4198              :   /* Use a label already defined or ref'd with this name, but not if
    4199              :      it is inherited from a containing function and wasn't declared
    4200              :      using __label__.  */
    4201        86604 :   label = I_LABEL_DECL (name);
    4202        80112 :   if (label && (DECL_CONTEXT (label) == current_function_decl
    4203          627 :                 || C_DECLARED_LABEL_FLAG (label)))
    4204              :     {
    4205              :       /* If the label has only been declared, update its apparent
    4206              :          location to point here, for better diagnostics if it
    4207              :          turns out not to have been defined.  */
    4208        80105 :       if (DECL_INITIAL (label) == NULL_TREE)
    4209        62947 :         DECL_SOURCE_LOCATION (label) = input_location;
    4210              :       return label;
    4211              :     }
    4212              : 
    4213              :   /* No label binding for that identifier; make one.  */
    4214         6499 :   label = make_label (input_location, name, false, &label_vars);
    4215              : 
    4216              :   /* Ordinary labels go in the current function scope.  */
    4217         6499 :   bind_label (name, label, current_function_scope, label_vars);
    4218              : 
    4219         6499 :   return label;
    4220              : }
    4221              : 
    4222              : /* Issue a warning about DECL for a goto statement at GOTO_LOC going
    4223              :    to LABEL.  */
    4224              : 
    4225              : static void
    4226         1490 : warn_about_goto (location_t goto_loc, tree label, tree decl)
    4227              : {
    4228         1490 :   auto_diagnostic_group d;
    4229         1490 :   if (c_type_variably_modified_p (TREE_TYPE (decl)))
    4230         1484 :     error_at (goto_loc,
    4231              :               "jump into scope of identifier with variably modified type");
    4232            6 :   else if (flag_openmp
    4233            6 :            && lookup_attribute ("omp allocate", DECL_ATTRIBUTES (decl)))
    4234            2 :     error_at (goto_loc, "jump skips OpenMP %<allocate%> allocation");
    4235              :   else
    4236            4 :     if (!warning_at (goto_loc, OPT_Wjump_misses_init,
    4237              :                      "jump skips variable initialization"))
    4238            0 :       return;
    4239         1490 :   inform (DECL_SOURCE_LOCATION (label), "label %qD defined here", label);
    4240         1490 :   inform (DECL_SOURCE_LOCATION (decl), "%qD declared here", decl);
    4241         1490 : }
    4242              : 
    4243              : /* Look up a label because of a goto statement.  This is like
    4244              :    lookup_label, but also issues any appropriate warnings.  */
    4245              : 
    4246              : tree
    4247        84592 : lookup_label_for_goto (location_t loc, tree name)
    4248              : {
    4249        84592 :   tree label;
    4250        84592 :   struct c_label_vars *label_vars;
    4251        84592 :   unsigned int ix;
    4252        84592 :   tree decl;
    4253              : 
    4254        84592 :   label = lookup_label (name);
    4255        84592 :   if (label == NULL_TREE)
    4256              :     return NULL_TREE;
    4257              : 
    4258              :   /* If we are jumping to a different function, we can't issue any
    4259              :      useful warnings.  */
    4260        84592 :   if (DECL_CONTEXT (label) != current_function_decl)
    4261              :     {
    4262          541 :       gcc_assert (C_DECLARED_LABEL_FLAG (label));
    4263              :       return label;
    4264              :     }
    4265              : 
    4266        84051 :   label_vars = I_LABEL_BINDING (name)->u.label;
    4267              : 
    4268              :   /* If the label has not yet been defined, then push this goto on a
    4269              :      list for possible later warnings.  */
    4270        84051 :   if (label_vars->label_bindings.scope == NULL)
    4271              :     {
    4272        67121 :       c_goto_bindings *g = ggc_alloc<c_goto_bindings> ();
    4273              : 
    4274        67121 :       g->loc = loc;
    4275        67121 :       set_spot_bindings (&g->goto_bindings, true);
    4276        67121 :       vec_safe_push (label_vars->gotos, g);
    4277        67121 :       return label;
    4278              :     }
    4279              : 
    4280              :   /* If there are any decls in label_vars->decls_in_scope, then this
    4281              :      goto has missed the declaration of the decl.  This happens for a
    4282              :      case like
    4283              :        int i = 1;
    4284              :       lab:
    4285              :        ...
    4286              :        goto lab;
    4287              :      Issue a warning or error.  */
    4288        17705 :   FOR_EACH_VEC_SAFE_ELT (label_vars->decls_in_scope, ix, decl)
    4289          775 :     warn_about_goto (loc, label, decl);
    4290              : 
    4291        16930 :   if (label_vars->label_bindings.left_stmt_expr)
    4292              :     {
    4293          120 :       auto_diagnostic_group d;
    4294          120 :       error_at (loc, "jump into statement expression");
    4295          120 :       inform (DECL_SOURCE_LOCATION (label), "label %qD defined here", label);
    4296          120 :     }
    4297              : 
    4298              :   return label;
    4299              : }
    4300              : 
    4301              : /* Make a label named NAME in the current function, shadowing silently
    4302              :    any that may be inherited from containing functions or containing
    4303              :    scopes.  This is called for __label__ declarations.  */
    4304              : 
    4305              : tree
    4306         1232 : declare_label (tree name)
    4307              : {
    4308         1232 :   struct c_binding *b = I_LABEL_BINDING (name);
    4309         1232 :   tree label;
    4310         1232 :   struct c_label_vars *label_vars;
    4311              : 
    4312              :   /* Check to make sure that the label hasn't already been declared
    4313              :      at this scope */
    4314         1232 :   if (b && B_IN_CURRENT_SCOPE (b))
    4315              :     {
    4316            2 :       auto_diagnostic_group d;
    4317            2 :       error ("duplicate label declaration %qE", name);
    4318            2 :       locate_old_decl (b->decl);
    4319              : 
    4320              :       /* Just use the previous declaration.  */
    4321            2 :       return b->decl;
    4322            2 :     }
    4323              : 
    4324         1230 :   label = make_label (input_location, name, false, &label_vars);
    4325         1230 :   C_DECLARED_LABEL_FLAG (label) = 1;
    4326              : 
    4327              :   /* Declared labels go in the current scope.  */
    4328         1230 :   bind_label (name, label, current_scope, label_vars);
    4329              : 
    4330         1230 :   return label;
    4331              : }
    4332              : 
    4333              : /* When we define a label, issue any appropriate warnings if there are
    4334              :    any gotos earlier in the function which jump to this label.  */
    4335              : 
    4336              : static void
    4337         7649 : check_earlier_gotos (tree label, struct c_label_vars* label_vars)
    4338              : {
    4339         7649 :   unsigned int ix;
    4340         7649 :   struct c_goto_bindings *g;
    4341              : 
    4342        74704 :   FOR_EACH_VEC_SAFE_ELT (label_vars->gotos, ix, g)
    4343              :     {
    4344        67055 :       struct c_binding *b;
    4345        67055 :       struct c_scope *scope;
    4346              : 
    4347              :       /* We have a goto to this label.  The goto is going forward.  In
    4348              :          g->scope, the goto is going to skip any binding which was
    4349              :          defined after g->bindings_in_scope.  */
    4350        67055 :       if (g->goto_bindings.scope->has_jump_unsafe_decl)
    4351              :         {
    4352          939 :           for (b = g->goto_bindings.scope->bindings;
    4353         1405 :                b != g->goto_bindings.bindings_in_scope;
    4354          466 :                b = b->prev)
    4355              :             {
    4356          466 :               if (decl_jump_unsafe (b->decl))
    4357          176 :                 warn_about_goto (g->loc, label, b->decl);
    4358              :             }
    4359              :         }
    4360              : 
    4361              :       /* We also need to warn about decls defined in any scopes
    4362              :          between the scope of the label and the scope of the goto.  */
    4363        67055 :       for (scope = label_vars->label_bindings.scope;
    4364        69926 :            scope != g->goto_bindings.scope;
    4365         2871 :            scope = scope->outer)
    4366              :         {
    4367         2871 :           gcc_assert (scope != NULL);
    4368         2871 :           if (scope->has_jump_unsafe_decl)
    4369              :             {
    4370          325 :               if (scope == label_vars->label_bindings.scope)
    4371          249 :                 b = label_vars->label_bindings.bindings_in_scope;
    4372              :               else
    4373           76 :                 b = scope->bindings;
    4374          864 :               for (; b != NULL; b = b->prev)
    4375              :                 {
    4376          539 :                   if (decl_jump_unsafe (b->decl))
    4377          539 :                     warn_about_goto (g->loc, label, b->decl);
    4378              :                 }
    4379              :             }
    4380              :         }
    4381              : 
    4382        67055 :       if (g->goto_bindings.stmt_exprs > 0)
    4383              :         {
    4384          100 :           auto_diagnostic_group d;
    4385          100 :           error_at (g->loc, "jump into statement expression");
    4386          100 :           inform (DECL_SOURCE_LOCATION (label), "label %qD defined here",
    4387              :                   label);
    4388          100 :         }
    4389              :     }
    4390              : 
    4391              :   /* Now that the label is defined, we will issue warnings about
    4392              :      subsequent gotos to this label when we see them.  */
    4393         7649 :   vec_safe_truncate (label_vars->gotos, 0);
    4394         7649 :   label_vars->gotos = NULL;
    4395         7649 : }
    4396              : 
    4397              : /* Define a label, specifying the location in the source file.
    4398              :    Return the LABEL_DECL node for the label, if the definition is valid.
    4399              :    Otherwise return NULL_TREE.  */
    4400              : 
    4401              : tree
    4402        24790 : define_label (location_t location, tree name)
    4403              : {
    4404              :   /* Find any preexisting label with this name.  It is an error
    4405              :      if that label has already been defined in this function, or
    4406              :      if there is a containing function with a declared label with
    4407              :      the same name.  */
    4408        24790 :   tree label = I_LABEL_DECL (name);
    4409              : 
    4410         7685 :   if (label
    4411         7685 :       && ((DECL_CONTEXT (label) == current_function_decl
    4412         7671 :            && DECL_INITIAL (label) != NULL_TREE)
    4413         7663 :           || (DECL_CONTEXT (label) != current_function_decl
    4414           14 :               && C_DECLARED_LABEL_FLAG (label))))
    4415              :     {
    4416           29 :       auto_diagnostic_group d;
    4417           29 :       error_at (location, "duplicate label %qD", label);
    4418           29 :       locate_old_decl (label);
    4419           29 :       return NULL_TREE;
    4420           29 :     }
    4421        24761 :   else if (label && DECL_CONTEXT (label) == current_function_decl)
    4422              :     {
    4423         7649 :       struct c_label_vars *label_vars = I_LABEL_BINDING (name)->u.label;
    4424              : 
    4425              :       /* The label has been used or declared already in this function,
    4426              :          but not defined.  Update its location to point to this
    4427              :          definition.  */
    4428         7649 :       DECL_SOURCE_LOCATION (label) = location;
    4429         7649 :       set_spot_bindings (&label_vars->label_bindings, true);
    4430              : 
    4431              :       /* Issue warnings as required about any goto statements from
    4432              :          earlier in the function.  */
    4433         7649 :       check_earlier_gotos (label, label_vars);
    4434              :     }
    4435              :   else
    4436              :     {
    4437        17112 :       struct c_label_vars *label_vars;
    4438              : 
    4439              :       /* No label binding for that identifier; make one.  */
    4440        17112 :       label = make_label (location, name, true, &label_vars);
    4441              : 
    4442              :       /* Ordinary labels go in the current function scope.  */
    4443        17112 :       bind_label (name, label, current_function_scope, label_vars);
    4444              :     }
    4445              : 
    4446        24761 :   if (!in_system_header_at (input_location) && lookup_name (name))
    4447          143 :     warning_at (location, OPT_Wtraditional,
    4448              :                 "traditional C lacks a separate namespace "
    4449              :                 "for labels, identifier %qE conflicts", name);
    4450              : 
    4451              :   /* Mark label as having been defined.  */
    4452        24761 :   DECL_INITIAL (label) = error_mark_node;
    4453        24761 :   return label;
    4454              : }
    4455              : 
    4456              : /* Get the bindings for a new switch statement.  This is used to issue
    4457              :    warnings as appropriate for jumps from the switch to case or
    4458              :    default labels.  */
    4459              : 
    4460              : struct c_spot_bindings *
    4461        38874 : c_get_switch_bindings (void)
    4462              : {
    4463        38874 :   struct c_spot_bindings *switch_bindings;
    4464              : 
    4465        38874 :   switch_bindings = XNEW (struct c_spot_bindings);
    4466        38874 :   set_spot_bindings (switch_bindings, true);
    4467        38874 :   return switch_bindings;
    4468              : }
    4469              : 
    4470              : void
    4471        38874 : c_release_switch_bindings (struct c_spot_bindings *bindings)
    4472              : {
    4473        38874 :   gcc_assert (bindings->stmt_exprs == 0 && !bindings->left_stmt_expr);
    4474        38874 :   XDELETE (bindings);
    4475        38874 : }
    4476              : 
    4477              : /* This is called at the point of a case or default label to issue
    4478              :    warnings about decls as needed.  It returns true if it found an
    4479              :    error, not just a warning.  */
    4480              : 
    4481              : bool
    4482      1039788 : c_check_switch_jump_warnings (struct c_spot_bindings *switch_bindings,
    4483              :                               location_t switch_loc, location_t case_loc)
    4484              : {
    4485      1039788 :   bool saw_error;
    4486      1039788 :   struct c_scope *scope;
    4487              : 
    4488      1039788 :   saw_error = false;
    4489      1039788 :   for (scope = current_scope;
    4490      3119261 :        scope != switch_bindings->scope;
    4491      2079473 :        scope = scope->outer)
    4492              :     {
    4493      2079473 :       struct c_binding *b;
    4494              : 
    4495      2079473 :       gcc_assert (scope != NULL);
    4496              : 
    4497      2079473 :       if (!scope->has_jump_unsafe_decl)
    4498      2079462 :         continue;
    4499              : 
    4500           22 :       for (b = scope->bindings; b != NULL; b = b->prev)
    4501              :         {
    4502           11 :           if (decl_jump_unsafe (b->decl))
    4503              :             {
    4504           11 :               auto_diagnostic_group d;
    4505           11 :               bool emitted;
    4506           11 :               if (c_type_variably_modified_p (TREE_TYPE (b->decl)))
    4507              :                 {
    4508            6 :                   saw_error = true;
    4509            6 :                   error_at (case_loc,
    4510              :                             "switch jumps into scope of identifier with "
    4511              :                             "variably modified type");
    4512            6 :                   emitted = true;
    4513              :                 }
    4514            5 :               else if (flag_openmp
    4515            7 :                        && lookup_attribute ("omp allocate",
    4516            2 :                                             DECL_ATTRIBUTES (b->decl)))
    4517              :                 {
    4518            2 :                   saw_error = true;
    4519            2 :                   error_at (case_loc,
    4520              :                             "switch jumps over OpenMP %<allocate%> allocation");
    4521            2 :                   emitted = true;
    4522              :                 }
    4523              :               else
    4524            3 :                 emitted
    4525            3 :                   = warning_at (case_loc, OPT_Wjump_misses_init,
    4526              :                                 "switch jumps over variable initialization");
    4527           11 :               if (emitted)
    4528              :                 {
    4529           11 :                   inform (switch_loc, "switch starts here");
    4530           11 :                   inform (DECL_SOURCE_LOCATION (b->decl), "%qD declared here",
    4531              :                           b->decl);
    4532              :                 }
    4533           11 :             }
    4534              :         }
    4535              :     }
    4536              : 
    4537      1039788 :   if (switch_bindings->stmt_exprs > 0)
    4538              :     {
    4539            4 :       saw_error = true;
    4540            4 :       auto_diagnostic_group d;
    4541            4 :       error_at (case_loc, "switch jumps into statement expression");
    4542            4 :       inform (switch_loc, "switch starts here");
    4543            4 :     }
    4544              : 
    4545      1039788 :   return saw_error;
    4546              : }
    4547              : 
    4548              : /* Given NAME, an IDENTIFIER_NODE,
    4549              :    return the structure (or union or enum) definition for that name.
    4550              :    If THISLEVEL_ONLY is nonzero, searches only the current_scope.
    4551              :    CODE says which kind of type the caller wants;
    4552              :    it is RECORD_TYPE or UNION_TYPE or ENUMERAL_TYPE.
    4553              :    If PLOC is not NULL and this returns non-null, it sets *PLOC to the
    4554              :    location where the tag was defined.
    4555              :    If the wrong kind of type is found, an error is reported.  */
    4556              : 
    4557              : static tree
    4558      2135818 : lookup_tag (enum tree_code code, tree name, bool thislevel_only,
    4559              :             location_t *ploc)
    4560              : {
    4561      2135818 :   struct c_binding *b = I_TAG_BINDING (name);
    4562      2135818 :   bool thislevel = false;
    4563              : 
    4564      2135818 :   if (!b || !b->decl)
    4565              :     return NULL_TREE;
    4566              : 
    4567              :   /* We only care about whether it's in this level if
    4568              :      thislevel_only was set or it might be a type clash.  */
    4569      1494447 :   if (thislevel_only || TREE_CODE (b->decl) != code)
    4570              :     {
    4571              :       /* For our purposes, a tag in the external scope is the same as
    4572              :          a tag in the file scope.  (Primarily relevant to Objective-C
    4573              :          and its builtin structure tags, which get pushed before the
    4574              :          file scope is created.)  */
    4575       479253 :       if (B_IN_CURRENT_SCOPE (b)
    4576          196 :           || (current_scope == file_scope && B_IN_EXTERNAL_SCOPE (b)))
    4577      1494447 :         thislevel = true;
    4578              :     }
    4579              : 
    4580      1494447 :   if (thislevel_only && !thislevel)
    4581              :     return NULL_TREE;
    4582              : 
    4583      1494272 :   if (TREE_CODE (b->decl) != code)
    4584              :     {
    4585              :       /* Definition isn't the kind we were looking for.  */
    4586           39 :       pending_invalid_xref = name;
    4587           39 :       pending_invalid_xref_location = input_location;
    4588              : 
    4589              :       /* If in the same binding level as a declaration as a tag
    4590              :          of a different type, this must not be allowed to
    4591              :          shadow that tag, so give the error immediately.
    4592              :          (For example, "struct foo; union foo;" is invalid.)  */
    4593           39 :       if (thislevel)
    4594           18 :         pending_xref_error ();
    4595              :     }
    4596              : 
    4597      1494272 :   if (ploc != NULL)
    4598      1041364 :     *ploc = b->locus;
    4599              : 
    4600      1494272 :   return b->decl;
    4601              : }
    4602              : 
    4603              : /* Return true if a definition exists for NAME with code CODE.  */
    4604              : 
    4605              : bool
    4606          372 : tag_exists_p (enum tree_code code, tree name)
    4607              : {
    4608          372 :   struct c_binding *b = I_TAG_BINDING (name);
    4609              : 
    4610          372 :   if (b == NULL || b->decl == NULL_TREE)
    4611              :     return false;
    4612           18 :   return TREE_CODE (b->decl) == code;
    4613              : }
    4614              : 
    4615              : /* Print an error message now
    4616              :    for a recent invalid struct, union or enum cross reference.
    4617              :    We don't print them immediately because they are not invalid
    4618              :    when used in the `struct foo;' construct for shadowing.  */
    4619              : 
    4620              : void
    4621    325509887 : pending_xref_error (void)
    4622              : {
    4623    325509887 :   if (pending_invalid_xref != NULL_TREE)
    4624           27 :     error_at (pending_invalid_xref_location, "%qE defined as wrong kind of tag",
    4625              :               pending_invalid_xref);
    4626    325509887 :   pending_invalid_xref = NULL_TREE;
    4627    325509887 : }
    4628              : 
    4629              : 
    4630              : /* Look up NAME in the current scope and its superiors
    4631              :    in the namespace of variables, functions and typedefs.
    4632              :    Return a ..._DECL node of some kind representing its definition,
    4633              :    or return NULL_TREE if it is undefined.  */
    4634              : 
    4635              : tree
    4636   1312624947 : lookup_name (tree name)
    4637              : {
    4638   1312624947 :   struct c_binding *b = I_SYMBOL_BINDING (name);
    4639              :   /* Do not resolve non-default function versions.  */
    4640   1312624947 :   if (b
    4641    887170962 :       && TREE_CODE (b->decl) == FUNCTION_DECL
    4642    122143724 :       && DECL_FUNCTION_VERSIONED (b->decl)
    4643   1312624947 :       && !is_function_default_version (b->decl))
    4644              :     return NULL_TREE;
    4645   1312624947 :   if (b && !b->invisible)
    4646              :     {
    4647    875797438 :       maybe_record_typedef_use (b->decl);
    4648    875797438 :       return b->decl;
    4649              :     }
    4650              :   return NULL_TREE;
    4651              : }
    4652              : 
    4653              : /* Similar to `lookup_name' but look only at the indicated scope.  */
    4654              : 
    4655              : static tree
    4656    135720022 : lookup_name_in_scope (tree name, struct c_scope *scope)
    4657              : {
    4658    135720022 :   struct c_binding *b;
    4659              : 
    4660    135723255 :   for (b = I_SYMBOL_BINDING (name); b; b = b->shadowed)
    4661      7800631 :     if (B_IN_SCOPE (b, scope))
    4662      7797398 :       return b->decl;
    4663              :   return NULL_TREE;
    4664              : }
    4665              : 
    4666              : /* Look for the closest match for NAME within the currently valid
    4667              :    scopes.
    4668              : 
    4669              :    This finds the identifier with the lowest Levenshtein distance to
    4670              :    NAME.  If there are multiple candidates with equal minimal distance,
    4671              :    the first one found is returned.  Scopes are searched from innermost
    4672              :    outwards, and within a scope in reverse order of declaration, thus
    4673              :    benefiting candidates "near" to the current scope.
    4674              : 
    4675              :    The function also looks for similar macro names to NAME, since a
    4676              :    misspelled macro name will not be expanded, and hence looks like an
    4677              :    identifier to the C frontend.
    4678              : 
    4679              :    It also looks for start_typename keywords, to detect "singed" vs "signed"
    4680              :    typos.
    4681              : 
    4682              :    Use LOC for any deferred diagnostics.  */
    4683              : 
    4684              : name_hint
    4685         2097 : lookup_name_fuzzy (tree name, enum lookup_name_fuzzy_kind kind, location_t loc)
    4686              : {
    4687         2097 :   gcc_assert (TREE_CODE (name) == IDENTIFIER_NODE);
    4688              : 
    4689              :   /* Look up function-like macros first; maybe misusing them. */
    4690         4194 :   auto cpp_node = cpp_lookup (parse_in,
    4691         2097 :                               (const unsigned char*)IDENTIFIER_POINTER (name),
    4692         2097 :                               IDENTIFIER_LENGTH (name));
    4693         2097 :   if (cpp_node && cpp_fun_like_macro_p (cpp_node))
    4694            5 :     return name_hint
    4695              :       (nullptr,
    4696            5 :        std::make_unique<macro_like_function_used> (loc,
    4697           10 :                                                    IDENTIFIER_POINTER (name)));
    4698              : 
    4699              :   /* Next, try some well-known names in the C standard library, in case
    4700              :      the user forgot a #include.  */
    4701         2092 :   const char *header_hint
    4702         2092 :     = get_c_stdlib_header_for_name (IDENTIFIER_POINTER (name));
    4703              : 
    4704         2092 :   if (header_hint)
    4705           56 :     return name_hint
    4706              :       (nullptr,
    4707           56 :        std::make_unique<suggest_missing_header> (loc,
    4708          112 :                                                  IDENTIFIER_POINTER (name),
    4709           56 :                                                  header_hint));
    4710              : 
    4711              :   /* Next, look for exact matches for builtin defines that would have been
    4712              :      defined if the user had passed a command-line option (e.g. -fopenmp
    4713              :      for "_OPENMP").  */
    4714         2036 :   diagnostics::option_id option_id
    4715         2036 :     = get_option_for_builtin_define (IDENTIFIER_POINTER (name));
    4716         2036 :   if (option_id.m_idx > 0)
    4717            2 :     return name_hint
    4718              :       (nullptr,
    4719            2 :        std::make_unique<suggest_missing_option> (loc,
    4720            4 :                                                  IDENTIFIER_POINTER (name),
    4721            2 :                                                  option_id));
    4722              : 
    4723              :   /* Only suggest names reserved for the implementation if NAME begins
    4724              :      with an underscore.  */
    4725         2034 :   bool consider_implementation_names = (IDENTIFIER_POINTER (name)[0] == '_');
    4726              : 
    4727         2034 :   best_match<tree, tree> bm (name);
    4728              : 
    4729              :   /* Look within currently valid scopes.  */
    4730         9208 :   for (c_scope *scope = current_scope; scope; scope = scope->outer)
    4731     11563656 :     for (c_binding *binding = scope->bindings; binding; binding = binding->prev)
    4732              :       {
    4733     11556482 :         if (!binding->id || binding->invisible)
    4734      6535313 :           continue;
    4735      5021169 :         if (binding->decl == error_mark_node)
    4736          374 :           continue;
    4737              :         /* Don't use bindings from implicitly declared functions,
    4738              :            as they were likely misspellings themselves.  */
    4739      5020795 :         if (TREE_CODE (binding->decl) == FUNCTION_DECL)
    4740      4615435 :           if (C_DECL_IMPLICIT (binding->decl))
    4741          229 :             continue;
    4742              :         /* Don't suggest names that are reserved for use by the
    4743              :            implementation, unless NAME began with an underscore.  */
    4744      5020566 :         if (!consider_implementation_names)
    4745              :           {
    4746      2344781 :             const char *suggestion_str = IDENTIFIER_POINTER (binding->id);
    4747      2344781 :             if (name_reserved_for_implementation_p (suggestion_str))
    4748      2284741 :               continue;
    4749              :           }
    4750      2735825 :         switch (kind)
    4751              :           {
    4752        37362 :           case FUZZY_LOOKUP_TYPENAME:
    4753        37362 :             if (TREE_CODE (binding->decl) != TYPE_DECL)
    4754        29927 :               continue;
    4755              :             break;
    4756              : 
    4757       129882 :           case FUZZY_LOOKUP_FUNCTION_NAME:
    4758       129882 :             if (TREE_CODE (binding->decl) != FUNCTION_DECL)
    4759              :               {
    4760              :                 /* Allow function pointers.  */
    4761        27001 :                 if ((VAR_P (binding->decl)
    4762        22476 :                      || TREE_CODE (binding->decl) == PARM_DECL)
    4763         5403 :                     && TREE_CODE (TREE_TYPE (binding->decl)) == POINTER_TYPE
    4764        28283 :                     && (TREE_CODE (TREE_TYPE (TREE_TYPE (binding->decl)))
    4765              :                         == FUNCTION_TYPE))
    4766              :                   break;
    4767        26982 :                 continue;
    4768              :               }
    4769              :             break;
    4770              : 
    4771              :           default:
    4772              :             break;
    4773              :           }
    4774      2678916 :         bm.consider (binding->id);
    4775              :       }
    4776              : 
    4777              :   /* Consider macros: if the user misspelled a macro name e.g. "SOME_MACRO"
    4778              :      as:
    4779              :        x = SOME_OTHER_MACRO (y);
    4780              :      then "SOME_OTHER_MACRO" will survive to the frontend and show up
    4781              :      as a misspelled identifier.
    4782              : 
    4783              :      Use the best distance so far so that a candidate is only set if
    4784              :      a macro is better than anything so far.  This allows early rejection
    4785              :      (without calculating the edit distance) of macro names that must have
    4786              :      distance >= bm.get_best_distance (), and means that we only get a
    4787              :      non-NULL result for best_macro_match if it's better than any of
    4788              :      the identifiers already checked, which avoids needless creation
    4789              :      of identifiers for macro hashnodes.  */
    4790         2034 :   best_macro_match bmm (name, bm.get_best_distance (), parse_in);
    4791         2034 :   cpp_hashnode *best_macro = bmm.get_best_meaningful_candidate ();
    4792              :   /* If a macro is the closest so far to NAME, use it, creating an
    4793              :      identifier tree node for it.  */
    4794         2034 :   if (best_macro)
    4795              :     {
    4796           11 :       const char *id = (const char *)best_macro->ident.str;
    4797           11 :       tree macro_as_identifier
    4798           11 :         = get_identifier_with_length (id, best_macro->ident.len);
    4799           11 :       bm.set_best_so_far (macro_as_identifier,
    4800              :                           bmm.get_best_distance (),
    4801              :                           bmm.get_best_candidate_length ());
    4802              :     }
    4803              : 
    4804              :   /* Try the "start_typename" keywords to detect
    4805              :      "singed" vs "signed" typos.  */
    4806         2034 :   if (kind == FUZZY_LOOKUP_TYPENAME)
    4807              :     {
    4808        56882 :       for (unsigned i = 0; i < num_c_common_reswords; i++)
    4809              :         {
    4810        56643 :           const c_common_resword *resword = &c_common_reswords[i];
    4811        56643 :           if (!c_keyword_starts_typename (resword->rid))
    4812        43498 :             continue;
    4813        13145 :           tree resword_identifier = ridpointers [resword->rid];
    4814        13145 :           if (!resword_identifier)
    4815           30 :             continue;
    4816        13115 :           gcc_assert (TREE_CODE (resword_identifier) == IDENTIFIER_NODE);
    4817        13115 :           bm.consider (resword_identifier);
    4818              :         }
    4819              :     }
    4820              : 
    4821         2034 :   tree best = bm.get_best_meaningful_candidate ();
    4822         2034 :   if (best)
    4823          276 :     return name_hint (IDENTIFIER_POINTER (best), NULL);
    4824              :   else
    4825         1758 :     return name_hint (NULL, NULL);
    4826              : }
    4827              : 
    4828              : 
    4829              : /* Handle the standard [[nodiscard]] attribute.  */
    4830              : 
    4831              : static tree
    4832           34 : handle_nodiscard_attribute (tree *node, tree name, tree /*args*/,
    4833              :                             int /*flags*/, bool *no_add_attrs)
    4834              : {
    4835           34 :   if (TREE_CODE (*node) == FUNCTION_DECL)
    4836              :     {
    4837           18 :       if (VOID_TYPE_P (TREE_TYPE (TREE_TYPE (*node))))
    4838            1 :         warning_at (DECL_SOURCE_LOCATION (*node),
    4839            1 :                     OPT_Wattributes, "%qE attribute applied to %qD with void "
    4840              :                     "return type", name, *node);
    4841              :     }
    4842           16 :   else if (RECORD_OR_UNION_TYPE_P (*node)
    4843           12 :            || TREE_CODE (*node) == ENUMERAL_TYPE)
    4844              :     /* OK */;
    4845              :   else
    4846              :     {
    4847           10 :       pedwarn (input_location,
    4848           10 :                OPT_Wattributes, "%qE attribute can only be applied to "
    4849              :                "functions or to structure, union or enumeration types", name);
    4850           10 :       *no_add_attrs = true;
    4851              :     }
    4852           34 :   return NULL_TREE;
    4853              : }
    4854              : 
    4855              : /* Handle the standard [[noreturn]] attribute.  */
    4856              : 
    4857              : static tree
    4858           44 : handle_std_noreturn_attribute (tree *node, tree name, tree args,
    4859              :                                int flags, bool *no_add_attrs)
    4860              : {
    4861              :   /* Unlike GNU __attribute__ ((noreturn)), the standard [[noreturn]]
    4862              :      only applies to functions, not function pointers.  */
    4863           44 :   if (TREE_CODE (*node) == FUNCTION_DECL)
    4864           22 :     return handle_noreturn_attribute (node, name, args, flags, no_add_attrs);
    4865              :   else
    4866              :     {
    4867           22 :       pedwarn (input_location, OPT_Wattributes,
    4868              :                "standard %qE attribute can only be applied to functions",
    4869              :                name);
    4870           22 :       *no_add_attrs = true;
    4871           22 :       return NULL_TREE;
    4872              :     }
    4873              : }
    4874              : 
    4875              : /* Handle the standard [[unsequenced]] attribute.  */
    4876              : 
    4877              : static tree
    4878           68 : handle_std_unsequenced_attribute (tree *node, tree name, tree args,
    4879              :                                   int flags, bool *no_add_attrs)
    4880              : {
    4881              :   /* Unlike GNU __attribute__ ((unsequenced)), the standard [[unsequenced]]
    4882              :      should be only applied to function declarators or type specifiers which
    4883              :      have function type.  */
    4884           68 :   if (node[2])
    4885              :     {
    4886            8 :       auto_diagnostic_group d;
    4887            8 :       if (pedwarn (input_location, OPT_Wattributes,
    4888              :                    "standard %qE attribute can only be applied to function "
    4889              :                    "declarators or type specifiers with function type", name))
    4890            8 :         inform (input_location, "did you mean to specify it after %<)%> "
    4891              :                                 "following function parameters?");
    4892            8 :       *no_add_attrs = true;
    4893            8 :       return NULL_TREE;
    4894            8 :     }
    4895           60 :   return handle_unsequenced_attribute (node, name, args, flags, no_add_attrs);
    4896              : }
    4897              : 
    4898              : /* Handle the standard [[reproducible]] attribute.  */
    4899              : 
    4900              : static tree
    4901           34 : handle_std_reproducible_attribute (tree *node, tree name, tree args,
    4902              :                                    int flags, bool *no_add_attrs)
    4903              : {
    4904           34 :   return handle_std_unsequenced_attribute (node, name, args, flags,
    4905           34 :                                            no_add_attrs);
    4906              : }
    4907              : 
    4908              : /* Table of supported standard (C23) attributes.  */
    4909              : static const attribute_spec std_attributes[] =
    4910              : {
    4911              :   /* { name, min_len, max_len, decl_req, type_req, fn_type_req,
    4912              :        affects_type_identity, handler, exclude } */
    4913              :   { "_Noreturn", 0, 0, false, false, false, false,
    4914              :     handle_std_noreturn_attribute, NULL },
    4915              :   { "deprecated", 0, 1, false, false, false, false,
    4916              :     handle_deprecated_attribute, NULL },
    4917              :   { "fallthrough", 0, 0, false, false, false, false,
    4918              :     handle_fallthrough_attribute, NULL },
    4919              :   { "maybe_unused", 0, 0, false, false, false, false,
    4920              :     handle_unused_attribute, NULL },
    4921              :   { "nodiscard", 0, 1, false, false, false, false,
    4922              :     handle_nodiscard_attribute, NULL },
    4923              :   { "noreturn", 0, 0, false, false, false, false,
    4924              :     handle_std_noreturn_attribute, NULL },
    4925              :   { "reproducible", 0, 0, false, true, true, false,
    4926              :     handle_std_reproducible_attribute, NULL },
    4927              :   { "unsequenced", 0, 0, false, true, true, false,
    4928              :     handle_std_unsequenced_attribute, NULL }
    4929              : };
    4930              : 
    4931              : const scoped_attribute_specs std_attribute_table =
    4932              : {
    4933              :   nullptr, { std_attributes }
    4934              : };
    4935              : 
    4936              : /* Create the predefined scalar types of C,
    4937              :    and some nodes representing standard constants (0, 1, (void *) 0).
    4938              :    Initialize the global scope.
    4939              :    Make definitions for built-in primitive functions.  */
    4940              : 
    4941              : void
    4942       116041 : c_init_decl_processing (void)
    4943              : {
    4944       116041 :   location_t save_loc = input_location;
    4945              : 
    4946              :   /* Initialize reserved words for parser.  */
    4947       116041 :   c_parse_init ();
    4948              : 
    4949       116041 :   current_function_decl = NULL_TREE;
    4950              : 
    4951       116041 :   gcc_obstack_init (&parser_obstack);
    4952              : 
    4953              :   /* Make the externals scope.  */
    4954       116041 :   push_scope ();
    4955       116041 :   external_scope = current_scope;
    4956              : 
    4957              :   /* Declarations from c_common_nodes_and_builtins must not be associated
    4958              :      with this input file, lest we get differences between using and not
    4959              :      using preprocessed headers.  */
    4960       116041 :   input_location = BUILTINS_LOCATION;
    4961              : 
    4962       116041 :   c_common_nodes_and_builtins ();
    4963              : 
    4964              :   /* In C, comparisons and TRUTH_* expressions have type int.  */
    4965       116041 :   truthvalue_type_node = integer_type_node;
    4966       116041 :   truthvalue_true_node = integer_one_node;
    4967       116041 :   truthvalue_false_node = integer_zero_node;
    4968              : 
    4969              :   /* Even in C99, which has a real boolean type.  */
    4970       116041 :   pushdecl (build_decl (UNKNOWN_LOCATION, TYPE_DECL,
    4971       116041 :                         get_identifier (flag_isoc23 ? "bool" : "_Bool"),
    4972              :                         boolean_type_node));
    4973              : 
    4974              :   /* C-specific nullptr initialization.  */
    4975       116041 :   record_builtin_type (RID_MAX, "typeof (nullptr)", nullptr_type_node);
    4976              :   /* The size and alignment of nullptr_t is the same as for a pointer to
    4977              :      character type.  */
    4978       116041 :   SET_TYPE_ALIGN (nullptr_type_node, GET_MODE_ALIGNMENT (ptr_mode));
    4979              : 
    4980       116041 :   input_location = save_loc;
    4981              : 
    4982       116041 :   make_fname_decl = c_make_fname_decl;
    4983       116041 :   start_fname_decls ();
    4984              : 
    4985       116041 :   if (warn_keyword_macro)
    4986              :     {
    4987         1190 :       for (unsigned int i = 0; i < num_c_common_reswords; ++i)
    4988              :         /* For C register keywords which don't start with underscore
    4989              :            or start with just single underscore.  Don't complain about
    4990              :            ObjC or Transactional Memory keywords.  */
    4991         1185 :         if (c_common_reswords[i].word[0] == '_'
    4992          555 :             && c_common_reswords[i].word[1] == '_')
    4993          415 :           continue;
    4994          995 :         else if (c_common_reswords[i].disable
    4995          770 :                  & (D_TRANSMEM | D_OBJC | D_CXX_OBJC))
    4996          225 :           continue;
    4997              :         else
    4998              :           {
    4999          545 :             tree id = get_identifier (c_common_reswords[i].word);
    5000          545 :             if (C_IS_RESERVED_WORD (id)
    5001          545 :                 && C_RID_CODE (id) != RID_CXX_COMPAT_WARN)
    5002          332 :               cpp_warn (parse_in, IDENTIFIER_POINTER (id),
    5003          332 :                         IDENTIFIER_LENGTH (id));
    5004              :           }
    5005              :     }
    5006       116041 : }
    5007              : 
    5008              : /* Create the VAR_DECL at LOC for __FUNCTION__ etc. ID is the name to
    5009              :    give the decl, NAME is the initialization string and TYPE_DEP
    5010              :    indicates whether NAME depended on the type of the function.  As we
    5011              :    don't yet implement delayed emission of static data, we mark the
    5012              :    decl as emitted so it is not placed in the output.  Anything using
    5013              :    it must therefore pull out the STRING_CST initializer directly.
    5014              :    FIXME.  */
    5015              : 
    5016              : static tree
    5017         2983 : c_make_fname_decl (location_t loc, tree id, int type_dep)
    5018              : {
    5019         2983 :   const char *name = fname_as_string (type_dep);
    5020         2983 :   tree decl, type, init;
    5021         2983 :   size_t length = strlen (name);
    5022              : 
    5023         2983 :   type = c_build_array_type (char_type_node,
    5024         2983 :                              build_index_type (size_int (length)));
    5025         2983 :   type = c_build_qualified_type (type, TYPE_QUAL_CONST);
    5026              : 
    5027         2983 :   decl = build_decl (loc, VAR_DECL, id, type);
    5028              : 
    5029         2983 :   TREE_STATIC (decl) = 1;
    5030         2983 :   TREE_READONLY (decl) = 1;
    5031         2983 :   DECL_ARTIFICIAL (decl) = 1;
    5032              : 
    5033         2983 :   init = build_string (length + 1, name);
    5034         2983 :   free (const_cast<char *> (name));
    5035         2983 :   TREE_TYPE (init) = type;
    5036         2983 :   DECL_INITIAL (decl) = init;
    5037              : 
    5038         2983 :   TREE_USED (decl) = 1;
    5039              : 
    5040         2983 :   if (current_function_decl
    5041              :       /* For invalid programs like this:
    5042              : 
    5043              :          void foo()
    5044              :          const char* p = __FUNCTION__;
    5045              : 
    5046              :          the __FUNCTION__ is believed to appear in K&R style function
    5047              :          parameter declarator.  In that case we still don't have
    5048              :          function_scope.  */
    5049         2976 :       && current_function_scope)
    5050              :     {
    5051         2968 :       DECL_CONTEXT (decl) = current_function_decl;
    5052         2968 :       bind (id, decl, current_function_scope,
    5053              :             /*invisible=*/false, /*nested=*/false, UNKNOWN_LOCATION);
    5054              :     }
    5055              : 
    5056         2983 :   finish_decl (decl, loc, init, NULL_TREE, NULL_TREE);
    5057              : 
    5058         2983 :   return decl;
    5059              : }
    5060              : 
    5061              : tree
    5062    340104218 : c_builtin_function (tree decl)
    5063              : {
    5064    340104218 :   tree type = TREE_TYPE (decl);
    5065    340104218 :   tree   id = DECL_NAME (decl);
    5066              : 
    5067    340104218 :   const char *name = IDENTIFIER_POINTER (id);
    5068    340104218 :   C_DECL_BUILTIN_PROTOTYPE (decl) = prototype_p (type);
    5069              : 
    5070              :   /* Should never be called on a symbol with a preexisting meaning.  */
    5071    340104218 :   gcc_assert (!I_SYMBOL_BINDING (id));
    5072              : 
    5073    340104218 :   bind (id, decl, external_scope, /*invisible=*/true, /*nested=*/false,
    5074              :         UNKNOWN_LOCATION);
    5075              : 
    5076              :   /* Builtins in the implementation namespace are made visible without
    5077              :      needing to be explicitly declared.  See push_file_scope.  */
    5078    340104218 :   if (name[0] == '_' && (name[1] == '_' || ISUPPER (name[1])))
    5079              :     {
    5080    232357280 :       DECL_CHAIN (decl) = visible_builtins;
    5081    232357280 :       visible_builtins = decl;
    5082              :     }
    5083              : 
    5084    340104218 :   return decl;
    5085              : }
    5086              : 
    5087              : tree
    5088     11048256 : c_builtin_function_ext_scope (tree decl)
    5089              : {
    5090     11048256 :   tree type = TREE_TYPE (decl);
    5091     11048256 :   tree   id = DECL_NAME (decl);
    5092              : 
    5093     11048256 :   const char *name = IDENTIFIER_POINTER (id);
    5094     11048256 :   C_DECL_BUILTIN_PROTOTYPE (decl) = prototype_p (type);
    5095              : 
    5096     11048256 :   if (external_scope)
    5097     10854715 :     bind (id, decl, external_scope, /*invisible=*/false, /*nested=*/false,
    5098              :           UNKNOWN_LOCATION);
    5099              : 
    5100              :   /* Builtins in the implementation namespace are made visible without
    5101              :      needing to be explicitly declared.  See push_file_scope.  */
    5102     11048256 :   if (name[0] == '_' && (name[1] == '_' || ISUPPER (name[1])))
    5103              :     {
    5104     11048256 :       DECL_CHAIN (decl) = visible_builtins;
    5105     11048256 :       visible_builtins = decl;
    5106              :     }
    5107              : 
    5108     11048256 :   return decl;
    5109              : }
    5110              : 
    5111              : /* Implement LANG_HOOKS_SIMULATE_BUILTIN_FUNCTION_DECL.  */
    5112              : 
    5113              : tree
    5114            0 : c_simulate_builtin_function_decl (tree decl)
    5115              : {
    5116            0 :   tree type = TREE_TYPE (decl);
    5117            0 :   C_DECL_BUILTIN_PROTOTYPE (decl) = prototype_p (type);
    5118            0 :   return pushdecl (decl);
    5119              : }
    5120              : 
    5121              : /* Warn about attributes in a context where they are unused
    5122              :    (attribute-declarations, except for the "fallthrough" case, and
    5123              :    attributes on statements).  */
    5124              : 
    5125              : void
    5126     43126312 : c_warn_unused_attributes (tree attrs)
    5127              : {
    5128     43126357 :   for (tree t = attrs; t != NULL_TREE; t = TREE_CHAIN (t))
    5129           45 :     if (get_attribute_namespace (t) == NULL_TREE)
    5130              :       /* The specifications of standard attributes mean this is a
    5131              :          constraint violation.  */
    5132           29 :       pedwarn (input_location, OPT_Wattributes, "%qE attribute ignored",
    5133              :                get_attribute_name (t));
    5134           16 :     else if (!attribute_ignored_p (t))
    5135           12 :       warning (OPT_Wattributes, "%qE attribute ignored",
    5136              :                get_attribute_name (t));
    5137     43126312 : }
    5138              : 
    5139              : /* Warn for standard attributes being applied to a type that is not
    5140              :    being defined, where that is a constraint violation, and return a
    5141              :    list of attributes with them removed.  */
    5142              : 
    5143              : tree
    5144    452613967 : c_warn_type_attributes (tree type, tree attrs)
    5145              : {
    5146    452613967 :   tree *attr_ptr = &attrs;
    5147    452637500 :   while (*attr_ptr)
    5148        23533 :     if (get_attribute_namespace (*attr_ptr) == NULL_TREE)
    5149              :       {
    5150           89 :         if (TREE_CODE (type) == FUNCTION_TYPE)
    5151              :           {
    5152           65 :             tree name = get_attribute_name (*attr_ptr);
    5153              :             /* [[unsequenced]] and [[reproducible]] is fine on function
    5154              :                types that aren't being defined.  */
    5155           65 :             if (is_attribute_p ("unsequenced", name)
    5156           65 :                 || is_attribute_p ("reproducible", name))
    5157              :               {
    5158           60 :                 attr_ptr = &TREE_CHAIN (*attr_ptr);
    5159           60 :                 continue;
    5160              :               }
    5161              :           }
    5162           29 :         pedwarn (input_location, OPT_Wattributes, "%qE attribute ignored",
    5163              :                  get_attribute_name (*attr_ptr));
    5164           29 :         *attr_ptr = TREE_CHAIN (*attr_ptr);
    5165              :       }
    5166              :     else
    5167        23444 :       attr_ptr = &TREE_CHAIN (*attr_ptr);
    5168    452613967 :   return attrs;
    5169              : }
    5170              : 
    5171              : /* Called when a declaration is seen that contains no names to declare.
    5172              :    If its type is a reference to a structure, union or enum inherited
    5173              :    from a containing scope, shadow that tag name for the current scope
    5174              :    with a forward reference.
    5175              :    If its type defines a new named structure or union
    5176              :    or defines an enum, it is valid but we need not do anything here.
    5177              :    Otherwise, it is an error.  */
    5178              : 
    5179              : void
    5180       516256 : shadow_tag (const struct c_declspecs *declspecs)
    5181              : {
    5182       516256 :   shadow_tag_warned (declspecs, 0);
    5183       516256 : }
    5184              : 
    5185              : /* WARNED is 1 if we have done a pedwarn, 2 if we have done a warning,
    5186              :    but no pedwarn.  */
    5187              : void
    5188       516332 : shadow_tag_warned (const struct c_declspecs *declspecs, int warned)
    5189              : {
    5190       516332 :   bool found_tag = false;
    5191              : 
    5192       516332 :   if (declspecs->type && !declspecs->default_int_p && !declspecs->typedef_p)
    5193              :     {
    5194       516212 :       tree value = declspecs->type;
    5195       516212 :       enum tree_code code = TREE_CODE (value);
    5196              : 
    5197       516212 :       if (code == RECORD_TYPE || code == UNION_TYPE || code == ENUMERAL_TYPE)
    5198              :         /* Used to test also that TYPE_SIZE (value) != 0.
    5199              :            That caused warning for `struct foo;' at top level in the file.  */
    5200              :         {
    5201       516161 :           tree name = TYPE_NAME (value);
    5202       516161 :           tree t;
    5203              : 
    5204       516161 :           found_tag = true;
    5205              : 
    5206       516161 :           if (declspecs->restrict_p)
    5207              :             {
    5208            2 :               error ("invalid use of %<restrict%>");
    5209            2 :               warned = 1;
    5210              :             }
    5211              : 
    5212       516161 :           if (in_underspecified_init)
    5213              :             {
    5214              :               /* This can only occur with extensions such as statement
    5215              :                  expressions, but is still appropriate as an error to
    5216              :                  avoid types declared in such a context escaping to
    5217              :                  the type of an auto variable.  */
    5218            1 :               error ("%qT declared in underspecified object initializer",
    5219              :                      value);
    5220            1 :               warned = 1;
    5221              :             }
    5222              : 
    5223       516161 :           if (name == NULL_TREE)
    5224              :             {
    5225        63242 :               if (warned != 1 && code != ENUMERAL_TYPE)
    5226              :                 /* Empty unnamed enum OK */
    5227              :                 {
    5228           19 :                   pedwarn (input_location, 0,
    5229              :                            "unnamed struct/union that defines no instances");
    5230           19 :                   warned = 1;
    5231              :                 }
    5232              :             }
    5233       452919 :           else if (declspecs->typespec_kind != ctsk_tagdef
    5234        89273 :                    && declspecs->typespec_kind != ctsk_tagfirstref
    5235        26515 :                    && declspecs->typespec_kind != ctsk_tagfirstref_attrs
    5236        26507 :                    && declspecs->storage_class != csc_none)
    5237              :             {
    5238            2 :               if (warned != 1)
    5239            2 :                 pedwarn (input_location, 0,
    5240              :                          "empty declaration with storage class specifier "
    5241              :                          "does not redeclare tag");
    5242            2 :               warned = 1;
    5243            2 :               pending_xref_error ();
    5244              :             }
    5245       452917 :           else if (declspecs->typespec_kind != ctsk_tagdef
    5246        89271 :                    && declspecs->typespec_kind != ctsk_tagfirstref
    5247        26513 :                    && declspecs->typespec_kind != ctsk_tagfirstref_attrs
    5248        26505 :                    && (declspecs->const_p
    5249        26502 :                        || declspecs->volatile_p
    5250        26502 :                        || declspecs->atomic_p
    5251        26502 :                        || declspecs->restrict_p
    5252        26502 :                        || declspecs->address_space))
    5253              :             {
    5254            3 :               if (warned != 1)
    5255            3 :                 pedwarn (input_location, 0,
    5256              :                          "empty declaration with type qualifier "
    5257              :                           "does not redeclare tag");
    5258            3 :               warned = 1;
    5259            3 :               pending_xref_error ();
    5260              :             }
    5261       452914 :           else if (declspecs->typespec_kind != ctsk_tagdef
    5262        89268 :                    && declspecs->typespec_kind != ctsk_tagfirstref
    5263        26510 :                    && declspecs->typespec_kind != ctsk_tagfirstref_attrs
    5264        26502 :                    && declspecs->alignas_p)
    5265              :             {
    5266            1 :               if (warned != 1)
    5267            1 :                 pedwarn (input_location, 0,
    5268              :                          "empty declaration with %<_Alignas%> "
    5269              :                           "does not redeclare tag");
    5270            1 :               warned = 1;
    5271            1 :               pending_xref_error ();
    5272              :             }
    5273       452913 :           else if (declspecs->typespec_kind != ctsk_tagdef
    5274        89267 :                    && declspecs->typespec_kind != ctsk_tagfirstref
    5275        26509 :                    && declspecs->typespec_kind != ctsk_tagfirstref_attrs
    5276        26501 :                    && code == ENUMERAL_TYPE
    5277           15 :                    && !declspecs->enum_type_specifier_ref_p)
    5278              :             {
    5279            3 :               bool warned_enum = false;
    5280            3 :               if (warned != 1)
    5281            3 :                 warned_enum = pedwarn (input_location, OPT_Wpedantic,
    5282              :                                        "empty declaration of %<enum%> type "
    5283              :                                        "does not redeclare tag");
    5284            3 :               if (warned_enum)
    5285            2 :                 warned = 1;
    5286            3 :               pending_xref_error ();
    5287            3 :             }
    5288              :           else
    5289              :             {
    5290       452910 :               pending_invalid_xref = NULL_TREE;
    5291       452910 :               t = lookup_tag (code, name, true, NULL);
    5292              : 
    5293       452910 :               if (t == NULL_TREE)
    5294              :                 {
    5295            2 :                   t = make_node (code);
    5296            2 :                   if (flag_isoc23 || code == ENUMERAL_TYPE)
    5297            1 :                     SET_TYPE_STRUCTURAL_EQUALITY (t);
    5298            2 :                   pushtag (input_location, name, t);
    5299              :                 }
    5300              :             }
    5301              :         }
    5302              :       else
    5303              :         {
    5304           51 :           if (warned != 1 && !in_system_header_at (input_location))
    5305              :             {
    5306           44 :               pedwarn (input_location, 0,
    5307              :                        "useless type name in empty declaration");
    5308           44 :               warned = 1;
    5309              :             }
    5310              :         }
    5311              :     }
    5312           71 :   else if (warned != 1 && !in_system_header_at (input_location)
    5313          191 :            && declspecs->typedef_p)
    5314              :     {
    5315           11 :       pedwarn (input_location, 0, "useless type name in empty declaration");
    5316           11 :       warned = 1;
    5317              :     }
    5318              : 
    5319       516332 :   pending_invalid_xref = NULL_TREE;
    5320              : 
    5321       516332 :   if (declspecs->inline_p)
    5322              :     {
    5323            5 :       error ("%<inline%> in empty declaration");
    5324            5 :       warned = 1;
    5325              :     }
    5326              : 
    5327       516332 :   if (declspecs->noreturn_p)
    5328              :     {
    5329            2 :       error ("%<_Noreturn%> in empty declaration");
    5330            2 :       warned = 1;
    5331              :     }
    5332              : 
    5333       516332 :   if (declspecs->constexpr_p)
    5334              :     {
    5335            7 :       error ("%<constexpr%> in empty declaration");
    5336            7 :       warned = 1;
    5337              :     }
    5338              : 
    5339       516332 :   if (current_scope == file_scope && declspecs->storage_class == csc_auto)
    5340              :     {
    5341            2 :       error ("%<auto%> in file-scope empty declaration");
    5342            2 :       warned = 1;
    5343              :     }
    5344              : 
    5345       516332 :   if (current_scope == file_scope && declspecs->storage_class == csc_register)
    5346              :     {
    5347            2 :       error ("%<register%> in file-scope empty declaration");
    5348            2 :       warned = 1;
    5349              :     }
    5350              : 
    5351       516332 :   if (declspecs->enum_type_specifier_ref_p && !warned)
    5352              :     {
    5353           40 :       if (declspecs->storage_class != csc_none)
    5354              :         {
    5355            1 :           error ("storage class specifier in empty declaration with %<enum%> "
    5356              :                  "underlying type");
    5357            1 :           warned = 1;
    5358              :         }
    5359           39 :       else if (declspecs->thread_p)
    5360              :         {
    5361            2 :           error ("%qs in empty declaration with %<enum%> underlying type",
    5362            1 :                  declspecs->thread_gnu_p ? "__thread" : "_Thread_local");
    5363            1 :           warned = 1;
    5364              :         }
    5365           38 :       else if (declspecs->const_p
    5366           37 :                || declspecs->volatile_p
    5367           37 :                || declspecs->atomic_p
    5368           37 :                || declspecs->restrict_p
    5369           37 :                || declspecs->address_space)
    5370              :         {
    5371            1 :           error ("type qualifier in empty declaration with %<enum%> "
    5372              :                  "underlying type");
    5373            1 :           warned = 1;
    5374              :         }
    5375           37 :       else if (declspecs->alignas_p)
    5376              :         {
    5377            1 :           error ("%<alignas%> in empty declaration with %<enum%> "
    5378              :                  "underlying type");
    5379            1 :           warned = 1;
    5380              :         }
    5381              :     }
    5382              : 
    5383       516158 :   if (!warned && !in_system_header_at (input_location)
    5384       637410 :       && declspecs->storage_class != csc_none)
    5385              :     {
    5386           12 :       warning (0, "useless storage class specifier in empty declaration");
    5387           12 :       warned = 2;
    5388              :     }
    5389              : 
    5390       516332 :   if (!warned && !in_system_header_at (input_location) && declspecs->thread_p)
    5391              :     {
    5392            3 :       warning (0, "useless %qs in empty declaration",
    5393            3 :                declspecs->thread_gnu_p ? "__thread" : "_Thread_local");
    5394            3 :       warned = 2;
    5395              :     }
    5396              : 
    5397            3 :   if (!warned
    5398       516139 :       && !in_system_header_at (input_location)
    5399       637400 :       && (declspecs->const_p
    5400       121063 :           || declspecs->volatile_p
    5401       121063 :           || declspecs->atomic_p
    5402       121063 :           || declspecs->restrict_p
    5403       121063 :           || declspecs->address_space))
    5404              :     {
    5405            8 :       warning (0, "useless type qualifier in empty declaration");
    5406            8 :       warned = 2;
    5407              :     }
    5408              : 
    5409       516139 :   if (!warned && !in_system_header_at (input_location)
    5410       637387 :       && declspecs->alignas_p)
    5411              :     {
    5412            4 :       warning (0, "useless %<_Alignas%> in empty declaration");
    5413            4 :       warned = 2;
    5414              :     }
    5415              : 
    5416       516332 :   if (found_tag
    5417       516332 :       && warned == 2
    5418           23 :       && (declspecs->typespec_kind == ctsk_tagref_attrs
    5419           23 :           || declspecs->typespec_kind == ctsk_tagfirstref_attrs))
    5420              :     {
    5421              :       /* Standard attributes after the "struct" or "union" keyword are
    5422              :          only permitted when the contents of the type are defined, or
    5423              :          in the form "struct-or-union attribute-specifier-sequence
    5424              :          identifier;".  If the ';' was not present, attributes were
    5425              :          diagnosed in the parser.  Here, ensure that any other useless
    5426              :          elements of the declaration result in a pedwarn, not just a
    5427              :          warning.  Forward declarations of enum types are not part of
    5428              :          standard C, but handle them the same.  */
    5429            2 :       pedwarn (input_location, 0,
    5430              :                "invalid use of attributes in empty declaration");
    5431            2 :       warned = 1;
    5432              :     }
    5433              : 
    5434       516332 :   if (warned != 1)
    5435              :     {
    5436       516152 :       if (declspecs->declspecs_seen_p
    5437       516152 :           && !declspecs->non_std_attrs_seen_p)
    5438              :         /* An attribute declaration (but not a fallthrough attribute
    5439              :            declaration, which was handled separately); warn if there
    5440              :            are any attributes being ignored (but not if the attributes
    5441              :            were empty).  */
    5442           48 :         c_warn_unused_attributes (declspecs->attrs);
    5443       516104 :       else if (!found_tag)
    5444           10 :         pedwarn (input_location, 0, "empty declaration");
    5445              :     }
    5446       516332 : }
    5447              : 
    5448              : 
    5449              : /* Return the qualifiers from SPECS as a bitwise OR of TYPE_QUAL_*
    5450              :    bits.  SPECS represents declaration specifiers that the grammar
    5451              :    only permits to contain type qualifiers and attributes.  */
    5452              : 
    5453              : qualifier_set
    5454     18841893 : quals_from_declspecs (const struct c_declspecs *specs)
    5455              : {
    5456     37683786 :   auto cv_quals = cv_qualifier ((specs->const_p ? TYPE_QUAL_CONST : 0)
    5457     37250023 :                                 | (specs->volatile_p ? TYPE_QUAL_VOLATILE : 0)
    5458     18841893 :                                 | (specs->restrict_p ? TYPE_QUAL_RESTRICT : 0)
    5459     18841893 :                                 | (specs->atomic_p ? TYPE_QUAL_ATOMIC : 0));
    5460     18841893 :   gcc_assert (!specs->type
    5461              :               && !specs->decl_attr
    5462              :               && specs->typespec_word == cts_none
    5463              :               && specs->storage_class == csc_none
    5464              :               && !specs->typedef_p
    5465              :               && !specs->explicit_signed_p
    5466              :               && !specs->deprecated_p
    5467              :               && !specs->unavailable_p
    5468              :               && !specs->long_p
    5469              :               && !specs->long_long_p
    5470              :               && !specs->short_p
    5471              :               && !specs->signed_p
    5472              :               && !specs->unsigned_p
    5473              :               && !specs->complex_p
    5474              :               && !specs->inline_p
    5475              :               && !specs->noreturn_p
    5476              :               && !specs->thread_p);
    5477     18841893 :   return {cv_quals, specs->address_space};
    5478              : }
    5479              : 
    5480              : /* Construct an array declarator.  LOC is the location of the
    5481              :    beginning of the array (usually the opening brace).  EXPR is the
    5482              :    expression inside [], or NULL_TREE.  QUALS are the type qualifiers
    5483              :    inside the [] (to be applied to the pointer to which a parameter
    5484              :    array is converted).  STATIC_P is true if "static" is inside the
    5485              :    [], false otherwise.  VLA_UNSPEC_P is true if the array is [*], a
    5486              :    VLA of unspecified length which is nevertheless a complete type,
    5487              :    false otherwise.  The field for the contained declarator is left to
    5488              :    be filled in by set_array_declarator_inner.  */
    5489              : 
    5490              : struct c_declarator *
    5491      1158546 : build_array_declarator (location_t loc,
    5492              :                         tree expr, struct c_declspecs *quals, bool static_p,
    5493              :                         bool vla_unspec_p)
    5494              : {
    5495      1158546 :   struct c_declarator *declarator = XOBNEW (&parser_obstack,
    5496              :                                             struct c_declarator);
    5497      1158546 :   declarator->id_loc = loc;
    5498      1158546 :   declarator->kind = cdk_array;
    5499      1158546 :   declarator->declarator = 0;
    5500      1158546 :   declarator->u.array.dimen = expr;
    5501      1158546 :   if (quals)
    5502              :     {
    5503          966 :       declarator->u.array.attrs = quals->attrs;
    5504          966 :       declarator->u.array.quals = quals_from_declspecs (quals);
    5505              :     }
    5506              :   else
    5507              :     {
    5508      1157580 :       declarator->u.array.attrs = NULL_TREE;
    5509      1157580 :       declarator->u.array.quals = qualifier_set {};
    5510              :     }
    5511      1158546 :   declarator->u.array.static_p = static_p;
    5512      1158546 :   declarator->u.array.vla_unspec_p = vla_unspec_p;
    5513      1158546 :   if (static_p || quals != NULL)
    5514         1069 :     pedwarn_c90 (loc, OPT_Wpedantic,
    5515              :                  "ISO C90 does not support %<static%> or type "
    5516              :                  "qualifiers in parameter array declarators");
    5517      1158546 :   if (vla_unspec_p)
    5518              :     {
    5519          152 :       pedwarn_c90 (loc, OPT_Wpedantic,
    5520              :                    "ISO C90 does not support %<[*]%> array declarators");
    5521          152 :       if (current_scope->parm_flag)
    5522          144 :         current_scope->had_vla_unspec = true;
    5523              :     }
    5524      1158546 :   return declarator;
    5525              : }
    5526              : 
    5527              : /* Set the contained declarator of an array declarator.  DECL is the
    5528              :    declarator, as constructed by build_array_declarator; INNER is what
    5529              :    appears on the left of the [].  */
    5530              : 
    5531              : struct c_declarator *
    5532      1158546 : set_array_declarator_inner (struct c_declarator *decl,
    5533              :                             struct c_declarator *inner)
    5534              : {
    5535      1158546 :   decl->declarator = inner;
    5536      1158546 :   return decl;
    5537              : }
    5538              : 
    5539              : /* Determine whether TYPE is a one-element array type "[1]".  */
    5540              : static bool
    5541       543063 : one_element_array_type_p (const_tree type)
    5542              : {
    5543       543063 :   if (TREE_CODE (type) != ARRAY_TYPE)
    5544              :     return false;
    5545       543063 :   return integer_zerop (array_type_nelts_minus_one (type));
    5546              : }
    5547              : 
    5548              : /* Determine whether TYPE is a zero-length array type "[0]".  */
    5549              : bool
    5550      1489431 : zero_length_array_type_p (const_tree type)
    5551              : {
    5552      1489431 :   if (TREE_CODE (type) == ARRAY_TYPE
    5553      1489431 :       && COMPLETE_TYPE_P (type)
    5554      1402378 :       && TYPE_DOMAIN (type) != NULL_TREE
    5555      2891809 :       && (TYPE_MAX_VALUE (TYPE_DOMAIN (type)) == NULL_TREE
    5556      1399821 :           || integer_all_onesp (TYPE_MAX_VALUE (TYPE_DOMAIN (type)))))
    5557         2694 :     return true;
    5558              :   return false;
    5559              : }
    5560              : 
    5561              : /* INIT is a constructor that forms DECL's initializer.  If the final
    5562              :    element initializes a flexible array field, adjust the size of the
    5563              :    DECL with the initializer based on whether the DECL is a union or
    5564              :    a structure.  */
    5565              : 
    5566              : static void
    5567       107710 : add_flexible_array_elts_to_size (tree decl, tree init)
    5568              : {
    5569       107710 :   tree elt, type;
    5570              : 
    5571       107710 :   if (vec_safe_is_empty (CONSTRUCTOR_ELTS (init)))
    5572         1633 :     return;
    5573              : 
    5574       106077 :   elt = CONSTRUCTOR_ELTS (init)->last ().value;
    5575       106077 :   type = TREE_TYPE (elt);
    5576       106077 :   if (flexible_array_member_type_p (type))
    5577              :     {
    5578          227 :       complete_array_type (&type, elt, false);
    5579              :       /* For a structure, add the size of the initializer to the DECL's
    5580              :          size.  */
    5581          227 :       if (TREE_CODE (TREE_TYPE (decl)) == RECORD_TYPE)
    5582              :         {
    5583          217 :           DECL_SIZE (decl)
    5584          217 :             = size_binop (PLUS_EXPR, DECL_SIZE (decl), TYPE_SIZE (type));
    5585          217 :           DECL_SIZE_UNIT (decl)
    5586          434 :             = size_binop (PLUS_EXPR, DECL_SIZE_UNIT (decl),
    5587              :                           TYPE_SIZE_UNIT (type));
    5588              :         }
    5589              :       /* For a union, the DECL's size is the maximum of the current size
    5590              :          and the size of the initializer.  */
    5591              :       else
    5592              :         {
    5593           10 :           DECL_SIZE (decl)
    5594           10 :             = size_binop (MAX_EXPR, DECL_SIZE (decl), TYPE_SIZE (type));
    5595           10 :           DECL_SIZE_UNIT (decl)
    5596           20 :             = size_binop (MAX_EXPR, DECL_SIZE_UNIT (decl),
    5597              :                           TYPE_SIZE_UNIT (type));
    5598              :         }
    5599              :     }
    5600              : }
    5601              : 
    5602              : /* Decode a "typename", such as "int **", returning a ..._TYPE node.
    5603              :    Set *EXPR, if EXPR not NULL, to any expression to be evaluated
    5604              :    before the type name, and set *EXPR_CONST_OPERANDS, if
    5605              :    EXPR_CONST_OPERANDS not NULL, to indicate whether the type name may
    5606              :    appear in a constant expression.  */
    5607              : 
    5608              : tree
    5609    126565113 : groktypename (struct c_type_name *type_name, tree *expr,
    5610              :               bool *expr_const_operands)
    5611              : {
    5612    126565113 :   tree type;
    5613    126565113 :   tree attrs = type_name->specs->attrs;
    5614              : 
    5615    126565113 :   type_name->specs->attrs = NULL_TREE;
    5616              : 
    5617    126565113 :   type = grokdeclarator (type_name->declarator, type_name->specs, TYPENAME,
    5618              :                          false, NULL, &attrs, expr, expr_const_operands,
    5619              :                          DEPRECATED_NORMAL);
    5620              : 
    5621              :   /* Apply attributes.  */
    5622    126565113 :   attrs = c_warn_type_attributes (type, attrs);
    5623    126565113 :   decl_attributes (&type, attrs, 0);
    5624              : 
    5625    126565113 :   return type;
    5626              : }
    5627              : 
    5628              : 
    5629              : /* Decode a "typename", such as "int **", returning a ..._TYPE node,
    5630              :    as for groktypename but setting the context to GENERIC_ASSOC.  */
    5631              : 
    5632              : tree
    5633         1542 : grokgenassoc (struct c_type_name *type_name)
    5634              : {
    5635         1542 :   tree type;
    5636         1542 :   tree attrs = type_name->specs->attrs;
    5637              : 
    5638         1542 :   type_name->specs->attrs = NULL_TREE;
    5639              : 
    5640         1542 :   type = grokdeclarator (type_name->declarator, type_name->specs, GENERIC_ASSOC,
    5641              :                          false, NULL, &attrs, NULL, NULL, DEPRECATED_NORMAL);
    5642              : 
    5643              :   /* Apply attributes.  */
    5644         1542 :   attrs = c_warn_type_attributes (type, attrs);
    5645         1542 :   decl_attributes (&type, attrs, 0);
    5646              : 
    5647         1542 :   return type;
    5648              : }
    5649              : 
    5650              : 
    5651              : /* Looks up the most recent pushed declaration corresponding to DECL.  */
    5652              : 
    5653              : static tree
    5654     95310211 : lookup_last_decl (tree decl)
    5655              : {
    5656     95310211 :   tree last_decl = lookup_name (DECL_NAME (decl));
    5657     95310211 :   if (!last_decl)
    5658     92586832 :     last_decl = lookup_name_in_scope (DECL_NAME (decl), external_scope);
    5659     95310211 :   return last_decl;
    5660              : }
    5661              : 
    5662              : /* Wrapper for decl_attributes that adds some implicit attributes
    5663              :    to VAR_DECLs or FUNCTION_DECLs.  */
    5664              : 
    5665              : static tree
    5666     66512098 : c_decl_attributes (tree *node, tree attributes, int flags)
    5667              : {
    5668              :   /* Add implicit "omp declare target" attribute if requested.  */
    5669     66512098 :   if (vec_safe_length (current_omp_declare_target_attribute)
    5670         9995 :       && ((VAR_P (*node) && is_global_var (*node))
    5671         2732 :           || TREE_CODE (*node) == FUNCTION_DECL))
    5672              :     {
    5673         1187 :       if (VAR_P (*node) && !omp_mappable_type (TREE_TYPE (*node)))
    5674           13 :         attributes = tree_cons (get_identifier ("omp declare target implicit"),
    5675              :                                 NULL_TREE, attributes);
    5676              :       else
    5677         1174 :         attributes = tree_cons (get_identifier ("omp declare target"),
    5678              :                                 NULL_TREE, attributes);
    5679         1187 :       if (TREE_CODE (*node) == FUNCTION_DECL)
    5680              :         {
    5681         1004 :           int device_type
    5682         1004 :             = current_omp_declare_target_attribute->last ().device_type;
    5683         1004 :           device_type = MAX (device_type, 0);
    5684         1004 :           if ((device_type & OMP_CLAUSE_DEVICE_TYPE_HOST) != 0
    5685         1004 :               && !lookup_attribute ("omp declare target host", attributes))
    5686            2 :             attributes
    5687            2 :               = tree_cons (get_identifier ("omp declare target host"),
    5688              :                            NULL_TREE, attributes);
    5689         1004 :           if ((device_type & OMP_CLAUSE_DEVICE_TYPE_NOHOST) != 0
    5690         1004 :               && !lookup_attribute ("omp declare target nohost", attributes))
    5691            2 :             attributes
    5692            2 :               = tree_cons (get_identifier ("omp declare target nohost"),
    5693              :                            NULL_TREE, attributes);
    5694              : 
    5695         1004 :           int indirect
    5696         1004 :             = current_omp_declare_target_attribute->last ().indirect;
    5697         1004 :           if (indirect && !lookup_attribute ("omp declare target indirect",
    5698              :                                              attributes))
    5699           10 :             attributes
    5700           10 :               = tree_cons (get_identifier ("omp declare target indirect"),
    5701              :                            NULL_TREE, attributes);
    5702              :         }
    5703              :     }
    5704              : 
    5705     66512098 :   if (flag_openmp || flag_openmp_simd)
    5706              :     {
    5707              :       bool diagnosed = false;
    5708      1498229 :       for (tree *pa = &attributes; *pa; )
    5709              :         {
    5710       959783 :           if (is_attribute_namespace_p ("omp", *pa))
    5711              :             {
    5712           65 :               tree name = get_attribute_name (*pa);
    5713           65 :               if (is_attribute_p ("directive", name)
    5714            0 :                   || is_attribute_p ("sequence", name)
    5715           65 :                   || is_attribute_p ("decl", name))
    5716              :                 {
    5717           65 :                   const char *p = NULL;
    5718           65 :                   if (TREE_VALUE (*pa) == NULL_TREE)
    5719           12 :                     p = IDENTIFIER_POINTER (name);
    5720          118 :                   for (tree a = TREE_VALUE (*pa); a; a = TREE_CHAIN (a))
    5721              :                     {
    5722           53 :                       tree d = TREE_VALUE (a);
    5723           53 :                       gcc_assert (TREE_CODE (d) == C_TOKEN_VEC);
    5724           96 :                       if (TREE_PUBLIC (d)
    5725           43 :                           && (VAR_P (*node)
    5726            2 :                               || TREE_CODE (*node) == FUNCTION_DECL)
    5727           96 :                           && c_maybe_parse_omp_decl (*node, d))
    5728           43 :                         continue;
    5729           10 :                       p = TREE_PUBLIC (d) ? "decl" : "directive";
    5730              :                     }
    5731           65 :                   if (p && !diagnosed)
    5732              :                     {
    5733           22 :                       error ("%<omp::%s%> not allowed to be specified in "
    5734              :                              "this context", p);
    5735           22 :                       diagnosed = true;
    5736              :                     }
    5737           65 :                   if (p)
    5738              :                     {
    5739           22 :                       *pa = TREE_CHAIN (*pa);
    5740           22 :                       continue;
    5741              :                     }
    5742              :                 }
    5743              :             }
    5744       959761 :           pa = &TREE_CHAIN (*pa);
    5745              :         }
    5746              :     }
    5747              : 
    5748              :   /* Look up the current declaration with all the attributes merged
    5749              :      so far so that attributes on the current declaration that's
    5750              :      about to be pushed that conflict with the former can be detected,
    5751              :      diagnosed, and rejected as appropriate.  To match the C++ FE, do
    5752              :      not pass an error_mark_node when we found an undeclared variable.  */
    5753     66512098 :   tree last_decl = lookup_last_decl (*node);
    5754     66512098 :   if (last_decl == error_mark_node)
    5755           20 :     last_decl = NULL_TREE;
    5756     66512098 :   tree attr = decl_attributes (node, attributes, flags, last_decl);
    5757     66512097 :   if (VAR_P (*node) && DECL_THREAD_LOCAL_P (*node))
    5758              :     {
    5759              :       // tls_model attribute can set a stronger TLS access model.
    5760         2870 :       tls_model model = DECL_TLS_MODEL (*node);
    5761         2870 :       tls_model default_model = decl_default_tls_model (*node);
    5762         2870 :       if (default_model > model)
    5763         1607 :         set_decl_tls_model (*node, default_model);
    5764              :     }
    5765     66512097 :   return attr;
    5766              : }
    5767              : 
    5768              : 
    5769              : /* Decode a declarator in an ordinary declaration or data definition.
    5770              :    This is called as soon as the type information and variable name
    5771              :    have been parsed, before parsing the initializer if any.
    5772              :    Here we create the ..._DECL node, fill in its type,
    5773              :    and (if DO_PUSH) put it on the list of decls for the current context.
    5774              :    When nonnull, set *LASTLOC to the location of the prior declaration
    5775              :    of the same entity if one exists.
    5776              :    The ..._DECL node is returned as the value.
    5777              : 
    5778              :    Exception: for arrays where the length is not specified,
    5779              :    the type is left null, to be filled in by `finish_decl'.
    5780              : 
    5781              :    Function definitions do not come here; they go to start_function
    5782              :    instead.  However, external and forward declarations of functions
    5783              :    do go through here.  Structure field declarations are done by
    5784              :    grokfield and not through here.  */
    5785              : 
    5786              : tree
    5787     28798137 : start_decl (struct c_declarator *declarator, struct c_declspecs *declspecs,
    5788              :             bool initialized, tree attributes, bool do_push /* = true */,
    5789              :             location_t *lastloc /* = NULL */)
    5790              : {
    5791     28798137 :   tree decl;
    5792     28798137 :   tree old_decl;
    5793     28798137 :   tree tem;
    5794     28798137 :   tree expr = NULL_TREE;
    5795     28798137 :   enum deprecated_states deprecated_state = DEPRECATED_NORMAL;
    5796              : 
    5797              :   /* An object declared as __attribute__((unavailable)) suppresses
    5798              :      warnings and errors from __attribute__((deprecated/unavailable))
    5799              :      components.
    5800              :      An object declared as __attribute__((deprecated)) suppresses
    5801              :      warnings of uses of other deprecated items.  */
    5802     28798137 :   if (lookup_attribute ("unavailable", attributes))
    5803              :     deprecated_state = UNAVAILABLE_DEPRECATED_SUPPRESS;
    5804     28798113 :   else if (lookup_attribute ("deprecated", attributes))
    5805        30983 :     deprecated_state = DEPRECATED_SUPPRESS;
    5806              : 
    5807     28798137 :   decl = grokdeclarator (declarator, declspecs,
    5808              :                          NORMAL, initialized, NULL, &attributes, &expr, NULL,
    5809              :                          deprecated_state);
    5810     28798137 :   if (!decl || decl == error_mark_node)
    5811              :     return NULL_TREE;
    5812              : 
    5813     28798113 :   old_decl = lookup_last_decl (decl);
    5814              : 
    5815     28798113 :   if (tree lastdecl = lastloc ? old_decl : NULL_TREE)
    5816      5022812 :     if (lastdecl != error_mark_node)
    5817      5022803 :       *lastloc = DECL_SOURCE_LOCATION (lastdecl);
    5818              : 
    5819              :   /* Make sure the size expression is evaluated at this point.  */
    5820     28798113 :   if (expr && !current_scope->parm_flag)
    5821        12983 :     add_stmt (fold_convert (void_type_node, expr));
    5822              : 
    5823              :   /* Mark a forward declaration of a nested function as requiring
    5824              :      a static chain (see start_function).  */
    5825     28798113 :   if (TREE_CODE (decl) == FUNCTION_DECL
    5826     15359045 :       && declspecs->storage_class == csc_auto
    5827           70 :       && current_function_decl != NULL_TREE)
    5828           70 :     DECL_STATIC_CHAIN (decl) = 1;
    5829              : 
    5830     13439068 :   if (TREE_CODE (decl) != FUNCTION_DECL && MAIN_NAME_P (DECL_NAME (decl))
    5831     28798115 :       && TREE_PUBLIC (decl))
    5832            1 :     warning (OPT_Wmain, "%q+D is usually a function", decl);
    5833              : 
    5834           14 :   if (warn_missing_variable_declarations && VAR_P (decl)
    5835     28798126 :       && !DECL_EXTERNAL (decl) && TREE_PUBLIC (decl) && old_decl == NULL_TREE)
    5836            5 :     warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wmissing_variable_declarations,
    5837              :                 "no previous declaration for %qD", decl);
    5838              : 
    5839     28798113 :   if (initialized)
    5840              :     /* Is it valid for this decl to have an initializer at all?
    5841              :        If not, set INITIALIZED to zero, which will indirectly
    5842              :        tell 'finish_decl' to ignore the initializer once it is parsed.  */
    5843      6432159 :     switch (TREE_CODE (decl))
    5844              :       {
    5845            6 :       case TYPE_DECL:
    5846            6 :         error ("typedef %qD is initialized (use %<__typeof__%> instead)", decl);
    5847            6 :         initialized = false;
    5848            6 :         break;
    5849              : 
    5850            9 :       case FUNCTION_DECL:
    5851            9 :         error ("function %qD is initialized like a variable", decl);
    5852            9 :         initialized = false;
    5853            9 :         break;
    5854              : 
    5855           49 :       case PARM_DECL:
    5856              :         /* DECL_INITIAL in a PARM_DECL is really DECL_ARG_TYPE.  */
    5857           49 :         error ("parameter %qD is initialized", decl);
    5858           49 :         initialized = false;
    5859           49 :         break;
    5860              : 
    5861      6432095 :       default:
    5862              :         /* Don't allow initializations for incomplete types except for
    5863              :            arrays which might be completed by the initialization.  */
    5864              : 
    5865              :         /* This can happen if the array size is an undefined macro.
    5866              :            We already gave a warning, so we don't need another one.  */
    5867      6432095 :         if (TREE_TYPE (decl) == error_mark_node)
    5868              :           initialized = false;
    5869      6432073 :         else if (COMPLETE_TYPE_P (TREE_TYPE (decl)))
    5870              :           {
    5871              :             /* A complete type is ok if size is fixed.  If the size is
    5872              :                variable, an empty initializer is OK and nonempty
    5873              :                initializers will be diagnosed in the parser.  */
    5874              :           }
    5875        12962 :         else if (TREE_CODE (TREE_TYPE (decl)) != ARRAY_TYPE)
    5876              :           {
    5877            3 :             error ("variable %qD has initializer but incomplete type", decl);
    5878            3 :             initialized = false;
    5879              :           }
    5880              :       }
    5881              : 
    5882           67 :   if (initialized)
    5883              :     {
    5884      6432070 :       if (current_scope == file_scope)
    5885       157609 :         TREE_STATIC (decl) = 1;
    5886              : 
    5887              :       /* Tell 'pushdecl' this is an initialized decl
    5888              :          even though we don't yet have the initializer expression.
    5889              :          Also tell 'finish_decl' it may store the real initializer.  */
    5890      6432070 :       DECL_INITIAL (decl) = error_mark_node;
    5891              :     }
    5892              : 
    5893              :   /* If this is a function declaration, write a record describing it to the
    5894              :      prototypes file (if requested).  */
    5895              : 
    5896     28798113 :   if (TREE_CODE (decl) == FUNCTION_DECL)
    5897     15359045 :     gen_aux_info_record (decl, 0, 0, prototype_p (TREE_TYPE (decl)));
    5898              : 
    5899              :   /* ANSI specifies that a tentative definition which is not merged with
    5900              :      a non-tentative definition behaves exactly like a definition with an
    5901              :      initializer equal to zero.  (Section 3.7.2)
    5902              : 
    5903              :      -fno-common gives strict ANSI behavior, though this tends to break
    5904              :      a large body of code that grew up without this rule.
    5905              : 
    5906              :      Thread-local variables are never common, since there's no entrenched
    5907              :      body of code to break, and it allows more efficient variable references
    5908              :      in the presence of dynamic linking.  */
    5909              : 
    5910     28798113 :   if (VAR_P (decl)
    5911      9020147 :       && !initialized
    5912      2588077 :       && TREE_PUBLIC (decl)
    5913       992184 :       && !DECL_THREAD_LOCAL_P (decl)
    5914     29787907 :       && !flag_no_common)
    5915          128 :     DECL_COMMON (decl) = 1;
    5916              : 
    5917              :   /* Set attributes here so if duplicate decl, will have proper attributes.  */
    5918     28798113 :   c_decl_attributes (&decl, attributes, 0);
    5919              : 
    5920              :   /* Handle gnu_inline attribute.  */
    5921     28798112 :   if (declspecs->inline_p
    5922         1056 :       && !flag_gnu89_inline
    5923         1024 :       && TREE_CODE (decl) == FUNCTION_DECL
    5924     28799128 :       && (lookup_attribute ("gnu_inline", DECL_ATTRIBUTES (decl))
    5925          993 :           || current_function_decl))
    5926              :     {
    5927           46 :       if (declspecs->storage_class == csc_auto && current_scope != file_scope)
    5928              :         ;
    5929           37 :       else if (declspecs->storage_class != csc_static)
    5930           37 :         DECL_EXTERNAL (decl) = !DECL_EXTERNAL (decl);
    5931              :     }
    5932              : 
    5933     28798112 :   if (TREE_CODE (decl) == FUNCTION_DECL
    5934     15359044 :       && DECL_DECLARED_INLINE_P (decl)
    5935         1046 :       && DECL_UNINLINABLE (decl)
    5936     28798114 :       && lookup_attribute ("noinline", DECL_ATTRIBUTES (decl)))
    5937              :     {
    5938            2 :       auto_urlify_attributes sentinel;
    5939            2 :       warning (OPT_Wattributes, "inline function %q+D given attribute %qs",
    5940              :                decl, "noinline");
    5941            2 :     }
    5942              : 
    5943              :   /* C99 6.7.4p3: An inline definition of a function with external
    5944              :      linkage shall not contain a definition of a modifiable object
    5945              :      with static storage duration...  */
    5946     28798112 :   if (VAR_P (decl)
    5947      9020147 :       && current_scope != file_scope
    5948      7863074 :       && TREE_STATIC (decl)
    5949        79656 :       && !TREE_READONLY (decl)
    5950        76336 :       && DECL_DECLARED_INLINE_P (current_function_decl)
    5951     28798182 :       && DECL_EXTERNAL (current_function_decl))
    5952            7 :     record_inline_static (input_location, current_function_decl,
    5953              :                           decl, csi_modifiable);
    5954              : 
    5955     28798112 :   if (c_dialect_objc ()
    5956            0 :       && VAR_OR_FUNCTION_DECL_P (decl))
    5957            0 :       objc_check_global_decl (decl);
    5958              : 
    5959              :   /* To enable versions to be created across TU's we mark and mangle all
    5960              :      non-default versioned functions.  */
    5961     28798112 :   if (TREE_CODE (decl) == FUNCTION_DECL
    5962              :       && !TARGET_HAS_FMV_TARGET_ATTRIBUTE
    5963              :       && get_target_version (decl).is_valid ())
    5964              :     {
    5965              :       maybe_mark_function_versioned (decl);
    5966              :       if (current_scope != file_scope)
    5967              :         error ("versioned declarations are only allowed at file scope");
    5968              :     }
    5969              : 
    5970              :   /* Add this decl to the current scope.
    5971              :      TEM may equal DECL or it may be a previous decl of the same name.  */
    5972     28798112 :   if (do_push)
    5973              :     {
    5974     28797734 :       tem = pushdecl (decl);
    5975              : 
    5976     28797734 :       if (initialized && DECL_EXTERNAL (tem))
    5977              :         {
    5978           27 :           DECL_EXTERNAL (tem) = 0;
    5979           27 :           TREE_STATIC (tem) = 1;
    5980              :         }
    5981              : 
    5982              :       return tem;
    5983              :     }
    5984              :   else
    5985          378 :     return decl;
    5986              : }
    5987              : 
    5988              : /* Subroutine of finish_decl. TYPE is the type of an uninitialized object
    5989              :    DECL or the non-array element type if DECL is an uninitialized array.
    5990              :    If that type has a const member, diagnose this. */
    5991              : 
    5992              : static void
    5993            7 : diagnose_uninitialized_cst_member (tree decl, tree type)
    5994              : {
    5995            7 :   tree field;
    5996           17 :   for (field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field))
    5997              :     {
    5998           10 :       tree field_type;
    5999           10 :       if (TREE_CODE (field) != FIELD_DECL)
    6000            0 :         continue;
    6001           10 :       field_type = strip_array_types (TREE_TYPE (field));
    6002              : 
    6003           10 :       if (TYPE_QUALS (field_type).has (TYPE_QUAL_CONST))
    6004              :         {
    6005            5 :           auto_diagnostic_group d;
    6006            5 :           if (warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wc___compat,
    6007              :                           "uninitialized const member in %qT is invalid in C++",
    6008            5 :                           strip_array_types (TREE_TYPE (decl))))
    6009            5 :             inform (DECL_SOURCE_LOCATION (field), "%qD should be initialized", field);
    6010            5 :         }
    6011              : 
    6012           10 :       if (RECORD_OR_UNION_TYPE_P (field_type))
    6013            2 :         diagnose_uninitialized_cst_member (decl, field_type);
    6014              :     }
    6015            7 : }
    6016              : 
    6017              : /* Finish processing of a declaration;
    6018              :    install its initial value.
    6019              :    If ORIGTYPE is not NULL_TREE, it is the original type of INIT.
    6020              :    If the length of an array type is not known before,
    6021              :    it must be determined now, from the initial value, or it is an error.
    6022              : 
    6023              :    INIT_LOC is the location of the initial value.  */
    6024              : 
    6025              : void
    6026    161736301 : finish_decl (tree decl, location_t init_loc, tree init,
    6027              :              tree origtype, tree asmspec_tree)
    6028              : {
    6029    161736301 :   tree type;
    6030    161736301 :   bool was_incomplete = (DECL_SIZE (decl) == NULL_TREE);
    6031    161736301 :   const char *asmspec = 0;
    6032              : 
    6033              :   /* If a name was specified, get the string.  */
    6034    152713115 :   if (VAR_OR_FUNCTION_DECL_P (decl)
    6035    177095345 :       && DECL_FILE_SCOPE_P (decl))
    6036     16517630 :     asmspec_tree = maybe_apply_renaming_pragma (decl, asmspec_tree);
    6037    161736301 :   if (asmspec_tree)
    6038       880615 :     asmspec = TREE_STRING_POINTER (asmspec_tree);
    6039              : 
    6040    161736301 :   if (VAR_P (decl)
    6041      9023186 :       && TREE_STATIC (decl)
    6042    162805225 :       && global_bindings_p ())
    6043              :     /* So decl is a global variable. Record the types it uses
    6044              :        so that we can decide later to emit debug info for them.  */
    6045       986015 :     record_types_used_by_current_var_decl (decl);
    6046              : 
    6047              :   /* If `start_decl' didn't like having an initialization, ignore it now.  */
    6048    161736301 :   if (init != NULL_TREE && DECL_INITIAL (decl) == NULL_TREE)
    6049              :     init = NULL_TREE;
    6050              : 
    6051              :   /* Don't crash if parm is initialized.  */
    6052    161736301 :   if (TREE_CODE (decl) == PARM_DECL)
    6053              :     init = NULL_TREE;
    6054              : 
    6055     33163248 :   if (init)
    6056      6435110 :     store_init_value (init_loc, decl, init, origtype);
    6057              : 
    6058    161736301 :   if (c_dialect_objc () && (VAR_OR_FUNCTION_DECL_P (decl)
    6059            0 :                             || TREE_CODE (decl) == FIELD_DECL))
    6060            0 :     objc_check_decl (decl);
    6061              : 
    6062    161736301 :   type = TREE_TYPE (decl);
    6063              : 
    6064              :   /* Deduce size of array from initialization, if not already known.
    6065              :      This is only needed for an initialization in the current scope;
    6066              :      it must not be done for a file-scope initialization of a
    6067              :      declaration with external linkage, redeclared in an inner scope
    6068              :      with the outer declaration shadowed in an intermediate scope.  */
    6069    161736301 :   if (TREE_CODE (type) == ARRAY_TYPE
    6070       869224 :       && TYPE_DOMAIN (type) == NULL_TREE
    6071        20593 :       && TREE_CODE (decl) != TYPE_DECL
    6072    161756796 :       && !(TREE_PUBLIC (decl) && current_scope != file_scope))
    6073              :     {
    6074        20308 :       bool do_default
    6075        20308 :         = !TREE_STATIC (decl) && !DECL_EXTERNAL (decl);
    6076        20308 :       int failure
    6077        20308 :         = complete_array_type (&TREE_TYPE (decl), DECL_INITIAL (decl),
    6078              :                                do_default);
    6079              : 
    6080              :       /* Get the completed type made by complete_array_type.  */
    6081        20308 :       type = TREE_TYPE (decl);
    6082              : 
    6083        20308 :       switch (failure)
    6084              :         {
    6085            0 :         case 1:
    6086            0 :           error ("initializer fails to determine size of %q+D", decl);
    6087            0 :           break;
    6088              : 
    6089         7374 :         case 2:
    6090         7374 :           if (do_default)
    6091            1 :             error ("array size missing in %q+D", decl);
    6092         7373 :           else if (!TREE_PUBLIC (decl))
    6093           37 :             pedwarn_c23 (DECL_SOURCE_LOCATION (decl), OPT_Wpedantic,
    6094              :                          "array size missing in %q+D", decl);
    6095              :           break;
    6096              : 
    6097            3 :         case 3:
    6098            3 :           error ("zero or negative size array %q+D", decl);
    6099            3 :           break;
    6100              : 
    6101        12931 :         case 0:
    6102              :           /* For global variables, update the copy of the type that
    6103              :              exists in the binding.  */
    6104        12931 :           if (TREE_PUBLIC (decl))
    6105              :             {
    6106         3844 :               struct c_binding *b_ext = I_SYMBOL_BINDING (DECL_NAME (decl));
    6107         7688 :               while (b_ext && !B_IN_EXTERNAL_SCOPE (b_ext))
    6108         3844 :                 b_ext = b_ext->shadowed;
    6109         3844 :               if (b_ext && TREE_CODE (decl) == TREE_CODE (b_ext->decl))
    6110              :                 {
    6111         3844 :                   if (b_ext->u.type && comptypes (b_ext->u.type, type))
    6112          176 :                     b_ext->u.type = composite_type (b_ext->u.type, type);
    6113              :                   else
    6114         3668 :                     b_ext->u.type = type;
    6115              :                 }
    6116              :             }
    6117              :           break;
    6118              : 
    6119            0 :         default:
    6120            0 :           gcc_unreachable ();
    6121              :         }
    6122              : 
    6123        20308 :       if (DECL_INITIAL (decl) && DECL_INITIAL (decl) != error_mark_node)
    6124        12062 :         TREE_TYPE (DECL_INITIAL (decl)) = type;
    6125              : 
    6126        20308 :       relayout_decl (decl);
    6127              :     }
    6128              : 
    6129              :   /* Look for braced array initializers for character arrays and
    6130              :      recursively convert them into STRING_CSTs.  */
    6131    161736301 :   if (tree init = DECL_INITIAL (decl))
    6132    135010595 :     DECL_INITIAL (decl) = braced_lists_to_strings (type, init);
    6133              : 
    6134    161736301 :   if (VAR_P (decl))
    6135              :     {
    6136      9023186 :       if (init && TREE_CODE (init) == CONSTRUCTOR)
    6137       107710 :         add_flexible_array_elts_to_size (decl, init);
    6138              : 
    6139      9023186 :       complete_flexible_array_elts (DECL_INITIAL (decl));
    6140              : 
    6141      9023186 :       if (is_global_var (decl))
    6142              :         {
    6143      1241290 :           type_context_kind context = (DECL_THREAD_LOCAL_P (decl)
    6144      1241290 :                                        ? TCTX_THREAD_STORAGE
    6145              :                                        : TCTX_STATIC_STORAGE);
    6146      1241290 :           if (!verify_type_context (input_location, context, TREE_TYPE (decl)))
    6147            0 :             TREE_TYPE (decl) = error_mark_node;
    6148              :         }
    6149              : 
    6150      9031302 :       if (DECL_SIZE (decl) == NULL_TREE && TREE_TYPE (decl) != error_mark_node
    6151      9031199 :           && COMPLETE_TYPE_P (TREE_TYPE (decl)))
    6152          107 :         layout_decl (decl, 0);
    6153              : 
    6154      9023186 :       if (DECL_SIZE (decl) == NULL_TREE
    6155              :           /* Don't give an error if we already gave one earlier.  */
    6156         8009 :           && TREE_TYPE (decl) != error_mark_node
    6157      9031092 :           && (TREE_STATIC (decl)
    6158              :               /* A static variable with an incomplete type
    6159              :                  is an error if it is initialized.
    6160              :                  Also if it is not file scope.
    6161              :                  Also if it is thread-local (in C23).
    6162              :                  Otherwise, let it through, but if it is not `extern'
    6163              :                  then it may cause an error message later.  */
    6164          309 :               ? (DECL_INITIAL (decl) != NULL_TREE
    6165          309 :                  || !DECL_FILE_SCOPE_P (decl)
    6166          306 :                  || (flag_isoc23 && DECL_THREAD_LOCAL_P (decl)))
    6167              :               /* An automatic variable with an incomplete type
    6168              :                  is an error.  */
    6169         7597 :               : !DECL_EXTERNAL (decl)))
    6170              :          {
    6171           19 :            error ("storage size of %q+D isn%'t known", decl);
    6172           19 :            TREE_TYPE (decl) = error_mark_node;
    6173              :          }
    6174              : 
    6175     17861057 :       if ((RECORD_OR_UNION_TYPE_P (TREE_TYPE (decl))
    6176      8752848 :           || TREE_CODE (TREE_TYPE (decl)) == ENUMERAL_TYPE)
    6177       285074 :           && DECL_SIZE (decl) == NULL_TREE
    6178      9023474 :           && TREE_STATIC (decl))
    6179          135 :         incomplete_record_decls.safe_push (decl);
    6180              : 
    6181      9023186 :       if (is_global_var (decl)
    6182      1241290 :           && DECL_SIZE (decl) != NULL_TREE
    6183     10256510 :           && TREE_TYPE (decl) != error_mark_node)
    6184              :         {
    6185      1233304 :           if (TREE_CODE (DECL_SIZE (decl)) == INTEGER_CST)
    6186      1233301 :             constant_expression_warning (DECL_SIZE (decl));
    6187              :           else
    6188              :             {
    6189            3 :               error ("storage size of %q+D isn%'t constant", decl);
    6190            3 :               TREE_TYPE (decl) = error_mark_node;
    6191              :             }
    6192              :         }
    6193              : 
    6194      9023186 :       if (TREE_USED (type))
    6195              :         {
    6196            4 :           TREE_USED (decl) = 1;
    6197            4 :           DECL_READ_P (decl) = 1;
    6198              :         }
    6199              :     }
    6200              : 
    6201              :   /* If this is a function and an assembler name is specified, reset DECL_RTL
    6202              :      so we can give it its new name.  Also, update builtin_decl if it
    6203              :      was a normal built-in.  */
    6204    161736301 :   if (TREE_CODE (decl) == FUNCTION_DECL && asmspec)
    6205              :     {
    6206       867416 :       if (DECL_BUILT_IN_CLASS (decl) == BUILT_IN_NORMAL)
    6207        72824 :         set_builtin_user_assembler_name (decl, asmspec);
    6208       867416 :       set_user_assembler_name (decl, asmspec);
    6209              :     }
    6210              : 
    6211              :   /* If #pragma weak was used, mark the decl weak now.  */
    6212    161736301 :   maybe_apply_pragma_weak (decl);
    6213              : 
    6214              :   /* Output the assembler code and/or RTL code for variables and functions,
    6215              :      unless the type is an undefined structure or union.
    6216              :      If not, it will get done when the type is completed.  */
    6217              : 
    6218    161736301 :   if (VAR_OR_FUNCTION_DECL_P (decl))
    6219              :     {
    6220              :       /* Determine the ELF visibility.  */
    6221     24382230 :       if (TREE_PUBLIC (decl))
    6222     16491898 :         c_determine_visibility (decl);
    6223              : 
    6224              :       /* This is a no-op in c-lang.cc or something real in objc-act.cc.  */
    6225     24382230 :       if (c_dialect_objc ())
    6226            0 :         objc_check_decl (decl);
    6227              : 
    6228     24382230 :       if (asmspec)
    6229              :         {
    6230              :           /* If this is not a static variable, issue a warning.
    6231              :              It doesn't make any sense to give an ASMSPEC for an
    6232              :              ordinary, non-register local variable.  Historically,
    6233              :              GCC has accepted -- but ignored -- the ASMSPEC in
    6234              :              this case.  */
    6235       881664 :           if (!DECL_FILE_SCOPE_P (decl)
    6236         1049 :               && VAR_P (decl)
    6237         1049 :               && !C_DECL_REGISTER (decl)
    6238       880623 :               && !TREE_STATIC (decl))
    6239            1 :             warning (0, "ignoring %<asm%> specifier for non-static local "
    6240              :                      "variable %q+D", decl);
    6241              :           else
    6242       880614 :             set_user_assembler_name (decl, asmspec);
    6243              :         }
    6244              : 
    6245     24382230 :       if (DECL_FILE_SCOPE_P (decl))
    6246              :         {
    6247     16517630 :           if (DECL_INITIAL (decl) == NULL_TREE
    6248     16517630 :               || DECL_INITIAL (decl) == error_mark_node)
    6249              :             /* Don't output anything
    6250              :                when a tentative file-scope definition is seen.
    6251              :                But at end of compilation, do output code for them.  */
    6252     16359855 :             DECL_DEFER_OUTPUT (decl) = 1;
    6253     16517630 :           if (asmspec && VAR_P (decl) && C_DECL_REGISTER (decl))
    6254           69 :             DECL_HARD_REGISTER (decl) = 1;
    6255     16517630 :           rest_of_decl_compilation (decl, true, 0);
    6256              : 
    6257     16517630 :           if (TREE_CODE (decl) == FUNCTION_DECL)
    6258              :             {
    6259     15358973 :               tree parms = DECL_ARGUMENTS (decl);
    6260     15358973 :               const bool builtin = fndecl_built_in_p (decl);
    6261     15358973 :               if (tree access = build_attr_access_from_parms (parms, !builtin))
    6262       350325 :                 decl_attributes (&decl, access, 0);
    6263              :             }
    6264              :         }
    6265              :       else
    6266              :         {
    6267              :           /* In conjunction with an ASMSPEC, the `register'
    6268              :              keyword indicates that we should place the variable
    6269              :              in a particular register.  */
    6270      7864600 :           if (asmspec && C_DECL_REGISTER (decl))
    6271              :             {
    6272         1041 :               DECL_HARD_REGISTER (decl) = 1;
    6273              :               /* This cannot be done for a structure with volatile
    6274              :                  fields, on which DECL_REGISTER will have been
    6275              :                  reset.  */
    6276         1041 :               if (!DECL_REGISTER (decl))
    6277            1 :                 error ("cannot put object with volatile field into register");
    6278              :             }
    6279              : 
    6280      7864600 :           if (TREE_CODE (decl) != FUNCTION_DECL)
    6281              :             {
    6282              :               /* If we're building a variable sized type, and we might be
    6283              :                  reachable other than via the top of the current binding
    6284              :                  level, then create a new BIND_EXPR so that we deallocate
    6285              :                  the object at the right time.  */
    6286              :               /* Note that DECL_SIZE can be null due to errors.  */
    6287      7864529 :               if (DECL_SIZE (decl)
    6288      7864483 :                   && !TREE_CONSTANT (DECL_SIZE (decl))
    6289      7871921 :                   && STATEMENT_LIST_HAS_LABEL (cur_stmt_list))
    6290              :                 {
    6291         1337 :                   tree bind;
    6292         1337 :                   bind = build3 (BIND_EXPR, void_type_node, NULL, NULL, NULL);
    6293         1337 :                   TREE_SIDE_EFFECTS (bind) = 1;
    6294         1337 :                   add_stmt (bind);
    6295         1337 :                   BIND_EXPR_BODY (bind) = push_stmt_list ();
    6296              :                 }
    6297      7864529 :               add_stmt (build_stmt (DECL_SOURCE_LOCATION (decl),
    6298              :                                     DECL_EXPR, decl));
    6299              :             }
    6300              :         }
    6301              : 
    6302              : 
    6303     24382230 :       if (!DECL_FILE_SCOPE_P (decl))
    6304              :         {
    6305              :           /* Recompute the RTL of a local array now
    6306              :              if it used to be an incomplete type.  */
    6307      7864600 :           if (was_incomplete && !is_global_var (decl))
    6308              :             {
    6309              :               /* If we used it already as memory, it must stay in memory.  */
    6310         5486 :               TREE_ADDRESSABLE (decl) = TREE_USED (decl);
    6311              :               /* If it's still incomplete now, no init will save it.  */
    6312         5486 :               if (DECL_SIZE (decl) == NULL_TREE)
    6313          113 :                 DECL_INITIAL (decl) = NULL_TREE;
    6314              :             }
    6315              :         }
    6316              :     }
    6317              : 
    6318    161736301 :   if (TREE_CODE (decl) == TYPE_DECL)
    6319              :     {
    6320      4524590 :       if (!DECL_FILE_SCOPE_P (decl)
    6321      4524590 :           && c_type_variably_modified_p (TREE_TYPE (decl)))
    6322         5321 :         add_stmt (build_stmt (DECL_SOURCE_LOCATION (decl), DECL_EXPR, decl));
    6323              : 
    6324      8664187 :       rest_of_decl_compilation (decl, DECL_FILE_SCOPE_P (decl), 0);
    6325              :     }
    6326              : 
    6327              :   /* Install a cleanup (aka destructor) if one was given.  */
    6328    161736301 :   if (VAR_P (decl) && !TREE_STATIC (decl))
    6329              :     {
    6330      7954259 :       tree attr = lookup_attribute ("cleanup", DECL_ATTRIBUTES (decl));
    6331      7954259 :       if (attr)
    6332              :         {
    6333          140 :           tree cleanup_id = TREE_VALUE (TREE_VALUE (attr));
    6334          140 :           tree cleanup_decl = lookup_name (cleanup_id);
    6335          140 :           tree cleanup;
    6336          140 :           vec<tree, va_gc> *v;
    6337              : 
    6338              :           /* Build "cleanup(&decl)" for the destructor.  */
    6339          140 :           cleanup = build_unary_op (input_location, ADDR_EXPR, decl, false);
    6340          140 :           vec_alloc (v, 1);
    6341          140 :           v->quick_push (cleanup);
    6342          140 :           cleanup = c_build_function_call_vec (DECL_SOURCE_LOCATION (decl),
    6343          140 :                                                vNULL, cleanup_decl, v, NULL);
    6344          140 :           vec_free (v);
    6345              : 
    6346              :           /* Don't warn about decl unused; the cleanup uses it.  */
    6347          140 :           TREE_USED (decl) = 1;
    6348          140 :           TREE_USED (cleanup_decl) = 1;
    6349          140 :           DECL_READ_P (decl) = 1;
    6350              : 
    6351          140 :           push_cleanup (decl, cleanup, false);
    6352              :         }
    6353              :     }
    6354              : 
    6355    161736301 :   if (warn_cxx_compat
    6356       802492 :       && VAR_P (decl)
    6357        33525 :       && !DECL_EXTERNAL (decl)
    6358    161760817 :       && DECL_INITIAL (decl) == NULL_TREE)
    6359              :     {
    6360         7121 :       type = strip_array_types (type);
    6361         7121 :       if (TREE_READONLY (decl))
    6362            6 :         warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wc___compat,
    6363              :                     "uninitialized %<const %D%> is invalid in C++", decl);
    6364         7115 :       else if (RECORD_OR_UNION_TYPE_P (type)
    6365         7115 :                && C_TYPE_FIELDS_READONLY (type))
    6366            5 :         diagnose_uninitialized_cst_member (decl, type);
    6367              :     }
    6368              : 
    6369    161736301 :   if (flag_openmp
    6370       546558 :       && VAR_P (decl)
    6371    161762884 :       && lookup_attribute ("omp declare target implicit",
    6372        26583 :                            DECL_ATTRIBUTES (decl)))
    6373              :     {
    6374           13 :       DECL_ATTRIBUTES (decl)
    6375           13 :         = remove_attribute ("omp declare target implicit",
    6376           13 :                             DECL_ATTRIBUTES (decl));
    6377           13 :       if (!omp_mappable_type (TREE_TYPE (decl)))
    6378            9 :         error ("%q+D in declare target directive does not have mappable type",
    6379              :                decl);
    6380            4 :       else if (!lookup_attribute ("omp declare target",
    6381            4 :                                   DECL_ATTRIBUTES (decl))
    6382            8 :                && !lookup_attribute ("omp declare target link",
    6383            4 :                                      DECL_ATTRIBUTES (decl)))
    6384              :         {
    6385            4 :           DECL_ATTRIBUTES (decl)
    6386            4 :             = tree_cons (get_identifier ("omp declare target"),
    6387            4 :                          NULL_TREE, DECL_ATTRIBUTES (decl));
    6388            4 :             symtab_node *node = symtab_node::get (decl);
    6389            4 :             if (node != NULL)
    6390              :               {
    6391            4 :                 node->offloadable = 1;
    6392            4 :                 if (ENABLE_OFFLOADING)
    6393              :                   {
    6394              :                     g->have_offload = true;
    6395              :                     if (is_a <varpool_node *> (node))
    6396              :                       vec_safe_push (offload_vars, decl);
    6397              :                   }
    6398              :               }
    6399              :         }
    6400              :     }
    6401              : 
    6402              :   /* This is the last point we can lower alignment so give the target the
    6403              :      chance to do so.  */
    6404    161736301 :   if (VAR_P (decl)
    6405      9023186 :       && !is_global_var (decl)
    6406    169518197 :       && !DECL_HARD_REGISTER (decl))
    6407      7780855 :     targetm.lower_local_decl_alignment (decl);
    6408              : 
    6409    161736301 :   invoke_plugin_callbacks (PLUGIN_FINISH_DECL, decl);
    6410    161736301 : }
    6411              : 
    6412              : /* Given a parsed parameter declaration, decode it into a PARM_DECL.
    6413              :    EXPR is NULL or a pointer to an expression that needs to be
    6414              :    evaluated for the side effects of array size expressions in the
    6415              :    parameters.  */
    6416              : 
    6417              : tree
    6418            0 : grokparm (const struct c_parm *parm, tree *expr)
    6419              : {
    6420            0 :   tree attrs = parm->attrs;
    6421            0 :   tree decl = grokdeclarator (parm->declarator, parm->specs, PARM, false,
    6422            0 :                               NULL, &attrs, expr, NULL, DEPRECATED_NORMAL);
    6423              : 
    6424            0 :   decl_attributes (&decl, attrs, 0);
    6425              : 
    6426            0 :   return decl;
    6427              : }
    6428              : 
    6429              : 
    6430              : 
    6431              : /* Given a parsed parameter declaration, decode it into a PARM_DECL
    6432              :    and push that on the current scope.  EXPR is a pointer to an
    6433              :    expression that needs to be evaluated for the side effects of array
    6434              :    size expressions in the parameters.  */
    6435              : 
    6436              : void
    6437    128550391 : push_parm_decl (const struct c_parm *parm, tree *expr)
    6438              : {
    6439    128550391 :   tree attrs = parm->attrs;
    6440    128550391 :   tree decl = grokdeclarator (parm->declarator, parm->specs, PARM, false, NULL,
    6441    128550391 :                               &attrs, expr, NULL, DEPRECATED_NORMAL);
    6442    128550391 :   if (decl && DECL_P (decl))
    6443    128550391 :     DECL_SOURCE_LOCATION (decl) = parm->loc;
    6444              : 
    6445    128550391 :   decl_attributes (&decl, attrs, 0);
    6446              : 
    6447    128550391 :   decl = pushdecl (decl);
    6448              : 
    6449    128550391 :   finish_decl (decl, input_location, NULL_TREE, NULL_TREE, NULL_TREE);
    6450    128550391 : }
    6451              : 
    6452              : /* Mark all the parameter declarations to date as forward decls.
    6453              :    Also diagnose use of this extension.  */
    6454              : 
    6455              : void
    6456           42 : mark_forward_parm_decls (void)
    6457              : {
    6458           42 :   struct c_binding *b;
    6459              : 
    6460           42 :   if (current_scope->had_forward_parm_decls)
    6461           12 :     warning_at (input_location, OPT_Wmultiple_parameter_fwd_decl_lists,
    6462              :                 "more than one list of forward declarations of parameters");
    6463           42 :   if (pedantic && !current_scope->had_forward_parm_decls)
    6464            4 :     pedwarn (input_location, OPT_Wpedantic,
    6465              :              "ISO C forbids forward parameter declarations");
    6466              : 
    6467           42 :   current_scope->had_forward_parm_decls = true;
    6468              : 
    6469           95 :   for (b = current_scope->bindings; b; b = b->prev)
    6470           53 :     if (TREE_CODE (b->decl) == PARM_DECL)
    6471           53 :       TREE_ASM_WRITTEN (b->decl) = 1;
    6472           42 : }
    6473              : 
    6474              : /* Build a COMPOUND_LITERAL_EXPR.  TYPE is the type given in the compound
    6475              :    literal, which may be an incomplete array type completed by the
    6476              :    initializer; INIT is a CONSTRUCTOR at LOC that initializes the compound
    6477              :    literal.  NON_CONST is true if the initializers contain something
    6478              :    that cannot occur in a constant expression.  If ALIGNAS_ALIGN is nonzero,
    6479              :    it is the (valid) alignment for this compound literal, as specified
    6480              :    with _Alignas.  SCSPECS are the storage class specifiers (C23) from the
    6481              :    compound literal.  */
    6482              : 
    6483              : tree
    6484       930298 : build_compound_literal (location_t loc, tree type, tree init, bool non_const,
    6485              :                         unsigned int alignas_align,
    6486              :                         struct c_declspecs *scspecs)
    6487              : {
    6488              :   /* We do not use start_decl here because we have a type, not a declarator;
    6489              :      and do not use finish_decl because the decl should be stored inside
    6490              :      the COMPOUND_LITERAL_EXPR rather than added elsewhere as a DECL_EXPR.  */
    6491       930298 :   tree decl;
    6492       930298 :   tree complit;
    6493       930298 :   tree stmt;
    6494       930298 :   bool threadp = scspecs ? scspecs->thread_p : false;
    6495          307 :   enum c_storage_class storage_class = (scspecs
    6496              :                                         ? scspecs->storage_class
    6497              :                                         : csc_none);
    6498              : 
    6499       930298 :   if (type == error_mark_node
    6500       930291 :       || init == error_mark_node)
    6501              :     return error_mark_node;
    6502              : 
    6503       930238 :   if (current_scope == file_scope && storage_class == csc_register)
    6504              :     {
    6505            1 :       error_at (loc, "file-scope compound literal specifies %<register%>");
    6506            1 :       storage_class = csc_none;
    6507              :     }
    6508              : 
    6509       930238 :   if (current_scope != file_scope && threadp && storage_class == csc_none)
    6510              :     {
    6511            6 :       error_at (loc, "compound literal implicitly auto and declared %qs",
    6512            3 :                 scspecs->thread_gnu_p ? "__thread" : "_Thread_local");
    6513            3 :       threadp = false;
    6514              :     }
    6515              : 
    6516       930238 :   decl = build_decl (loc, VAR_DECL, NULL_TREE, type);
    6517       930238 :   DECL_EXTERNAL (decl) = 0;
    6518       930238 :   TREE_PUBLIC (decl) = 0;
    6519      1860476 :   TREE_STATIC (decl) = (current_scope == file_scope
    6520       930238 :                         || storage_class == csc_static);
    6521       930238 :   DECL_CONTEXT (decl) = current_function_decl;
    6522       930238 :   TREE_USED (decl) = 1;
    6523       930238 :   DECL_READ_P (decl) = 1;
    6524       930238 :   DECL_ARTIFICIAL (decl) = 1;
    6525       930238 :   DECL_IGNORED_P (decl) = 1;
    6526       930238 :   C_DECL_COMPOUND_LITERAL_P (decl) = 1;
    6527       930238 :   C_DECL_DECLARED_CONSTEXPR (decl) = scspecs && scspecs->constexpr_p;
    6528       930238 :   TREE_TYPE (decl) = type;
    6529       930238 :   if (threadp)
    6530           16 :     set_decl_tls_model (decl, decl_default_tls_model (decl));
    6531       930238 :   if (storage_class == csc_register)
    6532              :     {
    6533           25 :       C_DECL_REGISTER (decl) = 1;
    6534           25 :       DECL_REGISTER (decl) = 1;
    6535              :     }
    6536       930238 :   c_apply_type_quals_to_decl (TYPE_QUALS (strip_array_types (type)), decl);
    6537       930238 :   if (alignas_align)
    6538              :     {
    6539            3 :       SET_DECL_ALIGN (decl, alignas_align * BITS_PER_UNIT);
    6540            3 :       DECL_USER_ALIGN (decl) = 1;
    6541              :     }
    6542       930238 :   store_init_value (loc, decl, init, NULL_TREE);
    6543       930238 :   if (current_scope != file_scope
    6544       929987 :       && TREE_STATIC (decl)
    6545           28 :       && !TREE_READONLY (decl)
    6546           17 :       && DECL_DECLARED_INLINE_P (current_function_decl)
    6547       930244 :       && DECL_EXTERNAL (current_function_decl))
    6548            4 :     record_inline_static (input_location, current_function_decl,
    6549              :                           decl, csi_modifiable);
    6550              : 
    6551       930238 :   if (TREE_CODE (type) == ARRAY_TYPE && !COMPLETE_TYPE_P (type))
    6552              :     {
    6553          262 :       int failure = complete_array_type (&TREE_TYPE (decl),
    6554          262 :                                          DECL_INITIAL (decl), true);
    6555              :       /* If complete_array_type returns 3, it means that the initial value of
    6556              :          the compound literal is empty.  Allow it with a pedwarn; in pre-C23
    6557              :          modes, the empty initializer itself has been diagnosed if pedantic so
    6558              :          does not need to be diagnosed again here.  */
    6559          262 :       gcc_assert (failure == 0 || failure == 3);
    6560          262 :       if (failure == 3 && flag_isoc23)
    6561            1 :         pedwarn (loc, OPT_Wpedantic,
    6562              :                  "array of unknown size with empty initializer");
    6563              : 
    6564          262 :       type = TREE_TYPE (decl);
    6565          262 :       TREE_TYPE (DECL_INITIAL (decl)) = type;
    6566          262 :       relayout_decl (decl);
    6567              :     }
    6568              : 
    6569       930238 :   if (type == error_mark_node || !COMPLETE_TYPE_P (type))
    6570              :     {
    6571           19 :       c_incomplete_type_error (loc, NULL_TREE, type);
    6572           19 :       return error_mark_node;
    6573              :     }
    6574              : 
    6575       929940 :   if ((TREE_STATIC (decl) || C_DECL_DECLARED_CONSTEXPR (decl))
    6576       930440 :       && C_TYPE_VARIABLE_SIZE (type))
    6577            2 :     error_at (loc, "storage size isn%'t constant");
    6578              : 
    6579       930219 :   if (TREE_STATIC (decl)
    6580       930219 :       && !verify_type_context (loc, TCTX_STATIC_STORAGE, type))
    6581            0 :     return error_mark_node;
    6582              : 
    6583       930219 :   stmt = build_stmt (DECL_SOURCE_LOCATION (decl), DECL_EXPR, decl);
    6584       930219 :   complit = build1 (COMPOUND_LITERAL_EXPR, type, stmt);
    6585       930219 :   TREE_SIDE_EFFECTS (complit) = 1;
    6586              : 
    6587       930219 :   layout_decl (decl, 0);
    6588              : 
    6589       930219 :   if (TREE_STATIC (decl))
    6590              :     {
    6591              :       /* This decl needs a name for the assembler output.  */
    6592          279 :       set_compound_literal_name (decl);
    6593          279 :       DECL_DEFER_OUTPUT (decl) = 1;
    6594          279 :       DECL_COMDAT (decl) = 1;
    6595          279 :       pushdecl (decl);
    6596          279 :       rest_of_decl_compilation (decl, 1, 0);
    6597              :     }
    6598       929940 :   else if (current_function_decl && !current_scope->parm_flag)
    6599       929931 :     pushdecl (decl);
    6600              : 
    6601       930219 :   if (non_const)
    6602              :     {
    6603          221 :       complit = build2 (C_MAYBE_CONST_EXPR, type, NULL, complit);
    6604          221 :       C_MAYBE_CONST_EXPR_NON_CONST (complit) = 1;
    6605              :     }
    6606              : 
    6607              :   return complit;
    6608              : }
    6609              : 
    6610              : /* Check the type of a compound literal.  Here we just check that it
    6611              :    is valid for C++.  */
    6612              : 
    6613              : void
    6614       930295 : check_compound_literal_type (location_t loc, struct c_type_name *type_name)
    6615              : {
    6616       930295 :   if (warn_cxx_compat
    6617          377 :       && (type_name->specs->typespec_kind == ctsk_tagdef
    6618          376 :           || type_name->specs->typespec_kind == ctsk_tagfirstref
    6619          375 :           || type_name->specs->typespec_kind == ctsk_tagfirstref_attrs))
    6620            2 :     warning_at (loc, OPT_Wc___compat,
    6621              :                 "defining a type in a compound literal is invalid in C++");
    6622       930295 : }
    6623              : 
    6624              : /* Performs sanity checks on the TYPE and WIDTH of the bit-field NAME,
    6625              :    replacing with appropriate values if they are invalid.  */
    6626              : 
    6627              : static void
    6628        55230 : check_bitfield_type_and_width (location_t loc, tree *type, tree *width,
    6629              :                                tree orig_name)
    6630              : {
    6631        55230 :   tree type_mv;
    6632        55230 :   unsigned int max_width;
    6633        55230 :   unsigned HOST_WIDE_INT w;
    6634        55230 :   const char *name = (orig_name
    6635        98830 :                       ? identifier_to_locale (IDENTIFIER_POINTER (orig_name))
    6636        11630 :                       : _("<anonymous>"));
    6637              : 
    6638              :   /* Detect and ignore out of range field width and process valid
    6639              :      field widths.  */
    6640        55230 :   if (!INTEGRAL_TYPE_P (TREE_TYPE (*width)))
    6641              :     {
    6642            8 :       error_at (loc, "bit-field %qs width not an integer constant", name);
    6643            8 :       *width = integer_one_node;
    6644              :     }
    6645              :   else
    6646              :     {
    6647        55222 :       if (TREE_CODE (*width) != INTEGER_CST)
    6648              :         {
    6649           12 :           *width = c_fully_fold (*width, false, NULL);
    6650           12 :           if (TREE_CODE (*width) == INTEGER_CST)
    6651            6 :             pedwarn (loc, OPT_Wpedantic,
    6652              :                      "bit-field %qs width not an integer constant expression",
    6653              :                      name);
    6654              :         }
    6655        55222 :       if (TREE_CODE (*width) != INTEGER_CST)
    6656              :         {
    6657            6 :           error_at (loc, "bit-field %qs width not an integer constant", name);
    6658            6 :           *width = integer_one_node;
    6659              :         }
    6660        55222 :       constant_expression_warning (*width);
    6661        55222 :       if (tree_int_cst_sgn (*width) < 0)
    6662              :         {
    6663            2 :           error_at (loc, "negative width in bit-field %qs", name);
    6664            2 :           *width = integer_one_node;
    6665              :         }
    6666        55220 :       else if (integer_zerop (*width) && orig_name)
    6667              :         {
    6668            4 :           error_at (loc, "zero width for bit-field %qs", name);
    6669            4 :           *width = integer_one_node;
    6670              :         }
    6671              :     }
    6672              : 
    6673              :   /* Detect invalid bit-field type.  */
    6674        55230 :   if (TREE_CODE (*type) != INTEGER_TYPE
    6675              :       && TREE_CODE (*type) != BOOLEAN_TYPE
    6676              :       && TREE_CODE (*type) != ENUMERAL_TYPE
    6677        55230 :       && TREE_CODE (*type) != BITINT_TYPE)
    6678              :     {
    6679            8 :       error_at (loc, "bit-field %qs has invalid type", name);
    6680            8 :       *type = unsigned_type_node;
    6681              :     }
    6682              : 
    6683        55230 :   if (TYPE_WARN_IF_NOT_ALIGN (*type))
    6684              :     {
    6685            1 :       error_at (loc, "cannot declare bit-field %qs with %<warn_if_not_aligned%> type",
    6686              :                 name);
    6687            1 :       *type = unsigned_type_node;
    6688              :     }
    6689              : 
    6690        55230 :   type_mv = TYPE_MAIN_VARIANT (*type);
    6691        55230 :   if (!in_system_header_at (input_location)
    6692        29836 :       && type_mv != integer_type_node
    6693        26998 :       && type_mv != unsigned_type_node
    6694        67996 :       && type_mv != boolean_type_node)
    6695        12183 :     pedwarn_c90 (loc, OPT_Wpedantic,
    6696              :                  "type of bit-field %qs is a GCC extension", name);
    6697              : 
    6698        55230 :   max_width = TYPE_PRECISION (*type);
    6699              : 
    6700        55230 :   if (compare_tree_int (*width, max_width) > 0)
    6701              :     {
    6702            4 :       error_at (loc, "width of %qs exceeds its type", name);
    6703            4 :       w = max_width;
    6704            4 :       *width = build_int_cst (integer_type_node, w);
    6705              :     }
    6706              :   else
    6707        55226 :     w = tree_to_uhwi (*width);
    6708              : 
    6709              :   /* Truncation of hardbool false and true representation values is always safe:
    6710              :      either the values remain different, or we'll report a problem when creating
    6711              :      the narrower type.  */
    6712        55230 :   if (c_hardbool_type_attr (*type))
    6713        55230 :     return;
    6714              : 
    6715        54949 :   if (TREE_CODE (*type) == ENUMERAL_TYPE)
    6716              :     {
    6717         4148 :       struct lang_type *lt = TYPE_LANG_SPECIFIC (*type);
    6718         4148 :       if (!lt
    6719         4138 :           || w < tree_int_cst_min_precision (lt->enum_min, TYPE_SIGN (*type))
    6720         8282 :           || w < tree_int_cst_min_precision (lt->enum_max, TYPE_SIGN (*type)))
    6721           15 :         warning_at (loc, 0, "%qs is narrower than values of its type", name);
    6722              :     }
    6723              : }
    6724              : 
    6725              : 
    6726              : 
    6727              : /* Print warning about variable length array if necessary.  */
    6728              : 
    6729              : static void
    6730        22504 : warn_variable_length_array (tree name, tree size)
    6731              : {
    6732        22504 :   if (TREE_CONSTANT (size))
    6733              :     {
    6734          181 :       if (name)
    6735          168 :         pedwarn_c90 (input_location, OPT_Wvla,
    6736              :                      "ISO C90 forbids array %qE whose size "
    6737              :                      "cannot be evaluated", name);
    6738              :       else
    6739           13 :         pedwarn_c90 (input_location, OPT_Wvla, "ISO C90 forbids array "
    6740              :                      "whose size cannot be evaluated");
    6741              :     }
    6742              :   else
    6743              :     {
    6744        22323 :       if (name)
    6745        13839 :         pedwarn_c90 (input_location, OPT_Wvla,
    6746              :                      "ISO C90 forbids variable length array %qE", name);
    6747              :       else
    6748         8484 :         pedwarn_c90 (input_location, OPT_Wvla, "ISO C90 forbids variable "
    6749              :                      "length array");
    6750              :     }
    6751        22504 : }
    6752              : 
    6753              : /* Returns the smallest location != UNKNOWN_LOCATION in LOCATIONS,
    6754              :    considering only those c_declspec_words found in LIST, which
    6755              :    must be terminated by cdw_number_of_elements.  */
    6756              : 
    6757              : static location_t
    6758          235 : smallest_type_quals_location (const location_t *locations,
    6759              :                               const c_declspec_word *list)
    6760              : {
    6761          235 :   location_t loc = UNKNOWN_LOCATION;
    6762         1410 :   while (*list != cdw_number_of_elements)
    6763              :     {
    6764         1175 :       location_t newloc = locations[*list];
    6765         1175 :       if (loc == UNKNOWN_LOCATION
    6766          288 :           || (newloc != UNKNOWN_LOCATION && newloc < loc))
    6767          887 :         loc = newloc;
    6768         1175 :       list++;
    6769              :     }
    6770              : 
    6771          235 :   return loc;
    6772              : }
    6773              : 
    6774              : 
    6775              : /* We attach an artificial TYPE_DECL to pointed-to type
    6776              :    and arrange for it to be included in a DECL_EXPR.  This
    6777              :    forces the sizes evaluation at a safe point and ensures it
    6778              :    is not deferred until e.g. within a deeper conditional context.
    6779              : 
    6780              :    PARM contexts have no enclosing statement list that
    6781              :    can hold the DECL_EXPR, so we need to use a BIND_EXPR
    6782              :    instead, and add it to the list of expressions that
    6783              :    need to be evaluated.
    6784              : 
    6785              :    TYPENAME contexts do have an enclosing statement list,
    6786              :    but it would be incorrect to use it, as the size should
    6787              :    only be evaluated if the containing expression is
    6788              :    evaluated.  We might also be in the middle of an
    6789              :    expression with side effects on the pointed-to type size
    6790              :    "arguments" prior to the pointer declaration point and
    6791              :    the fake TYPE_DECL in the enclosing context would force
    6792              :    the size evaluation prior to the side effects.  We therefore
    6793              :    use BIND_EXPRs in TYPENAME contexts too.  */
    6794              : static void
    6795         7043 : add_decl_expr (location_t loc, tree type, tree *expr, bool set_name_p)
    6796              : {
    6797         7043 :   tree bind = NULL_TREE;
    6798         7043 :   if (expr)
    6799              :     {
    6800         1600 :       bind = build3 (BIND_EXPR, void_type_node, NULL_TREE, NULL_TREE,
    6801              :                      NULL_TREE);
    6802         1600 :       TREE_SIDE_EFFECTS (bind) = 1;
    6803         1600 :       BIND_EXPR_BODY (bind) = push_stmt_list ();
    6804         1600 :       push_scope ();
    6805              :     }
    6806              : 
    6807         7043 :   tree decl = build_decl (loc, TYPE_DECL, NULL_TREE, type);
    6808         7043 :   pushdecl (decl);
    6809         7043 :   DECL_ARTIFICIAL (decl) = 1;
    6810         7043 :   add_stmt (build_stmt (DECL_SOURCE_LOCATION (decl), DECL_EXPR, decl));
    6811         7043 :   if (set_name_p)
    6812         6326 :     TYPE_NAME (type) = decl;
    6813              : 
    6814         7043 :   if (bind)
    6815              :     {
    6816         1600 :       pop_scope ();
    6817         1600 :       BIND_EXPR_BODY (bind) = pop_stmt_list (BIND_EXPR_BODY (bind));
    6818         1600 :       if (*expr)
    6819         1478 :         *expr = build2 (COMPOUND_EXPR, void_type_node, *expr, bind);
    6820              :       else
    6821          122 :         *expr = bind;
    6822              :     }
    6823         7043 : }
    6824              : 
    6825              : 
    6826              : /* Add attribute "arg spec" to ATTRS corresponding to an array/VLA parameter
    6827              :    declared with type TYPE.  The attribute has two arguments.  The first is
    6828              :    a string that encodes the presence of the static keyword.  The second is
    6829              :    the declared type of the array before adjustment, i.e. as an array type
    6830              :    including the outermost bound.  */
    6831              : 
    6832              : static tree
    6833       443656 : build_arg_spec_attribute (tree type, bool static_p, tree attrs)
    6834              : {
    6835       443656 :   tree vbchain = tree_cons (NULL_TREE, type, NULL_TREE);
    6836       443656 :   tree acsstr = static_p ? build_string (7, "static") :
    6837       443534 :                            build_string (1, "");
    6838       443656 :   tree args = tree_cons (NULL_TREE, acsstr, vbchain);
    6839       443656 :   tree name = get_identifier ("arg spec");
    6840       443656 :   return tree_cons (name, args, attrs);
    6841              : }
    6842              : 
    6843              : 
    6844              : /* Given declspecs and a declarator,
    6845              :    determine the name and type of the object declared
    6846              :    and construct a ..._DECL node for it.
    6847              :    (In one case we can return a ..._TYPE node instead.
    6848              :     For invalid input we sometimes return NULL_TREE.)
    6849              : 
    6850              :    DECLSPECS is a c_declspecs structure for the declaration specifiers.
    6851              : 
    6852              :    DECL_CONTEXT says which syntactic context this declaration is in:
    6853              :      NORMAL for most contexts.  Make a VAR_DECL or FUNCTION_DECL or TYPE_DECL.
    6854              :      FUNCDEF for a function definition.  Like NORMAL but a few different
    6855              :       error messages in each case.  Return value may be zero meaning
    6856              :       this definition is too screwy to try to parse.
    6857              :      PARM for a parameter declaration (either within a function prototype
    6858              :       or before a function body).  Make a PARM_DECL, or return void_type_node.
    6859              :      TYPENAME if for a typename (in a cast or sizeof).
    6860              :       Don't make a DECL node; just return the ..._TYPE node.
    6861              :      GENERIC_ASSOC for typenames in a generic association.
    6862              :      FIELD for a struct or union field; make a FIELD_DECL.
    6863              :    INITIALIZED is true if the decl has an initializer.
    6864              :    WIDTH is non-NULL for bit-fields, and is a pointer to an INTEGER_CST node
    6865              :    representing the width of the bit-field.
    6866              :    DECL_ATTRS points to the list of attributes that should be added to this
    6867              :      decl.  Any nested attributes that belong on the decl itself will be
    6868              :      added to this list.
    6869              :    If EXPR is not NULL, any expressions that need to be evaluated as
    6870              :      part of evaluating variably modified types will be stored in *EXPR.
    6871              :    If EXPR_CONST_OPERANDS is not NULL, *EXPR_CONST_OPERANDS will be
    6872              :      set to indicate whether operands in *EXPR can be used in constant
    6873              :      expressions.
    6874              :    DEPRECATED_STATE is a deprecated_states value indicating whether
    6875              :    deprecation/unavailability warnings should be suppressed.
    6876              : 
    6877              :    In the TYPENAME case, DECLARATOR is really an absolute declarator.
    6878              :    It may also be so in the PARM case, for a prototype where the
    6879              :    argument type is specified but not the name.
    6880              : 
    6881              :    This function is where the complicated C meanings of `static'
    6882              :    and `extern' are interpreted.  */
    6883              : 
    6884              : static tree
    6885    326013772 : grokdeclarator (const struct c_declarator *declarator,
    6886              :                 struct c_declspecs *declspecs,
    6887              :                 enum decl_context decl_context, bool initialized, tree *width,
    6888              :                 tree *decl_attrs, tree *expr, bool *expr_const_operands,
    6889              :                 enum deprecated_states deprecated_state)
    6890              : {
    6891    326013772 :   tree type = declspecs->type;
    6892    326013772 :   bool threadp = declspecs->thread_p;
    6893    326013772 :   bool constexprp = declspecs->constexpr_p;
    6894    326013772 :   enum c_storage_class storage_class = declspecs->storage_class;
    6895    326013772 :   int constp;
    6896    326013772 :   int restrictp;
    6897    326013772 :   int volatilep;
    6898    326013772 :   int atomicp;
    6899    326013772 :   qualifier_set type_quals {};
    6900    326013772 :   tree name = NULL_TREE;
    6901    326013772 :   bool funcdef_flag = false;
    6902    326013772 :   bool funcdef_syntax = false;
    6903    326013772 :   bool size_varies = false;
    6904    326013772 :   bool size_error = false;
    6905    326013772 :   tree decl_attr = declspecs->decl_attr;
    6906    326013772 :   qualifier_set array_ptr_quals {};
    6907    326013772 :   tree array_ptr_attrs = NULL_TREE;
    6908    326013772 :   bool array_parm_static = false;
    6909    326013772 :   bool array_parm_vla_unspec_p = false;
    6910    326013772 :   tree returned_attrs = NULL_TREE;
    6911    326013772 :   tree decl_id_attrs = NULL_TREE;
    6912    326013772 :   bool bitfield = width != NULL;
    6913    326013772 :   tree element_type;
    6914    326013772 :   tree orig_qual_type = NULL;
    6915    326013772 :   size_t orig_qual_indirect = 0;
    6916    326013772 :   struct c_arg_info *arg_info = 0;
    6917    326013772 :   addr_space_t as1, as2, address_space;
    6918    326013772 :   location_t loc = UNKNOWN_LOCATION;
    6919    326013772 :   tree expr_dummy;
    6920    326013772 :   bool expr_const_operands_dummy;
    6921    326013772 :   enum c_declarator_kind first_non_attr_kind;
    6922    326013772 :   unsigned int alignas_align = 0;
    6923              : 
    6924    326013772 :   if (type == NULL_TREE)
    6925              :     {
    6926              :       /* This can occur for auto on a parameter in C23 mode.  Set a
    6927              :          dummy type here so subsequent code can give diagnostics for
    6928              :          this case.  */
    6929            2 :       gcc_assert (declspecs->c23_auto_p);
    6930            2 :       gcc_assert (decl_context == PARM);
    6931            2 :       type = declspecs->type = integer_type_node;
    6932              :     }
    6933    326013772 :   if (TREE_CODE (type) == ERROR_MARK)
    6934           29 :     return error_mark_node;
    6935    326013743 :   if (expr == NULL)
    6936              :     {
    6937        38668 :       expr = &expr_dummy;
    6938        38668 :       expr_dummy = NULL_TREE;
    6939              :     }
    6940    326013743 :   if (expr_const_operands == NULL)
    6941    199508079 :     expr_const_operands = &expr_const_operands_dummy;
    6942              : 
    6943    326013743 :   if (declspecs->expr)
    6944              :     {
    6945          954 :       if (*expr)
    6946            7 :         *expr = build2 (COMPOUND_EXPR, TREE_TYPE (declspecs->expr), *expr,
    6947              :                         declspecs->expr);
    6948              :       else
    6949          947 :         *expr = declspecs->expr;
    6950              :     }
    6951    326013743 :   *expr_const_operands = declspecs->expr_const_operands;
    6952              : 
    6953    326013743 :   if (decl_context == FUNCDEF)
    6954     37714021 :     funcdef_flag = true, decl_context = NORMAL;
    6955              : 
    6956              :   /* Look inside a declarator for the name being declared
    6957              :      and get it as an IDENTIFIER_NODE, for an error message.  */
    6958    326013743 :   {
    6959    326013743 :     const struct c_declarator *decl = declarator;
    6960              : 
    6961    326013743 :     first_non_attr_kind = cdk_attrs;
    6962    398681073 :     while (decl)
    6963    398681073 :       switch (decl->kind)
    6964              :         {
    6965      1158546 :         case cdk_array:
    6966      1158546 :           loc = decl->id_loc;
    6967              :           /* FALL THRU.  */
    6968              : 
    6969     72660446 :         case cdk_function:
    6970     72660446 :         case cdk_pointer:
    6971     72660446 :           funcdef_syntax = (decl->kind == cdk_function);
    6972     72660446 :           if (first_non_attr_kind == cdk_attrs)
    6973     70420302 :             first_non_attr_kind = decl->kind;
    6974     72660446 :           decl = decl->declarator;
    6975     72660446 :           break;
    6976              : 
    6977         6884 :         case cdk_attrs:
    6978         6884 :           decl = decl->declarator;
    6979         6884 :           break;
    6980              : 
    6981    326013743 :         case cdk_id:
    6982    326013743 :           loc = decl->id_loc;
    6983    326013743 :           if (decl->u.id.id)
    6984              :             name = decl->u.id.id;
    6985    326013743 :           decl_id_attrs = decl->u.id.attrs;
    6986    326013743 :           if (first_non_attr_kind == cdk_attrs)
    6987    255593441 :             first_non_attr_kind = decl->kind;
    6988              :           decl = 0;
    6989              :           break;
    6990              : 
    6991            0 :         default:
    6992            0 :           gcc_unreachable ();
    6993              :         }
    6994    326013743 :     if (name == NULL_TREE)
    6995              :       {
    6996    131292761 :         gcc_assert (decl_context == PARM
    6997              :                     || decl_context == TYPENAME
    6998              :                     || decl_context == GENERIC_ASSOC
    6999              :                     || (decl_context == FIELD
    7000              :                         && declarator->kind == cdk_id));
    7001    131292761 :         gcc_assert (!initialized);
    7002              :       }
    7003              :   }
    7004              : 
    7005              :   /* An enum type specifier (": specifier-qualifier-list") may only be
    7006              :      specified when the enum is being defined or in an empty
    7007              :      declaration of the form "enum identifier enum-type-specifier;".
    7008              :      Except for the case of an empty declaration that has additional
    7009              :      declaration specifiers, all invalid contexts (declarations that
    7010              :      aren't empty, type names, parameter declarations, member
    7011              :      declarations) pass through grokdeclarator.  */
    7012    326013743 :   if (declspecs->enum_type_specifier_ref_p)
    7013            6 :     error_at (loc, "%<enum%> underlying type may not be specified here");
    7014              : 
    7015              :   /* A function definition's declarator must have the form of
    7016              :      a function declarator.  */
    7017              : 
    7018    326013743 :   if (funcdef_flag && !funcdef_syntax)
    7019              :     return NULL_TREE;
    7020              : 
    7021              :   /* If this looks like a function definition, make it one,
    7022              :      even if it occurs where parms are expected.
    7023              :      Then store_parm_decls will reject it and not use it as a parm.  */
    7024    326013714 :   if (decl_context == NORMAL && !funcdef_flag && current_scope->parm_flag)
    7025        22662 :     decl_context = PARM;
    7026              : 
    7027    326013714 :   if (deprecated_state != UNAVAILABLE_DEPRECATED_SUPPRESS)
    7028              :     {
    7029    326013690 :       if (declspecs->unavailable_p)
    7030           28 :         error_unavailable_use (declspecs->type, declspecs->decl_attr);
    7031    326013662 :       else if (declspecs->deprecated_p
    7032           46 :                 && deprecated_state != DEPRECATED_SUPPRESS)
    7033           38 :         warn_deprecated_use (declspecs->type, declspecs->decl_attr);
    7034              :     }
    7035              : 
    7036    326013714 :   if ((decl_context == NORMAL || decl_context == FIELD)
    7037     70874023 :       && current_scope == file_scope
    7038    388722420 :       && c_type_variably_modified_p (type))
    7039              :     {
    7040            3 :       if (name)
    7041            3 :         error_at (loc, "variably modified %qE at file scope", name);
    7042              :       else
    7043            0 :         error_at (loc, "variably modified field at file scope");
    7044            3 :       type = integer_type_node;
    7045              :     }
    7046              : 
    7047    326013714 :   size_varies = C_TYPE_VARIABLE_SIZE (type) != 0;
    7048              : 
    7049              :   /* Diagnose defaulting to "int".  */
    7050              : 
    7051    326013714 :   if (declspecs->default_int_p)
    7052              :     {
    7053              :       /* Issue a warning if this is an ISO C 99 program or if
    7054              :          -Wreturn-type and this is a function, or if -Wimplicit;
    7055              :          prefer the former warning since it is more explicit.  */
    7056         9764 :       if ((warn_implicit_int || warn_return_type > 0 || flag_isoc99)
    7057         1229 :           && funcdef_flag)
    7058          702 :         warn_about_return_type = 1;
    7059              :       else
    7060              :         {
    7061         9062 :           if (name)
    7062         9052 :             permerror_opt (loc, OPT_Wimplicit_int,
    7063              :                            "type defaults to %<int%> in declaration "
    7064              :                            "of %qE", name);
    7065              :           else
    7066           10 :             permerror_opt (loc, OPT_Wimplicit_int,
    7067              :                            "type defaults to %<int%> in type name");
    7068              :         }
    7069              :     }
    7070              : 
    7071              :   /* Adjust the type if a bit-field is being declared,
    7072              :      -funsigned-bitfields applied and the type is not explicitly
    7073              :      "signed".  */
    7074    326013714 :   if (bitfield && !flag_signed_bitfields && !declspecs->explicit_signed_p
    7075           40 :       && TREE_CODE (type) == INTEGER_TYPE)
    7076           38 :     type = c_common_unsigned_type (type);
    7077              : 
    7078              :   /* Figure out the type qualifiers for the declaration.  There are
    7079              :      two ways a declaration can become qualified.  One is something
    7080              :      like `const int i' where the `const' is explicit.  Another is
    7081              :      something like `typedef const int CI; CI i' where the type of the
    7082              :      declaration contains the `const'.  A third possibility is that
    7083              :      there is a type qualifier on the element type of a typedefed
    7084              :      array type, in which case we should extract that qualifier so
    7085              :      that c_apply_type_quals_to_decl receives the full list of
    7086              :      qualifiers to work with (C90 is not entirely clear about whether
    7087              :      duplicate qualifiers should be diagnosed in this case, but it
    7088              :      seems most appropriate to do so).  */
    7089    326013714 :   element_type = strip_array_types (type);
    7090    326013714 :   constp = declspecs->const_p + TYPE_READONLY (element_type);
    7091    326013714 :   restrictp = declspecs->restrict_p + TYPE_RESTRICT (element_type);
    7092    326013714 :   volatilep = declspecs->volatile_p + TYPE_VOLATILE (element_type);
    7093    326013714 :   atomicp = declspecs->atomic_p + TYPE_ATOMIC (element_type);
    7094    326013714 :   as1 = declspecs->address_space;
    7095    326013714 :   as2 = TYPE_ADDR_SPACE (element_type);
    7096    326013714 :   address_space = ADDR_SPACE_GENERIC_P (as1)? as2 : as1;
    7097              : 
    7098    326013714 :   if (constp > 1)
    7099           25 :     pedwarn_c90 (loc, OPT_Wpedantic, "duplicate %<const%>");
    7100    326013714 :   if (restrictp > 1)
    7101            6 :     pedwarn_c90 (loc, OPT_Wpedantic, "duplicate %<restrict%>");
    7102    326013714 :   if (volatilep > 1)
    7103           15 :     pedwarn_c90 (loc, OPT_Wpedantic, "duplicate %<volatile%>");
    7104    326013714 :   if (atomicp > 1)
    7105            9 :     pedwarn_c90 (loc, OPT_Wpedantic, "duplicate %<_Atomic%>");
    7106              : 
    7107    326013714 :   if (!ADDR_SPACE_GENERIC_P (as1) && !ADDR_SPACE_GENERIC_P (as2) && as1 != as2)
    7108            0 :     error_at (loc, "conflicting named address spaces (%s vs %s)",
    7109              :               c_addr_space_name (as1), c_addr_space_name (as2));
    7110              : 
    7111    326013714 :   if ((TREE_CODE (type) == ARRAY_TYPE
    7112    325835525 :        || first_non_attr_kind == cdk_array)
    7113    327103211 :       && TYPE_QUALS (element_type))
    7114              :     {
    7115           73 :       orig_qual_type = type;
    7116           73 :       type = c_build_qualified_type (type, TYPE_UNQUALIFIED);
    7117              :     }
    7118    652027428 :   type_quals = {(constp ? TYPE_QUAL_CONST : TYPE_UNQUALIFIED)
    7119              :                 | (restrictp ? TYPE_QUAL_RESTRICT : TYPE_UNQUALIFIED)
    7120              :                 | (volatilep ? TYPE_QUAL_VOLATILE : TYPE_UNQUALIFIED)
    7121              :                 | (atomicp ? TYPE_QUAL_ATOMIC : TYPE_UNQUALIFIED),
    7122   1616690359 :                 address_space};
    7123    638677236 :   if (type_quals != TYPE_QUALS (element_type))
    7124    326013714 :     orig_qual_type = NULL_TREE;
    7125              : 
    7126              :   /* Applying the _Atomic qualifier to an array type (through the use
    7127              :      of typedefs or typeof) must be detected here.  If the qualifier
    7128              :      is introduced later, any appearance of applying it to an array is
    7129              :      actually applying it to an element of that array.  */
    7130    326013714 :   if (declspecs->atomic_p && TREE_CODE (type) == ARRAY_TYPE)
    7131            6 :     error_at (loc, "%<_Atomic%>-qualified array type");
    7132              : 
    7133              :   /* Warn about storage classes that are invalid for certain
    7134              :      kinds of declarations (parameters, typenames, etc.).  */
    7135              : 
    7136    326013714 :   if (funcdef_flag
    7137     37713992 :       && (threadp
    7138     37713992 :           || constexprp
    7139     37713990 :           || storage_class == csc_auto
    7140     37713990 :           || storage_class == csc_register
    7141     37713945 :           || storage_class == csc_typedef))
    7142              :     {
    7143           47 :       if (storage_class == csc_auto)
    7144           42 :         pedwarn (loc,
    7145           81 :                  (current_scope == file_scope) ? 0 : OPT_Wpedantic,
    7146              :                  "function definition declared %<auto%>");
    7147           50 :       if (storage_class == csc_register)
    7148            3 :         error_at (loc, "function definition declared %<register%>");
    7149           50 :       if (storage_class == csc_typedef)
    7150            3 :         error_at (loc, "function definition declared %<typedef%>");
    7151           50 :       if (threadp)
    7152            2 :         error_at (loc, "function definition declared %qs",
    7153            2 :                   declspecs->thread_gnu_p ? "__thread" : "_Thread_local");
    7154           50 :       threadp = false;
    7155              :       /* The parser ensures a constexpr function definition never
    7156              :          reaches here.  */
    7157           50 :       gcc_assert (!constexprp);
    7158           50 :       if (storage_class == csc_auto
    7159           50 :           || storage_class == csc_register
    7160              :           || storage_class == csc_typedef)
    7161    326013714 :         storage_class = csc_none;
    7162              :     }
    7163    326013664 :   else if (decl_context != NORMAL && (storage_class != csc_none
    7164    259524259 :                                       || threadp
    7165    259523676 :                                       || constexprp
    7166    259523674 :                                       || declspecs->c23_auto_p))
    7167              :     {
    7168          587 :       if (decl_context == PARM
    7169          587 :           && storage_class == csc_register
    7170          568 :           && !constexprp
    7171          566 :           && !declspecs->c23_auto_p)
    7172              :         ;
    7173              :       else
    7174              :         {
    7175           21 :           switch (decl_context)
    7176              :             {
    7177            0 :             case FIELD:
    7178            0 :               if (name)
    7179            0 :                 error_at (loc, "storage class specified for structure "
    7180              :                           "field %qE", name);
    7181              :               else
    7182            0 :                 error_at (loc, "storage class specified for structure field");
    7183              :               break;
    7184           21 :             case PARM:
    7185           21 :               if (name)
    7186            7 :                 error_at (loc, "storage class specified for parameter %qE",
    7187              :                           name);
    7188              :               else
    7189           14 :                 error_at (loc, "storage class specified for unnamed parameter");
    7190              :               break;
    7191            0 :             default:
    7192            0 :               error_at (loc, "storage class specified for typename");
    7193            0 :               break;
    7194              :             }
    7195    326013714 :           storage_class = csc_none;
    7196    326013714 :           threadp = false;
    7197    326013714 :           constexprp = false;
    7198              :         }
    7199              :     }
    7200    326013077 :   else if (storage_class == csc_extern
    7201    326013077 :            && initialized
    7202     36835950 :            && !funcdef_flag)
    7203              :     {
    7204              :       /* 'extern' with initialization is invalid if not at file scope.  */
    7205           28 :        if (current_scope == file_scope)
    7206              :          {
    7207              :            /* It is fine to have 'extern const' when compiling at C
    7208              :               and C++ intersection.  */
    7209           19 :            if (!(warn_cxx_compat && constp))
    7210           18 :              warning_at (loc, 0, "%qE initialized and declared %<extern%>",
    7211              :                          name);
    7212              :          }
    7213              :       else
    7214            9 :         error_at (loc, "%qE has both %<extern%> and initializer", name);
    7215              :     }
    7216    326013049 :   else if (current_scope == file_scope)
    7217              :     {
    7218     63588614 :       if (storage_class == csc_auto)
    7219            7 :         error_at (loc, "file-scope declaration of %qE specifies %<auto%>",
    7220              :                   name);
    7221     63588614 :       if (pedantic && storage_class == csc_register)
    7222            4 :         pedwarn (input_location, OPT_Wpedantic,
    7223              :                  "file-scope declaration of %qE specifies %<register%>", name);
    7224              :     }
    7225              :   else
    7226              :     {
    7227    262424435 :       if (storage_class == csc_extern && funcdef_flag)
    7228            3 :         error_at (loc, "nested function %qE declared %<extern%>", name);
    7229    262424432 :       else if (threadp && storage_class == csc_none)
    7230              :         {
    7231           14 :           error_at (loc, "function-scope %qE implicitly auto and declared "
    7232              :                     "%qs", name,
    7233            7 :                     declspecs->thread_gnu_p ? "__thread" : "_Thread_local");
    7234            7 :           threadp = false;
    7235              :         }
    7236              :     }
    7237              : 
    7238              :   /* Now figure out the structure of the declarator proper.
    7239              :      Descend through it, creating more complex types, until we reach
    7240              :      the declared identifier (or NULL_TREE, in an absolute declarator).
    7241              :      At each stage we maintain an unqualified version of the type
    7242              :      together with any qualifiers that should be applied to it with
    7243              :      c_build_qualified_type; this way, array types including
    7244              :      multidimensional array types are first built up in unqualified
    7245              :      form and then the qualified form is created with
    7246              :      TYPE_MAIN_VARIANT pointing to the unqualified form.  */
    7247              : 
    7248    398681043 :   while (declarator && declarator->kind != cdk_id)
    7249              :     {
    7250     72667329 :       if (type == error_mark_node)
    7251              :         {
    7252           39 :           declarator = declarator->declarator;
    7253           39 :           continue;
    7254              :         }
    7255              : 
    7256              :       /* Each level of DECLARATOR is either a cdk_array (for ...[..]),
    7257              :          a cdk_pointer (for *...),
    7258              :          a cdk_function (for ...(...)),
    7259              :          a cdk_attrs (for nested attributes),
    7260              :          or a cdk_id (for the name being declared
    7261              :          or the place in an absolute declarator
    7262              :          where the name was omitted).
    7263              :          For the last case, we have just exited the loop.
    7264              : 
    7265              :          At this point, TYPE is the type of elements of an array,
    7266              :          or for a function to return, or for a pointer to point to.
    7267              :          After this sequence of ifs, TYPE is the type of the
    7268              :          array or function or pointer, and DECLARATOR has had its
    7269              :          outermost layer removed.  */
    7270              : 
    7271     72667290 :       if (array_ptr_quals != TYPE_UNQUALIFIED
    7272     72667290 :           || array_ptr_attrs != NULL_TREE
    7273     72667290 :           || array_parm_static)
    7274              :         {
    7275              :           /* Only the innermost declarator (making a parameter be of
    7276              :              array type which is converted to pointer type)
    7277              :              may have static or type qualifiers.  */
    7278            1 :           error_at (loc, "static or type qualifiers in non-parameter array declarator");
    7279            1 :           array_ptr_quals = TYPE_UNQUALIFIED;
    7280            1 :           array_ptr_attrs = NULL_TREE;
    7281            1 :           array_parm_static = false;
    7282              :         }
    7283              : 
    7284     72667290 :       switch (declarator->kind)
    7285              :         {
    7286         6884 :         case cdk_attrs:
    7287         6884 :           {
    7288              :             /* A declarator with embedded attributes.  */
    7289         6884 :             tree attrs = declarator->u.attrs;
    7290         6884 :             const struct c_declarator *inner_decl;
    7291         6884 :             int attr_flags = 0;
    7292         6884 :             declarator = declarator->declarator;
    7293              :             /* Standard attribute syntax precisely defines what entity
    7294              :                an attribute in each position appertains to, so only
    7295              :                apply laxity about positioning to GNU attribute syntax.
    7296              :                Standard attributes applied to a function or array
    7297              :                declarator apply exactly to that type; standard
    7298              :                attributes applied to the identifier apply to the
    7299              :                declaration rather than to the type, and are specified
    7300              :                using a cdk_id declarator rather than using
    7301              :                cdk_attrs.  */
    7302         6884 :             inner_decl = declarator;
    7303         6884 :             while (inner_decl->kind == cdk_attrs)
    7304            0 :               inner_decl = inner_decl->declarator;
    7305         6884 :             if (!cxx11_attribute_p (attrs))
    7306              :               {
    7307         6746 :                 if (inner_decl->kind == cdk_id)
    7308              :                   attr_flags |= (int) ATTR_FLAG_DECL_NEXT;
    7309              :                 else if (inner_decl->kind == cdk_function)
    7310              :                   attr_flags |= (int) ATTR_FLAG_FUNCTION_NEXT;
    7311              :                 else if (inner_decl->kind == cdk_array)
    7312         6884 :                   attr_flags |= (int) ATTR_FLAG_ARRAY_NEXT;
    7313              :               }
    7314         6884 :             attrs = c_warn_type_attributes (type, attrs);
    7315         6884 :             returned_attrs = decl_attributes (&type,
    7316              :                                               chainon (returned_attrs, attrs),
    7317              :                                               attr_flags);
    7318         6884 :             break;
    7319              :           }
    7320      1158536 :         case cdk_array:
    7321      1158536 :           {
    7322      1158536 :             tree itype = NULL_TREE;
    7323      1158536 :             tree size = declarator->u.array.dimen;
    7324              :             /* The index is a signed object `sizetype' bits wide.  */
    7325      1158536 :             tree index_type = c_common_signed_type (sizetype);
    7326              : 
    7327      1158536 :             array_ptr_quals = declarator->u.array.quals;
    7328      1158536 :             array_ptr_attrs = declarator->u.array.attrs;
    7329      1158536 :             array_parm_static = declarator->u.array.static_p;
    7330      1158536 :             array_parm_vla_unspec_p = declarator->u.array.vla_unspec_p;
    7331              : 
    7332      1158536 :             declarator = declarator->declarator;
    7333              : 
    7334      1158536 :             bool flexible_array_member = false;
    7335              : 
    7336              :             /* Check for some types that there cannot be arrays of.  */
    7337              : 
    7338      1158536 :             if (VOID_TYPE_P (type))
    7339              :               {
    7340           11 :                 if (name)
    7341            9 :                   error_at (loc, "declaration of %qE as array of voids", name);
    7342              :                 else
    7343            2 :                   error_at (loc, "declaration of type name as array of voids");
    7344           11 :                 type = error_mark_node;
    7345              :               }
    7346              : 
    7347      1158536 :             if (TREE_CODE (type) == FUNCTION_TYPE)
    7348              :               {
    7349            3 :                 if (name)
    7350            2 :                   error_at (loc, "declaration of %qE as array of functions",
    7351              :                             name);
    7352              :                 else
    7353            1 :                   error_at (loc, "declaration of type name as array of "
    7354              :                             "functions");
    7355            3 :                 type = error_mark_node;
    7356              :               }
    7357              : 
    7358        21390 :             if (pedantic && !in_system_header_at (input_location)
    7359      1173608 :                 && flexible_array_type_p (type))
    7360           20 :               pedwarn (loc, OPT_Wpedantic,
    7361              :                        "invalid use of structure with flexible array member");
    7362              : 
    7363      1158536 :             if (size == error_mark_node)
    7364          119 :               type = error_mark_node;
    7365              : 
    7366      1158536 :             if (type == error_mark_node)
    7367          133 :               continue;
    7368              : 
    7369      1158403 :             if (!verify_type_context (loc, TCTX_ARRAY_ELEMENT, type))
    7370              :               {
    7371            0 :                 type = error_mark_node;
    7372            0 :                 continue;
    7373              :               }
    7374              : 
    7375              :             /* If size was specified, set ITYPE to a range-type for
    7376              :                that size.  Otherwise, ITYPE remains null.  finish_decl
    7377              :                may figure it out from an initial value.  */
    7378              : 
    7379      1158403 :             if (size)
    7380              :               {
    7381       985351 :                 bool size_maybe_const = true;
    7382       985351 :                 bool size_int_const = (TREE_CODE (size) == INTEGER_CST
    7383       985351 :                                        && !TREE_OVERFLOW (size));
    7384       985351 :                 bool this_size_varies = false;
    7385              : 
    7386              :                 /* Strip NON_LVALUE_EXPRs since we aren't using as an
    7387              :                    lvalue.  */
    7388       985360 :                 STRIP_TYPE_NOPS (size);
    7389              : 
    7390       985351 :                 if (!INTEGRAL_TYPE_P (TREE_TYPE (size)))
    7391              :                   {
    7392           16 :                     if (name)
    7393           14 :                       error_at (loc, "size of array %qE has non-integer type",
    7394              :                                 name);
    7395              :                     else
    7396            2 :                       error_at (loc,
    7397              :                                 "size of unnamed array has non-integer type");
    7398           16 :                     size = integer_one_node;
    7399           16 :                     size_int_const = true;
    7400           16 :                     size_error = true;
    7401              :                   }
    7402              :                 /* This can happen with enum forward declaration.  */
    7403       985335 :                 else if (!COMPLETE_TYPE_P (TREE_TYPE (size)))
    7404              :                   {
    7405            0 :                     if (name)
    7406            0 :                       error_at (loc, "size of array %qE has incomplete type",
    7407              :                                 name);
    7408              :                     else
    7409            0 :                       error_at (loc, "size of unnamed array has incomplete "
    7410              :                                 "type");
    7411            0 :                     size = integer_one_node;
    7412            0 :                     size_int_const = true;
    7413            0 :                     size_error = true;
    7414              :                   }
    7415              : 
    7416       985351 :                 size = c_fully_fold (size, false, &size_maybe_const);
    7417              : 
    7418       985351 :                 if (pedantic && size_maybe_const && integer_zerop (size))
    7419              :                   {
    7420            3 :                     if (name)
    7421            3 :                       pedwarn (loc, OPT_Wpedantic,
    7422              :                                "ISO C forbids zero-size array %qE", name);
    7423              :                     else
    7424            0 :                       pedwarn (loc, OPT_Wpedantic,
    7425              :                                "ISO C forbids zero-size array");
    7426              :                   }
    7427              : 
    7428       985351 :                 if (TREE_CODE (size) == INTEGER_CST && size_maybe_const)
    7429              :                   {
    7430       962981 :                     constant_expression_warning (size);
    7431       962981 :                     if (tree_int_cst_sgn (size) < 0)
    7432              :                       {
    7433          509 :                         if (name)
    7434          506 :                           error_at (loc, "size of array %qE is negative", name);
    7435              :                         else
    7436            3 :                           error_at (loc, "size of unnamed array is negative");
    7437          509 :                         size = integer_one_node;
    7438          509 :                         size_int_const = true;
    7439          509 :                         size_error = true;
    7440              :                       }
    7441              :                     /* Handle a size folded to an integer constant but
    7442              :                        not an integer constant expression.  */
    7443       962981 :                     if (!size_int_const)
    7444              :                       {
    7445              :                         /* If this is a file scope declaration of an
    7446              :                            ordinary identifier, this is invalid code;
    7447              :                            diagnosing it here and not subsequently
    7448              :                            treating the type as variable-length avoids
    7449              :                            more confusing diagnostics later.  */
    7450          155 :                         if ((decl_context == NORMAL || decl_context == FIELD)
    7451          142 :                             && current_scope == file_scope)
    7452           14 :                           pedwarn (input_location, 0,
    7453              :                                    "variably modified %qE at file scope",
    7454              :                                    name);
    7455              :                         else
    7456              :                           this_size_varies = size_varies = true;
    7457          155 :                         warn_variable_length_array (name, size);
    7458              :                       }
    7459              :                   }
    7460        22370 :                 else if ((decl_context == NORMAL || decl_context == FIELD)
    7461        13268 :                          && current_scope == file_scope)
    7462              :                   {
    7463           21 :                     error_at (loc, "variably modified %qE at file scope", name);
    7464           21 :                     size = integer_one_node;
    7465              :                   }
    7466              :                 else
    7467              :                   {
    7468              :                     /* Make sure the array size remains visibly
    7469              :                        nonconstant even if it is (eg) a const variable
    7470              :                        with known value.  */
    7471        22349 :                     this_size_varies = size_varies = true;
    7472        22349 :                     warn_variable_length_array (name, size);
    7473        22349 :                     if (sanitize_flags_p (SANITIZE_VLA)
    7474          181 :                         && current_function_decl != NULL_TREE
    7475        22512 :                         && decl_context == NORMAL)
    7476              :                       {
    7477              :                         /* Evaluate the array size only once.  */
    7478          155 :                         size = save_expr (size);
    7479          155 :                         size = c_fully_fold (size, false, NULL);
    7480          155 :                         size = fold_build2 (COMPOUND_EXPR, TREE_TYPE (size),
    7481              :                                             ubsan_instrument_vla (loc, size),
    7482              :                                             size);
    7483              :                       }
    7484              :                   }
    7485              : 
    7486       985351 :                 if (integer_zerop (size) && !this_size_varies)
    7487              :                   {
    7488              :                     /* A zero-length array cannot be represented with
    7489              :                        an unsigned index type, which is what we'll
    7490              :                        get with build_index_type.  Create an
    7491              :                        open-ended range instead.  */
    7492         2622 :                     itype = build_index_type (NULL_TREE);
    7493              :                   }
    7494              :                 else
    7495              :                   {
    7496              :                     /* Arrange for the SAVE_EXPR on the inside of the
    7497              :                        MINUS_EXPR, which allows the -1 to get folded
    7498              :                        with the +1 that happens when building TYPE_SIZE.  */
    7499       982729 :                     if (size_varies)
    7500        22865 :                       size = save_expr (size);
    7501       982729 :                     if (this_size_varies && TREE_CODE (size) == INTEGER_CST)
    7502          141 :                       size = build2 (COMPOUND_EXPR, TREE_TYPE (size),
    7503              :                                      integer_zero_node, size);
    7504              : 
    7505              :                     /* Compute the maximum valid index, that is, size
    7506              :                        - 1.  Do the calculation in index_type, so that
    7507              :                        if it is a variable the computations will be
    7508              :                        done in the proper mode.  */
    7509       982729 :                     itype = fold_build2_loc (loc, MINUS_EXPR, index_type,
    7510              :                                              convert (index_type, size),
    7511              :                                              convert (index_type,
    7512              :                                                       size_one_node));
    7513              : 
    7514              :                     /* The above overflows when size does not fit
    7515              :                        in index_type.
    7516              :                        ???  While a size of INT_MAX+1 technically shouldn't
    7517              :                        cause an overflow (because we subtract 1), handling
    7518              :                        this case seems like an unnecessary complication.  */
    7519       982729 :                     if (TREE_CODE (size) == INTEGER_CST
    7520       960239 :                         && !int_fits_type_p (size, index_type))
    7521              :                       {
    7522            6 :                         if (name)
    7523            5 :                           error_at (loc, "size of array %qE is too large",
    7524              :                                     name);
    7525              :                         else
    7526            1 :                           error_at (loc, "size of unnamed array is too large");
    7527            6 :                         type = error_mark_node;
    7528            6 :                         continue;
    7529              :                       }
    7530              : 
    7531       982723 :                     itype = build_index_type (itype);
    7532              :                   }
    7533       985345 :                 if (this_size_varies)
    7534              :                   {
    7535        22490 :                     if (TREE_SIDE_EFFECTS (size))
    7536              :                       {
    7537        22126 :                         if (*expr)
    7538         8178 :                           *expr = build2 (COMPOUND_EXPR, TREE_TYPE (size),
    7539              :                                           *expr, size);
    7540              :                         else
    7541        13948 :                           *expr = size;
    7542              :                       }
    7543        22490 :                     *expr_const_operands &= size_maybe_const;
    7544              :                   }
    7545              :               }
    7546       173052 :             else if (decl_context == FIELD)
    7547              :               {
    7548        86070 :                 if (array_parm_vla_unspec_p)
    7549              :                   /* Field names can in fact have function prototype
    7550              :                      scope so [*] is disallowed here through making
    7551              :                      the field variably modified, not through being
    7552              :                      something other than a declaration with function
    7553              :                      prototype scope.  */
    7554              :                   size_varies = true;
    7555              :                 else
    7556              :                   {
    7557              :                     const struct c_declarator *t = declarator;
    7558        86067 :                     while (t->kind == cdk_attrs)
    7559            0 :                       t = t->declarator;
    7560        86067 :                     flexible_array_member = (t->kind == cdk_id);
    7561              :                   }
    7562        86067 :                 if (flexible_array_member
    7563        86067 :                     && !in_system_header_at (input_location))
    7564        85035 :                   pedwarn_c90 (loc, OPT_Wpedantic, "ISO C90 does not "
    7565              :                                "support flexible array members");
    7566              : 
    7567              :                 /* ISO C99 Flexible array members are effectively
    7568              :                    identical to GCC's zero-length array extension.  */
    7569        86070 :                 if (flexible_array_member)
    7570        86047 :                   itype = build_index_type (NULL_TREE);
    7571              :               }
    7572              : 
    7573              :             /* Complain about arrays of incomplete types.  */
    7574      1158397 :             if (!COMPLETE_TYPE_P (type))
    7575              :               {
    7576           58 :                 auto_diagnostic_group d;
    7577           58 :                 error_at (loc, "array type has incomplete element type %qT",
    7578              :                           type);
    7579              :                 /* See if we can be more helpful.  */
    7580           58 :                 if (TREE_CODE (type) == ARRAY_TYPE)
    7581              :                   {
    7582           29 :                     if (name)
    7583           24 :                       inform (loc, "declaration of %qE as multidimensional "
    7584              :                               "array must have bounds for all dimensions "
    7585              :                               "except the first", name);
    7586              :                     else
    7587            5 :                       inform (loc, "declaration of multidimensional array "
    7588              :                               "must have bounds for all dimensions except "
    7589              :                               "the first");
    7590              :                   }
    7591           58 :                 type = error_mark_node;
    7592           58 :               }
    7593              :             else
    7594              :             /* When itype is NULL, a shared incomplete array type is
    7595              :                returned for all array of a given type.  Elsewhere we
    7596              :                make sure we don't complete that type before copying
    7597              :                it, but here we want to make sure we don't ever
    7598              :                modify the shared type, so we gcc_assert (itype)
    7599              :                below.  */
    7600              :               {
    7601      1158339 :                 addr_space_t as = type_quals.addr_space ();
    7602      1158339 :                 if (!ADDR_SPACE_GENERIC_P (as) && as != TYPE_ADDR_SPACE (type))
    7603            0 :                   type = c_build_qualified_type (type,
    7604              :                                                  {TYPE_UNQUALIFIED, as});
    7605      1158339 :                 if (array_parm_vla_unspec_p)
    7606          151 :                   type = c_build_array_type_unspecified (type);
    7607              :                 /* The GCC extension for zero-length arrays differs from
    7608              :                    ISO flexible array members in that sizeof yields
    7609              :                    zero.  */
    7610      1158188 :                 else if (size && integer_zerop (size))
    7611         2615 :                   type = c_build_array_type_zero_size (type);
    7612              :                 else
    7613      1155573 :                   type = c_build_array_type (type, itype);
    7614              : 
    7615      1158339 :                 if (!valid_array_size_p (loc, type, name))
    7616           33 :                   type = error_mark_node;
    7617              :               }
    7618              : 
    7619      1158397 :             if (array_parm_vla_unspec_p)
    7620              :               {
    7621              :                 /* C99 6.7.5.2p4 */
    7622          151 :                 if (decl_context == TYPENAME)
    7623            6 :                   warning (0, "%<[*]%> not in a declaration");
    7624          145 :                 else if (decl_context != GENERIC_ASSOC
    7625          145 :                          && decl_context != PARM
    7626            7 :                          && decl_context != FIELD)
    7627              :                   {
    7628            4 :                     error ("%<[*]%> not allowed in other than function prototype scope "
    7629              :                            "or generic association");
    7630            4 :                     type = error_mark_node;
    7631              :                   }
    7632              :                 size_varies = true;
    7633              :               }
    7634              : 
    7635              : 
    7636      1158397 :             gcc_assert (type == error_mark_node
    7637              :                         || flexible_array_member
    7638              :                            == flexible_array_member_type_p (type));
    7639              : 
    7640      1158397 :             if (decl_context != PARM
    7641      1158397 :                 && (array_ptr_quals != TYPE_UNQUALIFIED
    7642       834657 :                     || array_ptr_attrs != NULL_TREE
    7643       834657 :                     || array_parm_static))
    7644              :               {
    7645            2 :                 error_at (loc, "static or type qualifiers in non-parameter "
    7646              :                           "array declarator");
    7647            2 :                 array_ptr_quals = TYPE_UNQUALIFIED;
    7648            2 :                 array_ptr_attrs = NULL_TREE;
    7649            2 :                 array_parm_static = false;
    7650              :               }
    7651      1158397 :             orig_qual_indirect++;
    7652      1158397 :             break;
    7653              :           }
    7654     52661127 :         case cdk_function:
    7655     52661127 :           {
    7656              :             /* Say it's a definition only for the declarator closest
    7657              :                to the identifier, apart possibly from some
    7658              :                attributes.  */
    7659     52661127 :             bool really_funcdef = false;
    7660     52661127 :             tree arg_types;
    7661     52661127 :             orig_qual_type = NULL_TREE;
    7662     52661127 :             if (funcdef_flag)
    7663              :               {
    7664     37714015 :                 const struct c_declarator *t = declarator->declarator;
    7665     37714065 :                 while (t->kind == cdk_attrs)
    7666           50 :                   t = t->declarator;
    7667     37714015 :                 really_funcdef = (t->kind == cdk_id);
    7668              :               }
    7669              : 
    7670              :             /* Declaring a function type.  Make sure we have a valid
    7671              :                type for the function to return.  */
    7672     52661127 :             if (type == error_mark_node)
    7673            0 :               continue;
    7674              : 
    7675     52661127 :             size_varies = false;
    7676              : 
    7677              :             /* Warn about some types functions can't return.  */
    7678     52661127 :             if (TREE_CODE (type) == FUNCTION_TYPE)
    7679              :               {
    7680            0 :                 if (name)
    7681            0 :                   error_at (loc, "%qE declared as function returning a "
    7682              :                                  "function", name);
    7683              :                 else
    7684            0 :                   error_at (loc, "type name declared as function "
    7685              :                             "returning a function");
    7686            0 :                 type = integer_type_node;
    7687              :               }
    7688     52661127 :             if (TREE_CODE (type) == ARRAY_TYPE)
    7689              :               {
    7690            0 :                 if (name)
    7691            0 :                   error_at (loc, "%qE declared as function returning an array",
    7692              :                             name);
    7693              :                 else
    7694            0 :                   error_at (loc, "type name declared as function returning "
    7695              :                             "an array");
    7696            0 :                 type = integer_type_node;
    7697              :               }
    7698              : 
    7699              :             /* Construct the function type and go to the next
    7700              :                inner layer of declarator.  */
    7701     52661127 :             arg_info = declarator->u.arg_info;
    7702     52661127 :             arg_types = grokparms (arg_info, really_funcdef);
    7703              : 
    7704              :             /* Type qualifiers before the return type of the function
    7705              :                qualify the return type, not the function type.  */
    7706     52661127 :             if (type_quals)
    7707              :               {
    7708          235 :                 const enum c_declspec_word ignored_quals_list[] =
    7709              :                   {
    7710              :                     cdw_const, cdw_volatile, cdw_restrict, cdw_address_space,
    7711              :                     cdw_atomic, cdw_number_of_elements
    7712              :                   };
    7713          235 :                 location_t specs_loc
    7714          235 :                   = smallest_type_quals_location (declspecs->locations,
    7715              :                                                   ignored_quals_list);
    7716          235 :                 if (specs_loc == UNKNOWN_LOCATION)
    7717          139 :                   specs_loc = declspecs->locations[cdw_typedef];
    7718          139 :                 if (specs_loc == UNKNOWN_LOCATION)
    7719           15 :                   specs_loc = loc;
    7720              : 
    7721              :                 /* Type qualifiers on a function return type are
    7722              :                    normally permitted by the standard but have no
    7723              :                    effect, so give a warning at -Wreturn-type.
    7724              :                    Qualifiers on a void return type are banned on
    7725              :                    function definitions in ISO C; GCC used to used
    7726              :                    them for noreturn functions.  The resolution of C11
    7727              :                    DR#423 means qualifiers (other than _Atomic) are
    7728              :                    actually removed from the return type when
    7729              :                    determining the function type.  For C23, _Atomic is
    7730              :                    removed as well.  */
    7731          235 :                 auto quals_used = type_quals;
    7732          235 :                 if (flag_isoc23)
    7733              :                   quals_used = qualifier_set {};
    7734           65 :                 else if (flag_isoc11)
    7735           31 :                   quals_used = quals_used.intersect (TYPE_QUAL_ATOMIC);
    7736          235 :                 if (quals_used && VOID_TYPE_P (type) && really_funcdef)
    7737            5 :                   pedwarn (specs_loc, 0,
    7738              :                            "function definition has qualified void "
    7739              :                            "return type");
    7740              :                 else
    7741          230 :                   warning_at (specs_loc, OPT_Wignored_qualifiers,
    7742              :                               "type qualifiers ignored on function "
    7743              :                               "return type");
    7744              : 
    7745              :                 /* Ensure an error for restrict on invalid types; the
    7746              :                    DR#423 resolution is not entirely clear about
    7747              :                    this.  */
    7748          235 :                 if (flag_isoc11
    7749          201 :                     && (type_quals.has (TYPE_QUAL_RESTRICT))
    7750          241 :                     && (!POINTER_TYPE_P (type)
    7751            4 :                         || !C_TYPE_OBJECT_OR_INCOMPLETE_P (TREE_TYPE (type))))
    7752            4 :                   error_at (loc, "invalid use of %<restrict%>");
    7753          235 :                 type = c_build_qualified_type (type, quals_used);
    7754              :               }
    7755     52661127 :             type_quals = TYPE_UNQUALIFIED;
    7756              : 
    7757     52661127 :             type = c_build_function_type (type, arg_types,
    7758              :                                           arg_info->no_named_args_stdarg_p);
    7759     52661127 :             declarator = declarator->declarator;
    7760              : 
    7761              :             /* Set the TYPE_CONTEXTs for each tagged type which is local to
    7762              :                the formal parameter list of this FUNCTION_TYPE to point to
    7763              :                the FUNCTION_TYPE node itself.  */
    7764     52661127 :             {
    7765     52661127 :               c_arg_tag *tag;
    7766     52661127 :               unsigned ix;
    7767              : 
    7768    451342449 :               FOR_EACH_VEC_SAFE_ELT_REVERSE (arg_info->tags, ix, tag)
    7769          142 :                 TYPE_CONTEXT (tag->type) = type;
    7770              :             }
    7771              :             break;
    7772              :           }
    7773     18840743 :         case cdk_pointer:
    7774     18840743 :           {
    7775              :             /* Merge any constancy or volatility into the target type
    7776              :                for the pointer.  */
    7777     18840743 :             if (type_quals.has (TYPE_QUAL_ATOMIC)
    7778     18840743 :                 && TREE_CODE (type) == FUNCTION_TYPE)
    7779              :               {
    7780            2 :                 error_at (loc,
    7781              :                           "%<_Atomic%>-qualified function type");
    7782            2 :                 type_quals = type_quals.without (TYPE_QUAL_ATOMIC);
    7783              :               }
    7784       251917 :             else if (pedantic && TREE_CODE (type) == FUNCTION_TYPE
    7785     18840741 :                      && type_quals)
    7786            0 :               pedwarn (loc, OPT_Wpedantic,
    7787              :                        "ISO C forbids qualified function types");
    7788     18840743 :             if (type_quals)
    7789      6247331 :               type = c_build_qualified_type (type, type_quals, orig_qual_type,
    7790              :                                              orig_qual_indirect);
    7791     18840743 :             orig_qual_type = NULL_TREE;
    7792     18840743 :             size_varies = false;
    7793              : 
    7794              :             /* When the pointed-to type involves components of variable size,
    7795              :                care must be taken to ensure that the size evaluation code is
    7796              :                emitted early enough to dominate all the possible later uses
    7797              :                and late enough for the variables on which it depends to have
    7798              :                been assigned.
    7799              : 
    7800              :                This is expected to happen automatically when the pointed-to
    7801              :                type has a name/declaration of it's own, but special attention
    7802              :                is required if the type is anonymous. */
    7803     18840743 :             if (!TYPE_NAME (type) && c_type_variably_modified_p (type))
    7804              :               {
    7805         5951 :                 bool bind_p = decl_context == TYPENAME
    7806              :                               || decl_context == FIELD
    7807         5951 :                               || decl_context == PARM;
    7808        11394 :                 add_decl_expr (loc, type, bind_p ? expr : NULL, true);
    7809              :               }
    7810              : 
    7811     18840743 :             type = c_build_pointer_type (type);
    7812              : 
    7813              :             /* Process type qualifiers (such as const or volatile)
    7814              :                that were given inside the `*'.  */
    7815     18840743 :             type_quals = declarator->u.pointer_quals;
    7816              : 
    7817     18840743 :             declarator = declarator->declarator;
    7818     18840743 :             break;
    7819              :           }
    7820            0 :         default:
    7821            0 :           gcc_unreachable ();
    7822              :         }
    7823              :     }
    7824    326013714 :   *decl_attrs = chainon (returned_attrs, *decl_attrs);
    7825    326013714 :   *decl_attrs = chainon (decl_id_attrs, *decl_attrs);
    7826              : 
    7827              :   /* Now TYPE has the actual type, apart from any qualifiers in
    7828              :      TYPE_QUALS.  */
    7829              : 
    7830              :   /* Warn about address space used for things other than static memory or
    7831              :      pointers.  */
    7832    326013714 :   address_space = type_quals.addr_space ();
    7833    326013714 :   if (!ADDR_SPACE_GENERIC_P (address_space))
    7834              :     {
    7835           10 :       if (decl_context == NORMAL)
    7836              :         {
    7837           10 :           switch (storage_class)
    7838              :             {
    7839            0 :             case csc_auto:
    7840            0 :               error ("%qs combined with %<auto%> qualifier for %qE",
    7841              :                      c_addr_space_name (address_space), name);
    7842            0 :               break;
    7843            0 :             case csc_register:
    7844            0 :               error ("%qs combined with %<register%> qualifier for %qE",
    7845              :                      c_addr_space_name (address_space), name);
    7846            0 :               break;
    7847            6 :             case csc_none:
    7848            6 :               if (current_function_scope)
    7849              :                 {
    7850            0 :                   error ("%qs specified for auto variable %qE",
    7851              :                          c_addr_space_name (address_space), name);
    7852            0 :                   break;
    7853              :                 }
    7854              :               break;
    7855              :             case csc_static:
    7856              :             case csc_extern:
    7857              :             case csc_typedef:
    7858              :               break;
    7859            0 :             default:
    7860            0 :               gcc_unreachable ();
    7861              :             }
    7862              :         }
    7863            0 :       else if (decl_context == PARM && TREE_CODE (type) != ARRAY_TYPE)
    7864              :         {
    7865            0 :           if (name)
    7866            0 :             error ("%qs specified for parameter %qE",
    7867              :                    c_addr_space_name (address_space), name);
    7868              :           else
    7869            0 :             error ("%qs specified for unnamed parameter",
    7870              :                    c_addr_space_name (address_space));
    7871              :         }
    7872            0 :       else if (decl_context == FIELD)
    7873              :         {
    7874            0 :           if (name)
    7875            0 :             error ("%qs specified for structure field %qE",
    7876              :                    c_addr_space_name (address_space), name);
    7877              :           else
    7878            0 :             error ("%qs specified for structure field",
    7879              :                    c_addr_space_name (address_space));
    7880              :         }
    7881              :     }
    7882              : 
    7883              :   /* Check the type and width of a bit-field.  */
    7884    326013714 :   if (bitfield)
    7885              :     {
    7886        55230 :       check_bitfield_type_and_width (loc, &type, width, name);
    7887              :       /* C11 makes it implementation-defined (6.7.2.1#5) whether
    7888              :          atomic types are permitted for bit-fields; we have no code to
    7889              :          make bit-field accesses atomic, so disallow them.  */
    7890        55230 :       if (type_quals.has (TYPE_QUAL_ATOMIC))
    7891              :         {
    7892            2 :           if (name)
    7893            1 :             error_at (loc, "bit-field %qE has atomic type", name);
    7894              :           else
    7895            1 :             error_at (loc, "bit-field has atomic type");
    7896            2 :           type_quals = type_quals.without (TYPE_QUAL_ATOMIC);
    7897              :         }
    7898              :     }
    7899              : 
    7900              :   /* Reject invalid uses of _Alignas.  */
    7901    326013714 :   if (declspecs->alignas_p)
    7902              :     {
    7903          190 :       if (storage_class == csc_typedef)
    7904            1 :         error_at (loc, "alignment specified for typedef %qE", name);
    7905          189 :       else if (storage_class == csc_register)
    7906            1 :         error_at (loc, "alignment specified for %<register%> object %qE",
    7907              :                   name);
    7908          188 :       else if (decl_context == PARM)
    7909              :         {
    7910            2 :           if (name)
    7911            1 :             error_at (loc, "alignment specified for parameter %qE", name);
    7912              :           else
    7913            1 :             error_at (loc, "alignment specified for unnamed parameter");
    7914              :         }
    7915          186 :       else if (bitfield)
    7916              :         {
    7917            0 :           if (name)
    7918            0 :             error_at (loc, "alignment specified for bit-field %qE", name);
    7919              :           else
    7920            0 :             error_at (loc, "alignment specified for unnamed bit-field");
    7921              :         }
    7922          186 :       else if (TREE_CODE (type) == FUNCTION_TYPE)
    7923            1 :         error_at (loc, "alignment specified for function %qE", name);
    7924          185 :       else if (declspecs->align_log != -1 && TYPE_P (type))
    7925              :         {
    7926          158 :           alignas_align = 1U << declspecs->align_log;
    7927          158 :           if (alignas_align < min_align_of_type (type))
    7928              :             {
    7929           26 :               if (name)
    7930           25 :                 error_at (loc, "%<_Alignas%> specifiers cannot reduce "
    7931              :                           "alignment of %qE", name);
    7932              :               else
    7933            1 :                 error_at (loc, "%<_Alignas%> specifiers cannot reduce "
    7934              :                           "alignment of unnamed field");
    7935              :               alignas_align = 0;
    7936              :             }
    7937              :         }
    7938              :     }
    7939              : 
    7940              :   /* If this is declaring a typedef name, return a TYPE_DECL.  */
    7941              : 
    7942    326013714 :   if (storage_class == csc_typedef)
    7943              :     {
    7944      4396259 :       tree decl;
    7945      4396259 :       if ((type_quals.has (TYPE_QUAL_ATOMIC))
    7946      4396259 :           && TREE_CODE (type) == FUNCTION_TYPE)
    7947              :         {
    7948            0 :           error_at (loc,
    7949              :                     "%<_Atomic%>-qualified function type");
    7950            0 :           type_quals = type_quals.without (TYPE_QUAL_ATOMIC);
    7951              :         }
    7952       133642 :       else if (pedantic && TREE_CODE (type) == FUNCTION_TYPE
    7953      4396259 :                && type_quals)
    7954            0 :         pedwarn (loc, OPT_Wpedantic,
    7955              :                  "ISO C forbids qualified function types");
    7956      4396259 :       if (type_quals)
    7957        32149 :         type = c_build_qualified_type (type, type_quals, orig_qual_type,
    7958              :                                        orig_qual_indirect);
    7959      8792518 :       decl = build_decl (declarator->id_loc,
    7960      4396259 :                          TYPE_DECL, declarator->u.id.id, type);
    7961      4396259 :       if (declspecs->explicit_signed_p)
    7962       359924 :         C_TYPEDEF_EXPLICITLY_SIGNED (decl) = 1;
    7963      4396259 :       if (declspecs->inline_p)
    7964            4 :         pedwarn (loc, 0,"typedef %q+D declared %<inline%>", decl);
    7965      4396259 :       if (declspecs->noreturn_p)
    7966            1 :         pedwarn (loc, 0,"typedef %q+D declared %<_Noreturn%>", decl);
    7967              : 
    7968      4396259 :       if (warn_cxx_compat && declarator->u.id.id != NULL_TREE)
    7969              :         {
    7970        43667 :           struct c_binding *b = I_TAG_BINDING (declarator->u.id.id);
    7971              : 
    7972        43667 :           if (b != NULL
    7973         4320 :               && b->decl != NULL_TREE
    7974         4320 :               && (B_IN_CURRENT_SCOPE (b)
    7975            4 :                   || (current_scope == file_scope && B_IN_EXTERNAL_SCOPE (b)))
    7976        47983 :               && TYPE_MAIN_VARIANT (b->decl) != TYPE_MAIN_VARIANT (type))
    7977              :             {
    7978            7 :               auto_diagnostic_group d;
    7979            8 :               if (warning_at (declarator->id_loc, OPT_Wc___compat,
    7980              :                               "using %qD as both a typedef and a tag is "
    7981              :                               "invalid in C++", decl)
    7982            7 :                   && b->locus != UNKNOWN_LOCATION)
    7983            6 :                 inform (b->locus, "originally defined here");
    7984            7 :             }
    7985              :         }
    7986              : 
    7987              :       return decl;
    7988              :     }
    7989              : 
    7990              :   /* If this is a type name (such as, in a cast or sizeof),
    7991              :      compute the type and return it now.  */
    7992              : 
    7993    321617455 :   if (decl_context == TYPENAME || decl_context == GENERIC_ASSOC)
    7994              :     {
    7995              :       /* Note that the grammar rejects storage classes in typenames
    7996              :          and fields.  */
    7997    126566638 :       gcc_assert (storage_class == csc_none && !threadp
    7998              :                   && !declspecs->inline_p && !declspecs->noreturn_p);
    7999    126566638 :       if (type_quals.has (TYPE_QUAL_ATOMIC)
    8000    126566638 :           && TREE_CODE (type) == FUNCTION_TYPE)
    8001              :         {
    8002            0 :           error_at (loc,
    8003              :                     "%<_Atomic%>-qualified function type");
    8004            0 :           type_quals = type_quals.without (TYPE_QUAL_ATOMIC);
    8005              :         }
    8006       308144 :       else if (pedantic && TREE_CODE (type) == FUNCTION_TYPE
    8007    126566638 :                && type_quals)
    8008            0 :         pedwarn (loc, OPT_Wpedantic,
    8009              :                  "ISO C forbids const or volatile function types");
    8010    126566638 :       if (type_quals)
    8011        43134 :         type = c_build_qualified_type (type, type_quals, orig_qual_type,
    8012              :                                        orig_qual_indirect);
    8013    126566638 :       return type;
    8014              :     }
    8015              : 
    8016       396836 :   if (pedantic && decl_context == FIELD
    8017    195073468 :       && c_type_variably_modified_p (type))
    8018              :     {
    8019              :       /* C99 6.7.2.1p8 */
    8020            7 :       pedwarn (loc, OPT_Wpedantic, "a member of a structure or union cannot "
    8021              :                "have a variably modified type");
    8022              :     }
    8023              : 
    8024              :   /* Aside from typedefs and type names (handle above),
    8025              :      `void' at top level (not within pointer)
    8026              :      is allowed only in public variables.
    8027              :      We don't complain about parms either, but that is because
    8028              :      a better error message can be made later.  */
    8029              : 
    8030    195050817 :   if (VOID_TYPE_P (type) && decl_context != PARM
    8031           64 :       && !((decl_context != FIELD && TREE_CODE (type) != FUNCTION_TYPE)
    8032              :             && (storage_class == csc_extern
    8033           27 :                 || (current_scope == file_scope
    8034           18 :                     && !(storage_class == csc_static
    8035              :                          || storage_class == csc_register)))))
    8036              :     {
    8037           15 :       error_at (loc, "variable or field %qE declared void", name);
    8038           15 :       type = integer_type_node;
    8039              :     }
    8040              : 
    8041              :   /* Now create the decl, which may be a VAR_DECL, a PARM_DECL
    8042              :      or a FUNCTION_DECL, depending on DECL_CONTEXT and TYPE.  */
    8043              : 
    8044    194053501 :   {
    8045    194053501 :     tree decl;
    8046              : 
    8047    194053501 :     if (decl_context == PARM)
    8048              :       {
    8049    128573053 :         tree promoted_type;
    8050    128573053 :         bool array_parameter_p = false;
    8051              : 
    8052              :         /* A parameter declared as an array of T is really a pointer to T.
    8053              :            One declared as a function is really a pointer to a function.  */
    8054              : 
    8055    128573053 :         if (TREE_CODE (type) == ARRAY_TYPE)
    8056              :           {
    8057       443670 :             if (!size_error)
    8058       443656 :               *decl_attrs = build_arg_spec_attribute (type, array_parm_static,
    8059              :                                                       *decl_attrs);
    8060              : 
    8061              :             /* Transfer const-ness of array into that of type pointed to.  */
    8062       443670 :             type = TREE_TYPE (type);
    8063       443670 :             if (orig_qual_type != NULL_TREE)
    8064              :               {
    8065            7 :                 if (orig_qual_indirect == 0)
    8066            5 :                   orig_qual_type = TREE_TYPE (orig_qual_type);
    8067              :                 else
    8068            2 :                   orig_qual_indirect--;
    8069              :               }
    8070       443670 :             if (type_quals)
    8071        48668 :               type = c_build_qualified_type (type, type_quals, orig_qual_type,
    8072              :                                              orig_qual_indirect);
    8073              : 
    8074              :             /* The pointed-to type may need a decl expr (see above).  */
    8075       443670 :             if (!TYPE_NAME (type) && c_type_variably_modified_p (type))
    8076              :               {
    8077          375 :                 bool bind_p = decl_context == TYPENAME
    8078              :                               || decl_context == FIELD
    8079              :                               || decl_context == PARM;
    8080          375 :                 add_decl_expr (loc, type, bind_p ? expr : NULL, true);
    8081              :               }
    8082              : 
    8083       443670 :             type = c_build_pointer_type (type);
    8084       443670 :             type_quals = array_ptr_quals;
    8085       443670 :             if (type_quals)
    8086          965 :               type = c_build_qualified_type (type, type_quals);
    8087              : 
    8088              :             /* We don't yet implement attributes in this context.  */
    8089       443670 :             if (array_ptr_attrs != NULL_TREE)
    8090            0 :               warning_at (loc, OPT_Wattributes,
    8091              :                           "attributes in parameter array declarator ignored");
    8092              : 
    8093              :             size_varies = false;
    8094              :             array_parameter_p = true;
    8095              :           }
    8096    128129383 :         else if (TREE_CODE (type) == FUNCTION_TYPE)
    8097              :           {
    8098          301 :             if (type_quals.has (TYPE_QUAL_ATOMIC))
    8099              :               {
    8100            1 :                 error_at (loc,
    8101              :                           "%<_Atomic%>-qualified function type");
    8102            1 :                 type_quals = type_quals.without (TYPE_QUAL_ATOMIC);
    8103              :               }
    8104          300 :             else if (type_quals)
    8105            0 :               pedwarn (loc, OPT_Wpedantic,
    8106              :                        "ISO C forbids qualified function types");
    8107          301 :             if (type_quals)
    8108            0 :               type = c_build_qualified_type (type, type_quals);
    8109          301 :             type = c_build_pointer_type (type);
    8110          301 :             type_quals = TYPE_UNQUALIFIED;
    8111              :           }
    8112    128129082 :         else if (type_quals)
    8113     10311232 :           type = c_build_qualified_type (type, type_quals);
    8114              : 
    8115    257146106 :         decl = build_decl (declarator->id_loc,
    8116    128573053 :                            PARM_DECL, declarator->u.id.id, type);
    8117    128573053 :         if (size_varies)
    8118           42 :           C_DECL_VARIABLE_SIZE (decl) = 1;
    8119    128573053 :         C_ARRAY_PARAMETER (decl) = array_parameter_p;
    8120              : 
    8121              :         /* Compute the type actually passed in the parmlist,
    8122              :            for the case where there is no prototype.
    8123              :            (For example, shorts and chars are passed as ints.)
    8124              :            When there is a prototype, this is overridden later.  */
    8125              : 
    8126    128573053 :         if (type == error_mark_node)
    8127              :           promoted_type = type;
    8128              :         else
    8129    128572969 :           promoted_type = c_type_promotes_to (type);
    8130              : 
    8131    128573053 :         DECL_ARG_TYPE (decl) = promoted_type;
    8132    128573053 :         if (declspecs->inline_p)
    8133            4 :           pedwarn (loc, 0, "parameter %q+D declared %<inline%>", decl);
    8134    128573053 :         if (declspecs->noreturn_p)
    8135            1 :           pedwarn (loc, 0, "parameter %q+D declared %<_Noreturn%>", decl);
    8136              :       }
    8137     66477764 :     else if (decl_context == FIELD)
    8138              :       {
    8139              :         /* Note that the grammar rejects storage classes in typenames
    8140              :            and fields.  */
    8141      4384568 :         gcc_assert (storage_class == csc_none && !threadp
    8142              :                     && !declspecs->inline_p && !declspecs->noreturn_p);
    8143              : 
    8144              :         /* Structure field.  It may not be a function.  */
    8145              : 
    8146      4384568 :         if (TREE_CODE (type) == FUNCTION_TYPE)
    8147              :           {
    8148            0 :             error_at (loc, "field %qE declared as a function", name);
    8149            0 :             type = c_build_pointer_type (type);
    8150              :           }
    8151      4384568 :         else if (TREE_CODE (type) != ERROR_MARK
    8152      4384568 :                  && !COMPLETE_OR_UNBOUND_ARRAY_TYPE_P (type))
    8153              :           {
    8154           24 :             if (name)
    8155           17 :               error_at (loc, "field %qE has incomplete type", name);
    8156              :             else
    8157            7 :               error_at (loc, "unnamed field has incomplete type");
    8158           24 :             type = error_mark_node;
    8159              :           }
    8160      4384544 :         else if (TREE_CODE (type) == ARRAY_TYPE
    8161      4384544 :                  && TYPE_DOMAIN (type) == NULL_TREE)
    8162              :           {
    8163              :             /* We have a flexible array member through a typedef.
    8164              :                Set suitable range.  Whether this is a correct position
    8165              :                for a flexible array member will be determined elsewhere.  */
    8166           14 :             if (!in_system_header_at (input_location))
    8167           14 :               pedwarn_c90 (loc, OPT_Wpedantic, "ISO C90 does not "
    8168              :                            "support flexible array members");
    8169           14 :             type = build_distinct_type_copy (TYPE_MAIN_VARIANT (type));
    8170           14 :             TYPE_DOMAIN (type) = build_index_type (NULL_TREE);
    8171           14 :             if (orig_qual_indirect == 0)
    8172      4384568 :               orig_qual_type = NULL_TREE;
    8173              :           }
    8174      4384568 :         if (type != error_mark_node
    8175      4384568 :             && !verify_type_context (loc, TCTX_FIELD, type))
    8176            0 :           type = error_mark_node;
    8177              : 
    8178      4384568 :         type = c_build_qualified_type (type, type_quals, orig_qual_type,
    8179              :                                        orig_qual_indirect);
    8180      8769136 :         decl = build_decl (declarator->id_loc,
    8181      4384568 :                            FIELD_DECL, declarator->u.id.id, type);
    8182      4384568 :         DECL_NONADDRESSABLE_P (decl) = bitfield;
    8183      4384568 :         if (bitfield && !declarator->u.id.id)
    8184        11630 :           DECL_PADDING_P (decl) = 1;
    8185              : 
    8186      4384568 :         if (size_varies)
    8187          669 :           C_DECL_VARIABLE_SIZE (decl) = 1;
    8188              :       }
    8189     62093196 :     else if (TREE_CODE (type) == FUNCTION_TYPE)
    8190              :       {
    8191     53073042 :         if (storage_class == csc_register || threadp || constexprp)
    8192              :           {
    8193           12 :             error_at (loc, "invalid storage class for function %qE", name);
    8194              :           }
    8195     53073030 :         else if (current_scope != file_scope)
    8196              :           {
    8197              :             /* Function declaration not at file scope.  Storage
    8198              :                classes other than `extern' are not allowed, C99
    8199              :                6.7.1p5, and `extern' makes no difference.  However,
    8200              :                GCC allows 'auto', perhaps with 'inline', to support
    8201              :                nested functions.  */
    8202        10607 :             if (storage_class == csc_auto)
    8203           70 :                 pedwarn (loc, OPT_Wpedantic,
    8204              :                          "invalid storage class for function %qE", name);
    8205        10537 :             else if (storage_class == csc_static)
    8206              :               {
    8207           20 :                 error_at (loc, "invalid storage class for function %qE", name);
    8208           20 :                 if (funcdef_flag)
    8209            8 :                   storage_class = declspecs->storage_class = csc_none;
    8210              :                 else
    8211              :                   return NULL_TREE;
    8212              :               }
    8213              :           }
    8214              : 
    8215    106146060 :         decl = build_decl (declarator->id_loc,
    8216     53073030 :                            FUNCTION_DECL, declarator->u.id.id, type);
    8217     53073030 :         decl = build_decl_attribute_variant (decl, decl_attr);
    8218              : 
    8219     53073030 :         if (type_quals.has (TYPE_QUAL_ATOMIC))
    8220              :           {
    8221            2 :             error_at (loc,
    8222              :                       "%<_Atomic%>-qualified function type");
    8223            2 :             type_quals = type_quals.without (TYPE_QUAL_ATOMIC);
    8224              :           }
    8225     53073037 :         else if (pedantic && type_quals && !DECL_IN_SYSTEM_HEADER (decl))
    8226            9 :           pedwarn (loc, OPT_Wpedantic,
    8227              :                    "ISO C forbids qualified function types");
    8228              : 
    8229              :         /* Every function declaration is an external reference
    8230              :            (DECL_EXTERNAL) except for those which are not at file
    8231              :            scope and are explicitly declared "auto".  This is
    8232              :            forbidden by standard C (C99 6.7.1p5) and is interpreted by
    8233              :            GCC to signify a forward declaration of a nested function.  */
    8234     53073030 :         if (storage_class == csc_auto && current_scope != file_scope)
    8235           70 :           DECL_EXTERNAL (decl) = 0;
    8236              :         /* In C99, a function which is declared 'inline' with 'extern'
    8237              :            is not an external reference (which is confusing).  It
    8238              :            means that the later definition of the function must be output
    8239              :            in this file, C99 6.7.4p6.  In GNU C89, a function declared
    8240              :            'extern inline' is an external reference.  */
    8241     53072960 :         else if (declspecs->inline_p && storage_class != csc_static)
    8242     36839663 :           DECL_EXTERNAL (decl) = ((storage_class == csc_extern)
    8243     36839663 :                                   == flag_gnu89_inline);
    8244              :         else
    8245     16233297 :           DECL_EXTERNAL (decl) = !initialized;
    8246              : 
    8247              :         /* Record absence of global scope for `static' or `auto'.  */
    8248     53073030 :         TREE_PUBLIC (decl)
    8249     53073030 :           = !(storage_class == csc_static || storage_class == csc_auto);
    8250              : 
    8251              :         /* For a function definition, record the argument information
    8252              :            block where store_parm_decls will look for it.  */
    8253     53073030 :         if (funcdef_flag)
    8254     37713985 :           current_function_arg_info = arg_info;
    8255              : 
    8256     53073030 :         if (declspecs->default_int_p)
    8257         9220 :           C_FUNCTION_IMPLICIT_INT (decl) = 1;
    8258              : 
    8259              :         /* Record presence of `inline' and `_Noreturn', if it is
    8260              :            reasonable.  */
    8261     53073030 :         if (flag_hosted && MAIN_NAME_P (declarator->u.id.id))
    8262              :           {
    8263        50311 :             if (declspecs->inline_p)
    8264            5 :               pedwarn (loc, 0, "cannot inline function %<main%>");
    8265        50311 :             if (declspecs->noreturn_p)
    8266            1 :               pedwarn (loc, 0, "%<main%> declared %<_Noreturn%>");
    8267              :           }
    8268              :         else
    8269              :           {
    8270     53022719 :             if (declspecs->inline_p)
    8271              :               /* Record that the function is declared `inline'.  */
    8272     37005560 :               DECL_DECLARED_INLINE_P (decl) = 1;
    8273     53022719 :             if (declspecs->noreturn_p)
    8274              :               {
    8275        23307 :                 if (flag_isoc99)
    8276        23304 :                   pedwarn_c99 (loc, OPT_Wpedantic,
    8277              :                                "ISO C99 does not support %<_Noreturn%>");
    8278              :                 else
    8279            3 :                   pedwarn_c99 (loc, OPT_Wpedantic,
    8280              :                                "ISO C90 does not support %<_Noreturn%>");
    8281        23307 :                 TREE_THIS_VOLATILE (decl) = 1;
    8282              :               }
    8283              :           }
    8284              : 
    8285              :         /* C99 6.2.2p7: It is invalid (compile-time undefined
    8286              :            behavior) to create an 'extern' declaration for a
    8287              :            function if there is a global declaration that is
    8288              :            'static' and the global declaration is not visible.
    8289              :            (If the static declaration _is_ currently visible,
    8290              :            the 'extern' declaration is taken to refer to that decl.) */
    8291     53073030 :         if (!initialized
    8292     15359036 :             && TREE_PUBLIC (decl)
    8293     15350894 :             && current_scope != file_scope)
    8294              :           {
    8295         8898 :             tree global_decl  = identifier_global_value (declarator->u.id.id);
    8296         8898 :             tree visible_decl = lookup_name (declarator->u.id.id);
    8297              : 
    8298         8898 :             if (global_decl
    8299         8898 :                 && global_decl != visible_decl
    8300         1713 :                 && VAR_OR_FUNCTION_DECL_P (global_decl)
    8301         1713 :                 && !TREE_PUBLIC (global_decl))
    8302            2 :               error_at (loc, "function previously declared %<static%> "
    8303              :                         "redeclared %<extern%>");
    8304              :           }
    8305              :       }
    8306              :     else
    8307              :       {
    8308              :         /* It's a variable.  */
    8309              :         /* An uninitialized decl with `extern' is a reference.  */
    8310      9020154 :         int extern_ref = !initialized && storage_class == csc_extern;
    8311              : 
    8312      9020154 :         if (constexprp)
    8313              :           {
    8314              :             /* The type of a constexpr variable must not be variably
    8315              :                modified, volatile, atomic or restrict qualified or
    8316              :                have a member with such a qualifier.  const
    8317              :                qualification is implicitly added, and, at file scope,
    8318              :                has internal linkage.  */
    8319          386 :             if (c_type_variably_modified_p (type))
    8320            1 :               error_at (loc, "%<constexpr%> object has variably modified "
    8321              :                         "type");
    8322          386 :             if (type_quals.has
    8323          386 :                 (TYPE_QUAL_VOLATILE | TYPE_QUAL_RESTRICT | TYPE_QUAL_ATOMIC))
    8324            9 :               error_at (loc, "invalid qualifiers for %<constexpr%> object");
    8325              :             else
    8326              :               {
    8327          377 :                 tree type_no_array = strip_array_types (type);
    8328          377 :                 if (RECORD_OR_UNION_TYPE_P (type_no_array)
    8329          377 :                     && C_TYPE_FIELDS_NON_CONSTEXPR (type_no_array))
    8330            8 :                   error_at (loc, "invalid qualifiers for field of "
    8331              :                             "%<constexpr%> object");
    8332              :               }
    8333          386 :             type_quals |= TYPE_QUAL_CONST;
    8334          386 :             if (current_scope == file_scope)
    8335          296 :               storage_class = csc_static;
    8336              :           }
    8337              : 
    8338      9020154 :         type = c_build_qualified_type (type, type_quals, orig_qual_type,
    8339              :                                        orig_qual_indirect);
    8340              : 
    8341              :         /* C99 6.2.2p7: It is invalid (compile-time undefined
    8342              :            behavior) to create an 'extern' declaration for a
    8343              :            variable if there is a global declaration that is
    8344              :            'static' and the global declaration is not visible.
    8345              :            (If the static declaration _is_ currently visible,
    8346              :            the 'extern' declaration is taken to refer to that decl.) */
    8347      9020154 :         if (extern_ref && current_scope != file_scope)
    8348              :           {
    8349         1571 :             tree global_decl  = identifier_global_value (declarator->u.id.id);
    8350         1571 :             tree visible_decl = lookup_name (declarator->u.id.id);
    8351              : 
    8352         1571 :             if (global_decl
    8353         1571 :                 && global_decl != visible_decl
    8354          282 :                 && VAR_P (global_decl)
    8355          282 :                 && !TREE_PUBLIC (global_decl))
    8356            8 :               error_at (loc, "variable previously declared %<static%> "
    8357              :                         "redeclared %<extern%>");
    8358              :           }
    8359              : 
    8360     18040308 :         decl = build_decl (declarator->id_loc,
    8361      9020154 :                            VAR_DECL, declarator->u.id.id, type);
    8362      9020154 :         if (size_varies)
    8363         7452 :           C_DECL_VARIABLE_SIZE (decl) = 1;
    8364      9020154 :         if (constexprp)
    8365          386 :           C_DECL_DECLARED_CONSTEXPR (decl) = 1;
    8366              : 
    8367      9020154 :         if (declspecs->inline_p)
    8368            4 :           pedwarn (loc, 0, "variable %q+D declared %<inline%>", decl);
    8369      9020154 :         if (declspecs->noreturn_p)
    8370            1 :           pedwarn (loc, 0, "variable %q+D declared %<_Noreturn%>", decl);
    8371              : 
    8372              :         /* At file scope, an initialized extern declaration may follow
    8373              :            a static declaration.  In that case, DECL_EXTERNAL will be
    8374              :            reset later in start_decl.  */
    8375      9020154 :         DECL_EXTERNAL (decl) = (storage_class == csc_extern);
    8376              : 
    8377              :         /* At file scope, the presence of a `static' or `register' storage
    8378              :            class specifier, or the absence of all storage class specifiers
    8379              :            makes this declaration a definition (perhaps tentative).  Also,
    8380              :            the absence of `static' makes it public.  */
    8381      9020154 :         if (current_scope == file_scope)
    8382              :           {
    8383      1157080 :             TREE_PUBLIC (decl) = storage_class != csc_static;
    8384      1157080 :             TREE_STATIC (decl) = !extern_ref;
    8385              :           }
    8386              :         /* Not at file scope, only `static' makes a static definition.  */
    8387              :         else
    8388              :           {
    8389      7863074 :             TREE_STATIC (decl) = (storage_class == csc_static);
    8390      7863074 :             TREE_PUBLIC (decl) = extern_ref;
    8391              :           }
    8392              : 
    8393              :         // NB: Set a tentative TLS model to avoid tls_model attribute
    8394              :         // warnings due to lack of thread storage duration.  It will
    8395              :         // be updated by c_decl_attributes later.
    8396      9020154 :         if (threadp)
    8397         2855 :           set_decl_tls_model (decl, TLS_MODEL_REAL);
    8398              :       }
    8399              : 
    8400    195050805 :     if ((storage_class == csc_extern
    8401    143000996 :          || (storage_class == csc_none
    8402    142528071 :              && TREE_CODE (type) == FUNCTION_TYPE
    8403       824239 :              && !funcdef_flag))
    8404    195360997 :         && c_type_variably_modified_p (type))
    8405              :       {
    8406              :         /* C99 6.7.5.2p2 */
    8407            6 :         if (TREE_CODE (type) == FUNCTION_TYPE)
    8408            4 :           error_at (loc, "non-nested function with variably modified type");
    8409              :         else
    8410            2 :           error_at (loc, "object with variably modified type must have "
    8411              :                     "no linkage");
    8412              :       }
    8413              : 
    8414              :     /* For nested functions disqualify ones taking VLAs by value
    8415              :        from inlining since the middle-end cannot deal with this.
    8416              :        ???  We should arrange for those to be passed by reference
    8417              :        with emitting the copy on the caller side in the frontend.  */
    8418    195050805 :     if (storage_class == csc_none
    8419    142528071 :         && TREE_CODE (type) == FUNCTION_TYPE)
    8420      4228186 :       for (tree al = TYPE_ARG_TYPES (type); al; al = TREE_CHAIN (al))
    8421              :         {
    8422      3403987 :           tree arg = TREE_VALUE (al);
    8423      3403987 :           if (arg != error_mark_node
    8424      3403987 :               && C_TYPE_VARIABLE_SIZE (arg))
    8425              :             {
    8426           40 :               DECL_UNINLINABLE (decl) = 1;
    8427           40 :               break;
    8428              :             }
    8429              :         }
    8430              : 
    8431              :     /* Record `register' declaration for warnings on &
    8432              :        and in case doing stupid register allocation.  */
    8433              : 
    8434    195050805 :     if (storage_class == csc_register
    8435         3653 :         && TREE_CODE (type) != FUNCTION_TYPE)
    8436              :       {
    8437         3647 :         C_DECL_REGISTER (decl) = 1;
    8438         3647 :         DECL_REGISTER (decl) = 1;
    8439              :       }
    8440              : 
    8441              :     /* Record constancy and volatility.  */
    8442    195050805 :     c_apply_type_quals_to_decl (type_quals, decl);
    8443              : 
    8444              :     /* Apply _Alignas specifiers.  */
    8445    195050805 :     if (alignas_align)
    8446              :       {
    8447          123 :         SET_DECL_ALIGN (decl, alignas_align * BITS_PER_UNIT);
    8448          123 :         DECL_USER_ALIGN (decl) = 1;
    8449              :       }
    8450              : 
    8451              :     /* If a type has volatile components, it should be stored in memory.
    8452              :        Otherwise, the fact that those components are volatile
    8453              :        will be ignored, and would even crash the compiler.
    8454              :        Of course, this only makes sense on  VAR,PARM, and RESULT decl's.   */
    8455    195050805 :     if (C_TYPE_FIELDS_VOLATILE (TREE_TYPE (decl))
    8456    195050805 :         && (VAR_P (decl) ||  TREE_CODE (decl) == PARM_DECL
    8457              :           || TREE_CODE (decl) == RESULT_DECL))
    8458              :       {
    8459              :         /* It is not an error for a structure with volatile fields to
    8460              :            be declared register, but reset DECL_REGISTER since it
    8461              :            cannot actually go in a register.  */
    8462          186 :         int was_reg = C_DECL_REGISTER (decl);
    8463          186 :         C_DECL_REGISTER (decl) = 0;
    8464          186 :         DECL_REGISTER (decl) = 0;
    8465          186 :         c_mark_addressable (decl);
    8466          186 :         C_DECL_REGISTER (decl) = was_reg;
    8467              :       }
    8468              : 
    8469              :   /* This is the earliest point at which we might know the assembler
    8470              :      name of a variable.  Thus, if it's known before this, die horribly.  */
    8471    195050805 :     gcc_assert (!HAS_DECL_ASSEMBLER_NAME_P (decl)
    8472              :                 || !DECL_ASSEMBLER_NAME_SET_P (decl));
    8473              : 
    8474    195050805 :     if (warn_cxx_compat
    8475       782027 :         && VAR_P (decl)
    8476        33444 :         && TREE_PUBLIC (decl)
    8477        11613 :         && TREE_STATIC (decl)
    8478         2594 :         && (RECORD_OR_UNION_TYPE_P (TREE_TYPE (decl))
    8479         2444 :             || TREE_CODE (TREE_TYPE (decl)) == ENUMERAL_TYPE)
    8480    195050986 :         && TYPE_NAME (TREE_TYPE (decl)) == NULL_TREE)
    8481            4 :       warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wc___compat,
    8482              :                   "non-local variable %qD with anonymous type is "
    8483              :                   "questionable in C++", decl);
    8484              : 
    8485              :     return decl;
    8486              :   }
    8487              : }
    8488              : 
    8489              : /* Decode the parameter-list info for a function type or function definition.
    8490              :    The argument is the value returned by `get_parm_info' (or made in c-parse.c
    8491              :    if there is an identifier list instead of a parameter decl list).
    8492              :    These two functions are separate because when a function returns
    8493              :    or receives functions then each is called multiple times but the order
    8494              :    of calls is different.  The last call to `grokparms' is always the one
    8495              :    that contains the formal parameter names of a function definition.
    8496              : 
    8497              :    Return a list of arg types to use in the FUNCTION_TYPE for this function.
    8498              : 
    8499              :    FUNCDEF_FLAG is true for a function definition, false for
    8500              :    a mere declaration.  A nonempty identifier-list gets an error message
    8501              :    when FUNCDEF_FLAG is false.  */
    8502              : 
    8503              : static tree
    8504     52661127 : grokparms (struct c_arg_info *arg_info, bool funcdef_flag)
    8505              : {
    8506     52661127 :   tree arg_types = arg_info->types;
    8507              : 
    8508     52661127 :   if (funcdef_flag && arg_info->had_vla_unspec)
    8509              :     {
    8510              :       /* A function definition isn't function prototype scope C99 6.2.1p4.  */
    8511              :       /* C99 6.7.5.2p4 */
    8512            2 :       error ("%<[*]%> not allowed in other than function prototype scope");
    8513              :     }
    8514              : 
    8515       715906 :   if (arg_types == NULL_TREE && !funcdef_flag && !flag_isoc23
    8516     52664188 :       && !in_system_header_at (input_location))
    8517         3061 :     warning (OPT_Wstrict_prototypes,
    8518              :              "function declaration isn%'t a prototype");
    8519              : 
    8520     52661127 :   if (arg_types == error_mark_node)
    8521              :     /* Don't set TYPE_ARG_TYPES in this case.  */
    8522              :     return NULL_TREE;
    8523              : 
    8524    104532052 :   else if (arg_types && TREE_CODE (TREE_VALUE (arg_types)) == IDENTIFIER_NODE)
    8525              :     {
    8526         8684 :       if (!funcdef_flag)
    8527              :         {
    8528           13 :           permerror_opt (input_location,
    8529           13 :                          OPT_Wdeclaration_missing_parameter_type,
    8530              :                          "parameter names (without types) in "
    8531              :                          "function declaration");
    8532           13 :           arg_info->parms = NULL_TREE;
    8533              :         }
    8534              :       else
    8535         8671 :         arg_info->parms = arg_info->types;
    8536              : 
    8537         8684 :       arg_info->types = NULL_TREE;
    8538         8684 :       return NULL_TREE;
    8539              :     }
    8540              :   else
    8541              :     {
    8542     52652443 :       tree parm, type, typelt;
    8543     52652443 :       unsigned int parmno;
    8544              : 
    8545              :       /* In C23, convert () to (void).  */
    8546     52652443 :       if (flag_isoc23
    8547     43373564 :           && !arg_types
    8548       782557 :           && !arg_info->parms
    8549       782557 :           && !arg_info->no_named_args_stdarg_p)
    8550              :         {
    8551       782414 :           arg_types = arg_info->types = void_list_node;
    8552       782414 :           arg_info->c23_empty_parens = 1;
    8553              :         }
    8554              : 
    8555              :       /* If there is a parameter of incomplete type in a definition,
    8556              :          this is an error.  In a declaration this is valid, and a
    8557              :          struct or union type may be completed later, before any calls
    8558              :          or definition of the function.  In the case where the tag was
    8559              :          first declared within the parameter list, a warning has
    8560              :          already been given.  If a parameter has void type, then
    8561              :          this has already received an error (constraint violation in C2Y,
    8562              :          previously implicitly undefined behavior).  */
    8563              : 
    8564     52652443 :       for (parm = arg_info->parms, typelt = arg_types, parmno = 1;
    8565    180205346 :            parm;
    8566    127552903 :            parm = DECL_CHAIN (parm), typelt = TREE_CHAIN (typelt), parmno++)
    8567              :         {
    8568    127552903 :           type = TREE_VALUE (typelt);
    8569    127552903 :           if (type == error_mark_node)
    8570           61 :             continue;
    8571              : 
    8572    127552842 :           if (!COMPLETE_TYPE_P (type))
    8573              :             {
    8574           40 :               if (funcdef_flag)
    8575              :                 {
    8576           13 :                   if (DECL_NAME (parm))
    8577           13 :                     error_at (input_location,
    8578              :                               "parameter %u (%q+D) has incomplete type",
    8579              :                               parmno, parm);
    8580              :                   else
    8581            0 :                     error_at (DECL_SOURCE_LOCATION (parm),
    8582              :                               "parameter %u has incomplete type",
    8583              :                               parmno);
    8584              : 
    8585           13 :                   TREE_VALUE (typelt) = error_mark_node;
    8586           13 :                   TREE_TYPE (parm) = error_mark_node;
    8587           13 :                   arg_types = NULL_TREE;
    8588              :                 }
    8589              :             }
    8590              : 
    8591    127552842 :           if (DECL_NAME (parm) && TREE_USED (parm))
    8592        17739 :             warn_if_shadowing (parm);
    8593              :         }
    8594              :       return arg_types;
    8595              :     }
    8596              : }
    8597              : 
    8598              : /* Allocate and initialize a c_arg_info structure from the parser's
    8599              :    obstack.  */
    8600              : 
    8601              : struct c_arg_info *
    8602     52661145 : build_arg_info (void)
    8603              : {
    8604     52661145 :   struct c_arg_info *ret = XOBNEW (&parser_obstack, struct c_arg_info);
    8605     52661145 :   ret->parms = NULL_TREE;
    8606     52661145 :   ret->tags = NULL;
    8607     52661145 :   ret->types = NULL_TREE;
    8608     52661145 :   ret->others = NULL_TREE;
    8609     52661145 :   ret->pending_sizes = NULL;
    8610     52661145 :   ret->had_vla_unspec = 0;
    8611     52661145 :   ret->no_named_args_stdarg_p = 0;
    8612     52661145 :   ret->c23_empty_parens = 0;
    8613     52661145 :   return ret;
    8614              : }
    8615              : 
    8616              : /* Take apart the current scope and return a c_arg_info structure with
    8617              :    info on a parameter list just parsed.
    8618              : 
    8619              :    This structure is later fed to 'grokparms' and 'store_parm_decls'.
    8620              : 
    8621              :    ELLIPSIS being true means the argument list ended in '...' so don't
    8622              :    append a sentinel (void_list_node) to the end of the type-list.
    8623              : 
    8624              :    EXPR is NULL or an expression that needs to be evaluated for the
    8625              :    side effects of array size expressions in the parameters.  */
    8626              : 
    8627              : struct c_arg_info *
    8628     51862270 : get_parm_info (bool ellipsis, tree expr)
    8629              : {
    8630     51862270 :   struct c_binding *b = current_scope->bindings;
    8631     51862270 :   struct c_arg_info *arg_info = build_arg_info ();
    8632              : 
    8633     51862270 :   tree parms = NULL_TREE;
    8634     51862270 :   vec<c_arg_tag, va_gc> *tags = NULL;
    8635     51862270 :   tree types = NULL_TREE;
    8636     51862270 :   tree others = NULL_TREE;
    8637              : 
    8638     51862270 :   bool gave_void_only_once_err = false;
    8639              : 
    8640     51862270 :   arg_info->had_vla_unspec = current_scope->had_vla_unspec;
    8641              : 
    8642              :   /* The bindings in this scope must not get put into a block.
    8643              :      We will take care of deleting the binding nodes.  */
    8644     51862270 :   current_scope->bindings = 0;
    8645              : 
    8646              :   /* This function is only called if there was *something* on the
    8647              :      parameter list.  */
    8648     51862270 :   gcc_assert (b);
    8649              : 
    8650              :   /* A parameter list consisting solely of 'void' indicates that the
    8651              :      function takes no arguments.  But if the 'void' is qualified
    8652              :      (by 'const' or 'volatile'), or has a storage class specifier
    8653              :      ('register'), then the behavior is undefined; issue an error.
    8654              :      Typedefs for 'void' are OK (see DR#157).  */
    8655     51862270 :   if (b->prev == 0                       /* one binding */
    8656     13891927 :       && TREE_CODE (b->decl) == PARM_DECL   /* which is a parameter */
    8657     13891927 :       && !DECL_NAME (b->decl)               /* anonymous */
    8658     53756415 :       && VOID_TYPE_P (TREE_TYPE (b->decl))) /* of void type */
    8659              :     {
    8660       997202 :       if (TYPE_QUALS (TREE_TYPE (b->decl)) != TYPE_UNQUALIFIED
    8661       997128 :           || C_DECL_REGISTER (b->decl))
    8662           96 :         error_at (b->locus, "%<void%> as only parameter may not be qualified");
    8663              : 
    8664              :       /* There cannot be an ellipsis.  */
    8665       997202 :       if (ellipsis)
    8666           17 :         error_at (b->locus, "%<void%> must be the only parameter");
    8667              : 
    8668       997202 :       arg_info->types = void_list_node;
    8669       997202 :       return arg_info;
    8670              :     }
    8671              : 
    8672     50865068 :   if (!ellipsis)
    8673     50649611 :     types = void_list_node;
    8674              : 
    8675              :   /* Break up the bindings list into parms, tags, types, and others;
    8676              :      apply sanity checks; purge the name-to-decl bindings.  */
    8677    178418434 :   while (b)
    8678              :     {
    8679    127553366 :       tree decl = b->decl;
    8680    127553366 :       tree type = TREE_TYPE (decl);
    8681    127553366 :       c_arg_tag tag;
    8682    127553366 :       const char *keyword;
    8683              : 
    8684    127553366 :       switch (TREE_CODE (decl))
    8685              :         {
    8686    127553026 :         case PARM_DECL:
    8687    127553026 :           if (b->id)
    8688              :             {
    8689    123846642 :               gcc_assert (I_SYMBOL_BINDING (b->id) == b);
    8690    123846642 :               I_SYMBOL_BINDING (b->id) = b->shadowed;
    8691              :             }
    8692              : 
    8693              :           /* Check for forward decls that never got their actual decl.  */
    8694    127553026 :           if (TREE_ASM_WRITTEN (decl))
    8695            4 :             error_at (b->locus,
    8696              :                       "parameter %q+D has just a forward declaration", decl);
    8697              :           /* Check for (..., void, ...) and named void parameters and issue an
    8698              :              error.  */
    8699    127553022 :           else if (VOID_TYPE_P (type))
    8700              :             {
    8701          114 :               if (!gave_void_only_once_err)
    8702              :                 {
    8703          114 :                   error_at (b->locus,
    8704              :                             "%<void%> must be the only parameter and unnamed");
    8705          114 :                   gave_void_only_once_err = true;
    8706              :                 }
    8707              :             }
    8708              :           else
    8709              :             {
    8710              :               /* Valid parameter, add it to the list.  */
    8711    127552908 :               DECL_CHAIN (decl) = parms;
    8712    127552908 :               parms = decl;
    8713              : 
    8714              :               /* Since there is a prototype, args are passed in their
    8715              :                  declared types.  The back end may override this later.  */
    8716    127552908 :               DECL_ARG_TYPE (decl) = type;
    8717    127552908 :               types = tree_cons (0, type, types);
    8718              :             }
    8719              :           break;
    8720              : 
    8721           21 :         case ENUMERAL_TYPE: keyword = "enum"; goto tag;
    8722           20 :         case UNION_TYPE:    keyword = "union"; goto tag;
    8723          101 :         case RECORD_TYPE:   keyword = "struct"; goto tag;
    8724          142 :         tag:
    8725              :           /* Types may not have tag-names, in which case the type
    8726              :              appears in the bindings list with b->id NULL.  */
    8727          142 :           if (b->id)
    8728              :             {
    8729           97 :               gcc_assert (I_TAG_BINDING (b->id) == b);
    8730           97 :               I_TAG_BINDING (b->id) = b->shadowed;
    8731              :             }
    8732              : 
    8733              :           /* Warn about any struct, union or enum tags defined in a
    8734              :              parameter list.  The scope of such types is limited to
    8735              :              the parameter list, which is rarely if ever desirable
    8736              :              (it's impossible to call such a function with type-
    8737              :              correct arguments).  An anonymous union parm type is
    8738              :              meaningful as a GNU extension, so don't warn for that.  */
    8739          142 :           if (TREE_CODE (decl) != UNION_TYPE || b->id != NULL_TREE)
    8740              :             {
    8741          122 :               if (b->id)
    8742              :                 {
    8743              :                   /* The %s will be one of 'struct', 'union', or 'enum'.  */
    8744           97 :                   if (!flag_isoc23 || !COMPLETE_TYPE_P (decl))
    8745           73 :                     warning_at (b->locus, 0,
    8746              :                                 "%<%s %E%> declared inside parameter list"
    8747              :                                 " will not be visible outside of this definition or"
    8748              :                                 " declaration", keyword, b->id);
    8749              :                 }
    8750              :               else
    8751              :                 /* The %s will be one of 'struct', 'union', or 'enum'.  */
    8752           25 :                 warning_at (b->locus, 0,
    8753              :                             "anonymous %s declared inside parameter list"
    8754              :                             " will not be visible outside of this definition or"
    8755              :                             " declaration", keyword);
    8756              :             }
    8757              : 
    8758          142 :           tag.id = b->id;
    8759          142 :           tag.type = decl;
    8760          142 :           vec_safe_push (tags, tag);
    8761          142 :           break;
    8762              : 
    8763           20 :         case FUNCTION_DECL:
    8764              :           /* FUNCTION_DECLs appear when there is an implicit function
    8765              :              declaration in the parameter list.  */
    8766           20 :           gcc_assert (b->nested || seen_error ());
    8767           20 :           goto set_shadowed;
    8768              : 
    8769          144 :         case CONST_DECL:
    8770          144 :         case TYPE_DECL:
    8771              :           /* CONST_DECLs appear here when we have an embedded enum,
    8772              :              and TYPE_DECLs appear here when we have an embedded struct
    8773              :              or union.  No warnings for this - we already warned about the
    8774              :              type itself.  */
    8775              : 
    8776              :           /* When we reinsert this decl in the function body, we need
    8777              :              to reconstruct whether it was marked as nested.  */
    8778          144 :           gcc_assert (!b->nested);
    8779          144 :           DECL_CHAIN (decl) = others;
    8780          144 :           others = decl;
    8781              :           /* fall through */
    8782              : 
    8783          198 :         case ERROR_MARK:
    8784          198 :         set_shadowed:
    8785              :           /* error_mark_node appears here when we have an undeclared
    8786              :              variable.  Just throw it away.  */
    8787          198 :           if (b->id)
    8788              :             {
    8789           56 :               gcc_assert (I_SYMBOL_BINDING (b->id) == b);
    8790           56 :               I_SYMBOL_BINDING (b->id) = b->shadowed;
    8791              :             }
    8792              :           break;
    8793              : 
    8794              :           /* Other things that might be encountered.  */
    8795            0 :         case LABEL_DECL:
    8796            0 :         case VAR_DECL:
    8797            0 :         default:
    8798            0 :           gcc_unreachable ();
    8799              :         }
    8800              : 
    8801    127553366 :       b = free_binding_and_advance (b);
    8802              :     }
    8803              : 
    8804     50865068 :   arg_info->parms = parms;
    8805     50865068 :   arg_info->tags = tags;
    8806     50865068 :   arg_info->types = types;
    8807     50865068 :   arg_info->others = others;
    8808     50865068 :   arg_info->pending_sizes = expr;
    8809     50865068 :   arg_info->no_named_args_stdarg_p = ellipsis && !types;
    8810     50865068 :   return arg_info;
    8811              : }
    8812              : 
    8813              : /* Get the struct, enum or union (CODE says which) with tag NAME.
    8814              :    Define the tag as a forward-reference with location LOC if it is
    8815              :    not defined.  HAVE_STD_ATTRS says whether any standard attributes
    8816              :    were present after the struct, union or enum keyword; ATTRS are the
    8817              :    standard attributes present there.  HAS_ENUM_TYPE_SPECIFIER says
    8818              :    whether an enum type specifier (": specifier-qualifier-list") is
    8819              :    present; if so, this is called before that specifier is parsed, so
    8820              :    that the tag is in scope for that specifier.  Return a c_typespec
    8821              :    structure for the type specifier.  */
    8822              : 
    8823              : struct c_typespec
    8824      1111591 : parser_xref_tag (location_t loc, enum tree_code code, tree name,
    8825              :                  bool have_std_attrs, tree attrs, bool has_enum_type_specifier)
    8826              : {
    8827      1111591 :   struct c_typespec ret;
    8828      1111591 :   tree ref;
    8829      1111591 :   location_t refloc;
    8830              : 
    8831      1111591 :   ret.expr = NULL_TREE;
    8832      1111591 :   ret.expr_const_operands = true;
    8833      1111591 :   ret.has_enum_type_specifier = has_enum_type_specifier;
    8834              : 
    8835              :   /* If a cross reference is requested, look up the type already
    8836              :      defined for this tag and return it.  If an enum type specifier is
    8837              :      present, only a definition in the current scope is relevant.  */
    8838              : 
    8839      1111591 :   ref = lookup_tag (code, name, has_enum_type_specifier, &refloc);
    8840              : 
    8841              :   /* If the visible type is still being defined, see if there is
    8842              :      an earlier definition (which may be complete).  We do not
    8843              :      have to loop because nested redefinitions are not allowed.  */
    8844      1111591 :   if (flag_isoc23 && ref && C_TYPE_BEING_DEFINED (ref))
    8845              :     {
    8846        87808 :       tree vis = previous_tag (ref);
    8847        87808 :       if (vis)
    8848           17 :         ref = vis;
    8849              :     }
    8850              : 
    8851              :   /* If this is the right type of tag, return what we found.
    8852              :      (This reference will be shadowed by shadow_tag later if appropriate.)
    8853              :      If this is the wrong type of tag, do not return it.  If it was the
    8854              :      wrong type in the same scope, we will have had an error
    8855              :      message already; if in a different scope and declaring
    8856              :      a name, pending_xref_error will give an error message; but if in a
    8857              :      different scope and not declaring a name, this tag should
    8858              :      shadow the previous declaration of a different type of tag, and
    8859              :      this would not work properly if we return the reference found.
    8860              :      (For example, with "struct foo" in an outer scope, "union foo;"
    8861              :      must shadow that tag with a new one of union type.)  */
    8862      2223182 :   ret.kind = (ref
    8863      1111591 :               ? (have_std_attrs ? ctsk_tagref_attrs : ctsk_tagref)
    8864        96344 :               : (have_std_attrs ? ctsk_tagfirstref_attrs : ctsk_tagfirstref));
    8865      1111591 :   if (ref && TREE_CODE (ref) == code)
    8866              :     {
    8867      1015213 :       decl_attributes (&ref, attrs, (int) ATTR_FLAG_TYPE_IN_PLACE);
    8868      1015213 :       if (C_TYPE_DEFINED_IN_STRUCT (ref)
    8869            5 :           && loc != UNKNOWN_LOCATION
    8870      1015218 :           && warn_cxx_compat)
    8871              :         {
    8872            5 :           auto_diagnostic_group d;
    8873            5 :           switch (code)
    8874              :             {
    8875            2 :             case ENUMERAL_TYPE:
    8876            2 :               if (warning_at (loc, OPT_Wc___compat,
    8877              :                               ("enum type defined in struct or union "
    8878              :                                "is not visible in C++")))
    8879            2 :                   inform (refloc, "enum type defined here");
    8880              :               break;
    8881            2 :             case RECORD_TYPE:
    8882            2 :               if (warning_at (loc, OPT_Wc___compat,
    8883              :                               ("struct defined in struct or union "
    8884              :                                "is not visible in C++")))
    8885            2 :                 inform (refloc, "struct defined here");
    8886              :               break;
    8887            1 :             case UNION_TYPE:
    8888            1 :               if (warning_at (loc, OPT_Wc___compat,
    8889              :                               ("union defined in struct or union "
    8890              :                                "is not visible in C++")))
    8891            1 :                 inform (refloc, "union defined here");
    8892              :               break;
    8893            0 :             default:
    8894            0 :               gcc_unreachable();
    8895              :             }
    8896            5 :         }
    8897              : 
    8898      1015213 :       ret.spec = ref;
    8899      1015213 :       return ret;
    8900              :     }
    8901              : 
    8902              :   /* If no such tag is yet defined, create a forward-reference node
    8903              :      and record it as the "definition".
    8904              :      When a real declaration of this type is found,
    8905              :      the forward-reference will be altered into a real type.  */
    8906              : 
    8907        96378 :   ref = make_node (code);
    8908        96378 :   if (flag_isoc23 || code == ENUMERAL_TYPE)
    8909        74101 :     SET_TYPE_STRUCTURAL_EQUALITY (ref);
    8910        74101 :   if (code == ENUMERAL_TYPE)
    8911              :     {
    8912              :       /* Give the type a default layout like unsigned int
    8913              :          to avoid crashing if it does not get defined.  */
    8914          470 :       SET_TYPE_MODE (ref, TYPE_MODE (unsigned_type_node));
    8915          470 :       SET_TYPE_ALIGN (ref, TYPE_ALIGN (unsigned_type_node));
    8916          470 :       TYPE_USER_ALIGN (ref) = 0;
    8917          470 :       TYPE_UNSIGNED (ref) = 1;
    8918          470 :       TYPE_PRECISION (ref) = TYPE_PRECISION (unsigned_type_node);
    8919          470 :       TYPE_MIN_VALUE (ref) = TYPE_MIN_VALUE (unsigned_type_node);
    8920          470 :       TYPE_MAX_VALUE (ref) = TYPE_MAX_VALUE (unsigned_type_node);
    8921          470 :       ENUM_FIXED_UNDERLYING_TYPE_P (ref) = has_enum_type_specifier;
    8922              :     }
    8923              : 
    8924        96378 :   pushtag (loc, name, ref);
    8925        96378 :   decl_attributes (&ref, attrs, (int) ATTR_FLAG_TYPE_IN_PLACE);
    8926        96378 :   if (in_underspecified_init)
    8927            9 :     error_at (loc, "%qT declared in underspecified object initializer",
    8928              :               ref);
    8929              : 
    8930        96378 :   ret.spec = ref;
    8931        96378 :   return ret;
    8932              : }
    8933              : 
    8934              : /* Get the struct, enum or union (CODE says which) with tag NAME.
    8935              :    Define the tag as a forward-reference if it is not defined.
    8936              :    Return a tree for the type.  */
    8937              : 
    8938              : tree
    8939            0 : xref_tag (enum tree_code code, tree name)
    8940              : {
    8941            0 :   return parser_xref_tag (input_location, code, name, false, NULL_TREE,
    8942            0 :                           false).spec;
    8943              : }
    8944              : 
    8945              : /* Make sure that the tag NAME is defined *in the current scope*
    8946              :    at least as a forward reference.
    8947              :    LOC is the location of the struct's definition.
    8948              :    CODE says which kind of tag NAME ought to be.
    8949              : 
    8950              :    This stores the current value of the file static STRUCT_PARSE_INFO
    8951              :    in *ENCLOSING_STRUCT_PARSE_INFO, and points STRUCT_PARSE_INFO at a
    8952              :    new c_struct_parse_info structure.  The old value of
    8953              :    STRUCT_PARSE_INFO is restored in finish_struct.  */
    8954              : 
    8955              : tree
    8956      1199842 : start_struct (location_t loc, enum tree_code code, tree name,
    8957              :               class c_struct_parse_info **enclosing_struct_parse_info)
    8958              : {
    8959              :   /* If there is already a tag defined at this scope
    8960              :      (as a forward reference), just return it.  */
    8961              : 
    8962      1199842 :   tree ref = NULL_TREE;
    8963      1199842 :   location_t refloc = UNKNOWN_LOCATION;
    8964              : 
    8965      1199842 :   if (name != NULL_TREE)
    8966       495764 :     ref = lookup_tag (code, name, true, &refloc);
    8967              : 
    8968              :   /* For C23, even if we already have a completed definition,
    8969              :      we do not use it. We will check for consistency later.
    8970              :      If we are in a nested redefinition the type is not
    8971              :      complete. We will then detect this below.  */
    8972      1199842 :   if (flag_isoc23 && ref && TYPE_SIZE (ref))
    8973              :     ref = NULL_TREE;
    8974              : 
    8975      1199733 :   if (ref && TREE_CODE (ref) == code)
    8976              :     {
    8977        25606 :       if (TYPE_STUB_DECL (ref))
    8978        25606 :         refloc = DECL_SOURCE_LOCATION (TYPE_STUB_DECL (ref));
    8979              : 
    8980        25606 :       if (TYPE_SIZE (ref))
    8981              :         {
    8982           11 :           auto_diagnostic_group d;
    8983           11 :           if (code == UNION_TYPE)
    8984            2 :             error_at (loc, "redefinition of %<union %E%>", name);
    8985              :           else
    8986            9 :             error_at (loc, "redefinition of %<struct %E%>", name);
    8987           11 :           if (refloc != UNKNOWN_LOCATION)
    8988           11 :             inform (refloc, "originally defined here");
    8989              :           /* Don't create structures using a name already in use.  */
    8990           11 :           ref = NULL_TREE;
    8991           11 :         }
    8992        25595 :       else if (C_TYPE_BEING_DEFINED (ref))
    8993              :         {
    8994           17 :           if (code == UNION_TYPE)
    8995            1 :             error_at (loc, "nested redefinition of %<union %E%>", name);
    8996              :           else
    8997           16 :             error_at (loc, "nested redefinition of %<struct %E%>", name);
    8998              :           /* Don't bother to report "originally defined here" for a
    8999              :              nested redefinition; the original definition should be
    9000              :              obvious.  */
    9001              :           /* Don't create structures that contain themselves.  */
    9002              :           ref = NULL_TREE;
    9003              :         }
    9004              :     }
    9005              : 
    9006              :   /* Otherwise create a forward-reference just so the tag is in scope.  */
    9007              : 
    9008        25609 :   if (ref == NULL_TREE || TREE_CODE (ref) != code)
    9009              :     {
    9010      1174264 :       ref = make_node (code);
    9011      1174264 :       if (flag_isoc23)
    9012       945611 :         SET_TYPE_STRUCTURAL_EQUALITY (ref);
    9013      1174264 :       pushtag (loc, name, ref);
    9014              :     }
    9015              : 
    9016      1199842 :   C_TYPE_BEING_DEFINED (ref) = 1;
    9017      2430698 :   for (tree v = TYPE_MAIN_VARIANT (ref); v; v = TYPE_NEXT_VARIANT (v))
    9018      1230856 :     TYPE_PACKED (v) = flag_pack_struct;
    9019              : 
    9020      1199842 :   *enclosing_struct_parse_info = struct_parse_info;
    9021      1199842 :   struct_parse_info = new c_struct_parse_info ();
    9022      1199842 :   struct_parse_info->refloc = refloc;
    9023              : 
    9024              :   /* FIXME: This will issue a warning for a use of a type defined
    9025              :      within a statement expr used within sizeof, et. al.  This is not
    9026              :      terribly serious as C++ doesn't permit statement exprs within
    9027              :      sizeof anyhow.  */
    9028      1199842 :   if (warn_cxx_compat
    9029        21412 :       && (in_sizeof || in_typeof || in_alignof || in_countof))
    9030           10 :     warning_at (loc, OPT_Wc___compat,
    9031              :                 "defining type in %qs expression is invalid in C++",
    9032              :                 (in_sizeof ? "sizeof"
    9033            4 :                  : in_typeof ? "typeof"
    9034            1 :                  : in_alignof ? "alignof"
    9035              :                  : "_Countof"));
    9036              : 
    9037      1199842 :   if (in_underspecified_init)
    9038           18 :     error_at (loc, "%qT defined in underspecified object initializer", ref);
    9039              : 
    9040      1199842 :   return ref;
    9041              : }
    9042              : 
    9043              : /* Process the specs, declarator and width (NULL if omitted)
    9044              :    of a structure component, returning a FIELD_DECL node.
    9045              :    WIDTH is non-NULL for bit-fields only, and is an INTEGER_CST node.
    9046              :    DECL_ATTRS is as for grokdeclarator.
    9047              : 
    9048              :    LOC is the location of the structure component.
    9049              : 
    9050              :    This is done during the parsing of the struct declaration.
    9051              :    The FIELD_DECL nodes are chained together and the lot of them
    9052              :    are ultimately passed to `build_struct' to make the RECORD_TYPE node.  */
    9053              : 
    9054              : tree
    9055      4384597 : grokfield (location_t loc,
    9056              :            struct c_declarator *declarator, struct c_declspecs *declspecs,
    9057              :            tree width, tree *decl_attrs, tree *expr)
    9058              : {
    9059      4384597 :   tree value;
    9060              : 
    9061      4384597 :   if (declarator->kind == cdk_id && declarator->u.id.id == NULL_TREE
    9062        22555 :       && width == NULL_TREE)
    9063              :     {
    9064              :       /* This is an unnamed decl.
    9065              : 
    9066              :          If we have something of the form "union { list } ;" then this
    9067              :          is the anonymous union extension.  Similarly for struct.
    9068              : 
    9069              :          If this is something of the form "struct foo;", then
    9070              :            If MS or Plan 9 extensions are enabled, this is handled as
    9071              :              an anonymous struct.
    9072              :            Otherwise this is a forward declaration of a structure tag.
    9073              : 
    9074              :          If this is something of the form "foo;" and foo is a TYPE_DECL, then
    9075              :            If foo names a structure or union without a tag, then this
    9076              :              is an anonymous struct (this is permitted by C11).
    9077              :            If MS or Plan 9 extensions are enabled and foo names a
    9078              :              structure, then again this is an anonymous struct.
    9079              :            Otherwise this is an error.
    9080              : 
    9081              :          Oh what a horrid tangled web we weave.  I wonder if MS consciously
    9082              :          took this from Plan 9 or if it was an accident of implementation
    9083              :          that took root before someone noticed the bug...  */
    9084              : 
    9085        10925 :       tree type = declspecs->type;
    9086        10925 :       bool ok = false;
    9087              : 
    9088        10925 :       if (RECORD_OR_UNION_TYPE_P (type)
    9089        10919 :           && (flag_ms_extensions
    9090        10890 :               || flag_plan9_extensions
    9091        10859 :               || !declspecs->typedef_p))
    9092              :         {
    9093        10912 :           if (flag_ms_extensions || flag_plan9_extensions)
    9094              :             ok = true;
    9095        10852 :           else if (TYPE_NAME (type) == NULL)
    9096              :             ok = true;
    9097              :           else
    9098              :             ok = false;
    9099              :         }
    9100              :       if (!ok)
    9101              :         {
    9102           29 :           pedwarn (loc, 0, "declaration does not declare anything");
    9103           29 :           return NULL_TREE;
    9104              :         }
    9105        10896 :       if (flag_isoc99)
    9106        10874 :         pedwarn_c99 (loc, OPT_Wpedantic,
    9107              :                      "ISO C99 doesn%'t support unnamed structs/unions");
    9108              :       else
    9109           22 :         pedwarn_c99 (loc, OPT_Wpedantic,
    9110              :                      "ISO C90 doesn%'t support unnamed structs/unions");
    9111              :     }
    9112              : 
    9113      4384568 :   value = grokdeclarator (declarator, declspecs, FIELD, false,
    9114      4384568 :                           width ? &width : NULL, decl_attrs, expr, NULL,
    9115              :                           DEPRECATED_NORMAL);
    9116              : 
    9117              :   /* When this field has name, its type is a top level type, we should
    9118              :      call verify_counted_by_for_top_anonymous_type.  */
    9119      4384568 :   if (DECL_NAME (value) != NULL_TREE
    9120      4384568 :       && declspecs->typespec_kind == ctsk_tagdef)
    9121       156553 :     verify_counted_by_for_top_anonymous_type (declspecs->type);
    9122              : 
    9123      4384568 :   finish_decl (value, loc, NULL_TREE, NULL_TREE, NULL_TREE);
    9124      4384568 :   DECL_INITIAL (value) = width;
    9125      4384568 :   if (width)
    9126        55230 :     SET_DECL_C_BIT_FIELD (value);
    9127              : 
    9128      4384568 :   if (warn_cxx_compat && DECL_NAME (value) != NULL_TREE)
    9129              :     {
    9130              :       /* If we currently have a binding for this field, set the
    9131              :          in_struct field in the binding, so that we warn about lookups
    9132              :          which find it.  */
    9133        98638 :       struct c_binding *b = I_SYMBOL_BINDING (DECL_NAME (value));
    9134        98638 :       if (b != NULL)
    9135              :         {
    9136              :           /* If the in_struct field is not yet set, push it on a list
    9137              :              to be cleared when this struct is finished.  */
    9138          476 :           if (!b->in_struct)
    9139              :             {
    9140          474 :               struct_parse_info->fields.safe_push (b);
    9141          474 :               b->in_struct = 1;
    9142              :             }
    9143              :         }
    9144              :     }
    9145              : 
    9146              :   return value;
    9147              : }
    9148              : 
    9149              : /* Subroutine of detect_field_duplicates: return whether X and Y,
    9150              :    which are both fields in the same struct, have duplicate field
    9151              :    names.  */
    9152              : 
    9153              : static bool
    9154      4375898 : is_duplicate_field (tree x, tree y)
    9155              : {
    9156      4375898 :   if (DECL_NAME (x) != NULL_TREE && DECL_NAME (x) == DECL_NAME (y))
    9157              :     return true;
    9158              : 
    9159              :   /* When using -fplan9-extensions, an anonymous field whose name is a
    9160              :      typedef can duplicate a field name.  */
    9161      4375897 :   if (flag_plan9_extensions
    9162      4375897 :       && (DECL_NAME (x) == NULL_TREE || DECL_NAME (y) == NULL_TREE))
    9163              :     {
    9164            0 :       tree xt, xn, yt, yn;
    9165              : 
    9166            0 :       xt = TREE_TYPE (x);
    9167            0 :       if (DECL_NAME (x) != NULL_TREE)
    9168            0 :         xn = DECL_NAME (x);
    9169            0 :       else if (RECORD_OR_UNION_TYPE_P (xt)
    9170            0 :                && TYPE_NAME (xt) != NULL_TREE
    9171            0 :                && TREE_CODE (TYPE_NAME (xt)) == TYPE_DECL)
    9172            0 :         xn = DECL_NAME (TYPE_NAME (xt));
    9173              :       else
    9174              :         xn = NULL_TREE;
    9175              : 
    9176            0 :       yt = TREE_TYPE (y);
    9177            0 :       if (DECL_NAME (y) != NULL_TREE)
    9178            0 :         yn = DECL_NAME (y);
    9179            0 :       else if (RECORD_OR_UNION_TYPE_P (yt)
    9180            0 :                && TYPE_NAME (yt) != NULL_TREE
    9181            0 :                && TREE_CODE (TYPE_NAME (yt)) == TYPE_DECL)
    9182            0 :         yn = DECL_NAME (TYPE_NAME (yt));
    9183              :       else
    9184              :         yn = NULL_TREE;
    9185              : 
    9186            0 :       if (xn != NULL_TREE && xn == yn)
    9187              :         return true;
    9188              :     }
    9189              : 
    9190              :   return false;
    9191              : }
    9192              : 
    9193              : /* Subroutine of detect_field_duplicates: add the fields of FIELDLIST
    9194              :    to HTAB, giving errors for any duplicates.  */
    9195              : 
    9196              : static void
    9197        82216 : detect_field_duplicates_hash (tree fieldlist,
    9198              :                               hash_table<nofree_ptr_hash <tree_node> > *htab)
    9199              : {
    9200        82216 :   tree x, y;
    9201        82216 :   tree_node **slot;
    9202              : 
    9203      1428256 :   for (x = fieldlist; x ; x = DECL_CHAIN (x))
    9204      1346040 :     if ((y = DECL_NAME (x)) != NULL_TREE)
    9205              :       {
    9206      1324991 :         slot = htab->find_slot (y, INSERT);
    9207      1324991 :         if (*slot)
    9208              :           {
    9209           15 :             error ("duplicate member %q+D", x);
    9210           15 :             DECL_NAME (x) = NULL_TREE;
    9211              :           }
    9212      1324991 :         *slot = y;
    9213              :       }
    9214        21049 :     else if (RECORD_OR_UNION_TYPE_P (TREE_TYPE (x)))
    9215              :       {
    9216        11693 :         detect_field_duplicates_hash (TYPE_FIELDS (TREE_TYPE (x)), htab);
    9217              : 
    9218              :         /* When using -fplan9-extensions, an anonymous field whose
    9219              :            name is a typedef can duplicate a field name.  */
    9220        11693 :         if (flag_plan9_extensions
    9221           31 :             && TYPE_NAME (TREE_TYPE (x)) != NULL_TREE
    9222        11723 :             && TREE_CODE (TYPE_NAME (TREE_TYPE (x))) == TYPE_DECL)
    9223              :           {
    9224           10 :             tree xn = DECL_NAME (TYPE_NAME (TREE_TYPE (x)));
    9225           10 :             slot = htab->find_slot (xn, INSERT);
    9226           10 :             if (*slot)
    9227            0 :               error ("duplicate member %q+D", TYPE_NAME (TREE_TYPE (x)));
    9228           10 :             *slot = xn;
    9229              :           }
    9230              :       }
    9231        82216 : }
    9232              : 
    9233              : /* Generate an error for any duplicate field names in FIELDLIST.  Munge
    9234              :    the list such that this does not present a problem later.  */
    9235              : 
    9236              : static void
    9237      1199972 : detect_field_duplicates (tree fieldlist)
    9238              : {
    9239      1199972 :   tree x, y;
    9240      1199972 :   int timeout = 10;
    9241              : 
    9242              :   /* If the struct is the list of instance variables of an Objective-C
    9243              :      class, then we need to check all the instance variables of
    9244              :      superclasses when checking for duplicates (since you can't have
    9245              :      an instance variable in a subclass with the same name as an
    9246              :      instance variable in a superclass).  We pass on this job to the
    9247              :      Objective-C compiler.  objc_detect_field_duplicates() will return
    9248              :      false if we are not checking the list of instance variables and
    9249              :      the C frontend should proceed with the standard field duplicate
    9250              :      checks.  If we are checking the list of instance variables, the
    9251              :      ObjC frontend will do the check, emit the errors if needed, and
    9252              :      then return true.  */
    9253      1199972 :   if (c_dialect_objc ())
    9254            0 :     if (objc_detect_field_duplicates (false))
    9255              :       return;
    9256              : 
    9257              :   /* First, see if there are more than "a few" fields.
    9258              :      This is trivially true if there are zero or one fields.  */
    9259      1199972 :   if (!fieldlist || !DECL_CHAIN (fieldlist))
    9260              :     return;
    9261              :   x = fieldlist;
    9262      3539362 :   do {
    9263      3539362 :     timeout--;
    9264      3539362 :     if (DECL_NAME (x) == NULL_TREE
    9265      3539362 :         && RECORD_OR_UNION_TYPE_P (TREE_TYPE (x)))
    9266              :       timeout = 0;
    9267      3539362 :     x = DECL_CHAIN (x);
    9268      3539362 :   } while (timeout > 0 && x);
    9269              : 
    9270              :   /* If there were "few" fields and no anonymous structures or unions,
    9271              :      avoid the overhead of allocating a hash table.  Instead just do
    9272              :      the nested traversal thing.  */
    9273       990960 :   if (timeout > 0)
    9274              :     {
    9275      2868471 :       for (x = DECL_CHAIN (fieldlist); x; x = DECL_CHAIN (x))
    9276              :         /* When using -fplan9-extensions, we can have duplicates
    9277              :            between typedef names and fields.  */
    9278      1948034 :         if (DECL_NAME (x)
    9279      1948034 :             || (flag_plan9_extensions
    9280            0 :                 && DECL_NAME (x) == NULL_TREE
    9281            0 :                 && RECORD_OR_UNION_TYPE_P (TREE_TYPE (x))
    9282            0 :                 && TYPE_NAME (TREE_TYPE (x)) != NULL_TREE
    9283            0 :                 && TREE_CODE (TYPE_NAME (TREE_TYPE (x))) == TYPE_DECL))
    9284              :           {
    9285      6321848 :             for (y = fieldlist; y != x; y = TREE_CHAIN (y))
    9286      4375898 :               if (is_duplicate_field (y, x))
    9287              :                 {
    9288            1 :                   error ("duplicate member %q+D", x);
    9289            1 :                   DECL_NAME (x) = NULL_TREE;
    9290              :                 }
    9291              :           }
    9292              :     }
    9293              :   else
    9294              :     {
    9295        70523 :       hash_table<nofree_ptr_hash <tree_node> > htab (37);
    9296        70523 :       detect_field_duplicates_hash (fieldlist, &htab);
    9297        70523 :     }
    9298              : }
    9299              : 
    9300              : /* Finish up struct info used by -Wc++-compat.  */
    9301              : 
    9302              : static void
    9303        21413 : warn_cxx_compat_finish_struct (tree fieldlist, enum tree_code code,
    9304              :                                location_t record_loc)
    9305              : {
    9306        21413 :   unsigned int ix;
    9307        21413 :   tree x;
    9308        21413 :   struct c_binding *b;
    9309              : 
    9310        21413 :   if (fieldlist == NULL_TREE)
    9311              :     {
    9312            9 :       if (code == RECORD_TYPE)
    9313            6 :         warning_at (record_loc, OPT_Wc___compat,
    9314              :                     "empty struct has size 0 in C, size 1 in C++");
    9315              :       else
    9316            3 :         warning_at (record_loc, OPT_Wc___compat,
    9317              :                     "empty union has size 0 in C, size 1 in C++");
    9318              :     }
    9319              : 
    9320              :   /* Set the C_TYPE_DEFINED_IN_STRUCT flag for each type defined in
    9321              :      the current struct.  We do this now at the end of the struct
    9322              :      because the flag is used to issue visibility warnings, and we
    9323              :      only want to issue those warnings if the type is referenced
    9324              :      outside of the struct declaration.  */
    9325        25249 :   FOR_EACH_VEC_ELT (struct_parse_info->struct_types, ix, x)
    9326         3836 :     C_TYPE_DEFINED_IN_STRUCT (x) = 1;
    9327              : 
    9328              :   /* The TYPEDEFS_SEEN field of STRUCT_PARSE_INFO is a list of
    9329              :      typedefs used when declaring fields in this struct.  If the name
    9330              :      of any of the fields is also a typedef name then the struct would
    9331              :      not parse in C++, because the C++ lookup rules say that the
    9332              :      typedef name would be looked up in the context of the struct, and
    9333              :      would thus be the field rather than the typedef.  */
    9334        21413 :   if (!struct_parse_info->typedefs_seen.is_empty ()
    9335         9495 :       && fieldlist != NULL_TREE)
    9336              :     {
    9337              :       /* Use a hash_set<tree> using the name of the typedef.  We can use
    9338              :          a hash_set<tree> because identifiers are interned.  */
    9339         9495 :       hash_set<tree> tset;
    9340              : 
    9341        38644 :       FOR_EACH_VEC_ELT (struct_parse_info->typedefs_seen, ix, x)
    9342        19654 :         tset.add (DECL_NAME (x));
    9343              : 
    9344        69561 :       for (x = fieldlist; x != NULL_TREE; x = DECL_CHAIN (x))
    9345              :         {
    9346        60066 :           if (DECL_NAME (x) != NULL_TREE
    9347        60066 :               && tset.contains (DECL_NAME (x)))
    9348              :             {
    9349            2 :               warning_at (DECL_SOURCE_LOCATION (x), OPT_Wc___compat,
    9350              :                           "using %qD as both field and typedef name is "
    9351              :                           "invalid in C++", x);
    9352              :               /* FIXME: It would be nice to report the location where
    9353              :                  the typedef name is used.  */
    9354              :             }
    9355              :         }
    9356         9495 :     }
    9357              : 
    9358              :   /* For each field which has a binding and which was not defined in
    9359              :      an enclosing struct, clear the in_struct field.  */
    9360        21887 :   FOR_EACH_VEC_ELT (struct_parse_info->fields, ix, b)
    9361          474 :     b->in_struct = 0;
    9362        21413 : }
    9363              : 
    9364              : /* Function to help qsort sort FIELD_DECLs by name order.  */
    9365              : 
    9366              : static int
    9367     20321206 : field_decl_cmp (const void *x_p, const void *y_p)
    9368              : {
    9369     20321206 :   const tree *const x = (const tree *) x_p;
    9370     20321206 :   const tree *const y = (const tree *) y_p;
    9371              : 
    9372     20321206 :   if (DECL_NAME (*x) == DECL_NAME (*y))
    9373              :     /* A nontype is "greater" than a type.  */
    9374            0 :     return (TREE_CODE (*y) == TYPE_DECL) - (TREE_CODE (*x) == TYPE_DECL);
    9375     20321206 :   if (DECL_NAME (*x) == NULL_TREE)
    9376              :     return -1;
    9377     20321206 :   if (DECL_NAME (*y) == NULL_TREE)
    9378              :     return 1;
    9379     20321206 :   if (DECL_NAME (*x) < DECL_NAME (*y))
    9380     10012821 :     return -1;
    9381              :   return 1;
    9382              : }
    9383              : 
    9384              : /* If this structure or union completes the type of any previous
    9385              :    variable declaration, lay it out and output its rtl.  */
    9386              : static void
    9387      1387591 : finish_incomplete_vars (tree incomplete_vars, bool toplevel)
    9388              : {
    9389      1387740 :   for (tree x = incomplete_vars; x; x = TREE_CHAIN (x))
    9390              :     {
    9391          149 :       tree decl = TREE_VALUE (x);
    9392          149 :       if (TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE)
    9393            0 :         layout_array_type (TREE_TYPE (decl));
    9394          149 :       if (TREE_CODE (decl) != TYPE_DECL)
    9395              :         {
    9396          149 :           relayout_decl (decl);
    9397          149 :           if (c_dialect_objc ())
    9398            0 :             objc_check_decl (decl);
    9399          149 :           rest_of_decl_compilation (decl, toplevel, 0);
    9400              :         }
    9401              :     }
    9402      1387591 : }
    9403              : 
    9404              : /* Determine whether the FIELD_DECL X is a flexible array member according to
    9405              :    the following info:
    9406              :   A. whether the FIELD_DECL X is the last field of the DECL_CONTEXT;
    9407              :   B. whether the FIELD_DECL is an array that is declared as "[]", "[0]",
    9408              :      or "[1]";
    9409              :   C. flag_strict_flex_arrays;
    9410              :   D. the attribute strict_flex_array that is attached to the field
    9411              :      if presenting.
    9412              :   Return TRUE when it's a flexible array member, FALSE otherwise.  */
    9413              : 
    9414              : static bool
    9415      4384719 : is_flexible_array_member_p (bool is_last_field,
    9416              :                             tree x)
    9417              : {
    9418              :   /* If not the last field, return false.  */
    9419      4384719 :   if (!is_last_field)
    9420              :     return false;
    9421              : 
    9422              :   /* If not an array field, return false.  */
    9423      1683098 :   if (TREE_CODE (TREE_TYPE (x)) != ARRAY_TYPE)
    9424              :     return false;
    9425              : 
    9426       543063 :   bool is_zero_length_array = zero_length_array_type_p (TREE_TYPE (x));
    9427       543063 :   bool is_one_element_array = one_element_array_type_p (TREE_TYPE (x));
    9428       543063 :   bool is_flexible_array = flexible_array_member_type_p (TREE_TYPE (x));
    9429              : 
    9430       543063 :   unsigned int strict_flex_array_level = c_strict_flex_array_level_of (x);
    9431              : 
    9432       543063 :   switch (strict_flex_array_level)
    9433              :     {
    9434              :       case 0:
    9435              :         /* Default, all trailing arrays are flexible array members.  */
    9436              :         return true;
    9437           77 :       case 1:
    9438              :         /* Level 1: all "[1]", "[0]", and "[]" are flexible array members.  */
    9439           77 :         if (is_one_element_array)
    9440              :           return true;
    9441              :         /* FALLTHROUGH.  */
    9442          141 :       case 2:
    9443              :         /* Level 2: all "[0]", and "[]" are flexible array members.  */
    9444          141 :         if (is_zero_length_array)
    9445              :           return true;
    9446              :         /* FALLTHROUGH.  */
    9447          201 :       case 3:
    9448              :         /* Level 3: Only "[]" are flexible array members.  */
    9449          201 :         if (is_flexible_array)
    9450              :           return true;
    9451              :         break;
    9452            0 :       default:
    9453            0 :         gcc_unreachable ();
    9454              :     }
    9455              :   return false;
    9456              : }
    9457              : 
    9458              : /* Recompute TYPE_CANONICAL for variants of the type including qualified
    9459              :    versions of the type and related pointer types after an aggregate type
    9460              :    has been finalized.
    9461              :    Will not update array types, pointers to array types, function
    9462              :    types and other derived types created while the type was still
    9463              :    incomplete, those will remain TYPE_STRUCTURAL_EQUALITY_P.  */
    9464              : 
    9465              : static void
    9466      1224730 : c_update_type_canonical (tree t)
    9467              : {
    9468      1224730 :   gcc_checking_assert (TYPE_MAIN_VARIANT (t) == t && !TYPE_QUALS (t));
    9469      2476694 :   for (tree x = t, l = NULL_TREE; x; l = x, x = TYPE_NEXT_VARIANT (x))
    9470              :     {
    9471      1251964 :       if (x != t && TYPE_STRUCTURAL_EQUALITY_P (x))
    9472              :         {
    9473        27234 :           if (!TYPE_QUALS (x))
    9474        26599 :             TYPE_CANONICAL (x) = TYPE_CANONICAL (t);
    9475              :           else
    9476              :             {
    9477          635 :               tree
    9478          635 :                 c = c_build_qualified_type (TYPE_CANONICAL (t), TYPE_QUALS (x));
    9479          635 :               if (TYPE_STRUCTURAL_EQUALITY_P (c))
    9480              :                 {
    9481          206 :                   gcc_checking_assert (TYPE_CANONICAL (t) == t);
    9482          206 :                   if (c == x)
    9483          206 :                     TYPE_CANONICAL (x) = x;
    9484              :                   else
    9485              :                     {
    9486              :                       /* build_qualified_type for this function unhelpfully
    9487              :                          moved c from some later spot in TYPE_MAIN_VARIANT (t)
    9488              :                          chain to right after t (or created it there).  Move
    9489              :                          it right before x and process c and then x.  */
    9490            0 :                       gcc_checking_assert (TYPE_NEXT_VARIANT (t) == c);
    9491            0 :                       if (l != t)
    9492              :                         {
    9493            0 :                           TYPE_NEXT_VARIANT (t) = TYPE_NEXT_VARIANT (c);
    9494            0 :                           TYPE_NEXT_VARIANT (l) = c;
    9495            0 :                           TYPE_NEXT_VARIANT (c) = x;
    9496              :                         }
    9497            0 :                       TYPE_CANONICAL (c) = c;
    9498            0 :                       x = c;
    9499              :                     }
    9500              :                 }
    9501              :               else
    9502          429 :                 TYPE_CANONICAL (x) = TYPE_CANONICAL (c);
    9503              :             }
    9504              :         }
    9505      1224730 :       else if (x != t)
    9506            0 :         continue;
    9507      1322155 :       for (tree p = TYPE_POINTER_TO (x); p; p = TYPE_NEXT_PTR_TO (p))
    9508              :         {
    9509        70191 :           if (!TYPE_STRUCTURAL_EQUALITY_P (p))
    9510            0 :             continue;
    9511        70191 :           if (TYPE_CANONICAL (x) != x || TYPE_REF_CAN_ALIAS_ALL (p))
    9512        68061 :             TYPE_CANONICAL (p)
    9513       136122 :               = c_build_pointer_type_for_mode (TYPE_CANONICAL (x), TYPE_MODE (p),
    9514              :                                                false);
    9515              :           else
    9516         2130 :             TYPE_CANONICAL (p) = p;
    9517        70191 :           c_update_type_canonical (p);
    9518              :         }
    9519              :     }
    9520      1224730 : }
    9521              : 
    9522              : 
    9523              : /* We set C_TYPE_VARIABLY_MODIFIED for derived types.  We will not update
    9524              :    array types, pointers to array types, function types and other derived
    9525              :    types created while the type was still incomplete.  We need to update
    9526              :    at least all types for which TYPE_CANONICAL will bet set, because for
    9527              :    those we later assume (in c_variably_modified_p) that the bit is
    9528              :    up-to-date.  */
    9529              : 
    9530              : static void
    9531          735 : c_update_variably_modified (tree t)
    9532              : {
    9533         1479 :   for (tree x = t; x; x = TYPE_NEXT_VARIANT (x))
    9534              :     {
    9535          744 :       C_TYPE_VARIABLY_MODIFIED (x) = 1;
    9536          762 :       for (tree p = TYPE_POINTER_TO (x); p; p = TYPE_NEXT_PTR_TO (p))
    9537           18 :         c_update_variably_modified (p);
    9538              :     }
    9539          735 : }
    9540              : 
    9541              : 
    9542              : /* Verify the argument of the counted_by attribute of each field of
    9543              :    the containing structure, OUTMOST_STRUCT_TYPE, including its inner
    9544              :    anonymous struct/union, Report error and remove the corresponding
    9545              :    attribute when it's not.  */
    9546              : 
    9547              : static void
    9548          534 : verify_counted_by_attribute (tree outmost_struct_type,
    9549              :                              tree cur_struct_type)
    9550              : {
    9551         1718 :   for (tree field = TYPE_FIELDS (cur_struct_type); field;
    9552         1184 :        field = TREE_CHAIN (field))
    9553              :     {
    9554         1184 :       if (flexible_array_member_type_p (TREE_TYPE (field))
    9555         1184 :            || TREE_CODE (TREE_TYPE (field)) == POINTER_TYPE)
    9556              :         {
    9557          404 :           tree attr_counted_by = lookup_attribute ("counted_by",
    9558          404 :                                                    DECL_ATTRIBUTES (field));
    9559              : 
    9560          404 :           if (!attr_counted_by)
    9561            1 :             continue;
    9562              : 
    9563              :           /* If there is an counted_by attribute attached to the field,
    9564              :              verify it.  */
    9565              : 
    9566          403 :           tree fieldname = TREE_VALUE (TREE_VALUE (attr_counted_by));
    9567              : 
    9568              :           /* Verify the argument of the attribute is a valid field of the
    9569              :              containing structure.  */
    9570              : 
    9571          403 :           tree counted_by_field = lookup_field (outmost_struct_type,
    9572              :                                                 fieldname);
    9573              : 
    9574              :           /* Error when the field is not found in the containing structure
    9575              :              and remove the corresponding counted_by attribute from the
    9576              :              field_decl.  */
    9577          403 :           if (!counted_by_field)
    9578              :             {
    9579           24 :               error_at (DECL_SOURCE_LOCATION (field),
    9580              :                     "argument %qE to the %<counted_by%> attribute"
    9581              :                     " is not a field declaration in the same structure"
    9582              :                     " as %qD", fieldname, field);
    9583           24 :               DECL_ATTRIBUTES (field)
    9584           48 :                 = remove_attribute ("counted_by", DECL_ATTRIBUTES (field));
    9585              :             }
    9586              :           else
    9587              :           /* Error when the field is not with an integer type.  */
    9588              :             {
    9589          580 :               while (TREE_CHAIN (counted_by_field))
    9590          201 :                 counted_by_field = TREE_CHAIN (counted_by_field);
    9591          379 :               tree real_field = TREE_VALUE (counted_by_field);
    9592              : 
    9593          379 :               if (!INTEGRAL_TYPE_P (TREE_TYPE (real_field)))
    9594              :                 {
    9595            6 :                   error_at (DECL_SOURCE_LOCATION (field),
    9596              :                         "argument %qE to the %<counted_by%> attribute"
    9597              :                         " is not a field declaration with an integer type",
    9598              :                         fieldname);
    9599            6 :                   DECL_ATTRIBUTES (field)
    9600           12 :                     = remove_attribute ("counted_by",
    9601            6 :                                     DECL_ATTRIBUTES (field));
    9602              :                 }
    9603              :             }
    9604              :         }
    9605         1463 :       else if (RECORD_OR_UNION_TYPE_P (TREE_TYPE (field))
    9606          871 :                && (DECL_NAME (field) == NULL_TREE))
    9607          188 :         verify_counted_by_attribute (outmost_struct_type, TREE_TYPE (field));
    9608              :     }
    9609          534 : }
    9610              : 
    9611              : /* Caller should make sure the TYPE is a top-level type (i.e. not being
    9612              :    nested in other structure/uniona). For such type, verify its counted_by
    9613              :    if it is an anonymous structure/union.  */
    9614              : 
    9615              : void
    9616      1376598 : verify_counted_by_for_top_anonymous_type (tree type)
    9617              : {
    9618      1376598 :   if (!RECORD_OR_UNION_TYPE_P (type))
    9619              :     return;
    9620              : 
    9621      1188986 :   if (C_TYPE_FIELDS_HAS_COUNTED_BY (type)
    9622      1188986 :       && c_type_tag (type) == NULL_TREE)
    9623           48 :     verify_counted_by_attribute (type, type);
    9624              : }
    9625              : 
    9626              : /* TYPE is a struct or union that we're applying may_alias to after the body is
    9627              :    parsed.  Fixup any POINTER_TO types.  */
    9628              : 
    9629              : static void
    9630          363 : c_fixup_may_alias (tree type)
    9631              : {
    9632          428 :   for (tree t = TYPE_POINTER_TO (type); t; t = TYPE_NEXT_PTR_TO (t))
    9633          190 :     for (tree v = TYPE_MAIN_VARIANT (t); v; v = TYPE_NEXT_VARIANT (v))
    9634          125 :       TYPE_REF_CAN_ALIAS_ALL (v) = true;
    9635          363 : }
    9636              : 
    9637              : /* Fill in the fields of a RECORD_TYPE or UNION_TYPE node, T.
    9638              :    LOC is the location of the RECORD_TYPE or UNION_TYPE's definition.
    9639              :    FIELDLIST is a chain of FIELD_DECL nodes for the fields.
    9640              :    ATTRIBUTES are attributes to be applied to the structure.
    9641              : 
    9642              :    ENCLOSING_STRUCT_PARSE_INFO is the value of STRUCT_PARSE_INFO when
    9643              :    the struct was started.  */
    9644              : 
    9645              : tree
    9646      1199972 : finish_struct (location_t loc, tree t, tree fieldlist, tree attributes,
    9647              :                class c_struct_parse_info *enclosing_struct_parse_info,
    9648              :                tree *expr)
    9649              : {
    9650      1199972 :   tree x;
    9651      1199972 :   bool toplevel = file_scope == current_scope;
    9652              : 
    9653              :   /* If this type was previously laid out as a forward reference,
    9654              :      make sure we lay it out again.  */
    9655              : 
    9656      1199972 :   TYPE_SIZE (t) = NULL_TREE;
    9657              : 
    9658      1199972 :   decl_attributes (&t, attributes, (int) ATTR_FLAG_TYPE_IN_PLACE);
    9659              : 
    9660      1199972 :   if (pedantic)
    9661              :     {
    9662         6904 :       for (x = fieldlist; x; x = DECL_CHAIN (x))
    9663              :         {
    9664         6885 :           if (DECL_NAME (x) != NULL_TREE)
    9665              :             break;
    9666           25 :           if (flag_isoc11 && RECORD_OR_UNION_TYPE_P (TREE_TYPE (x)))
    9667              :             break;
    9668              :         }
    9669              : 
    9670         6886 :       if (x == NULL_TREE)
    9671              :         {
    9672           19 :           if (TREE_CODE (t) == UNION_TYPE)
    9673              :             {
    9674            5 :               if (fieldlist)
    9675            2 :                 pedwarn (loc, OPT_Wpedantic, "union has no named members");
    9676              :               else
    9677            3 :                 pedwarn (loc, OPT_Wpedantic, "union has no members");
    9678              :             }
    9679              :           else
    9680              :             {
    9681           14 :               if (fieldlist)
    9682            3 :                 pedwarn (loc, OPT_Wpedantic, "struct has no named members");
    9683              :               else
    9684           11 :                 pedwarn (loc, OPT_Wpedantic, "struct has no members");
    9685              :             }
    9686              :         }
    9687              :     }
    9688              : 
    9689              :   /* Install struct as DECL_CONTEXT of each field decl.
    9690              :      Also process specified field sizes, found in the DECL_INITIAL,
    9691              :      storing 0 there after the type has been changed to precision equal
    9692              :      to its width, rather than the precision of the specified standard
    9693              :      type.  (Correct layout requires the original type to have been preserved
    9694              :      until now.)  */
    9695              : 
    9696      1199972 :   bool saw_named_field = false;
    9697      5584731 :   for (x = fieldlist; x; x = DECL_CHAIN (x))
    9698              :     {
    9699              :       /* Whether this field is the last field of the structure or union.
    9700              :          for UNION, any field is the last field of it.  */
    9701      4384759 :       bool is_last_field = (DECL_CHAIN (x) == NULL_TREE)
    9702      4384759 :                             || (TREE_CODE (t) == UNION_TYPE);
    9703              : 
    9704      4384759 :       if (TREE_TYPE (x) == error_mark_node)
    9705           40 :         continue;
    9706              : 
    9707      4384719 :       DECL_CONTEXT (x) = t;
    9708              : 
    9709      4384719 :       tree t1 = strip_array_types (TREE_TYPE (x));
    9710              :       /* If any field is const, the structure type is pseudo-const.  */
    9711      4384719 :       if (TREE_READONLY (x))
    9712        64248 :         C_TYPE_FIELDS_READONLY (t) = 1;
    9713              :       else
    9714              :         {
    9715              :           /* A field that is pseudo-const makes the structure likewise.  */
    9716      4320471 :           if (RECORD_OR_UNION_TYPE_P (t1) && C_TYPE_FIELDS_READONLY (t1))
    9717          641 :             C_TYPE_FIELDS_READONLY (t) = 1;
    9718              :         }
    9719              : 
    9720              :       /* Any field that is volatile means variables of this type must be
    9721              :          treated in some ways as volatile.  */
    9722      4384719 :       if (TREE_THIS_VOLATILE (x))
    9723              :         {
    9724          659 :           C_TYPE_FIELDS_VOLATILE (t) = 1;
    9725          659 :           C_TYPE_FIELDS_NON_CONSTEXPR (t) = 1;
    9726              :         }
    9727              : 
    9728              :       /* Any field that is volatile, restrict-qualified or atomic
    9729              :          means the type cannot be used for a constexpr object.  */
    9730      4384719 :       if (TYPE_QUALS (t1)
    9731      4384719 :           .has (TYPE_QUAL_VOLATILE | TYPE_QUAL_RESTRICT | TYPE_QUAL_ATOMIC))
    9732         1652 :         C_TYPE_FIELDS_NON_CONSTEXPR (t) = 1;
    9733      4383067 :       else if (RECORD_OR_UNION_TYPE_P (t1) && C_TYPE_FIELDS_NON_CONSTEXPR (t1))
    9734          179 :             C_TYPE_FIELDS_NON_CONSTEXPR (t) = 1;
    9735              : 
    9736              :       /* Any field of nominal variable size implies structure is too.  */
    9737      4384719 :       if (C_DECL_VARIABLE_SIZE (x))
    9738          698 :         C_TYPE_VARIABLE_SIZE (t) = 1;
    9739              : 
    9740              :       /* If any field is variably modified, record this fact. */
    9741      4384719 :       if (c_type_variably_modified_p (TREE_TYPE (x)))
    9742          778 :         C_TYPE_VARIABLY_MODIFIED (t) = 1;
    9743              : 
    9744      4384719 :       if (DECL_C_BIT_FIELD (x))
    9745              :         {
    9746        55239 :           unsigned HOST_WIDE_INT width = tree_to_uhwi (DECL_INITIAL (x));
    9747        55239 :           DECL_SIZE (x) = bitsize_int (width);
    9748        55239 :           DECL_BIT_FIELD (x) = 1;
    9749              :         }
    9750              : 
    9751      4384719 :       if (TYPE_PACKED (t)
    9752      4390353 :           && (DECL_BIT_FIELD (x)
    9753         3258 :               || TYPE_ALIGN (TREE_TYPE (x)) > BITS_PER_UNIT))
    9754         4512 :         DECL_PACKED (x) = 1;
    9755              : 
    9756              :       /* Detect flexible array member in an invalid context.  */
    9757      4384719 :       if (flexible_array_member_type_p (TREE_TYPE (x)))
    9758              :         {
    9759        86062 :           if (TREE_CODE (t) == UNION_TYPE)
    9760           31 :             pedwarn (DECL_SOURCE_LOCATION (x), OPT_Wpedantic,
    9761              :                      "flexible array member in union is a GCC extension");
    9762        86031 :           else if (!is_last_field)
    9763              :             {
    9764            3 :               error_at (DECL_SOURCE_LOCATION (x),
    9765              :                         "flexible array member not at end of struct");
    9766            3 :               TREE_TYPE (x) = error_mark_node;
    9767              :             }
    9768        86028 :           else if (!saw_named_field)
    9769           39 :             pedwarn (DECL_SOURCE_LOCATION (x), OPT_Wpedantic,
    9770              :                      "flexible array member in a struct with no named "
    9771              :                      "members is a GCC extension");
    9772        86062 :           if (lookup_attribute ("counted_by", DECL_ATTRIBUTES (x)))
    9773          135 :             C_TYPE_FIELDS_HAS_COUNTED_BY (t) = 1;
    9774              :         }
    9775              : 
    9776      4384719 :       if (TREE_CODE (TREE_TYPE (x)) == POINTER_TYPE
    9777      4384719 :           && lookup_attribute ("counted_by", DECL_ATTRIBUTES (x)))
    9778          268 :         C_TYPE_FIELDS_HAS_COUNTED_BY (t) = 1;
    9779              : 
    9780              :       /* If the field is an anonymous structure that includes a field
    9781              :          with counted_by attribute, this structure should also be marked
    9782              :          too.  */
    9783      8386164 :       if (RECORD_OR_UNION_TYPE_P (TREE_TYPE (x))
    9784       476065 :           && C_TYPE_FIELDS_HAS_COUNTED_BY (TREE_TYPE (x))
    9785           19 :           && DECL_NAME (x) == NULL_TREE
    9786      4384732 :           && c_type_tag (TREE_TYPE (x)) == NULL_TREE)
    9787           12 :         C_TYPE_FIELDS_HAS_COUNTED_BY (t) = 1;
    9788              : 
    9789        23161 :       if (pedantic && TREE_CODE (t) == RECORD_TYPE
    9790      4403903 :           && flexible_array_type_p (TREE_TYPE (x)))
    9791           18 :         pedwarn (DECL_SOURCE_LOCATION (x), OPT_Wpedantic,
    9792              :                  "invalid use of structure with flexible array member");
    9793              : 
    9794              :       /* Set DECL_NOT_FLEXARRAY flag for FIELD_DECL x.  */
    9795      4384719 :       DECL_NOT_FLEXARRAY (x) = !is_flexible_array_member_p (is_last_field, x);
    9796              : 
    9797              :       /* Set TYPE_INCLUDES_FLEXARRAY for the context of x, t.
    9798              :          when x is an array and is the last field.
    9799              :          There is only one last_field for a structure type, but there might
    9800              :          be multiple last_fields for a union type, therefore we should ORed
    9801              :          the result for multiple last_fields.  */
    9802      4384719 :       if (TREE_CODE (TREE_TYPE (x)) == ARRAY_TYPE)
    9803       702912 :         TYPE_INCLUDES_FLEXARRAY (t)
    9804      1405824 :           |= is_last_field && flexible_array_member_type_p (TREE_TYPE (x));
    9805              :       /* Recursively set TYPE_INCLUDES_FLEXARRAY for the context of x, t
    9806              :          when x is an union or record and is the last field.  */
    9807      3681807 :       else if (RECORD_OR_UNION_TYPE_P (TREE_TYPE (x)))
    9808       476065 :         TYPE_INCLUDES_FLEXARRAY (t)
    9809       952130 :           |= is_last_field && TYPE_INCLUDES_FLEXARRAY (TREE_TYPE (x));
    9810              : 
    9811      4384719 :       if (warn_flex_array_member_not_at_end
    9812           56 :           && !is_last_field
    9813           22 :           && RECORD_OR_UNION_TYPE_P (TREE_TYPE (x))
    9814      4384731 :           && TYPE_INCLUDES_FLEXARRAY (TREE_TYPE (x)))
    9815            5 :         warning_at (DECL_SOURCE_LOCATION (x),
    9816            5 :                     OPT_Wflex_array_member_not_at_end,
    9817              :                     "structure containing a flexible array member"
    9818              :                     " is not at the end of another structure");
    9819              : 
    9820      4384719 :       if (DECL_NAME (x)
    9821      4384719 :           || RECORD_OR_UNION_TYPE_P (TREE_TYPE (x)))
    9822              :         saw_named_field = true;
    9823              : 
    9824      8066526 :       if (AGGREGATE_TYPE_P (TREE_TYPE (x))
    9825      4860784 :           && TYPE_TYPELESS_STORAGE (TREE_TYPE (x)))
    9826       425442 :         TYPE_TYPELESS_STORAGE (t) = true;
    9827              :     }
    9828              : 
    9829      1199972 :   detect_field_duplicates (fieldlist);
    9830              : 
    9831              :   /* Now we have the nearly final fieldlist.  Record it,
    9832              :      then lay out the structure or union (including the fields).  */
    9833              : 
    9834      1199972 :   TYPE_FIELDS (t) = fieldlist;
    9835              : 
    9836      1199972 :   maybe_apply_pragma_scalar_storage_order (t);
    9837              : 
    9838      1199972 :   layout_type (t);
    9839              : 
    9840      1199972 :   if (TYPE_SIZE_UNIT (t)
    9841      1199972 :       && TREE_CODE (TYPE_SIZE_UNIT (t)) == INTEGER_CST
    9842      1199329 :       && !TREE_OVERFLOW (TYPE_SIZE_UNIT (t))
    9843      2399301 :       && !valid_constant_size_p (TYPE_SIZE_UNIT (t)))
    9844            1 :     error ("type %qT is too large", t);
    9845              : 
    9846              :   /* Give bit-fields their proper types and rewrite the type of array fields
    9847              :      with scalar component if the enclosing type has reverse storage order.  */
    9848      5584731 :   for (tree field = fieldlist; field; field = DECL_CHAIN (field))
    9849              :     {
    9850      4384759 :       if (TREE_CODE (field) == FIELD_DECL
    9851      4384759 :           && DECL_INITIAL (field)
    9852      4440008 :           && TREE_TYPE (field) != error_mark_node)
    9853              :         {
    9854        55239 :           unsigned HOST_WIDE_INT width
    9855        55239 :             = tree_to_uhwi (DECL_INITIAL (field));
    9856        55239 :           tree type = TREE_TYPE (field);
    9857        55239 :           if (VECTOR_TYPE_P (type))
    9858              :             {
    9859            2 :               error_at (DECL_SOURCE_LOCATION (field),
    9860              :                         "bit-field %qD has invalid type", field);
    9861            2 :               type = TREE_TYPE (type);
    9862            2 :               TREE_TYPE (field) = type;
    9863              :             }
    9864        55239 :           if (width != TYPE_PRECISION (type))
    9865              :             {
    9866        38468 :               if (BITINT_TYPE_P (type)
    9867        38801 :                   && width >= ((TYPE_UNSIGNED (type) || flag_isoc2y) ? 1 : 2))
    9868          208 :                 TREE_TYPE (field)
    9869          416 :                   = build_bitint_type (width, TYPE_UNSIGNED (type));
    9870              :               else
    9871        38458 :                 TREE_TYPE (field)
    9872        38458 :                   = c_build_bitfield_integer_type (width,
    9873        38458 :                                                    TYPE_UNSIGNED (type));
    9874        38666 :               if (tree attr = c_hardbool_type_attr (type))
    9875          281 :                 decl_attributes (&TREE_TYPE (field),
    9876              :                                  copy_list (attr),
    9877              :                                  0, NULL_TREE);
    9878        38666 :               SET_DECL_MODE (field, TYPE_MODE (TREE_TYPE (field)));
    9879              :             }
    9880        55239 :           DECL_INITIAL (field) = NULL_TREE;
    9881              :         }
    9882      4329520 :       else if (TYPE_REVERSE_STORAGE_ORDER (t)
    9883          736 :                && TREE_CODE (field) == FIELD_DECL
    9884      4330256 :                && TREE_CODE (TREE_TYPE (field)) == ARRAY_TYPE)
    9885              :         {
    9886          113 :           tree ftype = TREE_TYPE (field);
    9887          113 :           tree ctype = strip_array_types (ftype);
    9888          113 :           if (!RECORD_OR_UNION_TYPE_P (ctype) && TYPE_MODE (ctype) != QImode)
    9889              :             {
    9890          100 :               tree fmain_type = TYPE_MAIN_VARIANT (ftype);
    9891          100 :               tree *typep = &fmain_type;
    9892          102 :               do {
    9893          102 :                 *typep = build_distinct_type_copy (*typep);
    9894          102 :                 TYPE_REVERSE_STORAGE_ORDER (*typep) = 1;
    9895          102 :                 typep = &TREE_TYPE (*typep);
    9896          102 :               } while (TREE_CODE (*typep) == ARRAY_TYPE);
    9897          100 :               TREE_TYPE (field)
    9898          200 :                 = c_build_qualified_type (fmain_type, TYPE_QUALS (ftype));
    9899              :             }
    9900              :         }
    9901              : 
    9902              :       /* Warn on problematic type punning for storage order purposes.  */
    9903      4384759 :       if (TREE_CODE (t) == UNION_TYPE
    9904       869675 :           && TREE_CODE (field) == FIELD_DECL
    9905      5254434 :           && AGGREGATE_TYPE_P (TREE_TYPE (field)))
    9906              :         {
    9907       433192 :           tree ftype = TREE_TYPE (field);
    9908       433192 :           if (TREE_CODE (ftype) == ARRAY_TYPE)
    9909       317853 :             ftype = strip_array_types (ftype);
    9910       433192 :           if (RECORD_OR_UNION_TYPE_P (ftype)
    9911       433192 :               && TYPE_REVERSE_STORAGE_ORDER (ftype)
    9912       115841 :                  != TYPE_REVERSE_STORAGE_ORDER (t))
    9913            1 :             warning_at (DECL_SOURCE_LOCATION (field),
    9914            1 :                         OPT_Wscalar_storage_order,
    9915              :                         "type punning toggles scalar storage order");
    9916              :         }
    9917              :     }
    9918              : 
    9919              :   /* Now we have the truly final field list.
    9920              :      Store it in this type and in the variants.  */
    9921              : 
    9922      1199972 :   TYPE_FIELDS (t) = fieldlist;
    9923              : 
    9924              :   /* If there are lots of fields, sort so we can look through them fast.
    9925              :      We arbitrarily consider 16 or more elts to be "a lot".  */
    9926              : 
    9927      1199972 :   {
    9928      1199972 :     int len = 0;
    9929              : 
    9930      5133788 :     for (x = fieldlist; x; x = DECL_CHAIN (x))
    9931              :       {
    9932      3963249 :         if (len > 15 || DECL_NAME (x) == NULL)
    9933              :           break;
    9934      3933816 :         len += 1;
    9935              :       }
    9936              : 
    9937      1199972 :     if (len > 15)
    9938              :       {
    9939        22789 :         tree *field_array;
    9940        22789 :         struct lang_type *space;
    9941        22789 :         struct sorted_fields_type *space2;
    9942              : 
    9943        22789 :         len += list_length (x);
    9944              : 
    9945              :         /* Use the same allocation policy here that make_node uses, to
    9946              :            ensure that this lives as long as the rest of the struct decl.
    9947              :            All decls in an inline function need to be saved.  */
    9948              : 
    9949        22789 :         space = ((struct lang_type *)
    9950        22789 :                  ggc_internal_cleared_alloc (c_dialect_objc ()
    9951              :                                              ? sizeof (struct lang_type)
    9952              :                                              : offsetof (struct lang_type,
    9953              :                                                          info)));
    9954        22789 :         space2 = ((sorted_fields_type *)
    9955        45578 :                   ggc_internal_alloc (sizeof (struct sorted_fields_type)
    9956        22789 :                                       + len * sizeof (tree)));
    9957              : 
    9958        22789 :         len = 0;
    9959        22789 :         space->s = space2;
    9960        22789 :         field_array = &space2->elts[0];
    9961       800624 :         for (x = fieldlist; x; x = DECL_CHAIN (x))
    9962              :           {
    9963       781293 :             field_array[len++] = x;
    9964              : 
    9965              :             /* If there is anonymous struct or union, break out of the loop.  */
    9966       781293 :             if (DECL_NAME (x) == NULL)
    9967              :               break;
    9968              :           }
    9969              :         /* Found no anonymous struct/union.  Add the TYPE_LANG_SPECIFIC.  */
    9970        22789 :         if (x == NULL)
    9971              :           {
    9972        19331 :             TYPE_LANG_SPECIFIC (t) = space;
    9973        19331 :             TYPE_LANG_SPECIFIC (t)->s->len = len;
    9974        19331 :             field_array = TYPE_LANG_SPECIFIC (t)->s->elts;
    9975        19331 :             qsort (field_array, len, sizeof (tree), field_decl_cmp);
    9976              :           }
    9977              :       }
    9978              :   }
    9979              : 
    9980              :   /* If this was supposed to be a transparent union, but we can't
    9981              :      make it one, warn and turn off the flag.  */
    9982      1199972 :   if (TREE_CODE (t) == UNION_TYPE
    9983       384293 :       && TYPE_TRANSPARENT_AGGR (t)
    9984      1200017 :       && (!TYPE_FIELDS (t) || TYPE_MODE (t) != DECL_MODE (TYPE_FIELDS (t))))
    9985              :     {
    9986           13 :       TYPE_TRANSPARENT_AGGR (t) = 0;
    9987           13 :       warning_at (loc, 0, "union cannot be made transparent");
    9988              :     }
    9989              : 
    9990      1199972 :   tree incomplete_vars = C_TYPE_INCOMPLETE_VARS (TYPE_MAIN_VARIANT (t));
    9991      2431135 :   for (x = TYPE_MAIN_VARIANT (t); x; x = TYPE_NEXT_VARIANT (x))
    9992              :     {
    9993      1231163 :       TYPE_FIELDS (x) = TYPE_FIELDS (t);
    9994      1231163 :       TYPE_LANG_SPECIFIC (x) = TYPE_LANG_SPECIFIC (t);
    9995      1231163 :       TYPE_TRANSPARENT_AGGR (x) = TYPE_TRANSPARENT_AGGR (t);
    9996      1231163 :       TYPE_TYPELESS_STORAGE (x) = TYPE_TYPELESS_STORAGE (t);
    9997      1231163 :       C_TYPE_FIELDS_READONLY (x) = C_TYPE_FIELDS_READONLY (t);
    9998      1231163 :       C_TYPE_FIELDS_VOLATILE (x) = C_TYPE_FIELDS_VOLATILE (t);
    9999      1231163 :       C_TYPE_FIELDS_NON_CONSTEXPR (x) = C_TYPE_FIELDS_NON_CONSTEXPR (t);
   10000      1231163 :       C_TYPE_FIELDS_HAS_COUNTED_BY (x) = C_TYPE_FIELDS_HAS_COUNTED_BY (t);
   10001      1231163 :       C_TYPE_VARIABLE_SIZE (x) = C_TYPE_VARIABLE_SIZE (t);
   10002      1231163 :       C_TYPE_VARIABLY_MODIFIED (x) = C_TYPE_VARIABLY_MODIFIED (t);
   10003      1231163 :       C_TYPE_INCOMPLETE_VARS (x) = NULL_TREE;
   10004      1231163 :       TYPE_INCLUDES_FLEXARRAY (x) = TYPE_INCLUDES_FLEXARRAY (t);
   10005              :     }
   10006              : 
   10007              :   /* Check for consistency with previous definition.  */
   10008      1199972 :   if (flag_isoc23 && NULL != enclosing_struct_parse_info)
   10009              :     {
   10010       930864 :       tree vistype = previous_tag (t);
   10011       930864 :       if (vistype
   10012          128 :           && TREE_CODE (vistype) == TREE_CODE (t)
   10013       930992 :           && !C_TYPE_BEING_DEFINED (vistype))
   10014              :         {
   10015          108 :           TYPE_STUB_DECL (t) = TYPE_STUB_DECL (vistype);
   10016          108 :           if (c_type_variably_modified_p (t))
   10017              :             {
   10018            7 :               error ("redefinition of struct or union %qT with variably "
   10019              :                      "modified type", t);
   10020            7 :               if (struct_parse_info->refloc != UNKNOWN_LOCATION)
   10021            7 :                 inform (struct_parse_info->refloc, "originally defined here");
   10022              :             }
   10023          101 :           else if (!comptypes_same_p (t, vistype))
   10024              :             {
   10025           38 :               error ("redefinition of struct or union %qT", t);
   10026           38 :               if (struct_parse_info->refloc != UNKNOWN_LOCATION)
   10027           38 :                 inform (struct_parse_info->refloc, "originally defined here");
   10028              :             }
   10029              :         }
   10030              :     }
   10031              : 
   10032      1199972 :   C_TYPE_BEING_DEFINED (t) = 0;
   10033              : 
   10034      1199972 :   if (lookup_attribute ("may_alias", TYPE_ATTRIBUTES (t)))
   10035          694 :     for (x = TYPE_MAIN_VARIANT (t); x; x = TYPE_NEXT_VARIANT (x))
   10036          363 :       c_fixup_may_alias (x);
   10037              : 
   10038              :   /* Set type canonical based on equivalence class.  */
   10039      1199972 :   if (flag_isoc23 && !C_TYPE_VARIABLE_SIZE (t))
   10040              :     {
   10041       967244 :       if (c_struct_htab == NULL)
   10042        36614 :         c_struct_htab = hash_table<c_struct_hasher>::create_ggc (61);
   10043              : 
   10044       967244 :       hashval_t hash = c_struct_hasher::hash (t);
   10045              : 
   10046       967244 :       gcc_checking_assert (TYPE_STRUCTURAL_EQUALITY_P (t));
   10047       967244 :       gcc_checking_assert (!TYPE_NAME (t)
   10048              :                            || TREE_CODE (TYPE_NAME (t)) == IDENTIFIER_NODE);
   10049              : 
   10050       967244 :       tree *e = c_struct_htab->find_slot_with_hash (t, hash, INSERT);
   10051       967244 :       if (*e)
   10052        63901 :         TYPE_CANONICAL (t) = TYPE_CANONICAL (*e);
   10053              :       else
   10054              :         {
   10055       903343 :           TYPE_CANONICAL (t) = c_type_canonical (t);
   10056       903343 :           *e = t;
   10057              :         }
   10058       967244 :       c_update_type_canonical (t);
   10059              :     }
   10060              : 
   10061              :   /* Update type location to the one of the definition, instead of e.g.
   10062              :      a forward declaration.  */
   10063      1199972 :   if (TYPE_STUB_DECL (t))
   10064      1199972 :     DECL_SOURCE_LOCATION (TYPE_STUB_DECL (t)) = loc;
   10065              : 
   10066              :   /* Finish debugging output for this type.  */
   10067      1199972 :   rest_of_type_compilation (t, toplevel);
   10068              : 
   10069      1199972 :   finish_incomplete_vars (incomplete_vars, toplevel);
   10070              : 
   10071              : 
   10072      1199972 :   if (c_type_variably_modified_p (t))
   10073              :     {
   10074          717 :       c_update_variably_modified (t);
   10075              :       /* Make sure a DECL_EXPR is created for structs with VLA members.
   10076              :          Because we do not know the context, we always pass expr
   10077              :          to force creation of a BIND_EXPR which is required in some
   10078              :          contexts.  */
   10079          717 :       add_decl_expr (loc, t, expr, false);
   10080              :     }
   10081              : 
   10082      1199972 :   if (warn_cxx_compat)
   10083        21413 :     warn_cxx_compat_finish_struct (fieldlist, TREE_CODE (t), loc);
   10084              : 
   10085      1199972 :   if (NULL != enclosing_struct_parse_info)
   10086              :     {
   10087      1158346 :       delete struct_parse_info;
   10088              : 
   10089      1158346 :       struct_parse_info = enclosing_struct_parse_info;
   10090              : 
   10091              :       /* If this struct is defined inside a struct, add it to
   10092              :          struct_types.  */
   10093      1158346 :       if (warn_cxx_compat
   10094              :           && struct_parse_info != NULL
   10095        21067 :           && !in_sizeof && !in_typeof && !in_alignof && !in_countof)
   10096        21062 :         struct_parse_info->struct_types.safe_push (t);
   10097              :      }
   10098              : 
   10099              :   /* Only when the enclosing struct/union type is not anonymous, do more
   10100              :      verification on the fields with counted_by attributes.  */
   10101      1199972 :   if (C_TYPE_FIELDS_HAS_COUNTED_BY (t) && c_type_tag (t) != NULL_TREE)
   10102          298 :     verify_counted_by_attribute (t, t);
   10103              : 
   10104      1199972 :   return t;
   10105              : }
   10106              : 
   10107              : static struct {
   10108              :   gt_pointer_operator new_value;
   10109              :   void *cookie;
   10110              : } resort_data;
   10111              : 
   10112              : /* This routine compares two fields like field_decl_cmp but using the
   10113              : pointer operator in resort_data.  */
   10114              : 
   10115              : static int
   10116         5416 : resort_field_decl_cmp (const void *x_p, const void *y_p)
   10117              : {
   10118         5416 :   const tree *const x = (const tree *) x_p;
   10119         5416 :   const tree *const y = (const tree *) y_p;
   10120              : 
   10121         5416 :   if (DECL_NAME (*x) == DECL_NAME (*y))
   10122              :     /* A nontype is "greater" than a type.  */
   10123            0 :     return (TREE_CODE (*y) == TYPE_DECL) - (TREE_CODE (*x) == TYPE_DECL);
   10124         5416 :   if (DECL_NAME (*x) == NULL_TREE)
   10125              :     return -1;
   10126         5416 :   if (DECL_NAME (*y) == NULL_TREE)
   10127              :     return 1;
   10128         5416 :   {
   10129         5416 :     tree d1 = DECL_NAME (*x);
   10130         5416 :     tree d2 = DECL_NAME (*y);
   10131         5416 :     resort_data.new_value (&d1, &d1, resort_data.cookie);
   10132         5416 :     resort_data.new_value (&d2, &d2, resort_data.cookie);
   10133         5416 :     if (d1 < d2)
   10134         2719 :       return -1;
   10135              :   }
   10136         2697 :   return 1;
   10137              : }
   10138              : 
   10139              : /* Resort DECL_SORTED_FIELDS because pointers have been reordered.  */
   10140              : 
   10141              : void
   10142            6 : resort_sorted_fields (void *obj,
   10143              :                       void * ARG_UNUSED (orig_obj),
   10144              :                       gt_pointer_operator new_value,
   10145              :                       void *cookie)
   10146              : {
   10147            6 :   struct sorted_fields_type *sf = (struct sorted_fields_type *) obj;
   10148            6 :   resort_data.new_value = new_value;
   10149            6 :   resort_data.cookie = cookie;
   10150            6 :   qsort (&sf->elts[0], sf->len, sizeof (tree),
   10151              :          resort_field_decl_cmp);
   10152            6 : }
   10153              : 
   10154              : /* Lay out the type T, and its element type, and so on.  */
   10155              : 
   10156              : static void
   10157            0 : layout_array_type (tree t)
   10158              : {
   10159            0 :   if (TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE)
   10160            0 :     layout_array_type (TREE_TYPE (t));
   10161            0 :   layout_type (t);
   10162            0 : }
   10163              : 
   10164              : /* Begin compiling the definition of an enumeration type.
   10165              :    NAME is its name (or null if anonymous).
   10166              :    LOC is the enum's location.
   10167              :    FIXED_UNDERLYING_TYPE is the (C23) underlying type specified in the
   10168              :    definition.
   10169              :    Returns the type object, as yet incomplete.
   10170              :    Also records info about it so that build_enumerator
   10171              :    may be used to declare the individual values as they are read.  */
   10172              : 
   10173              : tree
   10174       187619 : start_enum (location_t loc, struct c_enum_contents *the_enum, tree name,
   10175              :             tree fixed_underlying_type, bool potential_nesting_p)
   10176              : {
   10177       187619 :   tree enumtype = NULL_TREE;
   10178       187619 :   location_t enumloc = UNKNOWN_LOCATION;
   10179              : 
   10180              :   /* If this is the real definition for a previous forward reference,
   10181              :      fill in the contents in the same object that used to be the
   10182              :      forward reference.  */
   10183              : 
   10184       187619 :   if (name != NULL_TREE)
   10185        75553 :     enumtype = lookup_tag (ENUMERAL_TYPE, name, true, &enumloc);
   10186              : 
   10187        75553 :   if (enumtype != NULL_TREE && TREE_CODE (enumtype) == ENUMERAL_TYPE)
   10188              :     {
   10189              :       /* If the type is currently being defined or if we have seen an
   10190              :          incomplete version which is now complete, this is a nested
   10191              :          redefinition.  The later happens if the redefinition occurs
   10192              :          inside the enum specifier itself.  */
   10193          397 :       if (C_TYPE_BEING_DEFINED (enumtype)
   10194          397 :           || (potential_nesting_p && TYPE_VALUES (enumtype) != NULL_TREE))
   10195            9 :         error_at (loc, "nested redefinition of %<enum %E%>", name);
   10196              : 
   10197              :       /* For C23 we allow redefinitions.  We set to zero and check for
   10198              :          consistency later.  */
   10199          777 :       if (flag_isoc23 && TYPE_VALUES (enumtype) != NULL_TREE)
   10200              :         enumtype = NULL_TREE;
   10201              :     }
   10202              : 
   10203       112435 :   if (enumtype == NULL_TREE || TREE_CODE (enumtype) != ENUMERAL_TYPE)
   10204              :     {
   10205       187252 :       enumtype = make_node (ENUMERAL_TYPE);
   10206       187252 :       TYPE_SIZE (enumtype) = NULL_TREE;
   10207       187252 :       SET_TYPE_STRUCTURAL_EQUALITY (enumtype);
   10208       187252 :       pushtag (loc, name, enumtype);
   10209       187252 :       if (fixed_underlying_type != NULL_TREE)
   10210              :         {
   10211              :           /* For an enum definition with a fixed underlying type, the
   10212              :              type is complete during the definition and the
   10213              :              enumeration constants have that type.  If there was a
   10214              :              tag, the type was completed in c_parser_enum_specifier.
   10215              :              If not, it must be completed here.  */
   10216           12 :           ENUM_FIXED_UNDERLYING_TYPE_P (enumtype) = true;
   10217           12 :           TYPE_MIN_VALUE (enumtype) = TYPE_MIN_VALUE (fixed_underlying_type);
   10218           12 :           TYPE_MAX_VALUE (enumtype) = TYPE_MAX_VALUE (fixed_underlying_type);
   10219           12 :           TYPE_UNSIGNED (enumtype) = TYPE_UNSIGNED (fixed_underlying_type);
   10220           12 :           SET_TYPE_ALIGN (enumtype, TYPE_ALIGN (fixed_underlying_type));
   10221           12 :           TYPE_SIZE (enumtype) = NULL_TREE;
   10222           12 :           TYPE_PRECISION (enumtype) = TYPE_PRECISION (fixed_underlying_type);
   10223           12 :           ENUM_UNDERLYING_TYPE (enumtype) = fixed_underlying_type;
   10224           12 :           TYPE_CANONICAL (enumtype) = TYPE_CANONICAL (fixed_underlying_type);
   10225           12 :           c_update_type_canonical (enumtype);
   10226           12 :           layout_type (enumtype);
   10227              :         }
   10228              :     }
   10229              :   /* Update type location to the one of the definition, instead of e.g.
   10230              :      a forward declaration.  */
   10231          367 :   else if (TYPE_STUB_DECL (enumtype))
   10232              :     {
   10233          367 :       enumloc = DECL_SOURCE_LOCATION (TYPE_STUB_DECL (enumtype));
   10234          367 :       DECL_SOURCE_LOCATION (TYPE_STUB_DECL (enumtype)) = loc;
   10235              :     }
   10236              : 
   10237       187619 :   C_TYPE_BEING_DEFINED (enumtype) = 1;
   10238              : 
   10239       187619 :   if (TYPE_VALUES (enumtype) != NULL_TREE)
   10240              :     {
   10241              :       /* This enum is a named one that has been declared already.  */
   10242            6 :       auto_diagnostic_group d;
   10243            6 :       error_at (loc, "redeclaration of %<enum %E%>", name);
   10244            6 :       if (enumloc != UNKNOWN_LOCATION)
   10245            6 :         inform (enumloc, "originally defined here");
   10246              : 
   10247              :       /* Completely replace its old definition.
   10248              :          The old enumerators remain defined, however.  */
   10249            6 :       TYPE_VALUES (enumtype) = NULL_TREE;
   10250            6 :     }
   10251              : 
   10252       187619 :   if (ENUM_FIXED_UNDERLYING_TYPE_P (enumtype)
   10253       187619 :       && fixed_underlying_type == NULL_TREE)
   10254              :     {
   10255            3 :       error_at (loc, "%<enum%> declared with but defined without "
   10256              :                 "fixed underlying type");
   10257            3 :       ENUM_FIXED_UNDERLYING_TYPE_P (enumtype) = false;
   10258              :     }
   10259              : 
   10260       187619 :   the_enum->enum_next_value = integer_zero_node;
   10261       187619 :   the_enum->enum_type = enumtype;
   10262       187619 :   the_enum->enum_overflow = 0;
   10263              : 
   10264       187619 :   if (flag_short_enums && !ENUM_FIXED_UNDERLYING_TYPE_P (enumtype))
   10265          106 :     for (tree v = TYPE_MAIN_VARIANT (enumtype); v; v = TYPE_NEXT_VARIANT (v))
   10266           53 :       TYPE_PACKED (v) = 1;
   10267              : 
   10268              :   /* FIXME: This will issue a warning for a use of a type defined
   10269              :      within sizeof in a statement expr.  This is not terribly serious
   10270              :      as C++ doesn't permit statement exprs within sizeof anyhow.  */
   10271       187619 :   if (warn_cxx_compat
   10272         9221 :       && (in_sizeof || in_typeof || in_alignof || in_countof))
   10273            0 :     warning_at (loc, OPT_Wc___compat,
   10274              :                 "defining type in %qs expression is invalid in C++",
   10275              :                 (in_sizeof ? "sizeof"
   10276            0 :                  : in_typeof ? "typeof"
   10277            0 :                  : in_alignof ? "alignof"
   10278              :                  : "_Countof"));
   10279              : 
   10280       187619 :   if (in_underspecified_init)
   10281            6 :     error_at (loc, "%qT defined in underspecified object initializer",
   10282              :               enumtype);
   10283              : 
   10284       187619 :   return enumtype;
   10285              : }
   10286              : 
   10287              : /* After processing and defining all the values of an enumeration type,
   10288              :    install their decls in the enumeration type and finish it off.
   10289              :    ENUMTYPE is the type object, VALUES a list of decl-value pairs,
   10290              :    and ATTRIBUTES are the specified attributes.
   10291              :    Returns ENUMTYPE.  */
   10292              : 
   10293              : tree
   10294       187619 : finish_enum (tree enumtype, tree values, tree attributes)
   10295              : {
   10296       187619 :   tree pair, tem;
   10297       187619 :   tree minnode = NULL_TREE, maxnode = NULL_TREE;
   10298       187619 :   int precision;
   10299       187619 :   signop sign;
   10300       187619 :   bool toplevel = (file_scope == current_scope);
   10301       187619 :   struct lang_type *lt;
   10302              : 
   10303       187619 :   decl_attributes (&enumtype, attributes, (int) ATTR_FLAG_TYPE_IN_PLACE);
   10304              : 
   10305              :   /* Calculate the maximum value of any enumerator in this type.  */
   10306              : 
   10307       187619 :   if (values == error_mark_node)
   10308           26 :     minnode = maxnode = integer_zero_node;
   10309              :   else
   10310              :     {
   10311       187593 :       minnode = maxnode = TREE_VALUE (values);
   10312      5841265 :       for (pair = TREE_CHAIN (values); pair; pair = TREE_CHAIN (pair))
   10313              :         {
   10314      5653672 :           tree value = TREE_VALUE (pair);
   10315      5653672 :           if (tree_int_cst_lt (maxnode, value))
   10316      5500620 :             maxnode = value;
   10317      5653672 :           if (tree_int_cst_lt (value, minnode))
   10318        67042 :             minnode = value;
   10319              :         }
   10320              :     }
   10321              : 
   10322              :   /* Construct the final type of this enumeration.  It is the same
   10323              :      as one of the integral types - the narrowest one that fits, except
   10324              :      that normally we only go as narrow as int - and signed iff any of
   10325              :      the values are negative.  */
   10326       187619 :   sign = (tree_int_cst_sgn (minnode) >= 0) ? UNSIGNED : SIGNED;
   10327       187619 :   precision = MAX (tree_int_cst_min_precision (minnode, sign),
   10328              :                    tree_int_cst_min_precision (maxnode, sign));
   10329              : 
   10330       187619 :   bool wider_than_int =
   10331       187619 :     (tree_int_cst_lt (minnode, TYPE_MIN_VALUE (integer_type_node))
   10332       187619 :      || tree_int_cst_lt (TYPE_MAX_VALUE (integer_type_node), maxnode));
   10333              : 
   10334              : 
   10335       187619 :   if (!ENUM_FIXED_UNDERLYING_TYPE_P (enumtype))
   10336              :     {
   10337              :       /* If the precision of the type was specified with an attribute and it
   10338              :          was too small, give an error.  Otherwise, use it.  */
   10339       187283 :       if (TYPE_PRECISION (enumtype) && lookup_attribute ("mode", attributes))
   10340              :         {
   10341           23 :           if (precision > TYPE_PRECISION (enumtype))
   10342              :             {
   10343            6 :               TYPE_PRECISION (enumtype) = 0;
   10344            6 :               error ("specified mode too small for enumerated values");
   10345              :             }
   10346              :           else
   10347           17 :             precision = TYPE_PRECISION (enumtype);
   10348              :         }
   10349              :       else
   10350       187260 :         TYPE_PRECISION (enumtype) = 0;
   10351              : 
   10352       187283 :       if (TYPE_PACKED (enumtype)
   10353       187204 :           || precision > TYPE_PRECISION (integer_type_node)
   10354       371124 :           || TYPE_PRECISION (enumtype))
   10355              :         {
   10356         3569 :           tem = c_common_type_for_size (precision, sign == UNSIGNED ? 1 : 0);
   10357         3454 :           if (tem == NULL)
   10358              :             {
   10359              :               /* This should only occur when both signed and unsigned
   10360              :                  values of maximum precision occur among the
   10361              :                  enumerators.  */
   10362            3 :               pedwarn (input_location, 0,
   10363              :                        "enumeration values exceed range of largest integer");
   10364            3 :               tem = widest_integer_literal_type_node;
   10365              :             }
   10366         3451 :           else if (precision > TYPE_PRECISION (intmax_type_node)
   10367            4 :                    && !tree_int_cst_lt (minnode,
   10368            4 :                                         TYPE_MIN_VALUE (intmax_type_node))
   10369         3454 :                    && !tree_int_cst_lt (TYPE_MAX_VALUE (uintmax_type_node),
   10370              :                                         maxnode))
   10371            2 :             pedwarn (input_location, OPT_Wpedantic,
   10372              :                      "enumeration values exceed range of %qs",
   10373              :                      sign == UNSIGNED ? "uintmax_t" : "intmax_t");
   10374              :         }
   10375              :       else
   10376       183829 :         tem = sign == UNSIGNED ? unsigned_type_node : integer_type_node;
   10377              : 
   10378       187283 :       TYPE_MIN_VALUE (enumtype) = TYPE_MIN_VALUE (tem);
   10379       187283 :       TYPE_MAX_VALUE (enumtype) = TYPE_MAX_VALUE (tem);
   10380       187283 :       TYPE_UNSIGNED (enumtype) = TYPE_UNSIGNED (tem);
   10381       187283 :       SET_TYPE_ALIGN (enumtype, TYPE_ALIGN (tem));
   10382       187283 :       TYPE_SIZE (enumtype) = NULL_TREE;
   10383       187283 :       TYPE_PRECISION (enumtype) = TYPE_PRECISION (tem);
   10384       187283 :       ENUM_UNDERLYING_TYPE (enumtype) =
   10385       187283 :         c_common_type_for_size (TYPE_PRECISION (tem), TYPE_UNSIGNED (tem));
   10386              : 
   10387       561849 :       TYPE_CANONICAL (enumtype) =
   10388       187283 :         TYPE_CANONICAL (ENUM_UNDERLYING_TYPE (enumtype));
   10389       187283 :       c_update_type_canonical (enumtype);
   10390              : 
   10391       187283 :       layout_type (enumtype);
   10392              :     }
   10393              : 
   10394       187619 :   if (values != error_mark_node)
   10395              :     {
   10396              :       /* Change the type of the enumerators to be the enum type.  We
   10397              :          need to do this irrespective of the size of the enum, for
   10398              :          proper type checking.  Replace the DECL_INITIALs of the
   10399              :          enumerators, and the value slots of the list, with copies
   10400              :          that have the enum type; they cannot be modified in place
   10401              :          because they may be shared (e.g.  integer_zero_node) Finally,
   10402              :          change the purpose slots to point to the names of the decls.  */
   10403      6028858 :       for (pair = values; pair; pair = TREE_CHAIN (pair))
   10404              :         {
   10405      5841265 :           tree enu = TREE_PURPOSE (pair);
   10406      5841265 :           tree ini = DECL_INITIAL (enu);
   10407              : 
   10408      5841265 :           TREE_TYPE (enu) = enumtype;
   10409              : 
   10410              :           /* Before C23, the ISO C Standard mandates enumerators to
   10411              :              have type int, even though the underlying type of an enum
   10412              :              type is unspecified.  However, C23 allows enumerators of
   10413              :              any integer type, and if an enumeration has any
   10414              :              enumerators wider than int, all enumerators have the
   10415              :              enumerated type after it is parsed.  Any enumerators that
   10416              :              fit in int are given type int in build_enumerator (which
   10417              :              is the correct type while the enumeration is being
   10418              :              parsed), so no conversions are needed here if all
   10419              :              enumerators fit in int.  If the enum has a fixed
   10420              :              underlying type, the correct type was also given in
   10421              :              build_enumerator.  */
   10422      5841265 :           if (!ENUM_FIXED_UNDERLYING_TYPE_P (enumtype) && wider_than_int)
   10423        38088 :             ini = convert (enumtype, ini);
   10424              : 
   10425      5841265 :           DECL_INITIAL (enu) = ini;
   10426      5841265 :           TREE_PURPOSE (pair) = DECL_NAME (enu);
   10427              :           /* To match the C++ FE, store the CONST_DECL rather than just its
   10428              :              value.  */
   10429      5841265 :           TREE_VALUE (pair) = enu;
   10430              :         }
   10431              : 
   10432       187593 :       TYPE_VALUES (enumtype) = values;
   10433              :     }
   10434              : 
   10435              :   /* Record the min/max values so that we can warn about bit-field
   10436              :      enumerations that are too small for the values.  */
   10437       187619 :   lt = ((struct lang_type *)
   10438       187619 :         ggc_internal_cleared_alloc (c_dialect_objc ()
   10439              :                                     ? sizeof (struct lang_type)
   10440              :                                     : offsetof (struct lang_type, info)));
   10441       187619 :   lt->enum_min = minnode;
   10442       187619 :   lt->enum_max = maxnode;
   10443       187619 :   TYPE_LANG_SPECIFIC (enumtype) = lt;
   10444              : 
   10445              :   /* Fix up all variant types of this enum type.  */
   10446       187619 :   tree incomplete_vars = C_TYPE_INCOMPLETE_VARS (TYPE_MAIN_VARIANT (enumtype));
   10447       375248 :   for (tem = TYPE_MAIN_VARIANT (enumtype); tem; tem = TYPE_NEXT_VARIANT (tem))
   10448              :     {
   10449       187629 :       C_TYPE_INCOMPLETE_VARS (tem) = NULL_TREE;
   10450       187629 :       if (tem == enumtype)
   10451       187619 :         continue;
   10452           10 :       TYPE_VALUES (tem) = TYPE_VALUES (enumtype);
   10453           10 :       TYPE_MIN_VALUE (tem) = TYPE_MIN_VALUE (enumtype);
   10454           10 :       TYPE_MAX_VALUE (tem) = TYPE_MAX_VALUE (enumtype);
   10455           10 :       TYPE_SIZE (tem) = TYPE_SIZE (enumtype);
   10456           10 :       TYPE_SIZE_UNIT (tem) = TYPE_SIZE_UNIT (enumtype);
   10457           10 :       SET_TYPE_MODE (tem, TYPE_MODE (enumtype));
   10458           10 :       TYPE_PRECISION (tem) = TYPE_PRECISION (enumtype);
   10459           10 :       SET_TYPE_ALIGN (tem, TYPE_ALIGN (enumtype));
   10460           10 :       TYPE_USER_ALIGN (tem) = TYPE_USER_ALIGN (enumtype);
   10461           10 :       TYPE_UNSIGNED (tem) = TYPE_UNSIGNED (enumtype);
   10462           10 :       TYPE_LANG_SPECIFIC (tem) = TYPE_LANG_SPECIFIC (enumtype);
   10463           10 :       ENUM_UNDERLYING_TYPE (tem) = ENUM_UNDERLYING_TYPE (enumtype);
   10464           10 :       TYPE_PACKED (tem) = TYPE_PACKED (enumtype);
   10465              :     }
   10466              : 
   10467              :   /* Finish debugging output for this type.  */
   10468       187619 :   rest_of_type_compilation (enumtype, toplevel);
   10469              : 
   10470       187619 :   finish_incomplete_vars (incomplete_vars, toplevel);
   10471              : 
   10472              :   /* If this enum is defined inside a struct, add it to
   10473              :      struct_types.  */
   10474       187619 :   if (warn_cxx_compat
   10475         9221 :       && struct_parse_info != NULL
   10476         9129 :       && !in_sizeof && !in_typeof && !in_alignof && !in_countof)
   10477         9129 :     struct_parse_info->struct_types.safe_push (enumtype);
   10478              : 
   10479              :   /* Check for consistency with previous definition */
   10480       187619 :   if (flag_isoc23)
   10481              :     {
   10482       149382 :       tree vistype = previous_tag (enumtype);
   10483       149382 :       if (vistype
   10484           35 :           && TREE_CODE (vistype) == TREE_CODE (enumtype)
   10485       149413 :           && !C_TYPE_BEING_DEFINED (vistype))
   10486              :         {
   10487           31 :           TYPE_STUB_DECL (enumtype) = TYPE_STUB_DECL (vistype);
   10488           31 :           if (!comptypes_same_p (enumtype, vistype))
   10489            3 :             error("conflicting redefinition of enum %qT", enumtype);
   10490              :         }
   10491              :     }
   10492              : 
   10493       187619 :   C_TYPE_BEING_DEFINED (enumtype) = 0;
   10494              : 
   10495       187619 :   return enumtype;
   10496              : }
   10497              : 
   10498              : /* Build and install a CONST_DECL for one value of the
   10499              :    current enumeration type (one that was begun with start_enum).
   10500              :    DECL_LOC is the location of the enumerator.
   10501              :    LOC is the location of the '=' operator if any, DECL_LOC otherwise.
   10502              :    Return a tree-list containing the CONST_DECL and its value.
   10503              :    Assignment of sequential values by default is handled here.  */
   10504              : 
   10505              : tree
   10506      5841282 : build_enumerator (location_t decl_loc, location_t loc,
   10507              :                   struct c_enum_contents *the_enum, tree name, tree value)
   10508              : {
   10509      5841282 :   tree decl;
   10510      5841282 :   tree old_decl;
   10511              : 
   10512              :   /* Validate and default VALUE.  */
   10513              : 
   10514      5841282 :   if (value != NULL_TREE)
   10515              :     {
   10516              :       /* Don't issue more errors for error_mark_node (i.e. an
   10517              :          undeclared identifier) - just ignore the value expression.  */
   10518      3649288 :       if (value == error_mark_node)
   10519              :         value = NULL_TREE;
   10520      3648623 :       else if (!INTEGRAL_TYPE_P (TREE_TYPE (value)))
   10521              :         {
   10522            6 :           error_at (loc, "enumerator value for %qE is not an integer constant",
   10523              :                     name);
   10524            6 :           value = NULL_TREE;
   10525              :         }
   10526              :       else
   10527              :         {
   10528      3648617 :           if (TREE_CODE (value) != INTEGER_CST)
   10529              :             {
   10530           97 :               value = c_fully_fold (value, false, NULL);
   10531           97 :               if (TREE_CODE (value) == INTEGER_CST)
   10532           48 :                 pedwarn (loc, OPT_Wpedantic,
   10533              :                          "enumerator value for %qE is not an integer "
   10534              :                          "constant expression", name);
   10535              :             }
   10536      3648617 :           if (TREE_CODE (value) != INTEGER_CST)
   10537              :             {
   10538           49 :               error ("enumerator value for %qE is not an integer constant",
   10539              :                      name);
   10540           49 :               value = NULL_TREE;
   10541              :             }
   10542              :           else
   10543              :             {
   10544      3648568 :               value = default_conversion (value);
   10545      3648568 :               constant_expression_warning (value);
   10546              :             }
   10547              :         }
   10548              :     }
   10549              : 
   10550              :   /* Default based on previous value.  */
   10551              :   /* It should no longer be possible to have NON_LVALUE_EXPR
   10552              :      in the default.  */
   10553      3648623 :   if (value == NULL_TREE)
   10554              :     {
   10555      2192714 :       value = the_enum->enum_next_value;
   10556      2192714 :       if (the_enum->enum_overflow)
   10557            8 :         error_at (loc, "overflow in enumeration values");
   10558              :     }
   10559      5841282 :   if (ENUM_FIXED_UNDERLYING_TYPE_P (the_enum->enum_type))
   10560              :     {
   10561              :       /* Enumeration constants must fit in the fixed underlying type.  */
   10562         4167 :       if (!int_fits_type_p (value, ENUM_UNDERLYING_TYPE (the_enum->enum_type)))
   10563            4 :         error_at (loc,
   10564              :                   "enumerator value outside the range of underlying type");
   10565              :       /* Enumeration constants for an enum with fixed underlying type
   10566              :          have the enum type, both inside and outside the
   10567              :          definition.  */
   10568         4167 :       value = convert (the_enum->enum_type, value);
   10569              :     }
   10570      5837115 :   else if (flag_isoc23
   10571      5419205 :            && (old_decl = lookup_name_in_scope (name, current_scope))
   10572           39 :            && old_decl != error_mark_node
   10573           39 :            && TREE_TYPE (old_decl)
   10574           39 :            && TREE_TYPE (TREE_TYPE (old_decl))
   10575      5837153 :            && TREE_CODE (old_decl) == CONST_DECL)
   10576              :     {
   10577              :       /* Enumeration constants in a redeclaration have the previous type.  */
   10578           38 :       tree previous_type = TREE_TYPE (DECL_INITIAL (old_decl));
   10579           38 :       if (!int_fits_type_p (value, previous_type))
   10580              :         {
   10581            2 :           error_at (loc, "value of redeclared enumerator outside the range "
   10582              :                          "of %qT", previous_type);
   10583            2 :           locate_old_decl (old_decl);
   10584              :         }
   10585           38 :       value = convert (previous_type, value);
   10586              :     }
   10587              :   else
   10588              :     {
   10589              :       /* Even though the underlying type of an enum is unspecified, the
   10590              :          type of enumeration constants is explicitly defined as int
   10591              :          (6.4.4.3/2 in the C99 Standard).  C23 allows any integer type, and
   10592              :          GCC allows such types for older standards as an extension.  */
   10593      5837077 :       bool warned_range = false;
   10594      5837077 :       if (!int_fits_type_p (value,
   10595      5837077 :                             (TYPE_UNSIGNED (TREE_TYPE (value))
   10596              :                              ? uintmax_type_node
   10597              :                              : intmax_type_node)))
   10598              :         /* GCC does not consider its types larger than intmax_t to be
   10599              :            extended integer types (although C23 would permit such types to
   10600              :            be considered extended integer types if all the features
   10601              :            required by <stdint.h> and <inttypes.h> macros, such as support
   10602              :            for integer constants and I/O, were present), so diagnose if
   10603              :            such a wider type is used.  (If the wider type arose from a
   10604              :            constant of such a type, that will also have been diagnosed,
   10605              :            but this is the only diagnostic in the case where it arises
   10606              :            from choosing a wider type automatically when adding 1
   10607              :            overflows.)  */
   10608           11 :         warned_range = pedwarn (loc, OPT_Wpedantic,
   10609              :                                 "enumerator value outside the range of %qs",
   10610           11 :                                 TYPE_UNSIGNED (TREE_TYPE (value))
   10611              :                                 ? "uintmax_t"
   10612              :                                 : "intmax_t");
   10613      5837077 :       if (!warned_range && !int_fits_type_p (value, integer_type_node))
   10614         5653 :         pedwarn_c11 (loc, OPT_Wpedantic,
   10615              :                      "ISO C restricts enumerator values to range of %<int%> "
   10616              :                      "before C23");
   10617              : 
   10618              :       /* The ISO C Standard mandates enumerators to have type int before
   10619              :          C23, even though the underlying type of an enum type is
   10620              :          unspecified.  C23 allows enumerators of any integer type.  During
   10621              :          the parsing of the enumeration, C23 specifies that constants
   10622              :          representable in int have type int, constants not representable
   10623              :          in int have the type of the given expression if any, and
   10624              :          constants not representable in int and derived by adding 1 to the
   10625              :          previous constant have the type of that constant unless the
   10626              :          addition would overflow or wraparound, in which case a wider type
   10627              :          of the same signedness is chosen automatically; after the
   10628              :          enumeration is parsed, all the constants have the type of the
   10629              :          enumeration if any do not fit in int.  */
   10630      5837077 :       if (int_fits_type_p (value, integer_type_node))
   10631      5831420 :         value = convert (integer_type_node, value);
   10632              :     }
   10633              : 
   10634              :   /* Set basis for default for next value.  */
   10635      5841282 :   if (ENUM_FIXED_UNDERLYING_TYPE_P (the_enum->enum_type))
   10636              :     {
   10637         4167 :       tree underlying_type = ENUM_UNDERLYING_TYPE (the_enum->enum_type);
   10638         4167 :       if (TREE_CODE (underlying_type) == BOOLEAN_TYPE)
   10639              :         /* A value of 2 following a value of 1 overflows bool, but we
   10640              :            cannot carry out addition directly on bool without
   10641              :            promotion, and converting the result of arithmetic in a
   10642              :            wider type back to bool would not produce the right result
   10643              :            for this overflow check.  */
   10644           61 :         the_enum->enum_next_value = invert_truthvalue_loc (loc, value);
   10645              :       else
   10646         4106 :         the_enum->enum_next_value
   10647         4106 :           = build_binary_op (EXPR_LOC_OR_LOC (value, input_location),
   10648              :                              PLUS_EXPR, convert (underlying_type, value),
   10649              :                              convert (underlying_type, integer_one_node),
   10650              :                              false);
   10651              :     }
   10652              :   else
   10653              :     {
   10654      5837115 :       tree tmp = value;
   10655              : 
   10656              :       /* In a redeclaration the type can already be the enumeral type.  */
   10657      5837115 :       if (TREE_CODE (TREE_TYPE (value)) == ENUMERAL_TYPE)
   10658           14 :         tmp = convert (ENUM_UNDERLYING_TYPE (TREE_TYPE (tmp)), tmp);
   10659              : 
   10660      5837115 :       the_enum->enum_next_value
   10661      5837115 :         = build_binary_op (EXPR_LOC_OR_LOC (value, input_location),
   10662              :                            PLUS_EXPR, tmp, integer_one_node, false);
   10663              :     }
   10664      5841282 :   the_enum->enum_overflow = tree_int_cst_lt (the_enum->enum_next_value, value);
   10665      5841282 :   if (the_enum->enum_overflow
   10666      5841282 :       && !ENUM_FIXED_UNDERLYING_TYPE_P (the_enum->enum_type))
   10667              :     {
   10668              :       /* Choose a wider type with the same signedness if
   10669              :          available.  */
   10670         4842 :       int prec = TYPE_PRECISION (TREE_TYPE (value)) + 1;
   10671         4842 :       bool unsignedp = TYPE_UNSIGNED (TREE_TYPE (value));
   10672         4842 :       tree new_type = (unsignedp
   10673         4842 :                        ? long_unsigned_type_node
   10674              :                        : long_integer_type_node);
   10675         4842 :       if (prec > TYPE_PRECISION (new_type))
   10676         3832 :         new_type = (unsignedp
   10677         3832 :                     ? long_long_unsigned_type_node
   10678              :                     : long_long_integer_type_node);
   10679         4842 :       if (prec > TYPE_PRECISION (new_type))
   10680         3246 :         new_type = (unsignedp
   10681         3246 :                     ? widest_unsigned_literal_type_node
   10682              :                     : widest_integer_literal_type_node);
   10683         4842 :       if (prec <= TYPE_PRECISION (new_type))
   10684              :         {
   10685         4837 :           the_enum->enum_overflow = false;
   10686         4837 :           the_enum->enum_next_value
   10687         4837 :             = build_binary_op (EXPR_LOC_OR_LOC (value, input_location),
   10688              :                                PLUS_EXPR, convert (new_type, value),
   10689              :                                integer_one_node, false);
   10690         4837 :           gcc_assert (!tree_int_cst_lt (the_enum->enum_next_value, value));
   10691              :         }
   10692              :     }
   10693              : 
   10694              :   /* Now create a declaration for the enum value name.  */
   10695              : 
   10696      5841282 :   decl = build_decl (decl_loc, CONST_DECL, name, TREE_TYPE (value));
   10697      5841282 :   DECL_INITIAL (decl) = value;
   10698      5841282 :   DECL_CONTEXT (decl) = the_enum->enum_type;
   10699      5841282 :   pushdecl (decl);
   10700              : 
   10701      5841282 :   return tree_cons (decl, value, NULL_TREE);
   10702              : }
   10703              : 
   10704              : /* Implement LANG_HOOKS_SIMULATE_ENUM_DECL.  */
   10705              : 
   10706              : tree
   10707            0 : c_simulate_enum_decl (location_t loc, const char *name,
   10708              :                       vec<string_int_pair> *values_ptr)
   10709              : {
   10710            0 :   location_t saved_loc = input_location;
   10711            0 :   input_location = loc;
   10712              : 
   10713            0 :   struct c_enum_contents the_enum;
   10714            0 :   tree enumtype = start_enum (loc, &the_enum, get_identifier (name),
   10715              :                               NULL_TREE, false);
   10716              : 
   10717            0 :   tree value_chain = NULL_TREE;
   10718            0 :   string_int_pair *value;
   10719            0 :   vec<string_int_pair> values = *values_ptr;
   10720            0 :   unsigned int i;
   10721            0 :   FOR_EACH_VEC_ELT (values, i, value)
   10722              :     {
   10723            0 :       tree decl = build_enumerator (loc, loc, &the_enum,
   10724              :                                     get_identifier (value->first),
   10725              :                                     build_int_cst (integer_type_node,
   10726            0 :                                                    value->second));
   10727            0 :       TREE_CHAIN (decl) = value_chain;
   10728            0 :       value_chain = decl;
   10729              :     }
   10730              : 
   10731            0 :   finish_enum (enumtype, nreverse (value_chain), NULL_TREE);
   10732              : 
   10733            0 :   input_location = saved_loc;
   10734            0 :   return enumtype;
   10735              : }
   10736              : 
   10737              : /* Implement LANG_HOOKS_SIMULATE_RECORD_DECL.  */
   10738              : 
   10739              : tree
   10740            0 : c_simulate_record_decl (location_t loc, const char *name,
   10741              :                         array_slice<const tree> fields)
   10742              : {
   10743            0 :   location_t saved_loc = input_location;
   10744            0 :   input_location = loc;
   10745              : 
   10746            0 :   class c_struct_parse_info *struct_info;
   10747            0 :   tree ident = get_identifier (name);
   10748            0 :   tree type = start_struct (loc, RECORD_TYPE, ident, &struct_info);
   10749              : 
   10750            0 :   for (unsigned int i = 0; i < fields.size (); ++i)
   10751              :     {
   10752            0 :       DECL_FIELD_CONTEXT (fields[i]) = type;
   10753            0 :       if (i > 0)
   10754            0 :         DECL_CHAIN (fields[i - 1]) = fields[i];
   10755              :     }
   10756              : 
   10757            0 :   finish_struct (loc, type, fields[0], NULL_TREE, struct_info);
   10758              : 
   10759            0 :   tree decl = build_decl (loc, TYPE_DECL, ident, type);
   10760            0 :   set_underlying_type (decl);
   10761            0 :   lang_hooks.decls.pushdecl (decl);
   10762              : 
   10763            0 :   input_location = saved_loc;
   10764            0 :   return type;
   10765              : }
   10766              : 
   10767              : /* Create the FUNCTION_DECL for a function definition.
   10768              :    DECLSPECS, DECLARATOR and ATTRIBUTES are the parts of
   10769              :    the declaration; they describe the function's name and the type it returns,
   10770              :    but twisted together in a fashion that parallels the syntax of C.
   10771              : 
   10772              :    This function creates a binding context for the function body
   10773              :    as well as setting up the FUNCTION_DECL in current_function_decl.
   10774              : 
   10775              :    Returns true on success.  If the DECLARATOR is not suitable for a function
   10776              :    (it defines a datum instead), we return false to report a parse error.  */
   10777              : 
   10778              : bool
   10779     37714021 : start_function (struct c_declspecs *declspecs, struct c_declarator *declarator,
   10780              :                 tree attributes)
   10781              : {
   10782     37714021 :   tree decl1, old_decl;
   10783     37714021 :   tree restype, resdecl;
   10784     37714021 :   location_t loc;
   10785     37714021 :   location_t result_loc;
   10786     37714021 :   tree expr = NULL;
   10787              : 
   10788     37714021 :   current_function_returns_value = 0;  /* Assume, until we see it does.  */
   10789     37714021 :   current_function_returns_null = 0;
   10790     37714021 :   current_function_returns_abnormally = 0;
   10791     37714021 :   warn_about_return_type = 0;
   10792     37714021 :   c_switch_stack = NULL;
   10793              : 
   10794              :   /* Indicate no valid break/continue context.  */
   10795     37714021 :   in_statement = 0;
   10796              : 
   10797     37714021 :   decl1 = grokdeclarator (declarator, declspecs, FUNCDEF, true, NULL,
   10798              :                           &attributes, &expr, NULL, DEPRECATED_NORMAL);
   10799     37714021 :   invoke_plugin_callbacks (PLUGIN_START_PARSE_FUNCTION, decl1);
   10800              : 
   10801              :   /* If the declarator is not suitable for a function definition,
   10802              :      cause a syntax error.  */
   10803     37714021 :   if (decl1 == NULL_TREE
   10804     37713992 :       || TREE_CODE (decl1) != FUNCTION_DECL)
   10805              :     return false;
   10806              : 
   10807              :   /* Nested functions may have variably modified (return) type.
   10808              :      Make sure the size expression is evaluated at this point.  */
   10809     37713985 :   if (expr && !current_scope->parm_flag)
   10810           11 :     add_stmt (fold_convert (void_type_node, expr));
   10811              : 
   10812              :   /* Mark nested functions as needing a static chain initially.
   10813              :      The flag is cleared at the end of the function if no static
   10814              :      chain is needed.  */
   10815     37713985 :   if (current_function_decl != NULL_TREE)
   10816         1626 :     DECL_STATIC_CHAIN (decl1) = 1;
   10817              : 
   10818     37713985 :   loc = DECL_SOURCE_LOCATION (decl1);
   10819              : 
   10820              :   /* A nested function is not global.  */
   10821     37713985 :   if (current_function_decl != NULL_TREE)
   10822         1626 :     TREE_PUBLIC (decl1) = 0;
   10823              : 
   10824     37713985 :   c_decl_attributes (&decl1, attributes, 0);
   10825              : 
   10826     37713985 :   if (DECL_DECLARED_INLINE_P (decl1)
   10827     37004514 :       && DECL_UNINLINABLE (decl1)
   10828     37713988 :       && lookup_attribute ("noinline", DECL_ATTRIBUTES (decl1)))
   10829              :     {
   10830            3 :       auto_urlify_attributes sentinel;
   10831            3 :       warning_at (loc, OPT_Wattributes,
   10832              :                   "inline function %qD given attribute %qs",
   10833              :                   decl1, "noinline");
   10834            3 :     }
   10835              : 
   10836              :   /* Handle gnu_inline attribute.  */
   10837     37713985 :   if (declspecs->inline_p
   10838     37004517 :       && !flag_gnu89_inline
   10839     36961796 :       && TREE_CODE (decl1) == FUNCTION_DECL
   10840     74675781 :       && (lookup_attribute ("gnu_inline", DECL_ATTRIBUTES (decl1))
   10841       164455 :           || current_function_decl))
   10842              :     {
   10843     36797413 :       if (declspecs->storage_class != csc_static)
   10844     36797407 :         DECL_EXTERNAL (decl1) = !DECL_EXTERNAL (decl1);
   10845              :     }
   10846              : 
   10847     37713985 :   announce_function (decl1);
   10848              : 
   10849     37713985 :   if (!COMPLETE_OR_VOID_TYPE_P (TREE_TYPE (TREE_TYPE (decl1))))
   10850              :     {
   10851            1 :       error_at (loc, "return type is an incomplete type");
   10852              :       /* Make it return void instead.  */
   10853            1 :       TREE_TYPE (decl1)
   10854            2 :         = c_build_function_type (void_type_node,
   10855            1 :                                  TYPE_ARG_TYPES (TREE_TYPE (decl1)),
   10856            1 :                                  TYPE_NO_NAMED_ARGS_STDARG_P (TREE_TYPE (decl1)));
   10857              :     }
   10858              : 
   10859     37713985 :   if (warn_about_return_type)
   10860         1404 :     permerror_opt (loc, flag_isoc99 ? OPT_Wimplicit_int
   10861            0 :                    : (warn_return_type > 0 ? OPT_Wreturn_type
   10862              :                       : OPT_Wimplicit_int),
   10863              :                    "return type defaults to %<int%>");
   10864              : 
   10865              :   /* Make the init_value nonzero so pushdecl knows this is not tentative.
   10866              :      error_mark_node is replaced below (in pop_scope) with the BLOCK.  */
   10867     37713985 :   DECL_INITIAL (decl1) = error_mark_node;
   10868              : 
   10869              :   /* If this definition isn't a prototype and we had a prototype declaration
   10870              :      before, copy the arg type info from that prototype.  */
   10871     37713985 :   old_decl = lookup_name_in_scope (DECL_NAME (decl1), current_scope);
   10872     37713985 :   if (old_decl && TREE_CODE (old_decl) != FUNCTION_DECL)
   10873     37481932 :     old_decl = NULL_TREE;
   10874              : 
   10875     37713985 :   current_function_prototype_locus = UNKNOWN_LOCATION;
   10876     37713985 :   current_function_prototype_built_in = false;
   10877     37713985 :   current_function_prototype_arg_types = NULL_TREE;
   10878     37713985 :   tree newtype = TREE_TYPE (decl1);
   10879     37713985 :   tree oldtype = old_decl ? TREE_TYPE (old_decl) : newtype;
   10880     37713985 :   if (!prototype_p (newtype))
   10881              :     {
   10882        13265 :       tree oldrt = TREE_TYPE (oldtype);
   10883        13265 :       tree newrt = TREE_TYPE (newtype);
   10884        13265 :       if (old_decl != NULL_TREE
   10885          317 :           && TREE_CODE (oldtype) == FUNCTION_TYPE
   10886          317 :           && comptypes (oldrt, newrt)
   10887        13563 :           && !TYPE_NO_NAMED_ARGS_STDARG_P (oldtype))
   10888              :         {
   10889          297 :           if (stdarg_p (oldtype))
   10890              :             {
   10891            1 :               auto_diagnostic_group d;
   10892            1 :               warning_at (loc, 0, "%q+D defined as variadic function "
   10893              :                           "without prototype", decl1);
   10894            1 :               locate_old_decl (old_decl);
   10895            1 :             }
   10896          297 :           TREE_TYPE (decl1) = composite_type (oldtype, newtype);
   10897          297 :           current_function_prototype_locus = DECL_SOURCE_LOCATION (old_decl);
   10898          297 :           current_function_prototype_built_in
   10899          297 :             = C_DECL_BUILTIN_PROTOTYPE (old_decl);
   10900          297 :           current_function_prototype_arg_types
   10901          297 :             = TYPE_ARG_TYPES (newtype);
   10902              :         }
   10903        13265 :       if (TREE_PUBLIC (decl1))
   10904              :         {
   10905              :           /* If there is an external prototype declaration of this
   10906              :              function, record its location but do not copy information
   10907              :              to this decl.  This may be an invisible declaration
   10908              :              (built-in or in a scope which has finished) or simply
   10909              :              have more refined argument types than any declaration
   10910              :              found above.  */
   10911        12850 :           struct c_binding *b;
   10912        13126 :           for (b = I_SYMBOL_BINDING (DECL_NAME (decl1)); b; b = b->shadowed)
   10913          713 :             if (B_IN_SCOPE (b, external_scope))
   10914              :               break;
   10915        12850 :           if (b)
   10916              :             {
   10917          437 :               tree ext_decl, ext_type;
   10918          437 :               ext_decl = b->decl;
   10919          437 :               ext_type = b->u.type ? b->u.type : TREE_TYPE (ext_decl);
   10920          437 :               if (TREE_CODE (ext_type) == FUNCTION_TYPE
   10921          874 :                   && comptypes (TREE_TYPE (TREE_TYPE (decl1)),
   10922          437 :                                 TREE_TYPE (ext_type)))
   10923              :                 {
   10924          417 :                   current_function_prototype_locus
   10925          417 :                     = DECL_SOURCE_LOCATION (ext_decl);
   10926          417 :                   current_function_prototype_built_in
   10927          417 :                     = C_DECL_BUILTIN_PROTOTYPE (ext_decl);
   10928          417 :                   current_function_prototype_arg_types
   10929          417 :                     = TYPE_ARG_TYPES (ext_type);
   10930              :                 }
   10931              :             }
   10932              :         }
   10933              :     }
   10934              : 
   10935              :   /* Optionally warn about C23 compatibility.  */
   10936     37713985 :   if (warn_deprecated_non_prototype
   10937           34 :       && old_decl != NULL_TREE
   10938            5 :       && TREE_CODE (oldtype) == FUNCTION_TYPE
   10939            5 :       && !TYPE_ARG_TYPES (oldtype)
   10940            5 :       && !TYPE_NO_NAMED_ARGS_STDARG_P (oldtype)
   10941     37713990 :       && (TYPE_ARG_TYPES (newtype)
   10942            3 :           && TREE_VALUE (TYPE_ARG_TYPES (newtype)) != void_type_node))
   10943              :     {
   10944            3 :       bool warned = warning_at (loc, OPT_Wdeprecated_non_prototype,
   10945              :                                 "ISO C23 does not allow defining"
   10946              :                                 " parameters for function %qE declared"
   10947              :                                 " without parameters",
   10948              :                                 decl1);
   10949            3 :       if (warned)
   10950            3 :         inform (DECL_SOURCE_LOCATION (old_decl), "declared here");
   10951              :     }
   10952              : 
   10953              :   /* Optionally warn of old-fashioned def with no previous prototype.  */
   10954     37713985 :   if (warn_strict_prototypes
   10955       107968 :       && old_decl != error_mark_node
   10956       107968 :       && !prototype_p (TREE_TYPE (decl1))
   10957     37713986 :       && C_DECL_ISNT_PROTOTYPE (old_decl))
   10958            1 :     warning_at (loc, OPT_Wstrict_prototypes,
   10959              :                 "function declaration isn%'t a prototype");
   10960              :   /* Optionally warn of any global def with no previous prototype.  */
   10961     37713984 :   else if (warn_missing_prototypes
   10962       107669 :            && old_decl != error_mark_node
   10963       107669 :            && TREE_PUBLIC (decl1)
   10964        74130 :            && !MAIN_NAME_P (DECL_NAME (decl1))
   10965        74093 :            && C_DECL_ISNT_PROTOTYPE (old_decl)
   10966     37714625 :            && !DECL_DECLARED_INLINE_P (decl1))
   10967            4 :     warning_at (loc, OPT_Wmissing_prototypes,
   10968              :                 "no previous prototype for %qD", decl1);
   10969              :   /* Optionally warn of any def with no previous prototype
   10970              :      if the function has already been used.  */
   10971     37713980 :   else if (warn_missing_prototypes
   10972       107665 :            && old_decl != NULL_TREE
   10973        74467 :            && old_decl != error_mark_node
   10974        74467 :            && TREE_USED (old_decl)
   10975     37721104 :            && !prototype_p (TREE_TYPE (old_decl)))
   10976            0 :     warning_at (loc, OPT_Wmissing_prototypes,
   10977              :                 "%qD was used with no prototype before its definition", decl1);
   10978              :   /* Optionally warn of any global def with no previous declaration.  */
   10979     37713980 :   else if (warn_missing_declarations
   10980            4 :            && TREE_PUBLIC (decl1)
   10981            3 :            && old_decl == NULL_TREE
   10982            3 :            && !MAIN_NAME_P (DECL_NAME (decl1))
   10983     37713983 :            && !DECL_DECLARED_INLINE_P (decl1))
   10984            2 :     warning_at (loc, OPT_Wmissing_declarations,
   10985              :                 "no previous declaration for %qD",
   10986              :                 decl1);
   10987              :   /* Optionally warn of any def with no previous declaration
   10988              :      if the function has already been used.  */
   10989     37713978 :   else if (warn_missing_declarations
   10990            2 :            && old_decl != NULL_TREE
   10991            0 :            && old_decl != error_mark_node
   10992            0 :            && TREE_USED (old_decl)
   10993     37713978 :            && C_DECL_IMPLICIT (old_decl))
   10994            0 :     warning_at (loc, OPT_Wmissing_declarations,
   10995              :                 "%qD was used with no declaration before its definition", decl1);
   10996              : 
   10997              :   /* This function exists in static storage.
   10998              :      (This does not mean `static' in the C sense!)  */
   10999     37713985 :   TREE_STATIC (decl1) = 1;
   11000              : 
   11001              :   /* This is the earliest point at which we might know the assembler
   11002              :      name of the function.  Thus, if it's set before this, die horribly.  */
   11003     37713985 :   gcc_assert (!DECL_ASSEMBLER_NAME_SET_P (decl1));
   11004              : 
   11005              :   /* If #pragma weak was used, mark the decl weak now.  */
   11006     37713985 :   if (current_scope == file_scope)
   11007     37712359 :     maybe_apply_pragma_weak (decl1);
   11008              : 
   11009              :   /* Warn for unlikely, improbable, or stupid declarations of `main'.  */
   11010     37713985 :   if (warn_main && MAIN_NAME_P (DECL_NAME (decl1)))
   11011              :     {
   11012         3361 :       if (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (decl1)))
   11013         3361 :           != integer_type_node)
   11014            5 :         pedwarn (loc, OPT_Wmain, "return type of %qD is not %<int%>", decl1);
   11015         3356 :       else if (TYPE_ATOMIC (TREE_TYPE (TREE_TYPE (decl1))))
   11016            1 :         pedwarn (loc, OPT_Wmain, "%<_Atomic%>-qualified return type of %qD",
   11017              :                  decl1);
   11018              : 
   11019         3361 :       check_main_parameter_types (decl1);
   11020              : 
   11021         3361 :       if (!TREE_PUBLIC (decl1))
   11022            0 :         pedwarn (loc, OPT_Wmain,
   11023              :                  "%qD is normally a non-static function", decl1);
   11024              :     }
   11025              : 
   11026     37713985 :   tree parms = current_function_arg_info->parms;
   11027     37713985 :   if (old_decl)
   11028              :     {
   11029       232053 :       location_t origloc = DECL_SOURCE_LOCATION (old_decl);
   11030       232053 :       warn_parms_array_mismatch (origloc, old_decl, parms);
   11031              :     }
   11032              : 
   11033              :   /* To enable versions to be created across TU's we mark and mangle all
   11034              :      non-default versioned functions.  */
   11035     37713985 :   if (TREE_CODE (decl1) == FUNCTION_DECL
   11036              :       && !TARGET_HAS_FMV_TARGET_ATTRIBUTE
   11037              :       && get_target_version (decl1).is_valid ())
   11038              :     {
   11039              :       maybe_mark_function_versioned (decl1);
   11040              :       if (current_scope != file_scope)
   11041              :         error ("versioned definitions are only allowed at file scope");
   11042              :     }
   11043              : 
   11044              :   /* Record the decl so that the function name is defined.
   11045              :      If we already have a decl for this name, and it is a FUNCTION_DECL,
   11046              :      use the old decl.  */
   11047              : 
   11048     37713985 :   current_function_decl = pushdecl (decl1);
   11049              : 
   11050     37713985 :   if (tree access = build_attr_access_from_parms (parms, false))
   11051        58510 :     decl_attributes (&current_function_decl, access, ATTR_FLAG_INTERNAL,
   11052              :                      old_decl);
   11053              : 
   11054     37713985 :   push_scope ();
   11055     37713985 :   declare_parm_level ();
   11056              : 
   11057              :   /* Set the result decl source location to the location of the typespec.  */
   11058      4276794 :   result_loc = (declspecs->locations[cdw_typespec] == UNKNOWN_LOCATION
   11059     37713985 :                 ? loc : declspecs->locations[cdw_typespec]);
   11060     37713985 :   restype = TREE_TYPE (TREE_TYPE (current_function_decl));
   11061     37713985 :   resdecl = build_decl (result_loc, RESULT_DECL, NULL_TREE, restype);
   11062     37713985 :   DECL_ARTIFICIAL (resdecl) = 1;
   11063     37713985 :   DECL_IGNORED_P (resdecl) = 1;
   11064     37713985 :   DECL_RESULT (current_function_decl) = resdecl;
   11065              : 
   11066     37713985 :   start_fname_decls ();
   11067              : 
   11068     37713985 :   return true;
   11069              : }
   11070              : 
   11071              : /* Subroutine of store_parm_decls which handles new-style function
   11072              :    definitions (prototype format). The parms already have decls, so we
   11073              :    need only record them as in effect and complain if any redundant
   11074              :    old-style parm decls were written.  */
   11075              : static void
   11076     37700733 : store_parm_decls_newstyle (tree fndecl, const struct c_arg_info *arg_info)
   11077              : {
   11078     37700733 :   tree decl;
   11079     37700733 :   c_arg_tag *tag;
   11080     37700733 :   unsigned ix;
   11081              : 
   11082     37700733 :   if (current_scope->bindings)
   11083              :     {
   11084            8 :       error_at (DECL_SOURCE_LOCATION (fndecl),
   11085              :                 "old-style parameter declarations in prototyped "
   11086              :                 "function definition");
   11087              : 
   11088              :       /* Get rid of the old-style declarations.  */
   11089            8 :       pop_scope ();
   11090            8 :       push_scope ();
   11091              :     }
   11092              :   /* Don't issue this warning for nested functions, and don't issue this
   11093              :      warning if we got here because ARG_INFO_TYPES was error_mark_node
   11094              :      (this happens when a function definition has just an ellipsis in
   11095              :      its parameter list).  */
   11096     37700725 :   else if (!in_system_header_at (input_location)
   11097       661035 :            && !current_function_scope
   11098       659557 :            && arg_info->types != error_mark_node
   11099     38360282 :            && !arg_info->c23_empty_parens)
   11100       604785 :     warning_at (DECL_SOURCE_LOCATION (fndecl), OPT_Wtraditional,
   11101              :                 "traditional C rejects ISO C style function definitions");
   11102              : 
   11103              :   /* Now make all the parameter declarations visible in the function body.
   11104              :      We can bypass most of the grunt work of pushdecl.  */
   11105    140991541 :   for (decl = arg_info->parms; decl; decl = DECL_CHAIN (decl))
   11106              :     {
   11107    103290808 :       DECL_CONTEXT (decl) = current_function_decl;
   11108    103290808 :       if (DECL_NAME (decl))
   11109              :         {
   11110    103289217 :           bind (DECL_NAME (decl), decl, current_scope,
   11111              :                 /*invisible=*/false, /*nested=*/false,
   11112              :                 UNKNOWN_LOCATION);
   11113    103289217 :           if (!TREE_USED (decl))
   11114    103271736 :             warn_if_shadowing (decl);
   11115              :         }
   11116              :       else
   11117         1591 :         pedwarn_c11 (DECL_SOURCE_LOCATION (decl), OPT_Wmissing_parameter_name,
   11118              :                      "ISO C does not support omitting parameter names in "
   11119              :                      "function definitions before C23");
   11120              :     }
   11121              : 
   11122              :   /* Record the parameter list in the function declaration.  */
   11123     37700733 :   DECL_ARGUMENTS (fndecl) = arg_info->parms;
   11124              : 
   11125              :   /* Now make all the ancillary declarations visible, likewise.  */
   11126     37700794 :   for (decl = arg_info->others; decl; decl = DECL_CHAIN (decl))
   11127              :     {
   11128           61 :       DECL_CONTEXT (decl) = current_function_decl;
   11129           61 :       if (DECL_NAME (decl))
   11130            0 :         bind (DECL_NAME (decl), decl, current_scope,
   11131              :               /*invisible=*/false,
   11132            0 :               /*nested=*/(TREE_CODE (decl) == FUNCTION_DECL),
   11133              :               UNKNOWN_LOCATION);
   11134              :     }
   11135              : 
   11136              :   /* And all the tag declarations.  */
   11137     37700850 :   FOR_EACH_VEC_SAFE_ELT_REVERSE (arg_info->tags, ix, tag)
   11138           61 :     if (tag->id)
   11139           28 :       bind (tag->id, tag->type, current_scope,
   11140              :             /*invisible=*/false, /*nested=*/false, UNKNOWN_LOCATION);
   11141     37700733 : }
   11142              : 
   11143              : /* Subroutine of store_parm_decls which handles old-style function
   11144              :    definitions (separate parameter list and declarations).  */
   11145              : 
   11146              : static void
   11147        13252 : store_parm_decls_oldstyle (tree fndecl, const struct c_arg_info *arg_info)
   11148              : {
   11149        13252 :   struct c_binding *b;
   11150        13252 :   tree parm, decl, last;
   11151        13252 :   tree parmids = arg_info->parms;
   11152        13252 :   hash_set<tree> seen_args;
   11153              : 
   11154        13252 :   if (!in_system_header_at (input_location))
   11155              :     {
   11156        13159 :       if (flag_isoc23)
   11157         1348 :         pedwarn (DECL_SOURCE_LOCATION (fndecl),
   11158         1348 :                  OPT_Wold_style_definition, "old-style function definition");
   11159              :       else
   11160        11811 :         warning_at (DECL_SOURCE_LOCATION (fndecl),
   11161        11811 :                     OPT_Wold_style_definition,
   11162              :                     "old-style function definition");
   11163              :     }
   11164              : 
   11165        13252 :   if (current_scope->had_vla_unspec)
   11166            1 :     error ("%<[*]%> not allowed in other than function prototype scope");
   11167              : 
   11168              :   /* Match each formal parameter name with its declaration.  Save each
   11169              :      decl in the appropriate TREE_PURPOSE slot of the parmids chain.  */
   11170        47526 :   for (parm = parmids; parm; parm = TREE_CHAIN (parm))
   11171              :     {
   11172        34274 :       if (TREE_VALUE (parm) == NULL_TREE)
   11173              :         {
   11174            0 :           error_at (DECL_SOURCE_LOCATION (fndecl),
   11175              :                     "parameter name missing from parameter list");
   11176            0 :           TREE_PURPOSE (parm) = NULL_TREE;
   11177            0 :           continue;
   11178              :         }
   11179              : 
   11180        34274 :       b = I_SYMBOL_BINDING (TREE_VALUE (parm));
   11181        34274 :       if (b && B_IN_CURRENT_SCOPE (b))
   11182              :         {
   11183        22654 :           decl = b->decl;
   11184              :           /* Skip erroneous parameters.  */
   11185        22654 :           if (decl == error_mark_node)
   11186            2 :             continue;
   11187              :           /* If we got something other than a PARM_DECL it is an error.  */
   11188        22652 :           if (TREE_CODE (decl) != PARM_DECL)
   11189              :             {
   11190            7 :               error_at (DECL_SOURCE_LOCATION (decl),
   11191              :                         "%qD declared as a non-parameter", decl);
   11192            7 :               continue;
   11193              :             }
   11194              :           /* If the declaration is already marked, we have a duplicate
   11195              :              name.  Complain and ignore the duplicate.  */
   11196        22645 :           else if (seen_args.contains (decl))
   11197              :             {
   11198            0 :               error_at (DECL_SOURCE_LOCATION (decl),
   11199              :                         "multiple parameters named %qD", decl);
   11200            0 :               TREE_PURPOSE (parm) = NULL_TREE;
   11201            0 :               continue;
   11202              :             }
   11203              :           /* If the declaration says "void", complain and turn it into
   11204              :              an int.  */
   11205        22645 :           else if (VOID_TYPE_P (TREE_TYPE (decl)))
   11206              :             {
   11207            0 :               error_at (DECL_SOURCE_LOCATION (decl),
   11208              :                         "parameter %qD declared with void type", decl);
   11209            0 :               TREE_TYPE (decl) = integer_type_node;
   11210            0 :               DECL_ARG_TYPE (decl) = integer_type_node;
   11211            0 :               layout_decl (decl, 0);
   11212              :             }
   11213        22645 :           warn_if_shadowing (decl);
   11214              :         }
   11215              :       /* If no declaration found, default to int.  */
   11216              :       else
   11217              :         {
   11218              :           /* FIXME diagnostics: This should be the location of the argument,
   11219              :              not the FNDECL.  E.g., for an old-style declaration
   11220              : 
   11221              :                int f10(v) { blah; }
   11222              : 
   11223              :              We should use the location of the V, not the F10.
   11224              :              Unfortunately, the V is an IDENTIFIER_NODE which has no
   11225              :              location.  In the future we need locations for c_arg_info
   11226              :              entries.
   11227              : 
   11228              :              See gcc.dg/Wshadow-3.c for an example of this problem. */
   11229        11620 :           decl = build_decl (DECL_SOURCE_LOCATION (fndecl),
   11230        11620 :                              PARM_DECL, TREE_VALUE (parm), integer_type_node);
   11231        11620 :           DECL_ARG_TYPE (decl) = TREE_TYPE (decl);
   11232        11620 :           pushdecl (decl);
   11233        11620 :           warn_if_shadowing (decl);
   11234              : 
   11235        11620 :           if (flag_isoc99)
   11236          118 :             permerror_opt (DECL_SOURCE_LOCATION (decl),
   11237          118 :                            OPT_Wimplicit_int, "type of %qD defaults to %<int%>",
   11238              :                            decl);
   11239              :           else
   11240        11502 :             warning_at (DECL_SOURCE_LOCATION (decl),
   11241        11502 :                         OPT_Wmissing_parameter_type,
   11242              :                         "type of %qD defaults to %<int%>", decl);
   11243              :         }
   11244              : 
   11245        34265 :       TREE_PURPOSE (parm) = decl;
   11246        34265 :       seen_args.add (decl);
   11247              :     }
   11248              : 
   11249              :   /* Now examine the parms chain for incomplete declarations
   11250              :      and declarations with no corresponding names.  */
   11251              : 
   11252        47605 :   for (b = current_scope->bindings; b; b = b->prev)
   11253              :     {
   11254        34353 :       parm = b->decl;
   11255        34353 :       if (TREE_CODE (parm) != PARM_DECL)
   11256           79 :         continue;
   11257              : 
   11258        34274 :       if (TREE_TYPE (parm) != error_mark_node
   11259        34274 :           && !COMPLETE_TYPE_P (TREE_TYPE (parm)))
   11260              :         {
   11261            0 :           error_at (DECL_SOURCE_LOCATION (parm),
   11262              :                     "parameter %qD has incomplete type", parm);
   11263            0 :           TREE_TYPE (parm) = error_mark_node;
   11264              :         }
   11265              : 
   11266        34274 :       if (!seen_args.contains (parm))
   11267              :         {
   11268            9 :           error_at (DECL_SOURCE_LOCATION (parm),
   11269              :                     "declaration for parameter %qD but no such parameter",
   11270              :                     parm);
   11271              : 
   11272              :           /* Pretend the parameter was not missing.
   11273              :              This gets us to a standard state and minimizes
   11274              :              further error messages.  */
   11275            9 :           parmids = chainon (parmids, tree_cons (parm, 0, 0));
   11276              :         }
   11277              :     }
   11278              : 
   11279              :   /* Chain the declarations together in the order of the list of
   11280              :      names.  Store that chain in the function decl, replacing the
   11281              :      list of names.  Update the current scope to match.  */
   11282        13252 :   DECL_ARGUMENTS (fndecl) = NULL_TREE;
   11283              : 
   11284        13260 :   for (parm = parmids; parm; parm = TREE_CHAIN (parm))
   11285         8680 :     if (TREE_PURPOSE (parm))
   11286              :       break;
   11287        13252 :   if (parm && TREE_PURPOSE (parm))
   11288              :     {
   11289         8672 :       last = TREE_PURPOSE (parm);
   11290         8672 :       DECL_ARGUMENTS (fndecl) = last;
   11291              : 
   11292        34275 :       for (parm = TREE_CHAIN (parm); parm; parm = TREE_CHAIN (parm))
   11293        25603 :         if (TREE_PURPOSE (parm))
   11294              :           {
   11295        25602 :             DECL_CHAIN (last) = TREE_PURPOSE (parm);
   11296        25603 :             last = TREE_PURPOSE (parm);
   11297              :           }
   11298         8672 :       DECL_CHAIN (last) = NULL_TREE;
   11299              :     }
   11300              : 
   11301              :   /* If there was a previous prototype,
   11302              :      set the DECL_ARG_TYPE of each argument according to
   11303              :      the type previously specified, and report any mismatches.  */
   11304              : 
   11305        13252 :   if (current_function_prototype_arg_types)
   11306              :     {
   11307          171 :       tree type;
   11308          171 :       for (parm = DECL_ARGUMENTS (fndecl),
   11309          171 :              type = current_function_prototype_arg_types;
   11310          373 :            parm || (type != NULL_TREE
   11311          166 :                     && TREE_VALUE (type) != error_mark_node
   11312          166 :                     && TYPE_MAIN_VARIANT (TREE_VALUE (type)) != void_type_node);
   11313          202 :            parm = DECL_CHAIN (parm), type = TREE_CHAIN (type))
   11314              :         {
   11315          212 :           if (parm == NULL_TREE
   11316          206 :               || type == NULL_TREE
   11317          418 :               || (TREE_VALUE (type) != error_mark_node
   11318          192 :                   && TYPE_MAIN_VARIANT (TREE_VALUE (type)) == void_type_node))
   11319              :             {
   11320           10 :               if (current_function_prototype_built_in)
   11321            6 :                 warning_at (DECL_SOURCE_LOCATION (fndecl),
   11322            6 :                             0, "number of arguments doesn%'t match "
   11323              :                             "built-in prototype");
   11324              :               else
   11325              :                 {
   11326              :                   /* FIXME diagnostics: This should be the location of
   11327              :                      FNDECL, but there is bug when a prototype is
   11328              :                      declared inside function context, but defined
   11329              :                      outside of it (e.g., gcc.dg/pr15698-2.c).  In
   11330              :                      which case FNDECL gets the location of the
   11331              :                      prototype, not the definition.  */
   11332            4 :                   error_at (input_location,
   11333              :                             "number of arguments doesn%'t match prototype");
   11334              : 
   11335            4 :                   error_at (current_function_prototype_locus,
   11336              :                             "prototype declaration");
   11337              :                 }
   11338              :               break;
   11339              :             }
   11340              :           /* Type for passing arg must be consistent with that
   11341              :              declared for the arg.  ISO C says we take the unqualified
   11342              :              type for parameters declared with qualified type.  */
   11343          202 :           if (TREE_TYPE (parm) != error_mark_node
   11344          201 :               && TREE_VALUE (type) != error_mark_node
   11345          389 :               && ((TYPE_ATOMIC (DECL_ARG_TYPE (parm))
   11346          187 :                    != TYPE_ATOMIC (TREE_VALUE (type)))
   11347          185 :                   || !comptypes (TYPE_MAIN_VARIANT (DECL_ARG_TYPE (parm)),
   11348          185 :                                  TYPE_MAIN_VARIANT (TREE_VALUE (type)))))
   11349              :             {
   11350           36 :               if ((TYPE_ATOMIC (DECL_ARG_TYPE (parm))
   11351           36 :                    == TYPE_ATOMIC (TREE_VALUE (type)))
   11352           36 :                   && (TYPE_MAIN_VARIANT (TREE_TYPE (parm))
   11353           34 :                       == TYPE_MAIN_VARIANT (TREE_VALUE (type))))
   11354              :                 {
   11355              :                   /* Adjust argument to match prototype.  E.g. a previous
   11356              :                      `int foo(float);' prototype causes
   11357              :                      `int foo(x) float x; {...}' to be treated like
   11358              :                      `int foo(float x) {...}'.  This is particularly
   11359              :                      useful for argument types like uid_t.  */
   11360           17 :                   DECL_ARG_TYPE (parm) = TREE_TYPE (parm);
   11361              : 
   11362              :                   /* ??? Is it possible to get here with a
   11363              :                      built-in prototype or will it always have
   11364              :                      been diagnosed as conflicting with an
   11365              :                      old-style definition and discarded?  */
   11366           17 :                   if (current_function_prototype_built_in)
   11367            2 :                     warning_at (DECL_SOURCE_LOCATION (parm),
   11368            2 :                                 OPT_Wpedantic, "promoted argument %qD "
   11369              :                                 "doesn%'t match built-in prototype", parm);
   11370              :                   else
   11371              :                     {
   11372           15 :                       pedwarn (DECL_SOURCE_LOCATION (parm),
   11373           15 :                                OPT_Wpedantic, "promoted argument %qD "
   11374              :                                "doesn%'t match prototype", parm);
   11375           15 :                       pedwarn (current_function_prototype_locus, OPT_Wpedantic,
   11376              :                                "prototype declaration");
   11377              :                     }
   11378              :                 }
   11379              :               else
   11380              :                 {
   11381           19 :                   if (current_function_prototype_built_in)
   11382           10 :                     warning_at (DECL_SOURCE_LOCATION (parm),
   11383           10 :                                 0, "argument %qD doesn%'t match "
   11384              :                                 "built-in prototype", parm);
   11385              :                   else
   11386              :                     {
   11387            9 :                       error_at (DECL_SOURCE_LOCATION (parm),
   11388              :                                 "argument %qD doesn%'t match prototype", parm);
   11389            9 :                       error_at (current_function_prototype_locus,
   11390              :                                 "prototype declaration");
   11391              :                     }
   11392              :                 }
   11393              :             }
   11394              :         }
   11395          171 :       TYPE_ACTUAL_ARG_TYPES (TREE_TYPE (fndecl)) = NULL_TREE;
   11396              :     }
   11397              : 
   11398              :   /* Otherwise, create a prototype that would match.  */
   11399              : 
   11400              :   else
   11401              :     {
   11402        13081 :       tree actual = NULL_TREE, last = NULL_TREE, type;
   11403              : 
   11404        47149 :       for (parm = DECL_ARGUMENTS (fndecl); parm; parm = DECL_CHAIN (parm))
   11405              :         {
   11406        34068 :           type = tree_cons (NULL_TREE, DECL_ARG_TYPE (parm), NULL_TREE);
   11407        34068 :           if (last)
   11408        25552 :             TREE_CHAIN (last) = type;
   11409              :           else
   11410              :             actual = type;
   11411        34068 :           last = type;
   11412              :         }
   11413        13081 :       type = tree_cons (NULL_TREE, void_type_node, NULL_TREE);
   11414        13081 :       if (last)
   11415         8516 :         TREE_CHAIN (last) = type;
   11416              :       else
   11417              :         actual = type;
   11418              : 
   11419              :       /* We are going to assign a new value for the TYPE_ACTUAL_ARG_TYPES
   11420              :          of the type of this function, but we need to avoid having this
   11421              :          affect the types of other similarly-typed functions, so we must
   11422              :          first force the generation of an identical (but separate) type
   11423              :          node for the relevant function type.  The new node we create
   11424              :          will be a variant of the main variant of the original function
   11425              :          type.  */
   11426              : 
   11427        13081 :       TREE_TYPE (fndecl) = build_variant_type_copy (TREE_TYPE (fndecl));
   11428              : 
   11429        13081 :       TYPE_ACTUAL_ARG_TYPES (TREE_TYPE (fndecl)) = actual;
   11430              :     }
   11431        13252 : }
   11432              : 
   11433              : /* Store parameter declarations passed in ARG_INFO into the current
   11434              :    function declaration.  */
   11435              : 
   11436              : void
   11437            0 : store_parm_decls_from (struct c_arg_info *arg_info)
   11438              : {
   11439            0 :   current_function_arg_info = arg_info;
   11440            0 :   store_parm_decls ();
   11441            0 : }
   11442              : 
   11443              : /* Called by walk_tree to look for and update context-less labels
   11444              :    or labels with context in the parent function.  */
   11445              : 
   11446              : static tree
   11447         8175 : set_labels_context_r (tree *tp, int *walk_subtrees, void *data)
   11448              : {
   11449         8175 :   tree ctx = static_cast<tree>(data);
   11450         8175 :   if (TREE_CODE (*tp) == LABEL_EXPR
   11451         8175 :       && (DECL_CONTEXT (LABEL_EXPR_LABEL (*tp)) == NULL_TREE
   11452            2 :           || DECL_CONTEXT (LABEL_EXPR_LABEL (*tp)) == DECL_CONTEXT (ctx)))
   11453              :     {
   11454           72 :       DECL_CONTEXT (LABEL_EXPR_LABEL (*tp)) = ctx;
   11455           72 :       *walk_subtrees = 0;
   11456              :     }
   11457              : 
   11458         8175 :   return NULL_TREE;
   11459              : }
   11460              : 
   11461              : /* Store the parameter declarations into the current function declaration.
   11462              :    This is called after parsing the parameter declarations, before
   11463              :    digesting the body of the function.
   11464              : 
   11465              :    For an old-style definition, construct a prototype out of the old-style
   11466              :    parameter declarations and inject it into the function's type.  */
   11467              : 
   11468              : void
   11469     37713985 : store_parm_decls (void)
   11470              : {
   11471     37713985 :   tree fndecl = current_function_decl;
   11472     37713985 :   bool proto;
   11473              : 
   11474              :   /* The argument information block for FNDECL.  */
   11475     37713985 :   struct c_arg_info *arg_info = current_function_arg_info;
   11476     37713985 :   current_function_arg_info = 0;
   11477              : 
   11478              :   /* True if this definition is written with a prototype.  In C23, an
   11479              :      empty argument list was converted to (void) in grokparms; in
   11480              :      older C standard versions, it does not give the function a type
   11481              :      with a prototype for future calls.  */
   11482     37713985 :   proto = arg_info->types != 0 || arg_info->no_named_args_stdarg_p;
   11483              : 
   11484        13252 :   if (proto)
   11485     37700733 :     store_parm_decls_newstyle (fndecl, arg_info);
   11486              :   else
   11487        13252 :     store_parm_decls_oldstyle (fndecl, arg_info);
   11488              : 
   11489              :   /* The next call to push_scope will be a function body.  */
   11490              : 
   11491     37713985 :   next_is_function_body = true;
   11492              : 
   11493              :   /* Write a record describing this function definition to the prototypes
   11494              :      file (if requested).  */
   11495              : 
   11496     37713985 :   gen_aux_info_record (fndecl, 1, 0, proto);
   11497              : 
   11498              :   /* Initialize the RTL code for the function.  */
   11499     37713985 :   allocate_struct_function (fndecl, false);
   11500              : 
   11501     37713985 :   if (warn_unused_local_typedefs)
   11502      3197962 :     cfun->language = ggc_cleared_alloc<language_function> ();
   11503              : 
   11504              :   /* Begin the statement tree for this function.  */
   11505     37713985 :   DECL_SAVED_TREE (fndecl) = push_stmt_list ();
   11506              : 
   11507              :   /* ??? Insert the contents of the pending sizes list into the function
   11508              :      to be evaluated.  The only reason left to have this is
   11509              :         void foo(int n, int array[n++])
   11510              :      because we throw away the array type in favor of a pointer type, and
   11511              :      thus won't naturally see the SAVE_EXPR containing the increment.  All
   11512              :      other pending sizes would be handled by gimplify_parameters.  */
   11513     37713985 :   if (arg_info->pending_sizes)
   11514              :     {
   11515              :       /* In very special circumstances, e.g. for code like
   11516              :            _Atomic int i = 5;
   11517              :            void f (int a[i += 2]) {}
   11518              :          we need to execute the atomic assignment on function entry.
   11519              :          But in this case, it is not just a straight store, it has the
   11520              :          op= form, which means that build_atomic_assign has generated
   11521              :          gotos, labels, etc.  Because at that time the function decl
   11522              :          for F has not been created yet, those labels do not have any
   11523              :          function context.  But we have the fndecl now, so update the
   11524              :          labels accordingly.  gimplify_expr would crash otherwise.
   11525              :          Or with nested functions the labels could be created with parent
   11526              :          function's context, while when the statement is emitted at the
   11527              :          start of the nested function, it needs the nested function's
   11528              :          context.  */
   11529          298 :       walk_tree_without_duplicates (&arg_info->pending_sizes,
   11530              :                                     set_labels_context_r, fndecl);
   11531          298 :       add_stmt (arg_info->pending_sizes);
   11532              :     }
   11533     37713985 : }
   11534              : 
   11535              : /* Store PARM_DECLs in PARMS into scope temporarily.  Used for
   11536              :    c_finish_omp_declare_simd for function prototypes.  No diagnostics
   11537              :    should be done.  */
   11538              : 
   11539              : void
   11540          267 : temp_store_parm_decls (tree fndecl, tree parms)
   11541              : {
   11542          267 :   push_scope ();
   11543         1004 :   for (tree p = parms; p; p = DECL_CHAIN (p))
   11544              :     {
   11545          470 :       DECL_CONTEXT (p) = fndecl;
   11546          470 :       if (DECL_NAME (p))
   11547          334 :         bind (DECL_NAME (p), p, current_scope,
   11548              :               /*invisible=*/false, /*nested=*/false,
   11549              :               UNKNOWN_LOCATION);
   11550              :     }
   11551          267 : }
   11552              : 
   11553              : /* Undo what temp_store_parm_decls did.  */
   11554              : 
   11555              : void
   11556          267 : temp_pop_parm_decls (void)
   11557              : {
   11558              :   /* Clear all bindings in this temporary scope, so that
   11559              :      pop_scope doesn't create a BLOCK.  */
   11560          267 :   struct c_binding *b = current_scope->bindings;
   11561          267 :   current_scope->bindings = NULL;
   11562          606 :   for (; b; b = free_binding_and_advance (b))
   11563              :     {
   11564          339 :       gcc_assert (TREE_CODE (b->decl) == PARM_DECL
   11565              :                   || b->decl == error_mark_node);
   11566          339 :       gcc_assert (I_SYMBOL_BINDING (b->id) == b);
   11567          339 :       I_SYMBOL_BINDING (b->id) = b->shadowed;
   11568          339 :       if (b->shadowed && b->shadowed->u.type)
   11569            0 :         TREE_TYPE (b->shadowed->decl) = b->shadowed->u.type;
   11570              :     }
   11571          267 :   pop_scope ();
   11572          267 : }
   11573              : 
   11574              : 
   11575              : /* Finish up a function declaration and compile that function
   11576              :    all the way to assembler language output.  Then free the storage
   11577              :    for the function definition.
   11578              : 
   11579              :    This is called after parsing the body of the function definition.  */
   11580              : 
   11581              : void
   11582     37713983 : finish_function (location_t end_loc)
   11583              : {
   11584     37713983 :   tree fndecl = current_function_decl;
   11585              : 
   11586     37713983 :   if (c_dialect_objc ())
   11587            0 :     objc_finish_function ();
   11588              : 
   11589              :   /* Clear the static chain for nested functions that do not need one.  */
   11590     37713983 :   if (!C_FUNC_NONLOCAL_CONTEXT (fndecl))
   11591     37712928 :     DECL_STATIC_CHAIN (fndecl) = 0;
   11592              : 
   11593     37713983 :   if (DECL_INITIAL (fndecl) && DECL_INITIAL (fndecl) != error_mark_node)
   11594     37713981 :     BLOCK_SUPERCONTEXT (DECL_INITIAL (fndecl)) = fndecl;
   11595              : 
   11596              :   /* Must mark the RESULT_DECL as being in this function.  */
   11597              : 
   11598     37713983 :   if (DECL_RESULT (fndecl) && DECL_RESULT (fndecl) != error_mark_node)
   11599     37713983 :     DECL_CONTEXT (DECL_RESULT (fndecl)) = fndecl;
   11600              : 
   11601     37764265 :   if (MAIN_NAME_P (DECL_NAME (fndecl)) && !TREE_THIS_VOLATILE (fndecl)
   11602        50281 :       && TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (fndecl)))
   11603     37764264 :       == integer_type_node && flag_isoc99)
   11604              :     {
   11605              :       /* Hack.  We don't want the middle-end to warn that this return
   11606              :          is unreachable, so we mark its location as special.  Using
   11607              :          UNKNOWN_LOCATION has the problem that it gets clobbered in
   11608              :          annotate_one_with_locus.  A cleaner solution might be to
   11609              :          ensure ! should_carry_locus_p (stmt), but that needs a flag.
   11610              :       */
   11611        48885 :       c_finish_return (BUILTINS_LOCATION, integer_zero_node, NULL_TREE);
   11612              :     }
   11613              : 
   11614              :   /* Tie off the statement tree for this function.  */
   11615     37713983 :   DECL_SAVED_TREE (fndecl) = pop_stmt_list (DECL_SAVED_TREE (fndecl));
   11616              : 
   11617     37713983 :   finish_fname_decls ();
   11618              : 
   11619              :   /* Complain if there's no return statement only if option specified on
   11620              :      command line.  */
   11621     37713983 :   if (warn_return_type > 0
   11622      3197985 :       && TREE_CODE (TREE_TYPE (TREE_TYPE (fndecl))) != VOID_TYPE
   11623      2993003 :       && !current_function_returns_value && !current_function_returns_null
   11624              :       /* Don't complain if we are no-return.  */
   11625           72 :       && !current_function_returns_abnormally
   11626              :       /* Don't complain if we are declared noreturn.  */
   11627           21 :       && !TREE_THIS_VOLATILE (fndecl)
   11628              :       /* Don't warn for main().  */
   11629           18 :       && !MAIN_NAME_P (DECL_NAME (fndecl))
   11630              :       /* Or if they didn't actually specify a return type.  */
   11631           17 :       && !C_FUNCTION_IMPLICIT_INT (fndecl)
   11632              :       /* Normally, with -Wreturn-type, flow will complain, but we might
   11633              :          optimize out static functions.  */
   11634           17 :       && !TREE_PUBLIC (fndecl)
   11635            6 :       && targetm.warn_func_return (fndecl)
   11636     40911968 :       && warning (OPT_Wreturn_type,
   11637              :                   "no return statement in function returning non-void"))
   11638            5 :     suppress_warning (fndecl, OPT_Wreturn_type);
   11639              : 
   11640              :   /* Complain about parameters that are only set, but never otherwise used.  */
   11641     37713983 :   if (warn_unused_but_set_parameter)
   11642              :     {
   11643      3129225 :       tree decl;
   11644              : 
   11645      3129225 :       for (decl = DECL_ARGUMENTS (fndecl);
   11646     11647492 :            decl;
   11647      8518267 :            decl = DECL_CHAIN (decl))
   11648      8518267 :         if (TREE_USED (decl)
   11649      8457564 :             && TREE_CODE (decl) == PARM_DECL
   11650      8457564 :             && !DECL_READ_P (decl)
   11651           48 :             && DECL_NAME (decl)
   11652           48 :             && !DECL_ARTIFICIAL (decl)
   11653      8518315 :             && !warning_suppressed_p (decl, OPT_Wunused_but_set_parameter_))
   11654           48 :           warning_at (DECL_SOURCE_LOCATION (decl),
   11655           48 :                       OPT_Wunused_but_set_parameter_,
   11656              :                       "parameter %qD set but not used", decl);
   11657              :     }
   11658              : 
   11659              :   /* Complain about locally defined typedefs that are not used in this
   11660              :      function.  */
   11661     37713983 :   maybe_warn_unused_local_typedefs ();
   11662              : 
   11663              :   /* Possibly warn about unused parameters.  */
   11664     37713983 :   if (warn_unused_parameter)
   11665      3035330 :     do_warn_unused_parameter (fndecl);
   11666              : 
   11667              :   /* Store the end of the function, so that we get good line number
   11668              :      info for the epilogue.  */
   11669     37713983 :   cfun->function_end_locus = end_loc;
   11670              : 
   11671              :   /* Finalize the ELF visibility for the function.  */
   11672     37713983 :   c_determine_visibility (fndecl);
   11673              : 
   11674              :   /* For GNU C extern inline functions disregard inline limits.  */
   11675     37713983 :   if (DECL_EXTERNAL (fndecl)
   11676     36834573 :       && DECL_DECLARED_INLINE_P (fndecl)
   11677     74548553 :       && (flag_gnu89_inline
   11678     36795000 :           || lookup_attribute ("gnu_inline", DECL_ATTRIBUTES (fndecl))))
   11679     36834087 :     DECL_DISREGARD_INLINE_LIMITS (fndecl) = 1;
   11680              : 
   11681              :   /* Genericize before inlining.  Delay genericizing nested functions
   11682              :      until their parent function is genericized.  Since finalizing
   11683              :      requires GENERIC, delay that as well.  */
   11684              : 
   11685     75427966 :   if (DECL_INITIAL (fndecl) && DECL_INITIAL (fndecl) != error_mark_node
   11686     75427964 :       && !undef_nested_function)
   11687              :     {
   11688     37713975 :       if (!decl_function_context (fndecl))
   11689              :         {
   11690     37712349 :           invoke_plugin_callbacks (PLUGIN_PRE_GENERICIZE, fndecl);
   11691     37712349 :           c_genericize (fndecl);
   11692              : 
   11693              :           /* ??? Objc emits functions after finalizing the compilation unit.
   11694              :              This should be cleaned up later and this conditional removed.  */
   11695     37712349 :           if (symtab->global_info_ready)
   11696              :             {
   11697            0 :               cgraph_node::add_new_function (fndecl, false);
   11698            0 :               return;
   11699              :             }
   11700     37712349 :           cgraph_node::finalize_function (fndecl, false);
   11701              :         }
   11702              :       else
   11703              :         {
   11704              :           /* Register this function with cgraph just far enough to get it
   11705              :             added to our parent's nested function list.  Handy, since the
   11706              :             C front end doesn't have such a list.  */
   11707         1626 :           (void) cgraph_node::get_create (fndecl);
   11708              :         }
   11709              :     }
   11710              : 
   11711     37713983 :   if (!decl_function_context (fndecl))
   11712     37712357 :     undef_nested_function = false;
   11713              : 
   11714     37713983 :   if (cfun->language != NULL)
   11715              :     {
   11716      3197961 :       ggc_free (cfun->language);
   11717      3197961 :       cfun->language = NULL;
   11718              :     }
   11719              : 
   11720              :   /* We're leaving the context of this function, so zap cfun.
   11721              :      It's still in DECL_STRUCT_FUNCTION, and we'll restore it in
   11722              :      tree_rest_of_compilation.  */
   11723     37713983 :   set_cfun (NULL);
   11724     37713983 :   invoke_plugin_callbacks (PLUGIN_FINISH_PARSE_FUNCTION, current_function_decl);
   11725     37713983 :   current_function_decl = NULL;
   11726              : }
   11727              : 
   11728              : /* Check the declarations given in a for-loop for satisfying the C99
   11729              :    constraints.  If exactly one such decl is found, return it.  LOC is
   11730              :    the location of the opening parenthesis of the for loop.  The last
   11731              :    parameter allows you to control the "for loop initial declarations
   11732              :    are only allowed in C99 mode".  Normally, you should pass
   11733              :    flag_isoc99 as that parameter.  But in some cases (Objective-C
   11734              :    foreach loop, for example) we want to run the checks in this
   11735              :    function even if not in C99 mode, so we allow the caller to turn
   11736              :    off the error about not being in C99 mode.
   11737              : */
   11738              : 
   11739              : tree
   11740        30962 : check_for_loop_decls (location_t loc, bool turn_off_iso_c99_error)
   11741              : {
   11742        30962 :   struct c_binding *b;
   11743        30962 :   tree one_decl = NULL_TREE;
   11744        30962 :   int n_decls = 0;
   11745              : 
   11746        30962 :   if (!turn_off_iso_c99_error)
   11747              :     {
   11748            1 :       static bool hint = true;
   11749              :       /* If we get here, declarations have been used in a for loop without
   11750              :          the C99 for loop scope.  This doesn't make much sense, so don't
   11751              :          allow it.  */
   11752            1 :       auto_diagnostic_group d;
   11753            1 :       error_at (loc, "%<for%> loop initial declarations "
   11754              :                 "are only allowed in C99 or C11 mode");
   11755            1 :       if (hint)
   11756              :         {
   11757            1 :           inform (loc,
   11758              :                   "use option %<-std=c99%>, %<-std=gnu99%>, %<-std=c11%> or "
   11759              :                   "%<-std=gnu11%> to compile your code");
   11760            1 :           hint = false;
   11761              :         }
   11762            1 :       return NULL_TREE;
   11763            1 :     }
   11764              :   else
   11765        30961 :     pedwarn_c90 (loc, OPT_Wpedantic, "ISO C90 does not support %<for%> loop "
   11766              :                  "initial declarations");
   11767              : 
   11768              :   /* C99 subclause 6.8.5 paragraph 3:
   11769              : 
   11770              :        [#3]  The  declaration  part  of  a for statement shall only
   11771              :        declare identifiers for objects having storage class auto or
   11772              :        register.
   11773              : 
   11774              :      It isn't clear whether, in this sentence, "identifiers" binds to
   11775              :      "shall only declare" or to "objects" - that is, whether all identifiers
   11776              :      declared must be identifiers for objects, or whether the restriction
   11777              :      only applies to those that are.  (A question on this in comp.std.c
   11778              :      in November 2000 received no answer.)  We implement the strictest
   11779              :      interpretation, to avoid creating an extension which later causes
   11780              :      problems.
   11781              : 
   11782              :      This constraint was removed in C23.  */
   11783              : 
   11784        62010 :   for (b = current_scope->bindings; b; b = b->prev)
   11785              :     {
   11786        31049 :       tree id = b->id;
   11787        31049 :       tree decl = b->decl;
   11788              : 
   11789        31049 :       if (!id)
   11790           27 :         continue;
   11791              : 
   11792        31022 :       switch (TREE_CODE (decl))
   11793              :         {
   11794        30974 :         case VAR_DECL:
   11795        30974 :           {
   11796        30974 :             location_t decl_loc = DECL_SOURCE_LOCATION (decl);
   11797        30974 :             if (TREE_STATIC (decl))
   11798            5 :               pedwarn_c11 (decl_loc, OPT_Wpedantic,
   11799              :                            "declaration of static variable %qD in %<for%> "
   11800              :                            "loop initial declaration", decl);
   11801        30969 :             else if (DECL_EXTERNAL (decl))
   11802            5 :               pedwarn_c11 (decl_loc, OPT_Wpedantic,
   11803              :                            "declaration of %<extern%> variable %qD in %<for%> "
   11804              :                            "loop initial declaration", decl);
   11805              :           }
   11806              :           break;
   11807              : 
   11808            6 :         case RECORD_TYPE:
   11809            6 :           pedwarn_c11 (loc, OPT_Wpedantic,
   11810              :                        "%<struct %E%> declared in %<for%> loop initial "
   11811              :                        "declaration", id);
   11812            6 :           break;
   11813            5 :         case UNION_TYPE:
   11814            5 :           pedwarn_c11 (loc, OPT_Wpedantic,
   11815              :                        "%<union %E%> declared in %<for%> loop initial "
   11816              :                        "declaration",
   11817              :                        id);
   11818            5 :           break;
   11819            5 :         case ENUMERAL_TYPE:
   11820            5 :           pedwarn_c11 (loc, OPT_Wpedantic,
   11821              :                        "%<enum %E%> declared in %<for%> loop "
   11822              :                        "initial declaration", id);
   11823            5 :           break;
   11824           32 :         default:
   11825           32 :           pedwarn_c11 (loc, OPT_Wpedantic, "declaration of non-variable "
   11826              :                        "%qD in %<for%> loop initial declaration", decl);
   11827              :         }
   11828              : 
   11829        31022 :       n_decls++;
   11830        31022 :       one_decl = decl;
   11831              :     }
   11832              : 
   11833        30961 :   return n_decls == 1 ? one_decl : NULL_TREE;
   11834              : }
   11835              : 
   11836              : /* Save and reinitialize the variables
   11837              :    used during compilation of a C function.  */
   11838              : 
   11839              : void
   11840         1654 : c_push_function_context (void)
   11841              : {
   11842         1654 :   struct language_function *p = cfun->language;
   11843              :   /* cfun->language might have been already allocated by the use of
   11844              :      -Wunused-local-typedefs.  In that case, just re-use it.  */
   11845         1654 :   if (p == NULL)
   11846         1598 :     cfun->language = p = ggc_cleared_alloc<language_function> ();
   11847              : 
   11848         1654 :   p->base.x_stmt_tree = c_stmt_tree;
   11849         1654 :   c_stmt_tree.x_cur_stmt_list = vec_safe_copy (c_stmt_tree.x_cur_stmt_list);
   11850         1654 :   p->x_in_statement = in_statement;
   11851         1654 :   p->x_switch_stack = c_switch_stack;
   11852         1654 :   p->loop_names = loop_names;
   11853         1654 :   loop_names = vNULL;
   11854         1654 :   p->loop_names_hash = loop_names_hash;
   11855         1654 :   loop_names_hash = NULL;
   11856         1654 :   p->arg_info = current_function_arg_info;
   11857         1654 :   p->returns_value = current_function_returns_value;
   11858         1654 :   p->returns_null = current_function_returns_null;
   11859         1654 :   p->returns_abnormally = current_function_returns_abnormally;
   11860         1654 :   p->warn_about_return_type = warn_about_return_type;
   11861              : 
   11862         1654 :   push_function_context ();
   11863         1654 : }
   11864              : 
   11865              : /* Restore the variables used during compilation of a C function.  */
   11866              : 
   11867              : void
   11868         1654 : c_pop_function_context (void)
   11869              : {
   11870         1654 :   struct language_function *p;
   11871              : 
   11872         1654 :   pop_function_context ();
   11873         1654 :   p = cfun->language;
   11874              : 
   11875              :   /* When -Wunused-local-typedefs is in effect, cfun->languages is
   11876              :      used to store data throughout the life time of the current cfun,
   11877              :      So don't deallocate it.  */
   11878         1654 :   if (!warn_unused_local_typedefs)
   11879         1598 :     cfun->language = NULL;
   11880              : 
   11881         1654 :   if (DECL_STRUCT_FUNCTION (current_function_decl) == 0
   11882         1654 :       && DECL_SAVED_TREE (current_function_decl) == NULL_TREE)
   11883              :     {
   11884              :       /* Stop pointing to the local nodes about to be freed.  */
   11885              :       /* But DECL_INITIAL must remain nonzero so we know this
   11886              :          was an actual function definition.  */
   11887            0 :       DECL_INITIAL (current_function_decl) = error_mark_node;
   11888            0 :       DECL_ARGUMENTS (current_function_decl) = NULL_TREE;
   11889              :     }
   11890              : 
   11891         1654 :   c_stmt_tree = p->base.x_stmt_tree;
   11892         1654 :   p->base.x_stmt_tree.x_cur_stmt_list = NULL;
   11893         1654 :   in_statement = p->x_in_statement;
   11894         1654 :   c_switch_stack = p->x_switch_stack;
   11895         1654 :   loop_names.release ();
   11896         1654 :   loop_names = p->loop_names;
   11897         1654 :   p->loop_names = vNULL;
   11898         1654 :   delete loop_names_hash;
   11899         1654 :   loop_names_hash = p->loop_names_hash;
   11900         1654 :   p->loop_names_hash = NULL;
   11901         1654 :   current_function_arg_info = p->arg_info;
   11902         1654 :   current_function_returns_value = p->returns_value;
   11903         1654 :   current_function_returns_null = p->returns_null;
   11904         1654 :   current_function_returns_abnormally = p->returns_abnormally;
   11905         1654 :   warn_about_return_type = p->warn_about_return_type;
   11906         1654 : }
   11907              : 
   11908              : /* The functions below are required for functionality of doing
   11909              :    function at once processing in the C front end. Currently these
   11910              :    functions are not called from anywhere in the C front end, but as
   11911              :    these changes continue, that will change.  */
   11912              : 
   11913              : /* Returns the stmt_tree (if any) to which statements are currently
   11914              :    being added.  If there is no active statement-tree, NULL is
   11915              :    returned.  */
   11916              : 
   11917              : stmt_tree
   11918   1020214614 : current_stmt_tree (void)
   11919              : {
   11920   1020214614 :   return &c_stmt_tree;
   11921              : }
   11922              : 
   11923              : /* Return the global value of T as a symbol.  */
   11924              : 
   11925              : tree
   11926      4097794 : identifier_global_value (tree t)
   11927              : {
   11928      4097794 :   struct c_binding *b;
   11929              : 
   11930      4098761 :   for (b = I_SYMBOL_BINDING (t); b; b = b->shadowed)
   11931      4091506 :     if (B_IN_FILE_SCOPE (b) || B_IN_EXTERNAL_SCOPE (b))
   11932      4090539 :       return b->decl;
   11933              : 
   11934              :   return NULL_TREE;
   11935              : }
   11936              : 
   11937              : /* Return the global value of tag T as a symbol.  */
   11938              : 
   11939              : tree
   11940           12 : identifier_global_tag (tree t)
   11941              : {
   11942           12 :   struct c_binding *b;
   11943              : 
   11944           12 :   for (b = I_TAG_BINDING (t); b; b = b->shadowed)
   11945           11 :     if (B_IN_FILE_SCOPE (b) || B_IN_EXTERNAL_SCOPE (b))
   11946           11 :       return b->decl;
   11947              : 
   11948              :   return NULL_TREE;
   11949              : }
   11950              : 
   11951              : /* Returns non-zero (result of __has_builtin) if NAME refers to a built-in
   11952              :    function or function-like operator.  */
   11953              : 
   11954              : int
   11955        25711 : names_builtin_p (const char *name)
   11956              : {
   11957        25711 :   tree id = get_identifier (name);
   11958        25711 :   if (tree decl = identifier_global_value (id))
   11959        25612 :     return TREE_CODE (decl) == FUNCTION_DECL && DECL_IS_UNDECLARED_BUILTIN (decl);
   11960              : 
   11961              :   /* Also detect common reserved C words that aren't strictly built-in
   11962              :      functions.  */
   11963           99 :   switch (C_RID_CODE (id))
   11964              :     {
   11965              :     case RID_BUILTIN_ASSOC_BARRIER:
   11966              :     case RID_BUILTIN_BITCOMPRESSG:
   11967              :     case RID_BUILTIN_BITEXPANDG:
   11968              :     case RID_BUILTIN_BITREVERSEG:
   11969              :     case RID_BUILTIN_BSWAPG:
   11970              :     case RID_BUILTIN_CLMULG:
   11971              :     case RID_BUILTIN_CONVERTVECTOR:
   11972              :     case RID_BUILTIN_HAS_ATTRIBUTE:
   11973              :     case RID_BUILTIN_SHUFFLE:
   11974              :     case RID_BUILTIN_SHUFFLEVECTOR:
   11975              :     case RID_BUILTIN_STDC:
   11976              :     case RID_BUILTIN_COUNTED_BY_REF:
   11977              :     case RID_CHOOSE_EXPR:
   11978              :     case RID_OFFSETOF:
   11979              :     case RID_TYPES_COMPATIBLE_P:
   11980              :     case RID_C23_VA_START:
   11981              :     case RID_VA_ARG:
   11982              :       return 1;
   11983           66 :     default:
   11984           66 :       break;
   11985              :     }
   11986              : 
   11987           66 :   return 0;
   11988              : }
   11989              : 
   11990              : /* In C, the only C-linkage public declaration is at file scope.  */
   11991              : 
   11992              : tree
   11993            5 : c_linkage_bindings (tree name)
   11994              : {
   11995            5 :   return identifier_global_value (name);
   11996              : }
   11997              : 
   11998              : /* Record a builtin type for C.  If NAME is non-NULL, it is the name used;
   11999              :    otherwise the name is found in ridpointers from RID_INDEX.  */
   12000              : 
   12001              : void
   12002      3481230 : record_builtin_type (enum rid rid_index, const char *name, tree type)
   12003              : {
   12004      3481230 :   tree id, decl;
   12005      3481230 :   if (name == 0)
   12006      1624574 :     id = ridpointers[(int) rid_index];
   12007              :   else
   12008      1856656 :     id = get_identifier (name);
   12009      3481230 :   decl = build_decl (UNKNOWN_LOCATION, TYPE_DECL, id, type);
   12010      3481230 :   pushdecl (decl);
   12011      3481230 :   if (debug_hooks->type_decl)
   12012      3481230 :     debug_hooks->type_decl (decl, false);
   12013      3481230 : }
   12014              : 
   12015              : /* Return a c_parm structure with the given SPECS, ATTRS and DECLARATOR.  */
   12016              : 
   12017              : struct c_parm *
   12018    128550391 : build_c_parm (struct c_declspecs *specs, tree attrs,
   12019              :               struct c_declarator *declarator,
   12020              :               location_t loc)
   12021              : {
   12022    128550391 :   struct c_parm *ret = XOBNEW (&parser_obstack, struct c_parm);
   12023    128550391 :   ret->specs = specs;
   12024    128550391 :   ret->attrs = attrs;
   12025    128550391 :   ret->declarator = declarator;
   12026    128550391 :   ret->loc = loc;
   12027    128550391 :   return ret;
   12028              : }
   12029              : 
   12030              : /* Return a declarator with nested attributes.  TARGET is the inner
   12031              :    declarator to which these attributes apply.  ATTRS are the
   12032              :    attributes.  */
   12033              : 
   12034              : struct c_declarator *
   12035         6884 : build_attrs_declarator (tree attrs, struct c_declarator *target)
   12036              : {
   12037         6884 :   struct c_declarator *ret = XOBNEW (&parser_obstack, struct c_declarator);
   12038         6884 :   ret->kind = cdk_attrs;
   12039         6884 :   ret->declarator = target;
   12040         6884 :   ret->u.attrs = attrs;
   12041         6884 :   return ret;
   12042              : }
   12043              : 
   12044              : /* Return a declarator for a function with arguments specified by ARGS
   12045              :    and return type specified by TARGET.  */
   12046              : 
   12047              : struct c_declarator *
   12048     52661145 : build_function_declarator (struct c_arg_info *args,
   12049              :                            struct c_declarator *target)
   12050              : {
   12051     52661145 :   struct c_declarator *ret = XOBNEW (&parser_obstack, struct c_declarator);
   12052     52661145 :   ret->kind = cdk_function;
   12053     52661145 :   ret->declarator = target;
   12054     52661145 :   ret->u.arg_info = args;
   12055     52661145 :   return ret;
   12056              : }
   12057              : 
   12058              : /* Return a declarator for the identifier IDENT (which may be
   12059              :    NULL_TREE for an abstract declarator).  */
   12060              : 
   12061              : struct c_declarator *
   12062    326016148 : build_id_declarator (tree ident)
   12063              : {
   12064    326016148 :   struct c_declarator *ret = XOBNEW (&parser_obstack, struct c_declarator);
   12065    326016148 :   ret->kind = cdk_id;
   12066    326016148 :   ret->declarator = 0;
   12067    326016148 :   ret->u.id.id = ident;
   12068    326016148 :   ret->u.id.attrs = NULL_TREE;
   12069              :   /* Default value - may get reset to a more precise location. */
   12070    326016148 :   ret->id_loc = input_location;
   12071    326016148 :   return ret;
   12072              : }
   12073              : 
   12074              : /* Return something to represent absolute declarators containing a *.
   12075              :    TARGET is the absolute declarator that the * contains.
   12076              :    TYPE_QUALS_ATTRS is a structure for type qualifiers and attributes
   12077              :    to apply to the pointer type.  */
   12078              : 
   12079              : struct c_declarator *
   12080     18840927 : make_pointer_declarator (struct c_declspecs *type_quals_attrs,
   12081              :                          struct c_declarator *target)
   12082              : {
   12083     18840927 :   tree attrs;
   12084     18840927 :   qualifier_set quals {};
   12085     18840927 :   struct c_declarator *itarget = target;
   12086     18840927 :   struct c_declarator *ret = XOBNEW (&parser_obstack, struct c_declarator);
   12087     18840927 :   if (type_quals_attrs)
   12088              :     {
   12089     18840927 :       attrs = type_quals_attrs->attrs;
   12090     18840927 :       quals = quals_from_declspecs (type_quals_attrs);
   12091     18840927 :       if (attrs != NULL_TREE)
   12092         6572 :         itarget = build_attrs_declarator (attrs, target);
   12093              :     }
   12094     18840927 :   ret->kind = cdk_pointer;
   12095     18840927 :   ret->declarator = itarget;
   12096     18840927 :   ret->u.pointer_quals = quals;
   12097     18840927 :   return ret;
   12098              : }
   12099              : 
   12100              : /* Return a pointer to a structure for an empty list of declaration
   12101              :    specifiers.  */
   12102              : 
   12103              : struct c_declspecs *
   12104    472564983 : build_null_declspecs (void)
   12105              : {
   12106    472564983 :   struct c_declspecs *ret = XOBNEW (&parser_obstack, struct c_declspecs);
   12107    472564983 :   memset (ret, 0, sizeof *ret);
   12108    472564983 :   ret->align_log = -1;
   12109    472564983 :   ret->typespec_word = cts_none;
   12110    472564983 :   ret->storage_class = csc_none;
   12111    472564983 :   ret->expr_const_operands = true;
   12112    472564983 :   ret->typespec_kind = ctsk_none;
   12113    472564983 :   ret->address_space = ADDR_SPACE_GENERIC;
   12114    472564983 :   return ret;
   12115              : }
   12116              : 
   12117              : /* Add the address space ADDRSPACE to the declaration specifiers
   12118              :    SPECS, returning SPECS.  */
   12119              : 
   12120              : struct c_declspecs *
   12121          185 : declspecs_add_addrspace (location_t location,
   12122              :                          struct c_declspecs *specs, addr_space_t as)
   12123              : {
   12124          185 :   specs->non_sc_seen_p = true;
   12125          185 :   specs->declspecs_seen_p = true;
   12126          185 :   specs->non_std_attrs_seen_p = true;
   12127              : 
   12128          185 :   if (!ADDR_SPACE_GENERIC_P (specs->address_space)
   12129            0 :       && specs->address_space != as)
   12130            0 :     error ("incompatible address space qualifiers %qs and %qs",
   12131              :            c_addr_space_name (as),
   12132              :            c_addr_space_name (specs->address_space));
   12133              :   else
   12134              :     {
   12135          185 :       specs->address_space = as;
   12136          185 :       specs->locations[cdw_address_space] = location;
   12137              :     }
   12138          185 :   return specs;
   12139              : }
   12140              : 
   12141              : /* Add the type qualifier QUAL to the declaration specifiers SPECS,
   12142              :    returning SPECS.  */
   12143              : 
   12144              : struct c_declspecs *
   12145     17251537 : declspecs_add_qual (location_t loc,
   12146              :                     struct c_declspecs *specs, tree qual)
   12147              : {
   12148     17251537 :   enum rid i;
   12149     17251537 :   bool dupe = false;
   12150     17251537 :   specs->non_sc_seen_p = true;
   12151     17251537 :   specs->declspecs_seen_p = true;
   12152     17251537 :   specs->non_std_attrs_seen_p = true;
   12153     17251537 :   gcc_assert (TREE_CODE (qual) == IDENTIFIER_NODE
   12154              :               && C_IS_RESERVED_WORD (qual));
   12155     17251537 :   i = C_RID_CODE (qual);
   12156     17251537 :   location_t prev_loc = UNKNOWN_LOCATION;
   12157     17251537 :   switch (i)
   12158              :     {
   12159     13620669 :     case RID_CONST:
   12160     13620669 :       dupe = specs->const_p;
   12161     13620669 :       specs->const_p = true;
   12162     13620669 :       prev_loc = specs->locations[cdw_const];
   12163     13620669 :       specs->locations[cdw_const] = loc;
   12164     13620669 :       break;
   12165       103001 :     case RID_VOLATILE:
   12166       103001 :       dupe = specs->volatile_p;
   12167       103001 :       specs->volatile_p = true;
   12168       103001 :       prev_loc = specs->locations[cdw_volatile];
   12169       103001 :       specs->locations[cdw_volatile] = loc;
   12170       103001 :       break;
   12171      3507352 :     case RID_RESTRICT:
   12172      3507352 :       dupe = specs->restrict_p;
   12173      3507352 :       specs->restrict_p = true;
   12174      3507352 :       prev_loc = specs->locations[cdw_restrict];
   12175      3507352 :       specs->locations[cdw_restrict] = loc;
   12176      3507352 :       break;
   12177        20515 :     case RID_ATOMIC:
   12178        20515 :       dupe = specs->atomic_p;
   12179        20515 :       specs->atomic_p = true;
   12180        20515 :       prev_loc = specs->locations[cdw_atomic];
   12181        20515 :       specs->locations[cdw_atomic] = loc;
   12182        20515 :       break;
   12183            0 :     default:
   12184            0 :       gcc_unreachable ();
   12185              :     }
   12186     17251537 :   if (dupe)
   12187              :     {
   12188           56 :       bool warned = pedwarn_c90 (loc, OPT_Wpedantic,
   12189              :                                  "duplicate %qE declaration specifier", qual);
   12190           56 :       if (!warned
   12191           52 :           && warn_duplicate_decl_specifier
   12192           33 :           && prev_loc >= RESERVED_LOCATION_COUNT
   12193           33 :           && !from_macro_expansion_at (prev_loc)
   12194           77 :           && !from_macro_expansion_at (loc))
   12195           12 :         warning_at (loc, OPT_Wduplicate_decl_specifier,
   12196              :                     "duplicate %qE declaration specifier", qual);
   12197              :     }
   12198     17251537 :   return specs;
   12199              : }
   12200              : 
   12201              : /* Add the type specifier TYPE to the declaration specifiers SPECS,
   12202              :    returning SPECS.  */
   12203              : 
   12204              : struct c_declspecs *
   12205    344254246 : declspecs_add_type (location_t loc, struct c_declspecs *specs,
   12206              :                     struct c_typespec spec)
   12207              : {
   12208    344254246 :   tree type = spec.spec;
   12209    344254246 :   specs->non_sc_seen_p = true;
   12210    344254246 :   specs->declspecs_seen_p = true;
   12211    344254246 :   specs->non_std_attrs_seen_p = true;
   12212    344254246 :   specs->typespec_kind = spec.kind;
   12213    344254246 :   if (TREE_DEPRECATED (type))
   12214           56 :     specs->deprecated_p = true;
   12215    344254246 :   if (TREE_UNAVAILABLE (type))
   12216           40 :     specs->unavailable_p = true;
   12217              : 
   12218              :   /* As a type specifier is present, "auto" must be used as a storage
   12219              :      class specifier, not for type deduction.  */
   12220    344254246 :   if (specs->c23_auto_p)
   12221              :     {
   12222          119 :       specs->c23_auto_p = false;
   12223          119 :       if (specs->storage_class != csc_none)
   12224            1 :         error ("multiple storage classes in declaration specifiers");
   12225          118 :       else if (specs->thread_p)
   12226            1 :         error ("%qs used with %<auto%>",
   12227            1 :                specs->thread_gnu_p ? "__thread" : "_Thread_local");
   12228          117 :       else if (specs->constexpr_p)
   12229              :         /* auto may only be used with another storage class specifier,
   12230              :            such as constexpr, if the type is inferred.  */
   12231            2 :         error ("%<auto%> used with %<constexpr%>");
   12232              :       else
   12233          115 :         specs->storage_class = csc_auto;
   12234              :     }
   12235              : 
   12236              :   /* Handle type specifier keywords.  */
   12237    344254246 :   if (TREE_CODE (type) == IDENTIFIER_NODE
   12238     86002323 :       && C_IS_RESERVED_WORD (type)
   12239    430256569 :       && C_RID_CODE (type) != RID_CXX_COMPAT_WARN)
   12240              :     {
   12241     86002323 :       enum rid i = C_RID_CODE (type);
   12242     86002323 :       if (specs->type)
   12243              :         {
   12244           58 :           error_at (loc, "two or more data types in declaration specifiers");
   12245           58 :           return specs;
   12246              :         }
   12247     86002265 :       if ((int) i <= (int) RID_LAST_MODIFIER)
   12248              :         {
   12249              :           /* "long", "short", "signed", "unsigned", "_Complex" or "_Sat".  */
   12250     22504315 :           bool dupe = false;
   12251     22504315 :           switch (i)
   12252              :             {
   12253     11274379 :             case RID_LONG:
   12254     11274379 :               if (specs->long_long_p)
   12255              :                 {
   12256          104 :                   error_at (loc, "%<long long long%> is too long for GCC");
   12257          104 :                   break;
   12258              :                 }
   12259     11274275 :               if (specs->long_p)
   12260              :                 {
   12261      3045042 :                   if (specs->typespec_word == cts_double)
   12262              :                     {
   12263           15 :                       error_at (loc,
   12264              :                                 "both %qs and %qs in declaration specifiers",
   12265              :                                 "long long", "double");
   12266           15 :                       break;
   12267              :                     }
   12268      3045027 :                   pedwarn_c90 (loc, OPT_Wlong_long,
   12269              :                                "ISO C90 does not support %<long long%>");
   12270      3045027 :                   specs->long_long_p = 1;
   12271      3045027 :                   specs->locations[cdw_long_long] = loc;
   12272      3045027 :                   break;
   12273              :                 }
   12274      8229233 :               if (specs->short_p)
   12275           77 :                 error_at (loc,
   12276              :                           "both %qs and %qs in declaration specifiers",
   12277              :                           "long", "short");
   12278      8229156 :               else if (specs->typespec_word == cts_auto_type)
   12279            1 :                 error_at (loc,
   12280              :                           "both %qs and %qs in declaration specifiers",
   12281              :                           "long", "__auto_type");
   12282              :               else if (specs->typespec_word == cts_void)
   12283            5 :                 error_at (loc,
   12284              :                           "both %qs and %qs in declaration specifiers",
   12285              :                           "long", "void");
   12286              :               else if (specs->typespec_word == cts_int_n)
   12287           19 :                 error_at (loc,
   12288              :                           "both %qs and %<__int%d%> in declaration specifiers",
   12289           19 :                           "long", int_n_data[specs->u.int_n_idx].bitsize);
   12290              :               else if (specs->typespec_word == cts_bool)
   12291            3 :                 error_at (loc,
   12292              :                           "both %qs and %qs in declaration specifiers",
   12293              :                           "long", "_Bool");
   12294              :               else if (specs->typespec_word == cts_bitint)
   12295            3 :                 error_at (loc,
   12296              :                           "both %qs and %qs in declaration specifiers",
   12297              :                           "long", "_BitInt");
   12298              :               else if (specs->typespec_word == cts_char)
   12299           21 :                 error_at (loc,
   12300              :                           "both %qs and %qs in declaration specifiers",
   12301              :                           "long", "char");
   12302              :               else if (specs->typespec_word == cts_float)
   12303            7 :                 error_at (loc,
   12304              :                           "both %qs and %qs in declaration specifiers",
   12305              :                           "long", "float");
   12306              :               else if (specs->typespec_word == cts_floatn_nx)
   12307            0 :                 error_at (loc,
   12308              :                           "both %qs and %<_Float%d%s%> in declaration "
   12309              :                           "specifiers", "long",
   12310            0 :                           floatn_nx_types[specs->u.floatn_nx_idx].n,
   12311            0 :                           floatn_nx_types[specs->u.floatn_nx_idx].extended
   12312              :                           ? "x"
   12313              :                           : "");
   12314              :               else if (specs->typespec_word == cts_dfloat32)
   12315            4 :                 error_at (loc,
   12316              :                           "both %qs and %qs in declaration specifiers",
   12317              :                           "long", "_Decimal32");
   12318              :               else if (specs->typespec_word == cts_dfloat64)
   12319            4 :                 error_at (loc,
   12320              :                           "both %qs and %qs in declaration specifiers",
   12321              :                           "long", "_Decimal64");
   12322              :               else if (specs->typespec_word == cts_dfloat128)
   12323            4 :                 error_at (loc,
   12324              :                           "both %qs and %qs in declaration specifiers",
   12325              :                           "long", "_Decimal128");
   12326              :               else if (specs->typespec_word == cts_dfloat64x)
   12327            0 :                 error_at (loc,
   12328              :                           "both %qs and %qs in declaration specifiers",
   12329              :                           "long", "_Decimal64x");
   12330              :               else
   12331              :                 {
   12332      8229085 :                   specs->long_p = true;
   12333      8229085 :                   specs->locations[cdw_long] = loc;
   12334              :                 }
   12335              :               break;
   12336      1725853 :             case RID_SHORT:
   12337      1725853 :               dupe = specs->short_p;
   12338      1725853 :               if (specs->long_p)
   12339          197 :                 error_at (loc,
   12340              :                           "both %qs and %qs in declaration specifiers",
   12341              :                           "long", "short");
   12342      1725656 :               else if (specs->typespec_word == cts_auto_type)
   12343            1 :                 error_at (loc,
   12344              :                           "both %qs and %qs in declaration specifiers",
   12345              :                           "short", "__auto_type");
   12346              :               else if (specs->typespec_word == cts_void)
   12347            5 :                 error_at (loc,
   12348              :                           "both %qs and %qs in declaration specifiers",
   12349              :                           "short", "void");
   12350              :               else if (specs->typespec_word == cts_int_n)
   12351           19 :                 error_at (loc,
   12352              :                           "both %qs and %<__int%d%> in declaration specifiers",
   12353           19 :                           "short", int_n_data[specs->u.int_n_idx].bitsize);
   12354              :               else if (specs->typespec_word == cts_bool)
   12355            3 :                 error_at (loc,
   12356              :                           "both %qs and %qs in declaration specifiers",
   12357              :                           "short", "_Bool");
   12358              :               else if (specs->typespec_word == cts_bitint)
   12359            1 :                 error_at (loc,
   12360              :                           "both %qs and %qs in declaration specifiers",
   12361              :                           "short", "_BitInt");
   12362              :               else if (specs->typespec_word == cts_char)
   12363           21 :                 error_at (loc,
   12364              :                           "both %qs and %qs in declaration specifiers",
   12365              :                           "short", "char");
   12366              :               else if (specs->typespec_word == cts_float)
   12367            7 :                 error_at (loc,
   12368              :                           "both %qs and %qs in declaration specifiers",
   12369              :                           "short", "float");
   12370              :               else if (specs->typespec_word == cts_double)
   12371            7 :                 error_at (loc,
   12372              :                           "both %qs and %qs in declaration specifiers",
   12373              :                           "short", "double");
   12374              :               else if (specs->typespec_word == cts_floatn_nx)
   12375            0 :                 error_at (loc,
   12376              :                           "both %qs and %<_Float%d%s%> in declaration "
   12377              :                           "specifiers", "short",
   12378            0 :                           floatn_nx_types[specs->u.floatn_nx_idx].n,
   12379            0 :                           floatn_nx_types[specs->u.floatn_nx_idx].extended
   12380              :                           ? "x"
   12381              :                           : "");
   12382              :               else if (specs->typespec_word == cts_dfloat32)
   12383            4 :                 error_at (loc,
   12384              :                           "both %qs and %qs in declaration specifiers",
   12385              :                           "short", "_Decimal32");
   12386              :               else if (specs->typespec_word == cts_dfloat64)
   12387            4 :                 error_at (loc,
   12388              :                           "both %qs and %qs in declaration specifiers",
   12389              :                           "short", "_Decimal64");
   12390              :               else if (specs->typespec_word == cts_dfloat128)
   12391            4 :                 error_at (loc,
   12392              :                           "both %qs and %qs in declaration specifiers",
   12393              :                           "short", "_Decimal128");
   12394              :               else if (specs->typespec_word == cts_dfloat64x)
   12395            0 :                 error_at (loc,
   12396              :                           "both %qs and %qs in declaration specifiers",
   12397              :                           "short", "_Decimal64x");
   12398              :               else
   12399              :                 {
   12400      1725580 :                   specs->short_p = true;
   12401      1725580 :                   specs->locations[cdw_short] = loc;
   12402              :                 }
   12403              :               break;
   12404       557329 :             case RID_SIGNED:
   12405       557329 :               dupe = specs->signed_p;
   12406       557329 :               if (specs->unsigned_p)
   12407          138 :                 error_at (loc,
   12408              :                           "both %qs and %qs in declaration specifiers",
   12409              :                           "signed", "unsigned");
   12410       557191 :               else if (specs->typespec_word == cts_auto_type)
   12411            1 :                 error_at (loc,
   12412              :                           "both %qs and %qs in declaration specifiers",
   12413              :                           "signed", "__auto_type");
   12414              :               else if (specs->typespec_word == cts_void)
   12415            5 :                 error_at (loc,
   12416              :                           "both %qs and %qs in declaration specifiers",
   12417              :                           "signed", "void");
   12418              :               else if (specs->typespec_word == cts_bool)
   12419            3 :                 error_at (loc,
   12420              :                           "both %qs and %qs in declaration specifiers",
   12421              :                           "signed", "_Bool");
   12422              :               else if (specs->typespec_word == cts_float)
   12423            7 :                 error_at (loc,
   12424              :                           "both %qs and %qs in declaration specifiers",
   12425              :                           "signed", "float");
   12426              :               else if (specs->typespec_word == cts_double)
   12427           21 :                 error_at (loc,
   12428              :                           "both %qs and %qs in declaration specifiers",
   12429              :                           "signed", "double");
   12430              :               else if (specs->typespec_word == cts_floatn_nx)
   12431            0 :                 error_at (loc,
   12432              :                           "both %qs and %<_Float%d%s%> in declaration "
   12433              :                           "specifiers", "signed",
   12434            0 :                           floatn_nx_types[specs->u.floatn_nx_idx].n,
   12435            0 :                           floatn_nx_types[specs->u.floatn_nx_idx].extended
   12436              :                           ? "x"
   12437              :                           : "");
   12438              :               else if (specs->typespec_word == cts_dfloat32)
   12439            4 :                 error_at (loc,
   12440              :                           "both %qs and %qs in declaration specifiers",
   12441              :                           "signed", "_Decimal32");
   12442              :               else if (specs->typespec_word == cts_dfloat64)
   12443            4 :                 error_at (loc,
   12444              :                           "both %qs and %qs in declaration specifiers",
   12445              :                           "signed", "_Decimal64");
   12446              :               else if (specs->typespec_word == cts_dfloat128)
   12447            4 :                 error_at (loc,
   12448              :                           "both %qs and %qs in declaration specifiers",
   12449              :                           "signed", "_Decimal128");
   12450              :               else if (specs->typespec_word == cts_dfloat64x)
   12451            0 :                 error_at (loc,
   12452              :                           "both %qs and %qs in declaration specifiers",
   12453              :                           "signed", "_Decimal64x");
   12454              :               else
   12455              :                 {
   12456       557142 :                   specs->signed_p = true;
   12457       557142 :                   specs->locations[cdw_signed] = loc;
   12458              :                 }
   12459              :               break;
   12460      6365008 :             case RID_UNSIGNED:
   12461      6365008 :               dupe = specs->unsigned_p;
   12462      6365008 :               if (specs->signed_p)
   12463          139 :                 error_at (loc,
   12464              :                           "both %qs and %qs in declaration specifiers",
   12465              :                           "signed", "unsigned");
   12466      6364869 :               else if (specs->typespec_word == cts_auto_type)
   12467            1 :                 error_at (loc,
   12468              :                           "both %qs and %qs in declaration specifiers",
   12469              :                           "unsigned", "__auto_type");
   12470              :               else if (specs->typespec_word == cts_void)
   12471            5 :                 error_at (loc,
   12472              :                           "both %qs and %qs in declaration specifiers",
   12473              :                           "unsigned", "void");
   12474              :               else if (specs->typespec_word == cts_bool)
   12475            3 :                 error_at (loc,
   12476              :                           "both %qs and %qs in declaration specifiers",
   12477              :                           "unsigned", "_Bool");
   12478              :               else if (specs->typespec_word == cts_float)
   12479            7 :                 error_at (loc,
   12480              :                           "both %qs and %qs in declaration specifiers",
   12481              :                           "unsigned", "float");
   12482              :               else if (specs->typespec_word == cts_double)
   12483           21 :                 error_at (loc,
   12484              :                           "both %qs and %qs in declaration specifiers",
   12485              :                           "unsigned", "double");
   12486              :               else if (specs->typespec_word == cts_floatn_nx)
   12487            0 :                 error_at (loc,
   12488              :                           "both %qs and %<_Float%d%s%> in declaration "
   12489              :                           "specifiers", "unsigned",
   12490            0 :                           floatn_nx_types[specs->u.floatn_nx_idx].n,
   12491            0 :                           floatn_nx_types[specs->u.floatn_nx_idx].extended
   12492              :                           ? "x"
   12493              :                           : "");
   12494              :               else if (specs->typespec_word == cts_dfloat32)
   12495            2 :                 error_at (loc,
   12496              :                           "both %qs and %qs in declaration specifiers",
   12497              :                           "unsigned", "_Decimal32");
   12498              :               else if (specs->typespec_word == cts_dfloat64)
   12499            2 :                 error_at (loc,
   12500              :                           "both %qs and %qs in declaration specifiers",
   12501              :                           "unsigned", "_Decimal64");
   12502              :               else if (specs->typespec_word == cts_dfloat128)
   12503            2 :                 error_at (loc,
   12504              :                           "both %qs and %qs in declaration specifiers",
   12505              :                           "unsigned", "_Decimal128");
   12506              :               else if (specs->typespec_word == cts_dfloat64x)
   12507            0 :                 error_at (loc,
   12508              :                           "both %qs and %qs in declaration specifiers",
   12509              :                           "unsigned", "_Decimal64x");
   12510              :               else
   12511              :                 {
   12512      6364826 :                   specs->unsigned_p = true;
   12513      6364826 :                   specs->locations[cdw_unsigned] = loc;
   12514              :                 }
   12515              :               break;
   12516      2581673 :             case RID_COMPLEX:
   12517      2581673 :               dupe = specs->complex_p;
   12518      2581673 :               if (!in_system_header_at (loc))
   12519        69937 :                 pedwarn_c90 (loc, OPT_Wpedantic,
   12520              :                              "ISO C90 does not support complex types");
   12521      2581673 :               if (specs->typespec_word == cts_auto_type)
   12522            1 :                 error_at (loc,
   12523              :                           "both %qs and %qs in declaration specifiers",
   12524              :                           "complex", "__auto_type");
   12525              :               else if (specs->typespec_word == cts_void)
   12526            2 :                 error_at (loc,
   12527              :                           "both %qs and %qs in declaration specifiers",
   12528              :                           "complex", "void");
   12529              :               else if (specs->typespec_word == cts_bool)
   12530            2 :                 error_at (loc,
   12531              :                           "both %qs and %qs in declaration specifiers",
   12532              :                           "complex", "_Bool");
   12533              :               else if (specs->typespec_word == cts_bitint)
   12534            1 :                 error_at (loc,
   12535              :                           "both %qs and %qs in declaration specifiers",
   12536              :                           "complex", "_BitInt");
   12537              :               else if (specs->typespec_word == cts_dfloat32)
   12538            1 :                 error_at (loc,
   12539              :                           "both %qs and %qs in declaration specifiers",
   12540              :                           "complex", "_Decimal32");
   12541              :               else if (specs->typespec_word == cts_dfloat64)
   12542            1 :                 error_at (loc,
   12543              :                           "both %qs and %qs in declaration specifiers",
   12544              :                           "complex", "_Decimal64");
   12545              :               else if (specs->typespec_word == cts_dfloat128)
   12546            1 :                 error_at (loc,
   12547              :                           "both %qs and %qs in declaration specifiers",
   12548              :                           "complex", "_Decimal128");
   12549              :               else if (specs->typespec_word == cts_dfloat64x)
   12550            0 :                 error_at (loc,
   12551              :                           "both %qs and %qs in declaration specifiers",
   12552              :                           "complex", "_Decimal64x");
   12553              :               else if (specs->typespec_word == cts_fract)
   12554            0 :                 error_at (loc,
   12555              :                           "both %qs and %qs in declaration specifiers",
   12556              :                           "complex", "_Fract");
   12557              :               else if (specs->typespec_word == cts_accum)
   12558            0 :                 error_at (loc,
   12559              :                           "both %qs and %qs in declaration specifiers",
   12560              :                           "complex", "_Accum");
   12561      2581664 :               else if (specs->saturating_p)
   12562            0 :                 error_at (loc,
   12563              :                           "both %qs and %qs in declaration specifiers",
   12564              :                           "complex", "_Sat");
   12565              :               else
   12566              :                 {
   12567      2581664 :                   specs->complex_p = true;
   12568      2581664 :                   specs->locations[cdw_complex] = loc;
   12569              :                 }
   12570              :               break;
   12571           73 :             case RID_SAT:
   12572           73 :               dupe = specs->saturating_p;
   12573           73 :               pedwarn (loc, OPT_Wpedantic,
   12574              :                        "ISO C does not support saturating types");
   12575           73 :               if (specs->typespec_word == cts_int_n)
   12576            0 :                 error_at (loc,
   12577              :                           "both %qs and %<__int%d%> in declaration specifiers",
   12578            0 :                           "_Sat", int_n_data[specs->u.int_n_idx].bitsize);
   12579              :               else if (specs->typespec_word == cts_auto_type)
   12580            0 :                 error_at (loc,
   12581              :                           "both %qs and %qs in declaration specifiers",
   12582              :                           "_Sat", "__auto_type");
   12583              :               else if (specs->typespec_word == cts_void)
   12584            0 :                 error_at (loc,
   12585              :                           "both %qs and %qs in declaration specifiers",
   12586              :                           "_Sat", "void");
   12587              :               else if (specs->typespec_word == cts_bool)
   12588            0 :                 error_at (loc,
   12589              :                           "both %qs and %qs in declaration specifiers",
   12590              :                           "_Sat", "_Bool");
   12591              :               else if (specs->typespec_word == cts_bitint)
   12592            0 :                 error_at (loc,
   12593              :                           "both %qs and %qs in declaration specifiers",
   12594              :                           "_Sat", "_BitInt");
   12595              :               else if (specs->typespec_word == cts_char)
   12596            0 :                 error_at (loc,
   12597              :                           "both %qs and %qs in declaration specifiers",
   12598              :                           "_Sat", "char");
   12599              :               else if (specs->typespec_word == cts_int)
   12600            0 :                 error_at (loc,
   12601              :                           "both %qs and %qs in declaration specifiers",
   12602              :                           "_Sat", "int");
   12603              :               else if (specs->typespec_word == cts_float)
   12604            0 :                 error_at (loc,
   12605              :                           "both %qs and %qs in declaration specifiers",
   12606              :                           "_Sat", "float");
   12607              :               else if (specs->typespec_word == cts_double)
   12608            0 :                 error_at (loc,
   12609              :                           "both %qs and %qs in declaration specifiers",
   12610              :                           "_Sat", "double");
   12611              :               else if (specs->typespec_word == cts_floatn_nx)
   12612            0 :                 error_at (loc,
   12613              :                           "both %qs and %<_Float%d%s%> in declaration "
   12614              :                           "specifiers", "_Sat",
   12615            0 :                           floatn_nx_types[specs->u.floatn_nx_idx].n,
   12616            0 :                           floatn_nx_types[specs->u.floatn_nx_idx].extended
   12617              :                           ? "x"
   12618              :                           : "");
   12619              :               else if (specs->typespec_word == cts_dfloat32)
   12620            0 :                 error_at (loc,
   12621              :                           "both %qs and %qs in declaration specifiers",
   12622              :                           "_Sat", "_Decimal32");
   12623              :               else if (specs->typespec_word == cts_dfloat64)
   12624            0 :                 error_at (loc,
   12625              :                           "both %qs and %qs in declaration specifiers",
   12626              :                           "_Sat", "_Decimal64");
   12627              :               else if (specs->typespec_word == cts_dfloat128)
   12628            0 :                 error_at (loc,
   12629              :                           "both %qs and %qs in declaration specifiers",
   12630              :                           "_Sat", "_Decimal128");
   12631              :               else if (specs->typespec_word == cts_dfloat64x)
   12632            0 :                 error_at (loc,
   12633              :                           "both %qs and %qs in declaration specifiers",
   12634              :                           "_Sat", "_Decimal64x");
   12635           73 :               else if (specs->complex_p)
   12636            0 :                 error_at (loc,
   12637              :                           "both %qs and %qs in declaration specifiers",
   12638              :                           "_Sat", "complex");
   12639              :               else
   12640              :                 {
   12641           73 :                   specs->saturating_p = true;
   12642           73 :                   specs->locations[cdw_saturating] = loc;
   12643              :                 }
   12644              :               break;
   12645            0 :             default:
   12646            0 :               gcc_unreachable ();
   12647              :             }
   12648              : 
   12649     22504315 :           if (dupe)
   12650          378 :             error_at (loc, "duplicate %qE", type);
   12651              : 
   12652              :           return specs;
   12653              :         }
   12654              :       else
   12655              :         {
   12656              :           /* "void", "_Bool", "char", "int", "float", "double",
   12657              :              "_FloatN", "_FloatNx", "_Decimal32", "__intN",
   12658              :              "_Decimal64", "_Decimal128", "_Fract", "_Accum", "_BitInt(N)" or
   12659              :              "__auto_type".  */
   12660     63497950 :           if (specs->typespec_word != cts_none)
   12661              :             {
   12662         2171 :               if (i == RID_BOOL)
   12663              :                 {
   12664          175 :                   auto_diagnostic_group d;
   12665          175 :                   if (specs->storage_class == csc_typedef)
   12666            4 :                     error_at (loc,
   12667              :                               "%qs cannot be defined via %<typedef%>",
   12668            2 :                               IDENTIFIER_POINTER (type));
   12669              :                   else
   12670          346 :                     error_at (loc,
   12671              :                               "%qs cannot be used here",
   12672          173 :                               IDENTIFIER_POINTER (type));
   12673          175 :                   add_note_about_new_keyword (loc, type);
   12674          175 :                 }
   12675              :               else
   12676         1996 :                 error_at (loc,
   12677              :                           "two or more data types in declaration specifiers");
   12678              :               return specs;
   12679              :             }
   12680     63495779 :           switch (i)
   12681              :             {
   12682         1897 :             case RID_AUTO_TYPE:
   12683         1897 :               if (specs->long_p)
   12684            1 :                 error_at (loc,
   12685              :                           "both %qs and %qs in declaration specifiers",
   12686              :                           "long", "__auto_type");
   12687         1896 :               else if (specs->short_p)
   12688            1 :                 error_at (loc,
   12689              :                           "both %qs and %qs in declaration specifiers",
   12690              :                           "short", "__auto_type");
   12691         1895 :               else if (specs->signed_p)
   12692            1 :                 error_at (loc,
   12693              :                           "both %qs and %qs in declaration specifiers",
   12694              :                           "signed", "__auto_type");
   12695         1894 :               else if (specs->unsigned_p)
   12696            1 :                 error_at (loc,
   12697              :                           "both %qs and %qs in declaration specifiers",
   12698              :                           "unsigned", "__auto_type");
   12699         1893 :               else if (specs->complex_p)
   12700            1 :                 error_at (loc,
   12701              :                           "both %qs and %qs in declaration specifiers",
   12702              :                           "complex", "__auto_type");
   12703         1892 :               else if (specs->saturating_p)
   12704            0 :                 error_at (loc,
   12705              :                           "both %qs and %qs in declaration specifiers",
   12706              :                           "_Sat", "__auto_type");
   12707              :               else
   12708              :                 {
   12709         1892 :                   specs->typespec_word = cts_auto_type;
   12710         1892 :                   specs->locations[cdw_typespec] = loc;
   12711              :                 }
   12712              :               return specs;
   12713        52894 :             case RID_INT_N_0:
   12714        52894 :             case RID_INT_N_1:
   12715        52894 :             case RID_INT_N_2:
   12716        52894 :             case RID_INT_N_3:
   12717        52894 :               specs->u.int_n_idx = i - RID_INT_N_0;
   12718        52894 :               if (!in_system_header_at (input_location)
   12719              :                   /* If the INT_N type ends in "__", and so is of the format
   12720              :                      "__intN__", don't pedwarn.  */
   12721        52894 :                   && (strncmp (IDENTIFIER_POINTER (type)
   12722        42126 :                                + (IDENTIFIER_LENGTH (type) - 2), "__", 2) != 0))
   12723        42126 :                 pedwarn (loc, OPT_Wpedantic,
   12724              :                          "ISO C does not support %<__int%d%> types",
   12725        42126 :                          int_n_data[specs->u.int_n_idx].bitsize);
   12726              : 
   12727        52894 :               if (specs->long_p)
   12728           53 :                 error_at (loc,
   12729              :                           "both %<__int%d%> and %qs in declaration specifiers",
   12730           53 :                           int_n_data[specs->u.int_n_idx].bitsize, "long");
   12731        52841 :               else if (specs->saturating_p)
   12732            0 :                 error_at (loc,
   12733              :                           "both %qs and %<__int%d%> in declaration specifiers",
   12734            0 :                           "_Sat", int_n_data[specs->u.int_n_idx].bitsize);
   12735        52841 :               else if (specs->short_p)
   12736           19 :                 error_at (loc,
   12737              :                           "both %<__int%d%> and %qs in declaration specifiers",
   12738           19 :                           int_n_data[specs->u.int_n_idx].bitsize, "short");
   12739        52822 :               else if (! int_n_enabled_p[specs->u.int_n_idx])
   12740              :                 {
   12741            0 :                   specs->typespec_word = cts_int_n;
   12742            0 :                   error_at (loc,
   12743              :                             "%<__int%d%> is not supported on this target",
   12744            0 :                             int_n_data[specs->u.int_n_idx].bitsize);
   12745              :                 }
   12746              :               else
   12747              :                 {
   12748        52822 :                   specs->typespec_word = cts_int_n;
   12749        52822 :                   specs->locations[cdw_typespec] = loc;
   12750              :                 }
   12751              :               return specs;
   12752      8286044 :             case RID_VOID:
   12753      8286044 :               if (specs->long_p)
   12754           44 :                 error_at (loc,
   12755              :                           "both %qs and %qs in declaration specifiers",
   12756              :                           "long", "void");
   12757      8286000 :               else if (specs->short_p)
   12758           21 :                 error_at (loc,
   12759              :                           "both %qs and %qs in declaration specifiers",
   12760              :                           "short", "void");
   12761      8285979 :               else if (specs->signed_p)
   12762            5 :                 error_at (loc,
   12763              :                           "both %qs and %qs in declaration specifiers",
   12764              :                           "signed", "void");
   12765      8285974 :               else if (specs->unsigned_p)
   12766            5 :                 error_at (loc,
   12767              :                           "both %qs and %qs in declaration specifiers",
   12768              :                           "unsigned", "void");
   12769      8285969 :               else if (specs->complex_p)
   12770            2 :                 error_at (loc,
   12771              :                           "both %qs and %qs in declaration specifiers",
   12772              :                           "complex", "void");
   12773      8285967 :               else if (specs->saturating_p)
   12774            0 :                 error_at (loc,
   12775              :                           "both %qs and %qs in declaration specifiers",
   12776              :                           "_Sat", "void");
   12777              :               else
   12778              :                 {
   12779      8285967 :                   specs->typespec_word = cts_void;
   12780      8285967 :                   specs->locations[cdw_typespec] = loc;
   12781              :                 }
   12782              :               return specs;
   12783        95561 :             case RID_BOOL:
   12784        95561 :               if (!in_system_header_at (loc))
   12785        77282 :                 pedwarn_c90 (loc, OPT_Wpedantic,
   12786              :                              "ISO C90 does not support boolean types");
   12787        95561 :               if (specs->long_p)
   12788           27 :                 error_at (loc,
   12789              :                           "both %qs and %qs in declaration specifiers",
   12790              :                           "long", "_Bool");
   12791        95534 :               else if (specs->short_p)
   12792           11 :                 error_at (loc,
   12793              :                           "both %qs and %qs in declaration specifiers",
   12794              :                           "short", "_Bool");
   12795        95523 :               else if (specs->signed_p)
   12796            3 :                 error_at (loc,
   12797              :                           "both %qs and %qs in declaration specifiers",
   12798              :                           "signed", "_Bool");
   12799        95520 :               else if (specs->unsigned_p)
   12800            3 :                 error_at (loc,
   12801              :                           "both %qs and %qs in declaration specifiers",
   12802              :                           "unsigned", "_Bool");
   12803        95517 :               else if (specs->complex_p)
   12804            2 :                 error_at (loc,
   12805              :                           "both %qs and %qs in declaration specifiers",
   12806              :                           "complex", "_Bool");
   12807        95515 :               else if (specs->saturating_p)
   12808            0 :                 error_at (loc,
   12809              :                           "both %qs and %qs in declaration specifiers",
   12810              :                           "_Sat", "_Bool");
   12811              :               else
   12812              :                 {
   12813        95515 :                   specs->typespec_word = cts_bool;
   12814        95515 :                   specs->locations[cdw_typespec] = loc;
   12815              :                 }
   12816              :               return specs;
   12817      9319782 :             case RID_CHAR:
   12818      9319782 :               if (specs->long_p)
   12819           44 :                 error_at (loc,
   12820              :                           "both %qs and %qs in declaration specifiers",
   12821              :                           "long", "char");
   12822      9319738 :               else if (specs->short_p)
   12823           21 :                 error_at (loc,
   12824              :                           "both %qs and %qs in declaration specifiers",
   12825              :                           "short", "char");
   12826      9319717 :               else if (specs->saturating_p)
   12827            0 :                 error_at (loc,
   12828              :                           "both %qs and %qs in declaration specifiers",
   12829              :                           "_Sat", "char");
   12830              :               else
   12831              :                 {
   12832      9319717 :                   specs->typespec_word = cts_char;
   12833      9319717 :                   specs->locations[cdw_typespec] = loc;
   12834              :                 }
   12835              :               return specs;
   12836     24722933 :             case RID_INT:
   12837     24722933 :               if (specs->saturating_p)
   12838            0 :                 error_at (loc,
   12839              :                           "both %qs and %qs in declaration specifiers",
   12840              :                           "_Sat", "int");
   12841              :               else
   12842              :                 {
   12843     24722933 :                   specs->typespec_word = cts_int;
   12844     24722933 :                   specs->locations[cdw_typespec] = loc;
   12845              :                 }
   12846              :               return specs;
   12847      3676632 :             case RID_FLOAT:
   12848      3676632 :               if (specs->long_p)
   12849           44 :                 error_at (loc,
   12850              :                           "both %qs and %qs in declaration specifiers",
   12851              :                           "long", "float");
   12852      3676588 :               else if (specs->short_p)
   12853           21 :                 error_at (loc,
   12854              :                           "both %qs and %qs in declaration specifiers",
   12855              :                           "short", "float");
   12856      3676567 :               else if (specs->signed_p)
   12857            5 :                 error_at (loc,
   12858              :                           "both %qs and %qs in declaration specifiers",
   12859              :                           "signed", "float");
   12860      3676562 :               else if (specs->unsigned_p)
   12861            5 :                 error_at (loc,
   12862              :                           "both %qs and %qs in declaration specifiers",
   12863              :                           "unsigned", "float");
   12864      3676557 :               else if (specs->saturating_p)
   12865            0 :                 error_at (loc,
   12866              :                           "both %qs and %qs in declaration specifiers",
   12867              :                           "_Sat", "float");
   12868              :               else
   12869              :                 {
   12870      3676557 :                   specs->typespec_word = cts_float;
   12871      3676557 :                   specs->locations[cdw_typespec] = loc;
   12872              :                 }
   12873              :               return specs;
   12874      6690474 :             case RID_DOUBLE:
   12875      6690474 :               if (specs->long_long_p)
   12876           22 :                 error_at (loc,
   12877              :                           "both %qs and %qs in declaration specifiers",
   12878              :                           "long long", "double");
   12879      6690452 :               else if (specs->short_p)
   12880           21 :                 error_at (loc,
   12881              :                           "both %qs and %qs in declaration specifiers",
   12882              :                           "short", "double");
   12883      6690431 :               else if (specs->signed_p)
   12884           13 :                 error_at (loc,
   12885              :                           "both %qs and %qs in declaration specifiers",
   12886              :                           "signed", "double");
   12887      6690418 :               else if (specs->unsigned_p)
   12888           13 :                 error_at (loc,
   12889              :                           "both %qs and %qs in declaration specifiers",
   12890              :                           "unsigned", "double");
   12891      6690405 :               else if (specs->saturating_p)
   12892            0 :                 error_at (loc,
   12893              :                           "both %qs and %qs in declaration specifiers",
   12894              :                           "_Sat", "double");
   12895              :               else
   12896              :                 {
   12897      6690405 :                   specs->typespec_word = cts_double;
   12898      6690405 :                   specs->locations[cdw_typespec] = loc;
   12899              :                 }
   12900              :               return specs;
   12901     10553277 :             CASE_RID_FLOATN_NX:
   12902     10553277 :               specs->u.floatn_nx_idx = i - RID_FLOATN_NX_FIRST;
   12903     10553277 :               if (!in_system_header_at (input_location))
   12904        54110 :                 pedwarn_c11 (loc, OPT_Wpedantic,
   12905              :                              "ISO C does not support the %<_Float%d%s%> type"
   12906              :                              " before C23",
   12907        54110 :                              floatn_nx_types[specs->u.floatn_nx_idx].n,
   12908        54110 :                              floatn_nx_types[specs->u.floatn_nx_idx].extended
   12909              :                              ? "x"
   12910              :                              : "");
   12911              : 
   12912     10553277 :               if (specs->long_p)
   12913            0 :                 error_at (loc,
   12914              :                           "both %qs and %<_Float%d%s%> in declaration "
   12915              :                           "specifiers", "long",
   12916            0 :                           floatn_nx_types[specs->u.floatn_nx_idx].n,
   12917            0 :                           floatn_nx_types[specs->u.floatn_nx_idx].extended
   12918              :                           ? "x"
   12919              :                           : "");
   12920     10553277 :               else if (specs->short_p)
   12921            0 :                 error_at (loc,
   12922              :                           "both %qs and %<_Float%d%s%> in declaration "
   12923              :                           "specifiers", "short",
   12924            0 :                           floatn_nx_types[specs->u.floatn_nx_idx].n,
   12925            0 :                           floatn_nx_types[specs->u.floatn_nx_idx].extended
   12926              :                           ? "x"
   12927              :                           : "");
   12928     10553277 :               else if (specs->signed_p)
   12929            0 :                 error_at (loc,
   12930              :                           "both %qs and %<_Float%d%s%> in declaration "
   12931              :                           "specifiers", "signed",
   12932            0 :                           floatn_nx_types[specs->u.floatn_nx_idx].n,
   12933            0 :                           floatn_nx_types[specs->u.floatn_nx_idx].extended
   12934              :                           ? "x"
   12935              :                           : "");
   12936     10553277 :               else if (specs->unsigned_p)
   12937            0 :                 error_at (loc,
   12938              :                           "both %qs and %<_Float%d%s%> in declaration "
   12939              :                           "specifiers", "unsigned",
   12940            0 :                           floatn_nx_types[specs->u.floatn_nx_idx].n,
   12941            0 :                           floatn_nx_types[specs->u.floatn_nx_idx].extended
   12942              :                           ? "x"
   12943              :                           : "");
   12944     10553277 :               else if (specs->saturating_p)
   12945            0 :                 error_at (loc,
   12946              :                           "both %qs and %<_Float%d%s%> in declaration "
   12947              :                           "specifiers", "_Sat",
   12948            0 :                           floatn_nx_types[specs->u.floatn_nx_idx].n,
   12949            0 :                           floatn_nx_types[specs->u.floatn_nx_idx].extended
   12950              :                           ? "x"
   12951              :                           : "");
   12952     10553277 :               else if (FLOATN_NX_TYPE_NODE (specs->u.floatn_nx_idx) == NULL_TREE)
   12953              :                 {
   12954           88 :                   specs->typespec_word = cts_floatn_nx;
   12955          176 :                   error_at (loc,
   12956              :                             "%<_Float%d%s%> is not supported on this target",
   12957           88 :                             floatn_nx_types[specs->u.floatn_nx_idx].n,
   12958           88 :                             floatn_nx_types[specs->u.floatn_nx_idx].extended
   12959              :                             ? "x"
   12960              :                             : "");
   12961              :                 }
   12962              :               else
   12963              :                 {
   12964     10553189 :                   specs->typespec_word = cts_floatn_nx;
   12965     10553189 :                   specs->locations[cdw_typespec] = loc;
   12966              :                 }
   12967              :               return specs;
   12968        47660 :             case RID_DFLOAT32:
   12969        47660 :             case RID_DFLOAT64:
   12970        47660 :             case RID_DFLOAT128:
   12971        47660 :             case RID_DFLOAT64X:
   12972        47660 :               {
   12973        47660 :                 const char *str;
   12974        47660 :                 if (i == RID_DFLOAT32)
   12975              :                   str = "_Decimal32";
   12976              :                 else if (i == RID_DFLOAT64)
   12977              :                   str = "_Decimal64";
   12978              :                 else if (i == RID_DFLOAT128)
   12979              :                   str = "_Decimal128";
   12980              :                 else
   12981        47660 :                   str = "_Decimal64x";
   12982        47660 :                 if (specs->long_long_p)
   12983           18 :                   error_at (loc,
   12984              :                             "both %qs and %qs in declaration specifiers",
   12985              :                             "long long", str);
   12986        47660 :                 if (specs->long_p)
   12987           33 :                   error_at (loc,
   12988              :                             "both %qs and %qs in declaration specifiers",
   12989              :                             "long", str);
   12990        47627 :                 else if (specs->short_p)
   12991           18 :                   error_at (loc,
   12992              :                             "both %qs and %qs in declaration specifiers",
   12993              :                             "short", str);
   12994        47609 :                 else if (specs->signed_p)
   12995            6 :                   error_at (loc,
   12996              :                             "both %qs and %qs in declaration specifiers",
   12997              :                             "signed", str);
   12998        47603 :                 else if (specs->unsigned_p)
   12999            3 :                   error_at (loc,
   13000              :                             "both %qs and %qs in declaration specifiers",
   13001              :                             "unsigned", str);
   13002        47600 :                 else if (specs->complex_p)
   13003            3 :                   error_at (loc,
   13004              :                             "both %qs and %qs in declaration specifiers",
   13005              :                             "complex", str);
   13006        47597 :                 else if (specs->saturating_p)
   13007            0 :                   error_at (loc,
   13008              :                             "both %qs and %qs in declaration specifiers",
   13009              :                             "_Sat", str);
   13010        47597 :                 else if (i == RID_DFLOAT32)
   13011        15972 :                   specs->typespec_word = cts_dfloat32;
   13012        31625 :                 else if (i == RID_DFLOAT64)
   13013        15844 :                   specs->typespec_word = cts_dfloat64;
   13014        15781 :                 else if (i == RID_DFLOAT128)
   13015        15734 :                   specs->typespec_word = cts_dfloat128;
   13016              :                 else
   13017           47 :                   specs->typespec_word = cts_dfloat64x;
   13018        47660 :                 specs->locations[cdw_typespec] = loc;
   13019              :               }
   13020        47660 :               if (!targetm.decimal_float_supported_p ())
   13021            0 :                 error_at (loc,
   13022              :                           "decimal floating-point not supported "
   13023              :                           "for this target");
   13024        47660 :               pedwarn_c11 (loc, OPT_Wpedantic,
   13025              :                            "ISO C does not support decimal floating-point "
   13026              :                            "before C23");
   13027        47660 :               return specs;
   13028           75 :             case RID_FRACT:
   13029           75 :             case RID_ACCUM:
   13030           75 :               {
   13031           75 :                 const char *str;
   13032           75 :                 if (i == RID_FRACT)
   13033              :                   str = "_Fract";
   13034              :                 else
   13035           37 :                   str = "_Accum";
   13036           75 :                 if (specs->complex_p)
   13037            0 :                   error_at (loc,
   13038              :                             "both %qs and %qs in declaration specifiers",
   13039              :                             "complex", str);
   13040           75 :                 else if (i == RID_FRACT)
   13041           38 :                     specs->typespec_word = cts_fract;
   13042              :                 else
   13043           37 :                     specs->typespec_word = cts_accum;
   13044           75 :                 specs->locations[cdw_typespec] = loc;
   13045              :               }
   13046           75 :               if (!targetm.fixed_point_supported_p ())
   13047           75 :                 error_at (loc,
   13048              :                           "fixed-point types not supported for this target");
   13049           75 :               pedwarn (loc, OPT_Wpedantic,
   13050              :                        "ISO C does not support fixed-point types");
   13051           75 :               return specs;
   13052        48550 :             case RID_BITINT:
   13053        48550 :               if (specs->long_p)
   13054            2 :                 error_at (loc,
   13055              :                           "both %qs and %qs in declaration specifiers",
   13056              :                           "long", "_BitInt");
   13057        48548 :               else if (specs->short_p)
   13058            1 :                 error_at (loc,
   13059              :                           "both %qs and %qs in declaration specifiers",
   13060              :                           "short", "_BitInt");
   13061        48547 :               else if (specs->complex_p)
   13062            1 :                 error_at (loc,
   13063              :                           "both %qs and %qs in declaration specifiers",
   13064              :                           "complex", "_BitInt");
   13065        48546 :               else if (specs->saturating_p)
   13066            0 :                 error_at (loc,
   13067              :                           "both %qs and %qs in declaration specifiers",
   13068              :                           "_Sat", "_BitInt");
   13069              :               else
   13070              :                 {
   13071        48546 :                   specs->typespec_word = cts_bitint;
   13072        48546 :                   specs->locations[cdw_typespec] = loc;
   13073        48546 :                   specs->u.bitint_prec = -1;
   13074        48546 :                   if (error_operand_p (spec.expr))
   13075            7 :                     return specs;
   13076        48546 :                   if (TREE_CODE (spec.expr) != INTEGER_CST
   13077        48546 :                       || !INTEGRAL_TYPE_P (TREE_TYPE (spec.expr)))
   13078              :                     {
   13079            1 :                       error_at (loc, "%<_BitInt%> argument is not an integer "
   13080              :                                      "constant expression");
   13081            1 :                       return specs;
   13082              :                     }
   13083        48545 :                   if (tree_int_cst_sgn (spec.expr) <= 0)
   13084              :                     {
   13085            4 :                       error_at (loc, "%<_BitInt%> argument %qE is not a "
   13086              :                                      "positive integer constant expression",
   13087              :                                 spec.expr);
   13088            4 :                       return specs;
   13089              :                     }
   13090        48541 :                   if (wi::to_widest (spec.expr) > WIDE_INT_MAX_PRECISION - 1)
   13091              :                     {
   13092            2 :                       error_at (loc, "%<_BitInt%> argument %qE is larger than "
   13093              :                                      "%<BITINT_MAXWIDTH%> %qd",
   13094              :                                 spec.expr, (int) WIDE_INT_MAX_PRECISION - 1);
   13095            2 :                       return specs;
   13096              :                     }
   13097        48539 :                   specs->u.bitint_prec = tree_to_uhwi (spec.expr);
   13098        48539 :                   struct bitint_info info;
   13099        48539 :                   if (!targetm.c.bitint_type_info (specs->u.bitint_prec,
   13100              :                                                    &info))
   13101              :                     {
   13102            0 :                       sorry_at (loc, "%<_BitInt(%d)%> is not supported on "
   13103              :                                      "this target", specs->u.bitint_prec);
   13104            0 :                       specs->u.bitint_prec = -1;
   13105            0 :                       return specs;
   13106              :                     }
   13107              :                 }
   13108              :               return specs;
   13109              :             default:
   13110              :               /* ObjC reserved word "id", handled below.  */
   13111              :               break;
   13112              :             }
   13113              :         }
   13114              :     }
   13115              : 
   13116              :   /* Now we have a typedef (a TYPE_DECL node), an identifier (some
   13117              :      form of ObjC type, cases such as "int" and "long" being handled
   13118              :      above), a TYPE (struct, union, enum and typeof specifiers) or an
   13119              :      ERROR_MARK.  In none of these cases may there have previously
   13120              :      been any type specifiers.  */
   13121    258251923 :   if (specs->type || specs->typespec_word != cts_none
   13122    258251911 :       || specs->long_p || specs->short_p || specs->signed_p
   13123    258251908 :       || specs->unsigned_p || specs->complex_p)
   13124           21 :     error_at (loc, "two or more data types in declaration specifiers");
   13125    258251902 :   else if (TREE_CODE (type) == TYPE_DECL)
   13126              :     {
   13127    254917130 :       specs->type = TREE_TYPE (type);
   13128    254917130 :       if (TREE_TYPE (type) != error_mark_node)
   13129              :         {
   13130    254917115 :           mark_decl_used (type, false);
   13131    254917115 :           specs->decl_attr = DECL_ATTRIBUTES (type);
   13132    254917115 :           specs->typedef_p = true;
   13133    254917115 :           specs->explicit_signed_p = C_TYPEDEF_EXPLICITLY_SIGNED (type);
   13134    254917115 :           specs->locations[cdw_typedef] = loc;
   13135              : 
   13136              :           /* If this typedef name is defined in a struct, then a C++
   13137              :              lookup would return a different value.  */
   13138    254917115 :           if (warn_cxx_compat
   13139    254917115 :               && I_SYMBOL_BINDING (DECL_NAME (type))->in_struct)
   13140            2 :             warning_at (loc, OPT_Wc___compat,
   13141              :                         "C++ lookup of %qD would return a field, not a type",
   13142              :                         type);
   13143              : 
   13144              :           /* If we are parsing a struct, record that a struct field
   13145              :              used a typedef.  */
   13146    254917115 :           if (warn_cxx_compat && struct_parse_info != NULL)
   13147       178978 :             struct_parse_info->typedefs_seen.safe_push (type);
   13148              :         }
   13149              :     }
   13150      3334772 :   else if (TREE_CODE (type) == IDENTIFIER_NODE)
   13151              :     {
   13152            0 :       tree t = lookup_name (type);
   13153            0 :       if (!t || TREE_CODE (t) != TYPE_DECL)
   13154            0 :         error_at (loc, "%qE fails to be a typedef or built in type", type);
   13155            0 :       else if (TREE_TYPE (t) == error_mark_node)
   13156              :         ;
   13157              :       else
   13158              :         {
   13159            0 :           specs->type = TREE_TYPE (t);
   13160            0 :           specs->locations[cdw_typespec] = loc;
   13161              :         }
   13162              :     }
   13163              :   else
   13164              :     {
   13165      3334772 :       if (TREE_CODE (type) != ERROR_MARK)
   13166              :         {
   13167      3334571 :           if (spec.kind == ctsk_typeof)
   13168              :             {
   13169       835873 :               specs->typedef_p = true;
   13170       835873 :               specs->locations[cdw_typedef] = loc;
   13171              :             }
   13172              : 
   13173      3334571 :           if (TREE_CODE (type) == RECORD_TYPE || TREE_CODE (type) == UNION_TYPE
   13174      1077107 :               || TREE_CODE (type) == ENUMERAL_TYPE)
   13175      2507305 :             mark_decl_used (TYPE_STUB_DECL (type), false);
   13176              : 
   13177      3334571 :           if (spec.expr)
   13178              :             {
   13179          958 :               tree expr = save_expr (fold_convert (void_type_node, spec.expr));
   13180          958 :               if (specs->expr)
   13181            0 :                 specs->expr = build2 (COMPOUND_EXPR, TREE_TYPE (expr),
   13182              :                                       specs->expr, expr);
   13183              :               else
   13184              :                 specs->expr = expr;
   13185          958 :               specs->expr_const_operands &= spec.expr_const_operands;
   13186              :             }
   13187              :         }
   13188      3334772 :       specs->type = type;
   13189      3334772 :       if (spec.has_enum_type_specifier
   13190          387 :           && spec.kind != ctsk_tagdef)
   13191           50 :         specs->enum_type_specifier_ref_p = true;
   13192              :     }
   13193              : 
   13194              :   return specs;
   13195              : }
   13196              : 
   13197              : /* Add the storage class specifier or function specifier SCSPEC to the
   13198              :    declaration specifiers SPECS, returning SPECS.  */
   13199              : 
   13200              : struct c_declspecs *
   13201     93903537 : declspecs_add_scspec (location_t loc,
   13202              :                       struct c_declspecs *specs,
   13203              :                       tree scspec)
   13204              : {
   13205     93903537 :   enum rid i;
   13206     93903537 :   enum c_storage_class n = csc_none;
   13207     93903537 :   bool dupe = false;
   13208     93903537 :   specs->declspecs_seen_p = true;
   13209     93903537 :   specs->non_std_attrs_seen_p = true;
   13210     93903537 :   gcc_assert (TREE_CODE (scspec) == IDENTIFIER_NODE
   13211              :               && C_IS_RESERVED_WORD (scspec));
   13212     93903537 :   i = C_RID_CODE (scspec);
   13213     93903537 :   if (specs->non_sc_seen_p)
   13214         2152 :     warning (OPT_Wold_style_declaration,
   13215              :              "%qE is not at beginning of declaration", scspec);
   13216     93903537 :   switch (i)
   13217              :     {
   13218     37005584 :     case RID_INLINE:
   13219              :       /* C99 permits duplicate inline.  Although of doubtful utility,
   13220              :          it seems simplest to permit it in gnu89 mode as well, as
   13221              :          there is also little utility in maintaining this as a
   13222              :          difference between gnu89 and C99 inline.  */
   13223     37005584 :       dupe = false;
   13224     37005584 :       specs->inline_p = true;
   13225     37005584 :       specs->locations[cdw_inline] = loc;
   13226     37005584 :       break;
   13227        23317 :     case RID_NORETURN:
   13228              :       /* Duplicate _Noreturn is permitted.  */
   13229        23317 :       dupe = false;
   13230        23317 :       specs->noreturn_p = true;
   13231        23317 :       specs->locations[cdw_noreturn] = loc;
   13232        23317 :       break;
   13233         2896 :     case RID_THREAD:
   13234         2896 :       dupe = specs->thread_p;
   13235         2896 :       if (specs->storage_class == csc_auto)
   13236            2 :         error ("%qE used with %<auto%>", scspec);
   13237         2894 :       else if (specs->storage_class == csc_register)
   13238            3 :         error ("%qE used with %<register%>", scspec);
   13239         2891 :       else if (specs->storage_class == csc_typedef)
   13240            2 :         error ("%qE used with %<typedef%>", scspec);
   13241         2889 :       else if (specs->constexpr_p)
   13242            2 :         error ("%qE used with %<constexpr%>", scspec);
   13243              :       else
   13244              :         {
   13245         2887 :           specs->thread_p = true;
   13246         2887 :           specs->thread_gnu_p = (strcmp (IDENTIFIER_POINTER (scspec),
   13247         2887 :                                          "__thread") == 0);
   13248              :           /* A diagnostic is not required for the use of this
   13249              :              identifier in the implementation namespace; only diagnose
   13250              :              it for the C11 spelling because of existing code using
   13251              :              the other spelling.  */
   13252         2887 :           if (!specs->thread_gnu_p)
   13253              :             {
   13254          116 :               if (flag_isoc99)
   13255          113 :                 pedwarn_c99 (loc, OPT_Wpedantic,
   13256              :                              "ISO C99 does not support %qE", scspec);
   13257              :               else
   13258            3 :                 pedwarn_c99 (loc, OPT_Wpedantic,
   13259              :                              "ISO C90 does not support %qE", scspec);
   13260              :             }
   13261         2887 :           specs->locations[cdw_thread] = loc;
   13262              :         }
   13263              :       break;
   13264          268 :     case RID_AUTO:
   13265          268 :       if (flag_isoc23
   13266          229 :           && specs->typespec_kind == ctsk_none
   13267          218 :           && specs->storage_class != csc_typedef)
   13268              :         {
   13269              :           /* "auto" potentially used for type deduction.  */
   13270          217 :           if (specs->c23_auto_p)
   13271            2 :             error ("duplicate %qE", scspec);
   13272          217 :           specs->c23_auto_p = true;
   13273          217 :           return specs;
   13274              :         }
   13275           51 :       n = csc_auto;
   13276              :       /* auto may only be used with another storage class specifier,
   13277              :          such as constexpr, if the type is inferred.  */
   13278           51 :       if (specs->constexpr_p)
   13279            2 :         error ("%qE used with %<constexpr%>", scspec);
   13280              :       break;
   13281     52034421 :     case RID_EXTERN:
   13282     52034421 :       n = csc_extern;
   13283              :       /* Diagnose "__thread extern".  */
   13284     52034421 :       if (specs->thread_p && specs->thread_gnu_p)
   13285            2 :         error ("%<__thread%> before %<extern%>");
   13286              :       break;
   13287              :     case RID_REGISTER:
   13288              :       n = csc_register;
   13289              :       break;
   13290       437215 :     case RID_STATIC:
   13291       437215 :       n = csc_static;
   13292              :       /* Diagnose "__thread static".  */
   13293       437215 :       if (specs->thread_p && specs->thread_gnu_p)
   13294            1 :         error ("%<__thread%> before %<static%>");
   13295              :       break;
   13296      4396013 :     case RID_TYPEDEF:
   13297      4396013 :       n = csc_typedef;
   13298      4396013 :       if (specs->c23_auto_p)
   13299              :         {
   13300            1 :           error ("%<typedef%> used with %<auto%>");
   13301            1 :           specs->c23_auto_p = false;
   13302              :         }
   13303              :       break;
   13304          646 :     case RID_CONSTEXPR:
   13305          646 :       dupe = specs->constexpr_p;
   13306          646 :       if (specs->storage_class == csc_extern)
   13307            1 :         error ("%qE used with %<extern%>", scspec);
   13308          645 :       else if (specs->storage_class == csc_typedef)
   13309            1 :         error ("%qE used with %<typedef%>", scspec);
   13310          644 :       else if (specs->storage_class == csc_auto)
   13311              :         /* auto may only be used with another storage class specifier,
   13312              :            such as constexpr, if the type is inferred.  */
   13313            2 :         error ("%qE used with %<auto%>", scspec);
   13314          642 :       else if (specs->thread_p)
   13315            4 :         error ("%qE used with %qs", scspec,
   13316            2 :                specs->thread_gnu_p ? "__thread" : "_Thread_local");
   13317              :       else
   13318          640 :         specs->constexpr_p = true;
   13319              :       break;
   13320            0 :     default:
   13321            0 :       gcc_unreachable ();
   13322              :     }
   13323     93903320 :   if (n != csc_none && n == specs->storage_class)
   13324              :     dupe = true;
   13325     93903312 :   if (dupe)
   13326              :     {
   13327           12 :       if (i == RID_THREAD)
   13328            2 :         error ("duplicate %<_Thread_local%> or %<__thread%>");
   13329              :       else
   13330           10 :         error ("duplicate %qE", scspec);
   13331              :     }
   13332     93903320 :   if (n != csc_none)
   13333              :     {
   13334     56870877 :       if (specs->storage_class != csc_none && n != specs->storage_class)
   13335              :         {
   13336            7 :           error ("multiple storage classes in declaration specifiers");
   13337              :         }
   13338              :       else
   13339              :         {
   13340     56870870 :           specs->storage_class = n;
   13341     56870870 :           specs->locations[cdw_storage_class] = loc;
   13342     56870870 :           if (n != csc_extern && n != csc_static && specs->thread_p)
   13343              :             {
   13344            8 :               error ("%qs used with %qE",
   13345            8 :                      specs->thread_gnu_p ? "__thread" : "_Thread_local",
   13346              :                      scspec);
   13347            8 :               specs->thread_p = false;
   13348              :             }
   13349     56870870 :           if (n != csc_auto && n != csc_register && n != csc_static
   13350     56430431 :               && specs->constexpr_p)
   13351              :             {
   13352            2 :               error ("%<constexpr%> used with %qE", scspec);
   13353            2 :               specs->constexpr_p = false;
   13354              :             }
   13355              :         }
   13356              :     }
   13357              :   return specs;
   13358              : }
   13359              : 
   13360              : /* Add the attributes ATTRS to the declaration specifiers SPECS,
   13361              :    returning SPECS.  */
   13362              : 
   13363              : struct c_declspecs *
   13364     37321881 : declspecs_add_attrs (location_t loc, struct c_declspecs *specs, tree attrs)
   13365              : {
   13366     37321881 :   specs->attrs = chainon (attrs, specs->attrs);
   13367     37321881 :   specs->locations[cdw_attributes] = loc;
   13368     37321881 :   specs->declspecs_seen_p = true;
   13369              :   /* In the case of standard attributes at the start of the
   13370              :      declaration, the caller will reset this.  */
   13371     37321881 :   specs->non_std_attrs_seen_p = true;
   13372     37321881 :   return specs;
   13373              : }
   13374              : 
   13375              : /* Add an _Alignas specifier (expression ALIGN, or type whose
   13376              :    alignment is ALIGN) to the declaration specifiers SPECS, returning
   13377              :    SPECS.  */
   13378              : struct c_declspecs *
   13379          202 : declspecs_add_alignas (location_t loc,
   13380              :                        struct c_declspecs *specs, tree align)
   13381              : {
   13382          202 :   specs->alignas_p = true;
   13383          202 :   specs->locations[cdw_alignas] = loc;
   13384          202 :   if (align == error_mark_node)
   13385              :     return specs;
   13386              : 
   13387              :   /* Only accept the alignment if it's valid and greater than
   13388              :      the current one.  Zero is invalid but by C11 required to
   13389              :      be silently ignored.  */
   13390          200 :   int align_log = check_user_alignment (align, false, /* warn_zero = */false);
   13391          200 :   if (align_log > specs->align_log)
   13392          167 :     specs->align_log = align_log;
   13393              :   return specs;
   13394              : }
   13395              : 
   13396              : /* Combine "long", "short", "signed", "unsigned" and "_Complex" type
   13397              :    specifiers with any other type specifier to determine the resulting
   13398              :    type.  This is where ISO C checks on complex types are made, since
   13399              :    "_Complex long" is a prefix of the valid ISO C type "_Complex long
   13400              :    double".  Also apply postfix standard attributes to modify the type.  */
   13401              : 
   13402              : struct c_declspecs *
   13403    326042413 : finish_declspecs (struct c_declspecs *specs)
   13404              : {
   13405              :   /* If a type was specified as a whole, we have no modifiers and are
   13406              :      done.  */
   13407    326042413 :   if (specs->type != NULL_TREE)
   13408              :     {
   13409    258251858 :       gcc_assert (!specs->long_p && !specs->long_long_p && !specs->short_p
   13410              :                   && !specs->signed_p && !specs->unsigned_p
   13411              :                   && !specs->complex_p && !specs->c23_auto_p);
   13412              : 
   13413              :       /* Set a dummy type.  */
   13414    258251858 :       if (TREE_CODE (specs->type) == ERROR_MARK)
   13415          181 :         specs->type = integer_type_node;
   13416    258251858 :       goto handle_postfix_attrs;
   13417              :     }
   13418              : 
   13419              :   /* If none of "void", "_Bool", "char", "int", "float" or "double"
   13420              :      has been specified, treat it as "int" unless "_Complex" is
   13421              :      present and there are no other specifiers.  If we just have
   13422              :      "_Complex", it is equivalent to "_Complex double", but e.g.
   13423              :      "_Complex short" is equivalent to "_Complex short int".  */
   13424     67790555 :   if (specs->typespec_word == cts_none)
   13425              :     {
   13426      4295254 :       if (specs->saturating_p)
   13427              :         {
   13428            1 :           error_at (specs->locations[cdw_saturating],
   13429              :                     "%<_Sat%> is used without %<_Fract%> or %<_Accum%>");
   13430            1 :           if (!targetm.fixed_point_supported_p ())
   13431            1 :             error_at (specs->locations[cdw_saturating],
   13432              :                       "fixed-point types not supported for this target");
   13433            1 :           specs->typespec_word = cts_fract;
   13434              :         }
   13435      4295253 :       else if (specs->long_p || specs->short_p
   13436       209423 :                || specs->signed_p || specs->unsigned_p)
   13437              :         {
   13438      4284800 :           specs->typespec_word = cts_int;
   13439              :         }
   13440        10453 :       else if (specs->complex_p)
   13441              :         {
   13442          132 :           specs->typespec_word = cts_double;
   13443          132 :           pedwarn (specs->locations[cdw_complex], OPT_Wpedantic,
   13444              :                    "ISO C does not support plain %<complex%> meaning "
   13445              :                    "%<double complex%>");
   13446              :         }
   13447        10321 :       else if (specs->c23_auto_p)
   13448              :         {
   13449              :           /* Type to be filled in later, including applying postfix
   13450              :              attributes.  This warning only actually appears for
   13451              :              -Wc11-c23-compat in C23 mode; in older modes, there may
   13452              :              be a warning or pedwarn for implicit "int" instead, or
   13453              :              other errors for use of auto at file scope.  */
   13454           95 :           pedwarn_c11 (input_location, OPT_Wpedantic,
   13455              :                        "ISO C does not support %<auto%> type deduction "
   13456              :                        "before C23");
   13457           95 :           return specs;
   13458              :         }
   13459              :       else
   13460              :         {
   13461        10226 :           specs->typespec_word = cts_int;
   13462        10226 :           specs->default_int_p = true;
   13463              :           /* We don't diagnose this here because grokdeclarator will
   13464              :              give more specific diagnostics according to whether it is
   13465              :              a function definition.  */
   13466              :         }
   13467              :     }
   13468              : 
   13469              :   /* If "signed" was specified, record this to distinguish "int" and
   13470              :      "signed int" in the case of a bit-field with
   13471              :      -funsigned-bitfields.  */
   13472     67790460 :   specs->explicit_signed_p = specs->signed_p;
   13473              : 
   13474              :   /* Now compute the actual type.  */
   13475     67790460 :   gcc_assert (!specs->c23_auto_p);
   13476     67790460 :   switch (specs->typespec_word)
   13477              :     {
   13478         1892 :     case cts_auto_type:
   13479         1892 :       gcc_assert (!specs->long_p && !specs->short_p
   13480              :                   && !specs->signed_p && !specs->unsigned_p
   13481              :                   && !specs->complex_p);
   13482              :       /* Type to be filled in later.  */
   13483         1892 :       if (specs->postfix_attrs)
   13484            2 :         error ("%<__auto_type%> followed by %<[[]]%> attributes");
   13485              :       break;
   13486      8285967 :     case cts_void:
   13487      8285967 :       gcc_assert (!specs->long_p && !specs->short_p
   13488              :                   && !specs->signed_p && !specs->unsigned_p
   13489              :                   && !specs->complex_p);
   13490      8285967 :       specs->type = void_type_node;
   13491      8285967 :       break;
   13492        95515 :     case cts_bool:
   13493        95515 :       gcc_assert (!specs->long_p && !specs->short_p
   13494              :                   && !specs->signed_p && !specs->unsigned_p
   13495              :                   && !specs->complex_p);
   13496        95515 :       specs->type = boolean_type_node;
   13497        95515 :       break;
   13498      9319717 :     case cts_char:
   13499      9319717 :       gcc_assert (!specs->long_p && !specs->short_p);
   13500      9319717 :       gcc_assert (!(specs->signed_p && specs->unsigned_p));
   13501      9319717 :       if (specs->signed_p)
   13502       175165 :         specs->type = signed_char_type_node;
   13503      9144552 :       else if (specs->unsigned_p)
   13504       893869 :         specs->type = unsigned_char_type_node;
   13505              :       else
   13506      8250683 :         specs->type = char_type_node;
   13507      9319717 :       if (specs->complex_p)
   13508              :         {
   13509         3856 :           pedwarn (specs->locations[cdw_complex], OPT_Wpedantic,
   13510              :                    "ISO C does not support complex integer types");
   13511         3856 :           specs->type = build_complex_type (specs->type);
   13512              :         }
   13513              :       break;
   13514        52822 :     case cts_int_n:
   13515        52822 :       gcc_assert (!specs->long_p && !specs->short_p && !specs->long_long_p);
   13516        52822 :       gcc_assert (!(specs->signed_p && specs->unsigned_p));
   13517        52822 :       if (! int_n_enabled_p[specs->u.int_n_idx])
   13518            0 :         specs->type = integer_type_node;
   13519              :       else
   13520        52822 :         specs->type = (specs->unsigned_p
   13521        52822 :                        ? int_n_trees[specs->u.int_n_idx].unsigned_type
   13522              :                        : int_n_trees[specs->u.int_n_idx].signed_type);
   13523        52822 :       if (specs->complex_p)
   13524              :         {
   13525          202 :           pedwarn (specs->locations[cdw_complex], OPT_Wpedantic,
   13526              :                    "ISO C does not support complex integer types");
   13527          202 :           specs->type = build_complex_type (specs->type);
   13528              :         }
   13529              :       break;
   13530     29017957 :     case cts_int:
   13531     29017957 :       gcc_assert (!(specs->long_p && specs->short_p));
   13532     29017957 :       gcc_assert (!(specs->signed_p && specs->unsigned_p));
   13533     29017957 :       if (specs->long_long_p)
   13534      3045027 :         specs->type = (specs->unsigned_p
   13535      3045027 :                        ? long_long_unsigned_type_node
   13536              :                        : long_long_integer_type_node);
   13537     25972930 :       else if (specs->long_p)
   13538      2264887 :         specs->type = (specs->unsigned_p
   13539      2264887 :                        ? long_unsigned_type_node
   13540              :                        : long_integer_type_node);
   13541     23708043 :       else if (specs->short_p)
   13542      1725503 :         specs->type = (specs->unsigned_p
   13543      1725503 :                        ? short_unsigned_type_node
   13544              :                        : short_integer_type_node);
   13545              :       else
   13546     21982540 :         specs->type = (specs->unsigned_p
   13547     21982540 :                        ? unsigned_type_node
   13548              :                        : integer_type_node);
   13549     29017957 :       if (specs->complex_p)
   13550              :         {
   13551        15763 :           pedwarn (specs->locations[cdw_complex], OPT_Wpedantic,
   13552              :                    "ISO C does not support complex integer types");
   13553        15763 :           specs->type = build_complex_type (specs->type);
   13554              :         }
   13555              :       break;
   13556      3676557 :     case cts_float:
   13557      3676557 :       gcc_assert (!specs->long_p && !specs->short_p
   13558              :                   && !specs->signed_p && !specs->unsigned_p);
   13559      7353114 :       specs->type = (specs->complex_p
   13560      3676557 :                      ? complex_float_type_node
   13561              :                      : float_type_node);
   13562      3676557 :       break;
   13563      6690537 :     case cts_double:
   13564      6690537 :       gcc_assert (!specs->long_long_p && !specs->short_p
   13565              :                   && !specs->signed_p && !specs->unsigned_p);
   13566      6690537 :       if (specs->long_p)
   13567              :         {
   13568      2919171 :           specs->type = (specs->complex_p
   13569      2919171 :                          ? complex_long_double_type_node
   13570              :                          : long_double_type_node);
   13571              :         }
   13572              :       else
   13573              :         {
   13574      3771366 :           specs->type = (specs->complex_p
   13575      3771366 :                          ? complex_double_type_node
   13576              :                          : double_type_node);
   13577              :         }
   13578              :       break;
   13579     10553277 :     case cts_floatn_nx:
   13580     10553277 :       gcc_assert (!specs->long_p && !specs->short_p
   13581              :                   && !specs->signed_p && !specs->unsigned_p);
   13582     10553277 :       if (FLOATN_NX_TYPE_NODE (specs->u.floatn_nx_idx) == NULL_TREE)
   13583           88 :         specs->type = integer_type_node;
   13584     10553189 :       else if (specs->complex_p)
   13585      1557548 :         specs->type = COMPLEX_FLOATN_NX_TYPE_NODE (specs->u.floatn_nx_idx);
   13586              :       else
   13587      8995641 :         specs->type = FLOATN_NX_TYPE_NODE (specs->u.floatn_nx_idx);
   13588              :       break;
   13589        47597 :     case cts_dfloat32:
   13590        47597 :     case cts_dfloat64:
   13591        47597 :     case cts_dfloat128:
   13592        47597 :     case cts_dfloat64x:
   13593        47597 :       gcc_assert (!specs->long_p && !specs->long_long_p && !specs->short_p
   13594              :                   && !specs->signed_p && !specs->unsigned_p && !specs->complex_p);
   13595        47597 :       if (!targetm.decimal_float_supported_p ())
   13596            0 :         specs->type = integer_type_node;
   13597        47597 :       else if (specs->typespec_word == cts_dfloat32)
   13598        15972 :         specs->type = dfloat32_type_node;
   13599        31625 :       else if (specs->typespec_word == cts_dfloat64)
   13600        15844 :         specs->type = dfloat64_type_node;
   13601        15781 :       else if (specs->typespec_word == cts_dfloat128)
   13602        15734 :         specs->type = dfloat128_type_node;
   13603              :       else
   13604           47 :         specs->type = dfloat64x_type_node;
   13605              :       break;
   13606           39 :     case cts_fract:
   13607           39 :       gcc_assert (!specs->complex_p);
   13608           39 :       if (!targetm.fixed_point_supported_p ())
   13609           39 :         specs->type = integer_type_node;
   13610            0 :       else if (specs->saturating_p)
   13611              :         {
   13612            0 :           if (specs->long_long_p)
   13613            0 :             specs->type = specs->unsigned_p
   13614            0 :                           ? sat_unsigned_long_long_fract_type_node
   13615              :                           : sat_long_long_fract_type_node;
   13616            0 :           else if (specs->long_p)
   13617            0 :             specs->type = specs->unsigned_p
   13618            0 :                           ? sat_unsigned_long_fract_type_node
   13619              :                           : sat_long_fract_type_node;
   13620            0 :           else if (specs->short_p)
   13621            0 :             specs->type = specs->unsigned_p
   13622            0 :                           ? sat_unsigned_short_fract_type_node
   13623              :                           : sat_short_fract_type_node;
   13624              :           else
   13625            0 :             specs->type = specs->unsigned_p
   13626            0 :                           ? sat_unsigned_fract_type_node
   13627              :                           : sat_fract_type_node;
   13628              :         }
   13629              :       else
   13630              :         {
   13631            0 :           if (specs->long_long_p)
   13632            0 :             specs->type = specs->unsigned_p
   13633            0 :                           ? unsigned_long_long_fract_type_node
   13634              :                           : long_long_fract_type_node;
   13635            0 :           else if (specs->long_p)
   13636            0 :             specs->type = specs->unsigned_p
   13637            0 :                           ? unsigned_long_fract_type_node
   13638              :                           : long_fract_type_node;
   13639            0 :           else if (specs->short_p)
   13640            0 :             specs->type = specs->unsigned_p
   13641            0 :                           ? unsigned_short_fract_type_node
   13642              :                           : short_fract_type_node;
   13643              :           else
   13644            0 :             specs->type = specs->unsigned_p
   13645            0 :                           ? unsigned_fract_type_node
   13646              :                           : fract_type_node;
   13647              :         }
   13648              :       break;
   13649           37 :     case cts_accum:
   13650           37 :       gcc_assert (!specs->complex_p);
   13651           37 :       if (!targetm.fixed_point_supported_p ())
   13652           37 :         specs->type = integer_type_node;
   13653            0 :       else if (specs->saturating_p)
   13654              :         {
   13655            0 :           if (specs->long_long_p)
   13656            0 :             specs->type = specs->unsigned_p
   13657            0 :                           ? sat_unsigned_long_long_accum_type_node
   13658              :                           : sat_long_long_accum_type_node;
   13659            0 :           else if (specs->long_p)
   13660            0 :             specs->type = specs->unsigned_p
   13661            0 :                           ? sat_unsigned_long_accum_type_node
   13662              :                           : sat_long_accum_type_node;
   13663            0 :           else if (specs->short_p)
   13664            0 :             specs->type = specs->unsigned_p
   13665            0 :                           ? sat_unsigned_short_accum_type_node
   13666              :                           : sat_short_accum_type_node;
   13667              :           else
   13668            0 :             specs->type = specs->unsigned_p
   13669            0 :                           ? sat_unsigned_accum_type_node
   13670              :                           : sat_accum_type_node;
   13671              :         }
   13672              :       else
   13673              :         {
   13674            0 :           if (specs->long_long_p)
   13675            0 :             specs->type = specs->unsigned_p
   13676            0 :                           ? unsigned_long_long_accum_type_node
   13677              :                           : long_long_accum_type_node;
   13678            0 :           else if (specs->long_p)
   13679            0 :             specs->type = specs->unsigned_p
   13680            0 :                           ? unsigned_long_accum_type_node
   13681              :                           : long_accum_type_node;
   13682            0 :           else if (specs->short_p)
   13683            0 :             specs->type = specs->unsigned_p
   13684            0 :                           ? unsigned_short_accum_type_node
   13685              :                           : short_accum_type_node;
   13686              :           else
   13687            0 :             specs->type = specs->unsigned_p
   13688            0 :                           ? unsigned_accum_type_node
   13689              :                           : accum_type_node;
   13690              :         }
   13691              :       break;
   13692        48546 :     case cts_bitint:
   13693        48546 :       gcc_assert (!specs->long_p && !specs->short_p
   13694              :                   && !specs->complex_p);
   13695        48546 :       if (!specs->unsigned_p && specs->u.bitint_prec == 1 && !flag_isoc2y)
   13696              :         {
   13697            2 :           error_at (specs->locations[cdw_typespec],
   13698              :                     "%<signed _BitInt%> argument must be at least 2 "
   13699              :                     "before C2Y");
   13700            2 :           specs->type = integer_type_node;
   13701            2 :           break;
   13702              :         }
   13703        48544 :       if (specs->u.bitint_prec == -1)
   13704            7 :         specs->type = integer_type_node;
   13705              :       else
   13706              :         {
   13707        71650 :           pedwarn_c11 (specs->locations[cdw_typespec], OPT_Wpedantic,
   13708              :                        "ISO C does not support %<%s_BitInt(%d)%> before C23",
   13709              :                        specs->unsigned_p ? "unsigned "
   13710        23113 :                        : specs->signed_p ? "signed " : "",
   13711              :                        specs->u.bitint_prec);
   13712        48537 :           specs->type = build_bitint_type (specs->u.bitint_prec,
   13713        48537 :                                            specs->unsigned_p);
   13714              :         }
   13715              :       break;
   13716            0 :     default:
   13717            0 :       gcc_unreachable ();
   13718              :     }
   13719    326042318 :  handle_postfix_attrs:
   13720    326042318 :   if (specs->type != NULL)
   13721              :     {
   13722    326040426 :       specs->postfix_attrs
   13723    326040426 :         = c_warn_type_attributes (specs->type, specs->postfix_attrs);
   13724    326040426 :       decl_attributes (&specs->type, specs->postfix_attrs, 0);
   13725    326040426 :       specs->postfix_attrs = NULL_TREE;
   13726              :     }
   13727              : 
   13728              :   return specs;
   13729              : }
   13730              : 
   13731              : /* Perform final processing on one file scope's declarations (or the
   13732              :    external scope's declarations), GLOBALS.  */
   13733              : 
   13734              : static void
   13735       219390 : c_write_global_declarations_1 (tree globals)
   13736              : {
   13737       219390 :   tree decl;
   13738       219390 :   bool reconsider;
   13739              : 
   13740              :   /* Process the decls in the order they were written.  */
   13741    401702036 :   for (decl = globals; decl; decl = DECL_CHAIN (decl))
   13742              :     {
   13743              :       /* Check for used but undefined static functions using the C
   13744              :          standard's definition of "used", and set TREE_NO_WARNING so
   13745              :          that check_global_declaration doesn't repeat the check.  */
   13746    401482646 :       if (TREE_CODE (decl) == FUNCTION_DECL
   13747    382883262 :           && DECL_INITIAL (decl) == NULL_TREE
   13748    345171275 :           && DECL_EXTERNAL (decl)
   13749    345171270 :           && !TREE_PUBLIC (decl)
   13750    401482781 :           && !warning_suppressed_p (decl, OPT_Wunused))
   13751              :         {
   13752          130 :           if (C_DECL_USED (decl))
   13753              :             {
   13754           31 :               if (pedwarn (input_location, 0, "%q+F used but never defined",
   13755              :                            decl))
   13756           30 :                 suppress_warning (decl, OPT_Wunused);
   13757              :             }
   13758              :           /* For -Wunused-function warn about unused static prototypes.  */
   13759           99 :           else if (warn_unused_function
   13760            2 :                    && ! DECL_ARTIFICIAL (decl)
   13761          101 :                    && warning (OPT_Wunused_function,
   13762              :                                "%q+F declared %<static%> but never defined",
   13763              :                                decl))
   13764            2 :             suppress_warning (decl, OPT_Wunused);
   13765              :         }
   13766              : 
   13767    401482646 :       wrapup_global_declaration_1 (decl);
   13768              :     }
   13769              : 
   13770       255042 :   do
   13771              :     {
   13772       255042 :       reconsider = false;
   13773    520949826 :       for (decl = globals; decl; decl = DECL_CHAIN (decl))
   13774    520694784 :         reconsider |= wrapup_global_declaration_2 (decl);
   13775              :     }
   13776              :   while (reconsider);
   13777       219390 : }
   13778              : 
   13779              : /* Preserve the external declarations scope across a garbage collect.  */
   13780              : static GTY(()) tree ext_block;
   13781              : 
   13782              : /* Collect all references relevant to SOURCE_FILE.  */
   13783              : 
   13784              : static void
   13785           15 : collect_all_refs (const char *source_file)
   13786              : {
   13787           15 :   tree t;
   13788           15 :   unsigned i;
   13789              : 
   13790           30 :   FOR_EACH_VEC_ELT (*all_translation_units, i, t)
   13791           15 :     collect_ada_nodes (BLOCK_VARS (DECL_INITIAL (t)), source_file);
   13792              : 
   13793           15 :   collect_ada_nodes (BLOCK_VARS (ext_block), source_file);
   13794           15 : }
   13795              : 
   13796              : /* Collect source file references at global level.  */
   13797              : 
   13798              : static void
   13799           15 : collect_source_refs (void)
   13800              : {
   13801           15 :   tree t;
   13802           15 :   tree decls;
   13803           15 :   tree decl;
   13804           15 :   unsigned i;
   13805              : 
   13806           30 :   FOR_EACH_VEC_ELT (*all_translation_units, i, t)
   13807              :     {
   13808           15 :       decls = DECL_INITIAL (t);
   13809           82 :       for (decl = BLOCK_VARS (decls); decl; decl = TREE_CHAIN (decl))
   13810           67 :         if (!DECL_IS_UNDECLARED_BUILTIN (decl))
   13811           67 :           collect_source_ref (DECL_SOURCE_FILE (decl));
   13812              :     }
   13813              : 
   13814        44321 :   for (decl = BLOCK_VARS (ext_block); decl; decl = TREE_CHAIN (decl))
   13815        44306 :     if (!DECL_IS_UNDECLARED_BUILTIN (decl))
   13816           11 :       collect_source_ref (DECL_SOURCE_FILE (decl));
   13817           15 : }
   13818              : 
   13819              : /* Free attribute access data that are not needed by the middle end. */
   13820              : 
   13821              : static void
   13822       109695 : free_attr_access_data ()
   13823              : {
   13824       109695 :   struct cgraph_node *n;
   13825              : 
   13826              :   /* Iterate over all functions declared in the translation unit.  */
   13827     37823367 :   FOR_EACH_FUNCTION (n)
   13828              :     {
   13829    141037435 :       for (tree parm = DECL_ARGUMENTS (n->decl); parm; parm = TREE_CHAIN (parm))
   13830    103323763 :         if (tree attrs = DECL_ATTRIBUTES (parm))
   13831        98797 :           attr_access::free_lang_data (attrs);
   13832              : 
   13833     37713672 :       tree fntype = TREE_TYPE (n->decl);
   13834     37713672 :       if (!fntype || fntype == error_mark_node)
   13835            0 :         continue;
   13836     37713672 :       tree attrs = TYPE_ATTRIBUTES (fntype);
   13837     37713672 :       if (!attrs)
   13838     37475961 :         continue;
   13839              : 
   13840       237711 :       attr_access::free_lang_data (attrs);
   13841              :     }
   13842       109695 : }
   13843              : 
   13844              : /* Perform any final parser cleanups and generate initial debugging
   13845              :    information.  */
   13846              : 
   13847              : void
   13848       110068 : c_parse_final_cleanups (void)
   13849              : {
   13850       110068 :   tree t;
   13851       110068 :   unsigned i;
   13852              : 
   13853              :   /* We don't want to do this if generating a PCH.  */
   13854       110068 :   if (pch_file)
   13855       110068 :     return;
   13856              : 
   13857       109695 :   timevar_stop (TV_PHASE_PARSING);
   13858       109695 :   timevar_start (TV_PHASE_DEFERRED);
   13859              : 
   13860              :   /* Do the Objective-C stuff.  This is where all the Objective-C
   13861              :      module stuff gets generated (symtab, class/protocol/selector
   13862              :      lists etc).  */
   13863       109695 :   if (c_dialect_objc ())
   13864            0 :     objc_write_global_declarations ();
   13865              : 
   13866              :   /* Close the external scope.  */
   13867       109695 :   ext_block = pop_scope ();
   13868       109695 :   external_scope = 0;
   13869       109695 :   gcc_assert (!current_scope);
   13870              : 
   13871              :   /* Handle -fdump-ada-spec[-slim]. */
   13872       109695 :   if (flag_dump_ada_spec || flag_dump_ada_spec_slim)
   13873              :     {
   13874              :       /* Build a table of files to generate specs for */
   13875           15 :       collect_source_ref (main_input_filename);
   13876           15 :       if (!flag_dump_ada_spec_slim)
   13877           15 :         collect_source_refs ();
   13878              : 
   13879           15 :       dump_ada_specs (collect_all_refs, NULL);
   13880              :     }
   13881              : 
   13882              :   /* Process all file scopes in this compilation, and the external_scope,
   13883              :      through wrapup_global_declarations.  */
   13884       219390 :   FOR_EACH_VEC_ELT (*all_translation_units, i, t)
   13885       109695 :     c_write_global_declarations_1 (BLOCK_VARS (DECL_INITIAL (t)));
   13886       109695 :   c_write_global_declarations_1 (BLOCK_VARS (ext_block));
   13887              : 
   13888              :   /* Call this to set cpp_implicit_aliases_done on all nodes.  This is
   13889              :      important for function multiversioning aliases to get resolved.  */
   13890       109695 :   symtab->process_same_body_aliases ();
   13891              : 
   13892       109695 :   if (!in_lto_p)
   13893       109695 :     free_attr_access_data ();
   13894              : 
   13895       109695 :   timevar_stop (TV_PHASE_DEFERRED);
   13896       109695 :   timevar_start (TV_PHASE_PARSING);
   13897              : 
   13898       109695 :   ext_block = NULL;
   13899              : }
   13900              : 
   13901              : /* Register reserved keyword WORD as qualifier for address space AS.  */
   13902              : 
   13903              : void
   13904       232082 : c_register_addr_space (const char *word, addr_space_t as)
   13905              : {
   13906       232082 :   int rid = RID_FIRST_ADDR_SPACE + as;
   13907       232082 :   tree id;
   13908              : 
   13909              :   /* Address space qualifiers are only supported
   13910              :      in C with GNU extensions enabled.  */
   13911       232082 :   if (c_dialect_objc () || flag_no_asm)
   13912              :     return;
   13913              : 
   13914       219338 :   id = get_identifier (word);
   13915       219338 :   C_SET_RID_CODE (id, rid);
   13916       219338 :   C_IS_RESERVED_WORD (id) = 1;
   13917       219338 :   ridpointers [rid] = id;
   13918              : }
   13919              : 
   13920              : /* Return identifier to look up for omp declare reduction.  */
   13921              : 
   13922              : tree
   13923         3391 : c_omp_reduction_id (enum tree_code reduction_code, tree reduction_id)
   13924              : {
   13925         3391 :   const char *p = NULL;
   13926         3391 :   switch (reduction_code)
   13927              :     {
   13928              :     case PLUS_EXPR: p = "+"; break;
   13929          279 :     case MULT_EXPR: p = "*"; break;
   13930          167 :     case MINUS_EXPR: p = "-"; break;
   13931           37 :     case BIT_AND_EXPR: p = "&"; break;
   13932           20 :     case BIT_XOR_EXPR: p = "^"; break;
   13933           98 :     case BIT_IOR_EXPR: p = "|"; break;
   13934           77 :     case TRUTH_ANDIF_EXPR: p = "&&"; break;
   13935           88 :     case TRUTH_ORIF_EXPR: p = "||"; break;
   13936           56 :     case MIN_EXPR: p = "min"; break;
   13937           95 :     case MAX_EXPR: p = "max"; break;
   13938              :     default:
   13939              :       break;
   13940              :     }
   13941              : 
   13942          917 :   if (p == NULL)
   13943              :     {
   13944          217 :       if (TREE_CODE (reduction_id) != IDENTIFIER_NODE)
   13945            0 :         return error_mark_node;
   13946          217 :       p = IDENTIFIER_POINTER (reduction_id);
   13947              :     }
   13948              : 
   13949         3391 :   const char prefix[] = "omp declare reduction ";
   13950         3391 :   size_t lenp = sizeof (prefix);
   13951         3391 :   size_t len = strlen (p);
   13952         3391 :   char *name = XALLOCAVEC (char, lenp + len);
   13953         3391 :   memcpy (name, prefix, lenp - 1);
   13954         3391 :   memcpy (name + lenp - 1, p, len + 1);
   13955         3391 :   return get_identifier (name);
   13956              : }
   13957              : 
   13958              : /* Lookup REDUCTION_ID in the current scope, or create an artificial
   13959              :    VAR_DECL, bind it into the current scope and return it.  */
   13960              : 
   13961              : tree
   13962          164 : c_omp_reduction_decl (tree reduction_id)
   13963              : {
   13964          164 :   struct c_binding *b = I_SYMBOL_BINDING (reduction_id);
   13965          164 :   if (b != NULL && B_IN_CURRENT_SCOPE (b))
   13966           47 :     return b->decl;
   13967              : 
   13968          117 :   tree decl = build_decl (BUILTINS_LOCATION, VAR_DECL,
   13969              :                           reduction_id, integer_type_node);
   13970          117 :   DECL_ARTIFICIAL (decl) = 1;
   13971          117 :   DECL_EXTERNAL (decl) = 1;
   13972          117 :   TREE_STATIC (decl) = 1;
   13973          117 :   TREE_PUBLIC (decl) = 0;
   13974          117 :   bind (reduction_id, decl, current_scope, true, false, BUILTINS_LOCATION);
   13975          117 :   return decl;
   13976              : }
   13977              : 
   13978              : /* Lookup REDUCTION_ID in the first scope where it has entry for TYPE.  */
   13979              : 
   13980              : tree
   13981          278 : c_omp_reduction_lookup (tree reduction_id, tree type)
   13982              : {
   13983          278 :   struct c_binding *b = I_SYMBOL_BINDING (reduction_id);
   13984          281 :   while (b)
   13985              :     {
   13986          279 :       tree t;
   13987          299 :       for (t = DECL_INITIAL (b->decl); t; t = TREE_CHAIN (t))
   13988          296 :         if (comptypes (TREE_PURPOSE (t), type))
   13989          276 :           return TREE_VALUE (t);
   13990            3 :       b = b->shadowed;
   13991              :     }
   13992            2 :   return error_mark_node;
   13993              : }
   13994              : 
   13995              : /* Helper function called via walk_tree, to diagnose invalid
   13996              :    #pragma omp declare reduction combiners or initializers.  */
   13997              : 
   13998              : tree
   13999         1430 : c_check_omp_declare_reduction_r (tree *tp, int *, void *data)
   14000              : {
   14001         1430 :   tree *vars = (tree *) data;
   14002         1430 :   if (SSA_VAR_P (*tp)
   14003          422 :       && !DECL_ARTIFICIAL (*tp)
   14004           24 :       && *tp != vars[0]
   14005           24 :       && *tp != vars[1])
   14006              :     {
   14007           24 :       location_t loc = DECL_SOURCE_LOCATION (vars[0]);
   14008           24 :       if (strcmp (IDENTIFIER_POINTER (DECL_NAME (vars[0])), "omp_out") == 0)
   14009           10 :         error_at (loc, "%<#pragma omp declare reduction%> combiner refers to "
   14010              :                        "variable %qD which is not %<omp_out%> nor %<omp_in%>",
   14011              :                   *tp);
   14012              :       else
   14013           14 :         error_at (loc, "%<#pragma omp declare reduction%> initializer refers "
   14014              :                        "to variable %qD which is not %<omp_priv%> nor "
   14015              :                        "%<omp_orig%>",
   14016              :                   *tp);
   14017           24 :       return *tp;
   14018              :     }
   14019              :   return NULL_TREE;
   14020              : }
   14021              : 
   14022              : /* Return identifier to look up for omp declare mapper.  */
   14023              : 
   14024              : tree
   14025          714 : c_omp_mapper_id (tree mapper_id)
   14026              : {
   14027          714 :   const char *p = NULL;
   14028              : 
   14029          714 :   const char prefix[] = "omp declare mapper ";
   14030              : 
   14031          714 :   if (mapper_id == NULL_TREE)
   14032              :     p = "<default>";
   14033           27 :   else if (TREE_CODE (mapper_id) == IDENTIFIER_NODE)
   14034           27 :     p = IDENTIFIER_POINTER (mapper_id);
   14035              :   else
   14036            0 :     return error_mark_node;
   14037              : 
   14038          714 :   size_t lenp = sizeof (prefix);
   14039          714 :   size_t len = strlen (p);
   14040          714 :   char *name = XALLOCAVEC (char, lenp + len);
   14041          714 :   memcpy (name, prefix, lenp - 1);
   14042          714 :   memcpy (name + lenp - 1, p, len + 1);
   14043          714 :   return get_identifier (name);
   14044              : }
   14045              : 
   14046              : /* Lookup MAPPER_ID in the current scope, or create an artificial
   14047              :    VAR_DECL, bind it into the current scope and return it.  */
   14048              : 
   14049              : tree
   14050           74 : c_omp_mapper_decl (tree mapper_id)
   14051              : {
   14052           74 :   struct c_binding *b = I_SYMBOL_BINDING (mapper_id);
   14053           74 :   if (b != NULL && B_IN_CURRENT_SCOPE (b))
   14054           22 :     return b->decl;
   14055              : 
   14056           52 :   tree decl = build_decl (BUILTINS_LOCATION, VAR_DECL,
   14057              :                           mapper_id, integer_type_node);
   14058           52 :   DECL_ARTIFICIAL (decl) = 1;
   14059           52 :   DECL_EXTERNAL (decl) = 1;
   14060           52 :   TREE_STATIC (decl) = 1;
   14061           52 :   TREE_PUBLIC (decl) = 0;
   14062           52 :   bind (mapper_id, decl, current_scope, true, false, BUILTINS_LOCATION);
   14063           52 :   return decl;
   14064              : }
   14065              : 
   14066              : /* Lookup MAPPER_ID in the first scope where it has entry for TYPE.  */
   14067              : 
   14068              : tree
   14069         6420 : c_omp_mapper_lookup (tree mapper_id, tree type)
   14070              : {
   14071         6420 :   if (!RECORD_OR_UNION_TYPE_P (type))
   14072              :     return NULL_TREE;
   14073              : 
   14074          640 :   mapper_id = c_omp_mapper_id (mapper_id);
   14075              : 
   14076          640 :   struct c_binding *b = I_SYMBOL_BINDING (mapper_id);
   14077          646 :   while (b)
   14078              :     {
   14079          129 :       tree t;
   14080          148 :       for (t = DECL_INITIAL (b->decl); t; t = TREE_CHAIN (t))
   14081          142 :         if (comptypes (TREE_PURPOSE (t), type))
   14082          123 :           return TREE_VALUE (t);
   14083            6 :       b = b->shadowed;
   14084              :     }
   14085              :   return NULL_TREE;
   14086              : }
   14087              : 
   14088              : /* For C, we record a pointer to the mapper itself without wrapping it in an
   14089              :    artificial function or similar.  So, just return it.  */
   14090              : 
   14091              : tree
   14092          115 : c_omp_extract_mapper_directive (tree mapper)
   14093              : {
   14094          115 :   return mapper;
   14095              : }
   14096              : 
   14097              : /* For now we can handle singleton OMP_ARRAY_SECTIONs with custom mappers, but
   14098              :    nothing more complicated.  */
   14099              : 
   14100              : tree
   14101          608 : c_omp_map_array_section (location_t loc, tree t)
   14102              : {
   14103          608 :   tree low = TREE_OPERAND (t, 1);
   14104          608 :   tree len = TREE_OPERAND (t, 2);
   14105              : 
   14106          608 :   if (len && integer_onep (len))
   14107              :     {
   14108          123 :       t = TREE_OPERAND (t, 0);
   14109              : 
   14110          123 :       if (!low)
   14111           37 :         low = integer_zero_node;
   14112              : 
   14113          123 :       t = build_array_ref (loc, t, low);
   14114              :     }
   14115              : 
   14116          608 :   return t;
   14117              : }
   14118              : 
   14119              : /* Helper function for below function.  */
   14120              : 
   14121              : static tree
   14122        58726 : c_omp_scan_mapper_bindings_r (tree *tp, int *walk_subtrees, void *ptr)
   14123              : {
   14124        58726 :   tree t = *tp;
   14125        58726 :   omp_mapper_list<tree> *mlist = (omp_mapper_list<tree> *) ptr;
   14126        58726 :   tree aggr_type = NULL_TREE;
   14127              : 
   14128        58726 :   if (TREE_CODE (t) == SIZEOF_EXPR
   14129        58726 :       || TREE_CODE (t) == ALIGNOF_EXPR)
   14130              :     {
   14131            0 :       *walk_subtrees = 0;
   14132            0 :       return NULL_TREE;
   14133              :     }
   14134              : 
   14135        58726 :   if (TREE_CODE (t) == OMP_CLAUSE)
   14136              :     return NULL_TREE;
   14137              : 
   14138        54941 :   if (TREE_CODE (t) == COMPONENT_REF
   14139        54941 :       && RECORD_OR_UNION_TYPE_P (TREE_TYPE (TREE_OPERAND (t, 0))))
   14140          378 :     aggr_type = TREE_TYPE (TREE_OPERAND (t, 0));
   14141        54563 :   else if ((TREE_CODE (t) == VAR_DECL
   14142              :             || TREE_CODE (t) == PARM_DECL
   14143              :             || TREE_CODE (t) == RESULT_DECL)
   14144         6357 :            && RECORD_OR_UNION_TYPE_P (TREE_TYPE (t)))
   14145          125 :     aggr_type = TREE_TYPE (t);
   14146              : 
   14147          503 :   if (aggr_type)
   14148              :     {
   14149          503 :       tree mapper_fn = c_omp_mapper_lookup (NULL_TREE, aggr_type);
   14150          503 :       if (mapper_fn)
   14151           76 :         mlist->add_mapper (NULL_TREE, aggr_type, mapper_fn);
   14152              :     }
   14153              : 
   14154              :   return NULL_TREE;
   14155              : }
   14156              : 
   14157              : /* Scan an offload region's body, and record uses of struct- or union-typed
   14158              :    variables.  Add _mapper_binding_ fake clauses to *CLAUSES_PTR.  */
   14159              : 
   14160              : void
   14161         2337 : c_omp_scan_mapper_bindings (location_t loc, tree *clauses_ptr, tree body)
   14162              : {
   14163         2337 :   hash_set<omp_name_type<tree>> seen_types;
   14164         2337 :   auto_vec<tree> mappers;
   14165         2337 :   omp_mapper_list<tree> mlist (&seen_types, &mappers);
   14166              : 
   14167         2337 :   walk_tree_without_duplicates (&body, c_omp_scan_mapper_bindings_r, &mlist);
   14168              : 
   14169         2337 :   unsigned int i;
   14170         2337 :   tree mapper;
   14171         4716 :   FOR_EACH_VEC_ELT (mappers, i, mapper)
   14172           42 :     c_omp_find_nested_mappers (&mlist, mapper);
   14173              : 
   14174         2408 :   FOR_EACH_VEC_ELT (mappers, i, mapper)
   14175              :     {
   14176           42 :       if (mapper == error_mark_node)
   14177            0 :         continue;
   14178           42 :       tree mapper_name = OMP_DECLARE_MAPPER_ID (mapper);
   14179           42 :       tree decl = OMP_DECLARE_MAPPER_DECL (mapper);
   14180              : 
   14181           42 :       tree c = build_omp_clause (loc, OMP_CLAUSE__MAPPER_BINDING_);
   14182           42 :       OMP_CLAUSE__MAPPER_BINDING__ID (c) = mapper_name;
   14183           42 :       OMP_CLAUSE__MAPPER_BINDING__DECL (c) = decl;
   14184           42 :       OMP_CLAUSE__MAPPER_BINDING__MAPPER (c) = mapper;
   14185              : 
   14186           42 :       OMP_CLAUSE_CHAIN (c) = *clauses_ptr;
   14187           42 :       *clauses_ptr = c;
   14188              :     }
   14189         2337 : }
   14190              : 
   14191              : bool
   14192          329 : c_check_in_current_scope (tree decl)
   14193              : {
   14194          329 :   struct c_binding *b = I_SYMBOL_BINDING (DECL_NAME (decl));
   14195          329 :   return b != NULL && B_IN_CURRENT_SCOPE (b);
   14196              : }
   14197              : 
   14198              : /* Search for loop or switch names.  BEFORE_LABELS is last statement before
   14199              :    possible labels and SWITCH_P true for a switch, false for loops.
   14200              :    Searches through last statements in cur_stmt_list, stops when seeing
   14201              :    BEFORE_LABELs, or statement other than LABEL_EXPR or CASE_LABEL_EXPR.
   14202              :    Returns number of loop/switch names found and if any are found, sets
   14203              :    *LAST_P to the canonical loop/switch name LABEL_DECL.  */
   14204              : 
   14205              : int
   14206       531246 : c_get_loop_names (tree before_labels, bool switch_p, tree *last_p)
   14207              : {
   14208       531246 :   *last_p = NULL_TREE;
   14209      1062492 :   if (!building_stmt_list_p ()
   14210       531246 :       || !STATEMENT_LIST_HAS_LABEL (cur_stmt_list)
   14211       552082 :       || before_labels == void_list_node)
   14212              :     return 0;
   14213              : 
   14214        20836 :   int ret = 0;
   14215        20836 :   tree last = NULL_TREE;
   14216        20836 :   for (tree_stmt_iterator tsi = tsi_last (cur_stmt_list);
   14217        29199 :        !tsi_end_p (tsi); tsi_prev (&tsi))
   14218              :     {
   14219        28333 :       tree stmt = tsi_stmt (tsi);
   14220        28333 :       if (stmt == before_labels)
   14221              :         break;
   14222         8363 :       else if (TREE_CODE (stmt) == LABEL_EXPR)
   14223              :         {
   14224         1181 :           if (last == NULL_TREE)
   14225          987 :             last = LABEL_EXPR_LABEL (stmt);
   14226              :           else
   14227              :             {
   14228          194 :               loop_names.safe_push (LABEL_EXPR_LABEL (stmt));
   14229          194 :               ++ret;
   14230              :             }
   14231              :         }
   14232         7182 :       else if (TREE_CODE (stmt) != CASE_LABEL_EXPR
   14233         4844 :                && TREE_CODE (stmt) != DEBUG_BEGIN_STMT)
   14234              :         break;
   14235              :     }
   14236        20836 :   if (last)
   14237              :     {
   14238          987 :       if (switch_p)
   14239          163 :         C_DECL_SWITCH_NAME (last) = 1;
   14240              :       else
   14241          824 :         C_DECL_LOOP_NAME (last) = 1;
   14242          987 :       loop_names.safe_push (last);
   14243          987 :       ++ret;
   14244          987 :       if (loop_names.length () > 16)
   14245              :         {
   14246           20 :           unsigned int first = 0, i;
   14247           20 :           tree l, c = NULL_TREE;
   14248           20 :           if (loop_names_hash == NULL)
   14249            8 :             loop_names_hash = new decl_tree_map (ret);
   14250              :           else
   14251           12 :             first = loop_names.length () - ret;
   14252          210 :           FOR_EACH_VEC_ELT_REVERSE (loop_names, i, l)
   14253              :             {
   14254          170 :               if (C_DECL_LOOP_NAME (l) || C_DECL_SWITCH_NAME (l))
   14255           48 :                 c = l;
   14256          170 :               gcc_checking_assert (c);
   14257          170 :               loop_names_hash->put (l, c);
   14258          170 :               if (i == first)
   14259              :                 break;
   14260              :             }
   14261              :         }
   14262          987 :       *last_p = last;
   14263              :     }
   14264              :   return ret;
   14265              : }
   14266              : 
   14267              : /* Undoes what get_loop_names did when it returned NUM_NAMES.  */
   14268              : 
   14269              : void
   14270          987 : c_release_loop_names (int num_names)
   14271              : {
   14272          987 :   unsigned len = loop_names.length () - num_names;
   14273          987 :   if (loop_names_hash)
   14274              :     {
   14275           20 :       if (len <= 16)
   14276              :         {
   14277            8 :           delete loop_names_hash;
   14278            8 :           loop_names_hash = NULL;
   14279              :         }
   14280              :       else
   14281              :         {
   14282           12 :           unsigned int i;
   14283           12 :           tree l;
   14284           42 :           FOR_EACH_VEC_ELT_REVERSE (loop_names, i, l)
   14285              :             {
   14286           30 :               loop_names_hash->remove (l);
   14287           30 :               if (i == len)
   14288              :                 break;
   14289              :             }
   14290              :         }
   14291              :     }
   14292          987 :   loop_names.truncate (len);
   14293          987 : }
   14294              : 
   14295              : /* Finish processing of break or continue identifier operand.
   14296              :    NAME is the identifier operand of break or continue and
   14297              :    IS_BREAK is true iff it is break stmt.  Returns the operand
   14298              :    to use for BREAK_STMT or CONTINUE_STMT, either NULL_TREE or
   14299              :    canonical loop/switch name LABEL_DECL.  */
   14300              : 
   14301              : tree
   14302          316 : c_finish_bc_name (location_t loc, tree name, bool is_break)
   14303              : {
   14304          316 :   tree label = NULL_TREE, lab;
   14305          457 :   pedwarn_c23 (loc, OPT_Wpedantic,
   14306              :                "ISO C does not support %qs statement with an identifier "
   14307              :                "operand before C2Y", is_break ? "break" : "continue");
   14308              : 
   14309              :   /* If I_LABEL_DECL is NULL or not from current function, don't waste time
   14310              :      trying to find it among loop_names, it can't be there.  */
   14311          316 :   if (!loop_names.is_empty ()
   14312          296 :       && current_function_scope
   14313          296 :       && (lab = I_LABEL_DECL (name))
   14314          290 :       && DECL_CONTEXT (lab) == current_function_decl)
   14315              :     {
   14316          280 :       unsigned int i;
   14317          280 :       tree l, c = NULL_TREE;
   14318          280 :       if (loop_names_hash)
   14319              :         {
   14320           86 :           if (tree *val = loop_names_hash->get (lab))
   14321           86 :             label = *val;
   14322              :         }
   14323              :       else
   14324          565 :         FOR_EACH_VEC_ELT_REVERSE (loop_names, i, l)
   14325              :           {
   14326          363 :             if (C_DECL_LOOP_NAME (l) || C_DECL_SWITCH_NAME (l))
   14327              :               c = l;
   14328          363 :             gcc_checking_assert (c);
   14329          363 :             if (l == lab)
   14330              :               {
   14331              :                 label = c;
   14332              :                 break;
   14333              :               }
   14334              :           }
   14335          280 :       if (label)
   14336          272 :         TREE_USED (lab) = 1;
   14337              :     }
   14338          272 :   if (label == NULL_TREE)
   14339              :     {
   14340           44 :       auto_vec<const char *> candidates;
   14341           44 :       unsigned int i;
   14342           44 :       tree l, c = NULL_TREE;
   14343          115 :       FOR_EACH_VEC_ELT_REVERSE (loop_names, i, l)
   14344              :         {
   14345           28 :           if (C_DECL_LOOP_NAME (l) || C_DECL_SWITCH_NAME (l))
   14346              :             c = l;
   14347           28 :           gcc_checking_assert (c);
   14348           42 :           if (is_break || C_DECL_LOOP_NAME (c))
   14349           25 :             candidates.safe_push (IDENTIFIER_POINTER (DECL_NAME (l)));
   14350              :         }
   14351           44 :       const char *hint = find_closest_string (IDENTIFIER_POINTER (name),
   14352              :                                               &candidates);
   14353           44 :       if (hint)
   14354              :         {
   14355           22 :           gcc_rich_location richloc (loc);
   14356           22 :           richloc.add_fixit_replace (hint);
   14357           22 :           if (is_break)
   14358           11 :             error_at (&richloc, "%<break%> statement operand %qE does not "
   14359              :                                 "refer to a named loop or %<switch%>; "
   14360              :                                 "did you mean %qs?", name, hint);
   14361              :           else
   14362           11 :             error_at (&richloc, "%<continue%> statement operand %qE does not "
   14363              :                                 "refer to a named loop; did you mean %qs?",
   14364              :                       name, hint);
   14365           22 :         }
   14366           22 :       else if (is_break)
   14367           12 :         error_at (loc, "%<break%> statement operand %qE does not refer to a "
   14368              :                        "named loop or %<switch%>", name);
   14369              :       else
   14370           10 :         error_at (loc, "%<continue%> statement operand %qE does not refer to "
   14371              :                        "a named loop", name);
   14372           44 :     }
   14373          272 :   else if (!C_DECL_LOOP_NAME (label) && !is_break)
   14374              :     {
   14375            2 :       auto_diagnostic_group d;
   14376            2 :       error_at (loc, "%<continue%> statement operand %qE refers to a named "
   14377              :                      "%<switch%>", name);
   14378            2 :       inform (DECL_SOURCE_LOCATION (label), "%<switch%> name defined here");
   14379            2 :       label = NULL_TREE;
   14380            2 :     }
   14381          270 :   else if (!C_DECL_LOOP_SWITCH_NAME_VALID (label))
   14382              :     {
   14383           18 :       auto_diagnostic_group d;
   14384           18 :       if (C_DECL_LOOP_NAME (label))
   14385              :         {
   14386           16 :           error_at (loc, "%qs statement operand %qE refers to a loop outside "
   14387              :                          "of its body", is_break ? "break" : "continue", name);
   14388           16 :           inform (DECL_SOURCE_LOCATION (label), "loop name defined here");
   14389              :         }
   14390              :       else
   14391              :         {
   14392            2 :           error_at (loc, "%<break%> statement operand %qE refers to a "
   14393              :                          "%<switch%> outside of its body", name);
   14394            2 :           inform (DECL_SOURCE_LOCATION (label),
   14395              :                   "%<switch%> name defined here");
   14396              :         }
   14397           18 :       label = NULL_TREE;
   14398           18 :     }
   14399          252 :   else if (label == loop_names.last () && (in_statement & IN_NAMED_STMT) != 0)
   14400              :     /* If it is just a fancy reference to the innermost construct, handle it
   14401              :        just like break; or continue; though tracking cheaply what is the
   14402              :        innermost loop for continue when nested in switches would require
   14403              :        another global variable and updating it.  */
   14404              :     label = NULL_TREE;
   14405              :   else
   14406           98 :     C_DECL_LOOP_SWITCH_NAME_USED (label) = 1;
   14407          316 :   return label;
   14408              : }
   14409              : 
   14410              : #include "gt-c-c-decl.h"
        

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