LCOV - code coverage report
Current view: top level - gcc/c - c-decl.c (source / functions) Hit Total Coverage
Test: gcc.info Lines: 4838 5315 91.0 %
Date: 2020-03-28 11:57:23 Functions: 140 155 90.3 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* Process declarations and variables for C compiler.
       2                 :            :    Copyright (C) 1988-2020 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_UNIQUE_PTR
      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                 :            : 
      61                 :            : /* In grokdeclarator, distinguish syntactic contexts of declarators.  */
      62                 :            : enum decl_context
      63                 :            : { NORMAL,                       /* Ordinary declaration */
      64                 :            :   FUNCDEF,                      /* Function definition */
      65                 :            :   PARM,                         /* Declaration of parm before function body */
      66                 :            :   FIELD,                        /* Declaration inside struct or union */
      67                 :            :   TYPENAME};                    /* Typename (inside cast or sizeof)  */
      68                 :            : 
      69                 :            : /* States indicating how grokdeclarator() should handle declspecs marked
      70                 :            :    with __attribute__((deprecated)).  An object declared as
      71                 :            :    __attribute__((deprecated)) suppresses warnings of uses of other
      72                 :            :    deprecated items.  */
      73                 :            : 
      74                 :            : enum deprecated_states {
      75                 :            :   DEPRECATED_NORMAL,
      76                 :            :   DEPRECATED_SUPPRESS
      77                 :            : };
      78                 :            : 
      79                 :            : 
      80                 :            : /* Nonzero if we have seen an invalid cross reference
      81                 :            :    to a struct, union, or enum, but not yet printed the message.  */
      82                 :            : tree pending_invalid_xref;
      83                 :            : 
      84                 :            : /* File and line to appear in the eventual error message.  */
      85                 :            : location_t pending_invalid_xref_location;
      86                 :            : 
      87                 :            : /* The file and line that the prototype came from if this is an
      88                 :            :    old-style definition; used for diagnostics in
      89                 :            :    store_parm_decls_oldstyle.  */
      90                 :            : 
      91                 :            : static location_t current_function_prototype_locus;
      92                 :            : 
      93                 :            : /* Whether this prototype was built-in.  */
      94                 :            : 
      95                 :            : static bool current_function_prototype_built_in;
      96                 :            : 
      97                 :            : /* The argument type information of this prototype.  */
      98                 :            : 
      99                 :            : static tree current_function_prototype_arg_types;
     100                 :            : 
     101                 :            : /* The argument information structure for the function currently being
     102                 :            :    defined.  */
     103                 :            : 
     104                 :            : static struct c_arg_info *current_function_arg_info;
     105                 :            : 
     106                 :            : /* The obstack on which parser and related data structures, which are
     107                 :            :    not live beyond their top-level declaration or definition, are
     108                 :            :    allocated.  */
     109                 :            : struct obstack parser_obstack;
     110                 :            : 
     111                 :            : /* The current statement tree.  */
     112                 :            : 
     113                 :            : static GTY(()) struct stmt_tree_s c_stmt_tree;
     114                 :            : 
     115                 :            : /* State saving variables.  */
     116                 :            : tree c_break_label;
     117                 :            : tree c_cont_label;
     118                 :            : 
     119                 :            : /* A list of decls to be made automatically visible in each file scope.  */
     120                 :            : static GTY(()) tree visible_builtins;
     121                 :            : 
     122                 :            : /* Set to 0 at beginning of a function definition, set to 1 if
     123                 :            :    a return statement that specifies a return value is seen.  */
     124                 :            : 
     125                 :            : int current_function_returns_value;
     126                 :            : 
     127                 :            : /* Set to 0 at beginning of a function definition, set to 1 if
     128                 :            :    a return statement with no argument is seen.  */
     129                 :            : 
     130                 :            : int current_function_returns_null;
     131                 :            : 
     132                 :            : /* Set to 0 at beginning of a function definition, set to 1 if
     133                 :            :    a call to a noreturn function is seen.  */
     134                 :            : 
     135                 :            : int current_function_returns_abnormally;
     136                 :            : 
     137                 :            : /* Set to nonzero by `grokdeclarator' for a function
     138                 :            :    whose return type is defaulted, if warnings for this are desired.  */
     139                 :            : 
     140                 :            : static int warn_about_return_type;
     141                 :            : 
     142                 :            : /* Nonzero when the current toplevel function contains a declaration
     143                 :            :    of a nested function which is never defined.  */
     144                 :            : 
     145                 :            : static bool undef_nested_function;
     146                 :            : 
     147                 :            : /* If non-zero, implicit "omp declare target" attribute is added into the
     148                 :            :    attribute lists.  */
     149                 :            : int current_omp_declare_target_attribute;
     150                 :            : 
     151                 :            : /* Each c_binding structure describes one binding of an identifier to
     152                 :            :    a decl.  All the decls in a scope - irrespective of namespace - are
     153                 :            :    chained together by the ->prev field, which (as the name implies)
     154                 :            :    runs in reverse order.  All the decls in a given namespace bound to
     155                 :            :    a given identifier are chained by the ->shadowed field, which runs
     156                 :            :    from inner to outer scopes.
     157                 :            : 
     158                 :            :    The ->decl field usually points to a DECL node, but there are two
     159                 :            :    exceptions.  In the namespace of type tags, the bound entity is a
     160                 :            :    RECORD_TYPE, UNION_TYPE, or ENUMERAL_TYPE node.  If an undeclared
     161                 :            :    identifier is encountered, it is bound to error_mark_node to
     162                 :            :    suppress further errors about that identifier in the current
     163                 :            :    function.
     164                 :            : 
     165                 :            :    The ->u.type field stores the type of the declaration in this scope;
     166                 :            :    if NULL, the type is the type of the ->decl field.  This is only of
     167                 :            :    relevance for objects with external or internal linkage which may
     168                 :            :    be redeclared in inner scopes, forming composite types that only
     169                 :            :    persist for the duration of those scopes.  In the external scope,
     170                 :            :    this stores the composite of all the types declared for this
     171                 :            :    object, visible or not.  The ->inner_comp field (used only at file
     172                 :            :    scope) stores whether an incomplete array type at file scope was
     173                 :            :    completed at an inner scope to an array size other than 1.
     174                 :            : 
     175                 :            :    The ->u.label field is used for labels.  It points to a structure
     176                 :            :    which stores additional information used for warnings.
     177                 :            : 
     178                 :            :    The depth field is copied from the scope structure that holds this
     179                 :            :    decl.  It is used to preserve the proper ordering of the ->shadowed
     180                 :            :    field (see bind()) and also for a handful of special-case checks.
     181                 :            :    Finally, the invisible bit is true for a decl which should be
     182                 :            :    ignored for purposes of normal name lookup, and the nested bit is
     183                 :            :    true for a decl that's been bound a second time in an inner scope;
     184                 :            :    in all such cases, the binding in the outer scope will have its
     185                 :            :    invisible bit true.  */
     186                 :            : 
     187                 :            : struct GTY((chain_next ("%h.prev"))) c_binding {
     188                 :            :   union GTY(()) {               /* first so GTY desc can use decl */
     189                 :            :     tree GTY((tag ("0"))) type; /* the type in this scope */
     190                 :            :     struct c_label_vars * GTY((tag ("1"))) label; /* for warnings */
     191                 :            :   } GTY((desc ("TREE_CODE (%0.decl) == LABEL_DECL"))) u;
     192                 :            :   tree decl;                    /* the decl bound */
     193                 :            :   tree id;                      /* the identifier it's bound to */
     194                 :            :   struct c_binding *prev;       /* the previous decl in this scope */
     195                 :            :   struct c_binding *shadowed;   /* the innermost decl shadowed by this one */
     196                 :            :   unsigned int depth : 28;      /* depth of this scope */
     197                 :            :   BOOL_BITFIELD invisible : 1;  /* normal lookup should ignore this binding */
     198                 :            :   BOOL_BITFIELD nested : 1;     /* do not set DECL_CONTEXT when popping */
     199                 :            :   BOOL_BITFIELD inner_comp : 1; /* incomplete array completed in inner scope */
     200                 :            :   BOOL_BITFIELD in_struct : 1;  /* currently defined as struct field */
     201                 :            :   location_t locus;             /* location for nested bindings */
     202                 :            : };
     203                 :            : #define B_IN_SCOPE(b1, b2) ((b1)->depth == (b2)->depth)
     204                 :            : #define B_IN_CURRENT_SCOPE(b) ((b)->depth == current_scope->depth)
     205                 :            : #define B_IN_FILE_SCOPE(b) ((b)->depth == 1 /*file_scope->depth*/)
     206                 :            : #define B_IN_EXTERNAL_SCOPE(b) ((b)->depth == 0 /*external_scope->depth*/)
     207                 :            : 
     208                 :            : /* Each C symbol points to three linked lists of c_binding structures.
     209                 :            :    These describe the values of the identifier in the three different
     210                 :            :    namespaces defined by the language.  */
     211                 :            : 
     212                 :            : struct GTY(()) lang_identifier {
     213                 :            :   struct c_common_identifier common_id;
     214                 :            :   struct c_binding *symbol_binding; /* vars, funcs, constants, typedefs */
     215                 :            :   struct c_binding *tag_binding;    /* struct/union/enum tags */
     216                 :            :   struct c_binding *label_binding;  /* labels */
     217                 :            : };
     218                 :            : 
     219                 :            : /* Validate c-lang.c's assumptions.  */
     220                 :            : extern char C_SIZEOF_STRUCT_LANG_IDENTIFIER_isnt_accurate
     221                 :            : [(sizeof(struct lang_identifier) == C_SIZEOF_STRUCT_LANG_IDENTIFIER) ? 1 : -1];
     222                 :            : 
     223                 :            : /* The binding oracle; see c-tree.h.  */
     224                 :            : void (*c_binding_oracle) (enum c_oracle_request, tree identifier);
     225                 :            : 
     226                 :            : /* This flag is set on an identifier if we have previously asked the
     227                 :            :    binding oracle for this identifier's symbol binding.  */
     228                 :            : #define I_SYMBOL_CHECKED(node) \
     229                 :            :   (TREE_LANG_FLAG_4 (IDENTIFIER_NODE_CHECK (node)))
     230                 :            : 
     231                 :            : static inline struct c_binding* *
     232                 : 2415520000 : i_symbol_binding (tree node)
     233                 :            : {
     234                 : 2415520000 :   struct lang_identifier *lid
     235                 : 2415520000 :     = (struct lang_identifier *) IDENTIFIER_NODE_CHECK (node);
     236                 :            : 
     237                 : 2415520000 :   if (lid->symbol_binding == NULL
     238                 :  869878000 :       && c_binding_oracle != NULL
     239                 : 2415520000 :       && !I_SYMBOL_CHECKED (node))
     240                 :            :     {
     241                 :            :       /* Set the "checked" flag first, to avoid infinite recursion
     242                 :            :          when the binding oracle calls back into gcc.  */
     243                 :          0 :       I_SYMBOL_CHECKED (node) = 1;
     244                 :          0 :       c_binding_oracle (C_ORACLE_SYMBOL, node);
     245                 :            :     }
     246                 :            : 
     247                 : 2415520000 :   return &lid->symbol_binding;
     248                 :            : }
     249                 :            : 
     250                 :            : #define I_SYMBOL_BINDING(node) (*i_symbol_binding (node))
     251                 :            : 
     252                 :            : #define I_SYMBOL_DECL(node) \
     253                 :            :  (I_SYMBOL_BINDING(node) ? I_SYMBOL_BINDING(node)->decl : 0)
     254                 :            : 
     255                 :            : /* This flag is set on an identifier if we have previously asked the
     256                 :            :    binding oracle for this identifier's tag binding.  */
     257                 :            : #define I_TAG_CHECKED(node) \
     258                 :            :   (TREE_LANG_FLAG_5 (IDENTIFIER_NODE_CHECK (node)))
     259                 :            : 
     260                 :            : static inline struct c_binding **
     261                 :    3018180 : i_tag_binding (tree node)
     262                 :            : {
     263                 :    3018180 :   struct lang_identifier *lid
     264                 :    3018180 :     = (struct lang_identifier *) IDENTIFIER_NODE_CHECK (node);
     265                 :            : 
     266                 :    3018180 :   if (lid->tag_binding == NULL
     267                 :     953921 :       && c_binding_oracle != NULL
     268                 :    3018180 :       && !I_TAG_CHECKED (node))
     269                 :            :     {
     270                 :            :       /* Set the "checked" flag first, to avoid infinite recursion
     271                 :            :          when the binding oracle calls back into gcc.  */
     272                 :          0 :       I_TAG_CHECKED (node) = 1;
     273                 :          0 :       c_binding_oracle (C_ORACLE_TAG, node);
     274                 :            :     }
     275                 :            : 
     276                 :    3018180 :   return &lid->tag_binding;
     277                 :            : }
     278                 :            : 
     279                 :            : #define I_TAG_BINDING(node) (*i_tag_binding (node))
     280                 :            : 
     281                 :            : #define I_TAG_DECL(node) \
     282                 :            :  (I_TAG_BINDING(node) ? I_TAG_BINDING(node)->decl : 0)
     283                 :            : 
     284                 :            : /* This flag is set on an identifier if we have previously asked the
     285                 :            :    binding oracle for this identifier's label binding.  */
     286                 :            : #define I_LABEL_CHECKED(node) \
     287                 :            :   (TREE_LANG_FLAG_6 (IDENTIFIER_NODE_CHECK (node)))
     288                 :            : 
     289                 :            : static inline struct c_binding **
     290                 :     337333 : i_label_binding (tree node)
     291                 :            : {
     292                 :     337333 :   struct lang_identifier *lid
     293                 :     337333 :     = (struct lang_identifier *) IDENTIFIER_NODE_CHECK (node);
     294                 :            : 
     295                 :     337333 :   if (lid->label_binding == NULL
     296                 :      42324 :       && c_binding_oracle != NULL
     297                 :     337333 :       && !I_LABEL_CHECKED (node))
     298                 :            :     {
     299                 :            :       /* Set the "checked" flag first, to avoid infinite recursion
     300                 :            :          when the binding oracle calls back into gcc.  */
     301                 :          0 :       I_LABEL_CHECKED (node) = 1;
     302                 :          0 :       c_binding_oracle (C_ORACLE_LABEL, node);
     303                 :            :     }
     304                 :            : 
     305                 :     337333 :   return &lid->label_binding;
     306                 :            : }
     307                 :            : 
     308                 :            : #define I_LABEL_BINDING(node) (*i_label_binding (node))
     309                 :            : 
     310                 :            : #define I_LABEL_DECL(node) \
     311                 :            :  (I_LABEL_BINDING(node) ? I_LABEL_BINDING(node)->decl : 0)
     312                 :            : 
     313                 :            : /* The resulting tree type.  */
     314                 :            : 
     315                 :            : union GTY((desc ("TREE_CODE (&%h.generic) == IDENTIFIER_NODE"),
     316                 :            :        chain_next ("(union lang_tree_node *) c_tree_chain_next (&%h.generic)"))) lang_tree_node
     317                 :            :  {
     318                 :            :   union tree_node GTY ((tag ("0"),
     319                 :            :                         desc ("tree_node_structure (&%h)")))
     320                 :            :     generic;
     321                 :            :   struct lang_identifier GTY ((tag ("1"))) identifier;
     322                 :            : };
     323                 :            : 
     324                 :            : /* Track bindings and other things that matter for goto warnings.  For
     325                 :            :    efficiency, we do not gather all the decls at the point of
     326                 :            :    definition.  Instead, we point into the bindings structure.  As
     327                 :            :    scopes are popped, we update these structures and gather the decls
     328                 :            :    that matter at that time.  */
     329                 :            : 
     330                 :            : struct GTY(()) c_spot_bindings {
     331                 :            :   /* The currently open scope which holds bindings defined when the
     332                 :            :      label was defined or the goto statement was found.  */
     333                 :            :   struct c_scope *scope;
     334                 :            :   /* The bindings in the scope field which were defined at the point
     335                 :            :      of the label or goto.  This lets us look at older or newer
     336                 :            :      bindings in the scope, as appropriate.  */
     337                 :            :   struct c_binding *bindings_in_scope;
     338                 :            :   /* The number of statement expressions that have started since this
     339                 :            :      label or goto statement was defined.  This is zero if we are at
     340                 :            :      the same statement expression level.  It is positive if we are in
     341                 :            :      a statement expression started since this spot.  It is negative
     342                 :            :      if this spot was in a statement expression and we have left
     343                 :            :      it.  */
     344                 :            :   int stmt_exprs;
     345                 :            :   /* Whether we started in a statement expression but are no longer in
     346                 :            :      it.  This is set to true if stmt_exprs ever goes negative.  */
     347                 :            :   bool left_stmt_expr;
     348                 :            : };
     349                 :            : 
     350                 :            : /* This structure is used to keep track of bindings seen when a goto
     351                 :            :    statement is defined.  This is only used if we see the goto
     352                 :            :    statement before we see the label.  */
     353                 :            : 
     354                 :            : struct GTY(()) c_goto_bindings {
     355                 :            :   /* The location of the goto statement.  */
     356                 :            :   location_t loc;
     357                 :            :   /* The bindings of the goto statement.  */
     358                 :            :   struct c_spot_bindings goto_bindings;
     359                 :            : };
     360                 :            : 
     361                 :            : typedef struct c_goto_bindings *c_goto_bindings_p;
     362                 :            : 
     363                 :            : /* The additional information we keep track of for a label binding.
     364                 :            :    These fields are updated as scopes are popped.  */
     365                 :            : 
     366                 :            : struct GTY(()) c_label_vars {
     367                 :            :   /* The shadowed c_label_vars, when one label shadows another (which
     368                 :            :      can only happen using a __label__ declaration).  */
     369                 :            :   struct c_label_vars *shadowed;
     370                 :            :   /* The bindings when the label was defined.  */
     371                 :            :   struct c_spot_bindings label_bindings;
     372                 :            :   /* A list of decls that we care about: decls about which we should
     373                 :            :      warn if a goto branches to this label from later in the function.
     374                 :            :      Decls are added to this list as scopes are popped.  We only add
     375                 :            :      the decls that matter.  */
     376                 :            :   vec<tree, va_gc> *decls_in_scope;
     377                 :            :   /* A list of goto statements to this label.  This is only used for
     378                 :            :      goto statements seen before the label was defined, so that we can
     379                 :            :      issue appropriate warnings for them.  */
     380                 :            :   vec<c_goto_bindings_p, va_gc> *gotos;
     381                 :            : };
     382                 :            : 
     383                 :            : /* Each c_scope structure describes the complete contents of one
     384                 :            :    scope.  Four scopes are distinguished specially: the innermost or
     385                 :            :    current scope, the innermost function scope, the file scope (always
     386                 :            :    the second to outermost) and the outermost or external scope.
     387                 :            : 
     388                 :            :    Most declarations are recorded in the current scope.
     389                 :            : 
     390                 :            :    All normal label declarations are recorded in the innermost
     391                 :            :    function scope, as are bindings of undeclared identifiers to
     392                 :            :    error_mark_node.  (GCC permits nested functions as an extension,
     393                 :            :    hence the 'innermost' qualifier.)  Explicitly declared labels
     394                 :            :    (using the __label__ extension) appear in the current scope.
     395                 :            : 
     396                 :            :    Being in the file scope (current_scope == file_scope) causes
     397                 :            :    special behavior in several places below.  Also, under some
     398                 :            :    conditions the Objective-C front end records declarations in the
     399                 :            :    file scope even though that isn't the current scope.
     400                 :            : 
     401                 :            :    All declarations with external linkage are recorded in the external
     402                 :            :    scope, even if they aren't visible there; this models the fact that
     403                 :            :    such declarations are visible to the entire program, and (with a
     404                 :            :    bit of cleverness, see pushdecl) allows diagnosis of some violations
     405                 :            :    of C99 6.2.2p7 and 6.2.7p2:
     406                 :            : 
     407                 :            :      If, within the same translation unit, the same identifier appears
     408                 :            :      with both internal and external linkage, the behavior is
     409                 :            :      undefined.
     410                 :            : 
     411                 :            :      All declarations that refer to the same object or function shall
     412                 :            :      have compatible type; otherwise, the behavior is undefined.
     413                 :            : 
     414                 :            :    Initially only the built-in declarations, which describe compiler
     415                 :            :    intrinsic functions plus a subset of the standard library, are in
     416                 :            :    this scope.
     417                 :            : 
     418                 :            :    The order of the blocks list matters, and it is frequently appended
     419                 :            :    to.  To avoid having to walk all the way to the end of the list on
     420                 :            :    each insertion, or reverse the list later, we maintain a pointer to
     421                 :            :    the last list entry.  (FIXME: It should be feasible to use a reversed
     422                 :            :    list here.)
     423                 :            : 
     424                 :            :    The bindings list is strictly in reverse order of declarations;
     425                 :            :    pop_scope relies on this.  */
     426                 :            : 
     427                 :            : 
     428                 :            : struct GTY((chain_next ("%h.outer"))) c_scope {
     429                 :            :   /* The scope containing this one.  */
     430                 :            :   struct c_scope *outer;
     431                 :            : 
     432                 :            :   /* The next outermost function scope.  */
     433                 :            :   struct c_scope *outer_function;
     434                 :            : 
     435                 :            :   /* All bindings in this scope.  */
     436                 :            :   struct c_binding *bindings;
     437                 :            : 
     438                 :            :   /* For each scope (except the global one), a chain of BLOCK nodes
     439                 :            :      for all the scopes that were entered and exited one level down.  */
     440                 :            :   tree blocks;
     441                 :            :   tree blocks_last;
     442                 :            : 
     443                 :            :   /* The depth of this scope.  Used to keep the ->shadowed chain of
     444                 :            :      bindings sorted innermost to outermost.  */
     445                 :            :   unsigned int depth : 28;
     446                 :            : 
     447                 :            :   /* True if we are currently filling this scope with parameter
     448                 :            :      declarations.  */
     449                 :            :   BOOL_BITFIELD parm_flag : 1;
     450                 :            : 
     451                 :            :   /* True if we saw [*] in this scope.  Used to give an error messages
     452                 :            :      if these appears in a function definition.  */
     453                 :            :   BOOL_BITFIELD had_vla_unspec : 1;
     454                 :            : 
     455                 :            :   /* True if we already complained about forward parameter decls
     456                 :            :      in this scope.  This prevents double warnings on
     457                 :            :      foo (int a; int b; ...)  */
     458                 :            :   BOOL_BITFIELD warned_forward_parm_decls : 1;
     459                 :            : 
     460                 :            :   /* True if this is the outermost block scope of a function body.
     461                 :            :      This scope contains the parameters, the local variables declared
     462                 :            :      in the outermost block, and all the labels (except those in
     463                 :            :      nested functions, or declared at block scope with __label__).  */
     464                 :            :   BOOL_BITFIELD function_body : 1;
     465                 :            : 
     466                 :            :   /* True means make a BLOCK for this scope no matter what.  */
     467                 :            :   BOOL_BITFIELD keep : 1;
     468                 :            : 
     469                 :            :   /* True means that an unsuffixed float constant is _Decimal64.  */
     470                 :            :   BOOL_BITFIELD float_const_decimal64 : 1;
     471                 :            : 
     472                 :            :   /* True if this scope has any label bindings.  This is used to speed
     473                 :            :      up searching for labels when popping scopes, particularly since
     474                 :            :      labels are normally only found at function scope.  */
     475                 :            :   BOOL_BITFIELD has_label_bindings : 1;
     476                 :            : 
     477                 :            :   /* True if we should issue a warning if a goto statement crosses any
     478                 :            :      of the bindings.  We still need to check the list of bindings to
     479                 :            :      find the specific ones we need to warn about.  This is true if
     480                 :            :      decl_jump_unsafe would return true for any of the bindings.  This
     481                 :            :      is used to avoid looping over all the bindings unnecessarily.  */
     482                 :            :   BOOL_BITFIELD has_jump_unsafe_decl : 1;
     483                 :            : };
     484                 :            : 
     485                 :            : /* The scope currently in effect.  */
     486                 :            : 
     487                 :            : static GTY(()) struct c_scope *current_scope;
     488                 :            : 
     489                 :            : /* The innermost function scope.  Ordinary (not explicitly declared)
     490                 :            :    labels, bindings to error_mark_node, and the lazily-created
     491                 :            :    bindings of __func__ and its friends get this scope.  */
     492                 :            : 
     493                 :            : static GTY(()) struct c_scope *current_function_scope;
     494                 :            : 
     495                 :            : /* The C file scope.  This is reset for each input translation unit.  */
     496                 :            : 
     497                 :            : static GTY(()) struct c_scope *file_scope;
     498                 :            : 
     499                 :            : /* The outermost scope.  This is used for all declarations with
     500                 :            :    external linkage, and only these, hence the name.  */
     501                 :            : 
     502                 :            : static GTY(()) struct c_scope *external_scope;
     503                 :            : 
     504                 :            : /* A chain of c_scope structures awaiting reuse.  */
     505                 :            : 
     506                 :            : static GTY((deletable)) struct c_scope *scope_freelist;
     507                 :            : 
     508                 :            : /* A chain of c_binding structures awaiting reuse.  */
     509                 :            : 
     510                 :            : static GTY((deletable)) struct c_binding *binding_freelist;
     511                 :            : 
     512                 :            : /* Append VAR to LIST in scope SCOPE.  */
     513                 :            : #define SCOPE_LIST_APPEND(scope, list, decl) do {       \
     514                 :            :   struct c_scope *s_ = (scope);                         \
     515                 :            :   tree d_ = (decl);                                     \
     516                 :            :   if (s_->list##_last)                                       \
     517                 :            :     BLOCK_CHAIN (s_->list##_last) = d_;                      \
     518                 :            :   else                                                  \
     519                 :            :     s_->list = d_;                                   \
     520                 :            :   s_->list##_last = d_;                                      \
     521                 :            : } while (0)
     522                 :            : 
     523                 :            : /* Concatenate FROM in scope FSCOPE onto TO in scope TSCOPE.  */
     524                 :            : #define SCOPE_LIST_CONCAT(tscope, to, fscope, from) do {        \
     525                 :            :   struct c_scope *t_ = (tscope);                                \
     526                 :            :   struct c_scope *f_ = (fscope);                                \
     527                 :            :   if (t_->to##_last)                                         \
     528                 :            :     BLOCK_CHAIN (t_->to##_last) = f_->from;                       \
     529                 :            :   else                                                          \
     530                 :            :     t_->to = f_->from;                                            \
     531                 :            :   t_->to##_last = f_->from##_last;                                \
     532                 :            : } while (0)
     533                 :            : 
     534                 :            : /* A c_inline_static structure stores details of a static identifier
     535                 :            :    referenced in a definition of a function that may be an inline
     536                 :            :    definition if no subsequent declaration of that function uses
     537                 :            :    "extern" or does not use "inline".  */
     538                 :            : 
     539                 :            : struct GTY((chain_next ("%h.next"))) c_inline_static {
     540                 :            :   /* The location for a diagnostic.  */
     541                 :            :   location_t location;
     542                 :            : 
     543                 :            :   /* The function that may be an inline definition.  */
     544                 :            :   tree function;
     545                 :            : 
     546                 :            :   /* The object or function referenced.  */
     547                 :            :   tree static_decl;
     548                 :            : 
     549                 :            :   /* What sort of reference this is.  */
     550                 :            :   enum c_inline_static_type type;
     551                 :            : 
     552                 :            :   /* The next such structure or NULL.  */
     553                 :            :   struct c_inline_static *next;
     554                 :            : };
     555                 :            : 
     556                 :            : /* List of static identifiers used or referenced in functions that may
     557                 :            :    be inline definitions.  */
     558                 :            : static GTY(()) struct c_inline_static *c_inline_statics;
     559                 :            : 
     560                 :            : /* True means unconditionally make a BLOCK for the next scope pushed.  */
     561                 :            : 
     562                 :            : static bool keep_next_level_flag;
     563                 :            : 
     564                 :            : /* True means the next call to push_scope will be the outermost scope
     565                 :            :    of a function body, so do not push a new scope, merely cease
     566                 :            :    expecting parameter decls.  */
     567                 :            : 
     568                 :            : static bool next_is_function_body;
     569                 :            : 
     570                 :            : /* A vector of pointers to c_binding structures.  */
     571                 :            : 
     572                 :            : typedef struct c_binding *c_binding_ptr;
     573                 :            : 
     574                 :            : /* Information that we keep for a struct or union while it is being
     575                 :            :    parsed.  */
     576                 :            : 
     577                 :     816099 : class c_struct_parse_info
     578                 :            : {
     579                 :            : public:
     580                 :            :   /* If warn_cxx_compat, a list of types defined within this
     581                 :            :      struct.  */
     582                 :            :   auto_vec<tree> struct_types;
     583                 :            :   /* If warn_cxx_compat, a list of field names which have bindings,
     584                 :            :      and which are defined in this struct, but which are not defined
     585                 :            :      in any enclosing struct.  This is used to clear the in_struct
     586                 :            :      field of the c_bindings structure.  */
     587                 :            :   auto_vec<c_binding_ptr> fields;
     588                 :            :   /* If warn_cxx_compat, a list of typedef names used when defining
     589                 :            :      fields in this struct.  */
     590                 :            :   auto_vec<tree> typedefs_seen;
     591                 :            : };
     592                 :            : 
     593                 :            : /* Information for the struct or union currently being parsed, or
     594                 :            :    NULL if not parsing a struct or union.  */
     595                 :            : static class c_struct_parse_info *struct_parse_info;
     596                 :            : 
     597                 :            : /* Forward declarations.  */
     598                 :            : static tree lookup_name_in_scope (tree, struct c_scope *);
     599                 :            : static tree c_make_fname_decl (location_t, tree, int);
     600                 :            : static tree grokdeclarator (const struct c_declarator *,
     601                 :            :                             struct c_declspecs *,
     602                 :            :                             enum decl_context, bool, tree *, tree *, tree *,
     603                 :            :                             bool *, enum deprecated_states);
     604                 :            : static tree grokparms (struct c_arg_info *, bool);
     605                 :            : static void layout_array_type (tree);
     606                 :            : static void warn_defaults_to (location_t, int, const char *, ...)
     607                 :            :     ATTRIBUTE_GCC_DIAG(3,4);
     608                 :            : static const char *header_for_builtin_fn (tree);
     609                 :            : 
     610                 :            : /* T is a statement.  Add it to the statement-tree.  This is the
     611                 :            :    C/ObjC version--C++ has a slightly different version of this
     612                 :            :    function.  */
     613                 :            : 
     614                 :            : tree
     615                 :   55014200 : add_stmt (tree t)
     616                 :            : {
     617                 :   55014200 :   enum tree_code code = TREE_CODE (t);
     618                 :            : 
     619                 :   55014200 :   if (CAN_HAVE_LOCATION_P (t) && code != LABEL_EXPR)
     620                 :            :     {
     621                 :   53559500 :       if (!EXPR_HAS_LOCATION (t))
     622                 :     288397 :         SET_EXPR_LOCATION (t, input_location);
     623                 :            :     }
     624                 :            : 
     625                 :   55014200 :   if (code == LABEL_EXPR || code == CASE_LABEL_EXPR)
     626                 :    1757000 :     STATEMENT_LIST_HAS_LABEL (cur_stmt_list) = 1;
     627                 :            : 
     628                 :            :   /* Add T to the statement-tree.  Non-side-effect statements need to be
     629                 :            :      recorded during statement expressions.  */
     630                 :   55014200 :   if (!building_stmt_list_p ())
     631                 :          2 :     push_stmt_list ();
     632                 :   55014200 :   append_to_statement_list_force (t, &cur_stmt_list);
     633                 :            : 
     634                 :   55014200 :   return t;
     635                 :            : }
     636                 :            : 
     637                 :            : /* Build a pointer type using the default pointer mode.  */
     638                 :            : 
     639                 :            : static tree
     640                 :   12506100 : c_build_pointer_type (tree to_type)
     641                 :            : {
     642                 :   12506100 :   addr_space_t as = to_type == error_mark_node? ADDR_SPACE_GENERIC
     643                 :   12506100 :                                               : TYPE_ADDR_SPACE (to_type);
     644                 :   12506100 :   machine_mode pointer_mode;
     645                 :            : 
     646                 :   12506100 :   if (as != ADDR_SPACE_GENERIC || c_default_pointer_mode == VOIDmode)
     647                 :   12506100 :     pointer_mode = targetm.addr_space.pointer_mode (as);
     648                 :            :   else
     649                 :            :     pointer_mode = c_default_pointer_mode;
     650                 :   12506100 :   return build_pointer_type_for_mode (to_type, pointer_mode, false);
     651                 :            : }
     652                 :            : 
     653                 :            : 
     654                 :            : /* Return true if we will want to say something if a goto statement
     655                 :            :    crosses DECL.  */
     656                 :            : 
     657                 :            : static bool
     658                 :  469977000 : decl_jump_unsafe (tree decl)
     659                 :            : {
     660                 :  939952000 :   if (error_operand_p (decl))
     661                 :            :     return false;
     662                 :            : 
     663                 :            :   /* Don't warn for compound literals.  If a goto statement crosses
     664                 :            :      their initialization, it should cross also all the places where
     665                 :            :      the complit is used or where the complit address might be saved
     666                 :            :      into some variable, so code after the label to which goto jumps
     667                 :            :      should not be able to refer to the compound literal.  */
     668                 :  469975000 :   if (VAR_P (decl) && C_DECL_COMPOUND_LITERAL_P (decl))
     669                 :            :     return false;
     670                 :            : 
     671                 :            :   /* Always warn about crossing variably modified types.  */
     672                 :  469493000 :   if ((VAR_P (decl) || TREE_CODE (decl) == TYPE_DECL)
     673                 :  482841000 :       && variably_modified_type_p (TREE_TYPE (decl), NULL_TREE))
     674                 :            :     return true;
     675                 :            : 
     676                 :            :   /* Otherwise, only warn if -Wgoto-misses-init and this is an
     677                 :            :      initialized automatic decl.  */
     678                 :  469454000 :   if (warn_jump_misses_init
     679                 :            :       && VAR_P (decl)
     680                 :       9663 :       && !TREE_STATIC (decl)
     681                 :  469454000 :       && DECL_INITIAL (decl) != NULL_TREE)
     682                 :         22 :     return true;
     683                 :            : 
     684                 :            :   return false;
     685                 :            : }
     686                 :            : 
     687                 :            : 
     688                 :            : void
     689                 :          0 : c_print_identifier (FILE *file, tree node, int indent)
     690                 :            : {
     691                 :          0 :   void (*save) (enum c_oracle_request, tree identifier);
     692                 :            : 
     693                 :            :   /* Temporarily hide any binding oracle.  Without this, calls to
     694                 :            :      debug_tree from the debugger will end up calling into the oracle,
     695                 :            :      making for a confusing debug session.  As the oracle isn't needed
     696                 :            :      here for normal operation, it's simplest to suppress it.  */
     697                 :          0 :   save = c_binding_oracle;
     698                 :          0 :   c_binding_oracle = NULL;
     699                 :            : 
     700                 :          0 :   print_node (file, "symbol", I_SYMBOL_DECL (node), indent + 4);
     701                 :          0 :   print_node (file, "tag", I_TAG_DECL (node), indent + 4);
     702                 :          0 :   print_node (file, "label", I_LABEL_DECL (node), indent + 4);
     703                 :          0 :   if (C_IS_RESERVED_WORD (node) && C_RID_CODE (node) != RID_CXX_COMPAT_WARN)
     704                 :            :     {
     705                 :          0 :       tree rid = ridpointers[C_RID_CODE (node)];
     706                 :          0 :       indent_to (file, indent + 4);
     707                 :          0 :       fprintf (file, "rid " HOST_PTR_PRINTF " \"%s\"",
     708                 :          0 :                (void *) rid, IDENTIFIER_POINTER (rid));
     709                 :            :     }
     710                 :            : 
     711                 :          0 :   c_binding_oracle = save;
     712                 :          0 : }
     713                 :            : 
     714                 :            : /* Establish a binding between NAME, an IDENTIFIER_NODE, and DECL,
     715                 :            :    which may be any of several kinds of DECL or TYPE or error_mark_node,
     716                 :            :    in the scope SCOPE.  */
     717                 :            : static void
     718                 :  469828000 : bind (tree name, tree decl, struct c_scope *scope, bool invisible,
     719                 :            :       bool nested, location_t locus)
     720                 :            : {
     721                 :  469828000 :   struct c_binding *b, **here;
     722                 :            : 
     723                 :  469828000 :   if (binding_freelist)
     724                 :            :     {
     725                 :  130764000 :       b = binding_freelist;
     726                 :  130764000 :       binding_freelist = b->prev;
     727                 :            :     }
     728                 :            :   else
     729                 :  339064000 :     b = ggc_alloc<c_binding> ();
     730                 :            : 
     731                 :  469828000 :   b->shadowed = 0;
     732                 :  469828000 :   b->decl = decl;
     733                 :  469828000 :   b->id = name;
     734                 :  469828000 :   b->depth = scope->depth;
     735                 :  469828000 :   b->invisible = invisible;
     736                 :  469828000 :   b->nested = nested;
     737                 :  469828000 :   b->inner_comp = 0;
     738                 :  469828000 :   b->in_struct = 0;
     739                 :  469828000 :   b->locus = locus;
     740                 :            : 
     741                 :  469828000 :   b->u.type = NULL;
     742                 :            : 
     743                 :  469828000 :   b->prev = scope->bindings;
     744                 :  469828000 :   scope->bindings = b;
     745                 :            : 
     746                 :  469828000 :   if (decl_jump_unsafe (decl))
     747                 :      18280 :     scope->has_jump_unsafe_decl = 1;
     748                 :            : 
     749                 :  469828000 :   if (!name)
     750                 :            :     return;
     751                 :            : 
     752                 :  463712000 :   switch (TREE_CODE (decl))
     753                 :            :     {
     754                 :      21190 :     case LABEL_DECL:     here = &I_LABEL_BINDING (name);   break;
     755                 :     476195 :     case ENUMERAL_TYPE:
     756                 :     476195 :     case UNION_TYPE:
     757                 :     476195 :     case RECORD_TYPE:    here = &I_TAG_BINDING (name);     break;
     758                 :  463214000 :     case VAR_DECL:
     759                 :  463214000 :     case FUNCTION_DECL:
     760                 :  463214000 :     case TYPE_DECL:
     761                 :  463214000 :     case CONST_DECL:
     762                 :  463214000 :     case PARM_DECL:
     763                 :  463214000 :     case ERROR_MARK:     here = &I_SYMBOL_BINDING (name);  break;
     764                 :            : 
     765                 :          0 :     default:
     766                 :          0 :       gcc_unreachable ();
     767                 :            :     }
     768                 :            : 
     769                 :            :   /* Locate the appropriate place in the chain of shadowed decls
     770                 :            :      to insert this binding.  Normally, scope == current_scope and
     771                 :            :      this does nothing.  */
     772                 :  463712000 :   while (*here && (*here)->depth > scope->depth)
     773                 :         35 :     here = &(*here)->shadowed;
     774                 :            : 
     775                 :  463712000 :   b->shadowed = *here;
     776                 :  463712000 :   *here = b;
     777                 :            : }
     778                 :            : 
     779                 :            : /* Clear the binding structure B, stick it on the binding_freelist,
     780                 :            :    and return the former value of b->prev.  This is used by pop_scope
     781                 :            :    and get_parm_info to iterate destructively over all the bindings
     782                 :            :    from a given scope.  */
     783                 :            : static struct c_binding *
     784                 :  464991000 : free_binding_and_advance (struct c_binding *b)
     785                 :            : {
     786                 :  464991000 :   struct c_binding *prev = b->prev;
     787                 :            : 
     788                 :  464991000 :   memset (b, 0, sizeof (struct c_binding));
     789                 :  464991000 :   b->prev = binding_freelist;
     790                 :  464991000 :   binding_freelist = b;
     791                 :            : 
     792                 :  464991000 :   return prev;
     793                 :            : }
     794                 :            : 
     795                 :            : /* Bind a label.  Like bind, but skip fields which aren't used for
     796                 :            :    labels, and add the LABEL_VARS value.  */
     797                 :            : static void
     798                 :      21190 : bind_label (tree name, tree label, struct c_scope *scope,
     799                 :            :             struct c_label_vars *label_vars)
     800                 :            : {
     801                 :      21190 :   struct c_binding *b;
     802                 :            : 
     803                 :      21190 :   bind (name, label, scope, /*invisible=*/false, /*nested=*/false,
     804                 :            :         UNKNOWN_LOCATION);
     805                 :            : 
     806                 :      21190 :   scope->has_label_bindings = true;
     807                 :            : 
     808                 :      21190 :   b = scope->bindings;
     809                 :      21190 :   gcc_assert (b->decl == label);
     810                 :      21190 :   label_vars->shadowed = b->u.label;
     811                 :      21190 :   b->u.label = label_vars;
     812                 :      21190 : }
     813                 :            : 
     814                 :            : /* Hook called at end of compilation to assume 1 elt
     815                 :            :    for a file-scope tentative array defn that wasn't complete before.  */
     816                 :            : 
     817                 :            : void
     818                 :      18735 : c_finish_incomplete_decl (tree decl)
     819                 :            : {
     820                 :      18735 :   if (VAR_P (decl))
     821                 :            :     {
     822                 :      18735 :       tree type = TREE_TYPE (decl);
     823                 :      18735 :       if (type != error_mark_node
     824                 :      18670 :           && TREE_CODE (type) == ARRAY_TYPE
     825                 :      18482 :           && !DECL_EXTERNAL (decl)
     826                 :      18806 :           && TYPE_DOMAIN (type) == NULL_TREE)
     827                 :            :         {
     828                 :         71 :           warning_at (DECL_SOURCE_LOCATION (decl),
     829                 :            :                       0, "array %q+D assumed to have one element", decl);
     830                 :            : 
     831                 :         71 :           complete_array_type (&TREE_TYPE (decl), NULL_TREE, true);
     832                 :            : 
     833                 :         71 :           relayout_decl (decl);
     834                 :            :         }
     835                 :            :     }
     836                 :      18735 : }
     837                 :            : 
     838                 :            : /* Record that inline function FUNC contains a reference (location
     839                 :            :    LOC) to static DECL (file-scope or function-local according to
     840                 :            :    TYPE).  */
     841                 :            : 
     842                 :            : void
     843                 :         32 : record_inline_static (location_t loc, tree func, tree decl,
     844                 :            :                       enum c_inline_static_type type)
     845                 :            : {
     846                 :         32 :   c_inline_static *csi = ggc_alloc<c_inline_static> ();
     847                 :         32 :   csi->location = loc;
     848                 :         32 :   csi->function = func;
     849                 :         32 :   csi->static_decl = decl;
     850                 :         32 :   csi->type = type;
     851                 :         32 :   csi->next = c_inline_statics;
     852                 :         32 :   c_inline_statics = csi;
     853                 :         32 : }
     854                 :            : 
     855                 :            : /* Check for references to static declarations in inline functions at
     856                 :            :    the end of the translation unit and diagnose them if the functions
     857                 :            :    are still inline definitions.  */
     858                 :            : 
     859                 :            : static void
     860                 :      76969 : check_inline_statics (void)
     861                 :            : {
     862                 :      76969 :   struct c_inline_static *csi;
     863                 :      77001 :   for (csi = c_inline_statics; csi; csi = csi->next)
     864                 :            :     {
     865                 :         32 :       if (DECL_EXTERNAL (csi->function))
     866                 :         28 :         switch (csi->type)
     867                 :            :           {
     868                 :         23 :           case csi_internal:
     869                 :         23 :             pedwarn (csi->location, 0,
     870                 :            :                      "%qD is static but used in inline function %qD "
     871                 :            :                      "which is not static", csi->static_decl, csi->function);
     872                 :         23 :             break;
     873                 :          5 :           case csi_modifiable:
     874                 :          5 :             pedwarn (csi->location, 0,
     875                 :            :                      "%q+D is static but declared in inline function %qD "
     876                 :            :                      "which is not static", csi->static_decl, csi->function);
     877                 :          5 :             break;
     878                 :          0 :           default:
     879                 :          0 :             gcc_unreachable ();
     880                 :            :           }
     881                 :            :     }
     882                 :      76969 :   c_inline_statics = NULL;
     883                 :      76969 : }
     884                 :            : 
     885                 :            : /* Fill in a c_spot_bindings structure.  If DEFINING is true, set it
     886                 :            :    for the current state, otherwise set it to uninitialized.  */
     887                 :            : 
     888                 :            : static void
     889                 :     118944 : set_spot_bindings (struct c_spot_bindings *p, bool defining)
     890                 :            : {
     891                 :          0 :   if (defining)
     892                 :            :     {
     893                 :     113335 :       p->scope = current_scope;
     894                 :      15581 :       p->bindings_in_scope = current_scope->bindings;
     895                 :            :     }
     896                 :            :   else
     897                 :            :     {
     898                 :       5609 :       p->scope = NULL;
     899                 :       5609 :       p->bindings_in_scope = NULL;
     900                 :            :     }
     901                 :     118944 :   p->stmt_exprs = 0;
     902                 :     118944 :   p->left_stmt_expr = false;
     903                 :          0 : }
     904                 :            : 
     905                 :            : /* Update spot bindings P as we pop out of SCOPE.  Return true if we
     906                 :            :    should push decls for a label.  */
     907                 :            : 
     908                 :            : static bool
     909                 :  470481000 : update_spot_bindings (struct c_scope *scope, struct c_spot_bindings *p)
     910                 :            : {
     911                 :          0 :   if (p->scope != scope)
     912                 :            :     {
     913                 :            :       /* This label or goto is defined in some other scope, or it is a
     914                 :            :          label which is not yet defined.  There is nothing to
     915                 :            :          update.  */
     916                 :            :       return false;
     917                 :            :     }
     918                 :            : 
     919                 :            :   /* Adjust the spot bindings to refer to the bindings already defined
     920                 :            :      in the enclosing scope.  */
     921                 :     190484 :   p->scope = scope->outer;
     922                 :     190484 :   p->bindings_in_scope = p->scope->bindings;
     923                 :            : 
     924                 :     145187 :   return true;
     925                 :            : }
     926                 :            : 
     927                 :            : /* The Objective-C front-end often needs to determine the current scope.  */
     928                 :            : 
     929                 :            : void *
     930                 :          0 : objc_get_current_scope (void)
     931                 :            : {
     932                 :          0 :   return current_scope;
     933                 :            : }
     934                 :            : 
     935                 :            : /* The following function is used only by Objective-C.  It needs to live here
     936                 :            :    because it accesses the innards of c_scope.  */
     937                 :            : 
     938                 :            : void
     939                 :          0 : objc_mark_locals_volatile (void *enclosing_blk)
     940                 :            : {
     941                 :          0 :   struct c_scope *scope;
     942                 :          0 :   struct c_binding *b;
     943                 :            : 
     944                 :          0 :   for (scope = current_scope;
     945                 :          0 :        scope && scope != enclosing_blk;
     946                 :          0 :        scope = scope->outer)
     947                 :            :     {
     948                 :          0 :       for (b = scope->bindings; b; b = b->prev)
     949                 :          0 :         objc_volatilize_decl (b->decl);
     950                 :            : 
     951                 :            :       /* Do not climb up past the current function.  */
     952                 :          0 :       if (scope->function_body)
     953                 :            :         break;
     954                 :            :     }
     955                 :          0 : }
     956                 :            : 
     957                 :            : /* Return true if we are in the global binding level.  */
     958                 :            : 
     959                 :            : bool
     960                 :    3055490 : global_bindings_p (void)
     961                 :            : {
     962                 :    3055490 :   return current_scope == file_scope;
     963                 :            : }
     964                 :            : 
     965                 :            : /* Return true if we're declaring parameters in an old-style function
     966                 :            :    declaration.  */
     967                 :            : 
     968                 :            : bool
     969                 :      30264 : old_style_parameter_scope (void)
     970                 :            : {
     971                 :            :   /* If processing parameters and there is no function statement list, we
     972                 :            :    * have an old-style function declaration.  */
     973                 :      30264 :   return (current_scope->parm_flag && !DECL_SAVED_TREE (current_function_decl));
     974                 :            : }
     975                 :            : 
     976                 :            : void
     977                 :      41930 : keep_next_level (void)
     978                 :            : {
     979                 :      41930 :   keep_next_level_flag = true;
     980                 :      41930 : }
     981                 :            : 
     982                 :            : /* Set the flag for the FLOAT_CONST_DECIMAL64 pragma being ON.  */
     983                 :            : 
     984                 :            : void
     985                 :         20 : set_float_const_decimal64 (void)
     986                 :            : {
     987                 :         20 :   current_scope->float_const_decimal64 = true;
     988                 :         20 : }
     989                 :            : 
     990                 :            : /* Clear the flag for the FLOAT_CONST_DECIMAL64 pragma.  */
     991                 :            : 
     992                 :            : void
     993                 :         28 : clear_float_const_decimal64 (void)
     994                 :            : {
     995                 :         28 :   current_scope->float_const_decimal64 = false;
     996                 :         28 : }
     997                 :            : 
     998                 :            : /* Return nonzero if an unsuffixed float constant is _Decimal64.  */
     999                 :            : 
    1000                 :            : bool
    1001                 :     410086 : float_const_decimal64_p (void)
    1002                 :            : {
    1003                 :     410086 :   return current_scope->float_const_decimal64;
    1004                 :            : }
    1005                 :            : 
    1006                 :            : /* Identify this scope as currently being filled with parameters.  */
    1007                 :            : 
    1008                 :            : void
    1009                 :   50389000 : declare_parm_level (void)
    1010                 :            : {
    1011                 :   50389000 :   current_scope->parm_flag = true;
    1012                 :   50389000 : }
    1013                 :            : 
    1014                 :            : void
    1015                 :   74180300 : push_scope (void)
    1016                 :            : {
    1017                 :   74180300 :   if (next_is_function_body)
    1018                 :            :     {
    1019                 :            :       /* This is the transition from the parameters to the top level
    1020                 :            :          of the function body.  These are the same scope
    1021                 :            :          (C99 6.2.1p4,6) so we do not push another scope structure.
    1022                 :            :          next_is_function_body is set only by store_parm_decls, which
    1023                 :            :          in turn is called when and only when we are about to
    1024                 :            :          encounter the opening curly brace for the function body.
    1025                 :            : 
    1026                 :            :          The outermost block of a function always gets a BLOCK node,
    1027                 :            :          because the debugging output routines expect that each
    1028                 :            :          function has at least one BLOCK.  */
    1029                 :   20340300 :       current_scope->parm_flag         = false;
    1030                 :   20340300 :       current_scope->function_body     = true;
    1031                 :   20340300 :       current_scope->keep              = true;
    1032                 :   20340300 :       current_scope->outer_function    = current_function_scope;
    1033                 :   20340300 :       current_function_scope           = current_scope;
    1034                 :            : 
    1035                 :   20340300 :       keep_next_level_flag = false;
    1036                 :   20340300 :       next_is_function_body = false;
    1037                 :            : 
    1038                 :            :       /* The FLOAT_CONST_DECIMAL64 pragma applies to nested scopes.  */
    1039                 :   20340300 :       if (current_scope->outer)
    1040                 :   20340300 :         current_scope->float_const_decimal64
    1041                 :   20340300 :           = current_scope->outer->float_const_decimal64;
    1042                 :            :       else
    1043                 :          0 :         current_scope->float_const_decimal64 = false;
    1044                 :            :     }
    1045                 :            :   else
    1046                 :            :     {
    1047                 :   53840000 :       struct c_scope *scope;
    1048                 :   53840000 :       if (scope_freelist)
    1049                 :            :         {
    1050                 :   53289200 :           scope = scope_freelist;
    1051                 :   53289200 :           scope_freelist = scope->outer;
    1052                 :            :         }
    1053                 :            :       else
    1054                 :     550811 :         scope = ggc_cleared_alloc<c_scope> ();
    1055                 :            : 
    1056                 :            :       /* The FLOAT_CONST_DECIMAL64 pragma applies to nested scopes.  */
    1057                 :   53840000 :       if (current_scope)
    1058                 :   53761400 :         scope->float_const_decimal64 = current_scope->float_const_decimal64;
    1059                 :            :       else
    1060                 :      78603 :         scope->float_const_decimal64 = false;
    1061                 :            : 
    1062                 :   53840000 :       scope->keep          = keep_next_level_flag;
    1063                 :   53840000 :       scope->outer         = current_scope;
    1064                 :   53840000 :       scope->depth      = current_scope ? (current_scope->depth + 1) : 0;
    1065                 :            : 
    1066                 :            :       /* Check for scope depth overflow.  Unlikely (2^28 == 268,435,456) but
    1067                 :            :          possible.  */
    1068                 :   53840000 :       if (current_scope && scope->depth == 0)
    1069                 :            :         {
    1070                 :          0 :           scope->depth--;
    1071                 :          0 :           sorry ("GCC supports only %u nested scopes", scope->depth);
    1072                 :            :         }
    1073                 :            : 
    1074                 :   53840000 :       current_scope        = scope;
    1075                 :   53840000 :       keep_next_level_flag = false;
    1076                 :            :     }
    1077                 :   74180300 : }
    1078                 :            : 
    1079                 :            : /* This is called when we are leaving SCOPE.  For each label defined
    1080                 :            :    in SCOPE, add any appropriate decls to its decls_in_scope fields.
    1081                 :            :    These are the decls whose initialization will be skipped by a goto
    1082                 :            :    later in the function.  */
    1083                 :            : 
    1084                 :            : static void
    1085                 :   53837700 : update_label_decls (struct c_scope *scope)
    1086                 :            : {
    1087                 :   53837700 :   struct c_scope *s;
    1088                 :            : 
    1089                 :   53837700 :   s = scope;
    1090                 :  157441000 :   while (s != NULL)
    1091                 :            :     {
    1092                 :  127252000 :       if (s->has_label_bindings)
    1093                 :            :         {
    1094                 :     203749 :           struct c_binding *b;
    1095                 :            : 
    1096                 :    1744430 :           for (b = s->bindings; b != NULL; b = b->prev)
    1097                 :            :             {
    1098                 :    1540680 :               struct c_label_vars *label_vars;
    1099                 :    1540680 :               struct c_binding *b1;
    1100                 :    1540680 :               bool hjud;
    1101                 :    1540680 :               unsigned int ix;
    1102                 :    1540680 :               struct c_goto_bindings *g;
    1103                 :            : 
    1104                 :    1540680 :               if (TREE_CODE (b->decl) != LABEL_DECL)
    1105                 :    1102920 :                 continue;
    1106                 :     437755 :               label_vars = b->u.label;
    1107                 :            : 
    1108                 :     437755 :               b1 = label_vars->label_bindings.bindings_in_scope;
    1109                 :     437755 :               if (label_vars->label_bindings.scope == NULL)
    1110                 :            :                 hjud = false;
    1111                 :            :               else
    1112                 :     144257 :                 hjud = label_vars->label_bindings.scope->has_jump_unsafe_decl;
    1113                 :     437755 :               if (update_spot_bindings (scope, &label_vars->label_bindings))
    1114                 :            :                 {
    1115                 :            :                   /* This label is defined in this scope.  */
    1116                 :      45297 :                   if (hjud)
    1117                 :            :                     {
    1118                 :     169421 :                       for (; b1 != NULL; b1 = b1->prev)
    1119                 :            :                         {
    1120                 :            :                           /* A goto from later in the function to this
    1121                 :            :                              label will never see the initialization
    1122                 :            :                              of B1, if any.  Save it to issue a
    1123                 :            :                              warning if needed.  */
    1124                 :     148036 :                           if (decl_jump_unsafe (b1->decl))
    1125                 :      19412 :                             vec_safe_push(label_vars->decls_in_scope, b1->decl);
    1126                 :            :                         }
    1127                 :            :                     }
    1128                 :            :                 }
    1129                 :            : 
    1130                 :            :               /* Update the bindings of any goto statements associated
    1131                 :            :                  with this label.  */
    1132                 :  471866000 :               FOR_EACH_VEC_SAFE_ELT (label_vars->gotos, ix, g)
    1133                 :  470188000 :                 update_spot_bindings (scope, &g->goto_bindings);
    1134                 :            :             }
    1135                 :            :         }
    1136                 :            : 
    1137                 :            :       /* Don't search beyond the current function.  */
    1138                 :  127252000 :       if (s == current_function_scope)
    1139                 :            :         break;
    1140                 :            : 
    1141                 :  103604000 :       s = s->outer;
    1142                 :            :     }
    1143                 :   53837700 : }
    1144                 :            : 
    1145                 :            : /* Set the TYPE_CONTEXT of all of TYPE's variants to CONTEXT.  */
    1146                 :            : 
    1147                 :            : static void
    1148                 :    4712560 : set_type_context (tree type, tree context)
    1149                 :            : {
    1150                 :   52750000 :   for (type = TYPE_MAIN_VARIANT (type); type;
    1151                 :   48037500 :        type = TYPE_NEXT_VARIANT (type))
    1152                 :   48037500 :     TYPE_CONTEXT (type) = context;
    1153                 :    4712560 : }
    1154                 :            : 
    1155                 :            : /* Exit a scope.  Restore the state of the identifier-decl mappings
    1156                 :            :    that were in effect when this scope was entered.  Return a BLOCK
    1157                 :            :    node containing all the DECLs in this scope that are of interest
    1158                 :            :    to debug info generation.  */
    1159                 :            : 
    1160                 :            : tree
    1161                 :   53837700 : pop_scope (void)
    1162                 :            : {
    1163                 :   53837700 :   struct c_scope *scope = current_scope;
    1164                 :   53837700 :   tree block, context, p;
    1165                 :   53837700 :   struct c_binding *b;
    1166                 :            : 
    1167                 :   53837700 :   bool functionbody = scope->function_body;
    1168                 :   53837700 :   bool keep = functionbody || scope->keep || scope->bindings;
    1169                 :            : 
    1170                 :   53837700 :   update_label_decls (scope);
    1171                 :            : 
    1172                 :            :   /* If appropriate, create a BLOCK to record the decls for the life
    1173                 :            :      of this function.  */
    1174                 :   53837700 :   block = NULL_TREE;
    1175                 :   53837700 :   if (keep)
    1176                 :            :     {
    1177                 :   20690600 :       block = make_node (BLOCK);
    1178                 :   20690600 :       BLOCK_SUBBLOCKS (block) = scope->blocks;
    1179                 :   20690600 :       TREE_USED (block) = 1;
    1180                 :            : 
    1181                 :            :       /* In each subblock, record that this is its superior.  */
    1182                 :   20887500 :       for (p = scope->blocks; p; p = BLOCK_CHAIN (p))
    1183                 :     196926 :         BLOCK_SUPERCONTEXT (p) = block;
    1184                 :            : 
    1185                 :   20690600 :       BLOCK_VARS (block) = NULL_TREE;
    1186                 :            :     }
    1187                 :            : 
    1188                 :            :   /* The TYPE_CONTEXTs for all of the tagged types belonging to this
    1189                 :            :      scope must be set so that they point to the appropriate
    1190                 :            :      construct, i.e.  either to the current FUNCTION_DECL node, or
    1191                 :            :      else to the BLOCK node we just constructed.
    1192                 :            : 
    1193                 :            :      Note that for tagged types whose scope is just the formal
    1194                 :            :      parameter list for some function type specification, we can't
    1195                 :            :      properly set their TYPE_CONTEXTs here, because we don't have a
    1196                 :            :      pointer to the appropriate FUNCTION_TYPE node readily available
    1197                 :            :      to us.  For those cases, the TYPE_CONTEXTs of the relevant tagged
    1198                 :            :      type nodes get set in `grokdeclarator' as soon as we have created
    1199                 :            :      the FUNCTION_TYPE node which will represent the "scope" for these
    1200                 :            :      "parameter list local" tagged types.  */
    1201                 :   53837700 :   if (scope->function_body)
    1202                 :   20340300 :     context = current_function_decl;
    1203                 :   33497400 :   else if (scope == file_scope)
    1204                 :            :     {
    1205                 :      76682 :       tree file_decl
    1206                 :      76682 :         = build_translation_unit_decl (get_identifier (main_input_filename));
    1207                 :      76682 :       context = file_decl;
    1208                 :      76682 :       debug_hooks->register_main_translation_unit (file_decl);
    1209                 :            :     }
    1210                 :            :   else
    1211                 :            :     context = block;
    1212                 :            : 
    1213                 :            :   /* Clear all bindings in this scope.  */
    1214                 :  447097000 :   for (b = scope->bindings; b; b = free_binding_and_advance (b))
    1215                 :            :     {
    1216                 :  393259000 :       p = b->decl;
    1217                 :  393259000 :       switch (TREE_CODE (p))
    1218                 :            :         {
    1219                 :      21190 :         case LABEL_DECL:
    1220                 :            :           /* Warnings for unused labels, errors for undefined labels.  */
    1221                 :      42011 :           if (TREE_USED (p) && !DECL_INITIAL (p))
    1222                 :            :             {
    1223                 :         63 :               error ("label %q+D used but not defined", p);
    1224                 :         63 :               DECL_INITIAL (p) = error_mark_node;
    1225                 :            :             }
    1226                 :            :           else
    1227                 :      21127 :             warn_for_unused_label (p);
    1228                 :            : 
    1229                 :            :           /* Labels go in BLOCK_VARS.  */
    1230                 :      21190 :           DECL_CHAIN (p) = BLOCK_VARS (block);
    1231                 :      21190 :           BLOCK_VARS (block) = p;
    1232                 :      21190 :           gcc_assert (I_LABEL_BINDING (b->id) == b);
    1233                 :      21190 :           I_LABEL_BINDING (b->id) = b->shadowed;
    1234                 :            : 
    1235                 :            :           /* Also pop back to the shadowed label_vars.  */
    1236                 :      21190 :           release_tree_vector (b->u.label->decls_in_scope);
    1237                 :      21190 :           b->u.label = b->u.label->shadowed;
    1238                 :      21190 :           break;
    1239                 :            : 
    1240                 :     997401 :         case ENUMERAL_TYPE:
    1241                 :     997401 :         case UNION_TYPE:
    1242                 :     997401 :         case RECORD_TYPE:
    1243                 :     997401 :           set_type_context (p, context);
    1244                 :            : 
    1245                 :            :           /* Types may not have tag-names, in which case the type
    1246                 :            :              appears in the bindings list with b->id NULL.  */
    1247                 :     997401 :           if (b->id)
    1248                 :            :             {
    1249                 :     475016 :               gcc_assert (I_TAG_BINDING (b->id) == b);
    1250                 :     475016 :               I_TAG_BINDING (b->id) = b->shadowed;
    1251                 :            :             }
    1252                 :            :           break;
    1253                 :            : 
    1254                 :  317839000 :         case FUNCTION_DECL:
    1255                 :            :           /* Propagate TREE_ADDRESSABLE from nested functions to their
    1256                 :            :              containing functions.  */
    1257                 :  317839000 :           if (!TREE_ASM_WRITTEN (p)
    1258                 :  317839000 :               && DECL_INITIAL (p) != NULL_TREE
    1259                 :   40621100 :               && TREE_ADDRESSABLE (p)
    1260                 :    2019010 :               && DECL_ABSTRACT_ORIGIN (p) != NULL_TREE
    1261                 :  317839000 :               && DECL_ABSTRACT_ORIGIN (p) != p)
    1262                 :          0 :             TREE_ADDRESSABLE (DECL_ABSTRACT_ORIGIN (p)) = 1;
    1263                 :  317839000 :           if (!TREE_PUBLIC (p)
    1264                 :     486582 :               && !DECL_INITIAL (p)
    1265                 :        114 :               && !b->nested
    1266                 :         51 :               && scope != file_scope
    1267                 :  317839000 :               && scope != external_scope)
    1268                 :            :             {
    1269                 :          4 :               error ("nested function %q+D declared but never defined", p);
    1270                 :          4 :               undef_nested_function = true;
    1271                 :            :             }
    1272                 :  317839000 :           else if (DECL_DECLARED_INLINE_P (p)
    1273                 :   39646300 :                    && TREE_PUBLIC (p)
    1274                 :  357369000 :                    && !DECL_INITIAL (p))
    1275                 :            :             {
    1276                 :            :               /* C99 6.7.4p6: "a function with external linkage... declared
    1277                 :            :                  with an inline function specifier ... shall also be defined
    1278                 :            :                  in the same translation unit."  */
    1279                 :         68 :               if (!flag_gnu89_inline
    1280                 :         43 :                   && !lookup_attribute ("gnu_inline", DECL_ATTRIBUTES (p))
    1281                 :         95 :                   && scope == external_scope)
    1282                 :          9 :                 pedwarn (input_location, 0,
    1283                 :            :                          "inline function %q+D declared but never defined", p);
    1284                 :         68 :               DECL_EXTERNAL (p) = 1;
    1285                 :            :             }
    1286                 :            : 
    1287                 :  317839000 :           goto common_symbol;
    1288                 :            : 
    1289                 :    5895830 :         case VAR_DECL:
    1290                 :            :           /* Warnings for unused variables.  */
    1291                 :    3556850 :           if ((!TREE_USED (p) || !DECL_READ_P (p))
    1292                 :    2360260 :               && !TREE_NO_WARNING (p)
    1293                 :    2360180 :               && !DECL_IN_SYSTEM_HEADER (p)
    1294                 :    2242830 :               && DECL_NAME (p)
    1295                 :    2242830 :               && !DECL_ARTIFICIAL (p)
    1296                 :    2242570 :               && scope != file_scope
    1297                 :    7378500 :               && scope != external_scope)
    1298                 :            :             {
    1299                 :     724139 :               if (!TREE_USED (p))
    1300                 :     718536 :                 warning (OPT_Wunused_variable, "unused variable %q+D", p);
    1301                 :       5603 :               else if (DECL_CONTEXT (p) == current_function_decl)
    1302                 :       5572 :                 warning_at (DECL_SOURCE_LOCATION (p),
    1303                 :            :                             OPT_Wunused_but_set_variable,
    1304                 :            :                             "variable %qD set but not used", p);
    1305                 :            :             }
    1306                 :            : 
    1307                 :    5895830 :           if (b->inner_comp)
    1308                 :            :             {
    1309                 :          2 :               error ("type of array %q+D completed incompatibly with"
    1310                 :            :                      " implicit initialization", p);
    1311                 :            :             }
    1312                 :            : 
    1313                 :            :           /* Fall through.  */
    1314                 :  335771000 :         case TYPE_DECL:
    1315                 :  335771000 :         case CONST_DECL:
    1316                 :    5895820 :         common_symbol:
    1317                 :            :           /* All of these go in BLOCK_VARS, but only if this is the
    1318                 :            :              binding in the home scope.  */
    1319                 :  335771000 :           if (!b->nested)
    1320                 :            :             {
    1321                 :  197657000 :               DECL_CHAIN (p) = BLOCK_VARS (block);
    1322                 :  197657000 :               BLOCK_VARS (block) = p;
    1323                 :            :             }
    1324                 :  138114000 :           else if (VAR_OR_FUNCTION_DECL_P (p) && scope != file_scope)
    1325                 :            :             {
    1326                 :            :               /* For block local externs add a special
    1327                 :            :                  DECL_EXTERNAL decl for debug info generation.  */
    1328                 :      30780 :               tree extp = copy_node (p);
    1329                 :            : 
    1330                 :      30780 :               DECL_EXTERNAL (extp) = 1;
    1331                 :      30780 :               TREE_STATIC (extp) = 0;
    1332                 :      30780 :               TREE_PUBLIC (extp) = 1;
    1333                 :      30780 :               DECL_INITIAL (extp) = NULL_TREE;
    1334                 :      30780 :               DECL_LANG_SPECIFIC (extp) = NULL;
    1335                 :      30780 :               DECL_CONTEXT (extp) = current_function_decl;
    1336                 :      30780 :               if (TREE_CODE (p) == FUNCTION_DECL)
    1337                 :            :                 {
    1338                 :      28993 :                   DECL_RESULT (extp) = NULL_TREE;
    1339                 :      28993 :                   DECL_SAVED_TREE (extp) = NULL_TREE;
    1340                 :      28993 :                   DECL_STRUCT_FUNCTION (extp) = NULL;
    1341                 :            :                 }
    1342                 :      30780 :               if (b->locus != UNKNOWN_LOCATION)
    1343                 :      30780 :                 DECL_SOURCE_LOCATION (extp) = b->locus;
    1344                 :      30780 :               DECL_CHAIN (extp) = BLOCK_VARS (block);
    1345                 :      30780 :               BLOCK_VARS (block) = extp;
    1346                 :            :             }
    1347                 :            :           /* If this is the file scope set DECL_CONTEXT of each decl to
    1348                 :            :              the TRANSLATION_UNIT_DECL.  This makes same_translation_unit_p
    1349                 :            :              work.  */
    1350                 :  335771000 :           if (scope == file_scope)
    1351                 :            :             {
    1352                 :  146413000 :               DECL_CONTEXT (p) = context;
    1353                 :  146413000 :               if (TREE_CODE (p) == TYPE_DECL
    1354                 :  150128000 :                   && TREE_TYPE (p) != error_mark_node)
    1355                 :    3715150 :                 set_type_context (TREE_TYPE (p), context);
    1356                 :            :             }
    1357                 :            : 
    1358                 :  392241000 :           gcc_fallthrough ();
    1359                 :            :           /* Parameters go in DECL_ARGUMENTS, not BLOCK_VARS, and have
    1360                 :            :              already been put there by store_parm_decls.  Unused-
    1361                 :            :              parameter warnings are handled by function.c.
    1362                 :            :              error_mark_node obviously does not go in BLOCK_VARS and
    1363                 :            :              does not get unused-variable warnings.  */
    1364                 :  392241000 :         case PARM_DECL:
    1365                 :  392241000 :         case ERROR_MARK:
    1366                 :            :           /* It is possible for a decl not to have a name.  We get
    1367                 :            :              here with b->id NULL in this case.  */
    1368                 :  392241000 :           if (b->id)
    1369                 :            :             {
    1370                 :  390142000 :               gcc_assert (I_SYMBOL_BINDING (b->id) == b);
    1371                 :  390142000 :               I_SYMBOL_BINDING (b->id) = b->shadowed;
    1372                 :  390142000 :               if (b->shadowed && b->shadowed->u.type)
    1373                 :    2289220 :                 TREE_TYPE (b->shadowed->decl) = b->shadowed->u.type;
    1374                 :            :             }
    1375                 :            :           break;
    1376                 :            : 
    1377                 :          0 :         default:
    1378                 :          0 :           gcc_unreachable ();
    1379                 :            :         }
    1380                 :            :     }
    1381                 :            : 
    1382                 :            : 
    1383                 :            :   /* Dispose of the block that we just made inside some higher level.  */
    1384                 :   53837700 :   if ((scope->function_body || scope == file_scope) && context)
    1385                 :            :     {
    1386                 :   20417000 :       DECL_INITIAL (context) = block;
    1387                 :   20417000 :       BLOCK_SUPERCONTEXT (block) = context;
    1388                 :            :     }
    1389                 :   33420700 :   else if (scope->outer)
    1390                 :            :     {
    1391                 :   33344000 :       if (block)
    1392                 :     196926 :         SCOPE_LIST_APPEND (scope->outer, blocks, block);
    1393                 :            :       /* If we did not make a block for the scope just exited, any
    1394                 :            :          blocks made for inner scopes must be carried forward so they
    1395                 :            :          will later become subblocks of something else.  */
    1396                 :   33147100 :       else if (scope->blocks)
    1397                 :     298528 :         SCOPE_LIST_CONCAT (scope->outer, blocks, scope, blocks);
    1398                 :            :     }
    1399                 :            : 
    1400                 :            :   /* Pop the current scope, and free the structure for reuse.  */
    1401                 :   53837700 :   current_scope = scope->outer;
    1402                 :   53837700 :   if (scope->function_body)
    1403                 :   20340300 :     current_function_scope = scope->outer_function;
    1404                 :            : 
    1405                 :   53837700 :   memset (scope, 0, sizeof (struct c_scope));
    1406                 :   53837700 :   scope->outer = scope_freelist;
    1407                 :   53837700 :   scope_freelist = scope;
    1408                 :            : 
    1409                 :   53837700 :   return block;
    1410                 :            : }
    1411                 :            : 
    1412                 :            : void
    1413                 :      77063 : push_file_scope (void)
    1414                 :            : {
    1415                 :      77063 :   tree decl;
    1416                 :            : 
    1417                 :      77063 :   if (file_scope)
    1418                 :            :     return;
    1419                 :            : 
    1420                 :      77063 :   push_scope ();
    1421                 :      77063 :   file_scope = current_scope;
    1422                 :            : 
    1423                 :      77063 :   start_fname_decls ();
    1424                 :            : 
    1425                 :  108348000 :   for (decl = visible_builtins; decl; decl = DECL_CHAIN (decl))
    1426                 :  108271000 :     bind (DECL_NAME (decl), decl, file_scope,
    1427                 :  108271000 :           /*invisible=*/false, /*nested=*/true, DECL_SOURCE_LOCATION (decl));
    1428                 :            : }
    1429                 :            : 
    1430                 :            : void
    1431                 :      76969 : pop_file_scope (void)
    1432                 :            : {
    1433                 :            :   /* In case there were missing closebraces, get us back to the global
    1434                 :            :      binding level.  */
    1435                 :      76969 :   while (current_scope != file_scope)
    1436                 :          0 :     pop_scope ();
    1437                 :            : 
    1438                 :            :   /* __FUNCTION__ is defined at file scope ("").  This
    1439                 :            :      call may not be necessary as my tests indicate it
    1440                 :            :      still works without it.  */
    1441                 :      76969 :   finish_fname_decls ();
    1442                 :            : 
    1443                 :      76969 :   check_inline_statics ();
    1444                 :            : 
    1445                 :            :   /* This is the point to write out a PCH if we're doing that.
    1446                 :            :      In that case we do not want to do anything else.  */
    1447                 :      76969 :   if (pch_file)
    1448                 :            :     {
    1449                 :        287 :       c_common_write_pch ();
    1450                 :            :       /* Ensure even the callers don't try to finalize the CU.  */
    1451                 :        287 :       flag_syntax_only = 1;
    1452                 :        287 :       return;
    1453                 :            :     }
    1454                 :            : 
    1455                 :            :   /* Pop off the file scope and close this translation unit.  */
    1456                 :      76682 :   pop_scope ();
    1457                 :      76682 :   file_scope = 0;
    1458                 :            : 
    1459                 :      76682 :   maybe_apply_pending_pragma_weaks ();
    1460                 :            : }
    1461                 :            : 
    1462                 :            : /* Adjust the bindings for the start of a statement expression.  */
    1463                 :            : 
    1464                 :            : void
    1465                 :      30243 : c_bindings_start_stmt_expr (struct c_spot_bindings* switch_bindings)
    1466                 :            : {
    1467                 :      30243 :   struct c_scope *scope;
    1468                 :            : 
    1469                 :     202963 :   for (scope = current_scope; scope != NULL; scope = scope->outer)
    1470                 :            :     {
    1471                 :     172720 :       struct c_binding *b;
    1472                 :            : 
    1473                 :     172720 :       if (!scope->has_label_bindings)
    1474                 :     170539 :         continue;
    1475                 :            : 
    1476                 :      11887 :       for (b = scope->bindings; b != NULL; b = b->prev)
    1477                 :            :         {
    1478                 :       9706 :           struct c_label_vars *label_vars;
    1479                 :       9706 :           unsigned int ix;
    1480                 :       9706 :           struct c_goto_bindings *g;
    1481                 :            : 
    1482                 :       9706 :           if (TREE_CODE (b->decl) != LABEL_DECL)
    1483                 :       1331 :             continue;
    1484                 :       8375 :           label_vars = b->u.label;
    1485                 :       8375 :           ++label_vars->label_bindings.stmt_exprs;
    1486                 :      12114 :           FOR_EACH_VEC_SAFE_ELT (label_vars->gotos, ix, g)
    1487                 :       1720 :             ++g->goto_bindings.stmt_exprs;
    1488                 :            :         }
    1489                 :            :     }
    1490                 :            : 
    1491                 :      30243 :   if (switch_bindings != NULL)
    1492                 :        111 :     ++switch_bindings->stmt_exprs;
    1493                 :      30243 : }
    1494                 :            : 
    1495                 :            : /* Adjust the bindings for the end of a statement expression.  */
    1496                 :            : 
    1497                 :            : void
    1498                 :      30243 : c_bindings_end_stmt_expr (struct c_spot_bindings *switch_bindings)
    1499                 :            : {
    1500                 :      30243 :   struct c_scope *scope;
    1501                 :            : 
    1502                 :     172720 :   for (scope = current_scope; scope != NULL; scope = scope->outer)
    1503                 :            :     {
    1504                 :     142477 :       struct c_binding *b;
    1505                 :            : 
    1506                 :     142477 :       if (!scope->has_label_bindings)
    1507                 :     140062 :         continue;
    1508                 :            : 
    1509                 :      15347 :       for (b = scope->bindings; b != NULL; b = b->prev)
    1510                 :            :         {
    1511                 :      12932 :           struct c_label_vars *label_vars;
    1512                 :      12932 :           unsigned int ix;
    1513                 :      12932 :           struct c_goto_bindings *g;
    1514                 :            : 
    1515                 :      12932 :           if (TREE_CODE (b->decl) != LABEL_DECL)
    1516                 :       1383 :             continue;
    1517                 :      11549 :           label_vars = b->u.label;
    1518                 :      11549 :           --label_vars->label_bindings.stmt_exprs;
    1519                 :      11549 :           if (label_vars->label_bindings.stmt_exprs < 0)
    1520                 :            :             {
    1521                 :       3309 :               label_vars->label_bindings.left_stmt_expr = true;
    1522                 :       3309 :               label_vars->label_bindings.stmt_exprs = 0;
    1523                 :            :             }
    1524                 :      15340 :           FOR_EACH_VEC_SAFE_ELT (label_vars->gotos, ix, g)
    1525                 :            :             {
    1526                 :       1720 :               --g->goto_bindings.stmt_exprs;
    1527                 :       1720 :               if (g->goto_bindings.stmt_exprs < 0)
    1528                 :            :                 {
    1529                 :        128 :                   g->goto_bindings.left_stmt_expr = true;
    1530                 :        128 :                   g->goto_bindings.stmt_exprs = 0;
    1531                 :            :                 }
    1532                 :            :             }
    1533                 :            :         }
    1534                 :            :     }
    1535                 :            : 
    1536                 :      30243 :   if (switch_bindings != NULL)
    1537                 :            :     {
    1538                 :        111 :       --switch_bindings->stmt_exprs;
    1539                 :        111 :       gcc_assert (switch_bindings->stmt_exprs >= 0);
    1540                 :            :     }
    1541                 :      30243 : }
    1542                 :            : 
    1543                 :            : /* Push a definition or a declaration of struct, union or enum tag "name".
    1544                 :            :    "type" should be the type node.
    1545                 :            :    We assume that the tag "name" is not already defined, and has a location
    1546                 :            :    of LOC.
    1547                 :            : 
    1548                 :            :    Note that the definition may really be just a forward reference.
    1549                 :            :    In that case, the TYPE_SIZE will be zero.  */
    1550                 :            : 
    1551                 :            : static void
    1552                 :    1000030 : pushtag (location_t loc, tree name, tree type)
    1553                 :            : {
    1554                 :            :   /* Record the identifier as the type's name if it has none.  */
    1555                 :    1476210 :   if (name && !TYPE_NAME (type))
    1556                 :     476182 :     TYPE_NAME (type) = name;
    1557                 :    1000030 :   bind (name, type, current_scope, /*invisible=*/false, /*nested=*/false, loc);
    1558                 :            : 
    1559                 :            :   /* Create a fake NULL-named TYPE_DECL node whose TREE_TYPE will be the
    1560                 :            :      tagged type we just added to the current scope.  This fake
    1561                 :            :      NULL-named TYPE_DECL node helps dwarfout.c to know when it needs
    1562                 :            :      to output a representation of a tagged type, and it also gives
    1563                 :            :      us a convenient place to record the "scope start" address for the
    1564                 :            :      tagged type.  */
    1565                 :            : 
    1566                 :    1000030 :   TYPE_STUB_DECL (type) = pushdecl (build_decl (loc,
    1567                 :            :                                                 TYPE_DECL, NULL_TREE, type));
    1568                 :            : 
    1569                 :            :   /* An approximation for now, so we can tell this is a function-scope tag.
    1570                 :            :      This will be updated in pop_scope.  */
    1571                 :    1000030 :   TYPE_CONTEXT (type) = DECL_CONTEXT (TYPE_STUB_DECL (type));
    1572                 :            : 
    1573                 :    1000030 :   if (warn_cxx_compat && name != NULL_TREE)
    1574                 :            :     {
    1575                 :        410 :       struct c_binding *b = I_SYMBOL_BINDING (name);
    1576                 :            : 
    1577                 :        410 :       if (b != NULL
    1578                 :         10 :           && b->decl != NULL_TREE
    1579                 :         10 :           && TREE_CODE (b->decl) == TYPE_DECL
    1580                 :         10 :           && (B_IN_CURRENT_SCOPE (b)
    1581                 :          5 :               || (current_scope == file_scope && B_IN_EXTERNAL_SCOPE (b)))
    1582                 :        415 :           && (TYPE_MAIN_VARIANT (TREE_TYPE (b->decl))
    1583                 :          5 :               != TYPE_MAIN_VARIANT (type)))
    1584                 :            :         {
    1585                 :         10 :           auto_diagnostic_group d;
    1586                 :          5 :           if (warning_at (loc, OPT_Wc___compat,
    1587                 :            :                           ("using %qD as both a typedef and a tag is "
    1588                 :            :                            "invalid in C++"), b->decl)
    1589                 :          5 :               && b->locus != UNKNOWN_LOCATION)
    1590                 :          4 :             inform (b->locus, "originally defined here");
    1591                 :            :         }
    1592                 :            :     }
    1593                 :    1000030 : }
    1594                 :            : 
    1595                 :            : /* An exported interface to pushtag.  This is used by the gdb plugin's
    1596                 :            :    binding oracle to introduce a new tag binding.  */
    1597                 :            : 
    1598                 :            : void
    1599                 :          0 : c_pushtag (location_t loc, tree name, tree type)
    1600                 :            : {
    1601                 :          0 :   pushtag (loc, name, type);
    1602                 :          0 : }
    1603                 :            : 
    1604                 :            : /* An exported interface to bind a declaration.  LOC is the location
    1605                 :            :    to use.  DECL is the declaration to bind.  The decl's name is used
    1606                 :            :    to determine how it is bound.  If DECL is a VAR_DECL, then
    1607                 :            :    IS_GLOBAL determines whether the decl is put into the global (file
    1608                 :            :    and external) scope or the current function's scope; if DECL is not
    1609                 :            :    a VAR_DECL then it is always put into the file scope.  */
    1610                 :            : 
    1611                 :            : void
    1612                 :          0 : c_bind (location_t loc, tree decl, bool is_global)
    1613                 :            : {
    1614                 :          0 :   struct c_scope *scope;
    1615                 :          0 :   bool nested = false;
    1616                 :            : 
    1617                 :          0 :   if (!VAR_P (decl) || current_function_scope == NULL)
    1618                 :            :     {
    1619                 :            :       /* Types and functions are always considered to be global.  */
    1620                 :          0 :       scope = file_scope;
    1621                 :          0 :       DECL_EXTERNAL (decl) = 1;
    1622                 :          0 :       TREE_PUBLIC (decl) = 1;
    1623                 :            :     }
    1624                 :          0 :   else if (is_global)
    1625                 :            :     {
    1626                 :            :       /* Also bind it into the external scope.  */
    1627                 :          0 :       bind (DECL_NAME (decl), decl, external_scope, true, false, loc);
    1628                 :          0 :       nested = true;
    1629                 :          0 :       scope = file_scope;
    1630                 :          0 :       DECL_EXTERNAL (decl) = 1;
    1631                 :          0 :       TREE_PUBLIC (decl) = 1;
    1632                 :            :     }
    1633                 :            :   else
    1634                 :            :     {
    1635                 :          0 :       DECL_CONTEXT (decl) = current_function_decl;
    1636                 :          0 :       TREE_PUBLIC (decl) = 0;
    1637                 :          0 :       scope = current_function_scope;
    1638                 :            :     }
    1639                 :            : 
    1640                 :          0 :   bind (DECL_NAME (decl), decl, scope, false, nested, loc);
    1641                 :          0 : }
    1642                 :            : 
    1643                 :            : 
    1644                 :            : /* Stores the first FILE*, const struct tm* etc. argument type (whatever
    1645                 :            :    it is) seen in a declaration of a file I/O etc. built-in, corresponding
    1646                 :            :    to the builtin_structptr_types array.  Subsequent declarations of such
    1647                 :            :    built-ins are expected to refer to it rather than to fileptr_type_node,
    1648                 :            :    etc. which is just void* (or to any other type).
    1649                 :            :    Used only by match_builtin_function_types.  */
    1650                 :            : 
    1651                 :            : static const unsigned builtin_structptr_type_count
    1652                 :            :   = sizeof builtin_structptr_types / sizeof builtin_structptr_types[0];
    1653                 :            : 
    1654                 :            : static GTY(()) tree last_structptr_types[builtin_structptr_type_count];
    1655                 :            : 
    1656                 :            : /* Returns true if types T1 and T2 representing return types or types
    1657                 :            :    of function arguments are close enough to be considered interchangeable
    1658                 :            :    in redeclarations of built-in functions.  */
    1659                 :            : 
    1660                 :            : static bool
    1661                 :     461134 : types_close_enough_to_match (tree t1, tree t2)
    1662                 :            : {
    1663                 :     922268 :   return (TYPE_MODE (t1) == TYPE_MODE (t2)
    1664                 :     460843 :           && POINTER_TYPE_P (t1) == POINTER_TYPE_P (t2)
    1665                 :    1692700 :           && FUNCTION_POINTER_TYPE_P (t1) == FUNCTION_POINTER_TYPE_P (t2));
    1666                 :            : }
    1667                 :            : 
    1668                 :            : /* Subroutine of compare_decls.  Allow harmless mismatches in return
    1669                 :            :    and argument types provided that the type modes match.  Set *STRICT
    1670                 :            :    and *ARGNO to the expected argument type and number in case of
    1671                 :            :    an argument type mismatch or null and zero otherwise.  Return
    1672                 :            :    a unified type given a suitable match, and 0 otherwise.  */
    1673                 :            : 
    1674                 :            : static tree
    1675                 :     106986 : match_builtin_function_types (tree newtype, tree oldtype,
    1676                 :            :                               tree *strict, unsigned *argno)
    1677                 :            : {
    1678                 :     106986 :   *argno = 0;
    1679                 :     106986 :   *strict = NULL_TREE;
    1680                 :            : 
    1681                 :            :   /* Accept the return type of the new declaration if it has the same
    1682                 :            :      mode and if they're both pointers or if neither is.  */
    1683                 :     106986 :   tree oldrettype = TREE_TYPE (oldtype);
    1684                 :     106986 :   tree newrettype = TREE_TYPE (newtype);
    1685                 :            : 
    1686                 :     106986 :   if (!types_close_enough_to_match (oldrettype, newrettype))
    1687                 :            :     return NULL_TREE;
    1688                 :            : 
    1689                 :            :   /* Check that the return types are compatible but don't fail if they
    1690                 :            :      are not (e.g., int vs long in ILP32) and just let the caller know.  */
    1691                 :     213328 :   if (!comptypes (TYPE_MAIN_VARIANT (oldrettype),
    1692                 :     106664 :                   TYPE_MAIN_VARIANT (newrettype)))
    1693                 :         36 :     *strict = oldrettype;
    1694                 :            : 
    1695                 :     106664 :   tree oldargs = TYPE_ARG_TYPES (oldtype);
    1696                 :     106664 :   tree newargs = TYPE_ARG_TYPES (newtype);
    1697                 :     106664 :   tree tryargs = newargs;
    1698                 :            : 
    1699                 :     106664 :   const unsigned nlst
    1700                 :            :     = sizeof last_structptr_types / sizeof last_structptr_types[0];
    1701                 :     106664 :   const unsigned nbst
    1702                 :            :     = sizeof builtin_structptr_types / sizeof builtin_structptr_types[0];
    1703                 :            : 
    1704                 :     106664 :   gcc_checking_assert (nlst == nbst);
    1705                 :            : 
    1706                 :     460740 :   for (unsigned i = 1; oldargs || newargs; ++i)
    1707                 :            :     {
    1708                 :     354217 :       if (!oldargs
    1709                 :     354217 :           || !newargs
    1710                 :     354148 :           || !TREE_VALUE (oldargs)
    1711                 :     708365 :           || !TREE_VALUE (newargs))
    1712                 :            :         return NULL_TREE;
    1713                 :            : 
    1714                 :     354148 :       tree oldtype = TYPE_MAIN_VARIANT (TREE_VALUE (oldargs));
    1715                 :     354148 :       tree newtype = TYPE_MAIN_VARIANT (TREE_VALUE (newargs));
    1716                 :            : 
    1717                 :     354148 :       if (!types_close_enough_to_match (oldtype, newtype))
    1718                 :            :         return NULL_TREE;
    1719                 :            : 
    1720                 :     354129 :       unsigned j = nbst;
    1721                 :     354129 :       if (POINTER_TYPE_P (oldtype))
    1722                 :            :         /* Iterate over well-known struct types like FILE (whose types
    1723                 :            :            aren't known to us) and compare the pointer to each to
    1724                 :            :            the pointer argument.  */
    1725                 :     725905 :         for (j = 0; j < nbst; ++j)
    1726                 :            :           {
    1727                 :     639577 :             if (TREE_VALUE (oldargs) != builtin_structptr_types[j].node)
    1728                 :     533245 :               continue;
    1729                 :            :             /* Store the first FILE* etc. argument type (whatever it is), and
    1730                 :            :                expect any subsequent declarations of file I/O etc. built-ins
    1731                 :            :                to refer to it rather than to fileptr_type_node etc. which is
    1732                 :            :                just void* (or const void*).  */
    1733                 :     106332 :             if (last_structptr_types[j])
    1734                 :            :               {
    1735                 :      93086 :                 if (!comptypes (last_structptr_types[j], newtype))
    1736                 :            :                   {
    1737                 :          2 :                     *argno = i;
    1738                 :          2 :                     *strict = last_structptr_types[j];
    1739                 :            :                   }
    1740                 :            :               }
    1741                 :            :             else
    1742                 :      13246 :               last_structptr_types[j] = newtype;
    1743                 :            :             break;
    1744                 :            :           }
    1745                 :            : 
    1746                 :     354129 :       if (j == nbst && !comptypes (oldtype, newtype))
    1747                 :            :         {
    1748                 :        229 :           if (POINTER_TYPE_P (oldtype))
    1749                 :            :             {
    1750                 :            :               /* For incompatible pointers, only reject differences in
    1751                 :            :                  the unqualified variants of the referenced types but
    1752                 :            :                  consider differences in qualifiers as benign (report
    1753                 :            :                  those to caller via *STRICT below).  */
    1754                 :        193 :               tree oldref = TYPE_MAIN_VARIANT (TREE_TYPE (oldtype));
    1755                 :        193 :               tree newref = TYPE_MAIN_VARIANT (TREE_TYPE (newtype));
    1756                 :        193 :               if (!comptypes (oldref, newref))
    1757                 :            :                 return NULL_TREE;
    1758                 :            :             }
    1759                 :            : 
    1760                 :        176 :           if (!*strict)
    1761                 :            :             {
    1762                 :        172 :               *argno = i;
    1763                 :        172 :               *strict = oldtype;
    1764                 :            :             }
    1765                 :            :         }
    1766                 :            : 
    1767                 :     354076 :       oldargs = TREE_CHAIN (oldargs);
    1768                 :     354076 :       newargs = TREE_CHAIN (newargs);
    1769                 :            :     }
    1770                 :            : 
    1771                 :     106523 :   tree trytype = build_function_type (newrettype, tryargs);
    1772                 :            : 
    1773                 :            :   /* Allow declaration to change transaction_safe attribute.  */
    1774                 :     106523 :   tree oldattrs = TYPE_ATTRIBUTES (oldtype);
    1775                 :     106523 :   tree oldtsafe = lookup_attribute ("transaction_safe", oldattrs);
    1776                 :     106523 :   tree newattrs = TYPE_ATTRIBUTES (newtype);
    1777                 :     106523 :   tree newtsafe = lookup_attribute ("transaction_safe", newattrs);
    1778                 :     106523 :   if (oldtsafe && !newtsafe)
    1779                 :          0 :     oldattrs = remove_attribute ("transaction_safe", oldattrs);
    1780                 :     106523 :   else if (newtsafe && !oldtsafe)
    1781                 :          7 :     oldattrs = tree_cons (get_identifier ("transaction_safe"),
    1782                 :            :                           NULL_TREE, oldattrs);
    1783                 :            : 
    1784                 :     106523 :   return build_type_attribute_variant (trytype, oldattrs);
    1785                 :            : }
    1786                 :            : 
    1787                 :            : /* Subroutine of diagnose_mismatched_decls.  Check for function type
    1788                 :            :    mismatch involving an empty arglist vs a nonempty one and give clearer
    1789                 :            :    diagnostics.  */
    1790                 :            : static void
    1791                 :         61 : diagnose_arglist_conflict (tree newdecl, tree olddecl,
    1792                 :            :                            tree newtype, tree oldtype)
    1793                 :            : {
    1794                 :         61 :   tree t;
    1795                 :            : 
    1796                 :         61 :   if (TREE_CODE (olddecl) != FUNCTION_DECL
    1797                 :         32 :       || !comptypes (TREE_TYPE (oldtype), TREE_TYPE (newtype))
    1798                 :         99 :       || !((!prototype_p (oldtype) && DECL_INITIAL (olddecl) == NULL_TREE)
    1799                 :         18 :            || (!prototype_p (newtype) && DECL_INITIAL (newdecl) == NULL_TREE)))
    1800                 :         53 :     return;
    1801                 :            : 
    1802                 :          8 :   t = TYPE_ARG_TYPES (oldtype);
    1803                 :          8 :   if (t == NULL_TREE)
    1804                 :          4 :     t = TYPE_ARG_TYPES (newtype);
    1805                 :          8 :   for (; t; t = TREE_CHAIN (t))
    1806                 :            :     {
    1807                 :          8 :       tree type = TREE_VALUE (t);
    1808                 :            : 
    1809                 :          8 :       if (TREE_CHAIN (t) == NULL_TREE
    1810                 :         14 :           && TYPE_MAIN_VARIANT (type) != void_type_node)
    1811                 :            :         {
    1812                 :          6 :           inform (input_location, "a parameter list with an ellipsis "
    1813                 :            :                   "cannot match an empty parameter name list declaration");
    1814                 :          6 :           break;
    1815                 :            :         }
    1816                 :            : 
    1817                 :          2 :       if (c_type_promotes_to (type) != type)
    1818                 :            :         {
    1819                 :          2 :           inform (input_location, "an argument type that has a default "
    1820                 :            :                   "promotion cannot match an empty parameter name list "
    1821                 :            :                   "declaration");
    1822                 :          2 :           break;
    1823                 :            :         }
    1824                 :            :     }
    1825                 :            : }
    1826                 :            : 
    1827                 :            : /* Another subroutine of diagnose_mismatched_decls.  OLDDECL is an
    1828                 :            :    old-style function definition, NEWDECL is a prototype declaration.
    1829                 :            :    Diagnose inconsistencies in the argument list.  Returns TRUE if
    1830                 :            :    the prototype is compatible, FALSE if not.  */
    1831                 :            : static bool
    1832                 :         19 : validate_proto_after_old_defn (tree newdecl, tree newtype, tree oldtype)
    1833                 :            : {
    1834                 :         19 :   tree newargs, oldargs;
    1835                 :         19 :   int i;
    1836                 :            : 
    1837                 :            : #define END_OF_ARGLIST(t) ((t) == void_type_node)
    1838                 :            : 
    1839                 :         19 :   oldargs = TYPE_ACTUAL_ARG_TYPES (oldtype);
    1840                 :         19 :   newargs = TYPE_ARG_TYPES (newtype);
    1841                 :         19 :   i = 1;
    1842                 :            : 
    1843                 :         45 :   for (;;)
    1844                 :            :     {
    1845                 :         32 :       tree oldargtype = TREE_VALUE (oldargs);
    1846                 :         32 :       tree newargtype = TREE_VALUE (newargs);
    1847                 :            : 
    1848                 :         32 :       if (oldargtype == error_mark_node || newargtype == error_mark_node)
    1849                 :            :         return false;
    1850                 :            : 
    1851                 :         31 :       oldargtype = (TYPE_ATOMIC (oldargtype)
    1852                 :          4 :                     ? c_build_qualified_type (TYPE_MAIN_VARIANT (oldargtype),
    1853                 :            :                                               TYPE_QUAL_ATOMIC)
    1854                 :         31 :                     : TYPE_MAIN_VARIANT (oldargtype));
    1855                 :         31 :       newargtype = (TYPE_ATOMIC (newargtype)
    1856                 :          2 :                     ? c_build_qualified_type (TYPE_MAIN_VARIANT (newargtype),
    1857                 :            :                                               TYPE_QUAL_ATOMIC)
    1858                 :         31 :                     : TYPE_MAIN_VARIANT (newargtype));
    1859                 :            : 
    1860                 :         31 :       if (END_OF_ARGLIST (oldargtype) && END_OF_ARGLIST (newargtype))
    1861                 :            :         break;
    1862                 :            : 
    1863                 :            :       /* Reaching the end of just one list means the two decls don't
    1864                 :            :          agree on the number of arguments.  */
    1865                 :         22 :       if (END_OF_ARGLIST (oldargtype))
    1866                 :            :         {
    1867                 :          2 :           error ("prototype for %q+D declares more arguments "
    1868                 :            :                  "than previous old-style definition", newdecl);
    1869                 :          2 :           return false;
    1870                 :            :         }
    1871                 :         20 :       else if (END_OF_ARGLIST (newargtype))
    1872                 :            :         {
    1873                 :          2 :           error ("prototype for %q+D declares fewer arguments "
    1874                 :            :                  "than previous old-style definition", newdecl);
    1875                 :          2 :           return false;
    1876                 :            :         }
    1877                 :            : 
    1878                 :            :       /* Type for passing arg must be consistent with that declared
    1879                 :            :          for the arg.  */
    1880                 :         18 :       else if (!comptypes (oldargtype, newargtype))
    1881                 :            :         {
    1882                 :          5 :           error ("prototype for %q+D declares argument %d"
    1883                 :            :                  " with incompatible type",
    1884                 :            :                  newdecl, i);
    1885                 :          5 :           return false;
    1886                 :            :         }
    1887                 :            : 
    1888                 :         13 :       oldargs = TREE_CHAIN (oldargs);
    1889                 :         13 :       newargs = TREE_CHAIN (newargs);
    1890                 :         13 :       i++;
    1891                 :         13 :     }
    1892                 :            : 
    1893                 :            :   /* If we get here, no errors were found, but do issue a warning
    1894                 :            :      for this poor-style construct.  */
    1895                 :          9 :   warning (0, "prototype for %q+D follows non-prototype definition",
    1896                 :            :            newdecl);
    1897                 :          9 :   return true;
    1898                 :            : #undef END_OF_ARGLIST
    1899                 :            : }
    1900                 :            : 
    1901                 :            : /* Subroutine of diagnose_mismatched_decls.  Report the location of DECL,
    1902                 :            :    first in a pair of mismatched declarations, using the diagnostic
    1903                 :            :    function DIAG.  */
    1904                 :            : static void
    1905                 :        243 : locate_old_decl (tree decl)
    1906                 :            : {
    1907                 :        119 :   if (TREE_CODE (decl) == FUNCTION_DECL && fndecl_built_in_p (decl)
    1908                 :        264 :       && !C_DECL_DECLARED_BUILTIN (decl))
    1909                 :            :     ;
    1910                 :        225 :   else if (DECL_INITIAL (decl))
    1911                 :         78 :     inform (input_location, "previous definition of %q+D was here", decl);
    1912                 :        147 :   else if (C_DECL_IMPLICIT (decl))
    1913                 :         15 :     inform (input_location, "previous implicit declaration of %q+D was here", decl);
    1914                 :            :   else
    1915                 :        132 :     inform (input_location, "previous declaration of %q+D was here", decl);
    1916                 :        243 : }
    1917                 :            : 
    1918                 :            : /* Subroutine of duplicate_decls.  Compare NEWDECL to OLDDECL.
    1919                 :            :    Returns true if the caller should proceed to merge the two, false
    1920                 :            :    if OLDDECL should simply be discarded.  As a side effect, issues
    1921                 :            :    all necessary diagnostics for invalid or poor-style combinations.
    1922                 :            :    If it returns true, writes the types of NEWDECL and OLDDECL to
    1923                 :            :    *NEWTYPEP and *OLDTYPEP - these may have been adjusted from
    1924                 :            :    TREE_TYPE (NEWDECL, OLDDECL) respectively.  */
    1925                 :            : 
    1926                 :            : static bool
    1927                 :    2456810 : diagnose_mismatched_decls (tree newdecl, tree olddecl,
    1928                 :            :                            tree *newtypep, tree *oldtypep)
    1929                 :            : {
    1930                 :    2456810 :   tree newtype, oldtype;
    1931                 :    2456810 :   bool retval = true;
    1932                 :            : 
    1933                 :            : #define DECL_EXTERN_INLINE(DECL) (DECL_DECLARED_INLINE_P (DECL)  \
    1934                 :            :                                   && DECL_EXTERNAL (DECL))
    1935                 :            : 
    1936                 :            :   /* If we have error_mark_node for either decl or type, just discard
    1937                 :            :      the previous decl - we're in an error cascade already.  */
    1938                 :    2456810 :   if (olddecl == error_mark_node || newdecl == error_mark_node)
    1939                 :            :     return false;
    1940                 :    2456800 :   *oldtypep = oldtype = TREE_TYPE (olddecl);
    1941                 :    2456800 :   *newtypep = newtype = TREE_TYPE (newdecl);
    1942                 :    2456800 :   if (oldtype == error_mark_node || newtype == error_mark_node)
    1943                 :            :     return false;
    1944                 :            : 
    1945                 :            :   /* Two different categories of symbol altogether.  This is an error
    1946                 :            :      unless OLDDECL is a builtin.  OLDDECL will be discarded in any case.  */
    1947                 :    2456790 :   if (TREE_CODE (olddecl) != TREE_CODE (newdecl))
    1948                 :            :     {
    1949                 :         23 :       if (!(TREE_CODE (olddecl) == FUNCTION_DECL
    1950                 :         17 :             && fndecl_built_in_p (olddecl)
    1951                 :         15 :             && !C_DECL_DECLARED_BUILTIN (olddecl)))
    1952                 :            :         {
    1953                 :         18 :           auto_diagnostic_group d;
    1954                 :          9 :           error ("%q+D redeclared as different kind of symbol", newdecl);
    1955                 :          9 :           locate_old_decl (olddecl);
    1956                 :            :         }
    1957                 :         14 :       else if (TREE_PUBLIC (newdecl))
    1958                 :          3 :         warning (OPT_Wbuiltin_declaration_mismatch,
    1959                 :            :                  "built-in function %q+D declared as non-function",
    1960                 :            :                  newdecl);
    1961                 :            :       else
    1962                 :         11 :         warning (OPT_Wshadow, "declaration of %q+D shadows "
    1963                 :            :                  "a built-in function", newdecl);
    1964                 :         23 :       return false;
    1965                 :            :     }
    1966                 :            : 
    1967                 :            :   /* Enumerators have no linkage, so may only be declared once in a
    1968                 :            :      given scope.  */
    1969                 :    2456770 :   if (TREE_CODE (olddecl) == CONST_DECL)
    1970                 :            :     {
    1971                 :          2 :       auto_diagnostic_group d;
    1972                 :          2 :       error ("redeclaration of enumerator %q+D", newdecl);
    1973                 :          2 :       locate_old_decl (olddecl);
    1974                 :          2 :       return false;
    1975                 :            :     }
    1976                 :            : 
    1977                 :    2456770 :   bool pedwarned = false;
    1978                 :    2456770 :   bool warned = false;
    1979                 :    4913540 :   auto_diagnostic_group d;
    1980                 :            : 
    1981                 :    2456770 :   if (!comptypes (oldtype, newtype))
    1982                 :            :     {
    1983                 :     107066 :       if (TREE_CODE (olddecl) == FUNCTION_DECL
    1984                 :     107037 :           && fndecl_built_in_p (olddecl, BUILT_IN_NORMAL)
    1985                 :     214053 :           && !C_DECL_DECLARED_BUILTIN (olddecl))
    1986                 :            :         {
    1987                 :            :           /* Accept "harmless" mismatches in function types such
    1988                 :            :              as missing qualifiers or int vs long when they're the same
    1989                 :            :              size.  However, diagnose return and argument types that are
    1990                 :            :              incompatible according to language rules.  */
    1991                 :     106986 :           tree mismatch_expect;
    1992                 :     106986 :           unsigned mismatch_argno;
    1993                 :            : 
    1994                 :     106986 :           tree trytype = match_builtin_function_types (newtype, oldtype,
    1995                 :            :                                                        &mismatch_expect,
    1996                 :            :                                                        &mismatch_argno);
    1997                 :            : 
    1998                 :     106986 :           if (trytype && comptypes (newtype, trytype))
    1999                 :     106523 :             *oldtypep = oldtype = trytype;
    2000                 :            :           else
    2001                 :            :             {
    2002                 :            :               /* If types don't match for a built-in, throw away the
    2003                 :            :                  built-in.  No point in calling locate_old_decl here, it
    2004                 :            :                  won't print anything.  */
    2005                 :        463 :               const char *header = header_for_builtin_fn (olddecl);
    2006                 :        463 :               location_t loc = DECL_SOURCE_LOCATION (newdecl);
    2007                 :        463 :               if (warning_at (loc, OPT_Wbuiltin_declaration_mismatch,
    2008                 :            :                               "conflicting types for built-in function %q+D; "
    2009                 :            :                               "expected %qT",
    2010                 :            :                               newdecl, oldtype)
    2011                 :        463 :                   && header)
    2012                 :            :                 {
    2013                 :            :                   /* Suggest the right header to include as the preferred
    2014                 :            :                      solution rather than the spelling of the declaration.  */
    2015                 :        390 :                   rich_location richloc (line_table, loc);
    2016                 :        195 :                   maybe_add_include_fixit (&richloc, header, true);
    2017                 :        195 :                   inform (&richloc,
    2018                 :            :                           "%qD is declared in header %qs", olddecl, header);
    2019                 :            :                 }
    2020                 :        463 :               return false;
    2021                 :            :             }
    2022                 :            : 
    2023                 :     106523 :           if (mismatch_expect && extra_warnings)
    2024                 :            :             {
    2025                 :          5 :               location_t newloc = DECL_SOURCE_LOCATION (newdecl);
    2026                 :          5 :               bool warned = false;
    2027                 :          5 :               if (mismatch_argno)
    2028                 :          5 :                 warned = warning_at (newloc, OPT_Wbuiltin_declaration_mismatch,
    2029                 :            :                                      "mismatch in argument %u type of built-in "
    2030                 :            :                                      "function %qD; expected %qT",
    2031                 :            :                                      mismatch_argno, newdecl, mismatch_expect);
    2032                 :            :               else
    2033                 :          0 :                 warned = warning_at (newloc, OPT_Wbuiltin_declaration_mismatch,
    2034                 :            :                                      "mismatch in return type of built-in "
    2035                 :            :                                      "function %qD; expected %qT",
    2036                 :            :                                      newdecl, mismatch_expect);
    2037                 :          5 :               const char *header = header_for_builtin_fn (olddecl);
    2038                 :          5 :               if (warned && header)
    2039                 :            :                 {
    2040                 :         10 :                   rich_location richloc (line_table, newloc);
    2041                 :          5 :                   maybe_add_include_fixit (&richloc, header, true);
    2042                 :          5 :                   inform (&richloc,
    2043                 :            :                           "%qD is declared in header %qs", olddecl, header);
    2044                 :            :                 }
    2045                 :            :             }
    2046                 :            :         }
    2047                 :         80 :       else if (TREE_CODE (olddecl) == FUNCTION_DECL
    2048                 :        131 :                && DECL_IS_BUILTIN (olddecl))
    2049                 :            :         {
    2050                 :            :           /* A conflicting function declaration for a predeclared
    2051                 :            :              function that isn't actually built in.  Objective C uses
    2052                 :            :              these.  The new declaration silently overrides everything
    2053                 :            :              but the volatility (i.e. noreturn) indication.  See also
    2054                 :            :              below.  FIXME: Make Objective C use normal builtins.  */
    2055                 :          0 :           TREE_THIS_VOLATILE (newdecl) |= TREE_THIS_VOLATILE (olddecl);
    2056                 :          0 :           return false;
    2057                 :            :         }
    2058                 :            :       /* Permit void foo (...) to match int foo (...) if the latter is
    2059                 :            :          the definition and implicit int was used.  See
    2060                 :            :          c-torture/compile/920625-2.c.  */
    2061                 :         51 :       else if (TREE_CODE (newdecl) == FUNCTION_DECL && DECL_INITIAL (newdecl)
    2062                 :         22 :                && TYPE_MAIN_VARIANT (TREE_TYPE (oldtype)) == void_type_node
    2063                 :          9 :                && TYPE_MAIN_VARIANT (TREE_TYPE (newtype)) == integer_type_node
    2064                 :         98 :                && C_FUNCTION_IMPLICIT_INT (newdecl) && !DECL_INITIAL (olddecl))
    2065                 :            :         {
    2066                 :          8 :           pedwarned = pedwarn (input_location, 0,
    2067                 :            :                                "conflicting types for %q+D", newdecl);
    2068                 :            :           /* Make sure we keep void as the return type.  */
    2069                 :          8 :           TREE_TYPE (newdecl) = *newtypep = newtype = oldtype;
    2070                 :          8 :           C_FUNCTION_IMPLICIT_INT (newdecl) = 0;
    2071                 :            :         }
    2072                 :            :       /* Permit void foo (...) to match an earlier call to foo (...) with
    2073                 :            :          no declared type (thus, implicitly int).  */
    2074                 :         72 :       else if (TREE_CODE (newdecl) == FUNCTION_DECL
    2075                 :         43 :                && TYPE_MAIN_VARIANT (TREE_TYPE (newtype)) == void_type_node
    2076                 :         31 :                && TYPE_MAIN_VARIANT (TREE_TYPE (oldtype)) == integer_type_node
    2077                 :         87 :                && C_DECL_IMPLICIT (olddecl) && !DECL_INITIAL (olddecl))
    2078                 :            :         {
    2079                 :         11 :           pedwarned = pedwarn (input_location, 0,
    2080                 :            :                                "conflicting types for %q+D", newdecl);
    2081                 :            :           /* Make sure we keep void as the return type.  */
    2082                 :         11 :           TREE_TYPE (olddecl) = *oldtypep = oldtype = newtype;
    2083                 :            :         }
    2084                 :            :       else
    2085                 :            :         {
    2086                 :         61 :           int new_quals = TYPE_QUALS (newtype);
    2087                 :         61 :           int old_quals = TYPE_QUALS (oldtype);
    2088                 :            : 
    2089                 :         61 :           if (new_quals != old_quals)
    2090                 :            :             {
    2091                 :          7 :               addr_space_t new_addr = DECODE_QUAL_ADDR_SPACE (new_quals);
    2092                 :          7 :               addr_space_t old_addr = DECODE_QUAL_ADDR_SPACE (old_quals);
    2093                 :          7 :               if (new_addr != old_addr)
    2094                 :            :                 {
    2095                 :          0 :                   if (ADDR_SPACE_GENERIC_P (new_addr))
    2096                 :          0 :                     error ("conflicting named address spaces (generic vs %s) "
    2097                 :            :                            "for %q+D",
    2098                 :            :                            c_addr_space_name (old_addr), newdecl);
    2099                 :          0 :                   else if (ADDR_SPACE_GENERIC_P (old_addr))
    2100                 :          0 :                     error ("conflicting named address spaces (%s vs generic) "
    2101                 :            :                            "for %q+D",
    2102                 :            :                            c_addr_space_name (new_addr), newdecl);
    2103                 :            :                   else
    2104                 :          0 :                     error ("conflicting named address spaces (%s vs %s) "
    2105                 :            :                            "for %q+D",
    2106                 :            :                            c_addr_space_name (new_addr),
    2107                 :            :                            c_addr_space_name (old_addr),
    2108                 :            :                            newdecl);
    2109                 :            :                 }
    2110                 :            : 
    2111                 :          7 :               if (CLEAR_QUAL_ADDR_SPACE (new_quals)
    2112                 :          7 :                   != CLEAR_QUAL_ADDR_SPACE (old_quals))
    2113                 :          7 :                 error ("conflicting type qualifiers for %q+D", newdecl);
    2114                 :            :             }
    2115                 :            :           else
    2116                 :         54 :             error ("conflicting types for %q+D", newdecl);
    2117                 :         61 :           diagnose_arglist_conflict (newdecl, olddecl, newtype, oldtype);
    2118                 :         61 :           locate_old_decl (olddecl);
    2119                 :         61 :           return false;
    2120                 :            :         }
    2121                 :            :     }
    2122                 :            : 
    2123                 :            :   /* Redeclaration of a type is a constraint violation (6.7.2.3p1),
    2124                 :            :      but silently ignore the redeclaration if either is in a system
    2125                 :            :      header.  (Conflicting redeclarations were handled above.)  This
    2126                 :            :      is allowed for C11 if the types are the same, not just
    2127                 :            :      compatible.  */
    2128                 :    2456240 :   if (TREE_CODE (newdecl) == TYPE_DECL)
    2129                 :            :     {
    2130                 :      70773 :       bool types_different = false;
    2131                 :      70773 :       int comptypes_result;
    2132                 :            : 
    2133                 :      70773 :       comptypes_result
    2134                 :      70773 :         = comptypes_check_different_types (oldtype, newtype, &types_different);
    2135                 :            : 
    2136                 :      70773 :       if (comptypes_result != 1 || types_different)
    2137                 :            :         {
    2138                 :          9 :           error ("redefinition of typedef %q+D with different type", newdecl);
    2139                 :          9 :           locate_old_decl (olddecl);
    2140                 :          9 :           return false;
    2141                 :            :         }
    2142                 :            : 
    2143                 :      70764 :       if (DECL_IN_SYSTEM_HEADER (newdecl)
    2144                 :       2097 :           || DECL_IN_SYSTEM_HEADER (olddecl)
    2145                 :       1915 :           || TREE_NO_WARNING (newdecl)
    2146                 :      72679 :           || TREE_NO_WARNING (olddecl))
    2147                 :      68849 :         return true;  /* Allow OLDDECL to continue in use.  */
    2148                 :            : 
    2149                 :       1915 :       if (variably_modified_type_p (newtype, NULL))
    2150                 :            :         {
    2151                 :          3 :           error ("redefinition of typedef %q+D with variably modified type",
    2152                 :            :                  newdecl);
    2153                 :          3 :           locate_old_decl (olddecl);
    2154                 :            :         }
    2155                 :       1912 :       else if (pedwarn_c99 (input_location, OPT_Wpedantic,
    2156                 :            :                             "redefinition of typedef %q+D", newdecl))
    2157                 :          8 :         locate_old_decl (olddecl);
    2158                 :            : 
    2159                 :       1915 :       return true;
    2160                 :            :     }
    2161                 :            : 
    2162                 :            :   /* Function declarations can either be 'static' or 'extern' (no
    2163                 :            :      qualifier is equivalent to 'extern' - C99 6.2.2p5) and therefore
    2164                 :            :      can never conflict with each other on account of linkage
    2165                 :            :      (6.2.2p4).  Multiple definitions are not allowed (6.9p3,5) but
    2166                 :            :      gnu89 mode permits two definitions if one is 'extern inline' and
    2167                 :            :      one is not.  The non- extern-inline definition supersedes the
    2168                 :            :      extern-inline definition.  */
    2169                 :            : 
    2170                 :    2385470 :   else if (TREE_CODE (newdecl) == FUNCTION_DECL)
    2171                 :            :     {
    2172                 :            :       /* If you declare a built-in function name as static, or
    2173                 :            :          define the built-in with an old-style definition (so we
    2174                 :            :          can't validate the argument list) the built-in definition is
    2175                 :            :          overridden, but optionally warn this was a bad choice of name.  */
    2176                 :    2372240 :       if (fndecl_built_in_p (olddecl)
    2177                 :    4122910 :           && !C_DECL_DECLARED_BUILTIN (olddecl))
    2178                 :            :         {
    2179                 :    1653100 :           if (!TREE_PUBLIC (newdecl)
    2180                 :    3306110 :               || (DECL_INITIAL (newdecl)
    2181                 :       5214 :                   && !prototype_p (TREE_TYPE (newdecl))))
    2182                 :            :             {
    2183                 :        120 :               warning_at (DECL_SOURCE_LOCATION (newdecl),
    2184                 :            :                           OPT_Wshadow, "declaration of %qD shadows "
    2185                 :            :                           "a built-in function", newdecl);
    2186                 :            :               /* Discard the old built-in function.  */
    2187                 :        120 :               return false;
    2188                 :            :             }
    2189                 :            : 
    2190                 :    1652980 :           if (!prototype_p (TREE_TYPE (newdecl)))
    2191                 :            :             {
    2192                 :            :               /* Set for built-ins that take no arguments.  */
    2193                 :        964 :               bool func_void_args = false;
    2194                 :        964 :               if (tree at = TYPE_ARG_TYPES (oldtype))
    2195                 :        964 :                 func_void_args = VOID_TYPE_P (TREE_VALUE (at));
    2196                 :            : 
    2197                 :        964 :               if (extra_warnings && !func_void_args)
    2198                 :         94 :                 warning_at (DECL_SOURCE_LOCATION (newdecl),
    2199                 :            :                             OPT_Wbuiltin_declaration_mismatch,
    2200                 :            :                             "declaration of built-in function %qD without "
    2201                 :            :                             "a prototype; expected %qT",
    2202                 :         47 :                             newdecl, TREE_TYPE (olddecl));
    2203                 :            :             }
    2204                 :            :         }
    2205                 :            : 
    2206                 :    2372120 :       if (DECL_INITIAL (newdecl))
    2207                 :            :         {
    2208                 :     184511 :           if (DECL_INITIAL (olddecl))
    2209                 :            :             {
    2210                 :            :               /* If both decls are in the same TU and the new declaration
    2211                 :            :                  isn't overriding an extern inline reject the new decl.
    2212                 :            :                  In c99, no overriding is allowed in the same translation
    2213                 :            :                  unit.  */
    2214                 :        236 :               if ((!DECL_EXTERN_INLINE (olddecl)
    2215                 :        108 :                    || DECL_EXTERN_INLINE (newdecl)
    2216                 :        106 :                    || (!flag_gnu89_inline
    2217                 :         15 :                        && (!DECL_DECLARED_INLINE_P (olddecl)
    2218                 :         15 :                            || !lookup_attribute ("gnu_inline",
    2219                 :         15 :                                                  DECL_ATTRIBUTES (olddecl)))
    2220                 :          0 :                        && (!DECL_DECLARED_INLINE_P (newdecl)
    2221                 :          0 :                            || !lookup_attribute ("gnu_inline",
    2222                 :          0 :                                                  DECL_ATTRIBUTES (newdecl))))
    2223                 :            :                   )
    2224                 :        130 :                   && same_translation_unit_p (newdecl, olddecl))
    2225                 :            :                 {
    2226                 :         19 :                   auto_diagnostic_group d;
    2227                 :         19 :                   error ("redefinition of %q+D", newdecl);
    2228                 :         19 :                   locate_old_decl (olddecl);
    2229                 :         19 :                   return false;
    2230                 :            :                 }
    2231                 :            :             }
    2232                 :            :         }
    2233                 :            :       /* If we have a prototype after an old-style function definition,
    2234                 :            :          the argument types must be checked specially.  */
    2235                 :    2187610 :       else if (DECL_INITIAL (olddecl)
    2236                 :       1435 :                && !prototype_p (oldtype) && prototype_p (newtype)
    2237                 :    2187630 :                && TYPE_ACTUAL_ARG_TYPES (oldtype))
    2238                 :            :         {
    2239                 :         28 :           auto_diagnostic_group d;
    2240                 :         19 :           if (!validate_proto_after_old_defn (newdecl, newtype, oldtype))
    2241                 :            :             {
    2242                 :         10 :               locate_old_decl (olddecl);
    2243                 :         10 :               return false;
    2244                 :            :             }
    2245                 :            :         }
    2246                 :            :       /* A non-static declaration (even an "extern") followed by a
    2247                 :            :          static declaration is undefined behavior per C99 6.2.2p3-5,7.
    2248                 :            :          The same is true for a static forward declaration at block
    2249                 :            :          scope followed by a non-static declaration/definition at file
    2250                 :            :          scope.  Static followed by non-static at the same scope is
    2251                 :            :          not undefined behavior, and is the most convenient way to get
    2252                 :            :          some effects (see e.g.  what unwind-dw2-fde-glibc.c does to
    2253                 :            :          the definition of _Unwind_Find_FDE in unwind-dw2-fde.c), but
    2254                 :            :          we do diagnose it if -Wtraditional.  */
    2255                 :    2372090 :       if (TREE_PUBLIC (olddecl) && !TREE_PUBLIC (newdecl))
    2256                 :            :         {
    2257                 :            :           /* Two exceptions to the rule.  If olddecl is an extern
    2258                 :            :              inline, or a predeclared function that isn't actually
    2259                 :            :              built in, newdecl silently overrides olddecl.  The latter
    2260                 :            :              occur only in Objective C; see also above.  (FIXME: Make
    2261                 :            :              Objective C use normal builtins.)  */
    2262                 :         17 :           if (!DECL_IS_BUILTIN (olddecl)
    2263                 :         48 :               && !DECL_EXTERN_INLINE (olddecl))
    2264                 :            :             {
    2265                 :          6 :               auto_diagnostic_group d;
    2266                 :          3 :               error ("static declaration of %q+D follows "
    2267                 :            :                      "non-static declaration", newdecl);
    2268                 :          3 :               locate_old_decl (olddecl);
    2269                 :            :             }
    2270                 :         17 :           return false;
    2271                 :            :         }
    2272                 :    2372070 :       else if (TREE_PUBLIC (newdecl) && !TREE_PUBLIC (olddecl))
    2273                 :            :         {
    2274                 :       1747 :           if (DECL_CONTEXT (olddecl))
    2275                 :            :             {
    2276                 :          0 :               auto_diagnostic_group d;
    2277                 :          0 :               error ("non-static declaration of %q+D follows "
    2278                 :            :                      "static declaration", newdecl);
    2279                 :          0 :               locate_old_decl (olddecl);
    2280                 :          0 :               return false;
    2281                 :            :             }
    2282                 :       1747 :           else if (warn_traditional)
    2283                 :            :             {
    2284                 :          2 :               warned |= warning (OPT_Wtraditional,
    2285                 :            :                                  "non-static declaration of %q+D "
    2286                 :            :                                  "follows static declaration", newdecl);
    2287                 :            :             }
    2288                 :            :         }
    2289                 :            : 
    2290                 :            :       /* Make sure gnu_inline attribute is either not present, or
    2291                 :            :          present on all inline decls.  */
    2292                 :    2372070 :       if (DECL_DECLARED_INLINE_P (olddecl)
    2293                 :    2373620 :           && DECL_DECLARED_INLINE_P (newdecl))
    2294                 :            :         {
    2295                 :        716 :           bool newa = lookup_attribute ("gnu_inline",
    2296                 :        716 :                                         DECL_ATTRIBUTES (newdecl)) != NULL;
    2297                 :        716 :           bool olda = lookup_attribute ("gnu_inline",
    2298                 :        716 :                                         DECL_ATTRIBUTES (olddecl)) != NULL;
    2299                 :        716 :           if (newa != olda)
    2300                 :            :             {
    2301                 :          0 :               auto_diagnostic_group d;
    2302                 :          0 :               error_at (input_location, "%<gnu_inline%> attribute present on %q+D",
    2303                 :            :                         newa ? newdecl : olddecl);
    2304                 :          0 :               error_at (DECL_SOURCE_LOCATION (newa ? olddecl : newdecl),
    2305                 :            :                         "but not here");
    2306                 :            :             }
    2307                 :            :         }
    2308                 :            :     }
    2309                 :      13231 :   else if (VAR_P (newdecl))
    2310                 :            :     {
    2311                 :            :       /* Only variables can be thread-local, and all declarations must
    2312                 :            :          agree on this property.  */
    2313                 :      13201 :       if (C_DECL_THREADPRIVATE_P (olddecl) && !DECL_THREAD_LOCAL_P (newdecl))
    2314                 :            :         {
    2315                 :            :           /* Nothing to check.  Since OLDDECL is marked threadprivate
    2316                 :            :              and NEWDECL does not have a thread-local attribute, we
    2317                 :            :              will merge the threadprivate attribute into NEWDECL.  */
    2318                 :            :           ;
    2319                 :            :         }
    2320                 :      63142 :       else if (DECL_THREAD_LOCAL_P (newdecl) != DECL_THREAD_LOCAL_P (olddecl))
    2321                 :            :         {
    2322                 :          6 :           auto_diagnostic_group d;
    2323                 :         10 :           if (DECL_THREAD_LOCAL_P (newdecl))
    2324                 :          3 :             error ("thread-local declaration of %q+D follows "
    2325                 :            :                    "non-thread-local declaration", newdecl);
    2326                 :            :           else
    2327                 :          3 :             error ("non-thread-local declaration of %q+D follows "
    2328                 :            :                    "thread-local declaration", newdecl);
    2329                 :            : 
    2330                 :          6 :           locate_old_decl (olddecl);
    2331                 :          6 :           return false;
    2332                 :            :         }
    2333                 :            : 
    2334                 :            :       /* Multiple initialized definitions are not allowed (6.9p3,5).  */
    2335                 :      13652 :       if (DECL_INITIAL (newdecl) && DECL_INITIAL (olddecl))
    2336                 :            :         {
    2337                 :          1 :           auto_diagnostic_group d;
    2338                 :          1 :           error ("redefinition of %q+D", newdecl);
    2339                 :          1 :           locate_old_decl (olddecl);
    2340                 :          1 :           return false;
    2341                 :            :         }
    2342                 :            : 
    2343                 :            :       /* Objects declared at file scope: if the first declaration had
    2344                 :            :          external linkage (even if it was an external reference) the
    2345                 :            :          second must have external linkage as well, or the behavior is
    2346                 :            :          undefined.  If the first declaration had internal linkage, then
    2347                 :            :          the second must too, or else be an external reference (in which
    2348                 :            :          case the composite declaration still has internal linkage).
    2349                 :            :          As for function declarations, we warn about the static-then-
    2350                 :            :          extern case only for -Wtraditional.  See generally 6.2.2p3-5,7.  */
    2351                 :      13209 :       if (DECL_FILE_SCOPE_P (newdecl)
    2352                 :      13194 :           && TREE_PUBLIC (newdecl) != TREE_PUBLIC (olddecl))
    2353                 :            :         {
    2354                 :        288 :           if (DECL_EXTERNAL (newdecl))
    2355                 :            :             {
    2356                 :        286 :               if (!DECL_FILE_SCOPE_P (olddecl))
    2357                 :            :                 {
    2358                 :          2 :                   auto_diagnostic_group d;
    2359                 :          2 :                   error ("extern declaration of %q+D follows "
    2360                 :            :                          "declaration with no linkage", newdecl);
    2361                 :          2 :                   locate_old_decl (olddecl);
    2362                 :          2 :                   return false;
    2363                 :            :                 }
    2364                 :        284 :               else if (warn_traditional)
    2365                 :            :                 {
    2366                 :          0 :                   warned |= warning (OPT_Wtraditional,
    2367                 :            :                                      "non-static declaration of %q+D "
    2368                 :            :                                      "follows static declaration", newdecl);
    2369                 :            :                 }
    2370                 :            :             }
    2371                 :            :           else
    2372                 :            :             {
    2373                 :          2 :               auto_diagnostic_group d;
    2374                 :          2 :               if (TREE_PUBLIC (newdecl))
    2375                 :          2 :                 error ("non-static declaration of %q+D follows "
    2376                 :            :                        "static declaration", newdecl);
    2377                 :            :               else
    2378                 :          0 :                 error ("static declaration of %q+D follows "
    2379                 :            :                        "non-static declaration", newdecl);
    2380                 :            : 
    2381                 :          2 :               locate_old_decl (olddecl);
    2382                 :          2 :               return false;
    2383                 :            :             }
    2384                 :            :         }
    2385                 :            :       /* Two objects with the same name declared at the same block
    2386                 :            :          scope must both be external references (6.7p3).  */
    2387                 :      12906 :       else if (!DECL_FILE_SCOPE_P (newdecl))
    2388                 :            :         {
    2389                 :         15 :           if (DECL_EXTERNAL (newdecl))
    2390                 :            :             {
    2391                 :            :               /* Extern with initializer at block scope, which will
    2392                 :            :                  already have received an error.  */
    2393                 :            :             }
    2394                 :         13 :           else if (DECL_EXTERNAL (olddecl))
    2395                 :            :             {
    2396                 :          4 :               auto_diagnostic_group d;
    2397                 :          2 :               error ("declaration of %q+D with no linkage follows "
    2398                 :            :                      "extern declaration", newdecl);
    2399                 :          2 :               locate_old_decl (olddecl);
    2400                 :            :             }
    2401                 :            :           else
    2402                 :            :             {
    2403                 :         22 :               auto_diagnostic_group d;
    2404                 :         11 :               error ("redeclaration of %q+D with no linkage", newdecl);
    2405                 :         11 :               locate_old_decl (olddecl);
    2406                 :            :             }
    2407                 :            : 
    2408                 :         15 :           return false;
    2409                 :            :         }
    2410                 :            : 
    2411                 :            :       /* C++ does not permit a decl to appear multiple times at file
    2412                 :            :          scope.  */
    2413                 :      13175 :       if (warn_cxx_compat
    2414                 :         21 :           && DECL_FILE_SCOPE_P (newdecl)
    2415                 :         21 :           && !DECL_EXTERNAL (newdecl)
    2416                 :      13185 :           && !DECL_EXTERNAL (olddecl))
    2417                 :          5 :         warned |= warning_at (DECL_SOURCE_LOCATION (newdecl),
    2418                 :            :                               OPT_Wc___compat,
    2419                 :            :                               ("duplicate declaration of %qD is "
    2420                 :            :                                "invalid in C++"),
    2421                 :            :                               newdecl);
    2422                 :            :     }
    2423                 :            : 
    2424                 :            :   /* warnings */
    2425                 :            :   /* All decls must agree on a visibility.  */
    2426                 :    2385280 :   if (CODE_CONTAINS_STRUCT (TREE_CODE (newdecl), TS_DECL_WITH_VIS)
    2427                 :    2856130 :       && DECL_VISIBILITY_SPECIFIED (newdecl) && DECL_VISIBILITY_SPECIFIED (olddecl)
    2428                 :    2386000 :       && DECL_VISIBILITY (newdecl) != DECL_VISIBILITY (olddecl))
    2429                 :            :     {
    2430                 :          1 :       warned |= warning (0, "redeclaration of %q+D with different visibility "
    2431                 :            :                          "(old visibility preserved)", newdecl);
    2432                 :            :     }
    2433                 :            : 
    2434                 :    2385280 :   if (TREE_CODE (newdecl) == FUNCTION_DECL)
    2435                 :    2372070 :     warned |= diagnose_mismatched_attributes (olddecl, newdecl);
    2436                 :            :   else /* PARM_DECL, VAR_DECL */
    2437                 :            :     {
    2438                 :            :       /* Redeclaration of a parameter is a constraint violation (this is
    2439                 :            :          not explicitly stated, but follows from C99 6.7p3 [no more than
    2440                 :            :          one declaration of the same identifier with no linkage in the
    2441                 :            :          same scope, except type tags] and 6.2.2p6 [parameters have no
    2442                 :            :          linkage]).  We must check for a forward parameter declaration,
    2443                 :            :          indicated by TREE_ASM_WRITTEN on the old declaration - this is
    2444                 :            :          an extension, the mandatory diagnostic for which is handled by
    2445                 :            :          mark_forward_parm_decls.  */
    2446                 :            : 
    2447                 :      13205 :       if (TREE_CODE (newdecl) == PARM_DECL
    2448                 :         30 :           && (!TREE_ASM_WRITTEN (olddecl) || TREE_ASM_WRITTEN (newdecl)))
    2449                 :            :         {
    2450                 :          2 :           auto_diagnostic_group d;
    2451                 :          2 :           error ("redefinition of parameter %q+D", newdecl);
    2452                 :          2 :           locate_old_decl (olddecl);
    2453                 :          2 :           return false;
    2454                 :            :         }
    2455                 :            :     }
    2456                 :            : 
    2457                 :            :   /* Optional warning for completely redundant decls.  */
    2458                 :    2385280 :   if (!warned && !pedwarned
    2459                 :    2385240 :       && warn_redundant_decls
    2460                 :            :       /* Don't warn about a function declaration followed by a
    2461                 :            :          definition.  */
    2462                 :         18 :       && !(TREE_CODE (newdecl) == FUNCTION_DECL
    2463                 :          2 :            && DECL_INITIAL (newdecl) && !DECL_INITIAL (olddecl))
    2464                 :            :       /* Don't warn about redundant redeclarations of builtins.  */
    2465                 :         18 :       && !(TREE_CODE (newdecl) == FUNCTION_DECL
    2466                 :          2 :            && !fndecl_built_in_p (newdecl)
    2467                 :          2 :            && fndecl_built_in_p (olddecl)
    2468                 :          2 :            && !C_DECL_DECLARED_BUILTIN (olddecl))
    2469                 :            :       /* Don't warn about an extern followed by a definition.  */
    2470                 :         18 :       && !(DECL_EXTERNAL (olddecl) && !DECL_EXTERNAL (newdecl))
    2471                 :            :       /* Don't warn about forward parameter decls.  */
    2472                 :         17 :       && !(TREE_CODE (newdecl) == PARM_DECL
    2473                 :          6 :            && TREE_ASM_WRITTEN (olddecl) && !TREE_ASM_WRITTEN (newdecl))
    2474                 :            :       /* Don't warn about a variable definition following a declaration.  */
    2475                 :    2385290 :       && !(VAR_P (newdecl)
    2476                 :         10 :            && DECL_INITIAL (newdecl) && !DECL_INITIAL (olddecl)))
    2477                 :            :     {
    2478                 :          6 :       warned = warning (OPT_Wredundant_decls, "redundant redeclaration of %q+D",
    2479                 :            :                         newdecl);
    2480                 :            :     }
    2481                 :            : 
    2482                 :            :   /* Report location of previous decl/defn.  */
    2483                 :    2385280 :   if (warned || pedwarned)
    2484                 :         41 :     locate_old_decl (olddecl);
    2485                 :            : 
    2486                 :            : #undef DECL_EXTERN_INLINE
    2487                 :            : 
    2488                 :            :   return retval;
    2489                 :            : }
    2490                 :            : 
    2491                 :            : /* Subroutine of duplicate_decls.  NEWDECL has been found to be
    2492                 :            :    consistent with OLDDECL, but carries new information.  Merge the
    2493                 :            :    new information into OLDDECL.  This function issues no
    2494                 :            :    diagnostics.  */
    2495                 :            : 
    2496                 :            : static void
    2497                 :    2456040 : merge_decls (tree newdecl, tree olddecl, tree newtype, tree oldtype)
    2498                 :            : {
    2499                 :    2456040 :   bool new_is_definition = (TREE_CODE (newdecl) == FUNCTION_DECL
    2500                 :    4828120 :                             && DECL_INITIAL (newdecl) != NULL_TREE);
    2501                 :    2456040 :   bool new_is_prototype = (TREE_CODE (newdecl) == FUNCTION_DECL
    2502                 :    4828120 :                            && prototype_p (TREE_TYPE (newdecl)));
    2503                 :    2456040 :   bool old_is_prototype = (TREE_CODE (olddecl) == FUNCTION_DECL
    2504                 :    4828120 :                            && prototype_p (TREE_TYPE (olddecl)));
    2505                 :            : 
    2506                 :            :   /* For real parm decl following a forward decl, rechain the old decl
    2507                 :            :      in its new location and clear TREE_ASM_WRITTEN (it's not a
    2508                 :            :      forward decl anymore).  */
    2509                 :    2456040 :   if (TREE_CODE (newdecl) == PARM_DECL
    2510                 :         28 :       && TREE_ASM_WRITTEN (olddecl) && !TREE_ASM_WRITTEN (newdecl))
    2511                 :            :     {
    2512                 :         28 :       struct c_binding *b, **here;
    2513                 :            : 
    2514                 :         42 :       for (here = &current_scope->bindings; *here; here = &(*here)->prev)
    2515                 :         42 :         if ((*here)->decl == olddecl)
    2516                 :         28 :           goto found;
    2517                 :          0 :       gcc_unreachable ();
    2518                 :            : 
    2519                 :         28 :     found:
    2520                 :         28 :       b = *here;
    2521                 :         28 :       *here = b->prev;
    2522                 :         28 :       b->prev = current_scope->bindings;
    2523                 :         28 :       current_scope->bindings = b;
    2524                 :            : 
    2525                 :         28 :       TREE_ASM_WRITTEN (olddecl) = 0;
    2526                 :            :     }
    2527                 :            : 
    2528                 :    4912080 :   DECL_ATTRIBUTES (newdecl)
    2529                 :    2456040 :     = targetm.merge_decl_attributes (olddecl, newdecl);
    2530                 :            : 
    2531                 :            :   /* For typedefs use the old type, as the new type's DECL_NAME points
    2532                 :            :      at newdecl, which will be ggc_freed.  */
    2533                 :    2456040 :   if (TREE_CODE (newdecl) == TYPE_DECL)
    2534                 :            :     {
    2535                 :            :       /* But NEWTYPE might have an attribute, honor that.  */
    2536                 :      70764 :       tree tem = newtype;
    2537                 :      70764 :       newtype = oldtype;
    2538                 :            : 
    2539                 :      70764 :       if (TYPE_USER_ALIGN (tem))
    2540                 :            :         {
    2541                 :         12 :           if (TYPE_ALIGN (tem) > TYPE_ALIGN (newtype))
    2542                 :          2 :             SET_TYPE_ALIGN (newtype, TYPE_ALIGN (tem));
    2543                 :          6 :           TYPE_USER_ALIGN (newtype) = true;
    2544                 :            :         }
    2545                 :            : 
    2546                 :            :       /* And remove the new type from the variants list.  */
    2547                 :      70764 :       if (TYPE_NAME (TREE_TYPE (newdecl)) == newdecl)
    2548                 :            :         {
    2549                 :          6 :           tree remove = TREE_TYPE (newdecl);
    2550                 :          6 :           if (TYPE_MAIN_VARIANT (remove) == remove)
    2551                 :            :             {
    2552                 :          2 :               gcc_assert (TYPE_NEXT_VARIANT (remove) == NULL_TREE);
    2553                 :            :               /* If remove is the main variant, no need to remove that
    2554                 :            :                  from the list.  One of the DECL_ORIGINAL_TYPE
    2555                 :            :                  variants, e.g. created for aligned attribute, might still
    2556                 :            :                  refer to the newdecl TYPE_DECL though, so remove that one
    2557                 :            :                  in that case.  */
    2558                 :          2 :               if (DECL_ORIGINAL_TYPE (newdecl)
    2559                 :          2 :                   && DECL_ORIGINAL_TYPE (newdecl) != remove)
    2560                 :          2 :                 for (tree t = TYPE_MAIN_VARIANT (DECL_ORIGINAL_TYPE (newdecl));
    2561                 :          2 :                      t; t = TYPE_MAIN_VARIANT (t))
    2562                 :          2 :                   if (TYPE_NAME (TYPE_NEXT_VARIANT (t)) == newdecl)
    2563                 :            :                     {
    2564                 :          2 :                       TYPE_NEXT_VARIANT (t)
    2565                 :          2 :                         = TYPE_NEXT_VARIANT (TYPE_NEXT_VARIANT (t));
    2566                 :          2 :                       break;
    2567                 :            :                     }
    2568                 :            :             }       
    2569                 :            :           else
    2570                 :          4 :             for (tree t = TYPE_MAIN_VARIANT (remove); ;
    2571                 :          4 :                  t = TYPE_NEXT_VARIANT (t))
    2572                 :          4 :               if (TYPE_NEXT_VARIANT (t) == remove)
    2573                 :            :                 {
    2574                 :          4 :                   TYPE_NEXT_VARIANT (t) = TYPE_NEXT_VARIANT (remove);
    2575                 :          4 :                   break;
    2576                 :            :                 }
    2577                 :            :         }
    2578                 :            :     }
    2579                 :            : 
    2580                 :            :   /* Merge the data types specified in the two decls.  */
    2581                 :    2456040 :   TREE_TYPE (newdecl)
    2582                 :    4912080 :     = TREE_TYPE (olddecl)
    2583                 :    2456040 :     = composite_type (newtype, oldtype);
    2584                 :            : 
    2585                 :            :   /* Lay the type out, unless already done.  */
    2586                 :    2456040 :   if (!comptypes (oldtype, TREE_TYPE (newdecl)))
    2587                 :            :     {
    2588                 :          0 :       if (TREE_TYPE (newdecl) != error_mark_node)
    2589                 :          0 :         layout_type (TREE_TYPE (newdecl));
    2590                 :          0 :       if (TREE_CODE (newdecl) != FUNCTION_DECL
    2591                 :          0 :           && TREE_CODE (newdecl) != TYPE_DECL
    2592                 :          0 :           && TREE_CODE (newdecl) != CONST_DECL)
    2593                 :          0 :         layout_decl (newdecl, 0);
    2594                 :            :     }
    2595                 :            :   else
    2596                 :            :     {
    2597                 :            :       /* Since the type is OLDDECL's, make OLDDECL's size go with.  */
    2598                 :    2456040 :       DECL_SIZE (newdecl) = DECL_SIZE (olddecl);
    2599                 :    2456040 :       DECL_SIZE_UNIT (newdecl) = DECL_SIZE_UNIT (olddecl);
    2600                 :    2456040 :       SET_DECL_MODE (newdecl, DECL_MODE (olddecl));
    2601                 :    4912080 :       if (DECL_ALIGN (olddecl) > DECL_ALIGN (newdecl))
    2602                 :            :         {
    2603                 :         37 :           SET_DECL_ALIGN (newdecl, DECL_ALIGN (olddecl));
    2604                 :         37 :           DECL_USER_ALIGN (newdecl) |= DECL_USER_ALIGN (olddecl);
    2605                 :            :         }
    2606                 :    4912080 :       if (DECL_WARN_IF_NOT_ALIGN (olddecl)
    2607                 :    2456040 :           > DECL_WARN_IF_NOT_ALIGN (newdecl))
    2608                 :          0 :         SET_DECL_WARN_IF_NOT_ALIGN (newdecl,
    2609                 :            :                                     DECL_WARN_IF_NOT_ALIGN (olddecl));
    2610                 :            :     }
    2611                 :            : 
    2612                 :            :   /* Keep the old rtl since we can safely use it.  */
    2613                 :    2456040 :   if (HAS_RTL_P (olddecl))
    2614                 :    2456040 :     COPY_DECL_RTL (olddecl, newdecl);
    2615                 :            : 
    2616                 :            :   /* Merge the type qualifiers.  */
    2617                 :    2456040 :   if (TREE_READONLY (newdecl))
    2618                 :     279275 :     TREE_READONLY (olddecl) = 1;
    2619                 :            : 
    2620                 :    2456040 :   if (TREE_THIS_VOLATILE (newdecl))
    2621                 :      35872 :     TREE_THIS_VOLATILE (olddecl) = 1;
    2622                 :            : 
    2623                 :            :   /* Merge deprecatedness.  */
    2624                 :    2456040 :   if (TREE_DEPRECATED (newdecl))
    2625                 :          2 :     TREE_DEPRECATED (olddecl) = 1;
    2626                 :            : 
    2627                 :            :   /* If a decl is in a system header and the other isn't, keep the one on the
    2628                 :            :      system header. Otherwise, keep source location of definition rather than
    2629                 :            :      declaration and of prototype rather than non-prototype unless that
    2630                 :            :      prototype is built-in.  */
    2631                 :    2456040 :   if (CODE_CONTAINS_STRUCT (TREE_CODE (olddecl), TS_DECL_WITH_VIS)
    2632                 :    2456010 :       && DECL_IN_SYSTEM_HEADER (olddecl)
    2633                 :    2730300 :       && !DECL_IN_SYSTEM_HEADER (newdecl) )
    2634                 :        724 :     DECL_SOURCE_LOCATION (newdecl) = DECL_SOURCE_LOCATION (olddecl);
    2635                 :    2455320 :   else if (CODE_CONTAINS_STRUCT (TREE_CODE (olddecl), TS_DECL_WITH_VIS)
    2636                 :    2455290 :            && DECL_IN_SYSTEM_HEADER (newdecl)
    2637                 :    4343300 :            && !DECL_IN_SYSTEM_HEADER (olddecl))
    2638                 :    1614450 :     DECL_SOURCE_LOCATION (olddecl) = DECL_SOURCE_LOCATION (newdecl);
    2639                 :     840868 :   else if ((DECL_INITIAL (newdecl) == NULL_TREE
    2640                 :     656627 :             && DECL_INITIAL (olddecl) != NULL_TREE)
    2641                 :    1495990 :            || (old_is_prototype && !new_is_prototype
    2642                 :       1054 :                && !C_DECL_BUILTIN_PROTOTYPE (olddecl)))
    2643                 :       1597 :     DECL_SOURCE_LOCATION (newdecl) = DECL_SOURCE_LOCATION (olddecl);
    2644                 :            : 
    2645                 :            :   /* Merge the initialization information.  */
    2646                 :    2456040 :    if (DECL_INITIAL (newdecl) == NULL_TREE)
    2647                 :    2271090 :     DECL_INITIAL (newdecl) = DECL_INITIAL (olddecl);
    2648                 :            : 
    2649                 :            :   /* Merge the threadprivate attribute.  */
    2650                 :    2456040 :   if (VAR_P (olddecl) && C_DECL_THREADPRIVATE_P (olddecl))
    2651                 :          2 :     C_DECL_THREADPRIVATE_P (newdecl) = 1;
    2652                 :            : 
    2653                 :    2456040 :   if (CODE_CONTAINS_STRUCT (TREE_CODE (olddecl), TS_DECL_WITH_VIS))
    2654                 :            :     {
    2655                 :            :       /* Copy the assembler name.
    2656                 :            :          Currently, it can only be defined in the prototype.  */
    2657                 :    2456010 :       COPY_DECL_ASSEMBLER_NAME (olddecl, newdecl);
    2658                 :            : 
    2659                 :            :       /* Use visibility of whichever declaration had it specified */
    2660                 :    2456010 :       if (DECL_VISIBILITY_SPECIFIED (olddecl))
    2661                 :            :         {
    2662                 :       4502 :           DECL_VISIBILITY (newdecl) = DECL_VISIBILITY (olddecl);
    2663                 :       4502 :           DECL_VISIBILITY_SPECIFIED (newdecl) = 1;
    2664                 :            :         }
    2665                 :            : 
    2666                 :    2456010 :       if (TREE_CODE (newdecl) == FUNCTION_DECL)
    2667                 :            :         {
    2668                 :    2372070 :           DECL_STATIC_CONSTRUCTOR(newdecl) |= DECL_STATIC_CONSTRUCTOR(olddecl);
    2669                 :    2372070 :           DECL_STATIC_DESTRUCTOR (newdecl) |= DECL_STATIC_DESTRUCTOR (olddecl);
    2670                 :    2372070 :           DECL_NO_LIMIT_STACK (newdecl) |= DECL_NO_LIMIT_STACK (olddecl);
    2671                 :    2372070 :           DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (newdecl)
    2672                 :    2372070 :             |= DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (olddecl);
    2673                 :    2372070 :           TREE_THIS_VOLATILE (newdecl) |= TREE_THIS_VOLATILE (olddecl);
    2674                 :    2372070 :           DECL_IS_MALLOC (newdecl) |= DECL_IS_MALLOC (olddecl);
    2675                 :    2372070 :           if (DECL_IS_OPERATOR_NEW_P (olddecl))
    2676                 :          0 :             DECL_SET_IS_OPERATOR_NEW (newdecl, true);
    2677                 :    2372070 :           if (DECL_IS_OPERATOR_DELETE_P (olddecl))
    2678                 :          0 :             DECL_SET_IS_OPERATOR_DELETE (newdecl, true);
    2679                 :    2372070 :           TREE_READONLY (newdecl) |= TREE_READONLY (olddecl);
    2680                 :    2372070 :           DECL_PURE_P (newdecl) |= DECL_PURE_P (olddecl);
    2681                 :    2372070 :           DECL_IS_NOVOPS (newdecl) |= DECL_IS_NOVOPS (olddecl);
    2682                 :            :         }
    2683                 :            : 
    2684                 :            :       /* Merge the storage class information.  */
    2685                 :    2456010 :       merge_weak (newdecl, olddecl);
    2686                 :            : 
    2687                 :            :       /* For functions, static overrides non-static.  */
    2688                 :    2456010 :       if (TREE_CODE (newdecl) == FUNCTION_DECL)
    2689                 :            :         {
    2690                 :    2372070 :           TREE_PUBLIC (newdecl) &= TREE_PUBLIC (olddecl);
    2691                 :            :           /* This is since we don't automatically
    2692                 :            :              copy the attributes of NEWDECL into OLDDECL.  */
    2693                 :    2372070 :           TREE_PUBLIC (olddecl) = TREE_PUBLIC (newdecl);
    2694                 :            :           /* If this clears `static', clear it in the identifier too.  */
    2695                 :    2372070 :           if (!TREE_PUBLIC (olddecl))
    2696                 :       5959 :             TREE_PUBLIC (DECL_NAME (olddecl)) = 0;
    2697                 :            :         }
    2698                 :            :     }
    2699                 :            : 
    2700                 :            :   /* In c99, 'extern' declaration before (or after) 'inline' means this
    2701                 :            :      function is not DECL_EXTERNAL, unless 'gnu_inline' attribute
    2702                 :            :      is present.  */
    2703                 :    2456040 :   if (TREE_CODE (newdecl) == FUNCTION_DECL
    2704                 :    2372070 :       && !flag_gnu89_inline
    2705                 :    2357540 :       && (DECL_DECLARED_INLINE_P (newdecl)
    2706                 :    4558840 :           || DECL_DECLARED_INLINE_P (olddecl))
    2707                 :     156983 :       && (!DECL_DECLARED_INLINE_P (newdecl)
    2708                 :     156230 :           || !DECL_DECLARED_INLINE_P (olddecl)
    2709                 :        703 :           || !DECL_EXTERNAL (olddecl))
    2710                 :     156298 :       && DECL_EXTERNAL (newdecl)
    2711                 :     156197 :       && !lookup_attribute ("gnu_inline", DECL_ATTRIBUTES (newdecl))
    2712                 :    2456150 :       && !current_function_decl)
    2713                 :         77 :     DECL_EXTERNAL (newdecl) = 0;
    2714                 :            : 
    2715                 :            :   /* An inline definition following a static declaration is not
    2716                 :            :      DECL_EXTERNAL.  */
    2717                 :    2456040 :   if (new_is_definition
    2718                 :     184475 :       && (DECL_DECLARED_INLINE_P (newdecl)
    2719                 :     212614 :           || DECL_DECLARED_INLINE_P (olddecl))
    2720                 :    2612500 :       && !TREE_PUBLIC (olddecl))
    2721                 :        695 :     DECL_EXTERNAL (newdecl) = 0;
    2722                 :            : 
    2723                 :    2456040 :   if (DECL_EXTERNAL (newdecl))
    2724                 :            :     {
    2725                 :    2355100 :       TREE_STATIC (newdecl) = TREE_STATIC (olddecl);
    2726                 :    2355100 :       DECL_EXTERNAL (newdecl) = DECL_EXTERNAL (olddecl);
    2727                 :            : 
    2728                 :            :       /* An extern decl does not override previous storage class.  */
    2729                 :    2355100 :       TREE_PUBLIC (newdecl) = TREE_PUBLIC (olddecl);
    2730                 :    2355100 :       if (!DECL_EXTERNAL (newdecl))
    2731                 :            :         {
    2732                 :       1546 :           DECL_CONTEXT (newdecl) = DECL_CONTEXT (olddecl);
    2733                 :       1546 :           DECL_COMMON (newdecl) = DECL_COMMON (olddecl);
    2734                 :            :         }
    2735                 :            :     }
    2736                 :            :   else
    2737                 :            :     {
    2738                 :     100939 :       TREE_STATIC (olddecl) = TREE_STATIC (newdecl);
    2739                 :     100939 :       TREE_PUBLIC (olddecl) = TREE_PUBLIC (newdecl);
    2740                 :            :     }
    2741                 :            : 
    2742                 :    2456040 :   if (TREE_CODE (newdecl) == FUNCTION_DECL)
    2743                 :            :     {
    2744                 :            :       /* If we're redefining a function previously defined as extern
    2745                 :            :          inline, make sure we emit debug info for the inline before we
    2746                 :            :          throw it away, in case it was inlined into a function that
    2747                 :            :          hasn't been written out yet.  */
    2748                 :    2556550 :       if (new_is_definition && DECL_INITIAL (olddecl))
    2749                 :            :         /* The new defn must not be inline.  */
    2750                 :         92 :         DECL_UNINLINABLE (newdecl) = 1;
    2751                 :            :       else
    2752                 :            :         {
    2753                 :            :           /* If either decl says `inline', this fn is inline, unless
    2754                 :            :              its definition was passed already.  */
    2755                 :    2371980 :           if (DECL_DECLARED_INLINE_P (newdecl)
    2756                 :    4587580 :               || DECL_DECLARED_INLINE_P (olddecl))
    2757                 :     157130 :             DECL_DECLARED_INLINE_P (newdecl) = 1;
    2758                 :            : 
    2759                 :    2371980 :           DECL_UNINLINABLE (newdecl) = DECL_UNINLINABLE (olddecl)
    2760                 :    7114340 :             = (DECL_UNINLINABLE (newdecl) || DECL_UNINLINABLE (olddecl));
    2761                 :            : 
    2762                 :    2371980 :           DECL_DISREGARD_INLINE_LIMITS (newdecl)
    2763                 :    2371980 :             = DECL_DISREGARD_INLINE_LIMITS (olddecl)
    2764                 :    2371980 :             = (DECL_DISREGARD_INLINE_LIMITS (newdecl)
    2765                 :    4743850 :                || DECL_DISREGARD_INLINE_LIMITS (olddecl));
    2766                 :            :         }
    2767                 :            : 
    2768                 :    2372070 :       if (fndecl_built_in_p (olddecl))
    2769                 :            :         {
    2770                 :            :           /* If redeclaring a builtin function, it stays built in.
    2771                 :            :              But it gets tagged as having been declared.  */
    2772                 :    1750550 :           copy_decl_built_in_function (newdecl, olddecl);
    2773                 :    1750550 :           C_DECL_DECLARED_BUILTIN (newdecl) = 1;
    2774                 :    1750550 :           if (new_is_prototype)
    2775                 :            :             {
    2776                 :    1749530 :               C_DECL_BUILTIN_PROTOTYPE (newdecl) = 0;
    2777                 :    1749530 :               if (DECL_BUILT_IN_CLASS (newdecl) == BUILT_IN_NORMAL)
    2778                 :            :                 {
    2779                 :    1749530 :                   enum built_in_function fncode = DECL_FUNCTION_CODE (newdecl);
    2780                 :    1749530 :                   switch (fncode)
    2781                 :            :                     {
    2782                 :            :                       /* If a compatible prototype of these builtin functions
    2783                 :            :                          is seen, assume the runtime implements it with the
    2784                 :            :                          expected semantics.  */
    2785                 :       4836 :                     case BUILT_IN_STPCPY:
    2786                 :       4836 :                       if (builtin_decl_explicit_p (fncode))
    2787                 :       4836 :                         set_builtin_decl_implicit_p (fncode, true);
    2788                 :            :                       break;
    2789                 :    1744690 :                     default:
    2790                 :    1744690 :                       if (builtin_decl_explicit_p (fncode))
    2791                 :    1744690 :                         set_builtin_decl_declared_p (fncode, true);
    2792                 :            :                       break;
    2793                 :            :                     }
    2794                 :            : 
    2795                 :    1749530 :                   copy_attributes_to_builtin (newdecl);
    2796                 :            :                 }
    2797                 :            :             }
    2798                 :            :           else
    2799                 :       2034 :             C_DECL_BUILTIN_PROTOTYPE (newdecl)
    2800                 :       1017 :               = C_DECL_BUILTIN_PROTOTYPE (olddecl);
    2801                 :            :         }
    2802                 :            : 
    2803                 :            :       /* Preserve function specific target and optimization options */
    2804                 :    2372070 :       if (DECL_FUNCTION_SPECIFIC_TARGET (olddecl)
    2805                 :    2372540 :           && !DECL_FUNCTION_SPECIFIC_TARGET (newdecl))
    2806                 :        469 :         DECL_FUNCTION_SPECIFIC_TARGET (newdecl)
    2807                 :        469 :           = DECL_FUNCTION_SPECIFIC_TARGET (olddecl);
    2808                 :            : 
    2809                 :    2372070 :       if (DECL_FUNCTION_SPECIFIC_OPTIMIZATION (olddecl)
    2810                 :    2372180 :           && !DECL_FUNCTION_SPECIFIC_OPTIMIZATION (newdecl))
    2811                 :          9 :         DECL_FUNCTION_SPECIFIC_OPTIMIZATION (newdecl)
    2812                 :          9 :           = DECL_FUNCTION_SPECIFIC_OPTIMIZATION (olddecl);
    2813                 :            : 
    2814                 :            :       /* Also preserve various other info from the definition.  */
    2815                 :    2372070 :       if (!new_is_definition)
    2816                 :            :         {
    2817                 :    2187600 :           tree t;
    2818                 :    2187600 :           DECL_RESULT (newdecl) = DECL_RESULT (olddecl);
    2819                 :    2187600 :           DECL_INITIAL (newdecl) = DECL_INITIAL (olddecl);
    2820                 :    2187600 :           DECL_STRUCT_FUNCTION (newdecl) = DECL_STRUCT_FUNCTION (olddecl);
    2821                 :    2187600 :           DECL_SAVED_TREE (newdecl) = DECL_SAVED_TREE (olddecl);
    2822                 :    2187600 :           DECL_ARGUMENTS (newdecl) = copy_list (DECL_ARGUMENTS (olddecl));
    2823                 :    3693980 :           for (t = DECL_ARGUMENTS (newdecl); t ; t = DECL_CHAIN (t))
    2824                 :    1506380 :             DECL_CONTEXT (t) = newdecl;
    2825                 :            : 
    2826                 :            :           /* See if we've got a function to instantiate from.  */
    2827                 :    2187600 :           if (DECL_SAVED_TREE (olddecl))
    2828                 :       1421 :             DECL_ABSTRACT_ORIGIN (newdecl)
    2829                 :       1421 :               = DECL_ABSTRACT_ORIGIN (olddecl);
    2830                 :            :         }
    2831                 :            :     }
    2832                 :            : 
    2833                 :            :   /* Merge the USED information.  */
    2834                 :    2456040 :   if (TREE_USED (olddecl))
    2835                 :     576570 :     TREE_USED (newdecl) = 1;
    2836                 :    1879470 :   else if (TREE_USED (newdecl))
    2837                 :          3 :     TREE_USED (olddecl) = 1;
    2838                 :    2456040 :   if (VAR_P (olddecl) || TREE_CODE (olddecl) == PARM_DECL)
    2839                 :      13259 :     DECL_READ_P (newdecl) |= DECL_READ_P (olddecl);
    2840                 :    2456040 :   if (DECL_PRESERVE_P (olddecl))
    2841                 :         24 :     DECL_PRESERVE_P (newdecl) = 1;
    2842                 :    2456020 :   else if (DECL_PRESERVE_P (newdecl))
    2843                 :          3 :     DECL_PRESERVE_P (olddecl) = 1;
    2844                 :            : 
    2845                 :            :   /* Merge DECL_COMMON */
    2846                 :      13175 :   if (VAR_P (olddecl) && VAR_P (newdecl)
    2847                 :      13175 :       && !lookup_attribute ("common", DECL_ATTRIBUTES (newdecl))
    2848                 :    2469210 :       && !lookup_attribute ("nocommon", DECL_ATTRIBUTES (newdecl)))
    2849                 :      13171 :     DECL_COMMON (newdecl) = DECL_COMMON (newdecl) && DECL_COMMON (olddecl);
    2850                 :            : 
    2851                 :            :   /* Copy most of the decl-specific fields of NEWDECL into OLDDECL.
    2852                 :            :      But preserve OLDDECL's DECL_UID, DECL_CONTEXT and
    2853                 :            :      DECL_ARGUMENTS (if appropriate).  */
    2854                 :    2456040 :   {
    2855                 :    2456040 :     unsigned olddecl_uid = DECL_UID (olddecl);
    2856                 :    2456040 :     tree olddecl_context = DECL_CONTEXT (olddecl);
    2857                 :    2456040 :     tree olddecl_arguments = NULL;
    2858                 :    2456040 :     if (TREE_CODE (olddecl) == FUNCTION_DECL)
    2859                 :    2372070 :       olddecl_arguments = DECL_ARGUMENTS (olddecl);
    2860                 :            : 
    2861                 :    2456040 :     memcpy ((char *) olddecl + sizeof (struct tree_common),
    2862                 :            :             (char *) newdecl + sizeof (struct tree_common),
    2863                 :            :             sizeof (struct tree_decl_common) - sizeof (struct tree_common));
    2864                 :    2456040 :     DECL_USER_ALIGN (olddecl) = DECL_USER_ALIGN (newdecl);
    2865                 :    2456040 :     switch (TREE_CODE (olddecl))
    2866                 :            :       {
    2867                 :    2385250 :       case FUNCTION_DECL:
    2868                 :    2385250 :       case VAR_DECL:
    2869                 :    2385250 :         {
    2870                 :    2385250 :           struct symtab_node *snode = olddecl->decl_with_vis.symtab_node;
    2871                 :            : 
    2872                 :    4770500 :           memcpy ((char *) olddecl + sizeof (struct tree_decl_common),
    2873                 :            :                   (char *) newdecl + sizeof (struct tree_decl_common),
    2874                 :    2385250 :                   tree_code_size (TREE_CODE (olddecl)) - sizeof (struct tree_decl_common));
    2875                 :    2385250 :           olddecl->decl_with_vis.symtab_node = snode;
    2876                 :            : 
    2877                 :    2385250 :           if ((DECL_EXTERNAL (olddecl)
    2878                 :    2385250 :                || TREE_PUBLIC (olddecl)
    2879                 :      31693 :                || TREE_STATIC (olddecl))
    2880                 :    2416940 :               && DECL_SECTION_NAME (newdecl) != NULL)
    2881                 :          8 :             set_decl_section_name (olddecl, DECL_SECTION_NAME (newdecl));
    2882                 :            : 
    2883                 :            :           /* This isn't quite correct for something like
    2884                 :            :                 int __thread x attribute ((tls_model ("local-exec")));
    2885                 :            :                 extern int __thread x;
    2886                 :            :              as we'll lose the "local-exec" model.  */
    2887                 :    2396080 :           if (VAR_P (olddecl) && DECL_THREAD_LOCAL_P (newdecl))
    2888                 :         84 :             set_decl_tls_model (olddecl, DECL_TLS_MODEL (newdecl));
    2889                 :            :           break;
    2890                 :            :         }
    2891                 :            : 
    2892                 :      70792 :       case FIELD_DECL:
    2893                 :      70792 :       case PARM_DECL:
    2894                 :      70792 :       case LABEL_DECL:
    2895                 :      70792 :       case RESULT_DECL:
    2896                 :      70792 :       case CONST_DECL:
    2897                 :      70792 :       case TYPE_DECL:
    2898                 :     141584 :         memcpy ((char *) olddecl + sizeof (struct tree_decl_common),
    2899                 :            :                 (char *) newdecl + sizeof (struct tree_decl_common),
    2900                 :      70792 :                 tree_code_size (TREE_CODE (olddecl)) - sizeof (struct tree_decl_common));
    2901                 :      70792 :         break;
    2902                 :            : 
    2903                 :          0 :       default:
    2904                 :            : 
    2905                 :          0 :         memcpy ((char *) olddecl + sizeof (struct tree_decl_common),
    2906                 :            :                 (char *) newdecl + sizeof (struct tree_decl_common),
    2907                 :            :                 sizeof (struct tree_decl_non_common) - sizeof (struct tree_decl_common));
    2908                 :            :       }
    2909                 :    2456040 :     DECL_UID (olddecl) = olddecl_uid;
    2910                 :    2456040 :     DECL_CONTEXT (olddecl) = olddecl_context;
    2911                 :    2456040 :     if (TREE_CODE (olddecl) == FUNCTION_DECL)
    2912                 :    2372070 :       DECL_ARGUMENTS (olddecl) = olddecl_arguments;
    2913                 :            :   }
    2914                 :            : 
    2915                 :            :   /* If OLDDECL had its DECL_RTL instantiated, re-invoke make_decl_rtl
    2916                 :            :      so that encode_section_info has a chance to look at the new decl
    2917                 :            :      flags and attributes.  */
    2918                 :    2456040 :   if (DECL_RTL_SET_P (olddecl)
    2919                 :    2456040 :       && (TREE_CODE (olddecl) == FUNCTION_DECL
    2920                 :          0 :           || (VAR_P (olddecl) && TREE_STATIC (olddecl))))
    2921                 :          0 :     make_decl_rtl (olddecl);
    2922                 :    2456040 : }
    2923                 :            : 
    2924                 :            : /* Handle when a new declaration NEWDECL has the same name as an old
    2925                 :            :    one OLDDECL in the same binding contour.  Prints an error message
    2926                 :            :    if appropriate.
    2927                 :            : 
    2928                 :            :    If safely possible, alter OLDDECL to look like NEWDECL, and return
    2929                 :            :    true.  Otherwise, return false.  */
    2930                 :            : 
    2931                 :            : static bool
    2932                 :    2456810 : duplicate_decls (tree newdecl, tree olddecl)
    2933                 :            : {
    2934                 :    2456810 :   tree newtype = NULL, oldtype = NULL;
    2935                 :            : 
    2936                 :    2456810 :   if (!diagnose_mismatched_decls (newdecl, olddecl, &newtype, &oldtype))
    2937                 :            :     {
    2938                 :            :       /* Avoid `unused variable' and other warnings for OLDDECL.  */
    2939                 :        771 :       TREE_NO_WARNING (olddecl) = 1;
    2940                 :        771 :       return false;
    2941                 :            :     }
    2942                 :            : 
    2943                 :    2456040 :   merge_decls (newdecl, olddecl, newtype, oldtype);
    2944                 :            : 
    2945                 :            :   /* The NEWDECL will no longer be needed.
    2946                 :            : 
    2947                 :            :      Before releasing the node, be sure to remove function from symbol
    2948                 :            :      table that might have been inserted there to record comdat group.
    2949                 :            :      Be sure to however do not free DECL_STRUCT_FUNCTION because this
    2950                 :            :      structure is shared in between NEWDECL and OLDECL.  */
    2951                 :    2456040 :   if (TREE_CODE (newdecl) == FUNCTION_DECL)
    2952                 :    2372070 :     DECL_STRUCT_FUNCTION (newdecl) = NULL;
    2953                 :    2456040 :   if (VAR_OR_FUNCTION_DECL_P (newdecl))
    2954                 :            :     {
    2955                 :    2385250 :       struct symtab_node *snode = symtab_node::get (newdecl);
    2956                 :    2385250 :       if (snode)
    2957                 :         99 :         snode->remove ();
    2958                 :            :     }
    2959                 :    2456040 :   ggc_free (newdecl);
    2960                 :    2456040 :   return true;
    2961                 :            : }
    2962                 :            : 
    2963                 :            : 
    2964                 :            : /* Check whether decl-node NEW_DECL shadows an existing declaration.  */
    2965                 :            : static void
    2966                 :   99715900 : warn_if_shadowing (tree new_decl)
    2967                 :            : {
    2968                 :   99715900 :   struct c_binding *b;
    2969                 :            : 
    2970                 :            :   /* Shadow warnings wanted?  */
    2971                 :   99715300 :   if (!(warn_shadow
    2972                 :            :         || warn_shadow_local
    2973                 :            :         || warn_shadow_compatible_local)
    2974                 :            :       /* No shadow warnings for internally generated vars.  */
    2975                 :   99716800 :       || DECL_IS_BUILTIN (new_decl))
    2976                 :   99715800 :     return;
    2977                 :            : 
    2978                 :            :   /* Is anything being shadowed?  Invisible decls do not count.  */
    2979                 :        253 :   for (b = I_SYMBOL_BINDING (DECL_NAME (new_decl)); b; b = b->shadowed)
    2980                 :        157 :     if (b->decl && b->decl != new_decl && !b->invisible
    2981                 :        214 :         && (b->decl == error_mark_node
    2982                 :         43 :             || diagnostic_report_warnings_p (global_dc,
    2983                 :            :                                              DECL_SOURCE_LOCATION (b->decl))))
    2984                 :            :       {
    2985                 :         57 :         tree old_decl = b->decl;
    2986                 :            : 
    2987                 :         57 :         if (old_decl == error_mark_node)
    2988                 :            :           {
    2989                 :         14 :             warning (OPT_Wshadow, "declaration of %q+D shadows previous "
    2990                 :            :                      "non-variable", new_decl);
    2991                 :         64 :             break;
    2992                 :            :           }
    2993                 :            : 
    2994                 :         43 :         bool warned = false;
    2995                 :         43 :         auto_diagnostic_group d;
    2996                 :         43 :         if (TREE_CODE (old_decl) == PARM_DECL)
    2997                 :            :           {
    2998                 :          5 :             enum opt_code warning_code;
    2999                 :            : 
    3000                 :            :             /* If '-Wshadow=compatible-local' is specified without other
    3001                 :            :                -Wshadow= flags, we will warn only when the types of the
    3002                 :            :                shadowing variable (i.e. new_decl) and the shadowed variable
    3003                 :            :                (old_decl) are compatible.  */
    3004                 :          5 :             if (warn_shadow)
    3005                 :            :               warning_code = OPT_Wshadow;
    3006                 :          2 :             else if (comptypes (TREE_TYPE (old_decl), TREE_TYPE (new_decl)))
    3007                 :            :               warning_code = OPT_Wshadow_compatible_local;
    3008                 :            :             else
    3009                 :          2 :               warning_code = OPT_Wshadow_local;
    3010                 :          5 :             warned = warning_at (DECL_SOURCE_LOCATION (new_decl), warning_code,
    3011                 :            :                                  "declaration of %qD shadows a parameter",
    3012                 :            :                                  new_decl);
    3013                 :            :           }
    3014                 :         38 :         else if (DECL_FILE_SCOPE_P (old_decl))
    3015                 :            :           {
    3016                 :            :             /* Do not warn if a variable shadows a function, unless
    3017                 :            :                the variable is a function or a pointer-to-function.  */
    3018                 :         34 :             if (TREE_CODE (old_decl) == FUNCTION_DECL
    3019                 :         11 :                 && TREE_CODE (new_decl) != FUNCTION_DECL
    3020                 :         36 :                 && !FUNCTION_POINTER_TYPE_P (TREE_TYPE (new_decl)))
    3021                 :          7 :                 continue;
    3022                 :            : 
    3023                 :         20 :             warned = warning_at (DECL_SOURCE_LOCATION (new_decl), OPT_Wshadow,
    3024                 :            :                                  "declaration of %qD shadows a global "
    3025                 :            :                                  "declaration",
    3026                 :            :                                  new_decl);
    3027                 :            :           }
    3028                 :         11 :         else if (TREE_CODE (old_decl) == FUNCTION_DECL
    3029                 :         11 :                  && fndecl_built_in_p (old_decl))
    3030                 :            :           {
    3031                 :          0 :             warning (OPT_Wshadow, "declaration of %q+D shadows "
    3032                 :            :                      "a built-in function", new_decl);
    3033                 :         36 :             break;
    3034                 :            :           }
    3035                 :            :         else
    3036                 :            :           {
    3037                 :         11 :             enum opt_code warning_code;
    3038                 :            : 
    3039                 :            :             /* If '-Wshadow=compatible-local' is specified without other
    3040                 :            :                -Wshadow= flags, we will warn only when the types of the
    3041                 :            :                shadowing variable (i.e. new_decl) and the shadowed variable
    3042                 :            :                (old_decl) are compatible.  */
    3043                 :         11 :             if (warn_shadow)
    3044                 :            :               warning_code = OPT_Wshadow;
    3045                 :          8 :             else if (comptypes (TREE_TYPE (old_decl), TREE_TYPE (new_decl)))
    3046                 :            :               warning_code = OPT_Wshadow_compatible_local;
    3047                 :            :             else
    3048                 :          2 :               warning_code = OPT_Wshadow_local;
    3049                 :         11 :             warned = warning_at (DECL_SOURCE_LOCATION (new_decl), warning_code,
    3050                 :            :                                  "declaration of %qD shadows a previous local",
    3051                 :            :                                  new_decl);
    3052                 :            :           }
    3053                 :            : 
    3054                 :         36 :         if (warned)
    3055                 :         26 :           inform (DECL_SOURCE_LOCATION (old_decl),
    3056                 :            :                   "shadowed declaration is here");
    3057                 :            : 
    3058                 :            :         break;
    3059                 :            :       }
    3060                 :            : }
    3061                 :            : 
    3062                 :            : /* Record a decl-node X as belonging to the current lexical scope.
    3063                 :            :    Check for errors (such as an incompatible declaration for the same
    3064                 :            :    name already seen in the same scope).
    3065                 :            : 
    3066                 :            :    Returns either X or an old decl for the same name.
    3067                 :            :    If an old decl is returned, it may have been smashed
    3068                 :            :    to agree with what X says.  */
    3069                 :            : 
    3070                 :            : tree
    3071                 :  120167000 : pushdecl (tree x)
    3072                 :            : {
    3073                 :  120167000 :   tree name = DECL_NAME (x);
    3074                 :  120167000 :   struct c_scope *scope = current_scope;
    3075                 :  120167000 :   struct c_binding *b;
    3076                 :  120167000 :   bool nested = false;
    3077                 :  120167000 :   location_t locus = DECL_SOURCE_LOCATION (x);
    3078                 :            : 
    3079                 :            :   /* Must set DECL_CONTEXT for everything not at file scope or
    3080                 :            :      DECL_FILE_SCOPE_P won't work.  Local externs don't count
    3081                 :            :      unless they have initializers (which generate code).  */
    3082                 :  120167000 :   if (current_function_decl
    3083                 :    4268970 :       && (!VAR_OR_FUNCTION_DECL_P (x)
    3084                 :  124156000 :           || DECL_INITIAL (x) || !TREE_PUBLIC (x)))
    3085                 :    4256230 :     DECL_CONTEXT (x) = current_function_decl;
    3086                 :            : 
    3087                 :            :   /* Anonymous decls are just inserted in the scope.  */
    3088                 :  120167000 :   if (!name)
    3089                 :            :     {
    3090                 :    5592210 :       bind (name, x, scope, /*invisible=*/false, /*nested=*/false,
    3091                 :            :             locus);
    3092                 :    5592210 :       return x;
    3093                 :            :     }
    3094                 :            : 
    3095                 :            :   /* First, see if there is another declaration with the same name in
    3096                 :            :      the current scope.  If there is, duplicate_decls may do all the
    3097                 :            :      work for us.  If duplicate_decls returns false, that indicates
    3098                 :            :      two incompatible decls in the same scope; we are to silently
    3099                 :            :      replace the old one (duplicate_decls has issued all appropriate
    3100                 :            :      diagnostics).  In particular, we should not consider possible
    3101                 :            :      duplicates in the external scope, or shadowing.  */
    3102                 :  114574000 :   b = I_SYMBOL_BINDING (name);
    3103                 :  114574000 :   if (b && B_IN_SCOPE (b, scope))
    3104                 :            :     {
    3105                 :     817076 :       struct c_binding *b_ext, *b_use;
    3106                 :     817076 :       tree type = TREE_TYPE (x);
    3107                 :     817076 :       tree visdecl = b->decl;
    3108                 :     817076 :       tree vistype = TREE_TYPE (visdecl);
    3109                 :     817076 :       if (TREE_CODE (TREE_TYPE (x)) == ARRAY_TYPE
    3110                 :     817076 :           && COMPLETE_TYPE_P (TREE_TYPE (x)))
    3111                 :       1381 :         b->inner_comp = false;
    3112                 :     817076 :       b_use = b;
    3113                 :     817076 :       b_ext = b;
    3114                 :            :       /* If this is an external linkage declaration, we should check
    3115                 :            :          for compatibility with the type in the external scope before
    3116                 :            :          setting the type at this scope based on the visible
    3117                 :            :          information only.  */
    3118                 :     817076 :       if (TREE_PUBLIC (x) && TREE_PUBLIC (visdecl))
    3119                 :            :         {
    3120                 :    1480120 :           while (b_ext && !B_IN_EXTERNAL_SCOPE (b_ext))
    3121                 :     740064 :             b_ext = b_ext->shadowed;
    3122                 :     740061 :           if (b_ext)
    3123                 :            :             {
    3124                 :     740060 :               b_use = b_ext;
    3125                 :     740060 :               if (b_use->u.type)
    3126                 :     105895 :                 TREE_TYPE (b_use->decl) = b_use->u.type;
    3127                 :            :             }
    3128                 :            :         }
    3129                 :     817076 :       if (duplicate_decls (x, b_use->decl))
    3130                 :            :         {
    3131                 :     816898 :           if (b_use != b)
    3132                 :            :             {
    3133                 :            :               /* Save the updated type in the external scope and
    3134                 :            :                  restore the proper type for this scope.  */
    3135                 :     739965 :               tree thistype;
    3136                 :     739965 :               if (comptypes (vistype, type))
    3137                 :     739938 :                 thistype = composite_type (vistype, type);
    3138                 :            :               else
    3139                 :         27 :                 thistype = TREE_TYPE (b_use->decl);
    3140                 :     739965 :               b_use->u.type = TREE_TYPE (b_use->decl);
    3141                 :     739965 :               if (TREE_CODE (b_use->decl) == FUNCTION_DECL
    3142                 :     739965 :                   && fndecl_built_in_p (b_use->decl))
    3143                 :     113634 :                 thistype
    3144                 :     113634 :                   = build_type_attribute_variant (thistype,
    3145                 :     113634 :                                                   TYPE_ATTRIBUTES
    3146                 :            :                                                   (b_use->u.type));
    3147                 :     739965 :               TREE_TYPE (b_use->decl) = thistype;
    3148                 :            :             }
    3149                 :     816898 :           return b_use->decl;
    3150                 :            :         }
    3151                 :            :       else
    3152                 :        178 :         goto skip_external_and_shadow_checks;
    3153                 :            :     }
    3154                 :            : 
    3155                 :            :   /* All declarations with external linkage, and all external
    3156                 :            :      references, go in the external scope, no matter what scope is
    3157                 :            :      current.  However, the binding in that scope is ignored for
    3158                 :            :      purposes of normal name lookup.  A separate binding structure is
    3159                 :            :      created in the requested scope; this governs the normal
    3160                 :            :      visibility of the symbol.
    3161                 :            : 
    3162                 :            :      The binding in the externals scope is used exclusively for
    3163                 :            :      detecting duplicate declarations of the same object, no matter
    3164                 :            :      what scope they are in; this is what we do here.  (C99 6.2.7p2:
    3165                 :            :      All declarations that refer to the same object or function shall
    3166                 :            :      have compatible type; otherwise, the behavior is undefined.)
    3167                 :            :      However, in Objective-C, we also want to detect declarations
    3168                 :            :      conflicting with those of the basic types.  */
    3169                 :  198015000 :   if ((DECL_EXTERNAL (x) || scope == file_scope)
    3170                 :  122010000 :       && (VAR_OR_FUNCTION_DECL_P (x) || c_dialect_objc ()))
    3171                 :            :     {
    3172                 :   30862900 :       tree type = TREE_TYPE (x);
    3173                 :   30862900 :       tree vistype = NULL_TREE;
    3174                 :   30862900 :       tree visdecl = NULL_TREE;
    3175                 :   30862900 :       bool type_saved = false;
    3176                 :    1639760 :       if (b && !B_IN_EXTERNAL_SCOPE (b)
    3177                 :       1618 :           && VAR_OR_FUNCTION_DECL_P (b->decl)
    3178                 :   30864600 :           && DECL_FILE_SCOPE_P (b->decl))
    3179                 :            :         {
    3180                 :       1148 :           visdecl = b->decl;
    3181                 :       1148 :           vistype = TREE_TYPE (visdecl);
    3182                 :            :         }
    3183                 :   30862900 :       if (scope != file_scope
    3184                 :   30875200 :           && !DECL_IN_SYSTEM_HEADER (x))
    3185                 :      12223 :         warning_at (locus, OPT_Wnested_externs,
    3186                 :            :                     "nested extern declaration of %qD", x);
    3187                 :            : 
    3188                 :   30865400 :       while (b && !B_IN_EXTERNAL_SCOPE (b))
    3189                 :            :         {
    3190                 :            :           /* If this decl might be modified, save its type.  This is
    3191                 :            :              done here rather than when the decl is first bound
    3192                 :            :              because the type may change after first binding, through
    3193                 :            :              being completed or through attributes being added.  If we
    3194                 :            :              encounter multiple such decls, only the first should have
    3195                 :            :              its type saved; the others will already have had their
    3196                 :            :              proper types saved and the types will not have changed as
    3197                 :            :              their scopes will not have been re-entered.  */
    3198                 :       2443 :           if (DECL_P (b->decl) && DECL_FILE_SCOPE_P (b->decl) && !type_saved)
    3199                 :            :             {
    3200                 :       1602 :               b->u.type = TREE_TYPE (b->decl);
    3201                 :       1602 :               type_saved = true;
    3202                 :            :             }
    3203                 :       2443 :           if (B_IN_FILE_SCOPE (b)
    3204                 :            :               && VAR_P (b->decl)
    3205                 :       1594 :               && TREE_STATIC (b->decl)
    3206                 :        557 :               && TREE_CODE (TREE_TYPE (b->decl)) == ARRAY_TYPE
    3207                 :        308 :               && !TYPE_DOMAIN (TREE_TYPE (b->decl))
    3208                 :         98 :               && TREE_CODE (type) == ARRAY_TYPE
    3209                 :         98 :               && TYPE_DOMAIN (type)
    3210                 :         62 :               && TYPE_MAX_VALUE (TYPE_DOMAIN (type))
    3211                 :       2505 :               && !integer_zerop (TYPE_MAX_VALUE (TYPE_DOMAIN (type))))
    3212                 :            :             {
    3213                 :            :               /* Array type completed in inner scope, which should be
    3214                 :            :                  diagnosed if the completion does not have size 1 and
    3215                 :            :                  it does not get completed in the file scope.  */
    3216                 :          6 :               b->inner_comp = true;
    3217                 :            :             }
    3218                 :       2443 :           b = b->shadowed;
    3219                 :            :         }
    3220                 :            : 
    3221                 :            :       /* If a matching external declaration has been found, set its
    3222                 :            :          type to the composite of all the types of that declaration.
    3223                 :            :          After the consistency checks, it will be reset to the
    3224                 :            :          composite of the visible types only.  */
    3225                 :    1639490 :       if (b && (TREE_PUBLIC (x) || same_translation_unit_p (x, b->decl))
    3226                 :   32502400 :           && b->u.type)
    3227                 :        924 :         TREE_TYPE (b->decl) = b->u.type;
    3228                 :            : 
    3229                 :            :       /* The point of the same_translation_unit_p check here is,
    3230                 :            :          we want to detect a duplicate decl for a construct like
    3231                 :            :          foo() { extern bar(); } ... static bar();  but not if
    3232                 :            :          they are in different translation units.  In any case,
    3233                 :            :          the static does not go in the externals scope.  */
    3234                 :   30862900 :       if (b
    3235                 :    1639490 :           && (TREE_PUBLIC (x) || same_translation_unit_p (x, b->decl))
    3236                 :   32502400 :           && duplicate_decls (x, b->decl))
    3237                 :            :         {
    3238                 :    1638890 :           tree thistype;
    3239                 :    1638890 :           if (vistype)
    3240                 :            :             {
    3241                 :        890 :               if (comptypes (vistype, type))
    3242                 :        853 :                 thistype = composite_type (vistype, type);
    3243                 :            :               else
    3244                 :         37 :                 thistype = TREE_TYPE (b->decl);
    3245                 :            :             }
    3246                 :            :           else
    3247                 :            :             thistype = type;
    3248                 :    1638890 :           b->u.type = TREE_TYPE (b->decl);
    3249                 :    1638890 :           if (TREE_CODE (b->decl) == FUNCTION_DECL
    3250                 :    1638890 :               && fndecl_built_in_p (b->decl))
    3251                 :    1636910 :             thistype
    3252                 :    1636910 :               = build_type_attribute_variant (thistype,
    3253                 :    1636910 :                                               TYPE_ATTRIBUTES (b->u.type));
    3254                 :    1638890 :           TREE_TYPE (b->decl) = thistype;
    3255                 :    1638890 :           bind (name, b->decl, scope, /*invisible=*/false, /*nested=*/true,
    3256                 :            :                 locus);
    3257                 :    1638890 :           return b->decl;
    3258                 :            :         }
    3259                 :   29224100 :       else if (TREE_PUBLIC (x))
    3260                 :            :         {
    3261                 :   28725200 :           if (visdecl && !b && duplicate_decls (x, visdecl))
    3262                 :            :             {
    3263                 :            :               /* An external declaration at block scope referring to a
    3264                 :            :                  visible entity with internal linkage.  The composite
    3265                 :            :                  type will already be correct for this scope, so we
    3266                 :            :                  just need to fall through to make the declaration in
    3267                 :            :                  this scope.  */
    3268                 :            :               nested = true;
    3269                 :            :               x = visdecl;
    3270                 :            :             }
    3271                 :            :           else
    3272                 :            :             {
    3273                 :   28725000 :               bind (name, x, external_scope, /*invisible=*/true,
    3274                 :            :                     /*nested=*/false, locus);
    3275                 :   28725000 :               nested = true;
    3276                 :            :             }
    3277                 :            :         }
    3278                 :            :     }
    3279                 :            : 
    3280                 :  112118000 :   if (TREE_CODE (x) != PARM_DECL)
    3281                 :   43247200 :     warn_if_shadowing (x);
    3282                 :            : 
    3283                 :   68871200 :  skip_external_and_shadow_checks:
    3284                 :  112119000 :   if (TREE_CODE (x) == TYPE_DECL)
    3285                 :            :     {
    3286                 :            :       /* So this is a typedef, set its underlying type.  */
    3287                 :    6279060 :       set_underlying_type (x);
    3288                 :            : 
    3289                 :            :       /* If X is a typedef defined in the current function, record it
    3290                 :            :          for the purpose of implementing the -Wunused-local-typedefs
    3291                 :            :          warning.  */
    3292                 :    6279060 :       record_locally_defined_typedef (x);
    3293                 :            :     }
    3294                 :            : 
    3295                 :  112119000 :   bind (name, x, scope, /*invisible=*/false, nested, locus);
    3296                 :            : 
    3297                 :            :   /* If x's type is incomplete because it's based on a
    3298                 :            :      structure or union which has not yet been fully declared,
    3299                 :            :      attach it to that structure or union type, so we can go
    3300                 :            :      back and complete the variable declaration later, if the
    3301                 :            :      structure or union gets fully declared.
    3302                 :            : 
    3303                 :            :      If the input is erroneous, we can have error_mark in the type
    3304                 :            :      slot (e.g. "f(void a, ...)") - that doesn't count as an
    3305                 :            :      incomplete type.  */
    3306                 :  112119000 :   if (TREE_TYPE (x) != error_mark_node
    3307                 :  112119000 :       && !COMPLETE_TYPE_P (TREE_TYPE (x)))
    3308                 :            :     {
    3309                 :     169694 :       tree element = TREE_TYPE (x);
    3310                 :            : 
    3311                 :     169694 :       while (TREE_CODE (element) == ARRAY_TYPE)
    3312                 :      26393 :         element = TREE_TYPE (element);
    3313                 :     143301 :       element = TYPE_MAIN_VARIANT (element);
    3314                 :            : 
    3315                 :     143301 :       if ((RECORD_OR_UNION_TYPE_P (element)
    3316                 :     143301 :            || TREE_CODE (element) == ENUMERAL_TYPE)
    3317                 :      32236 :           && (TREE_CODE (x) != TYPE_DECL
    3318                 :      29331 :               || TREE_CODE (TREE_TYPE (x)) == ARRAY_TYPE)
    3319                 :     146213 :           && !COMPLETE_TYPE_P (element))
    3320                 :        348 :         C_TYPE_INCOMPLETE_VARS (element)
    3321                 :        696 :           = tree_cons (NULL_TREE, x, C_TYPE_INCOMPLETE_VARS (element));
    3322                 :            :     }
    3323                 :            :   return x;
    3324                 :            : }
    3325                 :            : 
    3326                 :            : 
    3327                 :            : /* Issue a warning about implicit function declaration.  ID is the function
    3328                 :            :    identifier, OLDDECL is a declaration of the function in a different scope,
    3329                 :            :    or NULL_TREE.  */
    3330                 :            : 
    3331                 :            : static void
    3332                 :      12231 : implicit_decl_warning (location_t loc, tree id, tree olddecl)
    3333                 :            : {
    3334                 :      12231 :   if (!warn_implicit_function_declaration)
    3335                 :        214 :     return;
    3336                 :            : 
    3337                 :      12017 :   bool warned;
    3338                 :      12017 :   auto_diagnostic_group d;
    3339                 :      24034 :   name_hint hint;
    3340                 :      12017 :   if (!olddecl)
    3341                 :       2310 :     hint = lookup_name_fuzzy (id, FUZZY_LOOKUP_FUNCTION_NAME, loc);
    3342                 :            : 
    3343                 :      12017 :   if (flag_isoc99)
    3344                 :            :     {
    3345                 :      12011 :       if (const char *suggestion = hint.suggestion ())
    3346                 :            :         {
    3347                 :        526 :           gcc_rich_location richloc (loc);
    3348                 :        263 :           richloc.add_fixit_replace (suggestion);
    3349                 :        263 :           warned = pedwarn (&richloc, OPT_Wimplicit_function_declaration,
    3350                 :            :                             "implicit declaration of function %qE;"
    3351                 :            :                             " did you mean %qs?",
    3352                 :            :                             id, suggestion);
    3353                 :            :         }
    3354                 :            :       else
    3355                 :      11748 :         warned = pedwarn (loc, OPT_Wimplicit_function_declaration,
    3356                 :            :                           "implicit declaration of function %qE", id);
    3357                 :            :     }
    3358                 :          6 :   else if (const char *suggestion = hint.suggestion ())
    3359                 :            :     {
    3360                 :          4 :       gcc_rich_location richloc (loc);
    3361                 :          2 :       richloc.add_fixit_replace (suggestion);
    3362                 :          2 :       warned = warning_at
    3363                 :          2 :         (&richloc, OPT_Wimplicit_function_declaration,
    3364                 :            :          G_("implicit declaration of function %qE; did you mean %qs?"),
    3365                 :            :          id, suggestion);
    3366                 :            :     }
    3367                 :            :   else
    3368                 :          4 :     warned = warning_at (loc, OPT_Wimplicit_function_declaration,
    3369                 :            :                          G_("implicit declaration of function %qE"), id);
    3370                 :            : 
    3371                 :      12017 :   if (olddecl && warned)
    3372                 :         19 :     locate_old_decl (olddecl);
    3373                 :            : 
    3374                 :      12017 :   if (!warned)
    3375                 :      12017 :     hint.suppress ();
    3376                 :            : }
    3377                 :            : 
    3378                 :            : /* Return the name of the header file that declares built-in function
    3379                 :            :    FNDECL, or null if either we don't know or don't expect to see an
    3380                 :            :    explicit declaration.  */
    3381                 :            : 
    3382                 :            : static const char *
    3383                 :      18095 : header_for_builtin_fn (tree fndecl)
    3384                 :            : {
    3385                 :      18095 :   if (DECL_BUILT_IN_CLASS (fndecl) != BUILT_IN_NORMAL)
    3386                 :            :     return NULL;
    3387                 :            : 
    3388                 :      18095 :   switch (DECL_FUNCTION_CODE (fndecl))
    3389                 :            :     {
    3390                 :            :     CASE_FLT_FN (BUILT_IN_ACOS):
    3391                 :            :     CASE_FLT_FN (BUILT_IN_ACOSH):
    3392                 :            :     CASE_FLT_FN (BUILT_IN_ASIN):
    3393                 :            :     CASE_FLT_FN (BUILT_IN_ASINH):
    3394                 :            :     CASE_FLT_FN (BUILT_IN_ATAN):
    3395                 :            :     CASE_FLT_FN (BUILT_IN_ATANH):
    3396                 :            :     CASE_FLT_FN (BUILT_IN_ATAN2):
    3397                 :            :     CASE_FLT_FN (BUILT_IN_CBRT):
    3398                 :            :     CASE_FLT_FN (BUILT_IN_CEIL):
    3399                 :            :     CASE_FLT_FN_FLOATN_NX (BUILT_IN_CEIL):
    3400                 :            :     CASE_FLT_FN (BUILT_IN_COPYSIGN):
    3401                 :            :     CASE_FLT_FN_FLOATN_NX (BUILT_IN_COPYSIGN):
    3402                 :            :     CASE_FLT_FN (BUILT_IN_COS):
    3403                 :            :     CASE_FLT_FN (BUILT_IN_COSH):
    3404                 :            :     CASE_FLT_FN (BUILT_IN_ERF):
    3405                 :            :     CASE_FLT_FN (BUILT_IN_ERFC):
    3406                 :            :     CASE_FLT_FN (BUILT_IN_EXP):
    3407                 :            :     CASE_FLT_FN (BUILT_IN_EXP2):
    3408                 :            :     CASE_FLT_FN (BUILT_IN_EXPM1):
    3409                 :            :     CASE_FLT_FN (BUILT_IN_FABS):
    3410                 :            :     CASE_FLT_FN_FLOATN_NX (BUILT_IN_FABS):
    3411                 :            :     CASE_FLT_FN (BUILT_IN_FDIM):
    3412                 :            :     CASE_FLT_FN (BUILT_IN_FLOOR):
    3413                 :            :     CASE_FLT_FN_FLOATN_NX (BUILT_IN_FLOOR):
    3414                 :            :     CASE_FLT_FN (BUILT_IN_FMA):
    3415                 :            :     CASE_FLT_FN_FLOATN_NX (BUILT_IN_FMA):
    3416                 :            :     CASE_FLT_FN (BUILT_IN_FMAX):
    3417                 :            :     CASE_FLT_FN_FLOATN_NX (BUILT_IN_FMAX):
    3418                 :            :     CASE_FLT_FN (BUILT_IN_FMIN):
    3419                 :            :     CASE_FLT_FN_FLOATN_NX (BUILT_IN_FMIN):
    3420                 :            :     CASE_FLT_FN (BUILT_IN_FMOD):
    3421                 :            :     CASE_FLT_FN (BUILT_IN_FREXP):
    3422                 :            :     CASE_FLT_FN (BUILT_IN_HYPOT):
    3423                 :            :     CASE_FLT_FN (BUILT_IN_ILOGB):
    3424                 :            :     CASE_FLT_FN (BUILT_IN_LDEXP):
    3425                 :            :     CASE_FLT_FN (BUILT_IN_LGAMMA):
    3426                 :            :     CASE_FLT_FN (BUILT_IN_LLRINT):
    3427                 :            :     CASE_FLT_FN (BUILT_IN_LLROUND):
    3428                 :            :     CASE_FLT_FN (BUILT_IN_LOG):
    3429                 :            :     CASE_FLT_FN (BUILT_IN_LOG10):
    3430                 :            :     CASE_FLT_FN (BUILT_IN_LOG1P):
    3431                 :            :     CASE_FLT_FN (BUILT_IN_LOG2):
    3432                 :            :     CASE_FLT_FN (BUILT_IN_LOGB):
    3433                 :            :     CASE_FLT_FN (BUILT_IN_LRINT):
    3434                 :            :     CASE_FLT_FN (BUILT_IN_LROUND):
    3435                 :            :     CASE_FLT_FN (BUILT_IN_MODF):
    3436                 :            :     CASE_FLT_FN (BUILT_IN_NAN):
    3437                 :            :     CASE_FLT_FN (BUILT_IN_NEARBYINT):
    3438                 :            :     CASE_FLT_FN_FLOATN_NX (BUILT_IN_NEARBYINT):
    3439                 :            :     CASE_FLT_FN (BUILT_IN_NEXTAFTER):
    3440                 :            :     CASE_FLT_FN (BUILT_IN_NEXTTOWARD):
    3441                 :            :     CASE_FLT_FN (BUILT_IN_POW):
    3442                 :            :     CASE_FLT_FN (BUILT_IN_REMAINDER):
    3443                 :            :     CASE_FLT_FN (BUILT_IN_REMQUO):
    3444                 :            :     CASE_FLT_FN (BUILT_IN_RINT):
    3445                 :            :     CASE_FLT_FN_FLOATN_NX (BUILT_IN_RINT):
    3446                 :            :     CASE_FLT_FN (BUILT_IN_ROUND):
    3447                 :            :     CASE_FLT_FN_FLOATN_NX (BUILT_IN_ROUND):
    3448                 :            :     CASE_FLT_FN (BUILT_IN_SCALBLN):
    3449                 :            :     CASE_FLT_FN (BUILT_IN_SCALBN):
    3450                 :            :     CASE_FLT_FN (BUILT_IN_SIN):
    3451                 :            :     CASE_FLT_FN (BUILT_IN_SINH):
    3452                 :            :     CASE_FLT_FN (BUILT_IN_SINCOS):
    3453                 :            :     CASE_FLT_FN (BUILT_IN_SQRT):
    3454                 :            :     CASE_FLT_FN_FLOATN_NX (BUILT_IN_SQRT):
    3455                 :            :     CASE_FLT_FN (BUILT_IN_TAN):
    3456                 :            :     CASE_FLT_FN (BUILT_IN_TANH):
    3457                 :            :     CASE_FLT_FN (BUILT_IN_TGAMMA):
    3458                 :            :     CASE_FLT_FN (BUILT_IN_TRUNC):
    3459                 :            :     CASE_FLT_FN_FLOATN_NX (BUILT_IN_TRUNC):
    3460                 :            :     case BUILT_IN_ISINF:
    3461                 :            :     case BUILT_IN_ISNAN:
    3462                 :            :       return "<math.h>";
    3463                 :         37 :     CASE_FLT_FN (BUILT_IN_CABS):
    3464                 :         37 :     CASE_FLT_FN (BUILT_IN_CACOS):
    3465                 :         37 :     CASE_FLT_FN (BUILT_IN_CACOSH):
    3466                 :         37 :     CASE_FLT_FN (BUILT_IN_CARG):
    3467                 :         37 :     CASE_FLT_FN (BUILT_IN_CASIN):
    3468                 :         37 :     CASE_FLT_FN (BUILT_IN_CASINH):
    3469                 :         37 :     CASE_FLT_FN (BUILT_IN_CATAN):
    3470                 :         37 :     CASE_FLT_FN (BUILT_IN_CATANH):
    3471                 :         37 :     CASE_FLT_FN (BUILT_IN_CCOS):
    3472                 :         37 :     CASE_FLT_FN (BUILT_IN_CCOSH):
    3473                 :         37 :     CASE_FLT_FN (BUILT_IN_CEXP):
    3474                 :         37 :     CASE_FLT_FN (BUILT_IN_CIMAG):
    3475                 :         37 :     CASE_FLT_FN (BUILT_IN_CLOG):
    3476                 :         37 :     CASE_FLT_FN (BUILT_IN_CONJ):
    3477                 :         37 :     CASE_FLT_FN (BUILT_IN_CPOW):
    3478                 :         37 :     CASE_FLT_FN (BUILT_IN_CPROJ):
    3479                 :         37 :     CASE_FLT_FN (BUILT_IN_CREAL):
    3480                 :         37 :     CASE_FLT_FN (BUILT_IN_CSIN):
    3481                 :         37 :     CASE_FLT_FN (BUILT_IN_CSINH):
    3482                 :         37 :     CASE_FLT_FN (BUILT_IN_CSQRT):
    3483                 :         37 :     CASE_FLT_FN (BUILT_IN_CTAN):
    3484                 :         37 :     CASE_FLT_FN (BUILT_IN_CTANH):
    3485                 :         37 :       return "<complex.h>";
    3486                 :        552 :     case BUILT_IN_MEMCHR:
    3487                 :        552 :     case BUILT_IN_MEMCMP:
    3488                 :        552 :     case BUILT_IN_MEMCPY:
    3489                 :        552 :     case BUILT_IN_MEMMOVE:
    3490                 :        552 :     case BUILT_IN_MEMSET:
    3491                 :        552 :     case BUILT_IN_STRCAT:
    3492                 :        552 :     case BUILT_IN_STRCHR:
    3493                 :        552 :     case BUILT_IN_STRCMP:
    3494                 :        552 :     case BUILT_IN_STRCPY:
    3495                 :        552 :     case BUILT_IN_STRCSPN:
    3496                 :        552 :     case BUILT_IN_STRLEN:
    3497                 :        552 :     case BUILT_IN_STRNCAT:
    3498                 :        552 :     case BUILT_IN_STRNCMP:
    3499                 :        552 :     case BUILT_IN_STRNCPY:
    3500                 :        552 :     case BUILT_IN_STRPBRK:
    3501                 :        552 :     case BUILT_IN_STRRCHR:
    3502                 :        552 :     case BUILT_IN_STRSPN:
    3503                 :        552 :     case BUILT_IN_STRSTR:
    3504                 :        552 :       return "<string.h>";
    3505                 :        732 :     case BUILT_IN_FPRINTF:
    3506                 :        732 :     case BUILT_IN_PUTC:
    3507                 :        732 :     case BUILT_IN_FPUTC:
    3508                 :        732 :     case BUILT_IN_FPUTS:
    3509                 :        732 :     case BUILT_IN_FSCANF:
    3510                 :        732 :     case BUILT_IN_FWRITE:
    3511                 :        732 :     case BUILT_IN_PRINTF:
    3512                 :        732 :     case BUILT_IN_PUTCHAR:
    3513                 :        732 :     case BUILT_IN_PUTS:
    3514                 :        732 :     case BUILT_IN_SCANF:
    3515                 :        732 :     case BUILT_IN_SNPRINTF:
    3516                 :        732 :     case BUILT_IN_SPRINTF:
    3517                 :        732 :     case BUILT_IN_SSCANF:
    3518                 :        732 :     case BUILT_IN_VFPRINTF:
    3519                 :        732 :     case BUILT_IN_VFSCANF:
    3520                 :        732 :     case BUILT_IN_VPRINTF:
    3521                 :        732 :     case BUILT_IN_VSCANF:
    3522                 :        732 :     case BUILT_IN_VSNPRINTF:
    3523                 :        732 :     case BUILT_IN_VSPRINTF:
    3524                 :        732 :     case BUILT_IN_VSSCANF:
    3525                 :        732 :       return "<stdio.h>";
    3526                 :          0 :     case BUILT_IN_ISALNUM:
    3527                 :          0 :     case BUILT_IN_ISALPHA:
    3528                 :          0 :     case BUILT_IN_ISBLANK:
    3529                 :          0 :     case BUILT_IN_ISCNTRL:
    3530                 :          0 :     case BUILT_IN_ISDIGIT:
    3531                 :          0 :     case BUILT_IN_ISGRAPH:
    3532                 :          0 :     case BUILT_IN_ISLOWER:
    3533                 :          0 :     case BUILT_IN_ISPRINT:
    3534                 :          0 :     case BUILT_IN_ISPUNCT:
    3535                 :          0 :     case BUILT_IN_ISSPACE:
    3536                 :          0 :     case BUILT_IN_ISUPPER:
    3537                 :          0 :     case BUILT_IN_ISXDIGIT:
    3538                 :          0 :     case BUILT_IN_TOLOWER:
    3539                 :          0 :     case BUILT_IN_TOUPPER:
    3540                 :          0 :       return "<ctype.h>";
    3541                 :          0 :     case BUILT_IN_ISWALNUM:
    3542                 :          0 :     case BUILT_IN_ISWALPHA:
    3543                 :          0 :     case BUILT_IN_ISWBLANK:
    3544                 :          0 :     case BUILT_IN_ISWCNTRL:
    3545                 :          0 :     case BUILT_IN_ISWDIGIT:
    3546                 :          0 :     case BUILT_IN_ISWGRAPH:
    3547                 :          0 :     case BUILT_IN_ISWLOWER:
    3548                 :          0 :     case BUILT_IN_ISWPRINT:
    3549                 :          0 :     case BUILT_IN_ISWPUNCT:
    3550                 :          0 :     case BUILT_IN_ISWSPACE:
    3551                 :          0 :     case BUILT_IN_ISWUPPER:
    3552                 :          0 :     case BUILT_IN_ISWXDIGIT:
    3553                 :          0 :     case BUILT_IN_TOWLOWER:
    3554                 :          0 :     case BUILT_IN_TOWUPPER:
    3555                 :          0 :       return "<wctype.h>";
    3556                 :      16336 :     case BUILT_IN_ABORT:
    3557                 :      16336 :     case BUILT_IN_ABS:
    3558                 :      16336 :     case BUILT_IN_CALLOC:
    3559                 :      16336 :     case BUILT_IN_EXIT:
    3560                 :      16336 :     case BUILT_IN_FREE:
    3561                 :      16336 :     case BUILT_IN_LABS:
    3562                 :      16336 :     case BUILT_IN_LLABS:
    3563                 :      16336 :     case BUILT_IN_MALLOC:
    3564                 :      16336 :     case BUILT_IN_REALLOC:
    3565                 :      16336 :     case BUILT_IN__EXIT2:
    3566                 :      16336 :     case BUILT_IN_ALIGNED_ALLOC:
    3567                 :      16336 :       return "<stdlib.h>";
    3568                 :          1 :     case BUILT_IN_IMAXABS:
    3569                 :          1 :       return "<inttypes.h>";
    3570                 :          3 :     case BUILT_IN_STRFTIME:
    3571                 :          3 :       return "<time.h>";
    3572                 :        146 :     default:
    3573                 :        146 :       return NULL;
    3574                 :            :     }
    3575                 :            : }
    3576                 :            : 
    3577                 :            : /* Generate an implicit declaration for identifier FUNCTIONID at LOC as a
    3578                 :            :    function of type int ().  */
    3579                 :            : 
    3580                 :            : tree
    3581                 :      20963 : implicitly_declare (location_t loc, tree functionid)
    3582                 :            : {
    3583                 :      20963 :   struct c_binding *b;
    3584                 :      20963 :   tree decl = NULL_TREE;
    3585                 :      20963 :   tree asmspec_tree;
    3586                 :            : 
    3587                 :      20977 :   for (b = I_SYMBOL_BINDING (functionid); b; b = b->shadowed)
    3588                 :            :     {
    3589                 :      18596 :       if (B_IN_SCOPE (b, external_scope))
    3590                 :            :         {
    3591                 :      18582 :           decl = b->decl;
    3592                 :      18582 :           break;
    3593                 :            :         }
    3594                 :            :     }
    3595                 :            : 
    3596                 :      20963 :   if (decl)
    3597                 :            :     {
    3598                 :      18582 :       if (TREE_CODE (decl) != FUNCTION_DECL)
    3599                 :            :         return decl;
    3600                 :            : 
    3601                 :            :       /* FIXME: Objective-C has weird not-really-builtin functions
    3602                 :            :          which are supposed to be visible automatically.  They wind up
    3603                 :            :          in the external scope because they're pushed before the file
    3604                 :            :          scope gets created.  Catch this here and rebind them into the
    3605                 :            :          file scope.  */
    3606                 :      18575 :       if (!fndecl_built_in_p (decl) && DECL_IS_BUILTIN (decl))
    3607                 :            :         {
    3608                 :          0 :           bind (functionid, decl, file_scope,
    3609                 :            :                 /*invisible=*/false, /*nested=*/true,
    3610                 :          0 :                 DECL_SOURCE_LOCATION (decl));
    3611                 :          0 :           return decl;
    3612                 :            :         }
    3613                 :            :       else
    3614                 :            :         {
    3615                 :      18575 :           tree newtype = default_function_type;
    3616                 :      18575 :           if (b->u.type)
    3617                 :       8472 :             TREE_TYPE (decl) = b->u.type;
    3618                 :            :           /* Implicit declaration of a function already declared
    3619                 :            :              (somehow) in a different scope, or as a built-in.
    3620                 :            :              If this is the first time this has happened, warn;
    3621                 :            :              then recycle the old declaration but with the new type.  */
    3622                 :      18575 :           if (!C_DECL_IMPLICIT (decl))
    3623                 :            :             {
    3624                 :       9850 :               implicit_decl_warning (loc, functionid, decl);
    3625                 :       9850 :               C_DECL_IMPLICIT (decl) = 1;
    3626                 :            :             }
    3627                 :      18575 :           if (fndecl_built_in_p (decl))
    3628                 :            :             {
    3629                 :      54057 :               newtype = build_type_attribute_variant (newtype,
    3630                 :      18019 :                                                       TYPE_ATTRIBUTES
    3631                 :            :                                                       (TREE_TYPE (decl)));
    3632                 :      18019 :               if (!comptypes (newtype, TREE_TYPE (decl)))
    3633                 :            :                 {
    3634                 :      17627 :                   bool warned = warning_at (loc, 0, "incompatible implicit "
    3635                 :            :                                             "declaration of built-in "
    3636                 :            :                                             "function %qD", decl);
    3637                 :            :                   /* See if we can hint which header to include.  */
    3638                 :      17627 :                   const char *header = header_for_builtin_fn (decl);
    3639                 :      17627 :                   if (header != NULL && warned)
    3640                 :            :                     {
    3641                 :        260 :                       rich_location richloc (line_table, loc);
    3642                 :        130 :                       maybe_add_include_fixit (&richloc, header, true);
    3643                 :        130 :                       inform (&richloc,
    3644                 :            :                               "include %qs or provide a declaration of %qD",
    3645                 :            :                               header, decl);
    3646                 :            :                     }
    3647                 :      17627 :                   newtype = TREE_TYPE (decl);
    3648                 :            :                 }
    3649                 :            :             }
    3650                 :            :           else
    3651                 :            :             {
    3652                 :        556 :               if (!comptypes (newtype, TREE_TYPE (decl)))
    3653                 :            :                 {
    3654                 :          4 :                   auto_diagnostic_group d;
    3655                 :          2 :                   error_at (loc, "incompatible implicit declaration of "
    3656                 :            :                             "function %qD", decl);
    3657                 :          2 :                   locate_old_decl (decl);
    3658                 :            :                 }
    3659                 :            :             }
    3660                 :      18575 :           b->u.type = TREE_TYPE (decl);
    3661                 :      18575 :           TREE_TYPE (decl) = newtype;
    3662                 :      37150 :           bind (functionid, decl, current_scope,
    3663                 :            :                 /*invisible=*/false, /*nested=*/true,
    3664                 :      18575 :                 DECL_SOURCE_LOCATION (decl));
    3665                 :      18575 :           return decl;
    3666                 :            :         }
    3667                 :            :     }
    3668                 :            : 
    3669                 :            :   /* Not seen before.  */
    3670                 :       2381 :   decl = build_decl (loc, FUNCTION_DECL, functionid, default_function_type);
    3671                 :       2381 :   DECL_EXTERNAL (decl) = 1;
    3672                 :       2381 :   TREE_PUBLIC (decl) = 1;
    3673                 :       2381 :   C_DECL_IMPLICIT (decl) = 1;
    3674                 :       2381 :   implicit_decl_warning (loc, functionid, 0);
    3675                 :       2381 :   asmspec_tree = maybe_apply_renaming_pragma (decl, /*asmname=*/NULL);
    3676                 :       2381 :   if (asmspec_tree)
    3677                 :          1 :     set_user_assembler_name (decl, TREE_STRING_POINTER (asmspec_tree));
    3678                 :            : 
    3679                 :            :   /* C89 says implicit declarations are in the innermost block.
    3680                 :            :      So we record the decl in the standard fashion.  */
    3681                 :       2381 :   decl = pushdecl (decl);
    3682                 :            : 
    3683                 :            :   /* No need to call objc_check_decl here - it's a function type.  */
    3684                 :       2381 :   rest_of_decl_compilation (decl, 0, 0);
    3685                 :            : 
    3686                 :            :   /* Write a record describing this implicit function declaration
    3687                 :            :      to the prototypes file (if requested).  */
    3688                 :       2381 :   gen_aux_info_record (decl, 0, 1, 0);
    3689                 :            : 
    3690                 :            :   /* Possibly apply some default attributes to this implicit declaration.  */
    3691                 :       2381 :   decl_attributes (&decl, NULL_TREE, 0);
    3692                 :            : 
    3693                 :       2381 :   return decl;
    3694                 :            : }
    3695                 :            : 
    3696                 :            : /* Issue an error message for a reference to an undeclared variable
    3697                 :            :    ID, including a reference to a builtin outside of function-call
    3698                 :            :    context.  Establish a binding of the identifier to error_mark_node
    3699                 :            :    in an appropriate scope, which will suppress further errors for the
    3700                 :            :    same identifier.  The error message should be given location LOC.  */
    3701                 :            : void
    3702                 :       1115 : undeclared_variable (location_t loc, tree id)
    3703                 :            : {
    3704                 :       1115 :   static bool already = false;
    3705                 :       1115 :   struct c_scope *scope;
    3706                 :            : 
    3707                 :       2230 :   auto_diagnostic_group d;
    3708                 :       1115 :   if (current_function_decl == NULL_TREE)
    3709                 :            :     {
    3710                 :        522 :       name_hint guessed_id = lookup_name_fuzzy (id, FUZZY_LOOKUP_NAME, loc);
    3711                 :        261 :       if (const char *suggestion = guessed_id.suggestion ())
    3712                 :            :         {
    3713                 :        176 :           gcc_rich_location richloc (loc);
    3714                 :         88 :           richloc.add_fixit_replace (suggestion);
    3715                 :         88 :           error_at (&richloc,
    3716                 :            :                     "%qE undeclared here (not in a function);"
    3717                 :            :                     " did you mean %qs?",
    3718                 :            :                     id, suggestion);
    3719                 :            :         }
    3720                 :            :       else
    3721                 :        173 :         error_at (loc, "%qE undeclared here (not in a function)", id);
    3722                 :        261 :       scope = current_scope;
    3723                 :            :     }
    3724                 :            :   else
    3725                 :            :     {
    3726                 :        854 :       if (!objc_diagnose_private_ivar (id))
    3727                 :            :         {
    3728                 :       1708 :           name_hint guessed_id = lookup_name_fuzzy (id, FUZZY_LOOKUP_NAME, loc);
    3729                 :        854 :           if (const char *suggestion = guessed_id.suggestion ())
    3730                 :            :             {
    3731                 :         50 :               gcc_rich_location richloc (loc);
    3732                 :         25 :               richloc.add_fixit_replace (suggestion);
    3733                 :         25 :               error_at (&richloc,
    3734                 :            :                         "%qE undeclared (first use in this function);"
    3735                 :            :                         " did you mean %qs?",
    3736                 :            :                         id, suggestion);
    3737                 :            :             }
    3738                 :            :           else
    3739                 :        829 :             error_at (loc, "%qE undeclared (first use in this function)", id);
    3740                 :            :         }
    3741                 :        854 :       if (!already)
    3742                 :            :         {
    3743                 :        261 :           inform (loc, "each undeclared identifier is reported only"
    3744                 :            :                   " once for each function it appears in");
    3745                 :        261 :           already = true;
    3746                 :            :         }
    3747                 :            : 
    3748                 :            :       /* If we are parsing old-style parameter decls, current_function_decl
    3749                 :            :          will be nonnull but current_function_scope will be null.  */
    3750                 :        854 :       scope = current_function_scope ? current_function_scope : current_scope;
    3751                 :            :     }
    3752                 :       1115 :   bind (id, error_mark_node, scope, /*invisible=*/false, /*nested=*/false,
    3753                 :            :         UNKNOWN_LOCATION);
    3754                 :       1115 : }
    3755                 :            : 
    3756                 :            : /* Subroutine of lookup_label, declare_label, define_label: construct a
    3757                 :            :    LABEL_DECL with all the proper frills.  Also create a struct
    3758                 :            :    c_label_vars initialized for the current scope.  */
    3759                 :            : 
    3760                 :            : static tree
    3761                 :      21190 : make_label (location_t location, tree name, bool defining,
    3762                 :            :             struct c_label_vars **p_label_vars)
    3763                 :            : {
    3764                 :      21190 :   tree label = build_decl (location, LABEL_DECL, name, void_type_node);
    3765                 :      21190 :   DECL_CONTEXT (label) = current_function_decl;
    3766                 :      21190 :   SET_DECL_MODE (label, VOIDmode);
    3767                 :            : 
    3768                 :      21190 :   c_label_vars *label_vars = ggc_alloc<c_label_vars> ();
    3769                 :      21190 :   label_vars->shadowed = NULL;
    3770                 :      21190 :   set_spot_bindings (&label_vars->label_bindings, defining);
    3771                 :      21190 :   label_vars->decls_in_scope = make_tree_vector ();
    3772                 :      21190 :   label_vars->gotos = NULL;
    3773                 :      21190 :   *p_label_vars = label_vars;
    3774                 :            : 
    3775                 :      21190 :   return label;
    3776                 :            : }
    3777                 :            : 
    3778                 :            : /* Get the LABEL_DECL corresponding to identifier NAME as a label.
    3779                 :            :    Create one if none exists so far for the current function.
    3780                 :            :    This is called when a label is used in a goto expression or
    3781                 :            :    has its address taken.  */
    3782                 :            : 
    3783                 :            : tree
    3784                 :      82375 : lookup_label (tree name)
    3785                 :            : {
    3786                 :      82375 :   tree label;
    3787                 :      82375 :   struct c_label_vars *label_vars;
    3788                 :            : 
    3789                 :      82375 :   if (current_function_scope == 0)
    3790                 :            :     {
    3791                 :          2 :       error ("label %qE referenced outside of any function", name);
    3792                 :          2 :       return NULL_TREE;
    3793                 :            :     }
    3794                 :            : 
    3795                 :            :   /* Use a label already defined or ref'd with this name, but not if
    3796                 :            :      it is inherited from a containing function and wasn't declared
    3797                 :            :      using __label__.  */
    3798                 :      82373 :   label = I_LABEL_DECL (name);
    3799                 :     155776 :   if (label && (DECL_CONTEXT (label) == current_function_decl
    3800                 :        603 :                 || C_DECLARED_LABEL_FLAG (label)))
    3801                 :            :     {
    3802                 :            :       /* If the label has only been declared, update its apparent
    3803                 :            :          location to point here, for better diagnostics if it
    3804                 :            :          turns out not to have been defined.  */
    3805                 :      77881 :       if (DECL_INITIAL (label) == NULL_TREE)
    3806                 :      61958 :         DECL_SOURCE_LOCATION (label) = input_location;
    3807                 :      77881 :       return label;
    3808                 :            :     }
    3809                 :            : 
    3810                 :            :   /* No label binding for that identifier; make one.  */
    3811                 :       4492 :   label = make_label (input_location, name, false, &label_vars);
    3812                 :            : 
    3813                 :            :   /* Ordinary labels go in the current function scope.  */
    3814                 :       4492 :   bind_label (name, label, current_function_scope, label_vars);
    3815                 :            : 
    3816                 :       4492 :   return label;
    3817                 :            : }
    3818                 :            : 
    3819                 :            : /* Issue a warning about DECL for a goto statement at GOTO_LOC going
    3820                 :            :    to LABEL.  */
    3821                 :            : 
    3822                 :            : static void
    3823                 :       1464 : warn_about_goto (location_t goto_loc, tree label, tree decl)
    3824                 :            : {
    3825                 :       1464 :   if (variably_modified_type_p (TREE_TYPE (decl), NULL_TREE))
    3826                 :       1461 :     error_at (goto_loc,
    3827                 :            :               "jump into scope of identifier with variably modified type");
    3828                 :            :   else
    3829                 :          3 :     warning_at (goto_loc, OPT_Wjump_misses_init,
    3830                 :            :                 "jump skips variable initialization");
    3831                 :       1464 :   inform (DECL_SOURCE_LOCATION (label), "label %qD defined here", label);
    3832                 :       1464 :   inform (DECL_SOURCE_LOCATION (decl), "%qD declared here", decl);
    3833                 :       1464 : }
    3834                 :            : 
    3835                 :            : /* Look up a label because of a goto statement.  This is like
    3836                 :            :    lookup_label, but also issues any appropriate warnings.  */
    3837                 :            : 
    3838                 :            : tree
    3839                 :      80665 : lookup_label_for_goto (location_t loc, tree name)
    3840                 :            : {
    3841                 :      80665 :   tree label;
    3842                 :      80665 :   struct c_label_vars *label_vars;
    3843                 :      80665 :   unsigned int ix;
    3844                 :      80665 :   tree decl;
    3845                 :            : 
    3846                 :      80665 :   label = lookup_label (name);
    3847                 :      80665 :   if (label == NULL_TREE)
    3848                 :            :     return NULL_TREE;
    3849                 :            : 
    3850                 :            :   /* If we are jumping to a different function, we can't issue any
    3851                 :            :      useful warnings.  */
    3852                 :      80665 :   if (DECL_CONTEXT (label) != current_function_decl)
    3853                 :            :     {
    3854                 :       1038 :       gcc_assert (C_DECLARED_LABEL_FLAG (label));
    3855                 :            :       return label;
    3856                 :            :     }
    3857                 :            : 
    3858                 :      80146 :   label_vars = I_LABEL_BINDING (name)->u.label;
    3859                 :            : 
    3860                 :            :   /* If the label has not yet been defined, then push this goto on a
    3861                 :            :      list for possible later warnings.  */
    3862                 :      80146 :   if (label_vars->label_bindings.scope == NULL)
    3863                 :            :     {
    3864                 :      64502 :       c_goto_bindings *g = ggc_alloc<c_goto_bindings> ();
    3865                 :            : 
    3866                 :      64502 :       g->loc = loc;
    3867                 :      64502 :       set_spot_bindings (&g->goto_bindings, true);
    3868                 :      64502 :       vec_safe_push (label_vars->gotos, g);
    3869                 :      64502 :       return label;
    3870                 :            :     }
    3871                 :            : 
    3872                 :            :   /* If there are any decls in label_vars->decls_in_scope, then this
    3873                 :            :      goto has missed the declaration of the decl.  This happens for a
    3874                 :            :      case like
    3875                 :            :        int i = 1;
    3876                 :            :       lab:
    3877                 :            :        ...
    3878                 :            :        goto lab;
    3879                 :            :      Issue a warning or error.  */
    3880                 :      16419 :   FOR_EACH_VEC_SAFE_ELT (label_vars->decls_in_scope, ix, decl)
    3881                 :        775 :     warn_about_goto (loc, label, decl);
    3882                 :            : 
    3883                 :      15644 :   if (label_vars->label_bindings.left_stmt_expr)
    3884                 :            :     {
    3885                 :        117 :       error_at (loc, "jump into statement expression");
    3886                 :        117 :       inform (DECL_SOURCE_LOCATION (label), "label %qD defined here", label);
    3887                 :            :     }
    3888                 :            : 
    3889                 :            :   return label;
    3890                 :            : }
    3891                 :            : 
    3892                 :            : /* Make a label named NAME in the current function, shadowing silently
    3893                 :            :    any that may be inherited from containing functions or containing
    3894                 :            :    scopes.  This is called for __label__ declarations.  */
    3895                 :            : 
    3896                 :            : tree
    3897                 :       1119 : declare_label (tree name)
    3898                 :            : {
    3899                 :       1119 :   struct c_binding *b = I_LABEL_BINDING (name);
    3900                 :       1119 :   tree label;
    3901                 :       1119 :   struct c_label_vars *label_vars;
    3902                 :            : 
    3903                 :            :   /* Check to make sure that the label hasn't already been declared
    3904                 :            :      at this scope */
    3905                 :       1119 :   if (b && B_IN_CURRENT_SCOPE (b))
    3906                 :            :     {
    3907                 :          2 :       auto_diagnostic_group d;
    3908                 :          2 :       error ("duplicate label declaration %qE", name);
    3909                 :          2 :       locate_old_decl (b->decl);
    3910                 :            : 
    3911                 :            :       /* Just use the previous declaration.  */
    3912                 :          2 :       return b->decl;
    3913                 :            :     }
    3914                 :            : 
    3915                 :       1117 :   label = make_label (input_location, name, false, &label_vars);
    3916                 :       1117 :   C_DECLARED_LABEL_FLAG (label) = 1;
    3917                 :            : 
    3918                 :            :   /* Declared labels go in the current scope.  */
    3919                 :       1117 :   bind_label (name, label, current_scope, label_vars);
    3920                 :            : 
    3921                 :       1117 :   return label;
    3922                 :            : }
    3923                 :            : 
    3924                 :            : /* When we define a label, issue any appropriate warnings if there are
    3925                 :            :    any gotos earlier in the function which jump to this label.  */
    3926                 :            : 
    3927                 :            : static void
    3928                 :       5531 : check_earlier_gotos (tree label, struct c_label_vars* label_vars)
    3929                 :            : {
    3930                 :       5531 :   unsigned int ix;
    3931                 :       5531 :   struct c_goto_bindings *g;
    3932                 :            : 
    3933                 :      69969 :   FOR_EACH_VEC_SAFE_ELT (label_vars->gotos, ix, g)
    3934                 :            :     {
    3935                 :      64438 :       struct c_binding *b;
    3936                 :      64438 :       struct c_scope *scope;
    3937                 :            : 
    3938                 :            :       /* We have a goto to this label.  The goto is going forward.  In
    3939                 :            :          g->scope, the goto is going to skip any binding which was
    3940                 :            :          defined after g->bindings_in_scope.  */
    3941                 :      64438 :       if (g->goto_bindings.scope->has_jump_unsafe_decl)
    3942                 :            :         {
    3943                 :        236 :           for (b = g->goto_bindings.scope->bindings;
    3944                 :        548 :                b != g->goto_bindings.bindings_in_scope;
    3945                 :        312 :                b = b->prev)
    3946                 :            :             {
    3947                 :        312 :               if (decl_jump_unsafe (b->decl))
    3948                 :        154 :                 warn_about_goto (g->loc, label, b->decl);
    3949                 :            :             }
    3950                 :            :         }
    3951                 :            : 
    3952                 :            :       /* We also need to warn about decls defined in any scopes
    3953                 :            :          between the scope of the label and the scope of the goto.  */
    3954                 :      64438 :       for (scope = label_vars->label_bindings.scope;
    3955                 :      66255 :            scope != g->goto_bindings.scope;
    3956                 :       1817 :            scope = scope->outer)
    3957                 :            :         {
    3958                 :       1817 :           gcc_assert (scope != NULL);
    3959                 :       1817 :           if (scope->has_jump_unsafe_decl)
    3960                 :            :             {
    3961                 :        321 :               if (scope == label_vars->label_bindings.scope)
    3962                 :        249 :                 b = label_vars->label_bindings.bindings_in_scope;
    3963                 :            :               else
    3964                 :         72 :                 b = scope->bindings;
    3965                 :        856 :               for (; b != NULL; b = b->prev)
    3966                 :            :                 {
    3967                 :        535 :                   if (decl_jump_unsafe (b->decl))
    3968                 :        535 :                     warn_about_goto (g->loc, label, b->decl);
    3969                 :            :                 }
    3970                 :            :             }
    3971                 :            :         }
    3972                 :            : 
    3973                 :      64438 :       if (g->goto_bindings.stmt_exprs > 0)
    3974                 :            :         {
    3975                 :         96 :           error_at (g->loc, "jump into statement expression");
    3976                 :         96 :           inform (DECL_SOURCE_LOCATION (label), "label %qD defined here",
    3977                 :            :                   label);
    3978                 :            :         }
    3979                 :            :     }
    3980                 :            : 
    3981                 :            :   /* Now that the label is defined, we will issue warnings about
    3982                 :            :      subsequent gotos to this label when we see them.  */
    3983                 :       5531 :   vec_safe_truncate (label_vars->gotos, 0);
    3984                 :       5531 :   label_vars->gotos = NULL;
    3985                 :       5531 : }
    3986                 :            : 
    3987                 :            : /* Define a label, specifying the location in the source file.
    3988                 :            :    Return the LABEL_DECL node for the label, if the definition is valid.
    3989                 :            :    Otherwise return NULL_TREE.  */
    3990                 :            : 
    3991                 :            : tree
    3992                 :      21140 : define_label (location_t location, tree name)
    3993                 :            : {
    3994                 :            :   /* Find any preexisting label with this name.  It is an error
    3995                 :            :      if that label has already been defined in this function, or
    3996                 :            :      if there is a containing function with a declared label with
    3997                 :            :      the same name.  */
    3998                 :      21140 :   tree label = I_LABEL_DECL (name);
    3999                 :            : 
    4000                 :       5566 :   if (label
    4001                 :      11132 :       && ((DECL_CONTEXT (label) == current_function_decl
    4002                 :       5552 :            && DECL_INITIAL (label) != NULL_TREE)
    4003                 :       5545 :           || (DECL_CONTEXT (label) != current_function_decl
    4004                 :         14 :               && C_DECLARED_LABEL_FLAG (label))))
    4005                 :            :     {
    4006                 :         28 :       auto_diagnostic_group d;
    4007                 :         28 :       error_at (location, "duplicate label %qD", label);
    4008                 :         28 :       locate_old_decl (label);
    4009                 :         28 :       return NULL_TREE;
    4010                 :            :     }
    4011                 :      26650 :   else if (label && DECL_CONTEXT (label) == current_function_decl)
    4012                 :            :     {
    4013                 :       5531 :       struct c_label_vars *label_vars = I_LABEL_BINDING (name)->u.label;
    4014                 :            : 
    4015                 :            :       /* The label has been used or declared already in this function,
    4016                 :            :          but not defined.  Update its location to point to this
    4017                 :            :          definition.  */
    4018                 :       5531 :       DECL_SOURCE_LOCATION (label) = location;
    4019                 :       5531 :       set_spot_bindings (&label_vars->label_bindings, true);
    4020                 :            : 
    4021                 :            :       /* Issue warnings as required about any goto statements from
    4022                 :            :          earlier in the function.  */
    4023                 :       5531 :       check_earlier_gotos (label, label_vars);
    4024                 :            :     }
    4025                 :            :   else
    4026                 :            :     {
    4027                 :      15581 :       struct c_label_vars *label_vars;
    4028                 :            : 
    4029                 :            :       /* No label binding for that identifier; make one.  */
    4030                 :      15581 :       label = make_label (location, name, true, &label_vars);
    4031                 :            : 
    4032                 :            :       /* Ordinary labels go in the current function scope.  */
    4033                 :      15581 :       bind_label (name, label, current_function_scope, label_vars);
    4034                 :            :     }
    4035                 :            : 
    4036                 :      21112 :   if (!in_system_header_at (input_location) && lookup_name (name))
    4037                 :        100 :     warning_at (location, OPT_Wtraditional,
    4038                 :            :                 "traditional C lacks a separate namespace "
    4039                 :            :                 "for labels, identifier %qE conflicts", name);
    4040                 :            : 
    4041                 :            :   /* Mark label as having been defined.  */
    4042                 :      21112 :   DECL_INITIAL (label) = error_mark_node;
    4043                 :      21112 :   return label;
    4044                 :            : }
    4045                 :            : 
    4046                 :            : /* Get the bindings for a new switch statement.  This is used to issue
    4047                 :            :    warnings as appropriate for jumps from the switch to case or
    4048                 :            :    default labels.  */
    4049                 :            : 
    4050                 :            : struct c_spot_bindings *
    4051                 :      27721 : c_get_switch_bindings (void)
    4052                 :            : {
    4053                 :      27721 :   struct c_spot_bindings *switch_bindings;
    4054                 :            : 
    4055                 :      27721 :   switch_bindings = XNEW (struct c_spot_bindings);
    4056                 :      27721 :   set_spot_bindings (switch_bindings, true);
    4057                 :      27721 :   return switch_bindings;
    4058                 :            : }
    4059                 :            : 
    4060                 :            : void
    4061                 :      27721 : c_release_switch_bindings (struct c_spot_bindings *bindings)
    4062                 :            : {
    4063                 :      27721 :   gcc_assert (bindings->stmt_exprs == 0 && !bindings->left_stmt_expr);
    4064                 :      27721 :   XDELETE (bindings);
    4065                 :      27721 : }
    4066                 :            : 
    4067                 :            : /* This is called at the point of a case or default label to issue
    4068                 :            :    warnings about decls as needed.  It returns true if it found an
    4069                 :            :    error, not just a warning.  */
    4070                 :            : 
    4071                 :            : bool
    4072                 :     945845 : c_check_switch_jump_warnings (struct c_spot_bindings *switch_bindings,
    4073                 :            :                               location_t switch_loc, location_t case_loc)
    4074                 :            : {
    4075                 :     945845 :   bool saw_error;
    4076                 :     945845 :   struct c_scope *scope;
    4077                 :            : 
    4078                 :     945845 :   saw_error = false;
    4079                 :     945845 :   for (scope = current_scope;
    4080                 :    2837530 :        scope != switch_bindings->scope;
    4081                 :    1891690 :        scope = scope->outer)
    4082                 :            :     {
    4083                 :    1891690 :       struct c_binding *b;
    4084                 :            : 
    4085                 :    1891690 :       gcc_assert (scope != NULL);
    4086                 :            : 
    4087                 :    1891690 :       if (!scope->has_jump_unsafe_decl)
    4088                 :    1891680 :         continue;
    4089                 :            : 
    4090                 :         12 :       for (b = scope->bindings; b != NULL; b = b->prev)
    4091                 :            :         {
    4092                 :          6 :           if (decl_jump_unsafe (b->decl))
    4093                 :            :             {
    4094                 :          6 :               if (variably_modified_type_p (TREE_TYPE (b->decl), NULL_TREE))
    4095                 :            :                 {
    4096                 :          3 :                   saw_error = true;
    4097                 :          3 :                   error_at (case_loc,
    4098                 :            :                             ("switch jumps into scope of identifier with "
    4099                 :            :                              "variably modified type"));
    4100                 :            :                 }
    4101                 :            :               else
    4102                 :          3 :                 warning_at (case_loc, OPT_Wjump_misses_init,
    4103                 :            :                             "switch jumps over variable initialization");
    4104                 :          6 :               inform (switch_loc, "switch starts here");
    4105                 :          6 :               inform (DECL_SOURCE_LOCATION (b->decl), "%qD declared here",
    4106                 :            :                       b->decl);
    4107                 :            :             }
    4108                 :            :         }
    4109                 :            :     }
    4110                 :            : 
    4111                 :     945845 :   if (switch_bindings->stmt_exprs > 0)
    4112                 :            :     {
    4113                 :          2 :       saw_error = true;
    4114                 :          2 :       error_at (case_loc, "switch jumps into statement expression");
    4115                 :          2 :       inform (switch_loc, "switch starts here");
    4116                 :            :     }
    4117                 :            : 
    4118                 :     945845 :   return saw_error;
    4119                 :            : }
    4120                 :            : 
    4121                 :            : /* Given NAME, an IDENTIFIER_NODE,
    4122                 :            :    return the structure (or union or enum) definition for that name.
    4123                 :            :    If THISLEVEL_ONLY is nonzero, searches only the current_scope.
    4124                 :            :    CODE says which kind of type the caller wants;
    4125                 :            :    it is RECORD_TYPE or UNION_TYPE or ENUMERAL_TYPE.
    4126                 :            :    If PLOC is not NULL and this returns non-null, it sets *PLOC to the
    4127                 :            :    location where the tag was defined.
    4128                 :            :    If the wrong kind of type is found, an error is reported.  */
    4129                 :            : 
    4130                 :            : static tree
    4131                 :    1590020 : lookup_tag (enum tree_code code, tree name, bool thislevel_only,
    4132                 :            :             location_t *ploc)
    4133                 :            : {
    4134                 :    1590020 :   struct c_binding *b = I_TAG_BINDING (name);
    4135                 :    1590020 :   bool thislevel = false;
    4136                 :            : 
    4137                 :    1590020 :   if (!b || !b->decl)
    4138                 :            :     return NULL_TREE;
    4139                 :            : 
    4140                 :            :   /* We only care about whether it's in this level if
    4141                 :            :      thislevel_only was set or it might be a type clash.  */
    4142                 :    1113930 :   if (thislevel_only || TREE_CODE (b->decl) != code)
    4143                 :            :     {
    4144                 :            :       /* For our purposes, a tag in the external scope is the same as
    4145                 :            :          a tag in the file scope.  (Primarily relevant to Objective-C
    4146                 :            :          and its builtin structure tags, which get pushed before the
    4147                 :            :          file scope is created.)  */
    4148                 :     363030 :       if (B_IN_CURRENT_SCOPE (b)
    4149                 :         55 :           || (current_scope == file_scope && B_IN_EXTERNAL_SCOPE (b)))
    4150                 :     362975 :         thislevel = true;
    4151                 :            :     }
    4152                 :            : 
    4153                 :    1113930 :   if (thislevel_only && !thislevel)
    4154                 :            :     return NULL_TREE;
    4155                 :            : 
    4156                 :    1113890 :   if (TREE_CODE (b->decl) != code)
    4157                 :            :     {
    4158                 :            :       /* Definition isn't the kind we were looking for.  */
    4159                 :         31 :       pending_invalid_xref = name;
    4160                 :         31 :       pending_invalid_xref_location = input_location;
    4161                 :            : 
    4162                 :            :       /* If in the same binding level as a declaration as a tag
    4163                 :            :          of a different type, this must not be allowed to
    4164                 :            :          shadow that tag, so give the error immediately.
    4165                 :            :          (For example, "struct foo; union foo;" is invalid.)  */
    4166                 :         31 :       if (thislevel)
    4167                 :         10 :         pending_xref_error ();
    4168                 :            :     }
    4169                 :            : 
    4170                 :    1113890 :   if (ploc != NULL)
    4171                 :     770271 :     *ploc = b->locus;
    4172                 :            : 
    4173                 :    1113890 :   return b->decl;
    4174                 :            : }
    4175                 :            : 
    4176                 :            : /* Return true if a definition exists for NAME with code CODE.  */
    4177                 :            : 
    4178                 :            : bool
    4179                 :        294 : tag_exists_p (enum tree_code code, tree name)
    4180                 :            : {
    4181                 :        294 :   struct c_binding *b = I_TAG_BINDING (name);
    4182                 :            : 
    4183                 :        294 :   if (b == NULL || b->decl == NULL_TREE)
    4184                 :            :     return false;
    4185                 :         18 :   return TREE_CODE (b->decl) == code;
    4186                 :            : }
    4187                 :            : 
    4188                 :            : /* Print an error message now
    4189                 :            :    for a recent invalid struct, union or enum cross reference.
    4190                 :            :    We don't print them immediately because they are not invalid
    4191                 :            :    when used in the `struct foo;' construct for shadowing.  */
    4192                 :            : 
    4193                 :            : void
    4194                 :  184788000 : pending_xref_error (void)
    4195                 :            : {
    4196                 :  184788000 :   if (pending_invalid_xref != NULL_TREE)
    4197                 :         19 :     error_at (pending_invalid_xref_location, "%qE defined as wrong kind of tag",
    4198                 :            :               pending_invalid_xref);
    4199                 :  184788000 :   pending_invalid_xref = NULL_TREE;
    4200                 :  184788000 : }
    4201                 :            : 
    4202                 :            : 
    4203                 :            : /* Look up NAME in the current scope and its superiors
    4204                 :            :    in the namespace of variables, functions and typedefs.
    4205                 :            :    Return a ..._DECL node of some kind representing its definition,
    4206                 :            :    or return NULL_TREE if it is undefined.  */
    4207                 :            : 
    4208                 :            : tree
    4209                 :  708913000 : lookup_name (tree name)
    4210                 :            : {
    4211                 :  708913000 :   struct c_binding *b = I_SYMBOL_BINDING (name);
    4212                 :  708913000 :   if (b && !b->invisible)
    4213                 :            :     {
    4214                 :  478267000 :       maybe_record_typedef_use (b->decl);
    4215                 :  478267000 :       return b->decl;
    4216                 :            :     }
    4217                 :            :   return NULL_TREE;
    4218                 :            : }
    4219                 :            : 
    4220                 :            : /* Similar to `lookup_name' but look only at the indicated scope.  */
    4221                 :            : 
    4222                 :            : static tree
    4223                 :   57547900 : lookup_name_in_scope (tree name, struct c_scope *scope)
    4224                 :            : {
    4225                 :   57547900 :   struct c_binding *b;
    4226                 :            : 
    4227                 :   57551400 :   for (b = I_SYMBOL_BINDING (name); b; b = b->shadowed)
    4228                 :    1823220 :     if (B_IN_SCOPE (b, scope))
    4229                 :    1819720 :       return b->decl;
    4230                 :            :   return NULL_TREE;
    4231                 :            : }
    4232                 :            : 
    4233                 :            : /* Look for the closest match for NAME within the currently valid
    4234                 :            :    scopes.
    4235                 :            : 
    4236                 :            :    This finds the identifier with the lowest Levenshtein distance to
    4237                 :            :    NAME.  If there are multiple candidates with equal minimal distance,
    4238                 :            :    the first one found is returned.  Scopes are searched from innermost
    4239                 :            :    outwards, and within a scope in reverse order of declaration, thus
    4240                 :            :    benefiting candidates "near" to the current scope.
    4241                 :            : 
    4242                 :            :    The function also looks for similar macro names to NAME, since a
    4243                 :            :    misspelled macro name will not be expanded, and hence looks like an
    4244                 :            :    identifier to the C frontend.
    4245                 :            : 
    4246                 :            :    It also looks for start_typename keywords, to detect "singed" vs "signed"
    4247                 :            :    typos.
    4248                 :            : 
    4249                 :            :    Use LOC for any deferred diagnostics.  */
    4250                 :            : 
    4251                 :            : name_hint
    4252                 :       3596 : lookup_name_fuzzy (tree name, enum lookup_name_fuzzy_kind kind, location_t loc)
    4253                 :            : {
    4254                 :       3596 :   gcc_assert (TREE_CODE (name) == IDENTIFIER_NODE);
    4255                 :            : 
    4256                 :            :   /* First, try some well-known names in the C standard library, in case
    4257                 :            :      the user forgot a #include.  */
    4258                 :       3596 :   const char *header_hint
    4259                 :       3596 :     = get_c_stdlib_header_for_name (IDENTIFIER_POINTER (name));
    4260                 :            : 
    4261                 :       3596 :   if (header_hint)
    4262                 :         17 :     return name_hint (NULL,
    4263                 :            :                       new suggest_missing_header (loc,
    4264                 :         17 :                                                   IDENTIFIER_POINTER (name),
    4265                 :         17 :                                                   header_hint));
    4266                 :            : 
    4267                 :            :   /* Only suggest names reserved for the implementation if NAME begins
    4268                 :            :      with an underscore.  */
    4269                 :       3579 :   bool consider_implementation_names = (IDENTIFIER_POINTER (name)[0] == '_');
    4270                 :            : 
    4271                 :       3579 :   best_match<tree, tree> bm (name);
    4272                 :            : 
    4273                 :            :   /* Look within currently valid scopes.  */
    4274                 :      20021 :   for (c_scope *scope = current_scope; scope; scope = scope->outer)
    4275                 :   13155400 :     for (c_binding *binding = scope->bindings; binding; binding = binding->prev)
    4276                 :            :       {
    4277                 :   13139000 :         if (!binding->id || binding->invisible)
    4278                 :    7263540 :           continue;
    4279                 :    5875420 :         if (binding->decl == error_mark_node)
    4280                 :        301 :           continue;
    4281                 :            :         /* Don't use bindings from implicitly declared functions,
    4282                 :            :            as they were likely misspellings themselves.  */
    4283                 :    5875120 :         if (TREE_CODE (binding->decl) == FUNCTION_DECL)
    4284                 :    5410120 :           if (C_DECL_IMPLICIT (binding->decl))
    4285                 :       1025 :             continue;
    4286                 :            :         /* Don't suggest names that are reserved for use by the
    4287                 :            :            implementation, unless NAME began with an underscore.  */
    4288                 :    5874090 :         if (!consider_implementation_names)
    4289                 :            :           {
    4290                 :    3928090 :             const char *suggestion_str = IDENTIFIER_POINTER (binding->id);
    4291                 :    3928090 :             if (name_reserved_for_implementation_p (suggestion_str))
    4292                 :    3818250 :               continue;
    4293                 :            :           }
    4294                 :    2055840 :         switch (kind)
    4295                 :            :           {
    4296                 :      14488 :           case FUZZY_LOOKUP_TYPENAME:
    4297                 :      14488 :             if (TREE_CODE (binding->decl) != TYPE_DECL)
    4298                 :       9640 :               continue;
    4299                 :            :             break;
    4300                 :            : 
    4301                 :     265659 :           case FUZZY_LOOKUP_FUNCTION_NAME:
    4302                 :     265659 :             if (TREE_CODE (binding->decl) != FUNCTION_DECL)
    4303                 :            :               {
    4304                 :            :                 /* Allow function pointers.  */
    4305                 :      85459 :                 if ((VAR_P (binding->decl)
    4306                 :      74347 :                      || TREE_CODE (binding->decl) == PARM_DECL)
    4307                 :      15108 :                     && TREE_CODE (TREE_TYPE (binding->decl)) == POINTER_TYPE
    4308                 :      89006 :                     && (TREE_CODE (TREE_TYPE (TREE_TYPE (binding->decl)))
    4309                 :            :                         == FUNCTION_TYPE))
    4310                 :            :                   break;
    4311                 :      85421 :                 continue;
    4312                 :            :               }
    4313                 :            :             break;
    4314                 :            : 
    4315                 :            :           default:
    4316                 :            :             break;
    4317                 :            :           }
    4318                 :    1960780 :         bm.consider (binding->id);
    4319                 :            :       }
    4320                 :            : 
    4321                 :            :   /* Consider macros: if the user misspelled a macro name e.g. "SOME_MACRO"
    4322                 :            :      as:
    4323                 :            :        x = SOME_OTHER_MACRO (y);
    4324                 :            :      then "SOME_OTHER_MACRO" will survive to the frontend and show up
    4325                 :            :      as a misspelled identifier.
    4326                 :            : 
    4327                 :            :      Use the best distance so far so that a candidate is only set if
    4328                 :            :      a macro is better than anything so far.  This allows early rejection
    4329                 :            :      (without calculating the edit distance) of macro names that must have
    4330                 :            :      distance >= bm.get_best_distance (), and means that we only get a
    4331                 :            :      non-NULL result for best_macro_match if it's better than any of
    4332                 :            :      the identifiers already checked, which avoids needless creation
    4333                 :            :      of identifiers for macro hashnodes.  */
    4334                 :       3579 :   best_macro_match bmm (name, bm.get_best_distance (), parse_in);
    4335                 :       3579 :   cpp_hashnode *best_macro = bmm.get_best_meaningful_candidate ();
    4336                 :            :   /* If a macro is the closest so far to NAME, use it, creating an
    4337                 :            :      identifier tree node for it.  */
    4338                 :       3579 :   if (best_macro)
    4339                 :            :     {
    4340                 :          6 :       const char *id = (const char *)best_macro->ident.str;
    4341                 :          6 :       tree macro_as_identifier
    4342                 :          6 :         = get_identifier_with_length (id, best_macro->ident.len);
    4343                 :          6 :       bm.set_best_so_far (macro_as_identifier,
    4344                 :            :                           bmm.get_best_distance (),
    4345                 :            :                           bmm.get_best_candidate_length ());
    4346                 :            :     }
    4347                 :            : 
    4348                 :            :   /* Try the "start_typename" keywords to detect
    4349                 :            :      "singed" vs "signed" typos.  */
    4350                 :       3579 :   if (kind == FUZZY_LOOKUP_TYPENAME)
    4351                 :            :     {
    4352                 :      37184 :       for (unsigned i = 0; i < num_c_common_reswords; i++)
    4353                 :            :         {
    4354                 :      37018 :           const c_common_resword *resword = &c_common_reswords[i];
    4355                 :      37018 :           if (!c_keyword_starts_typename (resword->rid))
    4356                 :      28718 :             continue;
    4357                 :       8300 :           tree resword_identifier = ridpointers [resword->rid];
    4358                 :       8300 :           if (!resword_identifier)
    4359                 :         27 :             continue;
    4360                 :       8273 :           gcc_assert (TREE_CODE (resword_identifier) == IDENTIFIER_NODE);
    4361                 :       8273 :           bm.consider (resword_identifier);
    4362                 :            :         }
    4363                 :            :     }
    4364                 :            : 
    4365                 :       3579 :   tree best = bm.get_best_meaningful_candidate ();
    4366                 :       3579 :   if (best)
    4367                 :        420 :     return name_hint (IDENTIFIER_POINTER (best), NULL);
    4368                 :            :   else
    4369                 :       3159 :     return name_hint (NULL, NULL);
    4370                 :            : }
    4371                 :            : 
    4372                 :            : 
    4373                 :            : /* Table of supported standard (C2x) attributes.  */
    4374                 :            : const struct attribute_spec std_attribute_table[] =
    4375                 :            : {
    4376                 :            :   /* { name, min_len, max_len, decl_req, type_req, fn_type_req,
    4377                 :            :        affects_type_identity, handler, exclude } */
    4378                 :            :   { "deprecated", 0, 1, false, false, false, false,
    4379                 :            :     handle_deprecated_attribute, NULL },
    4380                 :            :   { "fallthrough", 0, 0, false, false, false, false,
    4381                 :            :     handle_fallthrough_attribute, NULL },
    4382                 :            :   { "maybe_unused", 0, 0, false, false, false, false,
    4383                 :            :     handle_unused_attribute, NULL },
    4384                 :            :   { NULL, 0, 0, false, false, false, false, NULL, NULL }
    4385                 :            : };
    4386                 :            : 
    4387                 :            : /* Create the predefined scalar types of C,
    4388                 :            :    and some nodes representing standard constants (0, 1, (void *) 0).
    4389                 :            :    Initialize the global scope.
    4390                 :            :    Make definitions for built-in primitive functions.  */
    4391                 :            : 
    4392                 :            : void
    4393                 :      78603 : c_init_decl_processing (void)
    4394                 :            : {
    4395                 :      78603 :   location_t save_loc = input_location;
    4396                 :            : 
    4397                 :            :   /* Initialize reserved words for parser.  */
    4398                 :      78603 :   c_parse_init ();
    4399                 :            : 
    4400                 :      78603 :   register_scoped_attributes (std_attribute_table, NULL);
    4401                 :            : 
    4402                 :      78603 :   current_function_decl = NULL_TREE;
    4403                 :            : 
    4404                 :      78603 :   gcc_obstack_init (&parser_obstack);
    4405                 :            : 
    4406                 :            :   /* Make the externals scope.  */
    4407                 :      78603 :   push_scope ();
    4408                 :      78603 :   external_scope = current_scope;
    4409                 :            : 
    4410                 :            :   /* Declarations from c_common_nodes_and_builtins must not be associated
    4411                 :            :      with this input file, lest we get differences between using and not
    4412                 :            :      using preprocessed headers.  */
    4413                 :      78603 :   input_location = BUILTINS_LOCATION;
    4414                 :            : 
    4415                 :      78603 :   c_common_nodes_and_builtins ();
    4416                 :            : 
    4417                 :            :   /* In C, comparisons and TRUTH_* expressions have type int.  */
    4418                 :      78603 :   truthvalue_type_node = integer_type_node;
    4419                 :      78603 :   truthvalue_true_node = integer_one_node;
    4420                 :      78603 :   truthvalue_false_node = integer_zero_node;
    4421                 :            : 
    4422                 :            :   /* Even in C99, which has a real boolean type.  */
    4423                 :      78603 :   pushdecl (build_decl (UNKNOWN_LOCATION, TYPE_DECL, get_identifier ("_Bool"),
    4424                 :            :                         boolean_type_node));
    4425                 :            : 
    4426                 :      78603 :   input_location = save_loc;
    4427                 :            : 
    4428                 :      78603 :   make_fname_decl = c_make_fname_decl;
    4429                 :      78603 :   start_fname_decls ();
    4430                 :      78603 : }
    4431                 :            : 
    4432                 :            : /* Create the VAR_DECL at LOC for __FUNCTION__ etc. ID is the name to
    4433                 :            :    give the decl, NAME is the initialization string and TYPE_DEP
    4434                 :            :    indicates whether NAME depended on the type of the function.  As we
    4435                 :            :    don't yet implement delayed emission of static data, we mark the
    4436                 :            :    decl as emitted so it is not placed in the output.  Anything using
    4437                 :            :    it must therefore pull out the STRING_CST initializer directly.
    4438                 :            :    FIXME.  */
    4439                 :            : 
    4440                 :            : static tree
    4441                 :       1586 : c_make_fname_decl (location_t loc, tree id, int type_dep)
    4442                 :            : {
    4443                 :       1586 :   const char *name = fname_as_string (type_dep);
    4444                 :       1586 :   tree decl, type, init;
    4445                 :       1586 :   size_t length = strlen (name);
    4446                 :            : 
    4447                 :       1586 :   type = build_array_type (char_type_node,
    4448                 :            :                            build_index_type (size_int (length)));
    4449                 :       1586 :   type = c_build_qualified_type (type, TYPE_QUAL_CONST);
    4450                 :            : 
    4451                 :       1586 :   decl = build_decl (loc, VAR_DECL, id, type);
    4452                 :            : 
    4453                 :       1586 :   TREE_STATIC (decl) = 1;
    4454                 :       1586 :   TREE_READONLY (decl) = 1;
    4455                 :       1586 :   DECL_ARTIFICIAL (decl) = 1;
    4456                 :            : 
    4457                 :       1586 :   init = build_string (length + 1, name);
    4458                 :       1586 :   free (CONST_CAST (char *, name));
    4459                 :       1586 :   TREE_TYPE (init) = type;
    4460                 :       1586 :   DECL_INITIAL (decl) = init;
    4461                 :            : 
    4462                 :       1586 :   TREE_USED (decl) = 1;
    4463                 :            : 
    4464                 :       1586 :   if (current_function_decl
    4465                 :            :       /* For invalid programs like this:
    4466                 :            : 
    4467                 :            :          void foo()
    4468                 :            :          const char* p = __FUNCTION__;
    4469                 :            : 
    4470                 :            :          the __FUNCTION__ is believed to appear in K&R style function
    4471                 :            :          parameter declarator.  In that case we still don't have
    4472                 :            :          function_scope.  */
    4473                 :       1586 :       && current_function_scope)
    4474                 :            :     {
    4475                 :       1571 :       DECL_CONTEXT (decl) = current_function_decl;
    4476                 :       1571 :       bind (id, decl, current_function_scope,
    4477                 :            :             /*invisible=*/false, /*nested=*/false, UNKNOWN_LOCATION);
    4478                 :            :     }
    4479                 :            : 
    4480                 :       1586 :   finish_decl (decl, loc, init, NULL_TREE, NULL_TREE);
    4481                 :            : 
    4482                 :       1586 :   return decl;
    4483                 :            : }
    4484                 :            : 
    4485                 :            : tree
    4486                 :  150454000 : c_builtin_function (tree decl)
    4487                 :            : {
    4488                 :  150454000 :   tree type = TREE_TYPE (decl);
    4489                 :  150454000 :   tree   id = DECL_NAME (decl);
    4490                 :            : 
    4491                 :  150454000 :   const char *name = IDENTIFIER_POINTER (id);
    4492                 :  150454000 :   C_DECL_BUILTIN_PROTOTYPE (decl) = prototype_p (type);
    4493                 :            : 
    4494                 :            :   /* Should never be called on a symbol with a preexisting meaning.  */
    4495                 :  150454000 :   gcc_assert (!I_SYMBOL_BINDING (id));
    4496                 :            : 
    4497                 :  150454000 :   bind (id, decl, external_scope, /*invisible=*/true, /*nested=*/false,
    4498                 :            :         UNKNOWN_LOCATION);
    4499                 :            : 
    4500                 :            :   /* Builtins in the implementation namespace are made visible without
    4501                 :            :      needing to be explicitly declared.  See push_file_scope.  */
    4502                 :  150454000 :   if (name[0] == '_' && (name[1] == '_' || ISUPPER (name[1])))
    4503                 :            :     {
    4504                 :  110381000 :       DECL_CHAIN (decl) = visible_builtins;
    4505                 :  110381000 :       visible_builtins = decl;
    4506                 :            :     }
    4507                 :            : 
    4508                 :  150454000 :   return decl;
    4509                 :            : }
    4510                 :            : 
    4511                 :            : tree
    4512                 :    5660420 : c_builtin_function_ext_scope (tree decl)
    4513                 :            : {
    4514                 :    5660420 :   tree type = TREE_TYPE (decl);
    4515                 :    5660420 :   tree   id = DECL_NAME (decl);
    4516                 :            : 
    4517                 :    5660420 :   const char *name = IDENTIFIER_POINTER (id);
    4518                 :    5660420 :   C_DECL_BUILTIN_PROTOTYPE (decl) = prototype_p (type);
    4519                 :            : 
    4520                 :    5660420 :   if (external_scope)
    4521                 :    5551130 :     bind (id, decl, external_scope, /*invisible=*/false, /*nested=*/false,
    4522                 :            :           UNKNOWN_LOCATION);
    4523                 :            : 
    4524                 :            :   /* Builtins in the implementation namespace are made visible without
    4525                 :            :      needing to be explicitly declared.  See push_file_scope.  */
    4526                 :    5660420 :   if (name[0] == '_' && (name[1] == '_' || ISUPPER (name[1])))
    4527                 :            :     {
    4528                 :    5660420 :       DECL_CHAIN (decl) = visible_builtins;
    4529                 :    5660420 :       visible_builtins = decl;
    4530                 :            :     }
    4531                 :            : 
    4532                 :    5660420 :   return decl;
    4533                 :            : }
    4534                 :            : 
    4535                 :            : /* Implement LANG_HOOKS_SIMULATE_BUILTIN_FUNCTION_DECL.  */
    4536                 :            : 
    4537                 :            : tree
    4538                 :          0 : c_simulate_builtin_function_decl (tree decl)
    4539                 :            : {
    4540                 :          0 :   tree type = TREE_TYPE (decl);
    4541                 :          0 :   C_DECL_BUILTIN_PROTOTYPE (decl) = prototype_p (type);
    4542                 :          0 :   return pushdecl (decl);
    4543                 :            : }
    4544                 :            : 
    4545                 :            : /* Warn about attributes in a context where they are unused
    4546                 :            :    (attribute-declarations, except for the "fallthrough" case, and
    4547                 :            :    attributes on statements).  */
    4548                 :            : 
    4549                 :            : void
    4550                 :   24926200 : c_warn_unused_attributes (tree attrs)
    4551                 :            : {
    4552                 :   24926200 :   for (tree t = attrs; t != NULL_TREE; t = TREE_CHAIN (t))
    4553                 :         15 :     if (get_attribute_namespace (t) == NULL_TREE)
    4554                 :            :       /* The specifications of standard attributes mean this is a
    4555                 :            :          constraint violation.  */
    4556                 :          9 :       pedwarn (input_location, OPT_Wattributes, "%qE attribute ignored",
    4557                 :            :                get_attribute_name (t));
    4558                 :            :     else
    4559                 :          6 :       warning (OPT_Wattributes, "%qE attribute ignored",
    4560                 :            :                get_attribute_name (t));
    4561                 :   24926200 : }
    4562                 :            : 
    4563                 :            : /* Warn for standard attributes being applied to a type that is not
    4564                 :            :    being defined, where that is a constraint violation, and return a
    4565                 :            :    list of attributes with them removed.  */
    4566                 :            : 
    4567                 :            : tree
    4568                 :  257042000 : c_warn_type_attributes (tree attrs)
    4569                 :            : {
    4570                 :  257042000 :   tree *attr_ptr = &attrs;
    4571                 :  257049000 :   while (*attr_ptr)
    4572                 :       7339 :     if (get_attribute_namespace (*attr_ptr) == NULL_TREE)
    4573                 :            :       {
    4574                 :         12 :         pedwarn (input_location, OPT_Wattributes, "%qE attribute ignored",
    4575                 :            :                  get_attribute_name (*attr_ptr));
    4576                 :         12 :         *attr_ptr = TREE_CHAIN (*attr_ptr);
    4577                 :            :       }
    4578                 :            :     else
    4579                 :       7327 :       attr_ptr = &TREE_CHAIN (*attr_ptr);
    4580                 :  257042000 :   return attrs;
    4581                 :            : }
    4582                 :            : 
    4583                 :            : /* Called when a declaration is seen that contains no names to declare.
    4584                 :            :    If its type is a reference to a structure, union or enum inherited
    4585                 :            :    from a containing scope, shadow that tag name for the current scope
    4586                 :            :    with a forward reference.
    4587                 :            :    If its type defines a new named structure or union
    4588                 :            :    or defines an enum, it is valid but we need not do anything here.
    4589                 :            :    Otherwise, it is an error.  */
    4590                 :            : 
    4591                 :            : void
    4592                 :     384476 : shadow_tag (const struct c_declspecs *declspecs)
    4593                 :            : {
    4594                 :     384476 :   shadow_tag_warned (declspecs, 0);
    4595                 :     384476 : }
    4596                 :            : 
    4597                 :            : /* WARNED is 1 if we have done a pedwarn, 2 if we have done a warning,
    4598                 :            :    but no pedwarn.  */
    4599                 :            : void
    4600                 :     384501 : shadow_tag_warned (const struct c_declspecs *declspecs, int warned)
    4601                 :            : {
    4602                 :     384501 :   bool found_tag = false;
    4603                 :            : 
    4604                 :     384501 :   if (declspecs->type && !declspecs->default_int_p && !declspecs->typedef_p)
    4605                 :            :     {
    4606                 :     384462 :       tree value = declspecs->type;
    4607                 :     384462 :       enum tree_code code = TREE_CODE (value);
    4608                 :            : 
    4609                 :     384462 :       if (code == RECORD_TYPE || code == UNION_TYPE || code == ENUMERAL_TYPE)
    4610                 :            :         /* Used to test also that TYPE_SIZE (value) != 0.
    4611                 :            :            That caused warning for `struct foo;' at top level in the file.  */
    4612                 :            :         {
    4613                 :     384422 :           tree name = TYPE_NAME (value);
    4614                 :     384422 :           tree t;
    4615                 :            : 
    4616                 :     384422 :           found_tag = true;
    4617                 :            : 
    4618                 :     384422 :           if (declspecs->restrict_p)
    4619                 :            :             {
    4620                 :          2 :               error ("invalid use of %<restrict%>");
    4621                 :          2 :               warned = 1;
    4622                 :            :             }
    4623                 :            : 
    4624                 :     384422 :           if (name == NULL_TREE)
    4625                 :            :             {
    4626                 :      40795 :               if (warned != 1 && code != ENUMERAL_TYPE)
    4627                 :            :                 /* Empty unnamed enum OK */
    4628                 :            :                 {
    4629                 :         16 :                   pedwarn (input_location, 0,
    4630                 :            :                            "unnamed struct/union that defines no instances");
    4631                 :         16 :                   warned = 1;
    4632                 :            :                 }
    4633                 :            :             }
    4634                 :     343627 :           else if (declspecs->typespec_kind != ctsk_tagdef
    4635                 :     343627 :                    && declspecs->typespec_kind != ctsk_tagfirstref
    4636                 :      19165 :                    && declspecs->typespec_kind != ctsk_tagfirstref_attrs
    4637                 :      19157 :                    && declspecs->storage_class != csc_none)
    4638                 :            :             {
    4639                 :          1 :               if (warned != 1)
    4640                 :          1 :                 pedwarn (input_location, 0,
    4641                 :            :                          "empty declaration with storage class specifier "
    4642                 :            :                          "does not redeclare tag");
    4643                 :          1 :               warned = 1;
    4644                 :          1 :               pending_xref_error ();
    4645                 :            :             }
    4646                 :     343626 :           else if (declspecs->typespec_kind != ctsk_tagdef
    4647                 :            :                    && declspecs->typespec_kind != ctsk_tagfirstref
    4648                 :      19164 :                    && declspecs->typespec_kind != ctsk_tagfirstref_attrs
    4649                 :      19156 :                    && (declspecs->const_p
    4650                 :            :                        || declspecs->volatile_p
    4651                 :            :                        || declspecs->atomic_p
    4652                 :            :                        || declspecs->restrict_p
    4653                 :      19156 :                        || declspecs->address_space))
    4654                 :            :             {
    4655                 :          3 :               if (warned != 1)
    4656                 :          3 :                 pedwarn (input_location, 0,
    4657                 :            :                          "empty declaration with type qualifier "
    4658                 :            :                           "does not redeclare tag");
    4659                 :          3 :               warned = 1;
    4660                 :          3 :               pending_xref_error ();
    4661                 :            :             }
    4662                 :     343623 :           else if (declspecs->typespec_kind != ctsk_tagdef
    4663                 :            :                    && declspecs->typespec_kind != ctsk_tagfirstref
    4664                 :      19161 :                    && declspecs->typespec_kind != ctsk_tagfirstref_attrs
    4665                 :      19153 :                    && declspecs->alignas_p)
    4666                 :            :             {
    4667                 :          1 :               if (warned != 1)
    4668                 :          1 :                 pedwarn (input_location, 0,
    4669                 :            :                          "empty declaration with %<_Alignas%> "
    4670                 :            :                           "does not redeclare tag");
    4671                 :          1 :               warned = 1;
    4672                 :          1 :               pending_xref_error ();
    4673                 :            :             }
    4674                 :            :           else
    4675                 :            :             {
    4676                 :     343622 :               pending_invalid_xref = NULL_TREE;
    4677                 :     343622 :               t = lookup_tag (code, name, true, NULL);
    4678                 :            : 
    4679                 :     343622 :               if (t == NULL_TREE)
    4680                 :            :                 {
    4681                 :          1 :                   t = make_node (code);
    4682                 :          1 :                   pushtag (input_location, name, t);
    4683                 :            :                 }
    4684                 :            :             }
    4685                 :            :         }
    4686                 :            :       else
    4687                 :            :         {
    4688                 :         40 :           if (warned != 1 && !in_system_header_at (input_location))
    4689                 :            :             {
    4690                 :         37 :               pedwarn (input_location, 0,
    4691                 :            :                        "useless type name in empty declaration");
    4692                 :         37 :               warned = 1;
    4693                 :            :             }
    4694                 :            :         }
    4695                 :            :     }
    4696                 :         34 :   else if (warned != 1 && !in_system_header_at (input_location)
    4697                 :         73 :            && declspecs->typedef_p)
    4698                 :            :     {
    4699                 :          8 :       pedwarn (input_location, 0, "useless type name in empty declaration");
    4700                 :          8 :       warned = 1;
    4701                 :            :     }
    4702                 :            : 
    4703                 :     384501 :   pending_invalid_xref = NULL_TREE;
    4704                 :            : 
    4705                 :     384501 :   if (declspecs->inline_p)
    4706                 :            :     {
    4707                 :          4 :       error ("%<inline%> in empty declaration");
    4708                 :          4 :       warned = 1;
    4709                 :            :     }
    4710                 :            : 
    4711                 :     384501 :   if (declspecs->noreturn_p)
    4712                 :            :     {
    4713                 :          1 :       error ("%<_Noreturn%> in empty declaration");
    4714                 :          1 :       warned = 1;
    4715                 :            :     }
    4716                 :            : 
    4717                 :     384501 :   if (current_scope == file_scope && declspecs->storage_class == csc_auto)
    4718                 :            :     {
    4719                 :          1 :       error ("%<auto%> in file-scope empty declaration");
    4720                 :          1 :       warned = 1;
    4721                 :            :     }
    4722                 :            : 
    4723                 :     384501 :   if (current_scope == file_scope && declspecs->storage_class == csc_register)
    4724                 :            :     {
    4725                 :          1 :       error ("%<register%> in file-scope empty declaration");
    4726                 :          1 :       warned = 1;
    4727                 :            :     }
    4728                 :            : 
    4729                 :     384406 :   if (!warned && !in_system_header_at (input_location)
    4730                 :     491866 :       && declspecs->storage_class != csc_none)
    4731                 :            :     {
    4732                 :         10 :       warning (0, "useless storage class specifier in empty declaration");
    4733                 :         10 :       warned = 2;
    4734                 :            :     }
    4735                 :            : 
    4736                 :     384501 :   if (!warned && !in_system_header_at (input_location) && declspecs->thread_p)
    4737                 :            :     {
    4738                 :          4 :       warning (0, "useless %qs in empty declaration",
    4739                 :          2 :                declspecs->thread_gnu_p ? "__thread" : "_Thread_local");
    4740                 :          2 :       warned = 2;
    4741                 :            :     }
    4742                 :            : 
    4743                 :          2 :   if (!warned
    4744                 :     384393 :       && !in_system_header_at (input_location)
    4745                 :     384499 :       && (declspecs->const_p
    4746                 :            :           || declspecs->volatile_p
    4747                 :            :           || declspecs->atomic_p
    4748                 :            :           || declspecs->restrict_p
    4749                 :     107354 :           || declspecs->address_space))
    4750                 :            :     {
    4751                 :          7 :       warning (0, "useless type qualifier in empty declaration");
    4752                 :          7 :       warned = 2;
    4753                 :            :     }
    4754                 :            : 
    4755                 :     384393 :   if (!warned && !in_system_header_at (input_location)
    4756                 :     491841 :       && declspecs->alignas_p)
    4757                 :            :     {
    4758                 :          2 :       warning (0, "useless %<_Alignas%> in empty declaration");
    4759                 :          2 :       warned = 2;
    4760                 :            :     }
    4761                 :            : 
    4762                 :     384501 :   if (found_tag
    4763                 :     384501 :       && warned == 2
    4764                 :         17 :       && (declspecs->typespec_kind == ctsk_tagref_attrs
    4765                 :         17 :           || declspecs->typespec_kind == ctsk_tagfirstref_attrs))
    4766                 :            :     {
    4767                 :            :       /* Standard attributes after the "struct" or "union" keyword are
    4768                 :            :          only permitted when the contents of the type are defined, or
    4769                 :            :          in the form "struct-or-union attribute-specifier-sequence
    4770                 :            :          identifier;".  If the ';' was not present, attributes were
    4771                 :            :          diagnosed in the parser.  Here, ensure that any other useless
    4772                 :            :          elements of the declaration result in a pedwarn, not just a
    4773                 :            :          warning.  Forward declarations of enum types are not part of
    4774                 :            :          standard C, but handle them the same.  */
    4775                 :          2 :       pedwarn (input_location, 0,
    4776                 :            :                "invalid use of attributes in empty declaration");
    4777                 :          2 :       warned = 1;
    4778                 :            :     }
    4779                 :            : 
    4780                 :     384501 :   if (warned != 1)
    4781                 :            :     {
    4782                 :     384403 :       if (declspecs->declspecs_seen_p
    4783                 :     384403 :           && !declspecs->non_std_attrs_seen_p)
    4784                 :            :         /* An attribute declaration (but not a fallthrough attribute
    4785                 :            :            declaration, which was handled separately); warn if there
    4786                 :            :            are any attributes being ignored (but not if the attributes
    4787                 :            :            were empty).  */
    4788                 :         20 :         c_warn_unused_attributes (declspecs->attrs);
    4789                 :     384383 :       else if (!found_tag)
    4790                 :          6 :         pedwarn (input_location, 0, "empty declaration");
    4791                 :            :     }
    4792                 :     384501 : }
    4793                 :            : 
    4794                 :            : 
    4795                 :            : /* Return the qualifiers from SPECS as a bitwise OR of TYPE_QUAL_*
    4796                 :            :    bits.  SPECS represents declaration specifiers that the grammar
    4797                 :            :    only permits to contain type qualifiers and attributes.  */
    4798                 :            : 
    4799                 :            : int
    4800                 :   12257200 : quals_from_declspecs (const struct c_declspecs *specs)
    4801                 :            : {
    4802                 :   12257200 :   int quals = ((specs->const_p ? TYPE_QUAL_CONST : 0)
    4803                 :            :                | (specs->volatile_p ? TYPE_QUAL_VOLATILE : 0)
    4804                 :            :                | (specs->restrict_p ? TYPE_QUAL_RESTRICT : 0)
    4805                 :   12257200 :                | (specs->atomic_p ? TYPE_QUAL_ATOMIC : 0)
    4806                 :   12257200 :                | (ENCODE_QUAL_ADDR_SPACE (specs->address_space)));
    4807                 :   12257200 :   gcc_assert (!specs->type
    4808                 :            :               && !specs->decl_attr
    4809                 :            :               && specs->typespec_word == cts_none
    4810                 :            :               && specs->storage_class == csc_none
    4811                 :            :               && !specs->typedef_p
    4812                 :            :               && !specs->explicit_signed_p
    4813                 :            :               && !specs->deprecated_p
    4814                 :            :               && !specs->long_p
    4815                 :            :               && !specs->long_long_p
    4816                 :            :               && !specs->short_p
    4817                 :            :               && !specs->signed_p
    4818                 :            :               && !specs->unsigned_p
    4819                 :            :               && !specs->complex_p
    4820                 :            :               && !specs->inline_p
    4821                 :            :               && !specs->noreturn_p
    4822                 :            :               && !specs->thread_p);
    4823                 :   12257200 :   return quals;
    4824                 :            : }
    4825                 :            : 
    4826                 :            : /* Construct an array declarator.  LOC is the location of the
    4827                 :            :    beginning of the array (usually the opening brace).  EXPR is the
    4828                 :            :    expression inside [], or NULL_TREE.  QUALS are the type qualifiers
    4829                 :            :    inside the [] (to be applied to the pointer to which a parameter
    4830                 :            :    array is converted).  STATIC_P is true if "static" is inside the
    4831                 :            :    [], false otherwise.  VLA_UNSPEC_P is true if the array is [*], a
    4832                 :            :    VLA of unspecified length which is nevertheless a complete type,
    4833                 :            :    false otherwise.  The field for the contained declarator is left to
    4834                 :            :    be filled in by set_array_declarator_inner.  */
    4835                 :            : 
    4836                 :            : struct c_declarator *
    4837                 :     755899 : build_array_declarator (location_t loc,
    4838                 :            :                         tree expr, struct c_declspecs *quals, bool static_p,
    4839                 :            :                         bool vla_unspec_p)
    4840                 :            : {
    4841                 :     755899 :   struct c_declarator *declarator = XOBNEW (&parser_obstack,
    4842                 :            :                                             struct c_declarator);
    4843                 :     755899 :   declarator->id_loc = loc;
    4844                 :     755899 :   declarator->kind = cdk_array;
    4845                 :     755899 :   declarator->declarator = 0;
    4846                 :     755899 :   declarator->u.array.dimen = expr;
    4847                 :     755899 :   if (quals)
    4848                 :            :     {
    4849                 :         40 :       declarator->u.array.attrs = quals->attrs;
    4850                 :         40 :       declarator->u.array.quals = quals_from_declspecs (quals);
    4851                 :            :     }
    4852                 :            :   else
    4853                 :            :     {
    4854                 :     755859 :       declarator->u.array.attrs = NULL_TREE;
    4855                 :     755859 :       declarator->u.array.quals = 0;
    4856                 :            :     }
    4857                 :     755899 :   declarator->u.array.static_p = static_p;
    4858                 :     755899 :   declarator->u.array.vla_unspec_p = vla_unspec_p;
    4859                 :     755899 :   if (static_p || quals != NULL)
    4860                 :         74 :     pedwarn_c90 (loc, OPT_Wpedantic,
    4861                 :            :                  "ISO C90 does not support %<static%> or type "
    4862                 :            :                  "qualifiers in parameter array declarators");
    4863                 :     755899 :   if (vla_unspec_p)
    4864                 :         37 :     pedwarn_c90 (loc, OPT_Wpedantic,
    4865                 :            :                  "ISO C90 does not support %<[*]%> array declarators");
    4866                 :     755899 :   if (vla_unspec_p)
    4867                 :            :     {
    4868                 :         37 :       if (!current_scope->parm_flag)
    4869                 :            :         {
    4870                 :            :           /* C99 6.7.5.2p4 */
    4871                 :          4 :           error_at (loc, "%<[*]%> not allowed in other than "
    4872                 :            :                     "function prototype scope");
    4873                 :          4 :           declarator->u.array.vla_unspec_p = false;
    4874                 :          4 :           return NULL;
    4875                 :            :         }
    4876                 :         33 :       current_scope->had_vla_unspec = true;
    4877                 :            :     }
    4878                 :            :   return declarator;
    4879                 :            : }
    4880                 :            : 
    4881                 :            : /* Set the contained declarator of an array declarator.  DECL is the
    4882                 :            :    declarator, as constructed by build_array_declarator; INNER is what
    4883                 :            :    appears on the left of the [].  */
    4884                 :            : 
    4885                 :            : struct c_declarator *
    4886                 :     755895 : set_array_declarator_inner (struct c_declarator *decl,
    4887                 :            :                             struct c_declarator *inner)
    4888                 :            : {
    4889                 :     755895 :   decl->declarator = inner;
    4890                 :     755895 :   return decl;
    4891                 :            : }
    4892                 :            : 
    4893                 :            : /* INIT is a constructor that forms DECL's initializer.  If the final
    4894                 :            :    element initializes a flexible array field, add the size of that
    4895                 :            :    initializer to DECL's size.  */
    4896                 :            : 
    4897                 :            : static void
    4898                 :      19294 : add_flexible_array_elts_to_size (tree decl, tree init)
    4899                 :            : {
    4900                 :      19294 :   tree elt, type;
    4901                 :            : 
    4902                 :      19294 :   if (vec_safe_is_empty (CONSTRUCTOR_ELTS (init)))
    4903                 :        857 :     return;
    4904                 :            : 
    4905                 :      18437 :   elt = CONSTRUCTOR_ELTS (init)->last ().value;
    4906                 :      18437 :   type = TREE_TYPE (elt);
    4907                 :      18437 :   if (TREE_CODE (type) == ARRAY_TYPE
    4908                 :       1211 :       && TYPE_SIZE (type) == NULL_TREE
    4909                 :        123 :       && TYPE_DOMAIN (type) != NULL_TREE
    4910                 :      18560 :       && TYPE_MAX_VALUE (TYPE_DOMAIN (type)) == NULL_TREE)
    4911                 :            :     {
    4912                 :        123 :       complete_array_type (&type, elt, false);
    4913                 :        123 :       DECL_SIZE (decl)
    4914                 :        123 :         = size_binop (PLUS_EXPR, DECL_SIZE (decl), TYPE_SIZE (type));
    4915                 :        123 :       DECL_SIZE_UNIT (decl)
    4916                 :        123 :         = size_binop (PLUS_EXPR, DECL_SIZE_UNIT (decl), TYPE_SIZE_UNIT (type));
    4917                 :            :     }
    4918                 :            : }
    4919                 :            : 
    4920                 :            : /* Decode a "typename", such as "int **", returning a ..._TYPE node.
    4921                 :            :    Set *EXPR, if EXPR not NULL, to any expression to be evaluated
    4922                 :            :    before the type name, and set *EXPR_CONST_OPERANDS, if
    4923                 :            :    EXPR_CONST_OPERANDS not NULL, to indicate whether the type name may
    4924                 :            :    appear in a constant expression.  */
    4925                 :            : 
    4926                 :            : tree
    4927                 :   71834100 : groktypename (struct c_type_name *type_name, tree *expr,
    4928                 :            :               bool *expr_const_operands)
    4929                 :            : {
    4930                 :   71834100 :   tree type;
    4931                 :   71834100 :   tree attrs = type_name->specs->attrs;
    4932                 :            : 
    4933                 :   71834100 :   type_name->specs->attrs = NULL_TREE;
    4934                 :            : 
    4935                 :   71834100 :   type = grokdeclarator (type_name->declarator, type_name->specs, TYPENAME,
    4936                 :            :                          false, NULL, &attrs, expr, expr_const_operands,
    4937                 :            :                          DEPRECATED_NORMAL);
    4938                 :            : 
    4939                 :            :   /* Apply attributes.  */
    4940                 :   71834100 :   attrs = c_warn_type_attributes (attrs);
    4941                 :   71834100 :   decl_attributes (&type, attrs, 0);
    4942                 :            : 
    4943                 :   71834100 :   return type;
    4944                 :            : }
    4945                 :            : 
    4946                 :            : /* Wrapper for decl_attributes that adds some implicit attributes
    4947                 :            :    to VAR_DECLs or FUNCTION_DECLs.  */
    4948                 :            : 
    4949                 :            : static tree
    4950                 :   38029800 : c_decl_attributes (tree *node, tree attributes, int flags)
    4951                 :            : {
    4952                 :            :   /* Add implicit "omp declare target" attribute if requested.  */
    4953                 :   38029800 :   if (current_omp_declare_target_attribute
    4954                 :       2616 :       && ((VAR_P (*node) && is_global_var (*node))
    4955                 :   38032300 :           || TREE_CODE (*node) == FUNCTION_DECL))
    4956                 :            :     {
    4957                 :        930 :       if (VAR_P (*node)
    4958                 :        930 :           && !lang_hooks.types.omp_mappable_type (TREE_TYPE (*node)))
    4959                 :          4 :         attributes = tree_cons (get_identifier ("omp declare target implicit"),
    4960                 :            :                                 NULL_TREE, attributes);
    4961                 :            :       else
    4962                 :            :         {
    4963                 :        926 :           attributes = tree_cons (get_identifier ("omp declare target"),
    4964                 :            :                                   NULL_TREE, attributes);
    4965                 :        926 :           attributes = tree_cons (get_identifier ("omp declare target block"),
    4966                 :            :                                   NULL_TREE, attributes);
    4967                 :            :         }
    4968                 :            :     }
    4969                 :            : 
    4970                 :            :   /* Look up the current declaration with all the attributes merged
    4971                 :            :      so far so that attributes on the current declaration that's
    4972                 :            :      about to be pushed that conflict with the former can be detected,
    4973                 :            :      diagnosed, and rejected as appropriate.  */
    4974                 :   38029800 :   tree last_decl = lookup_name (DECL_NAME (*node));
    4975                 :   38029800 :   if (!last_decl)
    4976                 :   37207600 :     last_decl = lookup_name_in_scope (DECL_NAME (*node), external_scope);
    4977                 :            : 
    4978                 :   38029800 :   return decl_attributes (node, attributes, flags, last_decl);
    4979                 :            : }
    4980                 :            : 
    4981                 :            : 
    4982                 :            : /* Decode a declarator in an ordinary declaration or data definition.
    4983                 :            :    This is called as soon as the type information and variable name
    4984                 :            :    have been parsed, before parsing the initializer if any.
    4985                 :            :    Here we create the ..._DECL node, fill in its type,
    4986                 :            :    and put it on the list of decls for the current context.
    4987                 :            :    The ..._DECL node is returned as the value.
    4988                 :            : 
    4989                 :            :    Exception: for arrays where the length is not specified,
    4990                 :            :    the type is left null, to be filled in by `finish_decl'.
    4991                 :            : 
    4992                 :            :    Function definitions do not come here; they go to start_function
    4993                 :            :    instead.  However, external and forward declarations of functions
    4994                 :            :    do go through here.  Structure field declarations are done by
    4995                 :            :    grokfield and not through here.  */
    4996                 :            : 
    4997                 :            : tree
    4998                 :   17689500 : start_decl (struct c_declarator *declarator, struct c_declspecs *declspecs,
    4999                 :            :             bool initialized, tree attributes)
    5000                 :            : {
    5001                 :   17689500 :   tree decl;
    5002                 :   17689500 :   tree tem;
    5003                 :   17689500 :   tree expr = NULL_TREE;
    5004                 :   17689500 :   enum deprecated_states deprecated_state = DEPRECATED_NORMAL;
    5005                 :            : 
    5006                 :            :   /* An object declared as __attribute__((deprecated)) suppresses
    5007                 :            :      warnings of uses of other deprecated items.  */
    5008                 :   17689500 :   if (lookup_attribute ("deprecated", attributes))
    5009                 :      11141 :     deprecated_state = DEPRECATED_SUPPRESS;
    5010                 :            : 
    5011                 :   17689500 :   decl = grokdeclarator (declarator, declspecs,
    5012                 :            :                          NORMAL, initialized, NULL, &attributes, &expr, NULL,
    5013                 :            :                          deprecated_state);
    5014                 :   17689500 :   if (!decl || decl == error_mark_node)
    5015                 :            :     return NULL_TREE;
    5016                 :            : 
    5017                 :   17689500 :   if (expr)
    5018                 :      11867 :     add_stmt (fold_convert (void_type_node, expr));
    5019                 :            : 
    5020                 :    7400750 :   if (TREE_CODE (decl) != FUNCTION_DECL && MAIN_NAME_P (DECL_NAME (decl))
    5021                 :   17689500 :       && TREE_PUBLIC (decl))
    5022                 :          1 :     warning (OPT_Wmain, "%q+D is usually a function", decl);
    5023                 :            : 
    5024                 :   17689500 :   if (initialized)
    5025                 :            :     /* Is it valid for this decl to have an initializer at all?
    5026                 :            :        If not, set INITIALIZED to zero, which will indirectly
    5027                 :            :        tell 'finish_decl' to ignore the initializer once it is parsed.  */
    5028                 :    2090910 :     switch (TREE_CODE (decl))
    5029                 :            :       {
    5030                 :          2 :       case TYPE_DECL:
    5031                 :          2 :         error ("typedef %qD is initialized (use %<__typeof__%> instead)", decl);
    5032                 :          2 :         initialized = false;
    5033                 :          2 :         break;
    5034                 :            : 
    5035                 :          5 :       case FUNCTION_DECL:
    5036                 :          5 :         error ("function %qD is initialized like a variable", decl);
    5037                 :          5 :         initialized = false;
    5038                 :          5 :         break;
    5039                 :            : 
    5040                 :         49 :       case PARM_DECL:
    5041                 :            :         /* DECL_INITIAL in a PARM_DECL is really DECL_ARG_TYPE.  */
    5042                 :         49 :         error ("parameter %qD is initialized", decl);
    5043                 :         49 :         initialized = false;
    5044                 :         49 :         break;
    5045                 :            : 
    5046                 :    2090850 :       default:
    5047                 :            :         /* Don't allow initializations for incomplete types except for
    5048                 :            :            arrays which might be completed by the initialization.  */
    5049                 :            : 
    5050                 :            :         /* This can happen if the array size is an undefined macro.
    5051                 :            :            We already gave a warning, so we don't need another one.  */
    5052                 :    2090850 :         if (TREE_TYPE (decl) == error_mark_node)
    5053                 :            :           initialized = false;
    5054                 :    2090830 :         else if (COMPLETE_TYPE_P (TREE_TYPE (decl)))
    5055                 :            :           {
    5056                 :            :             /* A complete type is ok if size is fixed.  */
    5057                 :            : 
    5058                 :    2083520 :             if (!poly_int_tree_p (TYPE_SIZE (TREE_TYPE (decl)))
    5059                 :    2083520 :                 || C_DECL_VARIABLE_SIZE (decl))
    5060                 :            :               {
    5061                 :         47 :                 error ("variable-sized object may not be initialized");
    5062                 :         47 :                 initialized = false;
    5063                 :            :               }
    5064                 :            :           }
    5065                 :       7316 :         else if (TREE_CODE (TREE_TYPE (decl)) != ARRAY_TYPE)
    5066                 :            :           {
    5067                 :          3 :             error ("variable %qD has initializer but incomplete type", decl);
    5068                 :          3 :             initialized = false;
    5069                 :            :           }
    5070                 :       7313 :         else if (C_DECL_VARIABLE_SIZE (decl))
    5071                 :            :           {
    5072                 :            :             /* Although C99 is unclear about whether incomplete arrays
    5073                 :            :                of VLAs themselves count as VLAs, it does not make
    5074                 :            :                sense to permit them to be initialized given that
    5075                 :            :                ordinary VLAs may not be initialized.  */
    5076                 :          2 :             error ("variable-sized object may not be initialized");
    5077                 :          2 :             initialized = false;
    5078                 :            :           }
    5079                 :            :       }
    5080                 :            : 
    5081                 :   17689500 :   if (initialized)
    5082                 :            :     {
    5083                 :    2090780 :       if (current_scope == file_scope)
    5084                 :      27692 :         TREE_STATIC (decl) = 1;
    5085                 :            : 
    5086                 :            :       /* Tell 'pushdecl' this is an initialized decl
    5087                 :            :          even though we don't yet have the initializer expression.
    5088                 :            :          Also tell 'finish_decl' it may store the real initializer.  */
    5089                 :    2090780 :       DECL_INITIAL (decl) = error_mark_node;
    5090                 :            :     }
    5091                 :            : 
    5092                 :            :   /* If this is a function declaration, write a record describing it to the
    5093                 :            :      prototypes file (if requested).  */
    5094                 :            : 
    5095                 :   17689500 :   if (TREE_CODE (decl) == FUNCTION_DECL)
    5096                 :   10288800 :     gen_aux_info_record (decl, 0, 0, prototype_p (TREE_TYPE (decl)));
    5097                 :            : 
    5098                 :            :   /* ANSI specifies that a tentative definition which is not merged with
    5099                 :            :      a non-tentative definition behaves exactly like a definition with an
    5100                 :            :      initializer equal to zero.  (Section 3.7.2)
    5101                 :            : 
    5102                 :            :      -fno-common gives strict ANSI behavior, though this tends to break
    5103                 :            :      a large body of code that grew up without this rule.
    5104                 :            : 
    5105                 :            :      Thread-local variables are never common, since there's no entrenched
    5106                 :            :      body of code to break, and it allows more efficient variable references
    5107                 :            :      in the presence of dynamic linking.  */
    5108                 :            : 
    5109                 :   17689500 :   if (VAR_P (decl)
    5110                 :    4471960 :       && !initialized
    5111                 :    2381180 :       && TREE_PUBLIC (decl)
    5112                 :     944946 :       && !DECL_THREAD_LOCAL_P (decl)
    5113                 :   18632200 :       && !flag_no_common)
    5114                 :         77 :     DECL_COMMON (decl) = 1;
    5115                 :            : 
    5116                 :            :   /* Set attributes here so if duplicate decl, will have proper attributes.  */
    5117                 :   17689500 :   c_decl_attributes (&decl, attributes, 0);
    5118                 :            : 
    5119                 :            :   /* Handle gnu_inline attribute.  */
    5120                 :   17689500 :   if (declspecs->inline_p
    5121                 :        815 :       && !flag_gnu89_inline
    5122                 :        783 :       && TREE_CODE (decl) == FUNCTION_DECL
    5123                 :   17690300 :       && (lookup_attribute ("gnu_inline", DECL_ATTRIBUTES (decl))
    5124                 :        752 :           || current_function_decl))
    5125                 :            :     {
    5126                 :         46 :       if (declspecs->storage_class == csc_auto && current_scope != file_scope)
    5127                 :            :         ;
    5128                 :         37 :       else if (declspecs->storage_class != csc_static)
    5129                 :         37 :         DECL_EXTERNAL (decl) = !DECL_EXTERNAL (decl);
    5130                 :            :     }
    5131                 :            : 
    5132                 :   17689500 :   if (TREE_CODE (decl) == FUNCTION_DECL
    5133                 :   17689500 :       && targetm.calls.promote_prototypes (TREE_TYPE (decl)))
    5134                 :            :     {
    5135                 :   10288800 :       struct c_declarator *ce = declarator;
    5136                 :            : 
    5137                 :   10288800 :       if (ce->kind == cdk_pointer)
    5138                 :     650154 :         ce = declarator->declarator;
    5139                 :   10288800 :       if (ce->kind == cdk_function)
    5140                 :            :         {
    5141                 :    9594780 :           tree args = ce->u.arg_info->parms;
    5142                 :   24709900 :           for (; args; args = DECL_CHAIN (args))
    5143                 :            :             {
    5144                 :   15115100 :               tree type = TREE_TYPE (args);
    5145                 :   15115100 :               if (type && INTEGRAL_TYPE_P (type)
    5146                 :   18177300 :                   && TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node))
    5147                 :      22208 :                 DECL_ARG_TYPE (args) = c_type_promotes_to (type);
    5148                 :            :             }
    5149                 :            :         }
    5150                 :            :     }
    5151                 :            : 
    5152                 :   17689500 :   if (TREE_CODE (decl) == FUNCTION_DECL
    5153                 :   10288800 :       && DECL_DECLARED_INLINE_P (decl)
    5154                 :        805 :       && DECL_UNINLINABLE (decl)
    5155                 :   17689500 :       && lookup_attribute ("noinline", DECL_ATTRIBUTES (decl)))
    5156                 :          2 :     warning (OPT_Wattributes, "inline function %q+D given attribute %qs",
    5157                 :            :              decl, "noinline");
    5158                 :            : 
    5159                 :            :   /* C99 6.7.4p3: An inline definition of a function with external
    5160                 :            :      linkage shall not contain a definition of a modifiable object
    5161                 :            :      with static storage duration...  */
    5162                 :   17689500 :   if (VAR_P (decl)
    5163                 :    4471960 :       && current_scope != file_scope
    5164                 :    3494810 :       && TREE_STATIC (decl)
    5165                 :      70830 :       && !TREE_READONLY (decl)
    5166                 :      68538 :       && DECL_DECLARED_INLINE_P (current_function_decl)
    5167                 :   17689600 :       && DECL_EXTERNAL (current_function_decl))
    5168                 :          7 :     record_inline_static (input_location, current_function_decl,
    5169                 :            :                           decl, csi_modifiable);
    5170                 :            : 
    5171                 :   17689500 :   if (c_dialect_objc ()
    5172                 :          0 :       && VAR_OR_FUNCTION_DECL_P (decl))
    5173                 :          0 :       objc_check_global_decl (decl);
    5174                 :            : 
    5175                 :            :   /* Add this decl to the current scope.
    5176                 :            :      TEM may equal DECL or it may be a previous decl of the same name.  */
    5177                 :   17689500 :   tem = pushdecl (decl);
    5178                 :            : 
    5179                 :   19780300 :   if (initialized && DECL_EXTERNAL (tem))
    5180                 :            :     {
    5181                 :         15 :       DECL_EXTERNAL (tem) = 0;
    5182                 :         15 :       TREE_STATIC (tem) = 1;
    5183                 :            :     }
    5184                 :            : 
    5185                 :            :   return tem;
    5186                 :            : }
    5187                 :            : 
    5188                 :            : /* Subroutine of finish_decl. TYPE is the type of an uninitialized object
    5189                 :            :    DECL or the non-array element type if DECL is an uninitialized array.
    5190                 :            :    If that type has a const member, diagnose this. */
    5191                 :            : 
    5192                 :            : static void
    5193                 :          7 : diagnose_uninitialized_cst_member (tree decl, tree type)
    5194                 :            : {
    5195                 :          7 :   tree field;
    5196                 :         18 :   for (field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field))
    5197                 :            :     {
    5198                 :         10 :       tree field_type;
    5199                 :         10 :       if (TREE_CODE (field) != FIELD_DECL)
    5200                 :          0 :         continue;
    5201                 :         10 :       field_type = strip_array_types (TREE_TYPE (field));
    5202                 :            : 
    5203                 :         10 :       if (TYPE_QUALS (field_type) & TYPE_QUAL_CONST)
    5204                 :            :         {
    5205                 :         10 :           warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wc___compat,
    5206                 :            :                       "uninitialized const member in %qT is invalid in C++",
    5207                 :          5 :                       strip_array_types (TREE_TYPE (decl)));
    5208                 :          5 :           inform (DECL_SOURCE_LOCATION (field), "%qD should be initialized", field);
    5209                 :            :         }
    5210                 :            : 
    5211                 :         10 :       if (RECORD_OR_UNION_TYPE_P (field_type))
    5212                 :          2 :         diagnose_uninitialized_cst_member (decl, field_type);
    5213                 :            :     }
    5214                 :          7 : }
    5215                 :            : 
    5216                 :            : /* Finish processing of a declaration;
    5217                 :            :    install its initial value.
    5218                 :            :    If ORIGTYPE is not NULL_TREE, it is the original type of INIT.
    5219                 :            :    If the length of an array type is not known before,
    5220                 :            :    it must be determined now, from the initial value, or it is an error.
    5221                 :            : 
    5222                 :            :    INIT_LOC is the location of the initial value.  */
    5223                 :            : 
    5224                 :            : void
    5225                 :   92987300 : finish_decl (tree decl, location_t init_loc, tree init,
    5226                 :            :              tree origtype, tree asmspec_tree)
    5227                 :            : {
    5228                 :   92987300 :   tree type;
    5229                 :   92987300 :   bool was_incomplete = (DECL_SIZE (decl) == NULL_TREE);
    5230                 :   92987300 :   const char *asmspec = 0;
    5231                 :            : 
    5232                 :            :   /* If a name was specified, get the string.  */
    5233                 :   88513700 :   if (VAR_OR_FUNCTION_DECL_P (decl)
    5234                 :  103276000 :       && DECL_FILE_SCOPE_P (decl))
    5235                 :   11267700 :     asmspec_tree = maybe_apply_renaming_pragma (decl, asmspec_tree);
    5236                 :   92987300 :   if (asmspec_tree)
    5237                 :     586216 :     asmspec = TREE_STRING_POINTER (asmspec_tree);
    5238                 :            : 
    5239                 :   92987300 :   if (VAR_P (decl)
    5240                 :   92987300 :       && TREE_STATIC (decl)
    5241                 :   92987300 :       && global_bindings_p ())
    5242                 :            :     /* So decl is a global variable. Record the types it uses
    5243                 :            :        so that we can decide later to emit debug info for them.  */
    5244                 :     818552 :     record_types_used_by_current_var_decl (decl);
    5245                 :            : 
    5246                 :            :   /* If `start_decl' didn't like having an initialization, ignore it now.  */
    5247                 :   92987300 :   if (init != NULL_TREE && DECL_INITIAL (decl) == NULL_TREE)
    5248                 :            :     init = NULL_TREE;
    5249                 :            : 
    5250                 :            :   /* Don't crash if parm is initialized.  */
    5251                 :   92987300 :   if (TREE_CODE (decl) == PARM_DECL)
    5252                 :            :     init = NULL_TREE;
    5253                 :            : 
    5254                 :   20652400 :   if (init)
    5255                 :    2092420 :     store_init_value (init_loc, decl, init, origtype);
    5256                 :            : 
    5257                 :   92987300 :   if (c_dialect_objc () && (VAR_OR_FUNCTION_DECL_P (decl)
    5258                 :          0 :                             || TREE_CODE (decl) == FIELD_DECL))
    5259                 :          0 :     objc_check_decl (decl);
    5260                 :            : 
    5261                 :   92987300 :   type = TREE_TYPE (decl);
    5262                 :            : 
    5263                 :            :   /* Deduce size of array from initialization, if not already known.
    5264                 :            :      This is only needed for an initialization in the current scope;
    5265                 :            :      it must not be done for a file-scope initialization of a
    5266                 :            :      declaration with external linkage, redeclared in an inner scope
    5267                 :            :      with the outer declaration shadowed in an intermediate scope.  */
    5268                 :   92987300 :   if (TREE_CODE (type) == ARRAY_TYPE
    5269                 :     627735 :       && TYPE_DOMAIN (type) == NULL_TREE
    5270                 :      26329 :       && TREE_CODE (decl) != TYPE_DECL
    5271                 :   93013500 :       && !(TREE_PUBLIC (decl) && current_scope != file_scope))
    5272                 :            :     {
    5273                 :      26035 :       bool do_default
    5274                 :            :         = (TREE_STATIC (decl)
    5275                 :            :            /* Even if pedantic, an external linkage array
    5276                 :            :               may have incomplete type at first.  */
    5277                 :       5126 :            ? pedantic && !TREE_PUBLIC (decl)
    5278                 :      26035 :            : !DECL_EXTERNAL (decl));
    5279                 :      26035 :       int failure
    5280                 :      26035 :         = complete_array_type (&TREE_TYPE (decl), DECL_INITIAL (decl),
    5281                 :            :                                do_default);
    5282                 :            : 
    5283                 :            :       /* Get the completed type made by complete_array_type.  */
    5284                 :      26035 :       type = TREE_TYPE (decl);
    5285                 :            : 
    5286                 :      26035 :       switch (failure)
    5287                 :            :         {
    5288                 :          0 :         case 1:
    5289                 :          0 :           error ("initializer fails to determine size of %q+D", decl);
    5290                 :          0 :           break;
    5291                 :            : 
    5292                 :      18745 :         case 2:
    5293                 :      18745 :           if (do_default)
    5294                 :          2 :             error ("array size missing in %q+D", decl);
    5295                 :            :           break;
    5296                 :            : 
    5297                 :          0 :         case 3:
    5298                 :          0 :           error ("zero or negative size array %q+D", decl);
    5299                 :          0 :           break;
    5300                 :            : 
    5301                 :       7290 :         case 0:
    5302                 :            :           /* For global variables, update the copy of the type that
    5303                 :            :              exists in the binding.  */
    5304                 :       7290 :           if (TREE_PUBLIC (decl))
    5305                 :            :             {
    5306                 :       2309 :               struct c_binding *b_ext = I_SYMBOL_BINDING (DECL_NAME (decl));
    5307                 :       4620 :               while (b_ext && !B_IN_EXTERNAL_SCOPE (b_ext))
    5308                 :       2311 :                 b_ext = b_ext->shadowed;
    5309                 :       2309 :               if (b_ext && TREE_CODE (decl) == TREE_CODE (b_ext->decl))
    5310                 :            :                 {
    5311                 :       2308 :                   if (b_ext->u.type && comptypes (b_ext->u.type, type))
    5312                 :        168 :                     b_ext->u.type = composite_type (b_ext->u.type, type);
    5313                 :            :                   else
    5314                 :       2140 :                     b_ext->u.type = type;
    5315                 :            :                 }
    5316                 :            :             }
    5317                 :            :           break;
    5318                 :            : 
    5319                 :          0 :         default:
    5320                 :          0 :           gcc_unreachable ();
    5321                 :            :         }
    5322                 :            : 
    5323                 :      26035 :       if (DECL_INITIAL (decl))
    5324                 :       7290 :         TREE_TYPE (DECL_INITIAL (decl)) = type;
    5325                 :            : 
    5326                 :      26035 :       relayout_decl (decl);
    5327                 :            :     }
    5328                 :            : 
    5329                 :            :   /* Look for braced array initializers for character arrays and
    5330                 :            :      recursively convert them into STRING_CSTs.  */
    5331                 :   92987300 :   if (tree init = DECL_INITIAL (decl))
    5332                 :   74644200 :     DECL_INITIAL (decl) = braced_lists_to_strings (type, init);
    5333                 :            : 
    5334                 :   92987300 :   if (VAR_P (decl))
    5335                 :            :     {
    5336                 :    4473590 :       if (init && TREE_CODE (init) == CONSTRUCTOR)
    5337                 :      19294 :         add_flexible_array_elts_to_size (decl, init);
    5338                 :            : 
    5339                 :    4473590 :       complete_flexible_array_elts (DECL_INITIAL (decl));
    5340                 :            : 
    5341                 :    4473590 :       if (is_global_var (decl))
    5342                 :            :         {
    5343                 :    1051380 :           type_context_kind context = (DECL_THREAD_LOCAL_P (decl)
    5344                 :    1051380 :                                        ? TCTX_THREAD_STORAGE
    5345                 :    1051380 :                                        : TCTX_STATIC_STORAGE);
    5346                 :    1051380 :           if (!verify_type_context (input_location, context, TREE_TYPE (decl)))
    5347                 :          0 :             TREE_TYPE (decl) = error_mark_node;
    5348                 :            :         }
    5349                 :            : 
    5350                 :    4493100 :       if (DECL_SIZE (decl) == NULL_TREE && TREE_TYPE (decl) != error_mark_node
    5351                 :    4493020 :           && COMPLETE_TYPE_P (TREE_TYPE (decl)))
    5352                 :        141 :         layout_decl (decl, 0);
    5353                 :            : 
    5354                 :    4473590 :       if (DECL_SIZE (decl) == NULL_TREE
    5355                 :            :           /* Don't give an error if we already gave one earlier.  */
    5356                 :      19373 :           && TREE_TYPE (decl) != error_mark_node
    5357                 :    4473950 :           && (TREE_STATIC (decl)
    5358                 :            :               /* A static variable with an incomplete type
    5359                 :            :                  is an error if it is initialized.
    5360                 :            :                  Also if it is not file scope.
    5361                 :            :                  Otherwise, let it through, but if it is not `extern'
    5362                 :            :                  then it may cause an error message later.  */
    5363                 :      19285 :               ? (DECL_INITIAL (decl) != NULL_TREE
    5364                 :        357 :                  || !DECL_FILE_SCOPE_P (decl))
    5365                 :            :               /* An automatic variable with an incomplete type
    5366                 :            :                  is an error.  */
    5367                 :      19285 :               : !DECL_EXTERNAL (decl)))
    5368                 :            :          {
    5369                 :         11 :            error ("storage size of %q+D isn%'t known", decl);
    5370                 :         11 :            TREE_TYPE (decl) = error_mark_node;
    5371                 :            :          }
    5372                 :            : 
    5373                 :    8847220 :       if ((RECORD_OR_UNION_TYPE_P (TREE_TYPE (decl))
    5374                 :    4349280 :           || TREE_CODE (TREE_TYPE (decl)) == ENUMERAL_TYPE)
    5375                 :     133688 :           && DECL_SIZE (decl) == NULL_TREE
    5376                 :    4473910 :           && TREE_STATIC (decl))
    5377                 :        150 :         incomplete_record_decls.safe_push (decl);
    5378                 :            : 
    5379                 :    4473590 :       if (is_global_var (decl)
    5380                 :    1051380 :           && DECL_SIZE (decl) != NULL_TREE
    5381                 :    5505630 :           && TREE_TYPE (decl) != error_mark_node)
    5382                 :            :         {
    5383                 :    1032040 :           if (TREE_CODE (DECL_SIZE (decl)) == INTEGER_CST)
    5384                 :    1032040 :             constant_expression_warning (DECL_SIZE (decl));
    5385                 :            :           else
    5386                 :            :             {
    5387                 :          3 :               error ("storage size of %q+D isn%'t constant", decl);
    5388                 :          3 :               TREE_TYPE (decl) = error_mark_node;
    5389                 :            :             }
    5390                 :            :         }
    5391                 :            : 
    5392                 :    4473590 :       if (TREE_USED (type))
    5393                 :            :         {
    5394                 :          2 :           TREE_USED (decl) = 1;
    5395                 :          2 :           DECL_READ_P (decl) = 1;
    5396                 :            :         }
    5397                 :            :     }
    5398                 :            : 
    5399                 :            :   /* If this is a function and an assembler name is specified, reset DECL_RTL
    5400                 :            :      so we can give it its new name.  Also, update builtin_decl if it
    5401                 :            :      was a normal built-in.  */
    5402                 :   92987300 :   if (TREE_CODE (decl) == FUNCTION_DECL && asmspec)
    5403                 :            :     {
    5404                 :     576135 :       if (DECL_BUILT_IN_CLASS (decl) == BUILT_IN_NORMAL)
    5405                 :      52864 :         set_builtin_user_assembler_name (decl, asmspec);
    5406                 :     576135 :       set_user_assembler_name (decl, asmspec);
    5407                 :            :     }
    5408                 :            : 
    5409                 :            :   /* If #pragma weak was used, mark the decl weak now.  */
    5410                 :   92987300 :   maybe_apply_pragma_weak (decl);
    5411                 :            : 
    5412                 :            :   /* Output the assembler code and/or RTL code for variables and functions,
    5413                 :            :      unless the type is an undefined structure or union.
    5414                 :            :      If not, it will get done when the type is completed.  */
    5415                 :            : 
    5416                 :   92987300 :   if (VAR_OR_FUNCTION_DECL_P (decl))
    5417                 :            :     {
    5418                 :            :       /* Determine the ELF visibility.  */
    5419                 :   14762300 :       if (TREE_PUBLIC (decl))
    5420                 :   11033900 :         c_determine_visibility (decl);
    5421                 :            : 
    5422                 :            :       /* This is a no-op in c-lang.c or something real in objc-act.c.  */
    5423                 :   14762300 :       if (c_dialect_objc ())
    5424                 :          0 :         objc_check_decl (decl);
    5425                 :            : 
    5426                 :   14762300 :       if (asmspec)
    5427                 :            :         {
    5428                 :            :           /* If this is not a static variable, issue a warning.
    5429                 :            :              It doesn't make any sense to give an ASMSPEC for an
    5430                 :            :              ordinary, non-register local variable.  Historically,
    5431                 :            :              GCC has accepted -- but ignored -- the ASMSPEC in
    5432                 :            :              this case.  */
    5433                 :     586825 :           if (!DECL_FILE_SCOPE_P (decl)
    5434                 :        609 :               && VAR_P (decl)
    5435                 :        609 :               && !C_DECL_REGISTER (decl)
    5436                 :     586224 :               && !TREE_STATIC (decl))
    5437                 :          1 :             warning (0, "ignoring %<asm%> specifier for non-static local "
    5438                 :            :                      "variable %q+D", decl);
    5439                 :            :           else
    5440                 :     586215 :             set_user_assembler_name (decl, asmspec);
    5441                 :            :         }
    5442                 :            : 
    5443                 :   14762300 :       if (DECL_FILE_SCOPE_P (decl))
    5444                 :            :         {
    5445                 :   11267700 :           if (DECL_INITIAL (decl) == NULL_TREE
    5446                 :   11267700 :               || DECL_INITIAL (decl) == error_mark_node)
    5447                 :            :             /* Don't output anything
    5448                 :            :                when a tentative file-scope definition is seen.
    5449                 :            :                But at end of compilation, do output code for them.  */
    5450                 :   11239000 :             DECL_DEFER_OUTPUT (decl) = 1;
    5451                 :   11267700 :           if (asmspec && VAR_P (decl) && C_DECL_REGISTER (decl))
    5452                 :         45 :             DECL_HARD_REGISTER (decl) = 1;
    5453                 :   11267700 :           rest_of_decl_compilation (decl, true, 0);
    5454                 :            :         }
    5455                 :            :       else
    5456                 :            :         {
    5457                 :            :           /* In conjunction with an ASMSPEC, the `register'
    5458                 :            :              keyword indicates that we should place the variable
    5459                 :            :              in a particular register.  */
    5460                 :    3494670 :           if (asmspec && C_DECL_REGISTER (decl))
    5461                 :            :             {
    5462                 :        601 :               DECL_HARD_REGISTER (decl) = 1;
    5463                 :            :               /* This cannot be done for a structure with volatile
    5464                 :            :                  fields, on which DECL_REGISTER will have been
    5465                 :            :                  reset.  */
    5466                 :        601 :               if (!DECL_REGISTER (decl))
    5467                 :          1 :                 error ("cannot put object with volatile field into register");
    5468                 :            :             }
    5469                 :            : 
    5470                 :    3494670 :           if (TREE_CODE (decl) != FUNCTION_DECL)
    5471                 :            :             {
    5472                 :            :               /* If we're building a variable sized type, and we might be
    5473                 :            :                  reachable other than via the top of the current binding
    5474                 :            :                  level, then create a new BIND_EXPR so that we deallocate
    5475                 :            :                  the object at the right time.  */
    5476                 :            :               /* Note that DECL_SIZE can be null due to errors.  */
    5477                 :    3494610 :               if (DECL_SIZE (decl)
    5478                 :    3494580 :                   && !TREE_CONSTANT (DECL_SIZE (decl))
    5479                 :    3501500 :                   && STATEMENT_LIST_HAS_LABEL (cur_stmt_list))
    5480                 :            :                 {
    5481                 :       1333 :                   tree bind;
    5482                 :       1333 :                   bind = build3 (BIND_EXPR, void_type_node, NULL, NULL, NULL);
    5483                 :       1333 :                   TREE_SIDE_EFFECTS (bind) = 1;
    5484                 :       1333 :                   add_stmt (bind);
    5485                 :       1333 :                   BIND_EXPR_BODY (bind) = push_stmt_list ();
    5486                 :            :                 }
    5487                 :    3494610 :               add_stmt (build_stmt (DECL_SOURCE_LOCATION (decl),
    5488                 :            :                                     DECL_EXPR, decl));
    5489                 :            :             }
    5490                 :            :         }
    5491                 :            : 
    5492                 :            : 
    5493                 :   14762300 :       if (!DECL_FILE_SCOPE_P (decl))
    5494                 :            :         {
    5495                 :            :           /* Recompute the RTL of a local array now
    5496                 :            :              if it used to be an incomplete type.  */
    5497                 :    3494670 :           if (was_incomplete && !is_global_var (decl))
    5498                 :            :             {
    5499                 :            :               /* If we used it already as memory, it must stay in memory.  */
    5500                 :       2416 :               TREE_ADDRESSABLE (decl) = TREE_USED (decl);
    5501                 :            :               /* If it's still incomplete now, no init will save it.  */
    5502                 :       2416 :               if (DECL_SIZE (decl) == NULL_TREE)
    5503                 :         86 :                 DECL_INITIAL (decl) = NULL_TREE;
    5504                 :            :             }
    5505                 :            :         }
    5506                 :            :     }
    5507                 :            : 
    5508                 :   92987300 :   if (TREE_CODE (decl) == TYPE_DECL)
    5509                 :            :     {
    5510                 :    2997190 :       if (!DECL_FILE_SCOPE_P (decl)
    5511                 :    2997190 :           && variably_modified_type_p (TREE_TYPE (decl), NULL_TREE))
    5512                 :      10855 :         add_stmt (build_stmt (DECL_SOURCE_LOCATION (decl), DECL_EXPR, decl));
    5513                 :            : 
    5514                 :    2911850 :       rest_of_decl_compilation (decl, DECL_FILE_SCOPE_P (decl), 0);
    5515                 :            :     }
    5516                 :            : 
    5517                 :            :   /* Install a cleanup (aka destructor) if one was given.  */
    5518                 :   92987300 :   if (VAR_P (decl) && !TREE_STATIC (decl))
    5519                 :            :     {
    5520                 :    3582080 :       tree attr = lookup_attribute ("cleanup", DECL_ATTRIBUTES (decl));
    5521                 :    3582080 :       if (attr)
    5522                 :            :         {
    5523                 :         65 :           tree cleanup_id = TREE_VALUE (TREE_VALUE (attr));
    5524                 :         65 :           tree cleanup_decl = lookup_name (cleanup_id);
    5525                 :         65 :           tree cleanup;
    5526                 :         65 :           vec<tree, va_gc> *v;
    5527                 :            : 
    5528                 :            :           /* Build "cleanup(&decl)" for the destructor.  */
    5529                 :         65 :           cleanup = build_unary_op (input_location, ADDR_EXPR, decl, false);
    5530                 :         65 :           vec_alloc (v, 1);
    5531                 :         65 :           v->quick_push (cleanup);
    5532                 :         65 :           cleanup = c_build_function_call_vec (DECL_SOURCE_LOCATION (decl),
    5533                 :            :                                                vNULL, cleanup_decl, v, NULL);
    5534                 :         65 :           vec_free (v);
    5535                 :            : 
    5536                 :            :           /* Don't warn about decl unused; the cleanup uses it.  */
    5537                 :         65 :           TREE_USED (decl) = 1;
    5538                 :         65 :           TREE_USED (cleanup_decl) = 1;
    5539                 :         65 :           DECL_READ_P (decl) = 1;
    5540                 :            : 
    5541                 :         65 :           push_cleanup (decl, cleanup, false);
    5542                 :            :         }
    5543                 :            :     }
    5544                 :            : 
    5545                 :   92987300 :   if (warn_cxx_compat
    5546                 :      15361 :       && VAR_P (decl)
    5547                 :       5356 :       && !DECL_EXTERNAL (decl)
    5548                 :   92992400 :       && DECL_INITIAL (decl) == NULL_TREE)
    5549                 :            :     {
    5550                 :       1613 :       type = strip_array_types (type);
    5551                 :       1613 :       if (TREE_READONLY (decl))
    5552                 :          6 :         warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wc___compat,
    5553                 :            :                     "uninitialized %<const %D%> is invalid in C++", decl);
    5554                 :       1607 :       else if (RECORD_OR_UNION_TYPE_P (type)
    5555                 :       1607 :                && C_TYPE_FIELDS_READONLY (type))
    5556                 :          5 :         diagnose_uninitialized_cst_member (decl, type);
    5557                 :            :     }
    5558                 :            : 
    5559                 :   92987300 :   if (flag_openmp
    5560                 :     181811 :       && VAR_P (decl)
    5561                 :   93002700 :       && lookup_attribute ("omp declare target implicit",
    5562                 :      15337 :                            DECL_ATTRIBUTES (decl)))
    5563                 :            :     {
    5564                 :          8 :       DECL_ATTRIBUTES (decl)
    5565                 :          8 :         = remove_attribute ("omp declare target implicit",
    5566                 :          4 :                             DECL_ATTRIBUTES (decl));
    5567                 :          4 :       if (!lang_hooks.types.omp_mappable_type (TREE_TYPE (decl)))
    5568                 :          3 :         error ("%q+D in declare target directive does not have mappable type",
    5569                 :            :                decl);
    5570                 :          2 :       else if (!lookup_attribute ("omp declare target",
    5571                 :          1 :                                   DECL_ATTRIBUTES (decl))
    5572                 :          2 :                && !lookup_attribute ("omp declare target link",
    5573                 :          1 :                                      DECL_ATTRIBUTES (decl)))
    5574                 :          1 :         DECL_ATTRIBUTES (decl)
    5575                 :          1 :           = tree_cons (get_identifier ("omp declare target"),
    5576                 :          1 :                        NULL_TREE, DECL_ATTRIBUTES (decl));
    5577                 :            :     }
    5578                 :            : 
    5579                 :   92987300 :   invoke_plugin_callbacks (PLUGIN_FINISH_DECL, decl);
    5580                 :   92987300 : }
    5581                 :            : 
    5582                 :            : /* Given a parsed parameter declaration, decode it into a PARM_DECL.
    5583                 :            :    EXPR is NULL or a pointer to an expression that needs to be
    5584                 :            :    evaluated for the side effects of array size expressions in the
    5585                 :            :    parameters.  */
    5586                 :            : 
    5587                 :            : tree
    5588                 :          0 : grokparm (const struct c_parm *parm, tree *expr)
    5589                 :            : {
    5590                 :          0 :   tree attrs = parm->attrs;
    5591                 :          0 :   tree decl = grokdeclarator (parm->declarator, parm->specs, PARM, false,
    5592                 :          0 :                               NULL, &attrs, expr, NULL, DEPRECATED_NORMAL);
    5593                 :            : 
    5594                 :          0 :   decl_attributes (&decl, attrs, 0);
    5595                 :            : 
    5596                 :          0 :   return decl;
    5597                 :            : }
    5598                 :            : 
    5599                 :            : /* Given a parsed parameter declaration, decode it into a PARM_DECL
    5600                 :            :    and push that on the current scope.  EXPR is a pointer to an
    5601                 :            :    expression that needs to be evaluated for the side effects of array
    5602                 :            :    size expressions in the parameters.  */
    5603                 :            : 
    5604                 :            : void
    5605                 :   72312300 : push_parm_decl (const struct c_parm *parm, tree *expr)
    5606                 :            : {
    5607                 :   72312300 :   tree attrs = parm->attrs;
    5608                 :   72312300 :   tree decl;
    5609                 :            : 
    5610                 :   72312300 :   decl = grokdeclarator (parm->declarator, parm->specs, PARM, false, NULL,
    5611                 :            :                          &attrs, expr, NULL, DEPRECATED_NORMAL);
    5612                 :   72312300 :   if (decl && DECL_P (decl))
    5613                 :   72312300 :     DECL_SOURCE_LOCATION (decl) = parm->loc;
    5614                 :   72312300 :   decl_attributes (&decl, attrs, 0);
    5615                 :            : 
    5616                 :   72312300 :   decl = pushdecl (decl);
    5617                 :            : 
    5618                 :   72312300 :   finish_decl (decl, input_location, NULL_TREE, NULL_TREE, NULL_TREE);
    5619                 :   72312300 : }
    5620                 :            : 
    5621                 :            : /* Mark all the parameter declarations to date as forward decls.
    5622                 :            :    Also diagnose use of this extension.  */
    5623                 :            : 
    5624                 :            : void
    5625                 :         36 : mark_forward_parm_decls (void)
    5626                 :            : {
    5627                 :         36 :   struct c_binding *b;
    5628                 :            : 
    5629                 :         36 :   if (pedantic && !current_scope->warned_forward_parm_decls)
    5630                 :            :     {
    5631                 :          4 :       pedwarn (input_location, OPT_Wpedantic,
    5632                 :            :                "ISO C forbids forward parameter declarations");
    5633                 :          4 :       current_scope->warned_forward_parm_decls = true;
    5634                 :            :     }
    5635                 :            : 
    5636                 :         81 :   for (b = current_scope->bindings; b; b = b->prev)
    5637                 :         45 :     if (TREE_CODE (b->decl) == PARM_DECL)
    5638                 :         45 :       TREE_ASM_WRITTEN (b->decl) = 1;
    5639                 :         36 : }
    5640                 :            : 
    5641                 :            : /* Build a COMPOUND_LITERAL_EXPR.  TYPE is the type given in the compound
    5642                 :            :    literal, which may be an incomplete array type completed by the
    5643                 :            :    initializer; INIT is a CONSTRUCTOR at LOC that initializes the compound
    5644                 :            :    literal.  NON_CONST is true if the initializers contain something
    5645                 :            :    that cannot occur in a constant expression.  If ALIGNAS_ALIGN is nonzero,
    5646                 :            :    it is the (valid) alignment for this compound literal, as specified
    5647                 :            :    with _Alignas.  */
    5648                 :            : 
    5649                 :            : tree
    5650                 :     482624 : build_compound_literal (location_t loc, tree type, tree init, bool non_const,
    5651                 :            :                         unsigned int alignas_align)
    5652                 :            : {
    5653                 :            :   /* We do not use start_decl here because we have a type, not a declarator;
    5654                 :            :      and do not use finish_decl because the decl should be stored inside
    5655                 :            :      the COMPOUND_LITERAL_EXPR rather than added elsewhere as a DECL_EXPR.  */
    5656                 :     482624 :   tree decl;
    5657                 :     482624 :   tree complit;
    5658                 :     482624 :   tree stmt;
    5659                 :            : 
    5660                 :     482624 :   if (type == error_mark_node
    5661                 :     482612 :       || init == error_mark_node)
    5662                 :            :     return error_mark_node;
    5663                 :            : 
    5664                 :     482580 :   decl = build_decl (loc, VAR_DECL, NULL_TREE, type);
    5665                 :     482580 :   DECL_EXTERNAL (decl) = 0;
    5666                 :     482580 :   TREE_PUBLIC (decl) = 0;
    5667                 :     482580 :   TREE_STATIC (decl) = (current_scope == file_scope);
    5668                 :     482580 :   DECL_CONTEXT (decl) = current_function_decl;
    5669                 :     482580 :   TREE_USED (decl) = 1;
    5670                 :     482580 :   DECL_READ_P (decl) = 1;
    5671                 :     482580 :   DECL_ARTIFICIAL (decl) = 1;
    5672                 :     482580 :   DECL_IGNORED_P (decl) = 1;
    5673                 :     482580 :   C_DECL_COMPOUND_LITERAL_P (decl) = 1;
    5674                 :     482580 :   TREE_TYPE (decl) = type;
    5675                 :     482580 :   c_apply_type_quals_to_decl (TYPE_QUALS (strip_array_types (type)), decl);
    5676                 :     482580 :   if (alignas_align)
    5677                 :            :     {
    5678                 :          3 :       SET_DECL_ALIGN (decl, alignas_align * BITS_PER_UNIT);
    5679                 :          3 :       DECL_USER_ALIGN (decl) = 1;
    5680                 :            :     }
    5681                 :     482580 :   store_init_value (loc, decl, init, NULL_TREE);
    5682                 :            : 
    5683                 :     482875 :   if (TREE_CODE (type) == ARRAY_TYPE && !COMPLETE_TYPE_P (type))
    5684                 :            :     {
    5685                 :        376 :       int failure = complete_array_type (&TREE_TYPE (decl),
    5686                 :        188 :                                          DECL_INITIAL (decl), true);
    5687                 :            :       /* If complete_array_type returns 3, it means that the
    5688                 :            :          initial value of the compound literal is empty.  Allow it.  */
    5689                 :        188 :       gcc_assert (failure == 0 || failure == 3);
    5690                 :            : 
    5691                 :        188 :       type = TREE_TYPE (decl);
    5692                 :        188 :       TREE_TYPE (DECL_INITIAL (decl)) = type;
    5693                 :            :     }
    5694                 :            : 
    5695                 :     965160 :   if (type == error_mark_node || !COMPLETE_TYPE_P (type))
    5696                 :            :     {
    5697                 :         19 :       c_incomplete_type_error (loc, NULL_TREE, type);
    5698                 :         19 :       return error_mark_node;
    5699                 :            :     }
    5700                 :            : 
    5701                 :     482561 :   if (TREE_STATIC (decl)
    5702                 :     482561 :       && !verify_type_context (loc, TCTX_STATIC_STORAGE, type))
    5703                 :          0 :     return error_mark_node;
    5704                 :            : 
    5705                 :     482561 :   stmt = build_stmt (DECL_SOURCE_LOCATION (decl), DECL_EXPR, decl);
    5706                 :     482561 :   complit = build1 (COMPOUND_LITERAL_EXPR, type, stmt);
    5707                 :     482561 :   TREE_SIDE_EFFECTS (complit) = 1;
    5708                 :            : 
    5709                 :     482561 :   layout_decl (decl, 0);
    5710                 :            : 
    5711                 :     482561 :   if (TREE_STATIC (decl))
    5712                 :            :     {
    5713                 :            :       /* This decl needs a name for the assembler output.  */
    5714                 :        212 :       set_compound_literal_name (decl);
    5715                 :        212 :       DECL_DEFER_OUTPUT (decl) = 1;
    5716                 :        212 :       DECL_COMDAT (decl) = 1;
    5717                 :        212 :       pushdecl (decl);
    5718                 :        212 :       rest_of_decl_compilation (decl, 1, 0);
    5719                 :            :     }
    5720                 :     482349 :   else if (current_function_decl && !current_scope->parm_flag)
    5721                 :     482344 :     pushdecl (decl);
    5722                 :            : 
    5723                 :     482561 :   if (non_const)
    5724                 :            :     {
    5725                 :        148 :       complit = build2 (C_MAYBE_CONST_EXPR, type, NULL, complit);
    5726                 :        148 :       C_MAYBE_CONST_EXPR_NON_CONST (complit) = 1;
    5727                 :            :     }
    5728                 :            : 
    5729                 :            :   return complit;
    5730                 :            : }
    5731                 :            : 
    5732                 :            : /* Check the type of a compound literal.  Here we just check that it
    5733                 :            :    is valid for C++.  */
    5734                 :            : 
    5735                 :            : void
    5736                 :     482624 : check_compound_literal_type (location_t loc, struct c_type_name *type_name)
    5737                 :            : {
    5738                 :     482624 :   if (warn_cxx_compat
    5739                 :        156 :       && (type_name->specs->typespec_kind == ctsk_tagdef
    5740                 :        156 :           || type_name->specs->typespec_kind == ctsk_tagfirstref
    5741                 :        154 :           || type_name->specs->typespec_kind == ctsk_tagfirstref_attrs))
    5742                 :          2 :     warning_at (loc, OPT_Wc___compat,
    5743                 :            :                 "defining a type in a compound literal is invalid in C++");
    5744                 :     482624 : }
    5745                 :            : 
    5746                 :            : /* Performs sanity checks on the TYPE and WIDTH of the bit-field NAME,
    5747                 :            :    replacing with appropriate values if they are invalid.  */
    5748                 :            : 
    5749                 :            : static void
    5750                 :      36298 : check_bitfield_type_and_width (location_t loc, tree *type, tree *width,
    5751                 :            :                                tree orig_name)
    5752                 :            : {
    5753                 :      36298 :   tree type_mv;
    5754                 :      36298 :   unsigned int max_width;
    5755                 :      36298 :   unsigned HOST_WIDE_INT w;
    5756                 :      36298 :   const char *name = (orig_name
    5757                 :      64351 :                       ? identifier_to_locale (IDENTIFIER_POINTER (orig_name))
    5758                 :       8245 :                       : _("<anonymous>"));
    5759                 :            : 
    5760                 :            :   /* Detect and ignore out of range field width and process valid
    5761                 :            :      field widths.  */
    5762                 :      36298 :   if (!INTEGRAL_TYPE_P (TREE_TYPE (*width)))
    5763                 :            :     {
    5764                 :          3 :       error_at (loc, "bit-field %qs width not an integer constant", name);
    5765                 :          3 :       *width = integer_one_node;
    5766                 :            :     }
    5767                 :            :   else
    5768                 :            :     {
    5769                 :      36295 :       if (TREE_CODE (*width) != INTEGER_CST)
    5770                 :            :         {
    5771                 :         12 :           *width = c_fully_fold (*width, false, NULL);
    5772                 :         12 :           if (TREE_CODE (*width) == INTEGER_CST)
    5773                 :          6 :             pedwarn (loc, OPT_Wpedantic,
    5774                 :            :                      "bit-field %qs width not an integer constant expression",
    5775                 :            :                      name);
    5776                 :            :         }
    5777                 :      36295 :       if (TREE_CODE (*width) != INTEGER_CST)
    5778                 :            :         {
    5779                 :          6 :           error_at (loc, "bit-field %qs width not an integer constant", name);
    5780                 :          6 :           *width = integer_one_node;
    5781                 :            :         }
    5782                 :      36295 :       constant_expression_warning (*width);
    5783                 :      36295 :       if (tree_int_cst_sgn (*width) < 0)
    5784                 :            :         {
    5785                 :          2 :           error_at (loc, "negative width in bit-field %qs", name);
    5786                 :          2 :           *width = integer_one_node;
    5787                 :            :         }
    5788                 :      36293 :       else if (integer_zerop (*width) && orig_name)
    5789                 :            :         {
    5790                 :          4 :           error_at (loc, "zero width for bit-field %qs", name);
    5791                 :          4 :           *width = integer_one_node;
    5792                 :            :         }
    5793                 :            :     }
    5794                 :            : 
    5795                 :            :   /* Detect invalid bit-field type.  */
    5796                 :      36298 :   if (TREE_CODE (*type) != INTEGER_TYPE
    5797                 :            :       && TREE_CODE (*type) != BOOLEAN_TYPE
    5798                 :      36298 :       && TREE_CODE (*type) != ENUMERAL_TYPE)
    5799                 :            :     {
    5800                 :          6 :       error_at (loc, "bit-field %qs has invalid type", name);
    5801                 :          6 :       *type = unsigned_type_node;
    5802                 :            :     }
    5803                 :            : 
    5804                 :      36298 :   if (TYPE_WARN_IF_NOT_ALIGN (*type))
    5805                 :            :     {
    5806                 :          1 :       error_at (loc, "cannot declare bit-field %qs with %<warn_if_not_aligned%> type",
    5807                 :            :                 name);
    5808                 :          1 :       *type = unsigned_type_node;
    5809                 :            :     }
    5810                 :            : 
    5811                 :      36298 :   type_mv = TYPE_MAIN_VARIANT (*type);
    5812                 :      36298 :   if (!in_system_header_at (input_location)
    5813                 :      26797 :       && type_mv != integer_type_node
    5814                 :      24684 :       && type_mv != unsigned_type_node
    5815                 :      47880 :       && type_mv != boolean_type_node)
    5816                 :      11020 :     pedwarn_c90 (loc, OPT_Wpedantic,
    5817                 :            :                  "type of bit-field %qs is a GCC extension", name);
    5818                 :            : 
    5819                 :      36298 :   max_width = TYPE_PRECISION (*type);
    5820                 :            : 
    5821                 :      36298 :   if (compare_tree_int (*width, max_width) > 0)
    5822                 :            :     {
    5823                 :          4 :       error_at (loc, "width of %qs exceeds its type", name);
    5824                 :          4 :       w = max_width;
    5825                 :          4 :       *width = build_int_cst (integer_type_node, w);
    5826                 :            :     }
    5827                 :            :   else
    5828                 :      36294 :     w = tree_to_uhwi (*width);
    5829                 :            : 
    5830                 :      36298 :   if (TREE_CODE (*type) == ENUMERAL_TYPE)
    5831                 :            :     {
    5832                 :       4120 :       struct lang_type *lt = TYPE_LANG_SPECIFIC (*type);
    5833                 :       4120 :       if (!lt
    5834                 :       4112 :           || w < tree_int_cst_min_precision (lt->enum_min, TYPE_SIGN (*type))
    5835                 :       8228 :           || w < tree_int_cst_min_precision (lt->enum_max, TYPE_SIGN (*type)))
    5836                 :         13 :         warning_at (loc, 0, "%qs is narrower than values of its type", name);
    5837                 :            :     }
    5838                 :      36298 : }
    5839                 :            : 
    5840                 :            : 
    5841                 :            : 
    5842                 :            : /* Print warning about variable length array if necessary.  */
    5843                 :            : 
    5844                 :            : static void
    5845                 :      13233 : warn_variable_length_array (tree name, tree size)
    5846                 :            : {
    5847                 :      13233 :   if (TREE_CONSTANT (size))
    5848                 :            :     {
    5849                 :        185 :       if (name)
    5850                 :        181 :         pedwarn_c90 (input_location, OPT_Wvla,
    5851                 :            :                      "ISO C90 forbids array %qE whose size "
    5852                 :            :                      "cannot be evaluated", name);
    5853                 :            :       else
    5854                 :          4 :         pedwarn_c90 (input_location, OPT_Wvla, "ISO C90 forbids array "
    5855                 :            :                      "whose size cannot be evaluated");
    5856                 :            :     }
    5857                 :            :   else
    5858                 :            :     {
    5859                 :      13048 :       if (name)
    5860                 :      12794 :         pedwarn_c90 (input_location, OPT_Wvla,
    5861                 :            :                      "ISO C90 forbids variable length array %qE", name);
    5862                 :            :       else
    5863                 :        254 :         pedwarn_c90 (input_location, OPT_Wvla, "ISO C90 forbids variable "
    5864                 :            :                      "length array");
    5865                 :            :     }
    5866                 :      13233 : }
    5867                 :            : 
    5868                 :            : /* Print warning about defaulting to int if necessary.  */
    5869                 :            : 
    5870                 :            : static void
    5871                 :      13727 : warn_defaults_to (location_t location, int opt, const char *gmsgid, ...)
    5872                 :            : {
    5873                 :      13727 :   diagnostic_info diagnostic;
    5874                 :      13727 :   va_list ap;
    5875                 :      13727 :   rich_location richloc (line_table, location);
    5876                 :            : 
    5877                 :      13727 :   va_start (ap, gmsgid);
    5878                 :      13727 :   diagnostic_set_info (&diagnostic, gmsgid, &ap, &richloc,
    5879                 :      13727 :                        flag_isoc99 ? DK_PEDWARN : DK_WARNING);
    5880                 :      13727 :   diagnostic.option_index = opt;
    5881                 :      13727 :   diagnostic_report_diagnostic (global_dc, &diagnostic);
    5882                 :      13727 :   va_end (ap);
    5883                 :      13727 : }
    5884                 :            : 
    5885                 :            : /* Returns the smallest location != UNKNOWN_LOCATION in LOCATIONS,
    5886                 :            :    considering only those c_declspec_words found in LIST, which
    5887                 :            :    must be terminated by cdw_number_of_elements.  */
    5888                 :            : 
    5889                 :            : static location_t
    5890                 :         91 : smallest_type_quals_location (const location_t *locations,
    5891                 :            :                               const c_declspec_word *list)
    5892                 :            : {
    5893                 :          0 :   location_t loc = UNKNOWN_LOCATION;
    5894                 :        546 :   while (*list != cdw_number_of_elements)
    5895                 :            :     {
    5896                 :        455 :       location_t newloc = locations[*list];
    5897                 :        455 :       if (loc == UNKNOWN_LOCATION
    5898                 :        204 :           || (newloc != UNKNOWN_LOCATION && newloc < loc))
    5899                 :        251 :         loc = newloc;
    5900                 :        455 :       list++;
    5901                 :            :     }
    5902                 :            : 
    5903                 :         91 :   return loc;
    5904                 :            : }
    5905                 :            : 
    5906                 :            : /* Given declspecs and a declarator,
    5907                 :            :    determine the name and type of the object declared
    5908                 :            :    and construct a ..._DECL node for it.
    5909                 :            :    (In one case we can return a ..._TYPE node instead.
    5910                 :            :     For invalid input we sometimes return NULL_TREE.)
    5911                 :            : 
    5912                 :            :    DECLSPECS is a c_declspecs structure for the declaration specifiers.
    5913                 :            : 
    5914                 :            :    DECL_CONTEXT says which syntactic context this declaration is in:
    5915                 :            :      NORMAL for most contexts.  Make a VAR_DECL or FUNCTION_DECL or TYPE_DECL.
    5916                 :            :      FUNCDEF for a function definition.  Like NORMAL but a few different
    5917                 :            :       error messages in each case.  Return value may be zero meaning
    5918                 :            :       this definition is too screwy to try to parse.
    5919                 :            :      PARM for a parameter declaration (either within a function prototype
    5920                 :            :       or before a function body).  Make a PARM_DECL, or return void_type_node.
    5921                 :            :      TYPENAME if for a typename (in a cast or sizeof).
    5922                 :            :       Don't make a DECL node; just return the ..._TYPE node.
    5923                 :            :      FIELD for a struct or union field; make a FIELD_DECL.
    5924                 :            :    INITIALIZED is true if the decl has an initializer.
    5925                 :            :    WIDTH is non-NULL for bit-fields, and is a pointer to an INTEGER_CST node
    5926                 :            :    representing the width of the bit-field.
    5927                 :            :    DECL_ATTRS points to the list of attributes that should be added to this
    5928                 :            :      decl.  Any nested attributes that belong on the decl itself will be
    5929                 :            :      added to this list.
    5930                 :            :    If EXPR is not NULL, any expressions that need to be evaluated as
    5931                 :            :      part of evaluating variably modified types will be stored in *EXPR.
    5932                 :            :    If EXPR_CONST_OPERANDS is not NULL, *EXPR_CONST_OPERANDS will be
    5933                 :            :      set to indicate whether operands in *EXPR can be used in constant
    5934                 :            :      expressions.
    5935                 :            :    DEPRECATED_STATE is a deprecated_states value indicating whether
    5936                 :            :    deprecation warnings should be suppressed.
    5937                 :            : 
    5938                 :            :    In the TYPENAME case, DECLARATOR is really an absolute declarator.
    5939                 :            :    It may also be so in the PARM case, for a prototype where the
    5940                 :            :    argument type is specified but not the name.
    5941                 :            : 
    5942                 :            :    This function is where the complicated C meanings of `static'
    5943                 :            :    and `extern' are interpreted.  */
    5944                 :            : 
    5945                 :            : static tree
    5946                 :  185154000 : grokdeclarator (const struct c_declarator *declarator,
    5947                 :            :                 struct c_declspecs *declspecs,
    5948                 :            :                 enum decl_context decl_context, bool initialized, tree *width,
    5949                 :            :                 tree *decl_attrs, tree *expr, bool *expr_const_operands,
    5950                 :            :                 enum deprecated_states deprecated_state)
    5951                 :            : {
    5952                 :  185154000 :   tree type = declspecs->type;
    5953                 :  185154000 :   bool threadp = declspecs->thread_p;
    5954                 :  185154000 :   enum c_storage_class storage_class = declspecs->storage_class;
    5955                 :  185154000 :   int constp;
    5956                 :  185154000 :   int restrictp;
    5957                 :  185154000 :   int volatilep;
    5958                 :  185154000 :   int atomicp;
    5959                 :  185154000 :   int type_quals = TYPE_UNQUALIFIED;
    5960                 :  185154000 :   tree name = NULL_TREE;
    5961                 :  185154000 :   bool funcdef_flag = false;
    5962                 :  185154000 :   bool funcdef_syntax = false;
    5963                 :  185154000 :   bool size_varies = false;
    5964                 :  185154000 :   tree decl_attr = declspecs->decl_attr;
    5965                 :  185154000 :   int array_ptr_quals = TYPE_UNQUALIFIED;
    5966                 :  185154000 :   tree array_ptr_attrs = NULL_TREE;
    5967                 :  185154000 :   bool array_parm_static = false;
    5968                 :  185154000 :   bool array_parm_vla_unspec_p = false;
    5969                 :  185154000 :   tree returned_attrs = NULL_TREE;
    5970                 :  185154000 :   tree decl_id_attrs = NULL_TREE;
    5971                 :  185154000 :   bool bitfield = width != NULL;
    5972                 :  185154000 :   tree element_type;
    5973                 :  185154000 :   tree orig_qual_type = NULL;
    5974                 :  185154000 :   size_t orig_qual_indirect = 0;
    5975                 :  185154000 :   struct c_arg_info *arg_info = 0;
    5976                 :  185154000 :   addr_space_t as1, as2, address_space;
    5977                 :  185154000 :   location_t loc = UNKNOWN_LOCATION;
    5978                 :  185154000 :   tree expr_dummy;
    5979                 :  185154000 :   bool expr_const_operands_dummy;
    5980                 :  185154000 :   enum c_declarator_kind first_non_attr_kind;
    5981                 :  185154000 :   unsigned int alignas_align = 0;
    5982                 :            : 
    5983                 :  185154000 :   if (TREE_CODE (type) == ERROR_MARK)
    5984                 :         13 :     return error_mark_node;
    5985                 :  185154000 :   if (expr == NULL)
    5986                 :            :     {
    5987                 :   23337300 :       expr = &expr_dummy;
    5988                 :   23337300 :       expr_dummy = NULL_TREE;
    5989                 :            :     }
    5990                 :  185154000 :   if (expr_const_operands == NULL)
    5991                 :  113359000 :     expr_const_operands = &expr_const_operands_dummy;
    5992                 :            : 
    5993                 :  185154000 :   if (declspecs->expr)
    5994                 :            :     {
    5995                 :        270 :       if (*expr)
    5996                 :          0 :         *expr = build2 (COMPOUND_EXPR, TREE_TYPE (declspecs->expr), *expr,
    5997                 :            :                         declspecs->expr);
    5998                 :            :       else
    5999                 :        270 :         *expr = declspecs->expr;
    6000                 :            :     }
    6001                 :  185154000 :   *expr_const_operands = declspecs->expr_const_operands;
    6002                 :            : 
    6003                 :  185154000 :   if (decl_context == FUNCDEF)
    6004                 :   20340300 :     funcdef_flag = true, decl_context = NORMAL;
    6005                 :            : 
    6006                 :            :   /* Look inside a declarator for the name being declared
    6007                 :            :      and get it as an IDENTIFIER_NODE, for an error message.  */
    6008                 :  185154000 :   {
    6009                 :  185154000 :     const struct c_declarator *decl = declarator;
    6010                 :            : 
    6011                 :  185154000 :     first_non_attr_kind = cdk_attrs;
    6012                 :  413372000 :     while (decl)
    6013                 :  228218000 :       switch (decl->kind)
    6014                 :            :         {
    6015                 :     755895 :         case cdk_array:
    6016                 :     755895 :           loc = decl->id_loc;
    6017                 :            :           /* FALL THRU.  */
    6018                 :            : 
    6019                 :   43061600 :         case cdk_function:
    6020                 :   43061600 :         case cdk_pointer:
    6021                 :   43061600 :           funcdef_syntax = (decl->kind == cdk_function);
    6022                 :   43061600 :           if (first_non_attr_kind == cdk_attrs)
    6023                 :   41668100 :             first_non_attr_kind = decl->kind;
    6024                 :   43061600 :           decl = decl->declarator;
    6025                 :   43061600 :           break;
    6026                 :            : 
    6027                 :       1541 :         case cdk_attrs:
    6028                 :       1541 :           decl = decl->declarator;
    6029                 :       1541 :           break;
    6030                 :            : 
    6031                 :  185154000 :         case cdk_id:
    6032                 :  185154000 :           loc = decl->id_loc;
    6033                 :  185154000 :           if (decl->u.id.id)
    6034                 :  109803000 :             name = decl->u.id.id;
    6035                 :  185154000 :           decl_id_attrs = decl->u.id.attrs;
    6036                 :  185154000 :           if (first_non_attr_kind == cdk_attrs)
    6037                 :  143486000 :             first_non_attr_kind = decl->kind;
    6038                 :            :           decl = 0;
    6039                 :            :           break;
    6040                 :            : 
    6041                 :          0 :         default:
    6042                 :          0 :           gcc_unreachable ();
    6043                 :            :         }
    6044                 :  185154000 :     if (name == NULL_TREE)
    6045                 :            :       {
    6046                 :   75351600 :         gcc_assert (decl_context == PARM
    6047                 :            :                     || decl_context == TYPENAME
    6048                 :            :                     || (decl_context == FIELD
    6049                 :            :                         && declarator->kind == cdk_id));
    6050                 :   75351600 :         gcc_assert (!initialized);
    6051                 :            :       }
    6052                 :            :   }
    6053                 :            : 
    6054                 :            :   /* A function definition's declarator must have the form of
    6055                 :            :      a function declarator.  */
    6056                 :            : 
    6057                 :  185154000 :   if (funcdef_flag && !funcdef_syntax)
    6058                 :            :     return NULL_TREE;
    6059                 :            : 
    6060                 :            :   /* If this looks like a function definition, make it one,
    6061                 :            :      even if it occurs where parms are expected.
    6062                 :            :      Then store_parm_decls will reject it and not use it as a parm.  */
    6063                 :  185154000 :   if (decl_context == NORMAL && !funcdef_flag && current_scope->parm_flag)
    6064                 :      22567 :     decl_context = PARM;
    6065                 :            : 
    6066                 :  185154000 :   if (declspecs->deprecated_p && deprecated_state != DEPRECATED_SUPPRESS)
    6067                 :         38 :     warn_deprecated_use (declspecs->type, declspecs->decl_attr);
    6068                 :            : 
    6069                 :  185154000 :   if ((decl_context == NORMAL || decl_context == FIELD)
    6070                 :   40985500 :       && current_scope == file_scope
    6071                 :  222522000 :       && variably_modified_type_p (type, NULL_TREE))
    6072                 :            :     {
    6073                 :          3 :       if (name)
    6074                 :          3 :         error_at (loc, "variably modified %qE at file scope", name);
    6075                 :            :       else
    6076                 :          0 :         error_at (loc, "variably modified field at file scope");
    6077                 :          3 :       type = integer_type_node;
    6078                 :            :     }
    6079                 :            : 
    6080                 :  185154000 :   size_varies = C_TYPE_VARIABLE_SIZE (type) != 0;
    6081                 :            : 
    6082                 :            :   /* Diagnose defaulting to "int".  */
    6083                 :            : 
    6084                 :  185154000 :   if (declspecs->default_int_p && !in_system_header_at (input_location))
    6085                 :            :     {
    6086                 :            :       /* Issue a warning if this is an ISO C 99 program or if
    6087                 :            :          -Wreturn-type and this is a function, or if -Wimplicit;
    6088                 :            :          prefer the former warning since it is more explicit.  */
    6089                 :      13727 :       if ((warn_implicit_int || warn_return_type > 0 || flag_isoc99)
    6090                 :      13667 :           && funcdef_flag)
    6091                 :      13055 :         warn_about_return_type = 1;
    6092                 :            :       else
    6093                 :            :         {
    6094                 :        672 :           if (name)
    6095                 :        650 :             warn_defaults_to (loc, OPT_Wimplicit_int,
    6096                 :            :                               "type defaults to %<int%> in declaration "
    6097                 :            :                               "of %qE", name);
    6098                 :            :           else
    6099                 :         22 :             warn_defaults_to (loc, OPT_Wimplicit_int,
    6100                 :            :                               "type defaults to %<int%> in type name");
    6101                 :            :         }
    6102                 :            :     }
    6103                 :            : 
    6104                 :            :   /* Adjust the type if a bit-field is being declared,
    6105                 :            :      -funsigned-bitfields applied and the type is not explicitly
    6106                 :            :      "signed".  */
    6107                 :  185154000 :   if (bitfield && !flag_signed_bitfields && !declspecs->explicit_signed_p
    6108                 :         33 :       && TREE_CODE (type) == INTEGER_TYPE)
    6109                 :         33 :     type = unsigned_type_for (type);
    6110                 :            : 
    6111                 :            :   /* Figure out the type qualifiers for the declaration.  There are
    6112                 :            :      two ways a declaration can become qualified.  One is something
    6113                 :            :      like `const int i' where the `const' is explicit.  Another is
    6114                 :            :      something like `typedef const int CI; CI i' where the type of the
    6115                 :            :      declaration contains the `const'.  A third possibility is that
    6116                 :            :      there is a type qualifier on the element type of a typedefed
    6117                 :            :      array type, in which case we should extract that qualifier so
    6118                 :            :      that c_apply_type_quals_to_decl receives the full list of
    6119                 :            :      qualifiers to work with (C90 is not entirely clear about whether
    6120                 :            :      duplicate qualifiers should be diagnosed in this case, but it
    6121                 :            :      seems most appropriate to do so).  */
    6122                 :  185154000 :   element_type = strip_array_types (type);
    6123                 :  185154000 :   constp = declspecs->const_p + TYPE_READONLY (element_type);
    6124                 :  185154000 :   restrictp = declspecs->restrict_p + TYPE_RESTRICT (element_type);
    6125                 :  185154000 :   volatilep = declspecs->volatile_p + TYPE_VOLATILE (element_type);
    6126                 :  185154000 :   atomicp = declspecs->atomic_p + TYPE_ATOMIC (element_type);
    6127                 :  185154000 :   as1 = declspecs->address_space;
    6128                 :  185154000 :   as2 = TYPE_ADDR_SPACE (element_type);
    6129                 :  185154000 :   address_space = ADDR_SPACE_GENERIC_P (as1)? as2 : as1;
    6130                 :            : 
    6131                 :  185154000 :   if (constp > 1)
    6132                 :         21 :     pedwarn_c90 (loc, OPT_Wpedantic, "duplicate %<const%>");
    6133                 :  185154000 :   if (restrictp > 1)
    6134                 :          6 :     pedwarn_c90 (loc, OPT_Wpedantic, "duplicate %<restrict%>");
    6135                 :  185154000 :   if (volatilep > 1)
    6136                 :         12 :     pedwarn_c90 (loc, OPT_Wpedantic, "duplicate %<volatile%>");
    6137                 :  185154000 :   if (atomicp > 1)
    6138                 :          6 :     pedwarn_c90 (loc, OPT_Wpedantic, "duplicate %<_Atomic%>");
    6139                 :            : 
    6140                 :  185154000 :   if (!ADDR_SPACE_GENERIC_P (as1) && !ADDR_SPACE_GENERIC_P (as2) && as1 != as2)
    6141                 :          0 :     error_at (loc, "conflicting named address spaces (%s vs %s)",
    6142                 :            :               c_addr_space_name (as1), c_addr_space_name (as2));
    6143                 :            : 
    6144                 :  185154000 :   if ((TREE_CODE (type) == ARRAY_TYPE
    6145                 :  185028000 :        || first_non_attr_kind == cdk_array)
    6146                 :  185980000 :       && TYPE_QUALS (element_type))
    6147                 :            :     {
    6148                 :         36 :       orig_qual_type = type;
    6149                 :         36 :       type = TYPE_MAIN_VARIANT (type);
    6150                 :            :     }
    6151                 :  185154000 :   type_quals = ((constp ? TYPE_QUAL_CONST : 0)
    6152                 :  185154000 :                 | (restrictp ? TYPE_QUAL_RESTRICT : 0)
    6153                 :  185154000 :                 | (volatilep ? TYPE_QUAL_VOLATILE : 0)
    6154                 :  185154000 :                 | (atomicp ? TYPE_QUAL_ATOMIC : 0)
    6155                 :  185154000 :                 | ENCODE_QUAL_ADDR_SPACE (address_space));
    6156                 :  185154000 :   if (type_quals != TYPE_QUALS (element_type))
    6157                 :    7787370 :     orig_qual_type = NULL_TREE;
    6158                 :            : 
    6159                 :            :   /* Applying the _Atomic qualifier to an array type (through the use
    6160                 :            :      of typedefs or typeof) must be detected here.  If the qualifier
    6161                 :            :      is introduced later, any appearance of applying it to an array is
    6162                 :            :      actually applying it to an element of that array.  */
    6163                 :  185154000 :   if (declspecs->atomic_p && TREE_CODE (type) == ARRAY_TYPE)
    6164                 :          6 :     error_at (loc, "%<_Atomic%>-qualified array type");
    6165                 :            : 
    6166                 :            :   /* Warn about storage classes that are invalid for certain
    6167                 :            :      kinds of declarations (parameters, typenames, etc.).  */
    6168                 :            : 
    6169                 :  185154000 :   if (funcdef_flag
    6170                 :   20340300 :       && (threadp
    6171                 :   20340300 :           || storage_class == csc_auto
    6172                 :   20340300 :           || storage_class == csc_register
    6173                 :   20340300 :           || storage_class == csc_typedef))
    6174                 :            :     {
    6175                 :         34 :       if (storage_class == csc_auto)
    6176                 :         26 :         pedwarn (loc,
    6177                 :         26 :                  (current_scope == file_scope) ? 0 : OPT_Wpedantic,
    6178                 :            :                  "function definition declared %<auto%>");
    6179                 :         34 :       if (storage_class == csc_register)
    6180                 :          3 :         error_at (loc, "function definition declared %<register%>");
    6181                 :         34 :       if (storage_class == csc_typedef)
    6182                 :          3 :         error_at (loc, "function definition declared %<typedef%>");
    6183                 :         34 :       if (threadp)
    6184                 :          2 :         error_at (loc, "function definition declared %qs",
    6185                 :          2 :                   declspecs->thread_gnu_p ? "__thread" : "_Thread_local");
    6186                 :         34 :       threadp = false;
    6187                 :         34 :       if (storage_class == csc_auto
    6188                 :         34 :           || storage_class == csc_register
    6189                 :          5 :           || storage_class == csc_typedef)
    6190                 :         32 :         storage_class = csc_none;
    6191                 :            :     }
    6192                 :  185154000 :   else if (decl_context != NORMAL && (storage_class != csc_none || threadp))
    6193                 :            :     {
    6194                 :        556 :       if (decl_context == PARM && storage_class == csc_register)
    6195                 :            :         ;
    6196                 :            :       else
    6197                 :            :         {
    6198                 :         15 :           switch (decl_context)
    6199                 :            :             {
    6200                 :          0 :             case FIELD:
    6201                 :          0 :               if (name)
    6202                 :          0 :                 error_at (loc, "storage class specified for structure "
    6203                 :            :                           "field %qE", name);
    6204                 :            :               else
    6205                 :          0 :                 error_at (loc, "storage class specified for structure field");
    6206                 :            :               break;
    6207                 :         15 :             case PARM:
    6208                 :         15 :               if (name)
    6209                 :          3 :                 error_at (loc, "storage class specified for parameter %qE",
    6210                 :            :                           name);
    6211                 :            :               else
    6212                 :         12 :                 error_at (loc, "storage class specified for unnamed parameter");
    6213                 :            :               break;
    6214                 :          0 :             default:
    6215                 :          0 :               error_at (loc, "storage class specified for typename");
    6216                 :          0 :               break;
    6217                 :            :             }
    6218                 :  185154000 :           storage_class = csc_none;
    6219                 :  185154000 :           threadp = false;
    6220                 :            :         }
    6221                 :            :     }
    6222                 :  185154000 :   else if (storage_class == csc_extern
    6223                 :  185154000 :            && initialized
    6224                 :   19767200 :            && !funcdef_flag)
    6225                 :            :     {
    6226                 :            :       /* 'extern' with initialization is invalid if not at file scope.  */
    6227                 :         16 :        if (current_scope == file_scope)
    6228                 :            :          {
    6229                 :            :            /* It is fine to have 'extern const' when compiling at C
    6230                 :            :               and C++ intersection.  */
    6231                 :         11 :            if (!(warn_cxx_compat && constp))
    6232                 :         10 :              warning_at (loc, 0, "%qE initialized and declared %<extern%>",
    6233                 :            :                          name);
    6234                 :            :          }
    6235                 :            :       else
    6236                 :          5 :         error_at (loc, "%qE has both %<extern%> and initializer", name);
    6237                 :            :     }
    6238                 :  185154000 :   else if (current_scope == file_scope)
    6239                 :            :     {
    6240                 :   38160100 :       if (storage_class == csc_auto)
    6241                 :          3 :         error_at (loc, "file-scope declaration of %qE specifies %<auto%>",
    6242                 :            :                   name);
    6243                 :   38160100 :       if (pedantic && storage_class == csc_register)
    6244                 :          4 :         pedwarn (input_location, OPT_Wpedantic,
    6245                 :            :                  "file-scope declaration of %qE specifies %<register%>", name);
    6246                 :            :     }
    6247                 :            :   else
    6248                 :            :     {
    6249                 :  146994000 :       if (storage_class == csc_extern && funcdef_flag)
    6250                 :          3 :         error_at (loc, "nested function %qE declared %<extern%>", name);
    6251                 :  146994000 :       else if (threadp && storage_class == csc_none)
    6252                 :            :         {
    6253                 :          4 :           error_at (loc, "function-scope %qE implicitly auto and declared "
    6254                 :            :                     "%qs", name,
    6255                 :          2 :                     declspecs->thread_gnu_p ? "__thread" : "_Thread_local");
    6256                 :          2 :           threadp = false;
    6257                 :            :         }
    6258                 :            :     }
    6259                 :            : 
    6260                 :            :   /* Now figure out the structure of the declarator proper.
    6261                 :            :      Descend through it, creating more complex types, until we reach
    6262                 :            :      the declared identifier (or NULL_TREE, in an absolute declarator).
    6263                 :            :      At each stage we maintain an unqualified version of the type
    6264                 :            :      together with any qualifiers that should be applied to it with
    6265                 :            :      c_build_qualified_type; this way, array types including
    6266                 :            :      multidimensional array types are first built up in unqualified
    6267                 :            :      form and then the qualified form is created with
    6268                 :            :      TYPE_MAIN_VARIANT pointing to the unqualified form.  */
    6269                 :            : 
    6270                 :  228218000 :   while (declarator && declarator->kind != cdk_id)
    6271                 :            :     {
    6272                 :   43063100 :       if (type == error_mark_node)
    6273                 :            :         {
    6274                 :         35 :           declarator = declarator->declarator;
    6275                 :         35 :           continue;
    6276                 :            :         }
    6277                 :            : 
    6278                 :            :       /* Each level of DECLARATOR is either a cdk_array (for ...[..]),
    6279                 :            :          a cdk_pointer (for *...),
    6280                 :            :          a cdk_function (for ...(...)),
    6281                 :            :          a cdk_attrs (for nested attributes),
    6282                 :            :          or a cdk_id (for the name being declared
    6283                 :            :          or the place in an absolute declarator
    6284                 :            :          where the name was omitted).
    6285                 :            :          For the last case, we have just exited the loop.
    6286                 :            : 
    6287                 :            :          At this point, TYPE is the type of elements of an array,
    6288                 :            :          or for a function to return, or for a pointer to point to.
    6289                 :            :          After this sequence of ifs, TYPE is the type of the
    6290                 :            :          array or function or pointer, and DECLARATOR has had its
    6291                 :            :          outermost layer removed.  */
    6292                 :            : 
    6293                 :   43063100 :       if (array_ptr_quals != TYPE_UNQUALIFIED
    6294                 :   43063100 :           || array_ptr_attrs != NULL_TREE
    6295                 :   43063100 :           || array_parm_static)
    6296                 :            :         {
    6297                 :            :           /* Only the innermost declarator (making a parameter be of
    6298                 :            :              array type which is converted to pointer type)
    6299                 :            :              may have static or type qualifiers.  */
    6300                 :          1 :           error_at (loc, "static or type qualifiers in non-parameter array declarator");
    6301                 :          1 :           array_ptr_quals = TYPE_UNQUALIFIED;
    6302                 :          1 :           array_ptr_attrs = NULL_TREE;
    6303                 :          1 :           array_parm_static = false;
    6304                 :            :         }
    6305                 :            : 
    6306                 :   43063100 :       switch (declarator->kind)
    6307                 :            :         {
    6308                 :       1541 :         case cdk_attrs:
    6309                 :       1541 :           {
    6310                 :            :             /* A declarator with embedded attributes.  */
    6311                 :       1541 :             tree attrs = declarator->u.attrs;
    6312                 :       1541 :             const struct c_declarator *inner_decl;
    6313                 :       1541 :             int attr_flags = 0;
    6314                 :       1541 :             declarator = declarator->declarator;
    6315                 :            :             /* Standard attribute syntax precisely defines what entity
    6316                 :            :                an attribute in each position appertains to, so only
    6317                 :            :                apply laxity about positioning to GNU attribute syntax.
    6318                 :            :                Standard attributes applied to a function or array
    6319                 :            :                declarator apply exactly to that type; standard
    6320                 :            :                attributes applied to the identifier apply to the
    6321                 :            :                declaration rather than to the type, and are specified
    6322                 :            :                using a cdk_id declarator rather than using
    6323                 :            :                cdk_attrs.  */
    6324                 :       1541 :             inner_decl = declarator;
    6325                 :       1541 :             while (inner_decl->kind == cdk_attrs)
    6326                 :          0 :               inner_decl = inner_decl->declarator;
    6327                 :       1541 :             if (!cxx11_attribute_p (attrs))
    6328                 :            :               {
    6329                 :       1525 :                 if (inner_decl->kind == cdk_id)
    6330                 :            :                   attr_flags |= (int) ATTR_FLAG_DECL_NEXT;
    6331                 :       1398 :                 else if (inner_decl->kind == cdk_function)
    6332                 :            :                   attr_flags |= (int) ATTR_FLAG_FUNCTION_NEXT;
    6333                 :         27 :                 else if (inner_decl->kind == cdk_array)
    6334                 :          2 :                   attr_flags |= (int) ATTR_FLAG_ARRAY_NEXT;
    6335                 :            :               }
    6336                 :       1541 :             attrs = c_warn_type_attributes (attrs);
    6337                 :       1541 :             returned_attrs = decl_attributes (&type,
    6338                 :            :                                               chainon (returned_attrs, attrs),
    6339                 :            :                                               attr_flags);
    6340                 :       1541 :             break;
    6341                 :            :           }
    6342                 :     755888 :         case cdk_array:
    6343                 :     755888 :           {
    6344                 :     755888 :             tree itype = NULL_TREE;
    6345                 :     755888 :             tree size = declarator->u.array.dimen;
    6346                 :            :             /* The index is a signed object `sizetype' bits wide.  */
    6347                 :     755888 :             tree index_type = c_common_signed_type (sizetype);
    6348                 :            : 
    6349                 :     755888 :             array_ptr_quals = declarator->u.array.quals;
    6350                 :     755888 :             array_ptr_attrs = declarator->u.array.attrs;
    6351                 :     755888 :             array_parm_static = declarator->u.array.static_p;
    6352                 :     755888 :             array_parm_vla_unspec_p = declarator->u.array.vla_unspec_p;
    6353                 :            : 
    6354                 :     755888 :             declarator = declarator->declarator;
    6355                 :            : 
    6356                 :            :             /* Check for some types that there cannot be arrays of.  */
    6357                 :            : 
    6358                 :     755888 :             if (VOID_TYPE_P (type))
    6359                 :            :               {
    6360                 :         10 :                 if (name)
    6361                 :          9 :                   error_at (loc, "declaration of %qE as array of voids", name);
    6362                 :            :                 else
    6363                 :          1 :                   error_at (loc, "declaration of type name as array of voids");
    6364                 :         10 :                 type = error_mark_node;
    6365                 :            :               }
    6366                 :            : 
    6367                 :     755888 :             if (TREE_CODE (type) == FUNCTION_TYPE)
    6368                 :            :               {
    6369                 :          3 :                 if (name)
    6370                 :          2 :                   error_at (loc, "declaration of %qE as array of functions",
    6371                 :            :                             name);
    6372                 :            :                 else
    6373                 :          1 :                   error_at (loc, "declaration of type name as array of "
    6374                 :            :                             "functions");
    6375                 :          3 :                 type = error_mark_node;
    6376                 :            :               }
    6377                 :            : 
    6378                 :      18328 :             if (pedantic && !in_system_header_at (input_location)
    6379                 :     770195 :                 && flexible_array_type_p (type))
    6380                 :         20 :               pedwarn (loc, OPT_Wpedantic,
    6381                 :            :                        "invalid use of structure with flexible array member");
    6382                 :            : 
    6383                 :     755888 :             if (size == error_mark_node)
    6384                 :         94 :               type = error_mark_node;
    6385                 :            : 
    6386                 :     755888 :             if (type == error_mark_node)
    6387                 :        107 :               continue;
    6388                 :            : 
    6389                 :     755781 :             if (!verify_type_context (loc, TCTX_ARRAY_ELEMENT, type))
    6390                 :            :               {
    6391                 :          0 :                 type = error_mark_node;
    6392                 :          0 :                 continue;
    6393                 :            :               }
    6394                 :            : 
    6395                 :            :             /* If size was specified, set ITYPE to a range-type for
    6396                 :            :                that size.  Otherwise, ITYPE remains null.  finish_decl
    6397                 :            :                may figure it out from an initial value.  */
    6398                 :            : 
    6399                 :     755781 :             if (size)
    6400                 :            :               {
    6401                 :     634902 :                 bool size_maybe_const = true;
    6402                 :     634902 :                 bool size_int_const = (TREE_CODE (size) == INTEGER_CST
    6403                 :    1256550 :                                        && !TREE_OVERFLOW (size));
    6404                 :     634902 :                 bool this_size_varies = false;
    6405                 :            : 
    6406                 :            :                 /* Strip NON_LVALUE_EXPRs since we aren't using as an
    6407                 :            :                    lvalue.  */
    6408                 :     634942 :                 STRIP_TYPE_NOPS (size);
    6409                 :            : 
    6410                 :     634902 :                 if (!INTEGRAL_TYPE_P (TREE_TYPE (size)))
    6411                 :            :                   {
    6412                 :          9 :                     if (name)
    6413                 :          9 :                       error_at (loc, "size of array %qE has non-integer type",
    6414                 :            :                                 name);
    6415                 :            :                     else
    6416                 :          0 :                       error_at (loc,
    6417                 :            :                                 "size of unnamed array has non-integer type");
    6418                 :          9 :                     size = integer_one_node;
    6419                 :            :                   }
    6420                 :            :                 /* This can happen with enum forward declaration.  */
    6421                 :     634893 :                 else if (!COMPLETE_TYPE_P (TREE_TYPE (size)))
    6422                 :            :                   {
    6423                 :          0 :                     if (name)
    6424                 :          0 :                       error_at (loc, "size of array %qE has incomplete type",
    6425                 :            :                                 name);
    6426                 :            :                     else
    6427                 :          0 :                       error_at (loc, "size of unnamed array has incomplete "
    6428                 :            :                                 "type");
    6429                 :          0 :                     size = integer_one_node;
    6430                 :            :                   }
    6431                 :            : 
    6432                 :     634902 :                 size = c_fully_fold (size, false, &size_maybe_const);
    6433                 :            : 
    6434                 :     634902 :                 if (pedantic && size_maybe_const && integer_zerop (size))
    6435                 :            :                   {
    6436                 :          3 :                     if (name)
    6437                 :          3 :                       pedwarn (loc, OPT_Wpedantic,
    6438                 :            :                                "ISO C forbids zero-size array %qE", name);
    6439                 :            :                     else
    6440                 :          0 :                       pedwarn (loc, OPT_Wpedantic,
    6441                 :            :                                "ISO C forbids zero-size array");
    6442                 :            :                   }
    6443                 :            : 
    6444                 :     634902 :                 if (TREE_CODE (size) == INTEGER_CST && size_maybe_const)
    6445                 :            :                   {
    6446                 :     621790 :                     constant_expression_warning (size);
    6447                 :     621790 :                     if (tree_int_cst_sgn (size) < 0)
    6448                 :            :                       {
    6449                 :        224 :                         if (name)
    6450                 :        222 :                           error_at (loc, "size of array %qE is negative", name);
    6451                 :            :                         else
    6452                 :          2 :                           error_at (loc, "size of unnamed array is negative");
    6453                 :        224 :                         size = integer_one_node;
    6454                 :            :                       }
    6455                 :            :                     /* Handle a size folded to an integer constant but
    6456                 :            :                        not an integer constant expression.  */
    6457                 :     621790 :                     if (!size_int_const)
    6458                 :            :                       {
    6459                 :            :                         /* If this is a file scope declaration of an
    6460                 :            :                            ordinary identifier, this is invalid code;
    6461                 :            :                            diagnosing it here and not subsequently
    6462                 :            :                            treating the type as variable-length avoids
    6463                 :            :                            more confusing diagnostics later.  */
    6464                 :        142 :                         if ((decl_context == NORMAL || decl_context == FIELD)
    6465                 :        131 :                             && current_scope == file_scope)
    6466                 :         14 :                           pedwarn (input_location, 0,
    6467                 :            :                                    "variably modified %qE at file scope",
    6468                 :            :                                    name);
    6469                 :            :                         else
    6470                 :            :                           this_size_varies = size_varies = true;
    6471                 :        142 :                         warn_variable_length_array (name, size);
    6472                 :            :                       }
    6473                 :            :                   }
    6474                 :      13112 :                 else if ((decl_context == NORMAL || decl_context == FIELD)
    6475                 :      12502 :                          && current_scope == file_scope)
    6476                 :            :                   {
    6477                 :         21 :                     error_at (loc, "variably modified %qE at file scope", name);
    6478                 :         21 :                     size = integer_one_node;
    6479                 :            :                   }
    6480                 :            :                 else
    6481                 :            :                   {
    6482                 :            :                     /* Make sure the array size remains visibly
    6483                 :            :                        nonconstant even if it is (eg) a const variable
    6484                 :            :                        with known value.  */
    6485                 :      13091 :                     this_size_varies = size_varies = true;
    6486                 :      13091 :                     warn_variable_length_array (name, size);
    6487                 :      13091 :                     if (sanitize_flags_p (SANITIZE_VLA)
    6488                 :        145 :                         && current_function_decl != NULL_TREE
    6489                 :      13236 :                         && decl_context == NORMAL)
    6490                 :            :                       {
    6491                 :            :                         /* Evaluate the array size only once.  */
    6492                 :        137 :                         size = save_expr (size);
    6493                 :        137 :                         size = c_fully_fold (size, false, NULL);
    6494                 :        137 :                         size = fold_build2 (COMPOUND_EXPR, TREE_TYPE (size),
    6495                 :            :                                             ubsan_instrument_vla (loc, size),
    6496                 :            :                                             size);
    6497                 :            :                       }
    6498                 :            :                   }
    6499                 :            : 
    6500                 :     634902 :                 if (integer_zerop (size) && !this_size_varies)
    6501                 :            :                   {
    6502                 :            :                     /* A zero-length array cannot be represented with
    6503                 :            :                        an unsigned index type, which is what we'll
    6504                 :            :                        get with build_index_type.  Create an
    6505                 :            :                        open-ended range instead.  */
    6506                 :       2039 :                     itype = build_range_type (sizetype, size, NULL_TREE);
    6507                 :            :                   }
    6508                 :            :                 else
    6509                 :            :                   {
    6510                 :            :                     /* Arrange for the SAVE_EXPR on the inside of the
    6511                 :            :                        MINUS_EXPR, which allows the -1 to get folded
    6512                 :            :                        with the +1 that happens when building TYPE_SIZE.  */
    6513                 :     632863 :                     if (size_varies)
    6514                 :      13430 :                       size = save_expr (size);
    6515                 :     632863 :                     if (this_size_varies && TREE_CODE (size) == INTEGER_CST)
    6516                 :        128 :                       size = build2 (COMPOUND_EXPR, TREE_TYPE (size),
    6517                 :            :                                      integer_zero_node, size);
    6518                 :            : 
    6519                 :            :                     /* Compute the maximum valid index, that is, size
    6520                 :            :                        - 1.  Do the calculation in index_type, so that
    6521                 :            :                        if it is a variable the computations will be
    6522                 :            :                        done in the proper mode.  */
    6523                 :     632863 :                     itype = fold_build2_loc (loc, MINUS_EXPR, index_type,
    6524                 :            :                                              convert (index_type, size),
    6525                 :            :                                              convert (index_type,
    6526                 :            :                                                       size_one_node));
    6527                 :            : 
    6528                 :            :                     /* The above overflows when size does not fit
    6529                 :            :                        in index_type.
    6530                 :            :                        ???  While a size of INT_MAX+1 technically shouldn't
    6531                 :            :                        cause an overflow (because we subtract 1), handling
    6532                 :            :                        this case seems like an unnecessary complication.  */
    6533                 :     632863 :                     if (TREE_CODE (size) == INTEGER_CST
    6534                 :     619644 :                         && !int_fits_type_p (size, index_type))
    6535                 :            :                       {
    6536                 :          5 :                         if (name)
    6537                 :          5 :                           error_at (loc, "size of array %qE is too large",
    6538                 :            :                                     name);
    6539                 :            :                         else
    6540                 :          0 :                           error_at (loc, "size of unnamed array is too large");
    6541                 :          5 :                         type = error_mark_node;
    6542                 :          5 :                         continue;
    6543                 :            :                       }
    6544                 :            : 
    6545                 :     632858 :                     itype = build_index_type (itype);
    6546                 :            :                   }
    6547                 :     634897 :                 if (this_size_varies)
    6548                 :            :                   {
    6549                 :      13219 :                     if (TREE_SIDE_EFFECTS (size))
    6550                 :            :                       {
    6551                 :      12942 :                         if (*expr)
    6552                 :        202 :                           *expr = build2 (COMPOUND_EXPR, TREE_TYPE (size),
    6553                 :            :                                           *expr, size);
    6554                 :            :                         else
    6555                 :      12740 :                           *expr = size;
    6556                 :            :                       }
    6557                 :      13219 :                     *expr_const_operands &= size_maybe_const;
    6558                 :            :                   }
    6559                 :            :               }
    6560                 :     120879 :             else if (decl_context == FIELD)
    6561                 :            :               {
    6562                 :      53125 :                 bool flexible_array_member = false;
    6563                 :      53125 :                 if (array_parm_vla_unspec_p)
    6564                 :            :                   /* Field names can in fact have function prototype
    6565                 :            :                      scope so [*] is disallowed here through making
    6566                 :            :                      the field variably modified, not through being
    6567                 :            :                      something other than a declaration with function
    6568                 :            :                      prototype scope.  */
    6569                 :            :                   size_varies = true;
    6570                 :            :                 else
    6571                 :            :                   {
    6572                 :            :                     const struct c_declarator *t = declarator;
    6573                 :      53124 :                     while (t->kind == cdk_attrs)
    6574                 :          0 :                       t = t->declarator;
    6575                 :      53124 :                     flexible_array_member = (t->kind == cdk_id);
    6576                 :            :                   }
    6577                 :      53124 :                 if (flexible_array_member
    6578                 :      53124 :                     && !in_system_header_at (input_location))
    6579                 :      53069 :                   pedwarn_c90 (loc, OPT_Wpedantic, "ISO C90 does not "
    6580                 :            :                                "support flexible array members");
    6581                 :            : 
    6582                 :            :                 /* ISO C99 Flexible array members are effectively
    6583                 :            :                    identical to GCC's zero-length array extension.  */
    6584                 :      53125 :                 if (flexible_array_member || array_parm_vla_unspec_p)
    6585                 :      53121 :                   itype = build_range_type (sizetype, size_zero_node,
    6586                 :            :                                             NULL_TREE);
    6587                 :            :               }
    6588                 :      67754 :             else if (decl_context == PARM)
    6589                 :            :               {
    6590                 :      41079 :                 if (array_parm_vla_unspec_p)
    6591                 :            :                   {
    6592                 :         27 :                     itype = build_range_type (sizetype, size_zero_node, NULL_TREE);
    6593                 :         27 :                     size_varies = true;
    6594                 :            :                   }
    6595                 :            :               }
    6596                 :      26675 :             else if (decl_context == TYPENAME)
    6597                 :            :               {
    6598                 :        247 :                 if (array_parm_vla_unspec_p)
    6599                 :            :                   {
    6600                 :            :                     /* C99 6.7.5.2p4 */
    6601                 :          5 :                     warning (0, "%<[*]%> not in a declaration");
    6602                 :            :                     /* We use this to avoid messing up with incomplete
    6603                 :            :                        array types of the same type, that would
    6604                 :            :                        otherwise be modified below.  */
    6605                 :          5 :                     itype = build_range_type (sizetype, size_zero_node,
    6606                 :            :                                               NULL_TREE);
    6607                 :          5 :                     size_varies = true;
    6608                 :            :                   }
    6609                 :            :               }
    6610                 :            : 
    6611                 :            :             /* Complain about arrays of incomplete types.  */
    6612                 :     755776 :             if (!COMPLETE_TYPE_P (type))
    6613                 :            :               {
    6614                 :         54 :                 error_at (loc, "array type has incomplete element type %qT",
    6615                 :            :                           type);
    6616                 :            :                 /* See if we can be more helpful.  */
    6617                 :         54 :                 if (TREE_CODE (type) == ARRAY_TYPE)
    6618                 :            :                   {
    6619                 :         28 :                     if (name)
    6620                 :         24 :                       inform (loc, "declaration of %qE as multidimensional "
    6621                 :            :                               "array must have bounds for all dimensions "
    6622                 :            :                               "except the first", name);
    6623                 :            :                     else
    6624                 :          4 :                       inform (loc, "declaration of multidimensional array "
    6625                 :            :                               "must have bounds for all dimensions except "
    6626                 :            :                               "the first");
    6627                 :            :                   }
    6628                 :         54 :                 type = error_mark_node;
    6629                 :            :               }
    6630                 :            :             else
    6631                 :            :             /* When itype is NULL, a shared incomplete array type is
    6632                 :            :                returned for all array of a given type.  Elsewhere we
    6633                 :            :                make sure we don't complete that type before copying
    6634                 :            :                it, but here we want to make sure we don't ever
    6635                 :            :                modify the shared type, so we gcc_assert (itype)
    6636                 :            :                below.  */
    6637                 :            :               {
    6638                 :     755722 :                 addr_space_t as = DECODE_QUAL_ADDR_SPACE (type_quals);
    6639                 :     755722 :                 if (!ADDR_SPACE_GENERIC_P (as) && as != TYPE_ADDR_SPACE (type))
    6640                 :          0 :                   type = build_qualified_type (type,
    6641                 :            :                                                ENCODE_QUAL_ADDR_SPACE (as));
    6642                 :            : 
    6643                 :     755722 :                 type = build_array_type (type, itype);
    6644                 :            :               }
    6645                 :            : 
    6646                 :     755776 :             if (type != error_mark_node)
    6647                 :            :               {
    6648                 :     755722 :                 if (size_varies)
    6649                 :            :                   {
    6650                 :            :                     /* It is ok to modify type here even if itype is
    6651                 :            :                        NULL: if size_varies, we're in a
    6652                 :            :                        multi-dimensional array and the inner type has
    6653                 :            :                        variable size, so the enclosing shared array type
    6654                 :            :                        must too.  */
    6655                 :      13538 :                     if (size && TREE_CODE (size) == INTEGER_CST)
    6656                 :        211 :                       type
    6657                 :        211 :                         = build_distinct_type_copy (TYPE_MAIN_VARIANT (type));
    6658                 :      13538 :                     C_TYPE_VARIABLE_SIZE (type) = 1;
    6659                 :            :                   }
    6660                 :            : 
    6661                 :            :                 /* The GCC extension for zero-length arrays differs from
    6662                 :            :                    ISO flexible array members in that sizeof yields
    6663                 :            :                    zero.  */
    6664                 :     755722 :                 if (size && integer_zerop (size))
    6665                 :            :                   {
    6666                 :       2032 :                     gcc_assert (itype);
    6667                 :       2032 :                     type = build_distinct_type_copy (TYPE_MAIN_VARIANT (type));
    6668                 :       2032 :                     TYPE_SIZE (type) = bitsize_zero_node;
    6669                 :       2032 :                     TYPE_SIZE_UNIT (type) = size_zero_node;
    6670                 :       2032 :                     SET_TYPE_STRUCTURAL_EQUALITY (type);
    6671                 :            :                   }
    6672                 :     755722 :                 if (array_parm_vla_unspec_p)
    6673                 :            :                   {
    6674                 :         33 :                     gcc_assert (itype);
    6675                 :            :                     /* The type is complete.  C99 6.7.5.2p4  */
    6676                 :         33 :                     type = build_distinct_type_copy (TYPE_MAIN_VARIANT (type));
    6677                 :         33 :                     TYPE_SIZE (type) = bitsize_zero_node;
    6678                 :         33 :                     TYPE_SIZE_UNIT (type) = size_zero_node;
    6679                 :         33 :                     SET_TYPE_STRUCTURAL_EQUALITY (type);
    6680                 :            :                   }
    6681                 :            : 
    6682                 :     755722 :                 if (!valid_array_size_p (loc, type, name))
    6683                 :         33 :                   type = error_mark_node;
    6684                 :            :               }
    6685                 :            : 
    6686                 :     755776 :             if (decl_context != PARM
    6687                 :     595333 :                 && (array_ptr_quals != TYPE_UNQUALIFIED
    6688                 :     595333 :                     || array_ptr_attrs != NULL_TREE
    6689                 :     595332 :                     || array_parm_static))
    6690                 :            :               {
    6691                 :          2 :                 error_at (loc, "static or type qualifiers in non-parameter "
    6692                 :            :                           "array declarator");
    6693                 :          2 :                 array_ptr_quals = TYPE_UNQUALIFIED;
    6694                 :          2 :                 array_ptr_attrs = NULL_TREE;
    6695                 :          2 :                 array_parm_static = false;
    6696                 :            :               }
    6697                 :     755776 :             orig_qual_indirect++;
    6698                 :     755776 :             break;
    6699                 :            :           }
    6700                 :   30048600 :         case cdk_function:
    6701                 :   30048600 :           {
    6702                 :            :             /* Say it's a definition only for the declarator closest
    6703                 :            :                to the identifier, apart possibly from some
    6704                 :            :                attributes.  */
    6705                 :   30048600 :             bool really_funcdef = false;
    6706                 :   30048600 :             tree arg_types;
    6707                 :   30048600 :             orig_qual_type = NULL_TREE;
    6708                 :   30048600 :             if (funcdef_flag)
    6709                 :            :               {
    6710                 :   20340300 :                 const struct c_declarator *t = declarator->declarator;
    6711                 :   20340300 :                 while (t->kind == cdk_attrs)
    6712                 :          2 :                   t = t->declarator;
    6713                 :   20340300 :                 really_funcdef = (t->kind == cdk_id);
    6714                 :            :               }
    6715                 :            : 
    6716                 :            :             /* Declaring a function type.  Make sure we have a valid
    6717                 :            :                type for the function to return.  */
    6718                 :   30048600 :             if (type == error_mark_node)
    6719                 :          0 :               continue;
    6720                 :            : 
    6721                 :   30048600 :             size_varies = false;
    6722                 :            : 
    6723                 :            :             /* Warn about some types functions can't return.  */
    6724                 :   30048600 :             if (TREE_CODE (type) == FUNCTION_TYPE)
    6725                 :            :               {
    6726                 :          0 :                 if (name)
    6727                 :          0 :                   error_at (loc, "%qE declared as function returning a "
    6728                 :            :                                  "function", name);
    6729                 :            :                 else
    6730                 :          0 :                   error_at (loc, "type name declared as function "
    6731                 :            :                             "returning a function");
    6732                 :          0 :                 type = integer_type_node;
    6733                 :            :               }
    6734                 :   30048600 :             if (TREE_CODE (type) == ARRAY_TYPE)
    6735                 :            :               {
    6736                 :          0 :                 if (name)
    6737                 :          0 :                   error_at (loc, "%qE declared as function returning an array",
    6738                 :            :                             name);
    6739                 :            :                 else
    6740                 :          0 :                   error_at (loc, "type name declared as function returning "
    6741                 :            :                             "an array");
    6742                 :          0 :                 type = integer_type_node;
    6743                 :            :               }
    6744                 :            : 
    6745                 :            :             /* Construct the function type and go to the next
    6746                 :            :                inner layer of declarator.  */
    6747                 :   30048600 :             arg_info = declarator->u.arg_info;
    6748                 :   30048600 :             arg_types = grokparms (arg_info, really_funcdef);
    6749                 :            : 
    6750                 :            :             /* Type qualifiers before the return type of the function
    6751                 :            :                qualify the return type, not the function type.  */
    6752                 :   30048600 :             if (type_quals)
    6753                 :            :               {
    6754                 :         91 :                 const enum c_declspec_word ignored_quals_list[] =
    6755                 :            :                   {
    6756                 :            :                     cdw_const, cdw_volatile, cdw_restrict, cdw_address_space,
    6757                 :            :                     cdw_atomic, cdw_number_of_elements
    6758                 :            :                   };
    6759                 :         91 :                 location_t specs_loc
    6760                 :         91 :                   = smallest_type_quals_location (declspecs->locations,
    6761                 :            :                                                   ignored_quals_list);
    6762                 :         91 :                 if (specs_loc == UNKNOWN_LOCATION)
    6763                 :         25 :                   specs_loc = declspecs->locations[cdw_typedef];
    6764                 :         91 :                 if (specs_loc == UNKNOWN_LOCATION)
    6765                 :         14 :                   specs_loc = loc;
    6766                 :            : 
    6767                 :            :                 /* Type qualifiers on a function return type are
    6768                 :            :                    normally permitted by the standard but have no
    6769                 :            :                    effect, so give a warning at -Wreturn-type.
    6770                 :            :                    Qualifiers on a void return type are banned on
    6771                 :            :                    function definitions in ISO C; GCC used to used
    6772                 :            :                    them for noreturn functions.  The resolution of C11
    6773                 :            :                    DR#423 means qualifiers (other than _Atomic) are
    6774                 :            :                    actually removed from the return type when
    6775                 :            :                    determining the function type.  */
    6776                 :         91 :                 int quals_used = type_quals;
    6777                 :         91 :                 if (flag_isoc11)
    6778                 :         68 :                   quals_used &= TYPE_QUAL_ATOMIC;
    6779                 :         91 :                 if (quals_used && VOID_TYPE_P (type) && really_funcdef)
    6780                 :          4 :                   pedwarn (specs_loc, 0,
    6781                 :            :                            "function definition has qualified void "
    6782                 :            :                            "return type");
    6783                 :            :                 else
    6784                 :         87 :                   warning_at (specs_loc, OPT_Wignored_qualifiers,
    6785                 :            :                               "type qualifiers ignored on function "
    6786                 :            :                               "return type");
    6787                 :            : 
    6788                 :            :                 /* Ensure an error for restrict on invalid types; the
    6789                 :            :                    DR#423 resolution is not entirely clear about
    6790                 :            :                    this.  */
    6791                 :         91 :                 if (flag_isoc11
    6792                 :         68 :                     && (type_quals & TYPE_QUAL_RESTRICT)
    6793                 :         94 :                     && (!POINTER_TYPE_P (type)
    6794                 :          2 :                         || !C_TYPE_OBJECT_OR_INCOMPLETE_P (TREE_TYPE (type))))
    6795                 :          2 :                   error_at (loc, "invalid use of %<restrict%>");
    6796                 :         91 :                 type = c_build_qualified_type (type, quals_used);
    6797                 :            :               }
    6798                 :   30048600 :             type_quals = TYPE_UNQUALIFIED;
    6799                 :            : 
    6800                 :   30048600 :             type = build_function_type (type, arg_types);
    6801                 :   30048600 :             declarator = declarator->declarator;
    6802                 :            : 
    6803                 :            :             /* Set the TYPE_CONTEXTs for each tagged type which is local to
    6804                 :            :                the formal parameter list of this FUNCTION_TYPE to point to
    6805                 :            :                the FUNCTION_TYPE node itself.  */
    6806                 :   30048600 :             {
    6807                 :   30048600 :               c_arg_tag *tag;
    6808                 :   30048600 :               unsigned ix;
    6809                 :            : 
    6810                 :  258266000 :               FOR_EACH_VEC_SAFE_ELT_REVERSE (arg_info->tags, ix, tag)
    6811                 :        122 :                 TYPE_CONTEXT (tag->type) = type;
    6812                 :            :             }
    6813                 :            :             break;
    6814                 :            :           }
    6815                 :   12257100 :         case cdk_pointer:
    6816                 :   12257100 :           {
    6817                 :            :             /* Merge any constancy or volatility into the target type
    6818                 :            :                for the pointer.  */
    6819                 :   12257100 :             if ((type_quals & TYPE_QUAL_ATOMIC)
    6820                 :       1001 :                 && TREE_CODE (type) == FUNCTION_TYPE)
    6821                 :            :               {
    6822                 :          2 :                 error_at (loc,
    6823                 :            :                           "%<_Atomic%>-qualified function type");
    6824                 :          2 :                 type_quals &= ~TYPE_QUAL_ATOMIC;
    6825                 :            :               }
    6826                 :   12257100 :             else if (pedantic && TREE_CODE (type) == FUNCTION_TYPE
    6827                 :        838 :                      && type_quals)
    6828                 :          0 :               pedwarn (loc, OPT_Wpedantic,
    6829                 :            :                        "ISO C forbids qualified function types");
    6830                 :   12257100 :             if (type_quals)
    6831                 :    3904760 :               type = c_build_qualified_type (type, type_quals, orig_qual_type,
    6832                 :            :                                              orig_qual_indirect);
    6833                 :   12257100 :             orig_qual_type = NULL_TREE;
    6834                 :   12257100 :             size_varies = false;
    6835                 :            : 
    6836                 :            :             /* When the pointed-to type involves components of variable size,
    6837                 :            :                care must be taken to ensure that the size evaluation code is
    6838                 :            :                emitted early enough to dominate all the possible later uses
    6839                 :            :                and late enough for the variables on which it depends to have
    6840                 :            :                been assigned.
    6841                 :            : 
    6842                 :            :                This is expected to happen automatically when the pointed-to
    6843                 :            :                type has a name/declaration of it's own, but special attention
    6844                 :            :                is required if the type is anonymous.
    6845                 :            : 
    6846                 :            :                We attach an artificial TYPE_DECL to such pointed-to type
    6847                 :            :                and arrange for it to be included in a DECL_EXPR.  This
    6848                 :            :                forces the sizes evaluation at a safe point and ensures it
    6849                 :            :                is not deferred until e.g. within a deeper conditional context.
    6850                 :            : 
    6851                 :            :                PARM contexts have no enclosing statement list that
    6852                 :            :                can hold the DECL_EXPR, so we need to use a BIND_EXPR
    6853                 :            :                instead, and add it to the list of expressions that
    6854                 :            :                need to be evaluated.
    6855                 :            : 
    6856                 :            :                TYPENAME contexts do have an enclosing statement list,
    6857                 :            :                but it would be incorrect to use it, as the size should
    6858                 :            :                only be evaluated if the containing expression is
    6859                 :            :                evaluated.  We might also be in the middle of an
    6860                 :            :                expression with side effects on the pointed-to type size
    6861                 :            :                "arguments" prior to the pointer declaration point and
    6862                 :            :                the fake TYPE_DECL in the enclosing context would force
    6863                 :            :                the size evaluation prior to the side effects.  We therefore
    6864                 :            :                use BIND_EXPRs in TYPENAME contexts too.  */
    6865                 :   12257100 :             if (!TYPE_NAME (type)
    6866                 :   12257100 :                 && variably_modified_type_p (type, NULL_TREE))
    6867                 :            :               {
    6868                 :       5622 :                 tree bind = NULL_TREE;
    6869                 :       5622 :                 if (decl_context == TYPENAME || decl_context == PARM)
    6870                 :            :                   {
    6871                 :        195 :                     bind = build3 (BIND_EXPR, void_type_node, NULL_TREE,
    6872                 :            :                                    NULL_TREE, NULL_TREE);
    6873                 :        195 :                     TREE_SIDE_EFFECTS (bind) = 1;
    6874                 :        195 :                     BIND_EXPR_BODY (bind) = push_stmt_list ();
    6875                 :        195 :                     push_scope ();
    6876                 :            :                   }
    6877                 :       5622 :                 tree decl = build_decl (loc, TYPE_DECL, NULL_TREE, type);
    6878                 :       5622 :                 DECL_ARTIFICIAL (decl) = 1;
    6879                 :       5622 :                 pushdecl (decl);
    6880                 :       5622 :                 finish_decl (decl, loc, NULL_TREE, NULL_TREE, NULL_TREE);
    6881                 :       5622 :                 TYPE_NAME (type) = decl;
    6882                 :       5622 :                 if (bind)
    6883                 :            :                   {
    6884                 :        195 :                     pop_scope ();
    6885                 :        390 :                     BIND_EXPR_BODY (bind)
    6886                 :        195 :                       = pop_stmt_list (BIND_EXPR_BODY (bind));
    6887                 :        195 :                     if (*expr)
    6888                 :        178 :                       *expr = build2 (COMPOUND_EXPR, void_type_node, *expr,
    6889                 :            :                                       bind);
    6890                 :            :                     else
    6891                 :         17 :                       *expr = bind;
    6892                 :            :                   }
    6893                 :            :               }
    6894                 :            : 
    6895                 :   12257100 :             type = c_build_pointer_type (type);
    6896                 :            : 
    6897                 :            :             /* Process type qualifiers (such as const or volatile)
    6898                 :            :                that were given inside the `*'.  */
    6899                 :   12257100 :             type_quals = declarator->u.pointer_quals;
    6900                 :            : 
    6901                 :   12257100 :             declarator = declarator->declarator;
    6902                 :   12257100 :             break;
    6903                 :            :           }
    6904                 :          0 :         default:
    6905                 :          0 :           gcc_unreachable ();
    6906                 :            :         }
    6907                 :            :     }
    6908                 :  185154000 :   *decl_attrs = chainon (returned_attrs, *decl_attrs);
    6909                 :  185154000 :   *decl_attrs = chainon (decl_id_attrs, *decl_attrs);
    6910                 :            : 
    6911                 :            :   /* Now TYPE has the actual type, apart from any qualifiers in
    6912                 :            :      TYPE_QUALS.  */
    6913                 :            : 
    6914                 :            :   /* Warn about address space used for things other than static memory or
    6915                 :            :      pointers.  */
    6916                 :  185154000 :   address_space = DECODE_QUAL_ADDR_SPACE (type_quals);
    6917                 :  185154000 :   if (!ADDR_SPACE_GENERIC_P (address_space))
    6918                 :            :     {
    6919                 :          3 :       if (decl_context == NORMAL)
    6920                 :            :         {
    6921                 :          3 :           switch (storage_class)
    6922                 :            :             {
    6923                 :          0 :             case csc_auto:
    6924                 :          0 :               error ("%qs combined with %<auto%> qualifier for %qE",
    6925                 :            :                      c_addr_space_name (address_space), name);
    6926                 :          0 :               break;
    6927                 :          0 :             case csc_register:
    6928                 :          0 :               error ("%qs combined with %<register%> qualifier for %qE",
    6929                 :            :                      c_addr_space_name (address_space), name);
    6930                 :          0 :               break;
    6931                 :          0 :             case csc_none:
    6932                 :          0 :               if (current_function_scope)
    6933                 :            :                 {
    6934                 :          0 :                   error ("%qs specified for auto variable %qE",
    6935                 :            :                          c_addr_space_name (address_space), name);
    6936                 :          0 :                   break;
    6937                 :            :                 }
    6938                 :            :               break;
    6939                 :            :             case csc_static:
    6940                 :            :             case csc_extern:
    6941                 :            :             case csc_typedef:
    6942                 :            :               break;
    6943                 :          0 :             default:
    6944                 :          0 :               gcc_unreachable ();
    6945                 :            :             }
    6946                 :            :         }
    6947                 :          0 :       else if (decl_context == PARM && TREE_CODE (type) != ARRAY_TYPE)
    6948                 :            :         {
    6949                 :          0 :           if (name)
    6950                 :          0 :             error ("%qs specified for parameter %qE",
    6951                 :            :                    c_addr_space_name (address_space), name);
    6952                 :            :           else
    6953                 :          0 :             error ("%qs specified for unnamed parameter",
    6954                 :            :                    c_addr_space_name (address_space));
    6955                 :            :         }
    6956                 :          0 :       else if (decl_context == FIELD)
    6957                 :            :         {
    6958                 :          0 :           if (name)
    6959                 :          0 :             error ("%qs specified for structure field %qE",
    6960                 :            :                    c_addr_space_name (address_space), name);
    6961                 :            :           else
    6962                 :          0 :             error ("%qs specified for structure field",
    6963                 :            :                    c_addr_space_name (address_space));
    6964                 :            :         }
    6965                 :            :     }
    6966                 :            : 
    6967                 :            :   /* Check the type and width of a bit-field.  */
    6968                 :  185154000 :   if (bitfield)
    6969                 :            :     {
    6970                 :      36298 :       check_bitfield_type_and_width (loc, &type, width, name);
    6971                 :            :       /* C11 makes it implementation-defined (6.7.2.1#5) whether
    6972                 :            :          atomic types are permitted for bit-fields; we have no code to
    6973                 :            :          make bit-field accesses atomic, so disallow them.  */
    6974                 :      36298 :       if (type_quals & TYPE_QUAL_ATOMIC)
    6975                 :            :         {
    6976                 :          2 :           if (name)
    6977                 :          1 :             error_at (loc, "bit-field %qE has atomic type", name);
    6978                 :            :           else
    6979                 :          1 :             error_at (loc, "bit-field has atomic type");
    6980                 :          2 :           type_quals &= ~TYPE_QUAL_ATOMIC;
    6981                 :            :         }
    6982                 :            :     }
    6983                 :            : 
    6984                 :            :   /* Reject invalid uses of _Alignas.  */
    6985                 :  185154000 :   if (declspecs->alignas_p)
    6986                 :            :     {
    6987                 :        160 :       if (storage_class == csc_typedef)
    6988                 :          1 :         error_at (loc, "alignment specified for typedef %qE", name);
    6989                 :        159 :       else if (storage_class == csc_register)
    6990                 :          1 :         error_at (loc, "alignment specified for %<register%> object %qE",
    6991                 :            :                   name);
    6992                 :        158 :       else if (decl_context == PARM)
    6993                 :            :         {
    6994                 :          2 :           if (name)
    6995                 :          1 :             error_at (loc, "alignment specified for parameter %qE", name);
    6996                 :            :           else
    6997                 :          1 :             error_at (loc, "alignment specified for unnamed parameter");
    6998                 :            :         }
    6999                 :        156 :       else if (bitfield)
    7000                 :            :         {
    7001                 :          0 :           if (name)
    7002                 :          0 :             error_at (loc, "alignment specified for bit-field %qE", name);
    7003                 :            :           else
    7004                 :          0 :             error_at (loc, "alignment specified for unnamed bit-field");
    7005                 :            :         }
    7006                 :        156 :       else if (TREE_CODE (type) == FUNCTION_TYPE)
    7007                 :          1 :         error_at (loc, "alignment specified for function %qE", name);
    7008                 :        155 :       else if (declspecs->align_log != -1 && TYPE_P (type))
    7009                 :            :         {
    7010                 :        129 :           alignas_align = 1U << declspecs->align_log;
    7011                 :        129 :           if (alignas_align < min_align_of_type (type))
    7012                 :            :             {
    7013                 :         26 :               if (name)
    7014                 :         25 :                 error_at (loc, "%<_Alignas%> specifiers cannot reduce "
    7015                 :            :                           "alignment of %qE", name);
    7016                 :            :               else
    7017                 :          1 :                 error_at (loc, "%<_Alignas%> specifiers cannot reduce "
    7018                 :            :                           "alignment of unnamed field");
    7019                 :            :               alignas_align = 0;
    7020                 :            :             }
    7021                 :            :         }
    7022                 :            :     }
    7023                 :            : 
    7024                 :            :   /* If this is declaring a typedef name, return a TYPE_DECL.  */
    7025                 :            : 
    7026                 :  185154000 :   if (storage_class == csc_typedef)
    7027                 :            :     {
    7028                 :    2906230 :       tree decl;
    7029                 :    2906230 :       if ((type_quals & TYPE_QUAL_ATOMIC)
    7030                 :       8828 :           && TREE_CODE (type) == FUNCTION_TYPE)
    7031                 :            :         {
    7032                 :          0 :           error_at (loc,
    7033                 :            :                     "%<_Atomic%>-qualified function type");
    7034                 :          0 :           type_quals &= ~TYPE_QUAL_ATOMIC;
    7035                 :            :         }
    7036                 :    2906230 :       else if (pedantic && TREE_CODE (type) == FUNCTION_TYPE
    7037                 :         31 :                && type_quals)
    7038                 :          0 :         pedwarn (loc, OPT_Wpedantic,
    7039                 :            :                  "ISO C forbids qualified function types");
    7040                 :    2906230 :       if (type_quals)
    7041                 :      22596 :         type = c_build_qualified_type (type, type_quals, orig_qual_type,
    7042                 :            :                                        orig_qual_indirect);
    7043                 :    5812450 :       decl = build_decl (declarator->id_loc,
    7044                 :    2906230 :                          TYPE_DECL, declarator->u.id.id, type);
    7045                 :    2906230 :       if (declspecs->explicit_signed_p)
    7046                 :     254318 :         C_TYPEDEF_EXPLICITLY_SIGNED (decl) = 1;
    7047                 :    2906230 :       if (declspecs->inline_p)
    7048                 :          4 :         pedwarn (loc, 0,"typedef %q+D declared %<inline%>", decl);
    7049                 :    2906230 :       if (declspecs->noreturn_p)
    7050                 :          1 :         pedwarn (loc, 0,"typedef %q+D declared %<_Noreturn%>", decl);
    7051                 :            : 
    7052                 :    2906230 :       if (warn_cxx_compat && declarator->u.id.id != NULL_TREE)
    7053                 :            :         {
    7054                 :       1478 :           struct c_binding *b = I_TAG_BINDING (declarator->u.id.id);
    7055                 :            : 
    7056                 :       1478 :           if (b != NULL
    7057                 :         37 :               && b->decl != NULL_TREE
    7058                 :         37 :               && (B_IN_CURRENT_SCOPE (b)
    7059                 :          4 :                   || (current_scope == file_scope && B_IN_EXTERNAL_SCOPE (b)))
    7060                 :       1511 :               && TYPE_MAIN_VARIANT (b->decl) != TYPE_MAIN_VARIANT (type))
    7061                 :            :             {
    7062                 :         12 :               auto_diagnostic_group d;
    7063                 :          6 :               if (warning_at (declarator->id_loc, OPT_Wc___compat,
    7064                 :            :                               ("using %qD as both a typedef and a tag is "
    7065                 :            :                                "invalid in C++"), decl)
    7066                 :          6 :                   && b->locus != UNKNOWN_LOCATION)
    7067                 :          5 :                 inform (b->locus, "originally defined here");
    7068                 :            :             }
    7069                 :            :         }
    7070                 :            : 
    7071                 :    2906230 :       return decl;
    7072                 :            :     }
    7073                 :            : 
    7074                 :            :   /* If this is a type name (such as, in a cast or sizeof),
    7075                 :            :      compute the type and return it now.  */
    7076                 :            : 
    7077                 :  182248000 :   if (decl_context == TYPENAME)
    7078                 :            :     {
    7079                 :            :       /* Note that the grammar rejects storage classes in typenames
    7080                 :            :          and fields.  */
    7081                 :   71834100 :       gcc_assert (storage_class == csc_none && !threadp
    7082                 :            :                   && !declspecs->inline_p && !declspecs->noreturn_p);
    7083                 :   71834100 :       if ((type_quals & TYPE_QUAL_ATOMIC)
    7084                 :        155 :           && TREE_CODE (type) == FUNCTION_TYPE)
    7085                 :            :         {
    7086                 :          0 :           error_at (loc,
    7087                 :            :                     "%<_Atomic%>-qualified function type");
    7088                 :          0 :           type_quals &= ~TYPE_QUAL_ATOMIC;
    7089                 :            :         }
    7090                 :   71834100 :       else if (pedantic && TREE_CODE (type) == FUNCTION_TYPE
    7091                 :         10 :                && type_quals)
    7092                 :          0 :         pedwarn (loc, OPT_Wpedantic,
    7093                 :            :                  "ISO C forbids const or volatile function types");
    7094                 :   71834100 :       if (type_quals)
    7095                 :        539 :         type = c_build_qualified_type (type, type_quals, orig_qual_type,
    7096                 :            :                                        orig_qual_indirect);
    7097                 :   71834100 :       return type;
    7098                 :            :     }
    7099                 :            : 
    7100                 :     247114 :   if (pedantic && decl_context == FIELD
    7101                 :  110430000 :       && variably_modified_type_p (type, NULL_TREE))
    7102                 :            :     {
    7103                 :            :       /* C99 6.7.2.1p8 */
    7104                 :          4 :       pedwarn (loc, OPT_Wpedantic, "a member of a structure or union cannot "
    7105                 :            :                "have a variably modified type");
    7106                 :            :     }
    7107                 :            : 
    7108                 :            :   /* Aside from typedefs and type names (handle above),
    7109                 :            :      `void' at top level (not within pointer)
    7110                 :            :      is allowed only in public variables.
    7111                 :            :      We don't complain about parms either, but that is because
    7112                 :            :      a better error message can be made later.  */
    7113                 :            : 
    7114                 :  110414000 :   if (VOID_TYPE_P (type) && decl_context != PARM
    7115                 :         56 :       && !((decl_context != FIELD && TREE_CODE (type) != FUNCTION_TYPE)
    7116                 :            :             && (storage_class == csc_extern
    7117                 :         27 :                 || (current_scope == file_scope
    7118                 :         18 :                     && !(storage_class == csc_static
    7119                 :            :                          || storage_class == csc_register)))))
    7120                 :            :     {
    7121                 :         15 :       error_at (loc, "variable or field %qE declared void", name);
    7122                 :         15 :       type = integer_type_node;
    7123                 :            :     }
    7124                 :            : 
    7125                 :            :   /* Now create the decl, which may be a VAR_DECL, a PARM_DECL
    7126                 :            :      or a FUNCTION_DECL, depending on DECL_CONTEXT and TYPE.  */
    7127                 :            : 
    7128                 :  110414000 :   {
    7129                 :  110414000 :     tree decl;
    7130                 :            : 
    7131                 :  110414000 :     if (decl_context == PARM)
    7132                 :            :       {
    7133                 :   72334900 :         tree promoted_type;
    7134                 :   72334900 :         bool array_parameter_p = false;
    7135                 :            : 
    7136                 :            :         /* A parameter declared as an array of T is really a pointer to T.
    7137                 :            :            One declared as a function is really a pointer to a function.  */
    7138                 :            : 
    7139                 :   72334900 :         if (TREE_CODE (type) == ARRAY_TYPE)
    7140                 :            :           {
    7141                 :            :             /* Transfer const-ness of array into that of type pointed to.  */
    7142                 :     248760 :             type = TREE_TYPE (type);
    7143                 :     248760 :             if (orig_qual_type != NULL_TREE)
    7144                 :            :               {
    7145                 :          3 :                 if (orig_qual_indirect == 0)
    7146                 :          1 :                   orig_qual_type = TREE_TYPE (orig_qual_type);
    7147                 :            :                 else
    7148                 :          2 :                   orig_qual_indirect--;
    7149                 :            :               }
    7150                 :     248760 :             if (type_quals)
    7151                 :      14306 :               type = c_build_qualified_type (type, type_quals, orig_qual_type,
    7152                 :            :                                              orig_qual_indirect);
    7153                 :     248760 :             type = c_build_pointer_type (type);
    7154                 :     248760 :             type_quals = array_ptr_quals;
    7155                 :     248760 :             if (type_quals)
    7156                 :         39 :               type = c_build_qualified_type (type, type_quals);
    7157                 :            : 
    7158                 :            :             /* We don't yet implement attributes in this context.  */
    7159                 :     248760 :             if (array_ptr_attrs != NULL_TREE)
    7160                 :          0 :               warning_at (loc, OPT_Wattributes,
    7161                 :            :                           "attributes in parameter array declarator ignored");
    7162                 :            : 
    7163                 :            :             size_varies = false;
    7164                 :            :             array_parameter_p = true;
    7165                 :            :           }
    7166                 :   72086100 :         else if (TREE_CODE (type) == FUNCTION_TYPE)
    7167                 :            :           {
    7168                 :        203 :             if (type_quals & TYPE_QUAL_ATOMIC)
    7169                 :            :               {
    7170                 :          1 :                 error_at (loc,
    7171                 :            :                           "%<_Atomic%>-qualified function type");
    7172                 :          1 :                 type_quals &= ~TYPE_QUAL_ATOMIC;
    7173                 :            :               }
    7174                 :        202 :             else if (type_quals)
    7175                 :          0 :               pedwarn (loc, OPT_Wpedantic,
    7176                 :            :                        "ISO C forbids qualified function types");
    7177                 :        203 :             if (type_quals)
    7178                 :          0 :               type = c_build_qualified_type (type, type_quals);
    7179                 :        203 :             type = c_build_pointer_type (type);
    7180                 :        203 :             type_quals = TYPE_UNQUALIFIED;
    7181                 :            :           }
    7182                 :   72085900 :         else if (type_quals)
    7183                 :    5979200 :           type = c_build_qualified_type (type, type_quals);
    7184                 :            : 
    7185                 :  144670000 :         decl = build_decl (declarator->id_loc,
    7186                 :   72334900 :                            PARM_DECL, declarator->u.id.id, type);
    7187                 :   72334900 :         if (size_varies)
    7188                 :         36 :           C_DECL_VARIABLE_SIZE (decl) = 1;
    7189                 :   72334900 :         C_ARRAY_PARAMETER (decl) = array_parameter_p;
    7190                 :            : 
    7191                 :            :         /* Compute the type actually passed in the parmlist,
    7192                 :            :            for the case where there is no prototype.
    7193                 :            :            (For example, shorts and chars are passed as ints.)
    7194                 :            :            When there is a prototype, this is overridden later.  */
    7195                 :            : 
    7196                 :   72334900 :         if (type == error_mark_node)
    7197                 :            :           promoted_type = type;
    7198                 :            :         else
    7199                 :   72334800 :           promoted_type = c_type_promotes_to (type);
    7200                 :            : 
    7201                 :   72334900 :         DECL_ARG_TYPE (decl) = promoted_type;
    7202                 :   72334900 :         if (declspecs->inline_p)
    7203                 :          4 :           pedwarn (loc, 0, "parameter %q+D declared %<inline%>", decl);
    7204                 :   72334900 :         if (declspecs->noreturn_p)
    7205                 :          1 :           pedwarn (loc, 0, "parameter %q+D declared %<_Noreturn%>", decl);
    7206                 :            :       }
    7207                 :   38079200 :     else if (decl_context == FIELD)
    7208                 :            :       {
    7209                 :            :         /* Note that the grammar rejects storage classes in typenames
    7210                 :            :            and fields.  */
    7211                 :    2978230 :         gcc_assert (storage_class == csc_none && !threadp
    7212                 :            :                     && !declspecs->inline_p && !declspecs->noreturn_p);
    7213                 :            : 
    7214                 :            :         /* Structure field.  It may not be a function.  */
    7215                 :            : 
    7216                 :    2978230 :         if (TREE_CODE (type) == FUNCTION_TYPE)
    7217                 :            :           {
    7218                 :          0 :             error_at (loc, "field %qE declared as a function", name);
    7219                 :          0 :             type = build_pointer_type (type);
    7220                 :            :           }
    7221                 :    2978230 :         else if (TREE_CODE (type) != ERROR_MARK
    7222                 :    5956450 :                  && !COMPLETE_OR_UNBOUND_ARRAY_TYPE_P (type))
    7223                 :            :           {
    7224                 :         20 :             if (name)
    7225                 :         13 :               error_at (loc, "field %qE has incomplete type", name);
    7226                 :            :             else
    7227                 :          7 :               error_at (loc, "unnamed field has incomplete type");
    7228                 :         20 :             type = error_mark_node;
    7229                 :            :           }
    7230                 :    2978210 :         else if (TREE_CODE (type) == ARRAY_TYPE
    7231                 :    2978210 :                  && TYPE_DOMAIN (type) == NULL_TREE)
    7232                 :            :           {
    7233                 :            :             /* We have a flexible array member through a typedef.
    7234                 :            :                Set suitable range.  Whether this is a correct position
    7235                 :            :                for a flexible array member will be determined elsewhere.  */
    7236                 :         14 :             if (!in_system_header_at (input_location))
    7237                 :         14 :               pedwarn_c90 (loc, OPT_Wpedantic, "ISO C90 does not "
    7238                 :            :                            "support flexible array members");
    7239                 :         14 :             type = build_distinct_type_copy (TYPE_MAIN_VARIANT (type));
    7240                 :         14 :             TYPE_DOMAIN (type) = build_range_type (sizetype, size_zero_node,
    7241                 :            :                                                    NULL_TREE);
    7242                 :         14 :             if (orig_qual_indirect == 0)
    7243                 :         14 :               orig_qual_type = NULL_TREE;
    7244                 :            :           }
    7245                 :    2978230 :         if (type != error_mark_node
    7246                 :    2978230 :             && !verify_type_context (loc, TCTX_FIELD, type))
    7247                 :          0 :           type = error_mark_node;
    7248                 :            : 
    7249                 :    2978230 :         type = c_build_qualified_type (type, type_quals, orig_qual_type,
    7250                 :            :                                        orig_qual_indirect);
    7251                 :    5956460 :         decl = build_decl (declarator->id_loc,
    7252                 :    2978230 :                            FIELD_DECL, declarator->u.id.id, type);
    7253                 :    2978230 :         DECL_NONADDRESSABLE_P (decl) = bitfield;
    7254                 :    2978230 :         if (bitfield && !declarator->u.id.id)
    7255                 :            :           {
    7256                 :       8245 :             TREE_NO_WARNING (decl) = 1;
    7257                 :       8245 :             DECL_PADDING_P (decl) = 1;
    7258                 :            :           }
    7259                 :            : 
    7260                 :    2978230 :         if (size_varies)
    7261                 :        579 :           C_DECL_VARIABLE_SIZE (decl) = 1;
    7262                 :            :       }
    7263                 :   35101000 :     else if (TREE_CODE (type) == FUNCTION_TYPE)
    7264                 :            :       {
    7265                 :   30629100 :         if (storage_class == csc_register || threadp)
    7266                 :            :           {
    7267                 :          9 :             error_at (loc, "invalid storage class for function %qE", name);
    7268                 :            :           }
    7269                 :   30629000 :         else if (current_scope != file_scope)
    7270                 :            :           {
    7271                 :            :             /* Function declaration not at file scope.  Storage
    7272                 :            :                classes other than `extern' are not allowed, C99
    7273                 :            :                6.7.1p5, and `extern' makes no difference.  However,
    7274                 :            :                GCC allows 'auto', perhaps with 'inline', to support
    7275                 :            :                nested functions.  */
    7276                 :      10019 :             if (storage_class == csc_auto)
    7277                 :         52 :                 pedwarn (loc, OPT_Wpedantic,
    7278                 :            :                          "invalid storage class for function %qE", name);
    7279                 :       9967 :             else if (storage_class == csc_static)
    7280                 :            :               {
    7281                 :         19 :                 error_at (loc, "invalid storage class for function %qE", name);
    7282                 :         19 :                 if (funcdef_flag)
    7283                 :          8 :                   storage_class = declspecs->storage_class = csc_none;
    7284                 :            :                 else
    7285                 :            :                   return NULL_TREE;
    7286                 :            :               }
    7287                 :            :           }
    7288                 :            : 
    7289                 :   61258100 :         decl = build_decl (declarator->id_loc,
    7290                 :   30629000 :                            FUNCTION_DECL, declarator->u.id.id, type);
    7291                 :   30629000 :         decl = build_decl_attribute_variant (decl, decl_attr);
    7292                 :            : 
    7293                 :   30629000 :         if (type_quals & TYPE_QUAL_ATOMIC)
    7294                 :            :           {
    7295                 :          1 :             error_at (loc,
    7296                 :            :                       "%<_Atomic%>-qualified function type");
    7297                 :          1 :             type_quals &= ~TYPE_QUAL_ATOMIC;
    7298                 :            :           }
    7299                 :   30629000 :         else if (pedantic && type_quals && !DECL_IN_SYSTEM_HEADER (decl))
    7300                 :          0 :           pedwarn (loc, OPT_Wpedantic,
    7301                 :            :                    "ISO C forbids qualified function types");
    7302                 :            : 
    7303                 :            :         /* Every function declaration is an external reference
    7304                 :            :            (DECL_EXTERNAL) except for those which are not at file
    7305                 :            :            scope and are explicitly declared "auto".  This is
    7306                 :            :            forbidden by standard C (C99 6.7.1p5) and is interpreted by
    7307                 :            :            GCC to signify a forward declaration of a nested function.  */
    7308                 :   30629000 :         if (storage_class == csc_auto && current_scope != file_scope)
    7309                 :         52 :           DECL_EXTERNAL (decl) = 0;
    7310                 :            :         /* In C99, a function which is declared 'inline' with 'extern'
    7311                 :            :            is not an external reference (which is confusing).  It
    7312                 :            :            means that the later definition of the function must be output
    7313                 :            :            in this file, C99 6.7.4p6.  In GNU C89, a function declared
    7314                 :            :            'extern inline' is an external reference.  */
    7315                 :   30629000 :         else if (declspecs->inline_p && storage_class != csc_static)
    7316                 :   39533700 :           DECL_EXTERNAL (decl) = ((storage_class == csc_extern)
    7317                 :   19766800 :                                   == flag_gnu89_inline);
    7318                 :            :         else
    7319                 :   10862200 :           DECL_EXTERNAL (decl) = !initialized;
    7320                 :            : 
    7321                 :            :         /* Record absence of global scope for `static' or `auto'.  */
    7322                 :   30629000 :         TREE_PUBLIC (decl)
    7323                 :   30629000 :           = !(storage_class == csc_static || storage_class == csc_auto);
    7324                 :            : 
    7325                 :            :         /* For a function definition, record the argument information
    7326                 :            :            block where store_parm_decls will look for it.  */
    7327                 :   30629000 :         if (funcdef_flag)
    7328                 :   20340300 :           current_function_arg_info = arg_info;
    7329                 :            : 
    7330                 :   30629000 :         if (declspecs->default_int_p)
    7331                 :      13120 :           C_FUNCTION_IMPLICIT_INT (decl) = 1;
    7332                 :            : 
    7333                 :            :         /* Record presence of `inline' and `_Noreturn', if it is
    7334                 :            :            reasonable.  */
    7335                 :   30629000 :         if (flag_hosted && MAIN_NAME_P (declarator->u.id.id))
    7336                 :            :           {
    7337                 :      35821 :             if (declspecs->inline_p)
    7338                 :          5 :               pedwarn (loc, 0, "cannot inline function %<main%>");
    7339                 :      35821 :             if (declspecs->noreturn_p)
    7340                 :          1 :               pedwarn (loc, 0, "%<main%> declared %<_Noreturn%>");
    7341                 :            :           }
    7342                 :            :         else
    7343                 :            :           {
    7344                 :   30593200 :             if (declspecs->inline_p)
    7345                 :            :               /* Record that the function is declared `inline'.  */
    7346                 :   19883800 :               DECL_DECLARED_INLINE_P (decl) = 1;
    7347                 :   30593200 :             if (declspecs->noreturn_p)
    7348                 :            :               {
    7349                 :      17975 :                 if (flag_isoc99)
    7350                 :      17972 :                   pedwarn_c99 (loc, OPT_Wpedantic,
    7351                 :            :                                "ISO C99 does not support %<_Noreturn%>");
    7352                 :            :                 else
    7353                 :          3 :                   pedwarn_c99 (loc, OPT_Wpedantic,
    7354                 :            :                                "ISO C90 does not support %<_Noreturn%>");
    7355                 :      17975 :                 TREE_THIS_VOLATILE (decl) = 1;
    7356                 :            :               }
    7357                 :            :           }
    7358                 :            :       }
    7359                 :            :     else
    7360                 :            :       {
    7361                 :            :         /* It's a variable.  */
    7362                 :            :         /* An uninitialized decl with `extern' is a reference.  */
    7363                 :    4471960 :         int extern_ref = !initialized && storage_class == csc_extern;
    7364                 :            : 
    7365                 :    4471960 :         type = c_build_qualified_type (type, type_quals, orig_qual_type,
    7366                 :            :                                        orig_qual_indirect);
    7367                 :            : 
    7368                 :            :         /* C99 6.2.2p7: It is invalid (compile-time undefined
    7369                 :            :            behavior) to create an 'extern' declaration for a
    7370                 :            :            variable if there is a global declaration that is
    7371                 :            :            'static' and the global declaration is not visible.
    7372                 :            :            (If the static declaration _is_ currently visible,
    7373                 :            :            the 'extern' declaration is taken to refer to that decl.) */
    7374                 :    4471960 :         if (extern_ref && current_scope != file_scope)
    7375                 :            :           {
    7376                 :       1815 :             tree global_decl  = identifier_global_value (declarator->u.id.id);
    7377                 :       1815 :             tree visible_decl = lookup_name (declarator->u.id.id);
    7378                 :            : 
    7379                 :       1815 :             if (global_decl
    7380                 :       1815 :                 && global_decl != visible_decl
    7381                 :            :                 && VAR_P (global_decl)
    7382                 :        439 :                 && !TREE_PUBLIC (global_decl))
    7383                 :          7 :               error_at (loc, "variable previously declared %<static%> "
    7384                 :            :                         "redeclared %<extern%>");
    7385                 :            :           }
    7386                 :            : 
    7387                 :    8943930 :         decl = build_decl (declarator->id_loc,
    7388                 :    4471960 :                            VAR_DECL, declarator->u.id.id, type);
    7389                 :    4471960 :         if (size_varies)
    7390                 :       6925 :           C_DECL_VARIABLE_SIZE (decl) = 1;
    7391                 :            : 
    7392                 :    4471960 :         if (declspecs->inline_p)
    7393                 :          4 :           pedwarn (loc, 0, "variable %q+D declared %<inline%>", decl);
    7394                 :    4471960 :         if (declspecs->noreturn_p)
    7395                 :          1 :           pedwarn (loc, 0, "variable %q+D declared %<_Noreturn%>", decl);
    7396                 :            : 
    7397                 :            :         /* At file scope, an initialized extern declaration may follow
    7398                 :            :            a static declaration.  In that case, DECL_EXTERNAL will be
    7399                 :            :            reset later in start_decl.  */
    7400                 :    4471960 :         DECL_EXTERNAL (decl) = (storage_class == csc_extern);
    7401                 :            : 
    7402                 :            :         /* At file scope, the presence of a `static' or `register' storage
    7403                 :            :            class specifier, or the absence of all storage class specifiers
    7404                 :            :            makes this declaration a definition (perhaps tentative).  Also,
    7405                 :            :            the absence of `static' makes it public.  */
    7406                 :    4471960 :         if (current_scope == file_scope)
    7407                 :            :           {
    7408                 :     977155 :             TREE_PUBLIC (decl) = storage_class != csc_static;
    7409                 :     977155 :             TREE_STATIC (decl) = !extern_ref;
    7410                 :            :           }
    7411                 :            :         /* Not at file scope, only `static' makes a static definition.  */
    7412                 :            :         else
    7413                 :            :           {
    7414                 :    3494810 :             TREE_STATIC (decl) = (storage_class == csc_static);
    7415                 :    3494810 :             TREE_PUBLIC (decl) = extern_ref;
    7416                 :            :           }
    7417                 :            : 
    7418                 :    4471960 :         if (threadp)
    7419                 :       2616 :           set_decl_tls_model (decl, decl_default_tls_model (decl));
    7420                 :            :       }
    7421                 :            : 
    7422                 :  110414000 :     if ((storage_class == csc_extern
    7423                 :   80647200 :          || (storage_class == csc_none
    7424                 :   80070200 :              && TREE_CODE (type) == FUNCTION_TYPE
    7425                 :     533260 :              && !funcdef_flag))
    7426                 :  110644000 :         && variably_modified_type_p (type, NULL_TREE))
    7427                 :            :       {
    7428                 :            :         /* C99 6.7.5.2p2 */
    7429                 :          6 :         if (TREE_CODE (type) == FUNCTION_TYPE)
    7430                 :          4 :           error_at (loc, "non-nested function with variably modified type");
    7431                 :            :         else
    7432                 :          2 :           error_at (loc, "object with variably modified type must have "
    7433                 :            :                     "no linkage");
    7434                 :            :       }
    7435                 :            : 
    7436                 :            :     /* For nested functions disqualify ones taking VLAs by value
    7437                 :            :        from inlining since the middle-end cannot deal with this.
    7438                 :            :        ???  We should arrange for those to be passed by reference
    7439                 :            :        with emitting the copy on the caller side in the frontend.  */
    7440                 :  110414000 :     if (storage_class == csc_none
    7441                 :   80070200 :         && TREE_CODE (type) == FUNCTION_TYPE)
    7442                 :    2812050 :       for (tree al = TYPE_ARG_TYPES (type); al; al = TREE_CHAIN (al))
    7443                 :            :         {
    7444                 :    2278830 :           tree arg = TREE_VALUE (al);
    7445                 :    2278830 :           if (arg != error_mark_node
    7446                 :    4557620 :               && C_TYPE_VARIABLE_SIZE (arg))
    7447                 :            :             {
    7448                 :         36 :               DECL_UNINLINABLE (decl) = 1;
    7449                 :         36 :               break;
    7450                 :            :             }
    7451                 :            :         }
    7452                 :            : 
    7453                 :            :     /* Record `register' declaration for warnings on &
    7454                 :            :        and in case doing stupid register allocation.  */
    7455                 :            : 
    7456                 :  110414000 :     if (storage_class == csc_register)
    7457                 :            :       {
    7458                 :       3061 :         C_DECL_REGISTER (decl) = 1;
    7459                 :       3061 :         DECL_REGISTER (decl) = 1;
    7460                 :            :       }
    7461                 :            : 
    7462                 :            :     /* Record constancy and volatility.  */
    7463                 :  110414000 :     c_apply_type_quals_to_decl (type_quals, decl);
    7464                 :            : 
    7465                 :            :     /* Apply _Alignas specifiers.  */
    7466                 :  110414000 :     if (alignas_align)
    7467                 :            :       {
    7468                 :         96 :         SET_DECL_ALIGN (decl, alignas_align * BITS_PER_UNIT);
    7469                 :         96 :         DECL_USER_ALIGN (decl) = 1;
    7470                 :            :       }
    7471                 :            : 
    7472                 :            :     /* If a type has volatile components, it should be stored in memory.
    7473                 :            :        Otherwise, the fact that those components are volatile
    7474                 :            :        will be ignored, and would even crash the compiler.
    7475                 :            :        Of course, this only makes sense on  VAR,PARM, and RESULT decl's.   */
    7476                 :  110414000 :     if (C_TYPE_FIELDS_VOLATILE (TREE_TYPE (decl))
    7477                 :        153 :         && (VAR_P (decl) ||  TREE_CODE (decl) == PARM_DECL
    7478                 :  110414000 :           || TREE_CODE (decl) == RESULT_DECL))
    7479                 :            :       {
    7480                 :            :         /* It is not an error for a structure with volatile fields to
    7481                 :            :            be declared register, but reset DECL_REGISTER since it
    7482                 :            :            cannot actually go in a register.  */
    7483                 :        128 :         int was_reg = C_DECL_REGISTER (decl);
    7484                 :        128 :         C_DECL_REGISTER (decl) = 0;
    7485                 :        128 :         DECL_REGISTER (decl) = 0;
    7486                 :        128 :         c_mark_addressable (decl);
    7487                 :        128 :         C_DECL_REGISTER (decl) = was_reg;
    7488                 :            :       }
    7489                 :            : 
    7490                 :            :   /* This is the earliest point at which we might know the assembler
    7491                 :            :      name of a variable.  Thus, if it's known before this, die horribly.  */
    7492                 :  110414000 :     gcc_assert (!HAS_DECL_ASSEMBLER_NAME_P (decl)
    7493                 :            :                 || !DECL_ASSEMBLER_NAME_SET_P (decl));
    7494                 :            : 
    7495                 :  110414000 :     if (warn_cxx_compat
    7496                 :            :         && VAR_P (decl)
    7497                 :            :         && TREE_PUBLIC (decl)
    7498                 :      16653 :         && TREE_STATIC (decl)
    7499                 :       1474 :         && (RECORD_OR_UNION_TYPE_P (TREE_TYPE (decl))
    7500                 :       1409 :             || TREE_CODE (TREE_TYPE (decl)) == ENUMERAL_TYPE)
    7501                 :  110414000 :         && TYPE_NAME (TREE_TYPE (decl)) == NULL_TREE)
    7502                 :          4 :       warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wc___compat,
    7503                 :            :                   ("non-local variable %qD with anonymous type is "
    7504                 :            :                    "questionable in C++"),
    7505                 :            :                   decl);
    7506                 :            : 
    7507                 :            :     return decl;
    7508                 :            :   }
    7509                 :            : }
    7510                 :            : 
    7511                 :            : /* Decode the parameter-list info for a function type or function definition.
    7512                 :            :    The argument is the value returned by `get_parm_info' (or made in c-parse.c
    7513                 :            :    if there is an identifier list instead of a parameter decl list).
    7514                 :            :    These two functions are separate because when a function returns
    7515                 :            :    or receives functions then each is called multiple times but the order
    7516                 :            :    of calls is different.  The last call to `grokparms' is always the one
    7517                 :            :    that contains the formal parameter names of a function definition.
    7518                 :            : 
    7519                 :            :    Return a list of arg types to use in the FUNCTION_TYPE for this function.
    7520                 :            : 
    7521                 :            :    FUNCDEF_FLAG is true for a function definition, false for
    7522                 :            :    a mere declaration.  A nonempty identifier-list gets an error message
    7523                 :            :    when FUNCDEF_FLAG is false.  */
    7524                 :            : 
    7525                 :            : static tree
    7526                 :   30048600 : grokparms (struct c_arg_info *arg_info, bool funcdef_flag)
    7527                 :            : {
    7528                 :   30048600 :   tree arg_types = arg_info->types;
    7529                 :            : 
    7530                 :   30048600 :   if (funcdef_flag && arg_info->had_vla_unspec)
    7531                 :            :     {
    7532                 :            :       /* A function definition isn't function prototype scope C99 6.2.1p4.  */
    7533                 :            :       /* C99 6.7.5.2p4 */
    7534                 :          2 :       error ("%<[*]%> not allowed in other than function prototype scope");
    7535                 :            :     }
    7536                 :            : 
    7537                 :   30048600 :   if (arg_types == NULL_TREE && !funcdef_flag
    7538                 :   30048600 :       && !in_system_header_at (input_location))
    7539                 :     707302 :     warning (OPT_Wstrict_prototypes,
    7540                 :            :              "function declaration isn%'t a prototype");
    7541                 :            : 
    7542                 :   30048600 :   if (arg_types == error_mark_node)
    7543                 :            :     /* Don't set TYPE_ARG_TYPES in this case.  */
    7544                 :            :     return NULL_TREE;
    7545                 :            : 
    7546                 :   59350600 :   else if (arg_types && TREE_CODE (TREE_VALUE (arg_types)) == IDENTIFIER_NODE)
    7547                 :            :     {
    7548                 :       8692 :       if (!funcdef_flag)
    7549                 :            :         {
    7550                 :          1 :           pedwarn (input_location, 0, "parameter names (without types) in "
    7551                 :            :                    "function declaration");
    7552                 :          1 :           arg_info->parms = NULL_TREE;
    7553                 :            :         }
    7554                 :            :       else
    7555                 :       8691 :         arg_info->parms = arg_info->types;
    7556                 :            : 
    7557                 :       8692 :       arg_info->types = NULL_TREE;
    7558                 :       8692 :       return NULL_TREE;
    7559                 :            :     }
    7560                 :            :   else
    7561                 :            :     {
    7562                 :   30039900 :       tree parm, type, typelt;
    7563                 :   30039900 :       unsigned int parmno;
    7564                 :            : 
    7565                 :            :       /* In C2X, convert () in a function definition to (void).  */
    7566                 :   30039900 :       if (flag_isoc2x
    7567                 :   30039900 :           && funcdef_flag
    7568                 :        407 :           && !arg_types
    7569                 :          3 :           && !arg_info->parms)
    7570                 :          3 :         arg_types = arg_info->types = void_list_node;
    7571                 :            : 
    7572                 :            :       /* If there is a parameter of incomplete type in a definition,
    7573                 :            :