LCOV - code coverage report
Current view: top level - gcc/c - c-typeck.cc (source / functions) Coverage Total Hit
Test: gcc.info Lines: 93.5 % 8726 8159
Test Date: 2024-12-28 13:16:48 Functions: 99.5 % 184 183
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : /* Build expressions with type checking for C compiler.
       2                 :             :    Copyright (C) 1987-2024 Free Software Foundation, Inc.
       3                 :             : 
       4                 :             : This file is part of GCC.
       5                 :             : 
       6                 :             : GCC is free software; you can redistribute it and/or modify it under
       7                 :             : the terms of the GNU General Public License as published by the Free
       8                 :             : Software Foundation; either version 3, or (at your option) any later
       9                 :             : version.
      10                 :             : 
      11                 :             : GCC is distributed in the hope that it will be useful, but WITHOUT ANY
      12                 :             : WARRANTY; without even the implied warranty of MERCHANTABILITY or
      13                 :             : FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
      14                 :             : for more details.
      15                 :             : 
      16                 :             : You should have received a copy of the GNU General Public License
      17                 :             : along with GCC; see the file COPYING3.  If not see
      18                 :             : <http://www.gnu.org/licenses/>.  */
      19                 :             : 
      20                 :             : 
      21                 :             : /* This file is part of the C front end.
      22                 :             :    It contains routines to build C expressions given their operands,
      23                 :             :    including computing the types of the result, C-specific error checks,
      24                 :             :    and some optimization.  */
      25                 :             : 
      26                 :             : #include "config.h"
      27                 :             : #include "system.h"
      28                 :             : #include "coretypes.h"
      29                 :             : #include "memmodel.h"
      30                 :             : #include "target.h"
      31                 :             : #include "function.h"
      32                 :             : #include "bitmap.h"
      33                 :             : #include "c-tree.h"
      34                 :             : #include "gimple-expr.h"
      35                 :             : #include "predict.h"
      36                 :             : #include "stor-layout.h"
      37                 :             : #include "trans-mem.h"
      38                 :             : #include "varasm.h"
      39                 :             : #include "stmt.h"
      40                 :             : #include "langhooks.h"
      41                 :             : #include "c-lang.h"
      42                 :             : #include "intl.h"
      43                 :             : #include "tree-iterator.h"
      44                 :             : #include "gimplify.h"
      45                 :             : #include "tree-inline.h"
      46                 :             : #include "omp-general.h"
      47                 :             : #include "c-family/c-objc.h"
      48                 :             : #include "c-family/c-ubsan.h"
      49                 :             : #include "gomp-constants.h"
      50                 :             : #include "spellcheck-tree.h"
      51                 :             : #include "c-family/c-type-mismatch.h"
      52                 :             : #include "stringpool.h"
      53                 :             : #include "attribs.h"
      54                 :             : #include "asan.h"
      55                 :             : #include "realmpfr.h"
      56                 :             : #include "tree-pretty-print-markup.h"
      57                 :             : #include "gcc-urlifier.h"
      58                 :             : 
      59                 :             : /* Possible cases of implicit conversions.  Used to select diagnostic messages
      60                 :             :    and control folding initializers in convert_for_assignment.  */
      61                 :             : enum impl_conv {
      62                 :             :   ic_argpass,
      63                 :             :   ic_assign,
      64                 :             :   ic_init,
      65                 :             :   ic_init_const,
      66                 :             :   ic_return
      67                 :             : };
      68                 :             : 
      69                 :             : /* The level of nesting inside "__alignof__".  */
      70                 :             : int in_alignof;
      71                 :             : 
      72                 :             : /* The level of nesting inside "sizeof".  */
      73                 :             : int in_sizeof;
      74                 :             : 
      75                 :             : /* The level of nesting inside "typeof".  */
      76                 :             : int in_typeof;
      77                 :             : 
      78                 :             : /* True when parsing OpenMP loop expressions.  */
      79                 :             : bool c_in_omp_for;
      80                 :             : 
      81                 :             : /* True when parsing OpenMP map clause.  */
      82                 :             : bool c_omp_array_section_p;
      83                 :             : 
      84                 :             : /* The argument of last parsed sizeof expression, only to be tested
      85                 :             :    if expr.original_code == SIZEOF_EXPR.  */
      86                 :             : tree c_last_sizeof_arg;
      87                 :             : location_t c_last_sizeof_loc;
      88                 :             : 
      89                 :             : /* Nonzero if we might need to print a "missing braces around
      90                 :             :    initializer" message within this initializer.  */
      91                 :             : static int found_missing_braces;
      92                 :             : 
      93                 :             : static bool require_constant_value;
      94                 :             : static bool require_constant_elements;
      95                 :             : static bool require_constexpr_value;
      96                 :             : 
      97                 :             : static tree qualify_type (tree, tree);
      98                 :             : struct comptypes_data;
      99                 :             : static bool tagged_types_tu_compatible_p (const_tree, const_tree,
     100                 :             :                                           struct comptypes_data *);
     101                 :             : static bool comp_target_types (location_t, tree, tree);
     102                 :             : static bool function_types_compatible_p (const_tree, const_tree,
     103                 :             :                                          struct comptypes_data *);
     104                 :             : static bool type_lists_compatible_p (const_tree, const_tree,
     105                 :             :                                      struct comptypes_data *);
     106                 :             : static int convert_arguments (location_t, vec<location_t>, tree,
     107                 :             :                               vec<tree, va_gc> *, vec<tree, va_gc> *, tree,
     108                 :             :                               tree);
     109                 :             : static tree pointer_diff (location_t, tree, tree, tree *);
     110                 :             : static tree convert_for_assignment (location_t, location_t, tree, tree, tree,
     111                 :             :                                     enum impl_conv, bool, tree, tree, int,
     112                 :             :                                     int = 0);
     113                 :             : static tree valid_compound_expr_initializer (tree, tree);
     114                 :             : static void push_string (const char *);
     115                 :             : static void push_member_name (tree);
     116                 :             : static int spelling_length (void);
     117                 :             : static char *print_spelling (char *);
     118                 :             : static void warning_init (location_t, int, const char *);
     119                 :             : static tree digest_init (location_t, tree, tree, tree, bool, bool, bool, bool,
     120                 :             :                          bool, bool);
     121                 :             : static void output_init_element (location_t, tree, tree, bool, tree, tree, bool,
     122                 :             :                                  bool, struct obstack *);
     123                 :             : static void output_pending_init_elements (int, struct obstack *);
     124                 :             : static bool set_designator (location_t, bool, struct obstack *);
     125                 :             : static void push_range_stack (tree, struct obstack *);
     126                 :             : static void add_pending_init (location_t, tree, tree, tree, bool,
     127                 :             :                               struct obstack *);
     128                 :             : static void set_nonincremental_init (struct obstack *);
     129                 :             : static void set_nonincremental_init_from_string (tree, struct obstack *);
     130                 :             : static tree find_init_member (tree, struct obstack *);
     131                 :             : static void readonly_warning (tree, enum lvalue_use);
     132                 :             : static int lvalue_or_else (location_t, const_tree, enum lvalue_use);
     133                 :             : static void record_maybe_used_decl (tree);
     134                 :             : static bool comptypes_internal (const_tree, const_tree,
     135                 :             :                                 struct comptypes_data *data);
     136                 :             : 
     137                 :             : /* Return true if EXP is a null pointer constant, false otherwise.  */
     138                 :             : 
     139                 :             : bool
     140                 :   192806920 : null_pointer_constant_p (const_tree expr)
     141                 :             : {
     142                 :             :   /* This should really operate on c_expr structures, but they aren't
     143                 :             :      yet available everywhere required.  */
     144                 :   192806920 :   tree type = TREE_TYPE (expr);
     145                 :             : 
     146                 :             :   /* An integer constant expression with the value 0, such an expression
     147                 :             :      cast to type void*, or the predefined constant nullptr, are a null
     148                 :             :      pointer constant.  */
     149                 :   192806920 :   if (expr == nullptr_node)
     150                 :             :     return true;
     151                 :             : 
     152                 :   192806289 :   return (TREE_CODE (expr) == INTEGER_CST
     153                 :    19152791 :           && !TREE_OVERFLOW (expr)
     154                 :    19152708 :           && integer_zerop (expr)
     155                 :   196668513 :           && (INTEGRAL_TYPE_P (type)
     156                 :      328060 :               || (TREE_CODE (type) == POINTER_TYPE
     157                 :      328058 :                   && VOID_TYPE_P (TREE_TYPE (type))
     158                 :      253043 :                   && TYPE_QUALS (TREE_TYPE (type)) == TYPE_UNQUALIFIED)));
     159                 :             : }
     160                 :             : 
     161                 :             : /* EXPR may appear in an unevaluated part of an integer constant
     162                 :             :    expression, but not in an evaluated part.  Wrap it in a
     163                 :             :    C_MAYBE_CONST_EXPR, or mark it with TREE_OVERFLOW if it is just an
     164                 :             :    INTEGER_CST and we cannot create a C_MAYBE_CONST_EXPR.  */
     165                 :             : 
     166                 :             : static tree
     167                 :       62358 : note_integer_operands (tree expr)
     168                 :             : {
     169                 :       62358 :   tree ret;
     170                 :       62358 :   if (TREE_CODE (expr) == INTEGER_CST && in_late_binary_op)
     171                 :             :     {
     172                 :          22 :       ret = copy_node (expr);
     173                 :          22 :       TREE_OVERFLOW (ret) = 1;
     174                 :             :     }
     175                 :             :   else
     176                 :             :     {
     177                 :       62336 :       ret = build2 (C_MAYBE_CONST_EXPR, TREE_TYPE (expr), NULL_TREE, expr);
     178                 :       62336 :       C_MAYBE_CONST_EXPR_INT_OPERANDS (ret) = 1;
     179                 :             :     }
     180                 :       62358 :   return ret;
     181                 :             : }
     182                 :             : 
     183                 :             : /* Having checked whether EXPR may appear in an unevaluated part of an
     184                 :             :    integer constant expression and found that it may, remove any
     185                 :             :    C_MAYBE_CONST_EXPR noting this fact and return the resulting
     186                 :             :    expression.  */
     187                 :             : 
     188                 :             : static inline tree
     189                 :    33648699 : remove_c_maybe_const_expr (tree expr)
     190                 :             : {
     191                 :    33648699 :   if (TREE_CODE (expr) == C_MAYBE_CONST_EXPR)
     192                 :       61506 :     return C_MAYBE_CONST_EXPR_EXPR (expr);
     193                 :             :   else
     194                 :             :     return expr;
     195                 :             : }
     196                 :             : 
     197                 :             : /* This is a cache to hold if two types are seen.  */
     198                 :             : 
     199                 :             : struct tagged_tu_seen_cache {
     200                 :             :   const struct tagged_tu_seen_cache * next;
     201                 :             :   const_tree t1;
     202                 :             :   const_tree t2;
     203                 :             : };
     204                 :             : 
     205                 :             : /* Do `exp = require_complete_type (loc, exp);' to make sure exp
     206                 :             :    does not have an incomplete type.  (That includes void types.)
     207                 :             :    LOC is the location of the use.  */
     208                 :             : 
     209                 :             : tree
     210                 :   792990607 : require_complete_type (location_t loc, tree value)
     211                 :             : {
     212                 :   792990607 :   tree type = TREE_TYPE (value);
     213                 :             : 
     214                 :   792990607 :   if (error_operand_p (value))
     215                 :        8967 :     return error_mark_node;
     216                 :             : 
     217                 :             :   /* First, detect a valid value with a complete type.  */
     218                 :   792981640 :   if (COMPLETE_TYPE_P (type))
     219                 :             :     return value;
     220                 :             : 
     221                 :         142 :   c_incomplete_type_error (loc, value, type);
     222                 :         142 :   return error_mark_node;
     223                 :             : }
     224                 :             : 
     225                 :             : /* Print an error message for invalid use of an incomplete type.
     226                 :             :    VALUE is the expression that was used (or 0 if that isn't known)
     227                 :             :    and TYPE is the type that was invalid.  LOC is the location for
     228                 :             :    the error.  */
     229                 :             : 
     230                 :             : void
     231                 :         198 : c_incomplete_type_error (location_t loc, const_tree value, const_tree type)
     232                 :             : {
     233                 :             :   /* Avoid duplicate error message.  */
     234                 :         198 :   if (TREE_CODE (type) == ERROR_MARK)
     235                 :             :     return;
     236                 :             : 
     237                 :         198 :   if (value != NULL_TREE && (VAR_P (value) || TREE_CODE (value) == PARM_DECL))
     238                 :          88 :     error_at (loc, "%qD has an incomplete type %qT", value, type);
     239                 :             :   else
     240                 :             :     {
     241                 :         110 :     retry:
     242                 :             :       /* We must print an error message.  Be clever about what it says.  */
     243                 :             : 
     244                 :         110 :       switch (TREE_CODE (type))
     245                 :             :         {
     246                 :          70 :         case RECORD_TYPE:
     247                 :          70 :         case UNION_TYPE:
     248                 :          70 :         case ENUMERAL_TYPE:
     249                 :          70 :           break;
     250                 :             : 
     251                 :          34 :         case VOID_TYPE:
     252                 :          34 :           error_at (loc, "invalid use of void expression");
     253                 :          34 :           return;
     254                 :             : 
     255                 :           6 :         case ARRAY_TYPE:
     256                 :           6 :           if (TYPE_DOMAIN (type))
     257                 :             :             {
     258                 :           3 :               if (TYPE_MAX_VALUE (TYPE_DOMAIN (type)) == NULL)
     259                 :             :                 {
     260                 :           3 :                   error_at (loc, "invalid use of flexible array member");
     261                 :           3 :                   return;
     262                 :             :                 }
     263                 :           0 :               type = TREE_TYPE (type);
     264                 :           0 :               goto retry;
     265                 :             :             }
     266                 :           3 :           error_at (loc, "invalid use of array with unspecified bounds");
     267                 :           3 :           return;
     268                 :             : 
     269                 :           0 :         default:
     270                 :           0 :           gcc_unreachable ();
     271                 :             :         }
     272                 :             : 
     273                 :          70 :       if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
     274                 :          68 :         error_at (loc, "invalid use of undefined type %qT", type);
     275                 :             :       else
     276                 :             :         /* If this type has a typedef-name, the TYPE_NAME is a TYPE_DECL.  */
     277                 :           2 :         error_at (loc, "invalid use of incomplete typedef %qT", type);
     278                 :             :     }
     279                 :             : }
     280                 :             : 
     281                 :             : /* Given a type, apply default promotions wrt unnamed function
     282                 :             :    arguments and return the new type.  */
     283                 :             : 
     284                 :             : tree
     285                 :   146059630 : c_type_promotes_to (tree type)
     286                 :             : {
     287                 :   146059630 :   tree ret = NULL_TREE;
     288                 :             : 
     289                 :   146059630 :   if (TYPE_MAIN_VARIANT (type) == float_type_node)
     290                 :     1418435 :     ret = double_type_node;
     291                 :   144641195 :   else if (c_promoting_integer_type_p (type))
     292                 :             :     {
     293                 :             :       /* Preserve unsignedness if not really getting any wider.  */
     294                 :    38498316 :       if (TYPE_UNSIGNED (type)
     295                 :    38498316 :           && (TYPE_PRECISION (type) == TYPE_PRECISION (integer_type_node)))
     296                 :           0 :         ret = unsigned_type_node;
     297                 :             :       else
     298                 :    38498316 :         ret = integer_type_node;
     299                 :             :     }
     300                 :             : 
     301                 :    39916751 :   if (ret != NULL_TREE)
     302                 :    39916751 :     return (TYPE_ATOMIC (type)
     303                 :    39916751 :             ? c_build_qualified_type (ret, TYPE_QUAL_ATOMIC)
     304                 :             :             : ret);
     305                 :             : 
     306                 :             :   return type;
     307                 :             : }
     308                 :             : 
     309                 :             : /* Return true if between two named address spaces, whether there is a superset
     310                 :             :    named address space that encompasses both address spaces.  If there is a
     311                 :             :    superset, return which address space is the superset.  */
     312                 :             : 
     313                 :             : static bool
     314                 :     6840536 : addr_space_superset (addr_space_t as1, addr_space_t as2, addr_space_t *common)
     315                 :             : {
     316                 :     6840536 :   if (as1 == as2)
     317                 :             :     {
     318                 :     6840536 :       *common = as1;
     319                 :     6840536 :       return true;
     320                 :             :     }
     321                 :           0 :   else if (targetm.addr_space.subset_p (as1, as2))
     322                 :             :     {
     323                 :           0 :       *common = as2;
     324                 :           0 :       return true;
     325                 :             :     }
     326                 :           0 :   else if (targetm.addr_space.subset_p (as2, as1))
     327                 :             :     {
     328                 :           0 :       *common = as1;
     329                 :           0 :       return true;
     330                 :             :     }
     331                 :             :   else
     332                 :             :     return false;
     333                 :             : }
     334                 :             : 
     335                 :             : /* Return a variant of TYPE which has all the type qualifiers of LIKE
     336                 :             :    as well as those of TYPE.  */
     337                 :             : 
     338                 :             : static tree
     339                 :     2174205 : qualify_type (tree type, tree like)
     340                 :             : {
     341                 :     2174205 :   addr_space_t as_type = TYPE_ADDR_SPACE (type);
     342                 :     2174205 :   addr_space_t as_like = TYPE_ADDR_SPACE (like);
     343                 :     2174205 :   addr_space_t as_common;
     344                 :             : 
     345                 :             :   /* If the two named address spaces are different, determine the common
     346                 :             :      superset address space.  If there isn't one, raise an error.  */
     347                 :     2174205 :   if (!addr_space_superset (as_type, as_like, &as_common))
     348                 :             :     {
     349                 :           0 :       as_common = as_type;
     350                 :           0 :       error ("%qT and %qT are in disjoint named address spaces",
     351                 :             :              type, like);
     352                 :             :     }
     353                 :             : 
     354                 :     4348410 :   return c_build_qualified_type (type,
     355                 :     2174205 :                                  TYPE_QUALS_NO_ADDR_SPACE (type)
     356                 :     2174205 :                                  | TYPE_QUALS_NO_ADDR_SPACE_NO_ATOMIC (like)
     357                 :     2174205 :                                  | ENCODE_QUAL_ADDR_SPACE (as_common));
     358                 :             : }
     359                 :             : 
     360                 :             : 
     361                 :             : /* Check consistency of type TYPE.  For derived types, we test that
     362                 :             :    C_TYPE_VARIABLE_SIZE and C_TYPE_VARIABLY_MODIFIED are consistent with
     363                 :             :    the requirements of the base type.  We also check that arrays with a
     364                 :             :    non-constant length are marked with C_TYPE_VARIABLE_SIZE. If any
     365                 :             :    inconsistency is detected false is returned and true otherwise.  */
     366                 :             : 
     367                 :             : static bool
     368                 :   137474310 : c_verify_type (tree type)
     369                 :             : {
     370                 :   137474310 :   switch (TREE_CODE (type))
     371                 :             :     {
     372                 :    64841534 :     case POINTER_TYPE:
     373                 :    64841534 :     case FUNCTION_TYPE:
     374                 :             :       /* Pointer and funcions can not have variable size.  */
     375                 :    64841534 :       if (C_TYPE_VARIABLE_SIZE (type))
     376                 :             :         return false;
     377                 :             :       /* Pointer and funcions are variably modified if and only if the
     378                 :             :          return / target type is variably modified.  */
     379                 :    64841534 :       if (C_TYPE_VARIABLY_MODIFIED (type)
     380                 :    64841534 :           != C_TYPE_VARIABLY_MODIFIED (TREE_TYPE (type)))
     381                 :           0 :         return false;
     382                 :             :       break;
     383                 :      889899 :     case ARRAY_TYPE:
     384                 :             :       /* An array has variable size if and only if it has a non-constant
     385                 :             :          dimensions or its element type has variable size.  */
     386                 :      889899 :       if ((C_TYPE_VARIABLE_SIZE (TREE_TYPE (type))
     387                 :      889899 :            || (TYPE_DOMAIN (type) && TYPE_MAX_VALUE (TYPE_DOMAIN (type))
     388                 :      864668 :                && TREE_CODE (TYPE_MAX_VALUE (TYPE_DOMAIN (type)))
     389                 :             :                   != INTEGER_CST))
     390                 :      889899 :           != C_TYPE_VARIABLE_SIZE (type))
     391                 :             :         return false;
     392                 :             :       /* If the element type or the array has variable size, then the
     393                 :             :          array has variable size and is variably modified.  */
     394                 :      889899 :       if (C_TYPE_VARIABLE_SIZE (TREE_TYPE (type))
     395                 :      889899 :           || C_TYPE_VARIABLE_SIZE (type))
     396                 :             :         {
     397                 :       27501 :           if (!C_TYPE_VARIABLE_SIZE (type))
     398                 :             :             return false;
     399                 :       27501 :           if (!C_TYPE_VARIABLY_MODIFIED (type))
     400                 :             :             return false;
     401                 :             :         }
     402                 :             :       /* If the element type is variably modified, then also the array.  */
     403                 :      889899 :       if (C_TYPE_VARIABLY_MODIFIED (TREE_TYPE (type))
     404                 :      889899 :           && !C_TYPE_VARIABLY_MODIFIED (type))
     405                 :           0 :         return false;
     406                 :             :       break;
     407                 :             :     default:
     408                 :             :       break;
     409                 :             :     }
     410                 :             :   return true;
     411                 :             : }
     412                 :             : 
     413                 :             : /* Propagate C_TYPE_VARIABLY_MODIFIED and C_TYPE_VARIABLE_SIZE
     414                 :             :    from a base type to a newly built derived or qualified type.  */
     415                 :             : 
     416                 :             : static tree
     417                 :   131389998 : c_set_type_bits (tree new_type, tree old_type)
     418                 :             : {
     419                 :   131389998 :   gcc_checking_assert (c_verify_type (old_type));
     420                 :             : 
     421                 :   131389998 :   if (C_TYPE_VARIABLY_MODIFIED (old_type))
     422                 :       27137 :     C_TYPE_VARIABLY_MODIFIED (new_type) = true;
     423                 :             : 
     424                 :   131389998 :   if (TREE_CODE (new_type) == ARRAY_TYPE && C_TYPE_VARIABLE_SIZE (old_type))
     425                 :             :     {
     426                 :       16703 :       C_TYPE_VARIABLY_MODIFIED (new_type) = true;
     427                 :       16703 :       C_TYPE_VARIABLE_SIZE (new_type) = true;
     428                 :             :     }
     429                 :   131389998 :   return new_type;
     430                 :             : }
     431                 :             : 
     432                 :             : /* Build a pointer type using the default pointer mode.  */
     433                 :             : 
     434                 :             : tree
     435                 :    71767923 : c_build_pointer_type (tree to_type)
     436                 :             : {
     437                 :    71767923 :   addr_space_t as = to_type == error_mark_node ? ADDR_SPACE_GENERIC
     438                 :    71767923 :                                                : TYPE_ADDR_SPACE (to_type);
     439                 :    71767923 :   machine_mode pointer_mode;
     440                 :             : 
     441                 :    71767923 :   if (as != ADDR_SPACE_GENERIC || c_default_pointer_mode == VOIDmode)
     442                 :    71767923 :     pointer_mode = targetm.addr_space.pointer_mode (as);
     443                 :             :   else
     444                 :             :     pointer_mode = c_default_pointer_mode;
     445                 :             : 
     446                 :    71767923 :   return c_build_pointer_type_for_mode (to_type, pointer_mode, false);
     447                 :             : }
     448                 :             : 
     449                 :             : /* Build a pointer type using the given mode.  */
     450                 :             : 
     451                 :             : tree
     452                 :    71776619 : c_build_pointer_type_for_mode (tree type, machine_mode mode, bool m)
     453                 :             : {
     454                 :    71776619 :   tree ret = build_pointer_type_for_mode (type, mode, m);
     455                 :    71776619 :   return c_set_type_bits (ret, type);
     456                 :             : }
     457                 :             : 
     458                 :             : /* Build a function type.  */
     459                 :             : 
     460                 :             : tree
     461                 :    52387695 : c_build_function_type (tree type, tree args, bool no)
     462                 :             : {
     463                 :    52387695 :   tree ret = build_function_type (type, args, no);
     464                 :    52387695 :   return c_set_type_bits (ret, type);
     465                 :             : }
     466                 :             : 
     467                 :             : /* Build an array type.  This sets typeless storage as required
     468                 :             :    by C2Y and C_TYPE_VARIABLY_MODIFIED and C_TYPE_VARIABLE_SIZE
     469                 :             :    based on the element type and domain.  */
     470                 :             : 
     471                 :             : tree
     472                 :     1130179 : c_build_array_type (tree type, tree domain)
     473                 :             : {
     474                 :     1130179 :   int type_quals = TYPE_QUALS (type);
     475                 :             : 
     476                 :             :   /* Identify typeless storage as introduced in C2Y
     477                 :             :      and supported also in earlier language modes.  */
     478                 :     1694109 :   bool typeless = (char_type_p (type) && !(type_quals & TYPE_QUAL_ATOMIC))
     479                 :     1130179 :                   || (AGGREGATE_TYPE_P (type) && TYPE_TYPELESS_STORAGE (type));
     480                 :             : 
     481                 :     1130179 :   tree ret = build_array_type (type, domain, typeless);
     482                 :             : 
     483                 :     1046518 :   if (domain && TYPE_MAX_VALUE (domain)
     484                 :     2092754 :       && TREE_CODE (TYPE_MAX_VALUE (domain)) != INTEGER_CST)
     485                 :             :     {
     486                 :       23755 :       C_TYPE_VARIABLE_SIZE (ret) = 1;
     487                 :       23755 :       C_TYPE_VARIABLY_MODIFIED (ret) = 1;
     488                 :             :     }
     489                 :             : 
     490                 :     1130179 :   return c_set_type_bits (ret, type);
     491                 :             : }
     492                 :             : 
     493                 :             : 
     494                 :             : /* Build an array type of unspecified size.  */
     495                 :             : tree
     496                 :         134 : c_build_array_type_unspecified (tree type)
     497                 :             : {
     498                 :         134 :   tree upper = build2 (COMPOUND_EXPR, TREE_TYPE (size_zero_node),
     499                 :             :                        integer_zero_node, size_zero_node);
     500                 :         134 :   return c_build_array_type (type, build_index_type (upper));
     501                 :             : }
     502                 :             : 
     503                 :             : 
     504                 :             : tree
     505                 :     6095505 : c_build_type_attribute_qual_variant (tree type, tree attrs, int quals)
     506                 :             : {
     507                 :     6095505 :   tree ret = build_type_attribute_qual_variant (type, attrs, quals);
     508                 :     6095505 :   return c_set_type_bits (ret, type);
     509                 :             : }
     510                 :             : 
     511                 :             : tree
     512                 :     6095307 : c_build_type_attribute_variant (tree type, tree attrs)
     513                 :             : {
     514                 :     6095307 :   return c_build_type_attribute_qual_variant (type, attrs, TYPE_QUALS (type));
     515                 :             : }
     516                 :             : 
     517                 :             : /* Reconstruct a complex derived type.  This is used to re-construct types
     518                 :             :    with the vector attribute.  It is called via a langhook.  */
     519                 :             : 
     520                 :             : tree
     521                 :      484561 : c_reconstruct_complex_type (tree type, tree bottom)
     522                 :             : {
     523                 :      484561 :   tree inner, outer;
     524                 :             : 
     525                 :      484561 :   if (TREE_CODE (type) == POINTER_TYPE)
     526                 :             :     {
     527                 :          16 :       inner = c_reconstruct_complex_type (TREE_TYPE (type), bottom);
     528                 :          16 :       outer = c_build_pointer_type_for_mode (inner, TYPE_MODE (type),
     529                 :          16 :                                              TYPE_REF_CAN_ALIAS_ALL (type));
     530                 :             :     }
     531                 :             :   else if (TREE_CODE (type) == ARRAY_TYPE)
     532                 :             :     {
     533                 :          13 :       inner = c_reconstruct_complex_type (TREE_TYPE (type), bottom);
     534                 :          13 :       outer = c_build_array_type (inner, TYPE_DOMAIN (type));
     535                 :             : 
     536                 :          13 :       gcc_checking_assert (C_TYPE_VARIABLE_SIZE (type)
     537                 :             :                            == C_TYPE_VARIABLE_SIZE (outer));
     538                 :          13 :       gcc_checking_assert (C_TYPE_VARIABLY_MODIFIED (outer)
     539                 :             :                            == C_TYPE_VARIABLY_MODIFIED (type));
     540                 :             :     }
     541                 :             :   else if (TREE_CODE (type) == FUNCTION_TYPE)
     542                 :             :     {
     543                 :         169 :       inner = c_reconstruct_complex_type (TREE_TYPE (type), bottom);
     544                 :         169 :       outer = c_build_function_type (inner, TYPE_ARG_TYPES (type),
     545                 :         169 :                                      TYPE_NO_NAMED_ARGS_STDARG_P (type));
     546                 :             :     }
     547                 :             :   else if (TREE_CODE (type) == REFERENCE_TYPE
     548                 :             :            || TREE_CODE (type) == OFFSET_TYPE)
     549                 :           0 :     gcc_unreachable ();
     550                 :             :   else
     551                 :             :     return bottom;
     552                 :             : 
     553                 :         198 :   return c_build_type_attribute_qual_variant (outer, TYPE_ATTRIBUTES (type),
     554                 :         396 :                                               TYPE_QUALS (type));
     555                 :             : }
     556                 :             : 
     557                 :             : /* If NTYPE is a type of a non-variadic function with a prototype
     558                 :             :    and OTYPE is a type of a function without a prototype and ATTRS
     559                 :             :    contains attribute format, diagnosess and removes it from ATTRS.
     560                 :             :    Returns the result of build_type_attribute_variant of NTYPE and
     561                 :             :    the (possibly) modified ATTRS.  */
     562                 :             : 
     563                 :             : static tree
     564                 :        9448 : c_build_functype_attribute_variant (tree ntype, tree otype, tree attrs)
     565                 :             : {
     566                 :        9448 :   if (!prototype_p (otype)
     567                 :        9436 :       && prototype_p (ntype)
     568                 :       18854 :       && lookup_attribute ("format", attrs))
     569                 :             :     {
     570                 :          14 :       warning_at (input_location, OPT_Wattributes,
     571                 :             :                   "%qs attribute can only be applied to variadic functions",
     572                 :             :                   "format");
     573                 :          14 :       attrs = remove_attribute ("format", attrs);
     574                 :             :     }
     575                 :        9448 :   return c_build_type_attribute_variant (ntype, attrs);
     576                 :             : 
     577                 :             : }
     578                 :             : 
     579                 :             : /* Given a type which could be a typedef name, make sure to return the
     580                 :             :    original type.  */
     581                 :             : static const_tree
     582                 :    45612178 : c_type_original (const_tree t)
     583                 :             : {
     584                 :             :   /* It may even be a typedef of a typedef...
     585                 :             :      In the case of compiler-created builtin structs the TYPE_DECL
     586                 :             :      may be a dummy, with no DECL_ORIGINAL_TYPE.  Don't fault.  */
     587                 :    45612178 :   while (TYPE_NAME (t)
     588                 :    24138857 :          && TREE_CODE (TYPE_NAME (t)) == TYPE_DECL
     589                 :    45615016 :          && DECL_ORIGINAL_TYPE (TYPE_NAME (t)))
     590                 :        1419 :     t = DECL_ORIGINAL_TYPE (TYPE_NAME (t));
     591                 :    45612178 :   return t;
     592                 :             : }
     593                 :             : 
     594                 :             : 
     595                 :             : /* Return the composite type of two compatible types.
     596                 :             : 
     597                 :             :    We assume that comptypes has already been done and returned
     598                 :             :    nonzero; if that isn't so, this may crash.  In particular, we
     599                 :             :    assume that qualifiers match.  */
     600                 :             : 
     601                 :             : struct composite_cache {
     602                 :             :   tree t1;
     603                 :             :   tree t2;
     604                 :             :   tree composite;
     605                 :             :   struct composite_cache* next;
     606                 :             : };
     607                 :             : 
     608                 :             : tree
     609                 :    11151609 : composite_type_internal (tree t1, tree t2, struct composite_cache* cache)
     610                 :             : {
     611                 :    11151609 :   enum tree_code code1;
     612                 :    11151609 :   enum tree_code code2;
     613                 :    11151609 :   tree attributes;
     614                 :             : 
     615                 :             :   /* Save time if the two types are the same.  */
     616                 :             : 
     617                 :    11151609 :   if (t1 == t2) return t1;
     618                 :             : 
     619                 :             :   /* If one type is nonsense, use the other.  */
     620                 :     2200835 :   if (t1 == error_mark_node)
     621                 :             :     return t2;
     622                 :     2200831 :   if (t2 == error_mark_node)
     623                 :             :     return t1;
     624                 :             : 
     625                 :     2200829 :   code1 = TREE_CODE (t1);
     626                 :     2200829 :   code2 = TREE_CODE (t2);
     627                 :             : 
     628                 :             :   /* Merge the attributes.  */
     629                 :     2200829 :   attributes = targetm.merge_type_attributes (t1, t2);
     630                 :             : 
     631                 :             :   /* If one is an enumerated type and the other is the compatible
     632                 :             :      integer type, the composite type might be either of the two
     633                 :             :      (DR#013 question 3).  For consistency, use the enumerated type as
     634                 :             :      the composite type.  */
     635                 :             : 
     636                 :     2200829 :   if (code1 == ENUMERAL_TYPE
     637                 :         195 :       && (code2 == INTEGER_TYPE
     638                 :         195 :           || code2 == BOOLEAN_TYPE))
     639                 :             :     return t1;
     640                 :     2200634 :   if (code2 == ENUMERAL_TYPE
     641                 :          69 :       && (code1 == INTEGER_TYPE
     642                 :          69 :           || code1 == BOOLEAN_TYPE))
     643                 :             :     return t2;
     644                 :             : 
     645                 :     2200565 :   gcc_assert (code1 == code2);
     646                 :             : 
     647                 :     2200565 :   switch (code1)
     648                 :             :     {
     649                 :        6302 :     case POINTER_TYPE:
     650                 :             :       /* For two pointers, do this recursively on the target type.  */
     651                 :        6302 :       {
     652                 :        6302 :         tree pointed_to_1 = TREE_TYPE (t1);
     653                 :        6302 :         tree pointed_to_2 = TREE_TYPE (t2);
     654                 :        6302 :         tree target = composite_type_internal (pointed_to_1,
     655                 :             :                                                pointed_to_2, cache);
     656                 :        6302 :         t1 = c_build_pointer_type_for_mode (target, TYPE_MODE (t1), false);
     657                 :        6302 :         t1 = c_build_type_attribute_variant (t1, attributes);
     658                 :        6302 :         return qualify_type (t1, t2);
     659                 :             :       }
     660                 :             : 
     661                 :       11017 :     case ARRAY_TYPE:
     662                 :       11017 :       {
     663                 :       11017 :         tree elt = composite_type_internal (TREE_TYPE (t1), TREE_TYPE (t2),
     664                 :             :                                             cache);
     665                 :       11017 :         int quals;
     666                 :       11017 :         tree unqual_elt;
     667                 :       11017 :         tree d1 = TYPE_DOMAIN (t1);
     668                 :       11017 :         tree d2 = TYPE_DOMAIN (t2);
     669                 :       11017 :         bool d1_variable, d2_variable;
     670                 :       11017 :         bool d1_zero, d2_zero;
     671                 :       11017 :         bool t1_complete, t2_complete;
     672                 :             : 
     673                 :             :         /* We should not have any type quals on arrays at all.  */
     674                 :       11017 :         gcc_assert (!TYPE_QUALS_NO_ADDR_SPACE (t1)
     675                 :             :                     && !TYPE_QUALS_NO_ADDR_SPACE (t2));
     676                 :             : 
     677                 :       11017 :         t1_complete = COMPLETE_TYPE_P (t1);
     678                 :       11017 :         t2_complete = COMPLETE_TYPE_P (t2);
     679                 :             : 
     680                 :       11017 :         d1_zero = d1 == NULL_TREE || !TYPE_MAX_VALUE (d1);
     681                 :       11017 :         d2_zero = d2 == NULL_TREE || !TYPE_MAX_VALUE (d2);
     682                 :             : 
     683                 :       22034 :         d1_variable = (!d1_zero
     684                 :       11017 :                        && (TREE_CODE (TYPE_MIN_VALUE (d1)) != INTEGER_CST
     685                 :       10432 :                            || TREE_CODE (TYPE_MAX_VALUE (d1)) != INTEGER_CST));
     686                 :       22034 :         d2_variable = (!d2_zero
     687                 :       11017 :                        && (TREE_CODE (TYPE_MIN_VALUE (d2)) != INTEGER_CST
     688                 :       10690 :                            || TREE_CODE (TYPE_MAX_VALUE (d2)) != INTEGER_CST));
     689                 :             : 
     690                 :       11017 :         bool use1 = TYPE_DOMAIN (t1)
     691                 :       11017 :                     && (d2_variable || d2_zero || !d1_variable);
     692                 :       11017 :         bool use2 = TYPE_DOMAIN (t2)
     693                 :       11017 :                     && (d1_variable || d1_zero || !d2_variable);
     694                 :             : 
     695                 :             :         /* If the first is an unspecified size pick the other one.  */
     696                 :        8928 :         if (d2_variable && c_type_unspecified_p (t1))
     697                 :             :           {
     698                 :          28 :             gcc_assert (use1 && use2);
     699                 :             :             use1 = false;
     700                 :             :           }
     701                 :             : 
     702                 :             :         /* Save space: see if the result is identical to one of the args.  */
     703                 :       11017 :         if (elt == TREE_TYPE (t1) && use1)
     704                 :       10231 :           return c_build_type_attribute_variant (t1, attributes);
     705                 :         786 :         if (elt == TREE_TYPE (t2) && use2)
     706                 :         673 :           return c_build_type_attribute_variant (t2, attributes);
     707                 :             : 
     708                 :         156 :         if (elt == TREE_TYPE (t1) && !TYPE_DOMAIN (t2) && !TYPE_DOMAIN (t1))
     709                 :          10 :           return c_build_type_attribute_variant (t1, attributes);
     710                 :         111 :         if (elt == TREE_TYPE (t2) && !TYPE_DOMAIN (t2) && !TYPE_DOMAIN (t1))
     711                 :           2 :           return c_build_type_attribute_variant (t2, attributes);
     712                 :             : 
     713                 :             :         /* Merge the element types, and have a size if either arg has
     714                 :             :            one.  We may have qualifiers on the element types.  To set
     715                 :             :            up TYPE_MAIN_VARIANT correctly, we need to form the
     716                 :             :            composite of the unqualified types and add the qualifiers
     717                 :             :            back at the end.  */
     718                 :         101 :         quals = TYPE_QUALS (strip_array_types (elt));
     719                 :         101 :         unqual_elt = c_build_qualified_type (elt, TYPE_UNQUALIFIED);
     720                 :         202 :         t1 = c_build_array_type (unqual_elt, TYPE_DOMAIN (use1 ? t1 : t2));
     721                 :             : 
     722                 :             :         /* Check that a type which has a varying outermost dimension
     723                 :             :            got marked has having a variable size.  */
     724                 :         101 :         bool varsize = (d1_variable && d2_variable)
     725                 :          81 :                        || (d1_variable && !t2_complete)
     726                 :         171 :                        || (d2_variable && !t1_complete);
     727                 :          51 :         gcc_checking_assert (!varsize || C_TYPE_VARIABLE_SIZE (t1));
     728                 :             : 
     729                 :             :         /* Ensure a composite type involving a zero-length array type
     730                 :             :            is a zero-length type not an incomplete type.  */
     731                 :         101 :         if (d1_zero && d2_zero
     732                 :          16 :             && (t1_complete || t2_complete)
     733                 :         102 :             && !COMPLETE_TYPE_P (t1))
     734                 :             :           {
     735                 :           1 :             TYPE_SIZE (t1) = bitsize_zero_node;
     736                 :           1 :             TYPE_SIZE_UNIT (t1) = size_zero_node;
     737                 :             :           }
     738                 :         101 :         t1 = c_build_qualified_type (t1, quals);
     739                 :         101 :         return c_build_type_attribute_variant (t1, attributes);
     740                 :             :       }
     741                 :             : 
     742                 :         119 :     case RECORD_TYPE:
     743                 :         119 :     case UNION_TYPE:
     744                 :         119 :       if (flag_isoc23 && !comptypes_same_p (t1, t2))
     745                 :             :         {
     746                 :             :           /* Go to the original type to get the right tag.  */
     747                 :          72 :           tree tag = TYPE_NAME (c_type_original (const_cast<tree> (t1)));
     748                 :             : 
     749                 :          72 :           gcc_checking_assert (COMPLETE_TYPE_P (t1) && COMPLETE_TYPE_P (t2));
     750                 :          72 :           gcc_checking_assert (!tag || comptypes (t1, t2));
     751                 :             : 
     752                 :             :           /* If a composite type for these two types is already under
     753                 :             :              construction, return it.  */
     754                 :             : 
     755                 :         156 :           for (struct composite_cache *c = cache; c != NULL; c = c->next)
     756                 :          84 :             if (c->t1 == t1 && c->t2 == t2)
     757                 :           0 :                return c->composite;
     758                 :             : 
     759                 :             :           /* Otherwise, create a new type node and link it into the cache.  */
     760                 :             : 
     761                 :          72 :           tree n = make_node (code1);
     762                 :          72 :           SET_TYPE_STRUCTURAL_EQUALITY (n);
     763                 :          72 :           TYPE_NAME (n) = tag;
     764                 :             : 
     765                 :          72 :           struct composite_cache cache2 = { t1, t2, n, cache };
     766                 :          72 :           cache = &cache2;
     767                 :             : 
     768                 :          72 :           tree f1 = TYPE_FIELDS (t1);
     769                 :          72 :           tree f2 = TYPE_FIELDS (t2);
     770                 :          72 :           tree fields = NULL_TREE;
     771                 :             : 
     772                 :         170 :           for (tree a = f1, b = f2; a && b;
     773                 :          98 :                a = DECL_CHAIN (a), b = DECL_CHAIN (b))
     774                 :             :             {
     775                 :          98 :               tree ta = TREE_TYPE (a);
     776                 :          98 :               tree tb = TREE_TYPE (b);
     777                 :             : 
     778                 :          98 :               if (DECL_C_BIT_FIELD (a))
     779                 :             :                 {
     780                 :          19 :                   ta = DECL_BIT_FIELD_TYPE (a);
     781                 :          19 :                   tb = DECL_BIT_FIELD_TYPE (b);
     782                 :             :                 }
     783                 :             : 
     784                 :          98 :               gcc_assert (DECL_NAME (a) == DECL_NAME (b));
     785                 :          98 :               gcc_checking_assert (!DECL_NAME (a) || comptypes (ta, tb));
     786                 :             : 
     787                 :          98 :               tree t = composite_type_internal (ta, tb, cache);
     788                 :          98 :               tree f = build_decl (input_location, FIELD_DECL, DECL_NAME (a), t);
     789                 :             : 
     790                 :          98 :               DECL_PACKED (f) = DECL_PACKED (a);
     791                 :          98 :               SET_DECL_ALIGN (f, DECL_ALIGN (a));
     792                 :          98 :               DECL_ATTRIBUTES (f) = DECL_ATTRIBUTES (a);
     793                 :          98 :               C_DECL_VARIABLE_SIZE (f) = C_TYPE_VARIABLE_SIZE (t);
     794                 :             : 
     795                 :          98 :               decl_attributes (&f, DECL_ATTRIBUTES (f), 0);
     796                 :             : 
     797                 :          98 :               finish_decl (f, input_location, NULL, NULL, NULL);
     798                 :             : 
     799                 :          98 :               if (DECL_C_BIT_FIELD (a))
     800                 :             :                 {
     801                 :             :                   /* This will be processed by finish_struct.  */
     802                 :          19 :                   SET_DECL_C_BIT_FIELD (f);
     803                 :          19 :                   DECL_INITIAL (f) = build_int_cst (integer_type_node,
     804                 :          19 :                                                     tree_to_uhwi (DECL_SIZE (a)));
     805                 :          19 :                   DECL_NONADDRESSABLE_P (f) = true;
     806                 :          19 :                   DECL_PADDING_P (f) = !DECL_NAME (a);
     807                 :             :                 }
     808                 :             : 
     809                 :          98 :               DECL_CHAIN (f) = fields;
     810                 :          98 :               fields = f;
     811                 :             :             }
     812                 :             : 
     813                 :          72 :           fields = nreverse (fields);
     814                 :             : 
     815                 :             :           /* Setup the struct/union type.  Because we inherit all variably
     816                 :             :              modified components, we can ignore the size expression.  */
     817                 :          72 :           tree expr = NULL_TREE;
     818                 :             : 
     819                 :             :           /* Set TYPE_STUB_DECL for debugging symbols.  */
     820                 :          72 :           TYPE_STUB_DECL (n) = pushdecl (build_decl (input_location, TYPE_DECL,
     821                 :             :                                                      NULL_TREE, n));
     822                 :             : 
     823                 :          72 :           n = finish_struct (input_location, n, fields, attributes, NULL,
     824                 :             :                              &expr);
     825                 :             : 
     826                 :          72 :           n = qualify_type (n, t1);
     827                 :             : 
     828                 :          72 :           gcc_checking_assert (!TYPE_NAME (n) || comptypes (n, t1));
     829                 :          72 :           gcc_checking_assert (!TYPE_NAME (n) || comptypes (n, t2));
     830                 :             : 
     831                 :          72 :           return n;
     832                 :             :         }
     833                 :             :       /* FALLTHRU */
     834                 :          47 :     case ENUMERAL_TYPE:
     835                 :          47 :       if (attributes != NULL)
     836                 :             :         {
     837                 :             :           /* Try harder not to create a new aggregate type.  */
     838                 :           4 :           if (attribute_list_equal (TYPE_ATTRIBUTES (t1), attributes))
     839                 :             :             return t1;
     840                 :           0 :           if (attribute_list_equal (TYPE_ATTRIBUTES (t2), attributes))
     841                 :             :             return t2;
     842                 :             :         }
     843                 :          43 :       return c_build_type_attribute_variant (t1, attributes);
     844                 :             : 
     845                 :     2142540 :     case FUNCTION_TYPE:
     846                 :             :       /* Function types: prefer the one that specified arg types.
     847                 :             :          If both do, merge the arg types.  Also merge the return types.  */
     848                 :     2142540 :       {
     849                 :     2142540 :         tree valtype = composite_type_internal (TREE_TYPE (t1),
     850                 :     2142540 :                                                 TREE_TYPE (t2), cache);
     851                 :     2142540 :         tree p1 = TYPE_ARG_TYPES (t1);
     852                 :     2142540 :         tree p2 = TYPE_ARG_TYPES (t2);
     853                 :     2142540 :         int len;
     854                 :     2142540 :         tree newargs, n;
     855                 :     2142540 :         int i;
     856                 :             : 
     857                 :             :         /* Save space: see if the result is identical to one of the args.  */
     858                 :     2142540 :         if (valtype == TREE_TYPE (t1) && !TYPE_ARG_TYPES (t2))
     859                 :        8931 :           return c_build_functype_attribute_variant (t1, t2, attributes);
     860                 :     2133609 :         if (valtype == TREE_TYPE (t2) && !TYPE_ARG_TYPES (t1))
     861                 :         517 :           return c_build_functype_attribute_variant (t2, t1, attributes);
     862                 :             : 
     863                 :             :         /* Simple way if one arg fails to specify argument types.  */
     864                 :     2133092 :         if (TYPE_ARG_TYPES (t1) == NULL_TREE)
     865                 :             :           {
     866                 :           9 :             t1 = c_build_function_type (valtype, TYPE_ARG_TYPES (t2),
     867                 :           9 :                                         TYPE_NO_NAMED_ARGS_STDARG_P (t2));
     868                 :           9 :             t1 = c_build_type_attribute_variant (t1, attributes);
     869                 :           9 :             return qualify_type (t1, t2);
     870                 :             :          }
     871                 :     2133083 :         if (TYPE_ARG_TYPES (t2) == NULL_TREE)
     872                 :             :           {
     873                 :           1 :             t1 = c_build_function_type (valtype, TYPE_ARG_TYPES (t1),
     874                 :           1 :                                         TYPE_NO_NAMED_ARGS_STDARG_P (t1));
     875                 :           1 :             t1 = c_build_type_attribute_variant (t1, attributes);
     876                 :           1 :             return qualify_type (t1, t2);
     877                 :             :           }
     878                 :             : 
     879                 :             :         /* If both args specify argument types, we must merge the two
     880                 :             :            lists, argument by argument.  */
     881                 :             : 
     882                 :             :         for (len = 0, newargs = p1;
     883                 :     5763017 :              newargs && newargs != void_list_node;
     884                 :     3629935 :              len++, newargs = TREE_CHAIN (newargs))
     885                 :             :           ;
     886                 :             : 
     887                 :     5763017 :         for (i = 0; i < len; i++)
     888                 :     3629935 :           newargs = tree_cons (NULL_TREE, NULL_TREE, newargs);
     889                 :             : 
     890                 :             :         n = newargs;
     891                 :             : 
     892                 :     5763017 :         for (; p1 && p1 != void_list_node;
     893                 :     3629935 :              p1 = TREE_CHAIN (p1), p2 = TREE_CHAIN (p2), n = TREE_CHAIN (n))
     894                 :             :           {
     895                 :     3629935 :              tree mv1 = TREE_VALUE (p1);
     896                 :     3629935 :              if (mv1 && mv1 != error_mark_node
     897                 :     3629932 :                  && TREE_CODE (mv1) != ARRAY_TYPE)
     898                 :     3629932 :                mv1 = TYPE_MAIN_VARIANT (mv1);
     899                 :             : 
     900                 :     3629935 :              tree mv2 = TREE_VALUE (p2);
     901                 :     3629935 :              if (mv2 && mv2 != error_mark_node
     902                 :     3629933 :                  && TREE_CODE (mv2) != ARRAY_TYPE)
     903                 :     3629933 :                mv2 = TYPE_MAIN_VARIANT (mv2);
     904                 :             : 
     905                 :             :             /* A null type means arg type is not specified.
     906                 :             :                Take whatever the other function type has.  */
     907                 :     3629935 :             if (TREE_VALUE (p1) == NULL_TREE)
     908                 :             :               {
     909                 :           0 :                 TREE_VALUE (n) = TREE_VALUE (p2);
     910                 :           0 :                 goto parm_done;
     911                 :             :               }
     912                 :     3629935 :             if (TREE_VALUE (p2) == NULL_TREE)
     913                 :             :               {
     914                 :           0 :                 TREE_VALUE (n) = TREE_VALUE (p1);
     915                 :           0 :                 goto parm_done;
     916                 :             :               }
     917                 :             : 
     918                 :             :             /* Given  wait (union {union wait *u; int *i} *)
     919                 :             :                and  wait (union wait *),
     920                 :             :                prefer  union wait *  as type of parm.  */
     921                 :     3629935 :             if (TREE_CODE (TREE_VALUE (p1)) == UNION_TYPE
     922                 :     3629935 :                 && TREE_VALUE (p1) != TREE_VALUE (p2))
     923                 :             :               {
     924                 :          30 :                 tree memb;
     925                 :          30 :                 for (memb = TYPE_FIELDS (TREE_VALUE (p1));
     926                 :          38 :                      memb; memb = DECL_CHAIN (memb))
     927                 :             :                   {
     928                 :          38 :                     tree mv3 = TREE_TYPE (memb);
     929                 :          38 :                     if (mv3 && mv3 != error_mark_node
     930                 :          38 :                         && TREE_CODE (mv3) != ARRAY_TYPE)
     931                 :          38 :                       mv3 = TYPE_MAIN_VARIANT (mv3);
     932                 :          38 :                     if (comptypes (mv3, mv2))
     933                 :             :                       {
     934                 :          60 :                         TREE_VALUE (n) = composite_type_internal (TREE_TYPE (memb),
     935                 :          30 :                                                                   TREE_VALUE (p2),
     936                 :             :                                                                   cache);
     937                 :          30 :                         pedwarn (input_location, OPT_Wpedantic,
     938                 :             :                                  "function types not truly compatible in ISO C");
     939                 :          30 :                         goto parm_done;
     940                 :             :                       }
     941                 :             :                   }
     942                 :             :               }
     943                 :     3629905 :             if (TREE_CODE (TREE_VALUE (p2)) == UNION_TYPE
     944                 :     3629905 :                 && TREE_VALUE (p2) != TREE_VALUE (p1))
     945                 :             :               {
     946                 :          30 :                 tree memb;
     947                 :          30 :                 for (memb = TYPE_FIELDS (TREE_VALUE (p2));
     948                 :          38 :                      memb; memb = DECL_CHAIN (memb))
     949                 :             :                   {
     950                 :          38 :                     tree mv3 = TREE_TYPE (memb);
     951                 :          38 :                     if (mv3 && mv3 != error_mark_node
     952                 :          38 :                         && TREE_CODE (mv3) != ARRAY_TYPE)
     953                 :          38 :                       mv3 = TYPE_MAIN_VARIANT (mv3);
     954                 :          38 :                     if (comptypes (mv3, mv1))
     955                 :             :                       {
     956                 :          30 :                         TREE_VALUE (n)
     957                 :          30 :                                 = composite_type_internal (TREE_TYPE (memb),
     958                 :          30 :                                                            TREE_VALUE (p1),
     959                 :             :                                                            cache);
     960                 :          30 :                         pedwarn (input_location, OPT_Wpedantic,
     961                 :             :                                  "function types not truly compatible in ISO C");
     962                 :          30 :                         goto parm_done;
     963                 :             :                       }
     964                 :             :                   }
     965                 :             :               }
     966                 :     3629875 :             TREE_VALUE (n) = composite_type_internal (mv1, mv2, cache);
     967                 :     3629935 :           parm_done: ;
     968                 :             :           }
     969                 :             : 
     970                 :     2133082 :         t1 = c_build_function_type (valtype, newargs);
     971                 :     2133082 :         t1 = qualify_type (t1, t2);
     972                 :             :       }
     973                 :             :       /* FALLTHRU */
     974                 :             : 
     975                 :     2173669 :     default:
     976                 :     2173669 :       return c_build_type_attribute_variant (t1, attributes);
     977                 :             :     }
     978                 :             : }
     979                 :             : 
     980                 :             : tree
     981                 :     5361717 : composite_type (tree t1, tree t2)
     982                 :             : {
     983                 :     5361717 :   struct composite_cache cache = { };
     984                 :     5361717 :   return composite_type_internal (t1, t2, &cache);
     985                 :             : }
     986                 :             : 
     987                 :             : /* Return the type of a conditional expression between pointers to
     988                 :             :    possibly differently qualified versions of compatible types.
     989                 :             : 
     990                 :             :    We assume that comp_target_types has already been done and returned
     991                 :             :    true; if that isn't so, this may crash.  */
     992                 :             : 
     993                 :             : static tree
     994                 :      112715 : common_pointer_type (tree t1, tree t2)
     995                 :             : {
     996                 :      112715 :   tree attributes;
     997                 :      112715 :   tree pointed_to_1, mv1;
     998                 :      112715 :   tree pointed_to_2, mv2;
     999                 :      112715 :   tree target;
    1000                 :      112715 :   unsigned target_quals;
    1001                 :      112715 :   addr_space_t as1, as2, as_common;
    1002                 :      112715 :   int quals1, quals2;
    1003                 :             : 
    1004                 :             :   /* Save time if the two types are the same.  */
    1005                 :             : 
    1006                 :      112715 :   if (t1 == t2) return t1;
    1007                 :             : 
    1008                 :             :   /* If one type is nonsense, use the other.  */
    1009                 :        4375 :   if (t1 == error_mark_node)
    1010                 :             :     return t2;
    1011                 :        4375 :   if (t2 == error_mark_node)
    1012                 :             :     return t1;
    1013                 :             : 
    1014                 :        4375 :   gcc_assert (TREE_CODE (t1) == POINTER_TYPE
    1015                 :             :               && TREE_CODE (t2) == POINTER_TYPE);
    1016                 :             : 
    1017                 :             :   /* Merge the attributes.  */
    1018                 :        4375 :   attributes = targetm.merge_type_attributes (t1, t2);
    1019                 :             : 
    1020                 :             :   /* Find the composite type of the target types, and combine the
    1021                 :             :      qualifiers of the two types' targets.  Do not lose qualifiers on
    1022                 :             :      array element types by taking the TYPE_MAIN_VARIANT.  */
    1023                 :        4375 :   mv1 = pointed_to_1 = TREE_TYPE (t1);
    1024                 :        4375 :   mv2 = pointed_to_2 = TREE_TYPE (t2);
    1025                 :        4375 :   if (TREE_CODE (mv1) != ARRAY_TYPE)
    1026                 :        3991 :     mv1 = TYPE_MAIN_VARIANT (pointed_to_1);
    1027                 :        4375 :   if (TREE_CODE (mv2) != ARRAY_TYPE)
    1028                 :        3991 :     mv2 = TYPE_MAIN_VARIANT (pointed_to_2);
    1029                 :        4375 :   target = composite_type (mv1, mv2);
    1030                 :             : 
    1031                 :             :   /* Strip array types to get correct qualifier for pointers to arrays */
    1032                 :        4375 :   quals1 = TYPE_QUALS_NO_ADDR_SPACE (strip_array_types (pointed_to_1));
    1033                 :        4375 :   quals2 = TYPE_QUALS_NO_ADDR_SPACE (strip_array_types (pointed_to_2));
    1034                 :             : 
    1035                 :             :   /* For function types do not merge const qualifiers, but drop them
    1036                 :             :      if used inconsistently.  The middle-end uses these to mark const
    1037                 :             :      and noreturn functions.  */
    1038                 :        4375 :   if (TREE_CODE (pointed_to_1) == FUNCTION_TYPE)
    1039                 :        2129 :     target_quals = (quals1 & quals2);
    1040                 :             :   else
    1041                 :        2246 :     target_quals = (quals1 | quals2);
    1042                 :             : 
    1043                 :             :   /* If the two named address spaces are different, determine the common
    1044                 :             :      superset address space.  This is guaranteed to exist due to the
    1045                 :             :      assumption that comp_target_type returned true.  */
    1046                 :        4375 :   as1 = TYPE_ADDR_SPACE (pointed_to_1);
    1047                 :        4375 :   as2 = TYPE_ADDR_SPACE (pointed_to_2);
    1048                 :        4375 :   if (!addr_space_superset (as1, as2, &as_common))
    1049                 :           0 :     gcc_unreachable ();
    1050                 :             : 
    1051                 :        4375 :   target_quals |= ENCODE_QUAL_ADDR_SPACE (as_common);
    1052                 :             : 
    1053                 :        4375 :   t1 = c_build_pointer_type (c_build_qualified_type (target, target_quals));
    1054                 :        4375 :   return c_build_type_attribute_variant (t1, attributes);
    1055                 :             : }
    1056                 :             : 
    1057                 :             : /* Return the common type for two arithmetic types under the usual
    1058                 :             :    arithmetic conversions.  The default conversions have already been
    1059                 :             :    applied, and enumerated types converted to their compatible integer
    1060                 :             :    types.  The resulting type is unqualified and has no attributes.
    1061                 :             : 
    1062                 :             :    This is the type for the result of most arithmetic operations
    1063                 :             :    if the operands have the given two types.  */
    1064                 :             : 
    1065                 :             : static tree
    1066                 :    13589753 : c_common_type (tree t1, tree t2)
    1067                 :             : {
    1068                 :    13589753 :   enum tree_code code1;
    1069                 :    13589753 :   enum tree_code code2;
    1070                 :             : 
    1071                 :             :   /* If one type is nonsense, use the other.  */
    1072                 :    13589753 :   if (t1 == error_mark_node)
    1073                 :             :     return t2;
    1074                 :    13589753 :   if (t2 == error_mark_node)
    1075                 :             :     return t1;
    1076                 :             : 
    1077                 :    13589753 :   if (TYPE_QUALS (t1) != TYPE_UNQUALIFIED)
    1078                 :       38255 :     t1 = TYPE_MAIN_VARIANT (t1);
    1079                 :             : 
    1080                 :    13589753 :   if (TYPE_QUALS (t2) != TYPE_UNQUALIFIED)
    1081                 :       47692 :     t2 = TYPE_MAIN_VARIANT (t2);
    1082                 :             : 
    1083                 :    13589753 :   if (TYPE_ATTRIBUTES (t1) != NULL_TREE)
    1084                 :             :     {
    1085                 :      184212 :       tree attrs = affects_type_identity_attributes (TYPE_ATTRIBUTES (t1));
    1086                 :      184212 :       t1 = c_build_type_attribute_variant (t1, attrs);
    1087                 :             :     }
    1088                 :             : 
    1089                 :    13589753 :   if (TYPE_ATTRIBUTES (t2) != NULL_TREE)
    1090                 :             :     {
    1091                 :      183694 :       tree attrs = affects_type_identity_attributes (TYPE_ATTRIBUTES (t2));
    1092                 :      183694 :       t2 = c_build_type_attribute_variant (t2, attrs);
    1093                 :             :     }
    1094                 :             : 
    1095                 :             :   /* Save time if the two types are the same.  */
    1096                 :             : 
    1097                 :    13589753 :   if (t1 == t2) return t1;
    1098                 :             : 
    1099                 :     2294109 :   code1 = TREE_CODE (t1);
    1100                 :     2294109 :   code2 = TREE_CODE (t2);
    1101                 :             : 
    1102                 :     2294109 :   gcc_assert (code1 == VECTOR_TYPE || code1 == COMPLEX_TYPE
    1103                 :             :               || code1 == FIXED_POINT_TYPE || code1 == REAL_TYPE
    1104                 :             :               || code1 == INTEGER_TYPE || code1 == BITINT_TYPE);
    1105                 :     2294109 :   gcc_assert (code2 == VECTOR_TYPE || code2 == COMPLEX_TYPE
    1106                 :             :               || code2 == FIXED_POINT_TYPE || code2 == REAL_TYPE
    1107                 :             :               || code2 == INTEGER_TYPE || code2 == BITINT_TYPE);
    1108                 :             : 
    1109                 :             :   /* When one operand is a decimal float type, the other operand cannot be
    1110                 :             :      a generic float type or a complex type.  We also disallow vector types
    1111                 :             :      here.  */
    1112                 :     2294109 :   if ((DECIMAL_FLOAT_TYPE_P (t1) || DECIMAL_FLOAT_TYPE_P (t2))
    1113                 :     2296548 :       && !(DECIMAL_FLOAT_TYPE_P (t1) && DECIMAL_FLOAT_TYPE_P (t2)))
    1114                 :             :     {
    1115                 :        1072 :       if (code1 == VECTOR_TYPE || code2 == VECTOR_TYPE)
    1116                 :             :         {
    1117                 :           3 :           error ("cannot mix operands of decimal floating and vector types");
    1118                 :           3 :           return error_mark_node;
    1119                 :             :         }
    1120                 :        1069 :       if (code1 == COMPLEX_TYPE || code2 == COMPLEX_TYPE)
    1121                 :             :         {
    1122                 :           5 :           error ("cannot mix operands of decimal floating and complex types");
    1123                 :           5 :           return error_mark_node;
    1124                 :             :         }
    1125                 :        1064 :       if (code1 == REAL_TYPE && code2 == REAL_TYPE)
    1126                 :             :         {
    1127                 :          16 :           error ("cannot mix operands of decimal floating "
    1128                 :             :                  "and other floating types");
    1129                 :          16 :           return error_mark_node;
    1130                 :             :         }
    1131                 :             :     }
    1132                 :             : 
    1133                 :             :   /* If one type is a vector type, return that type.  (How the usual
    1134                 :             :      arithmetic conversions apply to the vector types extension is not
    1135                 :             :      precisely specified.)  */
    1136                 :     2294085 :   if (code1 == VECTOR_TYPE)
    1137                 :             :     return t1;
    1138                 :             : 
    1139                 :     2293842 :   if (code2 == VECTOR_TYPE)
    1140                 :             :     return t2;
    1141                 :             : 
    1142                 :             :   /* If one type is complex, form the common type of the non-complex
    1143                 :             :      components, then make that complex.  Use T1 or T2 if it is the
    1144                 :             :      required type.  */
    1145                 :     2293839 :   if (code1 == COMPLEX_TYPE || code2 == COMPLEX_TYPE)
    1146                 :             :     {
    1147                 :       89348 :       tree subtype1 = code1 == COMPLEX_TYPE ? TREE_TYPE (t1) : t1;
    1148                 :       89348 :       tree subtype2 = code2 == COMPLEX_TYPE ? TREE_TYPE (t2) : t2;
    1149                 :       89348 :       tree subtype = c_common_type (subtype1, subtype2);
    1150                 :             : 
    1151                 :       89348 :       if (code1 == COMPLEX_TYPE && TREE_TYPE (t1) == subtype)
    1152                 :             :         return t1;
    1153                 :       59232 :       else if (code2 == COMPLEX_TYPE && TREE_TYPE (t2) == subtype)
    1154                 :             :         return t2;
    1155                 :        3264 :       else if (TREE_CODE (subtype) == BITINT_TYPE)
    1156                 :             :         {
    1157                 :           8 :           sorry ("%<_Complex _BitInt(%d)%> unsupported",
    1158                 :           4 :                  TYPE_PRECISION (subtype));
    1159                 :           6 :           return code1 == COMPLEX_TYPE ? t1 : t2;
    1160                 :             :         }
    1161                 :             :       else
    1162                 :        3260 :         return build_complex_type (subtype);
    1163                 :             :     }
    1164                 :             : 
    1165                 :             :   /* If only one is real, use it as the result.  */
    1166                 :             : 
    1167                 :     2204491 :   if (code1 == REAL_TYPE && code2 != REAL_TYPE)
    1168                 :             :     return t1;
    1169                 :             : 
    1170                 :     2080135 :   if (code2 == REAL_TYPE && code1 != REAL_TYPE)
    1171                 :             :     return t2;
    1172                 :             : 
    1173                 :             :   /* If both are real and either are decimal floating point types, use
    1174                 :             :      the decimal floating point type with the greater precision. */
    1175                 :             : 
    1176                 :     2049840 :   if (code1 == REAL_TYPE && code2 == REAL_TYPE)
    1177                 :             :     {
    1178                 :      102654 :       if (TYPE_MAIN_VARIANT (t1) == dfloat128_type_node
    1179                 :      102654 :           || TYPE_MAIN_VARIANT (t2) == dfloat128_type_node)
    1180                 :             :         return dfloat128_type_node;
    1181                 :             :       /* And prefer _Decimal128 over _Decimal64x which has in GCC's
    1182                 :             :          implementation the same mode.  */
    1183                 :      102089 :       else if (TYPE_MAIN_VARIANT (t1) == dfloat64x_type_node
    1184                 :      102089 :                || TYPE_MAIN_VARIANT (t2) == dfloat64x_type_node)
    1185                 :             :         return dfloat64x_type_node;
    1186                 :      102085 :       else if (TYPE_MAIN_VARIANT (t1) == dfloat64_type_node
    1187                 :      102085 :                || TYPE_MAIN_VARIANT (t2) == dfloat64_type_node)
    1188                 :             :         return dfloat64_type_node;
    1189                 :      101632 :       else if (TYPE_MAIN_VARIANT (t1) == dfloat32_type_node
    1190                 :      101632 :                || TYPE_MAIN_VARIANT (t2) == dfloat32_type_node)
    1191                 :             :         return dfloat32_type_node;
    1192                 :             :     }
    1193                 :             : 
    1194                 :             :   /* Deal with fixed-point types.  */
    1195                 :     2048473 :   if (code1 == FIXED_POINT_TYPE || code2 == FIXED_POINT_TYPE)
    1196                 :             :     {
    1197                 :           0 :       unsigned int unsignedp = 0, satp = 0;
    1198                 :           0 :       scalar_mode m1, m2;
    1199                 :           0 :       unsigned int fbit1, ibit1, fbit2, ibit2, max_fbit, max_ibit;
    1200                 :             : 
    1201                 :           0 :       m1 = SCALAR_TYPE_MODE (t1);
    1202                 :           0 :       m2 = SCALAR_TYPE_MODE (t2);
    1203                 :             : 
    1204                 :             :       /* If one input type is saturating, the result type is saturating.  */
    1205                 :           0 :       if (TYPE_SATURATING (t1) || TYPE_SATURATING (t2))
    1206                 :             :         satp = 1;
    1207                 :             : 
    1208                 :             :       /* If both fixed-point types are unsigned, the result type is unsigned.
    1209                 :             :          When mixing fixed-point and integer types, follow the sign of the
    1210                 :             :          fixed-point type.
    1211                 :             :          Otherwise, the result type is signed.  */
    1212                 :           0 :       if ((TYPE_UNSIGNED (t1) && TYPE_UNSIGNED (t2)
    1213                 :           0 :            && code1 == FIXED_POINT_TYPE && code2 == FIXED_POINT_TYPE)
    1214                 :           0 :           || (code1 == FIXED_POINT_TYPE && code2 != FIXED_POINT_TYPE
    1215                 :           0 :               && TYPE_UNSIGNED (t1))
    1216                 :           0 :           || (code1 != FIXED_POINT_TYPE && code2 == FIXED_POINT_TYPE
    1217                 :           0 :               && TYPE_UNSIGNED (t2)))
    1218                 :             :         unsignedp = 1;
    1219                 :             : 
    1220                 :             :       /* The result type is signed.  */
    1221                 :           0 :       if (unsignedp == 0)
    1222                 :             :         {
    1223                 :             :           /* If the input type is unsigned, we need to convert to the
    1224                 :             :              signed type.  */
    1225                 :           0 :           if (code1 == FIXED_POINT_TYPE && TYPE_UNSIGNED (t1))
    1226                 :             :             {
    1227                 :           0 :               enum mode_class mclass = (enum mode_class) 0;
    1228                 :           0 :               if (GET_MODE_CLASS (m1) == MODE_UFRACT)
    1229                 :             :                 mclass = MODE_FRACT;
    1230                 :           0 :               else if (GET_MODE_CLASS (m1) == MODE_UACCUM)
    1231                 :             :                 mclass = MODE_ACCUM;
    1232                 :             :               else
    1233                 :           0 :                 gcc_unreachable ();
    1234                 :           0 :               m1 = as_a <scalar_mode>
    1235                 :           0 :                 (mode_for_size (GET_MODE_PRECISION (m1), mclass, 0));
    1236                 :             :             }
    1237                 :           0 :           if (code2 == FIXED_POINT_TYPE && TYPE_UNSIGNED (t2))
    1238                 :             :             {
    1239                 :           0 :               enum mode_class mclass = (enum mode_class) 0;
    1240                 :           0 :               if (GET_MODE_CLASS (m2) == MODE_UFRACT)
    1241                 :             :                 mclass = MODE_FRACT;
    1242                 :           0 :               else if (GET_MODE_CLASS (m2) == MODE_UACCUM)
    1243                 :             :                 mclass = MODE_ACCUM;
    1244                 :             :               else
    1245                 :           0 :                 gcc_unreachable ();
    1246                 :           0 :               m2 = as_a <scalar_mode>
    1247                 :           0 :                 (mode_for_size (GET_MODE_PRECISION (m2), mclass, 0));
    1248                 :             :             }
    1249                 :             :         }
    1250                 :             : 
    1251                 :           0 :       if (code1 == FIXED_POINT_TYPE)
    1252                 :             :         {
    1253                 :           0 :           fbit1 = GET_MODE_FBIT (m1);
    1254                 :           0 :           ibit1 = GET_MODE_IBIT (m1);
    1255                 :             :         }
    1256                 :             :       else
    1257                 :             :         {
    1258                 :           0 :           fbit1 = 0;
    1259                 :             :           /* Signed integers need to subtract one sign bit.  */
    1260                 :           0 :           ibit1 = TYPE_PRECISION (t1) - (!TYPE_UNSIGNED (t1));
    1261                 :             :         }
    1262                 :             : 
    1263                 :           0 :       if (code2 == FIXED_POINT_TYPE)
    1264                 :             :         {
    1265                 :           0 :           fbit2 = GET_MODE_FBIT (m2);
    1266                 :           0 :           ibit2 = GET_MODE_IBIT (m2);
    1267                 :             :         }
    1268                 :             :       else
    1269                 :             :         {
    1270                 :           0 :           fbit2 = 0;
    1271                 :             :           /* Signed integers need to subtract one sign bit.  */
    1272                 :           0 :           ibit2 = TYPE_PRECISION (t2) - (!TYPE_UNSIGNED (t2));
    1273                 :             :         }
    1274                 :             : 
    1275                 :           0 :       max_ibit = ibit1 >= ibit2 ?  ibit1 : ibit2;
    1276                 :           0 :       max_fbit = fbit1 >= fbit2 ?  fbit1 : fbit2;
    1277                 :           0 :       return c_common_fixed_point_type_for_size (max_ibit, max_fbit, unsignedp,
    1278                 :             :                                                  satp);
    1279                 :             :     }
    1280                 :             : 
    1281                 :             :   /* Both real or both integers; use the one with greater precision.  */
    1282                 :             : 
    1283                 :     2048473 :   if (TYPE_PRECISION (t1) > TYPE_PRECISION (t2))
    1284                 :             :     return t1;
    1285                 :     1077112 :   else if (TYPE_PRECISION (t2) > TYPE_PRECISION (t1))
    1286                 :             :     return t2;
    1287                 :             : 
    1288                 :             :   /* Same precision.  Prefer long longs to longs to ints when the
    1289                 :             :      same precision, following the C99 rules on integer type rank
    1290                 :             :      (which are equivalent to the C90 rules for C90 types).  */
    1291                 :             : 
    1292                 :      725796 :   if (TYPE_MAIN_VARIANT (t1) == long_long_unsigned_type_node
    1293                 :      725796 :       || TYPE_MAIN_VARIANT (t2) == long_long_unsigned_type_node)
    1294                 :             :     return long_long_unsigned_type_node;
    1295                 :             : 
    1296                 :      638762 :   if (TYPE_MAIN_VARIANT (t1) == long_long_integer_type_node
    1297                 :      638762 :       || TYPE_MAIN_VARIANT (t2) == long_long_integer_type_node)
    1298                 :             :     {
    1299                 :       14726 :       if (TYPE_UNSIGNED (t1) || TYPE_UNSIGNED (t2))
    1300                 :         358 :         return long_long_unsigned_type_node;
    1301                 :             :       else
    1302                 :             :         return long_long_integer_type_node;
    1303                 :             :     }
    1304                 :             : 
    1305                 :      624036 :   if (TYPE_MAIN_VARIANT (t1) == long_unsigned_type_node
    1306                 :      624036 :       || TYPE_MAIN_VARIANT (t2) == long_unsigned_type_node)
    1307                 :             :     return long_unsigned_type_node;
    1308                 :             : 
    1309                 :      524821 :   if (TYPE_MAIN_VARIANT (t1) == long_integer_type_node
    1310                 :      524821 :       || TYPE_MAIN_VARIANT (t2) == long_integer_type_node)
    1311                 :             :     {
    1312                 :             :       /* But preserve unsignedness from the other type,
    1313                 :             :          since long cannot hold all the values of an unsigned int.  */
    1314                 :       26029 :       if (TYPE_UNSIGNED (t1) || TYPE_UNSIGNED (t2))
    1315                 :         131 :         return long_unsigned_type_node;
    1316                 :             :       else
    1317                 :             :         return long_integer_type_node;
    1318                 :             :     }
    1319                 :             : 
    1320                 :             :   /* For floating types of the same TYPE_PRECISION (which we here
    1321                 :             :      assume means either the same set of values, or sets of values
    1322                 :             :      neither a subset of the other, with behavior being undefined in
    1323                 :             :      the latter case), follow the rules from TS 18661-3: prefer
    1324                 :             :      interchange types _FloatN, then standard types long double,
    1325                 :             :      double, float, then extended types _FloatNx.  For extended types,
    1326                 :             :      check them starting with _Float128x as that seems most consistent
    1327                 :             :      in spirit with preferring long double to double; for interchange
    1328                 :             :      types, also check in that order for consistency although it's not
    1329                 :             :      possible for more than one of them to have the same
    1330                 :             :      precision.  */
    1331                 :      498792 :   tree mv1 = TYPE_MAIN_VARIANT (t1);
    1332                 :      498792 :   tree mv2 = TYPE_MAIN_VARIANT (t2);
    1333                 :             : 
    1334                 :     2493394 :   for (int i = NUM_FLOATN_TYPES - 1; i >= 0; i--)
    1335                 :     1994765 :     if (mv1 == FLOATN_TYPE_NODE (i) || mv2 == FLOATN_TYPE_NODE (i))
    1336                 :             :       return FLOATN_TYPE_NODE (i);
    1337                 :             : 
    1338                 :             :   /* Likewise, prefer long double to double even if same size.  */
    1339                 :      498629 :   if (mv1 == long_double_type_node || mv2 == long_double_type_node)
    1340                 :             :     return long_double_type_node;
    1341                 :             : 
    1342                 :             :   /* Likewise, prefer double to float even if same size.
    1343                 :             :      We got a couple of embedded targets with 32 bit doubles, and the
    1344                 :             :      pdp11 might have 64 bit floats.  */
    1345                 :      498387 :   if (mv1 == double_type_node || mv2 == double_type_node)
    1346                 :             :     return double_type_node;
    1347                 :             : 
    1348                 :      497815 :   if (mv1 == float_type_node || mv2 == float_type_node)
    1349                 :             :     return float_type_node;
    1350                 :             : 
    1351                 :     1982584 :   for (int i = NUM_FLOATNX_TYPES - 1; i >= 0; i--)
    1352                 :     1486938 :     if (mv1 == FLOATNX_TYPE_NODE (i) || mv2 == FLOATNX_TYPE_NODE (i))
    1353                 :             :       return FLOATNX_TYPE_NODE (i);
    1354                 :             : 
    1355                 :      495646 :   if ((code1 == BITINT_TYPE || code2 == BITINT_TYPE) && code1 != code2)
    1356                 :             :     {
    1357                 :             :       /* Prefer any other integral types over bit-precise integer types.  */
    1358                 :          10 :       if (TYPE_UNSIGNED (t1) == TYPE_UNSIGNED (t2))
    1359                 :           6 :         return code1 == BITINT_TYPE ? t2 : t1;
    1360                 :             :       /* If BITINT_TYPE is unsigned and the other type is signed
    1361                 :             :          non-BITINT_TYPE with the same precision, the latter has higher rank.
    1362                 :             :          In that case:
    1363                 :             :          Otherwise, both operands are converted to the unsigned integer type
    1364                 :             :          corresponding to the type of the operand with signed integer type.  */
    1365                 :           8 :       if (TYPE_UNSIGNED (code1 == BITINT_TYPE ? t1 : t2))
    1366                 :           5 :         return c_common_unsigned_type (code1 == BITINT_TYPE ? t2 : t1);
    1367                 :             :     }
    1368                 :             : 
    1369                 :             :   /* Otherwise prefer the unsigned one.  */
    1370                 :             : 
    1371                 :      495638 :   if (TYPE_UNSIGNED (t1))
    1372                 :             :     return t1;
    1373                 :             :   else
    1374                 :             :     return t2;
    1375                 :             : }
    1376                 :             : 
    1377                 :             : /* Wrapper around c_common_type that is used by c-common.cc and other
    1378                 :             :    front end optimizations that remove promotions.  ENUMERAL_TYPEs
    1379                 :             :    are allowed here and are converted to their compatible integer types.
    1380                 :             :    BOOLEAN_TYPEs are allowed here and return either boolean_type_node or
    1381                 :             :    preferably a non-Boolean type as the common type.  */
    1382                 :             : tree
    1383                 :       99779 : common_type (tree t1, tree t2)
    1384                 :             : {
    1385                 :       99779 :   if (TREE_CODE (t1) == ENUMERAL_TYPE)
    1386                 :           0 :     t1 = ENUM_UNDERLYING_TYPE (t1);
    1387                 :       99779 :   if (TREE_CODE (t2) == ENUMERAL_TYPE)
    1388                 :           1 :     t2 = ENUM_UNDERLYING_TYPE (t2);
    1389                 :             : 
    1390                 :             :   /* If both types are BOOLEAN_TYPE, then return boolean_type_node.  */
    1391                 :       99779 :   if (TREE_CODE (t1) == BOOLEAN_TYPE
    1392                 :         584 :       && TREE_CODE (t2) == BOOLEAN_TYPE)
    1393                 :         584 :     return boolean_type_node;
    1394                 :             : 
    1395                 :             :   /* If either type is BOOLEAN_TYPE, then return the other.  */
    1396                 :       99195 :   if (TREE_CODE (t1) == BOOLEAN_TYPE)
    1397                 :             :     return t2;
    1398                 :       99195 :   if (TREE_CODE (t2) == BOOLEAN_TYPE)
    1399                 :             :     return t1;
    1400                 :             : 
    1401                 :       99195 :   return c_common_type (t1, t2);
    1402                 :             : }
    1403                 :             : 
    1404                 :             : 
    1405                 :             : 
    1406                 :             : /* Helper function for comptypes.  For two compatible types, return 1
    1407                 :             :    if they pass consistency checks.  In particular we test that
    1408                 :             :    TYPE_CANONICAL is set correctly, i.e. the two types can alias.  */
    1409                 :             : 
    1410                 :             : static bool
    1411                 :    42143301 : comptypes_verify (tree type1, tree type2)
    1412                 :             : {
    1413                 :    42143301 :   if (type1 == type2 || !type1 || !type2
    1414                 :     3042157 :       || TREE_CODE (type1) == ERROR_MARK || TREE_CODE (type2) == ERROR_MARK)
    1415                 :             :     return true;
    1416                 :             : 
    1417                 :     3042156 :   gcc_checking_assert (c_verify_type (type1));
    1418                 :     3042156 :   gcc_checking_assert (c_verify_type (type2));
    1419                 :             : 
    1420                 :     3042156 :   if (TYPE_CANONICAL (type1) != TYPE_CANONICAL (type2)
    1421                 :      376502 :       && !TYPE_STRUCTURAL_EQUALITY_P (type1)
    1422                 :     3417041 :       && !TYPE_STRUCTURAL_EQUALITY_P (type2))
    1423                 :             :     {
    1424                 :             :       /* FIXME: check other types. */
    1425                 :      374696 :       if (RECORD_OR_UNION_TYPE_P (type1)
    1426                 :      374696 :           || TREE_CODE (type1) == ENUMERAL_TYPE
    1427                 :      374696 :           || TREE_CODE (type2) == ENUMERAL_TYPE)
    1428                 :           0 :         return false;
    1429                 :             :     }
    1430                 :             :   return true;
    1431                 :             : }
    1432                 :             : 
    1433                 :             : struct comptypes_data {
    1434                 :             :   bool enum_and_int_p;
    1435                 :             :   bool different_types_p;
    1436                 :             :   bool warning_needed;
    1437                 :             :   bool anon_field;
    1438                 :             :   bool pointedto;
    1439                 :             :   bool equiv;
    1440                 :             : 
    1441                 :             :   const struct tagged_tu_seen_cache* cache;
    1442                 :             : };
    1443                 :             : 
    1444                 :             : /* C implementation of compatible_types_for_indirection_note_p.  */
    1445                 :             : 
    1446                 :             : bool
    1447                 :         761 : compatible_types_for_indirection_note_p (tree type1, tree type2)
    1448                 :             : {
    1449                 :         761 :   return comptypes (type1, type2) == 1;
    1450                 :             : }
    1451                 :             : 
    1452                 :             : /* Return 1 if TYPE1 and TYPE2 are compatible types for assignment
    1453                 :             :    or various other operations.  Return 2 if they are compatible
    1454                 :             :    but a warning may be needed if you use them together.  */
    1455                 :             : 
    1456                 :             : int
    1457                 :    54333242 : comptypes (tree type1, tree type2)
    1458                 :             : {
    1459                 :    54333242 :   struct comptypes_data data = { };
    1460                 :    54333242 :   bool ret = comptypes_internal (type1, type2, &data);
    1461                 :             : 
    1462                 :    54333242 :   gcc_checking_assert (!ret || comptypes_verify (type1, type2));
    1463                 :             : 
    1464                 :    36291609 :   return ret ? (data.warning_needed ? 2 : 1) : 0;
    1465                 :             : }
    1466                 :             : 
    1467                 :             : 
    1468                 :             : /* Like comptypes, but it returns non-zero only for identical
    1469                 :             :    types.  */
    1470                 :             : 
    1471                 :             : bool
    1472                 :         206 : comptypes_same_p (tree type1, tree type2)
    1473                 :             : {
    1474                 :         206 :   struct comptypes_data data = { };
    1475                 :         206 :   bool ret = comptypes_internal (type1, type2, &data);
    1476                 :             : 
    1477                 :         206 :   gcc_checking_assert (!ret || comptypes_verify (type1, type2));
    1478                 :             : 
    1479                 :         206 :   if (data.different_types_p)
    1480                 :          74 :     return false;
    1481                 :             : 
    1482                 :             :   return ret;
    1483                 :             : }
    1484                 :             : 
    1485                 :             : 
    1486                 :             : /* Like comptypes, but if it returns non-zero because enum and int are
    1487                 :             :    compatible, it sets *ENUM_AND_INT_P to true.  */
    1488                 :             : 
    1489                 :             : int
    1490                 :     6048689 : comptypes_check_enum_int (tree type1, tree type2, bool *enum_and_int_p)
    1491                 :             : {
    1492                 :     6048689 :   struct comptypes_data data = { };
    1493                 :     6048689 :   bool ret = comptypes_internal (type1, type2, &data);
    1494                 :     6048689 :   *enum_and_int_p = data.enum_and_int_p;
    1495                 :             : 
    1496                 :     6048689 :   gcc_checking_assert (!ret || comptypes_verify (type1, type2));
    1497                 :             : 
    1498                 :     5806948 :   return ret ? (data.warning_needed ? 2 : 1) : 0;
    1499                 :             : }
    1500                 :             : 
    1501                 :             : /* Like comptypes, but if it returns nonzero for different types, it
    1502                 :             :    sets *DIFFERENT_TYPES_P to true.  */
    1503                 :             : 
    1504                 :             : int
    1505                 :       44575 : comptypes_check_different_types (tree type1, tree type2,
    1506                 :             :                                  bool *different_types_p)
    1507                 :             : {
    1508                 :       44575 :   struct comptypes_data data = { };
    1509                 :       44575 :   bool ret = comptypes_internal (type1, type2, &data);
    1510                 :       44575 :   *different_types_p = data.different_types_p;
    1511                 :             : 
    1512                 :       44575 :   gcc_checking_assert (!ret || comptypes_verify (type1, type2));
    1513                 :             : 
    1514                 :       44575 :   return ret ? (data.warning_needed ? 2 : 1) : 0;
    1515                 :             : }
    1516                 :             : 
    1517                 :             : 
    1518                 :             : /* Like comptypes, but if it returns true for struct and union types
    1519                 :             :    considered equivalent for aliasing purposes, i.e. for setting
    1520                 :             :    TYPE_CANONICAL after completing a struct or union.
    1521                 :             : 
    1522                 :             :    This function must return false only for types which are not
    1523                 :             :    compatible according to C language semantics (cf. comptypes),
    1524                 :             :    otherwise the middle-end would make incorrect aliasing decisions.
    1525                 :             :    It may return true for some similar types that are not compatible
    1526                 :             :    according to those stricter rules.
    1527                 :             : 
    1528                 :             :    In particular, we ignore size expression in arrays so that the
    1529                 :             :    following structs are in the same equivalence class:
    1530                 :             : 
    1531                 :             :    struct foo { char (*buf)[]; };
    1532                 :             :    struct foo { char (*buf)[3]; };
    1533                 :             :    struct foo { char (*buf)[4]; };
    1534                 :             : 
    1535                 :             :    We also treat unions / structs with members which are pointers to
    1536                 :             :    structures or unions with the same tag as equivalent (if they are not
    1537                 :             :    incompatible for other reasons).  Although incomplete structure
    1538                 :             :    or union types are not compatible to any other type, they may become
    1539                 :             :    compatible to different types when completed.  To avoid having to update
    1540                 :             :    TYPE_CANONICAL at this point, we only consider the tag when forming
    1541                 :             :    the equivalence classes.  For example, the following types with tag
    1542                 :             :    'foo' are all considered equivalent:
    1543                 :             : 
    1544                 :             :    struct bar;
    1545                 :             :    struct foo { struct bar *x };
    1546                 :             :    struct foo { struct bar { int a; } *x };
    1547                 :             :    struct foo { struct bar { char b; } *x };  */
    1548                 :             : 
    1549                 :             : bool
    1550                 :    14228114 : comptypes_equiv_p (tree type1, tree type2)
    1551                 :             : {
    1552                 :    14228114 :   struct comptypes_data data = { };
    1553                 :    14228114 :   data.equiv = true;
    1554                 :    14228114 :   bool ret = comptypes_internal (type1, type2, &data);
    1555                 :             : 
    1556                 :             :   /* check that different equivance classes are assigned only
    1557                 :             :      to types that are not compatible.  */
    1558                 :    14228114 :   gcc_checking_assert (ret || !comptypes (type1, type2));
    1559                 :             : 
    1560                 :    14228114 :   return ret;
    1561                 :             : }
    1562                 :             : 
    1563                 :             : 
    1564                 :             : /* Return true if TYPE1 and TYPE2 are compatible types for assignment
    1565                 :             :    or various other operations.  If they are compatible but a warning may
    1566                 :             :    be needed if you use them together, 'warning_needed' in DATA is set.
    1567                 :             :    If one type is an enum and the other a compatible integer type, then
    1568                 :             :    this sets 'enum_and_int_p' in DATA to true (it is never set to
    1569                 :             :    false).  If the types are compatible but different enough not to be
    1570                 :             :    permitted in C11 typedef redeclarations, then this sets
    1571                 :             :    'different_types_p' in DATA to true; it is never set to
    1572                 :             :    false, but may or may not be set if the types are incompatible.
    1573                 :             :    This differs from comptypes, in that we don't free the seen
    1574                 :             :    types.  */
    1575                 :             : 
    1576                 :             : static bool
    1577                 :    88437364 : comptypes_internal (const_tree type1, const_tree type2,
    1578                 :             :                     struct comptypes_data *data)
    1579                 :             : {
    1580                 :    88693671 :   const_tree t1 = type1;
    1581                 :    88693671 :   const_tree t2 = type2;
    1582                 :             : 
    1583                 :             :   /* Suppress errors caused by previously reported errors.  */
    1584                 :             : 
    1585                 :    88693671 :   if (t1 == t2 || !t1 || !t2
    1586                 :    37852399 :       || TREE_CODE (t1) == ERROR_MARK || TREE_CODE (t2) == ERROR_MARK)
    1587                 :             :     return true;
    1588                 :             : 
    1589                 :             :   /* Enumerated types are compatible with integer types, but this is
    1590                 :             :      not transitive: two enumerated types in the same translation unit
    1591                 :             :      are compatible with each other only if they are the same type.  */
    1592                 :             : 
    1593                 :    37852398 :   if (TREE_CODE (t1) == ENUMERAL_TYPE
    1594                 :         524 :       && COMPLETE_TYPE_P (t1)
    1595                 :    37852878 :       && TREE_CODE (t2) != ENUMERAL_TYPE)
    1596                 :             :     {
    1597                 :         395 :       t1 = ENUM_UNDERLYING_TYPE (t1);
    1598                 :         395 :       if (TREE_CODE (t2) != VOID_TYPE)
    1599                 :             :         {
    1600                 :         391 :           data->enum_and_int_p = true;
    1601                 :         391 :           data->different_types_p = true;
    1602                 :             :         }
    1603                 :             :     }
    1604                 :    37852003 :   else if (TREE_CODE (t2) == ENUMERAL_TYPE
    1605                 :        4428 :            && COMPLETE_TYPE_P (t2)
    1606                 :    37856425 :            && TREE_CODE (t1) != ENUMERAL_TYPE)
    1607                 :             :     {
    1608                 :        4337 :       t2 = ENUM_UNDERLYING_TYPE (t2);
    1609                 :        4337 :       if (TREE_CODE (t1) != VOID_TYPE)
    1610                 :             :         {
    1611                 :        3438 :           data->enum_and_int_p = true;
    1612                 :        3438 :           data->different_types_p = true;
    1613                 :             :         }
    1614                 :             :     }
    1615                 :             : 
    1616                 :    37852398 :   if (t1 == t2)
    1617                 :             :     return true;
    1618                 :             : 
    1619                 :             :   /* Different classes of types can't be compatible.  */
    1620                 :             : 
    1621                 :    37851633 :   if (TREE_CODE (t1) != TREE_CODE (t2))
    1622                 :             :     return false;
    1623                 :             : 
    1624                 :             :   /* Qualifiers must match. C99 6.7.3p9 */
    1625                 :             : 
    1626                 :    30033187 :   if (TYPE_QUALS (t1) != TYPE_QUALS (t2))
    1627                 :             :     return false;
    1628                 :             : 
    1629                 :             :   /* Allow for two different type nodes which have essentially the same
    1630                 :             :      definition.  Note that we already checked for equality of the type
    1631                 :             :      qualifiers (just above).  */
    1632                 :             : 
    1633                 :    29994031 :   if (TREE_CODE (t1) != ARRAY_TYPE
    1634                 :    29994031 :       && TYPE_MAIN_VARIANT (t1) == TYPE_MAIN_VARIANT (t2))
    1635                 :             :     return true;
    1636                 :             : 
    1637                 :    29745181 :   int attrval;
    1638                 :             : 
    1639                 :             :   /* 1 if no need for warning yet, 2 if warning cause has been seen.  */
    1640                 :    29745181 :   if (!(attrval = comp_type_attributes (t1, t2)))
    1641                 :             :      return false;
    1642                 :             : 
    1643                 :    29744826 :   if (2 == attrval)
    1644                 :         204 :     data->warning_needed = true;
    1645                 :             : 
    1646                 :    29744826 :   switch (TREE_CODE (t1))
    1647                 :             :     {
    1648                 :     3300298 :     case INTEGER_TYPE:
    1649                 :     3300298 :     case FIXED_POINT_TYPE:
    1650                 :     3300298 :     case REAL_TYPE:
    1651                 :     3300298 :     case BITINT_TYPE:
    1652                 :             :       /* With these nodes, we can't determine type equivalence by
    1653                 :             :          looking at what is stored in the nodes themselves, because
    1654                 :             :          two nodes might have different TYPE_MAIN_VARIANTs but still
    1655                 :             :          represent the same type.  For example, wchar_t and int could
    1656                 :             :          have the same properties (TYPE_PRECISION, TYPE_MIN_VALUE,
    1657                 :             :          TYPE_MAX_VALUE, etc.), but have different TYPE_MAIN_VARIANTs
    1658                 :             :          and are distinct types.  On the other hand, int and the
    1659                 :             :          following typedef
    1660                 :             : 
    1661                 :             :            typedef int INT __attribute((may_alias));
    1662                 :             : 
    1663                 :             :          have identical properties, different TYPE_MAIN_VARIANTs, but
    1664                 :             :          represent the same type.  The canonical type system keeps
    1665                 :             :          track of equivalence in this case, so we fall back on it.  */
    1666                 :     3300298 :       return TYPE_CANONICAL (t1) == TYPE_CANONICAL (t2);
    1667                 :             : 
    1668                 :      256307 :     case POINTER_TYPE:
    1669                 :             :       /* Do not remove mode information.  */
    1670                 :      256307 :       if (TYPE_MODE (t1) != TYPE_MODE (t2))
    1671                 :             :         return false;
    1672                 :      256307 :       data->pointedto = true;
    1673                 :      256307 :       return comptypes_internal (TREE_TYPE (t1), TREE_TYPE (t2), data);
    1674                 :             : 
    1675                 :     2736295 :     case FUNCTION_TYPE:
    1676                 :     2736295 :       return function_types_compatible_p (t1, t2, data);
    1677                 :             : 
    1678                 :      128123 :     case ARRAY_TYPE:
    1679                 :      128123 :       {
    1680                 :      128123 :         tree d1 = TYPE_DOMAIN (t1);
    1681                 :      128123 :         tree d2 = TYPE_DOMAIN (t2);
    1682                 :      128123 :         bool d1_variable, d2_variable;
    1683                 :      128123 :         bool d1_zero, d2_zero;
    1684                 :             : 
    1685                 :             :         /* Target types must match incl. qualifiers.  */
    1686                 :      128123 :         if (!comptypes_internal (TREE_TYPE (t1), TREE_TYPE (t2), data))
    1687                 :             :           return false;
    1688                 :             : 
    1689                 :       94672 :         if ((d1 == NULL_TREE) != (d2 == NULL_TREE))
    1690                 :        4555 :           data->different_types_p = true;
    1691                 :             :         /* Ignore size mismatches when forming equivalence classes.  */
    1692                 :       94672 :         if (data->equiv)
    1693                 :             :           return true;
    1694                 :             :         /* Sizes must match unless one is missing or variable.  */
    1695                 :       27432 :         if (d1 == NULL_TREE || d2 == NULL_TREE || d1 == d2)
    1696                 :             :           return true;
    1697                 :             : 
    1698                 :       17155 :         d1_zero = !TYPE_MAX_VALUE (d1);
    1699                 :       17155 :         d2_zero = !TYPE_MAX_VALUE (d2);
    1700                 :             : 
    1701                 :       34310 :         d1_variable = (!d1_zero
    1702                 :       17155 :                        && (TREE_CODE (TYPE_MIN_VALUE (d1)) != INTEGER_CST
    1703                 :       17149 :                            || TREE_CODE (TYPE_MAX_VALUE (d1)) != INTEGER_CST));
    1704                 :       34310 :         d2_variable = (!d2_zero
    1705                 :       17155 :                        && (TREE_CODE (TYPE_MIN_VALUE (d2)) != INTEGER_CST
    1706                 :       17062 :                            || TREE_CODE (TYPE_MAX_VALUE (d2)) != INTEGER_CST));
    1707                 :             : 
    1708                 :       17155 :         if (d1_variable != d2_variable)
    1709                 :         448 :           data->different_types_p = true;
    1710                 :       17155 :         if (d1_variable || d2_variable)
    1711                 :             :           return true;
    1712                 :        3969 :         if (d1_zero && d2_zero)
    1713                 :             :           return true;
    1714                 :        3969 :         if (d1_zero || d2_zero
    1715                 :        3876 :             || !tree_int_cst_equal (TYPE_MIN_VALUE (d1), TYPE_MIN_VALUE (d2))
    1716                 :        7845 :             || !tree_int_cst_equal (TYPE_MAX_VALUE (d1), TYPE_MAX_VALUE (d2)))
    1717                 :        3969 :           return false;
    1718                 :             : 
    1719                 :             :         return true;
    1720                 :             :       }
    1721                 :             : 
    1722                 :    22806099 :     case ENUMERAL_TYPE:
    1723                 :    22806099 :     case RECORD_TYPE:
    1724                 :    22806099 :     case UNION_TYPE:
    1725                 :             : 
    1726                 :    22806099 :       if (!flag_isoc23)
    1727                 :             :         return false;
    1728                 :             : 
    1729                 :    22806053 :       return tagged_types_tu_compatible_p (t1, t2, data);
    1730                 :             : 
    1731                 :      517139 :     case VECTOR_TYPE:
    1732                 :     1034278 :       return known_eq (TYPE_VECTOR_SUBPARTS (t1), TYPE_VECTOR_SUBPARTS (t2))
    1733                 :      517139 :              && comptypes_internal (TREE_TYPE (t1), TREE_TYPE (t2), data);
    1734                 :             : 
    1735                 :             :     default:
    1736                 :             :       return false;
    1737                 :             :     }
    1738                 :             :   gcc_unreachable ();
    1739                 :             : }
    1740                 :             : 
    1741                 :             : /* Return true if TTL and TTR are pointers to types that are equivalent, ignoring
    1742                 :             :    their qualifiers, except for named address spaces.  If the pointers point to
    1743                 :             :    different named addresses, then we must determine if one address space is a
    1744                 :             :    subset of the other.  */
    1745                 :             : 
    1746                 :             : static bool
    1747                 :     1731143 : comp_target_types (location_t location, tree ttl, tree ttr)
    1748                 :             : {
    1749                 :     1731143 :   int val;
    1750                 :     1731143 :   int val_ped;
    1751                 :     1731143 :   tree mvl = TREE_TYPE (ttl);
    1752                 :     1731143 :   tree mvr = TREE_TYPE (ttr);
    1753                 :     1731143 :   addr_space_t asl = TYPE_ADDR_SPACE (mvl);
    1754                 :     1731143 :   addr_space_t asr = TYPE_ADDR_SPACE (mvr);
    1755                 :     1731143 :   addr_space_t as_common;
    1756                 :     1731143 :   bool enum_and_int_p;
    1757                 :             : 
    1758                 :             :   /* Fail if pointers point to incompatible address spaces.  */
    1759                 :     1731143 :   if (!addr_space_superset (asl, asr, &as_common))
    1760                 :             :     return 0;
    1761                 :             : 
    1762                 :             :   /* For pedantic record result of comptypes on arrays before losing
    1763                 :             :      qualifiers on the element type below. */
    1764                 :     1731143 :   val_ped = 1;
    1765                 :             : 
    1766                 :     1731143 :   if (TREE_CODE (mvl) == ARRAY_TYPE
    1767                 :        1939 :       && TREE_CODE (mvr) == ARRAY_TYPE)
    1768                 :        1916 :     val_ped = comptypes (mvl, mvr);
    1769                 :             : 
    1770                 :             :   /* Qualifiers on element types of array types that are
    1771                 :             :      pointer targets are lost by taking their TYPE_MAIN_VARIANT.  */
    1772                 :             : 
    1773                 :     1731143 :   mvl = (TYPE_ATOMIC (strip_array_types (mvl))
    1774                 :     3462150 :          ? c_build_qualified_type (TYPE_MAIN_VARIANT (mvl), TYPE_QUAL_ATOMIC)
    1775                 :     1731007 :          : TYPE_MAIN_VARIANT (mvl));
    1776                 :             : 
    1777                 :     1731143 :   mvr = (TYPE_ATOMIC (strip_array_types (mvr))
    1778                 :     3462146 :          ? c_build_qualified_type (TYPE_MAIN_VARIANT (mvr), TYPE_QUAL_ATOMIC)
    1779                 :     1731003 :          : TYPE_MAIN_VARIANT (mvr));
    1780                 :             : 
    1781                 :     1731143 :   enum_and_int_p = false;
    1782                 :     1731143 :   val = comptypes_check_enum_int (mvl, mvr, &enum_and_int_p);
    1783                 :             : 
    1784                 :     1731143 :   if (val == 1 && val_ped != 1)
    1785                 :         188 :     pedwarn_c11 (location, OPT_Wpedantic, "invalid use of pointers to arrays with different qualifiers "
    1786                 :             :                                           "in ISO C before C23");
    1787                 :             : 
    1788                 :     1731143 :   if (val == 2)
    1789                 :         126 :     pedwarn (location, OPT_Wpedantic, "types are not quite compatible");
    1790                 :             : 
    1791                 :     1731143 :   if (val == 1 && enum_and_int_p && warn_cxx_compat)
    1792                 :           2 :     warning_at (location, OPT_Wc___compat,
    1793                 :             :                 "pointer target types incompatible in C++");
    1794                 :             : 
    1795                 :     1731143 :   return val;
    1796                 :             : }
    1797                 :             : 
    1798                 :             : /* Subroutines of `comptypes'.  */
    1799                 :             : 
    1800                 :             : /* Return true if two 'struct', 'union', or 'enum' types T1 and T2 are
    1801                 :             :    compatible.  The two types are not the same (which has been
    1802                 :             :    checked earlier in comptypes_internal).  */
    1803                 :             : 
    1804                 :             : static bool
    1805                 :    22806053 : tagged_types_tu_compatible_p (const_tree t1, const_tree t2,
    1806                 :             :                               struct comptypes_data *data)
    1807                 :             : {
    1808                 :    22806053 :   tree s1, s2;
    1809                 :             : 
    1810                 :             :   /* We have to verify that the tags of the types are the same.  This
    1811                 :             :      is harder than it looks because this may be a typedef, so we have
    1812                 :             :      to go look at the original type.  */
    1813                 :    22806053 :   t1 = c_type_original (t1);
    1814                 :    22806053 :   t2 = c_type_original (t2);
    1815                 :             : 
    1816                 :    22806053 :   if (TYPE_NAME (t1) != TYPE_NAME (t2))
    1817                 :             :     return false;
    1818                 :             : 
    1819                 :             :   /* When forming equivalence classes for TYPE_CANONICAL in C23, we treat
    1820                 :             :      structs with the same tag as equivalent, but only when they are targets
    1821                 :             :      of pointers inside other structs.  */
    1822                 :    18872909 :   if (data->equiv && data->pointedto)
    1823                 :             :     return true;
    1824                 :             : 
    1825                 :             :   /* Different types without tag are incompatible except as an anonymous
    1826                 :             :      field or when forming equivalence classes for TYPE_CANONICAL.  */
    1827                 :    18872903 :   if (!data->anon_field && !data->equiv && NULL_TREE == TYPE_NAME (t1))
    1828                 :             :     return false;
    1829                 :             : 
    1830                 :    13996417 :   if (!data->anon_field && TYPE_STUB_DECL (t1) != TYPE_STUB_DECL (t2))
    1831                 :    13995693 :     data->different_types_p = true;
    1832                 :             : 
    1833                 :             :   /* Incomplete types are incompatible inside a TU.  */
    1834                 :    13996417 :   if (TYPE_SIZE (t1) == NULL || TYPE_SIZE (t2) == NULL)
    1835                 :             :     return false;
    1836                 :             : 
    1837                 :    13996407 :   if (ENUMERAL_TYPE != TREE_CODE (t1)
    1838                 :    13996407 :       && (TYPE_REVERSE_STORAGE_ORDER (t1)
    1839                 :    13996370 :           != TYPE_REVERSE_STORAGE_ORDER (t2)))
    1840                 :             :     return false;
    1841                 :             : 
    1842                 :    13996397 :   if (TYPE_USER_ALIGN (t1) != TYPE_USER_ALIGN (t2))
    1843                 :      140525 :     data->different_types_p = true;
    1844                 :             : 
    1845                 :             :   /* For types already being looked at in some active
    1846                 :             :      invocation of this function, assume compatibility.
    1847                 :             :      The cache is built as a linked list on the stack
    1848                 :             :      with the head of the list passed downwards.  */
    1849                 :    13996397 :   for (const struct tagged_tu_seen_cache *t = data->cache;
    1850                 :    14004604 :        t != NULL; t = t->next)
    1851                 :        8207 :     if (t->t1 == t1 && t->t2 == t2)
    1852                 :             :       return true;
    1853                 :             : 
    1854                 :    13996397 :   const struct tagged_tu_seen_cache entry = { data->cache, t1, t2 };
    1855                 :             : 
    1856                 :    13996397 :   switch (TREE_CODE (t1))
    1857                 :             :     {
    1858                 :          37 :     case ENUMERAL_TYPE:
    1859                 :          37 :       {
    1860                 :          37 :         if (!comptypes (ENUM_UNDERLYING_TYPE (t1), ENUM_UNDERLYING_TYPE (t2)))
    1861                 :             :           return false;
    1862                 :             : 
    1863                 :             :         /* Speed up the case where the type values are in the same order.  */
    1864                 :          33 :         tree tv1 = TYPE_VALUES (t1);
    1865                 :          33 :         tree tv2 = TYPE_VALUES (t2);
    1866                 :             : 
    1867                 :          33 :         if (tv1 == tv2)
    1868                 :             :           return true;
    1869                 :             : 
    1870                 :          61 :         for (;tv1 && tv2; tv1 = TREE_CHAIN (tv1), tv2 = TREE_CHAIN (tv2))
    1871                 :             :           {
    1872                 :          40 :             if (TREE_PURPOSE (tv1) != TREE_PURPOSE (tv2))
    1873                 :             :               break;
    1874                 :             : 
    1875                 :          33 :             if (simple_cst_equal (DECL_INITIAL (TREE_VALUE (tv1)),
    1876                 :          33 :                                   DECL_INITIAL (TREE_VALUE (tv2))) != 1)
    1877                 :             :               break;
    1878                 :             :           }
    1879                 :             : 
    1880                 :          33 :         if (tv1 == NULL_TREE && tv2 == NULL_TREE)
    1881                 :             :           return true;
    1882                 :             : 
    1883                 :          12 :         if (tv1 == NULL_TREE || tv2 == NULL_TREE)
    1884                 :             :           return false;
    1885                 :             : 
    1886                 :          12 :         if (list_length (TYPE_VALUES (t1)) != list_length (TYPE_VALUES (t2)))
    1887                 :             :           return false;
    1888                 :             : 
    1889                 :          20 :         for (s1 = TYPE_VALUES (t1); s1; s1 = TREE_CHAIN (s1))
    1890                 :             :           {
    1891                 :          16 :             s2 = purpose_member (TREE_PURPOSE (s1), TYPE_VALUES (t2));
    1892                 :             : 
    1893                 :          16 :             if (s2 == NULL
    1894                 :          29 :                 || simple_cst_equal (DECL_INITIAL (TREE_VALUE (s1)),
    1895                 :          13 :                                      DECL_INITIAL (TREE_VALUE (s2))) != 1)
    1896                 :           8 :               return false;
    1897                 :             :           }
    1898                 :             : 
    1899                 :             :         return true;
    1900                 :             :       }
    1901                 :             : 
    1902                 :    13996360 :     case UNION_TYPE:
    1903                 :    13996360 :     case RECORD_TYPE:
    1904                 :             : 
    1905                 :    13996360 :         if (list_length (TYPE_FIELDS (t1)) != list_length (TYPE_FIELDS (t2)))
    1906                 :             :           return false;
    1907                 :             : 
    1908                 :    12165060 :         for (s1 = TYPE_FIELDS (t1), s2 = TYPE_FIELDS (t2);
    1909                 :    13673626 :              s1 && s2;
    1910                 :     1508566 :              s1 = DECL_CHAIN (s1), s2 = DECL_CHAIN (s2))
    1911                 :             :           {
    1912                 :    13611487 :             gcc_assert (TREE_CODE (s1) == FIELD_DECL);
    1913                 :    13611487 :             gcc_assert (TREE_CODE (s2) == FIELD_DECL);
    1914                 :             : 
    1915                 :    13611487 :             tree ft1 = TREE_TYPE (s1);
    1916                 :    13611487 :             tree ft2 = TREE_TYPE (s2);
    1917                 :             : 
    1918                 :    13611487 :             if (DECL_NAME (s1) != DECL_NAME (s2))
    1919                 :             :               return false;
    1920                 :             : 
    1921                 :    12039170 :             if (DECL_ALIGN (s1) != DECL_ALIGN (s2))
    1922                 :             :               return false;
    1923                 :             : 
    1924                 :     3191665 :             if (DECL_C_BIT_FIELD (s1) != DECL_C_BIT_FIELD (s2))
    1925                 :             :                return false;
    1926                 :             : 
    1927                 :     3191645 :             if (DECL_C_BIT_FIELD (s1))
    1928                 :             :               {
    1929                 :         475 :                 if (!tree_int_cst_equal (DECL_SIZE (s1), DECL_SIZE (s2)))
    1930                 :             :                   return false;
    1931                 :             : 
    1932                 :         321 :                 ft1 = DECL_BIT_FIELD_TYPE (s1);
    1933                 :         321 :                 ft2 = DECL_BIT_FIELD_TYPE (s2);
    1934                 :             :               }
    1935                 :             : 
    1936                 :     3191491 :             data->anon_field = !DECL_NAME (s1);
    1937                 :     3191491 :             data->pointedto = false;
    1938                 :             : 
    1939                 :     3191491 :             const struct tagged_tu_seen_cache *cache = data->cache;
    1940                 :     3191491 :             data->cache = &entry;
    1941                 :     3191491 :             bool ret = comptypes_internal (ft1, ft2, data);
    1942                 :     3191491 :             data->cache = cache;
    1943                 :     3191491 :             if (!ret)
    1944                 :             :               return false;
    1945                 :             : 
    1946                 :     1575747 :             tree st1 = TYPE_SIZE (TREE_TYPE (s1));
    1947                 :     1575747 :             tree st2 = TYPE_SIZE (TREE_TYPE (s2));
    1948                 :             : 
    1949                 :     1575747 :             if (data->equiv
    1950                 :      983239 :                 && st1 && TREE_CODE (st1) == INTEGER_CST
    1951                 :      983203 :                 && st2 && TREE_CODE (st2) == INTEGER_CST
    1952                 :     2558947 :                 && !tree_int_cst_equal (st1, st2))
    1953                 :             :              return false;
    1954                 :             : 
    1955                 :     1508583 :             tree counted_by1 = lookup_attribute ("counted_by",
    1956                 :     1508583 :                                                  DECL_ATTRIBUTES (s1));
    1957                 :     1508583 :             tree counted_by2 = lookup_attribute ("counted_by",
    1958                 :     1508583 :                                                  DECL_ATTRIBUTES (s2));
    1959                 :             :             /* If there is no counted_by attribute for both fields.  */
    1960                 :     1508583 :             if (!counted_by1 && !counted_by2)
    1961                 :     1508556 :               continue;
    1962                 :             : 
    1963                 :             :             /* If only one field has counted_by attribute.  */
    1964                 :          27 :             if ((counted_by1 && !counted_by2)
    1965                 :          27 :                 || (!counted_by1 && counted_by2))
    1966                 :             :               return false;
    1967                 :             : 
    1968                 :             :             /* Now both s1 and s2 have counted_by attributes, check
    1969                 :             :                whether they are the same.  */
    1970                 :             : 
    1971                 :          21 :             tree counted_by_field1
    1972                 :          21 :               = lookup_field (t1, TREE_VALUE (TREE_VALUE (counted_by1)));
    1973                 :          21 :             tree counted_by_field2
    1974                 :          21 :               = lookup_field (t2, TREE_VALUE (TREE_VALUE (counted_by2)));
    1975                 :             : 
    1976                 :          21 :             gcc_assert (counted_by_field1 && counted_by_field2);
    1977                 :             : 
    1978                 :          42 :             while (TREE_CHAIN (counted_by_field1))
    1979                 :          21 :               counted_by_field1 = TREE_CHAIN (counted_by_field1);
    1980                 :          38 :             while (TREE_CHAIN (counted_by_field2))
    1981                 :          17 :               counted_by_field2 = TREE_CHAIN (counted_by_field2);
    1982                 :             : 
    1983                 :          21 :             if (DECL_NAME (TREE_VALUE (counted_by_field1))
    1984                 :          21 :                 != DECL_NAME (TREE_VALUE (counted_by_field2)))
    1985                 :             :               return false;
    1986                 :             :           }
    1987                 :             :         return true;
    1988                 :             : 
    1989                 :           0 :     default:
    1990                 :           0 :       gcc_unreachable ();
    1991                 :             :     }
    1992                 :             : }
    1993                 :             : 
    1994                 :             : /* Return true if two function types F1 and F2 are compatible.
    1995                 :             :    If either type specifies no argument types,
    1996                 :             :    the other must specify a fixed number of self-promoting arg types.
    1997                 :             :    Otherwise, if one type specifies only the number of arguments,
    1998                 :             :    the other must specify that number of self-promoting arg types.
    1999                 :             :    Otherwise, the argument types must match.  */
    2000                 :             : 
    2001                 :             : static bool
    2002                 :     2736295 : function_types_compatible_p (const_tree f1, const_tree f2,
    2003                 :             :                              struct comptypes_data *data)
    2004                 :             : {
    2005                 :     2736295 :   tree args1, args2;
    2006                 :             :   /* 1 if no need for warning yet, 2 if warning cause has been seen.  */
    2007                 :     2736295 :   int val = 1;
    2008                 :     2736295 :   int val1;
    2009                 :     2736295 :   tree ret1, ret2;
    2010                 :             : 
    2011                 :     2736295 :   ret1 = TREE_TYPE (f1);
    2012                 :     2736295 :   ret2 = TREE_TYPE (f2);
    2013                 :             : 
    2014                 :             :   /* 'volatile' qualifiers on a function's return type used to mean
    2015                 :             :      the function is noreturn.  */
    2016                 :     2736295 :   if (TYPE_VOLATILE (ret1) != TYPE_VOLATILE (ret2))
    2017                 :          13 :     pedwarn (input_location, 0, "function return types not compatible due to %<volatile%>");
    2018                 :     2736295 :   if (TYPE_VOLATILE (ret1))
    2019                 :           5 :     ret1 = build_qualified_type (TYPE_MAIN_VARIANT (ret1),
    2020                 :           5 :                                  TYPE_QUALS (ret1) & ~TYPE_QUAL_VOLATILE);
    2021                 :     2736295 :   if (TYPE_VOLATILE (ret2))
    2022                 :           8 :     ret2 = build_qualified_type (TYPE_MAIN_VARIANT (ret2),
    2023                 :           8 :                                  TYPE_QUALS (ret2) & ~TYPE_QUAL_VOLATILE);
    2024                 :     2736295 :   val = comptypes_internal (ret1, ret2, data);
    2025                 :     2736295 :   if (val == 0)
    2026                 :             :     return 0;
    2027                 :             : 
    2028                 :     2733732 :   args1 = TYPE_ARG_TYPES (f1);
    2029                 :     2733732 :   args2 = TYPE_ARG_TYPES (f2);
    2030                 :             : 
    2031                 :     2733732 :   if ((args1 == NULL_TREE) != (args2 == NULL_TREE))
    2032                 :       21114 :     data->different_types_p = true;
    2033                 :             : 
    2034                 :             :   /* An unspecified parmlist matches any specified parmlist
    2035                 :             :      whose argument types don't need default promotions.  */
    2036                 :             : 
    2037                 :     2733732 :   if (args1 == NULL_TREE)
    2038                 :             :     {
    2039                 :       20530 :       if (TYPE_NO_NAMED_ARGS_STDARG_P (f1) != TYPE_NO_NAMED_ARGS_STDARG_P (f2))
    2040                 :             :         return 0;
    2041                 :       20528 :       if (!self_promoting_args_p (args2))
    2042                 :             :         return 0;
    2043                 :             :       /* If one of these types comes from a non-prototype fn definition,
    2044                 :             :          compare that with the other type's arglist.
    2045                 :             :          If they don't match, ask for a warning (but no error).  */
    2046                 :       20061 :       if (TYPE_ACTUAL_ARG_TYPES (f1)
    2047                 :       20061 :           && type_lists_compatible_p (args2, TYPE_ACTUAL_ARG_TYPES (f1),
    2048                 :             :                                       data) != 1)
    2049                 :             :         {
    2050                 :          11 :           val = 1;
    2051                 :          11 :           data->warning_needed = true;
    2052                 :             :         }
    2053                 :       20061 :       return val;
    2054                 :             :     }
    2055                 :     2713202 :   if (args2 == NULL_TREE)
    2056                 :             :     {
    2057                 :         613 :       if (TYPE_NO_NAMED_ARGS_STDARG_P (f1) != TYPE_NO_NAMED_ARGS_STDARG_P (f2))
    2058                 :             :         return 0;
    2059                 :         611 :       if (!self_promoting_args_p (args1))
    2060                 :             :         return 0;
    2061                 :         552 :       if (TYPE_ACTUAL_ARG_TYPES (f2)
    2062                 :         552 :           && type_lists_compatible_p (args1, TYPE_ACTUAL_ARG_TYPES (f2),
    2063                 :             :                                       data) != 1)
    2064                 :             :         {
    2065                 :           0 :           val = 1;
    2066                 :           0 :           data->warning_needed = true;
    2067                 :             :         }
    2068                 :         552 :       return val;
    2069                 :             :     }
    2070                 :             : 
    2071                 :             :   /* Both types have argument lists: compare them and propagate results.  */
    2072                 :     2712589 :   val1 = type_lists_compatible_p (args1, args2, data);
    2073                 :     2712589 :   return val1;
    2074                 :             : }
    2075                 :             : 
    2076                 :             : /* Check two lists of types for compatibility, returning false for
    2077                 :             :    incompatible, true for compatible.  */
    2078                 :             : 
    2079                 :             : static bool
    2080                 :     2712627 : type_lists_compatible_p (const_tree args1, const_tree args2,
    2081                 :             :                          struct comptypes_data *data)
    2082                 :             : {
    2083                 :    17220043 :   while (1)
    2084                 :             :     {
    2085                 :     9966335 :       tree a1, mv1, a2, mv2;
    2086                 :     9966335 :       if (args1 == NULL_TREE && args2 == NULL_TREE)
    2087                 :             :         return true;
    2088                 :             :       /* If one list is shorter than the other,
    2089                 :             :          they fail to match.  */
    2090                 :     7394784 :       if (args1 == NULL_TREE || args2 == NULL_TREE)
    2091                 :             :         return 0;
    2092                 :     7394777 :       mv1 = a1 = TREE_VALUE (args1);
    2093                 :     7394777 :       mv2 = a2 = TREE_VALUE (args2);
    2094                 :     7394777 :       if (mv1 && mv1 != error_mark_node && TREE_CODE (mv1) != ARRAY_TYPE)
    2095                 :     7394776 :         mv1 = (TYPE_ATOMIC (mv1)
    2096                 :    14789539 :                ? c_build_qualified_type (TYPE_MAIN_VARIANT (mv1),
    2097                 :             :                                          TYPE_QUAL_ATOMIC)
    2098                 :     7394763 :                : TYPE_MAIN_VARIANT (mv1));
    2099                 :     7394777 :       if (mv2 && mv2 != error_mark_node && TREE_CODE (mv2) != ARRAY_TYPE)
    2100                 :     7394768 :         mv2 = (TYPE_ATOMIC (mv2)
    2101                 :    14789524 :                ? c_build_qualified_type (TYPE_MAIN_VARIANT (mv2),
    2102                 :             :                                          TYPE_QUAL_ATOMIC)
    2103                 :     7394756 :                : TYPE_MAIN_VARIANT (mv2));
    2104                 :             :       /* A null pointer instead of a type
    2105                 :             :          means there is supposed to be an argument
    2106                 :             :          but nothing is specified about what type it has.
    2107                 :             :          So match anything that self-promotes.  */
    2108                 :     7394777 :       if ((a1 == NULL_TREE) != (a2 == NULL_TREE))
    2109                 :           0 :         data->different_types_p = true;
    2110                 :     7394777 :       if (a1 == NULL_TREE)
    2111                 :             :         {
    2112                 :           0 :           if (c_type_promotes_to (a2) != a2)
    2113                 :             :             return 0;
    2114                 :             :         }
    2115                 :     7394777 :       else if (a2 == NULL_TREE)
    2116                 :             :         {
    2117                 :           0 :           if (c_type_promotes_to (a1) != a1)
    2118                 :             :             return 0;
    2119                 :             :         }
    2120                 :             :       /* If one of the lists has an error marker, ignore this arg.  */
    2121                 :     7394777 :       else if (TREE_CODE (a1) == ERROR_MARK
    2122                 :     7394776 :                || TREE_CODE (a2) == ERROR_MARK)
    2123                 :             :         ;
    2124                 :     7394767 :       else if (!comptypes_internal (mv1, mv2, data))
    2125                 :             :         {
    2126                 :      141166 :           data->different_types_p = true;
    2127                 :             :           /* Allow  wait (union {union wait *u; int *i} *)
    2128                 :             :              and  wait (union wait *)  to be compatible.  */
    2129                 :      141166 :           if (TREE_CODE (a1) == UNION_TYPE
    2130                 :          92 :               && (TYPE_NAME (a1) == NULL_TREE
    2131                 :          71 :                   || TYPE_TRANSPARENT_AGGR (a1))
    2132                 :          92 :               && TREE_CODE (TYPE_SIZE (a1)) == INTEGER_CST
    2133                 :      141258 :               && tree_int_cst_equal (TYPE_SIZE (a1),
    2134                 :          92 :                                      TYPE_SIZE (a2)))
    2135                 :             :             {
    2136                 :          92 :               tree memb;
    2137                 :          92 :               for (memb = TYPE_FIELDS (a1);
    2138                 :         120 :                    memb; memb = DECL_CHAIN (memb))
    2139                 :             :                 {
    2140                 :         118 :                   tree mv3 = TREE_TYPE (memb);
    2141                 :         118 :                   if (mv3 && mv3 != error_mark_node
    2142                 :         118 :                       && TREE_CODE (mv3) != ARRAY_TYPE)
    2143                 :         118 :                     mv3 = (TYPE_ATOMIC (mv3)
    2144                 :         236 :                            ? c_build_qualified_type (TYPE_MAIN_VARIANT (mv3),
    2145                 :             :                                                      TYPE_QUAL_ATOMIC)
    2146                 :         118 :                            : TYPE_MAIN_VARIANT (mv3));
    2147                 :         118 :                   if (comptypes_internal (mv3, mv2, data))
    2148                 :             :                     break;
    2149                 :             :                 }
    2150                 :             :               if (memb == NULL_TREE)
    2151                 :             :                 return 0;
    2152                 :             :             }
    2153                 :      141074 :           else if (TREE_CODE (a2) == UNION_TYPE
    2154                 :           9 :                    && (TYPE_NAME (a2) == NULL_TREE
    2155                 :           2 :                        || TYPE_TRANSPARENT_AGGR (a2))
    2156                 :           9 :                    && TREE_CODE (TYPE_SIZE (a2)) == INTEGER_CST
    2157                 :      141083 :                    && tree_int_cst_equal (TYPE_SIZE (a2),
    2158                 :           9 :                                           TYPE_SIZE (a1)))
    2159                 :             :             {
    2160                 :           9 :               tree memb;
    2161                 :           9 :               for (memb = TYPE_FIELDS (a2);
    2162                 :          13 :                    memb; memb = DECL_CHAIN (memb))
    2163                 :             :                 {
    2164                 :          11 :                   tree mv3 = TREE_TYPE (memb);
    2165                 :          11 :                   if (mv3 && mv3 != error_mark_node
    2166                 :          11 :                       && TREE_CODE (mv3) != ARRAY_TYPE)
    2167                 :          11 :                     mv3 = (TYPE_ATOMIC (mv3)
    2168                 :          22 :                            ? c_build_qualified_type (TYPE_MAIN_VARIANT (mv3),
    2169                 :             :                                                      TYPE_QUAL_ATOMIC)
    2170                 :          11 :                            : TYPE_MAIN_VARIANT (mv3));
    2171                 :          11 :                   if (comptypes_internal (mv3, mv1, data))
    2172                 :             :                     break;
    2173                 :             :                 }
    2174                 :             :               if (memb == NULL_TREE)
    2175                 :             :                 return 0;
    2176                 :             :             }
    2177                 :             :           else
    2178                 :      141065 :             return 0;
    2179                 :             :         }
    2180                 :             : 
    2181                 :     7253708 :       args1 = TREE_CHAIN (args1);
    2182                 :     7253708 :       args2 = TREE_CHAIN (args2);
    2183                 :     7253708 :     }
    2184                 :             : }
    2185                 :             : 
    2186                 :             : /* Compute the size to increment a pointer by.  When a function type or void
    2187                 :             :    type or incomplete type is passed, size_one_node is returned.
    2188                 :             :    This function does not emit any diagnostics; the caller is responsible
    2189                 :             :    for that.  */
    2190                 :             : 
    2191                 :             : static tree
    2192                 :      231692 : c_size_in_bytes (const_tree type)
    2193                 :             : {
    2194                 :      231692 :   enum tree_code code = TREE_CODE (type);
    2195                 :             : 
    2196                 :      231692 :   if (code == FUNCTION_TYPE || code == VOID_TYPE || code == ERROR_MARK
    2197                 :      231692 :       || !COMPLETE_TYPE_P (type))
    2198                 :         180 :     return size_one_node;
    2199                 :             : 
    2200                 :             :   /* Convert in case a char is more than one unit.  */
    2201                 :      231512 :   return size_binop_loc (input_location, CEIL_DIV_EXPR, TYPE_SIZE_UNIT (type),
    2202                 :      231512 :                          size_int (TYPE_PRECISION (char_type_node)
    2203                 :             :                                    / BITS_PER_UNIT));
    2204                 :             : }
    2205                 :             : 
    2206                 :             : /* Return either DECL or its known constant value (if it has one).  */
    2207                 :             : 
    2208                 :             : tree
    2209                 :    14074258 : decl_constant_value_1 (tree decl, bool in_init)
    2210                 :             : {
    2211                 :    14074258 :   if (/* Note that DECL_INITIAL isn't valid for a PARM_DECL.  */
    2212                 :    14074258 :       TREE_CODE (decl) != PARM_DECL
    2213                 :    14074258 :       && !TREE_THIS_VOLATILE (decl)
    2214                 :    13730059 :       && TREE_READONLY (decl)
    2215                 :       35518 :       && DECL_INITIAL (decl) != NULL_TREE
    2216                 :       34546 :       && !error_operand_p (DECL_INITIAL (decl))
    2217                 :             :       /* This is invalid if initial value is not constant.
    2218                 :             :          If it has either a function call, a memory reference,
    2219                 :             :          or a variable, then re-evaluating it could give different results.  */
    2220                 :       34537 :       && TREE_CONSTANT (DECL_INITIAL (decl))
    2221                 :             :       /* Check for cases where this is sub-optimal, even though valid.  */
    2222                 :    14095897 :       && (in_init || TREE_CODE (DECL_INITIAL (decl)) != CONSTRUCTOR))
    2223                 :       16448 :     return DECL_INITIAL (decl);
    2224                 :             :   return decl;
    2225                 :             : }
    2226                 :             : 
    2227                 :             : /* Return either DECL or its known constant value (if it has one).
    2228                 :             :    Like the above, but always return decl outside of functions.  */
    2229                 :             : 
    2230                 :             : tree
    2231                 :    14074071 : decl_constant_value (tree decl)
    2232                 :             : {
    2233                 :             :   /* Don't change a variable array bound or initial value to a constant
    2234                 :             :      in a place where a variable is invalid.  */
    2235                 :    14074071 :   return current_function_decl ? decl_constant_value_1 (decl, false) : decl;
    2236                 :             : }
    2237                 :             : 
    2238                 :             : /* Convert the array expression EXP to a pointer.  */
    2239                 :             : static tree
    2240                 :      807286 : array_to_pointer_conversion (location_t loc, tree exp)
    2241                 :             : {
    2242                 :      807286 :   tree orig_exp = exp;
    2243                 :      807286 :   tree type = TREE_TYPE (exp);
    2244                 :      807286 :   tree adr;
    2245                 :      807286 :   tree restype = TREE_TYPE (type);
    2246                 :      807286 :   tree ptrtype;
    2247                 :             : 
    2248                 :      807286 :   gcc_assert (TREE_CODE (type) == ARRAY_TYPE);
    2249                 :             : 
    2250                 :      807286 :   STRIP_TYPE_NOPS (exp);
    2251                 :             : 
    2252                 :      807286 :   copy_warning (exp, orig_exp);
    2253                 :             : 
    2254                 :      807286 :   ptrtype = c_build_pointer_type (restype);
    2255                 :             : 
    2256                 :      807286 :   if (INDIRECT_REF_P (exp))
    2257                 :        2758 :     return convert (ptrtype, TREE_OPERAND (exp, 0));
    2258                 :             : 
    2259                 :             :   /* In C++ array compound literals are temporary objects unless they are
    2260                 :             :      const or appear in namespace scope, so they are destroyed too soon
    2261                 :             :      to use them for much of anything  (c++/53220).  */
    2262                 :      804528 :   if (warn_cxx_compat && TREE_CODE (exp) == COMPOUND_LITERAL_EXPR)
    2263                 :             :     {
    2264                 :          48 :       tree decl = TREE_OPERAND (TREE_OPERAND (exp, 0), 0);
    2265                 :          48 :       if (!TREE_READONLY (decl) && !TREE_STATIC (decl))
    2266                 :          46 :         warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wc___compat,
    2267                 :             :                     "converting an array compound literal to a pointer "
    2268                 :             :                     "leads to a dangling pointer in C++");
    2269                 :             :     }
    2270                 :             : 
    2271                 :      804528 :   adr = build_unary_op (loc, ADDR_EXPR, exp, true);
    2272                 :      804528 :   return convert (ptrtype, adr);
    2273                 :             : }
    2274                 :             : 
    2275                 :             : /* Convert the function expression EXP to a pointer.  */
    2276                 :             : static tree
    2277                 :    51449078 : function_to_pointer_conversion (location_t loc, tree exp)
    2278                 :             : {
    2279                 :    51449078 :   tree orig_exp = exp;
    2280                 :             : 
    2281                 :    51449078 :   gcc_assert (TREE_CODE (TREE_TYPE (exp)) == FUNCTION_TYPE);
    2282                 :             : 
    2283                 :    51449078 :   STRIP_TYPE_NOPS (exp);
    2284                 :             : 
    2285                 :    51449078 :   copy_warning (exp, orig_exp);
    2286                 :             : 
    2287                 :    51449078 :   return build_unary_op (loc, ADDR_EXPR, exp, false);
    2288                 :             : }
    2289                 :             : 
    2290                 :             : /* Mark EXP as read, not just set, for set but not used -Wunused
    2291                 :             :    warning purposes.  */
    2292                 :             : 
    2293                 :             : void
    2294                 :   502095151 : mark_exp_read (tree exp)
    2295                 :             : {
    2296                 :   643354294 :   switch (TREE_CODE (exp))
    2297                 :             :     {
    2298                 :   226963909 :     case VAR_DECL:
    2299                 :   226963909 :     case PARM_DECL:
    2300                 :   226963909 :       DECL_READ_P (exp) = 1;
    2301                 :   226963909 :       break;
    2302                 :   138575949 :     case ARRAY_REF:
    2303                 :   138575949 :     case COMPONENT_REF:
    2304                 :   138575949 :     case MODIFY_EXPR:
    2305                 :   138575949 :     case REALPART_EXPR:
    2306                 :   138575949 :     case IMAGPART_EXPR:
    2307                 :   138575949 :     CASE_CONVERT:
    2308                 :   138575949 :     case ADDR_EXPR:
    2309                 :   138575949 :     case VIEW_CONVERT_EXPR:
    2310                 :   138575949 :       mark_exp_read (TREE_OPERAND (exp, 0));
    2311                 :   138575949 :       break;
    2312                 :      229974 :     case COMPOUND_EXPR:
    2313                 :             :       /* Pattern match what build_atomic_assign produces with modifycode
    2314                 :             :          NOP_EXPR.  */
    2315                 :      229974 :       if (VAR_P (TREE_OPERAND (exp, 1))
    2316                 :       27101 :           && DECL_ARTIFICIAL (TREE_OPERAND (exp, 1))
    2317                 :      256991 :           && TREE_CODE (TREE_OPERAND (exp, 0)) == COMPOUND_EXPR)
    2318                 :             :         {
    2319                 :        2112 :           tree t1 = TREE_OPERAND (TREE_OPERAND (exp, 0), 0);
    2320                 :        2112 :           tree t2 = TREE_OPERAND (TREE_OPERAND (exp, 0), 1);
    2321                 :        2112 :           if (TREE_CODE (t1) == TARGET_EXPR
    2322                 :        2104 :               && TARGET_EXPR_SLOT (t1) == TREE_OPERAND (exp, 1)
    2323                 :        4214 :               && TREE_CODE (t2) == CALL_EXPR)
    2324                 :             :             {
    2325                 :        2102 :               tree fndecl = get_callee_fndecl (t2);
    2326                 :        2102 :               tree arg = NULL_TREE;
    2327                 :        2102 :               if (fndecl
    2328                 :        2102 :                   && TREE_CODE (fndecl) == FUNCTION_DECL
    2329                 :        2102 :                   && fndecl_built_in_p (fndecl, BUILT_IN_NORMAL)
    2330                 :        4204 :                   && call_expr_nargs (t2) >= 2)
    2331                 :        2102 :                 switch (DECL_FUNCTION_CODE (fndecl))
    2332                 :             :                   {
    2333                 :         130 :                   case BUILT_IN_ATOMIC_STORE:
    2334                 :         130 :                     arg = CALL_EXPR_ARG (t2, 1);
    2335                 :         130 :                     break;
    2336                 :        1972 :                   case BUILT_IN_ATOMIC_STORE_1:
    2337                 :        1972 :                   case BUILT_IN_ATOMIC_STORE_2:
    2338                 :        1972 :                   case BUILT_IN_ATOMIC_STORE_4:
    2339                 :        1972 :                   case BUILT_IN_ATOMIC_STORE_8:
    2340                 :        1972 :                   case BUILT_IN_ATOMIC_STORE_16:
    2341                 :        1972 :                     arg = CALL_EXPR_ARG (t2, 0);
    2342                 :        1972 :                     break;
    2343                 :             :                   default:
    2344                 :             :                     break;
    2345                 :             :                   }
    2346                 :        2102 :               if (arg)
    2347                 :             :                 {
    2348                 :        2102 :                   STRIP_NOPS (arg);
    2349                 :        2102 :                   if (TREE_CODE (arg) == ADDR_EXPR
    2350                 :        2102 :                       && DECL_P (TREE_OPERAND (arg, 0))
    2351                 :        4204 :                       && TYPE_ATOMIC (TREE_TYPE (TREE_OPERAND (arg, 0))))
    2352                 :        2102 :                     mark_exp_read (TREE_OPERAND (arg, 0));
    2353                 :             :                 }
    2354                 :             :             }
    2355                 :             :         }
    2356                 :             :       /* FALLTHRU */
    2357                 :     2682777 :     case C_MAYBE_CONST_EXPR:
    2358                 :     2682777 :       mark_exp_read (TREE_OPERAND (exp, 1));
    2359                 :     2682777 :       break;
    2360                 :         452 :     case OMP_ARRAY_SECTION:
    2361                 :         452 :       mark_exp_read (TREE_OPERAND (exp, 0));
    2362                 :         452 :       if (TREE_OPERAND (exp, 1))
    2363                 :         315 :         mark_exp_read (TREE_OPERAND (exp, 1));
    2364                 :         452 :       if (TREE_OPERAND (exp, 2))
    2365                 :         417 :         mark_exp_read (TREE_OPERAND (exp, 2));
    2366                 :             :       break;
    2367                 :             :     default:
    2368                 :             :       break;
    2369                 :             :     }
    2370                 :   502095151 : }
    2371                 :             : 
    2372                 :             : /* Perform the default conversion of arrays and functions to pointers.
    2373                 :             :    Return the result of converting EXP.  For any other expression, just
    2374                 :             :    return EXP.
    2375                 :             : 
    2376                 :             :    LOC is the location of the expression.  */
    2377                 :             : 
    2378                 :             : struct c_expr
    2379                 :   368843604 : default_function_array_conversion (location_t loc, struct c_expr exp)
    2380                 :             : {
    2381                 :   368843604 :   tree orig_exp = exp.value;
    2382                 :   368843604 :   tree type = TREE_TYPE (exp.value);
    2383                 :   368843604 :   enum tree_code code = TREE_CODE (type);
    2384                 :             : 
    2385                 :   368843604 :   switch (code)
    2386                 :             :     {
    2387                 :             :     case ARRAY_TYPE:
    2388                 :             :       {
    2389                 :             :         bool not_lvalue = false;
    2390                 :             :         bool lvalue_array_p;
    2391                 :             : 
    2392                 :      760506 :         while ((TREE_CODE (exp.value) == NON_LVALUE_EXPR
    2393                 :      760506 :                 || CONVERT_EXPR_P (exp.value))
    2394                 :      760506 :                && TREE_TYPE (TREE_OPERAND (exp.value, 0)) == type)
    2395                 :             :           {
    2396                 :           0 :             if (TREE_CODE (exp.value) == NON_LVALUE_EXPR)
    2397                 :           0 :               not_lvalue = true;
    2398                 :           0 :             exp.value = TREE_OPERAND (exp.value, 0);
    2399                 :             :           }
    2400                 :             : 
    2401                 :      760506 :         copy_warning (exp.value, orig_exp);
    2402                 :             : 
    2403                 :      760506 :         lvalue_array_p = !not_lvalue && lvalue_p (exp.value);
    2404                 :      760506 :         if (!flag_isoc99 && !lvalue_array_p)
    2405                 :             :           {
    2406                 :             :             /* Before C99, non-lvalue arrays do not decay to pointers.
    2407                 :             :                Normally, using such an array would be invalid; but it can
    2408                 :             :                be used correctly inside sizeof or as a statement expression.
    2409                 :             :                Thus, do not give an error here; an error will result later.  */
    2410                 :         108 :             return exp;
    2411                 :             :           }
    2412                 :             : 
    2413                 :      760398 :         exp.value = array_to_pointer_conversion (loc, exp.value);
    2414                 :             :       }
    2415                 :      760398 :       break;
    2416                 :      761567 :     case FUNCTION_TYPE:
    2417                 :      761567 :       exp.value = function_to_pointer_conversion (loc, exp.value);
    2418                 :      761567 :       break;
    2419                 :             :     default:
    2420                 :             :       break;
    2421                 :             :     }
    2422                 :             : 
    2423                 :   368843496 :   return exp;
    2424                 :             : }
    2425                 :             : 
    2426                 :             : struct c_expr
    2427                 :      908239 : default_function_array_read_conversion (location_t loc, struct c_expr exp)
    2428                 :             : {
    2429                 :      908239 :   mark_exp_read (exp.value);
    2430                 :      908239 :   return default_function_array_conversion (loc, exp);
    2431                 :             : }
    2432                 :             : 
    2433                 :             : /* Return whether EXPR should be treated as an atomic lvalue for the
    2434                 :             :    purposes of load and store handling.  */
    2435                 :             : 
    2436                 :             : static bool
    2437                 :   369944926 : really_atomic_lvalue (tree expr)
    2438                 :             : {
    2439                 :   369944926 :   if (error_operand_p (expr))
    2440                 :             :     return false;
    2441                 :   369937362 :   if (!TYPE_ATOMIC (TREE_TYPE (expr)))
    2442                 :             :     return false;
    2443                 :       56792 :   if (!lvalue_p (expr))
    2444                 :             :     return false;
    2445                 :             : 
    2446                 :             :   /* Ignore _Atomic on register variables, since their addresses can't
    2447                 :             :      be taken so (a) atomicity is irrelevant and (b) the normal atomic
    2448                 :             :      sequences wouldn't work.  Ignore _Atomic on structures containing
    2449                 :             :      bit-fields, since accessing elements of atomic structures or
    2450                 :             :      unions is undefined behavior (C11 6.5.2.3#5), but it's unclear if
    2451                 :             :      it's undefined at translation time or execution time, and the
    2452                 :             :      normal atomic sequences again wouldn't work.  */
    2453                 :       56826 :   while (handled_component_p (expr))
    2454                 :             :     {
    2455                 :          36 :       if (TREE_CODE (expr) == COMPONENT_REF
    2456                 :          36 :           && DECL_C_BIT_FIELD (TREE_OPERAND (expr, 1)))
    2457                 :             :         return false;
    2458                 :          36 :       expr = TREE_OPERAND (expr, 0);
    2459                 :             :     }
    2460                 :       56790 :   if (DECL_P (expr) && C_DECL_REGISTER (expr))
    2461                 :             :     return false;
    2462                 :             :   return true;
    2463                 :             : }
    2464                 :             : 
    2465                 :             : /* If EXPR is a named constant (C23) derived from a constexpr variable
    2466                 :             :    - that is, a reference to such a variable, or a member extracted by
    2467                 :             :    a sequence of structure and union (but not array) member accesses
    2468                 :             :    (where union member accesses must access the same member as
    2469                 :             :    initialized) - then return the corresponding initializer;
    2470                 :             :    otherwise, return NULL_TREE.  */
    2471                 :             : 
    2472                 :             : static tree
    2473                 :   366798576 : maybe_get_constexpr_init (tree expr)
    2474                 :             : {
    2475                 :   366798576 :   tree decl = NULL_TREE;
    2476                 :   366798576 :   if (TREE_CODE (expr) == VAR_DECL)
    2477                 :             :     decl = expr;
    2478                 :   355384845 :   else if (TREE_CODE (expr) == COMPOUND_LITERAL_EXPR)
    2479                 :      804454 :     decl = COMPOUND_LITERAL_EXPR_DECL (expr);
    2480                 :      804454 :   if (decl
    2481                 :    12218185 :       && C_DECL_DECLARED_CONSTEXPR (decl)
    2482                 :         331 :       && DECL_INITIAL (decl) != NULL_TREE
    2483                 :      804785 :       && !error_operand_p (DECL_INITIAL (decl)))
    2484                 :         331 :     return DECL_INITIAL (decl);
    2485                 :   366798245 :   if (TREE_CODE (expr) != COMPONENT_REF)
    2486                 :             :     return NULL_TREE;
    2487                 :      846848 :   tree inner = maybe_get_constexpr_init (TREE_OPERAND (expr, 0));
    2488                 :      846848 :   if (inner == NULL_TREE)
    2489                 :             :     return NULL_TREE;
    2490                 :         126 :   while ((CONVERT_EXPR_P (inner) || TREE_CODE (inner) == NON_LVALUE_EXPR)
    2491                 :          47 :          && !error_operand_p (inner)
    2492                 :         220 :          && (TYPE_MAIN_VARIANT (TREE_TYPE (inner))
    2493                 :          47 :              == TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (inner, 0)))))
    2494                 :          47 :     inner = TREE_OPERAND (inner, 0);
    2495                 :         126 :   if (TREE_CODE (inner) != CONSTRUCTOR)
    2496                 :             :     return NULL_TREE;
    2497                 :         126 :   tree field = TREE_OPERAND (expr, 1);
    2498                 :         126 :   unsigned HOST_WIDE_INT cidx;
    2499                 :         126 :   tree cfield, cvalue;
    2500                 :         126 :   bool have_other_init = false;
    2501                 :         266 :   FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (inner), cidx, cfield, cvalue)
    2502                 :             :     {
    2503                 :         250 :       if (cfield == field)
    2504                 :             :         return cvalue;
    2505                 :         140 :       have_other_init = true;
    2506                 :             :     }
    2507                 :          16 :   if (TREE_CODE (TREE_TYPE (inner)) == UNION_TYPE
    2508                 :          16 :       && (have_other_init || field != TYPE_FIELDS (TREE_TYPE (inner))))
    2509                 :             :     return NULL_TREE;
    2510                 :             :   /* Return a default initializer.  */
    2511                 :          13 :   if (RECORD_OR_UNION_TYPE_P (TREE_TYPE (expr)))
    2512                 :           5 :     return build_constructor (TREE_TYPE (expr), NULL);
    2513                 :           8 :   return build_zero_cst (TREE_TYPE (expr));
    2514                 :             : }
    2515                 :             : 
    2516                 :             : /* Convert expression EXP (location LOC) from lvalue to rvalue,
    2517                 :             :    including converting functions and arrays to pointers if CONVERT_P.
    2518                 :             :    If READ_P, also mark the expression as having been read.  If
    2519                 :             :    FOR_INIT, constexpr expressions of structure and union type should
    2520                 :             :    be replaced by the corresponding CONSTRUCTOR; otherwise, only
    2521                 :             :    constexpr scalars (including elements of structures and unions) are
    2522                 :             :    replaced by their initializers.  */
    2523                 :             : 
    2524                 :             : struct c_expr
    2525                 :   366137385 : convert_lvalue_to_rvalue (location_t loc, struct c_expr exp,
    2526                 :             :                           bool convert_p, bool read_p, bool for_init)
    2527                 :             : {
    2528                 :   366137385 :   bool force_non_npc = false;
    2529                 :   366137385 :   if (read_p)
    2530                 :   321746154 :     mark_exp_read (exp.value);
    2531                 :   366137385 :   if (convert_p)
    2532                 :   366124369 :     exp = default_function_array_conversion (loc, exp);
    2533                 :   366137385 :   if (!VOID_TYPE_P (TREE_TYPE (exp.value)))
    2534                 :   363708030 :     exp.value = require_complete_type (loc, exp.value);
    2535                 :   366137385 :   if (for_init || !RECORD_OR_UNION_TYPE_P (TREE_TYPE (exp.value)))
    2536                 :             :     {
    2537                 :   365951728 :       tree init = maybe_get_constexpr_init (exp.value);
    2538                 :   365951728 :       if (init != NULL_TREE)
    2539                 :             :         {
    2540                 :             :           /* A named constant of pointer type or type nullptr_t is not
    2541                 :             :              a null pointer constant even if the initializer is
    2542                 :             :              one.  */
    2543                 :         328 :           if (TREE_CODE (init) == INTEGER_CST
    2544                 :         195 :               && !INTEGRAL_TYPE_P (TREE_TYPE (init))
    2545                 :         354 :               && integer_zerop (init))
    2546                 :             :             force_non_npc = true;
    2547                 :             :           exp.value = init;
    2548                 :             :         }
    2549                 :             :     }
    2550                 :   366137385 :   if (really_atomic_lvalue (exp.value))
    2551                 :             :     {
    2552                 :       26493 :       vec<tree, va_gc> *params;
    2553                 :       26493 :       tree nonatomic_type, tmp, tmp_addr, fndecl, func_call;
    2554                 :       26493 :       tree expr_type = TREE_TYPE (exp.value);
    2555                 :       26493 :       tree expr_addr = build_unary_op (loc, ADDR_EXPR, exp.value, false);
    2556                 :       26493 :       tree seq_cst = build_int_cst (integer_type_node, MEMMODEL_SEQ_CST);
    2557                 :             : 
    2558                 :       26493 :       gcc_assert (TYPE_ATOMIC (expr_type));
    2559                 :             : 
    2560                 :             :       /* Expansion of a generic atomic load may require an addition
    2561                 :             :          element, so allocate enough to prevent a resize.  */
    2562                 :       26493 :       vec_alloc (params, 4);
    2563                 :             : 
    2564                 :             :       /* Remove the qualifiers for the rest of the expressions and
    2565                 :             :          create the VAL temp variable to hold the RHS.  */
    2566                 :       26493 :       nonatomic_type = build_qualified_type (expr_type, TYPE_UNQUALIFIED);
    2567                 :       26493 :       tmp = create_tmp_var_raw (nonatomic_type);
    2568                 :       26493 :       tmp_addr = build_unary_op (loc, ADDR_EXPR, tmp, false);
    2569                 :       26493 :       TREE_ADDRESSABLE (tmp) = 1;
    2570                 :             :       /* Do not disable warnings for TMP even though it's artificial.
    2571                 :             :          -Winvalid-memory-model depends on it.  */
    2572                 :             : 
    2573                 :             :       /* Issue __atomic_load (&expr, &tmp, SEQ_CST);  */
    2574                 :       26493 :       fndecl = builtin_decl_explicit (BUILT_IN_ATOMIC_LOAD);
    2575                 :       26493 :       params->quick_push (expr_addr);
    2576                 :       26493 :       params->quick_push (tmp_addr);
    2577                 :       26493 :       params->quick_push (seq_cst);
    2578                 :       26493 :       func_call = c_build_function_call_vec (loc, vNULL, fndecl, params, NULL);
    2579                 :             : 
    2580                 :             :       /* EXPR is always read.  */
    2581                 :       26493 :       mark_exp_read (exp.value);
    2582                 :             : 
    2583                 :             :       /* Return tmp which contains the value loaded.  */
    2584                 :       26493 :       exp.value = build4 (TARGET_EXPR, nonatomic_type, tmp, func_call,
    2585                 :             :                           NULL_TREE, NULL_TREE);
    2586                 :             :     }
    2587                 :   366124369 :   if (convert_p && !error_operand_p (exp.value)
    2588                 :   732254234 :       && (TREE_CODE (TREE_TYPE (exp.value)) != ARRAY_TYPE))
    2589                 :   366116741 :     exp.value = convert (build_qualified_type (TREE_TYPE (exp.value), TYPE_UNQUALIFIED), exp.value);
    2590                 :   366137385 :   if (force_non_npc)
    2591                 :          24 :     exp.value = build1 (NOP_EXPR, TREE_TYPE (exp.value), exp.value);
    2592                 :             : 
    2593                 :   366137385 :   {
    2594                 :   366137385 :     tree false_value, true_value;
    2595                 :   366124369 :     if (convert_p && !error_operand_p (exp.value)
    2596                 :   732254234 :         && c_hardbool_type_attr (TREE_TYPE (exp.value),
    2597                 :             :                                  &false_value, &true_value))
    2598                 :             :       {
    2599                 :        3445 :         tree t = save_expr (exp.value);
    2600                 :             : 
    2601                 :        3445 :         mark_exp_read (exp.value);
    2602                 :             : 
    2603                 :        3445 :         tree trapfn = builtin_decl_explicit (BUILT_IN_TRAP);
    2604                 :        3445 :         tree expr = build_call_expr_loc (loc, trapfn, 0);
    2605                 :        3445 :         expr = build_compound_expr (loc, expr, boolean_true_node);
    2606                 :        3445 :         expr = fold_build3_loc (loc, COND_EXPR, boolean_type_node,
    2607                 :             :                                 fold_build2_loc (loc, NE_EXPR,
    2608                 :             :                                                  boolean_type_node,
    2609                 :             :                                                  t, true_value),
    2610                 :             :                                 expr, boolean_true_node);
    2611                 :        3445 :         expr = fold_build3_loc (loc, COND_EXPR, boolean_type_node,
    2612                 :             :                                 fold_build2_loc (loc, NE_EXPR,
    2613                 :             :                                                  boolean_type_node,
    2614                 :             :                                                  t, false_value),
    2615                 :             :                                 expr, boolean_false_node);
    2616                 :             : 
    2617                 :        3445 :         exp.value = expr;
    2618                 :             :       }
    2619                 :             :   }
    2620                 :             : 
    2621                 :   366137385 :   return exp;
    2622                 :             : }
    2623                 :             : 
    2624                 :             : /* EXP is an expression of integer type.  Apply the integer promotions
    2625                 :             :    to it and return the promoted value.  */
    2626                 :             : 
    2627                 :             : tree
    2628                 :    81560328 : perform_integral_promotions (tree exp)
    2629                 :             : {
    2630                 :    81560328 :   tree type = TREE_TYPE (exp);
    2631                 :    81560328 :   enum tree_code code = TREE_CODE (type);
    2632                 :             : 
    2633                 :    81560328 :   gcc_assert (INTEGRAL_TYPE_P (type));
    2634                 :             : 
    2635                 :             :   /* Convert enums to the result of applying the integer promotions to
    2636                 :             :      their underlying type.  */
    2637                 :    81560328 :   if (code == ENUMERAL_TYPE)
    2638                 :             :     {
    2639                 :      718545 :       type = ENUM_UNDERLYING_TYPE (type);
    2640                 :      718545 :       if (c_promoting_integer_type_p (type))
    2641                 :             :         {
    2642                 :        1312 :           if (TYPE_UNSIGNED (type)
    2643                 :        1312 :               && TYPE_PRECISION (type) == TYPE_PRECISION (integer_type_node))
    2644                 :           0 :             type = unsigned_type_node;
    2645                 :             :           else
    2646                 :        1312 :             type = integer_type_node;
    2647                 :             :         }
    2648                 :             : 
    2649                 :      718545 :       return convert (type, exp);
    2650                 :             :     }
    2651                 :             : 
    2652                 :             :   /* ??? This should no longer be needed now bit-fields have their
    2653                 :             :      proper types.  */
    2654                 :    80841783 :   if (TREE_CODE (exp) == COMPONENT_REF
    2655                 :    80841783 :       && DECL_C_BIT_FIELD (TREE_OPERAND (exp, 1)))
    2656                 :             :     {
    2657                 :       61840 :       if (TREE_CODE (DECL_BIT_FIELD_TYPE (TREE_OPERAND (exp, 1)))
    2658                 :             :           == BITINT_TYPE)
    2659                 :         142 :         return convert (DECL_BIT_FIELD_TYPE (TREE_OPERAND (exp, 1)), exp);
    2660                 :             :       /* If it's thinner than an int, promote it like a
    2661                 :             :          c_promoting_integer_type_p, otherwise leave it alone.  */
    2662                 :       61698 :       if (compare_tree_int (DECL_SIZE (TREE_OPERAND (exp, 1)),
    2663                 :       61698 :                             TYPE_PRECISION (integer_type_node)) < 0)
    2664                 :       53436 :         return convert (integer_type_node, exp);
    2665                 :             :     }
    2666                 :             : 
    2667                 :    80788205 :   if (c_promoting_integer_type_p (type))
    2668                 :             :     {
    2669                 :             :       /* Preserve unsignedness if not really getting any wider.  */
    2670                 :    24845101 :       if (TYPE_UNSIGNED (type)
    2671                 :    24845101 :           && TYPE_PRECISION (type) == TYPE_PRECISION (integer_type_node))
    2672                 :           0 :         return convert (unsigned_type_node, exp);
    2673                 :             : 
    2674                 :    24845101 :       return convert (integer_type_node, exp);
    2675                 :             :     }
    2676                 :             : 
    2677                 :             :   return exp;
    2678                 :             : }
    2679                 :             : 
    2680                 :             : 
    2681                 :             : /* Perform default promotions for C data used in expressions.
    2682                 :             :    Enumeral types or short or char are converted to int.
    2683                 :             :    In addition, manifest constants symbols are replaced by their values.  */
    2684                 :             : 
    2685                 :             : tree
    2686                 :    90856087 : default_conversion (tree exp)
    2687                 :             : {
    2688                 :    90856087 :   tree orig_exp;
    2689                 :    90856087 :   tree type = TREE_TYPE (exp);
    2690                 :    90856087 :   enum tree_code code = TREE_CODE (type);
    2691                 :    90856087 :   tree promoted_type;
    2692                 :             : 
    2693                 :    90856087 :   mark_exp_read (exp);
    2694                 :             : 
    2695                 :             :   /* Functions and arrays have been converted during parsing.  */
    2696                 :    90856087 :   gcc_assert (code != FUNCTION_TYPE);
    2697                 :    90856087 :   if (code == ARRAY_TYPE)
    2698                 :             :     return exp;
    2699                 :             : 
    2700                 :             :   /* Constants can be used directly unless they're not loadable.  */
    2701                 :    90855928 :   if (TREE_CODE (exp) == CONST_DECL)
    2702                 :           0 :     exp = DECL_INITIAL (exp);
    2703                 :             : 
    2704                 :             :   /* Strip no-op conversions.  */
    2705                 :    90855928 :   orig_exp = exp;
    2706                 :    91222107 :   STRIP_TYPE_NOPS (exp);
    2707                 :             : 
    2708                 :    90855928 :   copy_warning (exp, orig_exp);
    2709                 :             : 
    2710                 :    90855928 :   if (code == VOID_TYPE)
    2711                 :             :     {
    2712                 :           2 :       error_at (EXPR_LOC_OR_LOC (exp, input_location),
    2713                 :             :                 "void value not ignored as it ought to be");
    2714                 :           2 :       return error_mark_node;
    2715                 :             :     }
    2716                 :             : 
    2717                 :    90855926 :   exp = require_complete_type (EXPR_LOC_OR_LOC (exp, input_location), exp);
    2718                 :    90855926 :   if (exp == error_mark_node)
    2719                 :             :     return error_mark_node;
    2720                 :             : 
    2721                 :    90855028 :   promoted_type = targetm.promoted_type (type);
    2722                 :    90855028 :   if (promoted_type)
    2723                 :           0 :     return convert (promoted_type, exp);
    2724                 :             : 
    2725                 :    90855028 :   if (INTEGRAL_TYPE_P (type))
    2726                 :    80568564 :     return perform_integral_promotions (exp);
    2727                 :             : 
    2728                 :             :   return exp;
    2729                 :             : }
    2730                 :             : 
    2731                 :             : /* Look up COMPONENT in a structure or union TYPE.
    2732                 :             : 
    2733                 :             :    If the component name is not found, returns NULL_TREE.  Otherwise,
    2734                 :             :    the return value is a TREE_LIST, with each TREE_VALUE a FIELD_DECL
    2735                 :             :    stepping down the chain to the component, which is in the last
    2736                 :             :    TREE_VALUE of the list.  Normally the list is of length one, but if
    2737                 :             :    the component is embedded within (nested) anonymous structures or
    2738                 :             :    unions, the list steps down the chain to the component.  */
    2739                 :             : 
    2740                 :             : tree
    2741                 :     2268750 : lookup_field (const_tree type, tree component)
    2742                 :             : {
    2743                 :     2268750 :   tree field;
    2744                 :             : 
    2745                 :             :   /* If TYPE_LANG_SPECIFIC is set, then it is a sorted array of pointers
    2746                 :             :      to the field elements.  Use a binary search on this array to quickly
    2747                 :             :      find the element.  Otherwise, do a linear search.  TYPE_LANG_SPECIFIC
    2748                 :             :      will always be set for structures which have many elements.
    2749                 :             : 
    2750                 :             :      Duplicate field checking replaces duplicates with NULL_TREE so
    2751                 :             :      TYPE_LANG_SPECIFIC arrays are potentially no longer sorted.  In that
    2752                 :             :      case just iterate using DECL_CHAIN.  */
    2753                 :             : 
    2754                 :     2561880 :   if (TYPE_LANG_SPECIFIC (type) && TYPE_LANG_SPECIFIC (type)->s
    2755                 :     2561880 :       && !seen_error ())
    2756                 :             :     {
    2757                 :      293109 :       int bot, top, half;
    2758                 :      293109 :       tree *field_array = &TYPE_LANG_SPECIFIC (type)->s->elts[0];
    2759                 :             : 
    2760                 :      293109 :       field = TYPE_FIELDS (type);
    2761                 :      293109 :       bot = 0;
    2762                 :      293109 :       top = TYPE_LANG_SPECIFIC (type)->s->len;
    2763                 :     1340577 :       while (top - bot > 1)
    2764                 :             :         {
    2765                 :     1313980 :           half = (top - bot + 1) >> 1;
    2766                 :     1313980 :           field = field_array[bot+half];
    2767                 :             : 
    2768                 :     1313980 :           if (DECL_NAME (field) == NULL_TREE)
    2769                 :             :             {
    2770                 :             :               /* Step through all anon unions in linear fashion.  */
    2771                 :           0 :               while (DECL_NAME (field_array[bot]) == NULL_TREE)
    2772                 :             :                 {
    2773                 :           0 :                   field = field_array[bot++];
    2774                 :           0 :                   if (RECORD_OR_UNION_TYPE_P (TREE_TYPE (field)))
    2775                 :             :                     {
    2776                 :           0 :                       tree anon = lookup_field (TREE_TYPE (field), component);
    2777                 :             : 
    2778                 :           0 :                       if (anon)
    2779                 :           0 :                         return tree_cons (NULL_TREE, field, anon);
    2780                 :             : 
    2781                 :             :                       /* The Plan 9 compiler permits referring
    2782                 :             :                          directly to an anonymous struct/union field
    2783                 :             :                          using a typedef name.  */
    2784                 :           0 :                       if (flag_plan9_extensions
    2785                 :           0 :                           && TYPE_NAME (TREE_TYPE (field)) != NULL_TREE
    2786                 :           0 :                           && (TREE_CODE (TYPE_NAME (TREE_TYPE (field)))
    2787                 :             :                               == TYPE_DECL)
    2788                 :           0 :                           && (DECL_NAME (TYPE_NAME (TREE_TYPE (field)))
    2789                 :             :                               == component))
    2790                 :             :                         break;
    2791                 :             :                     }
    2792                 :             :                 }
    2793                 :             : 
    2794                 :             :               /* Entire record is only anon unions.  */
    2795                 :           0 :               if (bot > top)
    2796                 :             :                 return NULL_TREE;
    2797                 :             : 
    2798                 :             :               /* Restart the binary search, with new lower bound.  */
    2799                 :           0 :               continue;
    2800                 :           0 :             }
    2801                 :             : 
    2802                 :     1313980 :           if (DECL_NAME (field) == component)
    2803                 :             :             break;
    2804                 :     1047468 :           if (DECL_NAME (field) < component)
    2805                 :             :             bot += half;
    2806                 :             :           else
    2807                 :      863728 :             top = bot + half;
    2808                 :             :         }
    2809                 :             : 
    2810                 :      293109 :       if (DECL_NAME (field_array[bot]) == component)
    2811                 :             :         field = field_array[bot];
    2812                 :      266512 :       else if (DECL_NAME (field) != component)
    2813                 :             :         return NULL_TREE;
    2814                 :             :     }
    2815                 :             :   else
    2816                 :             :     {
    2817                 :     5174846 :       for (field = TYPE_FIELDS (type); field; field = DECL_CHAIN (field))
    2818                 :             :         {
    2819                 :     5166111 :           if (DECL_NAME (field) == NULL_TREE
    2820                 :     5166111 :               && RECORD_OR_UNION_TYPE_P (TREE_TYPE (field)))
    2821                 :             :             {
    2822                 :       10827 :               tree anon = lookup_field (TREE_TYPE (field), component);
    2823                 :             : 
    2824                 :       10827 :               if (anon)
    2825                 :        2165 :                 return tree_cons (NULL_TREE, field, anon);
    2826                 :             : 
    2827                 :             :               /* The Plan 9 compiler permits referring directly to an
    2828                 :             :                  anonymous struct/union field using a typedef
    2829                 :             :                  name.  */
    2830                 :        8662 :               if (flag_plan9_extensions
    2831                 :          38 :                   && TYPE_NAME (TREE_TYPE (field)) != NULL_TREE
    2832                 :          36 :                   && TREE_CODE (TYPE_NAME (TREE_TYPE (field))) == TYPE_DECL
    2833                 :        8668 :                   && (DECL_NAME (TYPE_NAME (TREE_TYPE (field)))
    2834                 :             :                       == component))
    2835                 :             :                 break;
    2836                 :             :             }
    2837                 :             : 
    2838                 :     5163942 :           if (DECL_NAME (field) == component)
    2839                 :             :             break;
    2840                 :             :         }
    2841                 :             : 
    2842                 :     1973476 :       if (field == NULL_TREE)
    2843                 :             :         return NULL_TREE;
    2844                 :             :     }
    2845                 :             : 
    2846                 :     2257850 :   return tree_cons (NULL_TREE, field, NULL_TREE);
    2847                 :             : }
    2848                 :             : 
    2849                 :             : /* Recursively append candidate IDENTIFIER_NODEs to CANDIDATES.  */
    2850                 :             : 
    2851                 :             : static void
    2852                 :         101 : lookup_field_fuzzy_find_candidates (tree type, tree component,
    2853                 :             :                                     vec<tree> *candidates)
    2854                 :             : {
    2855                 :         101 :   tree field;
    2856                 :         259 :   for (field = TYPE_FIELDS (type); field; field = DECL_CHAIN (field))
    2857                 :             :     {
    2858                 :         158 :       if (DECL_NAME (field) == NULL_TREE
    2859                 :         158 :           && RECORD_OR_UNION_TYPE_P (TREE_TYPE (field)))
    2860                 :          30 :         lookup_field_fuzzy_find_candidates (TREE_TYPE (field), component,
    2861                 :             :                                             candidates);
    2862                 :             : 
    2863                 :         158 :       if (DECL_NAME (field))
    2864                 :         112 :         candidates->safe_push (DECL_NAME (field));
    2865                 :             :     }
    2866                 :         101 : }
    2867                 :             : 
    2868                 :             : /* Like "lookup_field", but find the closest matching IDENTIFIER_NODE,
    2869                 :             :    rather than returning a TREE_LIST for an exact match.  */
    2870                 :             : 
    2871                 :             : static tree
    2872                 :          71 : lookup_field_fuzzy (tree type, tree component)
    2873                 :             : {
    2874                 :          71 :   gcc_assert (TREE_CODE (component) == IDENTIFIER_NODE);
    2875                 :             : 
    2876                 :             :   /* First, gather a list of candidates.  */
    2877                 :          71 :   auto_vec <tree> candidates;
    2878                 :             : 
    2879                 :          71 :   lookup_field_fuzzy_find_candidates (type, component,
    2880                 :             :                                       &candidates);
    2881                 :             : 
    2882                 :          71 :   return find_closest_identifier (component, &candidates);
    2883                 :          71 : }
    2884                 :             : 
    2885                 :             : /* Support function for build_component_ref's error-handling.
    2886                 :             : 
    2887                 :             :    Given DATUM_TYPE, and "DATUM.COMPONENT", where DATUM is *not* a
    2888                 :             :    struct or union, should we suggest "DATUM->COMPONENT" as a hint?  */
    2889                 :             : 
    2890                 :             : static bool
    2891                 :          72 : should_suggest_deref_p (tree datum_type)
    2892                 :             : {
    2893                 :             :   /* We don't do it for Objective-C, since Objective-C 2.0 dot-syntax
    2894                 :             :      allows "." for ptrs; we could be handling a failed attempt
    2895                 :             :      to access a property.  */
    2896                 :          72 :   if (c_dialect_objc ())
    2897                 :             :     return false;
    2898                 :             : 
    2899                 :             :   /* Only suggest it for pointers...  */
    2900                 :          72 :   if (TREE_CODE (datum_type) != POINTER_TYPE)
    2901                 :             :     return false;
    2902                 :             : 
    2903                 :             :   /* ...to structs/unions.  */
    2904                 :           8 :   tree underlying_type = TREE_TYPE (datum_type);
    2905                 :           8 :   enum tree_code code = TREE_CODE (underlying_type);
    2906                 :           8 :   if (code == RECORD_TYPE || code == UNION_TYPE)
    2907                 :             :     return true;
    2908                 :             :   else
    2909                 :           1 :     return false;
    2910                 :             : }
    2911                 :             : 
    2912                 :             : /* For a SUBDATUM field of a structure or union DATUM, generate a REF to
    2913                 :             :    the object that represents its counted_by per the attribute counted_by
    2914                 :             :    attached to this field if it's a flexible array member field, otherwise
    2915                 :             :    return NULL_TREE.
    2916                 :             :    Set COUNTED_BY_TYPE to the TYPE of the counted_by field.
    2917                 :             :    For example, if:
    2918                 :             : 
    2919                 :             :     struct P {
    2920                 :             :       int k;
    2921                 :             :       int x[] __attribute__ ((counted_by (k)));
    2922                 :             :     } *p;
    2923                 :             : 
    2924                 :             :     for:
    2925                 :             :     p->x
    2926                 :             : 
    2927                 :             :     the ref to the object that represents its element count will be:
    2928                 :             : 
    2929                 :             :     &(p->k)
    2930                 :             : 
    2931                 :             : */
    2932                 :             : static tree
    2933                 :     2176298 : build_counted_by_ref (tree datum, tree subdatum, tree *counted_by_type)
    2934                 :             : {
    2935                 :     2176298 :   tree type = TREE_TYPE (datum);
    2936                 :     2176298 :   if (!c_flexible_array_member_type_p (TREE_TYPE (subdatum)))
    2937                 :             :     return NULL_TREE;
    2938                 :             : 
    2939                 :       70451 :   tree attr_counted_by = lookup_attribute ("counted_by",
    2940                 :       70451 :                                            DECL_ATTRIBUTES (subdatum));
    2941                 :       70451 :   tree counted_by_ref = NULL_TREE;
    2942                 :       70451 :   *counted_by_type = NULL_TREE;
    2943                 :       70451 :   if (attr_counted_by)
    2944                 :             :     {
    2945                 :         150 :       tree field_id = TREE_VALUE (TREE_VALUE (attr_counted_by));
    2946                 :         150 :       counted_by_ref
    2947                 :         150 :         = build_component_ref (UNKNOWN_LOCATION,
    2948                 :             :                                datum, field_id,
    2949                 :             :                                UNKNOWN_LOCATION, UNKNOWN_LOCATION);
    2950                 :         150 :       counted_by_ref = build_fold_addr_expr (counted_by_ref);
    2951                 :             : 
    2952                 :             :       /* Get the TYPE of the counted_by field.  */
    2953                 :         150 :       tree counted_by_field = lookup_field (type, field_id);
    2954                 :         150 :       gcc_assert (counted_by_field);
    2955                 :             : 
    2956                 :         196 :       do
    2957                 :             :         {
    2958                 :         196 :           *counted_by_type = TREE_TYPE (TREE_VALUE (counted_by_field));
    2959                 :         196 :           counted_by_field = TREE_CHAIN (counted_by_field);
    2960                 :             :         }
    2961                 :         196 :       while (counted_by_field);
    2962                 :             :     }
    2963                 :             :   return counted_by_ref;
    2964                 :             : }
    2965                 :             : 
    2966                 :             : /* Given a COMPONENT_REF REF with the location LOC, the corresponding
    2967                 :             :    COUNTED_BY_REF, and the COUNTED_BY_TYPE, generate an INDIRECT_REF
    2968                 :             :    to a call to the internal function .ACCESS_WITH_SIZE.
    2969                 :             : 
    2970                 :             :    REF
    2971                 :             : 
    2972                 :             :    to:
    2973                 :             : 
    2974                 :             :    (*.ACCESS_WITH_SIZE (REF, COUNTED_BY_REF, 1, (TYPE_OF_SIZE)0, -1,
    2975                 :             :                         (TYPE_OF_ARRAY *)0))
    2976                 :             : 
    2977                 :             :    NOTE: The return type of this function is the POINTER type pointing
    2978                 :             :    to the original flexible array type.
    2979                 :             :    Then the type of the INDIRECT_REF is the original flexible array type.
    2980                 :             : 
    2981                 :             :    The type of the first argument of this function is a POINTER type
    2982                 :             :    to the original flexible array type.
    2983                 :             : 
    2984                 :             :    The 4th argument of the call is a constant 0 with the TYPE of the
    2985                 :             :    object pointed by COUNTED_BY_REF.
    2986                 :             : 
    2987                 :             :    The 6th argument of the call is a constant 0 with the pointer TYPE
    2988                 :             :    to the original flexible array type.
    2989                 :             : 
    2990                 :             :   */
    2991                 :             : static tree
    2992                 :         150 : build_access_with_size_for_counted_by (location_t loc, tree ref,
    2993                 :             :                                        tree counted_by_ref,
    2994                 :             :                                        tree counted_by_type)
    2995                 :             : {
    2996                 :         150 :   gcc_assert (c_flexible_array_member_type_p (TREE_TYPE (ref)));
    2997                 :             :   /* The result type of the call is a pointer to the flexible array type.  */
    2998                 :         150 :   tree result_type = c_build_pointer_type (TREE_TYPE (ref));
    2999                 :             : 
    3000                 :         150 :   tree call
    3001                 :         150 :     = build_call_expr_internal_loc (loc, IFN_ACCESS_WITH_SIZE,
    3002                 :             :                                     result_type, 6,
    3003                 :             :                                     array_to_pointer_conversion (loc, ref),
    3004                 :             :                                     counted_by_ref,
    3005                 :         150 :                                     build_int_cst (integer_type_node, 1),
    3006                 :         150 :                                     build_int_cst (counted_by_type, 0),
    3007                 :         150 :                                     build_int_cst (integer_type_node, -1),
    3008                 :         150 :                                     build_int_cst (result_type, 0));
    3009                 :             :   /* Wrap the call with an INDIRECT_REF with the flexible array type.  */
    3010                 :         150 :   call = build1 (INDIRECT_REF, TREE_TYPE (ref), call);
    3011                 :         150 :   SET_EXPR_LOCATION (call, loc);
    3012                 :         150 :   return call;
    3013                 :             : }
    3014                 :             : 
    3015                 :             : /* For the COMPONENT_REF ref, check whether it has a counted_by attribute,
    3016                 :             :    if so, wrap this COMPONENT_REF with the corresponding CALL to the
    3017                 :             :    function .ACCESS_WITH_SIZE.
    3018                 :             :    Otherwise, return the ref itself.  */
    3019                 :             : 
    3020                 :             : tree
    3021                 :     2176298 : handle_counted_by_for_component_ref (location_t loc, tree ref)
    3022                 :             : {
    3023                 :     2176298 :   gcc_assert (TREE_CODE (ref) == COMPONENT_REF);
    3024                 :     2176298 :   tree datum = TREE_OPERAND (ref, 0);
    3025                 :     2176298 :   tree subdatum = TREE_OPERAND (ref, 1);
    3026                 :     2176298 :   tree counted_by_type = NULL_TREE;
    3027                 :     2176298 :   tree counted_by_ref = build_counted_by_ref (datum, subdatum,
    3028                 :             :                                               &counted_by_type);
    3029                 :     2176298 :   if (counted_by_ref)
    3030                 :         150 :     ref = build_access_with_size_for_counted_by (loc, ref,
    3031                 :             :                                                  counted_by_ref,
    3032                 :             :                                                  counted_by_type);
    3033                 :     2176298 :   return ref;
    3034                 :             : }
    3035                 :             : 
    3036                 :             : /* Make an expression to refer to the COMPONENT field of structure or
    3037                 :             :    union value DATUM.  COMPONENT is an IDENTIFIER_NODE.  LOC is the
    3038                 :             :    location of the COMPONENT_REF.  COMPONENT_LOC is the location
    3039                 :             :    of COMPONENT.  ARROW_LOC is the location of the first -> operand if
    3040                 :             :    it is from -> operator.
    3041                 :             :    If HANDLE_COUNTED_BY is true, check the counted_by attribute and generate
    3042                 :             :    a call to .ACCESS_WITH_SIZE.  Otherwise, ignore the attribute.  */
    3043                 :             : 
    3044                 :             : tree
    3045                 :     2225912 : build_component_ref (location_t loc, tree datum, tree component,
    3046                 :             :                      location_t component_loc, location_t arrow_loc,
    3047                 :             :                      bool handle_counted_by)
    3048                 :             : {
    3049                 :     2225912 :   tree type = TREE_TYPE (datum);
    3050                 :     2225912 :   enum tree_code code = TREE_CODE (type);
    3051                 :     2225912 :   tree field = NULL;
    3052                 :     2225912 :   tree ref;
    3053                 :     2225912 :   bool datum_lvalue = lvalue_p (datum);
    3054                 :             : 
    3055                 :     2225912 :   if (!objc_is_public (datum, component))
    3056                 :           0 :     return error_mark_node;
    3057                 :             : 
    3058                 :             :   /* Detect Objective-C property syntax object.property.  */
    3059                 :     2225912 :   if (c_dialect_objc ()
    3060                 :     2225912 :       && (ref = objc_maybe_build_component_ref (datum, component)))
    3061                 :             :     return ref;
    3062                 :             : 
    3063                 :             :   /* See if there is a field or component with name COMPONENT.  */
    3064                 :             : 
    3065                 :     2225912 :   if (code == RECORD_TYPE || code == UNION_TYPE)
    3066                 :             :     {
    3067                 :     2225840 :       if (!COMPLETE_TYPE_P (type))
    3068                 :             :         {
    3069                 :          15 :           c_incomplete_type_error (loc, NULL_TREE, type);
    3070                 :          15 :           return error_mark_node;
    3071                 :             :         }
    3072                 :             : 
    3073                 :     2225825 :       field = lookup_field (type, component);
    3074                 :             : 
    3075                 :     2225825 :       if (!field)
    3076                 :             :         {
    3077                 :          63 :           tree guessed_id = lookup_field_fuzzy (type, component);
    3078                 :          63 :           if (guessed_id)
    3079                 :             :             {
    3080                 :             :               /* Attempt to provide a fixit replacement hint, if
    3081                 :             :                  we have a valid range for the component.  */
    3082                 :          54 :               location_t reported_loc
    3083                 :          27 :                 = (component_loc != UNKNOWN_LOCATION) ? component_loc : loc;
    3084                 :          27 :               gcc_rich_location rich_loc (reported_loc);
    3085                 :          27 :               if (component_loc != UNKNOWN_LOCATION)
    3086                 :          27 :                 rich_loc.add_fixit_misspelled_id (component_loc, guessed_id);
    3087                 :          27 :               error_at (&rich_loc,
    3088                 :             :                         "%qT has no member named %qE; did you mean %qE?",
    3089                 :             :                         type, component, guessed_id);
    3090                 :          27 :             }
    3091                 :             :           else
    3092                 :          36 :             error_at (loc, "%qT has no member named %qE", type, component);
    3093                 :          63 :           return error_mark_node;
    3094                 :             :         }
    3095                 :             : 
    3096                 :             :       /* Accessing elements of atomic structures or unions is undefined
    3097                 :             :          behavior (C11 6.5.2.3#5).  */
    3098                 :     2225762 :       if (TYPE_ATOMIC (type) && c_inhibit_evaluation_warnings == 0)
    3099                 :             :         {
    3100                 :          18 :           if (code == RECORD_TYPE)
    3101                 :          12 :             warning_at (loc, 0, "accessing a member %qE of an atomic "
    3102                 :             :                         "structure %qE", component, datum);
    3103                 :             :           else
    3104                 :           6 :             warning_at (loc, 0, "accessing a member %qE of an atomic "
    3105                 :             :                         "union %qE", component, datum);
    3106                 :             :         }
    3107                 :             : 
    3108                 :             :       /* Chain the COMPONENT_REFs if necessary down to the FIELD.
    3109                 :             :          This might be better solved in future the way the C++ front
    3110                 :             :          end does it - by giving the anonymous entities each a
    3111                 :             :          separate name and type, and then have build_component_ref
    3112                 :             :          recursively call itself.  We can't do that here.  */
    3113                 :     2227780 :       do
    3114                 :             :         {
    3115                 :     2227780 :           tree subdatum = TREE_VALUE (field);
    3116                 :     2227780 :           int quals;
    3117                 :     2227780 :           tree subtype;
    3118                 :     2227780 :           bool use_datum_quals;
    3119                 :             :           /* Do not handle counted_by when in typeof and alignof operator.  */
    3120                 :     2227780 :           handle_counted_by = handle_counted_by && !in_typeof && !in_alignof;
    3121                 :             : 
    3122                 :     2227780 :           if (TREE_TYPE (subdatum) == error_mark_node)
    3123                 :             :             return error_mark_node;
    3124                 :             : 
    3125                 :             :           /* If this is an rvalue, it does not have qualifiers in C
    3126                 :             :              standard terms and we must avoid propagating such
    3127                 :             :              qualifiers down to a non-lvalue array that is then
    3128                 :             :              converted to a pointer.  */
    3129                 :     4455560 :           use_datum_quals = (datum_lvalue
    3130                 :     2227780 :                              || TREE_CODE (TREE_TYPE (subdatum)) != ARRAY_TYPE);
    3131                 :             : 
    3132                 :     2227780 :           quals = TYPE_QUALS (strip_array_types (TREE_TYPE (subdatum)));
    3133                 :     2227780 :           if (use_datum_quals)
    3134                 :     2227518 :             quals |= TYPE_QUALS (TREE_TYPE (datum));
    3135                 :     2227780 :           subtype = c_build_qualified_type (TREE_TYPE (subdatum), quals);
    3136                 :             : 
    3137                 :     2227780 :           ref = build3 (COMPONENT_REF, subtype, datum, subdatum,
    3138                 :             :                         NULL_TREE);
    3139                 :     2227780 :           SET_EXPR_LOCATION (ref, loc);
    3140                 :             : 
    3141                 :     2227780 :           if (handle_counted_by)
    3142                 :     2176288 :             ref = handle_counted_by_for_component_ref (loc, ref);
    3143                 :             : 
    3144                 :     2227780 :           if (TREE_READONLY (subdatum)
    3145                 :     2227780 :               || (use_datum_quals && TREE_READONLY (datum)))
    3146                 :       30306 :             TREE_READONLY (ref) = 1;
    3147                 :     2227780 :           if (TREE_THIS_VOLATILE (subdatum)
    3148                 :     2226958 :               || (use_datum_quals && TREE_THIS_VOLATILE (datum)))
    3149                 :        2241 :             TREE_THIS_VOLATILE (ref) = 1;
    3150                 :             : 
    3151                 :     2227780 :           if (TREE_UNAVAILABLE (subdatum))
    3152                 :          10 :             error_unavailable_use (subdatum, NULL_TREE);
    3153                 :     2227770 :           else if (TREE_DEPRECATED (subdatum))
    3154                 :          16 :             warn_deprecated_use (subdatum, NULL_TREE);
    3155                 :             : 
    3156                 :     2227780 :           datum = ref;
    3157                 :             : 
    3158                 :     2227780 :           field = TREE_CHAIN (field);
    3159                 :             :         }
    3160                 :     2227780 :       while (field);
    3161                 :             : 
    3162                 :             :       return ref;
    3163                 :             :     }
    3164                 :          72 :   else if (should_suggest_deref_p (type))
    3165                 :             :     {
    3166                 :             :       /* Special-case the error message for "ptr.field" for the case
    3167                 :             :          where the user has confused "." vs "->".  */
    3168                 :           7 :       rich_location richloc (line_table, loc);
    3169                 :           7 :       if (INDIRECT_REF_P (datum) && arrow_loc != UNKNOWN_LOCATION)
    3170                 :             :         {
    3171                 :           2 :           richloc.add_fixit_insert_before (arrow_loc, "(*");
    3172                 :           2 :           richloc.add_fixit_insert_after (arrow_loc, ")");
    3173                 :           2 :           error_at (&richloc,
    3174                 :             :                     "%qE is a pointer to pointer; did you mean to dereference "
    3175                 :             :                     "it before applying %<->%> to it?",
    3176                 :           2 :                     TREE_OPERAND (datum, 0));
    3177                 :             :         }
    3178                 :             :       else
    3179                 :             :         {
    3180                 :             :           /* "loc" should be the "." token.  */
    3181                 :           5 :           richloc.add_fixit_replace ("->");
    3182                 :           5 :           error_at (&richloc,
    3183                 :             :                     "%qE is a pointer; did you mean to use %<->%>?",
    3184                 :             :                     datum);
    3185                 :             :         }
    3186                 :           7 :       return error_mark_node;
    3187                 :           7 :     }
    3188                 :          65 :   else if (code != ERROR_MARK)
    3189                 :           1 :     error_at (loc,
    3190                 :             :               "request for member %qE in something not a structure or union",
    3191                 :             :               component);
    3192                 :             : 
    3193                 :          65 :   return error_mark_node;
    3194                 :             : }
    3195                 :             : 
    3196                 :             : /* Given an expression PTR for a pointer, return an expression
    3197                 :             :    for the value pointed to.
    3198                 :             :    ERRORSTRING is the name of the operator to appear in error messages.
    3199                 :             : 
    3200                 :             :    LOC is the location to use for the generated tree.  */
    3201                 :             : 
    3202                 :             : tree
    3203                 :     2673227 : build_indirect_ref (location_t loc, tree ptr, ref_operator errstring)
    3204                 :             : {
    3205                 :     2673227 :   tree pointer = default_conversion (ptr);
    3206                 :     2673227 :   tree type = TREE_TYPE (pointer);
    3207                 :     2673227 :   tree ref;
    3208                 :             : 
    3209                 :     2673227 :   if (TREE_CODE (type) == POINTER_TYPE)
    3210                 :             :     {
    3211                 :     2672876 :       if (CONVERT_EXPR_P (pointer)
    3212                 :     1904896 :           || TREE_CODE (pointer) == VIEW_CONVERT_EXPR)
    3213                 :             :         {
    3214                 :             :           /* If a warning is issued, mark it to avoid duplicates from
    3215                 :             :              the backend.  This only needs to be done at
    3216                 :             :              warn_strict_aliasing > 2.  */
    3217                 :      767980 :           if (warn_strict_aliasing > 2)
    3218                 :      333289 :             if (strict_aliasing_warning (EXPR_LOCATION (pointer),
    3219                 :      333289 :                                          type, TREE_OPERAND (pointer, 0)))
    3220                 :           7 :               suppress_warning (pointer, OPT_Wstrict_aliasing_);
    3221                 :             :         }
    3222                 :             : 
    3223                 :     2672876 :       if (TREE_CODE (pointer) == ADDR_EXPR
    3224                 :     2672876 :           && (TREE_TYPE (TREE_OPERAND (pointer, 0))
    3225                 :       66773 :               == TREE_TYPE (type)))
    3226                 :             :         {
    3227                 :       66764 :           ref = TREE_OPERAND (pointer, 0);
    3228                 :       66764 :           protected_set_expr_location (ref, loc);
    3229                 :       66764 :           return ref;
    3230                 :             :         }
    3231                 :             :       else
    3232                 :             :         {
    3233                 :     2606112 :           tree t = TREE_TYPE (type);
    3234                 :             : 
    3235                 :     2606112 :           ref = build1 (INDIRECT_REF, t, pointer);
    3236                 :             : 
    3237                 :     2606112 :           if (VOID_TYPE_P (t) && c_inhibit_evaluation_warnings == 0)
    3238                 :         147 :             warning_at (loc, 0, "dereferencing %<void *%> pointer");
    3239                 :             : 
    3240                 :             :           /* We *must* set TREE_READONLY when dereferencing a pointer to const,
    3241                 :             :              so that we get the proper error message if the result is used
    3242                 :             :              to assign to.  Also, &* is supposed to be a no-op.
    3243                 :             :              And ANSI C seems to specify that the type of the result
    3244                 :             :              should be the const type.  */
    3245                 :             :           /* A de-reference of a pointer to const is not a const.  It is valid
    3246                 :             :              to change it via some other pointer.  */
    3247                 :     2606112 :           TREE_READONLY (ref) = TYPE_READONLY (t);
    3248                 :     2606112 :           TREE_SIDE_EFFECTS (ref)
    3249                 :     2606112 :             = TYPE_VOLATILE (t) || TREE_SIDE_EFFECTS (pointer);
    3250                 :     2606112 :           TREE_THIS_VOLATILE (ref) = TYPE_VOLATILE (t);
    3251                 :     2606112 :           protected_set_expr_location (ref, loc);
    3252                 :     2606112 :           return ref;
    3253                 :             :         }
    3254                 :             :     }
    3255                 :         351 :   else if (TREE_CODE (pointer) != ERROR_MARK)
    3256                 :         278 :     invalid_indirection_error (loc, type, errstring);
    3257                 :             : 
    3258                 :         351 :   return error_mark_node;
    3259                 :             : }
    3260                 :             : 
    3261                 :             : /* This handles expressions of the form "a[i]", which denotes
    3262                 :             :    an array reference.
    3263                 :             : 
    3264                 :             :    This is logically equivalent in C to *(a+i), but we may do it differently.
    3265                 :             :    If A is a variable or a member, we generate a primitive ARRAY_REF.
    3266                 :             :    This avoids forcing the array out of registers, and can work on
    3267                 :             :    arrays that are not lvalues (for example, members of structures returned
    3268                 :             :    by functions).
    3269                 :             : 
    3270                 :             :    For vector types, allow vector[i] but not i[vector], and create
    3271                 :             :    *(((type*)&vectortype) + i) for the expression.
    3272                 :             : 
    3273                 :             :    LOC is the location to use for the returned expression.  */
    3274                 :             : 
    3275                 :             : tree
    3276                 :     3393286 : build_array_ref (location_t loc, tree array, tree index)
    3277                 :             : {
    3278                 :     3393286 :   tree ret;
    3279                 :     3393286 :   bool swapped = false;
    3280                 :     3393286 :   if (TREE_TYPE (array) == error_mark_node
    3281                 :     3393286 :       || TREE_TYPE (index) == error_mark_node)
    3282                 :             :     return error_mark_node;
    3283                 :             : 
    3284                 :     3393178 :   if (TREE_CODE (TREE_TYPE (array)) != ARRAY_TYPE
    3285                 :     1939743 :       && TREE_CODE (TREE_TYPE (array)) != POINTER_TYPE
    3286                 :             :       /* Allow vector[index] but not index[vector].  */
    3287                 :     4392980 :       && !gnu_vector_type_p (TREE_TYPE (array)))
    3288                 :             :     {
    3289                 :         194 :       if (TREE_CODE (TREE_TYPE (index)) != ARRAY_TYPE
    3290                 :         194 :           && TREE_CODE (TREE_TYPE (index)) != POINTER_TYPE)
    3291                 :             :         {
    3292                 :           2 :           error_at (loc,
    3293                 :             :             "subscripted value is neither array nor pointer nor vector");
    3294                 :             : 
    3295                 :           2 :           return error_mark_node;
    3296                 :             :         }
    3297                 :         192 :       std::swap (array, index);
    3298                 :         192 :       swapped = true;
    3299                 :             :     }
    3300                 :             : 
    3301                 :     3393176 :   if (!INTEGRAL_TYPE_P (TREE_TYPE (index)))
    3302                 :             :     {
    3303                 :           2 :       error_at (loc, "array subscript is not an integer");
    3304                 :           2 :       return error_mark_node;
    3305                 :             :     }
    3306                 :             : 
    3307                 :     3393174 :   if (TREE_CODE (TREE_TYPE (TREE_TYPE (array))) == FUNCTION_TYPE)
    3308                 :             :     {
    3309                 :          10 :       error_at (loc, "subscripted value is pointer to function");
    3310                 :          10 :       return error_mark_node;
    3311                 :             :     }
    3312                 :             : 
    3313                 :             :   /* ??? Existing practice has been to warn only when the char
    3314                 :             :      index is syntactically the index, not for char[array].  */
    3315                 :     3393164 :   if (!swapped)
    3316                 :     3392978 :      warn_array_subscript_with_type_char (loc, index);
    3317                 :             : 
    3318                 :             :   /* Apply default promotions *after* noticing character types.  */
    3319                 :     3393164 :   index = default_conversion (index);
    3320                 :     3393164 :   if (index == error_mark_node)
    3321                 :             :     return error_mark_node;
    3322                 :             : 
    3323                 :     3393163 :   gcc_assert (TREE_CODE (TREE_TYPE (index)) == INTEGER_TYPE
    3324                 :             :               || TREE_CODE (TREE_TYPE (index)) == BITINT_TYPE);
    3325                 :             : 
    3326                 :     3393163 :   bool was_vector = VECTOR_TYPE_P (TREE_TYPE (array));
    3327                 :     3393163 :   bool non_lvalue = convert_vector_to_array_for_subscript (loc, &array, index);
    3328                 :             : 
    3329                 :     3393163 :   if (TREE_CODE (TREE_TYPE (array)) == ARRAY_TYPE)
    3330                 :             :     {
    3331                 :     2453050 :       tree rval, type;
    3332                 :             : 
    3333                 :             :       /* An array that is indexed by a non-constant
    3334                 :             :          cannot be stored in a register; we must be able to do
    3335                 :             :          address arithmetic on its address.
    3336                 :             :          Likewise an array of elements of variable size.  */
    3337                 :     2453050 :       if (TREE_CODE (index) != INTEGER_CST
    3338                 :     2453050 :           || (COMPLETE_TYPE_P (TREE_TYPE (TREE_TYPE (array)))
    3339                 :     1991139 :               && TREE_CODE (TYPE_SIZE (TREE_TYPE (TREE_TYPE (array)))) != INTEGER_CST))
    3340                 :             :         {
    3341                 :      462648 :           if (!c_mark_addressable (array, true))
    3342                 :           1 :             return error_mark_node;
    3343                 :             :         }
    3344                 :             :       /* An array that is indexed by a constant value which is not within
    3345                 :             :          the array bounds cannot be stored in a register either; because we
    3346                 :             :          would get a crash in store_bit_field/extract_bit_field when trying
    3347                 :             :          to access a non-existent part of the register.  */
    3348                 :     2453049 :       if (TREE_CODE (index) == INTEGER_CST
    3349                 :     1991139 :           && TYPE_DOMAIN (TREE_TYPE (array))
    3350                 :     4440857 :           && !int_fits_type_p (index, TYPE_DOMAIN (TREE_TYPE (array))))
    3351                 :             :         {
    3352                 :       60552 :           if (!c_mark_addressable (array))
    3353                 :           0 :             return error_mark_node;
    3354                 :             :         }
    3355                 :             : 
    3356                 :     2453049 :       if ((pedantic || warn_c90_c99_compat)
    3357                 :     2430152 :           && ! was_vector)
    3358                 :             :         {
    3359                 :     1452732 :           tree foo = array;
    3360                 :     2275359 :           while (TREE_CODE (foo) == COMPONENT_REF)
    3361                 :      822627 :             foo = TREE_OPERAND (foo, 0);
    3362                 :     1452732 :           if (VAR_P (foo) && C_DECL_REGISTER (foo))
    3363                 :           0 :             pedwarn (loc, OPT_Wpedantic,
    3364                 :             :                      "ISO C forbids subscripting %<register%> array");
    3365                 :     1452732 :           else if (!lvalue_p (foo))
    3366                 :         114 :             pedwarn_c90 (loc, OPT_Wpedantic,
    3367                 :             :                          "ISO C90 forbids subscripting non-lvalue "
    3368                 :             :                          "array");
    3369                 :             :         }
    3370                 :             : 
    3371                 :     2453049 :       if (TREE_CODE (TREE_TYPE (index)) == BITINT_TYPE
    3372                 :     2453049 :           && TYPE_PRECISION (TREE_TYPE (index)) > TYPE_PRECISION (sizetype))
    3373                 :           3 :         index = fold_convert (sizetype, index);
    3374                 :             : 
    3375                 :     2453049 :       type = TREE_TYPE (TREE_TYPE (array));
    3376                 :     2453049 :       rval = build4 (ARRAY_REF, type, array, index, NULL_TREE, NULL_TREE);
    3377                 :             :       /* Array ref is const/volatile if the array elements are
    3378                 :             :          or if the array is.  */
    3379                 :     7359147 :       TREE_READONLY (rval)
    3380                 :     2453049 :         |= (TYPE_READONLY (TREE_TYPE (TREE_TYPE (array)))
    3381                 :     2453049 :             | TREE_READONLY (array));
    3382                 :     7359147 :       TREE_SIDE_EFFECTS (rval)
    3383                 :     2453049 :         |= (TYPE_VOLATILE (TREE_TYPE (TREE_TYPE (array)))
    3384                 :     2453049 :             | TREE_SIDE_EFFECTS (array));
    3385                 :     4906098 :       TREE_THIS_VOLATILE (rval)
    3386                 :     2453049 :         |= (TYPE_VOLATILE (TREE_TYPE (TREE_TYPE (array)))
    3387                 :             :             /* This was added by rms on 16 Nov 91.
    3388                 :             :                It fixes  vol struct foo *a;  a->elts[1]
    3389                 :             :                in an inline function.
    3390                 :             :                Hope it doesn't break something else.  */
    3391                 :     2453049 :             | TREE_THIS_VOLATILE (array));
    3392                 :     2453049 :       ret = require_complete_type (loc, rval);
    3393                 :     2453049 :       protected_set_expr_location (ret, loc);
    3394                 :     2453049 :       if (non_lvalue)
    3395                 :      103046 :         ret = non_lvalue_loc (loc, ret);
    3396                 :     2453049 :       return ret;
    3397                 :             :     }
    3398                 :             :   else
    3399                 :             :     {
    3400                 :      940113 :       tree ar = default_conversion (array);
    3401                 :             : 
    3402                 :      940113 :       if (ar == error_mark_node)
    3403                 :             :         return ar;
    3404                 :             : 
    3405                 :      940113 :       gcc_assert (TREE_CODE (TREE_TYPE (ar)) == POINTER_TYPE);
    3406                 :      940113 :       gcc_assert (TREE_CODE (TREE_TYPE (TREE_TYPE (ar))) != FUNCTION_TYPE);
    3407                 :             : 
    3408                 :      940113 :       ret = build_indirect_ref (loc, build_binary_op (loc, PLUS_EXPR, ar,
    3409                 :             :                                                       index, false),
    3410                 :             :                                 RO_ARRAY_INDEXING);
    3411                 :      940113 :       if (non_lvalue)
    3412                 :           0 :         ret = non_lvalue_loc (loc, ret);
    3413                 :      940113 :       return ret;
    3414                 :             :     }
    3415                 :             : }
    3416                 :             : 
    3417                 :             : /* Build an OpenMP array section reference, creating an exact type for the
    3418                 :             :    resulting expression based on the element type and bounds if possible.  If
    3419                 :             :    we have variable bounds, create an incomplete array type for the result
    3420                 :             :    instead.  */
    3421                 :             : 
    3422                 :             : tree
    3423                 :        3634 : build_omp_array_section (location_t loc, tree array, tree index, tree length)
    3424                 :             : {
    3425                 :        3634 :   tree type = TREE_TYPE (array);
    3426                 :        3634 :   gcc_assert (type);
    3427                 :             : 
    3428                 :        3634 :   tree sectype, eltype = TREE_TYPE (type);
    3429                 :             : 
    3430                 :             :   /* It's not an array or pointer type.  Just reuse the type of the original
    3431                 :             :      expression as the type of the array section (an error will be raised
    3432                 :             :      anyway, later).  */
    3433                 :        3634 :   if (eltype == NULL_TREE || error_operand_p (eltype))
    3434                 :          11 :     sectype = TREE_TYPE (array);
    3435                 :             :   else
    3436                 :             :     {
    3437                 :        3623 :       tree idxtype = NULL_TREE;
    3438                 :             : 
    3439                 :        3623 :       if (index != NULL_TREE
    3440                 :        3623 :           && length != NULL_TREE
    3441                 :        2822 :           && INTEGRAL_TYPE_P (TREE_TYPE (index))
    3442                 :        6440 :           && INTEGRAL_TYPE_P (TREE_TYPE (length)))
    3443                 :             :         {
    3444                 :        2814 :           tree low = fold_convert (sizetype, index);
    3445                 :        2814 :           tree high = fold_convert (sizetype, length);
    3446                 :        2814 :           high = size_binop (PLUS_EXPR, low, high);
    3447                 :        2814 :           high = size_binop (MINUS_EXPR, high, size_one_node);
    3448                 :        2814 :           idxtype = build_range_type (sizetype, low, high);
    3449                 :             :         }
    3450                 :         131 :       else if ((index == NULL_TREE || integer_zerop (index))
    3451                 :         699 :                && length != NULL_TREE
    3452                 :        1356 :                && INTEGRAL_TYPE_P (TREE_TYPE (length)))
    3453                 :         534 :         idxtype = build_index_type (length);
    3454                 :             : 
    3455                 :        3623 :       gcc_assert (!error_operand_p (idxtype));
    3456                 :             : 
    3457                 :        3623 :       sectype = c_build_array_type (eltype, idxtype);
    3458                 :             :     }
    3459                 :             : 
    3460                 :        3634 :   return build3_loc (loc, OMP_ARRAY_SECTION, sectype, array, index, length);
    3461                 :             : }
    3462                 :             : 
    3463                 :             : 
    3464                 :             : /* Build an external reference to identifier ID.  FUN indicates
    3465                 :             :    whether this will be used for a function call.  LOC is the source
    3466                 :             :    location of the identifier.  This sets *TYPE to the type of the
    3467                 :             :    identifier, which is not the same as the type of the returned value
    3468                 :             :    for CONST_DECLs defined as enum constants.  If the type of the
    3469                 :             :    identifier is not available, *TYPE is set to NULL.  */
    3470                 :             : tree
    3471                 :   178947280 : build_external_ref (location_t loc, tree id, bool fun, tree *type)
    3472                 :             : {
    3473                 :   178947280 :   tree ref;
    3474                 :   178947280 :   tree decl = lookup_name (id);
    3475                 :             : 
    3476                 :             :   /* In Objective-C, an instance variable (ivar) may be preferred to
    3477                 :             :      whatever lookup_name() found.  */
    3478                 :   178947280 :   decl = objc_lookup_ivar (decl, id);
    3479                 :             : 
    3480                 :   178947280 :   *type = NULL;
    3481                 :   178947280 :   if (decl && decl != error_mark_node)
    3482                 :             :     {
    3483                 :   178940949 :       ref = decl;
    3484                 :   178940949 :       *type = TREE_TYPE (ref);
    3485                 :   178940949 :       if (DECL_P (decl) && C_DECL_UNDERSPECIFIED (decl))
    3486                 :           4 :         error_at (loc, "underspecified %qD referenced in its initializer",
    3487                 :             :                   decl);
    3488                 :             :     }
    3489                 :        6331 :   else if (fun)
    3490                 :             :     /* Implicit function declaration.  */
    3491                 :        4734 :     ref = implicitly_declare (loc, id);
    3492                 :        1597 :   else if (decl == error_mark_node)
    3493                 :             :     /* Don't complain about something that's already been
    3494                 :             :        complained about.  */
    3495                 :             :     return error_mark_node;
    3496                 :             :   else
    3497                 :             :     {
    3498                 :        1367 :       undeclared_variable (loc, id);
    3499                 :        1367 :       return error_mark_node;
    3500                 :             :     }
    3501                 :             : 
    3502                 :             :   /* For an OpenMP map clause, we can get better diagnostics for decls with
    3503                 :             :      unmappable types if we return the decl with an error_mark_node type,
    3504                 :             :      rather than returning error_mark_node for the decl itself.  */
    3505                 :   178945683 :   if (TREE_TYPE (ref) == error_mark_node
    3506                 :   178945683 :       && !c_omp_array_section_p)
    3507                 :             :     return error_mark_node;
    3508                 :             : 
    3509                 :   178945666 :   if (TREE_UNAVAILABLE (ref))
    3510                 :          14 :     error_unavailable_use (ref, NULL_TREE);
    3511                 :   178945652 :   else if (TREE_DEPRECATED (ref))
    3512                 :          49 :     warn_deprecated_use (ref, NULL_TREE);
    3513                 :             : 
    3514                 :             :   /* Recursive call does not count as usage.  */
    3515                 :   178945666 :   if (ref != current_function_decl)
    3516                 :             :     {
    3517                 :   178942964 :       TREE_USED (ref) = 1;
    3518                 :             :     }
    3519                 :             : 
    3520                 :   178945666 :   if (TREE_CODE (ref) == FUNCTION_DECL && !in_alignof)
    3521                 :             :     {
    3522                 :    52109527 :       if (!in_sizeof && !in_typeof)
    3523                 :    51512988 :         C_DECL_USED (ref) = 1;
    3524                 :      596539 :       else if (DECL_INITIAL (ref) == NULL_TREE
    3525                 :      590441 :                && DECL_EXTERNAL (ref)
    3526                 :     1186979 :                && !TREE_PUBLIC (ref))
    3527                 :          98 :         record_maybe_used_decl (ref);
    3528                 :             :     }
    3529                 :             : 
    3530                 :   178945666 :   if (TREE_CODE (ref) == CONST_DECL)
    3531                 :             :     {
    3532                 :      408502 :       used_types_insert (TREE_TYPE (ref));
    3533                 :             : 
    3534                 :      408502 :       if (warn_cxx_compat
    3535                 :         329 :           && TREE_CODE (TREE_TYPE (ref)) == ENUMERAL_TYPE
    3536                 :      408829 :           && C_TYPE_DEFINED_IN_STRUCT (TREE_TYPE (ref)))
    3537                 :             :         {
    3538                 :           1 :           warning_at (loc, OPT_Wc___compat,
    3539                 :             :                       ("enum constant defined in struct or union "
    3540                 :             :                        "is not visible in C++"));
    3541                 :           1 :           inform (DECL_SOURCE_LOCATION (ref), "enum constant defined here");
    3542                 :             :         }
    3543                 :             : 
    3544                 :      408502 :       ref = DECL_INITIAL (ref);
    3545                 :      408502 :       TREE_CONSTANT (ref) = 1;
    3546                 :             :     }
    3547                 :   178537164 :   else if (current_function_decl != NULL_TREE
    3548                 :   177072522 :            && !DECL_FILE_SCOPE_P (current_function_decl)
    3549                 :   178537164 :            && (VAR_OR_FUNCTION_DECL_P (ref)
    3550                 :             :                || TREE_CODE (ref) == PARM_DECL))
    3551                 :             :     {
    3552                 :       10080 :       tree context = decl_function_context (ref);
    3553                 :             : 
    3554                 :       10080 :       if (context != NULL_TREE && context != current_function_decl)
    3555                 :        1612 :         DECL_NONLOCAL (ref) = 1;
    3556                 :             :     }
    3557                 :             :   /* C99 6.7.4p3: An inline definition of a function with external
    3558                 :             :      linkage ... shall not contain a reference to an identifier with
    3559                 :             :      internal linkage.  */
    3560                 :   178527084 :   else if (current_function_decl != NULL_TREE
    3561                 :   177062442 :            && DECL_DECLARED_INLINE_P (current_function_decl)
    3562                 :   163711573 :            && DECL_EXTERNAL (current_function_decl)
    3563                 :   162961869 :            && VAR_OR_FUNCTION_DECL_P (ref)
    3564                 :    57338760 :            && (!VAR_P (ref) || TREE_STATIC (ref))
    3565                 :    48255840 :            && ! TREE_PUBLIC (ref)
    3566                 :   178527118 :            && DECL_CONTEXT (ref) != current_function_decl)
    3567                 :          25 :     record_inline_static (loc, current_function_decl, ref,
    3568                 :             :                           csi_internal);
    3569                 :             : 
    3570                 :             :   return ref;
    3571                 :             : }
    3572                 :             : 
    3573                 :             : /* Record details of decls possibly used inside sizeof or typeof.  */
    3574                 :             : struct maybe_used_decl
    3575                 :             : {
    3576                 :             :   /* The decl.  */
    3577                 :             :   tree decl;
    3578                 :             :   /* The level seen at (in_sizeof + in_typeof).  */
    3579                 :             :   int level;
    3580                 :             :   /* The next one at this level or above, or NULL.  */
    3581                 :             :   struct maybe_used_decl *next;
    3582                 :             : };
    3583                 :             : 
    3584                 :             : static struct maybe_used_decl *maybe_used_decls;
    3585                 :             : 
    3586                 :             : /* Record that DECL, an undefined static function reference seen
    3587                 :             :    inside sizeof or typeof, might be used if the operand of sizeof is
    3588                 :             :    a VLA type or the operand of typeof is a variably modified
    3589                 :             :    type.  */
    3590                 :             : 
    3591                 :             : static void
    3592                 :          98 : record_maybe_used_decl (tree decl)
    3593                 :             : {
    3594                 :          98 :   struct maybe_used_decl *t = XOBNEW (&parser_obstack, struct maybe_used_decl);
    3595                 :          98 :   t->decl = decl;
    3596                 :          98 :   t->level = in_sizeof + in_typeof;
    3597                 :          98 :   t->next = maybe_used_decls;
    3598                 :          98 :   maybe_used_decls = t;
    3599                 :          98 : }
    3600                 :             : 
    3601                 :             : /* Pop the stack of decls possibly used inside sizeof or typeof.  If
    3602                 :             :    USED is false, just discard them.  If it is true, mark them used
    3603                 :             :    (if no longer inside sizeof or typeof) or move them to the next
    3604                 :             :    level up (if still inside sizeof or typeof).  */
    3605                 :             : 
    3606                 :             : void
    3607                 :     1407252 : pop_maybe_used (bool used)
    3608                 :             : {
    3609                 :     1407252 :   struct maybe_used_decl *p = maybe_used_decls;
    3610                 :     1407252 :   int cur_level = in_sizeof + in_typeof;
    3611                 :     1407353 :   while (p && p->level > cur_level)
    3612                 :             :     {
    3613                 :         101 :       if (used)
    3614                 :             :         {
    3615                 :          12 :           if (cur_level == 0)
    3616                 :           9 :             C_DECL_USED (p->decl) = 1;
    3617                 :             :           else
    3618                 :           3 :             p->level = cur_level;
    3619                 :             :         }
    3620                 :         101 :       p = p->next;
    3621                 :             :     }
    3622                 :     1407252 :   if (!used || cur_level == 0)
    3623                 :     1407236 :     maybe_used_decls = p;
    3624                 :     1407252 : }
    3625                 :             : 
    3626                 :             : /* Return the result of sizeof applied to EXPR.  */
    3627                 :             : 
    3628                 :             : struct c_expr
    3629                 :      300463 : c_expr_sizeof_expr (location_t loc, struct c_expr expr)
    3630                 :             : {
    3631                 :      300463 :   struct c_expr ret;
    3632                 :      300463 :   if (expr.value == error_mark_node)
    3633                 :             :     {
    3634                 :         109 :       ret.value = error_mark_node;
    3635                 :         109 :       ret.original_code = ERROR_MARK;
    3636                 :         109 :       ret.original_type = NULL;
    3637                 :         109 :       ret.m_decimal = 0;
    3638                 :         109 :       pop_maybe_used (false);
    3639                 :             :     }
    3640                 :             :   else
    3641                 :             :     {
    3642                 :      300354 :       bool expr_const_operands = true;
    3643                 :             : 
    3644                 :      300354 :       if (TREE_CODE (expr.value) == PARM_DECL
    3645                 :      300354 :           && C_ARRAY_PARAMETER (expr.value))
    3646                 :             :         {
    3647                 :          55 :           auto_diagnostic_group d;
    3648                 :          55 :           if (warning_at (loc, OPT_Wsizeof_array_argument,
    3649                 :             :                           "%<sizeof%> on array function parameter %qE will "
    3650                 :             :                           "return size of %qT", expr.value,
    3651                 :          55 :                           TREE_TYPE (expr.value)))
    3652                 :          19 :             inform (DECL_SOURCE_LOCATION (expr.value), "declared here");
    3653                 :          55 :         }
    3654                 :      300354 :       tree folded_expr = c_fully_fold (expr.value, require_constant_value,
    3655                 :             :                                        &expr_const_operands);
    3656                 :      300354 :       ret.value = c_sizeof (loc, TREE_TYPE (folded_expr));
    3657                 :      300354 :       c_last_sizeof_arg = expr.value;
    3658                 :      300354 :       c_last_sizeof_loc = loc;
    3659                 :      300354 :       ret.original_code = SIZEOF_EXPR;
    3660                 :      300354 :       ret.original_type = NULL;
    3661                 :      300354 :       ret.m_decimal = 0;
    3662                 :      300354 :       if (C_TYPE_VARIABLE_SIZE (TREE_TYPE (folded_expr)))
    3663                 :             :         {
    3664                 :             :           /* sizeof is evaluated when given a vla (C99 6.5.3.4p2).  */
    3665                 :         271 :           ret.value = build2 (C_MAYBE_CONST_EXPR, TREE_TYPE (ret.value),
    3666                 :             :                               folded_expr, ret.value);
    3667                 :         271 :           C_MAYBE_CONST_EXPR_NON_CONST (ret.value) = !expr_const_operands;
    3668                 :         271 :           SET_EXPR_LOCATION (ret.value, loc);
    3669                 :             :         }
    3670                 :      300354 :       pop_maybe_used (C_TYPE_VARIABLE_SIZE (TREE_TYPE (folded_expr)));
    3671                 :             :     }
    3672                 :      300463 :   return ret;
    3673                 :             : }
    3674                 :             : 
    3675                 :             : /* Return the result of sizeof applied to T, a structure for the type
    3676                 :             :    name passed to sizeof (rather than the type itself).  LOC is the
    3677                 :             :    location of the original expression.  */
    3678                 :             : 
    3679                 :             : struct c_expr
    3680                 :      328196 : c_expr_sizeof_type (location_t loc, struct c_type_name *t)
    3681                 :             : {
    3682                 :      328196 :   tree type;
    3683                 :      328196 :   struct c_expr ret;
    3684                 :      328196 :   tree type_expr = NULL_TREE;
    3685                 :      328196 :   bool type_expr_const = true;
    3686                 :      328196 :   type = groktypename (t, &type_expr, &type_expr_const);
    3687                 :      328196 :   ret.value = c_sizeof (loc, type);
    3688                 :      328196 :   c_last_sizeof_arg = type;
    3689                 :      328196 :   c_last_sizeof_loc = loc;
    3690                 :      328196 :   ret.original_code = SIZEOF_EXPR;
    3691                 :      328196 :   ret.original_type = NULL;
    3692                 :      328196 :   ret.m_decimal = 0;
    3693                 :      328196 :   if (type == error_mark_node)
    3694                 :             :     {
    3695                 :           5 :       ret.value = error_mark_node;
    3696                 :           5 :       ret.original_code = ERROR_MARK;
    3697                 :             :     }
    3698                 :             :   else
    3699                 :      328149 :   if ((type_expr || TREE_CODE (ret.value) == INTEGER_CST)
    3700                 :      656280 :       && C_TYPE_VARIABLE_SIZE (type))
    3701                 :             :     {
    3702                 :             :       /* If the type is a [*] array, it is a VLA but is represented as
    3703                 :             :          having a size of zero.  In such a case we must ensure that
    3704                 :             :          the result of sizeof does not get folded to a constant by
    3705                 :             :          c_fully_fold, because if the size is evaluated the result is
    3706                 :             :          not constant and so constraints on zero or negative size
    3707                 :             :          arrays must not be applied when this sizeof call is inside
    3708                 :             :          another array declarator.  */
    3709                 :          41 :       if (!type_expr)
    3710                 :          16 :         type_expr = integer_zero_node;
    3711                 :          41 :       ret.value = build2 (C_MAYBE_CONST_EXPR, TREE_TYPE (ret.value),
    3712                 :             :                           type_expr, ret.value);
    3713                 :          41 :       C_MAYBE_CONST_EXPR_NON_CONST (ret.value) = !type_expr_const;
    3714                 :             :     }
    3715                 :      328196 :   pop_maybe_used (type != error_mark_node
    3716                 :      328196 :                   ? C_TYPE_VARIABLE_SIZE (type) : false);
    3717                 :      328196 :   return ret;
    3718                 :             : }
    3719                 :             : 
    3720                 :             : /* Build a function call to function FUNCTION with parameters PARAMS.
    3721                 :             :    The function call is at LOC.
    3722                 :             :    PARAMS is a list--a chain of TREE_LIST nodes--in which the
    3723                 :             :    TREE_VALUE of each node is a parameter-expression.
    3724                 :             :    FUNCTION's data type may be a function type or a pointer-to-function.  */
    3725                 :             : 
    3726                 :             : tree
    3727                 :           0 : build_function_call (location_t loc, tree function, tree params)
    3728                 :             : {
    3729                 :           0 :   vec<tree, va_gc> *v;
    3730                 :           0 :   tree ret;
    3731                 :             : 
    3732                 :           0 :   vec_alloc (v, list_length (params));
    3733                 :           0 :   for (; params; params = TREE_CHAIN (params))
    3734                 :           0 :     v->quick_push (TREE_VALUE (params));
    3735                 :           0 :   ret = c_build_function_call_vec (loc, vNULL, function, v, NULL);
    3736                 :           0 :   vec_free (v);
    3737                 :           0 :   return ret;
    3738                 :             : }
    3739                 :             : 
    3740                 :             : /* Give a note about the location of the declaration of DECL.  */
    3741                 :             : 
    3742                 :             : static void
    3743                 :         287 : inform_declaration (tree decl)
    3744                 :             : {
    3745                 :         287 :   if (decl && (TREE_CODE (decl) != FUNCTION_DECL
    3746                 :         272 :                || !DECL_IS_UNDECLARED_BUILTIN (decl)))
    3747                 :         201 :     inform (DECL_SOURCE_LOCATION (decl), "declared here");
    3748                 :         287 : }
    3749                 :             : 
    3750                 :             : /* C implementation of callback for use when checking param types.  */
    3751                 :             : 
    3752                 :             : static bool
    3753                 :           2 : comp_parm_types (tree wanted_type, tree actual_type)
    3754                 :             : {
    3755                 :           2 :   return comptypes (wanted_type, actual_type);
    3756                 :             : }
    3757                 :             : 
    3758                 :             : /* Build a function call to function FUNCTION with parameters PARAMS.
    3759                 :             :    If FUNCTION is the result of resolving an overloaded target built-in,
    3760                 :             :    ORIG_FUNDECL is the original function decl, otherwise it is null.
    3761                 :             :    ORIGTYPES, if not NULL, is a vector of types; each element is
    3762                 :             :    either NULL or the original type of the corresponding element in
    3763                 :             :    PARAMS.  The original type may differ from TREE_TYPE of the
    3764                 :             :    parameter for enums.  FUNCTION's data type may be a function type
    3765                 :             :    or pointer-to-function.  This function changes the elements of
    3766                 :             :    PARAMS.  */
    3767                 :             : 
    3768                 :             : tree
    3769                 :    50750197 : build_function_call_vec (location_t loc, vec<location_t> arg_loc,
    3770                 :             :                          tree function, vec<tree, va_gc> *params,
    3771                 :             :                          vec<tree, va_gc> *origtypes, tree orig_fundecl)
    3772                 :             : {
    3773                 :    50750197 :   tree fntype, fundecl = NULL_TREE;
    3774                 :    50750197 :   tree name = NULL_TREE, result;
    3775                 :    50750197 :   tree tem;
    3776                 :    50750197 :   int nargs;
    3777                 :    50750197 :   tree *argarray;
    3778                 :             : 
    3779                 :             : 
    3780                 :             :   /* Strip NON_LVALUE_EXPRs, etc., since we aren't using as an lvalue.  */
    3781                 :    50750197 :   STRIP_TYPE_NOPS (function);
    3782                 :             : 
    3783                 :             :   /* Convert anything with function type to a pointer-to-function.  */
    3784                 :    50750197 :   if (TREE_CODE (function) == FUNCTION_DECL)
    3785                 :             :     {
    3786                 :    50673450 :       name = DECL_NAME (function);
    3787                 :             : 
    3788                 :    50673450 :       if (flag_tm)
    3789                 :         421 :         tm_malloc_replacement (function);
    3790                 :    50673450 :       fundecl = function;
    3791                 :    50673450 :       if (!orig_fundecl)
    3792                 :    50673450 :         orig_fundecl = fundecl;
    3793                 :             :       /* Atomic functions have type checking/casting already done.  They are
    3794                 :             :          often rewritten and don't match the original parameter list.  */
    3795                 :   101346900 :       if (name && startswith (IDENTIFIER_POINTER (name), "__atomic_"))
    3796                 :             :         origtypes = NULL;
    3797                 :             :     }
    3798                 :    50750197 :   if (TREE_CODE (TREE_TYPE (function)) == FUNCTION_TYPE)
    3799                 :    50687511 :     function = function_to_pointer_conversion (loc, function);
    3800                 :             : 
    3801                 :             :   /* For Objective-C, convert any calls via a cast to OBJC_TYPE_REF
    3802                 :             :      expressions, like those used for ObjC messenger dispatches.  */
    3803                 :    50750197 :   if (params && !params->is_empty ())
    3804                 :    38660041 :     function = objc_rewrite_function_call (function, (*params)[0]);
    3805                 :             : 
    3806                 :    50750197 :   function = c_fully_fold (function, false, NULL);
    3807                 :             : 
    3808                 :    50750197 :   fntype = TREE_TYPE (function);
    3809                 :             : 
    3810                 :    50750197 :   if (TREE_CODE (fntype) == ERROR_MARK)
    3811                 :           3 :     return error_mark_node;
    3812                 :             : 
    3813                 :    50750194 :   if (!(TREE_CODE (fntype) == POINTER_TYPE
    3814                 :    50750160 :         && TREE_CODE (TREE_TYPE (fntype)) == FUNCTION_TYPE))
    3815                 :             :     {
    3816                 :          37 :       if (!flag_diagnostics_show_caret && !STATEMENT_CLASS_P (function))
    3817                 :          33 :         error_at (loc,
    3818                 :             :                   "called object %qE is not a function or function pointer",
    3819                 :             :                   function);
    3820                 :           4 :       else if (DECL_P (function))
    3821                 :             :         {
    3822                 :           1 :           error_at (loc,
    3823                 :             :                     "called object %qD is not a function or function pointer",
    3824                 :             :                     function);
    3825                 :           1 :           inform_declaration (function);
    3826                 :             :         }
    3827                 :             :       else
    3828                 :           3 :         error_at (loc,
    3829                 :             :                   "called object is not a function or function pointer");
    3830                 :          37 :       return error_mark_node;
    3831                 :             :     }
    3832                 :             : 
    3833                 :    50750157 :   if (fundecl && TREE_THIS_VOLATILE (fundecl))
    3834                 :      368984 :     current_function_returns_abnormally = 1;
    3835                 :             : 
    3836                 :             :   /* fntype now gets the type of function pointed to.  */
    3837                 :    50750157 :   fntype = TREE_TYPE (fntype);
    3838                 :    50750157 :   tree return_type = TREE_TYPE (fntype);
    3839                 :             : 
    3840                 :             :   /* Convert the parameters to the types declared in the
    3841                 :             :      function prototype, or apply default promotions.  */
    3842                 :             : 
    3843                 :    50750157 :   nargs = convert_arguments (loc, arg_loc, fntype, params,
    3844                 :             :                              origtypes, function, fundecl);
    3845                 :    50750157 :   if (nargs < 0)
    3846                 :         173 :     return error_mark_node;
    3847                 :             : 
    3848                 :             :   /* Check that the function is called through a compatible prototype.
    3849                 :             :      If it is not, warn.  */
    3850                 :    50749136 :   if (CONVERT_EXPR_P (function)
    3851                 :         863 :       && TREE_CODE (tem = TREE_OPERAND (function, 0)) == ADDR_EXPR
    3852                 :         200 :       && TREE_CODE (tem = TREE_OPERAND (tem, 0)) == FUNCTION_DECL
    3853                 :    50750154 :       && !comptypes (fntype, TREE_TYPE (tem)))
    3854                 :             :     {
    3855                 :             :       /* This situation leads to run-time undefined behavior.  We can't,
    3856                 :             :          therefore, simply error unless we can prove that all possible
    3857                 :             :          executions of the program must execute the code.  */
    3858                 :          20 :       warning_at (loc, 0, "function called through a non-compatible type");
    3859                 :             : 
    3860                 :          20 :       if (VOID_TYPE_P (return_type)
    3861                 :          20 :           && TYPE_QUALS (return_type) != TYPE_UNQUALIFIED)
    3862                 :           1 :         pedwarn (loc, 0,
    3863                 :             :                  "function with qualified void return type called");
    3864                 :             :      }
    3865                 :             : 
    3866                 :    50749984 :   argarray = vec_safe_address (params);
    3867                 :             : 
    3868                 :             :   /* Check that arguments to builtin functions match the expectations.  */
    3869                 :    50749984 :   if (fundecl
    3870                 :    50673290 :       && fndecl_built_in_p (fundecl)
    3871                 :    84590535 :       && !check_builtin_function_arguments (loc, arg_loc, fundecl,
    3872                 :             :                                             orig_fundecl, nargs, argarray))
    3873                 :         298 :     return error_mark_node;
    3874                 :             : 
    3875                 :             :   /* Check that the arguments to the function are valid.  */
    3876                 :    50749686 :   bool warned_p = check_function_arguments (loc, fundecl, fntype,
    3877                 :             :                                             nargs, argarray, &arg_loc,
    3878                 :             :                                             comp_parm_types);
    3879                 :             : 
    3880                 :    50749686 :   if (TYPE_QUALS (return_type) != TYPE_UNQUALIFIED
    3881                 :    50749686 :       && !VOID_TYPE_P (return_type))
    3882                 :          11 :     return_type = c_build_qualified_type (return_type, TYPE_UNQUALIFIED);
    3883                 :    50749686 :   if (name != NULL_TREE
    3884                 :   101422678 :       && startswith (IDENTIFIER_POINTER (name), "__builtin_"))
    3885                 :             :     {
    3886                 :    33127352 :       if (require_constant_value)
    3887                 :        3484 :         result
    3888                 :        3484 :           = fold_build_call_array_initializer_loc (loc, return_type,
    3889                 :             :                                                    function, nargs, argarray);
    3890                 :             :       else
    3891                 :    33123868 :         result = fold_build_call_array_loc (loc, return_type,
    3892                 :             :                                             function, nargs, argarray);
    3893                 :    33127352 :       if (TREE_CODE (result) == NOP_EXPR
    3894                 :    33127352 :           && TREE_CODE (TREE_OPERAND (result, 0)) == INTEGER_CST)
    3895                 :       26488 :         STRIP_TYPE_NOPS (result);
    3896                 :             :     }
    3897                 :             :   else
    3898                 :    17622334 :     result = build_call_array_loc (loc, return_type,
    3899                 :             :                                    function, nargs, argarray);
    3900                 :             :   /* If -Wnonnull warning has been diagnosed, avoid diagnosing it again
    3901                 :             :      later.  */
    3902                 :    50749686 :   if (warned_p && TREE_CODE (result) == CALL_EXPR)
    3903                 :         192 :     suppress_warning (result, OPT_Wnonnull);
    3904                 :             : 
    3905                 :             :   /* In this improbable scenario, a nested function returns a VM type.
    3906                 :             :      Create a TARGET_EXPR so that the call always has a LHS, much as
    3907                 :             :      what the C++ FE does for functions returning non-PODs.  */
    3908                 :    50749686 :   if (C_TYPE_VARIABLY_MODIFIED (TREE_TYPE (fntype)))
    3909                 :             :     {
    3910                 :          79 :       tree tmp = create_tmp_var_raw (TREE_TYPE (fntype));
    3911                 :          79 :       result = build4 (TARGET_EXPR, TREE_TYPE (fntype), tmp, result,
    3912                 :             :                        NULL_TREE, NULL_TREE);
    3913                 :             :     }
    3914                 :             : 
    3915                 :    50749686 :   if (VOID_TYPE_P (TREE_TYPE (result)))
    3916                 :             :     {
    3917                 :     2344796 :       if (TYPE_QUALS (TREE_TYPE (result)) != TYPE_UNQUALIFIED)
    3918                 :           2 :         pedwarn (loc, 0,
    3919                 :             :                  "function with qualified void return type called");
    3920                 :     2344796 :       return result;
    3921                 :             :     }
    3922                 :    48404890 :   return require_complete_type (loc, result);
    3923                 :             : }
    3924                 :             : 
    3925                 :             : /* Like build_function_call_vec, but call also resolve_overloaded_builtin.  */
    3926                 :             : 
    3927                 :             : tree
    3928                 :    50749754 : c_build_function_call_vec (location_t loc, const vec<location_t> &arg_loc,
    3929                 :             :                            tree function, vec<tree, va_gc> *params,
    3930                 :             :                            vec<tree, va_gc> *origtypes)
    3931                 :             : {
    3932                 :             :   /* Strip NON_LVALUE_EXPRs, etc., since we aren't using as an lvalue.  */
    3933                 :    50749765 :   STRIP_TYPE_NOPS (function);
    3934                 :             : 
    3935                 :             :   /* Convert anything with function type to a pointer-to-function.  */
    3936                 :    50749754 :   if (TREE_CODE (function) == FUNCTION_DECL)
    3937                 :             :     {
    3938                 :             :       /* Implement type-directed function overloading for builtins.
    3939                 :             :          resolve_overloaded_builtin and targetm.resolve_overloaded_builtin
    3940                 :             :          handle all the type checking.  The result is a complete expression
    3941                 :             :          that implements this function call.  */
    3942                 :    50673007 :       tree tem = resolve_overloaded_builtin (loc, function, params);
    3943                 :    50673007 :       if (tem)
    3944                 :             :         return tem;
    3945                 :             :     }
    3946                 :    50664859 :   return build_function_call_vec (loc, arg_loc, function, params, origtypes);
    3947                 :             : }
    3948                 :             : 
    3949                 :             : /* Helper for convert_arguments called to convert the VALue of argument
    3950                 :             :    number ARGNUM from ORIGTYPE to the corresponding parameter number
    3951                 :             :    PARMNUM and TYPE.
    3952                 :             :    PLOC is the location where the conversion is being performed.
    3953                 :             :    FUNCTION and FUNDECL are the same as in convert_arguments.
    3954                 :             :    VALTYPE is the original type of VAL before the conversion and,
    3955                 :             :    for EXCESS_PRECISION_EXPR, the operand of the expression.
    3956                 :             :    NPC is true if VAL represents the null pointer constant (VAL itself
    3957                 :             :    will have been folded to an integer constant).
    3958                 :             :    RNAME is the same as FUNCTION except in Objective C when it's
    3959                 :             :    the function selector.
    3960                 :             :    EXCESS_PRECISION is true when VAL was originally represented
    3961                 :             :    as EXCESS_PRECISION_EXPR.
    3962                 :             :    WARNOPT is the same as in convert_for_assignment.  */
    3963                 :             : 
    3964                 :             : static tree
    3965                 :   129758829 : convert_argument (location_t ploc, tree function, tree fundecl,
    3966                 :             :                   tree type, tree origtype, tree val, tree valtype,
    3967                 :             :                   bool npc, tree rname, int parmnum, int argnum,
    3968                 :             :                   bool excess_precision, int warnopt)
    3969                 :             : {
    3970                 :             :   /* Formal parm type is specified by a function prototype.  */
    3971                 :             : 
    3972                 :   129758829 :   if (type == error_mark_node || !COMPLETE_TYPE_P (type))
    3973                 :             :     {
    3974                 :           3 :       error_at (ploc, "type of formal parameter %d is incomplete",
    3975                 :             :                 parmnum + 1);
    3976                 :           3 :       return error_mark_node;
    3977                 :             :     }
    3978                 :             : 
    3979                 :             :   /* Optionally warn about conversions that differ from the default
    3980                 :             :      conversions.  */
    3981                 :   129758826 :   if (warn_traditional_conversion || warn_traditional)
    3982                 :             :     {
    3983                 :         193 :       if (INTEGRAL_TYPE_P (type)
    3984                 :         107 :           && SCALAR_FLOAT_TYPE_P (valtype))
    3985                 :          19 :         warning_at (ploc, OPT_Wtraditional_conversion,
    3986                 :             :                     "passing argument %d of %qE as integer rather "
    3987                 :             :                     "than floating due to prototype",
    3988                 :             :                     argnum, rname);
    3989                 :         193 :       if (INTEGRAL_TYPE_P (type)
    3990                 :         107 :           && TREE_CODE (valtype) == COMPLEX_TYPE)
    3991                 :           5 :         warning_at (ploc, OPT_Wtraditional_conversion,
    3992                 :             :                     "passing argument %d of %qE as integer rather "
    3993                 :             :                     "than complex due to prototype",
    3994                 :             :                     argnum, rname);
    3995                 :         188 :       else if (TREE_CODE (type) == COMPLEX_TYPE
    3996                 :          14 :                && SCALAR_FLOAT_TYPE_P (valtype))
    3997                 :           7 :         warning_at (ploc, OPT_Wtraditional_conversion,
    3998                 :             :                     "passing argument %d of %qE as complex rather "
    3999                 :             :                     "than floating due to prototype",
    4000                 :             :                     argnum, rname);
    4001                 :         181 :       else if (SCALAR_FLOAT_TYPE_P (type)
    4002                 :          71 :                && INTEGRAL_TYPE_P (valtype))
    4003                 :          19 :         warning_at (ploc, OPT_Wtraditional_conversion,
    4004                 :             :                     "passing argument %d of %qE as floating rather "
    4005                 :             :                     "than integer due to prototype",
    4006                 :             :                     argnum, rname);
    4007                 :         162 :       else if (TREE_CODE (type) == COMPLEX_TYPE
    4008                 :           7 :                && INTEGRAL_TYPE_P (valtype))
    4009                 :           5 :         warning_at (ploc, OPT_Wtraditional_conversion,
    4010                 :             :                     "passing argument %d of %qE as complex rather "
    4011                 :             :                     "than integer due to prototype",
    4012                 :             :                     argnum, rname);
    4013                 :         157 :       else if (SCALAR_FLOAT_TYPE_P (type)
    4014                 :          52 :                && TREE_CODE (valtype) == COMPLEX_TYPE)
    4015                 :           7 :         warning_at (ploc, OPT_Wtraditional_conversion,
    4016                 :             :                     "passing argument %d of %qE as floating rather "
    4017                 :             :                     "than complex due to prototype",
    4018                 :             :                     argnum, rname);
    4019                 :             :       /* ??? At some point, messages should be written about
    4020                 :             :          conversions between complex types, but that's too messy
    4021                 :             :          to do now.  */
    4022                 :         150 :       else if (SCALAR_FLOAT_TYPE_P (type)
    4023                 :          45 :                && SCALAR_FLOAT_TYPE_P (valtype))
    4024                 :             :         {
    4025                 :          45 :           unsigned int formal_prec = TYPE_PRECISION (type);
    4026                 :             : 
    4027                 :             :           /* Warn if any argument is passed as `float',
    4028                 :             :              since without a prototype it would be `double'.  */
    4029                 :          45 :           if (formal_prec == TYPE_PRECISION (float_type_node)
    4030                 :          45 :               && type != dfloat32_type_node)
    4031                 :           7 :             warning_at (ploc, 0,
    4032                 :             :                         "passing argument %d of %qE as %<float%> "
    4033                 :             :                         "rather than %<double%> due to prototype",
    4034                 :             :                         argnum, rname);
    4035                 :             : 
    4036                 :             :           /* Warn if mismatch between argument and prototype
    4037                 :             :              for decimal float types.  Warn of conversions with
    4038                 :             :              binary float types and of precision narrowing due to
    4039                 :             :              prototype.  */
    4040                 :          38 :           else if (type != valtype
    4041                 :          32 :                    && (type == dfloat32_type_node
    4042                 :          22 :                        || type == dfloat64_type_node
    4043                 :          12 :                        || type == dfloat128_type_node
    4044                 :           2 :                        || valtype == dfloat32_type_node
    4045                 :           2 :                        || valtype == dfloat64_type_node
    4046                 :           2 :                        || valtype == dfloat128_type_node)
    4047                 :          38 :                    && (formal_prec
    4048                 :          30 :                        <= TYPE_PRECISION (valtype)
    4049                 :          14 :                        || (type == dfloat128_type_node
    4050                 :          10 :                            && (valtype
    4051                 :          10 :                                != dfloat64_type_node
    4052                 :           8 :                                && (valtype
    4053                 :             :                                    != dfloat32_type_node)))
    4054                 :           8 :                        || (type == dfloat64_type_node
    4055                 :           4 :                            && (valtype
    4056                 :             :                                != dfloat32_type_node))))
    4057                 :          24 :             warning_at (ploc, 0,
    4058                 :             :                         "passing argument %d of %qE as %qT "
    4059                 :             :                         "rather than %qT due to prototype",
    4060                 :             :                         argnum, rname, type, valtype);
    4061                 :             : 
    4062                 :             :         }
    4063                 :             :       /* Detect integer changing in width or signedness.
    4064                 :             :          These warnings are only activated with
    4065                 :             :          -Wtraditional-conversion, not with -Wtraditional.  */
    4066                 :         105 :       else if (warn_traditional_conversion
    4067                 :         105 :                && INTEGRAL_TYPE_P (type)
    4068                 :         102 :                && INTEGRAL_TYPE_P (valtype))
    4069                 :             :         {
    4070                 :          83 :           unsigned int formal_prec = TYPE_PRECISION (type);
    4071                 :          83 :           tree would_have_been = default_conversion (val);
    4072                 :          83 :           tree type1 = TREE_TYPE (would_have_been);
    4073                 :             : 
    4074                 :          83 :           if (val == error_mark_node)
    4075                 :             :             /* VAL could have been of incomplete type.  */;
    4076                 :          83 :           else if (TREE_CODE (type) == ENUMERAL_TYPE
    4077                 :          83 :                    && (TYPE_MAIN_VARIANT (type)
    4078                 :           2 :                        == TYPE_MAIN_VARIANT (valtype)))
    4079                 :             :             /* No warning if function asks for enum
    4080                 :             :                and the actual arg is that enum type.  */
    4081                 :             :             ;
    4082                 :          81 :           else if (formal_prec != TYPE_PRECISION (type1))
    4083                 :          14 :             warning_at (ploc, OPT_Wtraditional_conversion,
    4084                 :             :                         "passing argument %d of %qE "
    4085                 :             :                         "with different width due to prototype",
    4086                 :             :                         argnum, rname);
    4087                 :          67 :           else if (TYPE_UNSIGNED (type) == TYPE_UNSIGNED (type1))
    4088                 :             :             ;
    4089                 :             :           /* Don't complain if the formal parameter type
    4090                 :             :              is an enum, because we can't tell now whether
    4091                 :             :              the value was an enum--even the same enum.  */
    4092                 :          32 :           else if (TREE_CODE (type) == ENUMERAL_TYPE)
    4093                 :             :             ;
    4094                 :          32 :           else if (TREE_CODE (val) == INTEGER_CST
    4095                 :           5 :                    && int_fits_type_p (val, type))
    4096                 :             :             /* Change in signedness doesn't matter
    4097                 :             :                if a constant value is unaffected.  */
    4098                 :             :             ;
    4099                 :             :           /* If the value is extended from a narrower
    4100                 :             :              unsigned type, it doesn't matter whether we
    4101                 :             :              pass it as signed or unsigned; the value
    4102                 :             :              certainly is the same either way.  */
    4103                 :          32 :           else if (TYPE_PRECISION (valtype) < TYPE_PRECISION (type)
    4104                 :          32 :                    && TYPE_UNSIGNED (valtype))
    4105                 :             :             ;
    4106                 :          32 :           else if (TYPE_UNSIGNED (type))
    4107                 :          17 :             warning_at (ploc, OPT_Wtraditional_conversion,
    4108                 :             :                         "passing argument %d of %qE "
    4109                 :             :                         "as unsigned due to prototype",
    4110                 :             :                         argnum, rname);
    4111                 :             :           else
    4112                 :          15 :             warning_at (ploc, OPT_Wtraditional_conversion,
    4113                 :             :                         "passing argument %d of %qE "
    4114                 :             :                         "as signed due to prototype",
    4115                 :             :                         argnum, rname);
    4116                 :             :         }
    4117                 :             :     }
    4118                 :             : 
    4119                 :             :   /* Possibly restore an EXCESS_PRECISION_EXPR for the
    4120                 :             :      sake of better warnings from convert_and_check.  */
    4121                 :   129758826 :   if (excess_precision)
    4122                 :         370 :     val = build1 (EXCESS_PRECISION_EXPR, valtype, val);
    4123                 :             : 
    4124                 :   129758826 :   tree parmval = convert_for_assignment (ploc, ploc, type,
    4125                 :             :                                          val, origtype, ic_argpass,
    4126                 :             :                                          npc, fundecl, function,
    4127                 :             :                                          parmnum + 1, warnopt);
    4128                 :             : 
    4129                 :   129758826 :   if (targetm.calls.promote_prototypes (fundecl ? TREE_TYPE (fundecl) : 0)
    4130                 :   129758826 :       && INTEGRAL_TYPE_P (type)
    4131                 :   177020652 :       && (TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node)))
    4132                 :    24226906 :     parmval = default_conversion (parmval);
    4133                 :             : 
    4134                 :             :   return parmval;
    4135                 :             : }
    4136                 :             : 
    4137                 :             : /* Convert the argument expressions in the vector VALUES
    4138                 :             :    to the types in the list TYPE_ARG_TYPES (FNTYPE).
    4139                 :             : 
    4140                 :             :    If the list is exhausted, or when an element has NULL as its type,
    4141                 :             :    perform the default conversions.
    4142                 :             : 
    4143                 :             :    ORIGTYPES is the original types of the expressions in VALUES.  This
    4144                 :             :    holds the type of enum values which have been converted to integral
    4145                 :             :    types.  It may be NULL.
    4146                 :             : 
    4147                 :             :    FUNCTION is a tree for the called function.  It is used only for
    4148                 :             :    error messages, where it is formatted with %qE.
    4149                 :             : 
    4150                 :             :    This is also where warnings about wrong number of args are generated.
    4151                 :             : 
    4152                 :             :    ARG_LOC are locations of function arguments (if any).
    4153                 :             : 
    4154                 :             :    Returns the actual number of arguments processed (which may be less
    4155                 :             :    than the length of VALUES in some error situations), or -1 on
    4156                 :             :    failure.  */
    4157                 :             : 
    4158                 :             : static int
    4159                 :    50750157 : convert_arguments (location_t loc, vec<location_t> arg_loc, tree fntype,
    4160                 :             :                    vec<tree, va_gc> *values, vec<tree, va_gc> *origtypes,
    4161                 :             :                    tree function, tree fundecl)
    4162                 :             : {
    4163                 :    50750157 :   tree typelist = TYPE_ARG_TYPES (fntype);
    4164                 :    50750157 :   unsigned int parmnum;
    4165                 :    50750157 :   bool error_args = false;
    4166                 :    50750157 :   const bool type_generic = fundecl
    4167                 :    50750157 :     && lookup_attribute ("type generic", TYPE_ATTRIBUTES (TREE_TYPE (fundecl)));
    4168                 :    50750157 :   bool type_generic_remove_excess_precision = false;
    4169                 :    50750157 :   bool type_generic_overflow_p = false;
    4170                 :    50750157 :   bool type_generic_bit_query = false;
    4171                 :    50750157 :   tree selector;
    4172                 :             : 
    4173                 :             :   /* Change pointer to function to the function itself for
    4174                 :             :      diagnostics.  */
    4175                 :    50750157 :   if (TREE_CODE (function) == ADDR_EXPR
    4176                 :    50750157 :       && TREE_CODE (TREE_OPERAND (function, 0)) == FUNCTION_DECL)
    4177                 :    50675563 :     function = TREE_OPERAND (function, 0);
    4178                 :             : 
    4179                 :             :   /* Handle an ObjC selector specially for diagnostics.  */
    4180                 :    50750157 :   selector = objc_message_selector ();
    4181                 :             : 
    4182                 :             :   /* For a call to a built-in function declared without a prototype,
    4183                 :             :      set to the built-in function's argument list.  */
    4184                 :    50750157 :   tree builtin_typelist = NULL_TREE;
    4185                 :             : 
    4186                 :             :   /* For type-generic built-in functions, determine whether excess
    4187                 :             :      precision should be removed (classification) or not
    4188                 :             :      (comparison).  */
    4189                 :    50750157 :   if (fundecl
    4190                 :    50750157 :       && fndecl_built_in_p (fundecl, BUILT_IN_NORMAL))
    4191                 :             :     {
    4192                 :     1379305 :       built_in_function code = DECL_FUNCTION_CODE (fundecl);
    4193                 :     1379305 :       if (C_DECL_BUILTIN_PROTOTYPE (fundecl))
    4194                 :             :         {
    4195                 :             :           /* For a call to a built-in function declared without a prototype
    4196                 :             :              use the types of the parameters of the internal built-in to
    4197                 :             :              match those of the arguments to.  */
    4198                 :      678996 :           if (tree bdecl = builtin_decl_explicit (code))
    4199                 :      678996 :             builtin_typelist = TYPE_ARG_TYPES (TREE_TYPE (bdecl));
    4200                 :             :         }
    4201                 :             : 
    4202                 :             :       /* For type-generic built-in functions, determine whether excess
    4203                 :             :          precision should be removed (classification) or not
    4204                 :             :          (comparison).  */
    4205                 :     1379305 :       if (type_generic)
    4206                 :       60597 :         switch (code)
    4207                 :             :           {
    4208                 :        5296 :           case BUILT_IN_ISFINITE:
    4209                 :        5296 :           case BUILT_IN_ISINF:
    4210                 :        5296 :           case BUILT_IN_ISINF_SIGN:
    4211                 :        5296 :           case BUILT_IN_ISNAN:
    4212                 :        5296 :           case BUILT_IN_ISNORMAL:
    4213                 :        5296 :           case BUILT_IN_ISSIGNALING:
    4214                 :        5296 :           case BUILT_IN_FPCLASSIFY:
    4215                 :        5296 :             type_generic_remove_excess_precision = true;
    4216                 :        5296 :             break;
    4217                 :             : 
    4218                 :       21008 :           case BUILT_IN_ADD_OVERFLOW_P:
    4219                 :       21008 :           case BUILT_IN_SUB_OVERFLOW_P:
    4220                 :       21008 :           case BUILT_IN_MUL_OVERFLOW_P:
    4221                 :             :             /* The last argument of these type-generic builtins
    4222                 :             :                should not be promoted.  */
    4223                 :       21008 :             type_generic_overflow_p = true;
    4224                 :       21008 :             break;
    4225                 :             : 
    4226                 :        1277 :           case BUILT_IN_CLZG:
    4227                 :        1277 :           case BUILT_IN_CTZG:
    4228                 :        1277 :           case BUILT_IN_CLRSBG:
    4229                 :        1277 :           case BUILT_IN_FFSG:
    4230                 :        1277 :           case BUILT_IN_PARITYG:
    4231                 :        1277 :           case BUILT_IN_POPCOUNTG:
    4232                 :             :             /* The first argument of these type-generic builtins
    4233                 :             :                should not be promoted.  */
    4234                 :        1277 :             type_generic_bit_query = true;
    4235                 :        1277 :             break;
    4236                 :             : 
    4237                 :             :           default:
    4238                 :             :             break;
    4239                 :             :           }
    4240                 :             :     }
    4241                 :             : 
    4242                 :             :   /* Scan the given expressions (VALUES) and types (TYPELIST), producing
    4243                 :             :      individual converted arguments.  */
    4244                 :             : 
    4245                 :    50750157 :   tree typetail, builtin_typetail, val;
    4246                 :    50750157 :   for (typetail = typelist,
    4247                 :    50750157 :          builtin_typetail = builtin_typelist,
    4248                 :    50750157 :          parmnum = 0;
    4249                 :   181440668 :        values && values->iterate (parmnum, &val);
    4250                 :             :        ++parmnum)
    4251                 :             :     {
    4252                 :             :       /* The type of the function parameter (if it was declared with one).  */
    4253                 :   260447476 :       tree type = typetail ? TREE_VALUE (typetail) : NULL_TREE;
    4254                 :             :       /* The type of the built-in function parameter (if the function
    4255                 :             :          is a built-in).  Used to detect type incompatibilities in
    4256                 :             :          calls to built-ins declared without a prototype.  */
    4257                 :   130690541 :       tree builtin_type = (builtin_typetail
    4258                 :   131712776 :                            ? TREE_VALUE (builtin_typetail) : NULL_TREE);
    4259                 :             :       /* The original type of the argument being passed to the function.  */
    4260                 :   130690541 :       tree valtype = TREE_TYPE (val);
    4261                 :             :       /* The called function (or function selector in Objective C).  */
    4262                 :   130690541 :       tree rname = function;
    4263                 :   130690541 :       int argnum = parmnum + 1;
    4264                 :   130690541 :       const char *invalid_func_diag;
    4265                 :             :       /* Set for EXCESS_PRECISION_EXPR arguments.  */
    4266                 :   130690541 :       bool excess_precision = false;
    4267                 :             :       /* The value of the argument after conversion to the type
    4268                 :             :          of the function parameter it is passed to.  */
    4269                 :   130690541 :       tree parmval;
    4270                 :             :       /* Some __atomic_* builtins have additional hidden argument at
    4271                 :             :          position 0.  */
    4272                 :   130690541 :       location_t ploc
    4273                 :   130424543 :         = !arg_loc.is_empty () && values->length () == arg_loc.length ()
    4274                 :   130690541 :           ? expansion_point_location_if_in_system_header (arg_loc[parmnum])
    4275                 :   130690541 :           : input_location;
    4276                 :             : 
    4277                 :   130690541 :       if (type == void_type_node)
    4278                 :             :         {
    4279                 :          27 :           if (selector)
    4280                 :           0 :             error_at (loc, "too many arguments to method %qE", selector);
    4281                 :             :           else
    4282                 :          27 :             error_at (loc, "too many arguments to function %qE", function);
    4283                 :          27 :           inform_declaration (fundecl);
    4284                 :          53 :           return error_args ? -1 : (int) parmnum;
    4285                 :             :         }
    4286                 :             : 
    4287                 :   130690514 :       if (builtin_type == void_type_node)
    4288                 :             :         {
    4289                 :          12 :           if (warning_at (loc, OPT_Wbuiltin_declaration_mismatch,
    4290                 :             :                           "too many arguments to built-in function %qE "
    4291                 :             :                           "expecting %d", function, parmnum))
    4292                 :          12 :             inform_declaration (fundecl);
    4293                 :             :           builtin_typetail = NULL_TREE;
    4294                 :             :         }
    4295                 :             : 
    4296                 :   130690514 :       if (!typetail && parmnum == 0 && !TYPE_NO_NAMED_ARGS_STDARG_P (fntype))
    4297                 :             :         {
    4298                 :       89591 :           bool warned;
    4299                 :       89591 :           if (selector)
    4300                 :           0 :             warned = warning_at (loc, OPT_Wdeprecated_non_prototype,
    4301                 :             :                                  "ISO C23 does not allow arguments"
    4302                 :             :                                  " for method %qE declared without parameters",
    4303                 :             :                                  function);
    4304                 :             :           else
    4305                 :       89591 :             warned = warning_at (loc, OPT_Wdeprecated_non_prototype,
    4306                 :             :                                  "ISO C23 does not allow arguments"
    4307                 :             :                                  " for function %qE declared without parameters",
    4308                 :             :                                  function);
    4309                 :       89591 :           if (warned)
    4310                 :           3 :             inform_declaration (fundecl);
    4311                 :             :         }
    4312                 :             : 
    4313                 :   130690514 :       if (selector && argnum > 2)
    4314                 :             :         {
    4315                 :           0 :           rname = selector;
    4316                 :           0 :           argnum -= 2;
    4317                 :             :         }
    4318                 :             : 
    4319                 :             :       /* Determine if VAL is a null pointer constant before folding it.  */
    4320                 :   130690514 :       bool npc = null_pointer_constant_p (val);
    4321                 :             : 
    4322                 :             :       /* If there is excess precision and a prototype, convert once to
    4323                 :             :          the required type rather than converting via the semantic
    4324                 :             :          type.  Likewise without a prototype a float value represented
    4325                 :             :          as long double should be converted once to double.  But for
    4326                 :             :          type-generic classification functions excess precision must
    4327                 :             :          be removed here.  */
    4328                 :   130690514 :       if (TREE_CODE (val) == EXCESS_PRECISION_EXPR
    4329                 :         423 :           && (type || !type_generic || !type_generic_remove_excess_precision))
    4330                 :             :         {
    4331                 :         403 :           val = TREE_OPERAND (val, 0);
    4332                 :         403 :           excess_precision = true;
    4333                 :             :         }
    4334                 :   130690514 :       val = c_fully_fold (val, false, NULL);
    4335                 :   261381029 :       STRIP_TYPE_NOPS (val);
    4336                 :             : 
    4337                 :   130690514 :       val = require_complete_type (ploc, val);
    4338                 :             : 
    4339                 :             :       /* Some floating-point arguments must be promoted to double when
    4340                 :             :          no type is specified by a prototype.  This applies to
    4341                 :             :          arguments of type float, and to architecture-specific types
    4342                 :             :          (ARM __fp16), but not to _FloatN or _FloatNx types.  */
    4343                 :   130690514 :       bool promote_float_arg = false;
    4344                 :   130690514 :       if (type == NULL_TREE
    4345                 :      933606 :           && TREE_CODE (valtype) == REAL_TYPE
    4346                 :      269517 :           && (TYPE_PRECISION (valtype)
    4347                 :      269517 :               <= TYPE_PRECISION (double_type_node))
    4348                 :      262238 :           && TYPE_MAIN_VARIANT (valtype) != double_type_node
    4349                 :      131336 :           && TYPE_MAIN_VARIANT (valtype) != long_double_type_node
    4350                 :   130821850 :           && !DECIMAL_FLOAT_MODE_P (TYPE_MODE (valtype)))
    4351                 :             :         {
    4352                 :             :           /* Promote this argument, unless it has a _FloatN or
    4353                 :             :              _FloatNx type.  */
    4354                 :     1027583 :           promote_float_arg = true;
    4355                 :     1027583 :           for (int i = 0; i < NUM_FLOATN_NX_TYPES; i++)
    4356                 :      900199 :             if (TYPE_MAIN_VARIANT (valtype) == FLOATN_NX_TYPE_NODE (i))
    4357                 :             :               {
    4358                 :             :                 promote_float_arg = false;
    4359                 :             :                 break;
    4360                 :             :               }
    4361                 :             :           /* Don't promote __bf16 either.  */
    4362                 :      130603 :           if (TYPE_MAIN_VARIANT (valtype) == bfloat16_type_node)
    4363                 :   130559981 :             promote_float_arg = false;
    4364                 :             :         }
    4365                 :             : 
    4366                 :   130690514 :       if (type != NULL_TREE)
    4367                 :             :         {
    4368                 :   129756908 :           tree origtype = (!origtypes) ? NULL_TREE : (*origtypes)[parmnum];
    4369                 :   129756908 :           parmval = convert_argument (ploc, function, fundecl, type, origtype,
    4370                 :             :                                       val, valtype, npc, rname, parmnum, argnum,
    4371                 :             :                                       excess_precision, 0);
    4372                 :             :         }
    4373                 :      933606 :       else if (promote_float_arg)
    4374                 :             :         {
    4375                 :      127314 :           if (type_generic)
    4376                 :             :             parmval = val;
    4377                 :             :           else
    4378                 :             :             {
    4379                 :             :               /* Convert `float' to `double'.  */
    4380                 :      124446 :               if (warn_double_promotion && !c_inhibit_evaluation_warnings)
    4381                 :           6 :                 warning_at (ploc, OPT_Wdouble_promotion,
    4382                 :             :                             "implicit conversion from %qT to %qT when passing "
    4383                 :             :                             "argument to function",
    4384                 :             :                             valtype, double_type_node);
    4385                 :      124446 :               parmval = convert (double_type_node, val);
    4386                 :             :             }
    4387                 :             :         }
    4388                 :      806292 :       else if ((excess_precision && !type_generic)
    4389                 :      806290 :                || (type_generic_overflow_p && parmnum == 2)
    4390                 :      785286 :                || (type_generic_bit_query && parmnum == 0))
    4391                 :             :         /* A "double" argument with excess precision being passed
    4392                 :             :            without a prototype or in variable arguments.
    4393                 :             :            The last argument of __builtin_*_overflow_p should not be
    4394                 :             :            promoted, similarly the first argument of
    4395                 :             :            __builtin_{clz,ctz,clrsb,ffs,parity,popcount}g.  */
    4396                 :       22277 :         parmval = convert (valtype, val);
    4397                 :     1568030 :       else if ((invalid_func_diag =
    4398                 :      784015 :                 targetm.calls.invalid_arg_for_unprototyped_fn (typelist, fundecl, val)))
    4399                 :             :         {
    4400                 :           0 :           error (invalid_func_diag);
    4401                 :           0 :           return -1;
    4402                 :             :         }
    4403                 :      784015 :       else if (TREE_CODE (val) == ADDR_EXPR && reject_gcc_builtin (val))
    4404                 :             :         {
    4405                 :             :           return -1;
    4406                 :             :         }
    4407                 :             :       else
    4408                 :             :         /* Convert `short' and `char' to full-size `int'.  */
    4409                 :      784012 :         parmval = default_conversion (val);
    4410                 :             : 
    4411                 :   130690511 :       (*values)[parmnum] = parmval;
    4412                 :   130690511 :       if (parmval == error_mark_node)
    4413                 :         105 :         error_args = true;
    4414                 :             : 
    4415                 :   130690511 :       if (!type && builtin_type && TREE_CODE (builtin_type) != VOID_TYPE)
    4416                 :             :         {
    4417                 :             :           /* For a call to a built-in function declared without a prototype,
    4418                 :             :              perform the conversions from the argument to the expected type
    4419                 :             :              but issue warnings rather than errors for any mismatches.
    4420                 :             :              Ignore the converted argument and use the PARMVAL obtained
    4421                 :             :              above by applying default conversions instead.  */
    4422                 :        1921 :           tree origtype = (!origtypes) ? NULL_TREE : (*origtypes)[parmnum];
    4423                 :        1921 :           convert_argument (ploc, function, fundecl, builtin_type, origtype,
    4424                 :             :                             val, valtype, npc, rname, parmnum, argnum,
    4425                 :             :                             excess_precision,
    4426                 :             :                             OPT_Wbuiltin_declaration_mismatch);
    4427                 :             :         }
    4428                 :             : 
    4429                 :   130690511 :       if (typetail)
    4430                 :   129756908 :         typetail = TREE_CHAIN (typetail);
    4431                 :             : 
    4432                 :   130690511 :       if (builtin_typetail)
    4433                 :     1022218 :         builtin_typetail = TREE_CHAIN (builtin_typetail);
    4434                 :             :     }
    4435                 :             : 
    4436                 :    89410129 :   gcc_assert (parmnum == vec_safe_length (values));
    4437                 :             : 
    4438                 :   101172540 :   if (typetail != NULL_TREE && TREE_VALUE (typetail) != void_type_node)
    4439                 :             :     {
    4440                 :          71 :       error_at (loc, "too few arguments to function %qE", function);
    4441                 :          71 :       inform_declaration (fundecl);
    4442                 :          71 :       return -1;
    4443                 :             :     }
    4444                 :             : 
    4445                 :    51393433 :   if (builtin_typetail && TREE_VALUE (builtin_typetail) != void_type_node)
    4446                 :             :     {
    4447                 :             :       unsigned nargs = parmnum;
    4448                 :         616 :       for (tree t = builtin_typetail; t; t = TREE_CHAIN (t))
    4449                 :         428 :         ++nargs;
    4450                 :             : 
    4451                 :         188 :       if (warning_at (loc, OPT_Wbuiltin_declaration_mismatch,
    4452                 :             :                       "too few arguments to built-in function %qE "
    4453                 :             :                       "expecting %u", function, nargs - 1))
    4454                 :         173 :         inform_declaration (fundecl);
    4455                 :             :     }
    4456                 :             : 
    4457                 :    50750056 :   return error_args ? -1 : (int) parmnum;
    4458                 :             : }
    4459                 :             : 
    4460                 :             : /* This is the entry point used by the parser to build unary operators
    4461                 :             :    in the input.  CODE, a tree_code, specifies the unary operator, and
    4462                 :             :    ARG is the operand.  For unary plus, the C parser currently uses
    4463                 :             :    CONVERT_EXPR for code.
    4464                 :             : 
    4465                 :             :    LOC is the location to use for the tree generated.
    4466                 :             : */
    4467                 :             : 
    4468                 :             : struct c_expr
    4469                 :     8392253 : parser_build_unary_op (location_t loc, enum tree_code code, struct c_expr arg)
    4470                 :             : {
    4471                 :     8392253 :   struct c_expr result;
    4472                 :             : 
    4473                 :     8392253 :   result.original_code = code;
    4474                 :     8392253 :   result.original_type = NULL;
    4475                 :     8392253 :   result.m_decimal = 0;
    4476                 :             : 
    4477                 :     8392253 :   if (reject_gcc_builtin (arg.value))
    4478                 :             :     {
    4479                 :           2 :       result.value = error_mark_node;
    4480                 :             :     }
    4481                 :             :   else
    4482                 :             :     {
    4483                 :     8392251 :       result.value = build_unary_op (loc, code, arg.value, false);
    4484                 :             : 
    4485                 :     8392251 :       if (TREE_OVERFLOW_P (result.value) && !TREE_OVERFLOW_P (arg.value))
    4486                 :           5 :         overflow_warning (loc, result.value, arg.value);
    4487                 :             :     }
    4488                 :             : 
    4489                 :             :   /* We are typically called when parsing a prefix token at LOC acting on
    4490                 :             :      ARG.  Reflect this by updating the source range of the result to
    4491                 :             :      start at LOC and end at the end of ARG.  */
    4492                 :     8392253 :   set_c_expr_source_range (&result,
    4493                 :             :                            loc, arg.get_finish ());
    4494                 :             : 
    4495                 :     8392253 :   return result;
    4496                 :             : }
    4497                 :             : 
    4498                 :             : /* Returns true if TYPE is a character type, *not* including wchar_t.  */
    4499                 :             : 
    4500                 :             : bool
    4501                 :     1235134 : char_type_p (tree type)
    4502                 :             : {
    4503                 :     1235134 :   return (type == char_type_node
    4504                 :      965407 :           || type == unsigned_char_type_node
    4505                 :      931775 :           || type == signed_char_type_node
    4506                 :      930970 :           || type == char16_type_node
    4507                 :     1954390 :           || type == char32_type_node);
    4508                 :             : }
    4509                 :             : 
    4510                 :             : /* This is the entry point used by the parser to build binary operators
    4511                 :             :    in the input.  CODE, a tree_code, specifies the binary operator, and
    4512                 :             :    ARG1 and ARG2 are the operands.  In addition to constructing the
    4513                 :             :    expression, we check for operands that were written with other binary
    4514                 :             :    operators in a way that is likely to confuse the user.
    4515                 :             : 
    4516                 :             :    LOCATION is the location of the binary operator.  */
    4517                 :             : 
    4518                 :             : struct c_expr
    4519                 :     9223839 : parser_build_binary_op (location_t location, enum tree_code code,
    4520                 :             :                         struct c_expr arg1, struct c_expr arg2)
    4521                 :             : {
    4522                 :     9223839 :   struct c_expr result;
    4523                 :     9223839 :   result.m_decimal = 0;
    4524                 :             : 
    4525                 :     9223839 :   enum tree_code code1 = arg1.original_code;
    4526                 :     9223839 :   enum tree_code code2 = arg2.original_code;
    4527                 :     9223839 :   tree type1 = (arg1.original_type
    4528                 :    15107667 :                 ? arg1.original_type
    4529                 :     5883828 :                 : TREE_TYPE (arg1.value));
    4530                 :     9223839 :   tree type2 = (arg2.original_type
    4531                 :    16001149 :                 ? arg2.original_type
    4532                 :     6777310 :                 : TREE_TYPE (arg2.value));
    4533                 :             : 
    4534                 :     9223839 :   result.value = build_binary_op (location, code,
    4535                 :             :                                   arg1.value, arg2.value, true);
    4536                 :     9223838 :   result.original_code = code;
    4537                 :     9223838 :   result.original_type = NULL;
    4538                 :     9223838 :   result.m_decimal = 0;
    4539                 :             : 
    4540                 :     9223838 :   if (TREE_CODE (result.value) == ERROR_MARK)
    4541                 :             :     {
    4542                 :        1294 :       set_c_expr_source_range (&result,
    4543                 :             :                                arg1.get_start (),
    4544                 :             :                                arg2.get_finish ());
    4545                 :        1294 :       return result;
    4546                 :             :     }
    4547                 :             : 
    4548                 :     9222544 :   if (location != UNKNOWN_LOCATION)
    4549                 :     9222544 :     protected_set_expr_location (result.value, location);
    4550                 :             : 
    4551                 :     9222544 :   set_c_expr_source_range (&result,
    4552                 :             :                            arg1.get_start (),
    4553                 :             :                            arg2.get_finish ());
    4554                 :             : 
    4555                 :             :   /* Check for cases such as x+y<<z which users are likely
    4556                 :             :      to misinterpret.  */
    4557                 :     9222544 :   if (warn_parentheses)
    4558                 :     2001878 :     warn_about_parentheses (location, code, code1, arg1.value, code2,
    4559                 :             :                             arg2.value);
    4560                 :             : 
    4561                 :     9222544 :   if (warn_logical_op)
    4562                 :         338 :     warn_logical_operator (location, code, TREE_TYPE (result.value),
    4563                 :             :                            code1, arg1.value, code2, arg2.value);
    4564                 :             : 
    4565                 :     9222544 :   if (warn_tautological_compare)
    4566                 :             :     {
    4567                 :     2000392 :       tree lhs = arg1.value;
    4568                 :     2000392 :       tree rhs = arg2.value;
    4569                 :     2000392 :       if (TREE_CODE (lhs) == C_MAYBE_CONST_EXPR)
    4570                 :             :         {
    4571                 :           2 :           if (C_MAYBE_CONST_EXPR_PRE (lhs) != NULL_TREE
    4572                 :           2 :               && TREE_SIDE_EFFECTS (C_MAYBE_CONST_EXPR_PRE (lhs)))
    4573                 :             :             lhs = NULL_TREE;
    4574                 :             :           else
    4575                 :           2 :             lhs = C_MAYBE_CONST_EXPR_EXPR (lhs);
    4576                 :             :         }
    4577                 :     2000392 :       if (TREE_CODE (rhs) == C_MAYBE_CONST_EXPR)
    4578                 :             :         {
    4579                 :          12 :           if (C_MAYBE_CONST_EXPR_PRE (rhs) != NULL_TREE
    4580                 :          12 :               && TREE_SIDE_EFFECTS (C_MAYBE_CONST_EXPR_PRE (rhs)))
    4581                 :             :             rhs = NULL_TREE;
    4582                 :             :           else
    4583                 :          12 :             rhs = C_MAYBE_CONST_EXPR_EXPR (rhs);
    4584                 :             :         }
    4585                 :     2000392 :       if (lhs != NULL_TREE && rhs != NULL_TREE)
    4586                 :     2000392 :         warn_tautological_cmp (location, code, lhs, rhs);
    4587                 :             :     }
    4588                 :             : 
    4589                 :     9222544 :   if (warn_logical_not_paren
    4590                 :     2000475 :       && TREE_CODE_CLASS (code) == tcc_comparison
    4591                 :      404857 :       && code1 == TRUTH_NOT_EXPR
    4592                 :      404857 :       && code2 != TRUTH_NOT_EXPR
    4593                 :             :       /* Avoid warning for !!x == y.  */
    4594                 :     9222670 :       && (TREE_CODE (arg1.value) != NE_EXPR
    4595                 :          19 :           || !integer_zerop (TREE_OPERAND (arg1.value, 1))))
    4596                 :             :     {
    4597                 :             :       /* Avoid warning for !b == y where b has _Bool type.  */
    4598                 :         107 :       tree t = integer_zero_node;
    4599                 :         107 :       if (TREE_CODE (arg1.value) == EQ_EXPR
    4600                 :          98 :           && integer_zerop (TREE_OPERAND (arg1.value, 1))
    4601                 :         205 :           && TREE_TYPE (TREE_OPERAND (arg1.value, 0)) == integer_type_node)
    4602                 :             :         {
    4603                 :          90 :           t = TREE_OPERAND (arg1.value, 0);
    4604                 :         199 :           do
    4605                 :             :             {
    4606                 :         199 :               if (TREE_TYPE (t) != integer_type_node)
    4607                 :             :                 break;
    4608                 :         180 :               if (TREE_CODE (t) == C_MAYBE_CONST_EXPR)
    4609                 :          90 :                 t = C_MAYBE_CONST_EXPR_EXPR (t);
    4610                 :          90 :               else if (CONVERT_EXPR_P (t))
    4611                 :          19 :                 t = TREE_OPERAND (t, 0);
    4612                 :             :               else
    4613                 :             :                 break;
    4614                 :             :             }
    4615                 :             :           while (1);
    4616                 :             :         }
    4617                 :         107 :       if (!C_BOOLEAN_TYPE_P (TREE_TYPE (t)))
    4618                 :          88 :         warn_logical_not_parentheses (location, code, arg1.value, arg2.value);
    4619                 :             :     }
    4620                 :             : 
    4621                 :             :   /* Warn about comparisons against string literals, with the exception
    4622                 :             :      of testing for equality or inequality of a string literal with NULL.  */
    4623                 :     9222544 :   if (code == EQ_EXPR || code == NE_EXPR)
    4624                 :             :     {
    4625                 :     1130659 :       if ((code1 == STRING_CST
    4626                 :          16 :            && !integer_zerop (tree_strip_nop_conversions (arg2.value)))
    4627                 :     1130670 :           || (code2 == STRING_CST
    4628                 :          20 :               && !integer_zerop (tree_strip_nop_conversions (arg1.value))))
    4629                 :          17 :         warning_at (location, OPT_Waddress,
    4630                 :             :                     "comparison with string literal results in unspecified behavior");
    4631                 :             :       /* Warn for ptr == '\0', it's likely that it should've been ptr[0].  */
    4632                 :     1130659 :       if (POINTER_TYPE_P (type1)
    4633                 :       89798 :           && null_pointer_constant_p (arg2.value)
    4634                 :     1151201 :           && char_type_p (type2))
    4635                 :             :         {
    4636                 :          18 :           auto_diagnostic_group d;
    4637                 :          18 :           if (warning_at (location, OPT_Wpointer_compare,
    4638                 :             :                             "comparison between pointer and zero character "
    4639                 :             :                             "constant"))
    4640                 :          10 :             inform (arg1.get_start (),
    4641                 :             :                       "did you mean to dereference the pointer?");
    4642                 :          18 :         }
    4643                 :     1130641 :       else if (POINTER_TYPE_P (type2)
    4644                 :       87191 :                && null_pointer_constant_p (arg1.value)
    4645                 :     1130903 :                && char_type_p (type1))
    4646                 :             :         {
    4647                 :          10 :           auto_diagnostic_group d;
    4648                 :          10 :           if (warning_at (location, OPT_Wpointer_compare,
    4649                 :             :                             "comparison between pointer and zero character "
    4650                 :             :                             "constant"))
    4651                 :          10 :             inform (arg2.get_start (),
    4652                 :             :                       "did you mean to dereference the pointer?");
    4653                 :          10 :         }
    4654                 :             :     }
    4655                 :     8091885 :   else if (TREE_CODE_CLASS (code) == tcc_comparison
    4656                 :      992710 :            && (code1 == STRING_CST || code2 == STRING_CST))
    4657                 :           0 :     warning_at (location, OPT_Waddress,
    4658                 :             :                 "comparison with string literal results in unspecified "
    4659                 :             :                 "behavior");
    4660                 :             : 
    4661                 :     9222544 :   if (warn_zero_as_null_pointer_constant
    4662                 :          18 :       && c_inhibit_evaluation_warnings == 0
    4663                 :          18 :       && TREE_CODE_CLASS (code) == tcc_comparison)
    4664                 :             :     {
    4665                 :          18 :       if ((TREE_CODE (type1) == POINTER_TYPE
    4666                 :          14 :            || TREE_CODE (type1) == NULLPTR_TYPE)
    4667                 :           6 :           && TREE_CODE (type2) == INTEGER_TYPE
    4668                 :          24 :           && null_pointer_constant_p (arg2.value))
    4669                 :           6 :         warning_at (arg2.get_location(), OPT_Wzero_as_null_pointer_constant,
    4670                 :             :                     "zero as null pointer constant");
    4671                 :             : 
    4672                 :          18 :       if ((TREE_CODE (type2) == POINTER_TYPE
    4673                 :          12 :            || TREE_CODE (type2) == NULLPTR_TYPE)
    4674                 :           8 :           && TREE_CODE (type1) == INTEGER_TYPE
    4675                 :          26 :           && null_pointer_constant_p (arg1.value))
    4676                 :           8 :         warning_at (arg1.get_location(), OPT_Wzero_as_null_pointer_constant,
    4677                 :             :                     "zero as null pointer constant");
    4678                 :             :     }
    4679                 :             : 
    4680                 :     9222544 :   if (warn_array_compare
    4681                 :     2000230 :       && TREE_CODE_CLASS (code) == tcc_comparison
    4682                 :      404642 :       && TREE_CODE (type1) == ARRAY_TYPE
    4683                 :          38 :       && TREE_CODE (type2) == ARRAY_TYPE)
    4684                 :          15 :     do_warn_array_compare (location, code, arg1.value, arg2.value);
    4685                 :             : 
    4686                 :     2130724 :   if (TREE_OVERFLOW_P (result.value)
    4687                 :         290 :       && !TREE_OVERFLOW_P (arg1.value)
    4688                 :     9222827 :       && !TREE_OVERFLOW_P (arg2.value))
    4689                 :         240 :     overflow_warning (location, result.value);
    4690                 :             : 
    4691                 :             :   /* Warn about comparisons of different enum types.  */
    4692                 :     9222543 :   if (warn_enum_compare
    4693                 :     2019611 :       && TREE_CODE_CLASS (code) == tcc_comparison
    4694                 :      408940 :       && TREE_CODE (type1) == ENUMERAL_TYPE
    4695                 :        6962 :       && TREE_CODE (type2) == ENUMERAL_TYPE
    4696                 :     9229447 :       && TYPE_MAIN_VARIANT (type1) != TYPE_MAIN_VARIANT (type2))
    4697                 :           2 :     warning_at (location, OPT_Wenum_compare,
    4698                 :             :                 "comparison between %qT and %qT",
    4699                 :             :                 type1, type2);
    4700                 :             : 
    4701                 :     9222543 :   if (warn_xor_used_as_pow
    4702                 :     9222543 :       && code == BIT_XOR_EXPR
    4703                 :       75077 :       && arg1.m_decimal
    4704                 :         721 :       && arg2.m_decimal)
    4705                 :         427 :     check_for_xor_used_as_pow (arg1.get_location (), arg1.value,
    4706                 :             :                                location,
    4707                 :             :                                arg2.get_location (), arg2.value);
    4708                 :             : 
    4709                 :             :   return result;
    4710                 :             : }
    4711                 :             : 
    4712                 :             : /* Return a tree for the difference of pointers OP0 and OP1.
    4713                 :             :    The resulting tree has type ptrdiff_t.  If POINTER_SUBTRACT sanitization is
    4714                 :             :    enabled, assign to INSTRUMENT_EXPR call to libsanitizer.  */
    4715                 :             : 
    4716                 :             : static tree
    4717                 :        3634 : pointer_diff (location_t loc, tree op0, tree op1, tree *instrument_expr)
    4718                 :             : {
    4719                 :        3634 :   tree restype = ptrdiff_type_node;
    4720                 :        3634 :   tree result, inttype;
    4721                 :             : 
    4722                 :        3634 :   addr_space_t as0 = TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (op0)));
    4723                 :        3634 :   addr_space_t as1 = TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (op1)));
    4724                 :        3634 :   tree target_type = TREE_TYPE (TREE_TYPE (op0));
    4725                 :        3634 :   tree orig_op0 = op0;
    4726                 :        3634 :   tree orig_op1 = op1;
    4727                 :             : 
    4728                 :             :   /* If the operands point into different address spaces, we need to
    4729                 :             :      explicitly convert them to pointers into the common address space
    4730                 :             :      before we can subtract the numerical address values.  */
    4731                 :        3634 :   if (as0 != as1)
    4732                 :             :     {
    4733                 :           0 :       addr_space_t as_common;
    4734                 :           0 :       tree common_type;
    4735                 :             : 
    4736                 :             :       /* Determine the common superset address space.  This is guaranteed
    4737                 :             :          to exist because the caller verified that comp_target_types
    4738                 :             :          returned non-zero.  */
    4739                 :           0 :       if (!addr_space_superset (as0, as1, &as_common))
    4740                 :           0 :         gcc_unreachable ();
    4741                 :             : 
    4742                 :           0 :       common_type = common_pointer_type (TREE_TYPE (op0), TREE_TYPE (op1));
    4743                 :           0 :       op0 = convert (common_type, op0);
    4744                 :           0 :       op1 = convert (common_type, op1);
    4745                 :             :     }
    4746                 :             : 
    4747                 :             :   /* Determine integer type result of the subtraction.  This will usually
    4748                 :             :      be the same as the result type (ptrdiff_t), but may need to be a wider
    4749                 :             :      type if pointers for the address space are wider than ptrdiff_t.  */
    4750                 :        3634 :   if (TYPE_PRECISION (restype) < TYPE_PRECISION (TREE_TYPE (op0)))
    4751                 :           0 :     inttype = c_common_type_for_size (TYPE_PRECISION (TREE_TYPE (op0)), 0);
    4752                 :             :   else
    4753                 :             :     inttype = restype;
    4754                 :             : 
    4755                 :        3634 :   if (VOID_TYPE_P (target_type))
    4756                 :         135 :     pedwarn (loc, OPT_Wpointer_arith,
    4757                 :             :              "pointer of type %<void *%> used in subtraction");
    4758                 :        3634 :   if (TREE_CODE (target_type) == FUNCTION_TYPE)
    4759                 :           4 :     pedwarn (loc, OPT_Wpointer_arith,
    4760                 :             :              "pointer to a function used in subtraction");
    4761                 :             : 
    4762                 :        3634 :   if (current_function_decl != NULL_TREE
    4763                 :        3634 :       && sanitize_flags_p (SANITIZE_POINTER_SUBTRACT))
    4764                 :             :     {
    4765                 :          63 :       op0 = save_expr (op0);
    4766                 :          63 :       op1 = save_expr (op1);
    4767                 :             : 
    4768                 :          63 :       tree tt = builtin_decl_explicit (BUILT_IN_ASAN_POINTER_SUBTRACT);
    4769                 :          63 :       *instrument_expr = build_call_expr_loc (loc, tt, 2, op0, op1);
    4770                 :             :     }
    4771                 :             : 
    4772                 :             :   /* First do the subtraction, then build the divide operator
    4773                 :             :      and only convert at the very end.
    4774                 :             :      Do not do default conversions in case restype is a short type.  */
    4775                 :             : 
    4776                 :             :   /* POINTER_DIFF_EXPR requires a signed integer type of the same size as
    4777                 :             :      pointers.  If some platform cannot provide that, or has a larger
    4778                 :             :      ptrdiff_type to support differences larger than half the address
    4779                 :             :      space, cast the pointers to some larger integer type and do the
    4780                 :             :      computations in that type.  */
    4781                 :        3634 :   if (TYPE_PRECISION (inttype) > TYPE_PRECISION (TREE_TYPE (op0)))
    4782                 :           0 :     op0 = build_binary_op (loc, MINUS_EXPR, convert (inttype, op0),
    4783                 :             :                            convert (inttype, op1), false);
    4784                 :             :   else
    4785                 :             :     {
    4786                 :             :       /* Cast away qualifiers.  */
    4787                 :        3634 :       op0 = convert (c_common_type (TREE_TYPE (op0), TREE_TYPE (op0)), op0);
    4788                 :        3634 :       op1 = convert (c_common_type (TREE_TYPE (op1), TREE_TYPE (op1)), op1);
    4789                 :        3634 :       op0 = build2_loc (loc, POINTER_DIFF_EXPR, inttype, op0, op1);
    4790                 :             :     }
    4791                 :             : 
    4792                 :             :   /* This generates an error if op1 is pointer to incomplete type.  */
    4793                 :        3634 :   if (!COMPLETE_OR_VOID_TYPE_P (TREE_TYPE (TREE_TYPE (orig_op1))))
    4794                 :           4 :     error_at (loc, "arithmetic on pointer to an incomplete type");
    4795                 :        3630 :   else if (verify_type_context (loc, TCTX_POINTER_ARITH,
    4796                 :        3630 :                                 TREE_TYPE (TREE_TYPE (orig_op0))))
    4797                 :        7260 :     verify_type_context (loc, TCTX_POINTER_ARITH,
    4798                 :        3630 :                          TREE_TYPE (TREE_TYPE (orig_op1)));
    4799                 :             : 
    4800                 :        3634 :   op1 = c_size_in_bytes (target_type);
    4801                 :             : 
    4802                 :        3634 :   if (pointer_to_zero_sized_aggr_p (TREE_TYPE (orig_op1)))
    4803                 :           4 :     error_at (loc, "arithmetic on pointer to an empty aggregate");
    4804                 :             : 
    4805                 :             :   /* Divide by the size, in easiest possible way.  */
    4806                 :        3634 :   result = fold_build2_loc (loc, EXACT_DIV_EXPR, inttype,
    4807                 :             :                             op0, convert (inttype, op1));
    4808                 :             : 
    4809                 :             :   /* Convert to final result type if necessary.  */
    4810                 :        3634 :   return convert (restype, result);
    4811                 :             : }
    4812                 :             : 
    4813                 :             : /* Expand atomic compound assignments into an appropriate sequence as
    4814                 :             :    specified by the C11 standard section 6.5.16.2.
    4815                 :             : 
    4816                 :             :        _Atomic T1 E1
    4817                 :             :        T2 E2
    4818                 :             :        E1 op= E2
    4819                 :             : 
    4820                 :             :   This sequence is used for all types for which these operations are
    4821                 :             :   supported.
    4822                 :             : 
    4823                 :             :   In addition, built-in versions of the 'fe' prefixed routines may
    4824                 :             :   need to be invoked for floating point (real, complex or vector) when
    4825                 :             :   floating-point exceptions are supported.  See 6.5.16.2 footnote 113.
    4826                 :             : 
    4827                 :             :   T1 newval;
    4828                 :             :   T1 old;
    4829                 :             :   T1 *addr
    4830                 :             :   T2 val
    4831                 :             :   fenv_t fenv
    4832                 :             : 
    4833                 :             :   addr = &E1;
    4834                 :             :   val = (E2);
    4835                 :             :   __atomic_load (addr, &old, SEQ_CST);
    4836                 :             :   feholdexcept (&fenv);
    4837                 :             : loop:
    4838                 :             :     newval = old op val;
    4839                 :             :     if (__atomic_compare_exchange_strong (addr, &old, &newval, SEQ_CST,
    4840                 :             :                                           SEQ_CST))
    4841                 :             :       goto done;
    4842                 :             :     feclearexcept (FE_ALL_EXCEPT);
    4843                 :             :     goto loop:
    4844                 :             : done:
    4845                 :             :   feupdateenv (&fenv);
    4846                 :             : 
    4847                 :             :   The compiler will issue the __atomic_fetch_* built-in when possible,
    4848                 :             :   otherwise it will generate the generic form of the atomic operations.
    4849                 :             :   This requires temp(s) and has their address taken.  The atomic processing
    4850                 :             :   is smart enough to figure out when the size of an object can utilize
    4851                 :             :   a lock-free version, and convert the built-in call to the appropriate
    4852                 :             :   lock-free routine.  The optimizers will then dispose of any temps that
    4853                 :             :   are no longer required, and lock-free implementations are utilized as
    4854                 :             :   long as there is target support for the required size.
    4855                 :             : 
    4856                 :             :   If the operator is NOP_EXPR, then this is a simple assignment, and
    4857                 :             :   an __atomic_store is issued to perform the assignment rather than
    4858                 :             :   the above loop.  */
    4859                 :             : 
    4860                 :             : /* Build an atomic assignment at LOC, expanding into the proper
    4861                 :             :    sequence to store LHS MODIFYCODE= RHS.  Return a value representing
    4862                 :             :    the result of the operation, unless RETURN_OLD_P, in which case
    4863                 :             :    return the old value of LHS (this is only for postincrement and
    4864                 :             :    postdecrement).  */
    4865                 :             : 
    4866                 :             : static tree
    4867                 :       30281 : build_atomic_assign (location_t loc, tree lhs, enum tree_code modifycode,
    4868                 :             :                      tree rhs, bool return_old_p)
    4869                 :             : {
    4870                 :       30281 :   tree fndecl, func_call;
    4871                 :       30281 :   vec<tree, va_gc> *params;
    4872                 :       30281 :   tree val, nonatomic_lhs_type, nonatomic_rhs_type, newval, newval_addr;
    4873                 :       30281 :   tree old, old_addr;
    4874                 :       30281 :   tree compound_stmt = NULL_TREE;
    4875                 :       30281 :   tree stmt, goto_stmt;
    4876                 :       30281 :   tree loop_label, loop_decl, done_label, done_decl;
    4877                 :             : 
    4878                 :       30281 :   tree lhs_type = TREE_TYPE (lhs);
    4879                 :       30281 :   tree lhs_addr = build_unary_op (loc, ADDR_EXPR, lhs, false);
    4880                 :       30281 :   tree seq_cst = build_int_cst (integer_type_node, MEMMODEL_SEQ_CST);
    4881                 :       30281 :   tree rhs_semantic_type = TREE_TYPE (rhs);
    4882                 :       30281 :   tree nonatomic_rhs_semantic_type;
    4883                 :       30281 :   tree rhs_type;
    4884                 :             : 
    4885                 :       30281 :   gcc_assert (TYPE_ATOMIC (lhs_type));
    4886                 :             : 
    4887                 :       30281 :   if (return_old_p)
    4888                 :        2299 :     gcc_assert (modifycode == PLUS_EXPR || modifycode == MINUS_EXPR);
    4889                 :             : 
    4890                 :             :   /* Allocate enough vector items for a compare_exchange.  */
    4891                 :       30281 :   vec_alloc (params, 6);
    4892                 :             : 
    4893                 :             :   /* Create a compound statement to hold the sequence of statements
    4894                 :             :      with a loop.  */
    4895                 :       30281 :   if (modifycode != NOP_EXPR)
    4896                 :             :     {
    4897                 :       19908 :       compound_stmt = c_begin_compound_stmt (false);
    4898                 :             : 
    4899                 :             :       /* For consistency with build_modify_expr on non-_Atomic,
    4900                 :             :          mark the lhs as read.  Also, it would be very hard to match
    4901                 :             :          such expressions in mark_exp_read.  */
    4902                 :       19908 :       mark_exp_read (lhs);
    4903                 :             :     }
    4904                 :             : 
    4905                 :             :   /* Remove any excess precision (which is only present here in the
    4906                 :             :      case of compound assignments).  */
    4907                 :       30281 :   if (TREE_CODE (rhs) == EXCESS_PRECISION_EXPR)
    4908                 :             :     {
    4909                 :           0 :       gcc_assert (modifycode != NOP_EXPR);
    4910                 :           0 :       rhs = TREE_OPERAND (rhs, 0);
    4911                 :             :     }
    4912                 :       30281 :   rhs_type = TREE_TYPE (rhs);
    4913                 :             : 
    4914                 :             :   /* Fold the RHS if it hasn't already been folded.  */
    4915                 :       30281 :   if (modifycode != NOP_EXPR)
    4916                 :       19908 :     rhs = c_fully_fold (rhs, false, NULL);
    4917                 :             : 
    4918                 :             :   /* Remove the qualifiers for the rest of the expressions and create
    4919                 :             :      the VAL temp variable to hold the RHS.  */
    4920                 :       30281 :   nonatomic_lhs_type = build_qualified_type (lhs_type, TYPE_UNQUALIFIED);
    4921                 :       30281 :   nonatomic_rhs_type = build_qualified_type (rhs_type, TYPE_UNQUALIFIED);
    4922                 :       30281 :   nonatomic_rhs_semantic_type = build_qualified_type (rhs_semantic_type,
    4923                 :             :                                                       TYPE_UNQUALIFIED);
    4924                 :       30281 :   val = create_tmp_var_raw (nonatomic_rhs_type);
    4925                 :       30281 :   TREE_ADDRESSABLE (val) = 1;
    4926                 :       30281 :   suppress_warning (val);
    4927                 :       30281 :   rhs = build4 (TARGET_EXPR, nonatomic_rhs_type, val, rhs, NULL_TREE,
    4928                 :             :                 NULL_TREE);
    4929                 :       30281 :   TREE_SIDE_EFFECTS (rhs) = 1;
    4930                 :       30281 :   SET_EXPR_LOCATION (rhs, loc);
    4931                 :       30281 :   if (modifycode != NOP_EXPR)
    4932                 :       19908 :     add_stmt (rhs);
    4933                 :             : 
    4934                 :             :   /* NOP_EXPR indicates it's a straight store of the RHS. Simply issue
    4935                 :             :      an atomic_store.  */
    4936                 :       30281 :   if (modifycode == NOP_EXPR)
    4937                 :             :     {
    4938                 :       10373 :       compound_stmt = rhs;
    4939                 :             :       /* Build __atomic_store (&lhs, &val, SEQ_CST)  */
    4940                 :       10373 :       rhs = build_unary_op (loc, ADDR_EXPR, val, false);
    4941                 :       10373 :       fndecl = builtin_decl_explicit (BUILT_IN_ATOMIC_STORE);
    4942                 :       10373 :       params->quick_push (lhs_addr);
    4943                 :       10373 :       params->quick_push (rhs);
    4944                 :       10373 :       params->quick_push (seq_cst);
    4945                 :       10373 :       func_call = c_build_function_call_vec (loc, vNULL, fndecl, params, NULL);
    4946                 :             : 
    4947                 :       10373 :       compound_stmt = build2 (COMPOUND_EXPR, void_type_node,
    4948                 :             :                               compound_stmt, func_call);
    4949                 :             : 
    4950                 :             :       /* VAL is the value which was stored, return a COMPOUND_STMT of
    4951                 :             :          the statement and that value.  */
    4952                 :       10373 :       return build2 (COMPOUND_EXPR, nonatomic_lhs_type, compound_stmt, val);
    4953                 :             :     }
    4954                 :             : 
    4955                 :             :   /* Attempt to implement the atomic operation as an __atomic_fetch_* or
    4956                 :             :      __atomic_*_fetch built-in rather than a CAS loop.  atomic_bool type
    4957                 :             :      isn't applicable for such builtins.  ??? Do we want to handle enums?  */
    4958                 :       19908 :   if ((TREE_CODE (lhs_type) == INTEGER_TYPE || POINTER_TYPE_P (lhs_type))
    4959                 :       13941 :       && TREE_CODE (rhs_type) == INTEGER_TYPE)
    4960                 :             :     {
    4961                 :       11713 :       built_in_function fncode;
    4962                 :       11713 :       switch (modifycode)
    4963                 :             :         {
    4964                 :        3075 :         case PLUS_EXPR:
    4965                 :        3075 :         case POINTER_PLUS_EXPR:
    4966                 :        3075 :           fncode = (return_old_p
    4967                 :        3075 :                     ? BUILT_IN_ATOMIC_FETCH_ADD_N
    4968                 :             :                     : BUILT_IN_ATOMIC_ADD_FETCH_N);
    4969                 :             :           break;
    4970                 :        2889 :         case MINUS_EXPR:
    4971                 :        2889 :           fncode = (return_old_p
    4972                 :        2889 :                     ? BUILT_IN_ATOMIC_FETCH_SUB_N
    4973                 :             :                     : BUILT_IN_ATOMIC_SUB_FETCH_N);
    4974                 :             :           break;
    4975                 :         609 :         case BIT_AND_EXPR:
    4976                 :         609 :           fncode = (return_old_p
    4977                 :         609 :                     ? BUILT_IN_ATOMIC_FETCH_AND_N
    4978                 :             :                     : BUILT_IN_ATOMIC_AND_FETCH_N);
    4979                 :             :           break;
    4980                 :         609 :         case BIT_IOR_EXPR:
    4981                 :         609 :           fncode = (return_old_p
    4982                 :         609 :                     ? BUILT_IN_ATOMIC_FETCH_OR_N
    4983                 :             :                     : BUILT_IN_ATOMIC_OR_FETCH_N);
    4984                 :             :           break;
    4985                 :         609 :         case BIT_XOR_EXPR:
    4986                 :         609 :           fncode = (return_old_p
    4987                 :         609 :                     ? BUILT_IN_ATOMIC_FETCH_XOR_N
    4988                 :             :                     : BUILT_IN_ATOMIC_XOR_FETCH_N);
    4989                 :             :           break;
    4990                 :        3922 :         default:
    4991                 :        3922 :           goto cas_loop;
    4992                 :             :         }
    4993                 :             : 
    4994                 :             :       /* We can only use "_1" through "_16" variants of the atomic fetch
    4995                 :             :          built-ins.  */
    4996                 :        7791 :       unsigned HOST_WIDE_INT size = tree_to_uhwi (TYPE_SIZE_UNIT (lhs_type));
    4997                 :        7791 :       if (size != 1 && size != 2 && size != 4 && size != 8 && size != 16)
    4998                 :           0 :         goto cas_loop;
    4999                 :             : 
    5000                 :             :       /* If this is a pointer type, we need to multiply by the size of
    5001                 :             :          the pointer target type.  */
    5002                 :        7791 :       if (POINTER_TYPE_P (lhs_type))
    5003                 :             :         {
    5004                 :        1018 :           if (!COMPLETE_TYPE_P (TREE_TYPE (lhs_type))
    5005                 :             :               /* ??? This would introduce -Wdiscarded-qualifiers
    5006                 :             :                  warning: __atomic_fetch_* expect volatile void *
    5007                 :             :                  type as the first argument.  (Assignments between
    5008                 :             :                  atomic and non-atomic objects are OK.) */
    5009                 :        1018 :               || TYPE_RESTRICT (lhs_type))
    5010                 :          17 :             goto cas_loop;
    5011                 :        1001 :           tree sz = TYPE_SIZE_UNIT (TREE_TYPE (lhs_type));
    5012                 :        1001 :           rhs = fold_build2_loc (loc, MULT_EXPR, ptrdiff_type_node,
    5013                 :             :                                  convert (ptrdiff_type_node, rhs),
    5014                 :             :                                  convert (ptrdiff_type_node, sz));
    5015                 :             :         }
    5016                 :             : 
    5017                 :             :       /* Build __atomic_fetch_* (&lhs, &val, SEQ_CST), or
    5018                 :             :          __atomic_*_fetch (&lhs, &val, SEQ_CST).  */
    5019                 :        7774 :       fndecl = builtin_decl_explicit (fncode);
    5020                 :        7774 :       params->quick_push (lhs_addr);
    5021                 :        7774 :       params->quick_push (rhs);
    5022                 :        7774 :       params->quick_push (seq_cst);
    5023                 :        7774 :       func_call = c_build_function_call_vec (loc, vNULL, fndecl, params, NULL);
    5024                 :             : 
    5025                 :        7774 :       newval = create_tmp_var_raw (nonatomic_lhs_type);
    5026                 :        7774 :       TREE_ADDRESSABLE (newval) = 1;
    5027                 :        7774 :       suppress_warning (newval);
    5028                 :        7774 :       rhs = build4 (TARGET_EXPR, nonatomic_lhs_type, newval, func_call,
    5029                 :             :                     NULL_TREE, NULL_TREE);
    5030                 :        7774 :       SET_EXPR_LOCATION (rhs, loc);
    5031                 :        7774 :       add_stmt (rhs);
    5032                 :             : 
    5033                 :             :       /* Finish the compound statement.  */
    5034                 :        7774 :       compound_stmt = c_end_compound_stmt (loc, compound_stmt, false);
    5035                 :             : 
    5036                 :             :       /* NEWVAL is the value which was stored, return a COMPOUND_STMT of
    5037                 :             :          the statement and that value.  */
    5038                 :        7774 :       return build2 (COMPOUND_EXPR, nonatomic_lhs_type, compound_stmt, newval);
    5039                 :             :     }
    5040                 :             : 
    5041                 :        8195 : cas_loop:
    5042                 :             :   /* Create the variables and labels required for the op= form.  */
    5043                 :       12134 :   old = create_tmp_var_raw (nonatomic_lhs_type);
    5044                 :       12134 :   old_addr = build_unary_op (loc, ADDR_EXPR, old, false);
    5045                 :       12134 :   TREE_ADDRESSABLE (old) = 1;
    5046                 :       12134 :   suppress_warning (old);
    5047                 :             : 
    5048                 :       12134 :   newval = create_tmp_var_raw (nonatomic_lhs_type);
    5049                 :       12134 :   newval_addr = build_unary_op (loc, ADDR_EXPR, newval, false);
    5050                 :       12134 :   TREE_ADDRESSABLE (newval) = 1;
    5051                 :       12134 :   suppress_warning (newval);
    5052                 :             : 
    5053                 :       12134 :   loop_decl = create_artificial_label (loc);
    5054                 :       12134 :   loop_label = build1 (LABEL_EXPR, void_type_node, loop_decl);
    5055                 :             : 
    5056                 :       12134 :   done_decl = create_artificial_label (loc);
    5057                 :       12134 :   done_label = build1 (LABEL_EXPR, void_type_node, done_decl);
    5058                 :             : 
    5059                 :             :   /* __atomic_load (addr, &old, SEQ_CST).  */
    5060                 :       12134 :   fndecl = builtin_decl_explicit (BUILT_IN_ATOMIC_LOAD);
    5061                 :       12134 :   params->quick_push (lhs_addr);
    5062                 :       12134 :   params->quick_push (old_addr);
    5063                 :       12134 :   params->quick_push (seq_cst);
    5064                 :       12134 :   func_call = c_build_function_call_vec (loc, vNULL, fndecl, params, NULL);
    5065                 :       12134 :   old = build4 (TARGET_EXPR, nonatomic_lhs_type, old, func_call, NULL_TREE,
    5066                 :             :                 NULL_TREE);
    5067                 :       12134 :   add_stmt (old);
    5068                 :       12134 :   params->truncate (0);
    5069                 :             : 
    5070                 :             :   /* Create the expressions for floating-point environment
    5071                 :             :      manipulation, if required.  */
    5072                 :       12134 :   bool need_fenv = (flag_trapping_math
    5073                 :       12134 :                     && (FLOAT_TYPE_P (lhs_type) || FLOAT_TYPE_P (rhs_type)));
    5074                 :       12134 :   tree hold_call = NULL_TREE, clear_call = NULL_TREE, update_call = NULL_TREE;
    5075                 :       12134 :   if (need_fenv)
    5076                 :        7054 :     targetm.atomic_assign_expand_fenv (&hold_call, &clear_call, &update_call);
    5077                 :             : 
    5078                 :       12134 :   if (hold_call)
    5079                 :        7054 :     add_stmt (hold_call);
    5080                 :             : 
    5081                 :             :   /* loop:  */
    5082                 :       12134 :   add_stmt (loop_label);
    5083                 :             : 
    5084                 :             :   /* newval = old + val;  */
    5085                 :       12134 :   if (rhs_type != rhs_semantic_type)
    5086                 :           0 :     val = build1 (EXCESS_PRECISION_EXPR, nonatomic_rhs_semantic_type, val);
    5087                 :       12134 :   rhs = build_binary_op (loc, modifycode, old, val, true);
    5088                 :       12134 :   if (TREE_CODE (rhs) == EXCESS_PRECISION_EXPR)
    5089                 :             :     {
    5090                 :           0 :       tree eptype = TREE_TYPE (rhs);
    5091                 :           0 :       rhs = c_fully_fold (TREE_OPERAND (rhs, 0), false, NULL);
    5092                 :           0 :       rhs = build1 (EXCESS_PRECISION_EXPR, eptype, rhs);
    5093                 :             :     }
    5094                 :             :   else
    5095                 :       12134 :     rhs = c_fully_fold (rhs, false, NULL);
    5096                 :       12134 :   rhs = convert_for_assignment (loc, UNKNOWN_LOCATION, nonatomic_lhs_type,
    5097                 :             :                                 rhs, NULL_TREE, ic_assign, false, NULL_TREE,
    5098                 :             :                                 NULL_TREE, 0);
    5099                 :             :   /* The temporary variable for NEWVAL is only gimplified correctly (in
    5100                 :             :      particular, given a DECL_CONTEXT) if used in a TARGET_EXPR.  To avoid
    5101                 :             :      subsequent ICEs in nested function processing after an error, ensure such
    5102                 :             :      a TARGET_EXPR is built even after an error.  */
    5103                 :       12134 :   if (rhs == error_mark_node)
    5104                 :          10 :     rhs = old;
    5105                 :       12134 :   rhs = build4 (TARGET_EXPR, nonatomic_lhs_type, newval, rhs, NULL_TREE,
    5106                 :             :                 NULL_TREE);
    5107                 :       12134 :   SET_EXPR_LOCATION (rhs, loc);
    5108                 :       12134 :   add_stmt (rhs);
    5109                 :             : 
    5110                 :             :   /* if (__atomic_compare_exchange (addr, &old, &new, false, SEQ_CST, SEQ_CST))
    5111                 :             :        goto done;  */
    5112                 :       12134 :   fndecl = builtin_decl_explicit (BUILT_IN_ATOMIC_COMPARE_EXCHANGE);
    5113                 :       12134 :   params->quick_push (lhs_addr);
    5114                 :       12134 :   params->quick_push (old_addr);
    5115                 :       12134 :   params->quick_push (newval_addr);
    5116                 :       12134 :   params->quick_push (integer_zero_node);
    5117                 :       12134 :   params->quick_push (seq_cst);
    5118                 :       12134 :   params->quick_push (seq_cst);
    5119                 :       12134 :   func_call = c_build_function_call_vec (loc, vNULL, fndecl, params, NULL);
    5120                 :             : 
    5121                 :       12134 :   goto_stmt = build1 (GOTO_EXPR, void_type_node, done_decl);
    5122                 :       12134 :   SET_EXPR_LOCATION (goto_stmt, loc);
    5123                 :             : 
    5124                 :       12134 :   stmt = build3 (COND_EXPR, void_type_node, func_call, goto_stmt, NULL_TREE);
    5125                 :       12134 :   SET_EXPR_LOCATION (stmt, loc);
    5126                 :       12134 :   add_stmt (stmt);
    5127                 :             : 
    5128                 :       12134 :   if (clear_call)
    5129                 :        7054 :     add_stmt (clear_call);
    5130                 :             : 
    5131                 :             :   /* goto loop;  */
    5132                 :       12134 :   goto_stmt  = build1 (GOTO_EXPR, void_type_node, loop_decl);
    5133                 :       12134 :   SET_EXPR_LOCATION (goto_stmt, loc);
    5134                 :       12134 :   add_stmt (goto_stmt);
    5135                 :             : 
    5136                 :             :   /* done:  */
    5137                 :       12134 :   add_stmt (done_label);
    5138                 :             : 
    5139                 :       12134 :   if (update_call)
    5140                 :        7054 :     add_stmt (update_call);
    5141                 :             : 
    5142                 :             :   /* Finish the compound statement.  */
    5143                 :       12134 :   compound_stmt = c_end_compound_stmt (loc, compound_stmt, false);
    5144                 :             : 
    5145                 :             :   /* NEWVAL is the value that was successfully stored, return a
    5146                 :             :      COMPOUND_EXPR of the statement and the appropriate value.  */
    5147                 :       23709 :   return build2 (COMPOUND_EXPR, nonatomic_lhs_type, compound_stmt,
    5148                 :       12134 :                  return_old_p ? old : newval);
    5149                 :             : }
    5150                 :             : 
    5151                 :             : /* Construct and perhaps optimize a tree representation
    5152                 :             :    for a unary operation.  CODE, a tree_code, specifies the operation
    5153                 :             :    and XARG is the operand.
    5154                 :             :    For any CODE other than ADDR_EXPR, NOCONVERT suppresses the default
    5155                 :             :    promotions (such as from short to int).
    5156                 :             :    For ADDR_EXPR, the default promotions are not applied; NOCONVERT allows
    5157                 :             :    non-lvalues; this is only used to handle conversion of non-lvalue arrays
    5158                 :             :    to pointers in C99.
    5159                 :             : 
    5160                 :             :    LOCATION is the location of the operator.  */
    5161                 :             : 
    5162                 :             : tree
    5163                 :    61561252 : build_unary_op (location_t location, enum tree_code code, tree xarg,
    5164                 :             :                 bool noconvert)
    5165                 :             : {
    5166                 :             :   /* No default_conversion here.  It causes trouble for ADDR_EXPR.  */
    5167                 :    61561252 :   tree arg = xarg;
    5168                 :    61561252 :   tree argtype = NULL_TREE;
    5169                 :    61561252 :   enum tree_code typecode;
    5170                 :    61561252 :   tree val;
    5171                 :    61561252 :   tree ret = error_mark_node;
    5172                 :    61561252 :   tree eptype = NULL_TREE;
    5173                 :    61561252 :   const char *invalid_op_diag;
    5174                 :    61561252 :   bool int_operands;
    5175                 :             : 
    5176                 :    61561252 :   int_operands = EXPR_INT_CONST_OPERANDS (xarg);
    5177                 :     6731695 :   if (int_operands)
    5178                 :     6731695 :     arg = remove_c_maybe_const_expr (arg);
    5179                 :             : 
    5180                 :    61561252 :   if (code != ADDR_EXPR)
    5181                 :     8747298 :     arg = require_complete_type (location, arg);
    5182                 :             : 
    5183                 :    61561252 :   typecode = TREE_CODE (TREE_TYPE (arg));
    5184                 :    61561252 :   if (typecode == ERROR_MARK)
    5185                 :          74 :     return error_mark_node;
    5186                 :    61561178 :   if (typecode == ENUMERAL_TYPE || typecode == BOOLEAN_TYPE)
    5187                 :       28063 :     typecode = INTEGER_TYPE;
    5188                 :             : 
    5189                 :   123122356 :   if ((invalid_op_diag
    5190                 :    61561178 :        = targetm.invalid_unary_op (code, TREE_TYPE (xarg))))
    5191                 :             :     {
    5192                 :           0 :       error_at (location, invalid_op_diag);
    5193                 :           0 :       return error_mark_node;
    5194                 :             :     }
    5195                 :             : 
    5196                 :    61561178 :   if (TREE_CODE (arg) == EXCESS_PRECISION_EXPR)
    5197                 :             :     {
    5198                 :         235 :       eptype = TREE_TYPE (arg);
    5199                 :         235 :       arg = TREE_OPERAND (arg, 0);
    5200                 :             :     }
    5201                 :             : 
    5202                 :    61561178 :   switch (code)
    5203                 :             :     {
    5204                 :       28529 :     case CONVERT_EXPR:
    5205                 :             :       /* This is used for unary plus, because a CONVERT_EXPR
    5206                 :             :          is enough to prevent anybody from looking inside for
    5207                 :             :          associativity, but won't generate any code.  */
    5208                 :       28534 :       if (!(typecode == INTEGER_TYPE || typecode == REAL_TYPE
    5209                 :           8 :             || typecode == FIXED_POINT_TYPE || typecode == COMPLEX_TYPE
    5210                 :           5 :             || typecode == BITINT_TYPE
    5211                 :           5 :             || gnu_vector_type_p (TREE_TYPE (arg))))
    5212                 :             :         {
    5213                 :           1 :           error_at (location, "wrong type argument to unary plus");
    5214                 :           1 :           return error_mark_node;
    5215                 :             :         }
    5216                 :       28528 :       else if (!noconvert)
    5217                 :       28528 :         arg = default_conversion (arg);
    5218                 :       28528 :       arg = non_lvalue_loc (location, arg);
    5219                 :       28528 :       break;
    5220                 :             : 
    5221                 :     6959610 :     case NEGATE_EXPR:
    5222                 :     7396893 :       if (!(typecode == INTEGER_TYPE || typecode == REAL_TYPE
    5223                 :      473674 :             || typecode == FIXED_POINT_TYPE || typecode == COMPLEX_TYPE
    5224                 :      442407 :             || typecode == BITINT_TYPE
    5225                 :      437283 :             || gnu_vector_type_p (TREE_TYPE (arg))))
    5226                 :             :         {
    5227                 :           1 :           error_at (location, "wrong type argument to unary minus");
    5228                 :           1 :           return error_mark_node;
    5229                 :             :         }
    5230                 :     6959609 :       else if (!noconvert)
    5231                 :     6959609 :         arg = default_conversion (arg);
    5232                 :             :       break;
    5233                 :             : 
    5234                 :      289010 :     case BIT_NOT_EXPR:
    5235                 :             :       /* ~ works on integer types and non float vectors. */
    5236                 :      289010 :       if (typecode == INTEGER_TYPE
    5237                 :      289010 :           || typecode == BITINT_TYPE
    5238                 :      289010 :           || (gnu_vector_type_p (TREE_TYPE (arg))
    5239                 :        2057 :               && !VECTOR_FLOAT_TYPE_P (TREE_TYPE (arg))))
    5240                 :             :         {
    5241                 :             :           tree e = arg;
    5242                 :             : 
    5243                 :             :           /* Warn if the expression has boolean value.  */
    5244                 :      288411 :           while (TREE_CODE (e) == COMPOUND_EXPR)
    5245                 :          11 :             e = TREE_OPERAND (e, 1);
    5246                 :             : 
    5247                 :      576787 :           if ((C_BOOLEAN_TYPE_P (TREE_TYPE (arg))
    5248                 :      576787 :                || truth_value_p (TREE_CODE (e))))
    5249                 :             :             {
    5250                 :         136 :               auto_diagnostic_group d;
    5251                 :         136 :               if (warning_at (location, OPT_Wbool_operation,
    5252                 :             :                                 "%<~%> on a boolean expression"))
    5253                 :             :                 {
    5254                 :          12 :                   gcc_rich_location richloc (location);
    5255                 :          12 :                   richloc.add_fixit_insert_before (location, "!");
    5256                 :          12 :                   inform (&richloc, "did you mean to use logical not?");
    5257                 :          12 :                 }
    5258                 :         136 :             }
    5259                 :      288400 :           if (!noconvert)
    5260                 :      288400 :             arg = default_conversion (arg);
    5261                 :             :         }
    5262                 :         610 :       else if (typecode == COMPLEX_TYPE)
    5263                 :             :         {
    5264                 :         605 :           code = CONJ_EXPR;
    5265                 :         605 :           pedwarn (location, OPT_Wpedantic,
    5266                 :             :                    "ISO C does not support %<~%> for complex conjugation");
    5267                 :         605 :           if (!noconvert)
    5268                 :         605 :             arg = default_conversion (arg);
    5269                 :             :         }
    5270                 :             :       else
    5271                 :             :         {
    5272                 :           5 :           error_at (location, "wrong type argument to bit-complement");
    5273                 :           5 :           return error_mark_node;
    5274                 :             :         }
    5275                 :             :       break;
    5276                 :             : 
    5277                 :           3 :     case ABS_EXPR:
    5278                 :           3 :       if (!(typecode == INTEGER_TYPE || typecode == REAL_TYPE))
    5279                 :             :         {
    5280                 :           0 :           error_at (location, "wrong type argument to abs");
    5281                 :           0 :           return error_mark_node;
    5282                 :             :         }
    5283                 :           3 :       else if (!noconvert)
    5284                 :           3 :         arg = default_conversion (arg);
    5285                 :             :       break;
    5286                 :             : 
    5287                 :           7 :     case ABSU_EXPR:
    5288                 :           7 :       if (!(typecode == INTEGER_TYPE))
    5289                 :             :         {
    5290                 :           0 :           error_at (location, "wrong type argument to absu");
    5291                 :           0 :           return error_mark_node;
    5292                 :             :         }
    5293                 :           7 :       else if (!noconvert)
    5294                 :           7 :         arg = default_conversion (arg);
    5295                 :             :       break;
    5296                 :             : 
    5297                 :           0 :     case CONJ_EXPR:
    5298                 :             :       /* Conjugating a real value is a no-op, but allow it anyway.  */
    5299                 :           0 :       if (!(typecode == INTEGER_TYPE || typecode == REAL_TYPE
    5300                 :             :             || typecode == COMPLEX_TYPE))
    5301                 :             :         {
    5302                 :           0 :           error_at (location, "wrong type argument to conjugation");
    5303                 :           0 :           return error_mark_node;
    5304                 :             :         }
    5305                 :           0 :       else if (!noconvert)
    5306                 :           0 :         arg = default_conversion (arg);
    5307                 :             :       break;
    5308                 :             : 
    5309                 :      372752 :     case TRUTH_NOT_EXPR:
    5310                 :      372752 :       if (typecode != INTEGER_TYPE && typecode != FIXED_POINT_TYPE
    5311                 :        6950 :           && typecode != REAL_TYPE && typecode != POINTER_TYPE
    5312                 :          21 :           && typecode != COMPLEX_TYPE && typecode != NULLPTR_TYPE
    5313                 :          18 :           && typecode != BITINT_TYPE)
    5314                 :             :         {
    5315                 :          10 :           error_at (location,
    5316                 :             :                     "wrong type argument to unary exclamation mark");
    5317                 :          10 :           return error_mark_node;
    5318                 :             :         }
    5319                 :      372742 :       if (int_operands)
    5320                 :             :         {
    5321                 :      139670 :           arg = c_objc_common_truthvalue_conversion (location, xarg);
    5322                 :      139670 :           arg = remove_c_maybe_const_expr (arg);
    5323                 :             :         }
    5324                 :             :       else
    5325                 :      233072 :         arg = c_objc_common_truthvalue_conversion (location, arg);
    5326                 :      372742 :       ret = invert_truthvalue_loc (location, arg);
    5327                 :             :       /* If the TRUTH_NOT_EXPR has been folded, reset the location.  */
    5328                 :      372742 :       if (EXPR_P (ret) && EXPR_HAS_LOCATION (ret))
    5329                 :      232677 :         location = EXPR_LOCATION (ret);
    5330                 :      372742 :       goto return_build_unary_op;
    5331                 :             : 
    5332                 :      201204 :     case REALPART_EXPR:
    5333                 :      201204 :     case IMAGPART_EXPR:
    5334                 :      201204 :       ret = build_real_imag_expr (location, code, arg);
    5335                 :      201204 :       if (ret == error_mark_node)
    5336                 :             :         return error_mark_node;
    5337                 :      201196 :       if (eptype && TREE_CODE (eptype) == COMPLEX_TYPE)
    5338                 :           2 :         eptype = TREE_TYPE (eptype);
    5339                 :      201196 :       goto return_build_unary_op;
    5340                 :             : 
    5341                 :      896141 :     case PREINCREMENT_EXPR:
    5342                 :      896141 :     case POSTINCREMENT_EXPR:
    5343                 :      896141 :     case PREDECREMENT_EXPR:
    5344                 :      896141 :     case POSTDECREMENT_EXPR:
    5345                 :             : 
    5346                 :      896141 :       if (TREE_CODE (arg) == C_MAYBE_CONST_EXPR)
    5347                 :             :         {
    5348                 :           2 :           tree inner = build_unary_op (location, code,
    5349                 :           2 :                                        C_MAYBE_CONST_EXPR_EXPR (arg),
    5350                 :             :                                        noconvert);
    5351                 :           2 :           if (inner == error_mark_node)
    5352                 :             :             return error_mark_node;
    5353                 :           4 :           ret = build2 (C_MAYBE_CONST_EXPR, TREE_TYPE (inner),
    5354                 :           2 :                         C_MAYBE_CONST_EXPR_PRE (arg), inner);
    5355                 :           2 :           gcc_assert (!C_MAYBE_CONST_EXPR_INT_OPERANDS (arg));
    5356                 :           2 :           C_MAYBE_CONST_EXPR_NON_CONST (ret) = 1;
    5357                 :           2 :           goto return_build_unary_op;
    5358                 :             :         }
    5359                 :             : 
    5360                 :             :       /* Complain about anything that is not a true lvalue.  In
    5361                 :             :          Objective-C, skip this check for property_refs.  */
    5362                 :      896139 :       if (!objc_is_property_ref (arg)
    5363                 :     1792278 :           && !lvalue_or_else (location,
    5364                 :      896139 :                               arg, ((code == PREINCREMENT_EXPR
    5365                 :      896139 :                                      || code == POSTINCREMENT_EXPR)
    5366                 :             :                                     ? lv_increment
    5367                 :             :                                     : lv_decrement)))
    5368                 :          20 :         return error_mark_node;
    5369                 :             : 
    5370                 :      896119 :       if (warn_cxx_compat && TREE_CODE (TREE_TYPE (arg)) == ENUMERAL_TYPE)
    5371                 :             :         {
    5372                 :           4 :           if (code == PREINCREMENT_EXPR || code == POSTINCREMENT_EXPR)
    5373                 :           2 :             warning_at (location, OPT_Wc___compat,
    5374                 :             :                         "increment of enumeration value is invalid in C++");
    5375                 :             :           else
    5376                 :           2 :             warning_at (location, OPT_Wc___compat,
    5377                 :             :                         "decrement of enumeration value is invalid in C++");
    5378                 :             :         }
    5379                 :             : 
    5380                 :      896119 :       if (C_BOOLEAN_TYPE_P (TREE_TYPE (arg)))
    5381                 :             :         {
    5382                 :         264 :           if (code == PREINCREMENT_EXPR || code == POSTINCREMENT_EXPR)
    5383                 :         132 :             warning_at (location, OPT_Wbool_operation,
    5384                 :             :                         "increment of a boolean expression");
    5385                 :             :           else
    5386                 :         132 :             warning_at (location, OPT_Wbool_operation,
    5387                 :             :                         "decrement of a boolean expression");
    5388                 :             :         }
    5389                 :             : 
    5390                 :             :       /* Ensure the argument is fully folded inside any SAVE_EXPR.  */
    5391                 :      896119 :       arg = c_fully_fold (arg, false, NULL, true);
    5392                 :             : 
    5393                 :      896119 :       bool atomic_op;
    5394                 :      896119 :       atomic_op = really_atomic_lvalue (arg);
    5395                 :             : 
    5396                 :             :       /* Increment or decrement the real part of the value,
    5397                 :             :          and don't change the imaginary part.  */
    5398                 :      896119 :       if (typecode == COMPLEX_TYPE)
    5399                 :             :         {
    5400                 :          57 :           tree real, imag;
    5401                 :             : 
    5402                 :          57 :           pedwarn_c23 (location, OPT_Wpedantic,
    5403                 :             :                        "ISO C does not support %<++%> and %<--%> on complex "
    5404                 :             :                        "types before C2Y");
    5405                 :             : 
    5406                 :          57 :           if (!atomic_op)
    5407                 :             :             {
    5408                 :          53 :               arg = stabilize_reference (arg);
    5409                 :          53 :               real = build_unary_op (EXPR_LOCATION (arg), REALPART_EXPR, arg,
    5410                 :             :                                      true);
    5411                 :          53 :               imag = build_unary_op (EXPR_LOCATION (arg), IMAGPART_EXPR, arg,
    5412                 :             :                                      true);
    5413                 :          53 :               real = build_unary_op (EXPR_LOCATION (arg), code, real, true);
    5414                 :          53 :               if (real == error_mark_node || imag == error_mark_node)
    5415                 :             :                 return error_mark_node;
    5416                 :          53 :               ret = build2 (COMPLEX_EXPR, TREE_TYPE (arg),
    5417                 :             :                             real, imag);
    5418                 :          53 :               goto return_build_unary_op;
    5419                 :             :             }
    5420                 :             :         }
    5421                 :             : 
    5422                 :             :       /* Report invalid types.  */
    5423                 :             : 
    5424                 :      896066 :       if (typecode != POINTER_TYPE && typecode != FIXED_POINT_TYPE
    5425                 :      668008 :           && typecode != INTEGER_TYPE && typecode != REAL_TYPE
    5426                 :         143 :           && typecode != COMPLEX_TYPE && typecode != BITINT_TYPE
    5427                 :      896115 :           && !gnu_vector_type_p (TREE_TYPE (arg)))
    5428                 :             :         {
    5429                 :           5 :           if (code == PREINCREMENT_EXPR || code == POSTINCREMENT_EXPR)
    5430                 :           3 :             error_at (location, "wrong type argument to increment");
    5431                 :             :           else
    5432                 :           2 :             error_at (location, "wrong type argument to decrement");
    5433                 :             : 
    5434                 :           5 :           return error_mark_node;
    5435                 :             :         }
    5436                 :             : 
    5437                 :      896061 :       {
    5438                 :      896061 :         tree inc;
    5439                 :             : 
    5440                 :      896061 :         argtype = TREE_TYPE (arg);
    5441                 :             : 
    5442                 :             :         /* Compute the increment.  */
    5443                 :             : 
    5444                 :      896061 :         if (typecode == POINTER_TYPE)
    5445                 :             :           {
    5446                 :             :             /* If pointer target is an incomplete type,
    5447                 :             :                we just cannot know how to do the arithmetic.  */
    5448                 :      228058 :             if (!COMPLETE_OR_VOID_TYPE_P (TREE_TYPE (argtype)))
    5449                 :             :               {
    5450                 :          27 :                 if (code == PREINCREMENT_EXPR || code == POSTINCREMENT_EXPR)
    5451                 :          17 :                   error_at (location,
    5452                 :             :                             "increment of pointer to an incomplete type %qT",
    5453                 :          17 :                             TREE_TYPE (argtype));
    5454                 :             :                 else
    5455                 :          10 :                   error_at (location,
    5456                 :             :                             "decrement of pointer to an incomplete type %qT",
    5457                 :          10 :                             TREE_TYPE (argtype));
    5458                 :             :               }
    5459                 :      228031 :             else if (TREE_CODE (TREE_TYPE (argtype)) == FUNCTION_TYPE
    5460                 :      228031 :                      || VOID_TYPE_P (TREE_TYPE (argtype)))
    5461                 :             :               {
    5462                 :          10 :                 if (code == PREINCREMENT_EXPR || code == POSTINCREMENT_EXPR)
    5463                 :           6 :                   pedwarn (location, OPT_Wpointer_arith,
    5464                 :             :                            "wrong type argument to increment");
    5465                 :             :                 else
    5466                 :           4 :                   pedwarn (location, OPT_Wpointer_arith,
    5467                 :             :                            "wrong type argument to decrement");
    5468                 :             :               }
    5469                 :             :             else
    5470                 :      456042 :               verify_type_context (location, TCTX_POINTER_ARITH,
    5471                 :      228021 :                                    TREE_TYPE (argtype));
    5472                 :             : 
    5473                 :      228058 :             inc = c_size_in_bytes (TREE_TYPE (argtype));
    5474                 :      228058 :             inc = convert_to_ptrofftype_loc (location, inc);
    5475                 :             :           }
    5476                 :      668003 :         else if (FRACT_MODE_P (TYPE_MODE (argtype)))
    5477                 :             :           {
    5478                 :             :             /* For signed fract types, we invert ++ to -- or
    5479                 :             :                -- to ++, and change inc from 1 to -1, because
    5480                 :             :                it is not possible to represent 1 in signed fract constants.
    5481                 :             :                For unsigned fract types, the result always overflows and
    5482                 :             :                we get an undefined (original) or the maximum value.  */
    5483                 :           0 :             if (code == PREINCREMENT_EXPR)
    5484                 :             :               code = PREDECREMENT_EXPR;
    5485                 :             :             else if (code == PREDECREMENT_EXPR)
    5486                 :             :               code = PREINCREMENT_EXPR;
    5487                 :             :             else if (code == POSTINCREMENT_EXPR)
    5488                 :             :               code = POSTDECREMENT_EXPR;
    5489                 :             :             else /* code == POSTDECREMENT_EXPR  */
    5490                 :           0 :               code = POSTINCREMENT_EXPR;
    5491                 :             : 
    5492                 :           0 :             inc = integer_minus_one_node;
    5493                 :           0 :             inc = convert (argtype, inc);
    5494                 :             :           }
    5495                 :             :         else
    5496                 :             :           {
    5497                 :     1336006 :             inc = VECTOR_TYPE_P (argtype)
    5498                 :      668003 :               ? build_one_cst (argtype)
    5499                 :             :               : integer_one_node;
    5500                 :      668003 :             inc = convert (argtype, inc);
    5501                 :             :           }
    5502                 :             : 
    5503                 :             :         /* If 'arg' is an Objective-C PROPERTY_REF expression, then we
    5504                 :             :            need to ask Objective-C to build the increment or decrement
    5505                 :             :            expression for it.  */
    5506                 :      896061 :         if (objc_is_property_ref (arg))
    5507                 :           0 :           return objc_build_incr_expr_for_property_ref (location, code,
    5508                 :           0 :                                                         arg, inc);
    5509                 :             : 
    5510                 :             :         /* Report a read-only lvalue.  */
    5511                 :      896061 :         if (TYPE_READONLY (argtype))
    5512                 :             :           {
    5513                 :          20 :             readonly_error (location, arg,
    5514                 :          20 :                             ((code == PREINCREMENT_EXPR
    5515                 :          20 :                               || code == POSTINCREMENT_EXPR)
    5516                 :             :                              ? lv_increment : lv_decrement));
    5517                 :          20 :             return error_mark_node;
    5518                 :             :           }
    5519                 :      896041 :         else if (TREE_READONLY (arg))
    5520                 :           4 :           readonly_warning (arg,
    5521                 :           4 :                             ((code == PREINCREMENT_EXPR
    5522                 :           4 :                               || code == POSTINCREMENT_EXPR)
    5523                 :             :                              ? lv_increment : lv_decrement));
    5524                 :             : 
    5525                 :             :         /* If the argument is atomic, use the special code sequences for
    5526                 :             :            atomic compound assignment.  */
    5527                 :      896041 :         if (atomic_op)
    5528                 :             :           {
    5529                 :        4441 :             arg = stabilize_reference (arg);
    5530                 :        8882 :             ret = build_atomic_assign (location, arg,
    5531                 :        4441 :                                        ((code == PREINCREMENT_EXPR
    5532                 :        4441 :                                          || code == POSTINCREMENT_EXPR)
    5533                 :             :                                         ? PLUS_EXPR
    5534                 :             :                                         : MINUS_EXPR),
    5535                 :        4441 :                                        (FRACT_MODE_P (TYPE_MODE (argtype))
    5536                 :             :                                         ? inc
    5537                 :             :                                         : integer_one_node),
    5538                 :             :                                        (code == POSTINCREMENT_EXPR
    5539                 :        4441 :                                         || code == POSTDECREMENT_EXPR));
    5540                 :        4441 :             goto return_build_unary_op;
    5541                 :             :           }
    5542                 :             : 
    5543                 :      891600 :         if (C_BOOLEAN_TYPE_P (TREE_TYPE (arg)))
    5544                 :          56 :           val = boolean_increment (code, arg);
    5545                 :             :         else
    5546                 :      891544 :           val = build2 (code, TREE_TYPE (arg), arg, inc);
    5547                 :      891600 :         TREE_SIDE_EFFECTS (val) = 1;
    5548                 :      891600 :         if (TYPE_QUALS (TREE_TYPE (val)) != TYPE_UNQUALIFIED)
    5549                 :        3897 :           TREE_TYPE (val) = c_build_qualified_type (TREE_TYPE (val),
    5550                 :             :                                                     TYPE_UNQUALIFIED);
    5551                 :      891600 :         ret = val;
    5552                 :      891600 :         goto return_build_unary_op;
    5553                 :             :       }
    5554                 :             : 
    5555                 :    52813913 :     case ADDR_EXPR:
    5556                 :             :       /* Note that this operation never does default_conversion.  */
    5557                 :             : 
    5558                 :             :       /* The operand of unary '&' must be an lvalue (which excludes
    5559                 :             :          expressions of type void), or, in C99, the result of a [] or
    5560                 :             :          unary '*' operator.  */
    5561                 :    52813913 :       if (VOID_TYPE_P (TREE_TYPE (arg))
    5562                 :          25 :           && TYPE_QUALS (TREE_TYPE (arg)) == TYPE_UNQUALIFIED
    5563                 :    52813932 :           && (!INDIRECT_REF_P (arg) || !flag_isoc99))
    5564                 :          18 :         pedwarn (location, 0, "taking address of expression of type %<void%>");
    5565                 :             : 
    5566                 :             :       /* Let &* cancel out to simplify resulting code.  */
    5567                 :    52813913 :       if (INDIRECT_REF_P (arg))
    5568                 :             :         {
    5569                 :             :           /* Don't let this be an lvalue.  */
    5570                 :       21661 :           if (lvalue_p (TREE_OPERAND (arg, 0)))
    5571                 :       16266 :             return non_lvalue_loc (location, TREE_OPERAND (arg, 0));
    5572                 :        5395 :           ret = TREE_OPERAND (arg, 0);
    5573                 :        5395 :           goto return_build_unary_op;
    5574                 :             :         }
    5575                 :             : 
    5576                 :             :       /* Anything not already handled and not a true memory reference
    5577                 :             :          or a non-lvalue array is an error.  */
    5578                 :    52792252 :       if (typecode != FUNCTION_TYPE && !noconvert
    5579                 :    52792252 :           && !lvalue_or_else (location, arg, lv_addressof))
    5580                 :          17 :         return error_mark_node;
    5581                 :             : 
    5582                 :             :       /* Move address operations inside C_MAYBE_CONST_EXPR to simplify
    5583                 :             :          folding later.  */
    5584                 :    52792235 :       if (TREE_CODE (arg) == C_MAYBE_CONST_EXPR)
    5585                 :             :         {
    5586                 :           1 :           tree inner = build_unary_op (location, code,
    5587                 :           1 :                                        C_MAYBE_CONST_EXPR_EXPR (arg),
    5588                 :             :                                        noconvert);
    5589                 :           2 :           ret = build2 (C_MAYBE_CONST_EXPR, TREE_TYPE (inner),
    5590                 :           1 :                         C_MAYBE_CONST_EXPR_PRE (arg), inner);
    5591                 :           1 :           gcc_assert (!C_MAYBE_CONST_EXPR_INT_OPERANDS (arg));
    5592                 :           1 :           C_MAYBE_CONST_EXPR_NON_CONST (ret)
    5593                 :           1 :             = C_MAYBE_CONST_EXPR_NON_CONST (arg);
    5594                 :           1 :           goto return_build_unary_op;
    5595                 :             :         }
    5596                 :             : 
    5597                 :             :       /* Ordinary case; arg is a COMPONENT_REF or a decl, or a call to
    5598                 :             :          .ACCESS_WITH_SIZE.  */
    5599                 :    52792234 :       if (is_access_with_size_p (arg))
    5600                 :           0 :         arg = TREE_OPERAND (TREE_OPERAND (CALL_EXPR_ARG (arg, 0), 0), 0);
    5601                 :             : 
    5602                 :    52792234 :       argtype = TREE_TYPE (arg);
    5603                 :             : 
    5604                 :             :       /* If the lvalue is const or volatile, merge that into the type
    5605                 :             :          to which the address will point.  This is only needed
    5606                 :             :          for function types.  */
    5607                 :    52792234 :       if ((DECL_P (arg) || REFERENCE_CLASS_P (arg))
    5608                 :    52311728 :           && (TREE_READONLY (arg) || TREE_THIS_VOLATILE (arg))
    5609                 :    83539772 :           && TREE_CODE (argtype) == FUNCTION_TYPE)
    5610                 :             :         {
    5611                 :    30669378 :           int orig_quals = TYPE_QUALS (strip_array_types (argtype));
    5612                 :    30669378 :           int quals = orig_quals;
    5613                 :             : 
    5614                 :    30669378 :           if (TREE_READONLY (arg))
    5615                 :    30301025 :             quals |= TYPE_QUAL_CONST;
    5616                 :    30669378 :           if (TREE_THIS_VOLATILE (arg))
    5617                 :      369165 :             quals |= TYPE_QUAL_VOLATILE;
    5618                 :             : 
    5619                 :    30669378 :           argtype = c_build_qualified_type (argtype, quals);
    5620                 :             :         }
    5621                 :             : 
    5622                 :    52792234 :       switch (TREE_CODE (arg))
    5623                 :             :         {
    5624                 :       63371 :         case COMPONENT_REF:
    5625                 :       63371 :           if (DECL_C_BIT_FIELD (TREE_OPERAND (arg, 1)))
    5626                 :             :             {
    5627                 :           8 :               error_at (location, "cannot take address of bit-field %qD",
    5628                 :           8 :                         TREE_OPERAND (arg, 1));
    5629                 :           8 :               return error_mark_node;
    5630                 :             :             }
    5631                 :             : 
    5632                 :             :           /* fall through */
    5633                 :             : 
    5634                 :      136873 :         case ARRAY_REF:
    5635                 :      136873 :           if (TYPE_REVERSE_STORAGE_ORDER (TREE_TYPE (TREE_OPERAND (arg, 0))))
    5636                 :             :             {
    5637                 :          78 :               if (!AGGREGATE_TYPE_P (TREE_TYPE (arg))
    5638                 :           7 :                   && !POINTER_TYPE_P (TREE_TYPE (arg))
    5639                 :          75 :                   && !VECTOR_TYPE_P (TREE_TYPE (arg)))
    5640                 :             :                 {
    5641                 :           6 :                   error_at (location, "cannot take address of scalar with "
    5642                 :             :                             "reverse storage order");
    5643                 :           6 :                   return error_mark_node;
    5644                 :             :                 }
    5645                 :             : 
    5646                 :          63 :               if (TREE_CODE (TREE_TYPE (arg)) == ARRAY_TYPE
    5647                 :          63 :                   && TYPE_REVERSE_STORAGE_ORDER (TREE_TYPE (arg)))
    5648                 :          58 :                 warning_at (location, OPT_Wscalar_storage_order,
    5649                 :             :                             "address of array with reverse scalar storage "
    5650                 :             :                             "order requested");
    5651                 :             :             }
    5652                 :             : 
    5653                 :    52792220 :         default:
    5654                 :    52792220 :           break;
    5655                 :             :         }
    5656                 :             : 
    5657                 :    52792220 :       if (!c_mark_addressable (arg))
    5658                 :          10 :         return error_mark_node;
    5659                 :             : 
    5660                 :    52792210 :       gcc_assert (TREE_CODE (arg) != COMPONENT_REF
    5661                 :             :                   || !DECL_C_BIT_FIELD (TREE_OPERAND (arg, 1)));
    5662                 :             : 
    5663                 :    52792210 :       argtype = c_build_pointer_type (argtype);
    5664                 :             : 
    5665                 :             :       /* ??? Cope with user tricks that amount to offsetof.  Delete this
    5666                 :             :          when we have proper support for integer constant expressions.  */
    5667                 :    52792210 :       val = get_base_address (arg);
    5668                 :    52792210 :       if (val && INDIRECT_REF_P (val)
    5669                 :    52814651 :           && TREE_CONSTANT (TREE_OPERAND (val, 0)))
    5670                 :             :         {
    5671                 :         538 :           ret = fold_offsetof (arg, argtype);
    5672                 :         538 :           goto return_build_unary_op;
    5673                 :             :         }
    5674                 :             : 
    5675                 :    52791672 :       val = build1 (ADDR_EXPR, argtype, arg);
    5676                 :             : 
    5677                 :    52791672 :       ret = val;
    5678                 :    52791672 :       goto return_build_unary_op;
    5679                 :             : 
    5680                 :           9 :     case PAREN_EXPR:
    5681                 :           9 :       ret = build1 (code, TREE_TYPE (arg), arg);
    5682                 :           9 :       goto return_build_unary_op;
    5683                 :             : 
    5684                 :           0 :     default:
    5685                 :           0 :       gcc_unreachable ();
    5686                 :             :     }
    5687                 :             : 
    5688                 :     7277152 :   if (argtype == NULL_TREE)
    5689                 :     7277152 :     argtype = TREE_TYPE (arg);
    5690                 :     7277152 :   if (TREE_CODE (arg) == INTEGER_CST)
    5691                 :     6588068 :     ret = (require_constant_value
    5692                 :     6588068 :            ? fold_build1_initializer_loc (location, code, argtype, arg)
    5693                 :     6569848 :            : fold_build1_loc (location, code, argtype, arg));
    5694                 :             :   else
    5695                 :      689084 :     ret = build1 (code, argtype, arg);
    5696                 :    61544801 :  return_build_unary_op:
    5697                 :    61544801 :   gcc_assert (ret != error_mark_node);
    5698                 :     6732173 :   if (TREE_CODE (ret) == INTEGER_CST && !TREE_OVERFLOW (ret)
    5699                 :    68276965 :       && !(TREE_CODE (xarg) == INTEGER_CST && !TREE_OVERFLOW (xarg)))
    5700                 :         562 :     ret = build1 (NOP_EXPR, TREE_TYPE (ret), ret);
    5701                 :    61544239 :   else if (TREE_CODE (ret) != INTEGER_CST && int_operands)
    5702                 :          74 :     ret = note_integer_operands (ret);
    5703                 :    61544801 :   if (eptype)
    5704                 :         235 :     ret = build1 (EXCESS_PRECISION_EXPR, eptype, ret);
    5705                 :    61544801 :   protected_set_expr_location (ret, location);
    5706                 :    61544801 :   return ret;
    5707                 :             : }
    5708                 :             : 
    5709                 :             : /* Return nonzero if REF is an lvalue valid for this language.
    5710                 :             :    Lvalues can be assigned, unless their type has TYPE_READONLY.
    5711                 :             :    Lvalues can have their address taken, unless they have C_DECL_REGISTER.  */
    5712                 :             : 
    5713                 :             : bool
    5714                 :   182781765 : lvalue_p (const_tree ref)
    5715                 :             : {
    5716                 :   184268285 :   const enum tree_code code = TREE_CODE (ref);
    5717                 :             : 
    5718                 :   184268285 :   switch (code)
    5719                 :             :     {
    5720                 :     1462530 :     case REALPART_EXPR:
    5721                 :     1462530 :     case IMAGPART_EXPR:
    5722                 :     1462530 :     case COMPONENT_REF:
    5723                 :     1462530 :       return lvalue_p (TREE_OPERAND (ref, 0));
    5724                 :             : 
    5725                 :       23990 :     case C_MAYBE_CONST_EXPR:
    5726                 :       23990 :       return lvalue_p (TREE_OPERAND (ref, 1));
    5727                 :             : 
    5728                 :             :     case COMPOUND_LITERAL_EXPR:
    5729                 :             :     case STRING_CST:
    5730                 :             :       return true;
    5731                 :             : 
    5732                 :    25712093 :     case MEM_REF:
    5733                 :    25712093 :     case TARGET_MEM_REF:
    5734                 :             :       /* MEM_REFs can appear from -fgimple parsing or folding, so allow them
    5735                 :             :          here as well.  */
    5736                 :    25712093 :     case INDIRECT_REF:
    5737                 :    25712093 :     case ARRAY_REF:
    5738                 :    25712093 :     case VAR_DECL:
    5739                 :    25712093 :     case PARM_DECL:
    5740                 :    25712093 :     case RESULT_DECL:
    5741                 :    25712093 :     case ERROR_MARK:
    5742                 :    25712093 :       return (TREE_CODE (TREE_TYPE (ref)) != FUNCTION_TYPE
    5743                 :    25712093 :               && TREE_CODE (TREE_TYPE (ref)) != METHOD_TYPE);
    5744                 :             : 
    5745                 :           6 :     case BIND_EXPR:
    5746                 :           6 :       return TREE_CODE (TREE_TYPE (ref)) == ARRAY_TYPE;
    5747                 :             : 
    5748                 :     7146704 :     case CALL_EXPR:
    5749                 :     7146704 :       return is_access_with_size_p (ref);
    5750                 :             : 
    5751                 :             :     default:
    5752                 :             :       return false;
    5753                 :             :     }
    5754                 :             : }
    5755                 :             : 
    5756                 :             : /* Give a warning for storing in something that is read-only in GCC
    5757                 :             :    terms but not const in ISO C terms.  */
    5758                 :             : 
    5759                 :             : static void
    5760                 :           5 : readonly_warning (tree arg, enum lvalue_use use)
    5761                 :             : {
    5762                 :           5 :   switch (use)
    5763                 :             :     {
    5764                 :           1 :     case lv_assign:
    5765                 :           1 :       warning (0, "assignment of read-only location %qE", arg);
    5766                 :           1 :       break;
    5767                 :           2 :     case lv_increment:
    5768                 :           2 :       warning (0, "increment of read-only location %qE", arg);
    5769                 :           2 :       break;
    5770                 :           2 :     case lv_decrement:
    5771                 :           2 :       warning (0, "decrement of read-only location %qE", arg);
    5772                 :           2 :       break;
    5773                 :           0 :     default:
    5774                 :           0 :       gcc_unreachable ();
    5775                 :             :     }
    5776                 :           5 :   return;
    5777                 :             : }
    5778                 :             : 
    5779                 :             : 
    5780                 :             : /* Return nonzero if REF is an lvalue valid for this language;
    5781                 :             :    otherwise, print an error message and return zero.  USE says
    5782                 :             :    how the lvalue is being used and so selects the error message.
    5783                 :             :    LOCATION is the location at which any error should be reported.  */
    5784                 :             : 
    5785                 :             : static int
    5786                 :     4632599 : lvalue_or_else (location_t loc, const_tree ref, enum lvalue_use use)
    5787                 :             : {
    5788                 :     4632599 :   int win = lvalue_p (ref);
    5789                 :             : 
    5790                 :     4632599 :   if (!win)
    5791                 :          72 :     lvalue_error (loc, use);
    5792                 :             : 
    5793                 :     4632599 :   return win;
    5794                 :             : }
    5795                 :             : 
    5796                 :             : /* Mark EXP saying that we need to be able to take the
    5797                 :             :    address of it; it should not be allocated in a register.
    5798                 :             :    Returns true if successful.  ARRAY_REF_P is true if this
    5799                 :             :    is for ARRAY_REF construction - in that case we don't want
    5800                 :             :    to look through VIEW_CONVERT_EXPR from VECTOR_TYPE to ARRAY_TYPE,
    5801                 :             :    it is fine to use ARRAY_REFs for vector subscripts on vector
    5802                 :             :    register variables.  */
    5803                 :             : 
    5804                 :             : bool
    5805                 :    53324212 : c_mark_addressable (tree exp, bool array_ref_p)
    5806                 :             : {
    5807                 :    53324212 :   tree x = exp;
    5808                 :             : 
    5809                 :    53895255 :   while (1)
    5810                 :    53895255 :     switch (TREE_CODE (x))
    5811                 :             :       {
    5812                 :        9918 :       case VIEW_CONVERT_EXPR:
    5813                 :        9918 :         if (array_ref_p
    5814                 :        9817 :             && TREE_CODE (TREE_TYPE (x)) == ARRAY_TYPE
    5815                 :       19735 :             && VECTOR_TYPE_P (TREE_TYPE (TREE_OPERAND (x, 0))))
    5816                 :             :           return true;
    5817                 :         101 :         x = TREE_OPERAND (x, 0);
    5818                 :         101 :         break;
    5819                 :             : 
    5820                 :      387750 :       case COMPONENT_REF:
    5821                 :      387750 :         if (DECL_C_BIT_FIELD (TREE_OPERAND (x, 1)))
    5822                 :             :           {
    5823                 :           6 :             error ("cannot take address of bit-field %qD",
    5824                 :           3 :                    TREE_OPERAND (x, 1));
    5825                 :           3 :             return false;
    5826                 :             :           }
    5827                 :             :         /* FALLTHRU */
    5828                 :      570942 :       case ADDR_EXPR:
    5829                 :      570942 :       case ARRAY_REF:
    5830                 :      570942 :       case REALPART_EXPR:
    5831                 :      570942 :       case IMAGPART_EXPR:
    5832                 :      570942 :         x = TREE_OPERAND (x, 0);
    5833                 :      570942 :         break;
    5834                 :             : 
    5835                 :         534 :       case COMPOUND_LITERAL_EXPR:
    5836                 :         534 :         if (C_DECL_REGISTER (COMPOUND_LITERAL_EXPR_DECL (x)))
    5837                 :             :           {
    5838                 :           2 :             error ("address of register compound literal requested");
    5839                 :           2 :             return false;
    5840                 :             :           }
    5841                 :         532 :         TREE_ADDRESSABLE (x) = 1;
    5842                 :         532 :         TREE_ADDRESSABLE (COMPOUND_LITERAL_EXPR_DECL (x)) = 1;
    5843                 :         532 :         return true;
    5844                 :             : 
    5845                 :           0 :       case CONSTRUCTOR:
    5846                 :           0 :         TREE_ADDRESSABLE (x) = 1;
    5847                 :           0 :         return true;
    5848                 :             : 
    5849                 :     1294898 :       case VAR_DECL:
    5850                 :     1294898 :       case CONST_DECL:
    5851                 :     1294898 :       case PARM_DECL:
    5852                 :     1294898 :       case RESULT_DECL:
    5853                 :     1294898 :         if (C_DECL_REGISTER (x)
    5854                 :     1294898 :             && DECL_NONLOCAL (x))
    5855                 :             :           {
    5856                 :           0 :             if (TREE_PUBLIC (x) || is_global_var (x))
    5857                 :             :               {
    5858                 :           0 :                 error
    5859                 :           0 :                   ("global register variable %qD used in nested function", x);
    5860                 :           0 :                 return false;
    5861                 :             :               }
    5862                 :           0 :             pedwarn (input_location, 0, "register variable %qD used in nested function", x);
    5863                 :             :           }
    5864                 :     1294898 :         else if (C_DECL_REGISTER (x))
    5865                 :             :           {
    5866                 :          11 :             if (TREE_PUBLIC (x) || is_global_var (x))
    5867                 :           4 :               error ("address of global register variable %qD requested", x);
    5868                 :             :             else
    5869                 :           7 :               error ("address of register variable %qD requested", x);
    5870                 :          11 :             return false;
    5871                 :             :           }
    5872                 :             : 
    5873                 :             :         /* FALLTHRU */
    5874                 :    52759034 :       case FUNCTION_DECL:
    5875                 :    52759034 :         TREE_ADDRESSABLE (x) = 1;
    5876                 :             :         /* FALLTHRU */
    5877                 :             :       default:
    5878                 :             :         return true;
    5879                 :             :     }
    5880                 :             : }
    5881                 :             : 
    5882                 :             : /* Convert EXPR to TYPE, warning about conversion problems with
    5883                 :             :    constants.  SEMANTIC_TYPE is the type this conversion would use
    5884                 :             :    without excess precision. If SEMANTIC_TYPE is NULL, this function
    5885                 :             :    is equivalent to convert_and_check. This function is a wrapper that
    5886                 :             :    handles conversions that may be different than
    5887                 :             :    the usual ones because of excess precision.  */
    5888                 :             : 
    5889                 :             : static tree
    5890                 :    22997550 : ep_convert_and_check (location_t loc, tree type, tree expr,
    5891                 :             :                       tree semantic_type)
    5892                 :             : {
    5893                 :    22997550 :   if (TREE_TYPE (expr) == type)
    5894                 :             :     return expr;
    5895                 :             : 
    5896                 :             :   /* For C11, integer conversions may have results with excess
    5897                 :             :      precision.  */
    5898                 :     2048279 :   if (flag_isoc11 || !semantic_type)
    5899                 :     2048275 :     return convert_and_check (loc, type, expr);
    5900                 :             : 
    5901                 :           4 :   if (TREE_CODE (TREE_TYPE (expr)) == INTEGER_TYPE
    5902                 :           4 :       && TREE_TYPE (expr) != semantic_type)
    5903                 :             :     {
    5904                 :             :       /* For integers, we need to check the real conversion, not
    5905                 :             :          the conversion to the excess precision type.  */
    5906                 :           4 :       expr = convert_and_check (loc, semantic_type, expr);
    5907                 :             :     }
    5908                 :             :   /* Result type is the excess precision type, which should be
    5909                 :             :      large enough, so do not check.  */
    5910                 :           4 :   return convert (type, expr);
    5911                 :             : }
    5912                 :             : 
    5913                 :             : /* If EXPR refers to a built-in declared without a prototype returns
    5914                 :             :    the actual type of the built-in and, if non-null, set *BLTIN to
    5915                 :             :    a pointer to the built-in.  Otherwise return the type of EXPR
    5916                 :             :    and clear *BLTIN if non-null.  */
    5917                 :             : 
    5918                 :             : static tree
    5919                 :     2765209 : type_or_builtin_type (tree expr, tree *bltin = NULL)
    5920                 :             : {
    5921                 :     2765209 :   tree dummy;
    5922                 :     2765209 :   if (!bltin)
    5923                 :           0 :     bltin = &dummy;
    5924                 :             : 
    5925                 :     2765209 :   *bltin = NULL_TREE;
    5926                 :             : 
    5927                 :     2765209 :   tree type = TREE_TYPE (expr);
    5928                 :     2765209 :   if (TREE_CODE (expr) != ADDR_EXPR)
    5929                 :             :     return type;
    5930                 :             : 
    5931                 :      207049 :   tree oper = TREE_OPERAND (expr, 0);
    5932                 :      207049 :   if (!DECL_P (oper)
    5933                 :      169005 :       || TREE_CODE (oper) != FUNCTION_DECL
    5934                 :      243398 :       || !fndecl_built_in_p (oper, BUILT_IN_NORMAL))
    5935                 :             :     return type;
    5936                 :             : 
    5937                 :        2079 :   built_in_function code = DECL_FUNCTION_CODE (oper);
    5938                 :        2079 :   if (!C_DECL_BUILTIN_PROTOTYPE (oper))
    5939                 :             :     return type;
    5940                 :             : 
    5941                 :        1977 :   if ((*bltin = builtin_decl_implicit (code)))
    5942                 :         991 :     type = c_build_pointer_type (TREE_TYPE (*bltin));
    5943                 :             : 
    5944                 :             :   return type;
    5945                 :             : }
    5946                 :             : 
    5947                 :             : /* Build and return a conditional expression IFEXP ? OP1 : OP2.  If
    5948                 :             :    IFEXP_BCP then the condition is a call to __builtin_constant_p, and
    5949                 :             :    if folded to an integer constant then the unselected half may
    5950                 :             :    contain arbitrary operations not normally permitted in constant
    5951                 :             :    expressions.  Set the location of the expression to LOC.  */
    5952                 :             : 
    5953                 :             : tree
    5954                 :      398800 : build_conditional_expr (location_t colon_loc, tree ifexp, bool ifexp_bcp,
    5955                 :             :                         tree op1, tree op1_original_type, location_t op1_loc,
    5956                 :             :                         tree op2, tree op2_original_type, location_t op2_loc)
    5957                 :             : {
    5958                 :      398800 :   tree type1;
    5959                 :      398800 :   tree type2;
    5960                 :      398800 :   enum tree_code code1;
    5961                 :      398800 :   enum tree_code code2;
    5962                 :      398800 :   tree result_type = NULL;
    5963                 :      398800 :   tree semantic_result_type = NULL;
    5964                 :      398800 :   tree orig_op1 = op1, orig_op2 = op2;
    5965                 :      398800 :   bool int_const, op1_int_operands, op2_int_operands, int_operands;
    5966                 :      398800 :   bool ifexp_int_operands;
    5967                 :      398800 :   tree ret;
    5968                 :             : 
    5969                 :      398800 :   op1_int_operands = EXPR_INT_CONST_OPERANDS (orig_op1);
    5970                 :      112538 :   if (op1_int_operands)
    5971                 :      112538 :     op1 = remove_c_maybe_const_expr (op1);
    5972                 :      398800 :   op2_int_operands = EXPR_INT_CONST_OPERANDS (orig_op2);
    5973                 :      145369 :   if (op2_int_operands)
    5974                 :      145369 :     op2 = remove_c_maybe_const_expr (op2);
    5975                 :      398800 :   ifexp_int_operands = EXPR_INT_CONST_OPERANDS (ifexp);
    5976                 :      240457 :   if (ifexp_int_operands)
    5977                 :      240457 :     ifexp = remove_c_maybe_const_expr (ifexp);
    5978                 :             : 
    5979                 :             :   /* Promote both alternatives.  */
    5980                 :             : 
    5981                 :      398800 :   if (TREE_CODE (TREE_TYPE (op1)) != VOID_TYPE)
    5982                 :      394918 :     op1 = default_conversion (op1);
    5983                 :      398800 :   if (TREE_CODE (TREE_TYPE (op2)) != VOID_TYPE)
    5984                 :      368995 :     op2 = default_conversion (op2);
    5985                 :             : 
    5986                 :      398800 :   if (TREE_CODE (ifexp) == ERROR_MARK
    5987                 :      398731 :       || TREE_CODE (TREE_TYPE (op1)) == ERROR_MARK
    5988                 :      797517 :       || TREE_CODE (TREE_TYPE (op2)) == ERROR_MARK)
    5989                 :          83 :     return error_mark_node;
    5990                 :             : 
    5991                 :      398717 :   tree bltin1 = NULL_TREE;
    5992                 :      398717 :   tree bltin2 = NULL_TREE;
    5993                 :      398717 :   type1 = type_or_builtin_type (op1, &bltin1);
    5994                 :      398717 :   code1 = TREE_CODE (type1);
    5995                 :      398717 :   type2 = type_or_builtin_type (op2, &bltin2);
    5996                 :      398717 :   code2 = TREE_CODE (type2);
    5997                 :             : 
    5998                 :      398717 :   if (code1 == POINTER_TYPE && reject_gcc_builtin (op1))
    5999                 :           1 :     return error_mark_node;
    6000                 :             : 
    6001                 :      398716 :   if (code2 == POINTER_TYPE && reject_gcc_builtin (op2))
    6002                 :           1 :     return error_mark_node;
    6003                 :             : 
    6004                 :             :   /* C90 does not permit non-lvalue arrays in conditional expressions.
    6005                 :             :      In C99 they will be pointers by now.  */
    6006                 :      398715 :   if (code1 == ARRAY_TYPE || code2 == ARRAY_TYPE)
    6007                 :             :     {
    6008                 :           1 :       error_at (colon_loc, "non-lvalue array in conditional expression");
    6009                 :           1 :       return error_mark_node;
    6010                 :             :     }
    6011                 :             : 
    6012                 :      398714 :   if ((TREE_CODE (op1) == EXCESS_PRECISION_EXPR
    6013                 :      398708 :        || TREE_CODE (op2) == EXCESS_PRECISION_EXPR)
    6014                 :           7 :       && (code1 == INTEGER_TYPE || code1 == REAL_TYPE
    6015                 :           0 :           || code1 == COMPLEX_TYPE || code1 == BITINT_TYPE)
    6016                 :           7 :       && (code2 == INTEGER_TYPE || code2 == REAL_TYPE
    6017                 :           0 :           || code2 == COMPLEX_TYPE || code2 == BITINT_TYPE))
    6018                 :             :     {
    6019                 :           7 :       semantic_result_type = c_common_type (type1, type2);
    6020                 :           7 :       if (TREE_CODE (op1) == EXCESS_PRECISION_EXPR)
    6021                 :             :         {
    6022                 :           6 :           op1 = TREE_OPERAND (op1, 0);
    6023                 :           6 :           type1 = TREE_TYPE (op1);
    6024                 :           6 :           gcc_assert (TREE_CODE (type1) == code1);
    6025                 :             :         }
    6026                 :           7 :       if (TREE_CODE (op2) == EXCESS_PRECISION_EXPR)
    6027                 :             :         {
    6028                 :           1 :           op2 = TREE_OPERAND (op2, 0);
    6029                 :           1 :           type2 = TREE_TYPE (op2);
    6030                 :           1 :           gcc_assert (TREE_CODE (type2) == code2);
    6031                 :             :         }
    6032                 :             :     }
    6033                 :             : 
    6034                 :      398714 :   if (warn_cxx_compat)
    6035                 :             :     {
    6036                 :         390 :       tree t1 = op1_original_type ? op1_original_type : TREE_TYPE (orig_op1);
    6037                 :         390 :       tree t2 = op2_original_type ? op2_original_type : TREE_TYPE (orig_op2);
    6038                 :             : 
    6039                 :         390 :       if (TREE_CODE (t1) == ENUMERAL_TYPE
    6040                 :           6 :           && TREE_CODE (t2) == ENUMERAL_TYPE
    6041                 :         396 :           && TYPE_MAIN_VARIANT (t1) != TYPE_MAIN_VARIANT (t2))
    6042                 :           2 :         warning_at (colon_loc, OPT_Wc___compat,
    6043                 :             :                     ("different enum types in conditional is "
    6044                 :             :                      "invalid in C++: %qT vs %qT"),
    6045                 :             :                     t1, t2);
    6046                 :             :     }
    6047                 :             : 
    6048                 :      398714 :   if (warn_zero_as_null_pointer_constant
    6049                 :          14 :       && c_inhibit_evaluation_warnings == 0)
    6050                 :             :     {
    6051                 :          14 :       if ((code1 == POINTER_TYPE || code1 == NULLPTR_TYPE)
    6052                 :          14 :           && code2 == INTEGER_TYPE && null_pointer_constant_p (orig_op2))
    6053                 :           2 :         warning_at (op2_loc, OPT_Wzero_as_null_pointer_constant,
    6054                 :             :                     "zero as null pointer constant");
    6055                 :             : 
    6056                 :          14 :       if ((code2 == POINTER_TYPE || code2 == NULLPTR_TYPE)
    6057                 :          14 :           && code1 == INTEGER_TYPE && null_pointer_constant_p (orig_op1))
    6058                 :           2 :         warning_at (op1_loc, OPT_Wzero_as_null_pointer_constant,
    6059                 :             :                     "zero as null pointer constant");
    6060                 :             :     }
    6061                 :             : 
    6062                 :             :   /* Quickly detect the usual case where op1 and op2 have the same type
    6063                 :             :      after promotion.  */
    6064                 :      398714 :   if (TYPE_MAIN_VARIANT (type1) == TYPE_MAIN_VARIANT (type2))
    6065                 :             :     {
    6066                 :      265694 :       if (type1 == type2)
    6067                 :             :         result_type = type1;
    6068                 :             :       else
    6069                 :        6034 :         result_type = TYPE_MAIN_VARIANT (type1);
    6070                 :             :     }
    6071                 :      133020 :   else if ((code1 == INTEGER_TYPE || code1 == REAL_TYPE
    6072                 :       79877 :             || code1 == COMPLEX_TYPE || code1 == BITINT_TYPE)
    6073                 :       53188 :            && (code2 == INTEGER_TYPE || code2 == REAL_TYPE
    6074                 :       26148 :                || code2 == COMPLEX_TYPE || code2 == BITINT_TYPE))
    6075                 :             :     {
    6076                 :             :       /* In C11, a conditional expression between a floating-point
    6077                 :             :          type and an integer type should convert the integer type to
    6078                 :             :          the evaluation format of the floating-point type, with
    6079                 :             :          possible excess precision.  */
    6080                 :       27139 :       tree eptype1 = type1;
    6081                 :       27139 :       tree eptype2 = type2;
    6082                 :       27139 :       if (flag_isoc11)
    6083                 :             :         {
    6084                 :       26823 :           tree eptype;
    6085                 :       10834 :           if (ANY_INTEGRAL_TYPE_P (type1)
    6086                 :       26823 :               && (eptype = excess_precision_type (type2)) != NULL_TREE)
    6087                 :             :             {
    6088                 :           2 :               eptype2 = eptype;
    6089                 :           2 :               if (!semantic_result_type)
    6090                 :           2 :                 semantic_result_type = c_common_type (type1, type2);
    6091                 :             :             }
    6092                 :         369 :           else if (ANY_INTEGRAL_TYPE_P (type2)
    6093                 :       26821 :                    && (eptype = excess_precision_type (type1)) != NULL_TREE)
    6094                 :             :             {
    6095                 :        4618 :               eptype1 = eptype;
    6096                 :        4618 :               if (!semantic_result_type)
    6097                 :        4618 :                 semantic_result_type = c_common_type (type1, type2);
    6098                 :             :             }
    6099                 :             :         }
    6100                 :       27139 :       result_type = c_common_type (eptype1, eptype2);
    6101                 :       27139 :       if (result_type == error_mark_node)
    6102                 :             :         return error_mark_node;
    6103                 :       27137 :       do_warn_double_promotion (result_type, type1, type2,
    6104                 :             :                                 "implicit conversion from %qT to %qT to "
    6105                 :             :                                 "match other result of conditional",
    6106                 :             :                                 colon_loc);
    6107                 :             : 
    6108                 :             :       /* If -Wsign-compare, warn here if type1 and type2 have
    6109                 :             :          different signedness.  We'll promote the signed to unsigned
    6110                 :             :          and later code won't know it used to be different.
    6111                 :             :          Do this check on the original types, so that explicit casts
    6112                 :             :          will be considered, but default promotions won't.  */
    6113                 :       27137 :       if (c_inhibit_evaluation_warnings == 0)
    6114                 :             :         {
    6115                 :       26946 :           int unsigned_op1 = TYPE_UNSIGNED (TREE_TYPE (orig_op1));
    6116                 :       26946 :           int unsigned_op2 = TYPE_UNSIGNED (TREE_TYPE (orig_op2));
    6117                 :             : 
    6118                 :       26946 :           if (unsigned_op1 ^ unsigned_op2)
    6119                 :             :             {
    6120                 :       12543 :               bool ovf;
    6121                 :             : 
    6122                 :             :               /* Do not warn if the result type is signed, since the
    6123                 :             :                  signed type will only be chosen if it can represent
    6124                 :             :                  all the values of the unsigned type.  */
    6125                 :       12543 :               if (!TYPE_UNSIGNED (result_type))
    6126                 :             :                 /* OK */;
    6127                 :             :               else
    6128                 :             :                 {
    6129                 :       12439 :                   bool op1_maybe_const = true;
    6130                 :       12439 :                   bool op2_maybe_const = true;
    6131                 :             : 
    6132                 :             :                   /* Do not warn if the signed quantity is an
    6133                 :             :                      unsuffixed integer literal (or some static
    6134                 :             :                      constant expression involving such literals) and
    6135                 :             :                      it is non-negative.  This warning requires the
    6136                 :             :                      operands to be folded for best results, so do
    6137                 :             :                      that folding in this case even without
    6138                 :             :                      warn_sign_compare to avoid warning options
    6139                 :             :                      possibly affecting code generation.  */
    6140                 :       12439 :                   c_inhibit_evaluation_warnings
    6141                 :       12439 :                     += (ifexp == truthvalue_false_node);
    6142                 :       12439 :                   op1 = c_fully_fold (op1, require_constant_value,
    6143                 :             :                                       &op1_maybe_const);
    6144                 :       12439 :                   c_inhibit_evaluation_warnings
    6145                 :       12439 :                     -= (ifexp == truthvalue_false_node);
    6146                 :             : 
    6147                 :       12439 :                   c_inhibit_evaluation_warnings
    6148                 :       12439 :                     += (ifexp == truthvalue_true_node);
    6149                 :       12439 :                   op2 = c_fully_fold (op2, require_constant_value,
    6150                 :             :                                       &op2_maybe_const);
    6151                 :       12439 :                   c_inhibit_evaluation_warnings
    6152                 :       12439 :                     -= (ifexp == truthvalue_true_node);
    6153                 :             : 
    6154                 :       12439 :                   if (warn_sign_compare)
    6155                 :             :                     {
    6156                 :        1241 :                       if ((unsigned_op2
    6157                 :         681 :                            && tree_expr_nonnegative_warnv_p (op1, &ovf))
    6158                 :        1244 :                           || (unsigned_op1
    6159                 :         560 :                               && tree_expr_nonnegative_warnv_p (op2, &ovf)))
    6160                 :             :                         /* OK */;
    6161                 :          10 :                       else if (unsigned_op2)
    6162                 :           3 :                         warning_at (op1_loc, OPT_Wsign_compare,
    6163                 :             :                                     "operand of %<?:%> changes signedness from "
    6164                 :             :                                     "%qT to %qT due to unsignedness of other "
    6165                 :           3 :                                     "operand", TREE_TYPE (orig_op1),
    6166                 :           3 :                                     TREE_TYPE (orig_op2));
    6167                 :             :                       else
    6168                 :           7 :                         warning_at (op2_loc, OPT_Wsign_compare,
    6169                 :             :                                     "operand of %<?:%> changes signedness from "
    6170                 :             :                                     "%qT to %qT due to unsignedness of other "
    6171                 :           7 :                                     "operand", TREE_TYPE (orig_op2),
    6172                 :           7 :                                     TREE_TYPE (orig_op1));
    6173                 :             :                     }
    6174                 :       12439 :                   if (!op1_maybe_const || TREE_CODE (op1) != INTEGER_CST)
    6175                 :        7108 :                     op1 = c_wrap_maybe_const (op1, !op1_maybe_const);
    6176                 :       12439 :                   if (!op2_maybe_const || TREE_CODE (op2) != INTEGER_CST)
    6177                 :        4366 :                     op2 = c_wrap_maybe_const (op2, !op2_maybe_const);
    6178                 :             :                 }
    6179                 :             :             }
    6180                 :             :         }
    6181                 :             :     }
    6182                 :      105881 :   else if (code1 == VOID_TYPE || code2 == VOID_TYPE)
    6183                 :             :     {
    6184                 :       25995 :       if (code1 != VOID_TYPE || code2 != VOID_TYPE)
    6185                 :       25995 :         pedwarn (colon_loc, OPT_Wpedantic,
    6186                 :             :                  "ISO C forbids conditional expr with only one void side");
    6187                 :       25995 :       result_type = void_type_node;
    6188                 :             :     }
    6189                 :       79886 :   else if (code1 == POINTER_TYPE && code2 == POINTER_TYPE)
    6190                 :             :     {
    6191                 :       79496 :       addr_space_t as1 = TYPE_ADDR_SPACE (TREE_TYPE (type1));
    6192                 :       79496 :       addr_space_t as2 = TYPE_ADDR_SPACE (TREE_TYPE (type2));
    6193                 :       79496 :       addr_space_t as_common;
    6194                 :             : 
    6195                 :       79496 :       if (comp_target_types (colon_loc, type1, type2))
    6196                 :        2572 :         result_type = common_pointer_type (type1, type2);
    6197                 :       76924 :       else if (null_pointer_constant_p (orig_op1))
    6198                 :             :         result_type = type2;
    6199                 :       72768 :       else if (null_pointer_constant_p (orig_op2))
    6200                 :             :         result_type = type1;
    6201                 :       34787 :       else if (!addr_space_superset (as1, as2, &as_common))
    6202                 :             :         {
    6203                 :           0 :           error_at (colon_loc, "pointers to disjoint address spaces "
    6204                 :             :                     "used in conditional expression");
    6205                 :           0 :           return error_mark_node;
    6206                 :             :         }
    6207                 :       34787 :       else if ((VOID_TYPE_P (TREE_TYPE (type1))
    6208                 :         322 :                 && !TYPE_ATOMIC (TREE_TYPE (type1)))
    6209                 :       34789 :                || (VOID_TYPE_P (TREE_TYPE (type2))
    6210                 :       34420 :                    && !TYPE_ATOMIC (TREE_TYPE (type2))))
    6211                 :             :         {
    6212                 :       34739 :           tree t1 = TREE_TYPE (type1);
    6213                 :       34739 :           tree t2 = TREE_TYPE (type2);
    6214                 :       34739 :           if (!(VOID_TYPE_P (t1)
    6215                 :         321 :                 && !TYPE_ATOMIC (t1)))
    6216                 :             :            {
    6217                 :             :              /* roles are swapped */
    6218                 :       34419 :              t1 = t2;
    6219                 :       34419 :              t2 = TREE_TYPE (type1);
    6220                 :             :            }
    6221                 :       34739 :           tree t2_stripped = strip_array_types (t2);
    6222                 :       34739 :           if ((TREE_CODE (t2) == ARRAY_TYPE)
    6223                 :       34739 :               && (TYPE_QUALS (t2_stripped) & ~TYPE_QUALS (t1)))
    6224                 :             :             {
    6225                 :          18 :               if (!flag_isoc23)
    6226                 :           6 :                 warning_at (colon_loc, OPT_Wdiscarded_array_qualifiers,
    6227                 :             :                             "pointer to array loses qualifier "
    6228                 :             :                             "in conditional expression");
    6229                 :          12 :               else if (warn_c11_c23_compat > 0)
    6230                 :           6 :                 warning_at (colon_loc, OPT_Wc11_c23_compat,
    6231                 :             :                             "pointer to array loses qualifier "
    6232                 :             :                             "in conditional expression in ISO C before C23");
    6233                 :             :             }
    6234                 :       34739 :           if (TREE_CODE (t2) == FUNCTION_TYPE)
    6235                 :           4 :             pedwarn (colon_loc, OPT_Wpedantic,
    6236                 :             :                      "ISO C forbids conditional expr between "
    6237                 :             :                      "%<void *%> and function pointer");
    6238                 :             :           /* for array, use qualifiers of element type */
    6239                 :       34739 :           if (flag_isoc23)
    6240                 :       11002 :             t2 = t2_stripped;
    6241                 :       34739 :           result_type = c_build_pointer_type (qualify_type (t1, t2));
    6242                 :             :         }
    6243                 :             :       /* Objective-C pointer comparisons are a bit more lenient.  */
    6244                 :          48 :       else if (objc_have_common_type (type1, type2, -3, NULL_TREE))
    6245                 :           0 :         result_type = objc_common_type (type1, type2);
    6246                 :             :       else
    6247                 :             :         {
    6248                 :          48 :           int qual = ENCODE_QUAL_ADDR_SPACE (as_common);
    6249                 :          48 :           diagnostic_t kind = DK_PERMERROR;
    6250                 :          48 :           if (!flag_isoc99)
    6251                 :             :             /* This downgrade to a warning ensures that -std=gnu89
    6252                 :             :                -pedantic-errors does not flag these mismatches between
    6253                 :             :                builtins as errors (as DK_PERMERROR would).  ISO C99
    6254                 :             :                and later do not have implicit function declarations,
    6255                 :             :                so the mismatch cannot occur naturally there.  */
    6256                 :           5 :             kind = bltin1 && bltin2 ? DK_WARNING : DK_PEDWARN;
    6257                 :          48 :           if (emit_diagnostic (kind, colon_loc, OPT_Wincompatible_pointer_types,
    6258                 :             :                                "pointer type mismatch "
    6259                 :             :                                "in conditional expression"))
    6260                 :             :             {
    6261                 :          46 :               inform (op1_loc, "first expression has type %qT", type1);
    6262                 :          46 :               inform (op2_loc, "second expression has type %qT", type2);
    6263                 :             :             }
    6264                 :          48 :           result_type = c_build_pointer_type
    6265                 :          48 :                           (c_build_qualified_type (void_type_node, qual));
    6266                 :             :         }
    6267                 :             :     }
    6268                 :         390 :   else if (code1 == POINTER_TYPE
    6269                 :         273 :            && (code2 == INTEGER_TYPE || code2 == BITINT_TYPE))
    6270                 :             :     {
    6271                 :         269 :       if (!null_pointer_constant_p (orig_op2))
    6272                 :          14 :         permerror_opt (colon_loc, OPT_Wint_conversion,
    6273                 :             :                        "pointer/integer type mismatch "
    6274                 :             :                        "in conditional expression");
    6275                 :             :       else
    6276                 :             :         {
    6277                 :         255 :           op2 = null_pointer_node;
    6278                 :             :         }
    6279                 :             :       result_type = type1;
    6280                 :             :     }
    6281                 :         121 :   else if (code2 == POINTER_TYPE
    6282                 :          87 :            && (code1 == INTEGER_TYPE || code1 == BITINT_TYPE))
    6283                 :             :     {
    6284                 :          83 :       if (!null_pointer_constant_p (orig_op1))
    6285                 :          14 :         permerror_opt (colon_loc, OPT_Wint_conversion,
    6286                 :             :                        "pointer/integer type mismatch "
    6287                 :             :                        "in conditional expression");
    6288                 :             :       else
    6289                 :             :         {
    6290                 :          69 :           op1 = null_pointer_node;
    6291                 :             :         }
    6292                 :             :       result_type = type2;
    6293                 :             :     }
    6294                 :             :   /* 6.5.15: "if one is a null pointer constant (other than a pointer) or has
    6295                 :             :      type nullptr_t and the other is a pointer, the result type is the pointer
    6296                 :             :      type."  */
    6297                 :          38 :   else if (code1 == NULLPTR_TYPE && code2 == POINTER_TYPE)
    6298                 :             :     result_type = type2;
    6299                 :          34 :   else if (code1 == POINTER_TYPE && code2 == NULLPTR_TYPE)
    6300                 :             :     result_type = type1;
    6301                 :           8 :   else if (RECORD_OR_UNION_TYPE_P (type1) && RECORD_OR_UNION_TYPE_P (type2)
    6302                 :          38 :            && comptypes (TYPE_MAIN_VARIANT (type1),
    6303                 :           8 :                          TYPE_MAIN_VARIANT (type2)))
    6304                 :           8 :     result_type = composite_type (TYPE_MAIN_VARIANT (type1),
    6305                 :           8 :                                   TYPE_MAIN_VARIANT (type2));
    6306                 :             : 
    6307                 :      398690 :   if (!result_type)
    6308                 :             :     {
    6309                 :          22 :       if (flag_cond_mismatch)
    6310                 :           0 :         result_type = void_type_node;
    6311                 :             :       else
    6312                 :             :         {
    6313                 :          22 :           error_at (colon_loc, "type mismatch in conditional expression");
    6314                 :          22 :           return error_mark_node;
    6315                 :             :         }
    6316                 :             :     }
    6317                 :             : 
    6318                 :             :   /* Merge const and volatile flags of the incoming types.  */
    6319                 :      398690 :   result_type
    6320                 :      398690 :     = build_type_variant (result_type,
    6321                 :             :                           TYPE_READONLY (type1) || TYPE_READONLY (type2),
    6322                 :             :                           TYPE_VOLATILE (type1) || TYPE_VOLATILE (type2));
    6323                 :             : 
    6324                 :      398690 :   op1 = ep_convert_and_check (colon_loc, result_type, op1,
    6325                 :             :                               semantic_result_type);
    6326                 :      398690 :   op2 = ep_convert_and_check (colon_loc, result_type, op2,
    6327                 :             :                               semantic_result_type);
    6328                 :             : 
    6329                 :      398690 :   if (ifexp_bcp && ifexp == truthvalue_true_node)
    6330                 :             :     {
    6331                 :          10 :       op2_int_operands = true;
    6332                 :          10 :       op1 = c_fully_fold (op1, require_constant_value, NULL);
    6333                 :             :     }
    6334                 :          59 :   if (ifexp_bcp && ifexp == truthvalue_false_node)
    6335                 :             :     {
    6336                 :          49 :       op1_int_operands = true;
    6337                 :          49 :       op2 = c_fully_fold (op2, require_constant_value, NULL);
    6338                 :             :     }
    6339                 :      892764 :   int_const = int_operands = (ifexp_int_operands
    6340                 :      398690 :                               && op1_int_operands
    6341                 :      398690 :                               && op2_int_operands);
    6342                 :       95384 :   if (int_operands)
    6343                 :             :     {
    6344                 :       95384 :       int_const = ((ifexp == truthvalue_true_node
    6345                 :       57568 :                     && TREE_CODE (orig_op1) == INTEGER_CST
    6346                 :       57554 :                     && !TREE_OVERFLOW (orig_op1))
    6347                 :       95398 :                    || (ifexp == truthvalue_false_node
    6348                 :       37770 :                        && TREE_CODE (orig_op2) == INTEGER_CST
    6349                 :       37754 :                        && !TREE_OVERFLOW (orig_op2)));
    6350                 :             :     }
    6351                 :             : 
    6352                 :             :   /* Need to convert condition operand into a vector mask.  */
    6353                 :      398690 :   if (VECTOR_TYPE_P (TREE_TYPE (ifexp)))
    6354                 :             :     {
    6355                 :           0 :       tree vectype = TREE_TYPE (ifexp);
    6356                 :           0 :       tree elem_type = TREE_TYPE (vectype);
    6357                 :           0 :       tree zero = build_int_cst (elem_type, 0);
    6358                 :           0 :       tree zero_vec = build_vector_from_val (vectype, zero);
    6359                 :           0 :       tree cmp_type = truth_type_for (vectype);
    6360                 :           0 :       ifexp = build2 (NE_EXPR, cmp_type, ifexp, zero_vec);
    6361                 :             :     }
    6362                 :             : 
    6363                 :      398690 :   if (int_const || (ifexp_bcp && TREE_CODE (ifexp) == INTEGER_CST))
    6364                 :       95340 :     ret = fold_build3_loc (colon_loc, COND_EXPR, result_type, ifexp, op1, op2);
    6365                 :             :   else
    6366                 :             :     {
    6367                 :      303350 :       if (int_operands)
    6368                 :             :         {
    6369                 :             :           /* Use c_fully_fold here, since C_MAYBE_CONST_EXPR might be
    6370                 :             :              nested inside of the expression.  */
    6371                 :          76 :           op1 = c_fully_fold (op1, false, NULL);
    6372                 :          76 :           op2 = c_fully_fold (op2, false, NULL);
    6373                 :             :         }
    6374                 :      303350 :       ret = build3 (COND_EXPR, result_type, ifexp, op1, op2);
    6375                 :      303350 :       if (int_operands)
    6376                 :          76 :         ret = note_integer_operands (ret);
    6377                 :             :     }
    6378                 :      398690 :   if (semantic_result_type)
    6379                 :        4627 :     ret = build1 (EXCESS_PRECISION_EXPR, semantic_result_type, ret);
    6380                 :             : 
    6381                 :      398690 :   protected_set_expr_location (ret, colon_loc);
    6382                 :             : 
    6383                 :             :   /* If the OP1 and OP2 are the same and don't have side-effects,
    6384                 :             :      warn here, because the COND_EXPR will be turned into OP1.  */
    6385                 :      398690 :   if (warn_duplicated_branches
    6386                 :          34 :       && TREE_CODE (ret) == COND_EXPR
    6387                 :      398724 :       && (op1 == op2 || operand_equal_p (op1, op2, OEP_ADDRESS_OF_SAME_FIELD)))
    6388                 :          13 :     warning_at (EXPR_LOCATION (ret), OPT_Wduplicated_branches,
    6389                 :             :                 "this condition has identical branches");
    6390                 :             : 
    6391                 :             :   return ret;
    6392                 :             : }
    6393                 :             : 
    6394                 :             : /* EXPR is an expression, location LOC, whose result is discarded.
    6395                 :             :    Warn if it is a call to a nodiscard function (or a COMPOUND_EXPR
    6396                 :             :    whose right-hand operand is such a call, possibly recursively).  */
    6397                 :             : 
    6398                 :             : static void
    6399                 :     6353312 : maybe_warn_nodiscard (location_t loc, tree expr)
    6400                 :             : {
    6401                 :     6353312 :   if (VOID_TYPE_P (TREE_TYPE (expr)))
    6402                 :             :     return;
    6403                 :     3893378 :   while (TREE_CODE (expr) == COMPOUND_EXPR)
    6404                 :             :     {
    6405                 :       48720 :       expr = TREE_OPERAND (expr, 1);
    6406                 :       48720 :       if (EXPR_HAS_LOCATION (expr))
    6407                 :       31631 :         loc = EXPR_LOCATION (expr);
    6408                 :             :     }
    6409                 :     3844658 :   if (TREE_CODE (expr) != CALL_EXPR)
    6410                 :             :     return;
    6411                 :      341308 :   tree fn = CALL_EXPR_FN (expr);
    6412                 :      341308 :   if (!fn)
    6413                 :             :     return;
    6414                 :      341295 :   tree attr;
    6415                 :      341295 :   if (TREE_CODE (fn) == ADDR_EXPR
    6416                 :      340634 :       && TREE_CODE (TREE_OPERAND (fn, 0)) == FUNCTION_DECL
    6417                 :      681929 :       && (attr = lookup_attribute ("nodiscard",
    6418                 :      340634 :                                    DECL_ATTRIBUTES (TREE_OPERAND (fn, 0)))))
    6419                 :             :     {
    6420                 :           3 :       fn = TREE_OPERAND (fn, 0);
    6421                 :           3 :       tree args = TREE_VALUE (attr);
    6422                 :           3 :       if (args)
    6423                 :           1 :         args = TREE_VALUE (args);
    6424                 :           3 :       auto_diagnostic_group d;
    6425                 :           3 :       auto_urlify_attributes sentinel;
    6426                 :           3 :       int warned;
    6427                 :           3 :       if (args)
    6428                 :           1 :         warned = warning_at (loc, OPT_Wunused_result,
    6429                 :             :                              "ignoring return value of %qD, declared with "
    6430                 :             :                              "attribute %<nodiscard%>: %E", fn, args);
    6431                 :             :       else
    6432                 :           2 :         warned = warning_at (loc, OPT_Wunused_result,
    6433                 :             :                              "ignoring return value of %qD, declared with "
    6434                 :             :                              "attribute %<nodiscard%>", fn);
    6435                 :           3 :       if (warned)
    6436                 :           3 :         inform (DECL_SOURCE_LOCATION (fn), "declared here");
    6437                 :           3 :     }
    6438                 :             :   else
    6439                 :             :     {
    6440                 :      341292 :       tree rettype = TREE_TYPE (TREE_TYPE (TREE_TYPE (fn)));
    6441                 :      341292 :       attr = lookup_attribute ("nodiscard", TYPE_ATTRIBUTES (rettype));
    6442                 :      341292 :       if (!attr)
    6443                 :      341280 :         return;
    6444                 :          12 :       tree args = TREE_VALUE (attr);
    6445                 :          12 :       if (args)
    6446                 :           5 :         args = TREE_VALUE (args);
    6447                 :          12 :       auto_diagnostic_group d;
    6448                 :          12 :       auto_urlify_attributes sentinel;
    6449                 :          12 :       int warned;
    6450                 :          12 :       if (args)
    6451                 :           5 :         warned = warning_at (loc, OPT_Wunused_result,
    6452                 :             :                              "ignoring return value of type %qT, declared "
    6453                 :             :                              "with attribute %<nodiscard%>: %E",
    6454                 :             :                              rettype, args);
    6455                 :             :       else
    6456                 :           7 :         warned = warning_at (loc, OPT_Wunused_result,
    6457                 :             :                              "ignoring return value of type %qT, declared "
    6458                 :             :                              "with attribute %<nodiscard%>", rettype);
    6459                 :          12 :       if (warned)
    6460                 :             :         {
    6461                 :          12 :           if (TREE_CODE (fn) == ADDR_EXPR)
    6462                 :             :             {
    6463                 :          11 :               fn = TREE_OPERAND (fn, 0);
    6464                 :          11 :               if (TREE_CODE (fn) == FUNCTION_DECL)
    6465                 :          11 :                 inform (DECL_SOURCE_LOCATION (fn),
    6466                 :             :                         "in call to %qD, declared here", fn);
    6467                 :             :             }
    6468                 :             :         }
    6469                 :          12 :     }
    6470                 :             : }
    6471                 :             : 
    6472                 :             : /* Return a compound expression that performs two expressions and
    6473                 :             :    returns the value of the second of them.
    6474                 :             : 
    6475                 :             :    LOC is the location of the COMPOUND_EXPR.  */
    6476                 :             : 
    6477                 :             : tree
    6478                 :      103187 : build_compound_expr (location_t loc, tree expr1, tree expr2)
    6479                 :             : {
    6480                 :      103187 :   bool expr1_int_operands, expr2_int_operands;
    6481                 :      103187 :   tree eptype = NULL_TREE;
    6482                 :      103187 :   tree ret;
    6483                 :             : 
    6484                 :      103187 :   expr1_int_operands = EXPR_INT_CONST_OPERANDS (expr1);
    6485                 :         325 :   if (expr1_int_operands)
    6486                 :         325 :     expr1 = remove_c_maybe_const_expr (expr1);
    6487                 :      103187 :   expr2_int_operands = EXPR_INT_CONST_OPERANDS (expr2);
    6488                 :       59779 :   if (expr2_int_operands)
    6489                 :       59779 :     expr2 = remove_c_maybe_const_expr (expr2);
    6490                 :             : 
    6491                 :      103187 :   if (TREE_CODE (expr1) == EXCESS_PRECISION_EXPR)
    6492                 :           0 :     expr1 = TREE_OPERAND (expr1, 0);
    6493                 :      103187 :   if (TREE_CODE (expr2) == EXCESS_PRECISION_EXPR)
    6494                 :             :     {
    6495                 :           1 :       eptype = TREE_TYPE (expr2);
    6496                 :           1 :       expr2 = TREE_OPERAND (expr2, 0);
    6497                 :             :     }
    6498                 :             : 
    6499                 :      103187 :   if (!TREE_SIDE_EFFECTS (expr1))
    6500                 :             :     {
    6501                 :             :       /* The left-hand operand of a comma expression is like an expression
    6502                 :             :          statement: with -Wunused, we should warn if it doesn't have
    6503                 :             :          any side-effects, unless it was explicitly cast to (void).  */
    6504                 :        6830 :       if (warn_unused_value)
    6505                 :             :         {
    6506                 :        1261 :           if (VOID_TYPE_P (TREE_TYPE (expr1))
    6507                 :        1261 :               && CONVERT_EXPR_P (expr1))
    6508                 :             :             ; /* (void) a, b */
    6509                 :          14 :           else if (VOID_TYPE_P (TREE_TYPE (expr1))
    6510                 :           4 :                    && TREE_CODE (expr1) == COMPOUND_EXPR
    6511                 :          17 :                    && CONVERT_EXPR_P (TREE_OPERAND (expr1, 1)))
    6512                 :             :             ; /* (void) a, (void) b, c */
    6513                 :             :           else
    6514                 :          11 :             warning_at (loc, OPT_Wunused_value,
    6515                 :             :                         "left-hand operand of comma expression has no effect");
    6516                 :             :         }
    6517                 :             :     }
    6518                 :       96357 :   else if (TREE_CODE (expr1) == COMPOUND_EXPR
    6519                 :       13056 :            && warn_unused_value)
    6520                 :             :     {
    6521                 :             :       tree r = expr1;
    6522                 :             :       location_t cloc = loc;
    6523                 :        4737 :       while (TREE_CODE (r) == COMPOUND_EXPR)
    6524                 :             :         {
    6525                 :        2369 :           if (EXPR_HAS_LOCATION (r))
    6526                 :        2369 :             cloc = EXPR_LOCATION (r);
    6527                 :        2369 :           r = TREE_OPERAND (r, 1);
    6528                 :             :         }
    6529                 :        2368 :       if (!TREE_SIDE_EFFECTS (r)
    6530                 :           4 :           && !VOID_TYPE_P (TREE_TYPE (r))
    6531                 :        2372 :           && !CONVERT_EXPR_P (r))
    6532                 :           4 :         warning_at (cloc, OPT_Wunused_value,
    6533                 :             :                     "right-hand operand of comma expression has no effect");
    6534                 :             :     }
    6535                 :             : 
    6536                 :             :   /* With -Wunused, we should also warn if the left-hand operand does have
    6537                 :             :      side-effects, but computes a value which is not used.  For example, in
    6538                 :             :      `foo() + bar(), baz()' the result of the `+' operator is not used,
    6539                 :             :      so we should issue a warning.  */
    6540                 :       93989 :   else if (warn_unused_value)
    6541                 :       35294 :     warn_if_unused_value (expr1, loc);
    6542                 :             : 
    6543                 :      103187 :   maybe_warn_nodiscard (loc, expr1);
    6544                 :             : 
    6545                 :      103187 :   if (expr2 == error_mark_node)
    6546                 :             :     return error_mark_node;
    6547                 :             : 
    6548                 :      103174 :   ret = build2 (COMPOUND_EXPR, TREE_TYPE (expr2), expr1, expr2);
    6549                 :             : 
    6550                 :      103174 :   if (flag_isoc99
    6551                 :             :       && expr1_int_operands
    6552                 :      102718 :       && expr2_int_operands)
    6553                 :         152 :     ret = note_integer_operands (ret);
    6554                 :             : 
    6555                 :      103174 :   if (eptype)
    6556                 :           1 :     ret = build1 (EXCESS_PRECISION_EXPR, eptype, ret);
    6557                 :             : 
    6558                 :      103174 :   protected_set_expr_location (ret, loc);
    6559                 :      103174 :   return ret;
    6560                 :             : }
    6561                 :             : 
    6562                 :             : /* Issue -Wcast-qual warnings when appropriate.  TYPE is the type to
    6563                 :             :    which we are casting.  OTYPE is the type of the expression being
    6564                 :             :    cast.  Both TYPE and OTYPE are pointer types.  LOC is the location
    6565                 :             :    of the cast.  -Wcast-qual appeared on the command line.  Named
    6566                 :             :    address space qualifiers are not handled here, because they result
    6567                 :             :    in different warnings.  */
    6568                 :             : 
    6569                 :             : static void
    6570                 :       12673 : handle_warn_cast_qual (location_t loc, tree type, tree otype)
    6571                 :             : {
    6572                 :       12673 :   tree in_type = type;
    6573                 :       12673 :   tree in_otype = otype;
    6574                 :       12673 :   int added = 0;
    6575                 :       12673 :   int discarded = 0;
    6576                 :       12843 :   bool is_const;
    6577                 :             : 
    6578                 :             :   /* Check that the qualifiers on IN_TYPE are a superset of the
    6579                 :             :      qualifiers of IN_OTYPE.  The outermost level of POINTER_TYPE
    6580                 :             :      nodes is uninteresting and we stop as soon as we hit a
    6581                 :             :      non-POINTER_TYPE node on either type.  */
    6582                 :       12843 :   do
    6583                 :             :     {
    6584                 :       12843 :       in_otype = TREE_TYPE (in_otype);
    6585                 :       12843 :       in_type = TREE_TYPE (in_type);
    6586                 :             : 
    6587                 :             :       /* GNU C allows cv-qualified function types.  'const' means the
    6588                 :             :          function is very pure, 'volatile' means it can't return.  We
    6589                 :             :          need to warn when such qualifiers are added, not when they're
    6590                 :             :          taken away.  */
    6591                 :       12843 :       if (TREE_CODE (in_otype) == FUNCTION_TYPE
    6592                 :          26 :           && TREE_CODE (in_type) == FUNCTION_TYPE)
    6593                 :          18 :         added |= (TYPE_QUALS_NO_ADDR_SPACE (in_type)
    6594                 :          18 :                   & ~TYPE_QUALS_NO_ADDR_SPACE (in_otype));
    6595                 :             :       else
    6596                 :       12825 :         discarded |= (TYPE_QUALS_NO_ADDR_SPACE (in_otype)
    6597                 :       12825 :                       & ~TYPE_QUALS_NO_ADDR_SPACE (in_type));
    6598                 :             :     }
    6599                 :       12843 :   while (TREE_CODE (in_type) == POINTER_TYPE
    6600                 :       12843 :          && TREE_CODE (in_otype) == POINTER_TYPE);
    6601                 :             : 
    6602                 :       12673 :   if (added)
    6603                 :           2 :     warning_at (loc, OPT_Wcast_qual,
    6604                 :             :                 "cast adds %q#v qualifier to function type", added);
    6605                 :             : 
    6606                 :       12673 :   if (discarded)
    6607                 :             :     /* There are qualifiers present in IN_OTYPE that are not present
    6608                 :             :        in IN_TYPE.  */
    6609                 :        1117 :     warning_at (loc, OPT_Wcast_qual,
    6610                 :             :                 "cast discards %qv qualifier from pointer target type",
    6611                 :             :                 discarded);
    6612                 :             : 
    6613                 :       12673 :   if (added || discarded)
    6614                 :             :     return;
    6615                 :             : 
    6616                 :             :   /* A cast from **T to const **T is unsafe, because it can cause a
    6617                 :             :      const value to be changed with no additional warning.  We only
    6618                 :             :      issue this warning if T is the same on both sides, and we only
    6619                 :             :      issue the warning if there are the same number of pointers on
    6620                 :             :      both sides, as otherwise the cast is clearly unsafe anyhow.  A
    6621                 :             :      cast is unsafe when a qualifier is added at one level and const
    6622                 :             :      is not present at all outer levels.
    6623                 :             : 
    6624                 :             :      To issue this warning, we check at each level whether the cast
    6625                 :             :      adds new qualifiers not already seen.  We don't need to special
    6626                 :             :      case function types, as they won't have the same
    6627                 :             :      TYPE_MAIN_VARIANT.  */
    6628                 :             : 
    6629                 :       11554 :   if (TYPE_MAIN_VARIANT (in_type) != TYPE_MAIN_VARIANT (in_otype))
    6630                 :             :     return;
    6631                 :          51 :   if (TREE_CODE (TREE_TYPE (type)) != POINTER_TYPE)
    6632                 :             :     return;
    6633                 :             : 
    6634                 :          48 :   in_type = type;
    6635                 :          48 :   in_otype = otype;
    6636                 :          48 :   is_const = TYPE_READONLY (TREE_TYPE (in_type));
    6637                 :         130 :   do
    6638                 :             :     {
    6639                 :         130 :       in_type = TREE_TYPE (in_type);
    6640                 :         130 :       in_otype = TREE_TYPE (in_otype);
    6641                 :         130 :       if ((TYPE_QUALS (in_type) &~ TYPE_QUALS (in_otype)) != 0
    6642                 :         130 :           && !is_const)
    6643                 :             :         {
    6644                 :          27 :           warning_at (loc, OPT_Wcast_qual,
    6645                 :             :                       "to be safe all intermediate pointers in cast from "
    6646                 :             :                       "%qT to %qT must be %<const%> qualified",
    6647                 :             :                       otype, type);
    6648                 :          27 :           break;
    6649                 :             :         }
    6650                 :         103 :       if (is_const)
    6651                 :          72 :         is_const = TYPE_READONLY (in_type);
    6652                 :             :     }
    6653                 :         103 :   while (TREE_CODE (in_type) == POINTER_TYPE);
    6654                 :             : }
    6655                 :             : 
    6656                 :             : /* Heuristic check if two parameter types can be considered ABI-equivalent.  */
    6657                 :             : 
    6658                 :             : static bool
    6659                 :        1067 : c_safe_arg_type_equiv_p (tree t1, tree t2)
    6660                 :             : {
    6661                 :        1067 :   if (error_operand_p (t1) || error_operand_p (t2))
    6662                 :             :     return true;
    6663                 :             : 
    6664                 :        1066 :   t1 = TYPE_MAIN_VARIANT (t1);
    6665                 :        1066 :   t2 = TYPE_MAIN_VARIANT (t2);
    6666                 :             : 
    6667                 :        1066 :   if (TREE_CODE (t1) == POINTER_TYPE
    6668                 :         114 :       && TREE_CODE (t2) == POINTER_TYPE)
    6669                 :             :     return true;
    6670                 :             : 
    6671                 :             :   /* The signedness of the parameter matters only when an integral
    6672                 :             :      type smaller than int is promoted to int, otherwise only the
    6673                 :             :      precision of the parameter matters.
    6674                 :             :      This check should make sure that the callee does not see
    6675                 :             :      undefined values in argument registers.  */
    6676                 :         974 :   if (INTEGRAL_TYPE_P (t1)
    6677                 :         869 :       && INTEGRAL_TYPE_P (t2)
    6678                 :         301 :       && TYPE_PRECISION (t1) == TYPE_PRECISION (t2)
    6679                 :        1095 :       && (TYPE_UNSIGNED (t1) == TYPE_UNSIGNED (t2)
    6680                 :           0 :           || !targetm.calls.promote_prototypes (NULL_TREE)
    6681                 :           0 :           || TYPE_PRECISION (t1) >= TYPE_PRECISION (integer_type_node)))
    6682                 :         121 :     return true;
    6683                 :             : 
    6684                 :         853 :   return comptypes (t1, t2);
    6685                 :             : }
    6686                 :             : 
    6687                 :             : /* Check if a type cast between two function types can be considered safe.  */
    6688                 :             : 
    6689                 :             : static bool
    6690                 :        7419 : c_safe_function_type_cast_p (tree t1, tree t2)
    6691                 :             : {
    6692                 :        7419 :   if (TREE_TYPE (t1) == void_type_node &&
    6693                 :        5436 :       TYPE_ARG_TYPES (t1) == void_list_node)
    6694                 :             :     return true;
    6695                 :             : 
    6696                 :        3665 :   if (TREE_TYPE (t2) == void_type_node &&
    6697                 :        2862 :       TYPE_ARG_TYPES (t2) == void_list_node)
    6698                 :             :     return true;
    6699                 :             : 
    6700                 :         835 :   if (!c_safe_arg_type_equiv_p (TREE_TYPE (t1), TREE_TYPE (t2)))
    6701                 :             :     return false;
    6702                 :             : 
    6703                 :         153 :   for (t1 = TYPE_ARG_TYPES (t1), t2 = TYPE_ARG_TYPES (t2);
    6704                 :         281 :        t1 && t2;
    6705                 :         128 :        t1 = TREE_CHAIN (t1), t2 = TREE_CHAIN (t2))
    6706                 :         232 :     if (!c_safe_arg_type_equiv_p (TREE_VALUE (t1), TREE_VALUE (t2)))
    6707                 :             :       return false;
    6708                 :             : 
    6709                 :             :   return true;
    6710                 :             : }
    6711                 :             : 
    6712                 :             : /* Build an expression representing a cast to type TYPE of expression EXPR.
    6713                 :             :    LOC is the location of the cast-- typically the open paren of the cast.  */
    6714                 :             : 
    6715                 :             : tree
    6716                 :   123639432 : build_c_cast (location_t loc, tree type, tree expr)
    6717                 :             : {
    6718                 :   123639432 :   tree value;
    6719                 :             : 
    6720                 :   123639432 :   bool int_operands = EXPR_INT_CONST_OPERANDS (expr);
    6721                 :             : 
    6722                 :   123639432 :   if (TREE_CODE (expr) == EXCESS_PRECISION_EXPR)
    6723                 :          66 :     expr = TREE_OPERAND (expr, 0);
    6724                 :             : 
    6725                 :   123639432 :   value = expr;
    6726                 :   123639432 :   if (int_operands)
    6727                 :     7147049 :     value = remove_c_maybe_const_expr (value);
    6728                 :             : 
    6729                 :   123639432 :   if (type == error_mark_node || expr == error_mark_node)
    6730                 :             :     return error_mark_node;
    6731                 :             : 
    6732                 :             :   /* The ObjC front-end uses TYPE_MAIN_VARIANT to tie together types differing
    6733                 :             :      only in <protocol> qualifications.  But when constructing cast expressions,
    6734                 :             :      the protocols do matter and must be kept around.  */
    6735                 :   123638411 :   if (objc_is_object_ptr (type) && objc_is_object_ptr (TREE_TYPE (expr)))
    6736                 :           0 :     return build1 (NOP_EXPR, type, expr);
    6737                 :             : 
    6738                 :   123638411 :   type = TYPE_MAIN_VARIANT (type);
    6739                 :             : 
    6740                 :   123638411 :   if (TREE_CODE (type) == ARRAY_TYPE)
    6741                 :             :     {
    6742                 :          13 :       error_at (loc, "cast specifies array type");
    6743                 :          13 :       return error_mark_node;
    6744                 :             :     }
    6745                 :             : 
    6746                 :   123638398 :   if (TREE_CODE (type) == FUNCTION_TYPE)
    6747                 :             :     {
    6748                 :           6 :       error_at (loc, "cast specifies function type");
    6749                 :           6 :       return error_mark_node;
    6750                 :             :     }
    6751                 :             : 
    6752                 :   123638392 :   if (!VOID_TYPE_P (type))
    6753                 :             :     {
    6754                 :   123596260 :       value = require_complete_type (loc, value);
    6755                 :   123596260 :       if (value == error_mark_node)
    6756                 :             :         return error_mark_node;
    6757                 :             :     }
    6758                 :             : 
    6759                 :   123638392 :   if (type == TYPE_MAIN_VARIANT (TREE_TYPE (value)))
    6760                 :             :     {
    6761                 :    18597006 :       if (RECORD_OR_UNION_TYPE_P (type)
    6762                 :    18597006 :           && pedwarn (loc, OPT_Wpedantic,
    6763                 :             :                       "ISO C forbids casting nonscalar to the same type"))
    6764                 :             :               ;
    6765                 :    18597002 :       else if (warn_useless_cast)
    6766                 :           7 :         warning_at (loc, OPT_Wuseless_cast,
    6767                 :             :                     "useless cast to type %qT", type);
    6768                 :             : 
    6769                 :             :       /* Convert to remove any qualifiers from VALUE's type.  */
    6770                 :    18597006 :       value = convert (type, value);
    6771                 :             :     }
    6772                 :   105041386 :   else if (TREE_CODE (type) == UNION_TYPE)
    6773                 :             :     {
    6774                 :         128 :       tree field;
    6775                 :             : 
    6776                 :         182 :       for (field = TYPE_FIELDS (type); field; field = DECL_CHAIN (field))
    6777                 :         176 :         if (TREE_TYPE (field) != error_mark_node
    6778                 :         351 :             && comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (field)),
    6779                 :         175 :                           TYPE_MAIN_VARIANT (TREE_TYPE (value))))
    6780                 :             :           break;
    6781                 :             : 
    6782                 :         128 :       if (field)
    6783                 :             :         {
    6784                 :         122 :           tree t;
    6785                 :         122 :           bool maybe_const = true;
    6786                 :             : 
    6787                 :         122 :           pedwarn (loc, OPT_Wpedantic, "ISO C forbids casts to union type");
    6788                 :         122 :           t = c_fully_fold (value, false, &maybe_const);
    6789                 :         122 :           t = build_constructor_single (type, field, t);
    6790                 :         122 :           if (!maybe_const)
    6791                 :           8 :             t = c_wrap_maybe_const (t, true);
    6792                 :         122 :           t = digest_init (loc, type, t,
    6793                 :             :                            NULL_TREE, false, false, false, true, false, false);
    6794                 :         122 :           TREE_CONSTANT (t) = TREE_CONSTANT (value);
    6795                 :         122 :           return t;
    6796                 :             :         }
    6797                 :           6 :       error_at (loc, "cast to union type from type not present in union");
    6798                 :           6 :       return error_mark_node;
    6799                 :             :     }
    6800                 :             :   else
    6801                 :             :     {
    6802                 :   105041258 :       tree otype, ovalue;
    6803                 :             : 
    6804                 :   105041258 :       if (type == void_type_node)
    6805                 :             :         {
    6806                 :       16176 :           tree t = build1 (CONVERT_EXPR, type, value);
    6807                 :       16176 :           SET_EXPR_LOCATION (t, loc);
    6808                 :       16176 :           return t;
    6809                 :             :         }
    6810                 :             : 
    6811                 :   105025082 :       otype = TREE_TYPE (value);
    6812                 :             : 
    6813                 :             :       /* Optionally warn about potentially worrisome casts.  */
    6814                 :   105025082 :       if (warn_cast_qual
    6815                 :      183113 :           && TREE_CODE (type) == POINTER_TYPE
    6816                 :       25661 :           && TREE_CODE (otype) == POINTER_TYPE)
    6817                 :       12673 :         handle_warn_cast_qual (loc, type, otype);
    6818                 :             : 
    6819                 :             :       /* Warn about conversions between pointers to disjoint
    6820                 :             :          address spaces.  */
    6821                 :   105025082 :       if (TREE_CODE (type) == POINTER_TYPE
    6822                 :     3267122 :           && TREE_CODE (otype) == POINTER_TYPE
    6823                 :   107951740 :           && !null_pointer_constant_p (value))
    6824                 :             :         {
    6825                 :     2874645 :           addr_space_t as_to = TYPE_ADDR_SPACE (TREE_TYPE (type));
    6826                 :     2874645 :           addr_space_t as_from = TYPE_ADDR_SPACE (TREE_TYPE (otype));
    6827                 :     2874645 :           addr_space_t as_common;
    6828                 :             : 
    6829                 :     2874645 :           if (!addr_space_superset (as_to, as_from, &as_common))
    6830                 :             :             {
    6831                 :           0 :               if (ADDR_SPACE_GENERIC_P (as_from))
    6832                 :           0 :                 warning_at (loc, 0, "cast to %qs address space pointer "
    6833                 :             :                             "from disjoint generic address space pointer",
    6834                 :             :                             c_addr_space_name (as_to));
    6835                 :             : 
    6836                 :           0 :               else if (ADDR_SPACE_GENERIC_P (as_to))
    6837                 :           0 :                 warning_at (loc, 0, "cast to generic address space pointer "
    6838                 :             :                             "from disjoint %qs address space pointer",
    6839                 :             :                             c_addr_space_name (as_from));
    6840                 :             : 
    6841                 :             :               else
    6842                 :           0 :                 warning_at (loc, 0, "cast to %qs address space pointer "
    6843                 :             :                             "from disjoint %qs address space pointer",
    6844                 :             :                             c_addr_space_name (as_to),
    6845                 :             :                             c_addr_space_name (as_from));
    6846                 :             :             }
    6847                 :             : 
    6848                 :             :           /* Warn of new allocations that are not big enough for the target
    6849                 :             :              type.  */
    6850                 :     2874645 :           if (warn_alloc_size && TREE_CODE (value) == CALL_EXPR)
    6851                 :         797 :             if (tree fndecl = get_callee_fndecl (value))
    6852                 :         793 :               if (DECL_IS_MALLOC (fndecl))
    6853                 :             :                 {
    6854                 :         509 :                   tree attrs = TYPE_ATTRIBUTES (TREE_TYPE (fndecl));
    6855                 :         509 :                   tree alloc_size = lookup_attribute ("alloc_size", attrs);
    6856                 :         509 :                   if (alloc_size)
    6857                 :         151 :                     warn_for_alloc_size (loc, TREE_TYPE (type), value,
    6858                 :             :                                          alloc_size);
    6859                 :             :                 }
    6860                 :             :         }
    6861                 :             : 
    6862                 :             :       /* Warn about possible alignment problems.  */
    6863                 :   105025082 :       if ((STRICT_ALIGNMENT || warn_cast_align == 2)
    6864                 :           7 :           && TREE_CODE (type) == POINTER_TYPE
    6865                 :           7 :           && TREE_CODE (otype) == POINTER_TYPE
    6866                 :           7 :           && TREE_CODE (TREE_TYPE (otype)) != VOID_TYPE
    6867                 :           7 :           && TREE_CODE (TREE_TYPE (otype)) != FUNCTION_TYPE
    6868                 :             :           /* Don't warn about opaque types, where the actual alignment
    6869                 :             :              restriction is unknown.  */
    6870                 :          12 :           && !(RECORD_OR_UNION_TYPE_P (TREE_TYPE (otype))
    6871                 :           5 :                && TYPE_MODE (TREE_TYPE (otype)) == VOIDmode)
    6872                 :   105025096 :           && min_align_of_type (TREE_TYPE (type))
    6873                 :           7 :              > min_align_of_type (TREE_TYPE (otype)))
    6874                 :           5 :         warning_at (loc, OPT_Wcast_align,
    6875                 :             :                     "cast increases required alignment of target type");
    6876                 :             : 
    6877                 :   105025082 :       if ((TREE_CODE (type) == INTEGER_TYPE
    6878                 :   105025082 :            || TREE_CODE (type) == BITINT_TYPE)
    6879                 :     7352492 :           && TREE_CODE (otype) == POINTER_TYPE
    6880                 :   105049938 :           && TYPE_PRECISION (type) != TYPE_PRECISION (otype))
    6881                 :             :       /* Unlike conversion of integers to pointers, where the
    6882                 :             :          warning is disabled for converting constants because
    6883                 :             :          of cases such as SIG_*, warn about converting constant
    6884                 :             :          pointers to integers. In some cases it may cause unwanted
    6885                 :             :          sign extension, and a warning is appropriate.  */
    6886                 :        1449 :         warning_at (loc, OPT_Wpointer_to_int_cast,
    6887                 :             :                     "cast from pointer to integer of different size");
    6888                 :             : 
    6889                 :   105025082 :       if (TREE_CODE (value) == CALL_EXPR
    6890                 :    35826210 :           && TREE_CODE (type) != TREE_CODE (otype))
    6891                 :        2275 :         warning_at (loc, OPT_Wbad_function_cast,
    6892                 :             :                     "cast from function call of type %qT "
    6893                 :             :                     "to non-matching type %qT", otype, type);
    6894                 :             : 
    6895                 :   105025082 :       if (TREE_CODE (type) == POINTER_TYPE
    6896                 :     3267122 :           && (TREE_CODE (otype) == INTEGER_TYPE
    6897                 :     3267122 :               || TREE_CODE (otype) == BITINT_TYPE)
    6898                 :      340402 :           && TYPE_PRECISION (type) != TYPE_PRECISION (otype)
    6899                 :             :           /* Don't warn about converting any constant.  */
    6900                 :   105328997 :           && !TREE_CONSTANT (value))
    6901                 :         407 :         warning_at (loc,
    6902                 :             :                     OPT_Wint_to_pointer_cast, "cast to pointer from integer "
    6903                 :             :                     "of different size");
    6904                 :             : 
    6905                 :   105025082 :       if (warn_strict_aliasing <= 2)
    6906                 :    96140315 :         strict_aliasing_warning (EXPR_LOCATION (value), type, expr);
    6907                 :             : 
    6908                 :             :       /* If pedantic, warn for conversions between function and object
    6909                 :             :          pointer types, except for converting a null pointer constant
    6910                 :             :          to function pointer type.  */
    6911                 :   105025082 :       if (pedantic
    6912                 :      239480 :           && TREE_CODE (type) == POINTER_TYPE
    6913                 :      144035 :           && TREE_CODE (otype) == POINTER_TYPE
    6914                 :        2657 :           && TREE_CODE (TREE_TYPE (otype)) == FUNCTION_TYPE
    6915                 :   105025103 :           && TREE_CODE (TREE_TYPE (type)) != FUNCTION_TYPE)
    6916                 :          18 :         pedwarn (loc, OPT_Wpedantic, "ISO C forbids "
    6917                 :             :                  "conversion of function pointer to object pointer type");
    6918                 :             : 
    6919                 :   105025082 :       if (pedantic
    6920                 :      239480 :           && TREE_CODE (type) == POINTER_TYPE
    6921                 :      144035 :           && TREE_CODE (otype) == POINTER_TYPE
    6922                 :        2657 :           && TREE_CODE (TREE_TYPE (type)) == FUNCTION_TYPE
    6923                 :          13 :           && TREE_CODE (TREE_TYPE (otype)) != FUNCTION_TYPE
    6924                 :   105025092 :           && !null_pointer_constant_p (value))
    6925                 :           4 :         pedwarn (loc, OPT_Wpedantic, "ISO C forbids "
    6926                 :             :                  "conversion of object pointer to function pointer type");
    6927                 :             : 
    6928                 :   105025082 :       if (TREE_CODE (type) == POINTER_TYPE
    6929                 :     3267122 :           && TREE_CODE (otype) == POINTER_TYPE
    6930                 :     2926658 :           && TREE_CODE (TREE_TYPE (type)) == FUNCTION_TYPE
    6931                 :        8478 :           && TREE_CODE (TREE_TYPE (otype)) == FUNCTION_TYPE
    6932                 :   105032501 :           && !c_safe_function_type_cast_p (TREE_TYPE (type),
    6933                 :        7419 :                                            TREE_TYPE (otype)))
    6934                 :         786 :         warning_at (loc, OPT_Wcast_function_type,
    6935                 :             :                     "cast between incompatible function types"
    6936                 :             :                     " from %qT to %qT", otype, type);
    6937                 :             : 
    6938                 :   105025082 :       ovalue = value;
    6939                 :             :       /* If converting to boolean a value with integer operands that
    6940                 :             :          is not itself represented as an INTEGER_CST, the call below
    6941                 :             :          to note_integer_operands may insert a C_MAYBE_CONST_EXPR, but
    6942                 :             :          build_binary_op as called by c_common_truthvalue_conversion
    6943                 :             :          may also insert a C_MAYBE_CONST_EXPR to indicate that a
    6944                 :             :          subexpression has been fully folded.  To avoid nested
    6945                 :             :          C_MAYBE_CONST_EXPR, ensure that
    6946                 :             :          c_objc_common_truthvalue_conversion receives an argument
    6947                 :             :          properly marked as having integer operands in that case.  */
    6948                 :   105025082 :       if (int_operands
    6949                 :     6959313 :           && TREE_CODE (value) != INTEGER_CST
    6950                 :   105025124 :           && (TREE_CODE (type) == BOOLEAN_TYPE
    6951                 :          28 :               || (TREE_CODE (type) == ENUMERAL_TYPE
    6952                 :          14 :                   && ENUM_UNDERLYING_TYPE (type) != NULL_TREE
    6953                 :          14 :                   && TREE_CODE (ENUM_UNDERLYING_TYPE (type)) == BOOLEAN_TYPE)))
    6954                 :          28 :         value = note_integer_operands (value);
    6955                 :   105025082 :       value = convert (type, value);
    6956                 :             : 
    6957                 :             :       /* Ignore any integer overflow caused by the cast.  */
    6958                 :   105025082 :       if (TREE_CODE (value) == INTEGER_CST && !FLOAT_TYPE_P (otype))
    6959                 :             :         {
    6960                 :     6905135 :           if (TREE_OVERFLOW_P (ovalue))
    6961                 :             :             {
    6962                 :           9 :               if (!TREE_OVERFLOW (value))
    6963                 :             :                 {
    6964                 :             :                   /* Avoid clobbering a shared constant.  */
    6965                 :           0 :                   value = copy_node (value);
    6966                 :           0 :                   TREE_OVERFLOW (value) = TREE_OVERFLOW (ovalue);
    6967                 :             :                 }
    6968                 :             :             }
    6969                 :     6905126 :           else if (TREE_OVERFLOW (value))
    6970                 :             :             /* Reset VALUE's overflow flags, ensuring constant sharing.  */
    6971                 :        3085 :             value = wide_int_to_tree (TREE_TYPE (value), wi::to_wide (value));
    6972                 :             :         }
    6973                 :             :     }
    6974                 :             : 
    6975                 :             :   /* Don't let a cast be an lvalue.  */
    6976                 :   123622088 :   if (lvalue_p (value))
    6977                 :       88777 :     value = non_lvalue_loc (loc, value);
    6978                 :             : 
    6979                 :             :   /* Don't allow the results of casting to floating-point or complex
    6980                 :             :      types be confused with actual constants, or casts involving
    6981                 :             :      integer and pointer types other than direct integer-to-integer
    6982                 :             :      and integer-to-pointer be confused with integer constant
    6983                 :             :      expressions and null pointer constants.  */
    6984                 :   123622088 :   if (TREE_CODE (value) == REAL_CST
    6985                 :   123572312 :       || TREE_CODE (value) == COMPLEX_CST
    6986                 :   247171777 :       || (TREE_CODE (value) == INTEGER_CST
    6987                 :     7151375 :           && !((TREE_CODE (expr) == INTEGER_CST
    6988                 :     7079626 :                 && INTEGRAL_TYPE_P (TREE_TYPE (expr)))
    6989                 :       64346 :                || TREE_CODE (expr) == REAL_CST
    6990                 :             :                || TREE_CODE (expr) == COMPLEX_CST)))
    6991                 :      132378 :       value = build1 (NOP_EXPR, type, value);
    6992                 :             : 
    6993                 :             :   /* If the expression has integer operands and so can occur in an
    6994                 :             :      unevaluated part of an integer constant expression, ensure the
    6995                 :             :      return value reflects this.  */
    6996                 :   123622088 :   if (int_operands
    6997                 :     7134743 :       && INTEGRAL_TYPE_P (type)
    6998                 :     6695536 :       && value != error_mark_node
    6999                 :   130317623 :       && !EXPR_INT_CONST_OPERANDS (value))
    7000                 :          11 :     value = note_integer_operands (value);
    7001                 :             : 
    7002                 :   123622088 :   protected_set_expr_location (value, loc);
    7003                 :   123622088 :   return value;
    7004                 :             : }
    7005                 :             : 
    7006                 :             : /* Interpret a cast of expression EXPR to type TYPE.  LOC is the
    7007                 :             :    location of the open paren of the cast, or the position of the cast
    7008                 :             :    expr.  */
    7009                 :             : tree
    7010                 :   123639086 : c_cast_expr (location_t loc, struct c_type_name *type_name, tree expr)
    7011                 :             : {
    7012                 :   123639086 :   tree type;
    7013                 :   123639086 :   tree type_expr = NULL_TREE;
    7014                 :   123639086 :   bool type_expr_const = true;
    7015                 :   123639086 :   tree ret;
    7016                 :   123639086 :   int saved_wsp = warn_strict_prototypes;
    7017                 :             : 
    7018                 :             :   /* This avoids warnings about unprototyped casts on
    7019                 :             :      integers.  E.g. "#define SIG_DFL (void(*)())0".  */
    7020                 :   123639086 :   if (TREE_CODE (expr) == INTEGER_CST)
    7021                 :     7199319 :     warn_strict_prototypes = 0;
    7022                 :   123639086 :   type = groktypename (type_name, &type_expr, &type_expr_const);
    7023                 :   123639086 :   warn_strict_prototypes = saved_wsp;
    7024                 :             : 
    7025                 :      764481 :   if (TREE_CODE (expr) == ADDR_EXPR && !VOID_TYPE_P (type)
    7026                 :   124403330 :       && reject_gcc_builtin (expr))
    7027                 :           2 :     return error_mark_node;
    7028                 :             : 
    7029                 :   123639084 :   ret = build_c_cast (loc, type, expr);
    7030                 :   123639084 :   if (ret == error_mark_node)
    7031                 :             :     return error_mark_node;
    7032                 :             : 
    7033                 :   123637934 :   if (type_expr)
    7034                 :             :     {
    7035                 :         203 :       bool inner_expr_const = true;
    7036                 :         203 :       ret = c_fully_fold (ret, require_constant_value, &inner_expr_const);
    7037                 :         203 :       ret = build2 (C_MAYBE_CONST_EXPR, TREE_TYPE (ret), type_expr, ret);
    7038                 :         406 :       C_MAYBE_CONST_EXPR_NON_CONST (ret) = !(type_expr_const
    7039                 :         129 :                                              && inner_expr_const);
    7040                 :         203 :       SET_EXPR_LOCATION (ret, loc);
    7041                 :             :     }
    7042                 :             : 
    7043                 :   123637934 :   if (!EXPR_HAS_LOCATION (ret))
    7044                 :     7081179 :     protected_set_expr_location (ret, loc);
    7045                 :             : 
    7046                 :             :   /* C++ does not permits types to be defined in a cast, but it
    7047                 :             :      allows references to incomplete types.  */
    7048                 :   123637934 :   if (warn_cxx_compat && type_name->specs->typespec_kind == ctsk_tagdef)
    7049                 :           1 :     warning_at (loc, OPT_Wc___compat,
    7050                 :             :                 "defining a type in a cast is invalid in C++");
    7051                 :             : 
    7052                 :             :   return ret;
    7053                 :             : }
    7054                 :             : 
    7055                 :             : /* Build an assignment expression of lvalue LHS from value RHS.
    7056                 :             :    If LHS_ORIGTYPE is not NULL, it is the original type of LHS, which
    7057                 :             :    may differ from TREE_TYPE (LHS) for an enum bitfield.
    7058                 :             :    MODIFYCODE is the code for a binary operator that we use
    7059                 :             :    to combine the old value of LHS with RHS to get the new value.
    7060                 :             :    Or else MODIFYCODE is NOP_EXPR meaning do a simple assignment.
    7061                 :             :    If RHS_ORIGTYPE is not NULL_TREE, it is the original type of RHS,
    7062                 :             :    which may differ from TREE_TYPE (RHS) for an enum value.
    7063                 :             : 
    7064                 :             :    LOCATION is the location of the MODIFYCODE operator.
    7065                 :             :    RHS_LOC is the location of the RHS.  */
    7066                 :             : 
    7067                 :             : tree
    7068                 :     2874757 : build_modify_expr (location_t location, tree lhs, tree lhs_origtype,
    7069                 :             :                    enum tree_code modifycode,
    7070                 :             :                    location_t rhs_loc, tree rhs, tree rhs_origtype)
    7071                 :             : {
    7072                 :     2874757 :   tree result;
    7073                 :     2874757 :   tree newrhs;
    7074                 :     2874757 :   tree rhseval = NULL_TREE;
    7075                 :     2874757 :   tree lhstype = TREE_TYPE (lhs);
    7076                 :     2874757 :   tree olhstype = lhstype;
    7077                 :     2874757 :   bool npc;
    7078                 :     2874757 :   bool is_atomic_op;
    7079                 :             : 
    7080                 :             :   /* Types that aren't fully specified cannot be used in assignments.  */
    7081                 :     2874757 :   lhs = require_complete_type (location, lhs);
    7082                 :     2874757 :   rhs = require_complete_type (location, rhs);
    7083                 :             : 
    7084                 :             :   /* Avoid duplicate error messages from operands that had errors.  */
    7085                 :     2874757 :   if (TREE_CODE (lhs) == ERROR_MARK || TREE_CODE (rhs) == ERROR_MARK)
    7086                 :         471 :     return error_mark_node;
    7087                 :             : 
    7088                 :             :   /* Ensure an error for assigning a non-lvalue array to an array in
    7089                 :             :      C90.  */
    7090                 :     2874286 :   if (TREE_CODE (lhstype) == ARRAY_TYPE)
    7091                 :             :     {
    7092                 :           1 :       error_at (location, "assignment to expression with array type");
    7093                 :           1 :       return error_mark_node;
    7094                 :             :     }
    7095                 :             : 
    7096                 :             :   /* For ObjC properties, defer this check.  */
    7097                 :     2874285 :   if (!objc_is_property_ref (lhs) && !lvalue_or_else (location, lhs, lv_assign))
    7098                 :          31 :     return error_mark_node;
    7099                 :             : 
    7100                 :     2874254 :   is_atomic_op = really_atomic_lvalue (lhs);
    7101                 :             : 
    7102                 :     2874254 :   newrhs = rhs;
    7103                 :             : 
    7104                 :     2874254 :   if (TREE_CODE (lhs) == C_MAYBE_CONST_EXPR)
    7105                 :             :     {
    7106                 :           2 :       tree inner = build_modify_expr (location, C_MAYBE_CONST_EXPR_EXPR (lhs),
    7107                 :             :                                       lhs_origtype, modifycode, rhs_loc, rhs,
    7108                 :             :                                       rhs_origtype);
    7109                 :           2 :       if (inner == error_mark_node)
    7110                 :             :         return error_mark_node;
    7111                 :           4 :       result = build2 (C_MAYBE_CONST_EXPR, TREE_TYPE (inner),
    7112                 :           2 :                        C_MAYBE_CONST_EXPR_PRE (lhs), inner);
    7113                 :           2 :       gcc_assert (!C_MAYBE_CONST_EXPR_INT_OPERANDS (lhs));
    7114                 :           2 :       C_MAYBE_CONST_EXPR_NON_CONST (result) = 1;
    7115                 :           2 :       protected_set_expr_location (result, location);
    7116                 :           2 :       return result;
    7117                 :             :     }
    7118                 :             : 
    7119                 :             :   /* If a binary op has been requested, combine the old LHS value with the RHS
    7120                 :             :      producing the value we should actually store into the LHS.  */
    7121                 :             : 
    7122                 :     2874252 :   if (modifycode != NOP_EXPR)
    7123                 :             :     {
    7124                 :      195765 :       lhs = c_fully_fold (lhs, false, NULL, true);
    7125                 :      195765 :       lhs = stabilize_reference (lhs);
    7126                 :             : 
    7127                 :             :       /* Construct the RHS for any non-atomic compound assignemnt. */
    7128                 :      195765 :       if (!is_atomic_op)
    7129                 :             :         {
    7130                 :             :           /* If in LHS op= RHS the RHS has side-effects, ensure they
    7131                 :             :              are preevaluated before the rest of the assignment expression's
    7132                 :             :              side-effects, because RHS could contain e.g. function calls
    7133                 :             :              that modify LHS.  */
    7134                 :      180298 :           if (TREE_SIDE_EFFECTS (rhs))
    7135                 :             :             {
    7136                 :        8556 :               if (TREE_CODE (rhs) == EXCESS_PRECISION_EXPR)
    7137                 :          28 :                 newrhs = save_expr (TREE_OPERAND (rhs, 0));
    7138                 :             :               else
    7139                 :        8528 :                 newrhs = save_expr (rhs);
    7140                 :        8556 :               rhseval = newrhs;
    7141                 :        8556 :               if (TREE_CODE (rhs) == EXCESS_PRECISION_EXPR)
    7142                 :          28 :                 newrhs = build1 (EXCESS_PRECISION_EXPR, TREE_TYPE (rhs),
    7143                 :             :                                  newrhs);
    7144                 :             :             }
    7145                 :      180298 :           newrhs = build_binary_op (location,
    7146                 :             :                                     modifycode, lhs, newrhs, true);
    7147                 :             : 
    7148                 :             :           /* The original type of the right hand side is no longer
    7149                 :             :              meaningful.  */
    7150                 :      180298 :           rhs_origtype = NULL_TREE;
    7151                 :             :         }
    7152                 :             :     }
    7153                 :             : 
    7154                 :     2874252 :   if (c_dialect_objc ())
    7155                 :             :     {
    7156                 :             :       /* Check if we are modifying an Objective-C property reference;
    7157                 :             :          if so, we need to generate setter calls.  */
    7158                 :           0 :       if (TREE_CODE (newrhs) == EXCESS_PRECISION_EXPR)
    7159                 :           0 :         result = objc_maybe_build_modify_expr (lhs, TREE_OPERAND (newrhs, 0));
    7160                 :             :       else
    7161                 :           0 :         result = objc_maybe_build_modify_expr (lhs, newrhs);
    7162                 :           0 :       if (result)
    7163                 :           0 :         goto return_result;
    7164                 :             : 
    7165                 :             :       /* Else, do the check that we postponed for Objective-C.  */
    7166                 :           0 :       if (!lvalue_or_else (location, lhs, lv_assign))
    7167                 :           0 :         return error_mark_node;
    7168                 :             :     }
    7169                 :             : 
    7170                 :             :   /* Give an error for storing in something that is 'const'.  */
    7171                 :             : 
    7172                 :     2874252 :   if (TYPE_READONLY (lhstype)
    7173                 :     2874252 :       || (RECORD_OR_UNION_TYPE_P (lhstype)
    7174                 :       25358 :           && C_TYPE_FIELDS_READONLY (lhstype)))
    7175                 :             :     {
    7176                 :          88 :       readonly_error (location, lhs, lv_assign);
    7177                 :          88 :       return error_mark_node;
    7178                 :             :     }
    7179                 :     2874164 :   else if (TREE_READONLY (lhs))
    7180                 :           1 :     readonly_warning (lhs, lv_assign);
    7181                 :             : 
    7182                 :             :   /* If storing into a structure or union member,
    7183                 :             :      it has probably been given type `int'.
    7184                 :             :      Compute the type that would go with
    7185                 :             :      the actual amount of storage the member occupies.  */
    7186                 :             : 
    7187                 :     2874164 :   if (TREE_CODE (lhs) == COMPONENT_REF
    7188                 :      243094 :       && (TREE_CODE (lhstype) == INTEGER_TYPE
    7189                 :      243094 :           || TREE_CODE (lhstype) == BOOLEAN_TYPE
    7190                 :      106291 :           || SCALAR_FLOAT_TYPE_P (lhstype)
    7191                 :       84488 :           || TREE_CODE (lhstype) == ENUMERAL_TYPE))
    7192                 :      165580 :     lhstype = TREE_TYPE (get_unwidened (lhs, 0));
    7193                 :             : 
    7194                 :             :   /* If storing in a field that is in actuality a short or narrower than one,
    7195                 :             :      we must store in the field in its actual type.  */
    7196                 :             : 
    7197                 :     2874164 :   if (lhstype != TREE_TYPE (lhs))
    7198                 :             :     {
    7199                 :           0 :       lhs = copy_node (lhs);
    7200                 :           0 :       TREE_TYPE (lhs) = lhstype;
    7201                 :             :     }
    7202                 :             : 
    7203                 :             :   /* Issue -Wc++-compat warnings about an assignment to an enum type
    7204                 :             :      when LHS does not have its original type.  This happens for,
    7205                 :             :      e.g., an enum bitfield in a struct.  */
    7206                 :     2874164 :   if (warn_cxx_compat
    7207                 :        2974 :       && lhs_origtype != NULL_TREE
    7208                 :        2974 :       && lhs_origtype != lhstype
    7209                 :           7 :       && TREE_CODE (lhs_origtype) == ENUMERAL_TYPE)
    7210                 :             :     {
    7211                 :           4 :       tree checktype = (rhs_origtype != NULL_TREE
    7212                 :           4 :                         ? rhs_origtype
    7213                 :           0 :                         : TREE_TYPE (rhs));
    7214                 :           4 :       if (checktype != error_mark_node
    7215                 :           4 :           && (TYPE_MAIN_VARIANT (checktype) != TYPE_MAIN_VARIANT (lhs_origtype)
    7216                 :           2 :               || (is_atomic_op && modifycode != NOP_EXPR)))
    7217                 :           2 :         warning_at (location, OPT_Wc___compat,
    7218                 :             :                     "enum conversion in assignment is invalid in C++");
    7219                 :             :     }
    7220                 :             : 
    7221                 :             :   /* Remove qualifiers.  */
    7222                 :     2874164 :   lhstype = c_build_qualified_type (lhstype, TYPE_UNQUALIFIED);
    7223                 :     2874164 :   olhstype = c_build_qualified_type (olhstype, TYPE_UNQUALIFIED);
    7224                 :             : 
    7225                 :             :   /* Convert new value to destination type.  Fold it first, then
    7226                 :             :      restore any excess precision information, for the sake of
    7227                 :             :      conversion warnings.  */
    7228                 :             : 
    7229                 :     2874164 :   if (!(is_atomic_op && modifycode != NOP_EXPR))
    7230                 :             :     {
    7231                 :     2858697 :       tree rhs_semantic_type = NULL_TREE;
    7232                 :     2858697 :       if (!c_in_omp_for)
    7233                 :             :         {
    7234                 :     2842786 :           if (TREE_CODE (newrhs) == EXCESS_PRECISION_EXPR)
    7235                 :             :             {
    7236                 :        5069 :               rhs_semantic_type = TREE_TYPE (newrhs);
    7237                 :        5069 :               newrhs = TREE_OPERAND (newrhs, 0);
    7238                 :             :             }
    7239                 :     2842786 :           npc = null_pointer_constant_p (newrhs);
    7240                 :     2842786 :           newrhs = c_fully_fold (newrhs, false, NULL);
    7241                 :     2842786 :           if (rhs_semantic_type)
    7242                 :        5069 :             newrhs = build1 (EXCESS_PRECISION_EXPR, rhs_semantic_type, newrhs);
    7243                 :             :         }
    7244                 :             :       else
    7245                 :       15911 :         npc = null_pointer_constant_p (newrhs);
    7246                 :     2858697 :       newrhs = convert_for_assignment (location, rhs_loc, lhstype, newrhs,
    7247                 :             :                                        rhs_origtype, ic_assign, npc,
    7248                 :             :                                        NULL_TREE, NULL_TREE, 0);
    7249                 :     2858697 :       if (TREE_CODE (newrhs) == ERROR_MARK)
    7250                 :         116 :         return error_mark_node;
    7251                 :             :     }
    7252                 :             : 
    7253                 :             :   /* Emit ObjC write barrier, if necessary.  */
    7254                 :     2874048 :   if (c_dialect_objc () && flag_objc_gc)
    7255                 :             :     {
    7256                 :           0 :       result = objc_generate_write_barrier (lhs, modifycode, newrhs);
    7257                 :           0 :       if (result)
    7258                 :             :         {
    7259                 :           0 :           protected_set_expr_location (result, location);
    7260                 :           0 :           goto return_result;
    7261                 :             :         }
    7262                 :             :     }
    7263                 :             : 
    7264                 :             :   /* Scan operands.  */
    7265                 :             : 
    7266                 :     2874048 :   if (is_atomic_op)
    7267                 :       25840 :     result = build_atomic_assign (location, lhs, modifycode, newrhs, false);
    7268                 :             :   else
    7269                 :             :     {
    7270                 :     2848208 :       result = build2 (MODIFY_EXPR, lhstype, lhs, newrhs);
    7271                 :     2848208 :       TREE_SIDE_EFFECTS (result) = 1;
    7272                 :     2848208 :       protected_set_expr_location (result, location);
    7273                 :             :     }
    7274                 :             : 
    7275                 :             :   /* If we got the LHS in a different type for storing in,
    7276                 :             :      convert the result back to the nominal type of LHS
    7277                 :             :      so that the value we return always has the same type
    7278                 :             :      as the LHS argument.  */
    7279                 :             : 
    7280                 :     2874048 :   if (olhstype == TREE_TYPE (result))
    7281                 :     2874048 :     goto return_result;
    7282                 :             : 
    7283                 :           0 :   result = convert_for_assignment (location, rhs_loc, olhstype, result,
    7284                 :             :                                    rhs_origtype, ic_assign, false, NULL_TREE,
    7285                 :             :                                    NULL_TREE, 0);
    7286                 :           0 :   protected_set_expr_location (result, location);
    7287                 :             : 
    7288                 :     2874048 : return_result:
    7289                 :     2874048 :   if (rhseval)
    7290                 :        8556 :     result = build2 (COMPOUND_EXPR, TREE_TYPE (result), rhseval, result);
    7291                 :             :   return result;
    7292                 :             : }
    7293                 :             : 
    7294                 :             : /* Return whether STRUCT_TYPE has an anonymous field with type TYPE.
    7295                 :             :    This is used to implement -fplan9-extensions.  */
    7296                 :             : 
    7297                 :             : static bool
    7298                 :          10 : find_anonymous_field_with_type (tree struct_type, tree type)
    7299                 :             : {
    7300                 :          10 :   tree field;
    7301                 :          10 :   bool found;
    7302                 :             : 
    7303                 :          10 :   gcc_assert (RECORD_OR_UNION_TYPE_P (struct_type));
    7304                 :          10 :   found = false;
    7305                 :          10 :   for (field = TYPE_FIELDS (struct_type);
    7306                 :          20 :        field != NULL_TREE;
    7307                 :          10 :        field = TREE_CHAIN (field))
    7308                 :             :     {
    7309                 :          10 :       tree fieldtype = (TYPE_ATOMIC (TREE_TYPE (field))
    7310                 :          20 :                         ? c_build_qualified_type (TREE_TYPE (field),
    7311                 :             :                                                   TYPE_QUAL_ATOMIC)
    7312                 :          10 :                         : TYPE_MAIN_VARIANT (TREE_TYPE (field)));
    7313                 :          10 :       if (DECL_NAME (field) == NULL
    7314                 :          10 :           && comptypes (type, fieldtype))
    7315                 :             :         {
    7316                 :           4 :           if (found)
    7317                 :             :             return false;
    7318                 :             :           found = true;
    7319                 :             :         }
    7320                 :           6 :       else if (DECL_NAME (field) == NULL
    7321                 :           2 :                && RECORD_OR_UNION_TYPE_P (TREE_TYPE (field))
    7322                 :           8 :                && find_anonymous_field_with_type (TREE_TYPE (field), type))
    7323                 :             :         {
    7324                 :           0 :           if (found)
    7325                 :             :             return false;
    7326                 :             :           found = true;
    7327                 :             :         }
    7328                 :             :     }
    7329                 :             :   return found;
    7330                 :             : }
    7331                 :             : 
    7332                 :             : /* RHS is an expression whose type is pointer to struct.  If there is
    7333                 :             :    an anonymous field in RHS with type TYPE, then return a pointer to
    7334                 :             :    that field in RHS.  This is used with -fplan9-extensions.  This
    7335                 :             :    returns NULL if no conversion could be found.  */
    7336                 :             : 
    7337                 :             : static tree
    7338                 :          12 : convert_to_anonymous_field (location_t location, tree type, tree rhs)
    7339                 :             : {
    7340                 :          12 :   tree rhs_struct_type, lhs_main_type;
    7341                 :          12 :   tree field, found_field;
    7342                 :          12 :   bool found_sub_field;
    7343                 :          12 :   tree ret;
    7344                 :             : 
    7345                 :          12 :   gcc_assert (POINTER_TYPE_P (TREE_TYPE (rhs)));
    7346                 :          12 :   rhs_struct_type = TREE_TYPE (TREE_TYPE (rhs));
    7347                 :          12 :   gcc_assert (RECORD_OR_UNION_TYPE_P (rhs_struct_type));
    7348                 :             : 
    7349                 :          12 :   gcc_assert (POINTER_TYPE_P (type));
    7350                 :          12 :   lhs_main_type = (TYPE_ATOMIC (TREE_TYPE (type))
    7351                 :          24 :                    ? c_build_qualified_type (TREE_TYPE (type),
    7352                 :             :                                              TYPE_QUAL_ATOMIC)
    7353                 :          12 :                    : TYPE_MAIN_VARIANT (TREE_TYPE (type)));
    7354                 :             : 
    7355                 :          12 :   found_field = NULL_TREE;
    7356                 :          12 :   found_sub_field = false;
    7357                 :          12 :   for (field = TYPE_FIELDS (rhs_struct_type);
    7358                 :          44 :        field != NULL_TREE;
    7359                 :          32 :        field = TREE_CHAIN (field))
    7360                 :             :     {
    7361                 :          36 :       if (DECL_NAME (field) != NULL_TREE
    7362                 :          36 :           || !RECORD_OR_UNION_TYPE_P (TREE_TYPE (field)))
    7363                 :          16 :         continue;
    7364                 :          20 :       tree fieldtype = (TYPE_ATOMIC (TREE_TYPE (field))
    7365                 :          40 :                         ? c_build_qualified_type (TREE_TYPE (field),
    7366                 :             :                                                   TYPE_QUAL_ATOMIC)
    7367                 :          20 :                         : TYPE_MAIN_VARIANT (TREE_TYPE (field)));
    7368                 :          20 :       if (comptypes (lhs_main_type, fieldtype))
    7369                 :             :         {
    7370                 :          12 :           if (found_field != NULL_TREE)
    7371                 :             :             return NULL_TREE;
    7372                 :             :           found_field = field;
    7373                 :             :         }
    7374                 :           8 :       else if (find_anonymous_field_with_type (TREE_TYPE (field),
    7375                 :             :                                                lhs_main_type))
    7376                 :             :         {
    7377                 :           4 :           if (found_field != NULL_TREE)
    7378                 :             :             return NULL_TREE;
    7379                 :             :           found_field = field;
    7380                 :             :           found_sub_field = true;
    7381                 :             :         }
    7382                 :             :     }
    7383                 :             : 
    7384                 :           8 :   if (found_field == NULL_TREE)
    7385                 :             :     return NULL_TREE;
    7386                 :             : 
    7387                 :           8 :   ret = fold_build3_loc (location, COMPONENT_REF, TREE_TYPE (found_field),
    7388                 :             :                          build_fold_indirect_ref (rhs), found_field,
    7389                 :             :                          NULL_TREE);
    7390                 :           8 :   ret = build_fold_addr_expr_loc (location, ret);
    7391                 :             : 
    7392                 :           8 :   if (found_sub_field)
    7393                 :             :     {
    7394                 :           2 :       ret = convert_to_anonymous_field (location, type, ret);
    7395                 :           2 :       gcc_assert (ret != NULL_TREE);
    7396                 :             :     }
    7397                 :             : 
    7398                 :             :   return ret;
    7399                 :             : }
    7400                 :             : 
    7401                 :             : /* Issue an error message for a bad initializer component.
    7402                 :             :    GMSGID identifies the message.
    7403                 :             :    The component name is taken from the spelling stack.  */
    7404                 :             : 
    7405                 :             : static void ATTRIBUTE_GCC_DIAG (2,0)
    7406                 :         891 : error_init (location_t loc, const char *gmsgid, ...)
    7407                 :             : {
    7408                 :         891 :   char *ofwhat;
    7409                 :             : 
    7410                 :         891 :   auto_diagnostic_group d;
    7411                 :             : 
    7412                 :             :   /* The gmsgid may be a format string with %< and %>. */
    7413                 :         891 :   va_list ap;
    7414                 :         891 :   va_start (ap, gmsgid);
    7415                 :         891 :   bool warned = emit_diagnostic_valist (DK_ERROR, loc, -1, gmsgid, &ap);
    7416                 :         891 :   va_end (ap);
    7417                 :             : 
    7418                 :         891 :   ofwhat = print_spelling ((char *) alloca (spelling_length () + 1));
    7419                 :         891 :   if (*ofwhat && warned)
    7420                 :         205 :     inform (loc, "(near initialization for %qs)", ofwhat);
    7421                 :         891 : }
    7422                 :             : 
    7423                 :             : /* Used to implement pedwarn_init and permerror_init.  */
    7424                 :             : 
    7425                 :             : static void ATTRIBUTE_GCC_DIAG (3,0)
    7426                 :        2405 : pedwarn_permerror_init (location_t loc, int opt, const char *gmsgid,
    7427                 :             :                         va_list *ap, diagnostic_t kind)
    7428                 :             : {
    7429                 :             :   /* Use the location where a macro was expanded rather than where
    7430                 :             :      it was defined to make sure macros defined in system headers
    7431                 :             :      but used incorrectly elsewhere are diagnosed.  */
    7432                 :        2405 :   location_t exploc = expansion_point_location_if_in_system_header (loc);
    7433                 :        2405 :   auto_diagnostic_group d;
    7434                 :        2405 :   bool warned = emit_diagnostic_valist (kind, exploc, opt, gmsgid, ap);
    7435                 :        2405 :   char *ofwhat = print_spelling ((char *) alloca (spelling_length () + 1));
    7436                 :        2405 :   if (*ofwhat && warned)
    7437                 :        1461 :     inform (exploc, "(near initialization for %qs)", ofwhat);
    7438                 :        2405 : }
    7439                 :             : 
    7440                 :             : /* Issue a pedantic warning for a bad initializer component.  OPT is
    7441                 :             :    the option OPT_* (from options.h) controlling this warning or 0 if
    7442                 :             :    it is unconditionally given.  GMSGID identifies the message.  The
    7443                 :             :    component name is taken from the spelling stack.  */
    7444                 :             : 
    7445                 :             : static void ATTRIBUTE_GCC_DIAG (3,0)
    7446                 :        2080 : pedwarn_init (location_t loc, int opt, const char *gmsgid, ...)
    7447                 :             : {
    7448                 :        2080 :   va_list ap;
    7449                 :        2080 :   va_start (ap, gmsgid);
    7450                 :        2080 :   pedwarn_permerror_init (loc, opt, gmsgid, &ap, DK_PEDWARN);
    7451                 :        2080 :   va_end (ap);
    7452                 :        2080 : }
    7453                 :             : 
    7454                 :             : /* Like pedwarn_init, but issue a permerror.  */
    7455                 :             : 
    7456                 :             : static void ATTRIBUTE_GCC_DIAG (3,0)
    7457                 :         325 : permerror_init (location_t loc, int opt, const char *gmsgid, ...)
    7458                 :             : {
    7459                 :         325 :   va_list ap;
    7460                 :         325 :   va_start (ap, gmsgid);
    7461                 :         325 :   pedwarn_permerror_init (loc, opt, gmsgid, &ap, DK_PERMERROR);
    7462                 :         325 :   va_end (ap);
    7463                 :         325 : }
    7464                 :             : 
    7465                 :             : /* Issue a warning for a bad initializer component.
    7466                 :             : 
    7467                 :             :    OPT is the OPT_W* value corresponding to the warning option that
    7468                 :             :    controls this warning.  GMSGID identifies the message.  The
    7469                 :             :    component name is taken from the spelling stack.  */
    7470                 :             : 
    7471                 :             : static void
    7472                 :         146 : warning_init (location_t loc, int opt, const char *gmsgid)
    7473                 :             : {
    7474                 :         146 :   char *ofwhat;
    7475                 :         146 :   bool warned;
    7476                 :             : 
    7477                 :         146 :   auto_diagnostic_group d;
    7478                 :             : 
    7479                 :             :   /* Use the location where a macro was expanded rather than where
    7480                 :             :      it was defined to make sure macros defined in system headers
    7481                 :             :      but used incorrectly elsewhere are diagnosed.  */
    7482                 :         146 :   location_t exploc = expansion_point_location_if_in_system_header (loc);
    7483                 :             : 
    7484                 :             :   /* The gmsgid may be a format string with %< and %>. */
    7485                 :         146 :   warned = warning_at (exploc, opt, gmsgid);
    7486                 :         146 :   ofwhat = print_spelling ((char *) alloca (spelling_length () + 1));
    7487                 :         146 :   if (*ofwhat && warned)
    7488                 :         124 :     inform (exploc, "(near initialization for %qs)", ofwhat);
    7489                 :         146 : }
    7490                 :             : 
    7491                 :             : /* If TYPE is an array type and EXPR is a parenthesized string
    7492                 :             :    constant, warn if pedantic that EXPR is being used to initialize an
    7493                 :             :    object of type TYPE.  */
    7494                 :             : 
    7495                 :             : void
    7496                 :     7115457 : maybe_warn_string_init (location_t loc, tree type, struct c_expr expr)
    7497                 :             : {
    7498                 :     7115457 :   if (pedantic
    7499                 :       80055 :       && TREE_CODE (type) == ARRAY_TYPE
    7500                 :        1004 :       && TREE_CODE (expr.value) == STRING_CST
    7501                 :         353 :       && expr.original_code != STRING_CST)
    7502                 :          13 :     pedwarn_init (loc, OPT_Wpedantic,
    7503                 :             :                   "array initialized from parenthesized string constant");
    7504                 :     7115457 : }
    7505                 :             : 
    7506                 :             : /* Attempt to locate the parameter with the given index within FNDECL,
    7507                 :             :    returning DECL_SOURCE_LOCATION (FNDECL) if it can't be found.  */
    7508                 :             : 
    7509                 :             : static location_t
    7510                 :         929 : get_fndecl_argument_location (tree fndecl, int argnum)
    7511                 :             : {
    7512                 :         929 :   int i;
    7513                 :         929 :   tree param;
    7514                 :             : 
    7515                 :             :   /* Locate param by index within DECL_ARGUMENTS (fndecl).  */
    7516                 :         929 :   for (i = 0, param = DECL_ARGUMENTS (fndecl);
    7517                 :        1000 :        i < argnum && param;
    7518                 :          71 :        i++, param = TREE_CHAIN (param))
    7519                 :             :     ;
    7520                 :             : 
    7521                 :             :   /* If something went wrong (e.g. if we have a builtin and thus no arguments),
    7522                 :             :      return DECL_SOURCE_LOCATION (FNDECL).  */
    7523                 :         929 :   if (param == NULL)
    7524                 :         653 :     return DECL_SOURCE_LOCATION (fndecl);
    7525                 :             : 
    7526                 :         276 :   return DECL_SOURCE_LOCATION (param);
    7527                 :             : }
    7528                 :             : 
    7529                 :             : /* Issue a note about a mismatching argument for parameter PARMNUM
    7530                 :             :    to FUNDECL, for types EXPECTED_TYPE and ACTUAL_TYPE.
    7531                 :             :    Attempt to issue the note at the pertinent parameter of the decl;
    7532                 :             :    failing that issue it at the location of FUNDECL; failing that
    7533                 :             :    issue it at PLOC.
    7534                 :             :    Use highlight_colors::actual for the ACTUAL_TYPE
    7535                 :             :    and highlight_colors::expected for EXPECTED_TYPE and the
    7536                 :             :    parameter of FUNDECL*/
    7537                 :             : 
    7538                 :             : static void
    7539                 :        1053 : inform_for_arg (tree fundecl, location_t ploc, int parmnum,
    7540                 :             :                 tree expected_type, tree actual_type)
    7541                 :             : {
    7542                 :        1053 :   location_t loc;
    7543                 :        1053 :   if (fundecl && !DECL_IS_UNDECLARED_BUILTIN (fundecl))
    7544                 :         929 :     loc = get_fndecl_argument_location (fundecl, parmnum - 1);
    7545                 :             :   else
    7546                 :             :     loc = ploc;
    7547                 :             : 
    7548                 :        1053 :   gcc_rich_location richloc (loc, nullptr, highlight_colors::expected);
    7549                 :             : 
    7550                 :        1053 :   pp_markup::element_expected_type elem_expected_type (expected_type);
    7551                 :        1053 :   pp_markup::element_actual_type elem_actual_type (actual_type);
    7552                 :        1053 :   inform (&richloc,
    7553                 :             :           "expected %e but argument is of type %e",
    7554                 :             :           &elem_expected_type, &elem_actual_type);
    7555                 :        1053 : }
    7556                 :             : 
    7557                 :             : /* Issue a warning when an argument of ARGTYPE is passed to a built-in
    7558                 :             :    function FUNDECL declared without prototype to parameter PARMNUM of
    7559                 :             :    PARMTYPE when ARGTYPE does not promote to PARMTYPE.  */
    7560                 :             : 
    7561                 :             : static void
    7562                 :         418 : maybe_warn_builtin_no_proto_arg (location_t loc, tree fundecl, int parmnum,
    7563                 :             :                                  tree parmtype, tree argtype)
    7564                 :             : {
    7565                 :         418 :   tree_code parmcode = TREE_CODE (parmtype);
    7566                 :         418 :   tree_code argcode = TREE_CODE (argtype);
    7567                 :         418 :   tree promoted = c_type_promotes_to (argtype);
    7568                 :             : 
    7569                 :             :   /* Avoid warning for enum arguments that promote to an integer type
    7570                 :             :      of the same size/mode.  */
    7571                 :         418 :   if (parmcode == INTEGER_TYPE
    7572                 :         418 :       && argcode == ENUMERAL_TYPE
    7573                 :         418 :       && TYPE_MODE (parmtype) == TYPE_MODE (argtype))
    7574                 :             :     return;
    7575                 :             : 
    7576                 :         417 :   if ((parmcode == argcode
    7577                 :         222 :        || (parmcode == INTEGER_TYPE
    7578                 :             :            && argcode == ENUMERAL_TYPE))
    7579                 :         418 :       && TYPE_MAIN_VARIANT (parmtype) == TYPE_MAIN_VARIANT (promoted))
    7580                 :             :     return;
    7581                 :             : 
    7582                 :             :   /* This diagnoses even signed/unsigned mismatches.  Those might be
    7583                 :             :      safe in many cases but GCC may emit suboptimal code for them so
    7584                 :             :      warning on those cases drives efficiency improvements.  */
    7585                 :         398 :   if (warning_at (loc, OPT_Wbuiltin_declaration_mismatch,
    7586                 :         398 :                   TYPE_MAIN_VARIANT (promoted) == argtype
    7587                 :             :                   ? G_("%qD argument %d type is %qT where %qT is expected "
    7588                 :             :                        "in a call to built-in function declared without "
    7589                 :             :                        "prototype")
    7590                 :             :                   : G_("%qD argument %d promotes to %qT where %qT is expected "
    7591                 :             :                        "in a call to built-in function declared without "
    7592                 :             :                        "prototype"),
    7593                 :             :                   fundecl, parmnum, promoted, parmtype))
    7594                 :         150 :     inform (DECL_SOURCE_LOCATION (fundecl),
    7595                 :             :             "built-in %qD declared here",
    7596                 :             :             fundecl);
    7597                 :             : }
    7598                 :             : 
    7599                 :             : /* Convert value RHS to type TYPE as preparation for an assignment to
    7600                 :             :    an lvalue of type TYPE.  If ORIGTYPE is not NULL_TREE, it is the
    7601                 :             :    original type of RHS; this differs from TREE_TYPE (RHS) for enum
    7602                 :             :    types.  NULL_POINTER_CONSTANT says whether RHS was a null pointer
    7603                 :             :    constant before any folding.
    7604                 :             :    The real work of conversion is done by `convert'.
    7605                 :             :    The purpose of this function is to generate error messages
    7606                 :             :    for assignments that are not allowed in C.
    7607                 :             :    ERRTYPE says whether it is argument passing, assignment,
    7608                 :             :    initialization or return.
    7609                 :             : 
    7610                 :             :    In the following example, '~' denotes where EXPR_LOC and '^' where
    7611                 :             :    LOCATION point to:
    7612                 :             : 
    7613                 :             :      f (var);      [ic_argpass]
    7614                 :             :      ^  ~~~
    7615                 :             :      x = var;      [ic_assign]
    7616                 :             :        ^ ~~~;
    7617                 :             :      int x = var;  [ic_init]
    7618                 :             :              ^^^
    7619                 :             :      return x;     [ic_return]
    7620                 :             :             ^
    7621                 :             : 
    7622                 :             :    FUNCTION is a tree for the function being called.
    7623                 :             :    PARMNUM is the number of the argument, for printing in error messages.
    7624                 :             :    WARNOPT may be set to a warning option to issue the corresponding warning
    7625                 :             :    rather than an error for invalid conversions.  Used for calls to built-in
    7626                 :             :    functions declared without a prototype.  */
    7627                 :             : 
    7628                 :             : static tree
    7629                 :   171666166 : convert_for_assignment (location_t location, location_t expr_loc, tree type,
    7630                 :             :                         tree rhs, tree origtype, enum impl_conv errtype,
    7631                 :             :                         bool null_pointer_constant, tree fundecl,
    7632                 :             :                         tree function, int parmnum, int warnopt /* = 0 */)
    7633                 :             : {
    7634                 :   171666166 :   enum tree_code codel = TREE_CODE (type);
    7635                 :   171666166 :   tree orig_rhs = rhs;
    7636                 :   171666166 :   tree rhstype;
    7637                 :   171666166 :   enum tree_code coder;
    7638                 :   171666166 :   tree rname = NULL_TREE;
    7639                 :   171666166 :   bool objc_ok = false;
    7640                 :             : 
    7641                 :             :   /* Use the expansion point location to handle cases such as user's
    7642                 :             :      function returning a wrong-type macro defined in a system header.  */
    7643                 :   171666166 :   location = expansion_point_location_if_in_system_header (location);
    7644                 :             : 
    7645                 :   171666166 :   if (errtype == ic_argpass)
    7646                 :             :     {
    7647                 :   129759096 :       tree selector;
    7648                 :             :       /* Change pointer to function to the function itself for
    7649                 :             :          diagnostics.  */
    7650                 :   129759096 :       if (TREE_CODE (function) == ADDR_EXPR
    7651                 :   129759096 :           && TREE_CODE (TREE_OPERAND (function, 0)) == FUNCTION_DECL)
    7652                 :           0 :         function = TREE_OPERAND (function, 0);
    7653                 :             : 
    7654                 :             :       /* Handle an ObjC selector specially for diagnostics.  */
    7655                 :   129759096 :       selector = objc_message_selector ();
    7656                 :   129759096 :       rname = function;
    7657                 :   129759096 :       if (selector && parmnum > 2)
    7658                 :             :         {
    7659                 :           0 :           rname = selector;
    7660                 :           0 :           parmnum -= 2;
    7661                 :             :         }
    7662                 :             :     }
    7663                 :             : 
    7664                 :             :   /* This macro is used to emit diagnostics to ensure that all format
    7665                 :             :      strings are complete sentences, visible to gettext and checked at
    7666                 :             :      compile time.  */
    7667                 :             : #define PEDWARN_FOR_ASSIGNMENT(LOCATION, PLOC, OPT, AR, AS, IN, RE)      \
    7668                 :             :   do {                                                                   \
    7669                 :             :     switch (errtype)                                                     \
    7670                 :             :       {                                                                  \
    7671                 :             :       case ic_argpass:                                                   \
    7672                 :             :         {                                                               \
    7673                 :             :           auto_diagnostic_group d;                                              \
    7674                 :             :           if (pedwarn (PLOC, OPT, AR, parmnum, rname))          \
    7675                 :             :             inform_for_arg (fundecl, (PLOC), parmnum, type, rhstype); \
    7676                 :             :         }                                                               \
    7677                 :             :         break;                                                           \
    7678                 :             :       case ic_assign:                                                    \
    7679                 :             :         pedwarn (LOCATION, OPT, AS);                                     \
    7680                 :             :         break;                                                           \
    7681                 :             :       case ic_init:                                                      \
    7682                 :             :       case ic_init_const:                                                \
    7683                 :             :         pedwarn_init (LOCATION, OPT, IN);                                \
    7684                 :             :         break;                                                           \
    7685                 :             :       case ic_return:                                                    \
    7686                 :             :         pedwarn (LOCATION, OPT, RE);                                     \
    7687                 :             :         break;                                                           \
    7688                 :             :       default:                                                           \
    7689                 :             :         gcc_unreachable ();                                              \
    7690                 :             :       }                                                                  \
    7691                 :             :   } while (0)
    7692                 :             : 
    7693                 :             :   /* This macro is used to emit diagnostics to ensure that all format
    7694                 :             :      strings are complete sentences, visible to gettext and checked at
    7695                 :             :      compile time.  It can be called with 'pedwarn' or 'warning_at'.  */
    7696                 :             : #define WARNING_FOR_QUALIFIERS(PEDWARN, LOCATION, PLOC, OPT, AR, AS, IN, RE, QUALS) \
    7697                 :             :   do {                                                                   \
    7698                 :             :     switch (errtype)                                                     \
    7699                 :             :       {                                                                  \
    7700                 :             :       case ic_argpass:                                                   \
    7701                 :             :         {                                                                \
    7702                 :             :           auto_diagnostic_group d;                                       \
    7703                 :             :           if (PEDWARN) {                                                 \
    7704                 :             :             if (pedwarn (PLOC, OPT, AR, parmnum, rname, QUALS))          \
    7705                 :             :               inform_for_arg (fundecl, (PLOC), parmnum, type, rhstype);  \
    7706                 :             :           } else {                                                       \
    7707                 :             :             if (warning_at (PLOC, OPT, AR, parmnum, rname, QUALS))       \
    7708                 :             :               inform_for_arg (fundecl, (PLOC), parmnum, type, rhstype);  \
    7709                 :             :           }                                                              \
    7710                 :             :         }                                                                \
    7711                 :             :         break;                                                           \
    7712                 :             :       case ic_assign:                                                    \
    7713                 :             :         if (PEDWARN)                                                     \
    7714                 :             :           pedwarn (LOCATION, OPT, AS, QUALS);                            \
    7715                 :             :         else                                                             \
    7716                 :             :           warning_at (LOCATION, OPT, AS, QUALS);                         \
    7717                 :             :         break;                                                           \
    7718                 :             :       case ic_init:                                                      \
    7719                 :             :       case ic_init_const:                                                \
    7720                 :             :         if (PEDWARN)                                                     \
    7721                 :             :           pedwarn (LOCATION, OPT, IN, QUALS);                            \
    7722                 :             :         else                                                             \
    7723                 :             :           warning_at (LOCATION, OPT, IN, QUALS);                         \
    7724                 :             :         break;                                                           \
    7725                 :             :       case ic_return:                                                    \
    7726                 :             :         if (PEDWARN)                                                     \
    7727                 :             :           pedwarn (LOCATION, OPT, RE, QUALS);                            \
    7728                 :             :         else                                                             \
    7729                 :             :           warning_at (LOCATION, OPT, RE, QUALS);                         \
    7730                 :             :         break;                                                           \
    7731                 :             :       default:                                                           \
    7732                 :             :         gcc_unreachable ();                                              \
    7733                 :             :       }                                                                  \
    7734                 :             :   } while (0)
    7735                 :             : 
    7736                 :             :   /* This macro is used to emit diagnostics to ensure that all format
    7737                 :             :      strings are complete sentences, visible to gettext and checked at
    7738                 :             :      compile time.  It is the same as PEDWARN_FOR_ASSIGNMENT but with an
    7739                 :             :      extra parameter to enumerate qualifiers.  */
    7740                 :             : #define PEDWARN_FOR_QUALIFIERS(LOCATION, PLOC, OPT, AR, AS, IN, RE, QUALS) \
    7741                 :             :    WARNING_FOR_QUALIFIERS (true, LOCATION, PLOC, OPT, AR, AS, IN, RE, QUALS)
    7742                 :             : 
    7743                 :             : 
    7744                 :   171666166 :   if (TREE_CODE (rhs) == EXCESS_PRECISION_EXPR)
    7745                 :        5963 :     rhs = TREE_OPERAND (rhs, 0);
    7746                 :             : 
    7747                 :   171666166 :   rhstype = TREE_TYPE (rhs);
    7748                 :   171666166 :   coder = TREE_CODE (rhstype);
    7749                 :             : 
    7750                 :   171666166 :   if (coder == ERROR_MARK)
    7751                 :         346 :     return error_mark_node;
    7752                 :             : 
    7753                 :   171665820 :   if (c_dialect_objc ())
    7754                 :             :     {
    7755                 :           0 :       int parmno;
    7756                 :             : 
    7757                 :           0 :       switch (errtype)
    7758                 :             :         {
    7759                 :             :         case ic_return:
    7760                 :             :           parmno = 0;
    7761                 :             :           break;
    7762                 :             : 
    7763                 :             :         case ic_assign:
    7764                 :             :           parmno = -1;
    7765                 :             :           break;
    7766                 :             : 
    7767                 :             :         case ic_init:
    7768                 :             :         case ic_init_const:
    7769                 :             :           parmno = -2;
    7770                 :             :           break;
    7771                 :             : 
    7772                 :             :         default:
    7773                 :           0 :           parmno = parmnum;
    7774                 :             :           break;
    7775                 :             :         }
    7776                 :             : 
    7777                 :           0 :       objc_ok = objc_compare_types (type, rhstype, parmno, rname);
    7778                 :             :     }
    7779                 :             : 
    7780                 :   171665820 :   if (warn_cxx_compat)
    7781                 :             :     {
    7782                 :       26552 :       tree checktype = origtype != NULL_TREE ? origtype : rhstype;
    7783                 :       26552 :       if (checktype != error_mark_node
    7784                 :       26552 :           && TREE_CODE (type) == ENUMERAL_TYPE
    7785                 :       26658 :           && TYPE_MAIN_VARIANT (checktype) != TYPE_MAIN_VARIANT (type))
    7786                 :          45 :         switch (errtype)
    7787                 :             :           {
    7788                 :           8 :           case ic_argpass:
    7789                 :           8 :             if (pedwarn (expr_loc, OPT_Wc___compat, "enum conversion when "
    7790                 :             :                          "passing argument %d of %qE is invalid in C++",
    7791                 :             :                          parmnum, rname))
    7792                 :          16 :               inform ((fundecl && !DECL_IS_UNDECLARED_BUILTIN (fundecl))
    7793                 :           8 :                       ? DECL_SOURCE_LOCATION (fundecl) : expr_loc,
    7794                 :             :                       "expected %qT but argument is of type %qT",
    7795                 :             :                       type, rhstype);
    7796                 :             :             break;
    7797                 :          10 :           case ic_assign:
    7798                 :          10 :             pedwarn (location, OPT_Wc___compat, "enum conversion from %qT to "
    7799                 :             :                      "%qT in assignment is invalid in C++", rhstype, type);
    7800                 :          10 :             break;
    7801                 :          18 :           case ic_init:
    7802                 :          18 :           case ic_init_const:
    7803                 :          18 :             pedwarn_init (location, OPT_Wc___compat, "enum conversion from "
    7804                 :             :                           "%qT to %qT in initialization is invalid in C++",
    7805                 :             :                           rhstype, type);
    7806                 :          18 :             break;
    7807                 :           9 :           case ic_return:
    7808                 :           9 :             pedwarn (location, OPT_Wc___compat, "enum conversion from %qT to "
    7809                 :             :                      "%qT in return is invalid in C++", rhstype, type);
    7810                 :           9 :             break;
    7811                 :           0 :           default:
    7812                 :           0 :             gcc_unreachable ();
    7813                 :             :           }
    7814                 :             :     }
    7815                 :             : 
    7816                 :   171665820 :   if (warn_enum_conversion)
    7817                 :             :     {
    7818                 :    15172170 :       tree checktype = origtype != NULL_TREE ? origtype : rhstype;
    7819                 :    15172170 :       if (checktype != error_mark_node
    7820                 :    15172170 :           && TREE_CODE (checktype) == ENUMERAL_TYPE
    7821                 :       12657 :           && TREE_CODE (type) == ENUMERAL_TYPE
    7822                 :    15180362 :           && !comptypes (TYPE_MAIN_VARIANT (checktype), TYPE_MAIN_VARIANT (type)))
    7823                 :             :        {
    7824                 :           3 :           gcc_rich_location loc (location);
    7825                 :           3 :           warning_at (&loc, OPT_Wenum_conversion,
    7826                 :             :                       "implicit conversion from %qT to %qT",
    7827                 :             :                       checktype, type);
    7828                 :           3 :        }
    7829                 :             :     }
    7830                 :             : 
    7831                 :   171665820 :   if (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (rhstype))
    7832                 :             :     {
    7833                 :   152888528 :       warn_for_address_of_packed_member (type, orig_rhs);
    7834                 :   152888528 :       return rhs;
    7835                 :             :     }
    7836                 :             : 
    7837                 :    18777292 :   if (coder == VOID_TYPE)
    7838                 :             :     {
    7839                 :             :       /* Except for passing an argument to an unprototyped function,
    7840                 :             :          this is a constraint violation.  When passing an argument to
    7841                 :             :          an unprototyped function, it is compile-time undefined;
    7842                 :             :          making it a constraint in that case was rejected in
    7843                 :             :          DR#252.  */
    7844                 :           8 :       const char msg[] = "void value not ignored as it ought to be";
    7845                 :           8 :       if (warnopt)
    7846                 :           0 :         warning_at (location, warnopt, msg);
    7847                 :             :       else
    7848                 :           8 :         error_at (location, msg);
    7849                 :           8 :       return error_mark_node;
    7850                 :             :     }
    7851                 :    18777284 :   rhs = require_complete_type (location, rhs);
    7852                 :    18777284 :   if (rhs == error_mark_node)
    7853                 :             :     return error_mark_node;
    7854                 :             : 
    7855                 :    18777284 :   if (coder == POINTER_TYPE && reject_gcc_builtin (rhs))
    7856                 :           6 :     return error_mark_node;
    7857                 :             : 
    7858                 :             :   /* A non-reference type can convert to a reference.  This handles
    7859                 :             :      va_start, va_copy and possibly port built-ins.  */
    7860                 :    18777278 :   if (codel == REFERENCE_TYPE && coder != REFERENCE_TYPE)
    7861                 :             :     {
    7862                 :         270 :       if (!lvalue_p (rhs))
    7863                 :             :         {
    7864                 :           0 :           const char msg[] = "cannot pass rvalue to reference parameter";
    7865                 :           0 :           if (warnopt)
    7866                 :           0 :             warning_at (location, warnopt, msg);
    7867                 :             :           else
    7868                 :           0 :             error_at (location, msg);
    7869                 :           0 :           return error_mark_node;
    7870                 :             :         }
    7871                 :         270 :       if (!c_mark_addressable (rhs))
    7872                 :           0 :         return error_mark_node;
    7873                 :         270 :       rhs = build1 (ADDR_EXPR, c_build_pointer_type (TREE_TYPE (rhs)), rhs);
    7874                 :         270 :       SET_EXPR_LOCATION (rhs, location);
    7875                 :             : 
    7876                 :         270 :       rhs = convert_for_assignment (location, expr_loc,
    7877                 :         270 :                                     c_build_pointer_type (TREE_TYPE (type)),
    7878                 :             :                                     rhs, origtype, errtype,
    7879                 :             :                                     null_pointer_constant, fundecl, function,
    7880                 :             :                                     parmnum, warnopt);
    7881                 :         270 :       if (rhs == error_mark_node)
    7882                 :             :         return error_mark_node;
    7883                 :             : 
    7884                 :         270 :       rhs = build1 (NOP_EXPR, type, rhs);
    7885                 :         270 :       SET_EXPR_LOCATION (rhs, location);
    7886                 :         270 :       return rhs;
    7887                 :             :     }
    7888                 :             :   /* Some types can interconvert without explicit casts.  */
    7889                 :    18777008 :   else if (codel == VECTOR_TYPE && coder == VECTOR_TYPE
    7890                 :    18777008 :            && vector_types_convertible_p (type, TREE_TYPE (rhs), true))
    7891                 :     9089854 :     return convert (type, rhs);
    7892                 :             :   /* Arithmetic types all interconvert, and enum is treated like int.  */
    7893                 :     9687154 :   else if ((codel == INTEGER_TYPE || codel == REAL_TYPE
    7894                 :     2217860 :             || codel == FIXED_POINT_TYPE
    7895                 :     2217860 :             || codel == ENUMERAL_TYPE || codel == COMPLEX_TYPE
    7896                 :     2135980 :             || codel == BOOLEAN_TYPE || codel == BITINT_TYPE)
    7897                 :     7641782 :            && (coder == INTEGER_TYPE || coder == REAL_TYPE
    7898                 :       79376 :                || coder == FIXED_POINT_TYPE
    7899                 :       79376 :                || coder == ENUMERAL_TYPE || coder == COMPLEX_TYPE
    7900                 :       37291 :                || coder == BOOLEAN_TYPE || coder == BITINT_TYPE))
    7901                 :             :     {
    7902                 :     7640665 :       if (warnopt && errtype == ic_argpass)
    7903                 :         418 :         maybe_warn_builtin_no_proto_arg (expr_loc, fundecl, parmnum, type,
    7904                 :             :                                          rhstype);
    7905                 :             : 
    7906                 :     7640665 :       bool save = in_late_binary_op;
    7907                 :     7610183 :       if (C_BOOLEAN_TYPE_P (type) || codel == COMPLEX_TYPE
    7908                 :    15201996 :           || (coder == REAL_TYPE
    7909                 :      271809 :               && (codel == INTEGER_TYPE || codel == ENUMERAL_TYPE)
    7910                 :       24064 :               && sanitize_flags_p (SANITIZE_FLOAT_CAST)))
    7911                 :       86078 :         in_late_binary_op = true;
    7912                 :    10956186 :       tree ret = convert_and_check (expr_loc != UNKNOWN_LOCATION
    7913                 :             :                                     ? expr_loc : location, type, orig_rhs,
    7914                 :             :                                     errtype == ic_init_const);
    7915                 :     7640665 :       in_late_binary_op = save;
    7916                 :     7640665 :       return ret;
    7917                 :             :     }
    7918                 :             : 
    7919                 :             :   /* Aggregates in different TUs might need conversion.  */
    7920                 :     2046489 :   if ((codel == RECORD_TYPE || codel == UNION_TYPE)
    7921                 :          95 :       && codel == coder
    7922                 :     2046506 :       && comptypes (TYPE_MAIN_VARIANT (type), TYPE_MAIN_VARIANT (rhstype)))
    7923                 :           6 :     return convert_and_check (expr_loc != UNKNOWN_LOCATION
    7924                 :           6 :                               ? expr_loc : location, type, rhs);
    7925                 :             : 
    7926                 :             :   /* Conversion to a transparent union or record from its member types.
    7927                 :             :      This applies only to function arguments.  */
    7928                 :     2046483 :   if (((codel == UNION_TYPE || codel == RECORD_TYPE)
    7929                 :          89 :       && TYPE_TRANSPARENT_AGGR (type))
    7930                 :     2046521 :       && errtype == ic_argpass)
    7931                 :             :     {
    7932                 :          38 :       tree memb, marginal_memb = NULL_TREE;
    7933                 :             : 
    7934                 :          48 :       for (memb = TYPE_FIELDS (type); memb ; memb = DECL_CHAIN (memb))
    7935                 :             :         {
    7936                 :          48 :           tree memb_type = TREE_TYPE (memb);
    7937                 :             : 
    7938                 :          48 :           if (comptypes (TYPE_MAIN_VARIANT (memb_type),
    7939                 :          48 :                          TYPE_MAIN_VARIANT (rhstype)))
    7940                 :             :             break;
    7941                 :             : 
    7942                 :          26 :           if (TREE_CODE (memb_type) != POINTER_TYPE)
    7943                 :           0 :             continue;
    7944                 :             : 
    7945                 :          26 :           if (coder == POINTER_TYPE)
    7946                 :             :             {
    7947                 :          26 :               tree ttl = TREE_TYPE (memb_type);
    7948                 :          26 :               tree ttr = TREE_TYPE (rhstype);
    7949                 :             : 
    7950                 :             :               /* Any non-function converts to a [const][volatile] void *
    7951                 :             :                  and vice versa; otherwise, targets must be the same.
    7952                 :             :                  Meanwhile, the lhs target must have all the qualifiers of
    7953                 :             :                  the rhs.  */
    7954                 :           0 :               if ((VOID_TYPE_P (ttl) && !TYPE_ATOMIC (ttl))
    7955                 :          26 :                   || (VOID_TYPE_P (ttr) && !TYPE_ATOMIC (ttr))
    7956                 :          45 :                   || comp_target_types (location, memb_type, rhstype))
    7957                 :             :                 {
    7958                 :          16 :                   int lquals = TYPE_QUALS (ttl) & ~TYPE_QUAL_ATOMIC;
    7959                 :          16 :                   int rquals = TYPE_QUALS (ttr) & ~TYPE_QUAL_ATOMIC;
    7960                 :             :                   /* If this type won't generate any warnings, use it.  */
    7961                 :          16 :                   if (lquals == rquals
    7962                 :          16 :                       || ((TREE_CODE (ttr) == FUNCTION_TYPE
    7963                 :           0 :                            && TREE_CODE (ttl) == FUNCTION_TYPE)
    7964                 :           0 :                           ? ((lquals | rquals) == rquals)
    7965                 :          16 :                           : ((lquals | rquals) == lquals)))
    7966                 :             :                     break;
    7967                 :             : 
    7968                 :             :                   /* Keep looking for a better type, but remember this one.  */
    7969                 :           0 :                   if (!marginal_memb)
    7970                 :          10 :                     marginal_memb = memb;
    7971                 :             :                 }
    7972                 :             :             }
    7973                 :             : 
    7974                 :             :           /* Can convert integer zero to any pointer type.  */
    7975                 :          10 :           if (null_pointer_constant)
    7976                 :             :             {
    7977                 :           0 :               rhs = null_pointer_node;
    7978                 :           0 :               break;
    7979                 :             :             }
    7980                 :             :         }
    7981                 :             : 
    7982                 :          38 :       if (memb || marginal_memb)
    7983                 :             :         {
    7984                 :          38 :           if (!memb)
    7985                 :             :             {
    7986                 :             :               /* We have only a marginally acceptable member type;
    7987                 :             :                  it needs a warning.  */
    7988                 :           0 :               tree ttl = TREE_TYPE (TREE_TYPE (marginal_memb));
    7989                 :           0 :               tree ttr = TREE_TYPE (rhstype);
    7990                 :             : 
    7991                 :             :               /* Const and volatile mean something different for function
    7992                 :             :                  types, so the usual warnings are not appropriate.  */
    7993                 :           0 :               if (TREE_CODE (ttr) == FUNCTION_TYPE
    7994                 :           0 :                   && TREE_CODE (ttl) == FUNCTION_TYPE)
    7995                 :             :                 {
    7996                 :             :                   /* Because const and volatile on functions are
    7997                 :             :                      restrictions that say the function will not do
    7998                 :             :                      certain things, it is okay to use a const or volatile
    7999                 :             :                      function where an ordinary one is wanted, but not
    8000                 :             :                      vice-versa.  */
    8001                 :           0 :                   if (TYPE_QUALS_NO_ADDR_SPACE (ttl)
    8002                 :           0 :                       & ~TYPE_QUALS_NO_ADDR_SPACE (ttr))
    8003                 :           0 :                     PEDWARN_FOR_QUALIFIERS (location, expr_loc,
    8004                 :             :                                             OPT_Wdiscarded_qualifiers,
    8005                 :             :                                             G_("passing argument %d of %qE "
    8006                 :             :                                                "makes %q#v qualified function "
    8007                 :             :                                                "pointer from unqualified"),
    8008                 :             :                                             G_("assignment makes %q#v qualified "
    8009                 :             :                                                "function pointer from "
    8010                 :             :                                                "unqualified"),
    8011                 :             :                                             G_("initialization makes %q#v qualified "
    8012                 :             :                                                "function pointer from "
    8013                 :             :                                                "unqualified"),
    8014                 :             :                                             G_("return makes %q#v qualified function "
    8015                 :             :                                                "pointer from unqualified"),
    8016                 :             :                                             TYPE_QUALS (ttl) & ~TYPE_QUALS (ttr));
    8017                 :             :                 }
    8018                 :           0 :               else if (TYPE_QUALS_NO_ADDR_SPACE (ttr)
    8019                 :           0 :                        & ~TYPE_QUALS_NO_ADDR_SPACE (ttl))
    8020                 :           0 :                 PEDWARN_FOR_QUALIFIERS (location, expr_loc,
    8021                 :             :                                         OPT_Wdiscarded_qualifiers,
    8022                 :             :                                         G_("passing argument %d of %qE discards "
    8023                 :             :                                            "%qv qualifier from pointer target type"),
    8024                 :             :                                         G_("assignment discards %qv qualifier "
    8025                 :             :                                            "from pointer target type"),
    8026                 :             :                                         G_("initialization discards %qv qualifier "
    8027                 :             :                                            "from pointer target type"),
    8028                 :             :                                         G_("return discards %qv qualifier from "
    8029                 :             :                                            "pointer target type"),
    8030                 :             :                                         TYPE_QUALS (ttr) & ~TYPE_QUALS (ttl));
    8031                 :             : 
    8032                 :             :               memb = marginal_memb;
    8033                 :             :             }
    8034                 :             : 
    8035                 :          38 :           if (!fundecl || !DECL_IN_SYSTEM_HEADER (fundecl))
    8036                 :          30 :             pedwarn (location, OPT_Wpedantic,
    8037                 :             :                      "ISO C prohibits argument conversion to union type");
    8038                 :             : 
    8039                 :          38 :           rhs = fold_convert_loc (location, TREE_TYPE (memb), rhs);
    8040                 :          38 :           return build_constructor_single (type, memb, rhs);
    8041                 :             :         }
    8042                 :             :     }
    8043                 :             : 
    8044                 :             :   /* Conversions among pointers */
    8045                 :     2046445 :   else if ((codel == POINTER_TYPE || codel == REFERENCE_TYPE)
    8046                 :     2045179 :            && (coder == codel))
    8047                 :             :     {
    8048                 :             :       /* If RHS refers to a built-in declared without a prototype
    8049                 :             :          BLTIN is the declaration of the built-in with a prototype
    8050                 :             :          and RHSTYPE is set to the actual type of the built-in.  */
    8051                 :     1967775 :       tree bltin;
    8052                 :     1967775 :       rhstype = type_or_builtin_type (rhs, &bltin);
    8053                 :             : 
    8054                 :     1967775 :       tree ttl = TREE_TYPE (type);
    8055                 :     1967775 :       tree ttr = TREE_TYPE (rhstype);
    8056                 :     1967775 :       tree mvl = ttl;
    8057                 :     1967775 :       tree mvr = ttr;
    8058                 :     1967775 :       bool is_opaque_pointer;
    8059                 :     1967775 :       bool target_cmp = false;   /* Cache comp_target_types () result.  */
    8060                 :     1967775 :       addr_space_t asl;
    8061                 :     1967775 :       addr_space_t asr;
    8062                 :             : 
    8063                 :     1967775 :       if (TREE_CODE (mvl) != ARRAY_TYPE)
    8064                 :     1967048 :         mvl = (TYPE_ATOMIC (mvl)
    8065                 :     3934001 :                ? c_build_qualified_type (TYPE_MAIN_VARIANT (mvl),
    8066                 :             :                                          TYPE_QUAL_ATOMIC)
    8067                 :     1966953 :                : TYPE_MAIN_VARIANT (mvl));
    8068                 :     1967775 :       if (TREE_CODE (mvr) != ARRAY_TYPE)
    8069                 :     1965646 :         mvr = (TYPE_ATOMIC (mvr)
    8070                 :     3916237 :                ? c_build_qualified_type (TYPE_MAIN_VARIANT (mvr),
    8071                 :             :                                          TYPE_QUAL_ATOMIC)
    8072                 :     1950591 :                : TYPE_MAIN_VARIANT (mvr));
    8073                 :             :       /* Opaque pointers are treated like void pointers.  */
    8074                 :     1967775 :       is_opaque_pointer = vector_targets_convertible_p (ttl, ttr);
    8075                 :             : 
    8076                 :             :       /* The Plan 9 compiler permits a pointer to a struct to be
    8077                 :             :          automatically converted into a pointer to an anonymous field
    8078                 :             :          within the struct.  */
    8079                 :     1967775 :       if (flag_plan9_extensions
    8080                 :          10 :           && RECORD_OR_UNION_TYPE_P (mvl)
    8081                 :          10 :           && RECORD_OR_UNION_TYPE_P (mvr)
    8082                 :          10 :           && mvl != mvr)
    8083                 :             :         {
    8084                 :          10 :           tree new_rhs = convert_to_anonymous_field (location, type, rhs);
    8085                 :          10 :           if (new_rhs != NULL_TREE)
    8086                 :             :             {
    8087                 :           6 :               rhs = new_rhs;
    8088                 :           6 :               rhstype = TREE_TYPE (rhs);
    8089                 :           6 :               coder = TREE_CODE (rhstype);
    8090                 :           6 :               ttr = TREE_TYPE (rhstype);
    8091                 :           6 :               mvr = TYPE_MAIN_VARIANT (ttr);
    8092                 :             :             }
    8093                 :             :         }
    8094                 :             : 
    8095                 :             :       /* C++ does not allow the implicit conversion void* -> T*.  However,
    8096                 :             :          for the purpose of reducing the number of false positives, we
    8097                 :             :          tolerate the special case of
    8098                 :             : 
    8099                 :             :                 int *p = NULL;
    8100                 :             : 
    8101                 :             :          where NULL is typically defined in C to be '(void *) 0'.  */
    8102                 :     1967775 :       if (VOID_TYPE_P (ttr) && rhs != null_pointer_node && !VOID_TYPE_P (ttl))
    8103                 :       26223 :         warning_at (errtype == ic_argpass ? expr_loc : location,
    8104                 :             :                     OPT_Wc___compat,
    8105                 :             :                     "request for implicit conversion "
    8106                 :             :                     "from %qT to %qT not permitted in C++", rhstype, type);
    8107                 :             : 
    8108                 :             :       /* Warn of new allocations that are not big enough for the target
    8109                 :             :          type.  */
    8110                 :     1967775 :       if (warn_alloc_size && TREE_CODE (rhs) == CALL_EXPR)
    8111                 :        5397 :         if (tree fndecl = get_callee_fndecl (rhs))
    8112                 :        5397 :           if (DECL_IS_MALLOC (fndecl))
    8113                 :             :             {
    8114                 :        4545 :               tree attrs = TYPE_ATTRIBUTES (TREE_TYPE (fndecl));
    8115                 :        4545 :               tree alloc_size = lookup_attribute ("alloc_size", attrs);
    8116                 :        4545 :               if (alloc_size)
    8117                 :         439 :                 warn_for_alloc_size (location, ttl, rhs, alloc_size);
    8118                 :             :             }
    8119                 :             : 
    8120                 :             :       /* See if the pointers point to incompatible address spaces.  */
    8121                 :     1967775 :       asl = TYPE_ADDR_SPACE (ttl);
    8122                 :     1967775 :       asr = TYPE_ADDR_SPACE (ttr);
    8123                 :     1967775 :       if (!null_pointer_constant_p (rhs)
    8124                 :     1967775 :           && asr != asl && !targetm.addr_space.subset_p (asr, asl))
    8125                 :             :         {
    8126                 :           3 :           auto_diagnostic_group d;
    8127                 :           3 :           bool diagnosed = true;
    8128                 :           3 :           switch (errtype)
    8129                 :             :             {
    8130                 :           1 :             case ic_argpass:
    8131                 :           1 :               {
    8132                 :           1 :                 const char msg[] = G_("passing argument %d of %qE from "
    8133                 :             :                                       "pointer to non-enclosed address space");
    8134                 :           1 :                 if (warnopt)
    8135                 :           0 :                   diagnosed
    8136                 :           0 :                     = warning_at (expr_loc, warnopt, msg, parmnum, rname);
    8137                 :             :                 else
    8138                 :           1 :                   error_at (expr_loc, msg, parmnum, rname);
    8139                 :           0 :               break;
    8140                 :             :               }
    8141                 :           0 :             case ic_assign:
    8142                 :           0 :               {
    8143                 :           0 :                 const char msg[] = G_("assignment from pointer to "
    8144                 :             :                                       "non-enclosed address space");
    8145                 :           0 :                 if (warnopt)
    8146                 :           0 :                   diagnosed = warning_at (location, warnopt, msg);
    8147                 :             :                 else
    8148                 :           0 :                   error_at (location, msg);
    8149                 :           0 :                 break;
    8150                 :             :               }
    8151                 :           0 :             case ic_init:
    8152                 :           0 :             case ic_init_const:
    8153                 :           0 :               {
    8154                 :           0 :                 const char msg[] = G_("initialization from pointer to "
    8155                 :             :                                       "non-enclosed address space");
    8156                 :           0 :                 if (warnopt)
    8157                 :           0 :                   diagnosed = warning_at (location, warnopt, msg);
    8158                 :             :                 else
    8159                 :           0 :                   error_at (location, msg);
    8160                 :           0 :                 break;
    8161                 :             :               }
    8162                 :           2 :             case ic_return:
    8163                 :           2 :               {
    8164                 :           2 :                 const char msg[] = G_("return from pointer to "
    8165                 :             :                                       "non-enclosed address space");
    8166                 :           2 :                 if (warnopt)
    8167                 :           0 :                   diagnosed = warning_at (location, warnopt, msg);
    8168                 :             :                 else
    8169                 :           2 :                   error_at (location, msg);
    8170                 :           0 :                 break;
    8171                 :             :               }
    8172                 :           0 :             default:
    8173                 :           0 :               gcc_unreachable ();
    8174                 :             :             }
    8175                 :           3 :           if (diagnosed)
    8176                 :             :             {
    8177                 :           3 :               if (errtype == ic_argpass)
    8178                 :           1 :                 inform_for_arg (fundecl, expr_loc, parmnum, type, rhstype);
    8179                 :             :               else
    8180                 :           2 :                 inform (location, "expected %qT but pointer is of type %qT",
    8181                 :             :                         type, rhstype);
    8182                 :             :             }
    8183                 :           3 :           return error_mark_node;
    8184                 :           3 :         }
    8185                 :             : 
    8186                 :             :       /* Check if the right-hand side has a format attribute but the
    8187                 :             :          left-hand side doesn't.  */
    8188                 :     1967772 :       if (warn_suggest_attribute_format
    8189                 :     1967772 :           && check_missing_format_attribute (type, rhstype))
    8190                 :             :         {
    8191                 :          16 :           switch (errtype)
    8192                 :             :           {
    8193                 :           4 :           case ic_argpass:
    8194                 :           4 :             warning_at (expr_loc, OPT_Wsuggest_attribute_format,
    8195                 :             :                         "argument %d of %qE might be "
    8196                 :             :                         "a candidate for a format attribute",
    8197                 :             :                         parmnum, rname);
    8198                 :           4 :             break;
    8199                 :           4 :           case ic_assign:
    8200                 :           4 :             warning_at (location, OPT_Wsuggest_attribute_format,
    8201                 :             :                         "assignment left-hand side might be "
    8202                 :             :                         "a candidate for a format attribute");
    8203                 :           4 :             break;
    8204                 :           4 :           case ic_init:
    8205                 :           4 :           case ic_init_const:
    8206                 :           4 :             warning_at (location, OPT_Wsuggest_attribute_format,
    8207                 :             :                         "initialization left-hand side might be "
    8208                 :             :                         "a candidate for a format attribute");
    8209                 :           4 :             break;
    8210                 :           4 :           case ic_return:
    8211                 :           4 :             warning_at (location, OPT_Wsuggest_attribute_format,
    8212                 :             :                         "return type might be "
    8213                 :             :                         "a candidate for a format attribute");
    8214                 :           4 :             break;
    8215                 :           0 :           default:
    8216                 :           0 :             gcc_unreachable ();
    8217                 :             :           }
    8218                 :             :         }
    8219                 :             : 
    8220                 :             :       /* See if the pointers point to incompatible scalar storage orders.  */
    8221                 :     1967772 :       if (warn_scalar_storage_order
    8222                 :     1964856 :           && !null_pointer_constant_p (rhs)
    8223                 :     5832588 :           && (AGGREGATE_TYPE_P (ttl) && TYPE_REVERSE_STORAGE_ORDER (ttl))
    8224                 :     1932408 :              != (AGGREGATE_TYPE_P (ttr) && TYPE_REVERSE_STORAGE_ORDER (ttr)))
    8225                 :             :         {
    8226                 :          18 :           tree t;
    8227                 :             : 
    8228                 :          18 :           switch (errtype)
    8229                 :             :           {
    8230                 :          11 :           case ic_argpass:
    8231                 :             :             /* Do not warn for built-in functions, for example memcpy, since we
    8232                 :             :                control how they behave and they can be useful in this area.  */
    8233                 :          11 :             if (TREE_CODE (rname) != FUNCTION_DECL
    8234                 :          11 :                 || !fndecl_built_in_p (rname))
    8235                 :           1 :               warning_at (location, OPT_Wscalar_storage_order,
    8236                 :             :                           "passing argument %d of %qE from incompatible "
    8237                 :             :                           "scalar storage order", parmnum, rname);
    8238                 :             :             break;
    8239                 :           3 :           case ic_assign:
    8240                 :             :             /* Do not warn if the RHS is a call to a function that returns a
    8241                 :             :                pointer that is not an alias.  */
    8242                 :           3 :             if (TREE_CODE (rhs) != CALL_EXPR
    8243                 :           2 :                 || (t = get_callee_fndecl (rhs)) == NULL_TREE
    8244                 :           5 :                 || !DECL_IS_MALLOC (t))
    8245                 :           1 :               warning_at (location, OPT_Wscalar_storage_order,
    8246                 :             :                           "assignment to %qT from pointer type %qT with "
    8247                 :             :                           "incompatible scalar storage order", type, rhstype);
    8248                 :             :             break;
    8249                 :           3 :           case ic_init:
    8250                 :           3 :           case ic_init_const:
    8251                 :             :             /* Likewise.  */
    8252                 :           3 :             if (TREE_CODE (rhs) != CALL_EXPR
    8253                 :           2 :                 || (t = get_callee_fndecl (rhs)) == NULL_TREE
    8254                 :           5 :                 || !DECL_IS_MALLOC (t))
    8255                 :           1 :               warning_at (location, OPT_Wscalar_storage_order,
    8256                 :             :                           "initialization of %qT from pointer type %qT with "
    8257                 :             :                           "incompatible scalar storage order", type, rhstype);
    8258                 :             :             break;
    8259                 :           1 :           case ic_return:
    8260                 :           1 :             warning_at (location, OPT_Wscalar_storage_order,
    8261                 :             :                         "returning %qT from pointer type with incompatible "
    8262                 :             :                         "scalar storage order %qT", rhstype, type);
    8263                 :           1 :             break;
    8264                 :           0 :           default:
    8265                 :           0 :             gcc_unreachable ();
    8266                 :             :           }
    8267                 :             :         }
    8268                 :             : 
    8269                 :             :       /* Any non-function converts to a [const][volatile] void *
    8270                 :             :          and vice versa; otherwise, targets must be the same.
    8271                 :             :          Meanwhile, the lhs target must have all the qualifiers of the rhs.  */
    8272                 :      405033 :       if ((VOID_TYPE_P (ttl) && !TYPE_ATOMIC (ttl))
    8273                 :     1562740 :           || (VOID_TYPE_P (ttr) && !TYPE_ATOMIC (ttr))
    8274                 :     1516458 :           || (target_cmp = comp_target_types (location, type, rhstype))
    8275                 :        1989 :           || is_opaque_pointer
    8276                 :     1971750 :           || ((c_common_unsigned_type (mvl)
    8277                 :        1989 :                == c_common_unsigned_type (mvr))
    8278                 :        2458 :               && (c_common_signed_type (mvl)
    8279                 :        1229 :                   == c_common_signed_type (mvr))
    8280                 :        1214 :               && TYPE_ATOMIC (mvl) == TYPE_ATOMIC (mvr)))
    8281                 :             :         {
    8282                 :             :           /* Warn about loss of qualifers from pointers to arrays with
    8283                 :             :              qualifiers on the element type. */
    8284                 :     1966989 :           if (TREE_CODE (ttr) == ARRAY_TYPE)
    8285                 :             :             {
    8286                 :        2078 :               ttr = strip_array_types (ttr);
    8287                 :        2078 :               ttl = strip_array_types (ttl);
    8288                 :             : 
    8289                 :        2078 :               if (TYPE_QUALS_NO_ADDR_SPACE_NO_ATOMIC (ttr)
    8290                 :        2078 :                   & ~TYPE_QUALS_NO_ADDR_SPACE_NO_ATOMIC (ttl))
    8291                 :         115 :                 WARNING_FOR_QUALIFIERS (flag_isoc23,
    8292                 :             :                                         location, expr_loc,
    8293                 :             :                                         OPT_Wdiscarded_array_qualifiers,
    8294                 :             :                                         G_("passing argument %d of %qE discards "
    8295                 :             :                                            "%qv qualifier from pointer target type"),
    8296                 :             :                                         G_("assignment discards %qv qualifier "
    8297                 :             :                                            "from pointer target type"),
    8298                 :             :                                         G_("initialization discards %qv qualifier "
    8299                 :             :                                            "from pointer target type"),
    8300                 :             :                                         G_("return discards %qv qualifier from "
    8301                 :             :                                            "pointer target type"),
    8302                 :             :                                         TYPE_QUALS (ttr) & ~TYPE_QUALS (ttl));
    8303                 :             :             }
    8304                 :     1964911 :           else if (pedantic
    8305                 :      145910 :               && ((VOID_TYPE_P (ttl) && TREE_CODE (ttr) == FUNCTION_TYPE)
    8306                 :      145890 :                   ||
    8307                 :             :                   (VOID_TYPE_P (ttr)
    8308                 :        2941 :                    && !null_pointer_constant
    8309                 :         177 :                    && TREE_CODE (ttl) == FUNCTION_TYPE)))
    8310                 :          34 :             PEDWARN_FOR_ASSIGNMENT (location, expr_loc, OPT_Wpedantic,
    8311                 :             :                                     G_("ISO C forbids passing argument %d of "
    8312                 :             :                                        "%qE between function pointer "
    8313                 :             :                                        "and %<void *%>"),
    8314                 :             :                                     G_("ISO C forbids assignment between "
    8315                 :             :                                        "function pointer and %<void *%>"),
    8316                 :             :                                     G_("ISO C forbids initialization between "
    8317                 :             :                                        "function pointer and %<void *%>"),
    8318                 :             :                                     G_("ISO C forbids return between function "
    8319                 :             :                                        "pointer and %<void *%>"));
    8320                 :             :           /* Const and volatile mean something different for function types,
    8321                 :             :              so the usual warnings are not appropriate.  */
    8322                 :     1964877 :           else if (TREE_CODE (ttr) != FUNCTION_TYPE
    8323                 :     1932494 :                    && TREE_CODE (ttl) != FUNCTION_TYPE)
    8324                 :             :             {
    8325                 :             :                /* Assignments between atomic and non-atomic objects are OK.  */
    8326                 :     1931869 :                bool warn_quals_ped = TYPE_QUALS_NO_ADDR_SPACE_NO_ATOMIC (ttr)
    8327                 :     1931869 :                                      & ~TYPE_QUALS_NO_ADDR_SPACE_NO_ATOMIC (ttl);
    8328                 :     1931869 :                bool warn_quals = TYPE_QUALS_NO_ADDR_SPACE_NO_ATOMIC (ttr)
    8329                 :     1931869 :                                  & ~TYPE_QUALS_NO_ADDR_SPACE_NO_ATOMIC (strip_array_types (ttl));
    8330                 :             : 
    8331                 :             :               /* Don't warn about loss of qualifier for conversions from
    8332                 :             :                  qualified void* to pointers to arrays with corresponding
    8333                 :             :                  qualifier on the element type (except for pedantic before C23). */
    8334                 :     1931869 :               if (warn_quals || (warn_quals_ped && pedantic && !flag_isoc23))
    8335                 :         697 :                 PEDWARN_FOR_QUALIFIERS (location, expr_loc,
    8336                 :             :                                         OPT_Wdiscarded_qualifiers,
    8337                 :             :                                         G_("passing argument %d of %qE discards "
    8338                 :             :                                            "%qv qualifier from pointer target type"),
    8339                 :             :                                         G_("assignment discards %qv qualifier "
    8340                 :             :                                            "from pointer target type"),
    8341                 :             :                                         G_("initialization discards %qv qualifier "
    8342                 :             :                                            "from pointer target type"),
    8343                 :             :                                         G_("return discards %qv qualifier from "
    8344                 :             :                                            "pointer target type"),
    8345                 :             :                                         TYPE_QUALS (ttr) & ~TYPE_QUALS (ttl));
    8346                 :          11 :               else if (warn_quals_ped)
    8347                 :          11 :                 pedwarn_c11 (location, OPT_Wc11_c23_compat,
    8348                 :             :                              "array with qualifier on the element is not qualified before C23");
    8349                 :             : 
    8350                 :             :               /* If this is not a case of ignoring a mismatch in signedness,
    8351                 :             :                  no warning.  */
    8352                 :     1931161 :               else if (VOID_TYPE_P (ttl) || VOID_TYPE_P (ttr)
    8353                 :     1511606 :                        || target_cmp)
    8354                 :             :                 ;
    8355                 :             :               /* If there is a mismatch, do warn.  */
    8356                 :        1206 :               else if (warn_pointer_sign)
    8357                 :          82 :                 switch (errtype)
    8358                 :             :                   {
    8359                 :          33 :                   case ic_argpass:
    8360                 :          33 :                     {
    8361                 :          33 :                       auto_diagnostic_group d;
    8362                 :          33 :                       range_label_for_type_mismatch rhs_label (rhstype, type);
    8363                 :          33 :                       gcc_rich_location richloc (expr_loc, &rhs_label,
    8364                 :          33 :                                                  highlight_colors::actual);
    8365                 :          33 :                       if (pedwarn (&richloc, OPT_Wpointer_sign,
    8366                 :             :                                    "pointer targets in passing argument %d of "
    8367                 :             :                                    "%qE differ in signedness", parmnum, rname))
    8368                 :          33 :                         inform_for_arg (fundecl, expr_loc, parmnum, type,
    8369                 :             :                                         rhstype);
    8370                 :          33 :                     }
    8371                 :          33 :                     break;
    8372                 :          21 :                   case ic_assign:
    8373                 :          21 :                     pedwarn (location, OPT_Wpointer_sign,
    8374                 :             :                              "pointer targets in assignment from %qT to %qT "
    8375                 :             :                              "differ in signedness", rhstype, type);
    8376                 :          21 :                     break;
    8377                 :          14 :                   case ic_init:
    8378                 :          14 :                   case ic_init_const:
    8379                 :          14 :                     pedwarn_init (location, OPT_Wpointer_sign,
    8380                 :             :                                   "pointer targets in initialization of %qT "
    8381                 :             :                                   "from %qT differ in signedness", type,
    8382                 :             :                                   rhstype);
    8383                 :          14 :                     break;
    8384                 :          14 :                   case ic_return:
    8385                 :          14 :                     pedwarn (location, OPT_Wpointer_sign, "pointer targets in "
    8386                 :             :                              "returning %qT from a function with return type "
    8387                 :             :                              "%qT differ in signedness", rhstype, type);
    8388                 :          14 :                     break;
    8389                 :           0 :                   default:
    8390                 :           0 :                     gcc_unreachable ();
    8391                 :             :                   }
    8392                 :             :             }
    8393                 :       33008 :           else if (TREE_CODE (ttl) == FUNCTION_TYPE
    8394                 :        4049 :                    && TREE_CODE (ttr) == FUNCTION_TYPE)
    8395                 :             :             {
    8396                 :             :               /* Because const and volatile on functions are restrictions
    8397                 :             :                  that say the function will not do certain things,
    8398                 :             :                  it is okay to use a const or volatile function
    8399                 :             :                  where an ordinary one is wanted, but not vice-versa.  */
    8400                 :        3424 :               if (TYPE_QUALS_NO_ADDR_SPACE (ttl)
    8401                 :        3424 :                   & ~TYPE_QUALS_NO_ADDR_SPACE (ttr))
    8402                 :          18 :                 PEDWARN_FOR_QUALIFIERS (location, expr_loc,
    8403                 :             :                                         OPT_Wdiscarded_qualifiers,
    8404                 :             :                                         G_("passing argument %d of %qE makes "
    8405                 :             :                                            "%q#v qualified function pointer "
    8406                 :             :                                            "from unqualified"),
    8407                 :             :                                         G_("assignment makes %q#v qualified function "
    8408                 :             :                                            "pointer from unqualified"),
    8409                 :             :                                         G_("initialization makes %q#v qualified "
    8410                 :             :                                            "function pointer from unqualified"),
    8411                 :             :                                         G_("return makes %q#v qualified function "
    8412                 :             :                                            "pointer from unqualified"),
    8413                 :             :                                         TYPE_QUALS (ttl) & ~TYPE_QUALS (ttr));
    8414                 :             :             }
    8415                 :             :         }
    8416                 :             :       /* Avoid warning about the volatile ObjC EH puts on decls.  */
    8417                 :         783 :       else if (!objc_ok)
    8418                 :             :         {
    8419                 :         783 :           switch (errtype)
    8420                 :             :             {
    8421                 :         299 :             case ic_argpass:
    8422                 :         299 :               {
    8423                 :         299 :                 auto_diagnostic_group d;
    8424                 :         299 :                 range_label_for_type_mismatch rhs_label (rhstype, type);
    8425                 :         299 :                 gcc_rich_location richloc (expr_loc, &rhs_label,
    8426                 :         299 :                                            highlight_colors::actual);
    8427                 :         299 :                 if (permerror_opt (&richloc, OPT_Wincompatible_pointer_types,
    8428                 :             :                                    "passing argument %d of %qE from "
    8429                 :             :                                    "incompatible pointer type",
    8430                 :             :                                    parmnum, rname))
    8431                 :         167 :                   inform_for_arg (fundecl, expr_loc, parmnum, type, rhstype);
    8432                 :         299 :               }
    8433                 :         299 :               break;
    8434                 :         264 :             case ic_assign:
    8435                 :         264 :               if (bltin)
    8436                 :          11 :                 permerror_opt (location, OPT_Wincompatible_pointer_types,
    8437                 :             :                                "assignment to %qT from pointer to "
    8438                 :             :                                "%qD with incompatible type %qT",
    8439                 :             :                                type, bltin, rhstype);
    8440                 :             :               else
    8441                 :         253 :                 permerror_opt (location, OPT_Wincompatible_pointer_types,
    8442                 :             :                                "assignment to %qT from incompatible pointer "
    8443                 :             :                                "type %qT", type, rhstype);
    8444                 :             :               break;
    8445                 :         163 :             case ic_init:
    8446                 :         163 :             case ic_init_const:
    8447                 :         163 :               if (bltin)
    8448                 :          13 :                 permerror_init (location, OPT_Wincompatible_pointer_types,
    8449                 :             :                                 "initialization of %qT from pointer to "
    8450                 :             :                                 "%qD with incompatible type %qT",
    8451                 :             :                                 type, bltin, rhstype);
    8452                 :             :               else
    8453                 :         150 :                 permerror_init (location, OPT_Wincompatible_pointer_types,
    8454                 :             :                                 "initialization of %qT from incompatible "
    8455                 :             :                                 "pointer type %qT",
    8456                 :             :                                 type, rhstype);
    8457                 :             :               break;
    8458                 :          57 :             case ic_return:
    8459                 :          57 :               if (bltin)
    8460                 :          11 :                 permerror_opt (location, OPT_Wincompatible_pointer_types,
    8461                 :             :                                "returning pointer to %qD of type %qT from "
    8462                 :             :                                "a function with incompatible type %qT",
    8463                 :             :                                bltin, rhstype, type);
    8464                 :             :               else
    8465                 :          46 :                 permerror_opt (location, OPT_Wincompatible_pointer_types,
    8466                 :             :                                "returning %qT from a function with "
    8467                 :             :                                "incompatible return type %qT", rhstype, type);
    8468                 :             :               break;
    8469                 :           0 :             default:
    8470                 :           0 :               gcc_unreachable ();
    8471                 :             :             }
    8472                 :             :         }
    8473                 :             : 
    8474                 :             :       /* If RHS isn't an address, check pointer or array of packed
    8475                 :             :          struct or union.  */
    8476                 :     1967772 :       warn_for_address_of_packed_member (type, orig_rhs);
    8477                 :             : 
    8478                 :     1967772 :       return convert (type, rhs);
    8479                 :             :     }
    8480                 :       78670 :   else if (codel == POINTER_TYPE && coder == ARRAY_TYPE)
    8481                 :             :     {
    8482                 :             :       /* ??? This should not be an error when inlining calls to
    8483                 :             :          unprototyped functions.  */
    8484                 :           4 :       const char msg[] = "invalid use of non-lvalue array";
    8485                 :           4 :       if (warnopt)
    8486                 :           0 :         warning_at (location, warnopt, msg);
    8487                 :             :       else
    8488                 :           4 :         error_at (location, msg);
    8489                 :           4 :       return error_mark_node;
    8490                 :             :     }
    8491                 :       78666 :   else if (codel == POINTER_TYPE
    8492                 :       77400 :            && (coder == INTEGER_TYPE
    8493                 :       77400 :                || coder == ENUMERAL_TYPE
    8494                 :         591 :                || coder == BOOLEAN_TYPE
    8495                 :         591 :                || coder == NULLPTR_TYPE
    8496                 :          20 :                || coder == BITINT_TYPE))
    8497                 :             :     {
    8498                 :       77392 :       if (null_pointer_constant && c_inhibit_evaluation_warnings == 0
    8499                 :       76394 :           && coder == INTEGER_TYPE)
    8500                 :       75806 :         warning_at (location, OPT_Wzero_as_null_pointer_constant,
    8501                 :             :                     "zero as null pointer constant");
    8502                 :             : 
    8503                 :             :       /* An explicit constant 0 or type nullptr_t can convert to a pointer,
    8504                 :             :          or one that results from arithmetic, even including a cast to
    8505                 :             :          integer type.  */
    8506                 :       77392 :       if (!null_pointer_constant && coder != NULLPTR_TYPE)
    8507                 :         972 :         switch (errtype)
    8508                 :             :           {
    8509                 :         800 :           case ic_argpass:
    8510                 :         800 :             {
    8511                 :         800 :               auto_diagnostic_group d;
    8512                 :         800 :               range_label_for_type_mismatch rhs_label (rhstype, type);
    8513                 :         800 :               gcc_rich_location richloc (expr_loc, &rhs_label,
    8514                 :         800 :                                          highlight_colors::actual);
    8515                 :         800 :               if (permerror_opt (&richloc, OPT_Wint_conversion,
    8516                 :             :                                  "passing argument %d of %qE makes pointer "
    8517                 :             :                                  "from integer without a cast", parmnum, rname))
    8518                 :             :                 {
    8519                 :         439 :                   maybe_emit_indirection_note (expr_loc, rhs, type);
    8520                 :         439 :                   inform_for_arg (fundecl, expr_loc, parmnum, type, rhstype);
    8521                 :             :                 }
    8522                 :         800 :             }
    8523                 :         800 :             break;
    8524                 :          93 :           case ic_assign:
    8525                 :          93 :             permerror_opt (location, OPT_Wint_conversion,
    8526                 :             :                            "assignment to %qT from %qT makes pointer from "
    8527                 :             :                            "integer without a cast", type, rhstype);
    8528                 :          93 :             break;
    8529                 :          56 :           case ic_init:
    8530                 :          56 :           case ic_init_const:
    8531                 :          56 :             permerror_init (location, OPT_Wint_conversion,
    8532                 :             :                             "initialization of %qT from %qT makes pointer "
    8533                 :             :                             "from integer without a cast", type, rhstype);
    8534                 :          56 :             break;
    8535                 :          23 :           case ic_return:
    8536                 :          23 :             permerror_init (location, OPT_Wint_conversion,
    8537                 :             :                             "returning %qT from a function with return type "
    8538                 :             :                             "%qT makes pointer from integer without a cast",
    8539                 :             :                             rhstype, type);
    8540                 :          23 :             break;
    8541                 :           0 :           default:
    8542                 :           0 :             gcc_unreachable ();
    8543                 :             :           }
    8544                 :             : 
    8545                 :       77392 :       return convert (type, rhs);
    8546                 :             :     }
    8547                 :        1274 :   else if ((codel == INTEGER_TYPE || codel == BITINT_TYPE)
    8548                 :         539 :            && coder == POINTER_TYPE)
    8549                 :             :     {
    8550                 :         513 :       switch (errtype)
    8551                 :             :         {
    8552                 :         343 :         case ic_argpass:
    8553                 :         343 :           {
    8554                 :         343 :             auto_diagnostic_group d;
    8555                 :         343 :             range_label_for_type_mismatch rhs_label (rhstype, type);
    8556                 :         343 :             gcc_rich_location richloc (expr_loc, &rhs_label,
    8557                 :         343 :                                        highlight_colors::actual);
    8558                 :         343 :             if (permerror_opt (&richloc, OPT_Wint_conversion,
    8559                 :             :                                "passing argument %d of %qE makes integer from "
    8560                 :             :                                "pointer without a cast", parmnum, rname))
    8561                 :             :               {
    8562                 :         322 :                 maybe_emit_indirection_note (expr_loc, rhs, type);
    8563                 :         322 :                 inform_for_arg (fundecl, expr_loc, parmnum, type, rhstype);
    8564                 :             :               }
    8565                 :         343 :           }
    8566                 :         343 :           break;
    8567                 :          52 :         case ic_assign:
    8568                 :          52 :           permerror_opt (location, OPT_Wint_conversion,
    8569                 :             :                          "assignment to %qT from %qT makes integer from "
    8570                 :             :                          "pointer without a cast", type, rhstype);
    8571                 :          52 :           break;
    8572                 :          83 :         case ic_init:
    8573                 :          83 :         case ic_init_const:
    8574                 :          83 :           permerror_init (location, OPT_Wint_conversion,
    8575                 :             :                           "initialization of %qT from %qT makes integer "
    8576                 :             :                           "from pointer without a cast", type, rhstype);
    8577                 :          83 :           break;
    8578                 :          35 :         case ic_return:
    8579                 :          35 :           permerror_opt (location, OPT_Wint_conversion, "returning %qT from a "
    8580                 :             :                          "function with return type %qT makes integer from "
    8581                 :             :                          "pointer without a cast", rhstype, type);
    8582                 :          35 :           break;
    8583                 :           0 :         default:
    8584                 :           0 :           gcc_unreachable ();
    8585                 :             :         }
    8586                 :             : 
    8587                 :         513 :       return convert (type, rhs);
    8588                 :             :     }
    8589                 :         613 :   else if (C_BOOLEAN_TYPE_P (type)
    8590                 :             :            /* The type nullptr_t may be converted to bool.  The
    8591                 :             :               result is false.  */
    8592                 :         763 :            && (coder == POINTER_TYPE || coder == NULLPTR_TYPE))
    8593                 :             :     {
    8594                 :         150 :       tree ret;
    8595                 :         150 :       bool save = in_late_binary_op;
    8596                 :         150 :       in_late_binary_op = true;
    8597                 :         150 :       ret = convert (type, rhs);
    8598                 :         150 :       in_late_binary_op = save;
    8599                 :         150 :       return ret;
    8600                 :             :     }
    8601                 :         611 :   else if (codel == NULLPTR_TYPE && null_pointer_constant)
    8602                 :           6 :     return convert (type, rhs);
    8603                 :             : 
    8604                 :         605 :   switch (errtype)
    8605                 :             :     {
    8606                 :          35 :     case ic_argpass:
    8607                 :          35 :       {
    8608                 :          35 :         auto_diagnostic_group d;
    8609                 :          35 :         range_label_for_type_mismatch rhs_label (rhstype, type);
    8610                 :          35 :         gcc_rich_location richloc (expr_loc, &rhs_label,
    8611                 :          35 :                                    highlight_colors::actual);
    8612                 :          35 :         const char msg[] = G_("incompatible type for argument %d of %qE");
    8613                 :          35 :         if (warnopt)
    8614                 :           8 :           warning_at (expr_loc, warnopt, msg, parmnum, rname);
    8615                 :             :         else
    8616                 :          27 :           error_at (&richloc, msg, parmnum, rname);
    8617                 :          35 :         inform_for_arg (fundecl, expr_loc, parmnum, type, rhstype);
    8618                 :          35 :       }
    8619                 :          35 :       break;
    8620                 :          97 :     case ic_assign:
    8621                 :          97 :       {
    8622                 :          97 :         const char msg[]
    8623                 :             :           = G_("incompatible types when assigning to type %qT from type %qT");
    8624                 :          97 :         if (warnopt)
    8625                 :           0 :           warning_at (expr_loc, 0, msg, type, rhstype);
    8626                 :             :         else
    8627                 :          97 :           error_at (expr_loc, msg, type, rhstype);
    8628                 :          97 :         break;
    8629                 :             :       }
    8630                 :         458 :     case ic_init:
    8631                 :         458 :     case ic_init_const:
    8632                 :         458 :       {
    8633                 :         458 :         const char msg[]
    8634                 :             :           = G_("incompatible types when initializing type %qT using type %qT");
    8635                 :         458 :         if (warnopt)
    8636                 :           0 :           warning_at (location, 0, msg, type, rhstype);
    8637                 :             :         else
    8638                 :         458 :           error_at (location, msg, type, rhstype);
    8639                 :         458 :         break;
    8640                 :             :       }
    8641                 :          15 :     case ic_return:
    8642                 :          15 :       {
    8643                 :          15 :         const char msg[]
    8644                 :             :           = G_("incompatible types when returning type %qT but %qT was expected");
    8645                 :          15 :         if (warnopt)
    8646                 :           0 :           warning_at (location, 0, msg, rhstype, type);
    8647                 :             :         else
    8648                 :          15 :           error_at (location, msg, rhstype, type);
    8649                 :          15 :         break;
    8650                 :             :       }
    8651                 :           0 :     default:
    8652                 :           0 :       gcc_unreachable ();
    8653                 :             :     }
    8654                 :             : 
    8655                 :         605 :   return error_mark_node;
    8656                 :             : }
    8657                 :             : 
    8658                 :             : /* If VALUE is a compound expr all of whose expressions are constant, then
    8659                 :             :    return its value.  Otherwise, return error_mark_node.
    8660                 :             : 
    8661                 :             :    This is for handling COMPOUND_EXPRs as initializer elements
    8662                 :             :    which is allowed with a warning when -pedantic is specified.  */
    8663                 :             : 
    8664                 :             : static tree
    8665                 :           2 : valid_compound_expr_initializer (tree value, tree endtype)
    8666                 :             : {
    8667                 :           2 :   if (TREE_CODE (value) == COMPOUND_EXPR)
    8668                 :             :     {
    8669                 :           1 :       if (valid_compound_expr_initializer (TREE_OPERAND (value, 0), endtype)
    8670                 :           1 :           == error_mark_node)
    8671                 :             :         return error_mark_node;
    8672                 :           0 :       return valid_compound_expr_initializer (TREE_OPERAND (value, 1),
    8673                 :           0 :                                               endtype);
    8674                 :             :     }
    8675                 :           1 :   else if (!initializer_constant_valid_p (value, endtype))
    8676                 :           1 :     return error_mark_node;
    8677                 :             :   else
    8678                 :             :     return value;
    8679                 :             : }
    8680                 :             : 
    8681                 :             : /* Perform appropriate conversions on the initial value of a variable,
    8682                 :             :    store it in the declaration DECL,
    8683                 :             :    and print any error messages that are appropriate.
    8684                 :             :    If ORIGTYPE is not NULL_TREE, it is the original type of INIT.
    8685                 :             :    If the init is invalid, store an ERROR_MARK.
    8686                 :             : 
    8687                 :             :    INIT_LOC is the location of the initial value.  */
    8688                 :             : 
    8689                 :             : void
    8690                 :     7106779 : store_init_value (location_t init_loc, tree decl, tree init, tree origtype)
    8691                 :             : {
    8692                 :     7106779 :   tree value, type;
    8693                 :     7106779 :   bool npc = false;
    8694                 :     7106779 :   bool int_const_expr = false;
    8695                 :     7106779 :   bool arith_const_expr = false;
    8696                 :             : 
    8697                 :             :   /* If variable's type was invalidly declared, just ignore it.  */
    8698                 :             : 
    8699                 :     7106779 :   type = TREE_TYPE (decl);
    8700                 :     7106779 :   if (TREE_CODE (type) == ERROR_MARK)
    8701                 :             :     return;
    8702                 :             : 
    8703                 :             :   /* Digest the specified initializer into an expression.  */
    8704                 :             : 
    8705                 :     7106772 :   if (init)
    8706                 :             :     {
    8707                 :     7106772 :       npc = null_pointer_constant_p (init);
    8708                 :     7106772 :       int_const_expr = (TREE_CODE (init) == INTEGER_CST
    8709                 :      407379 :                         && !TREE_OVERFLOW (init)
    8710                 :     7514115 :                         && INTEGRAL_TYPE_P (TREE_TYPE (init)));
    8711                 :             :       /* Not fully determined before folding.  */
    8712                 :             :       arith_const_expr = true;
    8713                 :             :     }
    8714                 :     7106772 :   bool constexpr_p = (VAR_P (decl)
    8715                 :     7106772 :                       && C_DECL_DECLARED_CONSTEXPR (decl));
    8716                 :     7106772 :   value = digest_init (init_loc, type, init, origtype, npc, int_const_expr,
    8717                 :             :                        arith_const_expr, true,
    8718                 :     7106772 :                        TREE_STATIC (decl) || constexpr_p, constexpr_p);
    8719                 :             : 
    8720                 :             :   /* Store the expression if valid; else report error.  */
    8721                 :             : 
    8722                 :     7106772 :   if (!in_system_header_at (input_location)
    8723                 :     7106772 :       && AGGREGATE_TYPE_P (TREE_TYPE (decl)) && !TREE_STATIC (decl))
    8724                 :       27151 :     warning (OPT_Wtraditional, "traditional C rejects automatic "
    8725                 :             :              "aggregate initialization");
    8726                 :             : 
    8727                 :     7106772 :   if (value != error_mark_node || TREE_CODE (decl) != FUNCTION_DECL)
    8728                 :     7106771 :     DECL_INITIAL (decl) = value;
    8729                 :             : 
    8730                 :             :   /* ANSI wants warnings about out-of-range constant initializers.  */
    8731                 :     7106783 :   STRIP_TYPE_NOPS (value);
    8732                 :     7106772 :   if (TREE_STATIC (decl))
    8733                 :      179089 :     constant_expression_warning (value);
    8734                 :             : 
    8735                 :             :   /* Check if we need to set array size from compound literal size.  */
    8736                 :     7106772 :   if (TREE_CODE (type) == ARRAY_TYPE
    8737                 :       25738 :       && TYPE_DOMAIN (type) == NULL_TREE
    8738                 :     7119089 :       && value != error_mark_node)
    8739                 :             :     {
    8740                 :             :       tree inside_init = init;
    8741                 :             : 
    8742                 :       11477 :       STRIP_TYPE_NOPS (inside_init);
    8743                 :       11477 :       inside_init = fold (inside_init);
    8744                 :             : 
    8745                 :       11477 :       if (TREE_CODE (inside_init) == COMPOUND_LITERAL_EXPR)
    8746                 :             :         {
    8747                 :          13 :           tree cldecl = COMPOUND_LITERAL_EXPR_DECL (inside_init);
    8748                 :             : 
    8749                 :          13 :           if (TYPE_DOMAIN (TREE_TYPE (cldecl)))
    8750                 :             :             {
    8751                 :             :               /* For int foo[] = (int [3]){1}; we need to set array size
    8752                 :             :                  now since later on array initializer will be just the
    8753                 :             :                  brace enclosed list of the compound literal.  */
    8754                 :          13 :               tree etype = strip_array_types (TREE_TYPE (decl));
    8755                 :          13 :               type = build_distinct_type_copy (TYPE_MAIN_VARIANT (type));
    8756                 :          13 :               TYPE_DOMAIN (type) = TYPE_DOMAIN (TREE_TYPE (cldecl));
    8757                 :          13 :               layout_type (type);
    8758                 :          13 :               layout_decl (cldecl, 0);
    8759                 :          13 :               TREE_TYPE (decl)
    8760                 :          26 :                 = c_build_qualified_type (type, TYPE_QUALS (etype));
    8761                 :             :             }
    8762                 :             :         }
    8763                 :             :     }
    8764                 :             : }
    8765                 :             : 
    8766                 :             : /* Methods for storing and printing names for error messages.  */
    8767                 :             : 
    8768                 :             : /* Implement a spelling stack that allows components of a name to be pushed
    8769                 :             :    and popped.  Each element on the stack is this structure.  */
    8770                 :             : 
    8771                 :             : struct spelling
    8772                 :             : {
    8773                 :             :   int kind;
    8774                 :             :   union
    8775                 :             :     {
    8776                 :             :       unsigned HOST_WIDE_INT i;
    8777                 :             :       const char *s;
    8778                 :             :     } u;
    8779                 :             : };
    8780                 :             : 
    8781                 :             : #define SPELLING_STRING 1
    8782                 :             : #define SPELLING_MEMBER 2
    8783                 :             : #define SPELLING_BOUNDS 3
    8784                 :             : 
    8785                 :             : static struct spelling *spelling;       /* Next stack element (unused).  */
    8786                 :             : static struct spelling *spelling_base;  /* Spelling stack base.  */
    8787                 :             : static int spelling_size;               /* Size of the spelling stack.  */
    8788                 :             : 
    8789                 :             : /* Macros to save and restore the spelling stack around push_... functions.
    8790                 :             :    Alternative to SAVE_SPELLING_STACK.  */
    8791                 :             : 
    8792                 :             : #define SPELLING_DEPTH() (spelling - spelling_base)
    8793                 :             : #define RESTORE_SPELLING_DEPTH(DEPTH) (spelling = spelling_base + (DEPTH))
    8794                 :             : 
    8795                 :             : /* Push an element on the spelling stack with type KIND and assign VALUE
    8796                 :             :    to MEMBER.  */
    8797                 :             : 
    8798                 :             : #define PUSH_SPELLING(KIND, VALUE, MEMBER)                              \
    8799                 :             : {                                                                       \
    8800                 :             :   int depth = SPELLING_DEPTH ();                                        \
    8801                 :             :                                                                         \
    8802                 :             :   if (depth >= spelling_size)                                                \
    8803                 :             :     {                                                                   \
    8804                 :             :       spelling_size += 10;                                              \
    8805                 :             :       spelling_base = XRESIZEVEC (struct spelling, spelling_base,       \
    8806                 :             :                                   spelling_size);                       \
    8807                 :             :       RESTORE_SPELLING_DEPTH (depth);                                   \
    8808                 :             :     }                                                                   \
    8809                 :             :                                                                         \
    8810                 :             :   spelling->kind = (KIND);                                           \
    8811                 :             :   spelling->MEMBER = (VALUE);                                                \
    8812                 :             :   spelling++;                                                           \
    8813                 :             : }
    8814                 :             : 
    8815                 :             : /* Push STRING on the stack.  Printed literally.  */
    8816                 :             : 
    8817                 :             : static void
    8818                 :     7104254 : push_string (const char *string)
    8819                 :             : {
    8820                 :     7104254 :   PUSH_SPELLING (SPELLING_STRING, string, u.s);
    8821                 :     7104254 : }
    8822                 :             : 
    8823                 :             : /* Push a member name on the stack.  Printed as '.' STRING.  */
    8824                 :             : 
    8825                 :             : static void
    8826                 :     1224587 : push_member_name (tree decl)
    8827                 :             : {
    8828                 :     1224587 :   const char *const string
    8829                 :     1224587 :     = (DECL_NAME (decl)
    8830                 :     1224587 :        ? identifier_to_locale (IDENTIFIER_POINTER (DECL_NAME (decl)))
    8831                 :         194 :        : _("<anonymous>"));
    8832                 :     1224587 :   PUSH_SPELLING (SPELLING_MEMBER, string, u.s);
    8833                 :     1224587 : }
    8834                 :             : 
    8835                 :             : /* Push an array bounds on the stack.  Printed as [BOUNDS].  */
    8836                 :             : 
    8837                 :             : static void
    8838                 :     2598875 : push_array_bounds (unsigned HOST_WIDE_INT bounds)
    8839                 :             : {
    8840                 :     2598875 :   PUSH_SPELLING (SPELLING_BOUNDS, bounds, u.i);
    8841                 :     2598875 : }
    8842                 :             : 
    8843                 :             : /* Compute the maximum size in bytes of the printed spelling.  */
    8844                 :             : 
    8845                 :             : static int
    8846                 :        3442 : spelling_length (void)
    8847                 :             : {
    8848                 :        3442 :   int size = 0;
    8849                 :        3442 :   struct spelling *p;
    8850                 :             : 
    8851                 :        7695 :   for (p = spelling_base; p < spelling; p++)
    8852                 :             :     {
    8853                 :        4253 :       if (p->kind == SPELLING_BOUNDS)
    8854                 :        1579 :         size += 25;
    8855                 :             :       else
    8856                 :        2674 :         size += strlen (p->u.s) + 1;
    8857                 :             :     }
    8858                 :             : 
    8859                 :        3442 :   return size;
    8860                 :             : }
    8861                 :             : 
    8862                 :             : /* Print the spelling to BUFFER and return it.  */
    8863                 :             : 
    8864                 :             : static char *
    8865                 :        3442 : print_spelling (char *buffer)
    8866                 :             : {
    8867                 :        3442 :   char *d = buffer;
    8868                 :        3442 :   struct spelling *p;
    8869                 :             : 
    8870                 :        7695 :   for (p = spelling_base; p < spelling; p++)
    8871                 :        4253 :     if (p->kind == SPELLING_BOUNDS)
    8872                 :             :       {
    8873                 :        1579 :         sprintf (d, "[" HOST_WIDE_INT_PRINT_UNSIGNED "]", p->u.i);
    8874                 :        1579 :         d += strlen (d);
    8875                 :             :       }
    8876                 :             :     else
    8877                 :             :       {
    8878                 :        2674 :         const char *s;
    8879                 :        2674 :         if (p->kind == SPELLING_MEMBER)
    8880                 :         517 :           *d++ = '.';
    8881                 :       20236 :         for (s = p->u.s; (*d = *s++); d++)
    8882                 :             :           ;
    8883                 :             :       }
    8884                 :        3442 :   *d++ = '\0';
    8885                 :        3442 :   return buffer;
    8886                 :             : }
    8887                 :             : 
    8888                 :             : /* Check whether INIT, a floating or integer constant, is
    8889                 :             :    representable in TYPE, a real floating type with the same radix or
    8890                 :             :    a decimal floating type initialized with a binary floating
    8891                 :             :    constant.  Return true if OK, false if not.  */
    8892                 :             : static bool
    8893                 :         361 : constexpr_init_fits_real_type (tree type, tree init)
    8894                 :             : {
    8895                 :         361 :   gcc_assert (SCALAR_FLOAT_TYPE_P (type));
    8896                 :         361 :   gcc_assert (TREE_CODE (init) == INTEGER_CST || TREE_CODE (init) == REAL_CST);
    8897                 :         361 :   if (TREE_CODE (init) == REAL_CST
    8898                 :         361 :       && TYPE_MODE (TREE_TYPE (init)) == TYPE_MODE (type))
    8899                 :             :     {
    8900                 :             :       /* Same mode, no conversion required except for the case of
    8901                 :             :          signaling NaNs if the types are incompatible (e.g. double and
    8902                 :             :          long double with the same mode).  */
    8903                 :         176 :       if (REAL_VALUE_ISSIGNALING_NAN (TREE_REAL_CST (init))
    8904                 :         194 :           && !comptypes (TYPE_MAIN_VARIANT (type),
    8905                 :          18 :                          TYPE_MAIN_VARIANT (TREE_TYPE (init))))
    8906                 :             :         return false;
    8907                 :         176 :       return true;
    8908                 :             :     }
    8909                 :         185 :   if (TREE_CODE (init) == INTEGER_CST)
    8910                 :             :     {
    8911                 :          54 :       tree converted = build_real_from_int_cst (type, init);
    8912                 :          54 :       bool fail = false;
    8913                 :         108 :       wide_int w = real_to_integer (&TREE_REAL_CST (converted), &fail,
    8914                 :          54 :                                     TYPE_PRECISION (TREE_TYPE (init)));
    8915                 :          68 :       return !fail && wi::eq_p (w, wi::to_wide (init));
    8916                 :          54 :     }
    8917                 :         131 :   if (REAL_VALUE_ISSIGNALING_NAN (TREE_REAL_CST (init)))
    8918                 :             :     return false;
    8919                 :         114 :   if ((REAL_VALUE_ISINF (TREE_REAL_CST (init))
    8920                 :          34 :        && MODE_HAS_INFINITIES (TYPE_MODE (type)))
    8921                 :         218 :       || (REAL_VALUE_ISNAN (TREE_REAL_CST (init))
    8922                 :          34 :           && MODE_HAS_NANS (TYPE_MODE (type))))
    8923                 :          20 :     return true;
    8924                 :          94 :   if (DECIMAL_FLOAT_TYPE_P (type)
    8925                 :         134 :       && !DECIMAL_FLOAT_TYPE_P (TREE_TYPE (init)))
    8926                 :             :     {
    8927                 :             :       /* This is valid if the real number represented by the
    8928                 :             :          initializer can be exactly represented in the decimal
    8929                 :             :          type.  Compare the values using MPFR.  */
    8930                 :           8 :       REAL_VALUE_TYPE t;
    8931                 :           8 :       real_convert (&t, TYPE_MODE (type), &TREE_REAL_CST (init));
    8932                 :           8 :       mpfr_t bin_val, dec_val;
    8933                 :           8 :       mpfr_init2 (bin_val, REAL_MODE_FORMAT (TYPE_MODE (TREE_TYPE (init)))->p);
    8934                 :           8 :       mpfr_init2 (dec_val, REAL_MODE_FORMAT (TYPE_MODE (TREE_TYPE (init)))->p);
    8935                 :           8 :       mpfr_from_real (bin_val, &TREE_REAL_CST (init), MPFR_RNDN);
    8936                 :           8 :       char string[256];
    8937                 :           8 :       real_to_decimal (string, &t, sizeof string, 0, 1);
    8938                 :           8 :       bool res = (mpfr_strtofr (dec_val, string, NULL, 10, MPFR_RNDN) == 0
    8939                 :           8 :                   && mpfr_equal_p (bin_val, dec_val));
    8940                 :           8 :       mpfr_clear (bin_val);
    8941                 :           8 :       mpfr_clear (dec_val);
    8942                 :           8 :       return res;
    8943                 :             :     }
    8944                 :             :   /* exact_real_truncate is not quite right here, since it doesn't
    8945                 :             :      allow even an exact conversion to subnormal values.  */
    8946                 :          86 :   REAL_VALUE_TYPE t;
    8947                 :          86 :   real_convert (&t, TYPE_MODE (type), &TREE_REAL_CST (init));
    8948                 :          86 :   return real_identical (&t, &TREE_REAL_CST (init));
    8949                 :             : }
    8950                 :             : 
    8951                 :             : /* Check whether INIT (location LOC) is valid as a 'constexpr'
    8952                 :             :    initializer for type TYPE, and give an error if not.  INIT has
    8953                 :             :    already been folded and verified to be constant.  INT_CONST_EXPR
    8954                 :             :    and ARITH_CONST_EXPR say whether it is an integer constant
    8955                 :             :    expression or arithmetic constant expression, respectively.  If
    8956                 :             :    TYPE is not a scalar type, this function does nothing.  */
    8957                 :             : 
    8958                 :             : static void
    8959                 :         881 : check_constexpr_init (location_t loc, tree type, tree init,
    8960                 :             :                       bool int_const_expr, bool arith_const_expr)
    8961                 :             : {
    8962                 :         881 :   if (POINTER_TYPE_P (type))
    8963                 :             :     {
    8964                 :             :       /* The initializer must be null.  */
    8965                 :          86 :       if (TREE_CODE (init) != INTEGER_CST || !integer_zerop (init))
    8966                 :           8 :         error_at (loc, "%<constexpr%> pointer initializer is not null");
    8967                 :          86 :       return;
    8968                 :             :     }
    8969                 :         795 :   if (INTEGRAL_TYPE_P (type))
    8970                 :             :     {
    8971                 :             :       /* The initializer must be an integer constant expression,
    8972                 :             :          representable in the target type.  */
    8973                 :         293 :       if (!int_const_expr)
    8974                 :           9 :         error_at (loc, "%<constexpr%> integer initializer is not an "
    8975                 :             :                   "integer constant expression");
    8976                 :         284 :       else if (!int_fits_type_p (init, type))
    8977                 :           6 :         error_at (loc, "%<constexpr%> initializer not representable in "
    8978                 :             :                   "type of object");
    8979                 :         293 :       return;
    8980                 :             :     }
    8981                 :             :   /* We don't apply any extra checks to extension types such as vector
    8982                 :             :      or fixed-point types.  */
    8983                 :         502 :   if (TREE_CODE (type) != REAL_TYPE && TREE_CODE (type) != COMPLEX_TYPE)
    8984                 :             :     return;
    8985                 :         352 :   if (!arith_const_expr)
    8986                 :             :     {
    8987                 :           5 :       error_at (loc, "%<constexpr%> initializer is not an arithmetic "
    8988                 :             :                 "constant expression");
    8989                 :           5 :       return;
    8990                 :             :     }
    8991                 :             :   /* We don't apply any extra checks to complex integers.  */
    8992                 :         347 :   if (TREE_CODE (type) == COMPLEX_TYPE
    8993                 :         347 :       && TREE_CODE (TREE_TYPE (type)) != REAL_TYPE)
    8994                 :             :     return;
    8995                 :             :   /* Following N3082, a real type cannot be initialized from a complex
    8996                 :             :      type and a binary type cannot be initialized from a decimal type
    8997                 :             :      (but initializing a decimal type from a binary type is OK).
    8998                 :             :      Signaling NaN initializers are OK only if the types are
    8999                 :             :      compatible (not just the same mode); all quiet NaN and infinity
    9000                 :             :      initializations are considered to preserve the value.  */
    9001                 :         347 :   if (TREE_CODE (TREE_TYPE (init)) == COMPLEX_TYPE
    9002                 :         347 :       && SCALAR_FLOAT_TYPE_P (type))
    9003                 :             :     {
    9004                 :           6 :       error_at (loc, "%<constexpr%> initializer for a real type is of "
    9005                 :             :                 "complex type");
    9006                 :           6 :       return;
    9007                 :             :     }
    9008                 :         341 :   if (SCALAR_FLOAT_TYPE_P (type)
    9009                 :         299 :       && SCALAR_FLOAT_TYPE_P (TREE_TYPE (init))
    9010                 :         249 :       && DECIMAL_FLOAT_TYPE_P (TREE_TYPE (init))
    9011                 :         480 :       && !DECIMAL_FLOAT_TYPE_P (type))
    9012                 :             :     {
    9013                 :           6 :       error_at (loc, "%<constexpr%> initializer for a binary "
    9014                 :             :                 "floating-point type is of decimal type");
    9015                 :           6 :       return;
    9016                 :             :     }
    9017                 :         335 :   bool fits;
    9018                 :         335 :   if (TREE_CODE (type) == COMPLEX_TYPE)
    9019                 :             :     {
    9020                 :          42 :       switch (TREE_CODE (init))
    9021                 :             :         {
    9022                 :          10 :         case INTEGER_CST:
    9023                 :          10 :         case REAL_CST:
    9024                 :          10 :           fits = constexpr_init_fits_real_type (TREE_TYPE (type), init);
    9025                 :          10 :           break;
    9026                 :          32 :         case COMPLEX_CST:
    9027                 :          32 :           fits = (constexpr_init_fits_real_type (TREE_TYPE (type),
    9028                 :          32 :                                                  TREE_REALPART (init))
    9029                 :          58 :                   && constexpr_init_fits_real_type (TREE_TYPE (type),
    9030                 :          26 :                                                     TREE_IMAGPART (init)));
    9031                 :             :           break;
    9032                 :           0 :         default:
    9033                 :           0 :           gcc_unreachable ();
    9034                 :             :         }
    9035                 :             :     }
    9036                 :             :   else
    9037                 :         293 :     fits = constexpr_init_fits_real_type (type, init);
    9038                 :         303 :   if (!fits)
    9039                 :          65 :     error_at (loc, "%<constexpr%> initializer not representable in "
    9040                 :             :               "type of object");
    9041                 :             : }
    9042                 :             : 
    9043                 :             : /* Digest the parser output INIT as an initializer for type TYPE.
    9044                 :             :    Return a C expression of type TYPE to represent the initial value.
    9045                 :             : 
    9046                 :             :    If ORIGTYPE is not NULL_TREE, it is the original type of INIT.
    9047                 :             : 
    9048                 :             :    NULL_POINTER_CONSTANT is true if INIT is a null pointer constant,
    9049                 :             :    INT_CONST_EXPR is true if INIT is an integer constant expression,
    9050                 :             :    and ARITH_CONST_EXPR is true if INIT is, or might be, an arithmetic
    9051                 :             :    constant expression, false if it has already been determined in the
    9052                 :             :    caller that it is not (but folding may have made the value passed here
    9053                 :             :    indistinguishable from an arithmetic constant expression).
    9054                 :             : 
    9055                 :             :    If INIT is a string constant, STRICT_STRING is true if it is
    9056                 :             :    unparenthesized or we should not warn here for it being parenthesized.
    9057                 :             :    For other types of INIT, STRICT_STRING is not used.
    9058                 :             : 
    9059                 :             :    INIT_LOC is the location of the INIT.
    9060                 :             : 
    9061                 :             :    REQUIRE_CONSTANT requests an error if non-constant initializers or
    9062                 :             :    elements are seen.  REQUIRE_CONSTEXPR means the stricter requirements
    9063                 :             :    on initializers for 'constexpr' objects apply.  */
    9064                 :             : 
    9065                 :             : static tree
    9066                 :    16580562 : digest_init (location_t init_loc, tree type, tree init, tree origtype,
    9067                 :             :              bool null_pointer_constant, bool int_const_expr,
    9068                 :             :              bool arith_const_expr, bool strict_string,
    9069                 :             :              bool require_constant, bool require_constexpr)
    9070                 :             : {
    9071                 :    16580562 :   enum tree_code code = TREE_CODE (type);
    9072                 :    16580562 :   tree inside_init = init;
    9073                 :    16580562 :   tree semantic_type = NULL_TREE;
    9074                 :    16580562 :   bool maybe_const = true;
    9075                 :             : 
    9076                 :    16580562 :   if (type == error_mark_node
    9077                 :    16580562 :       || !init
    9078                 :    33161124 :       || error_operand_p (init))
    9079                 :             :     return error_mark_node;
    9080                 :             : 
    9081                 :    16587805 :   STRIP_TYPE_NOPS (inside_init);
    9082                 :             : 
    9083                 :             :   /* If require_constant is TRUE,  when the initializer is a call to
    9084                 :             :      .ACCESS_WITH_SIZE, use the first argument as the initializer.
    9085                 :             :      For example:
    9086                 :             :      y = (char *) .ACCESS_WITH_SIZE ((char *) &static_annotated.c,...)
    9087                 :             :      will be converted to
    9088                 :             :      y = &static_annotated.c.  */
    9089                 :             : 
    9090                 :    16579279 :   if (require_constant
    9091                 :     2890005 :       && TREE_CODE (inside_init) == NOP_EXPR
    9092                 :      736202 :       && TREE_CODE (TREE_OPERAND (inside_init, 0)) == CALL_EXPR
    9093                 :    16579281 :       && is_access_with_size_p (TREE_OPERAND (inside_init, 0)))
    9094                 :           2 :     inside_init
    9095                 :           2 :       = get_ref_from_access_with_size (TREE_OPERAND (inside_init, 0));
    9096                 :             : 
    9097                 :    16579279 :   if (!c_in_omp_for)
    9098                 :             :     {
    9099                 :    16574587 :       if (TREE_CODE (inside_init) == EXCESS_PRECISION_EXPR)
    9100                 :             :         {
    9101                 :         437 :           semantic_type = TREE_TYPE (inside_init);
    9102                 :         437 :           inside_init = TREE_OPERAND (inside_init, 0);
    9103                 :             :         }
    9104                 :    16574587 :       inside_init = c_fully_fold (inside_init, require_constant, &maybe_const);
    9105                 :             :     }
    9106                 :             :   /* TODO: this may not detect all cases of expressions folding to
    9107                 :             :      constants that are not arithmetic constant expressions.  */
    9108                 :    16579279 :   if (!maybe_const)
    9109                 :             :     arith_const_expr = false;
    9110                 :    24769583 :   else if (!INTEGRAL_TYPE_P (TREE_TYPE (inside_init))
    9111                 :     5570805 :            && TREE_CODE (TREE_TYPE (inside_init)) != REAL_TYPE
    9112                 :    16550545 :            && TREE_CODE (TREE_TYPE (inside_init)) != COMPLEX_TYPE)
    9113                 :             :     arith_const_expr = false;
    9114                 :     8247009 :   else if (TREE_CODE (inside_init) != INTEGER_CST
    9115                 :             :            && TREE_CODE (inside_init) != REAL_CST
    9116                 :             :            && TREE_CODE (inside_init) != COMPLEX_CST
    9117                 :             :            && TREE_CODE (inside_init) != RAW_DATA_CST)
    9118                 :             :     arith_const_expr = false;
    9119                 :     4985424 :   else if (TREE_OVERFLOW (inside_init))
    9120                 :    11593899 :     arith_const_expr = false;
    9121                 :             : 
    9122                 :             :   /* Initialization of an array of chars from a string constant
    9123                 :             :      optionally enclosed in braces.  */
    9124                 :             : 
    9125                 :    16579279 :   if (code == ARRAY_TYPE && inside_init
    9126                 :      187135 :       && TREE_CODE (inside_init) == STRING_CST)
    9127                 :             :     {
    9128                 :       11296 :       tree typ1
    9129                 :       11296 :         = (TYPE_ATOMIC (TREE_TYPE (type))
    9130                 :       22583 :            ? c_build_qualified_type (TYPE_MAIN_VARIANT (TREE_TYPE (type)),
    9131                 :             :                                      TYPE_QUAL_ATOMIC)
    9132                 :       11287 :            : TYPE_MAIN_VARIANT (TREE_TYPE (type)));
    9133                 :             :       /* Note that an array could be both an array of character type
    9134                 :             :          and an array of wchar_t if wchar_t is signed char or unsigned
    9135                 :             :          char.  */
    9136                 :       22592 :       bool char_array = (typ1 == char_type_node
    9137                 :         462 :                          || typ1 == signed_char_type_node
    9138                 :       11729 :                          || typ1 == unsigned_char_type_node);
    9139                 :       11296 :       bool wchar_array = !!comptypes (typ1, wchar_type_node);
    9140                 :       11296 :       bool char16_array = !!comptypes (typ1, char16_type_node);
    9141                 :       11296 :       bool char32_array = !!comptypes (typ1, char32_type_node);
    9142                 :             : 
    9143                 :       11296 :       if (char_array || wchar_array || char16_array || char32_array)
    9144                 :             :         {
    9145                 :       11276 :           struct c_expr expr;
    9146                 :       11276 :           tree typ2 = TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (inside_init)));
    9147                 :       11276 :           bool incompat_string_cst = false;
    9148                 :       11276 :           expr.value = inside_init;
    9149                 :       11276 :           expr.original_code = (strict_string ? STRING_CST : ERROR_MARK);
    9150                 :       11276 :           expr.original_type = NULL;
    9151                 :       11276 :           expr.m_decimal = 0;
    9152                 :       11276 :           maybe_warn_string_init (init_loc, type, expr);
    9153                 :             : 
    9154                 :       11276 :           if (TYPE_DOMAIN (type) && !TYPE_MAX_VALUE (TYPE_DOMAIN (type)))
    9155                 :          88 :             pedwarn_init (init_loc, OPT_Wpedantic,
    9156                 :             :                           "initialization of a flexible array member");
    9157                 :             : 
    9158                 :       11276 :           if (comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (inside_init)),
    9159                 :       11276 :                          TYPE_MAIN_VARIANT (type)))
    9160                 :             :             return inside_init;
    9161                 :             : 
    9162                 :        4074 :           if (char_array)
    9163                 :             :             {
    9164                 :        3979 :               if (typ2 != char_type_node && typ2 != char8_type_node)
    9165                 :             :                 incompat_string_cst = true;
    9166                 :             :             }
    9167                 :          95 :           else if (!comptypes (typ1, typ2))
    9168                 :             :             incompat_string_cst = true;
    9169                 :             : 
    9170                 :             :           if (incompat_string_cst)
    9171                 :             :             {
    9172                 :          50 :               error_init (init_loc, "cannot initialize array of %qT from "
    9173                 :             :                           "a string literal with type array of %qT",
    9174                 :             :                           typ1, typ2);
    9175                 :          50 :               return error_mark_node;
    9176                 :             :             }
    9177                 :             : 
    9178                 :        4024 :           if (require_constexpr
    9179                 :        4024 :               && TYPE_UNSIGNED (typ1) != TYPE_UNSIGNED (typ2))
    9180                 :             :             {
    9181                 :             :               /* Check if all characters of the string can be
    9182                 :             :                  represented in the type of the constexpr object being
    9183                 :             :                  initialized.  */
    9184                 :          24 :               unsigned HOST_WIDE_INT len = TREE_STRING_LENGTH (inside_init);
    9185                 :          24 :               const unsigned char *p =
    9186                 :          24 :                 (const unsigned char *) TREE_STRING_POINTER (inside_init);
    9187                 :          24 :               gcc_assert (CHAR_TYPE_SIZE == 8 && CHAR_BIT == 8);
    9188                 :          70 :               for (unsigned i = 0; i < len; i++)
    9189                 :          58 :                 if (p[i] > 127)
    9190                 :             :                   {
    9191                 :          12 :                     error_init (init_loc, "%<constexpr%> initializer not "
    9192                 :             :                                 "representable in type of object");
    9193                 :          12 :                     break;
    9194                 :             :                   }
    9195                 :             :             }
    9196                 :             : 
    9197                 :        4024 :           if (TYPE_DOMAIN (type) != NULL_TREE
    9198                 :        3947 :               && TYPE_SIZE (type) != NULL_TREE
    9199                 :        7915 :               && TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST)
    9200                 :             :             {
    9201                 :        3891 :               unsigned HOST_WIDE_INT len = TREE_STRING_LENGTH (inside_init);
    9202                 :        3891 :               unsigned unit = TYPE_PRECISION (typ1) / BITS_PER_UNIT;
    9203                 :             : 
    9204                 :             :               /* Subtract the size of a single (possibly wide) character
    9205                 :             :                  because it's ok to ignore the terminating null char
    9206                 :             :                  that is counted in the length of the constant.  */
    9207                 :        3891 :               if (compare_tree_int (TYPE_SIZE_UNIT (type), len - unit) < 0)
    9208                 :          54 :                 pedwarn_init (init_loc, 0,
    9209                 :             :                               ("initializer-string for array of %qT "
    9210                 :             :                                "is too long"), typ1);
    9211                 :        3837 :               else if (warn_unterminated_string_initialization
    9212                 :        3837 :                        && compare_tree_int (TYPE_SIZE_UNIT (type), len) < 0)
    9213                 :           2 :                 warning_at (init_loc, OPT_Wunterminated_string_initialization,
    9214                 :             :                             ("initializer-string for array of %qT "
    9215                 :             :                              "is too long"), typ1);
    9216                 :        3891 :               if (compare_tree_int (TYPE_SIZE_UNIT (type), len) < 0)
    9217                 :             :                 {
    9218                 :         335 :                   unsigned HOST_WIDE_INT size
    9219                 :         335 :                     = tree_to_uhwi (TYPE_SIZE_UNIT (type));
    9220                 :         335 :                   const char *p = TREE_STRING_POINTER (inside_init);
    9221                 :             : 
    9222                 :         335 :                   inside_init = build_string (size, p);
    9223                 :             :                 }
    9224                 :             :             }
    9225                 :             : 
    9226                 :        4024 :           TREE_TYPE (inside_init) = type;
    9227                 :        4024 :           return inside_init;
    9228                 :             :         }
    9229                 :          20 :       else if (INTEGRAL_TYPE_P (typ1))
    9230                 :             :         {
    9231                 :          20 :           error_init (init_loc, "array of inappropriate type initialized "
    9232                 :             :                       "from string constant");
    9233                 :          20 :           return error_mark_node;
    9234                 :             :         }
    9235                 :             :     }
    9236                 :             : 
    9237                 :             :   /* Build a VECTOR_CST from a *constant* vector constructor.  If the
    9238                 :             :      vector constructor is not constant (e.g. {1,2,3,foo()}) then punt
    9239                 :             :      below and handle as a constructor.  */
    9240                 :    16567983 :   if (code == VECTOR_TYPE
    9241                 :     6168355 :       && VECTOR_TYPE_P (TREE_TYPE (inside_init))
    9242                 :     6168353 :       && vector_types_convertible_p (TREE_TYPE (inside_init), type, true)
    9243                 :    22736298 :       && TREE_CONSTANT (inside_init))
    9244                 :             :     {
    9245                 :      619679 :       if (TREE_CODE (inside_init) == VECTOR_CST
    9246                 :      619776 :           && comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (inside_init)),
    9247                 :          97 :                         TYPE_MAIN_VARIANT (type)))
    9248                 :             :         return inside_init;
    9249                 :             : 
    9250                 :      619582 :       if (TREE_CODE (inside_init) == CONSTRUCTOR)
    9251                 :             :         {
    9252                 :             :           unsigned HOST_WIDE_INT ix;
    9253                 :             :           tree value;
    9254                 :     4088633 :           bool constant_p = true;
    9255                 :             : 
    9256                 :             :           /* Iterate through elements and check if all constructor
    9257                 :             :              elements are *_CSTs.  */
    9258                 :     4088633 :           FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (inside_init), ix, value)
    9259                 :     3469104 :             if (!CONSTANT_CLASS_P (value))
    9260                 :             :               {
    9261                 :             :                 constant_p = false;
    9262                 :             :                 break;
    9263                 :             :               }
    9264                 :             : 
    9265                 :      619582 :           if (constant_p)
    9266                 :      619529 :             return build_vector_from_ctor (type,
    9267                 :      619529 :                                            CONSTRUCTOR_ELTS (inside_init));
    9268                 :             :         }
    9269                 :             :     }
    9270                 :             : 
    9271                 :    15948357 :   if (warn_sequence_point)
    9272                 :     2446846 :     verify_sequence_points (inside_init);
    9273                 :             : 
    9274                 :             :   /* Any type can be initialized
    9275                 :             :      from an expression of the same type, optionally with braces.  */
    9276                 :             : 
    9277                 :    15948357 :   if (inside_init && TREE_TYPE (inside_init) != NULL_TREE
    9278                 :    31896714 :       && (comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (inside_init)),
    9279                 :    15948357 :                      TYPE_MAIN_VARIANT (type))
    9280                 :     3077977 :           || (code == ARRAY_TYPE
    9281                 :         476 :               && comptypes (TREE_TYPE (inside_init), type))
    9282                 :     3077977 :           || (gnu_vector_type_p (type)
    9283                 :         159 :               && comptypes (TREE_TYPE (inside_init), type))
    9284                 :     3077977 :           || (code == POINTER_TYPE
    9285                 :      111573 :               && TREE_CODE (TREE_TYPE (inside_init)) == ARRAY_TYPE
    9286                 :        9249 :               && comptypes (TREE_TYPE (TREE_TYPE (inside_init)),
    9287                 :        9249 :                             TREE_TYPE (type)))))
    9288                 :             :     {
    9289                 :    12872354 :       if (code == POINTER_TYPE)
    9290                 :             :         {
    9291                 :      782948 :           if (TREE_CODE (TREE_TYPE (inside_init)) == ARRAY_TYPE)
    9292                 :             :             {
    9293                 :        1974 :               if (TREE_CODE (inside_init) == STRING_CST
    9294                 :          66 :                   || TREE_CODE (inside_init) == COMPOUND_LITERAL_EXPR)
    9295                 :        1972 :                 inside_init = array_to_pointer_conversion
    9296                 :        1972 :                   (init_loc, inside_init);
    9297                 :             :               else
    9298                 :             :                 {
    9299                 :           2 :                   error_init (init_loc, "invalid use of non-lvalue array");
    9300                 :           2 :                   return error_mark_node;
    9301                 :             :                 }
    9302                 :             :             }
    9303                 :             :         }
    9304                 :             : 
    9305                 :    12872352 :       if (code == VECTOR_TYPE || c_hardbool_type_attr (type))
    9306                 :             :         /* Although the types are compatible, we may require a
    9307                 :             :            conversion.  */
    9308                 :     5548626 :         inside_init = convert (type, inside_init);
    9309                 :             : 
    9310                 :    12872352 :       if ((code == RECORD_TYPE || code == UNION_TYPE)
    9311                 :    12872352 :           && !comptypes (TYPE_MAIN_VARIANT (type), TYPE_MAIN_VARIANT (TREE_TYPE (inside_init))))
    9312                 :             :         {
    9313                 :           0 :           error_init (init_loc, "invalid initializer");
    9314                 :           0 :           return error_mark_node;
    9315                 :             :         }
    9316                 :             : 
    9317                 :    12872352 :       if (require_constant
    9318                 :     2295905 :           && TREE_CODE (inside_init) == COMPOUND_LITERAL_EXPR)
    9319                 :             :         {
    9320                 :             :           /* As an extension, allow initializing objects with static storage
    9321                 :             :              duration with compound literals (which are then treated just as
    9322                 :             :              the brace enclosed list they contain).  Also allow this for
    9323                 :             :              vectors, as we can only assign them with compound literals.  */
    9324                 :          31 :           if (flag_isoc99 && code != VECTOR_TYPE)
    9325                 :           8 :             pedwarn_init (init_loc, OPT_Wpedantic, "initializer element "
    9326                 :             :                           "is not constant");
    9327                 :          31 :           tree decl = COMPOUND_LITERAL_EXPR_DECL (inside_init);
    9328                 :          31 :           inside_init = DECL_INITIAL (decl);
    9329                 :             :         }
    9330                 :             : 
    9331                 :    12872352 :       if (code == ARRAY_TYPE && TREE_CODE (inside_init) != STRING_CST
    9332                 :      175363 :           && TREE_CODE (inside_init) != CONSTRUCTOR)
    9333                 :             :         {
    9334                 :           2 :           error_init (init_loc, "array initialized from non-constant array "
    9335                 :             :                       "expression");
    9336                 :           2 :           return error_mark_node;
    9337                 :             :         }
    9338                 :             : 
    9339                 :             :       /* Compound expressions can only occur here if -Wpedantic or
    9340                 :             :          -pedantic-errors is specified.  In the later case, we always want
    9341                 :             :          an error.  In the former case, we simply want a warning.  */
    9342                 :    12872350 :       if (require_constant && pedantic
    9343                 :       20020 :           && TREE_CODE (inside_init) == COMPOUND_EXPR)
    9344                 :             :         {
    9345                 :           1 :           inside_init
    9346                 :           1 :             = valid_compound_expr_initializer (inside_init,
    9347                 :           1 :                                                TREE_TYPE (inside_init));
    9348                 :           1 :           if (inside_init == error_mark_node)
    9349                 :           1 :             error_init (init_loc, "initializer element is not constant");
    9350                 :             :           else
    9351                 :           0 :             pedwarn_init (init_loc, OPT_Wpedantic,
    9352                 :             :                           "initializer element is not constant");
    9353                 :           1 :           if (flag_pedantic_errors)
    9354                 :           0 :             inside_init = error_mark_node;
    9355                 :             :         }
    9356                 :     2295904 :       else if (require_constant
    9357                 :     2295904 :                && !initializer_constant_valid_p (inside_init,
    9358                 :     2295904 :                                                  TREE_TYPE (inside_init)))
    9359                 :             :         {
    9360                 :          94 :           error_init (init_loc, "initializer element is not constant");
    9361                 :          94 :           inside_init = error_mark_node;
    9362                 :             :         }
    9363                 :    12872255 :       else if (require_constant && !maybe_const)
    9364                 :         219 :         pedwarn_init (init_loc, OPT_Wpedantic,
    9365                 :             :                       "initializer element is not a constant expression");
    9366                 :    12872036 :       else if (require_constexpr)
    9367                 :         562 :         check_constexpr_init (init_loc, type, inside_init,
    9368                 :             :                               int_const_expr, arith_const_expr);
    9369                 :             : 
    9370                 :             :       /* Added to enable additional -Wsuggest-attribute=format warnings.  */
    9371                 :    12872350 :       if (TREE_CODE (TREE_TYPE (inside_init)) == POINTER_TYPE)
    9372                 :      850349 :         inside_init = convert_for_assignment (init_loc, UNKNOWN_LOCATION,
    9373                 :             :                                               type, inside_init, origtype,
    9374                 :             :                                               (require_constant
    9375                 :             :                                                ? ic_init_const
    9376                 :             :                                                : ic_init), null_pointer_constant,
    9377                 :             :                                               NULL_TREE, NULL_TREE, 0);
    9378                 :    12872350 :       if (TREE_CODE (inside_init) == RAW_DATA_CST
    9379                 :         245 :           && c_inhibit_evaluation_warnings == 0
    9380                 :         245 :           && warn_conversion
    9381                 :           1 :           && !TYPE_UNSIGNED (type)
    9382                 :    12872351 :           && TYPE_PRECISION (type) == CHAR_BIT)
    9383                 :         303 :         for (unsigned int i = 0;
    9384                 :         304 :              i < (unsigned) RAW_DATA_LENGTH (inside_init); ++i)
    9385                 :         303 :           if (RAW_DATA_SCHAR_ELT (inside_init, i) < 0)
    9386                 :          10 :             warning_at (init_loc, OPT_Wconversion,
    9387                 :             :                         "conversion from %qT to %qT changes value from "
    9388                 :             :                         "%qd to %qd",
    9389                 :             :                         integer_type_node, type,
    9390                 :          10 :                         RAW_DATA_UCHAR_ELT (inside_init, i),
    9391                 :          10 :                         RAW_DATA_SCHAR_ELT (inside_init, i));
    9392                 :    12872350 :       return inside_init;
    9393                 :             :     }
    9394                 :             : 
    9395                 :             :   /* Handle scalar types, including conversions.  */
    9396                 :             : 
    9397                 :     3076003 :   if (code == INTEGER_TYPE || code == REAL_TYPE || code == FIXED_POINT_TYPE
    9398                 :      127203 :       || code == POINTER_TYPE || code == ENUMERAL_TYPE || code == BOOLEAN_TYPE
    9399                 :       10802 :       || code == COMPLEX_TYPE || code == VECTOR_TYPE || code == NULLPTR_TYPE
    9400                 :        8773 :       || code == BITINT_TYPE)
    9401                 :             :     {
    9402                 :     3075521 :       tree unconverted_init = inside_init;
    9403                 :     3075521 :       if (TREE_CODE (TREE_TYPE (init)) == ARRAY_TYPE
    9404                 :     3075521 :           && (TREE_CODE (init) == STRING_CST
    9405                 :           1 :               || TREE_CODE (init) == COMPOUND_LITERAL_EXPR))
    9406                 :        7276 :         inside_init = init = array_to_pointer_conversion (init_loc, init);
    9407                 :     3075521 :       if (semantic_type)
    9408                 :         432 :         inside_init = build1 (EXCESS_PRECISION_EXPR, semantic_type,
    9409                 :             :                               inside_init);
    9410                 :     3075521 :       inside_init
    9411                 :     5571270 :         = convert_for_assignment (init_loc, UNKNOWN_LOCATION, type,
    9412                 :             :                                   inside_init, origtype,
    9413                 :             :                                   require_constant ? ic_init_const : ic_init,
    9414                 :             :                                   null_pointer_constant, NULL_TREE, NULL_TREE,
    9415                 :             :                                   0);
    9416                 :             : 
    9417                 :             :       /* Check to see if we have already given an error message.  */
    9418                 :     3075521 :       if (inside_init == error_mark_node)
    9419                 :             :         ;
    9420                 :     3075063 :       else if (require_constant && !TREE_CONSTANT (inside_init))
    9421                 :             :         {
    9422                 :          36 :           error_init (init_loc, "initializer element is not constant");
    9423                 :          36 :           inside_init = error_mark_node;
    9424                 :             :         }
    9425                 :     3075027 :       else if (require_constant
    9426                 :     3654371 :                && !initializer_constant_valid_p (inside_init,
    9427                 :      579344 :                                                  TREE_TYPE (inside_init)))
    9428                 :             :         {
    9429                 :          10 :           error_init (init_loc, "initializer element is not computable at "
    9430                 :             :                       "load time");
    9431                 :          10 :           inside_init = error_mark_node;
    9432                 :             :         }
    9433                 :     3075017 :       else if (require_constant && !maybe_const)
    9434                 :           5 :         pedwarn_init (init_loc, OPT_Wpedantic,
    9435                 :             :                       "initializer element is not a constant expression");
    9436                 :     3075012 :       else if (require_constexpr)
    9437                 :         319 :         check_constexpr_init (init_loc, type, unconverted_init,
    9438                 :             :                               int_const_expr, arith_const_expr);
    9439                 :             : 
    9440                 :     3075521 :       return inside_init;
    9441                 :             :     }
    9442                 :             : 
    9443                 :             :   /* Come here only for records and arrays.  */
    9444                 :             : 
    9445                 :         482 :   if (COMPLETE_TYPE_P (type) && TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST)
    9446                 :             :     {
    9447                 :           0 :       error_init (init_loc,
    9448                 :             :                   "variable-sized object may not be initialized except "
    9449                 :             :                   "with an empty initializer");
    9450                 :           0 :       return error_mark_node;
    9451                 :             :     }
    9452                 :             : 
    9453                 :         482 :   error_init (init_loc, "invalid initializer");
    9454                 :         482 :   return error_mark_node;
    9455                 :             : }
    9456                 :             : 
    9457                 :             : /* Handle initializers that use braces.  */
    9458                 :             : 
    9459                 :             : /* Type of object we are accumulating a constructor for.
    9460                 :             :    This type is always a RECORD_TYPE, UNION_TYPE or ARRAY_TYPE.  */
    9461                 :             : static tree constructor_type;
    9462                 :             : 
    9463                 :             : /* For a RECORD_TYPE or UNION_TYPE, this is the chain of fields
    9464                 :             :    left to fill.  */
    9465                 :             : static tree constructor_fields;
    9466                 :             : 
    9467                 :             : /* For an ARRAY_TYPE, this is the specified index
    9468                 :             :    at which to store the next element we get.  */
    9469                 :             : static tree constructor_index;
    9470                 :             : 
    9471                 :             : /* For an ARRAY_TYPE, this is the maximum index.  */
    9472                 :             : static tree constructor_max_index;
    9473                 :             : 
    9474                 :             : /* For a RECORD_TYPE, this is the first field not yet written out.  */
    9475                 :             : static tree constructor_unfilled_fields;
    9476                 :             : 
    9477                 :             : /* For an ARRAY_TYPE, this is the index of the first element
    9478                 :             :    not yet written out.  */
    9479                 :             : static tree constructor_unfilled_index;
    9480                 :             : 
    9481                 :             : /* In a RECORD_TYPE, the byte index of the next consecutive field.
    9482                 :             :    This is so we can generate gaps between fields, when appropriate.  */
    9483                 :             : static tree constructor_bit_index;
    9484                 :             : 
    9485                 :             : /* If we are saving up the elements rather than allocating them,
    9486                 :             :    this is the list of elements so far (in reverse order,
    9487                 :             :    most recent first).  */
    9488                 :             : static vec<constructor_elt, va_gc> *constructor_elements;
    9489                 :             : 
    9490                 :             : /* 1 if constructor should be incrementally stored into a constructor chain,
    9491                 :             :    0 if all the elements should be kept in AVL tree.  */
    9492                 :             : static int constructor_incremental;
    9493                 :             : 
    9494                 :             : /* 1 if so far this constructor's elements are all compile-time constants.  */
    9495                 :             : static int constructor_constant;
    9496                 :             : 
    9497                 :             : /* 1 if so far this constructor's elements are all valid address constants.  */
    9498                 :             : static int constructor_simple;
    9499                 :             : 
    9500                 :             : /* 1 if this constructor has an element that cannot be part of a
    9501                 :             :    constant expression.  */
    9502                 :             : static int constructor_nonconst;
    9503                 :             : 
    9504                 :             : /* 1 if this constructor is erroneous so far.  */
    9505                 :             : static int constructor_erroneous;
    9506                 :             : 
    9507                 :             : /* 1 if this constructor is the universal zero initializer { 0 }.  */
    9508                 :             : static int constructor_zeroinit;
    9509                 :             : 
    9510                 :             : /* 1 if this constructor should have padding bits zeroed (C23 {}.  */
    9511                 :             : static bool constructor_zero_padding_bits;
    9512                 :             : 
    9513                 :             : /* Structure for managing pending initializer elements, organized as an
    9514                 :             :    AVL tree.  */
    9515                 :             : 
    9516                 :             : struct init_node
    9517                 :             : {
    9518                 :             :   struct init_node *left, *right;
    9519                 :             :   struct init_node *parent;
    9520                 :             :   int balance;
    9521                 :             :   tree purpose;
    9522                 :             :   tree value;
    9523                 :             :   tree origtype;
    9524                 :             : };
    9525                 :             : 
    9526                 :             : /* Tree of pending elements at this constructor level.
    9527                 :             :    These are elements encountered out of order
    9528                 :             :    which belong at places we haven't reached yet in actually
    9529                 :             :    writing the output.
    9530                 :             :    Will never hold tree nodes across GC runs.  */
    9531                 :             : static struct init_node *constructor_pending_elts;
    9532                 :             : 
    9533                 :             : /* The SPELLING_DEPTH of this constructor.  */
    9534                 :             : static int constructor_depth;
    9535                 :             : 
    9536                 :             : /* DECL node for which an initializer is being read.
    9537                 :             :    0 means we are reading a constructor expression
    9538                 :             :    such as (struct foo) {...}.  */
    9539                 :             : static tree constructor_decl;
    9540                 :             : 
    9541                 :             : /* Nonzero if there were any member designators in this initializer.  */
    9542                 :             : static int constructor_designated;
    9543                 :             : 
    9544                 :             : /* Nesting depth of designator list.  */
    9545                 :             : static int designator_depth;
    9546                 :             : 
    9547                 :             : /* Nonzero if there were diagnosed errors in this designator list.  */
    9548                 :             : static int designator_erroneous;
    9549                 :             : 
    9550                 :             : 
    9551                 :             : /* This stack has a level for each implicit or explicit level of
    9552                 :             :    structuring in the initializer, including the outermost one.  It
    9553                 :             :    saves the values of most of the variables above.  */
    9554                 :             : 
    9555                 :             : struct constructor_range_stack;
    9556                 :             : 
    9557                 :             : struct constructor_stack
    9558                 :             : {
    9559                 :             :   struct constructor_stack *next;
    9560                 :             :   tree type;
    9561                 :             :   tree fields;
    9562                 :             :   tree index;
    9563                 :             :   tree max_index;
    9564                 :             :   tree unfilled_index;
    9565                 :             :   tree unfilled_fields;
    9566                 :             :   tree bit_index;
    9567                 :             :   vec<constructor_elt, va_gc> *elements;
    9568                 :             :   struct init_node *pending_elts;
    9569                 :             :   int offset;
    9570                 :             :   int depth;
    9571                 :             :   /* If value nonzero, this value should replace the entire
    9572                 :             :      constructor at this level.  */
    9573                 :             :   struct c_expr replacement_value;
    9574                 :             :   struct constructor_range_stack *range_stack;
    9575                 :             :   char constant;
    9576                 :             :   char simple;
    9577                 :             :   char nonconst;
    9578                 :             :   char implicit;
    9579                 :             :   char erroneous;
    9580                 :             :   char outer;
    9581                 :             :   char incremental;
    9582                 :             :   char designated;
    9583                 :             :   bool zero_padding_bits;
    9584                 :             :   int designator_depth;
    9585                 :             : };
    9586                 :             : 
    9587                 :             : static struct constructor_stack *constructor_stack;
    9588                 :             : 
    9589                 :             : /* This stack represents designators from some range designator up to
    9590                 :             :    the last designator in the list.  */
    9591                 :             : 
    9592                 :             : struct constructor_range_stack
    9593                 :             : {
    9594                 :             :   struct constructor_range_stack *next, *prev;
    9595                 :             :   struct constructor_stack *stack;
    9596                 :             :   tree range_start;
    9597                 :             :   tree index;
    9598                 :             :   tree range_end;
    9599                 :             :   tree fields;
    9600                 :             : };
    9601                 :             : 
    9602                 :             : static struct constructor_range_stack *constructor_range_stack;
    9603                 :             : 
    9604                 :             : /* This stack records separate initializers that are nested.
    9605                 :             :    Nested initializers can't happen in ANSI C, but GNU C allows them
    9606                 :             :    in cases like { ... (struct foo) { ... } ... }.  */
    9607                 :             : 
    9608                 :             : struct initializer_stack
    9609                 :             : {
    9610                 :             :   struct initializer_stack *next;
    9611                 :             :   tree decl;
    9612                 :             :   struct constructor_stack *constructor_stack;
    9613                 :             :   struct constructor_range_stack *constructor_range_stack;
    9614                 :             :   vec<constructor_elt, va_gc> *elements;
    9615                 :             :   struct spelling *spelling;
    9616                 :             :   struct spelling *spelling_base;
    9617                 :             :   int spelling_size;
    9618                 :             :   char require_constant_value;
    9619                 :             :   char require_constant_elements;
    9620                 :             :   char require_constexpr_value;
    9621                 :             :   char designated;
    9622                 :             :   rich_location *missing_brace_richloc;
    9623                 :             : };
    9624                 :             : 
    9625                 :             : static struct initializer_stack *initializer_stack;
    9626                 :             : 
    9627                 :             : /* Prepare to parse and output the initializer for variable DECL.  */
    9628                 :             : 
    9629                 :             : void
    9630                 :     7104254 : start_init (tree decl, tree asmspec_tree ATTRIBUTE_UNUSED,
    9631                 :             :             bool init_require_constant, bool init_require_constexpr,
    9632                 :             :             rich_location *richloc)
    9633                 :             : {
    9634                 :     7104254 :   const char *locus;
    9635                 :     7104254 :   struct initializer_stack *p = XNEW (struct initializer_stack);
    9636                 :             : 
    9637                 :     7104254 :   p->decl = constructor_decl;
    9638                 :     7104254 :   p->require_constant_value = require_constant_value;
    9639                 :     7104254 :   p->require_constant_elements = require_constant_elements;
    9640                 :     7104254 :   p->require_constexpr_value = require_constexpr_value;
    9641                 :     7104254 :   p->constructor_stack = constructor_stack;
    9642                 :     7104254 :   p->constructor_range_stack = constructor_range_stack;
    9643                 :     7104254 :   p->elements = constructor_elements;
    9644                 :     7104254 :   p->spelling = spelling;
    9645                 :     7104254 :   p->spelling_base = spelling_base;
    9646                 :     7104254 :   p->spelling_size = spelling_size;
    9647                 :     7104254 :   p->next = initializer_stack;
    9648                 :     7104254 :   p->missing_brace_richloc = richloc;
    9649                 :     7104254 :   p->designated = constructor_designated;
    9650                 :     7104254 :   initializer_stack = p;
    9651                 :             : 
    9652                 :     7104254 :   constructor_decl = decl;
    9653                 :     7104254 :   constructor_designated = 0;
    9654                 :             : 
    9655                 :     7104254 :   require_constant_value = init_require_constant;
    9656                 :     7104254 :   require_constexpr_value = init_require_constexpr;
    9657                 :     7104254 :   if (decl != NULL_TREE && decl != error_mark_node)
    9658                 :             :     {
    9659                 :     6202734 :       require_constant_elements
    9660                 :     6026612 :         = ((init_require_constant || (pedantic && !flag_isoc99))
    9661                 :             :            /* For a scalar, you can always use any value to initialize,
    9662                 :             :               even within braces.  */
    9663                 :     6214688 :            && AGGREGATE_TYPE_P (TREE_TYPE (decl)));
    9664                 :     6202734 :       locus = identifier_to_locale (IDENTIFIER_POINTER (DECL_NAME (decl)));
    9665                 :             :     }
    9666                 :             :   else
    9667                 :             :     {
    9668                 :      901520 :       require_constant_elements = false;
    9669                 :      901520 :       locus = _("(anonymous)");
    9670                 :             :     }
    9671                 :             : 
    9672                 :     7104254 :   constructor_stack = 0;
    9673                 :     7104254 :   constructor_range_stack = 0;
    9674                 :             : 
    9675                 :     7104254 :   found_missing_braces = 0;
    9676                 :             : 
    9677                 :     7104254 :   spelling_base = 0;
    9678                 :     7104254 :   spelling_size = 0;
    9679                 :     7104254 :   RESTORE_SPELLING_DEPTH (0);
    9680                 :             : 
    9681                 :     7104254 :   if (locus)
    9682                 :     7104254 :     push_string (locus);
    9683                 :     7104254 : }
    9684                 :             : 
    9685                 :             : void
    9686                 :     7104252 : finish_init (void)
    9687                 :             : {
    9688                 :     7104252 :   struct initializer_stack *p = initializer_stack;
    9689                 :             : 
    9690                 :             :   /* Free the whole constructor stack of this initializer.  */
    9691                 :     7104252 :   while (constructor_stack)
    9692                 :             :     {
    9693                 :           0 :       struct constructor_stack *q = constructor_stack;
    9694                 :           0 :       constructor_stack = q->next;
    9695                 :           0 :       XDELETE (q);
    9696                 :             :     }
    9697                 :             : 
    9698                 :     7104252 :   gcc_assert (!constructor_range_stack);
    9699                 :             : 
    9700                 :             :   /* Pop back to the data of the outer initializer (if any).  */
    9701                 :     7104252 :   XDELETE (spelling_base);
    9702                 :             : 
    9703                 :     7104252 :   constructor_decl = p->decl;
    9704                 :     7104252 :   require_constant_value = p->require_constant_value;
    9705                 :     7104252 :   require_constant_elements = p->require_constant_elements;
    9706                 :     7104252 :   require_constexpr_value = p->require_constexpr_value;
    9707                 :     7104252 :   constructor_stack = p->constructor_stack;
    9708                 :     7104252 :   constructor_designated = p->designated;
    9709                 :     7104252 :   constructor_range_stack = p->constructor_range_stack;
    9710                 :     7104252 :   constructor_elements = p->elements;
    9711                 :     7104252 :   spelling = p->spelling;
    9712                 :     7104252 :   spelling_base = p->spelling_base;
    9713                 :     7104252 :   spelling_size = p->spelling_size;
    9714                 :     7104252 :   initializer_stack = p->next;
    9715                 :     7104252 :   XDELETE (p);
    9716                 :     7104252 : }
    9717                 :             : 
    9718                 :             : /* Call here when we see the initializer is surrounded by braces.
    9719                 :             :    This is instead of a call to push_init_level;
    9720                 :             :    it is matched by a call to pop_init_level.
    9721                 :             : 
    9722                 :             :    TYPE is the type to initialize, for a constructor expression.
    9723                 :             :    For an initializer for a decl, TYPE is zero.  */
    9724                 :             : 
    9725                 :             : void
    9726                 :     1003510 : really_start_incremental_init (tree type)
    9727                 :             : {
    9728                 :     1003510 :   struct constructor_stack *p = XNEW (struct constructor_stack);
    9729                 :             : 
    9730                 :     1003510 :   if (type == NULL_TREE)
    9731                 :      103902 :     type = TREE_TYPE (constructor_decl);
    9732                 :             : 
    9733                 :     1003510 :   if (VECTOR_TYPE_P (type)
    9734                 :     1003510 :       && TYPE_VECTOR_OPAQUE (type))
    9735                 :           0 :     error ("opaque vector types cannot be initialized");
    9736                 :             : 
    9737                 :     1003510 :   p->type = constructor_type;
    9738                 :     1003510 :   p->fields = constructor_fields;
    9739                 :     1003510 :   p->index = constructor_index;
    9740                 :     1003510 :   p->max_index = constructor_max_index;
    9741                 :     1003510 :   p->unfilled_index = constructor_unfilled_index;
    9742                 :     1003510 :   p->unfilled_fields = constructor_unfilled_fields;
    9743                 :     1003510 :   p->bit_index = constructor_bit_index;
    9744                 :     1003510 :   p->elements = constructor_elements;
    9745                 :     1003510 :   p->constant = constructor_constant;
    9746                 :     1003510 :   p->simple = constructor_simple;
    9747                 :     1003510 :   p->nonconst = constructor_nonconst;
    9748                 :     1003510 :   p->erroneous = constructor_erroneous;
    9749                 :     1003510 :   p->pending_elts = constructor_pending_elts;
    9750                 :     1003510 :   p->depth = constructor_depth;
    9751                 :     1003510 :   p->replacement_value.value = 0;
    9752                 :     1003510 :   p->replacement_value.original_code = ERROR_MARK;
    9753                 :     1003510 :   p->replacement_value.original_type = NULL;
    9754                 :     1003510 :   p->implicit = 0;
    9755                 :     1003510 :   p->range_stack = 0;
    9756                 :     1003510 :   p->outer = 0;
    9757                 :     1003510 :   p->incremental = constructor_incremental;
    9758                 :     1003510 :   p->designated = constructor_designated;
    9759                 :     1003510 :   p->zero_padding_bits = constructor_zero_padding_bits;
    9760                 :     1003510 :   p->designator_depth = designator_depth;
    9761                 :     1003510 :   p->next = 0;
    9762                 :     1003510 :   constructor_stack = p;
    9763                 :             : 
    9764                 :     1003510 :   constructor_constant = 1;
    9765                 :     1003510 :   constructor_simple = 1;
    9766                 :     1003510 :   constructor_nonconst = 0;
    9767                 :     1003510 :   constructor_depth = SPELLING_DEPTH ();
    9768                 :     1003510 :   constructor_elements = NULL;
    9769                 :     1003510 :   constructor_pending_elts = 0;
    9770                 :     1003510 :   constructor_type = type;
    9771                 :     1003510 :   constructor_incremental = 1;
    9772                 :     1003510 :   constructor_designated = 0;
    9773                 :     1003510 :   constructor_zero_padding_bits = false;
    9774                 :     1003510 :   constructor_zeroinit = 1;
    9775                 :     1003510 :   designator_depth = 0;
    9776                 :     1003510 :   designator_erroneous = 0;
    9777                 :             : 
    9778                 :     1003510 :   if (RECORD_OR_UNION_TYPE_P (constructor_type))
    9779                 :             :     {
    9780                 :       80103 :       constructor_fields = TYPE_FIELDS (constructor_type);
    9781                 :             :       /* Skip any nameless bit fields at the beginning.  */
    9782                 :       80103 :       while (constructor_fields != NULL_TREE
    9783                 :       80131 :              && DECL_UNNAMED_BIT_FIELD (constructor_fields))
    9784                 :          28 :         constructor_fields = DECL_CHAIN (constructor_fields);
    9785                 :             : 
    9786                 :       80103 :       constructor_unfilled_fields = constructor_fields;
    9787                 :       80103 :       constructor_bit_index = bitsize_zero_node;
    9788                 :             :     }
    9789                 :      923407 :   else if (TREE_CODE (constructor_type) == ARRAY_TYPE)
    9790                 :             :     {
    9791                 :       17510 :       if (TYPE_DOMAIN (constructor_type))
    9792                 :             :         {
    9793                 :        9238 :           constructor_max_index
    9794                 :        9238 :             = TYPE_MAX_VALUE (TYPE_DOMAIN (constructor_type));
    9795                 :             : 
    9796                 :             :           /* Detect non-empty initializations of zero-length arrays.  */
    9797                 :        9238 :           if (constructor_max_index == NULL_TREE
    9798                 :        9238 :               && TYPE_SIZE (constructor_type))
    9799                 :         203 :             constructor_max_index = integer_minus_one_node;
    9800                 :             : 
    9801                 :             :           /* constructor_max_index needs to be an INTEGER_CST.  Attempts
    9802                 :             :              to initialize VLAs with a nonempty initializer will cause a
    9803                 :             :              proper error; avoid tree checking errors as well by setting a
    9804                 :             :              safe value.  */
    9805                 :        9238 :           if (constructor_max_index
    9806                 :        9238 :               && TREE_CODE (constructor_max_index) != INTEGER_CST)
    9807                 :          59 :             constructor_max_index = integer_minus_one_node;
    9808                 :             : 
    9809                 :        9238 :           constructor_index
    9810                 :        9238 :             = convert (bitsizetype,
    9811                 :        9238 :                        TYPE_MIN_VALUE (TYPE_DOMAIN (constructor_type)));
    9812                 :             :         }
    9813                 :             :       else
    9814                 :             :         {
    9815                 :        8272 :           constructor_index = bitsize_zero_node;
    9816                 :        8272 :           constructor_max_index = NULL_TREE;
    9817                 :             :         }
    9818                 :             : 
    9819                 :       17510 :       constructor_unfilled_index = constructor_index;
    9820                 :             :     }
    9821                 :      905897 :   else if (gnu_vector_type_p (constructor_type))
    9822                 :             :     {
    9823                 :             :       /* Vectors are like simple fixed-size arrays.  */
    9824                 :     1810722 :       constructor_max_index =
    9825                 :      905361 :         bitsize_int (TYPE_VECTOR_SUBPARTS (constructor_type) - 1);
    9826                 :      905361 :       constructor_index = bitsize_zero_node;
    9827                 :      905361 :       constructor_unfilled_index = constructor_index;
    9828                 :             :     }
    9829                 :             :   else
    9830                 :             :     {
    9831                 :             :       /* Handle the case of int x = {5}; */
    9832                 :         536 :       constructor_fields = constructor_type;
    9833                 :         536 :       constructor_unfilled_fields = constructor_type;
    9834                 :             :     }
    9835                 :     1003510 : }
    9836                 :             : 
    9837                 :             : extern location_t last_init_list_comma;
    9838                 :             : 
    9839                 :             : /* Called when we see an open brace for a nested initializer.  Finish
    9840                 :             :    off any pending levels with implicit braces.  */
    9841                 :             : void
    9842                 :      340121 : finish_implicit_inits (location_t loc, struct obstack *braced_init_obstack)
    9843                 :             : {
    9844                 :      340123 :   while (constructor_stack->implicit)
    9845                 :             :     {
    9846                 :         298 :       if (RECORD_OR_UNION_TYPE_P (constructor_type)
    9847                 :         140 :           && constructor_fields == NULL_TREE)
    9848                 :           0 :         process_init_element (input_location,
    9849                 :             :                               pop_init_level (loc, 1, braced_init_obstack,
    9850                 :             :                                               last_init_list_comma),
    9851                 :             :                               true, braced_init_obstack);
    9852                 :         298 :       else if (TREE_CODE (constructor_type) == ARRAY_TYPE
    9853                 :         158 :                && constructor_max_index
    9854                 :         456 :                && tree_int_cst_lt (constructor_max_index,
    9855                 :             :                                    constructor_index))
    9856                 :           2 :         process_init_element (input_location,
    9857                 :             :                               pop_init_level (loc, 1, braced_init_obstack,
    9858                 :             :                                               last_init_list_comma),
    9859                 :             :                               true, braced_init_obstack);
    9860                 :             :       else
    9861                 :             :         break;
    9862                 :             :     }
    9863                 :      340121 : }
    9864                 :             : 
    9865                 :             : /* Push down into a subobject, for initialization.
    9866                 :             :    If this is for an explicit set of braces, IMPLICIT is 0.
    9867                 :             :    If it is because the next element belongs at a lower level,
    9868                 :             :    IMPLICIT is 1 (or 2 if the push is because of designator list).  */
    9869                 :             : 
    9870                 :             : void
    9871                 :     1042727 : push_init_level (location_t loc, int implicit,
    9872                 :             :                  struct obstack *braced_init_obstack)
    9873                 :             : {
    9874                 :     1042727 :   struct constructor_stack *p;
    9875                 :     1042727 :   tree value = NULL_TREE;
    9876                 :             : 
    9877                 :             :   /* Unless this is an explicit brace, we need to preserve previous
    9878                 :             :      content if any.  */
    9879                 :     1042727 :   if (implicit)
    9880                 :             :     {
    9881                 :      703522 :       if (RECORD_OR_UNION_TYPE_P (constructor_type) && constructor_fields)
    9882                 :         770 :         value = find_init_member (constructor_fields, braced_init_obstack);
    9883                 :      702752 :       else if (TREE_CODE (constructor_type) == ARRAY_TYPE)
    9884                 :      702752 :         value = find_init_member (constructor_index, braced_init_obstack);
    9885                 :             :     }
    9886                 :             : 
    9887                 :     1042727 :   p = XNEW (struct constructor_stack);
    9888                 :     1042727 :   p->type = constructor_type;
    9889                 :     1042727 :   p->fields = constructor_fields;
    9890                 :     1042727 :   p->index = constructor_index;
    9891                 :     1042727 :   p->max_index = constructor_max_index;
    9892                 :     1042727 :   p->unfilled_index = constructor_unfilled_index;
    9893                 :     1042727 :   p->unfilled_fields = constructor_unfilled_fields;
    9894                 :     1042727 :   p->bit_index = constructor_bit_index;
    9895                 :     1042727 :   p->elements = constructor_elements;
    9896                 :     1042727 :   p->constant = constructor_constant;
    9897                 :     1042727 :   p->simple = constructor_simple;
    9898                 :     1042727 :   p->nonconst = constructor_nonconst;
    9899                 :     1042727 :   p->erroneous = constructor_erroneous;
    9900                 :     1042727 :   p->pending_elts = constructor_pending_elts;
    9901                 :     1042727 :   p->depth = constructor_depth;
    9902                 :     1042727 :   p->replacement_value.value = NULL_TREE;
    9903                 :     1042727 :   p->replacement_value.original_code = ERROR_MARK;
    9904                 :     1042727 :   p->replacement_value.original_type = NULL;
    9905                 :     1042727 :   p->implicit = implicit;
    9906                 :     1042727 :   p->outer = 0;
    9907                 :     1042727 :   p->incremental = constructor_incremental;
    9908                 :     1042727 :   p->designated = constructor_designated;
    9909                 :     1042727 :   p->zero_padding_bits = constructor_zero_padding_bits;
    9910                 :     1042727 :   p->designator_depth = designator_depth;
    9911                 :     1042727 :   p->next = constructor_stack;
    9912                 :     1042727 :   p->range_stack = 0;
    9913                 :     1042727 :   constructor_stack = p;
    9914                 :             : 
    9915                 :     1042727 :   constructor_constant = 1;
    9916                 :     1042727 :   constructor_simple = 1;
    9917                 :     1042727 :   constructor_nonconst = 0;
    9918                 :     1042727 :   constructor_depth = SPELLING_DEPTH ();
    9919                 :     1042727 :   constructor_elements = NULL;
    9920                 :     1042727 :   constructor_incremental = 1;
    9921                 :             :   /* If the upper initializer is designated, then mark this as
    9922                 :             :      designated too to prevent bogus warnings.  */
    9923                 :     1042727 :   constructor_designated = p->designated;
    9924                 :             :   /* If the upper initializer has padding bits zeroed, that includes
    9925                 :             :      all nested initializers as well.  */
    9926                 :     1042727 :   constructor_zero_padding_bits = p->zero_padding_bits;
    9927                 :     1042727 :   constructor_pending_elts = 0;
    9928                 :     1042727 :   if (!implicit)
    9929                 :             :     {
    9930                 :      339205 :       p->range_stack = constructor_range_stack;
    9931                 :      339205 :       constructor_range_stack = 0;
    9932                 :      339205 :       designator_depth = 0;
    9933                 :      339205 :       designator_erroneous = 0;
    9934                 :             :     }
    9935                 :             : 
    9936                 :             :   /* Don't die if an entire brace-pair level is superfluous
    9937                 :             :      in the containing level.  */
    9938                 :     1042727 :   if (constructor_type == NULL_TREE)
    9939                 :             :     ;
    9940                 :     1042727 :   else if (RECORD_OR_UNION_TYPE_P (constructor_type))
    9941                 :             :     {
    9942                 :             :       /* Don't die if there are extra init elts at the end.  */
    9943                 :      158673 :       if (constructor_fields == NULL_TREE)
    9944                 :          51 :         constructor_type = NULL_TREE;
    9945                 :             :       else
    9946                 :             :         {
    9947                 :      158622 :           constructor_type = TREE_TYPE (constructor_fields);
    9948                 :      158622 :           push_member_name (constructor_fields);
    9949                 :      158622 :           constructor_depth++;
    9950                 :             :         }
    9951                 :             :     }
    9952                 :      884054 :   else if (TREE_CODE (constructor_type) == ARRAY_TYPE)
    9953                 :             :     {
    9954                 :      884016 :       constructor_type = TREE_TYPE (constructor_type);
    9955                 :      884016 :       push_array_bounds (tree_to_uhwi (constructor_index));
    9956                 :      884016 :       constructor_depth++;
    9957                 :             :     }
    9958                 :             : 
    9959                 :     1042727 :   if (constructor_type == NULL_TREE)
    9960                 :             :     {
    9961                 :          51 :       error_init (loc, "extra brace group at end of initializer");
    9962                 :          51 :       constructor_fields = NULL_TREE;
    9963                 :          51 :       constructor_unfilled_fields = NULL_TREE;
    9964                 :          51 :       return;
    9965                 :             :     }
    9966                 :             : 
    9967                 :     1042676 :   if (value && TREE_CODE (value) == CONSTRUCTOR)
    9968                 :             :     {
    9969                 :         344 :       constructor_constant = TREE_CONSTANT (value);
    9970                 :         344 :       constructor_simple = TREE_STATIC (value);
    9971                 :         344 :       constructor_nonconst = CONSTRUCTOR_NON_CONST (value);
    9972                 :         344 :       constructor_elements = CONSTRUCTOR_ELTS (value);
    9973                 :         344 :       constructor_zero_padding_bits |= CONSTRUCTOR_ZERO_PADDING_BITS (value);
    9974                 :         344 :       if (!vec_safe_is_empty (constructor_elements)
    9975                 :         324 :           && (TREE_CODE (constructor_type) == RECORD_TYPE
    9976                 :         324 :               || TREE_CODE (constructor_type) == ARRAY_TYPE))
    9977                 :         278 :         set_nonincremental_init (braced_init_obstack);
    9978                 :             :     }
    9979                 :             : 
    9980                 :     1042676 :   if (implicit == 1)
    9981                 :             :     {
    9982                 :      702606 :       found_missing_braces = 1;
    9983                 :      702606 :       if (initializer_stack->missing_brace_richloc)
    9984                 :      702606 :         initializer_stack->missing_brace_richloc->add_fixit_insert_before
    9985                 :      702606 :           (loc, "{");
    9986                 :             :     }
    9987                 :             : 
    9988                 :     1042676 :   if (RECORD_OR_UNION_TYPE_P (constructor_type))
    9989                 :             :     {
    9990                 :      879559 :       constructor_fields = TYPE_FIELDS (constructor_type);
    9991                 :             :       /* Skip any nameless bit fields at the beginning.  */
    9992                 :      879559 :       while (constructor_fields != NULL_TREE
    9993                 :      879623 :              && DECL_UNNAMED_BIT_FIELD (constructor_fields))
    9994                 :          64 :         constructor_fields = DECL_CHAIN (constructor_fields);
    9995                 :             : 
    9996                 :      879559 :       constructor_unfilled_fields = constructor_fields;
    9997                 :      879559 :       constructor_bit_index = bitsize_zero_node;
    9998                 :             :     }
    9999                 :      163117 :   else if (gnu_vector_type_p (constructor_type))
   10000                 :             :     {
   10001                 :             :       /* Vectors are like simple fixed-size arrays.  */
   10002                 :        9600 :       constructor_max_index =
   10003                 :        4800 :         bitsize_int (TYPE_VECTOR_SUBPARTS (constructor_type) - 1);
   10004                 :        4800 :       constructor_index = bitsize_int (0);
   10005                 :        4800 :       constructor_unfilled_index = constructor_index;
   10006                 :             :     }
   10007                 :      158317 :   else if (TREE_CODE (constructor_type) == ARRAY_TYPE)
   10008                 :             :     {
   10009                 :      158259 :       if (TYPE_DOMAIN (constructor_type))
   10010                 :             :         {
   10011                 :      158259 :           constructor_max_index
   10012                 :      158259 :             = TYPE_MAX_VALUE (TYPE_DOMAIN (constructor_type));
   10013                 :             : 
   10014                 :             :           /* Detect non-empty initializations of zero-length arrays.  */
   10015                 :      158259 :           if (constructor_max_index == NULL_TREE
   10016                 :      158259 :               && TYPE_SIZE (constructor_type))
   10017                 :         135 :             constructor_max_index = integer_minus_one_node;
   10018                 :             : 
   10019                 :             :           /* constructor_max_index needs to be an INTEGER_CST.  Attempts
   10020                 :             :              to initialize VLAs will cause a proper error; avoid tree
   10021                 :             :              checking errors as well by setting a safe value.  */
   10022                 :      158259 :           if (constructor_max_index
   10023                 :      158023 :               && TREE_CODE (constructor_max_index) != INTEGER_CST)
   10024                 :           0 :             constructor_max_index = integer_minus_one_node;
   10025                 :             : 
   10026                 :      158259 :           constructor_index
   10027                 :      158259 :             = convert (bitsizetype,
   10028                 :      158259 :                        TYPE_MIN_VALUE (TYPE_DOMAIN (constructor_type)));
   10029                 :             :         }
   10030                 :             :       else
   10031                 :           0 :         constructor_index = bitsize_zero_node;
   10032                 :             : 
   10033                 :      158259 :       constructor_unfilled_index = constructor_index;
   10034                 :      158259 :       if (value && TREE_CODE (value) == STRING_CST)
   10035                 :             :         {
   10036                 :             :           /* We need to split the char/wchar array into individual
   10037                 :             :              characters, so that we don't have to special case it
   10038                 :             :              everywhere.  */
   10039                 :           7 :           set_nonincremental_init_from_string (value, braced_init_obstack);
   10040                 :             :         }
   10041                 :             :     }
   10042                 :             :   else
   10043                 :             :     {
   10044                 :          58 :       if (constructor_type != error_mark_node)
   10045                 :          29 :         warning_init (input_location, 0, "braces around scalar initializer");
   10046                 :          58 :       constructor_fields = constructor_type;
   10047                 :          58 :       constructor_unfilled_fields = constructor_type;
   10048                 :             :     }
   10049                 :             : }
   10050                 :             : 
   10051                 :             : /* At the end of an implicit or explicit brace level,
   10052                 :             :    finish up that level of constructor.  If a single expression
   10053                 :             :    with redundant braces initialized that level, return the
   10054                 :             :    c_expr structure for that expression.  Otherwise, the original_code
   10055                 :             :    element is set to ERROR_MARK.
   10056                 :             :    If we were outputting the elements as they are read, return 0 as the value
   10057                 :             :    from inner levels (process_init_element ignores that),
   10058                 :             :    but return error_mark_node as the value from the outermost level
   10059                 :             :    (that's what we want to put in DECL_INITIAL).
   10060                 :             :    Otherwise, return a CONSTRUCTOR expression as the value.  */
   10061                 :             : 
   10062                 :             : struct c_expr
   10063                 :     2046237 : pop_init_level (location_t loc, int implicit,
   10064                 :             :                 struct obstack *braced_init_obstack,
   10065                 :             :                 location_t insert_before)
   10066                 :             : {
   10067                 :     2046237 :   struct constructor_stack *p;
   10068                 :     2046237 :   struct c_expr ret;
   10069                 :     2046237 :   ret.value = NULL_TREE;
   10070                 :     2046237 :   ret.original_code = ERROR_MARK;
   10071                 :     2046237 :   ret.original_type = NULL;
   10072                 :     2046237 :   ret.m_decimal = 0;
   10073                 :             : 
   10074                 :     2046237 :   if (implicit == 0)
   10075                 :             :     {
   10076                 :             :       /* When we come to an explicit close brace,
   10077                 :             :          pop any inner levels that didn't have explicit braces.  */
   10078                 :     1343589 :       while (constructor_stack->implicit)
   10079                 :         874 :         process_init_element (input_location,
   10080                 :             :                               pop_init_level (loc, 1, braced_init_obstack,
   10081                 :             :                                               insert_before),
   10082                 :             :                               true, braced_init_obstack);
   10083                 :     1342715 :       gcc_assert (!constructor_range_stack);
   10084                 :             :     }
   10085                 :             :   else
   10086                 :      703522 :     if (initializer_stack->missing_brace_richloc)
   10087                 :      703522 :       initializer_stack->missing_brace_richloc->add_fixit_insert_before
   10088                 :      703522 :         (insert_before, "}");
   10089                 :             : 
   10090                 :             :   /* Now output all pending elements.  */
   10091                 :     2046237 :   constructor_incremental = 1;
   10092                 :     2046237 :   output_pending_init_elements (1, braced_init_obstack);
   10093                 :             : 
   10094                 :     2046237 :   p = constructor_stack;
   10095                 :             : 
   10096                 :             :   /* Error for initializing a flexible array member, or a zero-length
   10097                 :             :      array member in an inappropriate context.  */
   10098                 :     2046186 :   if (constructor_type && constructor_fields
   10099                 :      159104 :       && TREE_CODE (constructor_type) == ARRAY_TYPE
   10100                 :      152447 :       && TYPE_DOMAIN (constructor_type)
   10101                 :     2198676 :       && !TYPE_MAX_VALUE (TYPE_DOMAIN (constructor_type)))
   10102                 :             :     {
   10103                 :             :       /* Silently discard empty initializations.  The parser will
   10104                 :             :          already have pedwarned for empty brackets.  */
   10105                 :         266 :       if (integer_zerop (constructor_unfilled_index))
   10106                 :          72 :         constructor_type = NULL_TREE;
   10107                 :             :       else
   10108                 :             :         {
   10109                 :         194 :           gcc_assert (!TYPE_SIZE (constructor_type));
   10110                 :             : 
   10111                 :         194 :           if (constructor_depth > 2)
   10112                 :          24 :             error_init (loc, "initialization of flexible array member in a nested context");
   10113                 :             :           else
   10114                 :         170 :             pedwarn_init (loc, OPT_Wpedantic,
   10115                 :             :                           "initialization of a flexible array member");
   10116                 :             : 
   10117                 :             :           /* We have already issued an error message for the existence
   10118                 :             :              of a flexible array member not at the end of the structure.
   10119                 :             :              Discard the initializer so that we do not die later.  */
   10120                 :         194 :           if (DECL_CHAIN (constructor_fields) != NULL_TREE)
   10121                 :           0 :             constructor_type = NULL_TREE;
   10122                 :             :         }
   10123                 :             :     }
   10124                 :             : 
   10125                 :     2046237 :   switch (vec_safe_length (constructor_elements))
   10126                 :             :     {
   10127                 :        4499 :     case 0:
   10128                 :             :       /* Initialization with { } counts as zeroinit.  */
   10129                 :        4499 :       constructor_zeroinit = 1;
   10130                 :        4499 :       break;
   10131                 :      913799 :     case 1:
   10132                 :             :       /* This might be zeroinit as well.  */
   10133                 :      913799 :       if (integer_zerop ((*constructor_elements)[0].value))
   10134                 :        1846 :         constructor_zeroinit = 1;
   10135                 :             :       break;
   10136                 :     1127939 :     default:
   10137                 :             :       /* If the constructor has more than one element, it can't be { 0 }.  */
   10138                 :     1127939 :       constructor_zeroinit = 0;
   10139                 :     1127939 :       break;
   10140                 :             :     }
   10141                 :             : 
   10142                 :             :   /* Warn when some structs are initialized with direct aggregation.  */
   10143                 :     2046237 :   if (!implicit && found_missing_braces && warn_missing_braces
   10144                 :          37 :       && !constructor_zeroinit)
   10145                 :             :     {
   10146                 :          18 :       gcc_assert (initializer_stack->missing_brace_richloc);
   10147                 :          18 :       warning_at (initializer_stack->missing_brace_richloc,
   10148                 :             :                   OPT_Wmissing_braces,
   10149                 :             :                   "missing braces around initializer");
   10150                 :             :     }
   10151                 :             : 
   10152                 :             :   /* Warn when some struct elements are implicitly initialized to zero.  */
   10153                 :     2046237 :   if (warn_missing_field_initializers
   10154                 :      425445 :       && constructor_type
   10155                 :      425417 :       && TREE_CODE (constructor_type) == RECORD_TYPE
   10156                 :      193387 :       && constructor_unfilled_fields)
   10157                 :             :     {
   10158                 :             :         /* Do not warn for flexible array members or zero-length arrays.  */
   10159                 :          43 :         while (constructor_unfilled_fields
   10160                 :          43 :                && (!DECL_SIZE (constructor_unfilled_fields)
   10161                 :          43 :                    || integer_zerop (DECL_SIZE (constructor_unfilled_fields))))
   10162                 :           0 :           constructor_unfilled_fields = DECL_CHAIN (constructor_unfilled_fields);
   10163                 :             : 
   10164                 :          43 :         if (constructor_unfilled_fields
   10165                 :             :             /* Do not warn if this level of the initializer uses member
   10166                 :             :                designators; it is likely to be deliberate.  */
   10167                 :          43 :             && !constructor_designated
   10168                 :             :             /* Do not warn about initializing with { 0 } or with { }.  */
   10169                 :          24 :             && !constructor_zeroinit)
   10170                 :             :           {
   10171                 :          10 :             if (warning_at (input_location, OPT_Wmissing_field_initializers,
   10172                 :             :                             "missing initializer for field %qD of %qT",
   10173                 :             :                             constructor_unfilled_fields,
   10174                 :             :                             constructor_type))
   10175                 :          10 :               inform (DECL_SOURCE_LOCATION (constructor_unfilled_fields),
   10176                 :             :                       "%qD declared here", constructor_unfilled_fields);
   10177                 :             :           }
   10178                 :             :     }
   10179                 :             : 
   10180                 :             :   /* Pad out the end of the structure.  */
   10181                 :     2046237 :   if (p->replacement_value.value)
   10182                 :             :     /* If this closes a superfluous brace pair,
   10183                 :             :        just pass out the element between them.  */
   10184                 :         102 :     ret = p->replacement_value;
   10185                 :     2046135 :   else if (constructor_type == NULL_TREE)
   10186                 :             :     ;
   10187                 :     2046020 :   else if (!RECORD_OR_UNION_TYPE_P (constructor_type)
   10188                 :     2046020 :            && TREE_CODE (constructor_type) != ARRAY_TYPE
   10189                 :     2046020 :            && !gnu_vector_type_p (constructor_type))
   10190                 :             :     {
   10191                 :             :       /* A nonincremental scalar initializer--just return
   10192                 :             :          the element, after verifying there is just one.
   10193                 :             :          Empty scalar initializers are supported in C23.  */
   10194                 :         594 :       if (vec_safe_is_empty (constructor_elements))
   10195                 :             :         {
   10196                 :         207 :           if (constructor_erroneous || constructor_type == error_mark_node)
   10197                 :          94 :             ret.value = error_mark_node;
   10198                 :         113 :           else if (TREE_CODE (constructor_type) == FUNCTION_TYPE)
   10199                 :             :             {
   10200                 :           2 :               error_init (loc, "invalid initializer");
   10201                 :           2 :               ret.value = error_mark_node;
   10202                 :             :             }
   10203                 :         111 :           else if (TREE_CODE (constructor_type) == POINTER_TYPE)
   10204                 :             :             /* Ensure this is a null pointer constant in the case of a
   10205                 :             :                'constexpr' object initialized with {}.  */
   10206                 :          33 :             ret.value = build_zero_cst (ptr_type_node);
   10207                 :             :           else
   10208                 :          78 :             ret.value = build_zero_cst (constructor_type);
   10209                 :             :         }
   10210                 :         387 :       else if (vec_safe_length (constructor_elements) != 1)
   10211                 :             :         {
   10212                 :           0 :           error_init (loc, "extra elements in scalar initializer");
   10213                 :           0 :           ret.value = (*constructor_elements)[0].value;
   10214                 :             :         }
   10215                 :             :       else
   10216                 :         387 :         ret.value = (*constructor_elements)[0].value;
   10217                 :             :     }
   10218                 :             :   else
   10219                 :             :     {
   10220                 :     2045426 :       if (constructor_erroneous)
   10221                 :         464 :         ret.value = error_mark_node;
   10222                 :             :       else
   10223                 :             :         {
   10224                 :     2044962 :           ret.value = build_constructor (constructor_type,
   10225                 :             :                                          constructor_elements);
   10226                 :     2044962 :           if (constructor_constant)
   10227                 :     1723004 :             TREE_CONSTANT (ret.value) = 1;
   10228                 :     2044962 :           if (constructor_constant && constructor_simple)
   10229                 :     1722966 :             TREE_STATIC (ret.value) = 1;
   10230                 :     2044962 :           if (constructor_nonconst)
   10231                 :         577 :             CONSTRUCTOR_NON_CONST (ret.value) = 1;
   10232                 :     2044962 :           if (constructor_zero_padding_bits)
   10233                 :          20 :             CONSTRUCTOR_ZERO_PADDING_BITS (ret.value) = 1;
   10234                 :             :         }
   10235                 :             :     }
   10236                 :             : 
   10237                 :     2046237 :   if (ret.value && TREE_CODE (ret.value) != CONSTRUCTOR)
   10238                 :             :     {
   10239                 :        1160 :       if (constructor_nonconst)
   10240                 :          15 :         ret.original_code = C_MAYBE_CONST_EXPR;
   10241                 :        1145 :       else if (ret.original_code == C_MAYBE_CONST_EXPR)
   10242                 :           0 :         ret.original_code = ERROR_MARK;
   10243                 :             :     }
   10244                 :             : 
   10245                 :     2046237 :   constructor_type = p->type;
   10246                 :     2046237 :   constructor_fields = p->fields;
   10247                 :     2046237 :   constructor_index = p->index;
   10248                 :     2046237 :   constructor_max_index = p->max_index;
   10249                 :     2046237 :   constructor_unfilled_index = p->unfilled_index;
   10250                 :     2046237 :   constructor_unfilled_fields = p->unfilled_fields;
   10251                 :     2046237 :   constructor_bit_index = p->bit_index;
   10252                 :     2046237 :   constructor_elements = p->elements;
   10253                 :     2046237 :   constructor_constant = p->constant;
   10254                 :     2046237 :   constructor_simple = p->simple;
   10255                 :     2046237 :   constructor_nonconst = p->nonconst;
   10256                 :     2046237 :   constructor_erroneous = p->erroneous;
   10257                 :     2046237 :   constructor_incremental = p->incremental;
   10258                 :     2046237 :   constructor_designated = p->designated;
   10259                 :     2046237 :   constructor_zero_padding_bits = p->zero_padding_bits;
   10260                 :     2046237 :   designator_depth = p->designator_depth;
   10261                 :     2046237 :   constructor_pending_elts = p->pending_elts;
   10262                 :     2046237 :   constructor_depth = p->depth;
   10263                 :     2046237 :   if (!p->implicit)
   10264                 :     1342715 :     constructor_range_stack = p->range_stack;
   10265                 :     2046237 :   RESTORE_SPELLING_DEPTH (constructor_depth);
   10266                 :             : 
   10267                 :     2046237 :   constructor_stack = p->next;
   10268                 :     2046237 :   XDELETE (p);
   10269                 :             : 
   10270                 :     2046237 :   if (ret.value == NULL_TREE && constructor_stack == 0)
   10271                 :           0 :     ret.value = error_mark_node;
   10272                 :     2046237 :   return ret;
   10273                 :             : }
   10274                 :             : 
   10275                 :             : /* Common handling for both array range and field name designators.
   10276                 :             :    ARRAY argument is nonzero for array ranges.  Returns false for success.  */
   10277                 :             : 
   10278                 :             : static bool
   10279                 :       32993 : set_designator (location_t loc, bool array,
   10280                 :             :                 struct obstack *braced_init_obstack)
   10281                 :             : {
   10282                 :       32993 :   tree subtype;
   10283                 :       32993 :   enum tree_code subcode;
   10284                 :             : 
   10285                 :             :   /* Don't die if an entire brace-pair level is superfluous
   10286                 :             :      in the containing level, or for an erroneous type.  */
   10287                 :       32993 :   if (constructor_type == NULL_TREE || constructor_type == error_mark_node)
   10288                 :             :     return true;
   10289                 :             : 
   10290                 :             :   /* If there were errors in this designator list already, bail out
   10291                 :             :      silently.  */
   10292                 :       32984 :   if (designator_erroneous)
   10293                 :             :     return true;
   10294                 :             : 
   10295                 :             :   /* Likewise for an initializer for a variable-size type.  Those are
   10296                 :             :      diagnosed in the parser, except for empty initializer braces.  */
   10297                 :       32984 :   if (COMPLETE_TYPE_P (constructor_type)
   10298                 :       32984 :       && TREE_CODE (TYPE_SIZE (constructor_type)) != INTEGER_CST)
   10299                 :             :     return true;
   10300                 :             : 
   10301                 :       32974 :   if (!designator_depth)
   10302                 :             :     {
   10303                 :       32382 :       gcc_assert (!constructor_range_stack);
   10304                 :             : 
   10305                 :             :       /* Designator list starts at the level of closest explicit
   10306                 :             :          braces.  */
   10307                 :       32747 :       while (constructor_stack->implicit)
   10308                 :         365 :         process_init_element (input_location,
   10309                 :             :                               pop_init_level (loc, 1, braced_init_obstack,
   10310                 :             :                                               last_init_list_comma),
   10311                 :             :                               true, braced_init_obstack);
   10312                 :       32382 :       constructor_designated = 1;
   10313                 :       32382 :       return false;
   10314                 :             :     }
   10315                 :             : 
   10316                 :         592 :   switch (TREE_CODE (constructor_type))
   10317                 :             :     {
   10318                 :         415 :     case  RECORD_TYPE:
   10319                 :         415 :     case  UNION_TYPE:
   10320                 :         415 :       subtype = TREE_TYPE (constructor_fields);
   10321                 :         415 :       if (subtype != error_mark_node)
   10322                 :         415 :         subtype = TYPE_MAIN_VARIANT (subtype);
   10323                 :             :       break;
   10324                 :         177 :     case ARRAY_TYPE:
   10325                 :         177 :       subtype = TYPE_MAIN_VARIANT (TREE_TYPE (constructor_type));
   10326                 :         177 :       break;
   10327                 :           0 :     default:
   10328                 :           0 :       gcc_unreachable ();
   10329                 :             :     }
   10330                 :             : 
   10331                 :         592 :   subcode = TREE_CODE (subtype);
   10332                 :         592 :   if (array && subcode != ARRAY_TYPE)
   10333                 :             :     {
   10334                 :           1 :       error_init (loc, "array index in non-array initializer");
   10335                 :           1 :       return true;
   10336                 :             :     }
   10337                 :         591 :   else if (!array && subcode != RECORD_TYPE && subcode != UNION_TYPE)
   10338                 :             :     {
   10339                 :           0 :       error_init (loc, "field name not in record or union initializer");
   10340                 :           0 :       return true;
   10341                 :             :     }
   10342                 :             : 
   10343                 :         591 :   constructor_designated = 1;
   10344                 :         591 :   finish_implicit_inits (loc, braced_init_obstack);
   10345                 :         591 :   push_init_level (loc, 2, braced_init_obstack);
   10346                 :         591 :   return false;
   10347                 :             : }
   10348                 :             : 
   10349                 :             : /* If there are range designators in designator list, push a new designator
   10350                 :             :    to constructor_range_stack.  RANGE_END is end of such stack range or
   10351                 :             :    NULL_TREE if there is no range designator at this level.  */
   10352                 :             : 
   10353                 :             : static void
   10354                 :         384 : push_range_stack (tree range_end, struct obstack * braced_init_obstack)
   10355                 :             : {
   10356                 :         384 :   struct constructor_range_stack *p;
   10357                 :             : 
   10358                 :         768 :   p = (struct constructor_range_stack *)
   10359                 :         384 :     obstack_alloc (braced_init_obstack,
   10360                 :             :                    sizeof (struct constructor_range_stack));
   10361                 :         384 :   p->prev = constructor_range_stack;
   10362                 :         384 :   p->next = 0;
   10363                 :         384 :   p->fields = constructor_fields;
   10364                 :         384 :   p->range_start = constructor_index;
   10365                 :         384 :   p->index = constructor_index;
   10366                 :         384 :   p->stack = constructor_stack;
   10367                 :         384 :   p->range_end = range_end;
   10368                 :         384 :   if (constructor_range_stack)
   10369                 :          19 :     constructor_range_stack->next = p;
   10370                 :         384 :   constructor_range_stack = p;
   10371                 :         384 : }
   10372                 :             : 
   10373                 :             : /* Within an array initializer, specify the next index to be initialized.
   10374                 :             :    FIRST is that index.  If LAST is nonzero, then initialize a range
   10375                 :             :    of indices, running from FIRST through LAST.  */
   10376                 :             : 
   10377                 :             : void
   10378                 :        1091 : set_init_index (location_t loc, tree first, tree last,
   10379                 :             :                 struct obstack *braced_init_obstack)
   10380                 :             : {
   10381                 :        1091 :   if (set_designator (loc, true, braced_init_obstack))
   10382                 :             :     return;
   10383                 :             : 
   10384                 :        1088 :   designator_erroneous = 1;
   10385                 :             : 
   10386                 :        2176 :   if (!INTEGRAL_TYPE_P (TREE_TYPE (first))
   10387                 :        2165 :       || (last && !INTEGRAL_TYPE_P (TREE_TYPE (last))))
   10388                 :             :     {
   10389                 :          12 :       error_init (loc, "array index in initializer not of integer type");
   10390                 :          12 :       return;
   10391                 :             :     }
   10392                 :             : 
   10393                 :        1076 :   if (TREE_CODE (first) != INTEGER_CST)
   10394                 :             :     {
   10395                 :           6 :       first = c_fully_fold (first, false, NULL);
   10396                 :           6 :       if (TREE_CODE (first) == INTEGER_CST)
   10397                 :           5 :         pedwarn_init (loc, OPT_Wpedantic,
   10398                 :             :                       "array index in initializer is not "
   10399                 :             :                       "an integer constant expression");
   10400                 :             :     }
   10401                 :             : 
   10402                 :        1076 :   if (last && TREE_CODE (last) != INTEGER_CST)
   10403                 :             :     {
   10404                 :           2 :       last = c_fully_fold (last, false, NULL);
   10405                 :           2 :       if (TREE_CODE (last) == INTEGER_CST)
   10406                 :           1 :         pedwarn_init (loc, OPT_Wpedantic,
   10407                 :             :                       "array index in initializer is not "
   10408                 :             :                       "an integer constant expression");
   10409                 :             :     }
   10410                 :             : 
   10411                 :        1076 :   if (TREE_CODE (first) != INTEGER_CST)
   10412                 :           1 :     error_init (loc, "nonconstant array index in initializer");
   10413                 :        1075 :   else if (last != NULL_TREE && TREE_CODE (last) != INTEGER_CST)
   10414                 :           1 :     error_init (loc, "nonconstant array index in initializer");
   10415                 :        1074 :   else if (TREE_CODE (constructor_type) != ARRAY_TYPE)
   10416                 :           9 :     error_init (loc, "array index in non-array initializer");
   10417                 :        1065 :   else if (tree_int_cst_sgn (first) == -1)
   10418                 :          15 :     error_init (loc, "array index in initializer exceeds array bounds");
   10419                 :        1050 :   else if (constructor_max_index
   10420                 :        1050 :            && tree_int_cst_lt (constructor_max_index, first))
   10421                 :           7 :     error_init (loc, "array index in initializer exceeds array bounds");
   10422                 :             :   else
   10423                 :             :     {
   10424                 :        1043 :       constant_expression_warning (first);
   10425                 :        1043 :       if (last)
   10426                 :         379 :         constant_expression_warning (last);
   10427                 :        1043 :       constructor_index = convert (bitsizetype, first);
   10428                 :        1043 :       if (tree_int_cst_lt (constructor_index, first))
   10429                 :             :         {
   10430                 :           0 :           constructor_index = copy_node (constructor_index);
   10431                 :           0 :           TREE_OVERFLOW (constructor_index) = 1;
   10432                 :             :         }
   10433                 :             : 
   10434                 :        1043 :       if (last)
   10435                 :             :         {
   10436                 :         379 :           if (tree_int_cst_equal (first, last))
   10437                 :             :             last = NULL_TREE;
   10438                 :         378 :           else if (tree_int_cst_lt (last, first))
   10439                 :             :             {
   10440                 :           2 :               error_init (loc, "empty index range in initializer");
   10441                 :           2 :               last = NULL_TREE;
   10442                 :             :             }
   10443                 :             :           else
   10444                 :             :             {
   10445                 :         376 :               last = convert (bitsizetype, last);
   10446                 :         376 :               if (constructor_max_index != NULL_TREE
   10447                 :         376 :                   && tree_int_cst_lt (constructor_max_index, last))
   10448                 :             :                 {
   10449                 :           3 :                   error_init (loc, "array index range in initializer exceeds "
   10450                 :             :                               "array bounds");
   10451                 :           3 :                   last = NULL_TREE;
   10452                 :             :                 }
   10453                 :             :             }
   10454                 :             :         }
   10455                 :             : 
   10456                 :        1043 :       designator_depth++;
   10457                 :        1043 :       designator_erroneous = 0;
   10458                 :        1043 :       if (constructor_range_stack || last)
   10459                 :         373 :         push_range_stack (last, braced_init_obstack);
   10460                 :             :     }
   10461                 :             : }
   10462                 :             : 
   10463                 :             : /* Within a struct initializer, specify the next field to be initialized.  */
   10464                 :             : 
   10465                 :             : void
   10466                 :       31857 : set_init_label (location_t loc, tree fieldname, location_t fieldname_loc,
   10467                 :             :                 struct obstack *braced_init_obstack)
   10468                 :             : {
   10469                 :       31857 :   tree field;
   10470                 :             : 
   10471                 :       31857 :   if (set_designator (loc, false, braced_init_obstack))
   10472                 :             :     return;
   10473                 :             : 
   10474                 :       31840 :   designator_erroneous = 1;
   10475                 :             : 
   10476                 :       31840 :   if (!RECORD_OR_UNION_TYPE_P (constructor_type))
   10477                 :             :     {
   10478                 :           3 :       error_init (loc, "field name not in record or union initializer");
   10479                 :           3 :       return;
   10480                 :             :     }
   10481                 :             : 
   10482                 :       31837 :   field = lookup_field (constructor_type, fieldname);
   10483                 :             : 
   10484                 :       31837 :   if (field == NULL_TREE)
   10485                 :             :     {
   10486                 :           8 :       tree guessed_id = lookup_field_fuzzy (constructor_type, fieldname);
   10487                 :           8 :       if (guessed_id)
   10488                 :             :         {
   10489                 :           4 :           gcc_rich_location rich_loc (fieldname_loc);
   10490                 :           4 :           rich_loc.add_fixit_misspelled_id (fieldname_loc, guessed_id);
   10491                 :           4 :           error_at (&rich_loc,
   10492                 :             :                     "%qT has no member named %qE; did you mean %qE?",
   10493                 :             :                     constructor_type, fieldname, guessed_id);
   10494                 :           4 :         }
   10495                 :             :       else
   10496                 :           4 :         error_at (fieldname_loc, "%qT has no member named %qE",
   10497                 :             :                   constructor_type, fieldname);
   10498                 :             :     }
   10499                 :             :   else
   10500                 :       31874 :     do
   10501                 :             :       {
   10502                 :       31874 :         constructor_fields = TREE_VALUE (field);
   10503                 :       31874 :         designator_depth++;
   10504                 :       31874 :         designator_erroneous = 0;
   10505                 :       31874 :         if (constructor_range_stack)
   10506                 :          11 :           push_range_stack (NULL_TREE, braced_init_obstack);
   10507                 :       31874 :         field = TREE_CHAIN (field);
   10508                 :       31874 :         if (field)
   10509                 :             :           {
   10510                 :          45 :             if (set_designator (loc, false, braced_init_obstack))
   10511                 :             :               return;
   10512                 :             :           }
   10513                 :             :       }
   10514                 :       31874 :     while (field != NULL_TREE);
   10515                 :             : }
   10516                 :             : 
   10517                 :             : /* Helper function for add_pending_init.  Find inorder successor of P
   10518                 :             :    in AVL tree.  */
   10519                 :             : static struct init_node *
   10520                 :         129 : init_node_successor (struct init_node *p)
   10521                 :             : {
   10522                 :         129 :   struct init_node *r;
   10523                 :         129 :   if (p->right)
   10524                 :             :     {
   10525                 :             :       r = p->right;
   10526                 :          58 :       while (r->left)
   10527                 :             :         r = r->left;
   10528                 :             :       return r;
   10529                 :             :     }
   10530                 :          75 :   r = p->parent;
   10531                 :         114 :   while (r && p == r->right)
   10532                 :             :     {
   10533                 :          39 :       p = r;
   10534                 :          39 :       r = r->parent;
   10535                 :             :     }
   10536                 :             :   return r;
   10537                 :             : }
   10538                 :             : 
   10539                 :             : /* Add a new initializer to the tree of pending initializers.  PURPOSE
   10540                 :             :    identifies the initializer, either array index or field in a structure.
   10541                 :             :    VALUE is the value of that index or field.  If ORIGTYPE is not
   10542                 :             :    NULL_TREE, it is the original type of VALUE.
   10543                 :             : 
   10544                 :             :    IMPLICIT is true if value comes from pop_init_level (1),
   10545                 :             :    the new initializer has been merged with the existing one
   10546                 :             :    and thus no warnings should be emitted about overriding an
   10547                 :             :    existing initializer.  */
   10548                 :             : 
   10549                 :             : static void
   10550                 :        3130 : add_pending_init (location_t loc, tree purpose, tree value, tree origtype,
   10551                 :             :                   bool implicit, struct obstack *braced_init_obstack)
   10552                 :             : {
   10553                 :        3130 :   struct init_node *p, **q, *r;
   10554                 :             : 
   10555                 :        3130 :   q = &constructor_pending_elts;
   10556                 :        3130 :   p = 0;
   10557                 :             : 
   10558                 :        3130 :   if (TREE_CODE (constructor_type) == ARRAY_TYPE)
   10559                 :             :     {
   10560                 :        3492 :       while (*q != 0)
   10561                 :             :         {
   10562                 :        2356 :           p = *q;
   10563                 :        2356 :           if (tree_int_cst_lt (purpose, p->purpose))
   10564                 :         263 :             q = &p->left;
   10565                 :        2093 :           else if (tree_int_cst_lt (p->purpose, purpose))
   10566                 :             :             {
   10567                 :        1936 :               if (TREE_CODE (p->value) != RAW_DATA_CST
   10568                 :        1936 :                   || (p->right
   10569                 :         112 :                       && tree_int_cst_le (p->right->purpose, purpose)))
   10570                 :        1806 :                 q = &p->right;
   10571                 :             :               else
   10572                 :             :                 {
   10573                 :         130 :                   widest_int pp = wi::to_widest (p->purpose);
   10574                 :         130 :                   widest_int pw = wi::to_widest (purpose);
   10575                 :         130 :                   if (pp + RAW_DATA_LENGTH (p->value) <= pw)
   10576                 :          98 :                     q = &p->right;
   10577                 :             :                   else
   10578                 :             :                     {
   10579                 :             :                       /* Override which should split the old RAW_DATA_CST
   10580                 :             :                          into 2 or 3 pieces.  */
   10581                 :          32 :                       if (!implicit && warn_override_init)
   10582                 :           9 :                         warning_init (loc, OPT_Woverride_init,
   10583                 :             :                                       "initialized field overwritten");
   10584                 :          32 :                       unsigned HOST_WIDE_INT start = (pw - pp).to_uhwi ();
   10585                 :          32 :                       unsigned HOST_WIDE_INT len = 1;
   10586                 :          32 :                       if (TREE_CODE (value) == RAW_DATA_CST)
   10587                 :           0 :                         len = RAW_DATA_LENGTH (value);
   10588                 :          32 :                       unsigned HOST_WIDE_INT end = 0;
   10589                 :          32 :                       unsigned plen = RAW_DATA_LENGTH (p->value);
   10590                 :          32 :                       gcc_checking_assert (start < plen && start);
   10591                 :          32 :                       if (plen - start > len)
   10592                 :          30 :                         end = plen - start - len;
   10593                 :          32 :                       tree v = p->value;
   10594                 :          32 :                       tree origtype = p->origtype;
   10595                 :          32 :                       if (start == 1)
   10596                 :           2 :                         p->value = build_int_cst (TREE_TYPE (v),
   10597                 :           2 :                                                   RAW_DATA_UCHAR_ELT (v, 0));
   10598                 :             :                       else
   10599                 :             :                         {
   10600                 :          30 :                           p->value = v;
   10601                 :          30 :                           if (end > 1)
   10602                 :          26 :                             v = copy_node (v);
   10603                 :          30 :                           RAW_DATA_LENGTH (p->value) = start;
   10604                 :             :                         }
   10605                 :          32 :                       if (end)
   10606                 :             :                         {
   10607                 :          30 :                           tree epurpose
   10608                 :          30 :                             = size_binop (PLUS_EXPR, purpose,
   10609                 :             :                                           bitsize_int (len));
   10610                 :          30 :                           if (end > 1)
   10611                 :             :                             {
   10612                 :          28 :                               RAW_DATA_LENGTH (v) -= plen - end;
   10613                 :          28 :                               RAW_DATA_POINTER (v) += plen - end;
   10614                 :             :                             }
   10615                 :             :                           else
   10616                 :           4 :                             v = build_int_cst (TREE_TYPE (v),
   10617                 :           2 :                                                RAW_DATA_UCHAR_ELT (v, plen
   10618                 :             :                                                                       - end));
   10619                 :          30 :                           add_pending_init (loc, epurpose, v, origtype,
   10620                 :             :                                             implicit, braced_init_obstack);
   10621                 :             :                         }
   10622                 :          32 :                       q = &constructor_pending_elts;
   10623                 :          32 :                       continue;
   10624                 :          32 :                     }
   10625                 :         130 :                 }
   10626                 :             :             }
   10627                 :             :           else
   10628                 :             :             {
   10629                 :         157 :               if (TREE_CODE (p->value) == RAW_DATA_CST
   10630                 :         167 :                   && (RAW_DATA_LENGTH (p->value)
   10631                 :          10 :                       > (TREE_CODE (value) == RAW_DATA_CST
   10632                 :          10 :                          ? RAW_DATA_LENGTH (value) : 1)))
   10633                 :             :                 {
   10634                 :             :                   /* Override which should split the old RAW_DATA_CST
   10635                 :             :                      into 2 pieces.  */
   10636                 :           6 :                   if (!implicit && warn_override_init)
   10637                 :           3 :                     warning_init (loc, OPT_Woverride_init,
   10638                 :             :                                   "initialized field overwritten");
   10639                 :           6 :                   unsigned HOST_WIDE_INT len = 1;
   10640                 :           6 :                   if (TREE_CODE (value) == RAW_DATA_CST)
   10641                 :           2 :                     len = RAW_DATA_LENGTH (value);
   10642                 :           6 :                   if ((unsigned) RAW_DATA_LENGTH (p->value) > len + 1)
   10643                 :             :                     {
   10644                 :           6 :                       RAW_DATA_LENGTH (p->value) -= len;
   10645                 :           6 :                       RAW_DATA_POINTER (p->value) += len;
   10646                 :             :                     }
   10647                 :             :                   else
   10648                 :             :                     {
   10649                 :           0 :                       unsigned int l = RAW_DATA_LENGTH (p->value) - 1;
   10650                 :           0 :                       p->value
   10651                 :           0 :                         = build_int_cst (TREE_TYPE (p->value),
   10652                 :           0 :                                          RAW_DATA_UCHAR_ELT (p->value, l));
   10653                 :             :                     }
   10654                 :           6 :                   p->purpose = size_binop (PLUS_EXPR, p->purpose,
   10655                 :             :                                            bitsize_int (len));
   10656                 :           6 :                   continue;
   10657                 :           6 :                 }
   10658                 :         151 :               if (TREE_CODE (value) == RAW_DATA_CST)
   10659                 :             :                 {
   10660                 :           8 :                 handle_raw_data:
   10661                 :             :                   /* RAW_DATA_CST value might overlap various further
   10662                 :             :                      prior initval entries.  Find out how many.  */
   10663                 :          13 :                   unsigned cnt = 0;
   10664                 :          13 :                   widest_int w
   10665                 :          26 :                     = wi::to_widest (purpose) + RAW_DATA_LENGTH (value);
   10666                 :          13 :                   struct init_node *r = p, *last = NULL;
   10667                 :          13 :                   bool override_init = warn_override_init;
   10668                 :          13 :                   while ((r = init_node_successor (r))
   10669                 :          53 :                          && wi::to_widest (r->purpose) < w)
   10670                 :             :                     {
   10671                 :          40 :                       ++cnt;
   10672                 :          40 :                       if (TREE_SIDE_EFFECTS (r->value))
   10673                 :           2 :                         warning_init (loc, OPT_Woverride_init_side_effects,
   10674                 :             :                                       "initialized field with side-effects "
   10675                 :             :                                       "overwritten");
   10676                 :          38 :                       else if (override_init)
   10677                 :             :                         {
   10678                 :           6 :                           warning_init (loc, OPT_Woverride_init,
   10679                 :             :                                         "initialized field overwritten");
   10680                 :           6 :                           override_init = false;
   10681                 :             :                         }
   10682                 :             :                       last = r;
   10683                 :             :                     }
   10684                 :          13 :                   if (cnt)
   10685                 :             :                     {
   10686                 :          26 :                       if (TREE_CODE (last->value) == RAW_DATA_CST
   10687                 :          13 :                           && (wi::to_widest (last->purpose)
   10688                 :          13 :                               + RAW_DATA_LENGTH (last->value) > w))
   10689                 :             :                         {
   10690                 :             :                           /* The last overlapping prior initval overlaps
   10691                 :             :                              only partially.  Shrink it and decrease cnt.  */
   10692                 :           0 :                           unsigned int l = (wi::to_widest (last->purpose)
   10693                 :           0 :                                             + RAW_DATA_LENGTH (last->value)
   10694                 :           0 :                                             - w).to_uhwi ();
   10695                 :           0 :                           --cnt;
   10696                 :           0 :                           RAW_DATA_LENGTH (last->value) -= l;
   10697                 :           0 :                           RAW_DATA_POINTER (last->value) += l;
   10698                 :           0 :                           if (RAW_DATA_LENGTH (last->value) == 1)
   10699                 :           0 :                             last->value
   10700                 :           0 :                               = build_int_cst (TREE_TYPE (last->value),
   10701                 :           0 :                                                RAW_DATA_UCHAR_ELT (last->value,
   10702                 :             :                                                                    0));
   10703                 :           0 :                           last->purpose
   10704                 :           0 :                             = size_binop (PLUS_EXPR, last->purpose,
   10705                 :             :                                           bitsize_int (l));
   10706                 :             :                         }
   10707                 :             :                       /* Instead of deleting cnt nodes from the AVL tree
   10708                 :             :                          and rebalancing, peel of last cnt bytes from the
   10709                 :             :                          RAW_DATA_CST.  Overriding thousands of previously
   10710                 :             :                          initialized array elements with #embed needs to work,
   10711                 :             :                          but doesn't need to be super efficient.  */
   10712                 :          13 :                       gcc_checking_assert ((unsigned) RAW_DATA_LENGTH (value)
   10713                 :             :                                            > cnt);
   10714                 :          13 :                       RAW_DATA_LENGTH (value) -= cnt;
   10715                 :          13 :                       const unsigned char *s
   10716                 :          13 :                         = &RAW_DATA_UCHAR_ELT (value, RAW_DATA_LENGTH (value));
   10717                 :          13 :                       unsigned int o = RAW_DATA_LENGTH (value);
   10718                 :          53 :                       for (r = p; cnt--; ++o, ++s)
   10719                 :             :                         {
   10720                 :          40 :                           r = init_node_successor (r);
   10721                 :          40 :                           r->purpose = size_binop (PLUS_EXPR, purpose,
   10722                 :             :                                                    bitsize_int (o));
   10723                 :          40 :                           r->value = build_int_cst (TREE_TYPE (value), *s);
   10724                 :          40 :                           r->origtype = origtype;
   10725                 :             :                         }
   10726                 :          13 :                       if (RAW_DATA_LENGTH (value) == 1)
   10727                 :           0 :                         value = build_int_cst (TREE_TYPE (value),
   10728                 :           0 :                                                RAW_DATA_UCHAR_ELT (value, 0));
   10729                 :             :                     }
   10730                 :             :                 }
   10731                 :         156 :               if (!implicit)
   10732                 :             :                 {
   10733                 :          54 :                   if (TREE_SIDE_EFFECTS (p->value))
   10734                 :           6 :                     warning_init (loc, OPT_Woverride_init_side_effects,
   10735                 :             :                                   "initialized field with side-effects "
   10736                 :             :                                   "overwritten");
   10737                 :          48 :                   else if (warn_override_init)
   10738                 :          13 :                     warning_init (loc, OPT_Woverride_init,
   10739                 :             :                                   "initialized field overwritten");
   10740                 :             :                 }
   10741                 :         156 :               p->value = value;
   10742                 :         156 :               p->origtype = origtype;
   10743                 :         156 :               return;
   10744                 :             :             }
   10745                 :             :         }
   10746                 :        1136 :       if (TREE_CODE (value) == RAW_DATA_CST && p)
   10747                 :             :         {
   10748                 :          61 :           struct init_node *r;
   10749                 :          61 :           if (q == &p->left)
   10750                 :             :             r = p;
   10751                 :             :           else
   10752                 :          36 :             r = init_node_successor (p);
   10753                 :         131 :           if (r && wi::to_widest (r->purpose) < (wi::to_widest (purpose)
   10754                 :         131 :                                                  + RAW_DATA_LENGTH (value)))
   10755                 :             :             {
   10756                 :             :               /* Overlap with at least one prior initval in the range but
   10757                 :             :                  not at the start.  */
   10758                 :           5 :               p = r;
   10759                 :           5 :               p->purpose = purpose;
   10760                 :           5 :               goto handle_raw_data;
   10761                 :             :             }
   10762                 :             :         }
   10763                 :             :     }
   10764                 :             :   else
   10765                 :             :     {
   10766                 :        1843 :       tree bitpos;
   10767                 :             : 
   10768                 :        1843 :       bitpos = bit_position (purpose);
   10769                 :        5182 :       while (*q != NULL)
   10770                 :             :         {
   10771                 :        1743 :           p = *q;
   10772                 :        1743 :           if (tree_int_cst_lt (bitpos, bit_position (p->purpose)))
   10773                 :          32 :             q = &p->left;
   10774                 :        1711 :           else if (p->purpose != purpose)
   10775                 :        1464 :             q = &p->right;
   10776                 :             :           else
   10777                 :             :             {
   10778                 :         247 :               if (!implicit)
   10779                 :             :                 {
   10780                 :          33 :                   if (TREE_SIDE_EFFECTS (p->value))
   10781                 :           4 :                     warning_init (loc, OPT_Woverride_init_side_effects,
   10782                 :             :                                   "initialized field with side-effects "
   10783                 :             :                                   "overwritten");
   10784                 :          29 :                   else if (warn_override_init)
   10785                 :           6 :                     warning_init (loc, OPT_Woverride_init,
   10786                 :             :                                   "initialized field overwritten");
   10787                 :             :                 }
   10788                 :         247 :               p->value = value;
   10789                 :         247 :               p->origtype = origtype;
   10790                 :         247 :               return;
   10791                 :             :             }
   10792                 :             :         }
   10793                 :             :     }
   10794                 :             : 
   10795                 :        2727 :   r = (struct init_node *) obstack_alloc (braced_init_obstack,
   10796                 :             :                                           sizeof (struct init_node));
   10797                 :        2727 :   r->purpose = purpose;
   10798                 :        2727 :   r->value = value;
   10799                 :        2727 :   r->origtype = origtype;
   10800                 :             : 
   10801                 :        2727 :   *q = r;
   10802                 :        2727 :   r->parent = p;
   10803                 :        2727 :   r->left = 0;
   10804                 :        2727 :   r->right = 0;
   10805                 :        2727 :   r->balance = 0;
   10806                 :             : 
   10807                 :        4664 :   while (p)
   10808                 :             :     {
   10809                 :        2694 :       struct init_node *s;
   10810                 :             : 
   10811                 :        2694 :       if (r == p->left)
   10812                 :             :         {
   10813                 :         214 :           if (p->balance == 0)
   10814                 :         155 :             p->balance = -1;
   10815                 :          59 :           else if (p->balance < 0)
   10816                 :             :             {
   10817                 :          41 :               if (r->balance < 0)
   10818                 :             :                 {
   10819                 :             :                   /* L rotation.  */
   10820                 :          38 :                   p->left = r->right;
   10821                 :          38 :                   if (p->left)
   10822                 :           2 :                     p->left->parent = p;
   10823                 :          38 :                   r->right = p;
   10824                 :             : 
   10825                 :          38 :                   p->balance = 0;
   10826                 :          38 :                   r->balance = 0;
   10827                 :             : 
   10828                 :          38 :                   s = p->parent;
   10829                 :          38 :                   p->parent = r;
   10830                 :          38 :                   r->parent = s;
   10831                 :          38 :                   if (s)
   10832                 :             :                     {
   10833                 :          31 :                       if (s->left == p)
   10834                 :          10 :                         s->left = r;
   10835                 :             :                       else
   10836                 :          21 :                         s->right = r;
   10837                 :             :                     }
   10838                 :             :                   else
   10839                 :           7 :                     constructor_pending_elts = r;
   10840                 :             :                 }
   10841                 :             :               else
   10842                 :             :                 {
   10843                 :             :                   /* LR rotation.  */
   10844                 :           3 :                   struct init_node *t = r->right;
   10845                 :             : 
   10846                 :           3 :                   r->right = t->left;
   10847                 :           3 :                   if (r->right)
   10848                 :           0 :                     r->right->parent = r;
   10849                 :           3 :                   t->left = r;
   10850                 :             : 
   10851                 :           3 :                   p->left = t->right;
   10852                 :           3 :                   if (p->left)
   10853                 :           0 :                     p->left->parent = p;
   10854                 :           3 :                   t->right = p;
   10855                 :             : 
   10856                 :           3 :                   p->balance = t->balance < 0;
   10857                 :           3 :                   r->balance = -(t->balance > 0);
   10858                 :           3 :                   t->balance = 0;
   10859                 :             : 
   10860                 :           3 :                   s = p->parent;
   10861                 :           3 :                   p->parent = t;
   10862                 :           3 :                   r->parent = t;
   10863                 :           3 :                   t->parent = s;
   10864                 :           3 :                   if (s)
   10865                 :             :                     {
   10866                 :           0 :                       if (s->left == p)
   10867                 :           0 :                         s->left = t;
   10868                 :             :                       else
   10869                 :           0 :                         s->right = t;
   10870                 :             :                     }
   10871                 :             :                   else
   10872                 :           3 :                     constructor_pending_elts = t;
   10873                 :             :                 }
   10874                 :             :               break;
   10875                 :             :             }
   10876                 :             :           else
   10877                 :             :             {
   10878                 :             :               /* p->balance == +1; growth of left side balances the node.  */
   10879                 :          18 :               p->balance = 0;
   10880                 :          18 :               break;
   10881                 :             :             }
   10882                 :             :         }
   10883                 :             :       else /* r == p->right */
   10884                 :             :         {
   10885                 :        2480 :           if (p->balance == 0)
   10886                 :             :             /* Growth propagation from right side.  */
   10887                 :        1782 :             p->balance++;
   10888                 :         698 :           else if (p->balance > 0)
   10889                 :             :             {
   10890                 :         670 :               if (r->balance > 0)
   10891                 :             :                 {
   10892                 :             :                   /* R rotation.  */
   10893                 :         668 :                   p->right = r->left;
   10894                 :         668 :                   if (p->right)
   10895                 :         166 :                     p->right->parent = p;
   10896                 :         668 :                   r->left = p;
   10897                 :             : 
   10898                 :         668 :                   p->balance = 0;
   10899                 :         668 :                   r->balance = 0;
   10900                 :             : 
   10901                 :         668 :                   s = p->parent;
   10902                 :         668 :                   p->parent = r;
   10903                 :         668 :                   r->parent = s;
   10904                 :         668 :                   if (s)
   10905                 :             :                     {
   10906                 :         364 :                       if (s->left == p)
   10907                 :           2 :                         s->left = r;
   10908                 :             :                       else
   10909                 :         362 :                         s->right = r;
   10910                 :             :                     }
   10911                 :             :                   else
   10912                 :         304 :                     constructor_pending_elts = r;
   10913                 :             :                 }
   10914                 :             :               else /* r->balance == -1 */
   10915                 :             :                 {
   10916                 :             :                   /* RL rotation */
   10917                 :           2 :                   struct init_node *t = r->left;
   10918                 :             : 
   10919                 :           2 :                   r->left = t->right;
   10920                 :           2 :                   if (r->left)
   10921                 :           2 :                     r->left->parent = r;
   10922                 :           2 :                   t->right = r;
   10923                 :             : 
   10924                 :           2 :                   p->right = t->left;
   10925                 :           2 :                   if (p->right)
   10926                 :           2 :                     p->right->parent = p;
   10927                 :           2 :                   t->left = p;
   10928                 :             : 
   10929                 :           2 :                   r->balance = (t->balance < 0);
   10930                 :           2 :                   p->balance = -(t->balance > 0);
   10931                 :           2 :                   t->balance = 0;
   10932                 :             : 
   10933                 :           2 :                   s = p->parent;
   10934                 :           2 :                   p->parent = t;
   10935                 :           2 :                   r->parent = t;
   10936                 :           2 :                   t->parent = s;
   10937                 :           2 :                   if (s)
   10938                 :             :                     {
   10939                 :           0 :                       if (s->left == p)
   10940                 :           0 :                         s->left = t;
   10941                 :             :                       else
   10942                 :           0 :                         s->right = t;
   10943                 :             :                     }
   10944                 :             :                   else
   10945                 :           2 :                     constructor_pending_elts = t;
   10946                 :             :                 }
   10947                 :             :               break;
   10948                 :             :             }
   10949                 :             :           else
   10950                 :             :             {
   10951                 :             :               /* p->balance == -1; growth of right side balances the node.  */
   10952                 :          28 :               p->balance = 0;
   10953                 :          28 :               break;
   10954                 :             :             }
   10955                 :             :         }
   10956                 :             : 
   10957                 :        1937 :       r = p;
   10958                 :        1937 :       p = p->parent;
   10959                 :             :     }
   10960                 :             : }
   10961                 :             : 
   10962                 :             : /* Build AVL tree from a sorted chain.  */
   10963                 :             : 
   10964                 :             : static void
   10965                 :         398 : set_nonincremental_init (struct obstack * braced_init_obstack)
   10966                 :             : {
   10967                 :         398 :   unsigned HOST_WIDE_INT ix;
   10968                 :         398 :   tree index, value;
   10969                 :             : 
   10970                 :         398 :   if (TREE_CODE (constructor_type) != RECORD_TYPE
   10971                 :         398 :       && TREE_CODE (constructor_type) != ARRAY_TYPE)
   10972                 :             :     return;
   10973                 :             : 
   10974                 :        1543 :   FOR_EACH_CONSTRUCTOR_ELT (constructor_elements, ix, index, value)
   10975                 :        1145 :     add_pending_init (input_location, index, value, NULL_TREE, true,
   10976                 :             :                       braced_init_obstack);
   10977                 :         398 :   constructor_elements = NULL;
   10978                 :         398 :   if (TREE_CODE (constructor_type) == RECORD_TYPE)
   10979                 :             :     {
   10980                 :         198 :       constructor_unfilled_fields = TYPE_FIELDS (constructor_type);
   10981                 :             :       /* Skip any nameless bit fields at the beginning.  */
   10982                 :         198 :       while (constructor_unfilled_fields != NULL_TREE
   10983                 :         198 :              && DECL_UNNAMED_BIT_FIELD (constructor_unfilled_fields))
   10984                 :           0 :         constructor_unfilled_fields = TREE_CHAIN (constructor_unfilled_fields);
   10985                 :             : 
   10986                 :             :     }
   10987                 :         200 :   else if (TREE_CODE (constructor_type) == ARRAY_TYPE)
   10988                 :             :     {
   10989                 :         200 :       if (TYPE_DOMAIN (constructor_type))
   10990                 :         144 :         constructor_unfilled_index
   10991                 :         144 :           = convert (bitsizetype,
   10992                 :         144 :                      TYPE_MIN_VALUE (TYPE_DOMAIN (constructor_type)));
   10993                 :             :       else
   10994                 :          56 :         constructor_unfilled_index = bitsize_zero_node;
   10995                 :             :     }
   10996                 :         398 :   constructor_incremental = 0;
   10997                 :             : }
   10998                 :             : 
   10999                 :             : /* Build AVL tree from a string constant.  */
   11000                 :             : 
   11001                 :             : static void
   11002                 :           7 : set_nonincremental_init_from_string (tree str,
   11003                 :             :                                      struct obstack * braced_init_obstack)
   11004                 :             : {
   11005                 :           7 :   tree value, purpose, type;
   11006                 :           7 :   HOST_WIDE_INT val[2];
   11007                 :           7 :   const char *p, *end;
   11008                 :           7 :   int byte, wchar_bytes, charwidth, bitpos;
   11009                 :             : 
   11010                 :           7 :   gcc_assert (TREE_CODE (constructor_type) == ARRAY_TYPE);
   11011                 :             : 
   11012                 :           7 :   wchar_bytes = TYPE_PRECISION (TREE_TYPE (TREE_TYPE (str))) / BITS_PER_UNIT;
   11013                 :           7 :   charwidth = TYPE_PRECISION (char_type_node);
   11014                 :           7 :   gcc_assert ((size_t) wchar_bytes * charwidth
   11015                 :             :               <= ARRAY_SIZE (val) * HOST_BITS_PER_WIDE_INT);
   11016                 :           7 :   type = TREE_TYPE (constructor_type);
   11017                 :           7 :   p = TREE_STRING_POINTER (str);
   11018                 :           7 :   end = p + TREE_STRING_LENGTH (str);
   11019                 :             : 
   11020                 :           7 :   for (purpose = bitsize_zero_node;
   11021                 :             :        p < end
   11022                 :          52 :        && !(constructor_max_index
   11023                 :          20 :             && tree_int_cst_lt (constructor_max_index, purpose));
   11024                 :          25 :        purpose = size_binop (PLUS_EXPR, purpose, bitsize_one_node))
   11025                 :             :     {
   11026                 :          25 :       if (wchar_bytes == 1)
   11027                 :             :         {
   11028                 :           9 :           val[0] = (unsigned char) *p++;
   11029                 :           9 :           val[1] = 0;
   11030                 :             :         }
   11031                 :             :       else
   11032                 :             :         {
   11033                 :          16 :           val[1] = 0;
   11034                 :          16 :           val[0] = 0;
   11035                 :          64 :           for (byte = 0; byte < wchar_bytes; byte++)
   11036                 :             :             {
   11037                 :          48 :               if (BYTES_BIG_ENDIAN)
   11038                 :             :                 bitpos = (wchar_bytes - byte - 1) * charwidth;
   11039                 :             :               else
   11040                 :          48 :                 bitpos = byte * charwidth;
   11041                 :          48 :               val[bitpos / HOST_BITS_PER_WIDE_INT]
   11042                 :          48 :                 |= ((unsigned HOST_WIDE_INT) ((unsigned char) *p++))
   11043                 :          48 :                    << (bitpos % HOST_BITS_PER_WIDE_INT);
   11044                 :             :             }
   11045                 :             :         }
   11046                 :             : 
   11047                 :          25 :       if (!TYPE_UNSIGNED (type))
   11048                 :             :         {
   11049                 :          13 :           bitpos = ((wchar_bytes - 1) * charwidth) + HOST_BITS_PER_CHAR;
   11050                 :          13 :           if (bitpos < HOST_BITS_PER_WIDE_INT)
   11051                 :             :             {
   11052                 :          13 :               if (val[0] & (HOST_WIDE_INT_1 << (bitpos - 1)))
   11053                 :             :                 {
   11054                 :           0 :                   val[0] |= HOST_WIDE_INT_M1U << bitpos;
   11055                 :           0 :                   val[1] = -1;
   11056                 :             :                 }
   11057                 :             :             }
   11058                 :           0 :           else if (bitpos == HOST_BITS_PER_WIDE_INT)
   11059                 :             :             {
   11060                 :           0 :               if (val[0] < 0)
   11061                 :           0 :                 val[1] = -1;
   11062                 :             :             }
   11063                 :           0 :           else if (val[1] & (HOST_WIDE_INT_1
   11064                 :           0 :                              << (bitpos - 1 - HOST_BITS_PER_WIDE_INT)))
   11065                 :           0 :             val[1] |= HOST_WIDE_INT_M1U << (bitpos - HOST_BITS_PER_WIDE_INT);
   11066                 :             :         }
   11067                 :             : 
   11068                 :          25 :       value = wide_int_to_tree (type,
   11069                 :          25 :                                 wide_int::from_array (val, 2,
   11070                 :             :                                                       HOST_BITS_PER_WIDE_INT * 2));
   11071                 :          25 :       add_pending_init (input_location, purpose, value, NULL_TREE, true,
   11072                 :             :                         braced_init_obstack);
   11073                 :             :     }
   11074                 :             : 
   11075                 :           7 :   constructor_incremental = 0;
   11076                 :           7 : }
   11077                 :             : 
   11078                 :             : /* Return value of FIELD in pending initializer or NULL_TREE if the field was
   11079                 :             :    not initialized yet.  */
   11080                 :             : 
   11081                 :             : static tree
   11082                 :      703522 : find_init_member (tree field, struct obstack * braced_init_obstack)
   11083                 :             : {
   11084                 :      703522 :   struct init_node *p;
   11085                 :             : 
   11086                 :      703522 :   if (TREE_CODE (constructor_type) == ARRAY_TYPE)
   11087                 :             :     {
   11088                 :      702752 :       if (constructor_incremental
   11089                 :      702752 :           && tree_int_cst_lt (field, constructor_unfilled_index))
   11090                 :          14 :         set_nonincremental_init (braced_init_obstack);
   11091                 :             : 
   11092                 :      702752 :       p = constructor_pending_elts;
   11093                 :      702861 :       while (p)
   11094                 :             :         {
   11095                 :         209 :           if (tree_int_cst_lt (field, p->purpose))
   11096                 :          13 :             p = p->left;
   11097                 :         196 :           else if (tree_int_cst_lt (p->purpose, field))
   11098                 :          96 :             p = p->right;
   11099                 :             :           else
   11100                 :         100 :             return p->value;
   11101                 :             :         }
   11102                 :             :     }
   11103                 :         770 :   else if (TREE_CODE (constructor_type) == RECORD_TYPE)
   11104                 :             :     {
   11105                 :         651 :       tree bitpos = bit_position (field);
   11106                 :             : 
   11107                 :         651 :       if (constructor_incremental
   11108                 :         651 :           && (!constructor_unfilled_fields
   11109                 :         450 :               || tree_int_cst_lt (bitpos,
   11110                 :         450 :                                   bit_position (constructor_unfilled_fields))))
   11111                 :          49 :         set_nonincremental_init (braced_init_obstack);
   11112                 :             : 
   11113                 :         651 :       p = constructor_pending_elts;
   11114                 :         787 :       while (p)
   11115                 :             :         {
   11116                 :         337 :           if (field == p->purpose)
   11117                 :         201 :             return p->value;
   11118                 :         136 :           else if (tree_int_cst_lt (bitpos, bit_position (p->purpose)))
   11119                 :           3 :             p = p->left;
   11120                 :             :           else
   11121                 :         133 :             p = p->right;
   11122                 :             :         }
   11123                 :             :     }
   11124                 :         119 :   else if (TREE_CODE (constructor_type) == UNION_TYPE)
   11125                 :             :     {
   11126                 :         119 :       if (!vec_safe_is_empty (constructor_elements)
   11127                 :          50 :           && (constructor_elements->last ().index == field))
   11128                 :          50 :         return constructor_elements->last ().value;
   11129                 :             :     }
   11130                 :             :   return NULL_TREE;
   11131                 :             : }
   11132                 :             : 
   11133                 :             : /* "Output" the next constructor element.
   11134                 :             :    At top level, really output it to assembler code now.
   11135                 :             :    Otherwise, collect it in a list from which we will make a CONSTRUCTOR.
   11136                 :             :    If ORIGTYPE is not NULL_TREE, it is the original type of VALUE.
   11137                 :             :    TYPE is the data type that the containing data type wants here.
   11138                 :             :    FIELD is the field (a FIELD_DECL) or the index that this element fills.
   11139                 :             :    If VALUE is a string constant, STRICT_STRING is true if it is
   11140                 :             :    unparenthesized or we should not warn here for it being parenthesized.
   11141                 :             :    For other types of VALUE, STRICT_STRING is not used.
   11142                 :             : 
   11143                 :             :    PENDING if true means output pending elements that belong
   11144                 :             :    right after this element.  (PENDING is normally true;
   11145                 :             :    it is false while outputting pending elements, to avoid recursion.)
   11146                 :             : 
   11147                 :             :    IMPLICIT is true if value comes from pop_init_level (1),
   11148                 :             :    the new initializer has been merged with the existing one
   11149                 :             :    and thus no warnings should be emitted about overriding an
   11150                 :             :    existing initializer.  */
   11151                 :             : 
   11152                 :             : static void
   11153                 :     9474115 : output_init_element (location_t loc, tree value, tree origtype,
   11154                 :             :                      bool strict_string, tree type, tree field, bool pending,
   11155                 :             :                      bool implicit, struct obstack * braced_init_obstack)
   11156                 :             : {
   11157                 :     9474115 :   tree semantic_type = NULL_TREE;
   11158                 :     9474115 :   bool maybe_const = true;
   11159                 :     9474115 :   bool npc, int_const_expr, arith_const_expr;
   11160                 :             : 
   11161                 :     9474115 :   if (type == error_mark_node || value == error_mark_node)
   11162                 :             :     {
   11163                 :         436 :       constructor_erroneous = 1;
   11164                 :        2460 :       return;
   11165                 :             :     }
   11166                 :     9473679 :   if (TREE_CODE (TREE_TYPE (value)) == ARRAY_TYPE
   11167                 :      199565 :       && (TREE_CODE (value) == STRING_CST
   11168                 :      158330 :           || TREE_CODE (value) == COMPOUND_LITERAL_EXPR)
   11169                 :       41243 :       && !(TREE_CODE (value) == STRING_CST
   11170                 :       41235 :            && TREE_CODE (type) == ARRAY_TYPE
   11171                 :        3753 :            && INTEGRAL_TYPE_P (TREE_TYPE (type)))
   11172                 :     9511169 :       && !comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (value)),
   11173                 :       37490 :                      TYPE_MAIN_VARIANT (type)))
   11174                 :       37490 :     value = array_to_pointer_conversion (input_location, value);
   11175                 :             : 
   11176                 :     9473679 :   if (TREE_CODE (value) == COMPOUND_LITERAL_EXPR
   11177                 :         178 :       && require_constant_value && pending)
   11178                 :             :     {
   11179                 :             :       /* As an extension, allow initializing objects with static storage
   11180                 :             :          duration with compound literals (which are then treated just as
   11181                 :             :          the brace enclosed list they contain).  */
   11182                 :         114 :       if (flag_isoc99)
   11183                 :          24 :         pedwarn_init (loc, OPT_Wpedantic, "initializer element is not "
   11184                 :             :                       "constant");
   11185                 :         114 :       tree decl = COMPOUND_LITERAL_EXPR_DECL (value);
   11186                 :         114 :       value = DECL_INITIAL (decl);
   11187                 :             :     }
   11188                 :             : 
   11189                 :     9473679 :   npc = null_pointer_constant_p (value);
   11190                 :    18947358 :   int_const_expr = (TREE_CODE (value) == INTEGER_CST
   11191                 :     4149557 :                     && !TREE_OVERFLOW (value)
   11192                 :    13623235 :                     && INTEGRAL_TYPE_P (TREE_TYPE (value)));
   11193                 :             :   /* Not fully determined before folding.  */
   11194                 :     9473679 :   arith_const_expr = true;
   11195                 :     9473679 :   if (TREE_CODE (value) == EXCESS_PRECISION_EXPR)
   11196                 :             :     {
   11197                 :          16 :       semantic_type = TREE_TYPE (value);
   11198                 :          16 :       value = TREE_OPERAND (value, 0);
   11199                 :             :     }
   11200                 :     9473679 :   value = c_fully_fold (value, require_constant_value, &maybe_const);
   11201                 :             :   /* TODO: this may not detect all cases of expressions folding to
   11202                 :             :      constants that are not arithmetic constant expressions.  */
   11203                 :     9473679 :   if (!maybe_const)
   11204                 :             :     arith_const_expr = false;
   11205                 :    18945097 :   else if (!INTEGRAL_TYPE_P (TREE_TYPE (value))
   11206                 :     3155165 :            && TREE_CODE (TREE_TYPE (value)) != REAL_TYPE
   11207                 :    11312826 :            && TREE_CODE (TREE_TYPE (value)) != COMPLEX_TYPE)
   11208                 :             :     arith_const_expr = false;
   11209                 :     7647262 :   else if (TREE_CODE (value) != INTEGER_CST
   11210                 :             :            && TREE_CODE (value) != REAL_CST
   11211                 :             :            && TREE_CODE (value) != COMPLEX_CST
   11212                 :             :            && TREE_CODE (value) != RAW_DATA_CST)
   11213                 :             :     arith_const_expr = false;
   11214                 :     4531426 :   else if (TREE_OVERFLOW (value))
   11215                 :     4942254 :     arith_const_expr = false;
   11216                 :             : 
   11217                 :     9473679 :   if (value == error_mark_node)
   11218                 :           0 :     constructor_erroneous = 1;
   11219                 :     9473679 :   else if (!TREE_CONSTANT (value))
   11220                 :     3135343 :     constructor_constant = 0;
   11221                 :     6338336 :   else if (!initializer_constant_valid_p (value,
   11222                 :     6338336 :                                           TREE_TYPE (value),
   11223                 :     6338336 :                                           AGGREGATE_TYPE_P (constructor_type)
   11224                 :     6338336 :                                           && TYPE_REVERSE_STORAGE_ORDER
   11225                 :             :                                              (constructor_type))
   11226                 :     6338336 :            || (RECORD_OR_UNION_TYPE_P (constructor_type)
   11227                 :     1036605 :                && DECL_C_BIT_FIELD (field)
   11228                 :        7855 :                && TREE_CODE (value) != INTEGER_CST))
   11229                 :          76 :     constructor_simple = 0;
   11230                 :     9473679 :   if (!maybe_const)
   11231                 :        1027 :     constructor_nonconst = 1;
   11232                 :             : 
   11233                 :             :   /* Digest the initializer and issue any errors about incompatible
   11234                 :             :      types before issuing errors about non-constant initializers.  */
   11235                 :     9473679 :   tree new_value = value;
   11236                 :     9473679 :   if (semantic_type)
   11237                 :          16 :     new_value = build1 (EXCESS_PRECISION_EXPR, semantic_type, value);
   11238                 :             :   /* In the case of braces around a scalar initializer, the result of
   11239                 :             :      this initializer processing goes through digest_init again at the
   11240                 :             :      outer level.  In the case of a constexpr initializer for a
   11241                 :             :      pointer, avoid converting a null pointer constant to something
   11242                 :             :      that is not a null pointer constant to avoid a spurious error
   11243                 :             :      from that second processing.  */
   11244                 :     9473679 :   if (!require_constexpr_value
   11245                 :         388 :       || !npc
   11246                 :          69 :       || TREE_CODE (constructor_type) != POINTER_TYPE)
   11247                 :     9473668 :     new_value = digest_init (loc, type, new_value, origtype, npc,
   11248                 :             :                              int_const_expr, arith_const_expr, strict_string,
   11249                 :             :                              require_constant_value, require_constexpr_value);
   11250                 :     9473679 :   if (new_value == error_mark_node)
   11251                 :             :     {
   11252                 :          76 :       constructor_erroneous = 1;
   11253                 :          76 :       return;
   11254                 :             :     }
   11255                 :     9473603 :   if (require_constant_value || require_constant_elements)
   11256                 :     2711904 :     constant_expression_warning (new_value);
   11257                 :             : 
   11258                 :             :   /* Proceed to check the constness of the original initializer.  */
   11259                 :     9473603 :   if (!initializer_constant_valid_p (value, TREE_TYPE (value)))
   11260                 :             :     {
   11261                 :     3135368 :       if (require_constant_value)
   11262                 :             :         {
   11263                 :           0 :           error_init (loc, "initializer element is not constant");
   11264                 :           0 :           value = error_mark_node;
   11265                 :             :         }
   11266                 :     3135368 :       else if (require_constant_elements)
   11267                 :          15 :         pedwarn (loc, OPT_Wpedantic,
   11268                 :             :                  "initializer element is not computable at load time");
   11269                 :             :     }
   11270                 :     6338235 :   else if (!maybe_const
   11271                 :          54 :            && (require_constant_value || require_constant_elements))
   11272                 :          28 :     pedwarn_init (loc, OPT_Wpedantic,
   11273                 :             :                   "initializer element is not a constant expression");
   11274                 :             :   /* digest_init has already carried out the additional checks
   11275                 :             :      required for 'constexpr' initializers (using the information
   11276                 :             :      passed to it about whether the original initializer was certain
   11277                 :             :      kinds of constant expression), so that check does not need to be
   11278                 :             :      repeated here.  */
   11279                 :             : 
   11280                 :             :   /* Issue -Wc++-compat warnings about initializing a bitfield with
   11281                 :             :      enum type.  */
   11282                 :     9473603 :   if (warn_cxx_compat
   11283                 :        6797 :       && field != NULL_TREE
   11284                 :        6797 :       && TREE_CODE (field) == FIELD_DECL
   11285                 :         419 :       && DECL_BIT_FIELD_TYPE (field) != NULL_TREE
   11286                 :          21 :       && (TYPE_MAIN_VARIANT (DECL_BIT_FIELD_TYPE (field))
   11287                 :          21 :           != TYPE_MAIN_VARIANT (type))
   11288                 :     9473624 :       && TREE_CODE (DECL_BIT_FIELD_TYPE (field)) == ENUMERAL_TYPE)
   11289                 :             :     {
   11290                 :          21 :       tree checktype = origtype != NULL_TREE ? origtype : TREE_TYPE (value);
   11291                 :          21 :       if (checktype != error_mark_node
   11292                 :          21 :           && (TYPE_MAIN_VARIANT (checktype)
   11293                 :          21 :               != TYPE_MAIN_VARIANT (DECL_BIT_FIELD_TYPE (field))))
   11294                 :           9 :         warning_init (loc, OPT_Wc___compat,
   11295                 :             :                       "enum conversion in initialization is invalid in C++");
   11296                 :             :     }
   11297                 :             : 
   11298                 :             :   /* If this field is empty and does not have side effects (and is not at
   11299                 :             :      the end of structure), don't do anything other than checking the
   11300                 :             :      initializer.  */
   11301                 :     9473603 :   if (field
   11302                 :     9473603 :       && (TREE_TYPE (field) == error_mark_node
   11303                 :     9473216 :           || (COMPLETE_TYPE_P (TREE_TYPE (field))
   11304                 :     9472929 :               && integer_zerop (TYPE_SIZE (TREE_TYPE (field)))
   11305                 :          62 :               && !TREE_SIDE_EFFECTS (new_value)
   11306                 :          33 :               && (TREE_CODE (constructor_type) == ARRAY_TYPE
   11307                 :          33 :                   || DECL_CHAIN (field)))))
   11308                 :          18 :     return;
   11309                 :             : 
   11310                 :             :   /* Finally, set VALUE to the initializer value digested above.  */
   11311                 :     9473585 :   value = new_value;
   11312                 :             : 
   11313                 :             :   /* If this element doesn't come next in sequence,
   11314                 :             :      put it on constructor_pending_elts.  */
   11315                 :     9473585 :   if (TREE_CODE (constructor_type) == ARRAY_TYPE
   11316                 :     9473585 :       && (!constructor_incremental
   11317                 :     1715321 :           || !tree_int_cst_equal (field, constructor_unfilled_index)
   11318                 :     1714977 :           || (TREE_CODE (value) == RAW_DATA_CST
   11319                 :         226 :               && constructor_pending_elts
   11320                 :          66 :               && pending)))
   11321                 :             :     {
   11322                 :         585 :       if (constructor_incremental
   11323                 :         585 :           && (tree_int_cst_lt (field, constructor_unfilled_index)
   11324                 :         315 :               || (TREE_CODE (value) == RAW_DATA_CST
   11325                 :          14 :                   && constructor_pending_elts
   11326                 :          14 :                   && pending)))
   11327                 :          48 :         set_nonincremental_init (braced_init_obstack);
   11328                 :             : 
   11329                 :         585 :       add_pending_init (loc, field, value, origtype, implicit,
   11330                 :             :                         braced_init_obstack);
   11331                 :         585 :       return;
   11332                 :             :     }
   11333                 :     9473000 :   else if (TREE_CODE (constructor_type) == RECORD_TYPE
   11334                 :     1037281 :            && (!constructor_incremental
   11335                 :     1036943 :                || field != constructor_unfilled_fields))
   11336                 :             :     {
   11337                 :             :       /* We do this for records but not for unions.  In a union,
   11338                 :             :          no matter which field is specified, it can be initialized
   11339                 :             :          right away since it starts at the beginning of the union.  */
   11340                 :        1345 :       if (constructor_incremental)
   11341                 :             :         {
   11342                 :        1007 :           if (!constructor_unfilled_fields)
   11343                 :           5 :             set_nonincremental_init (braced_init_obstack);
   11344                 :             :           else
   11345                 :             :             {
   11346                 :        1002 :               tree bitpos, unfillpos;
   11347                 :             : 
   11348                 :        1002 :               bitpos = bit_position (field);
   11349                 :        1002 :               unfillpos = bit_position (constructor_unfilled_fields);
   11350                 :             : 
   11351                 :        1002 :               if (tree_int_cst_lt (bitpos, unfillpos))
   11352                 :           4 :                 set_nonincremental_init (braced_init_obstack);
   11353                 :             :             }
   11354                 :             :         }
   11355                 :             : 
   11356                 :        1345 :       add_pending_init (loc, field, value, origtype, implicit,
   11357                 :             :                         braced_init_obstack);
   11358                 :        1345 :       return;
   11359                 :             :     }
   11360                 :     9471655 :   else if (TREE_CODE (constructor_type) == UNION_TYPE
   11361                 :     9471655 :            && !vec_safe_is_empty (constructor_elements))
   11362                 :             :     {
   11363                 :          62 :       if (!implicit)
   11364                 :             :         {
   11365                 :          12 :           if (TREE_SIDE_EFFECTS (constructor_elements->last ().value))
   11366                 :           3 :             warning_init (loc, OPT_Woverride_init_side_effects,
   11367                 :             :                           "initialized field with side-effects overwritten");
   11368                 :           9 :           else if (warn_override_init)
   11369                 :           6 :             warning_init (loc, OPT_Woverride_init,
   11370                 :             :                           "initialized field overwritten");
   11371                 :             :         }
   11372                 :             : 
   11373                 :             :       /* We can have just one union field set.  */
   11374                 :          62 :       constructor_elements = NULL;
   11375                 :             :     }
   11376                 :             : 
   11377                 :             :   /* Otherwise, output this element either to
   11378                 :             :      constructor_elements or to the assembler file.  */
   11379                 :             : 
   11380                 :     9471655 :   constructor_elt celt = {field, value};
   11381                 :     9471655 :   vec_safe_push (constructor_elements, celt);
   11382                 :             : 
   11383                 :             :   /* Advance the variable that indicates sequential elements output.  */
   11384                 :     9471655 :   if (TREE_CODE (constructor_type) == ARRAY_TYPE)
   11385                 :             :     {
   11386                 :     1714972 :       tree inc = bitsize_one_node;
   11387                 :     1714972 :       if (value && TREE_CODE (value) == RAW_DATA_CST)
   11388                 :         221 :         inc = bitsize_int (RAW_DATA_LENGTH (value));
   11389                 :     1714972 :       constructor_unfilled_index
   11390                 :     1714972 :         = size_binop_loc (input_location, PLUS_EXPR,
   11391                 :             :                           constructor_unfilled_index, inc);
   11392                 :             :     }
   11393                 :     7756683 :   else if (TREE_CODE (constructor_type) == RECORD_TYPE)
   11394                 :             :     {
   11395                 :     1035936 :       constructor_unfilled_fields
   11396                 :     1035936 :         = DECL_CHAIN (constructor_unfilled_fields);
   11397                 :             : 
   11398                 :             :       /* Skip any nameless bit fields.  */
   11399                 :     1035936 :       while (constructor_unfilled_fields != NULL_TREE
   11400                 :     1036037 :              && DECL_UNNAMED_BIT_FIELD (constructor_unfilled_fields))
   11401                 :         101 :         constructor_unfilled_fields
   11402                 :         101 :           = DECL_CHAIN (constructor_unfilled_fields);
   11403                 :             :     }
   11404                 :     6720747 :   else if (TREE_CODE (constructor_type) == UNION_TYPE)
   11405                 :       30249 :     constructor_unfilled_fields = NULL_TREE;
   11406                 :             : 
   11407                 :             :   /* Now output any pending elements which have become next.  */
   11408                 :     9471655 :   if (pending)
   11409                 :     9468913 :     output_pending_init_elements (0, braced_init_obstack);
   11410                 :             : }
   11411                 :             : 
   11412                 :             : /* For two FIELD_DECLs in the same chain, return -1 if field1
   11413                 :             :    comes before field2, 1 if field1 comes after field2 and
   11414                 :             :    0 if field1 == field2.  */
   11415                 :             : 
   11416                 :             : static int
   11417                 :        3855 : init_field_decl_cmp (tree field1, tree field2)
   11418                 :             : {
   11419                 :        3855 :   if (field1 == field2)
   11420                 :             :     return 0;
   11421                 :             : 
   11422                 :        2061 :   tree bitpos1 = bit_position (field1);
   11423                 :        2061 :   tree bitpos2 = bit_position (field2);
   11424                 :        2061 :   if (tree_int_cst_equal (bitpos1, bitpos2))
   11425                 :             :     {
   11426                 :             :       /* If one of the fields has non-zero bitsize, then that
   11427                 :             :          field must be the last one in a sequence of zero
   11428                 :             :          sized fields, fields after it will have bigger
   11429                 :             :          bit_position.  */
   11430                 :          22 :       if (TREE_TYPE (field1) != error_mark_node
   11431                 :          22 :           && COMPLETE_TYPE_P (TREE_TYPE (field1))
   11432                 :          44 :           && integer_nonzerop (TREE_TYPE (field1)))
   11433                 :             :         return 1;
   11434                 :          22 :       if (TREE_TYPE (field2) != error_mark_node
   11435                 :          22 :           && COMPLETE_TYPE_P (TREE_TYPE (field2))
   11436                 :          37 :           && integer_nonzerop (TREE_TYPE (field2)))
   11437                 :             :         return -1;
   11438                 :             :       /* Otherwise, fallback to DECL_CHAIN walk to find out
   11439                 :             :          which field comes earlier.  Walk chains of both
   11440                 :             :          fields, so that if field1 and field2 are close to each
   11441                 :             :          other in either order, it is found soon even for large
   11442                 :             :          sequences of zero sized fields.  */
   11443                 :             :       tree f1 = field1, f2 = field2;
   11444                 :          22 :       while (1)
   11445                 :             :         {
   11446                 :          22 :           f1 = DECL_CHAIN (f1);
   11447                 :          22 :           f2 = DECL_CHAIN (f2);
   11448                 :          22 :           if (f1 == NULL_TREE)
   11449                 :             :             {
   11450                 :           7 :               gcc_assert (f2);
   11451                 :             :               return 1;
   11452                 :             :             }
   11453                 :          15 :           if (f2 == NULL_TREE)
   11454                 :             :             return -1;
   11455                 :           1 :           if (f1 == field2)
   11456                 :             :             return -1;
   11457                 :           0 :           if (f2 == field1)
   11458                 :             :             return 1;
   11459                 :           0 :           if (!tree_int_cst_equal (bit_position (f1), bitpos1))
   11460                 :             :             return 1;
   11461                 :           0 :           if (!tree_int_cst_equal (bit_position (f2), bitpos1))
   11462                 :             :             return -1;
   11463                 :             :         }
   11464                 :             :     }
   11465                 :        2039 :   else if (tree_int_cst_lt (bitpos1, bitpos2))
   11466                 :             :     return -1;
   11467                 :             :   else
   11468                 :             :     return 1;
   11469                 :             : }
   11470                 :             : 
   11471                 :             : /* Output any pending elements which have become next.
   11472                 :             :    As we output elements, constructor_unfilled_{fields,index}
   11473                 :             :    advances, which may cause other elements to become next;
   11474                 :             :    if so, they too are output.
   11475                 :             : 
   11476                 :             :    If ALL is 0, we return when there are
   11477                 :             :    no more pending elements to output now.
   11478                 :             : 
   11479                 :             :    If ALL is 1, we output space as necessary so that
   11480                 :             :    we can output all the pending elements.  */
   11481                 :             : static void
   11482                 :    11515150 : output_pending_init_elements (int all, struct obstack * braced_init_obstack)
   11483                 :             : {
   11484                 :    11515150 :   struct init_node *elt = constructor_pending_elts;
   11485                 :    11516128 :   tree next;
   11486                 :             : 
   11487                 :    11516128 :  retry:
   11488                 :             : 
   11489                 :             :   /* Look through the whole pending tree.
   11490                 :             :      If we find an element that should be output now,
   11491                 :             :      output it.  Otherwise, set NEXT to the element
   11492                 :             :      that comes first among those still pending.  */
   11493                 :             : 
   11494                 :    11516128 :   next = NULL_TREE;
   11495                 :    11521488 :   while (elt)
   11496                 :             :     {
   11497                 :        7270 :       if (TREE_CODE (constructor_type) == ARRAY_TYPE)
   11498                 :             :         {
   11499                 :        2838 :           if (tree_int_cst_equal (elt->purpose,
   11500                 :             :                                   constructor_unfilled_index))
   11501                 :        1133 :             output_init_element (input_location, elt->value, elt->origtype,
   11502                 :        1133 :                                  true, TREE_TYPE (constructor_type),
   11503                 :             :                                  constructor_unfilled_index, false, false,
   11504                 :             :                                  braced_init_obstack);
   11505                 :        1705 :           else if (tree_int_cst_lt (constructor_unfilled_index,
   11506                 :        1705 :                                     elt->purpose))
   11507                 :             :             {
   11508                 :             :               /* Advance to the next smaller node.  */
   11509                 :         559 :               if (elt->left)
   11510                 :             :                 elt = elt->left;
   11511                 :             :               else
   11512                 :             :                 {
   11513                 :             :                   /* We have reached the smallest node bigger than the
   11514                 :             :                      current unfilled index.  Fill the space first.  */
   11515                 :         199 :                   next = elt->purpose;
   11516                 :         199 :                   break;
   11517                 :             :                 }
   11518                 :             :             }
   11519                 :             :           else
   11520                 :             :             {
   11521                 :             :               /* Advance to the next bigger node.  */
   11522                 :        1146 :               if (elt->right)
   11523                 :             :                 elt = elt->right;
   11524                 :             :               else
   11525                 :             :                 {
   11526                 :             :                   /* We have reached the biggest node in a subtree.  Find
   11527                 :             :                      the parent of it, which is the next bigger node.  */
   11528                 :        1146 :                   while (elt->parent && elt->parent->right == elt)
   11529                 :             :                     elt = elt->parent;
   11530                 :         714 :                   elt = elt->parent;
   11531                 :        1069 :                   if (elt && tree_int_cst_lt (constructor_unfilled_index,
   11532                 :         355 :                                               elt->purpose))
   11533                 :             :                     {
   11534                 :          22 :                       next = elt->purpose;
   11535                 :          22 :                       break;
   11536                 :             :                     }
   11537                 :             :                 }
   11538                 :             :             }
   11539                 :             :         }
   11540                 :        4432 :       else if (RECORD_OR_UNION_TYPE_P (constructor_type))
   11541                 :             :         {
   11542                 :             :           /* If the current record is complete we are done.  */
   11543                 :        4432 :           if (constructor_unfilled_fields == NULL_TREE)
   11544                 :             :             break;
   11545                 :             : 
   11546                 :        3603 :           int cmp = init_field_decl_cmp (constructor_unfilled_fields,
   11547                 :             :                                          elt->purpose);
   11548                 :        3603 :           if (cmp == 0)
   11549                 :        1609 :             output_init_element (input_location, elt->value, elt->origtype,
   11550                 :        1609 :                                  true, TREE_TYPE (elt->purpose),
   11551                 :             :                                  elt->purpose, false, false,
   11552                 :             :                                  braced_init_obstack);
   11553                 :        1994 :           else if (cmp < 0)
   11554                 :             :             {
   11555                 :             :               /* Advance to the next smaller node.  */
   11556                 :        1052 :               if (elt->left)
   11557                 :             :                 elt = elt->left;
   11558                 :             :               else
   11559                 :             :                 {
   11560                 :             :                   /* We have reached the smallest node bigger than the
   11561                 :             :                      current unfilled field.  Fill the space first.  */
   11562                 :         793 :                   next = elt->purpose;
   11563                 :         793 :                   break;
   11564                 :             :                 }
   11565                 :             :             }
   11566                 :             :           else
   11567                 :             :             {
   11568                 :             :               /* Advance to the next bigger node.  */
   11569                 :         942 :               if (elt->right)
   11570                 :             :                 elt = elt->right;
   11571                 :             :               else
   11572                 :             :                 {
   11573                 :             :                   /* We have reached the biggest node in a subtree.  Find
   11574                 :             :                      the parent of it, which is the next bigger node.  */
   11575                 :         678 :                   while (elt->parent && elt->parent->right == elt)
   11576                 :             :                     elt = elt->parent;
   11577                 :         490 :                   elt = elt->parent;
   11578                 :         490 :                   if (elt
   11579                 :         490 :                       && init_field_decl_cmp (constructor_unfilled_fields,
   11580                 :             :                                               elt->purpose) < 0)
   11581                 :             :                     {
   11582                 :          67 :                       next = elt->purpose;
   11583                 :          67 :                       break;
   11584                 :             :                     }
   11585                 :             :                 }
   11586                 :             :             }
   11587                 :             :         }
   11588                 :             :     }
   11589                 :             : 
   11590                 :             :   /* Ordinarily return, but not if we want to output all
   11591                 :             :      and there are elements left.  */
   11592                 :    11516128 :   if (!(all && next != NULL_TREE))
   11593                 :    11515150 :     return;
   11594                 :             : 
   11595                 :             :   /* If it's not incremental, just skip over the gap, so that after
   11596                 :             :      jumping to retry we will output the next successive element.  */
   11597                 :         978 :   if (RECORD_OR_UNION_TYPE_P (constructor_type))
   11598                 :         794 :     constructor_unfilled_fields = next;
   11599                 :         184 :   else if (TREE_CODE (constructor_type) == ARRAY_TYPE)
   11600                 :         184 :     constructor_unfilled_index = next;
   11601                 :             : 
   11602                 :             :   /* ELT now points to the node in the pending tree with the next
   11603                 :             :      initializer to output.  */
   11604                 :         978 :   goto retry;
   11605                 :             : }
   11606                 :             : 
   11607                 :             : /* Expression VALUE coincides with the start of type TYPE in a braced
   11608                 :             :    initializer.  Return true if we should treat VALUE as initializing
   11609                 :             :    the first element of TYPE, false if we should treat it as initializing
   11610                 :             :    TYPE as a whole.
   11611                 :             : 
   11612                 :             :    If the initializer is clearly invalid, the question becomes:
   11613                 :             :    which choice gives the best error message?  */
   11614                 :             : 
   11615                 :             : static bool
   11616                 :     3479814 : initialize_elementwise_p (tree type, tree value)
   11617                 :             : {
   11618                 :     3479814 :   if (type == error_mark_node || value == error_mark_node)
   11619                 :             :     return false;
   11620                 :             : 
   11621                 :     3479399 :   gcc_checking_assert (TYPE_MAIN_VARIANT (type) == type);
   11622                 :             : 
   11623                 :     3479399 :   tree value_type = TREE_TYPE (value);
   11624                 :     3479399 :   if (value_type == error_mark_node)
   11625                 :             :     return false;
   11626                 :             : 
   11627                 :             :   /* GNU vectors can be initialized elementwise.  However, treat any
   11628                 :             :      kind of vector value as initializing the vector type as a whole,
   11629                 :             :      regardless of whether the value is a GNU vector.  Such initializers
   11630                 :             :      are valid if and only if they would have been valid in a non-braced
   11631                 :             :      initializer like:
   11632                 :             : 
   11633                 :             :         TYPE foo = VALUE;
   11634                 :             : 
   11635                 :             :      so recursing into the vector type would be at best confusing or at
   11636                 :             :      worst wrong.  For example, when -flax-vector-conversions is in effect,
   11637                 :             :      it's possible to initialize a V8HI from a V4SI, even though the vectors
   11638                 :             :      have different element types and different numbers of elements.  */
   11639                 :     3479399 :   if (gnu_vector_type_p (type))
   11640                 :       19202 :     return !VECTOR_TYPE_P (value_type);
   11641                 :             : 
   11642                 :     3460197 :   if (AGGREGATE_TYPE_P (type))
   11643                 :     1740759 :     return !comptypes (type, TYPE_MAIN_VARIANT (value_type));
   11644                 :             : 
   11645                 :             :   return false;
   11646                 :             : }
   11647                 :             : 
   11648                 :             : /* Helper function for process_init_element.  Split first element of
   11649                 :             :    RAW_DATA_CST and save the rest to *RAW_DATA.  */
   11650                 :             : 
   11651                 :             : static inline tree
   11652                 :     9471250 : maybe_split_raw_data (tree value, tree *raw_data)
   11653                 :             : {
   11654                 :     9471250 :   if (value == NULL_TREE || TREE_CODE (value) != RAW_DATA_CST)
   11655                 :             :     return value;
   11656                 :         211 :   *raw_data = value;
   11657                 :         211 :   value = build_int_cst (integer_type_node,
   11658                 :         211 :                          RAW_DATA_UCHAR_ELT (*raw_data, 0));
   11659                 :         211 :   ++RAW_DATA_POINTER (*raw_data);
   11660                 :         211 :   --RAW_DATA_LENGTH (*raw_data);
   11661                 :         211 :   return value;
   11662                 :             : }
   11663                 :             : 
   11664                 :             : /* Return non-zero if c_parser_initval should attempt to optimize
   11665                 :             :    large initializers into RAW_DATA_CST.  In that case return how
   11666                 :             :    many elements to optimize at most.  */
   11667                 :             : 
   11668                 :             : unsigned
   11669                 :     2936598 : c_maybe_optimize_large_byte_initializer (void)
   11670                 :             : {
   11671                 :     2936598 :   if (!constructor_type
   11672                 :     2936528 :       || TREE_CODE (constructor_type) != ARRAY_TYPE
   11673                 :      208332 :       || constructor_stack->implicit)
   11674                 :             :     return 0;
   11675                 :      205597 :   tree elttype = TYPE_MAIN_VARIANT (TREE_TYPE (constructor_type));
   11676                 :      205597 :   if (TREE_CODE (elttype) != INTEGER_TYPE
   11677                 :      205597 :       && TREE_CODE (elttype) != BITINT_TYPE)
   11678                 :             :     return 0;
   11679                 :      183216 :   if (TYPE_PRECISION (elttype) != CHAR_BIT
   11680                 :       27840 :       || constructor_stack->replacement_value.value
   11681                 :       27840 :       || (COMPLETE_TYPE_P (constructor_type)
   11682                 :       26219 :           && !poly_int_tree_p (TYPE_SIZE (constructor_type)))
   11683                 :      211056 :       || constructor_range_stack)
   11684                 :             :     return 0;
   11685                 :       27840 :   if (constructor_max_index == NULL_TREE)
   11686                 :             :     return INT_MAX;
   11687                 :       26219 :   if (tree_int_cst_le (constructor_max_index, constructor_index)
   11688                 :       26219 :       || integer_all_onesp (constructor_max_index))
   11689                 :        4744 :     return 0;
   11690                 :       21475 :   widest_int w = wi::to_widest (constructor_max_index);
   11691                 :       21475 :   w -= wi::to_widest (constructor_index);
   11692                 :       21475 :   w += 1;
   11693                 :       21475 :   if (w < 64)
   11694                 :             :     return 0;
   11695                 :        6888 :   if (w > INT_MAX)
   11696                 :             :     return INT_MAX;
   11697                 :        6888 :   return w.to_uhwi ();
   11698                 :       21475 : }
   11699                 :             : 
   11700                 :             : /* Add one non-braced element to the current constructor level.
   11701                 :             :    This adjusts the current position within the constructor's type.
   11702                 :             :    This may also start or terminate implicit levels
   11703                 :             :    to handle a partly-braced initializer.
   11704                 :             : 
   11705                 :             :    Once this has found the correct level for the new element,
   11706                 :             :    it calls output_init_element.
   11707                 :             : 
   11708                 :             :    IMPLICIT is true if value comes from pop_init_level (1),
   11709                 :             :    the new initializer has been merged with the existing one
   11710                 :             :    and thus no warnings should be emitted about overriding an
   11711                 :             :    existing initializer.  */
   11712                 :             : 
   11713                 :             : void
   11714                 :     9462255 : process_init_element (location_t loc, struct c_expr value, bool implicit,
   11715                 :             :                       struct obstack * braced_init_obstack)
   11716                 :             : {
   11717                 :     9462255 :   tree orig_value = value.value;
   11718                 :    18924510 :   int string_flag
   11719                 :     9462255 :     = (orig_value != NULL_TREE && TREE_CODE (orig_value) == STRING_CST);
   11720                 :     9462255 :   bool strict_string = value.original_code == STRING_CST;
   11721                 :     9462255 :   bool was_designated = designator_depth != 0;
   11722                 :     9462255 :   tree raw_data = NULL_TREE;
   11723                 :             : 
   11724                 :     9462467 : retry:
   11725                 :     9462467 :   designator_depth = 0;
   11726                 :     9462467 :   designator_erroneous = 0;
   11727                 :             : 
   11728                 :     9462467 :   if (!implicit && value.value && !integer_zerop (value.value))
   11729                 :     7461650 :     constructor_zeroinit = 0;
   11730                 :             : 
   11731                 :             :   /* Handle superfluous braces around string cst as in
   11732                 :             :      char x[] = {"foo"}; */
   11733                 :     9462467 :   if (constructor_type
   11734                 :     9462339 :       && !was_designated
   11735                 :     9429421 :       && TREE_CODE (constructor_type) == ARRAY_TYPE
   11736                 :     1703577 :       && INTEGRAL_TYPE_P (TREE_TYPE (constructor_type))
   11737                 :    10197590 :       && integer_zerop (constructor_unfilled_index))
   11738                 :             :     {
   11739                 :      162723 :       if (constructor_stack->replacement_value.value)
   11740                 :             :         {
   11741                 :           8 :           error_init (loc, "excess elements in %qT initializer", constructor_type);
   11742                 :         375 :           return;
   11743                 :             :         }
   11744                 :      162715 :       else if (string_flag)
   11745                 :             :         {
   11746                 :         102 :           constructor_stack->replacement_value = value;
   11747                 :         102 :           return;
   11748                 :             :         }
   11749                 :             :     }
   11750                 :             : 
   11751                 :     9462357 :   if (constructor_stack->replacement_value.value != NULL_TREE)
   11752                 :             :     {
   11753                 :           0 :       error_init (loc, "excess elements in struct initializer");
   11754                 :           0 :       return;
   11755                 :             :     }
   11756                 :             : 
   11757                 :             :   /* Ignore elements of a brace group if it is entirely superfluous
   11758                 :             :      and has already been diagnosed, or if the type is erroneous.  */
   11759                 :     9462357 :   if (constructor_type == NULL_TREE || constructor_type == error_mark_node)
   11760                 :             :     return;
   11761                 :             : 
   11762                 :             :   /* Ignore elements of an initializer for a variable-size type.
   11763                 :             :      Those are diagnosed in the parser (empty initializer braces are OK).  */
   11764                 :     9462152 :   if (COMPLETE_TYPE_P (constructor_type)
   11765                 :     9462152 :       && !poly_int_tree_p (TYPE_SIZE (constructor_type)))
   11766                 :             :     return;
   11767                 :             : 
   11768                 :     8758578 :   if (!implicit && warn_designated_init && !was_designated
   11769                 :     8726251 :       && TREE_CODE (constructor_type) == RECORD_TYPE
   11770                 :    10495573 :       && lookup_attribute ("designated_init",
   11771                 :     1033473 :                            TYPE_ATTRIBUTES (constructor_type)))
   11772                 :          50 :     warning_init (loc,
   11773                 :             :                   OPT_Wdesignated_init,
   11774                 :             :                   "positional initialization of field "
   11775                 :             :                   "in %<struct%> declared with %<designated_init%> attribute");
   11776                 :             : 
   11777                 :             :   /* If we've exhausted any levels that didn't have braces,
   11778                 :             :      pop them now.  */
   11779                 :    10164056 :   while (constructor_stack->implicit)
   11780                 :             :     {
   11781                 :      706735 :       if (RECORD_OR_UNION_TYPE_P (constructor_type)
   11782                 :      702758 :           && constructor_fields == NULL_TREE)
   11783                 :      701715 :         process_init_element (loc,
   11784                 :             :                               pop_init_level (loc, 1, braced_init_obstack,
   11785                 :             :                                               last_init_list_comma),
   11786                 :             :                               true, braced_init_obstack);
   11787                 :        5020 :       else if ((TREE_CODE (constructor_type) == ARRAY_TYPE
   11788                 :        1687 :                 || gnu_vector_type_p (constructor_type))
   11789                 :        3977 :                && constructor_max_index
   11790                 :        8970 :                && tree_int_cst_lt (constructor_max_index,
   11791                 :             :                                    constructor_index))
   11792                 :         241 :         process_init_element (loc,
   11793                 :             :                               pop_init_level (loc, 1, braced_init_obstack,
   11794                 :             :                                               last_init_list_comma),
   11795                 :             :                               true, braced_init_obstack);
   11796                 :             :       else
   11797                 :             :         break;
   11798                 :             :     }
   11799                 :             : 
   11800                 :             :   /* In the case of [LO ... HI] = VALUE, only evaluate VALUE once.  */
   11801                 :     9462100 :   if (constructor_range_stack)
   11802                 :             :     {
   11803                 :             :       /* If value is a compound literal and we'll be just using its
   11804                 :             :          content, don't put it into a SAVE_EXPR.  */
   11805                 :         365 :       if (TREE_CODE (value.value) != COMPOUND_LITERAL_EXPR
   11806                 :           3 :           || !require_constant_value)
   11807                 :             :         {
   11808                 :         362 :           tree semantic_type = NULL_TREE;
   11809                 :         362 :           if (TREE_CODE (value.value) == EXCESS_PRECISION_EXPR)
   11810                 :             :             {
   11811                 :           0 :               semantic_type = TREE_TYPE (value.value);
   11812                 :           0 :               value.value = TREE_OPERAND (value.value, 0);
   11813                 :             :             }
   11814                 :         362 :           value.value = save_expr (value.value);
   11815                 :         362 :           if (semantic_type)
   11816                 :           0 :             value.value = build1 (EXCESS_PRECISION_EXPR, semantic_type,
   11817                 :             :                                   value.value);
   11818                 :             :         }
   11819                 :             :     }
   11820                 :             : 
   11821                 :    10175508 :   while (1)
   11822                 :             :     {
   11823                 :    10175508 :       if (TREE_CODE (constructor_type) == RECORD_TYPE)
   11824                 :             :         {
   11825                 :     1037382 :           tree fieldtype;
   11826                 :     1037382 :           enum tree_code fieldcode;
   11827                 :             : 
   11828                 :     1037382 :           if (constructor_fields == NULL_TREE)
   11829                 :             :             {
   11830                 :        1280 :               pedwarn_init (loc, 0, "excess elements in struct initializer");
   11831                 :        1280 :               break;
   11832                 :             :             }
   11833                 :             : 
   11834                 :     1036102 :           fieldtype = TREE_TYPE (constructor_fields);
   11835                 :     1036102 :           if (fieldtype != error_mark_node)
   11836                 :     1036101 :             fieldtype = TYPE_MAIN_VARIANT (fieldtype);
   11837                 :     1036102 :           fieldcode = TREE_CODE (fieldtype);
   11838                 :             : 
   11839                 :             :           /* Error for non-static initialization of a flexible array member.  */
   11840                 :     1036102 :           if (fieldcode == ARRAY_TYPE
   11841                 :      155149 :               && !require_constant_value
   11842                 :        1072 :               && TYPE_SIZE (fieldtype) == NULL_TREE
   11843                 :     1036112 :               && DECL_CHAIN (constructor_fields) == NULL_TREE)
   11844                 :             :             {
   11845                 :          10 :               error_init (loc, "non-static initialization of a flexible "
   11846                 :             :                           "array member");
   11847                 :          10 :               break;
   11848                 :             :             }
   11849                 :             : 
   11850                 :             :           /* Error for initialization of a flexible array member with
   11851                 :             :              a string constant if the structure is in an array.  E.g.:
   11852                 :             :              struct S { int x; char y[]; };
   11853                 :             :              struct S s[] = { { 1, "foo" } };
   11854                 :             :              is invalid.  */
   11855                 :     1036092 :           if (string_flag
   11856                 :     1036092 :               && fieldcode == ARRAY_TYPE
   11857                 :        3334 :               && constructor_depth > 1
   11858                 :         489 :               && TYPE_SIZE (fieldtype) == NULL_TREE
   11859                 :     1036139 :               && DECL_CHAIN (constructor_fields) == NULL_TREE)
   11860                 :             :             {
   11861                 :          47 :               bool in_array_p = false;
   11862                 :          47 :               for (struct constructor_stack *p = constructor_stack;
   11863                 :          73 :                    p && p->type; p = p->next)
   11864                 :          59 :                 if (TREE_CODE (p->type) == ARRAY_TYPE)
   11865                 :             :                   {
   11866                 :             :                     in_array_p = true;
   11867                 :             :                     break;
   11868                 :             :                   }
   11869                 :          47 :               if (in_array_p)
   11870                 :             :                 {
   11871                 :          33 :                   error_init (loc, "initialization of flexible array "
   11872                 :             :                               "member in a nested context");
   11873                 :          33 :                   break;
   11874                 :             :                 }
   11875                 :             :             }
   11876                 :             : 
   11877                 :             :           /* Accept a string constant to initialize a subarray.  */
   11878                 :     1036059 :           if (value.value != NULL_TREE
   11879                 :     1035998 :               && fieldcode == ARRAY_TYPE
   11880                 :      155045 :               && INTEGRAL_TYPE_P (TREE_TYPE (fieldtype))
   11881                 :     1190647 :               && string_flag)
   11882                 :             :             value.value = orig_value;
   11883                 :             :           /* Otherwise, if we have come to a subaggregate,
   11884                 :             :              and we don't have an element of its type, push into it.  */
   11885                 :     1033044 :           else if (value.value != NULL_TREE
   11886                 :     1032758 :                    && initialize_elementwise_p (fieldtype, value.value))
   11887                 :             :             {
   11888                 :         286 :               push_init_level (loc, 1, braced_init_obstack);
   11889                 :         286 :               continue;
   11890                 :             :             }
   11891                 :             : 
   11892                 :     1035773 :           value.value = maybe_split_raw_data (value.value, &raw_data);
   11893                 :     1035773 :           if (value.value)
   11894                 :             :             {
   11895                 :     1035712 :               push_member_name (constructor_fields);
   11896                 :     1035712 :               output_init_element (loc, value.value, value.original_type,
   11897                 :             :                                    strict_string, fieldtype,
   11898                 :             :                                    constructor_fields, true, implicit,
   11899                 :             :                                    braced_init_obstack);
   11900                 :     1035712 :               RESTORE_SPELLING_DEPTH (constructor_depth);
   11901                 :             :             }
   11902                 :             :           else
   11903                 :             :             /* Do the bookkeeping for an element that was
   11904                 :             :                directly output as a constructor.  */
   11905                 :             :             {
   11906                 :             :               /* For a record, keep track of end position of last field.  */
   11907                 :          61 :               if (DECL_SIZE (constructor_fields))
   11908                 :          30 :                 constructor_bit_index
   11909                 :          30 :                   = size_binop_loc (input_location, PLUS_EXPR,
   11910                 :             :                                     bit_position (constructor_fields),
   11911                 :          30 :                                     DECL_SIZE (constructor_fields));
   11912                 :             : 
   11913                 :             :               /* If the current field was the first one not yet written out,
   11914                 :             :                  it isn't now, so update.  */
   11915                 :          61 :               if (constructor_unfilled_fields == constructor_fields)
   11916                 :             :                 {
   11917                 :          52 :                   constructor_unfilled_fields = DECL_CHAIN (constructor_fields);
   11918                 :             :                   /* Skip any nameless bit fields.  */
   11919                 :          52 :                   while (constructor_unfilled_fields != 0
   11920                 :          52 :                          && (DECL_UNNAMED_BIT_FIELD
   11921                 :             :                              (constructor_unfilled_fields)))
   11922                 :           0 :                     constructor_unfilled_fields =
   11923                 :           0 :                       DECL_CHAIN (constructor_unfilled_fields);
   11924                 :             :                 }
   11925                 :             :             }
   11926                 :             : 
   11927                 :     1035773 :           constructor_fields = DECL_CHAIN (constructor_fields);
   11928                 :             :           /* Skip any nameless bit fields at the beginning.  */
   11929                 :     1035773 :           while (constructor_fields != NULL_TREE
   11930                 :     1035874 :                  && DECL_UNNAMED_BIT_FIELD (constructor_fields))
   11931                 :         101 :             constructor_fields = DECL_CHAIN (constructor_fields);
   11932                 :             :         }
   11933                 :     9138126 :       else if (TREE_CODE (constructor_type) == UNION_TYPE)
   11934                 :             :         {
   11935                 :       30302 :           tree fieldtype;
   11936                 :       30302 :           enum tree_code fieldcode;
   11937                 :             : 
   11938                 :       30302 :           if (constructor_fields == NULL_TREE)
   11939                 :             :             {
   11940                 :           3 :               pedwarn_init (loc, 0,
   11941                 :             :                             "excess elements in union initializer");
   11942                 :           3 :               break;
   11943                 :             :             }
   11944                 :             : 
   11945                 :       30299 :           fieldtype = TREE_TYPE (constructor_fields);
   11946                 :       30299 :           if (fieldtype != error_mark_node)
   11947                 :       30299 :             fieldtype = TYPE_MAIN_VARIANT (fieldtype);
   11948                 :       30299 :           fieldcode = TREE_CODE (fieldtype);
   11949                 :             : 
   11950                 :             :           /* Warn that traditional C rejects initialization of unions.
   11951                 :             :              We skip the warning if the value is zero.  This is done
   11952                 :             :              under the assumption that the zero initializer in user
   11953                 :             :              code appears conditioned on e.g. __STDC__ to avoid
   11954                 :             :              "missing initializer" warnings and relies on default
   11955                 :             :              initialization to zero in the traditional C case.
   11956                 :             :              We also skip the warning if the initializer is designated,
   11957                 :             :              again on the assumption that this must be conditional on
   11958                 :             :              __STDC__ anyway (and we've already complained about the
   11959                 :             :              member-designator already).  */
   11960                 :       32328 :           if (!in_system_header_at (input_location) && !constructor_designated
   11961                 :       31722 :               && !(value.value && (integer_zerop (value.value)
   11962                 :        1325 :                                    || real_zerop (value.value))))
   11963                 :        1318 :             warning (OPT_Wtraditional, "traditional C rejects initialization "
   11964                 :             :                      "of unions");
   11965                 :             : 
   11966                 :             :           /* Accept a string constant to initialize a subarray.  */
   11967                 :       30299 :           if (value.value != NULL_TREE
   11968                 :       30299 :               && fieldcode == ARRAY_TYPE
   11969                 :         751 :               && INTEGRAL_TYPE_P (TREE_TYPE (fieldtype))
   11970                 :       31045 :               && string_flag)
   11971                 :             :             value.value = orig_value;
   11972                 :             :           /* Otherwise, if we have come to a subaggregate,
   11973                 :             :              and we don't have an element of its type, push into it.  */
   11974                 :       30344 :           else if (value.value != NULL_TREE
   11975                 :       30298 :                    && initialize_elementwise_p (fieldtype, value.value))
   11976                 :             :             {
   11977                 :          46 :               push_init_level (loc, 1, braced_init_obstack);
   11978                 :          46 :               continue;
   11979                 :             :             }
   11980                 :             : 
   11981                 :       30253 :           value.value = maybe_split_raw_data (value.value, &raw_data);
   11982                 :       30253 :           if (value.value)
   11983                 :             :             {
   11984                 :       30253 :               push_member_name (constructor_fields);
   11985                 :       30253 :               output_init_element (loc, value.value, value.original_type,
   11986                 :             :                                    strict_string, fieldtype,
   11987                 :             :                                    constructor_fields, true, implicit,
   11988                 :             :                                    braced_init_obstack);
   11989                 :       30253 :               RESTORE_SPELLING_DEPTH (constructor_depth);
   11990                 :             :             }
   11991                 :             :           else
   11992                 :             :             /* Do the bookkeeping for an element that was
   11993                 :             :                directly output as a constructor.  */
   11994                 :             :             {
   11995                 :           0 :               constructor_bit_index = DECL_SIZE (constructor_fields);
   11996                 :           0 :               constructor_unfilled_fields = DECL_CHAIN (constructor_fields);
   11997                 :             :             }
   11998                 :             : 
   11999                 :       30253 :           constructor_fields = NULL_TREE;
   12000                 :             :         }
   12001                 :     9107824 :       else if (TREE_CODE (constructor_type) == ARRAY_TYPE)
   12002                 :             :         {
   12003                 :     2417246 :           tree elttype = TYPE_MAIN_VARIANT (TREE_TYPE (constructor_type));
   12004                 :     2417246 :           enum tree_code eltcode = TREE_CODE (elttype);
   12005                 :             : 
   12006                 :             :           /* Accept a string constant to initialize a subarray.  */
   12007                 :     2417246 :           if (value.value != NULL_TREE
   12008                 :     2417246 :               && eltcode == ARRAY_TYPE
   12009                 :        6733 :               && INTEGRAL_TYPE_P (TREE_TYPE (elttype))
   12010                 :     2422573 :               && string_flag)
   12011                 :             :             value.value = orig_value;
   12012                 :             :           /* Otherwise, if we have come to a subaggregate,
   12013                 :             :              and we don't have an element of its type, push into it.  */
   12014                 :     3119093 :           else if (value.value != NULL_TREE
   12015                 :     2416819 :                    && initialize_elementwise_p (elttype, value.value))
   12016                 :             :             {
   12017                 :      702274 :               push_init_level (loc, 1, braced_init_obstack);
   12018                 :      702274 :               continue;
   12019                 :             :             }
   12020                 :             : 
   12021                 :     1714972 :           if (constructor_max_index != NULL_TREE
   12022                 :     1714972 :               && (tree_int_cst_lt (constructor_max_index, constructor_index)
   12023                 :      672737 :                   || integer_all_onesp (constructor_max_index)))
   12024                 :             :             {
   12025                 :         113 :               pedwarn_init (loc, 0,
   12026                 :             :                             "excess elements in array initializer");
   12027                 :         113 :               break;
   12028                 :             :             }
   12029                 :             : 
   12030                 :     1714859 :           if (value.value
   12031                 :     1714859 :               && TREE_CODE (value.value) == RAW_DATA_CST
   12032                 :         184 :               && RAW_DATA_LENGTH (value.value) > 1
   12033                 :         184 :               && (TREE_CODE (elttype) == INTEGER_TYPE
   12034                 :         184 :                   || TREE_CODE (elttype) == BITINT_TYPE)
   12035                 :         184 :               && TYPE_PRECISION (elttype) == CHAR_BIT
   12036                 :     1715043 :               && (constructor_max_index == NULL_TREE
   12037                 :          53 :                   || tree_int_cst_lt (constructor_index,
   12038                 :             :                                       constructor_max_index)))
   12039                 :             :             {
   12040                 :         184 :               unsigned int len = RAW_DATA_LENGTH (value.value);
   12041                 :         184 :               if (constructor_max_index)
   12042                 :             :                 {
   12043                 :          53 :                   widest_int w = wi::to_widest (constructor_max_index);
   12044                 :          53 :                   w -= wi::to_widest (constructor_index);
   12045                 :          53 :                   w += 1;
   12046                 :          53 :                   if (w < len)
   12047                 :           3 :                     len = w.to_uhwi ();
   12048                 :          53 :                 }
   12049                 :         184 :               if (len < (unsigned) RAW_DATA_LENGTH (value.value))
   12050                 :             :                 {
   12051                 :           3 :                   raw_data = copy_node (value.value);
   12052                 :           3 :                   RAW_DATA_LENGTH (raw_data) -= len;
   12053                 :           3 :                   RAW_DATA_POINTER (raw_data) += len;
   12054                 :           3 :                   RAW_DATA_LENGTH (value.value) = len;
   12055                 :             :                 }
   12056                 :         184 :               TREE_TYPE (value.value) = elttype;
   12057                 :         184 :               push_array_bounds (tree_to_uhwi (constructor_index));
   12058                 :         184 :               output_init_element (loc, value.value, value.original_type,
   12059                 :             :                                    false, elttype, constructor_index, true,
   12060                 :             :                                    implicit, braced_init_obstack);
   12061                 :         184 :               RESTORE_SPELLING_DEPTH (constructor_depth);
   12062                 :         184 :               constructor_index
   12063                 :         184 :                 = size_binop_loc (input_location, PLUS_EXPR,
   12064                 :         184 :                                   constructor_index, bitsize_int (len));
   12065                 :             :             }
   12066                 :             :           else
   12067                 :             :             {
   12068                 :     1714675 :               value.value = maybe_split_raw_data (value.value, &raw_data);
   12069                 :             :               /* Now output the actual element.  */
   12070                 :     1714675 :               if (value.value)
   12071                 :             :                 {
   12072                 :     1714675 :                   push_array_bounds (tree_to_uhwi (constructor_index));
   12073                 :     1714675 :                   output_init_element (loc, value.value, value.original_type,
   12074                 :             :                                        strict_string, elttype,
   12075                 :             :                                        constructor_index, true, implicit,
   12076                 :             :                                        braced_init_obstack);
   12077                 :     1714675 :                   RESTORE_SPELLING_DEPTH (constructor_depth);
   12078                 :             :                 }
   12079                 :             : 
   12080                 :     1714675 :               constructor_index
   12081                 :     1714675 :                 = size_binop_loc (input_location, PLUS_EXPR,
   12082                 :             :                                   constructor_index, bitsize_one_node);
   12083                 :             : 
   12084                 :     1714675 :               if (!value.value)
   12085                 :             :                 /* If we are doing the bookkeeping for an element that was
   12086                 :             :                    directly output as a constructor, we must update
   12087                 :             :                    constructor_unfilled_index.  */
   12088                 :           0 :                 constructor_unfilled_index = constructor_index;
   12089                 :             :             }
   12090                 :             :         }
   12091                 :     6690578 :       else if (gnu_vector_type_p (constructor_type))
   12092                 :             :         {
   12093                 :     6690136 :           tree elttype = TYPE_MAIN_VARIANT (TREE_TYPE (constructor_type));
   12094                 :             : 
   12095                 :             :           /* Do a basic check of initializer size.  Note that vectors
   12096                 :             :              may not always have a fixed size derived from their type.  */
   12097                 :     6690136 :           if (maybe_lt (tree_to_poly_uint64 (constructor_max_index),
   12098                 :     6690136 :                         tree_to_poly_uint64 (constructor_index)))
   12099                 :             :             {
   12100                 :             :               /* Diagose VLA out-of-bounds as errors.  */
   12101                 :           2 :               if (tree_to_poly_uint64 (constructor_max_index).is_constant())
   12102                 :           2 :                 pedwarn_init (loc, 0,
   12103                 :             :                               "excess elements in vector initializer");
   12104                 :             :               else
   12105                 :             :                 error_init (loc, "excess elements in vector initializer");
   12106                 :             : 
   12107                 :             :               break;
   12108                 :             :             }
   12109                 :             : 
   12110                 :     6690134 :           value.value = maybe_split_raw_data (value.value, &raw_data);
   12111                 :             :           /* Now output the actual element.  */
   12112                 :     6690134 :           if (value.value)
   12113                 :             :             {
   12114                 :     6690134 :               if (TREE_CODE (value.value) == VECTOR_CST)
   12115                 :           0 :                 elttype = TYPE_MAIN_VARIANT (constructor_type);
   12116                 :     6690134 :               output_init_element (loc, value.value, value.original_type,
   12117                 :             :                                    strict_string, elttype,
   12118                 :             :                                    constructor_index, true, implicit,
   12119                 :             :                                    braced_init_obstack);
   12120                 :             :             }
   12121                 :             : 
   12122                 :     6690134 :           constructor_index
   12123                 :     6690134 :             = size_binop_loc (input_location,
   12124                 :             :                               PLUS_EXPR, constructor_index, bitsize_one_node);
   12125                 :             : 
   12126                 :     6690134 :           if (!value.value)
   12127                 :             :             /* If we are doing the bookkeeping for an element that was
   12128                 :             :                directly output as a constructor, we must update
   12129                 :             :                constructor_unfilled_index.  */
   12130                 :           0 :             constructor_unfilled_index = constructor_index;
   12131                 :             :         }
   12132                 :             : 
   12133                 :             :       /* Handle the sole element allowed in a braced initializer
   12134                 :             :          for a scalar variable.  */
   12135                 :         442 :       else if (constructor_type != error_mark_node
   12136                 :         442 :                && constructor_fields == NULL_TREE)
   12137                 :             :         {
   12138                 :          27 :           pedwarn_init (loc, 0,
   12139                 :             :                         "excess elements in scalar initializer");
   12140                 :          27 :           break;
   12141                 :             :         }
   12142                 :             :       else
   12143                 :             :         {
   12144                 :         415 :           value.value = maybe_split_raw_data (value.value, &raw_data);
   12145                 :         415 :           if (value.value)
   12146                 :         415 :             output_init_element (loc, value.value, value.original_type,
   12147                 :             :                                  strict_string, constructor_type,
   12148                 :             :                                  NULL_TREE, true, implicit,
   12149                 :             :                                  braced_init_obstack);
   12150                 :         415 :           constructor_fields = NULL_TREE;
   12151                 :             :         }
   12152                 :             : 
   12153                 :             :       /* Handle range initializers either at this level or anywhere higher
   12154                 :             :          in the designator stack.  */
   12155                 :     9471434 :       if (constructor_range_stack)
   12156                 :             :         {
   12157                 :       10802 :           struct constructor_range_stack *p, *range_stack;
   12158                 :       10802 :           int finish = 0;
   12159                 :             : 
   12160                 :       10802 :           range_stack = constructor_range_stack;
   12161                 :       10802 :           constructor_range_stack = 0;
   12162                 :       10802 :           while (constructor_stack != range_stack->stack)
   12163                 :             :             {
   12164                 :           0 :               gcc_assert (constructor_stack->implicit);
   12165                 :           0 :               process_init_element (loc,
   12166                 :             :                                     pop_init_level (loc, 1,
   12167                 :             :                                                     braced_init_obstack,
   12168                 :             :                                                     last_init_list_comma),
   12169                 :             :                                     true, braced_init_obstack);
   12170                 :             :             }
   12171                 :         325 :           for (p = range_stack;
   12172                 :       11127 :                !p->range_end || tree_int_cst_equal (p->index, p->range_end);
   12173                 :         325 :                p = p->prev)
   12174                 :             :             {
   12175                 :         325 :               gcc_assert (constructor_stack->implicit);
   12176                 :         325 :               process_init_element (loc,
   12177                 :             :                                     pop_init_level (loc, 1,
   12178                 :             :                                                     braced_init_obstack,
   12179                 :             :                                                     last_init_list_comma),
   12180                 :             :                                     true, braced_init_obstack);
   12181                 :             :             }
   12182                 :             : 
   12183                 :       10802 :           p->index = size_binop_loc (input_location,
   12184                 :             :                                      PLUS_EXPR, p->index, bitsize_one_node);
   12185                 :       10802 :           if (tree_int_cst_equal (p->index, p->range_end) && !p->prev)
   12186                 :         373 :             finish = 1;
   12187                 :             : 
   12188                 :       11127 :           while (1)
   12189                 :             :             {
   12190                 :       11127 :               constructor_index = p->index;
   12191                 :       11127 :               constructor_fields = p->fields;
   12192                 :       11127 :               if (finish && p->range_end && p->index == p->range_start)
   12193                 :             :                 {
   12194                 :           8 :                   finish = 0;
   12195                 :           8 :                   p->prev = 0;
   12196                 :             :                 }
   12197                 :       11127 :               p = p->next;
   12198                 :       11127 :               if (!p)
   12199                 :             :                 break;
   12200                 :         325 :               finish_implicit_inits (loc, braced_init_obstack);
   12201                 :         325 :               push_init_level (loc, 2, braced_init_obstack);
   12202                 :         325 :               p->stack = constructor_stack;
   12203                 :         325 :               if (p->range_end && tree_int_cst_equal (p->index, p->range_end))
   12204                 :          33 :                 p->index = p->range_start;
   12205                 :             :             }
   12206                 :             : 
   12207                 :       10802 :           if (!finish)
   12208                 :       10437 :             constructor_range_stack = range_stack;
   12209                 :       10802 :           continue;
   12210                 :       10802 :         }
   12211                 :             : 
   12212                 :             :       break;
   12213                 :             :     }
   12214                 :             : 
   12215                 :     9462100 :   constructor_range_stack = 0;
   12216                 :             : 
   12217                 :     9462100 :   if (raw_data && RAW_DATA_LENGTH (raw_data))
   12218                 :             :     {
   12219                 :         212 :       gcc_assert (!string_flag && !was_designated);
   12220                 :         212 :       value.value = raw_data;
   12221                 :         212 :       raw_data = NULL_TREE;
   12222                 :         212 :       goto retry;
   12223                 :             :     }
   12224                 :             : }
   12225                 :             : 
   12226                 :             : /* Build a complete asm-statement, whose components are a CV_QUALIFIER
   12227                 :             :    (guaranteed to be 'volatile' or null) and ARGS (represented using
   12228                 :             :    an ASM_EXPR node).  */
   12229                 :             : tree
   12230                 :      200587 : build_asm_stmt (bool is_volatile, tree args)
   12231                 :             : {
   12232                 :      200587 :   if (is_volatile)
   12233                 :      161053 :     ASM_VOLATILE_P (args) = 1;
   12234                 :      200587 :   return add_stmt (args);
   12235                 :             : }
   12236                 :             : 
   12237                 :             : /* Build an asm-expr, whose components are a STRING, some OUTPUTS,
   12238                 :             :    some INPUTS, and some CLOBBERS.  The latter three may be NULL.
   12239                 :             :    SIMPLE indicates whether there was anything at all after the
   12240                 :             :    string in the asm expression -- asm("blah") and asm("blah" : )
   12241                 :             :    are subtly different.  We use a ASM_EXPR node to represent this.
   12242                 :             :    LOC is the location of the asm, and IS_INLINE says whether this
   12243                 :             :    is asm inline.  */
   12244                 :             : tree
   12245                 :      200616 : build_asm_expr (location_t loc, tree string, tree outputs, tree inputs,
   12246                 :             :                 tree clobbers, tree labels, bool simple, bool is_inline)
   12247                 :             : {
   12248                 :      200616 :   tree tail;
   12249                 :      200616 :   tree args;
   12250                 :      200616 :   int i;
   12251                 :      200616 :   const char *constraint;
   12252                 :      200616 :   const char **oconstraints;
   12253                 :      200616 :   bool allows_mem, allows_reg, is_inout;
   12254                 :      200616 :   int ninputs, noutputs;
   12255                 :             : 
   12256                 :      200616 :   ninputs = list_length (inputs);
   12257                 :      200616 :   noutputs = list_length (outputs);
   12258                 :      200616 :   oconstraints = (const char **) alloca (noutputs * sizeof (const char *));
   12259                 :             : 
   12260                 :      200616 :   string = resolve_asm_operand_names (string, outputs, inputs, labels);
   12261                 :             : 
   12262                 :             :   /* Remove output conversions that change the type but not the mode.  */
   12263                 :      539214 :   for (i = 0, tail = outputs; tail; ++i, tail = TREE_CHAIN (tail))
   12264                 :             :     {
   12265                 :      338598 :       tree output = TREE_VALUE (tail);
   12266                 :             : 
   12267                 :      338598 :       output = c_fully_fold (output, false, NULL, true);
   12268                 :             : 
   12269                 :             :       /* ??? Really, this should not be here.  Users should be using a
   12270                 :             :          proper lvalue, dammit.  But there's a long history of using casts
   12271                 :             :          in the output operands.  In cases like longlong.h, this becomes a
   12272                 :             :          primitive form of typechecking -- if the cast can be removed, then
   12273                 :             :          the output operand had a type of the proper width; otherwise we'll
   12274                 :             :          get an error.  Gross, but ...  */
   12275                 :      338598 :       STRIP_NOPS (output);
   12276                 :             : 
   12277                 :      338598 :       if (!lvalue_or_else (loc, output, lv_asm))
   12278                 :           4 :         output = error_mark_node;
   12279                 :             : 
   12280                 :      338598 :       if (output != error_mark_node
   12281                 :      338598 :           && (TREE_READONLY (output)
   12282                 :      338592 :               || TYPE_READONLY (TREE_TYPE (output))
   12283                 :      338592 :               || (RECORD_OR_UNION_TYPE_P (TREE_TYPE (output))
   12284                 :         111 :                   && C_TYPE_FIELDS_READONLY (TREE_TYPE (output)))))
   12285                 :           2 :         readonly_error (loc, output, lv_asm);
   12286                 :             : 
   12287                 :      338598 :       constraint = TREE_STRING_POINTER (TREE_VALUE (TREE_PURPOSE (tail)));
   12288                 :      338598 :       oconstraints[i] = constraint;
   12289                 :             : 
   12290                 :      338598 :       if (parse_output_constraint (&constraint, i, ninputs, noutputs,
   12291                 :             :                                    &allows_mem, &allows_reg, &is_inout))
   12292                 :             :         {
   12293                 :             :           /* If the operand is going to end up in memory,
   12294                 :             :              mark it addressable.  */
   12295                 :      338590 :           if (!allows_reg && !c_mark_addressable (output))
   12296                 :           3 :             output = error_mark_node;
   12297                 :        1086 :           if (!(!allows_reg && allows_mem)
   12298                 :      337504 :               && output != error_mark_node
   12299                 :      676093 :               && VOID_TYPE_P (TREE_TYPE (output)))
   12300                 :             :             {
   12301                 :           4 :               error_at (loc, "invalid use of void expression");
   12302                 :           4 :               output = error_mark_node;
   12303                 :             :             }
   12304                 :      338590 :           if (allows_reg && current_function_decl == NULL_TREE)
   12305                 :             :             {
   12306                 :           1 :               error_at (loc, "constraint allows registers outside of "
   12307                 :             :                              "a function");
   12308                 :           1 :               output = error_mark_node;
   12309                 :             :             }
   12310                 :             :         }
   12311                 :             :       else
   12312                 :           8 :         output = error_mark_node;
   12313                 :             : 
   12314                 :      338598 :       if (current_function_decl == NULL_TREE && output != error_mark_node)
   12315                 :             :         {
   12316                 :           7 :           if (TREE_SIDE_EFFECTS (output))
   12317                 :             :             {
   12318                 :           0 :               error_at (loc, "side-effects in output operand outside "
   12319                 :             :                              "of a function");
   12320                 :           0 :               output = error_mark_node;
   12321                 :             :             }
   12322                 :             :           else
   12323                 :             :             {
   12324                 :           7 :               tree addr = build_unary_op (loc, ADDR_EXPR, output, false);
   12325                 :           7 :               if (addr == error_mark_node)
   12326                 :             :                 output = error_mark_node;
   12327                 :           7 :               else if (!initializer_constant_valid_p (addr, TREE_TYPE (addr)))
   12328                 :             :                 {
   12329                 :           1 :                   error_at (loc, "output operand outside of a function is not "
   12330                 :             :                                  "constant");
   12331                 :           1 :                   output = error_mark_node;
   12332                 :             :                 }
   12333                 :             :             }
   12334                 :             :         }
   12335                 :      338591 :       else if (output != error_mark_node && strstr (constraint, "-"))
   12336                 :             :         {
   12337                 :           1 :           error_at (loc, "%<-%> modifier used inside of a function");
   12338                 :           1 :           output = error_mark_node;
   12339                 :             :         }
   12340                 :             : 
   12341                 :      338598 :       TREE_VALUE (tail) = output;
   12342                 :             :     }
   12343                 :             : 
   12344                 :      555838 :   for (i = 0, tail = inputs; tail; ++i, tail = TREE_CHAIN (tail))
   12345                 :             :     {
   12346                 :      355222 :       tree input;
   12347                 :             : 
   12348                 :      355222 :       constraint = TREE_STRING_POINTER (TREE_VALUE (TREE_PURPOSE (tail)));
   12349                 :      355222 :       input = TREE_VALUE (tail);
   12350                 :             : 
   12351                 :      355222 :       if (parse_input_constraint (&constraint, i, ninputs, noutputs, 0,
   12352                 :             :                                   oconstraints, &allows_mem, &allows_reg))
   12353                 :             :         {
   12354                 :             :           /* If the operand is going to end up in memory,
   12355                 :             :              mark it addressable.  */
   12356                 :      355215 :           if (!allows_reg && allows_mem)
   12357                 :             :             {
   12358                 :        1071 :               input = c_fully_fold (input, false, NULL, true);
   12359                 :             : 
   12360                 :             :               /* Strip the nops as we allow this case.  FIXME, this really
   12361                 :             :                  should be rejected or made deprecated.  */
   12362                 :        1071 :               STRIP_NOPS (input);
   12363                 :        1071 :               if (!c_mark_addressable (input))
   12364                 :           2 :                 input = error_mark_node;
   12365                 :             :             }
   12366                 :             :           else
   12367                 :             :             {
   12368                 :      354144 :               struct c_expr expr;
   12369                 :      354144 :               memset (&expr, 0, sizeof (expr));
   12370                 :      354144 :               expr.value = input;
   12371                 :      354144 :               expr = convert_lvalue_to_rvalue (loc, expr, true, false);
   12372                 :      354144 :               input = c_fully_fold (expr.value, false, NULL);
   12373                 :             : 
   12374                 :      354144 :               if (input != error_mark_node && VOID_TYPE_P (TREE_TYPE (input)))
   12375                 :             :                 {
   12376                 :           4 :                   error_at (loc, "invalid use of void expression");
   12377                 :           4 :                   input = error_mark_node;
   12378                 :             :                 }
   12379                 :             :             }
   12380                 :      355215 :           if (allows_reg && current_function_decl == NULL_TREE)
   12381                 :             :             {
   12382                 :           1 :               error_at (loc, "constraint allows registers outside of "
   12383                 :             :                              "a function");
   12384                 :           1 :               input = error_mark_node;
   12385                 :             :             }
   12386                 :      355215 :           if (constraint[0] == ':' && input != error_mark_node)
   12387                 :             :             {
   12388                 :          12 :               tree t = input;
   12389                 :          12 :               STRIP_NOPS (t);
   12390                 :          12 :               if (TREE_CODE (t) != ADDR_EXPR
   12391                 :          12 :                   || !(TREE_CODE (TREE_OPERAND (t, 0)) == FUNCTION_DECL
   12392                 :           8 :                        || (VAR_P (TREE_OPERAND (t, 0))
   12393                 :           6 :                            && is_global_var (TREE_OPERAND (t, 0)))))
   12394                 :             :                 {
   12395                 :           5 :                   error_at (loc, "%<:%> constraint operand is not address "
   12396                 :             :                                  "of a function or non-automatic variable");
   12397                 :           5 :                   input = error_mark_node;
   12398                 :             :                 }
   12399                 :             :             }
   12400                 :             :         }
   12401                 :             :       else
   12402                 :           7 :         input = error_mark_node;
   12403                 :             : 
   12404                 :      355222 :       if (current_function_decl == NULL_TREE && input != error_mark_node)
   12405                 :             :         {
   12406                 :          30 :           if (TREE_SIDE_EFFECTS (input))
   12407                 :             :             {
   12408                 :           2 :               error_at (loc, "side-effects in input operand outside "
   12409                 :             :                              "of a function");
   12410                 :           2 :               input = error_mark_node;
   12411                 :             :             }
   12412                 :             :           else
   12413                 :             :             {
   12414                 :          28 :               tree tem = input;
   12415                 :          28 :               if (allows_mem && lvalue_p (input))
   12416                 :           7 :                 tem = build_unary_op (loc, ADDR_EXPR, input, false);
   12417                 :          28 :               if (!initializer_constant_valid_p (tem, TREE_TYPE (tem)))
   12418                 :             :                 {
   12419                 :           2 :                   error_at (loc, "input operand outside of a function is not "
   12420                 :             :                                  "constant");
   12421                 :           2 :                   input = error_mark_node;
   12422                 :             :                 }
   12423                 :             :             }
   12424                 :             :         }
   12425                 :      355192 :       else if (input != error_mark_node && strstr (constraint, "-"))
   12426                 :             :         {
   12427                 :           3 :           error_at (loc, "%<-%> modifier used inside of a function");
   12428                 :           3 :           input = error_mark_node;
   12429                 :             :         }
   12430                 :             : 
   12431                 :      355222 :       TREE_VALUE (tail) = input;
   12432                 :             :     }
   12433                 :             : 
   12434                 :      200616 :   args = build_stmt (loc, ASM_EXPR, string, outputs, inputs, clobbers, labels);
   12435                 :             : 
   12436                 :             :   /* asm statements without outputs, including simple ones, are treated
   12437                 :             :      as volatile.  */
   12438                 :      200616 :   ASM_BASIC_P (args) = simple;
   12439                 :      200616 :   ASM_VOLATILE_P (args) = (noutputs == 0);
   12440                 :      200616 :   ASM_INLINE_P (args) = is_inline;
   12441                 :             : 
   12442                 :      200616 :   return args;
   12443                 :             : }
   12444                 :             : 
   12445                 :             : /* Generate a goto statement to LABEL.  LOC is the location of the
   12446                 :             :    GOTO.  */
   12447                 :             : 
   12448                 :             : tree
   12449                 :       82085 : c_finish_goto_label (location_t loc, tree label)
   12450                 :             : {
   12451                 :       82085 :   tree decl = lookup_label_for_goto (loc, label);
   12452                 :       82085 :   if (!decl)
   12453                 :             :     return NULL_TREE;
   12454                 :       82085 :   TREE_USED (decl) = 1;
   12455                 :       82085 :   {
   12456                 :       82085 :     add_stmt (build_predict_expr (PRED_GOTO, NOT_TAKEN));
   12457                 :       82085 :     tree t = build1 (GOTO_EXPR, void_type_node, decl);
   12458                 :       82085 :     SET_EXPR_LOCATION (t, loc);
   12459                 :       82085 :     return add_stmt (t);
   12460                 :             :   }
   12461                 :             : }
   12462                 :             : 
   12463                 :             : /* Generate a computed goto statement to EXPR.  LOC is the location of
   12464                 :             :    the GOTO.  */
   12465                 :             : 
   12466                 :             : tree
   12467                 :         925 : c_finish_goto_ptr (location_t loc, c_expr val)
   12468                 :             : {
   12469                 :         925 :   tree expr = val.value;
   12470                 :         925 :   tree t;
   12471                 :         925 :   pedwarn (loc, OPT_Wpedantic, "ISO C forbids %<goto *expr;%>");
   12472                 :         925 :   if (expr != error_mark_node
   12473                 :         924 :       && !POINTER_TYPE_P (TREE_TYPE (expr))
   12474                 :         930 :       && !null_pointer_constant_p (expr))
   12475                 :             :     {
   12476                 :           2 :       error_at (val.get_location (),
   12477                 :             :                 "computed goto must be pointer type");
   12478                 :           2 :       expr = build_zero_cst (ptr_type_node);
   12479                 :             :     }
   12480                 :         925 :   expr = c_fully_fold (expr, false, NULL);
   12481                 :         925 :   expr = convert (ptr_type_node, expr);
   12482                 :         925 :   t = build1 (GOTO_EXPR, void_type_node, expr);
   12483                 :         925 :   SET_EXPR_LOCATION (t, loc);
   12484                 :         925 :   return add_stmt (t);
   12485                 :             : }
   12486                 :             : 
   12487                 :             : /* Generate a C `return' statement.  RETVAL is the expression for what
   12488                 :             :    to return, or a null pointer for `return;' with no value.  LOC is
   12489                 :             :    the location of the return statement, or the location of the expression,
   12490                 :             :    if the statement has any.  If ORIGTYPE is not NULL_TREE, it
   12491                 :             :    is the original type of RETVAL.  MUSTTAIL_P indicates a musttail
   12492                 :             :    attribute.  */
   12493                 :             : 
   12494                 :             : tree
   12495                 :    35199276 : c_finish_return (location_t loc, tree retval, tree origtype, bool musttail_p)
   12496                 :             : {
   12497                 :    35199276 :   tree valtype = TREE_TYPE (TREE_TYPE (current_function_decl)), ret_stmt;
   12498                 :    35199276 :   bool no_warning = false;
   12499                 :    35199276 :   bool npc = false;
   12500                 :             : 
   12501                 :             :   /* Use the expansion point to handle cases such as returning NULL
   12502                 :             :      in a function returning void.  */
   12503                 :    35199276 :   location_t xloc = expansion_point_location_if_in_system_header (loc);
   12504                 :             : 
   12505                 :    35199276 :   if (TREE_THIS_VOLATILE (current_function_decl))
   12506                 :          22 :     warning_at (xloc, 0,
   12507                 :             :                 "function declared %<noreturn%> has a %<return%> statement");
   12508                 :             : 
   12509                 :    35199276 :   set_musttail_on_return (retval, xloc, musttail_p);
   12510                 :             : 
   12511                 :    35199276 :   if (retval)
   12512                 :             :     {
   12513                 :    35178038 :       tree semantic_type = NULL_TREE;
   12514                 :    35178038 :       npc = null_pointer_constant_p (retval);
   12515                 :    35178038 :       if (TREE_CODE (retval) == EXCESS_PRECISION_EXPR)
   12516                 :             :         {
   12517                 :          92 :           semantic_type = TREE_TYPE (retval);
   12518                 :          92 :           retval = TREE_OPERAND (retval, 0);
   12519                 :             :         }
   12520                 :    35178038 :       retval = c_fully_fold (retval, false, NULL);
   12521                 :    35178038 :       if (semantic_type
   12522                 :    35178038 :           && valtype != NULL_TREE
   12523                 :          92 :           && TREE_CODE (valtype) != VOID_TYPE)
   12524                 :          92 :         retval = build1 (EXCESS_PRECISION_EXPR, semantic_type, retval);
   12525                 :             :     }
   12526                 :             : 
   12527                 :    35178038 :   if (!retval)
   12528                 :             :     {
   12529                 :       21238 :       current_function_returns_null = 1;
   12530                 :       21238 :       if ((warn_return_type >= 0 || flag_isoc99)
   12531                 :       21113 :           && valtype != NULL_TREE && TREE_CODE (valtype) != VOID_TYPE)
   12532                 :             :         {
   12533                 :          46 :           no_warning = true;
   12534                 :          47 :           if (emit_diagnostic (flag_isoc99 ? DK_PERMERROR : DK_WARNING,
   12535                 :             :                                loc, OPT_Wreturn_mismatch,
   12536                 :             :                                "%<return%> with no value,"
   12537                 :             :                                " in function returning non-void"))
   12538                 :          27 :             inform (DECL_SOURCE_LOCATION (current_function_decl),
   12539                 :             :                     "declared here");
   12540                 :             :         }
   12541                 :             :     }
   12542                 :    35178038 :   else if (valtype == NULL_TREE || VOID_TYPE_P (valtype))
   12543                 :             :     {
   12544                 :         264 :       current_function_returns_null = 1;
   12545                 :         264 :       bool warned_here;
   12546                 :         264 :       if (TREE_CODE (TREE_TYPE (retval)) != VOID_TYPE)
   12547                 :          64 :         warned_here = permerror_opt
   12548                 :          64 :           (xloc, OPT_Wreturn_mismatch,
   12549                 :             :            "%<return%> with a value, in function returning void");
   12550                 :             :       else
   12551                 :         200 :         warned_here = pedwarn
   12552                 :         200 :           (xloc, OPT_Wpedantic, "ISO C forbids "
   12553                 :             :            "%<return%> with expression, in function returning void");
   12554                 :         264 :       if (warned_here)
   12555                 :          43 :         inform (DECL_SOURCE_LOCATION (current_function_decl),
   12556                 :             :                 "declared here");
   12557                 :             :     }
   12558                 :             :   else
   12559                 :             :     {
   12560                 :    35177774 :       tree t = convert_for_assignment (loc, UNKNOWN_LOCATION, valtype,
   12561                 :             :                                        retval, origtype, ic_return,
   12562                 :             :                                        npc, NULL_TREE, NULL_TREE, 0);
   12563                 :    35177774 :       tree res = DECL_RESULT (current_function_decl);
   12564                 :    35177774 :       tree inner;
   12565                 :    35177774 :       bool save;
   12566                 :             : 
   12567                 :    35177774 :       current_function_returns_value = 1;
   12568                 :    35177774 :       if (t == error_mark_node)
   12569                 :             :         return NULL_TREE;
   12570                 :             : 
   12571                 :    35177476 :       save = in_late_binary_op;
   12572                 :    70347483 :       if (C_BOOLEAN_TYPE_P (TREE_TYPE (res))
   12573                 :    35169986 :           || TREE_CODE (TREE_TYPE (res)) == COMPLEX_TYPE
   12574                 :    70346188 :           || (SCALAR_FLOAT_TYPE_P (TREE_TYPE (t))
   12575                 :      327825 :               && (TREE_CODE (TREE_TYPE (res)) == INTEGER_TYPE
   12576                 :      327825 :                   || TREE_CODE (TREE_TYPE (res)) == ENUMERAL_TYPE)
   12577                 :           0 :               && sanitize_flags_p (SANITIZE_FLOAT_CAST)))
   12578                 :        8764 :         in_late_binary_op = true;
   12579                 :    35177476 :       inner = t = convert (TREE_TYPE (res), t);
   12580                 :    35177476 :       in_late_binary_op = save;
   12581                 :             : 
   12582                 :             :       /* Strip any conversions, additions, and subtractions, and see if
   12583                 :             :          we are returning the address of a local variable.  Warn if so.  */
   12584                 :    38388812 :       while (1)
   12585                 :             :         {
   12586                 :    38388812 :           switch (TREE_CODE (inner))
   12587                 :             :             {
   12588                 :     3209948 :             CASE_CONVERT:
   12589                 :     3209948 :             case NON_LVALUE_EXPR:
   12590                 :     3209948 :             case PLUS_EXPR:
   12591                 :     3209948 :             case POINTER_PLUS_EXPR:
   12592                 :     3209948 :               inner = TREE_OPERAND (inner, 0);
   12593                 :     3209948 :               continue;
   12594                 :             : 
   12595                 :        1393 :             case MINUS_EXPR:
   12596                 :             :               /* If the second operand of the MINUS_EXPR has a pointer
   12597                 :             :                  type (or is converted from it), this may be valid, so
   12598                 :             :                  don't give a warning.  */
   12599                 :        1393 :               {
   12600                 :        1393 :                 tree op1 = TREE_OPERAND (inner, 1);
   12601                 :             : 
   12602                 :        3021 :                 while (!POINTER_TYPE_P (TREE_TYPE (op1))
   12603                 :        3261 :                        && (CONVERT_EXPR_P (op1)
   12604                 :        1388 :                            || TREE_CODE (op1) == NON_LVALUE_EXPR))
   12605                 :         240 :                   op1 = TREE_OPERAND (op1, 0);
   12606                 :             : 
   12607                 :        1393 :                 if (POINTER_TYPE_P (TREE_TYPE (op1)))
   12608                 :             :                   break;
   12609                 :             : 
   12610                 :        1388 :                 inner = TREE_OPERAND (inner, 0);
   12611                 :        1388 :                 continue;
   12612                 :        1388 :               }
   12613                 :             : 
   12614                 :        2687 :             case ADDR_EXPR:
   12615                 :        2687 :               inner = TREE_OPERAND (inner, 0);
   12616                 :             : 
   12617                 :        2687 :               while (REFERENCE_CLASS_P (inner)
   12618                 :        3546 :                      && !INDIRECT_REF_P (inner))
   12619                 :         859 :                 inner = TREE_OPERAND (inner, 0);
   12620                 :             : 
   12621                 :        2687 :               if (DECL_P (inner)
   12622                 :        1531 :                   && !DECL_EXTERNAL (inner)
   12623                 :         909 :                   && !TREE_STATIC (inner)
   12624                 :         132 :                   && DECL_CONTEXT (inner) == current_function_decl
   12625                 :        2740 :                   && POINTER_TYPE_P (TREE_TYPE (TREE_TYPE (current_function_decl))))
   12626                 :             :                 {
   12627                 :          13 :                   if (TREE_CODE (inner) == LABEL_DECL)
   12628                 :           4 :                     warning_at (loc, OPT_Wreturn_local_addr,
   12629                 :             :                                 "function returns address of label");
   12630                 :             :                   else
   12631                 :             :                     {
   12632                 :           9 :                       warning_at (loc, OPT_Wreturn_local_addr,
   12633                 :             :                                   "function returns address of local variable");
   12634                 :           9 :                       tree zero = build_zero_cst (TREE_TYPE (res));
   12635                 :           9 :                       t = build2 (COMPOUND_EXPR, TREE_TYPE (res), t, zero);
   12636                 :             :                     }
   12637                 :             :                 }
   12638                 :             :               break;
   12639                 :             : 
   12640                 :             :             default:
   12641                 :             :               break;
   12642                 :     3209948 :             }
   12643                 :             : 
   12644                 :    35177476 :           break;
   12645                 :             :         }
   12646                 :             : 
   12647                 :    35177476 :       retval = build2 (MODIFY_EXPR, TREE_TYPE (res), res, t);
   12648                 :    35177476 :       SET_EXPR_LOCATION (retval, loc);
   12649                 :             : 
   12650                 :    35177476 :       if (warn_sequence_point)
   12651                 :     3050637 :         verify_sequence_points (retval);
   12652                 :             :     }
   12653                 :             : 
   12654                 :    35198978 :   ret_stmt = build_stmt (loc, RETURN_EXPR, retval);
   12655                 :    35198978 :   if (no_warning)
   12656                 :          46 :     suppress_warning (ret_stmt, OPT_Wreturn_type);
   12657                 :    35198978 :   return add_stmt (ret_stmt);
   12658                 :             : }
   12659                 :             : 
   12660                 :             : struct c_switch {
   12661                 :             :   /* The SWITCH_STMT being built.  */
   12662                 :             :   tree switch_stmt;
   12663                 :             : 
   12664                 :             :   /* The original type of the testing expression, i.e. before the
   12665                 :             :      default conversion is applied.  */
   12666                 :             :   tree orig_type;
   12667                 :             : 
   12668                 :             :   /* A splay-tree mapping the low element of a case range to the high
   12669                 :             :      element, or NULL_TREE if there is no high element.  Used to
   12670                 :             :      determine whether or not a new case label duplicates an old case
   12671                 :             :      label.  We need a tree, rather than simply a hash table, because
   12672                 :             :      of the GNU case range extension.  */
   12673                 :             :   splay_tree cases;
   12674                 :             : 
   12675                 :             :   /* The bindings at the point of the switch.  This is used for
   12676                 :             :      warnings crossing decls when branching to a case label.  */
   12677                 :             :   struct c_spot_bindings *bindings;
   12678                 :             : 
   12679                 :             :   /* Whether the switch includes any break statements.  */
   12680                 :             :   bool break_stmt_seen_p;
   12681                 :             : 
   12682                 :             :   /* The next node on the stack.  */
   12683                 :             :   struct c_switch *next;
   12684                 :             : 
   12685                 :             :   /* Remember whether the controlling expression had boolean type
   12686                 :             :      before integer promotions for the sake of -Wswitch-bool.  */
   12687                 :             :   bool bool_cond_p;
   12688                 :             : };
   12689                 :             : 
   12690                 :             : /* A stack of the currently active switch statements.  The innermost
   12691                 :             :    switch statement is on the top of the stack.  There is no need to
   12692                 :             :    mark the stack for garbage collection because it is only active
   12693                 :             :    during the processing of the body of a function, and we never
   12694                 :             :    collect at that point.  */
   12695                 :             : 
   12696                 :             : struct c_switch *c_switch_stack;
   12697                 :             : 
   12698                 :             : /* Start a C switch statement, testing expression EXP.  Return the new
   12699                 :             :    SWITCH_STMT.  SWITCH_LOC is the location of the `switch'.
   12700                 :             :    SWITCH_COND_LOC is the location of the switch's condition.
   12701                 :             :    EXPLICIT_CAST_P is true if the expression EXP has an explicit cast.  */
   12702                 :             : 
   12703                 :             : tree
   12704                 :       36683 : c_start_switch (location_t switch_loc,
   12705                 :             :                 location_t switch_cond_loc,
   12706                 :             :                 tree exp, bool explicit_cast_p, tree switch_name)
   12707                 :             : {
   12708                 :       36683 :   tree orig_type = error_mark_node;
   12709                 :       36683 :   bool bool_cond_p = false;
   12710                 :       36683 :   struct c_switch *cs;
   12711                 :             : 
   12712                 :       36683 :   if (exp != error_mark_node)
   12713                 :             :     {
   12714                 :       36640 :       orig_type = TREE_TYPE (exp);
   12715                 :             : 
   12716                 :       36640 :       if (!INTEGRAL_TYPE_P (orig_type))
   12717                 :             :         {
   12718                 :          12 :           if (orig_type != error_mark_node)
   12719                 :             :             {
   12720                 :          12 :               error_at (switch_cond_loc, "switch quantity not an integer");
   12721                 :          12 :               orig_type = error_mark_node;
   12722                 :             :             }
   12723                 :          12 :           exp = integer_zero_node;
   12724                 :             :         }
   12725                 :             :       else
   12726                 :             :         {
   12727                 :       36628 :           tree type = TYPE_MAIN_VARIANT (orig_type);
   12728                 :       36628 :           tree e = exp;
   12729                 :             : 
   12730                 :             :           /* Warn if the condition has boolean value.  */
   12731                 :       36631 :           while (TREE_CODE (e) == COMPOUND_EXPR)
   12732                 :           3 :             e = TREE_OPERAND (e, 1);
   12733                 :             : 
   12734                 :       36603 :           if ((C_BOOLEAN_TYPE_P (type)
   12735                 :       36603 :                || truth_value_p (TREE_CODE (e)))
   12736                 :             :               /* Explicit cast to int suppresses this warning.  */
   12737                 :       36650 :               && !(TREE_CODE (type) == INTEGER_TYPE
   12738                 :             :                    && explicit_cast_p))
   12739                 :             :             bool_cond_p = true;
   12740                 :             : 
   12741                 :       36628 :           if (!in_system_header_at (input_location)
   12742                 :       36628 :               && (type == long_integer_type_node
   12743                 :       11869 :                   || type == long_unsigned_type_node))
   12744                 :         256 :             warning_at (switch_cond_loc,
   12745                 :             :                         OPT_Wtraditional, "%<long%> switch expression not "
   12746                 :             :                         "converted to %<int%> in ISO C");
   12747                 :             : 
   12748                 :       36628 :           exp = c_fully_fold (exp, false, NULL);
   12749                 :       36628 :           exp = default_conversion (exp);
   12750                 :             : 
   12751                 :       36628 :           if (warn_sequence_point)
   12752                 :        6109 :             verify_sequence_points (exp);
   12753                 :             :         }
   12754                 :             :     }
   12755                 :             : 
   12756                 :             :   /* Add this new SWITCH_STMT to the stack.  */
   12757                 :       36683 :   cs = XNEW (struct c_switch);
   12758                 :       36683 :   cs->switch_stmt = build_stmt (switch_loc, SWITCH_STMT, exp,
   12759                 :             :                                 NULL_TREE, orig_type, NULL_TREE, switch_name);
   12760                 :       36683 :   cs->orig_type = orig_type;
   12761                 :       36683 :   cs->cases = splay_tree_new (case_compare, NULL, NULL);
   12762                 :       36683 :   cs->bindings = c_get_switch_bindings ();
   12763                 :       36683 :   cs->break_stmt_seen_p = false;
   12764                 :       36683 :   cs->bool_cond_p = bool_cond_p;
   12765                 :       36683 :   cs->next = c_switch_stack;
   12766                 :       36683 :   c_switch_stack = cs;
   12767                 :             : 
   12768                 :       36683 :   return add_stmt (cs->switch_stmt);
   12769                 :             : }
   12770                 :             : 
   12771                 :             : /* Process a case label at location LOC, with attributes ATTRS.  */
   12772                 :             : 
   12773                 :             : tree
   12774                 :     1024396 : do_case (location_t loc, tree low_value, tree high_value, tree attrs)
   12775                 :             : {
   12776                 :     1024396 :   tree label = NULL_TREE;
   12777                 :             : 
   12778                 :     1024396 :   if (low_value && TREE_CODE (low_value) != INTEGER_CST)
   12779                 :             :     {
   12780                 :          87 :       low_value = c_fully_fold (low_value, false, NULL);
   12781                 :          87 :       if (TREE_CODE (low_value) == INTEGER_CST)
   12782                 :           9 :         pedwarn (loc, OPT_Wpedantic,
   12783                 :             :                  "case label is not an integer constant expression");
   12784                 :             :     }
   12785                 :             : 
   12786                 :     1024396 :   if (high_value && TREE_CODE (high_value) != INTEGER_CST)
   12787                 :             :     {
   12788                 :           0 :       high_value = c_fully_fold (high_value, false, NULL);
   12789                 :           0 :       if (TREE_CODE (high_value) == INTEGER_CST)
   12790                 :           0 :         pedwarn (input_location, OPT_Wpedantic,
   12791                 :             :                  "case label is not an integer constant expression");
   12792                 :             :     }
   12793                 :             : 
   12794                 :     1024396 :   if (c_switch_stack == NULL)
   12795                 :             :     {
   12796                 :           3 :       if (low_value)
   12797                 :           2 :         error_at (loc, "case label not within a switch statement");
   12798                 :             :       else
   12799                 :           1 :         error_at (loc, "%<default%> label not within a switch statement");
   12800                 :           3 :       return NULL_TREE;
   12801                 :             :     }
   12802                 :             : 
   12803                 :     1024393 :   if (c_check_switch_jump_warnings (c_switch_stack->bindings,
   12804                 :     1024393 :                                     EXPR_LOCATION (c_switch_stack->switch_stmt),
   12805                 :             :                                     loc))
   12806                 :             :     return NULL_TREE;
   12807                 :             : 
   12808                 :     1024381 :   label = c_add_case_label (loc, c_switch_stack->cases,
   12809                 :     1024381 :                             SWITCH_STMT_COND (c_switch_stack->switch_stmt),
   12810                 :             :                             low_value, high_value, attrs);
   12811                 :     1024381 :   if (label == error_mark_node)
   12812                 :         144 :     label = NULL_TREE;
   12813                 :             :   return label;
   12814                 :             : }
   12815                 :             : 
   12816                 :             : /* Finish the switch statement.  TYPE is the original type of the
   12817                 :             :    controlling expression of the switch, or NULL_TREE.  */
   12818                 :             : 
   12819                 :             : void
   12820                 :       36683 : c_finish_switch (tree body, tree type)
   12821                 :             : {
   12822                 :       36683 :   struct c_switch *cs = c_switch_stack;
   12823                 :       36683 :   location_t switch_location;
   12824                 :             : 
   12825                 :       36683 :   SWITCH_STMT_BODY (cs->switch_stmt) = body;
   12826                 :             : 
   12827                 :             :   /* Emit warnings as needed.  */
   12828                 :       36683 :   switch_location = EXPR_LOCATION (cs->switch_stmt);
   12829                 :       42873 :   c_do_switch_warnings (cs->cases, switch_location,
   12830                 :        6190 :                         type ? type : SWITCH_STMT_TYPE (cs->switch_stmt),
   12831                 :       36683 :                         SWITCH_STMT_COND (cs->switch_stmt), cs->bool_cond_p);
   12832                 :       36683 :   if (c_switch_covers_all_cases_p (cs->cases,
   12833                 :       36683 :                                    SWITCH_STMT_TYPE (cs->switch_stmt)))
   12834                 :       32855 :     SWITCH_STMT_ALL_CASES_P (cs->switch_stmt) = 1;
   12835                 :       36683 :   SWITCH_STMT_NO_BREAK_P (cs->switch_stmt) = !cs->break_stmt_seen_p;
   12836                 :             : 
   12837                 :             :   /* Pop the stack.  */
   12838                 :       36683 :   c_switch_stack = cs->next;
   12839                 :       36683 :   splay_tree_delete (cs->cases);
   12840                 :       36683 :   c_release_switch_bindings (cs->bindings);
   12841                 :       36683 :   XDELETE (cs);
   12842                 :       36683 : }
   12843                 :             : 
   12844                 :             : /* Emit an if statement.  IF_LOCUS is the location of the 'if'.  COND,
   12845                 :             :    THEN_BLOCK and ELSE_BLOCK are expressions to be used; ELSE_BLOCK
   12846                 :             :    may be null.  */
   12847                 :             : 
   12848                 :             : void
   12849                 :     1241565 : c_finish_if_stmt (location_t if_locus, tree cond, tree then_block,
   12850                 :             :                   tree else_block)
   12851                 :             : {
   12852                 :     1241565 :   tree stmt;
   12853                 :             : 
   12854                 :     1241565 :   stmt = build3 (COND_EXPR, void_type_node, cond, then_block, else_block);
   12855                 :     1241565 :   SET_EXPR_LOCATION (stmt, if_locus);
   12856                 :     1241565 :   add_stmt (stmt);
   12857                 :     1241565 : }
   12858                 :             : 
   12859                 :             : tree
   12860                 :      182885 : c_finish_bc_stmt (location_t loc, tree label, bool is_break, tree name)
   12861                 :             : {
   12862                 :             :   /* In switch statements break is sometimes stylistically used after
   12863                 :             :      a return statement.  This can lead to spurious warnings about
   12864                 :             :      control reaching the end of a non-void function when it is
   12865                 :             :      inlined.  Note that we are calling block_may_fallthru with
   12866                 :             :      language specific tree nodes; this works because
   12867                 :             :      block_may_fallthru returns true when given something it does not
   12868                 :             :      understand.  */
   12869                 :      182885 :   bool skip = !block_may_fallthru (cur_stmt_list);
   12870                 :             : 
   12871                 :      182885 :   if (is_break)
   12872                 :      170719 :     switch (in_statement & ~IN_NAMED_STMT)
   12873                 :             :       {
   12874                 :           9 :       case 0:
   12875                 :           9 :         error_at (loc, "break statement not within loop or switch");
   12876                 :           9 :         return NULL_TREE;
   12877                 :           4 :       case IN_OMP_BLOCK:
   12878                 :           4 :         error_at (loc, "invalid exit from OpenMP structured block");
   12879                 :           4 :         return NULL_TREE;
   12880                 :          12 :       case IN_OMP_FOR:
   12881                 :          12 :         error_at (loc, "break statement used with OpenMP for loop");
   12882                 :          12 :         return NULL_TREE;
   12883                 :             :       case IN_ITERATION_STMT:
   12884                 :             :       case IN_OBJC_FOREACH:
   12885                 :             :         break;
   12886                 :      155568 :       default:
   12887                 :      155568 :         gcc_assert (in_statement & IN_SWITCH_STMT);
   12888                 :      155568 :         c_switch_stack->break_stmt_seen_p = true;
   12889                 :      155568 :         break;
   12890                 :             :       }
   12891                 :             :   else
   12892                 :       12166 :     switch (in_statement & ~(IN_SWITCH_STMT | IN_NAMED_STMT))
   12893                 :             :       {
   12894                 :           7 :       case 0:
   12895                 :           7 :         error_at (loc, "continue statement not within a loop");
   12896                 :           7 :         return NULL_TREE;
   12897                 :           4 :       case IN_OMP_BLOCK:
   12898                 :           4 :         error_at (loc, "invalid exit from OpenMP structured block");
   12899                 :           4 :         return NULL_TREE;
   12900                 :             :       case IN_ITERATION_STMT:
   12901                 :             :       case IN_OMP_FOR:
   12902                 :             :       case IN_OBJC_FOREACH:
   12903                 :             :         break;
   12904                 :           0 :       default:
   12905                 :           0 :         gcc_unreachable ();
   12906                 :             :       }
   12907                 :             : 
   12908                 :      182849 :   if (skip)
   12909                 :             :     return NULL_TREE;
   12910                 :      182291 :   else if ((in_statement & IN_OBJC_FOREACH)
   12911                 :           0 :            && !(is_break && (in_statement & IN_SWITCH_STMT))
   12912                 :           0 :            && name == NULL_TREE)
   12913                 :             :     {
   12914                 :             :       /* The foreach expander produces low-level code using gotos instead
   12915                 :             :          of a structured loop construct.  */
   12916                 :           0 :       gcc_assert (label);
   12917                 :           0 :       return add_stmt (build_stmt (loc, GOTO_EXPR, label));
   12918                 :             :     }
   12919                 :      182379 :   else if (name && C_DECL_LOOP_NAME (name) && C_DECL_SWITCH_NAME (name))
   12920                 :             :     {
   12921                 :           0 :       label = DECL_CHAIN (name);
   12922                 :           0 :       if (!is_break)
   12923                 :           0 :         label = DECL_CHAIN (label);
   12924                 :             :       /* Foreach expander from some outer level.  */
   12925                 :           0 :       return add_stmt (build_stmt (loc, GOTO_EXPR, label));
   12926                 :             :     }
   12927                 :      194446 :   return add_stmt (build_stmt (loc, is_break ? BREAK_STMT : CONTINUE_STMT,
   12928                 :      182291 :                                name));
   12929                 :             : }
   12930                 :             : 
   12931                 :             : /* A helper routine for c_process_expr_stmt and c_finish_stmt_expr.  */
   12932                 :             : 
   12933                 :             : static void
   12934                 :     6250125 : emit_side_effect_warnings (location_t loc, tree expr)
   12935                 :             : {
   12936                 :     6250125 :   maybe_warn_nodiscard (loc, expr);
   12937                 :     6250125 :   if (!warn_unused_value)
   12938                 :             :     return;
   12939                 :     1297109 :   if (expr == error_mark_node)
   12940                 :             :     ;
   12941                 :     1297034 :   else if (!TREE_SIDE_EFFECTS (expr))
   12942                 :             :     {
   12943                 :        6420 :       if (!VOID_TYPE_P (TREE_TYPE (expr))
   12944                 :        6420 :           && !warning_suppressed_p (expr, OPT_Wunused_value))
   12945                 :          28 :         warning_at (loc, OPT_Wunused_value, "statement with no effect");
   12946                 :             :     }
   12947                 :     1290614 :   else if (TREE_CODE (expr) == COMPOUND_EXPR)
   12948                 :             :     {
   12949                 :             :       tree r = expr;
   12950                 :             :       location_t cloc = loc;
   12951                 :       11867 :       while (TREE_CODE (r) == COMPOUND_EXPR)
   12952                 :             :         {
   12953                 :        5949 :           if (EXPR_HAS_LOCATION (r))
   12954                 :        5419 :             cloc = EXPR_LOCATION (r);
   12955                 :        5949 :           r = TREE_OPERAND (r, 1);
   12956                 :             :         }
   12957                 :        5918 :       if (!TREE_SIDE_EFFECTS (r)
   12958                 :          33 :           && !VOID_TYPE_P (TREE_TYPE (r))
   12959                 :          24 :           && !CONVERT_EXPR_P (r)
   12960                 :          24 :           && !warning_suppressed_p (r, OPT_Wunused_value)
   12961                 :        5930 :           && !warning_suppressed_p (expr, OPT_Wunused_value))
   12962                 :           8 :         warning_at (cloc, OPT_Wunused_value,
   12963                 :             :                     "right-hand operand of comma expression has no effect");
   12964                 :             :     }
   12965                 :             :   else
   12966                 :     1284696 :     warn_if_unused_value (expr, loc);
   12967                 :             : }
   12968                 :             : 
   12969                 :             : /* Process an expression as if it were a complete statement.  Emit
   12970                 :             :    diagnostics, but do not call ADD_STMT.  LOC is the location of the
   12971                 :             :    statement.  */
   12972                 :             : 
   12973                 :             : tree
   12974                 :     6126824 : c_process_expr_stmt (location_t loc, tree expr)
   12975                 :             : {
   12976                 :     6126824 :   tree exprv;
   12977                 :             : 
   12978                 :     6126824 :   if (!expr)
   12979                 :             :     return NULL_TREE;
   12980                 :             : 
   12981                 :     6122771 :   expr = c_fully_fold (expr, false, NULL);
   12982                 :             : 
   12983                 :     6122771 :   if (warn_sequence_point)
   12984                 :     1292967 :     verify_sequence_points (expr);
   12985                 :             : 
   12986                 :     6122771 :   if (TREE_TYPE (expr) != error_mark_node
   12987                 :     6120286 :       && !COMPLETE_OR_VOID_TYPE_P (TREE_TYPE (expr))
   12988                 :     6122771 :       && TREE_CODE (TREE_TYPE (expr)) != ARRAY_TYPE)
   12989                 :           0 :     error_at (loc, "expression statement has incomplete type");
   12990                 :             : 
   12991                 :             :   /* If we're not processing a statement expression, warn about unused values.
   12992                 :             :      Warnings for statement expressions will be emitted later, once we figure
   12993                 :             :      out which is the result.  */
   12994                 :     6122771 :   if (!STATEMENT_LIST_STMT_EXPR (cur_stmt_list)
   12995                 :     6122771 :       && (warn_unused_value || warn_unused_result))
   12996                 :     6036329 :     emit_side_effect_warnings (EXPR_LOC_OR_LOC (expr, loc), expr);
   12997                 :             : 
   12998                 :             :   exprv = expr;
   12999                 :     6160918 :   while (TREE_CODE (exprv) == COMPOUND_EXPR)
   13000                 :       38148 :     exprv = TREE_OPERAND (exprv, 1);
   13001                 :     6133291 :   while (CONVERT_EXPR_P (exprv))
   13002                 :       10521 :     exprv = TREE_OPERAND (exprv, 0);
   13003                 :     6122770 :   if (DECL_P (exprv)
   13004                 :     6123317 :       || handled_component_p (exprv)
   13005                 :    12226600 :       || TREE_CODE (exprv) == ADDR_EXPR)
   13006                 :       19487 :     mark_exp_read (exprv);
   13007                 :             : 
   13008                 :             :   /* If the expression is not of a type to which we cannot assign a line
   13009                 :             :      number, wrap the thing in a no-op NOP_EXPR.  */
   13010                 :     6122770 :   if (DECL_P (expr) || CONSTANT_CLASS_P (expr))
   13011                 :             :     {
   13012                 :       14570 :       expr = build1 (NOP_EXPR, TREE_TYPE (expr), expr);
   13013                 :       14570 :       SET_EXPR_LOCATION (expr, loc);
   13014                 :             :     }
   13015                 :             : 
   13016                 :             :   return expr;
   13017                 :             : }
   13018                 :             : 
   13019                 :             : /* Emit an expression as a statement.  LOC is the location of the
   13020                 :             :    expression.  */
   13021                 :             : 
   13022                 :             : tree
   13023                 :     5839204 : c_finish_expr_stmt (location_t loc, tree expr)
   13024                 :             : {
   13025                 :     5839204 :   if (expr)
   13026                 :     5827434 :     return add_stmt (c_process_expr_stmt (loc, expr));
   13027                 :             :   else
   13028                 :             :     return NULL;
   13029                 :             : }
   13030                 :             : 
   13031                 :             : /* Do the opposite and emit a statement as an expression.  To begin,
   13032                 :             :    create a new binding level and return it.  */
   13033                 :             : 
   13034                 :             : tree
   13035                 :       33226 : c_begin_stmt_expr (void)
   13036                 :             : {
   13037                 :       33226 :   tree ret;
   13038                 :             : 
   13039                 :             :   /* We must force a BLOCK for this level so that, if it is not expanded
   13040                 :             :      later, there is a way to turn off the entire subtree of blocks that
   13041                 :             :      are contained in it.  */
   13042                 :       33226 :   keep_next_level ();
   13043                 :       33226 :   ret = c_begin_compound_stmt (true);
   13044                 :             : 
   13045                 :       33226 :   c_bindings_start_stmt_expr (c_switch_stack == NULL
   13046                 :             :                               ? NULL
   13047                 :             :                               : c_switch_stack->bindings);
   13048                 :             : 
   13049                 :             :   /* Mark the current statement list as belonging to a statement list.  */
   13050                 :       33226 :   STATEMENT_LIST_STMT_EXPR (ret) = 1;
   13051                 :             : 
   13052                 :       33226 :   return ret;
   13053                 :             : }
   13054                 :             : 
   13055                 :             : /* LOC is the location of the compound statement to which this body
   13056                 :             :    belongs.  */
   13057                 :             : 
   13058                 :             : tree
   13059                 :       33226 : c_finish_stmt_expr (location_t loc, tree body)
   13060                 :             : {
   13061                 :       33226 :   tree last, type, tmp, val;
   13062                 :       33226 :   tree *last_p;
   13063                 :             : 
   13064                 :       33226 :   body = c_end_compound_stmt (loc, body, true);
   13065                 :             : 
   13066                 :       33226 :   c_bindings_end_stmt_expr (c_switch_stack == NULL
   13067                 :             :                             ? NULL
   13068                 :             :                             : c_switch_stack->bindings);
   13069                 :             : 
   13070                 :             :   /* Locate the last statement in BODY.  See c_end_compound_stmt
   13071                 :             :      about always returning a BIND_EXPR.  */
   13072                 :       33226 :   last_p = &BIND_EXPR_BODY (body);
   13073                 :       33226 :   last = BIND_EXPR_BODY (body);
   13074                 :             : 
   13075                 :       33226 :  continue_searching:
   13076                 :       33226 :   if (TREE_CODE (last) == STATEMENT_LIST)
   13077                 :             :     {
   13078                 :       25742 :       tree_stmt_iterator l = tsi_last (last);
   13079                 :             : 
   13080                 :       25748 :       while (!tsi_end_p (l) && TREE_CODE (tsi_stmt (l)) == DEBUG_BEGIN_STMT)
   13081                 :           6 :         tsi_prev (&l);
   13082                 :             : 
   13083                 :             :       /* This can happen with degenerate cases like ({ }).  No value.  */
   13084                 :       25742 :       if (tsi_end_p (l))
   13085                 :         389 :         return body;
   13086                 :             : 
   13087                 :             :       /* If we're supposed to generate side effects warnings, process
   13088                 :             :          all of the statements except the last.  */
   13089                 :       25353 :       if (warn_unused_value || warn_unused_result)
   13090                 :             :         {
   13091                 :       25353 :           for (tree_stmt_iterator i = tsi_start (last);
   13092                 :      274888 :                tsi_stmt (i) != tsi_stmt (l); tsi_next (&i))
   13093                 :             :             {
   13094                 :      249535 :               location_t tloc;
   13095                 :      249535 :               tree t = tsi_stmt (i);
   13096                 :             : 
   13097                 :      249535 :               tloc = EXPR_HAS_LOCATION (t) ? EXPR_LOCATION (t) : loc;
   13098                 :      249535 :               emit_side_effect_warnings (tloc, t);
   13099                 :             :             }
   13100                 :             :         }
   13101                 :       25353 :       last_p = tsi_stmt_ptr (l);
   13102                 :       25353 :       last = *last_p;
   13103                 :             :     }
   13104                 :             : 
   13105                 :             :   /* If the end of the list is exception related, then the list was split
   13106                 :             :      by a call to push_cleanup.  Continue searching.  */
   13107                 :       32837 :   if (TREE_CODE (last) == TRY_FINALLY_EXPR
   13108                 :       32837 :       || TREE_CODE (last) == TRY_CATCH_EXPR)
   13109                 :             :     {
   13110                 :           0 :       last_p = &TREE_OPERAND (last, 0);
   13111                 :           0 :       last = *last_p;
   13112                 :           0 :       goto continue_searching;
   13113                 :             :     }
   13114                 :             : 
   13115                 :       32837 :   if (last == error_mark_node)
   13116                 :             :     return last;
   13117                 :             : 
   13118                 :             :   /* In the case that the BIND_EXPR is not necessary, return the
   13119                 :             :      expression out from inside it.  */
   13120                 :       32828 :   if ((last == BIND_EXPR_BODY (body)
   13121                 :             :        /* Skip nested debug stmts.  */
   13122                 :       25352 :        || last == expr_first (BIND_EXPR_BODY (body)))
   13123                 :       42289 :       && BIND_EXPR_VARS (body) == NULL)
   13124                 :             :     {
   13125                 :             :       /* Even if this looks constant, do not allow it in a constant
   13126                 :             :          expression.  */
   13127                 :        9452 :       last = c_wrap_maybe_const (last, true);
   13128                 :             :       /* Do not warn if the return value of a statement expression is
   13129                 :             :          unused.  */
   13130                 :        9452 :       suppress_warning (last, OPT_Wunused);
   13131                 :        9452 :       return last;
   13132                 :             :     }
   13133                 :             : 
   13134                 :             :   /* Extract the type of said expression.  */
   13135                 :       23376 :   type = TREE_TYPE (last);
   13136                 :             : 
   13137                 :             :   /* If we're not returning a value at all, then the BIND_EXPR that
   13138                 :             :      we already have is a fine expression to return.  */
   13139                 :       23376 :   if (!type || VOID_TYPE_P (type))
   13140                 :             :     return body;
   13141                 :             : 
   13142                 :             :   /* Now that we've located the expression containing the value, it seems
   13143                 :             :      silly to make voidify_wrapper_expr repeat the process.  Create a
   13144                 :             :      temporary of the appropriate type and stick it in a TARGET_EXPR.  */
   13145                 :       18068 :   tmp = create_tmp_var_raw (type);
   13146                 :             : 
   13147                 :             :   /* Unwrap a no-op NOP_EXPR as added by c_finish_expr_stmt.  This avoids
   13148                 :             :      tree_expr_nonnegative_p giving up immediately.  */
   13149                 :       18068 :   val = last;
   13150                 :       18068 :   if (TREE_CODE (val) == NOP_EXPR
   13151                 :       18068 :       && TREE_TYPE (val) == TREE_TYPE (TREE_OPERAND (val, 0)))
   13152                 :        3698 :     val = TREE_OPERAND (val, 0);
   13153                 :             : 
   13154                 :       18068 :   *last_p = build2 (MODIFY_EXPR, void_type_node, tmp, val);
   13155                 :       18068 :   SET_EXPR_LOCATION (*last_p, EXPR_LOCATION (last));
   13156                 :             : 
   13157                 :       18068 :   {
   13158                 :       18068 :     tree t = build4 (TARGET_EXPR, type, tmp, body, NULL_TREE, NULL_TREE);
   13159                 :       18068 :     SET_EXPR_LOCATION (t, loc);
   13160                 :       18068 :     return t;
   13161                 :             :   }
   13162                 :             : }
   13163                 :             : 
   13164                 :             : /* Begin and end compound statements.  This is as simple as pushing
   13165                 :             :    and popping new statement lists from the tree.  */
   13166                 :             : 
   13167                 :             : tree
   13168                 :    41566819 : c_begin_compound_stmt (bool do_scope)
   13169                 :             : {
   13170                 :    41566819 :   tree stmt = push_stmt_list ();
   13171                 :    41566819 :   if (do_scope)
   13172                 :    41470868 :     push_scope ();
   13173                 :    41566819 :   return stmt;
   13174                 :             : }
   13175                 :             : 
   13176                 :             : /* End a compound statement.  STMT is the statement.  LOC is the
   13177                 :             :    location of the compound statement-- this is usually the location
   13178                 :             :    of the opening brace.  */
   13179                 :             : 
   13180                 :             : tree
   13181                 :    41566818 : c_end_compound_stmt (location_t loc, tree stmt, bool do_scope)
   13182                 :             : {
   13183                 :    41566818 :   tree block = NULL;
   13184                 :             : 
   13185                 :    41566818 :   if (do_scope)
   13186                 :             :     {
   13187                 :    41470867 :       if (c_dialect_objc ())
   13188                 :           0 :         objc_clear_super_receiver ();
   13189                 :    41470867 :       block = pop_scope ();
   13190                 :             :     }
   13191                 :             : 
   13192                 :    41566818 :   stmt = pop_stmt_list (stmt);
   13193                 :    41566818 :   stmt = c_build_bind_expr (loc, block, stmt);
   13194                 :             : 
   13195                 :             :   /* If this compound statement is nested immediately inside a statement
   13196                 :             :      expression, then force a BIND_EXPR to be created.  Otherwise we'll
   13197                 :             :      do the wrong thing for ({ { 1; } }) or ({ 1; { } }).  In particular,
   13198                 :             :      STATEMENT_LISTs merge, and thus we can lose track of what statement
   13199                 :             :      was really last.  */
   13200                 :    83133636 :   if (building_stmt_list_p ()
   13201                 :    41566733 :       && STATEMENT_LIST_STMT_EXPR (cur_stmt_list)
   13202                 :    41687886 :       && TREE_CODE (stmt) != BIND_EXPR)
   13203                 :             :     {
   13204                 :      119329 :       stmt = build3 (BIND_EXPR, void_type_node, NULL, stmt, NULL);
   13205                 :      119329 :       TREE_SIDE_EFFECTS (stmt) = 1;
   13206                 :      119329 :       SET_EXPR_LOCATION (stmt, loc);
   13207                 :             :     }
   13208                 :             : 
   13209                 :    41566818 :   return stmt;
   13210                 :             : }
   13211                 :             : 
   13212                 :             : /* Queue a cleanup.  CLEANUP is an expression/statement to be executed
   13213                 :             :    when the current scope is exited.  EH_ONLY is true when this is not
   13214                 :             :    meant to apply to normal control flow transfer.  */
   13215                 :             : 
   13216                 :             : void
   13217                 :          95 : push_cleanup (tree decl, tree cleanup, bool eh_only)
   13218                 :             : {
   13219                 :          95 :   enum tree_code code;
   13220                 :          95 :   tree stmt, list;
   13221                 :          95 :   bool stmt_expr;
   13222                 :             : 
   13223                 :          95 :   code = eh_only ? TRY_CATCH_EXPR : TRY_FINALLY_EXPR;
   13224                 :          95 :   stmt = build_stmt (DECL_SOURCE_LOCATION (decl), code, NULL, cleanup);
   13225                 :          95 :   add_stmt (stmt);
   13226                 :          95 :   stmt_expr = STATEMENT_LIST_STMT_EXPR (cur_stmt_list);
   13227                 :          95 :   list = push_stmt_list ();
   13228                 :          95 :   TREE_OPERAND (stmt, 0) = list;
   13229                 :          95 :   STATEMENT_LIST_STMT_EXPR (list) = stmt_expr;
   13230                 :          95 : }
   13231                 :             : 
   13232                 :             : /* Build a vector comparison of ARG0 and ARG1 using CODE opcode
   13233                 :             :    into a value of TYPE type.  Comparison is done via VEC_COND_EXPR.  */
   13234                 :             : 
   13235                 :             : static tree
   13236                 :       98863 : build_vec_cmp (tree_code code, tree type,
   13237                 :             :                tree arg0, tree arg1)
   13238                 :             : {
   13239                 :       98863 :   tree zero_vec = build_zero_cst (type);
   13240                 :       98863 :   tree minus_one_vec = build_minus_one_cst (type);
   13241                 :       98863 :   tree cmp_type = truth_type_for (TREE_TYPE (arg0));
   13242                 :       98863 :   tree cmp = build2 (code, cmp_type, arg0, arg1);
   13243                 :       98863 :   return build3 (VEC_COND_EXPR, type, cmp, minus_one_vec, zero_vec);
   13244                 :             : }
   13245                 :             : 
   13246                 :             : /* Possibly warn about an address of OP never being NULL in a comparison
   13247                 :             :    operation CODE involving null.  */
   13248                 :             : 
   13249                 :             : static void
   13250                 :       49986 : maybe_warn_for_null_address (location_t loc, tree op, tree_code code)
   13251                 :             : {
   13252                 :             :   /* Prevent warnings issued for macro expansion.  */
   13253                 :       49986 :   if (!warn_address
   13254                 :       29418 :       || warning_suppressed_p (op, OPT_Waddress)
   13255                 :       79132 :       || from_macro_expansion_at (loc))
   13256                 :       23565 :     return;
   13257                 :             : 
   13258                 :       26421 :   if (TREE_CODE (op) == NOP_EXPR)
   13259                 :             :     {
   13260                 :             :       /* Allow casts to intptr_t to suppress the warning.  */
   13261                 :        1117 :       tree type = TREE_TYPE (op);
   13262                 :        1117 :       if (TREE_CODE (type) == INTEGER_TYPE)
   13263                 :             :         return;
   13264                 :        1117 :       op = TREE_OPERAND (op, 0);
   13265                 :             :     }
   13266                 :             : 
   13267                 :       26421 :   if (TREE_CODE (op) == POINTER_PLUS_EXPR)
   13268                 :             :     {
   13269                 :             :       /* Allow a cast to void* to suppress the warning.  */
   13270                 :          24 :       tree type = TREE_TYPE (TREE_TYPE (op));
   13271                 :          24 :       if (VOID_TYPE_P (type))
   13272                 :             :         return;
   13273                 :             : 
   13274                 :             :       /* Adding any value to a null pointer, including zero, is undefined
   13275                 :             :          in C.  This includes the expression &p[0] where p is the null
   13276                 :             :          pointer, although &p[0] will have been folded to p by this point
   13277                 :             :          and so not diagnosed.  */
   13278                 :          24 :       if (code == EQ_EXPR)
   13279                 :          22 :         warning_at (loc, OPT_Waddress,
   13280                 :             :                     "the comparison will always evaluate as %<false%> "
   13281                 :             :                     "for the pointer operand in %qE must not be NULL",
   13282                 :             :                     op);
   13283                 :             :       else
   13284                 :           2 :         warning_at (loc, OPT_Waddress,
   13285                 :             :                     "the comparison will always evaluate as %<true%> "
   13286                 :             :                     "for the pointer operand in %qE must not be NULL",
   13287                 :             :                     op);
   13288                 :             : 
   13289                 :          24 :       return;
   13290                 :             :     }
   13291                 :             : 
   13292                 :       26397 :   if (TREE_CODE (op) != ADDR_EXPR)
   13293                 :             :     return;
   13294                 :             : 
   13295                 :         254 :   op = TREE_OPERAND (op, 0);
   13296                 :             : 
   13297                 :         254 :   if (TREE_CODE (op) == IMAGPART_EXPR
   13298                 :         254 :       || TREE_CODE (op) == REALPART_EXPR)
   13299                 :             :     {
   13300                 :             :       /* The address of either complex part may not be null.  */
   13301                 :          14 :       if (code == EQ_EXPR)
   13302                 :           9 :         warning_at (loc, OPT_Waddress,
   13303                 :             :                     "the comparison will always evaluate as %<false%> "
   13304                 :             :                     "for the address of %qE will never be NULL",
   13305                 :             :                     op);
   13306                 :             :       else
   13307                 :           5 :         warning_at (loc, OPT_Waddress,
   13308                 :             :                     "the comparison will always evaluate as %<true%> "
   13309                 :             :                     "for the address of %qE will never be NULL",
   13310                 :             :                     op);
   13311                 :          14 :       return;
   13312                 :             :     }
   13313                 :             : 
   13314                 :             :   /* Set to true in the loop below if OP dereferences is operand.
   13315                 :             :      In such a case the ultimate target need not be a decl for
   13316                 :             :      the null [in]equality test to be constant.  */
   13317                 :             :   bool deref = false;
   13318                 :             : 
   13319                 :             :   /* Get the outermost array or object, or member.  */
   13320                 :         294 :   while (handled_component_p (op))
   13321                 :             :     {
   13322                 :          72 :       if (TREE_CODE (op) == COMPONENT_REF)
   13323                 :             :         {
   13324                 :             :           /* Get the member (its address is never null).  */
   13325                 :          18 :           op = TREE_OPERAND (op, 1);
   13326                 :          18 :           break;
   13327                 :             :         }
   13328                 :             : 
   13329                 :             :       /* Get the outer array/object to refer to in the warning.  */
   13330                 :          54 :       op = TREE_OPERAND (op, 0);
   13331                 :          54 :       deref = true;
   13332                 :             :     }
   13333                 :             : 
   13334                 :         192 :   if ((!deref && !decl_with_nonnull_addr_p (op))
   13335                 :         371 :       || from_macro_expansion_at (loc))
   13336                 :         109 :     return;
   13337                 :             : 
   13338                 :         131 :   bool w;
   13339                 :         131 :   if (code == EQ_EXPR)
   13340                 :          93 :     w = warning_at (loc, OPT_Waddress,
   13341                 :             :                     "the comparison will always evaluate as %<false%> "
   13342                 :             :                     "for the address of %qE will never be NULL",
   13343                 :             :                     op);
   13344                 :             :   else
   13345                 :          38 :     w = warning_at (loc, OPT_Waddress,
   13346                 :             :                     "the comparison will always evaluate as %<true%> "
   13347                 :             :                     "for the address of %qE will never be NULL",
   13348                 :             :                     op);
   13349                 :             : 
   13350                 :         131 :   if (w && DECL_P (op))
   13351                 :         120 :     inform (DECL_SOURCE_LOCATION (op), "%qD declared here", op);
   13352                 :             : }
   13353                 :             : 
   13354                 :             : /* Build a binary-operation expression without default conversions.
   13355                 :             :    CODE is the kind of expression to build.
   13356                 :             :    LOCATION is the operator's location.
   13357                 :             :    This function differs from `build' in several ways:
   13358                 :             :    the data type of the result is computed and recorded in it,
   13359                 :             :    warnings are generated if arg data types are invalid,
   13360                 :             :    special handling for addition and subtraction of pointers is known,
   13361                 :             :    and some optimization is done (operations on narrow ints
   13362                 :             :    are done in the narrower type when that gives the same result).
   13363                 :             :    Constant folding is also done before the result is returned.
   13364                 :             : 
   13365                 :             :    Note that the operands will never have enumeral types, or function
   13366                 :             :    or array types, because either they will have the default conversions
   13367                 :             :    performed or they have both just been converted to some other type in which
   13368                 :             :    the arithmetic is to be done.  */
   13369                 :             : 
   13370                 :             : tree
   13371                 :    16400680 : build_binary_op (location_t location, enum tree_code code,
   13372                 :             :                  tree orig_op0, tree orig_op1, bool convert_p)
   13373                 :             : {
   13374                 :    16400680 :   tree type0, type1, orig_type0, orig_type1;
   13375                 :    16400680 :   tree eptype;
   13376                 :    16400680 :   enum tree_code code0, code1;
   13377                 :    16400680 :   tree op0, op1;
   13378                 :    16400680 :   tree ret = error_mark_node;
   13379                 :    16400680 :   const char *invalid_op_diag;
   13380                 :    16400680 :   bool op0_int_operands, op1_int_operands;
   13381                 :    16400680 :   bool int_const, int_const_or_overflow, int_operands;
   13382                 :             : 
   13383                 :             :   /* Expression code to give to the expression when it is built.
   13384                 :             :      Normally this is CODE, which is what the caller asked for,
   13385                 :             :      but in some special cases we change it.  */
   13386                 :    16400680 :   enum tree_code resultcode = code;
   13387                 :             : 
   13388                 :             :   /* Data type in which the computation is to be performed.
   13389                 :             :      In the simplest cases this is the common type of the arguments.  */
   13390                 :    16400680 :   tree result_type = NULL;
   13391                 :             : 
   13392                 :             :   /* When the computation is in excess precision, the type of the
   13393                 :             :      final EXCESS_PRECISION_EXPR.  */
   13394                 :    16400680 :   tree semantic_result_type = NULL;
   13395                 :             : 
   13396                 :             :   /* Nonzero means operands have already been type-converted
   13397                 :             :      in whatever way is necessary.
   13398                 :             :      Zero means they need to be converted to RESULT_TYPE.  */
   13399                 :    16400680 :   int converted = 0;
   13400                 :             : 
   13401                 :             :   /* Nonzero means create the expression with this type, rather than
   13402                 :             :      RESULT_TYPE.  */
   13403                 :    16400680 :   tree build_type = NULL_TREE;
   13404                 :             : 
   13405                 :             :   /* Nonzero means after finally constructing the expression
   13406                 :             :      convert it to this type.  */
   13407                 :    16400680 :   tree final_type = NULL_TREE;
   13408                 :             : 
   13409                 :             :   /* Nonzero if this is an operation like MIN or MAX which can
   13410                 :             :      safely be computed in short if both args are promoted shorts.
   13411                 :             :      Also implies COMMON.
   13412                 :             :      -1 indicates a bitwise operation; this makes a difference
   13413                 :             :      in the exact conditions for when it is safe to do the operation
   13414                 :             :      in a narrower mode.  */
   13415                 :    16400680 :   int shorten = 0;
   13416                 :             : 
   13417                 :             :   /* Nonzero if this is a comparison operation;
   13418                 :             :      if both args are promoted shorts, compare the original shorts.
   13419                 :             :      Also implies COMMON.  */
   13420                 :    16400680 :   int short_compare = 0;
   13421                 :             : 
   13422                 :             :   /* Nonzero if this is a right-shift operation, which can be computed on the
   13423                 :             :      original short and then promoted if the operand is a promoted short.  */
   13424                 :    16400680 :   int short_shift = 0;
   13425                 :             : 
   13426                 :             :   /* Nonzero means set RESULT_TYPE to the common type of the args.  */
   13427                 :    16400680 :   int common = 0;
   13428                 :             : 
   13429                 :             :   /* True means types are compatible as far as ObjC is concerned.  */
   13430                 :    16400680 :   bool objc_ok;
   13431                 :             : 
   13432                 :             :   /* True means this is an arithmetic operation that may need excess
   13433                 :             :      precision.  */
   13434                 :    16400680 :   bool may_need_excess_precision;
   13435                 :             : 
   13436                 :             :   /* True means this is a boolean operation that converts both its
   13437                 :             :      operands to truth-values.  */
   13438                 :    16400680 :   bool boolean_op = false;
   13439                 :             : 
   13440                 :             :   /* Remember whether we're doing / or %.  */
   13441                 :    16400680 :   bool doing_div_or_mod = false;
   13442                 :             : 
   13443                 :             :   /* Remember whether we're doing << or >>.  */
   13444                 :    16400680 :   bool doing_shift = false;
   13445                 :             : 
   13446                 :             :   /* Tree holding instrumentation expression.  */
   13447                 :    16400680 :   tree instrument_expr = NULL;
   13448                 :             : 
   13449                 :    16400680 :   if (location == UNKNOWN_LOCATION)
   13450                 :       19350 :     location = input_location;
   13451                 :             : 
   13452                 :    16400680 :   op0 = orig_op0;
   13453                 :    16400680 :   op1 = orig_op1;
   13454                 :             : 
   13455                 :    16400680 :   op0_int_operands = EXPR_INT_CONST_OPERANDS (orig_op0);
   13456                 :     7837764 :   if (op0_int_operands)
   13457                 :     7837764 :     op0 = remove_c_maybe_const_expr (op0);
   13458                 :    16400680 :   op1_int_operands = EXPR_INT_CONST_OPERANDS (orig_op1);
   13459                 :    11051084 :   if (op1_int_operands)
   13460                 :    11051084 :     op1 = remove_c_maybe_const_expr (op1);
   13461                 :    27451764 :   int_operands = (op0_int_operands && op1_int_operands);
   13462                 :    11051084 :   if (int_operands)
   13463                 :             :     {
   13464                 :    15329811 :       int_const_or_overflow = (TREE_CODE (orig_op0) == INTEGER_CST
   13465                 :     7680072 :                                && TREE_CODE (orig_op1) == INTEGER_CST);
   13466                 :     7649739 :       int_const = (int_const_or_overflow
   13467                 :     7649739 :                    && !TREE_OVERFLOW (orig_op0)
   13468                 :     7649670 :                    && !TREE_OVERFLOW (orig_op1));
   13469                 :             :     }
   13470                 :             :   else
   13471                 :             :     int_const = int_const_or_overflow = false;
   13472                 :             : 
   13473                 :             :   /* Do not apply default conversion in mixed vector/scalar expression.  */
   13474                 :    16400680 :   if (convert_p
   13475                 :    16400680 :       && VECTOR_TYPE_P (TREE_TYPE (op0)) == VECTOR_TYPE_P (TREE_TYPE (op1)))
   13476                 :             :     {
   13477                 :     9970119 :       op0 = default_conversion (op0);
   13478                 :     9970119 :       op1 = default_conversion (op1);
   13479                 :             :     }
   13480                 :             : 
   13481                 :    16400680 :   orig_type0 = type0 = TREE_TYPE (op0);
   13482                 :             : 
   13483                 :    16400680 :   orig_type1 = type1 = TREE_TYPE (op1);
   13484                 :             : 
   13485                 :             :   /* The expression codes of the data types of the arguments tell us
   13486                 :             :      whether the arguments are integers, floating, pointers, etc.  */
   13487                 :    16400680 :   code0 = TREE_CODE (type0);
   13488                 :    16400680 :   code1 = TREE_CODE (type1);
   13489                 :             : 
   13490                 :             :   /* Strip NON_LVALUE_EXPRs, etc., since we aren't using as an lvalue.  */
   13491                 :    16400682 :   STRIP_TYPE_NOPS (op0);
   13492                 :    16400683 :   STRIP_TYPE_NOPS (op1);
   13493                 :             : 
   13494                 :             :   /* If an error was already reported for one of the arguments,
   13495                 :             :      avoid reporting another error.  */
   13496                 :             : 
   13497                 :    16400680 :   if (code0 == ERROR_MARK || code1 == ERROR_MARK)
   13498                 :         707 :     return error_mark_node;
   13499                 :             : 
   13500                 :    16399973 :   if (code0 == POINTER_TYPE
   13501                 :    16399973 :       && reject_gcc_builtin (op0, EXPR_LOCATION (orig_op0)))
   13502                 :          11 :     return error_mark_node;
   13503                 :             : 
   13504                 :    16399962 :   if (code1 == POINTER_TYPE
   13505                 :    16399962 :       && reject_gcc_builtin (op1, EXPR_LOCATION (orig_op1)))
   13506                 :          11 :     return error_mark_node;
   13507                 :             : 
   13508                 :    32799902 :   if ((invalid_op_diag
   13509                 :    16399951 :        = targetm.invalid_binary_op (code, type0, type1)))
   13510                 :             :     {
   13511                 :           0 :       error_at (location, invalid_op_diag);
   13512                 :           0 :       return error_mark_node;
   13513                 :             :     }
   13514                 :             : 
   13515                 :    16399951 :   switch (code)
   13516                 :             :     {
   13517                 :             :     case PLUS_EXPR:
   13518                 :             :     case MINUS_EXPR:
   13519                 :             :     case MULT_EXPR:
   13520                 :             :     case TRUNC_DIV_EXPR:
   13521                 :             :     case CEIL_DIV_EXPR:
   13522                 :             :     case FLOOR_DIV_EXPR:
   13523                 :             :     case ROUND_DIV_EXPR:
   13524                 :             :     case EXACT_DIV_EXPR:
   13525                 :             :       may_need_excess_precision = true;
   13526                 :             :       break;
   13527                 :             : 
   13528                 :     2660230 :     case EQ_EXPR:
   13529                 :     2660230 :     case NE_EXPR:
   13530                 :     2660230 :     case LE_EXPR:
   13531                 :     2660230 :     case GE_EXPR:
   13532                 :     2660230 :     case LT_EXPR:
   13533                 :     2660230 :     case GT_EXPR:
   13534                 :             :       /* Excess precision for implicit conversions of integers to
   13535                 :             :          floating point in C11 and later.  */
   13536                 :     2660230 :       may_need_excess_precision = (flag_isoc11
   13537                 :     2660230 :                                    && (ANY_INTEGRAL_TYPE_P (type0)
   13538                 :      468910 :                                        || ANY_INTEGRAL_TYPE_P (type1)));
   13539                 :             :       break;
   13540                 :             : 
   13541                 :             :     default:
   13542                 :    16399951 :       may_need_excess_precision = false;
   13543                 :             :       break;
   13544                 :             :     }
   13545                 :    16399951 :   if (TREE_CODE (op0) == EXCESS_PRECISION_EXPR)
   13546                 :             :     {
   13547                 :         184 :       op0 = TREE_OPERAND (op0, 0);
   13548                 :         184 :       type0 = TREE_TYPE (op0);
   13549                 :             :     }
   13550                 :    16399767 :   else if (may_need_excess_precision
   13551                 :    16399767 :            && (eptype = excess_precision_type (type0)) != NULL_TREE)
   13552                 :             :     {
   13553                 :         771 :       type0 = eptype;
   13554                 :         771 :       op0 = convert (eptype, op0);
   13555                 :             :     }
   13556                 :    16399951 :   if (TREE_CODE (op1) == EXCESS_PRECISION_EXPR)
   13557                 :             :     {
   13558                 :         887 :       op1 = TREE_OPERAND (op1, 0);
   13559                 :         887 :       type1 = TREE_TYPE (op1);
   13560                 :             :     }
   13561                 :    16399064 :   else if (may_need_excess_precision
   13562                 :    16399064 :            && (eptype = excess_precision_type (type1)) != NULL_TREE)
   13563                 :             :     {
   13564                 :         592 :       type1 = eptype;
   13565                 :         592 :       op1 = convert (eptype, op1);
   13566                 :             :     }
   13567                 :             : 
   13568                 :    16399951 :   objc_ok = objc_compare_types (type0, type1, -3, NULL_TREE);
   13569                 :             : 
   13570                 :             :   /* In case when one of the operands of the binary operation is
   13571                 :             :      a vector and another is a scalar -- convert scalar to vector.  */
   13572                 :    17944647 :   if ((gnu_vector_type_p (type0) && code1 != VECTOR_TYPE)
   13573                 :    17942890 :       || (gnu_vector_type_p (type1) && code0 != VECTOR_TYPE))
   13574                 :             :     {
   13575                 :        2328 :       enum stv_conv convert_flag = scalar_to_vector (location, code, orig_op0,
   13576                 :             :                                                      orig_op1, true);
   13577                 :             : 
   13578                 :        2328 :       switch (convert_flag)
   13579                 :             :         {
   13580                 :          12 :           case stv_error:
   13581                 :          12 :             return error_mark_node;
   13582                 :         558 :           case stv_firstarg:
   13583                 :         558 :             {
   13584                 :         558 :               bool maybe_const = true;
   13585                 :         558 :               tree sc;
   13586                 :         558 :               sc = c_fully_fold (op0, false, &maybe_const);
   13587                 :         558 :               sc = save_expr (sc);
   13588                 :         558 :               sc = convert (TREE_TYPE (type1), sc);
   13589                 :         558 :               op0 = build_vector_from_val (type1, sc);
   13590                 :         558 :               if (!maybe_const)
   13591                 :          93 :                 op0 = c_wrap_maybe_const (op0, true);
   13592                 :         558 :               orig_type0 = type0 = TREE_TYPE (op0);
   13593                 :         558 :               code0 = TREE_CODE (type0);
   13594                 :         558 :               converted = 1;
   13595                 :         558 :               break;
   13596                 :             :             }
   13597                 :         963 :           case stv_secondarg:
   13598                 :         963 :             {
   13599                 :         963 :               bool maybe_const = true;
   13600                 :         963 :               tree sc;
   13601                 :         963 :               sc = c_fully_fold (op1, false, &maybe_const);
   13602                 :         963 :               sc = save_expr (sc);
   13603                 :         963 :               sc = convert (TREE_TYPE (type0), sc);
   13604                 :         963 :               op1 = build_vector_from_val (type0, sc);
   13605                 :         963 :               if (!maybe_const)
   13606                 :          33 :                 op1 = c_wrap_maybe_const (op1, true);
   13607                 :         963 :               orig_type1 = type1 = TREE_TYPE (op1);
   13608                 :         963 :               code1 = TREE_CODE (type1);
   13609                 :         963 :               converted = 1;
   13610                 :         963 :               break;
   13611                 :             :             }
   13612                 :             :           default:
   13613                 :             :             break;
   13614                 :             :         }
   13615                 :             :     }
   13616                 :             : 
   13617                 :    16399939 :   switch (code)
   13618                 :             :     {
   13619                 :     8346672 :     case PLUS_EXPR:
   13620                 :             :       /* Handle the pointer + int case.  */
   13621                 :     8346672 :       if (code0 == POINTER_TYPE
   13622                 :     1210025 :           && (code1 == INTEGER_TYPE || code1 == BITINT_TYPE))
   13623                 :             :         {
   13624                 :     1210019 :           ret = pointer_int_sum (location, PLUS_EXPR, op0, op1);
   13625                 :     1210019 :           goto return_build_binary_op;
   13626                 :             :         }
   13627                 :     7136653 :       else if (code1 == POINTER_TYPE
   13628                 :        1505 :                && (code0 == INTEGER_TYPE || code0 == BITINT_TYPE))
   13629                 :             :         {
   13630                 :        1499 :           ret = pointer_int_sum (location, PLUS_EXPR, op1, op0);
   13631                 :        1499 :           goto return_build_binary_op;
   13632                 :             :         }
   13633                 :             :       else
   13634                 :             :         common = 1;
   13635                 :             :       break;
   13636                 :             : 
   13637                 :      779723 :     case MINUS_EXPR:
   13638                 :             :       /* Subtraction of two similar pointers.
   13639                 :             :          We must subtract them as integers, then divide by object size.  */
   13640                 :      779723 :       if (code0 == POINTER_TYPE && code1 == POINTER_TYPE
   13641                 :      779723 :           && comp_target_types (location, type0, type1))
   13642                 :             :         {
   13643                 :        3634 :           ret = pointer_diff (location, op0, op1, &instrument_expr);
   13644                 :        3634 :           goto return_build_binary_op;
   13645                 :             :         }
   13646                 :             :       /* Handle pointer minus int.  Just like pointer plus int.  */
   13647                 :      776089 :       else if (code0 == POINTER_TYPE
   13648                 :       28613 :                && (code1 == INTEGER_TYPE || code1 == BITINT_TYPE))
   13649                 :             :         {
   13650                 :       28601 :           ret = pointer_int_sum (location, MINUS_EXPR, op0, op1);
   13651                 :       28601 :           goto return_build_binary_op;
   13652                 :             :         }
   13653                 :             :       else
   13654                 :             :         common = 1;
   13655                 :             :       break;
   13656                 :             : 
   13657                 :             :     case MULT_EXPR:
   13658                 :             :       common = 1;
   13659                 :             :       break;
   13660                 :             : 
   13661                 :      275295 :     case TRUNC_DIV_EXPR:
   13662                 :      275295 :     case CEIL_DIV_EXPR:
   13663                 :      275295 :     case FLOOR_DIV_EXPR:
   13664                 :      275295 :     case ROUND_DIV_EXPR:
   13665                 :      275295 :     case EXACT_DIV_EXPR:
   13666                 :      275295 :       doing_div_or_mod = true;
   13667                 :      275295 :       warn_for_div_by_zero (location, op1);
   13668                 :             : 
   13669                 :      275294 :       if ((code0 == INTEGER_TYPE || code0 == REAL_TYPE
   13670                 :       48614 :            || code0 == FIXED_POINT_TYPE || code0 == BITINT_TYPE
   13671                 :       46638 :            || code0 == COMPLEX_TYPE
   13672                 :       44592 :            || gnu_vector_type_p (type0))
   13673                 :      323907 :           && (code1 == INTEGER_TYPE || code1 == REAL_TYPE
   13674                 :       46187 :               || code1 == FIXED_POINT_TYPE || code1 == BITINT_TYPE
   13675                 :       46051 :               || code1 == COMPLEX_TYPE
   13676                 :       44594 :               || gnu_vector_type_p (type1)))
   13677                 :             :         {
   13678                 :      275290 :           enum tree_code tcode0 = code0, tcode1 = code1;
   13679                 :             : 
   13680                 :      275290 :           if (code0 == COMPLEX_TYPE || code0 == VECTOR_TYPE)
   13681                 :       46637 :             tcode0 = TREE_CODE (TREE_TYPE (TREE_TYPE (op0)));
   13682                 :      275290 :           if (code1 == COMPLEX_TYPE || code1 == VECTOR_TYPE)
   13683                 :       46048 :             tcode1 = TREE_CODE (TREE_TYPE (TREE_TYPE (op1)));
   13684                 :             : 
   13685                 :      275290 :           if (!(((tcode0 == INTEGER_TYPE || tcode0 == BITINT_TYPE)
   13686                 :      207500 :                  && (tcode1 == INTEGER_TYPE || tcode1 == BITINT_TYPE))
   13687                 :       79819 :                 || (tcode0 == FIXED_POINT_TYPE && tcode1 == FIXED_POINT_TYPE)))
   13688                 :             :             resultcode = RDIV_EXPR;
   13689                 :             :           else
   13690                 :             :             /* Although it would be tempting to shorten always here, that
   13691                 :             :                loses on some targets, since the modulo instruction is
   13692                 :             :                undefined if the quotient can't be represented in the
   13693                 :             :                computation mode.  We shorten only if unsigned or if
   13694                 :             :                dividing by something we know != -1.  */
   13695                 :      195471 :             shorten = may_shorten_divmod (op0, op1);
   13696                 :             :           common = 1;
   13697                 :             :         }
   13698                 :             :       break;
   13699                 :             : 
   13700                 :     1575359 :     case BIT_AND_EXPR:
   13701                 :     1575359 :     case BIT_IOR_EXPR:
   13702                 :     1575359 :     case BIT_XOR_EXPR:
   13703                 :     1575359 :       if ((code0 == INTEGER_TYPE || code0 == BITINT_TYPE)
   13704                 :     1051898 :           && (code1 == INTEGER_TYPE || code1 == BITINT_TYPE))
   13705                 :             :         shorten = -1;
   13706                 :             :       /* Allow vector types which are not floating point types.   */
   13707                 :      523497 :       else if (gnu_vector_type_p (type0)
   13708                 :      523420 :                && gnu_vector_type_p (type1)
   13709                 :      523420 :                && !VECTOR_FLOAT_TYPE_P (type0)
   13710                 :     1046914 :                && !VECTOR_FLOAT_TYPE_P (type1))
   13711                 :             :         common = 1;
   13712                 :             :       break;
   13713                 :             : 
   13714                 :       56506 :     case TRUNC_MOD_EXPR:
   13715                 :       56506 :     case FLOOR_MOD_EXPR:
   13716                 :       56506 :       doing_div_or_mod = true;
   13717                 :       56506 :       warn_for_div_by_zero (location, op1);
   13718                 :             : 
   13719                 :       56506 :       if (gnu_vector_type_p (type0)
   13720                 :         295 :           && gnu_vector_type_p (type1)
   13721                 :         295 :           && TREE_CODE (TREE_TYPE (type0)) == INTEGER_TYPE
   13722                 :       56801 :           && TREE_CODE (TREE_TYPE (type1)) == INTEGER_TYPE)
   13723                 :             :         common = 1;
   13724                 :       56211 :       else if ((code0 == INTEGER_TYPE || code0 == BITINT_TYPE)
   13725                 :       56210 :                && (code1 == INTEGER_TYPE || code1 == BITINT_TYPE))
   13726                 :             :         {
   13727                 :             :           /* Although it would be tempting to shorten always here, that loses
   13728                 :             :              on some targets, since the modulo instruction is undefined if the
   13729                 :             :              quotient can't be represented in the computation mode.  We shorten
   13730                 :             :              only if unsigned or if dividing by something we know != -1.  */
   13731                 :       56210 :           shorten = may_shorten_divmod (op0, op1);
   13732                 :       56210 :           common = 1;
   13733                 :             :         }
   13734                 :             :       break;
   13735                 :             : 
   13736                 :      500891 :     case TRUTH_ANDIF_EXPR:
   13737                 :      500891 :     case TRUTH_ORIF_EXPR:
   13738                 :      500891 :     case TRUTH_AND_EXPR:
   13739                 :      500891 :     case TRUTH_OR_EXPR:
   13740                 :      500891 :     case TRUTH_XOR_EXPR:
   13741                 :      500891 :       if ((code0 == INTEGER_TYPE || code0 == POINTER_TYPE
   13742                 :           0 :            || code0 == REAL_TYPE || code0 == COMPLEX_TYPE
   13743                 :           0 :            || code0 == FIXED_POINT_TYPE || code0 == NULLPTR_TYPE
   13744                 :           0 :            || code0 == BITINT_TYPE)
   13745                 :      500891 :           && (code1 == INTEGER_TYPE || code1 == POINTER_TYPE
   13746                 :         159 :               || code1 == REAL_TYPE || code1 == COMPLEX_TYPE
   13747                 :          20 :               || code1 == FIXED_POINT_TYPE || code1 == NULLPTR_TYPE
   13748                 :          18 :               || code1 == BITINT_TYPE))
   13749                 :             :         {
   13750                 :             :           /* Result of these operations is always an int,
   13751                 :             :              but that does not mean the operands should be
   13752                 :             :              converted to ints!  */
   13753                 :      500891 :           result_type = integer_type_node;
   13754                 :      500891 :           if (op0_int_operands)
   13755                 :             :             {
   13756                 :      110618 :               op0 = c_objc_common_truthvalue_conversion (location, orig_op0);
   13757                 :      110618 :               op0 = remove_c_maybe_const_expr (op0);
   13758                 :             :             }
   13759                 :             :           else
   13760                 :      390273 :             op0 = c_objc_common_truthvalue_conversion (location, op0);
   13761                 :      500891 :           if (op1_int_operands)
   13762                 :             :             {
   13763                 :       72032 :               op1 = c_objc_common_truthvalue_conversion (location, orig_op1);
   13764                 :       72032 :               op1 = remove_c_maybe_const_expr (op1);
   13765                 :             :             }
   13766                 :             :           else
   13767                 :      428859 :             op1 = c_objc_common_truthvalue_conversion (location, op1);
   13768                 :             :           converted = 1;
   13769                 :             :           boolean_op = true;
   13770                 :             :         }
   13771                 :      500891 :       if (code == TRUTH_ANDIF_EXPR)
   13772                 :             :         {
   13773                 :      244591 :           int_const_or_overflow = (int_operands
   13774                 :       63955 :                                    && TREE_CODE (orig_op0) == INTEGER_CST
   13775                 :      244607 :                                    && (op0 == truthvalue_false_node
   13776                 :       13713 :                                        || TREE_CODE (orig_op1) == INTEGER_CST));
   13777                 :             :           int_const = (int_const_or_overflow
   13778                 :       63928 :                        && !TREE_OVERFLOW (orig_op0)
   13779                 :       63928 :                        && (op0 == truthvalue_false_node
   13780                 :       13697 :                            || !TREE_OVERFLOW (orig_op1)));
   13781                 :             :         }
   13782                 :      320228 :       else if (code == TRUTH_ORIF_EXPR)
   13783                 :             :         {
   13784                 :      326844 :           int_const_or_overflow = (int_operands
   13785                 :        6767 :                                    && TREE_CODE (orig_op0) == INTEGER_CST
   13786                 :      326867 :                                    && (op0 == truthvalue_true_node
   13787                 :        2084 :                                        || TREE_CODE (orig_op1) == INTEGER_CST));
   13788                 :             :           int_const = (int_const_or_overflow
   13789                 :        6737 :                        && !TREE_OVERFLOW (orig_op0)
   13790                 :        6737 :                        && (op0 == truthvalue_true_node
   13791                 :        2061 :                            || !TREE_OVERFLOW (orig_op1)));
   13792                 :             :         }
   13793                 :             :       break;
   13794                 :             : 
   13795                 :             :       /* Shift operations: result has same type as first operand;
   13796                 :             :          always convert second operand to int.
   13797                 :             :          Also set SHORT_SHIFT if shifting rightward.  */
   13798                 :             : 
   13799                 :      198392 :     case RSHIFT_EXPR:
   13800                 :      198392 :       if (gnu_vector_type_p (type0)
   13801                 :         759 :           && gnu_vector_type_p (type1)
   13802                 :         248 :           && TREE_CODE (TREE_TYPE (type0)) == INTEGER_TYPE
   13803                 :         246 :           && TREE_CODE (TREE_TYPE (type1)) == INTEGER_TYPE
   13804                 :      198638 :           && known_eq (TYPE_VECTOR_SUBPARTS (type0),
   13805                 :             :                        TYPE_VECTOR_SUBPARTS (type1)))
   13806                 :             :         {
   13807                 :             :           result_type = type0;
   13808                 :             :           converted = 1;
   13809                 :             :         }
   13810                 :      198148 :       else if ((code0 == INTEGER_TYPE || code0 == FIXED_POINT_TYPE
   13811                 :        1025 :                 || code0 == BITINT_TYPE
   13812                 :         519 :                 || (gnu_vector_type_p (type0)
   13813                 :         515 :                     && TREE_CODE (TREE_TYPE (type0)) == INTEGER_TYPE))
   13814                 :      199166 :                && (code1 == INTEGER_TYPE || code1 == BITINT_TYPE))
   13815                 :             :         {
   13816                 :      198139 :           doing_shift = true;
   13817                 :      198139 :           if (TREE_CODE (op1) == INTEGER_CST)
   13818                 :             :             {
   13819                 :      169287 :               if (tree_int_cst_sgn (op1) < 0)
   13820                 :             :                 {
   13821                 :         245 :                   int_const = false;
   13822                 :         245 :                   if (c_inhibit_evaluation_warnings == 0)
   13823                 :         105 :                     warning_at (location, OPT_Wshift_count_negative,
   13824                 :             :                                 "right shift count is negative");
   13825                 :             :                 }
   13826                 :      169042 :               else if (code0 == VECTOR_TYPE)
   13827                 :             :                 {
   13828                 :         434 :                   if (compare_tree_int (op1,
   13829                 :         434 :                                         TYPE_PRECISION (TREE_TYPE (type0)))
   13830                 :             :                       >= 0)
   13831                 :             :                     {
   13832                 :          16 :                       int_const = false;
   13833                 :          16 :                       if (c_inhibit_evaluation_warnings == 0)
   13834                 :          16 :                         warning_at (location, OPT_Wshift_count_overflow,
   13835                 :             :                                     "right shift count >= width of vector element");
   13836                 :             :                     }
   13837                 :             :                 }
   13838                 :             :               else
   13839                 :             :                 {
   13840                 :      168608 :                   if (!integer_zerop (op1))
   13841                 :      168250 :                     short_shift = 1;
   13842                 :             : 
   13843                 :      168608 :                   if (compare_tree_int (op1, TYPE_PRECISION (type0)) >= 0)
   13844                 :             :                     {
   13845                 :         584 :                       int_const = false;
   13846                 :         584 :                       if (c_inhibit_evaluation_warnings == 0)
   13847                 :          50 :                         warning_at (location, OPT_Wshift_count_overflow,
   13848                 :             :                                     "right shift count >= width of type");
   13849                 :             :                     }
   13850                 :             :                 }
   13851                 :             :             }
   13852                 :             : 
   13853                 :             :           /* Use the type of the value to be shifted.  */
   13854                 :             :           result_type = type0;
   13855                 :             :           /* Avoid converting op1 to result_type later.  */
   13856                 :             :           converted = 1;
   13857                 :             :         }
   13858                 :             :       break;
   13859                 :             : 
   13860                 :      814576 :     case LSHIFT_EXPR:
   13861                 :      814576 :       if (gnu_vector_type_p (type0)
   13862                 :         586 :           && gnu_vector_type_p (type1)
   13863                 :         308 :           && TREE_CODE (TREE_TYPE (type0)) == INTEGER_TYPE
   13864                 :         306 :           && TREE_CODE (TREE_TYPE (type1)) == INTEGER_TYPE
   13865                 :      814881 :           && known_eq (TYPE_VECTOR_SUBPARTS (type0),
   13866                 :             :                        TYPE_VECTOR_SUBPARTS (type1)))
   13867                 :             :         {
   13868                 :             :           result_type = type0;
   13869                 :             :           converted = 1;
   13870                 :             :         }
   13871                 :      814273 :       else if ((code0 == INTEGER_TYPE || code0 == FIXED_POINT_TYPE
   13872                 :         732 :                 || code0 == BITINT_TYPE
   13873                 :         289 :                 || (gnu_vector_type_p (type0)
   13874                 :         283 :                     && TREE_CODE (TREE_TYPE (type0)) == INTEGER_TYPE))
   13875                 :      814996 :                && (code1 == INTEGER_TYPE || code1 == BITINT_TYPE))
   13876                 :             :         {
   13877                 :      814259 :           doing_shift = true;
   13878                 :      814259 :           if (TREE_CODE (op0) == INTEGER_CST
   13879                 :      417390 :               && tree_int_cst_sgn (op0) < 0
   13880                 :      815008 :               && !TYPE_OVERFLOW_WRAPS (type0))
   13881                 :             :             {
   13882                 :             :               /* Don't reject a left shift of a negative value in a context
   13883                 :             :                  where a constant expression is needed in C90.  */
   13884                 :         712 :               if (flag_isoc99)
   13885                 :         666 :                 int_const = false;
   13886                 :         712 :               if (c_inhibit_evaluation_warnings == 0)
   13887                 :         712 :                 warning_at (location, OPT_Wshift_negative_value,
   13888                 :             :                             "left shift of negative value");
   13889                 :             :             }
   13890                 :      814259 :           if (TREE_CODE (op1) == INTEGER_CST)
   13891                 :             :             {
   13892                 :      744903 :               if (tree_int_cst_sgn (op1) < 0)
   13893                 :             :                 {
   13894                 :         281 :                   int_const = false;
   13895                 :         281 :                   if (c_inhibit_evaluation_warnings == 0)
   13896                 :         103 :                     warning_at (location, OPT_Wshift_count_negative,
   13897                 :             :                                 "left shift count is negative");
   13898                 :             :                 }
   13899                 :      744622 :               else if (code0 == VECTOR_TYPE)
   13900                 :             :                 {
   13901                 :         214 :                   if (compare_tree_int (op1,
   13902                 :         214 :                                         TYPE_PRECISION (TREE_TYPE (type0)))
   13903                 :             :                       >= 0)
   13904                 :             :                     {
   13905                 :           6 :                       int_const = false;
   13906                 :           6 :                       if (c_inhibit_evaluation_warnings == 0)
   13907                 :           6 :                         warning_at (location, OPT_Wshift_count_overflow,
   13908                 :             :                                     "left shift count >= width of vector element");
   13909                 :             :                     }
   13910                 :             :                 }
   13911                 :      744408 :               else if (compare_tree_int (op1, TYPE_PRECISION (type0)) >= 0)
   13912                 :             :                 {
   13913                 :       29731 :                   int_const = false;
   13914                 :       29731 :                   if (c_inhibit_evaluation_warnings == 0)
   13915                 :         111 :                     warning_at (location, OPT_Wshift_count_overflow,
   13916                 :             :                                 "left shift count >= width of type");
   13917                 :             :                 }
   13918                 :      714677 :               else if (TREE_CODE (op0) == INTEGER_CST
   13919                 :      346110 :                        && maybe_warn_shift_overflow (location, op0, op1)
   13920                 :      715309 :                        && flag_isoc99)
   13921                 :             :                 int_const = false;
   13922                 :             :             }
   13923                 :             : 
   13924                 :             :           /* Use the type of the value to be shifted.  */
   13925                 :             :           result_type = type0;
   13926                 :             :           /* Avoid converting op1 to result_type later.  */
   13927                 :             :           converted = 1;
   13928                 :             :         }
   13929                 :             :       break;
   13930                 :             : 
   13931                 :     1667464 :     case EQ_EXPR:
   13932                 :     1667464 :     case NE_EXPR:
   13933                 :     1667464 :       if (gnu_vector_type_p (type0) && gnu_vector_type_p (type1))
   13934                 :             :         {
   13935                 :       40972 :           tree intt;
   13936                 :       40972 :           if (!vector_types_compatible_elements_p (type0, type1))
   13937                 :             :             {
   13938                 :           4 :               error_at (location, "comparing vectors with different "
   13939                 :             :                                   "element types");
   13940                 :           4 :               return error_mark_node;
   13941                 :             :             }
   13942                 :             : 
   13943                 :       40968 :           if (maybe_ne (TYPE_VECTOR_SUBPARTS (type0),
   13944                 :       81936 :                         TYPE_VECTOR_SUBPARTS (type1)))
   13945                 :             :             {
   13946                 :           1 :               error_at (location, "comparing vectors with different "
   13947                 :             :                                   "number of elements");
   13948                 :           1 :               return error_mark_node;
   13949                 :             :             }
   13950                 :             : 
   13951                 :             :           /* It's not precisely specified how the usual arithmetic
   13952                 :             :              conversions apply to the vector types.  Here, we use
   13953                 :             :              the unsigned type if one of the operands is signed and
   13954                 :             :              the other one is unsigned.  */
   13955                 :       40967 :           if (TYPE_UNSIGNED (type0) != TYPE_UNSIGNED (type1))
   13956                 :             :             {
   13957                 :           4 :               if (!TYPE_UNSIGNED (type0))
   13958                 :           4 :                 op0 = build1 (VIEW_CONVERT_EXPR, type1, op0);
   13959                 :             :               else
   13960                 :           0 :                 op1 = build1 (VIEW_CONVERT_EXPR, type0, op1);
   13961                 :           4 :               warning_at (location, OPT_Wsign_compare, "comparison between "
   13962                 :             :                           "types %qT and %qT", type0, type1);
   13963                 :             :             }
   13964                 :             : 
   13965                 :             :           /* Always construct signed integer vector type.  */
   13966                 :      122901 :           intt = c_common_type_for_size (GET_MODE_BITSIZE
   13967                 :       81934 :                                          (SCALAR_TYPE_MODE
   13968                 :             :                                           (TREE_TYPE (type0))), 0);
   13969                 :       40967 :           if (!intt)
   13970                 :             :             {
   13971                 :           0 :               error_at (location, "could not find an integer type "
   13972                 :             :                                   "of the same size as %qT",
   13973                 :           0 :                         TREE_TYPE (type0));
   13974                 :           0 :               return error_mark_node;
   13975                 :             :             }
   13976                 :       40967 :           result_type = build_opaque_vector_type (intt,
   13977                 :       40967 :                                                   TYPE_VECTOR_SUBPARTS (type0));
   13978                 :       40967 :           converted = 1;
   13979                 :       40967 :           ret = build_vec_cmp (resultcode, result_type, op0, op1);
   13980                 :       40967 :           goto return_build_binary_op;
   13981                 :             :         }
   13982                 :     1626492 :       if (FLOAT_TYPE_P (type0) || FLOAT_TYPE_P (type1))
   13983                 :      245269 :         warning_at (location,
   13984                 :             :                     OPT_Wfloat_equal,
   13985                 :             :                     "comparing floating-point with %<==%> or %<!=%> is unsafe");
   13986                 :             :       /* Result of comparison is always int,
   13987                 :             :          but don't convert the args to int!  */
   13988                 :     1626492 :       build_type = integer_type_node;
   13989                 :     1626492 :       if ((code0 == INTEGER_TYPE || code0 == REAL_TYPE || code0 == BITINT_TYPE
   13990                 :      154042 :            || code0 == FIXED_POINT_TYPE || code0 == COMPLEX_TYPE)
   13991                 :     1507412 :           && (code1 == INTEGER_TYPE || code1 == REAL_TYPE
   13992                 :             :               || code1 == BITINT_TYPE
   13993                 :             :               || code1 == FIXED_POINT_TYPE || code1 == COMPLEX_TYPE))
   13994                 :             :         short_compare = 1;
   13995                 :      119343 :       else if (code0 == POINTER_TYPE
   13996                 :      119343 :                && (code1 == NULLPTR_TYPE
   13997                 :      119006 :                    || null_pointer_constant_p (orig_op1)))
   13998                 :             :         {
   13999                 :       49702 :           maybe_warn_for_null_address (location, op0, code);
   14000                 :       49702 :           result_type = type0;
   14001                 :             :         }
   14002                 :       69641 :       else if (code1 == POINTER_TYPE
   14003                 :       69641 :                && (code0 == NULLPTR_TYPE
   14004                 :       69547 :                    || null_pointer_constant_p (orig_op0)))
   14005                 :             :         {
   14006                 :         284 :           maybe_warn_for_null_address (location, op1, code);
   14007                 :         284 :           result_type = type1;
   14008                 :             :         }
   14009                 :       69357 :       else if (code0 == POINTER_TYPE && code1 == POINTER_TYPE)
   14010                 :             :         {
   14011                 :       69275 :           tree tt0 = TREE_TYPE (type0);
   14012                 :       69275 :           tree tt1 = TREE_TYPE (type1);
   14013                 :       69275 :           addr_space_t as0 = TYPE_ADDR_SPACE (tt0);
   14014                 :       69275 :           addr_space_t as1 = TYPE_ADDR_SPACE (tt1);
   14015                 :       69275 :           addr_space_t as_common = ADDR_SPACE_GENERIC;
   14016                 :             : 
   14017                 :             :           /* Anything compares with void *.  void * compares with anything.
   14018                 :             :              Otherwise, the targets must be compatible
   14019                 :             :              and both must be object or both incomplete.  */
   14020                 :       69275 :           if (comp_target_types (location, type0, type1))
   14021                 :       48007 :             result_type = common_pointer_type (type0, type1);
   14022                 :       21268 :           else if (!addr_space_superset (as0, as1, &as_common))
   14023                 :             :             {
   14024                 :           0 :               error_at (location, "comparison of pointers to "
   14025                 :             :                         "disjoint address spaces");
   14026                 :           0 :               return error_mark_node;
   14027                 :             :             }
   14028                 :       21268 :           else if (VOID_TYPE_P (tt0) && !TYPE_ATOMIC (tt0))
   14029                 :             :             {
   14030                 :       21086 :               if (pedantic && TREE_CODE (tt1) == FUNCTION_TYPE)
   14031                 :           4 :                 pedwarn (location, OPT_Wpedantic, "ISO C forbids "
   14032                 :             :                          "comparison of %<void *%> with function pointer");
   14033                 :             :             }
   14034                 :         182 :           else if (VOID_TYPE_P (tt1) && !TYPE_ATOMIC (tt1))
   14035                 :             :             {
   14036                 :         134 :               if (pedantic && TREE_CODE (tt0) == FUNCTION_TYPE)
   14037                 :           4 :                 pedwarn (location, OPT_Wpedantic, "ISO C forbids "
   14038                 :             :                          "comparison of %<void *%> with function pointer");
   14039                 :             :             }
   14040                 :             :           else
   14041                 :             :             /* Avoid warning about the volatile ObjC EH puts on decls.  */
   14042                 :          48 :             if (!objc_ok)
   14043                 :          48 :               pedwarn (location, OPT_Wcompare_distinct_pointer_types,
   14044                 :             :                        "comparison of distinct pointer types lacks a cast");
   14045                 :             : 
   14046                 :       48063 :           if (result_type == NULL_TREE)
   14047                 :             :             {
   14048                 :       21268 :               int qual = ENCODE_QUAL_ADDR_SPACE (as_common);
   14049                 :       21268 :               result_type = c_build_pointer_type
   14050                 :       21268 :                               (c_build_qualified_type (void_type_node, qual));
   14051                 :             :             }
   14052                 :             :         }
   14053                 :          82 :       else if (code0 == POINTER_TYPE
   14054                 :          26 :                && (code1 == INTEGER_TYPE || code1 == BITINT_TYPE))
   14055                 :             :         {
   14056                 :          26 :           result_type = type0;
   14057                 :          26 :           pedwarn (location, 0, "comparison between pointer and integer");
   14058                 :             :         }
   14059                 :          56 :       else if ((code0 == INTEGER_TYPE || code0 == BITINT_TYPE)
   14060                 :          21 :                && code1 == POINTER_TYPE)
   14061                 :             :         {
   14062                 :           8 :           result_type = type1;
   14063                 :           8 :           pedwarn (location, 0, "comparison between pointer and integer");
   14064                 :             :         }
   14065                 :             :       /* 6.5.9: One of the following shall hold:
   14066                 :             :          -- both operands have type nullptr_t;  */
   14067                 :          48 :       else if (code0 == NULLPTR_TYPE && code1 == NULLPTR_TYPE)
   14068                 :             :         {
   14069                 :          14 :           result_type = nullptr_type_node;
   14070                 :             :           /* No need to convert the operands to result_type later.  */
   14071                 :          14 :           converted = 1;
   14072                 :             :         }
   14073                 :             :     /* -- one operand has type nullptr_t and the other is a null pointer
   14074                 :             :        constant.  We will have to convert the former to the type of the
   14075                 :             :        latter, because during gimplification we can't have mismatching
   14076                 :             :        comparison operand type.  We convert from nullptr_t to the other
   14077                 :             :        type, since only nullptr_t can be converted to nullptr_t.  Also,
   14078                 :             :        even a constant 0 is a null pointer constant, so we may have to
   14079                 :             :        create a pointer type from its type.  */
   14080                 :          34 :       else if (code0 == NULLPTR_TYPE && null_pointer_constant_p (orig_op1))
   14081                 :          19 :         result_type = (INTEGRAL_TYPE_P (type1)
   14082                 :          19 :                        ? c_build_pointer_type (type1) : type1);
   14083                 :          15 :       else if (code1 == NULLPTR_TYPE && null_pointer_constant_p (orig_op0))
   14084                 :          11 :         result_type = (INTEGRAL_TYPE_P (type0)
   14085                 :          11 :                        ? c_build_pointer_type (type0) : type0);
   14086                 :     4809893 :       if ((C_BOOLEAN_TYPE_P (TREE_TYPE (orig_op0))
   14087                 :     3183376 :            || truth_value_p (TREE_CODE (orig_op0)))
   14088                 :     3245737 :           ^ (C_BOOLEAN_TYPE_P (TREE_TYPE (orig_op1))
   14089                 :     3245733 :              || truth_value_p (TREE_CODE (orig_op1))))
   14090                 :       66633 :         maybe_warn_bool_compare (location, code, orig_op0, orig_op1);
   14091                 :             :       break;
   14092                 :             : 
   14093                 :      992762 :     case LE_EXPR:
   14094                 :      992762 :     case GE_EXPR:
   14095                 :      992762 :     case LT_EXPR:
   14096                 :      992762 :     case GT_EXPR:
   14097                 :      992762 :       if (gnu_vector_type_p (type0) && gnu_vector_type_p (type1))
   14098                 :             :         {
   14099                 :       57901 :           tree intt;
   14100                 :       57901 :           if (!vector_types_compatible_elements_p (type0, type1))
   14101                 :             :             {
   14102                 :           5 :               error_at (location, "comparing vectors with different "
   14103                 :             :                                   "element types");
   14104                 :           5 :               return error_mark_node;
   14105                 :             :             }
   14106                 :             : 
   14107                 :       57896 :           if (maybe_ne (TYPE_VECTOR_SUBPARTS (type0),
   14108                 :      115792 :                         TYPE_VECTOR_SUBPARTS (type1)))
   14109                 :             :             {
   14110                 :           0 :               error_at (location, "comparing vectors with different "
   14111                 :             :                                   "number of elements");
   14112                 :           0 :               return error_mark_node;
   14113                 :             :             }
   14114                 :             : 
   14115                 :             :           /* It's not precisely specified how the usual arithmetic
   14116                 :             :              conversions apply to the vector types.  Here, we use
   14117                 :             :              the unsigned type if one of the operands is signed and
   14118                 :             :              the other one is unsigned.  */
   14119                 :       57896 :           if (TYPE_UNSIGNED (type0) != TYPE_UNSIGNED (type1))
   14120                 :             :             {
   14121                 :          15 :               if (!TYPE_UNSIGNED (type0))
   14122                 :           8 :                 op0 = build1 (VIEW_CONVERT_EXPR, type1, op0);
   14123                 :             :               else
   14124                 :           7 :                 op1 = build1 (VIEW_CONVERT_EXPR, type0, op1);
   14125                 :          15 :               warning_at (location, OPT_Wsign_compare, "comparison between "
   14126                 :             :                           "types %qT and %qT", type0, type1);
   14127                 :             :             }
   14128                 :             : 
   14129                 :             :           /* Always construct signed integer vector type.  */
   14130                 :      173688 :           intt = c_common_type_for_size (GET_MODE_BITSIZE
   14131                 :      115792 :                                          (SCALAR_TYPE_MODE
   14132                 :             :                                           (TREE_TYPE (type0))), 0);
   14133                 :       57896 :           if (!intt)
   14134                 :             :             {
   14135                 :           0 :               error_at (location, "could not find an integer type "
   14136                 :             :                                   "of the same size as %qT",
   14137                 :           0 :                         TREE_TYPE (type0));
   14138                 :           0 :               return error_mark_node;
   14139                 :             :             }
   14140                 :       57896 :           result_type = build_opaque_vector_type (intt,
   14141                 :       57896 :                                                   TYPE_VECTOR_SUBPARTS (type0));
   14142                 :       57896 :           converted = 1;
   14143                 :       57896 :           ret = build_vec_cmp (resultcode, result_type, op0, op1);
   14144                 :       57896 :           goto return_build_binary_op;
   14145                 :             :         }
   14146                 :      934861 :       build_type = integer_type_node;
   14147                 :      934861 :       if ((code0 == INTEGER_TYPE || code0 == REAL_TYPE
   14148                 :       62813 :            || code0 == BITINT_TYPE || code0 == FIXED_POINT_TYPE)
   14149                 :      872577 :           && (code1 == INTEGER_TYPE || code1 == REAL_TYPE
   14150                 :             :               || code1 == BITINT_TYPE || code1 == FIXED_POINT_TYPE))
   14151                 :             :         short_compare = 1;
   14152                 :       62316 :       else if (code0 == POINTER_TYPE && code1 == POINTER_TYPE)
   14153                 :             :         {
   14154                 :       62249 :           addr_space_t as0 = TYPE_ADDR_SPACE (TREE_TYPE (type0));
   14155                 :       62249 :           addr_space_t as1 = TYPE_ADDR_SPACE (TREE_TYPE (type1));
   14156                 :       62249 :           addr_space_t as_common;
   14157                 :             : 
   14158                 :       62249 :           if (comp_target_types (location, type0, type1))
   14159                 :             :             {
   14160                 :       62136 :               result_type = common_pointer_type (type0, type1);
   14161                 :       62136 :               if (!COMPLETE_TYPE_P (TREE_TYPE (type0))
   14162                 :       62136 :                   != !COMPLETE_TYPE_P (TREE_TYPE (type1)))
   14163                 :          32 :                 pedwarn_c99 (location, OPT_Wpedantic,
   14164                 :             :                              "comparison of complete and incomplete pointers");
   14165                 :       62104 :               else if (TREE_CODE (TREE_TYPE (type0)) == FUNCTION_TYPE)
   14166                 :           0 :                 pedwarn (location, OPT_Wpedantic, "ISO C forbids "
   14167                 :             :                          "ordered comparisons of pointers to functions");
   14168                 :       62104 :               else if (null_pointer_constant_p (orig_op0)
   14169                 :       62104 :                        || null_pointer_constant_p (orig_op1))
   14170                 :           8 :                 warning_at (location, OPT_Wextra,
   14171                 :             :                             "ordered comparison of pointer with null pointer");
   14172                 :             : 
   14173                 :             :             }
   14174                 :         113 :           else if (!addr_space_superset (as0, as1, &as_common))
   14175                 :             :             {
   14176                 :           0 :               error_at (location, "comparison of pointers to "
   14177                 :             :                         "disjoint address spaces");
   14178                 :           0 :               return error_mark_node;
   14179                 :             :             }
   14180                 :             :           else
   14181                 :             :             {
   14182                 :         113 :               int qual = ENCODE_QUAL_ADDR_SPACE (as_common);
   14183                 :         113 :               result_type = c_build_pointer_type
   14184                 :         113 :                               (c_build_qualified_type (void_type_node, qual));
   14185                 :         113 :               pedwarn (location, OPT_Wcompare_distinct_pointer_types,
   14186                 :             :                        "comparison of distinct pointer types lacks a cast");
   14187                 :             :             }
   14188                 :             :         }
   14189                 :          67 :       else if (code0 == POINTER_TYPE && null_pointer_constant_p (orig_op1))
   14190                 :             :         {
   14191                 :          17 :           result_type = type0;
   14192                 :          17 :           if (pedantic)
   14193                 :          11 :             pedwarn (location, OPT_Wpedantic,
   14194                 :             :                      "ordered comparison of pointer with integer zero");
   14195                 :           6 :           else if (extra_warnings)
   14196                 :           1 :             warning_at (location, OPT_Wextra,
   14197                 :             :                         "ordered comparison of pointer with integer zero");
   14198                 :             :         }
   14199                 :          50 :       else if (code1 == POINTER_TYPE && null_pointer_constant_p (orig_op0))
   14200                 :             :         {
   14201                 :          12 :           result_type = type1;
   14202                 :          12 :           if (pedantic)
   14203                 :           2 :             pedwarn (location, OPT_Wpedantic,
   14204                 :             :                      "ordered comparison of pointer with integer zero");
   14205                 :          10 :           else if (extra_warnings)
   14206                 :           1 :             warning_at (location, OPT_Wextra,
   14207                 :             :                         "ordered comparison of pointer with integer zero");
   14208                 :             :         }
   14209                 :          38 :       else if (code0 == POINTER_TYPE
   14210                 :          18 :                && (code1 == INTEGER_TYPE || code1 == BITINT_TYPE))
   14211                 :             :         {
   14212                 :          18 :           result_type = type0;
   14213                 :          18 :           pedwarn (location, 0, "comparison between pointer and integer");
   14214                 :             :         }
   14215                 :          20 :       else if ((code0 == INTEGER_TYPE || code0 == BITINT_TYPE)
   14216                 :          20 :                && code1 == POINTER_TYPE)
   14217                 :             :         {
   14218                 :          18 :           result_type = type1;
   14219                 :          18 :           pedwarn (location, 0, "comparison between pointer and integer");
   14220                 :             :         }
   14221                 :             : 
   14222                 :      934861 :       if ((code0 == POINTER_TYPE || code1 == POINTER_TYPE)
   14223                 :       62314 :           && current_function_decl != NULL_TREE
   14224                 :      997164 :           && sanitize_flags_p (SANITIZE_POINTER_COMPARE))
   14225                 :             :         {
   14226                 :          35 :           op0 = save_expr (op0);
   14227                 :          35 :           op1 = save_expr (op1);
   14228                 :             : 
   14229                 :          35 :           tree tt = builtin_decl_explicit (BUILT_IN_ASAN_POINTER_COMPARE);
   14230                 :          35 :           instrument_expr = build_call_expr_loc (location, tt, 2, op0, op1);
   14231                 :             :         }
   14232                 :             : 
   14233                 :     2804497 :       if ((C_BOOLEAN_TYPE_P (TREE_TYPE (orig_op0))
   14234                 :     1869636 :            || truth_value_p (TREE_CODE (orig_op0)))
   14235                 :     1869649 :           ^ (C_BOOLEAN_TYPE_P (TREE_TYPE (orig_op1))
   14236                 :     1869649 :              || truth_value_p (TREE_CODE (orig_op1))))
   14237                 :         506 :         maybe_warn_bool_compare (location, code, orig_op0, orig_op1);
   14238                 :             :       break;
   14239                 :             : 
   14240                 :          43 :     case MIN_EXPR:
   14241                 :          43 :     case MAX_EXPR:
   14242                 :             :       /* Used for OpenMP atomics.  */
   14243                 :          43 :       gcc_assert (flag_openmp);
   14244                 :             :       common = 1;
   14245                 :             :       break;
   14246                 :             : 
   14247                 :           0 :     default:
   14248                 :           0 :       gcc_unreachable ();
   14249                 :             :     }
   14250                 :             : 
   14251                 :    15057312 :   if (code0 == ERROR_MARK || code1 == ERROR_MARK)
   14252                 :           0 :     return error_mark_node;
   14253                 :             : 
   14254                 :    15057312 :   if (gnu_vector_type_p (type0)
   14255                 :     1446377 :       && gnu_vector_type_p (type1)
   14256                 :    16502899 :       && (!tree_int_cst_equal (TYPE_SIZE (type0), TYPE_SIZE (type1))
   14257                 :     1445567 :           || !vector_types_compatible_elements_p (type0, type1)))
   14258                 :             :     {
   14259                 :          26 :       gcc_rich_location richloc (location);
   14260                 :          26 :       maybe_range_label_for_tree_type_mismatch
   14261                 :          26 :         label_for_op0 (orig_op0, orig_op1),
   14262                 :          26 :         label_for_op1 (orig_op1, orig_op0);
   14263                 :          26 :       richloc.maybe_add_expr (orig_op0, &label_for_op0, highlight_colors::lhs);
   14264                 :          26 :       richloc.maybe_add_expr (orig_op1, &label_for_op1, highlight_colors::rhs);
   14265                 :          26 :       binary_op_error (&richloc, code, type0, type1);
   14266                 :          26 :       return error_mark_node;
   14267                 :          26 :     }
   14268                 :             : 
   14269                 :    15057286 :   if ((code0 == INTEGER_TYPE || code0 == REAL_TYPE || code0 == COMPLEX_TYPE
   14270                 :     1695343 :        || code0 == FIXED_POINT_TYPE || code0 == BITINT_TYPE
   14271                 :     1628130 :        || gnu_vector_type_p (type0))
   14272                 :    16570850 :       && (code1 == INTEGER_TYPE || code1 == REAL_TYPE || code1 == COMPLEX_TYPE
   14273                 :     1538490 :           || code1 == FIXED_POINT_TYPE || code1 == BITINT_TYPE
   14274                 :     1447610 :           || gnu_vector_type_p (type1)))
   14275                 :             :     {
   14276                 :    14873463 :       bool first_complex = (code0 == COMPLEX_TYPE);
   14277                 :    14873463 :       bool second_complex = (code1 == COMPLEX_TYPE);
   14278                 :    14873463 :       int none_complex = (!first_complex && !second_complex);
   14279                 :             : 
   14280                 :    14873463 :       if (shorten || common || short_compare)
   14281                 :             :         {
   14282                 :    13361285 :           result_type = c_common_type (type0, type1);
   14283                 :    13361285 :           do_warn_double_promotion (result_type, type0, type1,
   14284                 :             :                                     "implicit conversion from %qT to %qT "
   14285                 :             :                                     "to match other operand of binary "
   14286                 :             :                                     "expression",
   14287                 :             :                                     location);
   14288                 :    13361285 :           if (result_type == error_mark_node)
   14289                 :             :             return error_mark_node;
   14290                 :             :         }
   14291                 :             : 
   14292                 :    14873441 :       if (first_complex != second_complex
   14293                 :       82076 :           && (code == PLUS_EXPR
   14294                 :             :               || code == MINUS_EXPR
   14295                 :       82076 :               || code == MULT_EXPR
   14296                 :       17525 :               || (code == TRUNC_DIV_EXPR && first_complex))
   14297                 :       65965 :           && TREE_CODE (TREE_TYPE (result_type)) == REAL_TYPE
   14298                 :    14935728 :           && flag_signed_zeros)
   14299                 :             :         {
   14300                 :             :           /* An operation on mixed real/complex operands must be
   14301                 :             :              handled specially, but the language-independent code can
   14302                 :             :              more easily optimize the plain complex arithmetic if
   14303                 :             :              -fno-signed-zeros.  */
   14304                 :       61975 :           tree real_type = TREE_TYPE (result_type);
   14305                 :       61975 :           tree real, imag;
   14306                 :       61975 :           if (type0 != orig_type0 || type1 != orig_type1)
   14307                 :             :             {
   14308                 :          94 :               gcc_assert (may_need_excess_precision && common);
   14309                 :          94 :               semantic_result_type = c_common_type (orig_type0, orig_type1);
   14310                 :             :             }
   14311                 :       61975 :           if (first_complex)
   14312                 :             :             {
   14313                 :        8262 :               if (TREE_TYPE (op0) != result_type)
   14314                 :        1795 :                 op0 = convert_and_check (location, result_type, op0);
   14315                 :        8262 :               if (TREE_TYPE (op1) != real_type)
   14316                 :        4601 :                 op1 = convert_and_check (location, real_type, op1);
   14317                 :             :             }
   14318                 :             :           else
   14319                 :             :             {
   14320                 :       53713 :               if (TREE_TYPE (op0) != real_type)
   14321                 :        2698 :                 op0 = convert_and_check (location, real_type, op0);
   14322                 :       53713 :               if (TREE_TYPE (op1) != result_type)
   14323                 :        1881 :                 op1 = convert_and_check (location, result_type, op1);
   14324                 :             :             }
   14325                 :       61975 :           if (TREE_CODE (op0) == ERROR_MARK || TREE_CODE (op1) == ERROR_MARK)
   14326                 :           0 :             return error_mark_node;
   14327                 :       61975 :           if (first_complex)
   14328                 :             :             {
   14329                 :        8262 :               op0 = save_expr (op0);
   14330                 :        8262 :               real = build_unary_op (EXPR_LOCATION (orig_op0), REALPART_EXPR,
   14331                 :             :                                      op0, true);
   14332                 :        8262 :               imag = build_unary_op (EXPR_LOCATION (orig_op0), IMAGPART_EXPR,
   14333                 :             :                                      op0, true);
   14334                 :        8262 :               switch (code)
   14335                 :             :                 {
   14336                 :        3501 :                 case MULT_EXPR:
   14337                 :        3501 :                 case TRUNC_DIV_EXPR:
   14338                 :        3501 :                   op1 = save_expr (op1);
   14339                 :        3501 :                   imag = build2 (resultcode, real_type, imag, op1);
   14340                 :             :                   /* Fall through.  */
   14341                 :        8262 :                 case PLUS_EXPR:
   14342                 :        8262 :                 case MINUS_EXPR:
   14343                 :        8262 :                   real = build2 (resultcode, real_type, real, op1);
   14344                 :        8262 :                   break;
   14345                 :           0 :                 default:
   14346                 :           0 :                   gcc_unreachable();
   14347                 :             :                 }
   14348                 :             :             }
   14349                 :             :           else
   14350                 :             :             {
   14351                 :       53713 :               op1 = save_expr (op1);
   14352                 :       53713 :               real = build_unary_op (EXPR_LOCATION (orig_op1), REALPART_EXPR,
   14353                 :             :                                      op1, true);
   14354                 :       53713 :               imag = build_unary_op (EXPR_LOCATION (orig_op1), IMAGPART_EXPR,
   14355                 :             :                                      op1, true);
   14356                 :       53713 :               switch (code)
   14357                 :             :                 {
   14358                 :        2021 :                 case MULT_EXPR:
   14359                 :        2021 :                   op0 = save_expr (op0);
   14360                 :        2021 :                   imag = build2 (resultcode, real_type, op0, imag);
   14361                 :             :                   /* Fall through.  */
   14362                 :       31981 :                 case PLUS_EXPR:
   14363                 :       31981 :                   real = build2 (resultcode, real_type, op0, real);
   14364                 :       31981 :                   break;
   14365                 :       21732 :                 case MINUS_EXPR:
   14366                 :       21732 :                   real = build2 (resultcode, real_type, op0, real);
   14367                 :       21732 :                   imag = build1 (NEGATE_EXPR, real_type, imag);
   14368                 :       21732 :                   break;
   14369                 :           0 :                 default:
   14370                 :           0 :                   gcc_unreachable();
   14371                 :             :                 }
   14372                 :             :             }
   14373                 :       61975 :           ret = build2 (COMPLEX_EXPR, result_type, real, imag);
   14374                 :       61975 :           goto return_build_binary_op;
   14375                 :             :         }
   14376                 :             : 
   14377                 :             :       /* For certain operations (which identify themselves by shorten != 0)
   14378                 :             :          if both args were extended from the same smaller type,
   14379                 :             :          do the arithmetic in that type and then extend.
   14380                 :             : 
   14381                 :             :          shorten !=0 and !=1 indicates a bitwise operation.
   14382                 :             :          For them, this optimization is safe only if
   14383                 :             :          both args are zero-extended or both are sign-extended.
   14384                 :             :          Otherwise, we might change the result.
   14385                 :             :          Eg, (short)-1 | (unsigned short)-1 is (int)-1
   14386                 :             :          but calculated in (unsigned short) it would be (unsigned short)-1.  */
   14387                 :             : 
   14388                 :    14811466 :       if (shorten && none_complex)
   14389                 :             :         {
   14390                 :     1297403 :           final_type = result_type;
   14391                 :     1297403 :           result_type = shorten_binary_op (result_type, op0, op1,
   14392                 :             :                                            shorten == -1);
   14393                 :             :         }
   14394                 :             : 
   14395                 :             :       /* Shifts can be shortened if shifting right.  */
   14396                 :             : 
   14397                 :    14811466 :       if (short_shift)
   14398                 :             :         {
   14399                 :      168250 :           int unsigned_arg;
   14400                 :      168250 :           tree arg0 = get_narrower (op0, &unsigned_arg);
   14401                 :             : 
   14402                 :      168250 :           final_type = result_type;
   14403                 :             : 
   14404                 :      168250 :           if (arg0 == op0 && final_type == TREE_TYPE (op0))
   14405                 :      110445 :             unsigned_arg = TYPE_UNSIGNED (TREE_TYPE (op0));
   14406                 :             : 
   14407                 :      168250 :           if (TYPE_PRECISION (TREE_TYPE (arg0)) < TYPE_PRECISION (result_type)
   14408                 :        2607 :               && tree_int_cst_sgn (op1) > 0
   14409                 :             :               /* We can shorten only if the shift count is less than the
   14410                 :             :                  number of bits in the smaller type size.  */
   14411                 :        2607 :               && compare_tree_int (op1, TYPE_PRECISION (TREE_TYPE (arg0))) < 0
   14412                 :             :               /* We cannot drop an unsigned shift after sign-extension.  */
   14413                 :      170725 :               && (!TYPE_UNSIGNED (final_type) || unsigned_arg))
   14414                 :             :             {
   14415                 :             :               /* Do an unsigned shift if the operand was zero-extended.  */
   14416                 :        2461 :               result_type
   14417                 :        2461 :                 = c_common_signed_or_unsigned_type (unsigned_arg,
   14418                 :        2461 :                                                     TREE_TYPE (arg0));
   14419                 :             :               /* Convert value-to-be-shifted to that type.  */
   14420                 :        2461 :               if (TREE_TYPE (op0) != result_type)
   14421                 :        2461 :                 op0 = convert (result_type, op0);
   14422                 :             :               converted = 1;
   14423                 :             :             }
   14424                 :             :         }
   14425                 :             : 
   14426                 :             :       /* Comparison operations are shortened too but differently.
   14427                 :             :          They identify themselves by setting short_compare = 1.  */
   14428                 :             : 
   14429                 :    14811466 :       if (short_compare)
   14430                 :             :         {
   14431                 :             :           /* Don't write &op0, etc., because that would prevent op0
   14432                 :             :              from being kept in a register.
   14433                 :             :              Instead, make copies of the our local variables and
   14434                 :             :              pass the copies by reference, then copy them back afterward.  */
   14435                 :     2379692 :           tree xop0 = op0, xop1 = op1, xresult_type = result_type;
   14436                 :     2379692 :           enum tree_code xresultcode = resultcode;
   14437                 :     2379692 :           tree val
   14438                 :     2379692 :             = shorten_compare (location, &xop0, &xop1, &xresult_type,
   14439                 :             :                                &xresultcode);
   14440                 :             : 
   14441                 :     2379692 :           if (val != NULL_TREE)
   14442                 :             :             {
   14443                 :       15785 :               ret = val;
   14444                 :       15785 :               goto return_build_binary_op;
   14445                 :             :             }
   14446                 :             : 
   14447                 :     2363907 :           op0 = xop0, op1 = xop1;
   14448                 :     2363907 :           converted = 1;
   14449                 :     2363907 :           resultcode = xresultcode;
   14450                 :             : 
   14451                 :     2363907 :           if (c_inhibit_evaluation_warnings == 0 && !c_in_omp_for)
   14452                 :             :             {
   14453                 :     2218034 :               bool op0_maybe_const = true;
   14454                 :     2218034 :               bool op1_maybe_const = true;
   14455                 :     2218034 :               tree orig_op0_folded, orig_op1_folded;
   14456                 :             : 
   14457                 :     2218034 :               if (in_late_binary_op)
   14458                 :             :                 {
   14459                 :             :                   orig_op0_folded = orig_op0;
   14460                 :             :                   orig_op1_folded = orig_op1;
   14461                 :             :                 }
   14462                 :             :               else
   14463                 :             :                 {
   14464                 :             :                   /* Fold for the sake of possible warnings, as in
   14465                 :             :                      build_conditional_expr.  This requires the
   14466                 :             :                      "original" values to be folded, not just op0 and
   14467                 :             :                      op1.  */
   14468                 :     2212424 :                   c_inhibit_evaluation_warnings++;
   14469                 :     2212424 :                   op0 = c_fully_fold (op0, require_constant_value,
   14470                 :             :                                       &op0_maybe_const);
   14471                 :     2212424 :                   op1 = c_fully_fold (op1, require_constant_value,
   14472                 :             :                                       &op1_maybe_const);
   14473                 :     2212424 :                   c_inhibit_evaluation_warnings--;
   14474                 :     2212424 :                   orig_op0_folded = c_fully_fold (orig_op0,
   14475                 :             :                                                   require_constant_value,
   14476                 :             :                                                   NULL);
   14477                 :     2212424 :                   orig_op1_folded = c_fully_fold (orig_op1,
   14478                 :             :                                                   require_constant_value,
   14479                 :             :                                                   NULL);
   14480                 :             :                 }
   14481                 :             : 
   14482                 :     2218034 :               if (warn_sign_compare)
   14483                 :      368690 :                 warn_for_sign_compare (location, orig_op0_folded,
   14484                 :             :                                        orig_op1_folded, op0, op1,
   14485                 :             :                                        result_type, resultcode);
   14486                 :     2218034 :               if (!in_late_binary_op && !int_operands)
   14487                 :             :                 {
   14488                 :     2037812 :                   if (!op0_maybe_const || TREE_CODE (op0) != INTEGER_CST)
   14489                 :     2034303 :                     op0 = c_wrap_maybe_const (op0, !op0_maybe_const);
   14490                 :     2037812 :                   if (!op1_maybe_const || TREE_CODE (op1) != INTEGER_CST)
   14491                 :      811418 :                     op1 = c_wrap_maybe_const (op1, !op1_maybe_const);
   14492                 :             :                 }
   14493                 :             :             }
   14494                 :             :         }
   14495                 :             :     }
   14496                 :             : 
   14497                 :             :   /* At this point, RESULT_TYPE must be nonzero to avoid an error message.
   14498                 :             :      If CONVERTED is zero, both args will be converted to type RESULT_TYPE.
   14499                 :             :      Then the expression will be built.
   14500                 :             :      It will be given type FINAL_TYPE if that is nonzero;
   14501                 :             :      otherwise, it will be given type RESULT_TYPE.  */
   14502                 :             : 
   14503                 :    14979504 :   if (!result_type)
   14504                 :             :     {
   14505                 :             :       /* Favor showing any expression locations that are available. */
   14506                 :         514 :       op_location_t oploc (location, UNKNOWN_LOCATION);
   14507                 :         514 :       binary_op_rich_location richloc (oploc, orig_op0, orig_op1, true);
   14508                 :         514 :       binary_op_error (&richloc, code, TREE_TYPE (op0), TREE_TYPE (op1));
   14509                 :         514 :       return error_mark_node;
   14510                 :         514 :     }
   14511                 :             : 
   14512                 :    14978990 :   if (build_type == NULL_TREE)
   14513                 :             :     {
   14514                 :    12433430 :       build_type = result_type;
   14515                 :    12433430 :       if ((type0 != orig_type0 || type1 != orig_type1)
   14516                 :         797 :           && !boolean_op)
   14517                 :             :         {
   14518                 :         797 :           gcc_assert (may_need_excess_precision && common);
   14519                 :         797 :           semantic_result_type = c_common_type (orig_type0, orig_type1);
   14520                 :             :         }
   14521                 :             :     }
   14522                 :             : 
   14523                 :    14978990 :   if (!converted)
   14524                 :             :     {
   14525                 :    11100085 :       op0 = ep_convert_and_check (location, result_type, op0,
   14526                 :             :                                   semantic_result_type);
   14527                 :    11100085 :       op1 = ep_convert_and_check (location, result_type, op1,
   14528                 :             :                                   semantic_result_type);
   14529                 :             : 
   14530                 :             :       /* This can happen if one operand has a vector type, and the other
   14531                 :             :          has a different type.  */
   14532                 :    11100085 :       if (TREE_CODE (op0) == ERROR_MARK || TREE_CODE (op1) == ERROR_MARK)
   14533                 :           3 :         return error_mark_node;
   14534                 :             :     }
   14535                 :             : 
   14536                 :    14978987 :   if (sanitize_flags_p ((SANITIZE_SHIFT
   14537                 :             :                          | SANITIZE_DIVIDE
   14538                 :             :                          | SANITIZE_FLOAT_DIVIDE
   14539                 :             :                          | SANITIZE_SI_OVERFLOW))
   14540                 :       23398 :       && current_function_decl != NULL_TREE
   14541                 :       19939 :       && (doing_div_or_mod || doing_shift)
   14542                 :    14981941 :       && !require_constant_value)
   14543                 :             :     {
   14544                 :             :       /* OP0 and/or OP1 might have side-effects.  */
   14545                 :        2898 :       op0 = save_expr (op0);
   14546                 :        2898 :       op1 = save_expr (op1);
   14547                 :        2898 :       op0 = c_fully_fold (op0, false, NULL);
   14548                 :        2898 :       op1 = c_fully_fold (op1, false, NULL);
   14549                 :        2898 :       if (doing_div_or_mod && (sanitize_flags_p ((SANITIZE_DIVIDE
   14550                 :             :                                                   | SANITIZE_FLOAT_DIVIDE
   14551                 :             :                                                   | SANITIZE_SI_OVERFLOW))))
   14552                 :         937 :         instrument_expr = ubsan_instrument_division (location, op0, op1);
   14553                 :        1961 :       else if (doing_shift && sanitize_flags_p (SANITIZE_SHIFT))
   14554                 :        1781 :         instrument_expr = ubsan_instrument_shift (location, code, op0, op1);
   14555                 :             :     }
   14556                 :             : 
   14557                 :             :   /* Treat expressions in initializers specially as they can't trap.  */
   14558                 :    14978987 :   if (int_const_or_overflow)
   14559                 :     7634310 :     ret = (require_constant_value
   14560                 :     7634310 :            ? fold_build2_initializer_loc (location, resultcode, build_type,
   14561                 :             :                                           op0, op1)
   14562                 :     7588189 :            : fold_build2_loc (location, resultcode, build_type, op0, op1));
   14563                 :             :   else
   14564                 :     7344677 :     ret = build2 (resultcode, build_type, op0, op1);
   14565                 :    14978987 :   if (final_type != NULL_TREE)
   14566                 :     1465653 :     ret = convert (final_type, ret);
   14567                 :             : 
   14568                 :    13513334 :  return_build_binary_op:
   14569                 :    16399363 :   gcc_assert (ret != error_mark_node);
   14570                 :    16399363 :   if (TREE_CODE (ret) == INTEGER_CST && !TREE_OVERFLOW (ret) && !int_const)
   14571                 :        1720 :     ret = (int_operands
   14572                 :        1720 :            ? note_integer_operands (ret)
   14573                 :         422 :            : build1 (NOP_EXPR, TREE_TYPE (ret), ret));
   14574                 :    16397643 :   else if (TREE_CODE (ret) != INTEGER_CST && int_operands
   14575                 :       60324 :            && !in_late_binary_op)
   14576                 :       60324 :     ret = note_integer_operands (ret);
   14577                 :    16399363 :   protected_set_expr_location (ret, location);
   14578                 :             : 
   14579                 :    16399363 :   if (instrument_expr != NULL)
   14580                 :        1413 :     ret = fold_build2 (COMPOUND_EXPR, TREE_TYPE (ret),
   14581                 :             :                        instrument_expr, ret);
   14582                 :             : 
   14583                 :    16399363 :   if (semantic_result_type)
   14584                 :         891 :     ret = build1_loc (location, EXCESS_PRECISION_EXPR,
   14585                 :             :                       semantic_result_type, ret);
   14586                 :             : 
   14587                 :             :   return ret;
   14588                 :             : }
   14589                 :             : 
   14590                 :             : 
   14591                 :             : /* Convert EXPR to be a truth-value (type TYPE), validating its type for this
   14592                 :             :    purpose.  LOCATION is the source location for the expression.  */
   14593                 :             : 
   14594                 :             : tree
   14595                 :     4030493 : c_objc_common_truthvalue_conversion (location_t location, tree expr, tree type)
   14596                 :             : {
   14597                 :     4030493 :   bool int_const, int_operands;
   14598                 :             : 
   14599                 :     4030493 :   switch (TREE_CODE (TREE_TYPE (expr)))
   14600                 :             :     {
   14601                 :          72 :     case ARRAY_TYPE:
   14602                 :          72 :       error_at (location, "used array that cannot be converted to pointer where scalar is required");
   14603                 :          72 :       return error_mark_node;
   14604                 :             : 
   14605                 :          84 :     case RECORD_TYPE:
   14606                 :          84 :       error_at (location, "used struct type value where scalar is required");
   14607                 :          84 :       return error_mark_node;
   14608                 :             : 
   14609                 :          83 :     case UNION_TYPE:
   14610                 :          83 :       error_at (location, "used union type value where scalar is required");
   14611                 :          83 :       return error_mark_node;
   14612                 :             : 
   14613                 :          22 :     case VOID_TYPE:
   14614                 :          22 :       error_at (location, "void value not ignored as it ought to be");
   14615                 :          22 :       return error_mark_node;
   14616                 :             : 
   14617                 :       29448 :     case POINTER_TYPE:
   14618                 :       29448 :       if (reject_gcc_builtin (expr))
   14619                 :           3 :         return error_mark_node;
   14620                 :             :       break;
   14621                 :             : 
   14622                 :           0 :     case FUNCTION_TYPE:
   14623                 :           0 :       gcc_unreachable ();
   14624                 :             : 
   14625                 :           8 :     case VECTOR_TYPE:
   14626                 :           8 :       error_at (location, "used vector type where scalar is required");
   14627                 :           8 :       return error_mark_node;
   14628                 :             : 
   14629                 :             :     default:
   14630                 :             :       break;
   14631                 :             :     }
   14632                 :             : 
   14633                 :             :   /* Conversion of a floating constant to boolean goes through here
   14634                 :             :      and yields an integer constant expression.  Otherwise, the result
   14635                 :             :      is only an integer constant expression if the argument is.  */
   14636                 :      890398 :   int_const = ((TREE_CODE (expr) == INTEGER_CST && !TREE_OVERFLOW (expr))
   14637                 :     4030297 :                || ((TREE_CODE (expr) == REAL_CST
   14638                 :     3139525 :                     || TREE_CODE (expr) == COMPLEX_CST)
   14639                 :         374 :                    && (TREE_CODE (type) == BOOLEAN_TYPE
   14640                 :          15 :                        || (TREE_CODE (type) == ENUMERAL_TYPE
   14641                 :           5 :                            && ENUM_UNDERLYING_TYPE (type) != NULL_TREE
   14642                 :           5 :                            && (TREE_CODE (ENUM_UNDERLYING_TYPE (type))
   14643                 :             :                                == BOOLEAN_TYPE)))));
   14644                 :     4030221 :   int_operands = EXPR_INT_CONST_OPERANDS (expr);
   14645                 :      890558 :   if (int_operands && TREE_CODE (expr) != INTEGER_CST)
   14646                 :             :     {
   14647                 :         319 :       expr = remove_c_maybe_const_expr (expr);
   14648                 :         319 :       expr = build2 (NE_EXPR, type, expr,
   14649                 :         319 :                      convert (TREE_TYPE (expr), integer_zero_node));
   14650                 :         319 :       expr = note_integer_operands (expr);
   14651                 :             :     }
   14652                 :             :   else
   14653                 :             :     {
   14654                 :             :       /* ??? Should we also give an error for vectors rather than leaving
   14655                 :             :          those to give errors later?  */
   14656                 :     4029902 :       expr = c_common_truthvalue_conversion (location, expr);
   14657                 :     4029902 :       expr = fold_convert_loc (location, type, expr);
   14658                 :             :     }
   14659                 :             : 
   14660                 :     4030221 :   if (TREE_CODE (expr) == INTEGER_CST && int_operands && !int_const)
   14661                 :             :     {
   14662                 :          76 :       if (TREE_OVERFLOW (expr))
   14663                 :             :         return expr;
   14664                 :             :       else
   14665                 :          76 :         return note_integer_operands (expr);
   14666                 :             :     }
   14667                 :     4030145 :   if (TREE_CODE (expr) == INTEGER_CST && !int_const)
   14668                 :         751 :     return build1 (NOP_EXPR, TREE_TYPE (expr), expr);
   14669                 :             :   return expr;
   14670                 :             : }
   14671                 :             : 
   14672                 :             : 
   14673                 :             : /* Convert EXPR to a contained DECL, updating *TC, *TI and *SE as
   14674                 :             :    required.  */
   14675                 :             : 
   14676                 :             : tree
   14677                 :   113755035 : c_expr_to_decl (tree expr, bool *tc ATTRIBUTE_UNUSED, bool *se)
   14678                 :             : {
   14679                 :   113755035 :   if (TREE_CODE (expr) == COMPOUND_LITERAL_EXPR)
   14680                 :             :     {
   14681                 :         655 :       tree decl = COMPOUND_LITERAL_EXPR_DECL (expr);
   14682                 :             :       /* Executing a compound literal inside a function reinitializes
   14683                 :             :          it.  */
   14684                 :         655 :       if (!TREE_STATIC (decl))
   14685                 :         399 :         *se = true;
   14686                 :         655 :       return decl;
   14687                 :             :     }
   14688                 :             :   else
   14689                 :             :     return expr;
   14690                 :             : }
   14691                 :             : 
   14692                 :             : /* Generate OMP construct CODE, with BODY and CLAUSES as its compound
   14693                 :             :    statement.  LOC is the location of the construct.  */
   14694                 :             : 
   14695                 :             : tree
   14696                 :        1982 : c_finish_omp_construct (location_t loc, enum tree_code code, tree body,
   14697                 :             :                         tree clauses)
   14698                 :             : {
   14699                 :        1982 :   body = c_end_compound_stmt (loc, body, true);
   14700                 :             : 
   14701                 :        1982 :   tree stmt = make_node (code);
   14702                 :        1982 :   TREE_TYPE (stmt) = void_type_node;
   14703                 :        1982 :   OMP_BODY (stmt) = body;
   14704                 :        1982 :   OMP_CLAUSES (stmt) = clauses;
   14705                 :        1982 :   SET_EXPR_LOCATION (stmt, loc);
   14706                 :             : 
   14707                 :        1982 :   return add_stmt (stmt);
   14708                 :             : }
   14709                 :             : 
   14710                 :             : /* Generate OACC_DATA, with CLAUSES and BLOCK as its compound
   14711                 :             :    statement.  LOC is the location of the OACC_DATA.  */
   14712                 :             : 
   14713                 :             : tree
   14714                 :         465 : c_finish_oacc_data (location_t loc, tree clauses, tree block)
   14715                 :             : {
   14716                 :         465 :   tree stmt;
   14717                 :             : 
   14718                 :         465 :   block = c_end_compound_stmt (loc, block, true);
   14719                 :             : 
   14720                 :         465 :   stmt = make_node (OACC_DATA);
   14721                 :         465 :   TREE_TYPE (stmt) = void_type_node;
   14722                 :         465 :   OACC_DATA_CLAUSES (stmt) = clauses;
   14723                 :         465 :   OACC_DATA_BODY (stmt) = block;
   14724                 :         465 :   SET_EXPR_LOCATION (stmt, loc);
   14725                 :             : 
   14726                 :         465 :   return add_stmt (stmt);
   14727                 :             : }
   14728                 :             : 
   14729                 :             : /* Generate OACC_HOST_DATA, with CLAUSES and BLOCK as its compound
   14730                 :             :    statement.  LOC is the location of the OACC_HOST_DATA.  */
   14731                 :             : 
   14732                 :             : tree
   14733                 :          21 : c_finish_oacc_host_data (location_t loc, tree clauses, tree block)
   14734                 :             : {
   14735                 :          21 :   tree stmt;
   14736                 :             : 
   14737                 :          21 :   block = c_end_compound_stmt (loc, block, true);
   14738                 :             : 
   14739                 :          21 :   stmt = make_node (OACC_HOST_DATA);
   14740                 :          21 :   TREE_TYPE (stmt) = void_type_node;
   14741                 :          21 :   OACC_HOST_DATA_CLAUSES (stmt) = clauses;
   14742                 :          21 :   OACC_HOST_DATA_BODY (stmt) = block;
   14743                 :          21 :   SET_EXPR_LOCATION (stmt, loc);
   14744                 :             : 
   14745                 :          21 :   return add_stmt (stmt);
   14746                 :             : }
   14747                 :             : 
   14748                 :             : /* Like c_begin_compound_stmt, except force the retention of the BLOCK.  */
   14749                 :             : 
   14750                 :             : tree
   14751                 :       11691 : c_begin_omp_parallel (void)
   14752                 :             : {
   14753                 :       11691 :   tree block;
   14754                 :             : 
   14755                 :       11691 :   keep_next_level ();
   14756                 :       11691 :   block = c_begin_compound_stmt (true);
   14757                 :             : 
   14758                 :       11691 :   return block;
   14759                 :             : }
   14760                 :             : 
   14761                 :             : /* Generate OMP_PARALLEL, with CLAUSES and BLOCK as its compound
   14762                 :             :    statement.  LOC is the location of the OMP_PARALLEL.  */
   14763                 :             : 
   14764                 :             : tree
   14765                 :        5591 : c_finish_omp_parallel (location_t loc, tree clauses, tree block)
   14766                 :             : {
   14767                 :        5591 :   tree stmt;
   14768                 :             : 
   14769                 :        5591 :   block = c_end_compound_stmt (loc, block, true);
   14770                 :             : 
   14771                 :        5591 :   stmt = make_node (OMP_PARALLEL);
   14772                 :        5591 :   TREE_TYPE (stmt) = void_type_node;
   14773                 :        5591 :   OMP_PARALLEL_CLAUSES (stmt) = clauses;
   14774                 :        5591 :   OMP_PARALLEL_BODY (stmt) = block;
   14775                 :        5591 :   SET_EXPR_LOCATION (stmt, loc);
   14776                 :             : 
   14777                 :        5591 :   return add_stmt (stmt);
   14778                 :             : }
   14779                 :             : 
   14780                 :             : /* Like c_begin_compound_stmt, except force the retention of the BLOCK.  */
   14781                 :             : 
   14782                 :             : tree
   14783                 :         893 : c_begin_omp_task (void)
   14784                 :             : {
   14785                 :         893 :   tree block;
   14786                 :             : 
   14787                 :         893 :   keep_next_level ();
   14788                 :         893 :   block = c_begin_compound_stmt (true);
   14789                 :             : 
   14790                 :         893 :   return block;
   14791                 :             : }
   14792                 :             : 
   14793                 :             : /* Generate OMP_TASK, with CLAUSES and BLOCK as its compound
   14794                 :             :    statement.  LOC is the location of the #pragma.  */
   14795                 :             : 
   14796                 :             : tree
   14797                 :         893 : c_finish_omp_task (location_t loc, tree clauses, tree block)
   14798                 :             : {
   14799                 :         893 :   tree stmt;
   14800                 :             : 
   14801                 :         893 :   block = c_end_compound_stmt (loc, block, true);
   14802                 :             : 
   14803                 :         893 :   stmt = make_node (OMP_TASK);
   14804                 :         893 :   TREE_TYPE (stmt) = void_type_node;
   14805                 :         893 :   OMP_TASK_CLAUSES (stmt) = clauses;
   14806                 :         893 :   OMP_TASK_BODY (stmt) = block;
   14807                 :         893 :   SET_EXPR_LOCATION (stmt, loc);
   14808                 :             : 
   14809                 :         893 :   return add_stmt (stmt);
   14810                 :             : }
   14811                 :             : 
   14812                 :             : /* Generate GOMP_cancel call for #pragma omp cancel.  */
   14813                 :             : 
   14814                 :             : void
   14815                 :         213 : c_finish_omp_cancel (location_t loc, tree clauses)
   14816                 :             : {
   14817                 :         213 :   tree fn = builtin_decl_explicit (BUILT_IN_GOMP_CANCEL);
   14818                 :         213 :   int mask = 0;
   14819                 :         213 :   if (omp_find_clause (clauses, OMP_CLAUSE_PARALLEL))
   14820                 :             :     mask = 1;
   14821                 :         150 :   else if (omp_find_clause (clauses, OMP_CLAUSE_FOR))
   14822                 :             :     mask = 2;
   14823                 :         101 :   else if (omp_find_clause (clauses, OMP_CLAUSE_SECTIONS))
   14824                 :             :     mask = 4;
   14825                 :          58 :   else if (omp_find_clause (clauses, OMP_CLAUSE_TASKGROUP))
   14826                 :             :     mask = 8;
   14827                 :             :   else
   14828                 :             :     {
   14829                 :           0 :       error_at (loc, "%<#pragma omp cancel%> must specify one of "
   14830                 :             :                      "%<parallel%>, %<for%>, %<sections%> or %<taskgroup%> "
   14831                 :             :                      "clauses");
   14832                 :           0 :       return;
   14833                 :             :     }
   14834                 :         213 :   tree ifc = omp_find_clause (clauses, OMP_CLAUSE_IF);
   14835                 :         213 :   if (ifc != NULL_TREE)
   14836                 :             :     {
   14837                 :          31 :       if (OMP_CLAUSE_IF_MODIFIER (ifc) != ERROR_MARK
   14838                 :          31 :           && OMP_CLAUSE_IF_MODIFIER (ifc) != VOID_CST)
   14839                 :           2 :         error_at (OMP_CLAUSE_LOCATION (ifc),
   14840                 :             :                   "expected %<cancel%> %<if%> clause modifier");
   14841                 :             :       else
   14842                 :             :         {
   14843                 :          29 :           tree ifc2 = omp_find_clause (OMP_CLAUSE_CHAIN (ifc), OMP_CLAUSE_IF);
   14844                 :          29 :           if (ifc2 != NULL_TREE)
   14845                 :             :             {
   14846                 :           1 :               gcc_assert (OMP_CLAUSE_IF_MODIFIER (ifc) == VOID_CST
   14847                 :             :                           && OMP_CLAUSE_IF_MODIFIER (ifc2) != ERROR_MARK
   14848                 :             :                           && OMP_CLAUSE_IF_MODIFIER (ifc2) != VOID_CST);
   14849                 :           1 :               error_at (OMP_CLAUSE_LOCATION (ifc2),
   14850                 :             :                         "expected %<cancel%> %<if%> clause modifier");
   14851                 :             :             }
   14852                 :             :         }
   14853                 :             : 
   14854                 :          31 :       tree type = TREE_TYPE (OMP_CLAUSE_IF_EXPR (ifc));
   14855                 :          62 :       ifc = fold_build2_loc (OMP_CLAUSE_LOCATION (ifc), NE_EXPR,
   14856                 :          31 :                              boolean_type_node, OMP_CLAUSE_IF_EXPR (ifc),
   14857                 :             :                              build_zero_cst (type));
   14858                 :             :     }
   14859                 :             :   else
   14860                 :         182 :     ifc = boolean_true_node;
   14861                 :         213 :   tree stmt = build_call_expr_loc (loc, fn, 2,
   14862                 :         213 :                                    build_int_cst (integer_type_node, mask),
   14863                 :             :                                    ifc);
   14864                 :         213 :   add_stmt (stmt);
   14865                 :             : }
   14866                 :             : 
   14867                 :             : /* Generate GOMP_cancellation_point call for
   14868                 :             :    #pragma omp cancellation point.  */
   14869                 :             : 
   14870                 :             : void
   14871                 :         167 : c_finish_omp_cancellation_point (location_t loc, tree clauses)
   14872                 :             : {
   14873                 :         167 :   tree fn = builtin_decl_explicit (BUILT_IN_GOMP_CANCELLATION_POINT);
   14874                 :         167 :   int mask = 0;
   14875                 :         167 :   if (omp_find_clause (clauses, OMP_CLAUSE_PARALLEL))
   14876                 :             :     mask = 1;
   14877                 :         123 :   else if (omp_find_clause (clauses, OMP_CLAUSE_FOR))
   14878                 :             :     mask = 2;
   14879                 :          88 :   else if (omp_find_clause (clauses, OMP_CLAUSE_SECTIONS))
   14880                 :             :     mask = 4;
   14881                 :          53 :   else if (omp_find_clause (clauses, OMP_CLAUSE_TASKGROUP))
   14882                 :             :     mask = 8;
   14883                 :             :   else
   14884                 :             :     {
   14885                 :           1 :       error_at (loc, "%<#pragma omp cancellation point%> must specify one of "
   14886                 :             :                      "%<parallel%>, %<for%>, %<sections%> or %<taskgroup%> "
   14887                 :             :                      "clauses");
   14888                 :           1 :       return;
   14889                 :             :     }
   14890                 :         166 :   tree stmt = build_call_expr_loc (loc, fn, 1,
   14891                 :         166 :                                    build_int_cst (integer_type_node, mask));
   14892                 :         166 :   add_stmt (stmt);
   14893                 :             : }
   14894                 :             : 
   14895                 :             : /* Helper function for handle_omp_array_sections.  Called recursively
   14896                 :             :    to handle multiple array-section-subscripts.  C is the clause,
   14897                 :             :    T current expression (initially OMP_CLAUSE_DECL), which is either
   14898                 :             :    a TREE_LIST for array-section-subscript (TREE_PURPOSE is low-bound
   14899                 :             :    expression if specified, TREE_VALUE length expression if specified,
   14900                 :             :    TREE_CHAIN is what it has been specified after, or some decl.
   14901                 :             :    TYPES vector is populated with array section types, MAYBE_ZERO_LEN
   14902                 :             :    set to true if any of the array-section-subscript could have length
   14903                 :             :    of zero (explicit or implicit), FIRST_NON_ONE is the index of the
   14904                 :             :    first array-section-subscript which is known not to have length
   14905                 :             :    of one.  Given say:
   14906                 :             :    map(a[:b][2:1][:c][:2][:d][e:f][2:5])
   14907                 :             :    FIRST_NON_ONE will be 3, array-section-subscript [:b], [2:1] and [:c]
   14908                 :             :    all are or may have length of 1, array-section-subscript [:2] is the
   14909                 :             :    first one known not to have length 1.  For array-section-subscript
   14910                 :             :    <= FIRST_NON_ONE we diagnose non-contiguous arrays if low bound isn't
   14911                 :             :    0 or length isn't the array domain max + 1, for > FIRST_NON_ONE we
   14912                 :             :    can if MAYBE_ZERO_LEN is false.  MAYBE_ZERO_LEN will be true in the above
   14913                 :             :    case though, as some lengths could be zero.  */
   14914                 :             : 
   14915                 :             : static tree
   14916                 :        6084 : handle_omp_array_sections_1 (tree c, tree t, vec<tree> &types,
   14917                 :             :                              bool &maybe_zero_len, unsigned int &first_non_one,
   14918                 :             :                              enum c_omp_region_type ort)
   14919                 :             : {
   14920                 :        6084 :   tree ret, low_bound, length, type;
   14921                 :        6084 :   bool openacc = (ort & C_ORT_ACC) != 0;
   14922                 :        6084 :   if (TREE_CODE (t) != OMP_ARRAY_SECTION)
   14923                 :             :     {
   14924                 :        2837 :       if (error_operand_p (t))
   14925                 :           2 :         return error_mark_node;
   14926                 :        2835 :       c_omp_address_inspector ai (OMP_CLAUSE_LOCATION (c), t);
   14927                 :        2835 :       ret = t;
   14928                 :        2835 :       if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_AFFINITY
   14929                 :        2736 :           && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_DEPEND
   14930                 :        5263 :           && TYPE_ATOMIC (strip_array_types (TREE_TYPE (t))))
   14931                 :             :         {
   14932                 :           6 :           error_at (OMP_CLAUSE_LOCATION (c), "%<_Atomic%> %qE in %qs clause",
   14933                 :           6 :                     t, omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   14934                 :           6 :           return error_mark_node;
   14935                 :             :         }
   14936                 :        2829 :       if (!ai.check_clause (c))
   14937                 :           0 :         return error_mark_node;
   14938                 :        2829 :       else if (ai.component_access_p ()
   14939                 :        3075 :                && (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP
   14940                 :          15 :                    || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_TO
   14941                 :          11 :                    || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_FROM))
   14942                 :         246 :         t = ai.get_root_term (true);
   14943                 :             :       else
   14944                 :        2583 :         t = ai.unconverted_ref_origin ();
   14945                 :        2829 :       if (t == error_mark_node)
   14946                 :             :         return error_mark_node;
   14947                 :        2829 :       if (!VAR_P (t)
   14948                 :         700 :           && (ort == C_ORT_ACC || !EXPR_P (t))
   14949                 :         699 :           && TREE_CODE (t) != PARM_DECL)
   14950                 :             :         {
   14951                 :           5 :           if (DECL_P (t))
   14952                 :           5 :             error_at (OMP_CLAUSE_LOCATION (c),
   14953                 :             :                       "%qD is not a variable in %qs clause", t,
   14954                 :           5 :                       omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   14955                 :             :           else
   14956                 :           0 :             error_at (OMP_CLAUSE_LOCATION (c),
   14957                 :             :                       "%qE is not a variable in %qs clause", t,
   14958                 :           0 :                       omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   14959                 :           5 :           return error_mark_node;
   14960                 :             :         }
   14961                 :        2824 :       else if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_AFFINITY
   14962                 :        2726 :                && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_DEPEND
   14963                 :        5243 :                && TYPE_ATOMIC (TREE_TYPE (t)))
   14964                 :             :         {
   14965                 :           0 :           error_at (OMP_CLAUSE_LOCATION (c), "%<_Atomic%> %qD in %qs clause",
   14966                 :           0 :                     t, omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   14967                 :           0 :           return error_mark_node;
   14968                 :             :         }
   14969                 :        2824 :       else if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_AFFINITY
   14970                 :        2726 :                && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_DEPEND
   14971                 :        2419 :                && VAR_P (t)
   14972                 :        4736 :                && DECL_THREAD_LOCAL_P (t))
   14973                 :             :         {
   14974                 :           3 :           error_at (OMP_CLAUSE_LOCATION (c),
   14975                 :             :                     "%qD is threadprivate variable in %qs clause", t,
   14976                 :           3 :                     omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   14977                 :           3 :           return error_mark_node;
   14978                 :             :         }
   14979                 :        2821 :       if ((OMP_CLAUSE_CODE (c) == OMP_CLAUSE_AFFINITY
   14980                 :        2723 :            || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND)
   14981                 :         405 :           && TYPE_ATOMIC (TREE_TYPE (t))
   14982                 :        2823 :           && POINTER_TYPE_P (TREE_TYPE (t)))
   14983                 :             :         {
   14984                 :             :           /* If the array section is pointer based and the pointer
   14985                 :             :              itself is _Atomic qualified, we need to atomically load
   14986                 :             :              the pointer.  */
   14987                 :           2 :           c_expr expr;
   14988                 :           2 :           memset (&expr, 0, sizeof (expr));
   14989                 :           2 :           expr.value = ret;
   14990                 :           2 :           expr = convert_lvalue_to_rvalue (OMP_CLAUSE_LOCATION (c),
   14991                 :             :                                            expr, false, false);
   14992                 :           2 :           ret = expr.value;
   14993                 :             :         }
   14994                 :        2821 :       return ret;
   14995                 :        2835 :     }
   14996                 :             : 
   14997                 :        3247 :   ret = handle_omp_array_sections_1 (c, TREE_OPERAND (t, 0), types,
   14998                 :             :                                      maybe_zero_len, first_non_one, ort);
   14999                 :        3247 :   if (ret == error_mark_node || ret == NULL_TREE)
   15000                 :             :     return ret;
   15001                 :             : 
   15002                 :        3182 :   type = TREE_TYPE (ret);
   15003                 :        3182 :   low_bound = TREE_OPERAND (t, 1);
   15004                 :        3182 :   length = TREE_OPERAND (t, 2);
   15005                 :             : 
   15006                 :        3182 :   if (low_bound == error_mark_node || length == error_mark_node)
   15007                 :             :     return error_mark_node;
   15008                 :             : 
   15009                 :        3182 :   if (low_bound && !INTEGRAL_TYPE_P (TREE_TYPE (low_bound)))
   15010                 :             :     {
   15011                 :          13 :       error_at (OMP_CLAUSE_LOCATION (c),
   15012                 :             :                 "low bound %qE of array section does not have integral type",
   15013                 :             :                 low_bound);
   15014                 :          13 :       return error_mark_node;
   15015                 :             :     }
   15016                 :        3169 :   if (length && !INTEGRAL_TYPE_P (TREE_TYPE (length)))
   15017                 :             :     {
   15018                 :          12 :       error_at (OMP_CLAUSE_LOCATION (c),
   15019                 :             :                 "length %qE of array section does not have integral type",
   15020                 :             :                 length);
   15021                 :          12 :       return error_mark_node;
   15022                 :             :     }
   15023                 :        3157 :   if (low_bound
   15024                 :        2644 :       && TREE_CODE (low_bound) == INTEGER_CST
   15025                 :        5527 :       && TYPE_PRECISION (TREE_TYPE (low_bound))
   15026                 :        2370 :          > TYPE_PRECISION (sizetype))
   15027                 :           0 :     low_bound = fold_convert (sizetype, low_bound);
   15028                 :        3157 :   if (length
   15029                 :        2969 :       && TREE_CODE (length) == INTEGER_CST
   15030                 :        5238 :       && TYPE_PRECISION (TREE_TYPE (length))
   15031                 :        2081 :          > TYPE_PRECISION (sizetype))
   15032                 :           0 :     length = fold_convert (sizetype, length);
   15033                 :        3157 :   if (low_bound == NULL_TREE)
   15034                 :         513 :     low_bound = integer_zero_node;
   15035                 :        3157 :   if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP
   15036                 :        3157 :       && (OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_ATTACH
   15037                 :        1795 :           || OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_DETACH))
   15038                 :             :     {
   15039                 :          10 :       if (length != integer_one_node)
   15040                 :             :         {
   15041                 :           6 :           error_at (OMP_CLAUSE_LOCATION (c),
   15042                 :             :                     "expected single pointer in %qs clause",
   15043                 :             :                     user_omp_clause_code_name (c, openacc));
   15044                 :           6 :           return error_mark_node;
   15045                 :             :         }
   15046                 :             :     }
   15047                 :        3151 :   if (length != NULL_TREE)
   15048                 :             :     {
   15049                 :        2967 :       if (!integer_nonzerop (length))
   15050                 :             :         {
   15051                 :         915 :           if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_AFFINITY
   15052                 :             :               || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND
   15053                 :             :               || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION
   15054                 :             :               || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_IN_REDUCTION
   15055                 :             :               || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_TASK_REDUCTION)
   15056                 :             :             {
   15057                 :         180 :               if (integer_zerop (length))
   15058                 :             :                 {
   15059                 :          12 :                   error_at (OMP_CLAUSE_LOCATION (c),
   15060                 :             :                             "zero length array section in %qs clause",
   15061                 :          12 :                             omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   15062                 :          12 :                   return error_mark_node;
   15063                 :             :                 }
   15064                 :             :             }
   15065                 :             :           else
   15066                 :         735 :             maybe_zero_len = true;
   15067                 :             :         }
   15068                 :        2955 :       if (first_non_one == types.length ()
   15069                 :        2955 :           && (TREE_CODE (length) != INTEGER_CST || integer_onep (length)))
   15070                 :        1493 :         first_non_one++;
   15071                 :             :     }
   15072                 :        3139 :   if (TREE_CODE (type) == ARRAY_TYPE)
   15073                 :             :     {
   15074                 :        1474 :       if (length == NULL_TREE
   15075                 :        1474 :           && (TYPE_DOMAIN (type) == NULL_TREE
   15076                 :         168 :               || TYPE_MAX_VALUE (TYPE_DOMAIN (type)) == NULL_TREE))
   15077                 :             :         {
   15078                 :           8 :           error_at (OMP_CLAUSE_LOCATION (c),
   15079                 :             :                     "for unknown bound array type length expression must "
   15080                 :             :                     "be specified");
   15081                 :           8 :           return error_mark_node;
   15082                 :             :         }
   15083                 :        1466 :       if (TREE_CODE (low_bound) == INTEGER_CST
   15084                 :        1466 :           && tree_int_cst_sgn (low_bound) == -1)
   15085                 :             :         {
   15086                 :          35 :           error_at (OMP_CLAUSE_LOCATION (c),
   15087                 :             :                     "negative low bound in array section in %qs clause",
   15088                 :          35 :                     omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   15089                 :          35 :           return error_mark_node;
   15090                 :             :         }
   15091                 :        1431 :       if (length != NULL_TREE
   15092                 :        1275 :           && TREE_CODE (length) == INTEGER_CST
   15093                 :        2266 :           && tree_int_cst_sgn (length) == -1)
   15094                 :             :         {
   15095                 :          35 :           error_at (OMP_CLAUSE_LOCATION (c),
   15096                 :             :                     "negative length in array section in %qs clause",
   15097                 :          35 :                     omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   15098                 :          35 :           return error_mark_node;
   15099                 :             :         }
   15100                 :        1396 :       if (TYPE_DOMAIN (type)
   15101                 :        1385 :           && TYPE_MAX_VALUE (TYPE_DOMAIN (type))
   15102                 :        2781 :           && TREE_CODE (TYPE_MAX_VALUE (TYPE_DOMAIN (type)))
   15103                 :             :                         == INTEGER_CST)
   15104                 :             :         {
   15105                 :        1039 :           tree size
   15106                 :        1039 :             = fold_convert (sizetype, TYPE_MAX_VALUE (TYPE_DOMAIN (type)));
   15107                 :        1039 :           size = size_binop (PLUS_EXPR, size, size_one_node);
   15108                 :        1039 :           if (TREE_CODE (low_bound) == INTEGER_CST)
   15109                 :             :             {
   15110                 :         854 :               if (tree_int_cst_lt (size, low_bound))
   15111                 :             :                 {
   15112                 :          10 :                   error_at (OMP_CLAUSE_LOCATION (c),
   15113                 :             :                             "low bound %qE above array section size "
   15114                 :             :                             "in %qs clause", low_bound,
   15115                 :          10 :                             omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   15116                 :          10 :                   return error_mark_node;
   15117                 :             :                 }
   15118                 :         844 :               if (tree_int_cst_equal (size, low_bound))
   15119                 :             :                 {
   15120                 :           5 :                   if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_AFFINITY
   15121                 :             :                       || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND
   15122                 :             :                       || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION
   15123                 :             :                       || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_IN_REDUCTION
   15124                 :             :                       || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_TASK_REDUCTION)
   15125                 :             :                     {
   15126                 :           5 :                       error_at (OMP_CLAUSE_LOCATION (c),
   15127                 :             :                                 "zero length array section in %qs clause",
   15128                 :           5 :                                 omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   15129                 :           5 :                       return error_mark_node;
   15130                 :             :                     }
   15131                 :           0 :                   maybe_zero_len = true;
   15132                 :             :                 }
   15133                 :         839 :               else if (length == NULL_TREE
   15134                 :         256 :                        && first_non_one == types.length ()
   15135                 :         894 :                        && tree_int_cst_equal
   15136                 :          55 :                             (TYPE_MAX_VALUE (TYPE_DOMAIN (type)),
   15137                 :             :                              low_bound))
   15138                 :          30 :                 first_non_one++;
   15139                 :             :             }
   15140                 :         185 :           else if (length == NULL_TREE)
   15141                 :             :             {
   15142                 :           3 :               if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_AFFINITY
   15143                 :             :                   && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_DEPEND
   15144                 :             :                   && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_REDUCTION
   15145                 :             :                   && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_IN_REDUCTION
   15146                 :             :                   && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_TASK_REDUCTION)
   15147                 :           0 :                 maybe_zero_len = true;
   15148                 :           6 :               if (first_non_one == types.length ())
   15149                 :           1 :                 first_non_one++;
   15150                 :             :             }
   15151                 :        1024 :           if (length && TREE_CODE (length) == INTEGER_CST)
   15152                 :             :             {
   15153                 :         777 :               if (tree_int_cst_lt (size, length))
   15154                 :             :                 {
   15155                 :          11 :                   error_at (OMP_CLAUSE_LOCATION (c),
   15156                 :             :                             "length %qE above array section size "
   15157                 :             :                             "in %qs clause", length,
   15158                 :          11 :                             omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   15159                 :          11 :                   return error_mark_node;
   15160                 :             :                 }
   15161                 :         766 :               if (TREE_CODE (low_bound) == INTEGER_CST)
   15162                 :             :                 {
   15163                 :         668 :                   tree lbpluslen
   15164                 :         668 :                     = size_binop (PLUS_EXPR,
   15165                 :             :                                   fold_convert (sizetype, low_bound),
   15166                 :             :                                   fold_convert (sizetype, length));
   15167                 :         668 :                   if (TREE_CODE (lbpluslen) == INTEGER_CST
   15168                 :         668 :                       && tree_int_cst_lt (size, lbpluslen))
   15169                 :             :                     {
   15170                 :          10 :                       error_at (OMP_CLAUSE_LOCATION (c),
   15171                 :             :                                 "high bound %qE above array section size "
   15172                 :             :                                 "in %qs clause", lbpluslen,
   15173                 :          10 :                                 omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   15174                 :          10 :                       return error_mark_node;
   15175                 :             :                     }
   15176                 :             :                 }
   15177                 :             :             }
   15178                 :             :         }
   15179                 :         357 :       else if (length == NULL_TREE)
   15180                 :             :         {
   15181                 :          10 :           if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_AFFINITY
   15182                 :             :               && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_DEPEND
   15183                 :             :               && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_REDUCTION
   15184                 :             :               && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_IN_REDUCTION
   15185                 :             :               && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_TASK_REDUCTION)
   15186                 :           0 :             maybe_zero_len = true;
   15187                 :          20 :           if (first_non_one == types.length ())
   15188                 :          10 :             first_non_one++;
   15189                 :             :         }
   15190                 :             : 
   15191                 :             :       /* For [lb:] we will need to evaluate lb more than once.  */
   15192                 :         907 :       if (length == NULL_TREE && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_DEPEND)
   15193                 :             :         {
   15194                 :         127 :           tree lb = save_expr (low_bound);
   15195                 :         127 :           if (lb != low_bound)
   15196                 :             :             {
   15197                 :           2 :               TREE_OPERAND (t, 1) = lb;
   15198                 :           2 :               low_bound = lb;
   15199                 :             :             }
   15200                 :             :         }
   15201                 :             :     }
   15202                 :        1665 :   else if (TREE_CODE (type) == POINTER_TYPE)
   15203                 :             :     {
   15204                 :        1655 :       if (length == NULL_TREE)
   15205                 :             :         {
   15206                 :          10 :           if (TREE_CODE (ret) == PARM_DECL && C_ARRAY_PARAMETER (ret))
   15207                 :           8 :             error_at (OMP_CLAUSE_LOCATION (c),
   15208                 :             :                       "for array function parameter length expression "
   15209                 :             :                       "must be specified");
   15210                 :             :           else
   15211                 :           2 :             error_at (OMP_CLAUSE_LOCATION (c),
   15212                 :             :                       "for pointer type length expression must be specified");
   15213                 :          10 :           return error_mark_node;
   15214                 :             :         }
   15215                 :        1645 :       if (length != NULL_TREE
   15216                 :        1645 :           && TREE_CODE (length) == INTEGER_CST
   15217                 :        1197 :           && tree_int_cst_sgn (length) == -1)
   15218                 :             :         {
   15219                 :          20 :           error_at (OMP_CLAUSE_LOCATION (c),
   15220                 :             :                     "negative length in array section in %qs clause",
   15221                 :          20 :                     omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   15222                 :          20 :           return error_mark_node;
   15223                 :             :         }
   15224                 :             :       /* If there is a pointer type anywhere but in the very first
   15225                 :             :          array-section-subscript, the array section could be non-contiguous.  */
   15226                 :        1625 :       if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_DEPEND
   15227                 :        1464 :           && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_AFFINITY
   15228                 :        3060 :           && TREE_CODE (TREE_OPERAND (t, 0)) == OMP_ARRAY_SECTION)
   15229                 :             :         {
   15230                 :             :           /* If any prior dimension has a non-one length, then deem this
   15231                 :             :              array section as non-contiguous.  */
   15232                 :          15 :           for (tree d = TREE_OPERAND (t, 0);
   15233                 :          26 :                TREE_CODE (d) == OMP_ARRAY_SECTION;
   15234                 :          11 :                d = TREE_OPERAND (d, 0))
   15235                 :             :             {
   15236                 :          15 :               tree d_length = TREE_OPERAND (d, 2);
   15237                 :          15 :               if (d_length == NULL_TREE || !integer_onep (d_length))
   15238                 :             :                 {
   15239                 :           4 :                   error_at (OMP_CLAUSE_LOCATION (c),
   15240                 :             :                             "array section is not contiguous in %qs clause",
   15241                 :           4 :                             omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   15242                 :           4 :                   return error_mark_node;
   15243                 :             :                 }
   15244                 :             :             }
   15245                 :             :         }
   15246                 :             :     }
   15247                 :             :   else
   15248                 :             :     {
   15249                 :          10 :       error_at (OMP_CLAUSE_LOCATION (c),
   15250                 :             :                 "%qE does not have pointer or array type", ret);
   15251                 :          10 :       return error_mark_node;
   15252                 :             :     }
   15253                 :        2981 :   if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_DEPEND)
   15254                 :        2671 :     types.safe_push (TREE_TYPE (ret));
   15255                 :             :   /* We will need to evaluate lb more than once.  */
   15256                 :        2981 :   tree lb = save_expr (low_bound);
   15257                 :        2981 :   if (lb != low_bound)
   15258                 :             :     {
   15259                 :         262 :       TREE_OPERAND (t, 1) = lb;
   15260                 :         262 :       low_bound = lb;
   15261                 :             :     }
   15262                 :        2981 :   ret = build_array_ref (OMP_CLAUSE_LOCATION (c), ret, low_bound);
   15263                 :        2981 :   return ret;
   15264                 :             : }
   15265                 :             : 
   15266                 :             : /* Handle array sections for clause C.  */
   15267                 :             : 
   15268                 :             : static bool
   15269                 :        2837 : handle_omp_array_sections (tree &c, enum c_omp_region_type ort)
   15270                 :             : {
   15271                 :        2837 :   bool maybe_zero_len = false;
   15272                 :        2837 :   unsigned int first_non_one = 0;
   15273                 :        2837 :   auto_vec<tree, 10> types;
   15274                 :        2837 :   tree *tp = &OMP_CLAUSE_DECL (c);
   15275                 :        2837 :   if ((OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND
   15276                 :        2529 :        || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_AFFINITY)
   15277                 :         407 :       && TREE_CODE (*tp) == TREE_LIST
   15278                 :          66 :       && TREE_PURPOSE (*tp)
   15279                 :        2903 :       && TREE_CODE (TREE_PURPOSE (*tp)) == TREE_VEC)
   15280                 :          66 :     tp = &TREE_VALUE (*tp);
   15281                 :        2837 :   tree first = handle_omp_array_sections_1 (c, *tp, types,
   15282                 :             :                                             maybe_zero_len, first_non_one,
   15283                 :             :                                             ort);
   15284                 :        2837 :   if (first == error_mark_node)
   15285                 :             :     return true;
   15286                 :        2620 :   if (first == NULL_TREE)
   15287                 :             :     return false;
   15288                 :        2620 :   if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND
   15289                 :        2620 :       || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_AFFINITY)
   15290                 :             :     {
   15291                 :         330 :       tree t = *tp;
   15292                 :         330 :       tree tem = NULL_TREE;
   15293                 :             :       /* Need to evaluate side effects in the length expressions
   15294                 :             :          if any.  */
   15295                 :         330 :       while (TREE_CODE (t) == TREE_LIST)
   15296                 :             :         {
   15297                 :           0 :           if (TREE_VALUE (t) && TREE_SIDE_EFFECTS (TREE_VALUE (t)))
   15298                 :             :             {
   15299                 :           0 :               if (tem == NULL_TREE)
   15300                 :             :                 tem = TREE_VALUE (t);
   15301                 :             :               else
   15302                 :           0 :                 tem = build2 (COMPOUND_EXPR, TREE_TYPE (tem),
   15303                 :           0 :                               TREE_VALUE (t), tem);
   15304                 :             :             }
   15305                 :           0 :           t = TREE_CHAIN (t);
   15306                 :             :         }
   15307                 :         330 :       if (tem)
   15308                 :           0 :         first = build2 (COMPOUND_EXPR, TREE_TYPE (first), tem, first);
   15309                 :         330 :       first = c_fully_fold (first, false, NULL, true);
   15310                 :         330 :       *tp = first;
   15311                 :             :     }
   15312                 :             :   else
   15313                 :             :     {
   15314                 :        2290 :       unsigned int num = types.length (), i;
   15315                 :        2290 :       tree t, side_effects = NULL_TREE, size = NULL_TREE;
   15316                 :        2290 :       tree condition = NULL_TREE;
   15317                 :             : 
   15318                 :        2290 :       if (int_size_in_bytes (TREE_TYPE (first)) <= 0)
   15319                 :           3 :         maybe_zero_len = true;
   15320                 :             : 
   15321                 :        4752 :       for (i = num, t = OMP_CLAUSE_DECL (c); i > 0;
   15322                 :        2462 :            t = TREE_OPERAND (t, 0))
   15323                 :             :         {
   15324                 :        2477 :           tree low_bound = TREE_OPERAND (t, 1);
   15325                 :        2477 :           tree length = TREE_OPERAND (t, 2);
   15326                 :             : 
   15327                 :        2477 :           i--;
   15328                 :        2477 :           if (low_bound
   15329                 :        2078 :               && TREE_CODE (low_bound) == INTEGER_CST
   15330                 :        4384 :               && TYPE_PRECISION (TREE_TYPE (low_bound))
   15331                 :        1907 :                  > TYPE_PRECISION (sizetype))
   15332                 :           0 :             low_bound = fold_convert (sizetype, low_bound);
   15333                 :        2477 :           if (length
   15334                 :        2385 :               && TREE_CODE (length) == INTEGER_CST
   15335                 :        3992 :               && TYPE_PRECISION (TREE_TYPE (length))
   15336                 :        1515 :                  > TYPE_PRECISION (sizetype))
   15337                 :           0 :             length = fold_convert (sizetype, length);
   15338                 :        2477 :           if (low_bound == NULL_TREE)
   15339                 :         399 :             low_bound = integer_zero_node;
   15340                 :        2477 :           if (!maybe_zero_len && i > first_non_one)
   15341                 :             :             {
   15342                 :         108 :               if (integer_nonzerop (low_bound))
   15343                 :           6 :                 goto do_warn_noncontiguous;
   15344                 :         102 :               if (length != NULL_TREE
   15345                 :          49 :                   && TREE_CODE (length) == INTEGER_CST
   15346                 :          49 :                   && TYPE_DOMAIN (types[i])
   15347                 :          49 :                   && TYPE_MAX_VALUE (TYPE_DOMAIN (types[i]))
   15348                 :         151 :                   && TREE_CODE (TYPE_MAX_VALUE (TYPE_DOMAIN (types[i])))
   15349                 :             :                      == INTEGER_CST)
   15350                 :             :                 {
   15351                 :          49 :                   tree size;
   15352                 :          49 :                   size = size_binop (PLUS_EXPR,
   15353                 :             :                                      TYPE_MAX_VALUE (TYPE_DOMAIN (types[i])),
   15354                 :             :                                      size_one_node);
   15355                 :          49 :                   if (!tree_int_cst_equal (length, size))
   15356                 :             :                     {
   15357                 :           7 :                      do_warn_noncontiguous:
   15358                 :          26 :                       error_at (OMP_CLAUSE_LOCATION (c),
   15359                 :             :                                 "array section is not contiguous in %qs "
   15360                 :             :                                 "clause",
   15361                 :          13 :                                 omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   15362                 :        2290 :                       return true;
   15363                 :             :                     }
   15364                 :             :                 }
   15365                 :          95 :               if (length != NULL_TREE
   15366                 :          95 :                   && TREE_SIDE_EFFECTS (length))
   15367                 :             :                 {
   15368                 :           0 :                   if (side_effects == NULL_TREE)
   15369                 :             :                     side_effects = length;
   15370                 :             :                   else
   15371                 :           0 :                     side_effects = build2 (COMPOUND_EXPR,
   15372                 :           0 :                                            TREE_TYPE (side_effects),
   15373                 :             :                                            length, side_effects);
   15374                 :             :                 }
   15375                 :             :             }
   15376                 :             :           else
   15377                 :             :             {
   15378                 :        2369 :               tree l;
   15379                 :             : 
   15380                 :        2369 :               if (i > first_non_one
   15381                 :        2369 :                   && ((length && integer_nonzerop (length))
   15382                 :           0 :                       || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION
   15383                 :             :                       || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_IN_REDUCTION
   15384                 :             :                       || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_TASK_REDUCTION))
   15385                 :           0 :                 continue;
   15386                 :        2369 :               if (length)
   15387                 :        2336 :                 l = fold_convert (sizetype, length);
   15388                 :             :               else
   15389                 :             :                 {
   15390                 :          33 :                   l = size_binop (PLUS_EXPR,
   15391                 :             :                                   TYPE_MAX_VALUE (TYPE_DOMAIN (types[i])),
   15392                 :             :                                   size_one_node);
   15393                 :          33 :                   l = size_binop (MINUS_EXPR, l,
   15394                 :             :                                   fold_convert (sizetype, low_bound));
   15395                 :             :                 }
   15396                 :        2369 :               if (i > first_non_one)
   15397                 :             :                 {
   15398                 :           0 :                   l = fold_build2 (NE_EXPR, boolean_type_node, l,
   15399                 :             :                                    size_zero_node);
   15400                 :           0 :                   if (condition == NULL_TREE)
   15401                 :             :                     condition = l;
   15402                 :             :                   else
   15403                 :           0 :                     condition = fold_build2 (BIT_AND_EXPR, boolean_type_node,
   15404                 :             :                                              l, condition);
   15405                 :             :                 }
   15406                 :        2369 :               else if (size == NULL_TREE)
   15407                 :             :                 {
   15408                 :        2277 :                   size = size_in_bytes (TREE_TYPE (types[i]));
   15409                 :        2277 :                   tree eltype = TREE_TYPE (types[num - 1]);
   15410                 :        2297 :                   while (TREE_CODE (eltype) == ARRAY_TYPE)
   15411                 :          20 :                     eltype = TREE_TYPE (eltype);
   15412                 :        2277 :                   if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION
   15413                 :        2042 :                       || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_IN_REDUCTION
   15414                 :        4059 :                       || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_TASK_REDUCTION)
   15415                 :             :                     {
   15416                 :         539 :                       if (integer_zerop (size)
   15417                 :        1076 :                           || integer_zerop (size_in_bytes (eltype)))
   15418                 :             :                         {
   15419                 :           4 :                           error_at (OMP_CLAUSE_LOCATION (c),
   15420                 :             :                                     "zero length array section in %qs clause",
   15421                 :           2 :                                     omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   15422                 :           2 :                           return error_mark_node;
   15423                 :             :                         }
   15424                 :         537 :                       size = size_binop (EXACT_DIV_EXPR, size,
   15425                 :             :                                          size_in_bytes (eltype));
   15426                 :             :                     }
   15427                 :        2275 :                   size = size_binop (MULT_EXPR, size, l);
   15428                 :        2275 :                   if (condition)
   15429                 :           0 :                     size = fold_build3 (COND_EXPR, sizetype, condition,
   15430                 :             :                                         size, size_zero_node);
   15431                 :             :                 }
   15432                 :             :               else
   15433                 :          92 :                 size = size_binop (MULT_EXPR, size, l);
   15434                 :             :             }
   15435                 :             :         }
   15436                 :        2275 :       if (side_effects)
   15437                 :           0 :         size = build2 (COMPOUND_EXPR, sizetype, side_effects, size);
   15438                 :        2275 :       if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION
   15439                 :        2042 :           || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_IN_REDUCTION
   15440                 :        4057 :           || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_TASK_REDUCTION)
   15441                 :             :         {
   15442                 :         537 :           size = size_binop (MINUS_EXPR, size, size_one_node);
   15443                 :         537 :           size = c_fully_fold (size, false, NULL);
   15444                 :         537 :           size = save_expr (size);
   15445                 :         537 :           tree index_type = build_index_type (size);
   15446                 :         537 :           tree eltype = TREE_TYPE (first);
   15447                 :         549 :           while (TREE_CODE (eltype) == ARRAY_TYPE)
   15448                 :          12 :             eltype = TREE_TYPE (eltype);
   15449                 :         537 :           tree type = c_build_array_type (eltype, index_type);
   15450                 :         537 :           tree ptype = c_build_pointer_type (eltype);
   15451                 :         537 :           if (TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE)
   15452                 :         296 :             t = build_fold_addr_expr (t);
   15453                 :         537 :           tree t2 = build_fold_addr_expr (first);
   15454                 :         537 :           t2 = fold_convert_loc (OMP_CLAUSE_LOCATION (c),
   15455                 :             :                                  ptrdiff_type_node, t2);
   15456                 :         537 :           t2 = fold_build2_loc (OMP_CLAUSE_LOCATION (c), MINUS_EXPR,
   15457                 :             :                                 ptrdiff_type_node, t2,
   15458                 :         537 :                                 fold_convert_loc (OMP_CLAUSE_LOCATION (c),
   15459                 :             :                                                   ptrdiff_type_node, t));
   15460                 :         537 :           t2 = c_fully_fold (t2, false, NULL);
   15461                 :         537 :           if (tree_fits_shwi_p (t2))
   15462                 :         398 :             t = build2 (MEM_REF, type, t,
   15463                 :         398 :                         build_int_cst (ptype, tree_to_shwi (t2)));
   15464                 :             :           else
   15465                 :             :             {
   15466                 :         139 :               t2 = fold_convert_loc (OMP_CLAUSE_LOCATION (c), sizetype, t2);
   15467                 :         139 :               t = build2_loc (OMP_CLAUSE_LOCATION (c), POINTER_PLUS_EXPR,
   15468                 :         139 :                               TREE_TYPE (t), t, t2);
   15469                 :         139 :               t = build2 (MEM_REF, type, t, build_int_cst (ptype, 0));
   15470                 :             :             }
   15471                 :         537 :           OMP_CLAUSE_DECL (c) = t;
   15472                 :         537 :           return false;
   15473                 :             :         }
   15474                 :        1738 :       first = c_fully_fold (first, false, NULL);
   15475                 :        1738 :       OMP_CLAUSE_DECL (c) = first;
   15476                 :        1738 :       if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_HAS_DEVICE_ADDR)
   15477                 :             :         return false;
   15478                 :             :       /* Don't set OMP_CLAUSE_SIZE for bare attach/detach clauses.  */
   15479                 :        1727 :       if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_MAP
   15480                 :        1727 :           || (OMP_CLAUSE_MAP_KIND (c) != GOMP_MAP_ATTACH
   15481                 :        1599 :               && OMP_CLAUSE_MAP_KIND (c) != GOMP_MAP_DETACH
   15482                 :        1597 :               && OMP_CLAUSE_MAP_KIND (c) != GOMP_MAP_FORCE_DETACH))
   15483                 :             :         {
   15484                 :        1723 :           if (size)
   15485                 :        1723 :             size = c_fully_fold (size, false, NULL);
   15486                 :        1723 :           OMP_CLAUSE_SIZE (c) = size;
   15487                 :             :         }
   15488                 :             : 
   15489                 :        1727 :       if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_MAP)
   15490                 :             :         return false;
   15491                 :             : 
   15492                 :        1601 :       auto_vec<omp_addr_token *, 10> addr_tokens;
   15493                 :             : 
   15494                 :        1601 :       if (!omp_parse_expr (addr_tokens, first))
   15495                 :        1601 :         return true;
   15496                 :             : 
   15497                 :        1601 :       c_omp_address_inspector ai (OMP_CLAUSE_LOCATION (c), t);
   15498                 :             : 
   15499                 :        1601 :       tree nc = ai.expand_map_clause (c, first, addr_tokens, ort);
   15500                 :        1601 :       if (nc != error_mark_node)
   15501                 :             :         {
   15502                 :        1601 :           using namespace omp_addr_tokenizer;
   15503                 :             : 
   15504                 :        1601 :           if (ai.maybe_zero_length_array_section (c))
   15505                 :        1597 :             OMP_CLAUSE_MAP_MAYBE_ZERO_LENGTH_ARRAY_SECTION (c) = 1;
   15506                 :             : 
   15507                 :             :           /* !!! If we're accessing a base decl via chained access
   15508                 :             :              methods (e.g. multiple indirections), duplicate clause
   15509                 :             :              detection won't work properly.  Skip it in that case.  */
   15510                 :        1601 :           if ((addr_tokens[0]->type == STRUCTURE_BASE
   15511                 :        1369 :                || addr_tokens[0]->type == ARRAY_BASE)
   15512                 :        1601 :               && addr_tokens[0]->u.structure_base_kind == BASE_DECL
   15513                 :        1601 :               && addr_tokens[1]->type == ACCESS_METHOD
   15514                 :        3202 :               && omp_access_chain_p (addr_tokens, 1))
   15515                 :          27 :             c = nc;
   15516                 :             : 
   15517                 :        1601 :           return false;
   15518                 :             :         }
   15519                 :             :     }
   15520                 :             :   return false;
   15521                 :        2837 : }
   15522                 :             : 
   15523                 :             : /* Helper function of finish_omp_clauses.  Clone STMT as if we were making
   15524                 :             :    an inline call.  But, remap
   15525                 :             :    the OMP_DECL1 VAR_DECL (omp_out resp. omp_orig) to PLACEHOLDER
   15526                 :             :    and OMP_DECL2 VAR_DECL (omp_in resp. omp_priv) to DECL.  */
   15527                 :             : 
   15528                 :             : static tree
   15529                 :         510 : c_clone_omp_udr (tree stmt, tree omp_decl1, tree omp_decl2,
   15530                 :             :                  tree decl, tree placeholder)
   15531                 :             : {
   15532                 :         510 :   copy_body_data id;
   15533                 :         510 :   hash_map<tree, tree> decl_map;
   15534                 :             : 
   15535                 :         510 :   decl_map.put (omp_decl1, placeholder);
   15536                 :         510 :   decl_map.put (omp_decl2, decl);
   15537                 :         510 :   memset (&id, 0, sizeof (id));
   15538                 :         510 :   id.src_fn = DECL_CONTEXT (omp_decl1);
   15539                 :         510 :   id.dst_fn = current_function_decl;
   15540                 :         510 :   id.src_cfun = DECL_STRUCT_FUNCTION (id.src_fn);
   15541                 :         510 :   id.decl_map = &decl_map;
   15542                 :             : 
   15543                 :         510 :   id.copy_decl = copy_decl_no_change;
   15544                 :         510 :   id.transform_call_graph_edges = CB_CGE_DUPLICATE;
   15545                 :         510 :   id.transform_new_cfg = true;
   15546                 :         510 :   id.transform_return_to_modify = false;
   15547                 :         510 :   id.eh_lp_nr = 0;
   15548                 :         510 :   walk_tree (&stmt, copy_tree_body_r, &id, NULL);
   15549                 :         510 :   return stmt;
   15550                 :         510 : }
   15551                 :             : 
   15552                 :             : /* Helper function of c_finish_omp_clauses, called via walk_tree.
   15553                 :             :    Find OMP_CLAUSE_PLACEHOLDER (passed in DATA) in *TP.  */
   15554                 :             : 
   15555                 :             : static tree
   15556                 :        1123 : c_find_omp_placeholder_r (tree *tp, int *, void *data)
   15557                 :             : {
   15558                 :        1123 :   if (*tp == (tree) data)
   15559                 :          28 :     return *tp;
   15560                 :             :   return NULL_TREE;
   15561                 :             : }
   15562                 :             : 
   15563                 :             : /* Similarly, but also walk aggregate fields.  */
   15564                 :             : 
   15565                 :             : struct c_find_omp_var_s { tree var; hash_set<tree> *pset; };
   15566                 :             : 
   15567                 :             : static tree
   15568                 :         192 : c_find_omp_var_r (tree *tp, int *, void *data)
   15569                 :             : {
   15570                 :         192 :   if (*tp == ((struct c_find_omp_var_s *) data)->var)
   15571                 :             :     return *tp;
   15572                 :         184 :   if (RECORD_OR_UNION_TYPE_P (*tp))
   15573                 :             :     {
   15574                 :           2 :       tree field;
   15575                 :           2 :       hash_set<tree> *pset = ((struct c_find_omp_var_s *) data)->pset;
   15576                 :             : 
   15577                 :           2 :       for (field = TYPE_FIELDS (*tp); field;
   15578                 :           0 :            field = DECL_CHAIN (field))
   15579                 :           2 :         if (TREE_CODE (field) == FIELD_DECL)
   15580                 :             :           {
   15581                 :           2 :             tree ret = walk_tree (&DECL_FIELD_OFFSET (field),
   15582                 :             :                                   c_find_omp_var_r, data, pset);
   15583                 :           2 :             if (ret)
   15584                 :             :               return ret;
   15585                 :           2 :             ret = walk_tree (&DECL_SIZE (field), c_find_omp_var_r, data, pset);
   15586                 :           2 :             if (ret)
   15587                 :             :               return ret;
   15588                 :           2 :             ret = walk_tree (&DECL_SIZE_UNIT (field), c_find_omp_var_r, data,
   15589                 :             :                              pset);
   15590                 :           2 :             if (ret)
   15591                 :             :               return ret;
   15592                 :           2 :             ret = walk_tree (&TREE_TYPE (field), c_find_omp_var_r, data, pset);
   15593                 :           2 :             if (ret)
   15594                 :             :               return ret;
   15595                 :             :           }
   15596                 :             :     }
   15597                 :         182 :   else if (INTEGRAL_TYPE_P (*tp))
   15598                 :          27 :     return walk_tree (&TYPE_MAX_VALUE (*tp), c_find_omp_var_r, data,
   15599                 :             :                       ((struct c_find_omp_var_s *) data)->pset);
   15600                 :             :   return NULL_TREE;
   15601                 :             : }
   15602                 :             : 
   15603                 :             : /* Finish OpenMP iterators ITER.  Return true if they are errorneous
   15604                 :             :    and clauses containing them should be removed.  */
   15605                 :             : 
   15606                 :             : static bool
   15607                 :         111 : c_omp_finish_iterators (tree iter)
   15608                 :             : {
   15609                 :         111 :   bool ret = false;
   15610                 :         243 :   for (tree it = iter; it; it = TREE_CHAIN (it))
   15611                 :             :     {
   15612                 :         132 :       tree var = TREE_VEC_ELT (it, 0);
   15613                 :         132 :       tree begin = TREE_VEC_ELT (it, 1);
   15614                 :         132 :       tree end = TREE_VEC_ELT (it, 2);
   15615                 :         132 :       tree step = TREE_VEC_ELT (it, 3);
   15616                 :         132 :       tree orig_step;
   15617                 :         132 :       tree type = TREE_TYPE (var);
   15618                 :         132 :       location_t loc = DECL_SOURCE_LOCATION (var);
   15619                 :         132 :       if (type == error_mark_node)
   15620                 :             :         {
   15621                 :           0 :           ret = true;
   15622                 :          34 :           continue;
   15623                 :             :         }
   15624                 :         132 :       if (!INTEGRAL_TYPE_P (type) && !POINTER_TYPE_P (type))
   15625                 :             :         {
   15626                 :           6 :           error_at (loc, "iterator %qD has neither integral nor pointer type",
   15627                 :             :                     var);
   15628                 :           6 :           ret = true;
   15629                 :           6 :           continue;
   15630                 :             :         }
   15631                 :         126 :       else if (TYPE_ATOMIC (type))
   15632                 :             :         {
   15633                 :           2 :           error_at (loc, "iterator %qD has %<_Atomic%> qualified type", var);
   15634                 :           2 :           ret = true;
   15635                 :           2 :           continue;
   15636                 :             :         }
   15637                 :         124 :       else if (TYPE_READONLY (type))
   15638                 :             :         {
   15639                 :           4 :           error_at (loc, "iterator %qD has const qualified type", var);
   15640                 :           4 :           ret = true;
   15641                 :           4 :           continue;
   15642                 :             :         }
   15643                 :         120 :       else if (step == error_mark_node
   15644                 :         120 :                || TREE_TYPE (step) == error_mark_node)
   15645                 :             :         {
   15646                 :           0 :           ret = true;
   15647                 :           0 :           continue;
   15648                 :             :         }
   15649                 :         120 :       else if (!INTEGRAL_TYPE_P (TREE_TYPE (step)))
   15650                 :             :         {
   15651                 :           6 :           error_at (EXPR_LOC_OR_LOC (step, loc),
   15652                 :             :                     "iterator step with non-integral type");
   15653                 :           4 :           ret = true;
   15654                 :           4 :           continue;
   15655                 :             :         }
   15656                 :         116 :       begin = c_fully_fold (build_c_cast (loc, type, begin), false, NULL);
   15657                 :         116 :       end = c_fully_fold (build_c_cast (loc, type, end), false, NULL);
   15658                 :         116 :       orig_step = save_expr (c_fully_fold (step, false, NULL));
   15659                 :         116 :       tree stype = POINTER_TYPE_P (type) ? sizetype : type;
   15660                 :         116 :       step = c_fully_fold (build_c_cast (loc, stype, orig_step), false, NULL);
   15661                 :         116 :       if (POINTER_TYPE_P (type))
   15662                 :             :         {
   15663                 :          14 :           begin = save_expr (begin);
   15664                 :          14 :           step = pointer_int_sum (loc, PLUS_EXPR, begin, step);
   15665                 :          14 :           step = fold_build2_loc (loc, MINUS_EXPR, sizetype,
   15666                 :             :                                   fold_convert (sizetype, step),
   15667                 :             :                                   fold_convert (sizetype, begin));
   15668                 :          14 :           step = fold_convert (ssizetype, step);
   15669                 :             :         }
   15670                 :         116 :       if (integer_zerop (step))
   15671                 :             :         {
   15672                 :           6 :           error_at (loc, "iterator %qD has zero step", var);
   15673                 :           6 :           ret = true;
   15674                 :           6 :           continue;
   15675                 :             :         }
   15676                 :             : 
   15677                 :         110 :       if (begin == error_mark_node
   15678                 :         108 :           || end == error_mark_node
   15679                 :         106 :           || step == error_mark_node
   15680                 :         106 :           || orig_step == error_mark_node)
   15681                 :             :         {
   15682                 :           4 :           ret = true;
   15683                 :           4 :           continue;
   15684                 :             :         }
   15685                 :         106 :       hash_set<tree> pset;
   15686                 :         106 :       tree it2;
   15687                 :         123 :       for (it2 = TREE_CHAIN (it); it2; it2 = TREE_CHAIN (it2))
   15688                 :             :         {
   15689                 :          25 :           tree var2 = TREE_VEC_ELT (it2, 0);
   15690                 :          25 :           tree begin2 = TREE_VEC_ELT (it2, 1);
   15691                 :          25 :           tree end2 = TREE_VEC_ELT (it2, 2);
   15692                 :          25 :           tree step2 = TREE_VEC_ELT (it2, 3);
   15693                 :          25 :           tree type2 = TREE_TYPE (var2);
   15694                 :          25 :           location_t loc2 = DECL_SOURCE_LOCATION (var2);
   15695                 :          25 :           struct c_find_omp_var_s data = { var, &pset };
   15696                 :          25 :           if (walk_tree (&type2, c_find_omp_var_r, &data, &pset))
   15697                 :             :             {
   15698                 :           2 :               error_at (loc2,
   15699                 :             :                         "type of iterator %qD refers to outer iterator %qD",
   15700                 :             :                         var2, var);
   15701                 :          10 :               break;
   15702                 :             :             }
   15703                 :          23 :           else if (walk_tree (&begin2, c_find_omp_var_r, &data, &pset))
   15704                 :             :             {
   15705                 :           2 :               error_at (EXPR_LOC_OR_LOC (begin2, loc2),
   15706                 :             :                         "begin expression refers to outer iterator %qD", var);
   15707                 :           2 :               break;
   15708                 :             :             }
   15709                 :          21 :           else if (walk_tree (&end2, c_find_omp_var_r, &data, &pset))
   15710                 :             :             {
   15711                 :           2 :               error_at (EXPR_LOC_OR_LOC (end2, loc2),
   15712                 :             :                         "end expression refers to outer iterator %qD", var);
   15713                 :           2 :               break;
   15714                 :             :             }
   15715                 :          19 :           else if (walk_tree (&step2, c_find_omp_var_r, &data, &pset))
   15716                 :             :             {
   15717                 :           2 :               error_at (EXPR_LOC_OR_LOC (step2, loc2),
   15718                 :             :                         "step expression refers to outer iterator %qD", var);
   15719                 :           2 :               break;
   15720                 :             :             }
   15721                 :             :         }
   15722                 :         106 :       if (it2)
   15723                 :             :         {
   15724                 :           8 :           ret = true;
   15725                 :           8 :           continue;
   15726                 :             :         }
   15727                 :          98 :       TREE_VEC_ELT (it, 1) = begin;
   15728                 :          98 :       TREE_VEC_ELT (it, 2) = end;
   15729                 :          98 :       TREE_VEC_ELT (it, 3) = step;
   15730                 :          98 :       TREE_VEC_ELT (it, 4) = orig_step;
   15731                 :         106 :     }
   15732                 :         111 :   return ret;
   15733                 :             : }
   15734                 :             : 
   15735                 :             : /* Ensure that pointers are used in OpenACC attach and detach clauses.
   15736                 :             :    Return true if an error has been detected.  */
   15737                 :             : 
   15738                 :             : static bool
   15739                 :        8947 : c_oacc_check_attachments (tree c)
   15740                 :             : {
   15741                 :        8947 :   if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_MAP)
   15742                 :             :     return false;
   15743                 :             : 
   15744                 :             :   /* OpenACC attach / detach clauses must be pointers.  */
   15745                 :        5966 :   if (OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_ATTACH
   15746                 :        5966 :       || OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_DETACH)
   15747                 :             :     {
   15748                 :          54 :       tree t = OMP_CLAUSE_DECL (c);
   15749                 :             : 
   15750                 :          60 :       while (TREE_CODE (t) == OMP_ARRAY_SECTION)
   15751                 :           6 :         t = TREE_OPERAND (t, 0);
   15752                 :             : 
   15753                 :          54 :       if (TREE_CODE (TREE_TYPE (t)) != POINTER_TYPE)
   15754                 :             :         {
   15755                 :           6 :           error_at (OMP_CLAUSE_LOCATION (c), "expected pointer in %qs clause",
   15756                 :             :                     user_omp_clause_code_name (c, true));
   15757                 :           6 :           return true;
   15758                 :             :         }
   15759                 :             :     }
   15760                 :             : 
   15761                 :             :   return false;
   15762                 :             : }
   15763                 :             : 
   15764                 :             : /* For all elements of CLAUSES, validate them against their constraints.
   15765                 :             :    Remove any elements from the list that are invalid.  */
   15766                 :             : 
   15767                 :             : tree
   15768                 :       28290 : c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
   15769                 :             : {
   15770                 :       28290 :   bitmap_head generic_head, firstprivate_head, lastprivate_head;
   15771                 :       28290 :   bitmap_head aligned_head, map_head, map_field_head, map_firstprivate_head;
   15772                 :       28290 :   bitmap_head oacc_reduction_head, is_on_device_head;
   15773                 :       28290 :   tree c, t, type, *pc;
   15774                 :       28290 :   tree simdlen = NULL_TREE, safelen = NULL_TREE;
   15775                 :       28290 :   bool branch_seen = false;
   15776                 :       28290 :   bool copyprivate_seen = false;
   15777                 :       28290 :   bool mergeable_seen = false;
   15778                 :       28290 :   tree *detach_seen = NULL;
   15779                 :       28290 :   bool linear_variable_step_check = false;
   15780                 :       28290 :   tree *nowait_clause = NULL;
   15781                 :       28290 :   tree *grainsize_seen = NULL;
   15782                 :       28290 :   bool num_tasks_seen = false;
   15783                 :       28290 :   tree ordered_clause = NULL_TREE;
   15784                 :       28290 :   tree schedule_clause = NULL_TREE;
   15785                 :       28290 :   bool oacc_async = false;
   15786                 :       28290 :   tree last_iterators = NULL_TREE;
   15787                 :       28290 :   bool last_iterators_remove = false;
   15788                 :       28290 :   tree *nogroup_seen = NULL;
   15789                 :       28290 :   tree *order_clause = NULL;
   15790                 :             :   /* 1 if normal/task reduction has been seen, -1 if inscan reduction
   15791                 :             :      has been seen, -2 if mixed inscan/normal reduction diagnosed.  */
   15792                 :       28290 :   int reduction_seen = 0;
   15793                 :       28290 :   bool allocate_seen = false;
   15794                 :       28290 :   bool implicit_moved = false;
   15795                 :       28290 :   bool target_in_reduction_seen = false;
   15796                 :       28290 :   tree *full_seen = NULL;
   15797                 :       28290 :   bool partial_seen = false;
   15798                 :       28290 :   bool openacc = (ort & C_ORT_ACC) != 0;
   15799                 :       28290 :   bool init_seen = false;
   15800                 :       28290 :   bool init_use_destroy_seen = false;
   15801                 :       28290 :   tree init_no_targetsync_clause = NULL_TREE;
   15802                 :       28290 :   tree depend_clause = NULL_TREE;
   15803                 :             : 
   15804                 :       28290 :   bitmap_obstack_initialize (NULL);
   15805                 :       28290 :   bitmap_initialize (&generic_head, &bitmap_default_obstack);
   15806                 :       28290 :   bitmap_initialize (&firstprivate_head, &bitmap_default_obstack);
   15807                 :       28290 :   bitmap_initialize (&lastprivate_head, &bitmap_default_obstack);
   15808                 :       28290 :   bitmap_initialize (&aligned_head, &bitmap_default_obstack);
   15809                 :             :   /* If ort == C_ORT_OMP_DECLARE_SIMD used as uniform_head instead.  */
   15810                 :       28290 :   bitmap_initialize (&map_head, &bitmap_default_obstack);
   15811                 :       28290 :   bitmap_initialize (&map_field_head, &bitmap_default_obstack);
   15812                 :       28290 :   bitmap_initialize (&map_firstprivate_head, &bitmap_default_obstack);
   15813                 :             :   /* If ort == C_ORT_OMP used as nontemporal_head or use_device_xxx_head
   15814                 :             :      instead and for ort == C_ORT_OMP_TARGET used as in_reduction_head.  */
   15815                 :       28290 :   bitmap_initialize (&oacc_reduction_head, &bitmap_default_obstack);
   15816                 :       28290 :   bitmap_initialize (&is_on_device_head, &bitmap_default_obstack);
   15817                 :             : 
   15818                 :       28290 :   if (openacc)
   15819                 :       11352 :     for (c = clauses; c; c = OMP_CLAUSE_CHAIN (c))
   15820                 :        6813 :       if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_ASYNC)
   15821                 :             :         {
   15822                 :             :           oacc_async = true;
   15823                 :             :           break;
   15824                 :             :         }
   15825                 :             : 
   15826                 :       28290 :   tree *grp_start_p = NULL, grp_sentinel = NULL_TREE;
   15827                 :             : 
   15828                 :       74778 :   for (pc = &clauses, c = clauses; c ; c = *pc)
   15829                 :             :     {
   15830                 :       46488 :       bool remove = false;
   15831                 :       46488 :       bool need_complete = false;
   15832                 :       46488 :       bool need_implicitly_determined = false;
   15833                 :             : 
   15834                 :             :       /* We've reached the end of a list of expanded nodes.  Reset the group
   15835                 :             :          start pointer.  */
   15836                 :       46488 :       if (c == grp_sentinel)
   15837                 :        2332 :         grp_start_p = NULL;
   15838                 :             : 
   15839                 :       46488 :       switch (OMP_CLAUSE_CODE (c))
   15840                 :             :         {
   15841                 :        1137 :         case OMP_CLAUSE_SHARED:
   15842                 :        1137 :           need_implicitly_determined = true;
   15843                 :        1137 :           goto check_dup_generic;
   15844                 :             : 
   15845                 :         828 :         case OMP_CLAUSE_PRIVATE:
   15846                 :         828 :           need_complete = true;
   15847                 :         828 :           need_implicitly_determined = true;
   15848                 :         828 :           goto check_dup_generic;
   15849                 :             : 
   15850                 :        3285 :         case OMP_CLAUSE_REDUCTION:
   15851                 :        3285 :           if (reduction_seen == 0)
   15852                 :        2717 :             reduction_seen = OMP_CLAUSE_REDUCTION_INSCAN (c) ? -1 : 1;
   15853                 :         568 :           else if (reduction_seen != -2
   15854                 :        1136 :                    && reduction_seen != (OMP_CLAUSE_REDUCTION_INSCAN (c)
   15855                 :         568 :                                          ? -1 : 1))
   15856                 :             :             {
   15857                 :           2 :               error_at (OMP_CLAUSE_LOCATION (c),
   15858                 :             :                         "%<inscan%> and non-%<inscan%> %<reduction%> clauses "
   15859                 :             :                         "on the same construct");
   15860                 :           2 :               reduction_seen = -2;
   15861                 :             :             }
   15862                 :             :           /* FALLTHRU */
   15863                 :        3948 :         case OMP_CLAUSE_IN_REDUCTION:
   15864                 :        3948 :         case OMP_CLAUSE_TASK_REDUCTION:
   15865                 :        3948 :           need_implicitly_determined = true;
   15866                 :        3948 :           t = OMP_CLAUSE_DECL (c);
   15867                 :        3948 :           if (TREE_CODE (t) == OMP_ARRAY_SECTION)
   15868                 :             :             {
   15869                 :         553 :               if (handle_omp_array_sections (c, ort))
   15870                 :             :                 {
   15871                 :             :                   remove = true;
   15872                 :             :                   break;
   15873                 :             :                 }
   15874                 :             : 
   15875                 :         537 :               t = OMP_CLAUSE_DECL (c);
   15876                 :         537 :               if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION
   15877                 :         537 :                   && OMP_CLAUSE_REDUCTION_INSCAN (c))
   15878                 :             :                 {
   15879                 :           1 :                   error_at (OMP_CLAUSE_LOCATION (c),
   15880                 :             :                             "%<inscan%> %<reduction%> clause with array "
   15881                 :             :                             "section");
   15882                 :           1 :                   remove = true;
   15883                 :           1 :                   break;
   15884                 :             :                 }
   15885                 :             :             }
   15886                 :        3931 :           t = require_complete_type (OMP_CLAUSE_LOCATION (c), t);
   15887                 :        3931 :           if (t == error_mark_node)
   15888                 :             :             {
   15889                 :             :               remove = true;
   15890                 :             :               break;
   15891                 :             :             }
   15892                 :        3929 :           if (oacc_async)
   15893                 :           3 :             c_mark_addressable (t);
   15894                 :        3929 :           type = TREE_TYPE (t);
   15895                 :        3929 :           if (TREE_CODE (t) == MEM_REF)
   15896                 :         536 :             type = TREE_TYPE (type);
   15897                 :        3929 :           if (TREE_CODE (type) == ARRAY_TYPE)
   15898                 :             :             {
   15899                 :          74 :               tree oatype = type;
   15900                 :          74 :               gcc_assert (TREE_CODE (t) != MEM_REF);
   15901                 :         148 :               while (TREE_CODE (type) == ARRAY_TYPE)
   15902                 :          74 :                 type = TREE_TYPE (type);
   15903                 :          74 :               if (integer_zerop (TYPE_SIZE_UNIT (type)))
   15904                 :             :                 {
   15905                 :           1 :                   error_at (OMP_CLAUSE_LOCATION (c),
   15906                 :             :                             "%qD in %<reduction%> clause is a zero size array",
   15907                 :             :                             t);
   15908                 :           1 :                   remove = true;
   15909                 :           1 :                   break;
   15910                 :             :                 }
   15911                 :          73 :               tree size = size_binop (EXACT_DIV_EXPR, TYPE_SIZE_UNIT (oatype),
   15912                 :             :                                       TYPE_SIZE_UNIT (type));
   15913                 :          73 :               if (integer_zerop (size))
   15914                 :             :                 {
   15915                 :           1 :                   error_at (OMP_CLAUSE_LOCATION (c),
   15916                 :             :                             "%qD in %<reduction%> clause is a zero size array",
   15917                 :             :                             t);
   15918                 :           1 :                   remove = true;
   15919                 :           1 :                   break;
   15920                 :             :                 }
   15921                 :          72 :               size = size_binop (MINUS_EXPR, size, size_one_node);
   15922                 :          72 :               size = save_expr (size);
   15923                 :          72 :               tree index_type = build_index_type (size);
   15924                 :          72 :               tree atype = c_build_array_type (TYPE_MAIN_VARIANT (type),
   15925                 :             :                                                index_type);
   15926                 :          72 :               atype = c_build_qualified_type (atype, TYPE_QUALS (type));
   15927                 :          72 :               tree ptype = c_build_pointer_type (type);
   15928                 :          72 :               if (TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE)
   15929                 :          72 :                 t = build_fold_addr_expr (t);
   15930                 :          72 :               t = build2 (MEM_REF, atype, t, build_int_cst (ptype, 0));
   15931                 :          72 :               OMP_CLAUSE_DECL (c) = t;
   15932                 :             :             }
   15933                 :        3927 :           if (TYPE_ATOMIC (type))
   15934                 :             :             {
   15935                 :           3 :               error_at (OMP_CLAUSE_LOCATION (c),
   15936                 :             :                         "%<_Atomic%> %qE in %<reduction%> clause", t);
   15937                 :           3 :               remove = true;
   15938                 :           3 :               break;
   15939                 :             :             }
   15940                 :        3924 :           if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_REDUCTION
   15941                 :        3924 :               || OMP_CLAUSE_REDUCTION_TASK (c))
   15942                 :             :             {
   15943                 :             :               /* Disallow zero sized or potentially zero sized task
   15944                 :             :                  reductions.  */
   15945                 :         870 :               if (integer_zerop (TYPE_SIZE_UNIT (type)))
   15946                 :             :                 {
   15947                 :           6 :                   error_at (OMP_CLAUSE_LOCATION (c),
   15948                 :             :                             "zero sized type %qT in %qs clause", type,
   15949                 :           3 :                             omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   15950                 :           3 :                   remove = true;
   15951                 :           3 :                   break;
   15952                 :             :                 }
   15953                 :         867 :               else if (TREE_CODE (TYPE_SIZE_UNIT (type)) != INTEGER_CST)
   15954                 :             :                 {
   15955                 :           0 :                   error_at (OMP_CLAUSE_LOCATION (c),
   15956                 :             :                             "variable sized type %qT in %qs clause", type,
   15957                 :           0 :                             omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   15958                 :           0 :                   remove = true;
   15959                 :           0 :                   break;
   15960                 :             :                 }
   15961                 :             :             }
   15962                 :        3921 :           if (OMP_CLAUSE_REDUCTION_PLACEHOLDER (c) == NULL_TREE
   15963                 :        3921 :               && (FLOAT_TYPE_P (type)
   15964                 :        3377 :                   || TREE_CODE (type) == COMPLEX_TYPE))
   15965                 :             :             {
   15966                 :         332 :               enum tree_code r_code = OMP_CLAUSE_REDUCTION_CODE (c);
   15967                 :         332 :               const char *r_name = NULL;
   15968                 :             : 
   15969                 :         332 :               switch (r_code)
   15970                 :             :                 {
   15971                 :             :                 case PLUS_EXPR:
   15972                 :             :                 case MULT_EXPR:
   15973                 :             :                 case MINUS_EXPR:
   15974                 :             :                 case TRUTH_ANDIF_EXPR:
   15975                 :             :                 case TRUTH_ORIF_EXPR:
   15976                 :             :                   break;
   15977                 :          13 :                 case MIN_EXPR:
   15978                 :          13 :                   if (TREE_CODE (type) == COMPLEX_TYPE)
   15979                 :             :                     r_name = "min";
   15980                 :             :                   break;
   15981                 :          38 :                 case MAX_EXPR:
   15982                 :          38 :                   if (TREE_CODE (type) == COMPLEX_TYPE)
   15983                 :             :                     r_name = "max";
   15984                 :             :                   break;
   15985                 :           3 :                 case BIT_AND_EXPR:
   15986                 :           3 :                   r_name = "&";
   15987                 :           3 :                   break;
   15988                 :           2 :                 case BIT_XOR_EXPR:
   15989                 :           2 :                   r_name = "^";
   15990                 :           2 :                   break;
   15991                 :             :                 case BIT_IOR_EXPR:
   15992                 :             :                   r_name = "|";
   15993                 :             :                   break;
   15994                 :           0 :                 default:
   15995                 :           0 :                   gcc_unreachable ();
   15996                 :             :                 }
   15997                 :           5 :               if (r_name)
   15998                 :             :                 {
   15999                 :          12 :                   error_at (OMP_CLAUSE_LOCATION (c),
   16000                 :             :                             "%qE has invalid type for %<reduction(%s)%>",
   16001                 :             :                             t, r_name);
   16002                 :          12 :                   remove = true;
   16003                 :          12 :                   break;
   16004                 :             :                 }
   16005                 :             :             }
   16006                 :        3589 :           else if (OMP_CLAUSE_REDUCTION_PLACEHOLDER (c) == error_mark_node)
   16007                 :             :             {
   16008                 :           2 :               error_at (OMP_CLAUSE_LOCATION (c),
   16009                 :             :                         "user defined reduction not found for %qE", t);
   16010                 :           2 :               remove = true;
   16011                 :           2 :               break;
   16012                 :             :             }
   16013                 :        3587 :           else if (OMP_CLAUSE_REDUCTION_PLACEHOLDER (c))
   16014                 :             :             {
   16015                 :         277 :               tree list = OMP_CLAUSE_REDUCTION_PLACEHOLDER (c);
   16016                 :         277 :               type = TYPE_MAIN_VARIANT (type);
   16017                 :         277 :               tree placeholder = build_decl (OMP_CLAUSE_LOCATION (c),
   16018                 :             :                                              VAR_DECL, NULL_TREE, type);
   16019                 :         277 :               tree decl_placeholder = NULL_TREE;
   16020                 :         277 :               OMP_CLAUSE_REDUCTION_PLACEHOLDER (c) = placeholder;
   16021                 :         277 :               DECL_ARTIFICIAL (placeholder) = 1;
   16022                 :         277 :               DECL_IGNORED_P (placeholder) = 1;
   16023                 :         277 :               if (TREE_CODE (t) == MEM_REF)
   16024                 :             :                 {
   16025                 :          56 :                   decl_placeholder = build_decl (OMP_CLAUSE_LOCATION (c),
   16026                 :             :                                                  VAR_DECL, NULL_TREE, type);
   16027                 :          56 :                   OMP_CLAUSE_REDUCTION_DECL_PLACEHOLDER (c) = decl_placeholder;
   16028                 :          56 :                   DECL_ARTIFICIAL (decl_placeholder) = 1;
   16029                 :          56 :                   DECL_IGNORED_P (decl_placeholder) = 1;
   16030                 :             :                 }
   16031                 :         277 :               if (TREE_ADDRESSABLE (TREE_VEC_ELT (list, 0)))
   16032                 :          42 :                 c_mark_addressable (placeholder);
   16033                 :         277 :               if (TREE_ADDRESSABLE (TREE_VEC_ELT (list, 1)))
   16034                 :          76 :                 c_mark_addressable (decl_placeholder ? decl_placeholder
   16035                 :          34 :                                     : OMP_CLAUSE_DECL (c));
   16036                 :         277 :               OMP_CLAUSE_REDUCTION_MERGE (c)
   16037                 :         775 :                 = c_clone_omp_udr (TREE_VEC_ELT (list, 2),
   16038                 :         277 :                                    TREE_VEC_ELT (list, 0),
   16039                 :         277 :                                    TREE_VEC_ELT (list, 1),
   16040                 :             :                                    decl_placeholder ? decl_placeholder
   16041                 :         221 :                                    : OMP_CLAUSE_DECL (c), placeholder);
   16042                 :         277 :               OMP_CLAUSE_REDUCTION_MERGE (c)
   16043                 :         277 :                 = build3_loc (OMP_CLAUSE_LOCATION (c), BIND_EXPR,
   16044                 :             :                               void_type_node, NULL_TREE,
   16045                 :         277 :                               OMP_CLAUSE_REDUCTION_MERGE (c), NULL_TREE);
   16046                 :         277 :               TREE_SIDE_EFFECTS (OMP_CLAUSE_REDUCTION_MERGE (c)) = 1;
   16047                 :         277 :               if (TREE_VEC_LENGTH (list) == 6)
   16048                 :             :                 {
   16049                 :         233 :                   if (TREE_ADDRESSABLE (TREE_VEC_ELT (list, 3)))
   16050                 :          70 :                     c_mark_addressable (decl_placeholder ? decl_placeholder
   16051                 :          33 :                                         : OMP_CLAUSE_DECL (c));
   16052                 :         233 :                   if (TREE_ADDRESSABLE (TREE_VEC_ELT (list, 4)))
   16053                 :          27 :                     c_mark_addressable (placeholder);
   16054                 :         233 :                   tree init = TREE_VEC_ELT (list, 5);
   16055                 :         233 :                   if (init == error_mark_node)
   16056                 :         197 :                     init = DECL_INITIAL (TREE_VEC_ELT (list, 3));
   16057                 :         233 :                   OMP_CLAUSE_REDUCTION_INIT (c)
   16058                 :         651 :                     = c_clone_omp_udr (init, TREE_VEC_ELT (list, 4),
   16059                 :         233 :                                        TREE_VEC_ELT (list, 3),
   16060                 :             :                                        decl_placeholder ? decl_placeholder
   16061                 :         185 :                                        : OMP_CLAUSE_DECL (c), placeholder);
   16062                 :         233 :                   if (TREE_VEC_ELT (list, 5) == error_mark_node)
   16063                 :             :                     {
   16064                 :         197 :                       tree v = decl_placeholder ? decl_placeholder : t;
   16065                 :         197 :                       OMP_CLAUSE_REDUCTION_INIT (c)
   16066                 :         394 :                         = build2 (INIT_EXPR, TREE_TYPE (v), v,
   16067                 :         197 :                                   OMP_CLAUSE_REDUCTION_INIT (c));
   16068                 :             :                     }
   16069                 :         233 :                   if (walk_tree (&OMP_CLAUSE_REDUCTION_INIT (c),
   16070                 :             :                                  c_find_omp_placeholder_r,
   16071                 :             :                                  placeholder, NULL))
   16072                 :          28 :                     OMP_CLAUSE_REDUCTION_OMP_ORIG_REF (c) = 1;
   16073                 :             :                 }
   16074                 :             :               else
   16075                 :             :                 {
   16076                 :          44 :                   tree init;
   16077                 :          44 :                   tree v = decl_placeholder ? decl_placeholder : t;
   16078                 :          44 :                   if (AGGREGATE_TYPE_P (TREE_TYPE (v)))
   16079                 :          34 :                     init = build_constructor (TREE_TYPE (v), NULL);
   16080                 :             :                   else
   16081                 :          10 :                     init = fold_convert (TREE_TYPE (v), integer_zero_node);
   16082                 :          44 :                   OMP_CLAUSE_REDUCTION_INIT (c)
   16083                 :          88 :                     = build2 (INIT_EXPR, TREE_TYPE (v), v, init);
   16084                 :             :                 }
   16085                 :         277 :               OMP_CLAUSE_REDUCTION_INIT (c)
   16086                 :         277 :                 = build3_loc (OMP_CLAUSE_LOCATION (c), BIND_EXPR,
   16087                 :             :                               void_type_node, NULL_TREE,
   16088                 :         277 :                                OMP_CLAUSE_REDUCTION_INIT (c), NULL_TREE);
   16089                 :         277 :               TREE_SIDE_EFFECTS (OMP_CLAUSE_REDUCTION_INIT (c)) = 1;
   16090                 :             :             }
   16091                 :        3907 :           if (TREE_CODE (t) == MEM_REF)
   16092                 :             :             {
   16093                 :         607 :               if (TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (t))) == NULL_TREE
   16094                 :         607 :                   || TREE_CODE (TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (t))))
   16095                 :             :                      != INTEGER_CST)
   16096                 :             :                 {
   16097                 :           0 :                   sorry ("variable length element type in array "
   16098                 :             :                          "%<reduction%> clause");
   16099                 :           0 :                   remove = true;
   16100                 :           0 :                   break;
   16101                 :             :                 }
   16102                 :         607 :               t = TREE_OPERAND (t, 0);
   16103                 :         607 :               if (TREE_CODE (t) == POINTER_PLUS_EXPR)
   16104                 :         139 :                 t = TREE_OPERAND (t, 0);
   16105                 :         607 :               if (TREE_CODE (t) == ADDR_EXPR)
   16106                 :         367 :                 t = TREE_OPERAND (t, 0);
   16107                 :             :             }
   16108                 :        3907 :           goto check_dup_generic_t;
   16109                 :             : 
   16110                 :          24 :         case OMP_CLAUSE_COPYPRIVATE:
   16111                 :          24 :           copyprivate_seen = true;
   16112                 :          24 :           if (nowait_clause)
   16113                 :             :             {
   16114                 :           1 :               error_at (OMP_CLAUSE_LOCATION (*nowait_clause),
   16115                 :             :                         "%<nowait%> clause must not be used together "
   16116                 :             :                         "with %<copyprivate%> clause");
   16117                 :           1 :               *nowait_clause = OMP_CLAUSE_CHAIN (*nowait_clause);
   16118                 :           1 :               nowait_clause = NULL;
   16119                 :             :             }
   16120                 :          24 :           goto check_dup_generic;
   16121                 :             : 
   16122                 :          99 :         case OMP_CLAUSE_COPYIN:
   16123                 :          99 :           t = OMP_CLAUSE_DECL (c);
   16124                 :          99 :           if (!VAR_P (t) || !DECL_THREAD_LOCAL_P (t))
   16125                 :             :             {
   16126                 :           5 :               error_at (OMP_CLAUSE_LOCATION (c),
   16127                 :             :                         "%qE must be %<threadprivate%> for %<copyin%>", t);
   16128                 :           5 :               remove = true;
   16129                 :           5 :               break;
   16130                 :             :             }
   16131                 :          94 :           goto check_dup_generic;
   16132                 :             : 
   16133                 :         478 :         case OMP_CLAUSE_LINEAR:
   16134                 :         478 :           if (ort != C_ORT_OMP_DECLARE_SIMD)
   16135                 :         327 :             need_implicitly_determined = true;
   16136                 :         478 :           t = OMP_CLAUSE_DECL (c);
   16137                 :         478 :           if (ort != C_ORT_OMP_DECLARE_SIMD
   16138                 :         327 :               && OMP_CLAUSE_LINEAR_KIND (c) != OMP_CLAUSE_LINEAR_DEFAULT
   16139                 :         483 :               && OMP_CLAUSE_LINEAR_OLD_LINEAR_MODIFIER (c))
   16140                 :             :             {
   16141                 :           5 :               error_at (OMP_CLAUSE_LOCATION (c),
   16142                 :             :                         "modifier should not be specified in %<linear%> "
   16143                 :             :                         "clause on %<simd%> or %<for%> constructs when not "
   16144                 :             :                         "using OpenMP 5.2 modifiers");
   16145                 :           5 :               OMP_CLAUSE_LINEAR_KIND (c) = OMP_CLAUSE_LINEAR_DEFAULT;
   16146                 :             :             }
   16147                 :         956 :           if (!INTEGRAL_TYPE_P (TREE_TYPE (t))
   16148                 :         501 :               && TREE_CODE (TREE_TYPE (t)) != POINTER_TYPE)
   16149                 :             :             {
   16150                 :           1 :               error_at (OMP_CLAUSE_LOCATION (c),
   16151                 :             :                         "linear clause applied to non-integral non-pointer "
   16152                 :           1 :                         "variable with type %qT", TREE_TYPE (t));
   16153                 :           1 :               remove = true;
   16154                 :           1 :               break;
   16155                 :             :             }
   16156                 :         477 :           if (TYPE_ATOMIC (TREE_TYPE (t)))
   16157                 :             :             {
   16158                 :           3 :               error_at (OMP_CLAUSE_LOCATION (c),
   16159                 :             :                         "%<_Atomic%> %qD in %<linear%> clause", t);
   16160                 :           3 :               remove = true;
   16161                 :           3 :               break;
   16162                 :             :             }
   16163                 :         474 :           if (ort == C_ORT_OMP_DECLARE_SIMD)
   16164                 :             :             {
   16165                 :         150 :               tree s = OMP_CLAUSE_LINEAR_STEP (c);
   16166                 :         150 :               if (TREE_CODE (s) == PARM_DECL)
   16167                 :             :                 {
   16168                 :           9 :                   OMP_CLAUSE_LINEAR_VARIABLE_STRIDE (c) = 1;
   16169                 :             :                   /* map_head bitmap is used as uniform_head if
   16170                 :             :                      declare_simd.  */
   16171                 :           9 :                   if (!bitmap_bit_p (&map_head, DECL_UID (s)))
   16172                 :           5 :                     linear_variable_step_check = true;
   16173                 :           9 :                   goto check_dup_generic;
   16174                 :             :                 }
   16175                 :         141 :               if (TREE_CODE (s) != INTEGER_CST)
   16176                 :             :                 {
   16177                 :           7 :                   error_at (OMP_CLAUSE_LOCATION (c),
   16178                 :             :                             "%<linear%> clause step %qE is neither constant "
   16179                 :             :                             "nor a parameter", s);
   16180                 :           7 :                   remove = true;
   16181                 :           7 :                   break;
   16182                 :             :                 }
   16183                 :             :             }
   16184                 :         458 :           if (TREE_CODE (TREE_TYPE (OMP_CLAUSE_DECL (c))) == POINTER_TYPE)
   16185                 :             :             {
   16186                 :          20 :               tree s = OMP_CLAUSE_LINEAR_STEP (c);
   16187                 :          20 :               s = pointer_int_sum (OMP_CLAUSE_LOCATION (c), PLUS_EXPR,
   16188                 :          20 :                                    OMP_CLAUSE_DECL (c), s);
   16189                 :          20 :               s = fold_build2_loc (OMP_CLAUSE_LOCATION (c), MINUS_EXPR,
   16190                 :             :                                    sizetype, fold_convert (sizetype, s),
   16191                 :          20 :                                    fold_convert
   16192                 :             :                                      (sizetype, OMP_CLAUSE_DECL (c)));
   16193                 :          20 :               if (s == error_mark_node)
   16194                 :           0 :                 s = size_one_node;
   16195                 :          20 :               OMP_CLAUSE_LINEAR_STEP (c) = s;
   16196                 :             :             }
   16197                 :             :           else
   16198                 :         438 :             OMP_CLAUSE_LINEAR_STEP (c)
   16199                 :         876 :               = fold_convert (TREE_TYPE (t), OMP_CLAUSE_LINEAR_STEP (c));
   16200                 :         458 :           goto check_dup_generic;
   16201                 :             : 
   16202                 :        2847 :         check_dup_generic:
   16203                 :        2847 :           t = OMP_CLAUSE_DECL (c);
   16204                 :        6842 :         check_dup_generic_t:
   16205                 :        6842 :           if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL)
   16206                 :             :             {
   16207                 :           4 :               error_at (OMP_CLAUSE_LOCATION (c),
   16208                 :             :                         "%qE is not a variable in clause %qs", t,
   16209                 :           2 :                         omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   16210                 :           2 :               remove = true;
   16211                 :             :             }
   16212                 :         914 :           else if ((openacc && OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION)
   16213                 :        6032 :                    || (ort == C_ORT_OMP
   16214                 :        5334 :                        && (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_USE_DEVICE_PTR
   16215                 :        5323 :                            || (OMP_CLAUSE_CODE (c)
   16216                 :             :                                == OMP_CLAUSE_USE_DEVICE_ADDR)))
   16217                 :       12825 :                    || (ort == C_ORT_OMP_TARGET
   16218                 :         332 :                        && OMP_CLAUSE_CODE (c) == OMP_CLAUSE_IN_REDUCTION))
   16219                 :             :             {
   16220                 :         965 :               if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_IN_REDUCTION
   16221                 :         965 :                   && (bitmap_bit_p (&generic_head, DECL_UID (t))
   16222                 :         109 :                       || bitmap_bit_p (&firstprivate_head, DECL_UID (t))))
   16223                 :             :                 {
   16224                 :           2 :                   error_at (OMP_CLAUSE_LOCATION (c),
   16225                 :             :                             "%qD appears more than once in data-sharing "
   16226                 :             :                             "clauses", t);
   16227                 :           2 :                   remove = true;
   16228                 :           2 :                   break;
   16229                 :             :                 }
   16230                 :         963 :               if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_IN_REDUCTION)
   16231                 :         108 :                 target_in_reduction_seen = true;
   16232                 :         963 :               if (bitmap_bit_p (&oacc_reduction_head, DECL_UID (t)))
   16233                 :             :                 {
   16234                 :           4 :                   error_at (OMP_CLAUSE_LOCATION (c),
   16235                 :             :                             openacc
   16236                 :             :                             ? "%qD appears more than once in reduction clauses"
   16237                 :             :                             : "%qD appears more than once in data clauses",
   16238                 :             :                             t);
   16239                 :           2 :                   remove = true;
   16240                 :             :                 }
   16241                 :             :               else
   16242                 :         961 :                 bitmap_set_bit (&oacc_reduction_head, DECL_UID (t));
   16243                 :             :             }
   16244                 :        5875 :           else if (bitmap_bit_p (&generic_head, DECL_UID (t))
   16245                 :        5853 :                    || bitmap_bit_p (&firstprivate_head, DECL_UID (t))
   16246                 :        5852 :                    || bitmap_bit_p (&lastprivate_head, DECL_UID (t))
   16247                 :       11727 :                    || bitmap_bit_p (&map_firstprivate_head, DECL_UID (t)))
   16248                 :             :             {
   16249                 :          23 :               error_at (OMP_CLAUSE_LOCATION (c),
   16250                 :             :                         "%qE appears more than once in data clauses", t);
   16251                 :          23 :               remove = true;
   16252                 :             :             }
   16253                 :        5852 :           else if ((OMP_CLAUSE_CODE (c) == OMP_CLAUSE_PRIVATE
   16254                 :             :                     || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_HAS_DEVICE_ADDR
   16255                 :             :                     || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_IS_DEVICE_PTR)
   16256                 :        1011 :                    && bitmap_bit_p (&map_head, DECL_UID (t)))
   16257                 :             :             {
   16258                 :           3 :               if (openacc)
   16259                 :           0 :                 error_at (OMP_CLAUSE_LOCATION (c),
   16260                 :             :                           "%qD appears more than once in data clauses", t);
   16261                 :             :               else
   16262                 :           3 :                 error_at (OMP_CLAUSE_LOCATION (c),
   16263                 :             :                           "%qD appears both in data and map clauses", t);
   16264                 :             :               remove = true;
   16265                 :             :             }
   16266                 :             :           else
   16267                 :        5849 :             bitmap_set_bit (&generic_head, DECL_UID (t));
   16268                 :             :           break;
   16269                 :             : 
   16270                 :        1310 :         case OMP_CLAUSE_FIRSTPRIVATE:
   16271                 :        1310 :           if (OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT (c) && !implicit_moved)
   16272                 :             :             {
   16273                 :         186 :             move_implicit:
   16274                 :         186 :               implicit_moved = true;
   16275                 :             :               /* Move firstprivate and map clauses with
   16276                 :             :                  OMP_CLAUSE_{FIRSTPRIVATE,MAP}_IMPLICIT set to the end of
   16277                 :             :                  clauses chain.  */
   16278                 :         186 :               tree cl1 = NULL_TREE, cl2 = NULL_TREE;
   16279                 :         186 :               tree *pc1 = pc, *pc2 = &cl1, *pc3 = &cl2;
   16280                 :        1072 :               while (*pc1)
   16281                 :         886 :                 if (OMP_CLAUSE_CODE (*pc1) == OMP_CLAUSE_FIRSTPRIVATE
   16282                 :         886 :                     && OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT (*pc1))
   16283                 :             :                   {
   16284                 :         113 :                     *pc3 = *pc1;
   16285                 :         113 :                     pc3 = &OMP_CLAUSE_CHAIN (*pc3);
   16286                 :         113 :                     *pc1 = OMP_CLAUSE_CHAIN (*pc1);
   16287                 :             :                   }
   16288                 :         773 :                 else if (OMP_CLAUSE_CODE (*pc1) == OMP_CLAUSE_MAP
   16289                 :         773 :                          && OMP_CLAUSE_MAP_IMPLICIT (*pc1))
   16290                 :             :                   {
   16291                 :         164 :                     *pc2 = *pc1;
   16292                 :         164 :                     pc2 = &OMP_CLAUSE_CHAIN (*pc2);
   16293                 :         164 :                     *pc1 = OMP_CLAUSE_CHAIN (*pc1);
   16294                 :             :                   }
   16295                 :             :                 else
   16296                 :         609 :                   pc1 = &OMP_CLAUSE_CHAIN (*pc1);
   16297                 :         186 :               *pc3 = NULL;
   16298                 :         186 :               *pc2 = cl2;
   16299                 :         186 :               *pc1 = cl1;
   16300                 :         186 :               continue;
   16301                 :         186 :             }
   16302                 :        1215 :           t = OMP_CLAUSE_DECL (c);
   16303                 :        1215 :           need_complete = true;
   16304                 :        1215 :           need_implicitly_determined = true;
   16305                 :        1215 :           if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL)
   16306                 :             :             {
   16307                 :           1 :               error_at (OMP_CLAUSE_LOCATION (c),
   16308                 :             :                         "%qE is not a variable in clause %<firstprivate%>", t);
   16309                 :           1 :               remove = true;
   16310                 :             :             }
   16311                 :        1214 :           else if (OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT (c)
   16312                 :         113 :                    && !OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT_TARGET (c)
   16313                 :        1320 :                    && bitmap_bit_p (&map_firstprivate_head, DECL_UID (t)))
   16314                 :             :             remove = true;
   16315                 :        1214 :           else if (bitmap_bit_p (&generic_head, DECL_UID (t))
   16316                 :        1212 :                    || bitmap_bit_p (&firstprivate_head, DECL_UID (t))
   16317                 :        2425 :                    || bitmap_bit_p (&map_firstprivate_head, DECL_UID (t)))
   16318                 :             :             {
   16319                 :           4 :               error_at (OMP_CLAUSE_LOCATION (c),
   16320                 :             :                         "%qE appears more than once in data clauses", t);
   16321                 :           4 :               remove = true;
   16322                 :             :             }
   16323                 :        1210 :           else if (bitmap_bit_p (&map_head, DECL_UID (t))
   16324                 :        1210 :                    || bitmap_bit_p (&map_field_head, DECL_UID (t)))
   16325                 :             :             {
   16326                 :           7 :               if (openacc)
   16327                 :           0 :                 error_at (OMP_CLAUSE_LOCATION (c),
   16328                 :             :                           "%qD appears more than once in data clauses", t);
   16329                 :           7 :               else if (OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT (c)
   16330                 :           7 :                        && !OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT_TARGET (c))
   16331                 :             :                 /* Silently drop the clause.  */;
   16332                 :             :               else
   16333                 :           6 :                 error_at (OMP_CLAUSE_LOCATION (c),
   16334                 :             :                           "%qD appears both in data and map clauses", t);
   16335                 :             :               remove = true;
   16336                 :             :             }
   16337                 :             :           else
   16338                 :        1203 :             bitmap_set_bit (&firstprivate_head, DECL_UID (t));
   16339                 :             :           break;
   16340                 :             : 
   16341                 :        1522 :         case OMP_CLAUSE_LASTPRIVATE:
   16342                 :        1522 :           t = OMP_CLAUSE_DECL (c);
   16343                 :        1522 :           need_complete = true;
   16344                 :        1522 :           need_implicitly_determined = true;
   16345                 :        1522 :           if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL)
   16346                 :             :             {
   16347                 :           0 :               error_at (OMP_CLAUSE_LOCATION (c),
   16348                 :             :                         "%qE is not a variable in clause %<lastprivate%>", t);
   16349                 :           0 :               remove = true;
   16350                 :             :             }
   16351                 :        1522 :           else if (bitmap_bit_p (&generic_head, DECL_UID (t))
   16352                 :        1522 :                    || bitmap_bit_p (&lastprivate_head, DECL_UID (t)))
   16353                 :             :             {
   16354                 :           3 :               error_at (OMP_CLAUSE_LOCATION (c),
   16355                 :             :                      "%qE appears more than once in data clauses", t);
   16356                 :           3 :               remove = true;
   16357                 :             :             }
   16358                 :             :           else
   16359                 :        1519 :             bitmap_set_bit (&lastprivate_head, DECL_UID (t));
   16360                 :             :           break;
   16361                 :             : 
   16362                 :         253 :         case OMP_CLAUSE_ALIGNED:
   16363                 :         253 :           t = OMP_CLAUSE_DECL (c);
   16364                 :         253 :           if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL)
   16365                 :             :             {
   16366                 :           0 :               error_at (OMP_CLAUSE_LOCATION (c),
   16367                 :             :                         "%qE is not a variable in %<aligned%> clause", t);
   16368                 :           0 :               remove = true;
   16369                 :             :             }
   16370                 :         289 :           else if (!POINTER_TYPE_P (TREE_TYPE (t))
   16371                 :         289 :                    && TREE_CODE (TREE_TYPE (t)) != ARRAY_TYPE)
   16372                 :             :             {
   16373                 :           7 :               error_at (OMP_CLAUSE_LOCATION (c),
   16374                 :             :                         "%qE in %<aligned%> clause is neither a pointer nor "
   16375                 :             :                         "an array", t);
   16376                 :           7 :               remove = true;
   16377                 :             :             }
   16378                 :         246 :           else if (TYPE_ATOMIC (TREE_TYPE (t)))
   16379                 :             :             {
   16380                 :           1 :               error_at (OMP_CLAUSE_LOCATION (c),
   16381                 :             :                         "%<_Atomic%> %qD in %<aligned%> clause", t);
   16382                 :           1 :               remove = true;
   16383                 :           1 :               break;
   16384                 :             :             }
   16385                 :         245 :           else if (bitmap_bit_p (&aligned_head, DECL_UID (t)))
   16386                 :             :             {
   16387                 :           0 :               error_at (OMP_CLAUSE_LOCATION (c),
   16388                 :             :                         "%qE appears more than once in %<aligned%> clauses",
   16389                 :             :                         t);
   16390                 :           0 :               remove = true;
   16391                 :             :             }
   16392                 :             :           else
   16393                 :         245 :             bitmap_set_bit (&aligned_head, DECL_UID (t));
   16394                 :             :           break;
   16395                 :             : 
   16396                 :         125 :         case OMP_CLAUSE_NONTEMPORAL:
   16397                 :         125 :           t = OMP_CLAUSE_DECL (c);
   16398                 :         125 :           if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL)
   16399                 :             :             {
   16400                 :           0 :               error_at (OMP_CLAUSE_LOCATION (c),
   16401                 :             :                         "%qE is not a variable in %<nontemporal%> clause", t);
   16402                 :           0 :               remove = true;
   16403                 :             :             }
   16404                 :         125 :           else if (bitmap_bit_p (&oacc_reduction_head, DECL_UID (t)))
   16405                 :             :             {
   16406                 :           2 :               error_at (OMP_CLAUSE_LOCATION (c),
   16407                 :             :                         "%qE appears more than once in %<nontemporal%> "
   16408                 :             :                         "clauses", t);
   16409                 :           2 :               remove = true;
   16410                 :             :             }
   16411                 :             :           else
   16412                 :         123 :             bitmap_set_bit (&oacc_reduction_head, DECL_UID (t));
   16413                 :             :           break;
   16414                 :             : 
   16415                 :         786 :         case OMP_CLAUSE_ALLOCATE:
   16416                 :         786 :           t = OMP_CLAUSE_DECL (c);
   16417                 :         786 :           if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL)
   16418                 :             :             {
   16419                 :           1 :               error_at (OMP_CLAUSE_LOCATION (c),
   16420                 :             :                         "%qE is not a variable in %<allocate%> clause", t);
   16421                 :           1 :               remove = true;
   16422                 :             :             }
   16423                 :         785 :           else if (bitmap_bit_p (&aligned_head, DECL_UID (t)))
   16424                 :             :             {
   16425                 :           2 :               warning_at (OMP_CLAUSE_LOCATION (c), OPT_Wopenmp,
   16426                 :             :                           "%qE appears more than once in %<allocate%> clauses",
   16427                 :             :                           t);
   16428                 :           2 :               remove = true;
   16429                 :             :             }
   16430                 :             :           else
   16431                 :             :             {
   16432                 :         783 :               bitmap_set_bit (&aligned_head, DECL_UID (t));
   16433                 :         783 :               if (!OMP_CLAUSE_ALLOCATE_COMBINED (c))
   16434                 :         684 :                 allocate_seen = true;
   16435                 :             :             }
   16436                 :             :           break;
   16437                 :             : 
   16438                 :         355 :         case OMP_CLAUSE_DOACROSS:
   16439                 :         355 :           t = OMP_CLAUSE_DECL (c);
   16440                 :         355 :           if (t == NULL_TREE)
   16441                 :             :             break;
   16442                 :         168 :           if (OMP_CLAUSE_DOACROSS_KIND (c) == OMP_CLAUSE_DOACROSS_SINK)
   16443                 :             :             {
   16444                 :         168 :               gcc_assert (TREE_CODE (t) == TREE_LIST);
   16445                 :        1313 :               for (; t; t = TREE_CHAIN (t))
   16446                 :             :                 {
   16447                 :        1145 :                   tree decl = TREE_VALUE (t);
   16448                 :        1145 :                   if (TREE_CODE (TREE_TYPE (decl)) == POINTER_TYPE)
   16449                 :             :                     {
   16450                 :           3 :                       tree offset = TREE_PURPOSE (t);
   16451                 :           3 :                       bool neg = wi::neg_p (wi::to_wide (offset));
   16452                 :           3 :                       offset = fold_unary (ABS_EXPR, TREE_TYPE (offset), offset);
   16453                 :           6 :                       tree t2 = pointer_int_sum (OMP_CLAUSE_LOCATION (c),
   16454                 :             :                                                  neg ? MINUS_EXPR : PLUS_EXPR,
   16455                 :             :                                                  decl, offset);
   16456                 :           3 :                       t2 = fold_build2_loc (OMP_CLAUSE_LOCATION (c), MINUS_EXPR,
   16457                 :             :                                             sizetype,
   16458                 :             :                                             fold_convert (sizetype, t2),
   16459                 :             :                                             fold_convert (sizetype, decl));
   16460                 :           3 :                       if (t2 == error_mark_node)
   16461                 :             :                         {
   16462                 :             :                           remove = true;
   16463                 :             :                           break;
   16464                 :             :                         }
   16465                 :           3 :                       TREE_PURPOSE (t) = t2;
   16466                 :             :                     }
   16467                 :             :                 }
   16468                 :             :               break;
   16469                 :             :             }
   16470                 :           0 :           gcc_unreachable ();
   16471                 :         699 :         case OMP_CLAUSE_DEPEND:
   16472                 :         699 :           depend_clause = c;
   16473                 :             :           /* FALLTHRU */
   16474                 :         856 :         case OMP_CLAUSE_AFFINITY:
   16475                 :         856 :           t = OMP_CLAUSE_DECL (c);
   16476                 :         856 :           if (TREE_CODE (t) == TREE_LIST
   16477                 :         131 :               && TREE_PURPOSE (t)
   16478                 :         987 :               && TREE_CODE (TREE_PURPOSE (t)) == TREE_VEC)
   16479                 :             :             {
   16480                 :         131 :               if (TREE_PURPOSE (t) != last_iterators)
   16481                 :         111 :                 last_iterators_remove
   16482                 :         111 :                   = c_omp_finish_iterators (TREE_PURPOSE (t));
   16483                 :         131 :               last_iterators = TREE_PURPOSE (t);
   16484                 :         131 :               t = TREE_VALUE (t);
   16485                 :         131 :               if (last_iterators_remove)
   16486                 :          34 :                 t = error_mark_node;
   16487                 :             :             }
   16488                 :             :           else
   16489                 :             :             last_iterators = NULL_TREE;
   16490                 :         856 :           if (TREE_CODE (t) == OMP_ARRAY_SECTION)
   16491                 :             :             {
   16492                 :         407 :               if (handle_omp_array_sections (c, ort))
   16493                 :             :                 remove = true;
   16494                 :         330 :               else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND
   16495                 :         330 :                        && OMP_CLAUSE_DEPEND_KIND (c) == OMP_CLAUSE_DEPEND_DEPOBJ)
   16496                 :             :                 {
   16497                 :           1 :                   error_at (OMP_CLAUSE_LOCATION (c),
   16498                 :             :                             "%<depend%> clause with %<depobj%> dependence "
   16499                 :             :                             "type on array section");
   16500                 :           1 :                   remove = true;
   16501                 :             :                 }
   16502                 :             :               break;
   16503                 :             :             }
   16504                 :         449 :           if (t == error_mark_node)
   16505                 :             :             remove = true;
   16506                 :         415 :           else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND
   16507                 :         415 :                    && t == ridpointers[RID_OMP_ALL_MEMORY])
   16508                 :             :             {
   16509                 :          15 :               if (OMP_CLAUSE_DEPEND_KIND (c) != OMP_CLAUSE_DEPEND_OUT
   16510                 :          15 :                   && OMP_CLAUSE_DEPEND_KIND (c) != OMP_CLAUSE_DEPEND_INOUT)
   16511                 :             :                 {
   16512                 :           3 :                   error_at (OMP_CLAUSE_LOCATION (c),
   16513                 :             :                             "%<omp_all_memory%> used with %<depend%> kind "
   16514                 :             :                             "other than %<out%> or %<inout%>");
   16515                 :           3 :                   remove = true;
   16516                 :             :                 }
   16517                 :             :             }
   16518                 :         400 :           else if (!lvalue_p (t))
   16519                 :             :             {
   16520                 :           6 :               error_at (OMP_CLAUSE_LOCATION (c),
   16521                 :             :                         "%qE is not lvalue expression nor array section in "
   16522                 :             :                         "%qs clause", t,
   16523                 :           3 :                         omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   16524                 :           3 :               remove = true;
   16525                 :             :             }
   16526                 :         397 :           else if (TREE_CODE (t) == COMPONENT_REF
   16527                 :         397 :                    && DECL_C_BIT_FIELD (TREE_OPERAND (t, 1)))
   16528                 :             :             {
   16529                 :           2 :               gcc_assert (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND
   16530                 :             :                           || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_AFFINITY);
   16531                 :           2 :               error_at (OMP_CLAUSE_LOCATION (c),
   16532                 :             :                         "bit-field %qE in %qs clause", t,
   16533                 :           2 :                         omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   16534                 :           2 :               remove = true;
   16535                 :             :             }
   16536                 :         395 :           else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND
   16537                 :         395 :                    && OMP_CLAUSE_DEPEND_KIND (c) == OMP_CLAUSE_DEPEND_DEPOBJ)
   16538                 :             :             {
   16539                 :          17 :               if (!c_omp_depend_t_p (TREE_TYPE (t)))
   16540                 :             :                 {
   16541                 :           2 :                   error_at (OMP_CLAUSE_LOCATION (c),
   16542                 :             :                             "%qE does not have %<omp_depend_t%> type in "
   16543                 :             :                             "%<depend%> clause with %<depobj%> dependence "
   16544                 :             :                             "type", t);
   16545                 :           2 :                   remove = true;
   16546                 :             :                 }
   16547                 :             :             }
   16548                 :         378 :           else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND
   16549                 :         378 :                    && c_omp_depend_t_p (TREE_TYPE (t)))
   16550                 :             :             {
   16551                 :           2 :               error_at (OMP_CLAUSE_LOCATION (c),
   16552                 :             :                         "%qE should not have %<omp_depend_t%> type in "
   16553                 :             :                         "%<depend%> clause with dependence type other than "
   16554                 :             :                         "%<depobj%>", t);
   16555                 :           2 :               remove = true;
   16556                 :             :             }
   16557                 :          12 :           if (!remove)
   16558                 :             :             {
   16559                 :         403 :               if (t == ridpointers[RID_OMP_ALL_MEMORY])
   16560                 :          12 :                 t = null_pointer_node;
   16561                 :             :               else
   16562                 :             :                 {
   16563                 :         391 :                   tree addr = build_unary_op (OMP_CLAUSE_LOCATION (c),
   16564                 :             :                                               ADDR_EXPR, t, false);
   16565                 :         391 :                   if (addr == error_mark_node)
   16566                 :             :                     {
   16567                 :             :                       remove = true;
   16568                 :             :                       break;
   16569                 :             :                     }
   16570                 :         391 :                   t = build_indirect_ref (OMP_CLAUSE_LOCATION (c), addr,
   16571                 :             :                                           RO_UNARY_STAR);
   16572                 :         391 :                   if (t == error_mark_node)
   16573                 :             :                     {
   16574                 :             :                       remove = true;
   16575                 :             :                       break;
   16576                 :             :                     }
   16577                 :             :                 }
   16578                 :         403 :               if (TREE_CODE (OMP_CLAUSE_DECL (c)) == TREE_LIST
   16579                 :          31 :                   && TREE_PURPOSE (OMP_CLAUSE_DECL (c))
   16580                 :         434 :                   && (TREE_CODE (TREE_PURPOSE (OMP_CLAUSE_DECL (c)))
   16581                 :             :                       == TREE_VEC))
   16582                 :          31 :                 TREE_VALUE (OMP_CLAUSE_DECL (c)) = t;
   16583                 :             :               else
   16584                 :         372 :                 OMP_CLAUSE_DECL (c) = t;
   16585                 :             :             }
   16586                 :             :           break;
   16587                 :             : 
   16588                 :        6079 :         case OMP_CLAUSE_MAP:
   16589                 :        6079 :           if (OMP_CLAUSE_MAP_IMPLICIT (c) && !implicit_moved)
   16590                 :          91 :             goto move_implicit;
   16591                 :             :           /* FALLTHRU */
   16592                 :        8971 :         case OMP_CLAUSE_TO:
   16593                 :        8971 :         case OMP_CLAUSE_FROM:
   16594                 :        8971 :         case OMP_CLAUSE__CACHE_:
   16595                 :        8971 :           {
   16596                 :        8971 :             using namespace omp_addr_tokenizer;
   16597                 :        8971 :             auto_vec<omp_addr_token *, 10> addr_tokens;
   16598                 :             : 
   16599                 :        8971 :             t = OMP_CLAUSE_DECL (c);
   16600                 :        8971 :             if (TREE_CODE (t) == OMP_ARRAY_SECTION)
   16601                 :             :               {
   16602                 :        1866 :                 grp_start_p = pc;
   16603                 :        1866 :                 grp_sentinel = OMP_CLAUSE_CHAIN (c);
   16604                 :             : 
   16605                 :        1866 :                 if (handle_omp_array_sections (c, ort))
   16606                 :             :                   remove = true;
   16607                 :             :                 else
   16608                 :             :                   {
   16609                 :        1727 :                     t = OMP_CLAUSE_DECL (c);
   16610                 :        1727 :                     if (!omp_mappable_type (TREE_TYPE (t)))
   16611                 :             :                       {
   16612                 :           2 :                         error_at (OMP_CLAUSE_LOCATION (c),
   16613                 :             :                                   "array section does not have mappable type "
   16614                 :             :                                   "in %qs clause",
   16615                 :           1 :                                   omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   16616                 :           1 :                         remove = true;
   16617                 :             :                       }
   16618                 :        1726 :                     else if (TYPE_ATOMIC (TREE_TYPE (t)))
   16619                 :             :                       {
   16620                 :           2 :                         error_at (OMP_CLAUSE_LOCATION (c),
   16621                 :             :                                   "%<_Atomic%> %qE in %qs clause", t,
   16622                 :           1 :                                   omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   16623                 :           1 :                         remove = true;
   16624                 :             :                       }
   16625                 :        2361 :                     while (TREE_CODE (t) == ARRAY_REF)
   16626                 :         634 :                       t = TREE_OPERAND (t, 0);
   16627                 :             : 
   16628                 :        1727 :                     c_omp_address_inspector ai (OMP_CLAUSE_LOCATION (c), t);
   16629                 :             : 
   16630                 :        1727 :                     if (!omp_parse_expr (addr_tokens, t))
   16631                 :             :                       {
   16632                 :           0 :                         sorry_at (OMP_CLAUSE_LOCATION (c),
   16633                 :             :                                   "unsupported map expression %qE",
   16634                 :           0 :                                   OMP_CLAUSE_DECL (c));
   16635                 :           0 :                         remove = true;
   16636                 :           0 :                         break;
   16637                 :             :                       }
   16638                 :             : 
   16639                 :             :                     /* This check is to determine if this will be the only map
   16640                 :             :                        node created for this clause.  Otherwise, we'll check
   16641                 :             :                        the following FIRSTPRIVATE_POINTER or ATTACH_DETACH
   16642                 :             :                        node on the next iteration(s) of the loop.   */
   16643                 :        3436 :                     if (addr_tokens.length () >= 4
   16644                 :         247 :                         && addr_tokens[0]->type == STRUCTURE_BASE
   16645                 :         247 :                         && addr_tokens[0]->u.structure_base_kind == BASE_DECL
   16646                 :         247 :                         && addr_tokens[1]->type == ACCESS_METHOD
   16647                 :         247 :                         && addr_tokens[2]->type == COMPONENT_SELECTOR
   16648                 :         247 :                         && addr_tokens[3]->type == ACCESS_METHOD
   16649                 :        1917 :                         && (addr_tokens[3]->u.access_kind == ACCESS_DIRECT
   16650                 :         138 :                             || (addr_tokens[3]->u.access_kind
   16651                 :             :                                 == ACCESS_INDEXED_ARRAY)))
   16652                 :             :                       {
   16653                 :          54 :                         tree rt = addr_tokens[1]->expr;
   16654                 :             : 
   16655                 :          54 :                         gcc_assert (DECL_P (rt));
   16656                 :             : 
   16657                 :          54 :                         if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP
   16658                 :          49 :                             && OMP_CLAUSE_MAP_IMPLICIT (c)
   16659                 :          54 :                             && (bitmap_bit_p (&map_head, DECL_UID (rt))
   16660                 :           0 :                                 || bitmap_bit_p (&map_field_head, DECL_UID (rt))
   16661                 :           0 :                                 || bitmap_bit_p (&map_firstprivate_head,
   16662                 :           0 :                                                  DECL_UID (rt))))
   16663                 :             :                           {
   16664                 :             :                             remove = true;
   16665                 :             :                             break;
   16666                 :             :                           }
   16667                 :          54 :                         if (bitmap_bit_p (&map_field_head, DECL_UID (rt)))
   16668                 :             :                           break;
   16669                 :          36 :                         if (bitmap_bit_p (&map_head, DECL_UID (rt)))
   16670                 :             :                           {
   16671                 :           0 :                             if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_MAP)
   16672                 :           0 :                               error_at (OMP_CLAUSE_LOCATION (c),
   16673                 :             :                                         "%qD appears more than once in motion "
   16674                 :             :                                         "clauses", rt);
   16675                 :           0 :                             else if (openacc)
   16676                 :           0 :                               error_at (OMP_CLAUSE_LOCATION (c),
   16677                 :             :                                         "%qD appears more than once in data "
   16678                 :             :                                         "clauses", rt);
   16679                 :             :                             else
   16680                 :           0 :                               error_at (OMP_CLAUSE_LOCATION (c),
   16681                 :             :                                         "%qD appears more than once in map "
   16682                 :             :                                         "clauses", rt);
   16683                 :             :                             remove = true;
   16684                 :             :                           }
   16685                 :             :                         else
   16686                 :             :                           {
   16687                 :          36 :                             bitmap_set_bit (&map_head, DECL_UID (rt));
   16688                 :          36 :                             bitmap_set_bit (&map_field_head, DECL_UID (rt));
   16689                 :             :                           }
   16690                 :             :                       }
   16691                 :        1727 :                   }
   16692                 :        1848 :                 if (c_oacc_check_attachments (c))
   16693                 :           2 :                   remove = true;
   16694                 :        1848 :                 if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP
   16695                 :        1684 :                     && (OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_ATTACH
   16696                 :        1673 :                         || OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_DETACH)
   16697                 :        1866 :                     && !OMP_CLAUSE_SIZE (c))
   16698                 :             :                   /* In this case, we have a single array element which is a
   16699                 :             :                      pointer, and we already set OMP_CLAUSE_SIZE in
   16700                 :             :                      handle_omp_array_sections above.  For attach/detach
   16701                 :             :                      clauses, reset the OMP_CLAUSE_SIZE (representing a bias)
   16702                 :             :                      to zero here.  */
   16703                 :          10 :                   OMP_CLAUSE_SIZE (c) = size_zero_node;
   16704                 :             :                 break;
   16705                 :             :               }
   16706                 :        7105 :             else if (!omp_parse_expr (addr_tokens, t))
   16707                 :             :               {
   16708                 :           0 :                 sorry_at (OMP_CLAUSE_LOCATION (c),
   16709                 :             :                           "unsupported map expression %qE",
   16710                 :           0 :                           OMP_CLAUSE_DECL (c));
   16711                 :           0 :                 remove = true;
   16712                 :           0 :                 break;
   16713                 :             :               }
   16714                 :        7105 :             if (t == error_mark_node)
   16715                 :             :               {
   16716                 :             :                 remove = true;
   16717                 :             :                 break;
   16718                 :             :               }
   16719                 :             :             /* OpenACC attach / detach clauses must be pointers.  */
   16720                 :        7099 :             if (c_oacc_check_attachments (c))
   16721                 :             :               {
   16722                 :             :                 remove = true;
   16723                 :             :                 break;
   16724                 :             :               }
   16725                 :        7095 :             if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP
   16726                 :        4278 :                 && (OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_ATTACH
   16727                 :        4257 :                     || OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_DETACH)
   16728                 :        7127 :                 && !OMP_CLAUSE_SIZE (c))
   16729                 :             :               /* For attach/detach clauses, set OMP_CLAUSE_SIZE (representing a
   16730                 :             :                  bias) to zero here, so it is not set erroneously to the pointer
   16731                 :             :                  size later on in gimplify.cc.  */
   16732                 :          28 :               OMP_CLAUSE_SIZE (c) = size_zero_node;
   16733                 :             : 
   16734                 :        7095 :             c_omp_address_inspector ai (OMP_CLAUSE_LOCATION (c), t);
   16735                 :             : 
   16736                 :        7095 :             if (!ai.check_clause (c))
   16737                 :             :               {
   16738                 :             :                 remove = true;
   16739                 :             :                 break;
   16740                 :             :               }
   16741                 :             : 
   16742                 :        7087 :             if (!ai.map_supported_p ())
   16743                 :             :               {
   16744                 :          10 :                 sorry_at (OMP_CLAUSE_LOCATION (c),
   16745                 :             :                           "unsupported map expression %qE",
   16746                 :           5 :                           OMP_CLAUSE_DECL (c));
   16747                 :           5 :                 remove = true;
   16748                 :           5 :                 break;
   16749                 :             :               }
   16750                 :             : 
   16751                 :       14164 :             gcc_assert ((addr_tokens[0]->type == ARRAY_BASE
   16752                 :             :                          || addr_tokens[0]->type == STRUCTURE_BASE)
   16753                 :             :                         && addr_tokens[1]->type == ACCESS_METHOD);
   16754                 :             : 
   16755                 :        7082 :             t = addr_tokens[1]->expr;
   16756                 :             : 
   16757                 :        7082 :             if (addr_tokens[0]->u.structure_base_kind != BASE_DECL)
   16758                 :           0 :               goto skip_decl_checks;
   16759                 :             : 
   16760                 :             :             /* For OpenMP, we can access a struct "t" and "t.d" on the same
   16761                 :             :                mapping.  OpenACC allows multiple fields of the same structure
   16762                 :             :                to be written.  */
   16763                 :        7082 :             if (addr_tokens[0]->type == STRUCTURE_BASE
   16764                 :        7082 :                 && (bitmap_bit_p (&map_field_head, DECL_UID (t))
   16765                 :         194 :                     || (!openacc && bitmap_bit_p (&map_head, DECL_UID (t)))))
   16766                 :         184 :               goto skip_decl_checks;
   16767                 :             : 
   16768                 :        6898 :             if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL)
   16769                 :             :               {
   16770                 :           3 :                 if (ort != C_ORT_ACC && EXPR_P (t))
   16771                 :             :                   break;
   16772                 :             : 
   16773                 :           6 :                 error_at (OMP_CLAUSE_LOCATION (c),
   16774                 :             :                           "%qE is not a variable in %qs clause", t,
   16775                 :           3 :                           omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   16776                 :           3 :                 remove = true;
   16777                 :             :               }
   16778                 :        6895 :             else if (VAR_P (t) && DECL_THREAD_LOCAL_P (t))
   16779                 :             :               {
   16780                 :           0 :                 error_at (OMP_CLAUSE_LOCATION (c),
   16781                 :             :                           "%qD is threadprivate variable in %qs clause", t,
   16782                 :           0 :                           omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   16783                 :           0 :                 remove = true;
   16784                 :             :               }
   16785                 :        6895 :             else if ((OMP_CLAUSE_CODE (c) != OMP_CLAUSE_MAP
   16786                 :        4085 :                       || (OMP_CLAUSE_MAP_KIND (c)
   16787                 :             :                           != GOMP_MAP_FIRSTPRIVATE_POINTER))
   16788                 :        9981 :                      && !c_mark_addressable (t))
   16789                 :             :               remove = true;
   16790                 :        6895 :             else if (!(OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP
   16791                 :        4085 :                        && (OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_POINTER
   16792                 :        4085 :                            || (OMP_CLAUSE_MAP_KIND (c)
   16793                 :             :                                == GOMP_MAP_FIRSTPRIVATE_POINTER)
   16794                 :        3086 :                            || (OMP_CLAUSE_MAP_KIND (c)
   16795                 :             :                                == GOMP_MAP_FORCE_DEVICEPTR)))
   16796                 :        5843 :                      && t == OMP_CLAUSE_DECL (c)
   16797                 :       12546 :                      && !omp_mappable_type (TREE_TYPE (t)))
   16798                 :             :               {
   16799                 :          16 :                 error_at (OMP_CLAUSE_LOCATION (c),
   16800                 :             :                           "%qD does not have a mappable type in %qs clause", t,
   16801                 :           8 :                           omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   16802                 :           8 :                 remove = true;
   16803                 :             :               }
   16804                 :        6887 :             else if (TREE_TYPE (t) == error_mark_node)
   16805                 :             :               remove = true;
   16806                 :        6886 :             else if (TYPE_ATOMIC (strip_array_types (TREE_TYPE (t))))
   16807                 :             :               {
   16808                 :           8 :                 error_at (OMP_CLAUSE_LOCATION (c),
   16809                 :             :                           "%<_Atomic%> %qE in %qs clause", t,
   16810                 :           4 :                           omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   16811                 :           4 :                 remove = true;
   16812                 :             :               }
   16813                 :        6882 :             else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP
   16814                 :        4075 :                      && OMP_CLAUSE_MAP_IMPLICIT (c)
   16815                 :        7046 :                      && (bitmap_bit_p (&map_head, DECL_UID (t))
   16816                 :         128 :                          || bitmap_bit_p (&map_field_head, DECL_UID (t))
   16817                 :         128 :                          || bitmap_bit_p (&map_firstprivate_head,
   16818                 :         128 :                                           DECL_UID (t))))
   16819                 :             :               remove = true;
   16820                 :        6845 :             else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP
   16821                 :        6845 :                      && (OMP_CLAUSE_MAP_KIND (c)
   16822                 :             :                          == GOMP_MAP_FIRSTPRIVATE_POINTER))
   16823                 :             :               {
   16824                 :         997 :                 if (bitmap_bit_p (&generic_head, DECL_UID (t))
   16825                 :         997 :                     || bitmap_bit_p (&firstprivate_head, DECL_UID (t))
   16826                 :        1993 :                     || bitmap_bit_p (&map_firstprivate_head, DECL_UID (t)))
   16827                 :             :                   {
   16828                 :           4 :                     error_at (OMP_CLAUSE_LOCATION (c),
   16829                 :             :                               "%qD appears more than once in data clauses", t);
   16830                 :           4 :                     remove = true;
   16831                 :             :                   }
   16832                 :         993 :                 else if (bitmap_bit_p (&map_head, DECL_UID (t))
   16833                 :           4 :                          && !bitmap_bit_p (&map_field_head, DECL_UID (t))
   16834                 :         995 :                          && openacc)
   16835                 :             :                   {
   16836                 :           1 :                     error_at (OMP_CLAUSE_LOCATION (c),
   16837                 :             :                               "%qD appears more than once in data clauses", t);
   16838                 :           1 :                     remove = true;
   16839                 :             :                   }
   16840                 :             :                 else
   16841                 :         992 :                   bitmap_set_bit (&map_firstprivate_head, DECL_UID (t));
   16842                 :             :               }
   16843                 :        5848 :             else if (bitmap_bit_p (&map_head, DECL_UID (t))
   16844                 :          50 :                      && !bitmap_bit_p (&map_field_head, DECL_UID (t))
   16845                 :          13 :                      && ort != C_ORT_OMP
   16846                 :        5861 :                      && ort != C_ORT_OMP_EXIT_DATA)
   16847                 :             :               {
   16848                 :          10 :                 if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_MAP)
   16849                 :           0 :                   error_at (OMP_CLAUSE_LOCATION (c),
   16850                 :             :                             "%qD appears more than once in motion clauses", t);
   16851                 :          10 :                 else if (openacc)
   16852                 :           7 :                   error_at (OMP_CLAUSE_LOCATION (c),
   16853                 :             :                             "%qD appears more than once in data clauses", t);
   16854                 :             :                 else
   16855                 :           3 :                   error_at (OMP_CLAUSE_LOCATION (c),
   16856                 :             :                             "%qD appears more than once in map clauses", t);
   16857                 :             :                 remove = true;
   16858                 :             :               }
   16859                 :        5838 :             else if (openacc && bitmap_bit_p (&generic_head, DECL_UID (t)))
   16860                 :             :               {
   16861                 :           0 :                 error_at (OMP_CLAUSE_LOCATION (c),
   16862                 :             :                           "%qD appears more than once in data clauses", t);
   16863                 :           0 :                 remove = true;
   16864                 :             :               }
   16865                 :        5838 :             else if (bitmap_bit_p (&firstprivate_head, DECL_UID (t))
   16866                 :        5838 :                      || bitmap_bit_p (&is_on_device_head, DECL_UID (t)))
   16867                 :             :               {
   16868                 :           9 :                 if (openacc)
   16869                 :           0 :                   error_at (OMP_CLAUSE_LOCATION (c),
   16870                 :             :                             "%qD appears more than once in data clauses", t);
   16871                 :             :                 else
   16872                 :           9 :                   error_at (OMP_CLAUSE_LOCATION (c),
   16873                 :             :                             "%qD appears both in data and map clauses", t);
   16874                 :             :                 remove = true;
   16875                 :             :               }
   16876                 :        5829 :             else if (!omp_access_chain_p (addr_tokens, 1))
   16877                 :             :               {
   16878                 :        5829 :                 bitmap_set_bit (&map_head, DECL_UID (t));
   16879                 :        5829 :                 if (t != OMP_CLAUSE_DECL (c)
   16880                 :        5829 :                     && TREE_CODE (OMP_CLAUSE_DECL (c)) == COMPONENT_REF)
   16881                 :         188 :                   bitmap_set_bit (&map_field_head, DECL_UID (t));
   16882                 :             :               }
   16883                 :             : 
   16884                 :           0 :           skip_decl_checks:
   16885                 :             :             /* If we call omp_expand_map_clause in handle_omp_array_sections,
   16886                 :             :                the containing loop (here) iterates through the new nodes
   16887                 :             :                created by that expansion.  Avoid expanding those again (just
   16888                 :             :                by checking the node type).  */
   16889                 :        7082 :             if (!remove
   16890                 :        7082 :                 && ort != C_ORT_DECLARE_SIMD
   16891                 :        7082 :                 && (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_MAP
   16892                 :        4192 :                     || (OMP_CLAUSE_MAP_KIND (c) != GOMP_MAP_FIRSTPRIVATE_POINTER
   16893                 :        3200 :                         && (OMP_CLAUSE_MAP_KIND (c)
   16894                 :             :                             != GOMP_MAP_FIRSTPRIVATE_REFERENCE)
   16895                 :        3200 :                         && OMP_CLAUSE_MAP_KIND (c) != GOMP_MAP_ALWAYS_POINTER
   16896                 :        3200 :                         && OMP_CLAUSE_MAP_KIND (c) != GOMP_MAP_ATTACH_DETACH
   16897                 :        2969 :                         && OMP_CLAUSE_MAP_KIND (c) != GOMP_MAP_ATTACH
   16898                 :        2948 :                         && OMP_CLAUSE_MAP_KIND (c) != GOMP_MAP_DETACH)))
   16899                 :             :               {
   16900                 :        5750 :                 grp_start_p = pc;
   16901                 :        5750 :                 grp_sentinel = OMP_CLAUSE_CHAIN (c);
   16902                 :        5750 :                 tree nc = ai.expand_map_clause (c, OMP_CLAUSE_DECL (c),
   16903                 :             :                                                 addr_tokens, ort);
   16904                 :        5750 :                 if (nc != error_mark_node)
   16905                 :        5750 :                   c = nc;
   16906                 :             :               }
   16907                 :        8984 :           }
   16908                 :        7082 :           break;
   16909                 :             : 
   16910                 :         222 :         case OMP_CLAUSE_ENTER:
   16911                 :         222 :         case OMP_CLAUSE_LINK:
   16912                 :         222 :           t = OMP_CLAUSE_DECL (c);
   16913                 :         222 :           const char *cname;
   16914                 :         222 :           cname = omp_clause_code_name[OMP_CLAUSE_CODE (c)];
   16915                 :         222 :           if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_ENTER
   16916                 :         222 :               && OMP_CLAUSE_ENTER_TO (c))
   16917                 :             :             cname = "to";
   16918                 :         222 :           if (TREE_CODE (t) == FUNCTION_DECL
   16919                 :         222 :               && OMP_CLAUSE_CODE (c) == OMP_CLAUSE_ENTER)
   16920                 :             :             ;
   16921                 :         145 :           else if (!VAR_P (t))
   16922                 :             :             {
   16923                 :           1 :               if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_ENTER)
   16924                 :           0 :                 error_at (OMP_CLAUSE_LOCATION (c),
   16925                 :             :                           "%qE is neither a variable nor a function name in "
   16926                 :             :                           "clause %qs", t, cname);
   16927                 :             :               else
   16928                 :           1 :                 error_at (OMP_CLAUSE_LOCATION (c),
   16929                 :             :                           "%qE is not a variable in clause %qs", t, cname);
   16930                 :             :               remove = true;
   16931                 :             :             }
   16932                 :         144 :           else if (DECL_THREAD_LOCAL_P (t))
   16933                 :             :             {
   16934                 :           2 :               error_at (OMP_CLAUSE_LOCATION (c),
   16935                 :             :                         "%qD is threadprivate variable in %qs clause", t,
   16936                 :             :                         cname);
   16937                 :           2 :               remove = true;
   16938                 :             :             }
   16939                 :         142 :           else if (!omp_mappable_type (TREE_TYPE (t)))
   16940                 :             :             {
   16941                 :           6 :               error_at (OMP_CLAUSE_LOCATION (c),
   16942                 :             :                         "%qD does not have a mappable type in %qs clause", t,
   16943                 :             :                         cname);
   16944                 :           6 :               remove = true;
   16945                 :             :             }
   16946                 :           8 :           if (remove)
   16947                 :             :             break;
   16948                 :         213 :           if (bitmap_bit_p (&generic_head, DECL_UID (t)))
   16949                 :             :             {
   16950                 :           8 :               error_at (OMP_CLAUSE_LOCATION (c),
   16951                 :             :                         "%qE appears more than once on the same "
   16952                 :             :                         "%<declare target%> directive", t);
   16953                 :           8 :               remove = true;
   16954                 :             :             }
   16955                 :             :           else
   16956                 :         205 :             bitmap_set_bit (&generic_head, DECL_UID (t));
   16957                 :             :           break;
   16958                 :             : 
   16959                 :         117 :         case OMP_CLAUSE_UNIFORM:
   16960                 :         117 :           t = OMP_CLAUSE_DECL (c);
   16961                 :         117 :           if (TREE_CODE (t) != PARM_DECL)
   16962                 :             :             {
   16963                 :           0 :               if (DECL_P (t))
   16964                 :           0 :                 error_at (OMP_CLAUSE_LOCATION (c),
   16965                 :             :                           "%qD is not an argument in %<uniform%> clause", t);
   16966                 :             :               else
   16967                 :           0 :                 error_at (OMP_CLAUSE_LOCATION (c),
   16968                 :             :                           "%qE is not an argument in %<uniform%> clause", t);
   16969                 :             :               remove = true;
   16970                 :             :               break;
   16971                 :             :             }
   16972                 :             :           /* map_head bitmap is used as uniform_head if declare_simd.  */
   16973                 :         117 :           bitmap_set_bit (&map_head, DECL_UID (t));
   16974                 :         117 :           goto check_dup_generic;
   16975                 :             : 
   16976                 :         144 :         case OMP_CLAUSE_IS_DEVICE_PTR:
   16977                 :         144 :         case OMP_CLAUSE_USE_DEVICE_PTR:
   16978                 :         144 :           t = OMP_CLAUSE_DECL (c);
   16979                 :         144 :           if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_IS_DEVICE_PTR)
   16980                 :         106 :             bitmap_set_bit (&is_on_device_head, DECL_UID (t));
   16981                 :         144 :           if (TREE_CODE (TREE_TYPE (t)) != POINTER_TYPE)
   16982                 :             :             {
   16983                 :          21 :               if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_USE_DEVICE_PTR
   16984                 :          21 :                   && !openacc)
   16985                 :             :                 {
   16986                 :           1 :                   error_at (OMP_CLAUSE_LOCATION (c),
   16987                 :             :                             "%qs variable is not a pointer",
   16988                 :           1 :                             omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   16989                 :           1 :                   remove = true;
   16990                 :             :                 }
   16991                 :          20 :               else if (TREE_CODE (TREE_TYPE (t)) != ARRAY_TYPE)
   16992                 :             :                 {
   16993                 :           4 :                   error_at (OMP_CLAUSE_LOCATION (c),
   16994                 :             :                             "%qs variable is neither a pointer nor an array",
   16995                 :           4 :                             omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   16996                 :           4 :                   remove = true;
   16997                 :             :                 }
   16998                 :             :             }
   16999                 :         144 :           goto check_dup_generic;
   17000                 :             : 
   17001                 :          88 :         case OMP_CLAUSE_HAS_DEVICE_ADDR:
   17002                 :          88 :           t = OMP_CLAUSE_DECL (c);
   17003                 :          88 :           if (TREE_CODE (t) == OMP_ARRAY_SECTION)
   17004                 :             :             {
   17005                 :          11 :               if (handle_omp_array_sections (c, ort))
   17006                 :             :                 remove = true;
   17007                 :             :               else
   17008                 :             :                 {
   17009                 :          11 :                   t = OMP_CLAUSE_DECL (c);
   17010                 :          24 :                   while (TREE_CODE (t) == ARRAY_REF)
   17011                 :          13 :                     t = TREE_OPERAND (t, 0);
   17012                 :             :                 }
   17013                 :             :             }
   17014                 :          88 :           bitmap_set_bit (&is_on_device_head, DECL_UID (t));
   17015                 :          88 :           if (VAR_P (t) || TREE_CODE (t) == PARM_DECL)
   17016                 :          88 :             c_mark_addressable (t);
   17017                 :          88 :           goto check_dup_generic_t;
   17018                 :             : 
   17019                 :          36 :         case OMP_CLAUSE_USE_DEVICE_ADDR:
   17020                 :          36 :           t = OMP_CLAUSE_DECL (c);
   17021                 :          36 :           if (VAR_P (t) || TREE_CODE (t) == PARM_DECL)
   17022                 :          36 :             c_mark_addressable (t);
   17023                 :          36 :           goto check_dup_generic;
   17024                 :             : 
   17025                 :        4719 :         case OMP_CLAUSE_NOWAIT:
   17026                 :        4719 :           if (copyprivate_seen)
   17027                 :             :             {
   17028                 :           1 :               error_at (OMP_CLAUSE_LOCATION (c),
   17029                 :             :                         "%<nowait%> clause must not be used together "
   17030                 :             :                         "with %<copyprivate%> clause");
   17031                 :           1 :               remove = true;
   17032                 :           1 :               break;
   17033                 :             :             }
   17034                 :        4718 :           nowait_clause = pc;
   17035                 :        4718 :           pc = &OMP_CLAUSE_CHAIN (c);
   17036                 :        4718 :           continue;
   17037                 :             : 
   17038                 :         522 :         case OMP_CLAUSE_ORDER:
   17039                 :         522 :           if (ordered_clause)
   17040                 :             :             {
   17041                 :           2 :               error_at (OMP_CLAUSE_LOCATION (c),
   17042                 :             :                         "%<order%> clause must not be used together "
   17043                 :             :                         "with %<ordered%> clause");
   17044                 :           2 :               remove = true;
   17045                 :           2 :               break;
   17046                 :             :             }
   17047                 :         520 :           else if (order_clause)
   17048                 :             :             {
   17049                 :             :               /* Silently remove duplicates.  */
   17050                 :             :               remove = true;
   17051                 :             :               break;
   17052                 :             :             }
   17053                 :         512 :           order_clause = pc;
   17054                 :         512 :           pc = &OMP_CLAUSE_CHAIN (c);
   17055                 :         512 :           continue;
   17056                 :             : 
   17057                 :          32 :         case OMP_CLAUSE_DETACH:
   17058                 :          32 :           t = OMP_CLAUSE_DECL (c);
   17059                 :          32 :           if (detach_seen)
   17060                 :             :             {
   17061                 :           1 :               error_at (OMP_CLAUSE_LOCATION (c),
   17062                 :             :                         "too many %qs clauses on a task construct",
   17063                 :             :                         "detach");
   17064                 :           1 :               remove = true;
   17065                 :           1 :               break;
   17066                 :             :             }
   17067                 :          31 :           detach_seen = pc;
   17068                 :          31 :           pc = &OMP_CLAUSE_CHAIN (c);
   17069                 :          31 :           c_mark_addressable (t);
   17070                 :          31 :           continue;
   17071                 :             : 
   17072                 :       14284 :         case OMP_CLAUSE_IF:
   17073                 :       14284 :         case OMP_CLAUSE_SELF:
   17074                 :       14284 :         case OMP_CLAUSE_NUM_THREADS:
   17075                 :       14284 :         case OMP_CLAUSE_NUM_TEAMS:
   17076                 :       14284 :         case OMP_CLAUSE_THREAD_LIMIT:
   17077                 :       14284 :         case OMP_CLAUSE_DEFAULT:
   17078                 :       14284 :         case OMP_CLAUSE_UNTIED:
   17079                 :       14284 :         case OMP_CLAUSE_COLLAPSE:
   17080                 :       14284 :         case OMP_CLAUSE_FINAL:
   17081                 :       14284 :         case OMP_CLAUSE_DEVICE:
   17082                 :       14284 :         case OMP_CLAUSE_DIST_SCHEDULE:
   17083                 :       14284 :         case OMP_CLAUSE_PARALLEL:
   17084                 :       14284 :         case OMP_CLAUSE_FOR:
   17085                 :       14284 :         case OMP_CLAUSE_SECTIONS:
   17086                 :       14284 :         case OMP_CLAUSE_TASKGROUP:
   17087                 :       14284 :         case OMP_CLAUSE_PROC_BIND:
   17088                 :       14284 :         case OMP_CLAUSE_DEVICE_TYPE:
   17089                 :       14284 :         case OMP_CLAUSE_PRIORITY:
   17090                 :       14284 :         case OMP_CLAUSE_THREADS:
   17091                 :       14284 :         case OMP_CLAUSE_SIMD:
   17092                 :       14284 :         case OMP_CLAUSE_HINT:
   17093                 :       14284 :         case OMP_CLAUSE_FILTER:
   17094                 :       14284 :         case OMP_CLAUSE_DEFAULTMAP:
   17095                 :       14284 :         case OMP_CLAUSE_BIND:
   17096                 :       14284 :         case OMP_CLAUSE_NUM_GANGS:
   17097                 :       14284 :         case OMP_CLAUSE_NUM_WORKERS:
   17098                 :       14284 :         case OMP_CLAUSE_VECTOR_LENGTH:
   17099                 :       14284 :         case OMP_CLAUSE_ASYNC:
   17100                 :       14284 :         case OMP_CLAUSE_WAIT:
   17101                 :       14284 :         case OMP_CLAUSE_AUTO:
   17102                 :       14284 :         case OMP_CLAUSE_INDEPENDENT:
   17103                 :       14284 :         case OMP_CLAUSE_SEQ:
   17104                 :       14284 :         case OMP_CLAUSE_GANG:
   17105                 :       14284 :         case OMP_CLAUSE_WORKER:
   17106                 :       14284 :         case OMP_CLAUSE_VECTOR:
   17107                 :       14284 :         case OMP_CLAUSE_TILE:
   17108                 :       14284 :         case OMP_CLAUSE_IF_PRESENT:
   17109                 :       14284 :         case OMP_CLAUSE_FINALIZE:
   17110                 :       14284 :         case OMP_CLAUSE_NOHOST:
   17111                 :       14284 :         case OMP_CLAUSE_INDIRECT:
   17112                 :       14284 :         case OMP_CLAUSE_NOVARIANTS:
   17113                 :       14284 :         case OMP_CLAUSE_NOCONTEXT:
   17114                 :       14284 :           pc = &OMP_CLAUSE_CHAIN (c);
   17115                 :       14284 :           continue;
   17116                 :             : 
   17117                 :          62 :         case OMP_CLAUSE_GRAINSIZE:
   17118                 :          62 :           grainsize_seen = pc;
   17119                 :          62 :           pc = &OMP_CLAUSE_CHAIN (c);
   17120                 :          62 :           continue;
   17121                 :             : 
   17122                 :          49 :         case OMP_CLAUSE_NUM_TASKS:
   17123                 :          49 :           num_tasks_seen = true;
   17124                 :          49 :           pc = &OMP_CLAUSE_CHAIN (c);
   17125                 :          49 :           continue;
   17126                 :             : 
   17127                 :          78 :         case OMP_CLAUSE_MERGEABLE:
   17128                 :          78 :           mergeable_seen = true;
   17129                 :          78 :           pc = &OMP_CLAUSE_CHAIN (c);
   17130                 :          78 :           continue;
   17131                 :             : 
   17132                 :          18 :         case OMP_CLAUSE_NOGROUP:
   17133                 :          18 :           nogroup_seen = pc;
   17134                 :          18 :           pc = &OMP_CLAUSE_CHAIN (c);
   17135                 :          18 :           continue;
   17136                 :             : 
   17137                 :        3451 :         case OMP_CLAUSE_SCHEDULE:
   17138                 :        3451 :           schedule_clause = c;
   17139                 :        3451 :           pc = &OMP_CLAUSE_CHAIN (c);
   17140                 :        3451 :           continue;
   17141                 :             : 
   17142                 :         303 :         case OMP_CLAUSE_ORDERED:
   17143                 :         303 :           ordered_clause = c;
   17144                 :         303 :           if (order_clause)
   17145                 :             :             {
   17146                 :           2 :               error_at (OMP_CLAUSE_LOCATION (*order_clause),
   17147                 :             :                         "%<order%> clause must not be used together "
   17148                 :             :                         "with %<ordered%> clause");
   17149                 :           2 :               *order_clause = OMP_CLAUSE_CHAIN (*order_clause);
   17150                 :           2 :               order_clause = NULL;
   17151                 :             :             }
   17152                 :         303 :           pc = &OMP_CLAUSE_CHAIN (c);
   17153                 :         303 :           continue;
   17154                 :             : 
   17155                 :         223 :         case OMP_CLAUSE_SAFELEN:
   17156                 :         223 :           safelen = c;
   17157                 :         223 :           pc = &OMP_CLAUSE_CHAIN (c);
   17158                 :         223 :           continue;
   17159                 :         312 :         case OMP_CLAUSE_SIMDLEN:
   17160                 :         312 :           simdlen = c;
   17161                 :         312 :           pc = &OMP_CLAUSE_CHAIN (c);
   17162                 :         312 :           continue;
   17163                 :             : 
   17164                 :          69 :         case OMP_CLAUSE_FULL:
   17165                 :          69 :           full_seen = pc;
   17166                 :          69 :           pc = &OMP_CLAUSE_CHAIN (c);
   17167                 :          69 :           continue;
   17168                 :             : 
   17169                 :         223 :         case OMP_CLAUSE_PARTIAL:
   17170                 :         223 :           partial_seen = true;
   17171                 :         223 :           pc = &OMP_CLAUSE_CHAIN (c);
   17172                 :         223 :           continue;
   17173                 :             : 
   17174                 :           0 :         case OMP_CLAUSE_SIZES:
   17175                 :           0 :           pc = &OMP_CLAUSE_CHAIN (c);
   17176                 :           0 :           continue;
   17177                 :             : 
   17178                 :         198 :         case OMP_CLAUSE_INBRANCH:
   17179                 :         198 :         case OMP_CLAUSE_NOTINBRANCH:
   17180                 :         198 :           if (branch_seen)
   17181                 :             :             {
   17182                 :           1 :               error_at (OMP_CLAUSE_LOCATION (c),
   17183                 :             :                         "%<inbranch%> clause is incompatible with "
   17184                 :             :                         "%<notinbranch%>");
   17185                 :           1 :               remove = true;
   17186                 :           1 :               break;
   17187                 :             :             }
   17188                 :         197 :           branch_seen = true;
   17189                 :         197 :           pc = &OMP_CLAUSE_CHAIN (c);
   17190                 :         197 :           continue;
   17191                 :             : 
   17192                 :         367 :         case OMP_CLAUSE_INCLUSIVE:
   17193                 :         367 :         case OMP_CLAUSE_EXCLUSIVE:
   17194                 :         367 :           need_complete = true;
   17195                 :         367 :           need_implicitly_determined = true;
   17196                 :         367 :           t = OMP_CLAUSE_DECL (c);
   17197                 :         367 :           if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL)
   17198                 :             :             {
   17199                 :           0 :               error_at (OMP_CLAUSE_LOCATION (c),
   17200                 :             :                         "%qE is not a variable in clause %qs", t,
   17201                 :           0 :                         omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   17202                 :           0 :               remove = true;
   17203                 :             :             }
   17204                 :             :           break;
   17205                 :             : 
   17206                 :         103 :         case OMP_CLAUSE_INIT:
   17207                 :         103 :           init_seen = true;
   17208                 :         103 :           if (!OMP_CLAUSE_INIT_TARGETSYNC (c))
   17209                 :          69 :             init_no_targetsync_clause = c;
   17210                 :             :           /* FALLTHRU */
   17211                 :         157 :         case OMP_CLAUSE_DESTROY:
   17212                 :         157 :         case OMP_CLAUSE_USE:
   17213                 :         157 :           init_use_destroy_seen = true;
   17214                 :         157 :           t = OMP_CLAUSE_DECL (c);
   17215                 :         157 :           if (bitmap_bit_p (&generic_head, DECL_UID (t)))
   17216                 :             :             {
   17217                 :           6 :               error_at (OMP_CLAUSE_LOCATION (c),
   17218                 :             :                         "%qD appears more than once in action clauses", t);
   17219                 :           6 :               remove = true;
   17220                 :           6 :               break;
   17221                 :             :             }
   17222                 :         151 :           bitmap_set_bit (&generic_head, DECL_UID (t));
   17223                 :             :           /* FALLTHRU */
   17224                 :         182 :         case OMP_CLAUSE_INTEROP:
   17225                 :         182 :           if (/* ort == C_ORT_OMP_INTEROP [uncomment for depobj init]  */
   17226                 :         182 :                    !c_omp_interop_t_p (TREE_TYPE (OMP_CLAUSE_DECL (c))))
   17227                 :             :             {
   17228                 :          38 :               error_at (OMP_CLAUSE_LOCATION (c),
   17229                 :             :                         "%qD must be of %<omp_interop_t%>",
   17230                 :          19 :                         OMP_CLAUSE_DECL (c));
   17231                 :          19 :               remove = true;
   17232                 :             :             }
   17233                 :         163 :           else if ((OMP_CLAUSE_CODE (c) == OMP_CLAUSE_INIT
   17234                 :          70 :                     || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DESTROY)
   17235                 :         185 :                    && TREE_READONLY (OMP_CLAUSE_DECL (c)))
   17236                 :             :             {
   17237                 :          12 :               error_at (OMP_CLAUSE_LOCATION (c),
   17238                 :           6 :                       "%qD shall not be const", OMP_CLAUSE_DECL (c));
   17239                 :           6 :               remove = true;
   17240                 :             :             }
   17241                 :         182 :           pc = &OMP_CLAUSE_CHAIN (c);
   17242                 :         182 :           break;
   17243                 :           0 :         default:
   17244                 :           0 :           gcc_unreachable ();
   17245                 :       24530 :         }
   17246                 :             : 
   17247                 :       21772 :       if (!remove)
   17248                 :             :         {
   17249                 :       21222 :           t = OMP_CLAUSE_DECL (c);
   17250                 :             : 
   17251                 :       21222 :           if (need_complete)
   17252                 :             :             {
   17253                 :        3911 :               t = require_complete_type (OMP_CLAUSE_LOCATION (c), t);
   17254                 :        3911 :               if (t == error_mark_node)
   17255                 :           7 :                 remove = true;
   17256                 :             :             }
   17257                 :             : 
   17258                 :       21222 :           if (need_implicitly_determined)
   17259                 :             :             {
   17260                 :        9273 :               const char *share_name = NULL;
   17261                 :             : 
   17262                 :        9273 :               if (VAR_P (t) && DECL_THREAD_LOCAL_P (t))
   17263                 :             :                 share_name = "threadprivate";
   17264                 :        9267 :               else switch (c_omp_predetermined_sharing (t))
   17265                 :             :                 {
   17266                 :             :                 case OMP_CLAUSE_DEFAULT_UNSPECIFIED:
   17267                 :             :                   break;
   17268                 :          20 :                 case OMP_CLAUSE_DEFAULT_SHARED:
   17269                 :          20 :                   if ((OMP_CLAUSE_CODE (c) == OMP_CLAUSE_SHARED
   17270                 :          12 :                        || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_FIRSTPRIVATE)
   17271                 :          28 :                       && c_omp_predefined_variable (t))
   17272                 :             :                     /* The __func__ variable and similar function-local
   17273                 :             :                        predefined variables may be listed in a shared or
   17274                 :             :                        firstprivate clause.  */
   17275                 :             :                     break;
   17276                 :             :                   share_name = "shared";
   17277                 :             :                   break;
   17278                 :             :                 case OMP_CLAUSE_DEFAULT_PRIVATE:
   17279                 :             :                   share_name = "private";
   17280                 :             :                   break;
   17281                 :           0 :                 default:
   17282                 :           0 :                   gcc_unreachable ();
   17283                 :             :                 }
   17284                 :             :               if (share_name)
   17285                 :             :                 {
   17286                 :          20 :                   error_at (OMP_CLAUSE_LOCATION (c),
   17287                 :             :                             "%qE is predetermined %qs for %qs",
   17288                 :             :                             t, share_name,
   17289                 :          10 :                             omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   17290                 :          10 :                   remove = true;
   17291                 :             :                 }
   17292                 :        9263 :               else if (TREE_READONLY (t)
   17293                 :          23 :                        && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_SHARED
   17294                 :        9276 :                        && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_FIRSTPRIVATE)
   17295                 :             :                 {
   17296                 :           4 :                   error_at (OMP_CLAUSE_LOCATION (c),
   17297                 :             :                             "%<const%> qualified %qE may appear only in "
   17298                 :             :                             "%<shared%> or %<firstprivate%> clauses", t);
   17299                 :           4 :                   remove = true;
   17300                 :             :                 }
   17301                 :             :             }
   17302                 :             :         }
   17303                 :             : 
   17304                 :       21222 :       if (remove)
   17305                 :             :         {
   17306                 :         571 :           if (grp_start_p)
   17307                 :             :             {
   17308                 :             :               /* If we found a clause to remove, we want to remove the whole
   17309                 :             :                  expanded group, otherwise gimplify
   17310                 :             :                  (omp_resolve_clause_dependencies) can get confused.  */
   17311                 :         152 :               *grp_start_p = grp_sentinel;
   17312                 :         152 :               pc = grp_start_p;
   17313                 :         152 :               grp_start_p = NULL;
   17314                 :             :             }
   17315                 :             :           else
   17316                 :         419 :             *pc = OMP_CLAUSE_CHAIN (c);
   17317                 :             :         }
   17318                 :             :       else
   17319                 :       21201 :         pc = &OMP_CLAUSE_CHAIN (c);
   17320                 :             :     }
   17321                 :             : 
   17322                 :       28290 :   if (simdlen
   17323                 :       28290 :       && safelen
   17324                 :       28407 :       && tree_int_cst_lt (OMP_CLAUSE_SAFELEN_EXPR (safelen),
   17325                 :         117 :                           OMP_CLAUSE_SIMDLEN_EXPR (simdlen)))
   17326                 :             :     {
   17327                 :           0 :       error_at (OMP_CLAUSE_LOCATION (simdlen),
   17328                 :             :                 "%<simdlen%> clause value is bigger than "
   17329                 :             :                 "%<safelen%> clause value");
   17330                 :           0 :       OMP_CLAUSE_SIMDLEN_EXPR (simdlen)
   17331                 :           0 :         = OMP_CLAUSE_SAFELEN_EXPR (safelen);
   17332                 :             :     }
   17333                 :             : 
   17334                 :       28290 :   if (ordered_clause
   17335                 :       28290 :       && schedule_clause
   17336                 :       28290 :       && (OMP_CLAUSE_SCHEDULE_KIND (schedule_clause)
   17337                 :             :           & OMP_CLAUSE_SCHEDULE_NONMONOTONIC))
   17338                 :             :     {
   17339                 :           7 :       error_at (OMP_CLAUSE_LOCATION (schedule_clause),
   17340                 :             :                 "%<nonmonotonic%> schedule modifier specified together "
   17341                 :             :                 "with %<ordered%> clause");
   17342                 :          14 :       OMP_CLAUSE_SCHEDULE_KIND (schedule_clause)
   17343                 :           7 :         = (enum omp_clause_schedule_kind)
   17344                 :           7 :           (OMP_CLAUSE_SCHEDULE_KIND (schedule_clause)
   17345                 :             :            & ~OMP_CLAUSE_SCHEDULE_NONMONOTONIC);
   17346                 :             :     }
   17347                 :             : 
   17348                 :       28290 :   if (reduction_seen < 0 && ordered_clause)
   17349                 :             :     {
   17350                 :           2 :       error_at (OMP_CLAUSE_LOCATION (ordered_clause),
   17351                 :             :                 "%qs clause specified together with %<inscan%> "
   17352                 :             :                 "%<reduction%> clause", "ordered");
   17353                 :           2 :       reduction_seen = -2;
   17354                 :             :     }
   17355                 :             : 
   17356                 :       28290 :   if (reduction_seen < 0 && schedule_clause)
   17357                 :             :     {
   17358                 :           3 :       error_at (OMP_CLAUSE_LOCATION (schedule_clause),
   17359                 :             :                 "%qs clause specified together with %<inscan%> "
   17360                 :             :                 "%<reduction%> clause", "schedule");
   17361                 :           3 :       reduction_seen = -2;
   17362                 :             :     }
   17363                 :             : 
   17364                 :       28290 :   if (linear_variable_step_check
   17365                 :       28290 :       || reduction_seen == -2
   17366                 :             :       || allocate_seen
   17367                 :       28278 :       || target_in_reduction_seen)
   17368                 :        5145 :     for (pc = &clauses, c = clauses; c ; c = *pc)
   17369                 :             :       {
   17370                 :        4556 :         bool remove = false;
   17371                 :        4556 :         if (allocate_seen)
   17372                 :        4398 :           switch (OMP_CLAUSE_CODE (c))
   17373                 :             :             {
   17374                 :         430 :             case OMP_CLAUSE_REDUCTION:
   17375                 :         430 :             case OMP_CLAUSE_IN_REDUCTION:
   17376                 :         430 :             case OMP_CLAUSE_TASK_REDUCTION:
   17377                 :         430 :               if (TREE_CODE (OMP_CLAUSE_DECL (c)) == MEM_REF)
   17378                 :             :                 {
   17379                 :          23 :                   t = TREE_OPERAND (OMP_CLAUSE_DECL (c), 0);
   17380                 :          23 :                   if (TREE_CODE (t) == POINTER_PLUS_EXPR)
   17381                 :           0 :                     t = TREE_OPERAND (t, 0);
   17382                 :          23 :                   if (TREE_CODE (t) == ADDR_EXPR
   17383                 :          10 :                       || INDIRECT_REF_P (t))
   17384                 :          13 :                     t = TREE_OPERAND (t, 0);
   17385                 :          23 :                   if (DECL_P (t))
   17386                 :          23 :                     bitmap_clear_bit (&aligned_head, DECL_UID (t));
   17387                 :             :                   break;
   17388                 :             :                 }
   17389                 :             :               /* FALLTHRU */
   17390                 :        1302 :             case OMP_CLAUSE_PRIVATE:
   17391                 :        1302 :             case OMP_CLAUSE_FIRSTPRIVATE:
   17392                 :        1302 :             case OMP_CLAUSE_LASTPRIVATE:
   17393                 :        1302 :             case OMP_CLAUSE_LINEAR:
   17394                 :        1302 :               if (DECL_P (OMP_CLAUSE_DECL (c)))
   17395                 :        2604 :                 bitmap_clear_bit (&aligned_head,
   17396                 :        1302 :                                   DECL_UID (OMP_CLAUSE_DECL (c)));
   17397                 :             :               break;
   17398                 :             :             default:
   17399                 :             :               break;
   17400                 :             :             }
   17401                 :        4556 :         if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_LINEAR
   17402                 :          29 :             && OMP_CLAUSE_LINEAR_VARIABLE_STRIDE (c)
   17403                 :        4563 :             && !bitmap_bit_p (&map_head,
   17404                 :           7 :                               DECL_UID (OMP_CLAUSE_LINEAR_STEP (c))))
   17405                 :             :           {
   17406                 :           2 :             error_at (OMP_CLAUSE_LOCATION (c),
   17407                 :             :                       "%<linear%> clause step is a parameter %qD not "
   17408                 :             :                       "specified in %<uniform%> clause",
   17409                 :           2 :                       OMP_CLAUSE_LINEAR_STEP (c));
   17410                 :           2 :             remove = true;
   17411                 :             :           }
   17412                 :        4554 :         else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION
   17413                 :        4554 :                  && reduction_seen == -2)
   17414                 :           9 :           OMP_CLAUSE_REDUCTION_INSCAN (c) = 0;
   17415                 :        4556 :         if (target_in_reduction_seen
   17416                 :        4556 :             && OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP)
   17417                 :             :           {
   17418                 :         256 :             tree t = OMP_CLAUSE_DECL (c);
   17419                 :         256 :             while (handled_component_p (t)
   17420                 :             :                    || INDIRECT_REF_P (t)
   17421                 :             :                    || TREE_CODE (t) == ADDR_EXPR
   17422                 :             :                    || TREE_CODE (t) == MEM_REF
   17423                 :         288 :                    || TREE_CODE (t) == NON_LVALUE_EXPR)
   17424                 :          32 :               t = TREE_OPERAND (t, 0);
   17425                 :         256 :             if (DECL_P (t)
   17426                 :         256 :                 && bitmap_bit_p (&oacc_reduction_head, DECL_UID (t)))
   17427                 :         138 :               OMP_CLAUSE_MAP_IN_REDUCTION (c) = 1;
   17428                 :             :           }
   17429                 :             : 
   17430                 :        4556 :         if (remove)
   17431                 :           2 :           *pc = OMP_CLAUSE_CHAIN (c);
   17432                 :             :         else
   17433                 :        4554 :           pc = &OMP_CLAUSE_CHAIN (c);
   17434                 :             :       }
   17435                 :             : 
   17436                 :         589 :   if (allocate_seen)
   17437                 :        4961 :     for (pc = &clauses, c = clauses; c ; c = *pc)
   17438                 :             :       {
   17439                 :        4398 :         bool remove = false;
   17440                 :        4398 :         if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_ALLOCATE
   17441                 :         704 :             && !OMP_CLAUSE_ALLOCATE_COMBINED (c)
   17442                 :        5082 :             && bitmap_bit_p (&aligned_head, DECL_UID (OMP_CLAUSE_DECL (c))))
   17443                 :             :           {
   17444                 :           3 :             error_at (OMP_CLAUSE_LOCATION (c),
   17445                 :             :                       "%qD specified in %<allocate%> clause but not in "
   17446                 :           3 :                       "an explicit privatization clause", OMP_CLAUSE_DECL (c));
   17447                 :           3 :             remove = true;
   17448                 :             :           }
   17449                 :        4398 :         if (remove)
   17450                 :           3 :           *pc = OMP_CLAUSE_CHAIN (c);
   17451                 :             :         else
   17452                 :        4395 :           pc = &OMP_CLAUSE_CHAIN (c);
   17453                 :             :       }
   17454                 :             : 
   17455                 :       28290 :   if (nogroup_seen && reduction_seen)
   17456                 :             :     {
   17457                 :           1 :       error_at (OMP_CLAUSE_LOCATION (*nogroup_seen),
   17458                 :             :                 "%<nogroup%> clause must not be used together with "
   17459                 :             :                 "%<reduction%> clause");
   17460                 :           1 :       *nogroup_seen = OMP_CLAUSE_CHAIN (*nogroup_seen);
   17461                 :             :     }
   17462                 :             : 
   17463                 :       28290 :   if (grainsize_seen && num_tasks_seen)
   17464                 :             :     {
   17465                 :           2 :       error_at (OMP_CLAUSE_LOCATION (*grainsize_seen),
   17466                 :             :                 "%<grainsize%> clause must not be used together with "
   17467                 :             :                 "%<num_tasks%> clause");
   17468                 :           2 :       *grainsize_seen = OMP_CLAUSE_CHAIN (*grainsize_seen);
   17469                 :             :     }
   17470                 :             : 
   17471                 :       28290 :   if (full_seen && partial_seen)
   17472                 :             :     {
   17473                 :           4 :       error_at (OMP_CLAUSE_LOCATION (*full_seen),
   17474                 :             :                 "%<full%> clause must not be used together with "
   17475                 :             :                 "%<partial%> clause");
   17476                 :           4 :       *full_seen = OMP_CLAUSE_CHAIN (*full_seen);
   17477                 :             :     }
   17478                 :             : 
   17479                 :       28290 :   if (detach_seen)
   17480                 :             :     {
   17481                 :          31 :       if (mergeable_seen)
   17482                 :             :         {
   17483                 :           2 :           error_at (OMP_CLAUSE_LOCATION (*detach_seen),
   17484                 :             :                     "%<detach%> clause must not be used together with "
   17485                 :             :                     "%<mergeable%> clause");
   17486                 :           2 :           *detach_seen = OMP_CLAUSE_CHAIN (*detach_seen);
   17487                 :             :         }
   17488                 :             :       else
   17489                 :             :         {
   17490                 :          29 :           tree detach_decl = OMP_CLAUSE_DECL (*detach_seen);
   17491                 :             : 
   17492                 :          79 :           for (pc = &clauses, c = clauses; c ; c = *pc)
   17493                 :             :             {
   17494                 :          50 :               bool remove = false;
   17495                 :          50 :               if ((OMP_CLAUSE_CODE (c) == OMP_CLAUSE_SHARED
   17496                 :          48 :                    || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_PRIVATE
   17497                 :          48 :                    || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_FIRSTPRIVATE
   17498                 :          44 :                    || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_LASTPRIVATE)
   17499                 :          54 :                   && OMP_CLAUSE_DECL (c) == detach_decl)
   17500                 :             :                 {
   17501                 :           2 :                   error_at (OMP_CLAUSE_LOCATION (c),
   17502                 :             :                             "the event handle of a %<detach%> clause "
   17503                 :             :                             "should not be in a data-sharing clause");
   17504                 :           2 :                   remove = true;
   17505                 :             :                 }
   17506                 :          50 :               if (remove)
   17507                 :           2 :                 *pc = OMP_CLAUSE_CHAIN (c);
   17508                 :             :               else
   17509                 :          48 :                 pc = &OMP_CLAUSE_CHAIN (c);
   17510                 :             :             }
   17511                 :             :         }
   17512                 :             :     }
   17513                 :             : 
   17514                 :       28290 :   if (ort == C_ORT_OMP_INTEROP
   17515                 :       28290 :       && depend_clause
   17516                 :          13 :       && (!init_use_destroy_seen
   17517                 :          12 :           || (init_seen && init_no_targetsync_clause)))
   17518                 :             :     {
   17519                 :           3 :       error_at (OMP_CLAUSE_LOCATION (depend_clause),
   17520                 :             :                 "%<depend%> clause requires action clauses with "
   17521                 :             :                 "%<targetsync%> interop-type");
   17522                 :           3 :       if (init_no_targetsync_clause)
   17523                 :           2 :         inform (OMP_CLAUSE_LOCATION (init_no_targetsync_clause),
   17524                 :             :                 "%<init%> clause lacks the %<targetsync%> modifier");
   17525                 :             :     }
   17526                 :             : 
   17527                 :       28290 :   bitmap_obstack_release (NULL);
   17528                 :       28290 :   return clauses;
   17529                 :             : }
   17530                 :             : 
   17531                 :             : /* Return code to initialize DST with a copy constructor from SRC.
   17532                 :             :    C doesn't have copy constructors nor assignment operators, only for
   17533                 :             :    _Atomic vars we need to perform __atomic_load from src into a temporary
   17534                 :             :    followed by __atomic_store of the temporary to dst.  */
   17535                 :             : 
   17536                 :             : tree
   17537                 :       18586 : c_omp_clause_copy_ctor (tree clause, tree dst, tree src)
   17538                 :             : {
   17539                 :       18586 :   if (!really_atomic_lvalue (dst) && !really_atomic_lvalue (src))
   17540                 :       18582 :     return build2 (MODIFY_EXPR, TREE_TYPE (dst), dst, src);
   17541                 :             : 
   17542                 :           4 :   location_t loc = OMP_CLAUSE_LOCATION (clause);
   17543                 :           4 :   tree type = TREE_TYPE (dst);
   17544                 :           4 :   tree nonatomic_type = build_qualified_type (type, TYPE_UNQUALIFIED);
   17545                 :           4 :   tree tmp = create_tmp_var (nonatomic_type);
   17546                 :           4 :   tree tmp_addr = build_fold_addr_expr (tmp);
   17547                 :           4 :   TREE_ADDRESSABLE (tmp) = 1;
   17548                 :           4 :   suppress_warning (tmp);
   17549                 :           4 :   tree src_addr = build_fold_addr_expr (src);
   17550                 :           4 :   tree dst_addr = build_fold_addr_expr (dst);
   17551                 :           4 :   tree seq_cst = build_int_cst (integer_type_node, MEMMODEL_SEQ_CST);
   17552                 :           4 :   vec<tree, va_gc> *params;
   17553                 :             :   /* Expansion of a generic atomic load may require an addition
   17554                 :             :      element, so allocate enough to prevent a resize.  */
   17555                 :           4 :   vec_alloc (params, 4);
   17556                 :             : 
   17557                 :             :   /* Build __atomic_load (&src, &tmp, SEQ_CST);  */
   17558                 :           4 :   tree fndecl = builtin_decl_explicit (BUILT_IN_ATOMIC_LOAD);
   17559                 :           4 :   params->quick_push (src_addr);
   17560                 :           4 :   params->quick_push (tmp_addr);
   17561                 :           4 :   params->quick_push (seq_cst);
   17562                 :           4 :   tree load = c_build_function_call_vec (loc, vNULL, fndecl, params, NULL);
   17563                 :             : 
   17564                 :           4 :   vec_alloc (params, 4);
   17565                 :             : 
   17566                 :             :   /* Build __atomic_store (&dst, &tmp, SEQ_CST);  */
   17567                 :           4 :   fndecl = builtin_decl_explicit (BUILT_IN_ATOMIC_STORE);
   17568                 :           4 :   params->quick_push (dst_addr);
   17569                 :           4 :   params->quick_push (tmp_addr);
   17570                 :           4 :   params->quick_push (seq_cst);
   17571                 :           4 :   tree store = c_build_function_call_vec (loc, vNULL, fndecl, params, NULL);
   17572                 :           4 :   return build2 (COMPOUND_EXPR, void_type_node, load, store);
   17573                 :             : }
   17574                 :             : 
   17575                 :             : /* Create a transaction node.  */
   17576                 :             : 
   17577                 :             : tree
   17578                 :         135 : c_finish_transaction (location_t loc, tree block, int flags)
   17579                 :             : {
   17580                 :         135 :   tree stmt = build_stmt (loc, TRANSACTION_EXPR, block);
   17581                 :         135 :   if (flags & TM_STMT_ATTR_OUTER)
   17582                 :          10 :     TRANSACTION_EXPR_OUTER (stmt) = 1;
   17583                 :         135 :   if (flags & TM_STMT_ATTR_RELAXED)
   17584                 :          31 :     TRANSACTION_EXPR_RELAXED (stmt) = 1;
   17585                 :         135 :   return add_stmt (stmt);
   17586                 :             : }
   17587                 :             : 
   17588                 :             : /* Make a variant type in the proper way for C/C++, propagating qualifiers
   17589                 :             :    down to the element type of an array.  If ORIG_QUAL_TYPE is not
   17590                 :             :    NULL, then it should be used as the qualified type
   17591                 :             :    ORIG_QUAL_INDIRECT levels down in array type derivation (to
   17592                 :             :    preserve information about the typedef name from which an array
   17593                 :             :    type was derived).  */
   17594                 :             : 
   17595                 :             : tree
   17596                 :    75790690 : c_build_qualified_type (tree type, int type_quals, tree orig_qual_type,
   17597                 :             :                         size_t orig_qual_indirect)
   17598                 :             : {
   17599                 :    75790690 :   if (type == error_mark_node)
   17600                 :             :     return type;
   17601                 :             : 
   17602                 :    75790546 :   if (TREE_CODE (type) == ARRAY_TYPE)
   17603                 :             :     {
   17604                 :     3053843 :       tree t;
   17605                 :     3053843 :       tree element_type = c_build_qualified_type (TREE_TYPE (type),
   17606                 :             :                                                   type_quals, orig_qual_type,
   17607                 :             :                                                   orig_qual_indirect - 1);
   17608                 :             : 
   17609                 :             :       /* See if we already have an identically qualified type.  */
   17610                 :     3053843 :       if (orig_qual_type && orig_qual_indirect == 0)
   17611                 :             :         t = orig_qual_type;
   17612                 :             :       else
   17613                 :     4431535 :         for (t = TYPE_MAIN_VARIANT (type); t; t = TYPE_NEXT_VARIANT (t))
   17614                 :             :           {
   17615                 :     4297729 :             if (TYPE_QUALS (strip_array_types (t)) == type_quals
   17616                 :     2940499 :                 && TYPE_NAME (t) == TYPE_NAME (type)
   17617                 :     2919996 :                 && TYPE_CONTEXT (t) == TYPE_CONTEXT (type)
   17618                 :     7217725 :                 && attribute_list_equal (TYPE_ATTRIBUTES (t),
   17619                 :     2919996 :                                          TYPE_ATTRIBUTES (type)))
   17620                 :             :               break;
   17621                 :             :           }
   17622                 :     3053802 :       if (!t)
   17623                 :             :         {
   17624                 :      133806 :           tree domain = TYPE_DOMAIN (type);
   17625                 :             : 
   17626                 :      133806 :           t = build_variant_type_copy (type);
   17627                 :      133806 :           TREE_TYPE (t) = element_type;
   17628                 :      133806 :           TYPE_ADDR_SPACE (t) = TYPE_ADDR_SPACE (element_type);
   17629                 :             : 
   17630                 :      133806 :           if (TYPE_STRUCTURAL_EQUALITY_P (element_type)
   17631                 :      133806 :               || (domain && TYPE_STRUCTURAL_EQUALITY_P (domain)))
   17632                 :         179 :             SET_TYPE_STRUCTURAL_EQUALITY (t);
   17633                 :      133627 :           else if (TYPE_CANONICAL (element_type) != element_type
   17634                 :      133627 :                    || (domain && TYPE_CANONICAL (domain) != domain))
   17635                 :             :             {
   17636                 :        2703 :               tree unqualified_canon
   17637                 :        5199 :                 = c_build_array_type (TYPE_CANONICAL (element_type),
   17638                 :        2496 :                                       domain ? TYPE_CANONICAL (domain)
   17639                 :             :                                              : NULL_TREE);
   17640                 :        2703 :               if (TYPE_REVERSE_STORAGE_ORDER (type))
   17641                 :             :                 {
   17642                 :           0 :                   unqualified_canon
   17643                 :           0 :                     = build_distinct_type_copy (unqualified_canon);
   17644                 :           0 :                   TYPE_REVERSE_STORAGE_ORDER (unqualified_canon) = 1;
   17645                 :             :                 }
   17646                 :        2703 :               TYPE_CANONICAL (t)
   17647                 :        5406 :                 = c_build_qualified_type (unqualified_canon, type_quals);
   17648                 :             :             }
   17649                 :             :           else
   17650                 :      130924 :             TYPE_CANONICAL (t) = t;
   17651                 :             :         }
   17652                 :     3053843 :       return t;
   17653                 :             :     }
   17654                 :             : 
   17655                 :             :   /* A restrict-qualified pointer type must be a pointer to object or
   17656                 :             :      incomplete type.  Note that the use of POINTER_TYPE_P also allows
   17657                 :             :      REFERENCE_TYPEs, which is appropriate for C++.  */
   17658                 :    72736703 :   if ((type_quals & TYPE_QUAL_RESTRICT)
   17659                 :    72736703 :       && (!POINTER_TYPE_P (type)
   17660                 :     3278326 :           || !C_TYPE_OBJECT_OR_INCOMPLETE_P (TREE_TYPE (type))))
   17661                 :             :     {
   17662                 :           3 :       error ("invalid use of %<restrict%>");
   17663                 :           3 :       type_quals &= ~TYPE_QUAL_RESTRICT;
   17664                 :             :     }
   17665                 :             : 
   17666                 :    72736703 :   tree var_type = (orig_qual_type && orig_qual_indirect == 0
   17667                 :    72736703 :                    ? orig_qual_type
   17668                 :    72736688 :                    : build_qualified_type (type, type_quals));
   17669                 :             : 
   17670                 :    72736703 :   gcc_checking_assert (C_TYPE_VARIABLE_SIZE (var_type)
   17671                 :             :                        == C_TYPE_VARIABLE_SIZE (type));
   17672                 :    72736703 :   gcc_checking_assert (C_TYPE_VARIABLY_MODIFIED (var_type)
   17673                 :             :                        == C_TYPE_VARIABLY_MODIFIED (type));
   17674                 :             : 
   17675                 :             :   /* A variant type does not inherit the list of incomplete vars from the
   17676                 :             :      type main variant.  */
   17677                 :    72736703 :   if ((RECORD_OR_UNION_TYPE_P (var_type)
   17678                 :    70887034 :        || TREE_CODE (var_type) == ENUMERAL_TYPE)
   17679                 :    72836275 :       && TYPE_MAIN_VARIANT (var_type) != var_type)
   17680                 :     1344493 :     C_TYPE_INCOMPLETE_VARS (var_type) = 0;
   17681                 :             :   return var_type;
   17682                 :             : }
   17683                 :             : 
   17684                 :             : /* Build a VA_ARG_EXPR for the C parser.  */
   17685                 :             : 
   17686                 :             : tree
   17687                 :       19873 : c_build_va_arg (location_t loc1, tree expr, location_t loc2, tree type)
   17688                 :             : {
   17689                 :       19873 :   if (error_operand_p (type))
   17690                 :           2 :     return error_mark_node;
   17691                 :             :   /* VA_ARG_EXPR cannot be used for a scalar va_list with reverse storage
   17692                 :             :      order because it takes the address of the expression.  */
   17693                 :       19871 :   else if (handled_component_p (expr)
   17694                 :          31 :            && reverse_storage_order_for_component_p (expr))
   17695                 :             :     {
   17696                 :           0 :       error_at (loc1, "cannot use %<va_arg%> with reverse storage order");
   17697                 :           0 :       return error_mark_node;
   17698                 :             :     }
   17699                 :       19871 :   else if (!COMPLETE_TYPE_P (type))
   17700                 :             :     {
   17701                 :          11 :       error_at (loc2, "second argument to %<va_arg%> is of incomplete "
   17702                 :             :                 "type %qT", type);
   17703                 :          11 :       return error_mark_node;
   17704                 :             :     }
   17705                 :       19860 :   else if (TREE_CODE (type) == FUNCTION_TYPE)
   17706                 :             :     {
   17707                 :           1 :       error_at (loc2, "second argument to %<va_arg%> is a function type %qT",
   17708                 :             :                 type);
   17709                 :           1 :       return error_mark_node;
   17710                 :             :     }
   17711                 :       19859 :   else if (warn_cxx_compat && TREE_CODE (type) == ENUMERAL_TYPE)
   17712                 :           1 :     warning_at (loc2, OPT_Wc___compat,
   17713                 :             :                 "C++ requires promoted type, not enum type, in %<va_arg%>");
   17714                 :       19859 :   return build_va_arg (loc2, expr, type);
   17715                 :             : }
   17716                 :             : 
   17717                 :             : /* Return truthvalue of whether T1 is the same tree structure as T2.
   17718                 :             :    Return 1 if they are the same. Return false if they are different.  */
   17719                 :             : 
   17720                 :             : bool
   17721                 :        1854 : c_tree_equal (tree t1, tree t2)
   17722                 :             : {
   17723                 :        1883 :   enum tree_code code1, code2;
   17724                 :             : 
   17725                 :        1883 :   if (t1 == t2)
   17726                 :             :     return true;
   17727                 :         661 :   if (!t1 || !t2)
   17728                 :             :     return false;
   17729                 :             : 
   17730                 :         681 :   for (code1 = TREE_CODE (t1); code1 == NON_LVALUE_EXPR;
   17731                 :          20 :        code1 = TREE_CODE (t1))
   17732                 :          20 :     t1 = TREE_OPERAND (t1, 0);
   17733                 :         682 :   for (code2 = TREE_CODE (t2); code2 == NON_LVALUE_EXPR;
   17734                 :          21 :        code2 = TREE_CODE (t2))
   17735                 :          21 :     t2 = TREE_OPERAND (t2, 0);
   17736                 :             : 
   17737                 :             :   /* They might have become equal now.  */
   17738                 :         661 :   if (t1 == t2)
   17739                 :             :     return true;
   17740                 :             : 
   17741                 :         640 :   if (code1 != code2)
   17742                 :             :     return false;
   17743                 :             : 
   17744                 :         379 :   if (CONSTANT_CLASS_P (t1) && !comptypes (TREE_TYPE (t1), TREE_TYPE (t2)))
   17745                 :             :     return false;
   17746                 :             : 
   17747                 :         379 :   switch (code1)
   17748                 :             :     {
   17749                 :           2 :     case INTEGER_CST:
   17750                 :           2 :       return wi::to_wide (t1) == wi::to_wide (t2);
   17751                 :             : 
   17752                 :          10 :     case REAL_CST:
   17753                 :          10 :       return real_equal (&TREE_REAL_CST (t1), &TREE_REAL_CST (t2));
   17754                 :             : 
   17755                 :           0 :     case STRING_CST:
   17756                 :           0 :       return TREE_STRING_LENGTH (t1) == TREE_STRING_LENGTH (t2)
   17757                 :           0 :         && !memcmp (TREE_STRING_POINTER (t1), TREE_STRING_POINTER (t2),
   17758                 :           0 :                     TREE_STRING_LENGTH (t1));
   17759                 :             : 
   17760                 :           0 :     case FIXED_CST:
   17761                 :           0 :       return FIXED_VALUES_IDENTICAL (TREE_FIXED_CST (t1),
   17762                 :             :                                      TREE_FIXED_CST (t2));
   17763                 :             : 
   17764                 :           0 :     case COMPLEX_CST:
   17765                 :           0 :       return c_tree_equal (TREE_REALPART (t1), TREE_REALPART (t2))
   17766                 :           0 :              && c_tree_equal (TREE_IMAGPART (t1), TREE_IMAGPART (t2));
   17767                 :             : 
   17768                 :           0 :     case VECTOR_CST:
   17769                 :           0 :       return operand_equal_p (t1, t2, OEP_ONLY_CONST);
   17770                 :             : 
   17771                 :           0 :     case CONSTRUCTOR:
   17772                 :             :       /* We need to do this when determining whether or not two
   17773                 :             :          non-type pointer to member function template arguments
   17774                 :             :          are the same.  */
   17775                 :           0 :       if (!comptypes (TREE_TYPE (t1), TREE_TYPE (t2))
   17776                 :           0 :           || CONSTRUCTOR_NELTS (t1) != CONSTRUCTOR_NELTS (t2))
   17777                 :             :         return false;
   17778                 :             :       {
   17779                 :             :         tree field, value;
   17780                 :             :         unsigned int i;
   17781                 :           0 :         FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (t1), i, field, value)
   17782                 :             :           {
   17783                 :           0 :             constructor_elt *elt2 = CONSTRUCTOR_ELT (t2, i);
   17784                 :           0 :             if (!c_tree_equal (field, elt2->index)
   17785                 :           0 :                 || !c_tree_equal (value, elt2->value))
   17786                 :           0 :               return false;
   17787                 :             :           }
   17788                 :             :       }
   17789                 :             :       return true;
   17790                 :             : 
   17791                 :           0 :     case TREE_LIST:
   17792                 :           0 :       if (!c_tree_equal (TREE_PURPOSE (t1), TREE_PURPOSE (t2)))
   17793                 :             :         return false;
   17794                 :           0 :       if (!c_tree_equal (TREE_VALUE (t1), TREE_VALUE (t2)))
   17795                 :             :         return false;
   17796                 :           0 :       return c_tree_equal (TREE_CHAIN (t1), TREE_CHAIN (t2));
   17797                 :             : 
   17798                 :           0 :     case SAVE_EXPR:
   17799                 :           0 :       return c_tree_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0));
   17800                 :             : 
   17801                 :          25 :     case CALL_EXPR:
   17802                 :          25 :       {
   17803                 :          25 :         tree arg1, arg2;
   17804                 :          25 :         call_expr_arg_iterator iter1, iter2;
   17805                 :          25 :         if (!c_tree_equal (CALL_EXPR_FN (t1), CALL_EXPR_FN (t2)))
   17806                 :             :           return false;
   17807                 :          50 :         for (arg1 = first_call_expr_arg (t1, &iter1),
   17808                 :          25 :                arg2 = first_call_expr_arg (t2, &iter2);
   17809                 :          25 :              arg1 && arg2;
   17810                 :           0 :              arg1 = next_call_expr_arg (&iter1),
   17811                 :           0 :                arg2 = next_call_expr_arg (&iter2))
   17812                 :           0 :           if (!c_tree_equal (arg1, arg2))
   17813                 :             :             return false;
   17814                 :          25 :         if (arg1 || arg2)
   17815                 :             :           return false;
   17816                 :             :         return true;
   17817                 :             :       }
   17818                 :             : 
   17819                 :           0 :     case TARGET_EXPR:
   17820                 :           0 :       {
   17821                 :           0 :         tree o1 = TREE_OPERAND (t1, 0);
   17822                 :           0 :         tree o2 = TREE_OPERAND (t2, 0);
   17823                 :             : 
   17824                 :             :         /* Special case: if either target is an unallocated VAR_DECL,
   17825                 :             :            it means that it's going to be unified with whatever the
   17826                 :             :            TARGET_EXPR is really supposed to initialize, so treat it
   17827                 :             :            as being equivalent to anything.  */
   17828                 :           0 :         if (VAR_P (o1) && DECL_NAME (o1) == NULL_TREE
   17829                 :           0 :             && !DECL_RTL_SET_P (o1))
   17830                 :             :           /*Nop*/;
   17831                 :           0 :         else if (VAR_P (o2) && DECL_NAME (o2) == NULL_TREE
   17832                 :           0 :                  && !DECL_RTL_SET_P (o2))
   17833                 :             :           /*Nop*/;
   17834                 :           0 :         else if (!c_tree_equal (o1, o2))
   17835                 :             :           return false;
   17836                 :             : 
   17837                 :           0 :         return c_tree_equal (TREE_OPERAND (t1, 1), TREE_OPERAND (t2, 1));
   17838                 :             :       }
   17839                 :             : 
   17840                 :          29 :     case COMPONENT_REF:
   17841                 :          29 :       if (TREE_OPERAND (t1, 1) != TREE_OPERAND (t2, 1))
   17842                 :             :         return false;
   17843                 :          29 :       return c_tree_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0));
   17844                 :             : 
   17845                 :             :     case PARM_DECL:
   17846                 :             :     case VAR_DECL:
   17847                 :             :     case CONST_DECL:
   17848                 :             :     case FIELD_DECL:
   17849                 :             :     case FUNCTION_DECL:
   17850                 :             :     case IDENTIFIER_NODE:
   17851                 :             :     case SSA_NAME:
   17852                 :             :       return false;
   17853                 :             : 
   17854                 :           0 :     case TREE_VEC:
   17855                 :           0 :       {
   17856                 :           0 :         unsigned ix;
   17857                 :           0 :         if (TREE_VEC_LENGTH (t1) != TREE_VEC_LENGTH (t2))
   17858                 :             :           return false;
   17859                 :           0 :         for (ix = TREE_VEC_LENGTH (t1); ix--;)
   17860                 :           0 :           if (!c_tree_equal (TREE_VEC_ELT (t1, ix),
   17861                 :           0 :                              TREE_VEC_ELT (t2, ix)))
   17862                 :             :             return false;
   17863                 :             :         return true;
   17864                 :             :       }
   17865                 :             : 
   17866                 :          22 :     CASE_CONVERT:
   17867                 :          22 :       if (!comptypes (TREE_TYPE (t1), TREE_TYPE (t2)))
   17868                 :             :         return false;
   17869                 :             :       break;
   17870                 :             : 
   17871                 :             :     default:
   17872                 :             :       break;
   17873                 :             :     }
   17874                 :             : 
   17875                 :         131 :   switch (TREE_CODE_CLASS (code1))
   17876                 :             :     {
   17877                 :         131 :     case tcc_unary:
   17878                 :         131 :     case tcc_binary:
   17879                 :         131 :     case tcc_comparison:
   17880                 :         131 :     case tcc_expression:
   17881                 :         131 :     case tcc_vl_exp:
   17882                 :         131 :     case tcc_reference:
   17883                 :         131 :     case tcc_statement:
   17884                 :         131 :       {
   17885                 :         131 :         int i, n = TREE_OPERAND_LENGTH (t1);
   17886                 :             : 
   17887                 :         131 :         switch (code1)
   17888                 :             :           {
   17889                 :           0 :           case PREINCREMENT_EXPR:
   17890                 :           0 :           case PREDECREMENT_EXPR:
   17891                 :           0 :           case POSTINCREMENT_EXPR:
   17892                 :           0 :           case POSTDECREMENT_EXPR:
   17893                 :           0 :             n = 1;
   17894                 :           0 :             break;
   17895                 :          16 :           case ARRAY_REF:
   17896                 :          16 :             n = 2;
   17897                 :          16 :             break;
   17898                 :             :           default:
   17899                 :             :             break;
   17900                 :             :           }
   17901                 :             : 
   17902                 :         131 :         if (TREE_CODE_CLASS (code1) == tcc_vl_exp
   17903                 :         131 :             && n != TREE_OPERAND_LENGTH (t2))
   17904                 :             :           return false;
   17905                 :             : 
   17906                 :         305 :         for (i = 0; i < n; ++i)
   17907                 :         186 :           if (!c_tree_equal (TREE_OPERAND (t1, i), TREE_OPERAND (t2, i)))
   17908                 :             :             return false;
   17909                 :             : 
   17910                 :             :         return true;
   17911                 :             :       }
   17912                 :             : 
   17913                 :           0 :     case tcc_type:
   17914                 :           0 :       return comptypes (t1, t2);
   17915                 :           0 :     default:
   17916                 :           0 :       gcc_unreachable ();
   17917                 :             :     }
   17918                 :             : }
   17919                 :             : 
   17920                 :             : /* Returns true when the function declaration FNDECL is implicit,
   17921                 :             :    introduced as a result of a call to an otherwise undeclared
   17922                 :             :    function, and false otherwise.  */
   17923                 :             : 
   17924                 :             : bool
   17925                 :        2013 : c_decl_implicit (const_tree fndecl)
   17926                 :             : {
   17927                 :        2013 :   return C_DECL_IMPLICIT (fndecl);
   17928                 :             : }
        

Generated by: LCOV version 2.1-beta

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