LCOV - code coverage report
Current view: top level - gcc/c - c-typeck.cc (source / functions) Coverage Total Hit
Test: gcc.info Lines: 93.1 % 8158 7596
Test Date: 2024-04-20 14:03:02 Functions: 99.4 % 164 163
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 "gcc-rich-location.h"
      52                 :             : #include "stringpool.h"
      53                 :             : #include "attribs.h"
      54                 :             : #include "asan.h"
      55                 :             : #include "realmpfr.h"
      56                 :             : 
      57                 :             : /* Possible cases of implicit conversions.  Used to select diagnostic messages
      58                 :             :    and control folding initializers in convert_for_assignment.  */
      59                 :             : enum impl_conv {
      60                 :             :   ic_argpass,
      61                 :             :   ic_assign,
      62                 :             :   ic_init,
      63                 :             :   ic_init_const,
      64                 :             :   ic_return
      65                 :             : };
      66                 :             : 
      67                 :             : /* The level of nesting inside "__alignof__".  */
      68                 :             : int in_alignof;
      69                 :             : 
      70                 :             : /* The level of nesting inside "sizeof".  */
      71                 :             : int in_sizeof;
      72                 :             : 
      73                 :             : /* The level of nesting inside "typeof".  */
      74                 :             : int in_typeof;
      75                 :             : 
      76                 :             : /* True when parsing OpenMP loop expressions.  */
      77                 :             : bool c_in_omp_for;
      78                 :             : 
      79                 :             : /* True when parsing OpenMP map clause.  */
      80                 :             : bool c_omp_array_section_p;
      81                 :             : 
      82                 :             : /* The argument of last parsed sizeof expression, only to be tested
      83                 :             :    if expr.original_code == SIZEOF_EXPR.  */
      84                 :             : tree c_last_sizeof_arg;
      85                 :             : location_t c_last_sizeof_loc;
      86                 :             : 
      87                 :             : /* Nonzero if we might need to print a "missing braces around
      88                 :             :    initializer" message within this initializer.  */
      89                 :             : static int found_missing_braces;
      90                 :             : 
      91                 :             : static bool require_constant_value;
      92                 :             : static bool require_constant_elements;
      93                 :             : static bool require_constexpr_value;
      94                 :             : 
      95                 :             : static tree qualify_type (tree, tree);
      96                 :             : struct comptypes_data;
      97                 :             : static bool tagged_types_tu_compatible_p (const_tree, const_tree,
      98                 :             :                                           struct comptypes_data *);
      99                 :             : static bool comp_target_types (location_t, tree, tree);
     100                 :             : static bool function_types_compatible_p (const_tree, const_tree,
     101                 :             :                                          struct comptypes_data *);
     102                 :             : static bool type_lists_compatible_p (const_tree, const_tree,
     103                 :             :                                      struct comptypes_data *);
     104                 :             : static tree lookup_field (tree, tree);
     105                 :             : static int convert_arguments (location_t, vec<location_t>, tree,
     106                 :             :                               vec<tree, va_gc> *, vec<tree, va_gc> *, tree,
     107                 :             :                               tree);
     108                 :             : static tree pointer_diff (location_t, tree, tree, tree *);
     109                 :             : static tree convert_for_assignment (location_t, location_t, tree, tree, tree,
     110                 :             :                                     enum impl_conv, bool, tree, tree, int,
     111                 :             :                                     int = 0);
     112                 :             : static tree valid_compound_expr_initializer (tree, tree);
     113                 :             : static void push_string (const char *);
     114                 :             : static void push_member_name (tree);
     115                 :             : static int spelling_length (void);
     116                 :             : static char *print_spelling (char *);
     117                 :             : static void warning_init (location_t, int, const char *);
     118                 :             : static tree digest_init (location_t, tree, tree, tree, bool, bool, bool, bool,
     119                 :             :                          bool, bool);
     120                 :             : static void output_init_element (location_t, tree, tree, bool, tree, tree, bool,
     121                 :             :                                  bool, struct obstack *);
     122                 :             : static void output_pending_init_elements (int, struct obstack *);
     123                 :             : static bool set_designator (location_t, bool, struct obstack *);
     124                 :             : static void push_range_stack (tree, struct obstack *);
     125                 :             : static void add_pending_init (location_t, tree, tree, tree, bool,
     126                 :             :                               struct obstack *);
     127                 :             : static void set_nonincremental_init (struct obstack *);
     128                 :             : static void set_nonincremental_init_from_string (tree, struct obstack *);
     129                 :             : static tree find_init_member (tree, struct obstack *);
     130                 :             : static void readonly_warning (tree, enum lvalue_use);
     131                 :             : static int lvalue_or_else (location_t, const_tree, enum lvalue_use);
     132                 :             : static void record_maybe_used_decl (tree);
     133                 :             : static bool comptypes_internal (const_tree, const_tree,
     134                 :             :                                 struct comptypes_data *data);
     135                 :             : 
     136                 :             : /* Return true if EXP is a null pointer constant, false otherwise.  */
     137                 :             : 
     138                 :             : bool
     139                 :   167271069 : null_pointer_constant_p (const_tree expr)
     140                 :             : {
     141                 :             :   /* This should really operate on c_expr structures, but they aren't
     142                 :             :      yet available everywhere required.  */
     143                 :   167271069 :   tree type = TREE_TYPE (expr);
     144                 :             : 
     145                 :             :   /* An integer constant expression with the value 0, such an expression
     146                 :             :      cast to type void*, or the predefined constant nullptr, are a null
     147                 :             :      pointer constant.  */
     148                 :   167271069 :   if (expr == nullptr_node)
     149                 :             :     return true;
     150                 :             : 
     151                 :   167270956 :   return (TREE_CODE (expr) == INTEGER_CST
     152                 :    17390090 :           && !TREE_OVERFLOW (expr)
     153                 :    17390007 :           && integer_zerop (expr)
     154                 :   170975884 :           && (INTEGRAL_TYPE_P (type)
     155                 :      286721 :               || (TREE_CODE (type) == POINTER_TYPE
     156                 :      286719 :                   && VOID_TYPE_P (TREE_TYPE (type))
     157                 :      233612 :                   && TYPE_QUALS (TREE_TYPE (type)) == TYPE_UNQUALIFIED)));
     158                 :             : }
     159                 :             : 
     160                 :             : /* EXPR may appear in an unevaluated part of an integer constant
     161                 :             :    expression, but not in an evaluated part.  Wrap it in a
     162                 :             :    C_MAYBE_CONST_EXPR, or mark it with TREE_OVERFLOW if it is just an
     163                 :             :    INTEGER_CST and we cannot create a C_MAYBE_CONST_EXPR.  */
     164                 :             : 
     165                 :             : static tree
     166                 :       76262 : note_integer_operands (tree expr)
     167                 :             : {
     168                 :       76262 :   tree ret;
     169                 :       76262 :   if (TREE_CODE (expr) == INTEGER_CST && in_late_binary_op)
     170                 :             :     {
     171                 :          22 :       ret = copy_node (expr);
     172                 :          22 :       TREE_OVERFLOW (ret) = 1;
     173                 :             :     }
     174                 :             :   else
     175                 :             :     {
     176                 :       76240 :       ret = build2 (C_MAYBE_CONST_EXPR, TREE_TYPE (expr), NULL_TREE, expr);
     177                 :       76240 :       C_MAYBE_CONST_EXPR_INT_OPERANDS (ret) = 1;
     178                 :             :     }
     179                 :       76262 :   return ret;
     180                 :             : }
     181                 :             : 
     182                 :             : /* Having checked whether EXPR may appear in an unevaluated part of an
     183                 :             :    integer constant expression and found that it may, remove any
     184                 :             :    C_MAYBE_CONST_EXPR noting this fact and return the resulting
     185                 :             :    expression.  */
     186                 :             : 
     187                 :             : static inline tree
     188                 :    30118993 : remove_c_maybe_const_expr (tree expr)
     189                 :             : {
     190                 :    30118993 :   if (TREE_CODE (expr) == C_MAYBE_CONST_EXPR)
     191                 :       61461 :     return C_MAYBE_CONST_EXPR_EXPR (expr);
     192                 :             :   else
     193                 :             :     return expr;
     194                 :             : }
     195                 :             : 
     196                 :             : /* This is a cache to hold if two types are seen.  */
     197                 :             : 
     198                 :             : struct tagged_tu_seen_cache {
     199                 :             :   const struct tagged_tu_seen_cache * next;
     200                 :             :   const_tree t1;
     201                 :             :   const_tree t2;
     202                 :             : };
     203                 :             : 
     204                 :             : /* Do `exp = require_complete_type (loc, exp);' to make sure exp
     205                 :             :    does not have an incomplete type.  (That includes void types.)
     206                 :             :    LOC is the location of the use.  */
     207                 :             : 
     208                 :             : tree
     209                 :   684099216 : require_complete_type (location_t loc, tree value)
     210                 :             : {
     211                 :   684099216 :   tree type = TREE_TYPE (value);
     212                 :             : 
     213                 :   684099216 :   if (error_operand_p (value))
     214                 :        8333 :     return error_mark_node;
     215                 :             : 
     216                 :             :   /* First, detect a valid value with a complete type.  */
     217                 :   684090883 :   if (COMPLETE_TYPE_P (type))
     218                 :             :     return value;
     219                 :             : 
     220                 :         108 :   c_incomplete_type_error (loc, value, type);
     221                 :         108 :   return error_mark_node;
     222                 :             : }
     223                 :             : 
     224                 :             : /* Print an error message for invalid use of an incomplete type.
     225                 :             :    VALUE is the expression that was used (or 0 if that isn't known)
     226                 :             :    and TYPE is the type that was invalid.  LOC is the location for
     227                 :             :    the error.  */
     228                 :             : 
     229                 :             : void
     230                 :         164 : c_incomplete_type_error (location_t loc, const_tree value, const_tree type)
     231                 :             : {
     232                 :             :   /* Avoid duplicate error message.  */
     233                 :         164 :   if (TREE_CODE (type) == ERROR_MARK)
     234                 :             :     return;
     235                 :             : 
     236                 :         164 :   if (value != NULL_TREE && (VAR_P (value) || TREE_CODE (value) == PARM_DECL))
     237                 :          88 :     error_at (loc, "%qD has an incomplete type %qT", value, type);
     238                 :             :   else
     239                 :             :     {
     240                 :          76 :     retry:
     241                 :             :       /* We must print an error message.  Be clever about what it says.  */
     242                 :             : 
     243                 :          76 :       switch (TREE_CODE (type))
     244                 :             :         {
     245                 :          70 :         case RECORD_TYPE:
     246                 :          70 :         case UNION_TYPE:
     247                 :          70 :         case ENUMERAL_TYPE:
     248                 :          70 :           break;
     249                 :             : 
     250                 :           0 :         case VOID_TYPE:
     251                 :           0 :           error_at (loc, "invalid use of void expression");
     252                 :           0 :           return;
     253                 :             : 
     254                 :           6 :         case ARRAY_TYPE:
     255                 :           6 :           if (TYPE_DOMAIN (type))
     256                 :             :             {
     257                 :           3 :               if (TYPE_MAX_VALUE (TYPE_DOMAIN (type)) == NULL)
     258                 :             :                 {
     259                 :           3 :                   error_at (loc, "invalid use of flexible array member");
     260                 :           3 :                   return;
     261                 :             :                 }
     262                 :           0 :               type = TREE_TYPE (type);
     263                 :           0 :               goto retry;
     264                 :             :             }
     265                 :           3 :           error_at (loc, "invalid use of array with unspecified bounds");
     266                 :           3 :           return;
     267                 :             : 
     268                 :           0 :         default:
     269                 :           0 :           gcc_unreachable ();
     270                 :             :         }
     271                 :             : 
     272                 :          70 :       if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
     273                 :          68 :         error_at (loc, "invalid use of undefined type %qT", type);
     274                 :             :       else
     275                 :             :         /* If this type has a typedef-name, the TYPE_NAME is a TYPE_DECL.  */
     276                 :           2 :         error_at (loc, "invalid use of incomplete typedef %qT", type);
     277                 :             :     }
     278                 :             : }
     279                 :             : 
     280                 :             : /* Given a type, apply default promotions wrt unnamed function
     281                 :             :    arguments and return the new type.  */
     282                 :             : 
     283                 :             : tree
     284                 :   125259707 : c_type_promotes_to (tree type)
     285                 :             : {
     286                 :   125259707 :   tree ret = NULL_TREE;
     287                 :             : 
     288                 :   125259707 :   if (TYPE_MAIN_VARIANT (type) == float_type_node)
     289                 :     1253650 :     ret = double_type_node;
     290                 :   124006057 :   else if (c_promoting_integer_type_p (type))
     291                 :             :     {
     292                 :             :       /* Preserve unsignedness if not really getting any wider.  */
     293                 :    32772976 :       if (TYPE_UNSIGNED (type)
     294                 :    32772976 :           && (TYPE_PRECISION (type) == TYPE_PRECISION (integer_type_node)))
     295                 :           0 :         ret = unsigned_type_node;
     296                 :             :       else
     297                 :    32772976 :         ret = integer_type_node;
     298                 :             :     }
     299                 :             : 
     300                 :    34026626 :   if (ret != NULL_TREE)
     301                 :    34026626 :     return (TYPE_ATOMIC (type)
     302                 :    34026626 :             ? c_build_qualified_type (ret, TYPE_QUAL_ATOMIC)
     303                 :             :             : ret);
     304                 :             : 
     305                 :             :   return type;
     306                 :             : }
     307                 :             : 
     308                 :             : /* Return true if between two named address spaces, whether there is a superset
     309                 :             :    named address space that encompasses both address spaces.  If there is a
     310                 :             :    superset, return which address space is the superset.  */
     311                 :             : 
     312                 :             : static bool
     313                 :     6415256 : addr_space_superset (addr_space_t as1, addr_space_t as2, addr_space_t *common)
     314                 :             : {
     315                 :     6415256 :   if (as1 == as2)
     316                 :             :     {
     317                 :     6415256 :       *common = as1;
     318                 :     6415256 :       return true;
     319                 :             :     }
     320                 :           0 :   else if (targetm.addr_space.subset_p (as1, as2))
     321                 :             :     {
     322                 :           0 :       *common = as2;
     323                 :           0 :       return true;
     324                 :             :     }
     325                 :           0 :   else if (targetm.addr_space.subset_p (as2, as1))
     326                 :             :     {
     327                 :           0 :       *common = as1;
     328                 :           0 :       return true;
     329                 :             :     }
     330                 :             :   else
     331                 :             :     return false;
     332                 :             : }
     333                 :             : 
     334                 :             : /* Return a variant of TYPE which has all the type qualifiers of LIKE
     335                 :             :    as well as those of TYPE.  */
     336                 :             : 
     337                 :             : static tree
     338                 :     2051782 : qualify_type (tree type, tree like)
     339                 :             : {
     340                 :     2051782 :   addr_space_t as_type = TYPE_ADDR_SPACE (type);
     341                 :     2051782 :   addr_space_t as_like = TYPE_ADDR_SPACE (like);
     342                 :     2051782 :   addr_space_t as_common;
     343                 :             : 
     344                 :             :   /* If the two named address spaces are different, determine the common
     345                 :             :      superset address space.  If there isn't one, raise an error.  */
     346                 :     2051782 :   if (!addr_space_superset (as_type, as_like, &as_common))
     347                 :             :     {
     348                 :           0 :       as_common = as_type;
     349                 :           0 :       error ("%qT and %qT are in disjoint named address spaces",
     350                 :             :              type, like);
     351                 :             :     }
     352                 :             : 
     353                 :     4103564 :   return c_build_qualified_type (type,
     354                 :     2051782 :                                  TYPE_QUALS_NO_ADDR_SPACE (type)
     355                 :     2051782 :                                  | TYPE_QUALS_NO_ADDR_SPACE_NO_ATOMIC (like)
     356                 :     2051782 :                                  | ENCODE_QUAL_ADDR_SPACE (as_common));
     357                 :             : }
     358                 :             : 
     359                 :             : 
     360                 :             : /* If NTYPE is a type of a non-variadic function with a prototype
     361                 :             :    and OTYPE is a type of a function without a prototype and ATTRS
     362                 :             :    contains attribute format, diagnosess and removes it from ATTRS.
     363                 :             :    Returns the result of build_type_attribute_variant of NTYPE and
     364                 :             :    the (possibly) modified ATTRS.  */
     365                 :             : 
     366                 :             : static tree
     367                 :       10355 : build_functype_attribute_variant (tree ntype, tree otype, tree attrs)
     368                 :             : {
     369                 :       10355 :   if (!prototype_p (otype)
     370                 :       10343 :       && prototype_p (ntype)
     371                 :       20632 :       && lookup_attribute ("format", attrs))
     372                 :             :     {
     373                 :          14 :       warning_at (input_location, OPT_Wattributes,
     374                 :             :                   "%qs attribute cannot be applied to a function that "
     375                 :             :                   "does not take variable arguments", "format");
     376                 :          14 :       attrs = remove_attribute ("format", attrs);
     377                 :             :     }
     378                 :       10355 :   return build_type_attribute_variant (ntype, attrs);
     379                 :             : 
     380                 :             : }
     381                 :             : /* Return the composite type of two compatible types.
     382                 :             : 
     383                 :             :    We assume that comptypes has already been done and returned
     384                 :             :    nonzero; if that isn't so, this may crash.  In particular, we
     385                 :             :    assume that qualifiers match.  */
     386                 :             : 
     387                 :             : struct composite_cache {
     388                 :             :   tree t1;
     389                 :             :   tree t2;
     390                 :             :   tree composite;
     391                 :             :   struct composite_cache* next;
     392                 :             : };
     393                 :             : 
     394                 :             : tree
     395                 :    10437235 : composite_type_internal (tree t1, tree t2, struct composite_cache* cache)
     396                 :             : {
     397                 :    10437235 :   enum tree_code code1;
     398                 :    10437235 :   enum tree_code code2;
     399                 :    10437235 :   tree attributes;
     400                 :             : 
     401                 :             :   /* Save time if the two types are the same.  */
     402                 :             : 
     403                 :    10437235 :   if (t1 == t2) return t1;
     404                 :             : 
     405                 :             :   /* If one type is nonsense, use the other.  */
     406                 :     2089707 :   if (t1 == error_mark_node)
     407                 :             :     return t2;
     408                 :     2089705 :   if (t2 == error_mark_node)
     409                 :             :     return t1;
     410                 :             : 
     411                 :     2089704 :   code1 = TREE_CODE (t1);
     412                 :     2089704 :   code2 = TREE_CODE (t2);
     413                 :             : 
     414                 :             :   /* Merge the attributes.  */
     415                 :     2089704 :   attributes = targetm.merge_type_attributes (t1, t2);
     416                 :             : 
     417                 :             :   /* If one is an enumerated type and the other is the compatible
     418                 :             :      integer type, the composite type might be either of the two
     419                 :             :      (DR#013 question 3).  For consistency, use the enumerated type as
     420                 :             :      the composite type.  */
     421                 :             : 
     422                 :     2089704 :   if (code1 == ENUMERAL_TYPE
     423                 :         195 :       && (code2 == INTEGER_TYPE
     424                 :         195 :           || code2 == BOOLEAN_TYPE))
     425                 :             :     return t1;
     426                 :     2089509 :   if (code2 == ENUMERAL_TYPE
     427                 :          69 :       && (code1 == INTEGER_TYPE
     428                 :          69 :           || code1 == BOOLEAN_TYPE))
     429                 :             :     return t2;
     430                 :             : 
     431                 :     2089440 :   gcc_assert (code1 == code2);
     432                 :             : 
     433                 :     2089440 :   switch (code1)
     434                 :             :     {
     435                 :        6294 :     case POINTER_TYPE:
     436                 :             :       /* For two pointers, do this recursively on the target type.  */
     437                 :        6294 :       {
     438                 :        6294 :         tree pointed_to_1 = TREE_TYPE (t1);
     439                 :        6294 :         tree pointed_to_2 = TREE_TYPE (t2);
     440                 :        6294 :         tree target = composite_type_internal (pointed_to_1,
     441                 :             :                                                pointed_to_2, cache);
     442                 :        6294 :         t1 = build_pointer_type_for_mode (target, TYPE_MODE (t1), false);
     443                 :        6294 :         t1 = build_type_attribute_variant (t1, attributes);
     444                 :        6294 :         return qualify_type (t1, t2);
     445                 :             :       }
     446                 :             : 
     447                 :       10999 :     case ARRAY_TYPE:
     448                 :       10999 :       {
     449                 :       10999 :         tree elt = composite_type_internal (TREE_TYPE (t1), TREE_TYPE (t2),
     450                 :             :                                             cache);
     451                 :       10999 :         int quals;
     452                 :       10999 :         tree unqual_elt;
     453                 :       10999 :         tree d1 = TYPE_DOMAIN (t1);
     454                 :       10999 :         tree d2 = TYPE_DOMAIN (t2);
     455                 :       10999 :         bool d1_variable, d2_variable;
     456                 :       10999 :         bool d1_zero, d2_zero;
     457                 :       10999 :         bool t1_complete, t2_complete;
     458                 :             : 
     459                 :             :         /* We should not have any type quals on arrays at all.  */
     460                 :       10999 :         gcc_assert (!TYPE_QUALS_NO_ADDR_SPACE (t1)
     461                 :             :                     && !TYPE_QUALS_NO_ADDR_SPACE (t2));
     462                 :             : 
     463                 :       10999 :         t1_complete = COMPLETE_TYPE_P (t1);
     464                 :       10999 :         t2_complete = COMPLETE_TYPE_P (t2);
     465                 :             : 
     466                 :       10999 :         d1_zero = d1 == NULL_TREE || !TYPE_MAX_VALUE (d1);
     467                 :       10999 :         d2_zero = d2 == NULL_TREE || !TYPE_MAX_VALUE (d2);
     468                 :             : 
     469                 :       21998 :         d1_variable = (!d1_zero
     470                 :       10999 :                        && (TREE_CODE (TYPE_MIN_VALUE (d1)) != INTEGER_CST
     471                 :       10381 :                            || TREE_CODE (TYPE_MAX_VALUE (d1)) != INTEGER_CST));
     472                 :       21998 :         d2_variable = (!d2_zero
     473                 :       10999 :                        && (TREE_CODE (TYPE_MIN_VALUE (d2)) != INTEGER_CST
     474                 :       10637 :                            || TREE_CODE (TYPE_MAX_VALUE (d2)) != INTEGER_CST));
     475                 :       10999 :         d1_variable = d1_variable || (d1_zero && C_TYPE_VARIABLE_SIZE (t1));
     476                 :       10999 :         d2_variable = d2_variable || (d2_zero && C_TYPE_VARIABLE_SIZE (t2));
     477                 :             : 
     478                 :             :         /* Save space: see if the result is identical to one of the args.  */
     479                 :       21898 :         if (elt == TREE_TYPE (t1) && TYPE_DOMAIN (t1)
     480                 :       21345 :             && (d2_variable || d2_zero || !d1_variable))
     481                 :       10258 :           return build_type_attribute_variant (t1, attributes);
     482                 :        1388 :         if (elt == TREE_TYPE (t2) && TYPE_DOMAIN (t2)
     483                 :        1385 :             && (d1_variable || d1_zero || !d2_variable))
     484                 :         642 :           return build_type_attribute_variant (t2, attributes);
     485                 :             : 
     486                 :          99 :         if (elt == TREE_TYPE (t1) && !TYPE_DOMAIN (t2) && !TYPE_DOMAIN (t1))
     487                 :          10 :           return build_type_attribute_variant (t1, attributes);
     488                 :          89 :         if (elt == TREE_TYPE (t2) && !TYPE_DOMAIN (t2) && !TYPE_DOMAIN (t1))
     489                 :           2 :           return build_type_attribute_variant (t2, attributes);
     490                 :             : 
     491                 :             :         /* Merge the element types, and have a size if either arg has
     492                 :             :            one.  We may have qualifiers on the element types.  To set
     493                 :             :            up TYPE_MAIN_VARIANT correctly, we need to form the
     494                 :             :            composite of the unqualified types and add the qualifiers
     495                 :             :            back at the end.  */
     496                 :          87 :         quals = TYPE_QUALS (strip_array_types (elt));
     497                 :          87 :         unqual_elt = c_build_qualified_type (elt, TYPE_UNQUALIFIED);
     498                 :          87 :         t1 = build_array_type (unqual_elt,
     499                 :         174 :                                TYPE_DOMAIN ((TYPE_DOMAIN (t1)
     500                 :             :                                              && (d2_variable
     501                 :             :                                                  || d2_zero
     502                 :             :                                                  || !d1_variable))
     503                 :             :                                             ? t1
     504                 :             :                                             : t2));
     505                 :             :         /* Ensure a composite type involving a zero-length array type
     506                 :             :            is a zero-length type not an incomplete type.  */
     507                 :          87 :         if (d1_zero && d2_zero
     508                 :          16 :             && (t1_complete || t2_complete)
     509                 :          88 :             && !COMPLETE_TYPE_P (t1))
     510                 :             :           {
     511                 :           1 :             TYPE_SIZE (t1) = bitsize_zero_node;
     512                 :           1 :             TYPE_SIZE_UNIT (t1) = size_zero_node;
     513                 :             :           }
     514                 :          87 :         t1 = c_build_qualified_type (t1, quals);
     515                 :          87 :         return build_type_attribute_variant (t1, attributes);
     516                 :             :       }
     517                 :             : 
     518                 :         105 :     case RECORD_TYPE:
     519                 :         105 :     case UNION_TYPE:
     520                 :         105 :       if (flag_isoc23 && !comptypes_same_p (t1, t2))
     521                 :             :         {
     522                 :          67 :           gcc_checking_assert (COMPLETE_TYPE_P (t1) && COMPLETE_TYPE_P (t2));
     523                 :          67 :           gcc_checking_assert (!TYPE_NAME (t1) || comptypes (t1, t2));
     524                 :             : 
     525                 :             :           /* If a composite type for these two types is already under
     526                 :             :              construction, return it.  */
     527                 :             : 
     528                 :         146 :           for (struct composite_cache *c = cache; c != NULL; c = c->next)
     529                 :          79 :             if (c->t1 == t1 && c->t2 == t2)
     530                 :           0 :                return c->composite;
     531                 :             : 
     532                 :             :           /* Otherwise, create a new type node and link it into the cache.  */
     533                 :             : 
     534                 :          67 :           tree n = make_node (code1);
     535                 :          67 :           SET_TYPE_STRUCTURAL_EQUALITY (n);
     536                 :          67 :           TYPE_NAME (n) = TYPE_NAME (t1);
     537                 :             : 
     538                 :          67 :           struct composite_cache cache2 = { t1, t2, n, cache };
     539                 :          67 :           cache = &cache2;
     540                 :             : 
     541                 :          67 :           tree f1 = TYPE_FIELDS (t1);
     542                 :          67 :           tree f2 = TYPE_FIELDS (t2);
     543                 :          67 :           tree fields = NULL_TREE;
     544                 :             : 
     545                 :         160 :           for (tree a = f1, b = f2; a && b;
     546                 :          93 :                a = DECL_CHAIN (a), b = DECL_CHAIN (b))
     547                 :             :             {
     548                 :          93 :               tree ta = TREE_TYPE (a);
     549                 :          93 :               tree tb = TREE_TYPE (b);
     550                 :             : 
     551                 :          93 :               if (DECL_C_BIT_FIELD (a))
     552                 :             :                 {
     553                 :          19 :                   ta = DECL_BIT_FIELD_TYPE (a);
     554                 :          19 :                   tb = DECL_BIT_FIELD_TYPE (b);
     555                 :             :                 }
     556                 :             : 
     557                 :          93 :               gcc_assert (DECL_NAME (a) == DECL_NAME (b));
     558                 :          93 :               gcc_checking_assert (!DECL_NAME (a) || comptypes (ta, tb));
     559                 :             : 
     560                 :          93 :               tree t = composite_type_internal (ta, tb, cache);
     561                 :          93 :               tree f = build_decl (input_location, FIELD_DECL, DECL_NAME (a), t);
     562                 :             : 
     563                 :          93 :               DECL_PACKED (f) = DECL_PACKED (a);
     564                 :          93 :               SET_DECL_ALIGN (f, DECL_ALIGN (a));
     565                 :          93 :               DECL_ATTRIBUTES (f) = DECL_ATTRIBUTES (a);
     566                 :          93 :               C_DECL_VARIABLE_SIZE (f) = C_TYPE_VARIABLE_SIZE (t);
     567                 :             : 
     568                 :          93 :               finish_decl (f, input_location, NULL, NULL, NULL);
     569                 :             : 
     570                 :          93 :               if (DECL_C_BIT_FIELD (a))
     571                 :             :                 {
     572                 :             :                   /* This will be processed by finish_struct.  */
     573                 :          19 :                   SET_DECL_C_BIT_FIELD (f);
     574                 :          19 :                   DECL_INITIAL (f) = build_int_cst (integer_type_node,
     575                 :          19 :                                                     tree_to_uhwi (DECL_SIZE (a)));
     576                 :          19 :                   DECL_NONADDRESSABLE_P (f) = true;
     577                 :          19 :                   DECL_PADDING_P (f) = !DECL_NAME (a);
     578                 :             :                 }
     579                 :             : 
     580                 :          93 :               DECL_CHAIN (f) = fields;
     581                 :          93 :               fields = f;
     582                 :             :             }
     583                 :             : 
     584                 :          67 :           fields = nreverse (fields);
     585                 :             : 
     586                 :             :           /* Setup the struct/union type.  Because we inherit all variably
     587                 :             :              modified components, we can ignore the size expression.  */
     588                 :          67 :           tree expr = NULL_TREE;
     589                 :             : 
     590                 :             :           /* Set TYPE_STUB_DECL for debugging symbols.  */
     591                 :          67 :           TYPE_STUB_DECL (n) = pushdecl (build_decl (input_location, TYPE_DECL,
     592                 :             :                                                      NULL_TREE, n));
     593                 :             : 
     594                 :          67 :           n = finish_struct (input_location, n, fields, attributes, NULL,
     595                 :             :                              &expr);
     596                 :             : 
     597                 :          67 :           n = qualify_type (n, t1);
     598                 :             : 
     599                 :          67 :           gcc_checking_assert (!TYPE_NAME (n) || comptypes (n, t1));
     600                 :          67 :           gcc_checking_assert (!TYPE_NAME (n) || comptypes (n, t2));
     601                 :             : 
     602                 :          67 :           return n;
     603                 :             :         }
     604                 :             :       /* FALLTHRU */
     605                 :          38 :     case ENUMERAL_TYPE:
     606                 :          38 :       if (attributes != NULL)
     607                 :             :         {
     608                 :             :           /* Try harder not to create a new aggregate type.  */
     609                 :           4 :           if (attribute_list_equal (TYPE_ATTRIBUTES (t1), attributes))
     610                 :             :             return t1;
     611                 :           0 :           if (attribute_list_equal (TYPE_ATTRIBUTES (t2), attributes))
     612                 :             :             return t2;
     613                 :             :         }
     614                 :          34 :       return build_type_attribute_variant (t1, attributes);
     615                 :             : 
     616                 :     2031709 :     case FUNCTION_TYPE:
     617                 :             :       /* Function types: prefer the one that specified arg types.
     618                 :             :          If both do, merge the arg types.  Also merge the return types.  */
     619                 :     2031709 :       {
     620                 :     2031709 :         tree valtype = composite_type_internal (TREE_TYPE (t1),
     621                 :     2031709 :                                                 TREE_TYPE (t2), cache);
     622                 :     2031709 :         tree p1 = TYPE_ARG_TYPES (t1);
     623                 :     2031709 :         tree p2 = TYPE_ARG_TYPES (t2);
     624                 :     2031709 :         int len;
     625                 :     2031709 :         tree newargs, n;
     626                 :     2031709 :         int i;
     627                 :             : 
     628                 :             :         /* Save space: see if the result is identical to one of the args.  */
     629                 :     2031709 :         if (valtype == TREE_TYPE (t1) && !TYPE_ARG_TYPES (t2))
     630                 :        9017 :           return build_functype_attribute_variant (t1, t2, attributes);
     631                 :     2022692 :         if (valtype == TREE_TYPE (t2) && !TYPE_ARG_TYPES (t1))
     632                 :        1338 :           return build_functype_attribute_variant (t2, t1, attributes);
     633                 :             : 
     634                 :             :         /* Simple way if one arg fails to specify argument types.  */
     635                 :     2021354 :         if (TYPE_ARG_TYPES (t1) == NULL_TREE)
     636                 :             :           {
     637                 :           9 :             t1 = build_function_type (valtype, TYPE_ARG_TYPES (t2),
     638                 :           9 :                                       TYPE_NO_NAMED_ARGS_STDARG_P (t2));
     639                 :           9 :             t1 = build_type_attribute_variant (t1, attributes);
     640                 :           9 :             return qualify_type (t1, t2);
     641                 :             :          }
     642                 :     2021345 :         if (TYPE_ARG_TYPES (t2) == NULL_TREE)
     643                 :             :           {
     644                 :           1 :             t1 = build_function_type (valtype, TYPE_ARG_TYPES (t1),
     645                 :           1 :                                       TYPE_NO_NAMED_ARGS_STDARG_P (t1));
     646                 :           1 :             t1 = build_type_attribute_variant (t1, attributes);
     647                 :           1 :             return qualify_type (t1, t2);
     648                 :             :           }
     649                 :             : 
     650                 :             :         /* If both args specify argument types, we must merge the two
     651                 :             :            lists, argument by argument.  */
     652                 :             : 
     653                 :             :         for (len = 0, newargs = p1;
     654                 :     5484390 :              newargs && newargs != void_list_node;
     655                 :     3463046 :              len++, newargs = TREE_CHAIN (newargs))
     656                 :             :           ;
     657                 :             : 
     658                 :     5484390 :         for (i = 0; i < len; i++)
     659                 :     3463046 :           newargs = tree_cons (NULL_TREE, NULL_TREE, newargs);
     660                 :             : 
     661                 :             :         n = newargs;
     662                 :             : 
     663                 :     5484390 :         for (; p1 && p1 != void_list_node;
     664                 :     3463046 :              p1 = TREE_CHAIN (p1), p2 = TREE_CHAIN (p2), n = TREE_CHAIN (n))
     665                 :             :           {
     666                 :     3463046 :              tree mv1 = TREE_VALUE (p1);
     667                 :     3463046 :              if (mv1 && mv1 != error_mark_node
     668                 :     3463044 :                  && TREE_CODE (mv1) != ARRAY_TYPE)
     669                 :     3463044 :                mv1 = TYPE_MAIN_VARIANT (mv1);
     670                 :             : 
     671                 :     3463046 :              tree mv2 = TREE_VALUE (p2);
     672                 :     3463046 :              if (mv2 && mv2 != error_mark_node
     673                 :     3463045 :                  && TREE_CODE (mv2) != ARRAY_TYPE)
     674                 :     3463045 :                mv2 = TYPE_MAIN_VARIANT (mv2);
     675                 :             : 
     676                 :             :             /* A null type means arg type is not specified.
     677                 :             :                Take whatever the other function type has.  */
     678                 :     3463046 :             if (TREE_VALUE (p1) == NULL_TREE)
     679                 :             :               {
     680                 :           0 :                 TREE_VALUE (n) = TREE_VALUE (p2);
     681                 :           0 :                 goto parm_done;
     682                 :             :               }
     683                 :     3463046 :             if (TREE_VALUE (p2) == NULL_TREE)
     684                 :             :               {
     685                 :           0 :                 TREE_VALUE (n) = TREE_VALUE (p1);
     686                 :           0 :                 goto parm_done;
     687                 :             :               }
     688                 :             : 
     689                 :             :             /* Given  wait (union {union wait *u; int *i} *)
     690                 :             :                and  wait (union wait *),
     691                 :             :                prefer  union wait *  as type of parm.  */
     692                 :     3463046 :             if (TREE_CODE (TREE_VALUE (p1)) == UNION_TYPE
     693                 :     3463046 :                 && TREE_VALUE (p1) != TREE_VALUE (p2))
     694                 :             :               {
     695                 :          30 :                 tree memb;
     696                 :          30 :                 for (memb = TYPE_FIELDS (TREE_VALUE (p1));
     697                 :          38 :                      memb; memb = DECL_CHAIN (memb))
     698                 :             :                   {
     699                 :          38 :                     tree mv3 = TREE_TYPE (memb);
     700                 :          38 :                     if (mv3 && mv3 != error_mark_node
     701                 :          38 :                         && TREE_CODE (mv3) != ARRAY_TYPE)
     702                 :          38 :                       mv3 = TYPE_MAIN_VARIANT (mv3);
     703                 :          38 :                     if (comptypes (mv3, mv2))
     704                 :             :                       {
     705                 :          60 :                         TREE_VALUE (n) = composite_type_internal (TREE_TYPE (memb),
     706                 :          30 :                                                                   TREE_VALUE (p2),
     707                 :             :                                                                   cache);
     708                 :          30 :                         pedwarn (input_location, OPT_Wpedantic,
     709                 :             :                                  "function types not truly compatible in ISO C");
     710                 :          30 :                         goto parm_done;
     711                 :             :                       }
     712                 :             :                   }
     713                 :             :               }
     714                 :     3463016 :             if (TREE_CODE (TREE_VALUE (p2)) == UNION_TYPE
     715                 :     3463016 :                 && TREE_VALUE (p2) != TREE_VALUE (p1))
     716                 :             :               {
     717                 :          30 :                 tree memb;
     718                 :          30 :                 for (memb = TYPE_FIELDS (TREE_VALUE (p2));
     719                 :          38 :                      memb; memb = DECL_CHAIN (memb))
     720                 :             :                   {
     721                 :          38 :                     tree mv3 = TREE_TYPE (memb);
     722                 :          38 :                     if (mv3 && mv3 != error_mark_node
     723                 :          38 :                         && TREE_CODE (mv3) != ARRAY_TYPE)
     724                 :          38 :                       mv3 = TYPE_MAIN_VARIANT (mv3);
     725                 :          38 :                     if (comptypes (mv3, mv1))
     726                 :             :                       {
     727                 :          30 :                         TREE_VALUE (n)
     728                 :          30 :                                 = composite_type_internal (TREE_TYPE (memb),
     729                 :          30 :                                                            TREE_VALUE (p1),
     730                 :             :                                                            cache);
     731                 :          30 :                         pedwarn (input_location, OPT_Wpedantic,
     732                 :             :                                  "function types not truly compatible in ISO C");
     733                 :          30 :                         goto parm_done;
     734                 :             :                       }
     735                 :             :                   }
     736                 :             :               }
     737                 :     3462986 :             TREE_VALUE (n) = composite_type_internal (mv1, mv2, cache);
     738                 :     3463046 :           parm_done: ;
     739                 :             :           }
     740                 :             : 
     741                 :     2021344 :         t1 = build_function_type (valtype, newargs);
     742                 :     2021344 :         t1 = qualify_type (t1, t2);
     743                 :             :       }
     744                 :             :       /* FALLTHRU */
     745                 :             : 
     746                 :     2061677 :     default:
     747                 :     2061677 :       return build_type_attribute_variant (t1, attributes);
     748                 :             :     }
     749                 :             : }
     750                 :             : 
     751                 :             : tree
     752                 :     4925094 : composite_type (tree t1, tree t2)
     753                 :             : {
     754                 :     4925094 :   struct composite_cache cache = { };
     755                 :     4925094 :   return composite_type_internal (t1, t2, &cache);
     756                 :             : }
     757                 :             : 
     758                 :             : /* Return the type of a conditional expression between pointers to
     759                 :             :    possibly differently qualified versions of compatible types.
     760                 :             : 
     761                 :             :    We assume that comp_target_types has already been done and returned
     762                 :             :    true; if that isn't so, this may crash.  */
     763                 :             : 
     764                 :             : static tree
     765                 :      110570 : common_pointer_type (tree t1, tree t2)
     766                 :             : {
     767                 :      110570 :   tree attributes;
     768                 :      110570 :   tree pointed_to_1, mv1;
     769                 :      110570 :   tree pointed_to_2, mv2;
     770                 :      110570 :   tree target;
     771                 :      110570 :   unsigned target_quals;
     772                 :      110570 :   addr_space_t as1, as2, as_common;
     773                 :      110570 :   int quals1, quals2;
     774                 :             : 
     775                 :             :   /* Save time if the two types are the same.  */
     776                 :             : 
     777                 :      110570 :   if (t1 == t2) return t1;
     778                 :             : 
     779                 :             :   /* If one type is nonsense, use the other.  */
     780                 :        4453 :   if (t1 == error_mark_node)
     781                 :             :     return t2;
     782                 :        4453 :   if (t2 == error_mark_node)
     783                 :             :     return t1;
     784                 :             : 
     785                 :        4453 :   gcc_assert (TREE_CODE (t1) == POINTER_TYPE
     786                 :             :               && TREE_CODE (t2) == POINTER_TYPE);
     787                 :             : 
     788                 :             :   /* Merge the attributes.  */
     789                 :        4453 :   attributes = targetm.merge_type_attributes (t1, t2);
     790                 :             : 
     791                 :             :   /* Find the composite type of the target types, and combine the
     792                 :             :      qualifiers of the two types' targets.  Do not lose qualifiers on
     793                 :             :      array element types by taking the TYPE_MAIN_VARIANT.  */
     794                 :        4453 :   mv1 = pointed_to_1 = TREE_TYPE (t1);
     795                 :        4453 :   mv2 = pointed_to_2 = TREE_TYPE (t2);
     796                 :        4453 :   if (TREE_CODE (mv1) != ARRAY_TYPE)
     797                 :        4071 :     mv1 = TYPE_MAIN_VARIANT (pointed_to_1);
     798                 :        4453 :   if (TREE_CODE (mv2) != ARRAY_TYPE)
     799                 :        4071 :     mv2 = TYPE_MAIN_VARIANT (pointed_to_2);
     800                 :        4453 :   target = composite_type (mv1, mv2);
     801                 :             : 
     802                 :             :   /* Strip array types to get correct qualifier for pointers to arrays */
     803                 :        4453 :   quals1 = TYPE_QUALS_NO_ADDR_SPACE (strip_array_types (pointed_to_1));
     804                 :        4453 :   quals2 = TYPE_QUALS_NO_ADDR_SPACE (strip_array_types (pointed_to_2));
     805                 :             : 
     806                 :             :   /* For function types do not merge const qualifiers, but drop them
     807                 :             :      if used inconsistently.  The middle-end uses these to mark const
     808                 :             :      and noreturn functions.  */
     809                 :        4453 :   if (TREE_CODE (pointed_to_1) == FUNCTION_TYPE)
     810                 :        2198 :     target_quals = (quals1 & quals2);
     811                 :             :   else
     812                 :        2255 :     target_quals = (quals1 | quals2);
     813                 :             : 
     814                 :             :   /* If the two named address spaces are different, determine the common
     815                 :             :      superset address space.  This is guaranteed to exist due to the
     816                 :             :      assumption that comp_target_type returned true.  */
     817                 :        4453 :   as1 = TYPE_ADDR_SPACE (pointed_to_1);
     818                 :        4453 :   as2 = TYPE_ADDR_SPACE (pointed_to_2);
     819                 :        4453 :   if (!addr_space_superset (as1, as2, &as_common))
     820                 :           0 :     gcc_unreachable ();
     821                 :             : 
     822                 :        4453 :   target_quals |= ENCODE_QUAL_ADDR_SPACE (as_common);
     823                 :             : 
     824                 :        4453 :   t1 = build_pointer_type (c_build_qualified_type (target, target_quals));
     825                 :        4453 :   return build_type_attribute_variant (t1, attributes);
     826                 :             : }
     827                 :             : 
     828                 :             : /* Return the common type for two arithmetic types under the usual
     829                 :             :    arithmetic conversions.  The default conversions have already been
     830                 :             :    applied, and enumerated types converted to their compatible integer
     831                 :             :    types.  The resulting type is unqualified and has no attributes.
     832                 :             : 
     833                 :             :    This is the type for the result of most arithmetic operations
     834                 :             :    if the operands have the given two types.  */
     835                 :             : 
     836                 :             : static tree
     837                 :    13186555 : c_common_type (tree t1, tree t2)
     838                 :             : {
     839                 :    13186555 :   enum tree_code code1;
     840                 :    13186555 :   enum tree_code code2;
     841                 :             : 
     842                 :             :   /* If one type is nonsense, use the other.  */
     843                 :    13186555 :   if (t1 == error_mark_node)
     844                 :             :     return t2;
     845                 :    13186555 :   if (t2 == error_mark_node)
     846                 :             :     return t1;
     847                 :             : 
     848                 :    13186555 :   if (TYPE_QUALS (t1) != TYPE_UNQUALIFIED)
     849                 :       37702 :     t1 = TYPE_MAIN_VARIANT (t1);
     850                 :             : 
     851                 :    13186555 :   if (TYPE_QUALS (t2) != TYPE_UNQUALIFIED)
     852                 :       49123 :     t2 = TYPE_MAIN_VARIANT (t2);
     853                 :             : 
     854                 :    13186555 :   if (TYPE_ATTRIBUTES (t1) != NULL_TREE)
     855                 :             :     {
     856                 :      182462 :       tree attrs = affects_type_identity_attributes (TYPE_ATTRIBUTES (t1));
     857                 :      182462 :       t1 = build_type_attribute_variant (t1, attrs);
     858                 :             :     }
     859                 :             : 
     860                 :    13186555 :   if (TYPE_ATTRIBUTES (t2) != NULL_TREE)
     861                 :             :     {
     862                 :      181944 :       tree attrs = affects_type_identity_attributes (TYPE_ATTRIBUTES (t2));
     863                 :      181944 :       t2 = build_type_attribute_variant (t2, attrs);
     864                 :             :     }
     865                 :             : 
     866                 :             :   /* Save time if the two types are the same.  */
     867                 :             : 
     868                 :    13186555 :   if (t1 == t2) return t1;
     869                 :             : 
     870                 :     2166693 :   code1 = TREE_CODE (t1);
     871                 :     2166693 :   code2 = TREE_CODE (t2);
     872                 :             : 
     873                 :     2166693 :   gcc_assert (code1 == VECTOR_TYPE || code1 == COMPLEX_TYPE
     874                 :             :               || code1 == FIXED_POINT_TYPE || code1 == REAL_TYPE
     875                 :             :               || code1 == INTEGER_TYPE || code1 == BITINT_TYPE);
     876                 :     2166693 :   gcc_assert (code2 == VECTOR_TYPE || code2 == COMPLEX_TYPE
     877                 :             :               || code2 == FIXED_POINT_TYPE || code2 == REAL_TYPE
     878                 :             :               || code2 == INTEGER_TYPE || code2 == BITINT_TYPE);
     879                 :             : 
     880                 :             :   /* When one operand is a decimal float type, the other operand cannot be
     881                 :             :      a generic float type or a complex type.  We also disallow vector types
     882                 :             :      here.  */
     883                 :     2166693 :   if ((DECIMAL_FLOAT_TYPE_P (t1) || DECIMAL_FLOAT_TYPE_P (t2))
     884                 :     2169088 :       && !(DECIMAL_FLOAT_TYPE_P (t1) && DECIMAL_FLOAT_TYPE_P (t2)))
     885                 :             :     {
     886                 :        1060 :       if (code1 == VECTOR_TYPE || code2 == VECTOR_TYPE)
     887                 :             :         {
     888                 :           3 :           error ("cannot mix operands of decimal floating and vector types");
     889                 :           3 :           return error_mark_node;
     890                 :             :         }
     891                 :        1057 :       if (code1 == COMPLEX_TYPE || code2 == COMPLEX_TYPE)
     892                 :             :         {
     893                 :           5 :           error ("cannot mix operands of decimal floating and complex types");
     894                 :           5 :           return error_mark_node;
     895                 :             :         }
     896                 :        1052 :       if (code1 == REAL_TYPE && code2 == REAL_TYPE)
     897                 :             :         {
     898                 :          16 :           error ("cannot mix operands of decimal floating "
     899                 :             :                  "and other floating types");
     900                 :          16 :           return error_mark_node;
     901                 :             :         }
     902                 :             :     }
     903                 :             : 
     904                 :             :   /* If one type is a vector type, return that type.  (How the usual
     905                 :             :      arithmetic conversions apply to the vector types extension is not
     906                 :             :      precisely specified.)  */
     907                 :     2166669 :   if (code1 == VECTOR_TYPE)
     908                 :             :     return t1;
     909                 :             : 
     910                 :     2166436 :   if (code2 == VECTOR_TYPE)
     911                 :             :     return t2;
     912                 :             : 
     913                 :             :   /* If one type is complex, form the common type of the non-complex
     914                 :             :      components, then make that complex.  Use T1 or T2 if it is the
     915                 :             :      required type.  */
     916                 :     2166433 :   if (code1 == COMPLEX_TYPE || code2 == COMPLEX_TYPE)
     917                 :             :     {
     918                 :       89011 :       tree subtype1 = code1 == COMPLEX_TYPE ? TREE_TYPE (t1) : t1;
     919                 :       89011 :       tree subtype2 = code2 == COMPLEX_TYPE ? TREE_TYPE (t2) : t2;
     920                 :       89011 :       tree subtype = c_common_type (subtype1, subtype2);
     921                 :             : 
     922                 :       89011 :       if (code1 == COMPLEX_TYPE && TREE_TYPE (t1) == subtype)
     923                 :             :         return t1;
     924                 :       59154 :       else if (code2 == COMPLEX_TYPE && TREE_TYPE (t2) == subtype)
     925                 :             :         return t2;
     926                 :        3255 :       else if (TREE_CODE (subtype) == BITINT_TYPE)
     927                 :             :         {
     928                 :           8 :           sorry ("%<_Complex _BitInt(%d)%> unsupported",
     929                 :           4 :                  TYPE_PRECISION (subtype));
     930                 :           6 :           return code1 == COMPLEX_TYPE ? t1 : t2;
     931                 :             :         }
     932                 :             :       else
     933                 :        3251 :         return build_complex_type (subtype);
     934                 :             :     }
     935                 :             : 
     936                 :             :   /* If only one is real, use it as the result.  */
     937                 :             : 
     938                 :     2077422 :   if (code1 == REAL_TYPE && code2 != REAL_TYPE)
     939                 :             :     return t1;
     940                 :             : 
     941                 :     1962182 :   if (code2 == REAL_TYPE && code1 != REAL_TYPE)
     942                 :             :     return t2;
     943                 :             : 
     944                 :             :   /* If both are real and either are decimal floating point types, use
     945                 :             :      the decimal floating point type with the greater precision. */
     946                 :             : 
     947                 :     1931936 :   if (code1 == REAL_TYPE && code2 == REAL_TYPE)
     948                 :             :     {
     949                 :      106624 :       if (TYPE_MAIN_VARIANT (t1) == dfloat128_type_node
     950                 :      106624 :           || TYPE_MAIN_VARIANT (t2) == dfloat128_type_node)
     951                 :             :         return dfloat128_type_node;
     952                 :      106087 :       else if (TYPE_MAIN_VARIANT (t1) == dfloat64_type_node
     953                 :      106087 :                || TYPE_MAIN_VARIANT (t2) == dfloat64_type_node)
     954                 :             :         return dfloat64_type_node;
     955                 :      105634 :       else if (TYPE_MAIN_VARIANT (t1) == dfloat32_type_node
     956                 :      105634 :                || TYPE_MAIN_VARIANT (t2) == dfloat32_type_node)
     957                 :             :         return dfloat32_type_node;
     958                 :             :     }
     959                 :             : 
     960                 :             :   /* Deal with fixed-point types.  */
     961                 :     1930601 :   if (code1 == FIXED_POINT_TYPE || code2 == FIXED_POINT_TYPE)
     962                 :             :     {
     963                 :           0 :       unsigned int unsignedp = 0, satp = 0;
     964                 :           0 :       scalar_mode m1, m2;
     965                 :           0 :       unsigned int fbit1, ibit1, fbit2, ibit2, max_fbit, max_ibit;
     966                 :             : 
     967                 :           0 :       m1 = SCALAR_TYPE_MODE (t1);
     968                 :           0 :       m2 = SCALAR_TYPE_MODE (t2);
     969                 :             : 
     970                 :             :       /* If one input type is saturating, the result type is saturating.  */
     971                 :           0 :       if (TYPE_SATURATING (t1) || TYPE_SATURATING (t2))
     972                 :             :         satp = 1;
     973                 :             : 
     974                 :             :       /* If both fixed-point types are unsigned, the result type is unsigned.
     975                 :             :          When mixing fixed-point and integer types, follow the sign of the
     976                 :             :          fixed-point type.
     977                 :             :          Otherwise, the result type is signed.  */
     978                 :           0 :       if ((TYPE_UNSIGNED (t1) && TYPE_UNSIGNED (t2)
     979                 :           0 :            && code1 == FIXED_POINT_TYPE && code2 == FIXED_POINT_TYPE)
     980                 :           0 :           || (code1 == FIXED_POINT_TYPE && code2 != FIXED_POINT_TYPE
     981                 :           0 :               && TYPE_UNSIGNED (t1))
     982                 :           0 :           || (code1 != FIXED_POINT_TYPE && code2 == FIXED_POINT_TYPE
     983                 :           0 :               && TYPE_UNSIGNED (t2)))
     984                 :             :         unsignedp = 1;
     985                 :             : 
     986                 :             :       /* The result type is signed.  */
     987                 :           0 :       if (unsignedp == 0)
     988                 :             :         {
     989                 :             :           /* If the input type is unsigned, we need to convert to the
     990                 :             :              signed type.  */
     991                 :           0 :           if (code1 == FIXED_POINT_TYPE && TYPE_UNSIGNED (t1))
     992                 :             :             {
     993                 :           0 :               enum mode_class mclass = (enum mode_class) 0;
     994                 :           0 :               if (GET_MODE_CLASS (m1) == MODE_UFRACT)
     995                 :             :                 mclass = MODE_FRACT;
     996                 :           0 :               else if (GET_MODE_CLASS (m1) == MODE_UACCUM)
     997                 :             :                 mclass = MODE_ACCUM;
     998                 :             :               else
     999                 :           0 :                 gcc_unreachable ();
    1000                 :           0 :               m1 = as_a <scalar_mode>
    1001                 :           0 :                 (mode_for_size (GET_MODE_PRECISION (m1), mclass, 0));
    1002                 :             :             }
    1003                 :           0 :           if (code2 == FIXED_POINT_TYPE && TYPE_UNSIGNED (t2))
    1004                 :             :             {
    1005                 :           0 :               enum mode_class mclass = (enum mode_class) 0;
    1006                 :           0 :               if (GET_MODE_CLASS (m2) == MODE_UFRACT)
    1007                 :             :                 mclass = MODE_FRACT;
    1008                 :           0 :               else if (GET_MODE_CLASS (m2) == MODE_UACCUM)
    1009                 :             :                 mclass = MODE_ACCUM;
    1010                 :             :               else
    1011                 :           0 :                 gcc_unreachable ();
    1012                 :           0 :               m2 = as_a <scalar_mode>
    1013                 :           0 :                 (mode_for_size (GET_MODE_PRECISION (m2), mclass, 0));
    1014                 :             :             }
    1015                 :             :         }
    1016                 :             : 
    1017                 :           0 :       if (code1 == FIXED_POINT_TYPE)
    1018                 :             :         {
    1019                 :           0 :           fbit1 = GET_MODE_FBIT (m1);
    1020                 :           0 :           ibit1 = GET_MODE_IBIT (m1);
    1021                 :             :         }
    1022                 :             :       else
    1023                 :             :         {
    1024                 :           0 :           fbit1 = 0;
    1025                 :             :           /* Signed integers need to subtract one sign bit.  */
    1026                 :           0 :           ibit1 = TYPE_PRECISION (t1) - (!TYPE_UNSIGNED (t1));
    1027                 :             :         }
    1028                 :             : 
    1029                 :           0 :       if (code2 == FIXED_POINT_TYPE)
    1030                 :             :         {
    1031                 :           0 :           fbit2 = GET_MODE_FBIT (m2);
    1032                 :           0 :           ibit2 = GET_MODE_IBIT (m2);
    1033                 :             :         }
    1034                 :             :       else
    1035                 :             :         {
    1036                 :           0 :           fbit2 = 0;
    1037                 :             :           /* Signed integers need to subtract one sign bit.  */
    1038                 :           0 :           ibit2 = TYPE_PRECISION (t2) - (!TYPE_UNSIGNED (t2));
    1039                 :             :         }
    1040                 :             : 
    1041                 :           0 :       max_ibit = ibit1 >= ibit2 ?  ibit1 : ibit2;
    1042                 :           0 :       max_fbit = fbit1 >= fbit2 ?  fbit1 : fbit2;
    1043                 :           0 :       return c_common_fixed_point_type_for_size (max_ibit, max_fbit, unsignedp,
    1044                 :             :                                                  satp);
    1045                 :             :     }
    1046                 :             : 
    1047                 :             :   /* Both real or both integers; use the one with greater precision.  */
    1048                 :             : 
    1049                 :     1930601 :   if (TYPE_PRECISION (t1) > TYPE_PRECISION (t2))
    1050                 :             :     return t1;
    1051                 :      986193 :   else if (TYPE_PRECISION (t2) > TYPE_PRECISION (t1))
    1052                 :             :     return t2;
    1053                 :             : 
    1054                 :             :   /* Same precision.  Prefer long longs to longs to ints when the
    1055                 :             :      same precision, following the C99 rules on integer type rank
    1056                 :             :      (which are equivalent to the C90 rules for C90 types).  */
    1057                 :             : 
    1058                 :      630929 :   if (TYPE_MAIN_VARIANT (t1) == long_long_unsigned_type_node
    1059                 :      630929 :       || TYPE_MAIN_VARIANT (t2) == long_long_unsigned_type_node)
    1060                 :             :     return long_long_unsigned_type_node;
    1061                 :             : 
    1062                 :      562574 :   if (TYPE_MAIN_VARIANT (t1) == long_long_integer_type_node
    1063                 :      562574 :       || TYPE_MAIN_VARIANT (t2) == long_long_integer_type_node)
    1064                 :             :     {
    1065                 :       12174 :       if (TYPE_UNSIGNED (t1) || TYPE_UNSIGNED (t2))
    1066                 :         310 :         return long_long_unsigned_type_node;
    1067                 :             :       else
    1068                 :             :         return long_long_integer_type_node;
    1069                 :             :     }
    1070                 :             : 
    1071                 :      550400 :   if (TYPE_MAIN_VARIANT (t1) == long_unsigned_type_node
    1072                 :      550400 :       || TYPE_MAIN_VARIANT (t2) == long_unsigned_type_node)
    1073                 :             :     return long_unsigned_type_node;
    1074                 :             : 
    1075                 :      466463 :   if (TYPE_MAIN_VARIANT (t1) == long_integer_type_node
    1076                 :      466463 :       || TYPE_MAIN_VARIANT (t2) == long_integer_type_node)
    1077                 :             :     {
    1078                 :             :       /* But preserve unsignedness from the other type,
    1079                 :             :          since long cannot hold all the values of an unsigned int.  */
    1080                 :       24302 :       if (TYPE_UNSIGNED (t1) || TYPE_UNSIGNED (t2))
    1081                 :         131 :         return long_unsigned_type_node;
    1082                 :             :       else
    1083                 :             :         return long_integer_type_node;
    1084                 :             :     }
    1085                 :             : 
    1086                 :             :   /* For floating types of the same TYPE_PRECISION (which we here
    1087                 :             :      assume means either the same set of values, or sets of values
    1088                 :             :      neither a subset of the other, with behavior being undefined in
    1089                 :             :      the latter case), follow the rules from TS 18661-3: prefer
    1090                 :             :      interchange types _FloatN, then standard types long double,
    1091                 :             :      double, float, then extended types _FloatNx.  For extended types,
    1092                 :             :      check them starting with _Float128x as that seems most consistent
    1093                 :             :      in spirit with preferring long double to double; for interchange
    1094                 :             :      types, also check in that order for consistency although it's not
    1095                 :             :      possible for more than one of them to have the same
    1096                 :             :      precision.  */
    1097                 :      442161 :   tree mv1 = TYPE_MAIN_VARIANT (t1);
    1098                 :      442161 :   tree mv2 = TYPE_MAIN_VARIANT (t2);
    1099                 :             : 
    1100                 :     2210239 :   for (int i = NUM_FLOATN_TYPES - 1; i >= 0; i--)
    1101                 :     1768241 :     if (mv1 == FLOATN_TYPE_NODE (i) || mv2 == FLOATN_TYPE_NODE (i))
    1102                 :         163 :       return FLOATN_TYPE_NODE (i);
    1103                 :             : 
    1104                 :             :   /* Likewise, prefer long double to double even if same size.  */
    1105                 :      441998 :   if (mv1 == long_double_type_node || mv2 == long_double_type_node)
    1106                 :             :     return long_double_type_node;
    1107                 :             : 
    1108                 :             :   /* Likewise, prefer double to float even if same size.
    1109                 :             :      We got a couple of embedded targets with 32 bit doubles, and the
    1110                 :             :      pdp11 might have 64 bit floats.  */
    1111                 :      441756 :   if (mv1 == double_type_node || mv2 == double_type_node)
    1112                 :             :     return double_type_node;
    1113                 :             : 
    1114                 :      441184 :   if (mv1 == float_type_node || mv2 == float_type_node)
    1115                 :             :     return float_type_node;
    1116                 :             : 
    1117                 :     1756060 :   for (int i = NUM_FLOATNX_TYPES - 1; i >= 0; i--)
    1118                 :     1317045 :     if (mv1 == FLOATNX_TYPE_NODE (i) || mv2 == FLOATNX_TYPE_NODE (i))
    1119                 :           0 :       return FLOATNX_TYPE_NODE (i);
    1120                 :             : 
    1121                 :      439015 :   if ((code1 == BITINT_TYPE || code2 == BITINT_TYPE) && code1 != code2)
    1122                 :             :     {
    1123                 :             :       /* Prefer any other integral types over bit-precise integer types.  */
    1124                 :          10 :       if (TYPE_UNSIGNED (t1) == TYPE_UNSIGNED (t2))
    1125                 :           6 :         return code1 == BITINT_TYPE ? t2 : t1;
    1126                 :             :       /* If BITINT_TYPE is unsigned and the other type is signed
    1127                 :             :          non-BITINT_TYPE with the same precision, the latter has higher rank.
    1128                 :             :          In that case:
    1129                 :             :          Otherwise, both operands are converted to the unsigned integer type
    1130                 :             :          corresponding to the type of the operand with signed integer type.  */
    1131                 :           8 :       if (TYPE_UNSIGNED (code1 == BITINT_TYPE ? t1 : t2))
    1132                 :           5 :         return c_common_unsigned_type (code1 == BITINT_TYPE ? t2 : t1);
    1133                 :             :     }
    1134                 :             : 
    1135                 :             :   /* Otherwise prefer the unsigned one.  */
    1136                 :             : 
    1137                 :      439007 :   if (TYPE_UNSIGNED (t1))
    1138                 :             :     return t1;
    1139                 :             :   else
    1140                 :             :     return t2;
    1141                 :             : }
    1142                 :             : 
    1143                 :             : /* Wrapper around c_common_type that is used by c-common.cc and other
    1144                 :             :    front end optimizations that remove promotions.  ENUMERAL_TYPEs
    1145                 :             :    are allowed here and are converted to their compatible integer types.
    1146                 :             :    BOOLEAN_TYPEs are allowed here and return either boolean_type_node or
    1147                 :             :    preferably a non-Boolean type as the common type.  */
    1148                 :             : tree
    1149                 :       99880 : common_type (tree t1, tree t2)
    1150                 :             : {
    1151                 :       99880 :   if (TREE_CODE (t1) == ENUMERAL_TYPE)
    1152                 :           0 :     t1 = ENUM_UNDERLYING_TYPE (t1);
    1153                 :       99880 :   if (TREE_CODE (t2) == ENUMERAL_TYPE)
    1154                 :           1 :     t2 = ENUM_UNDERLYING_TYPE (t2);
    1155                 :             : 
    1156                 :             :   /* If both types are BOOLEAN_TYPE, then return boolean_type_node.  */
    1157                 :       99880 :   if (TREE_CODE (t1) == BOOLEAN_TYPE
    1158                 :         584 :       && TREE_CODE (t2) == BOOLEAN_TYPE)
    1159                 :         584 :     return boolean_type_node;
    1160                 :             : 
    1161                 :             :   /* If either type is BOOLEAN_TYPE, then return the other.  */
    1162                 :       99296 :   if (TREE_CODE (t1) == BOOLEAN_TYPE)
    1163                 :             :     return t2;
    1164                 :       99296 :   if (TREE_CODE (t2) == BOOLEAN_TYPE)
    1165                 :             :     return t1;
    1166                 :             : 
    1167                 :       99296 :   return c_common_type (t1, t2);
    1168                 :             : }
    1169                 :             : 
    1170                 :             : struct comptypes_data {
    1171                 :             :   bool enum_and_int_p;
    1172                 :             :   bool different_types_p;
    1173                 :             :   bool warning_needed;
    1174                 :             :   bool anon_field;
    1175                 :             :   bool equiv;
    1176                 :             : 
    1177                 :             :   const struct tagged_tu_seen_cache* cache;
    1178                 :             : };
    1179                 :             : 
    1180                 :             : /* Return 1 if TYPE1 and TYPE2 are compatible types for assignment
    1181                 :             :    or various other operations.  Return 2 if they are compatible
    1182                 :             :    but a warning may be needed if you use them together.  */
    1183                 :             : 
    1184                 :             : int
    1185                 :    37438642 : comptypes (tree type1, tree type2)
    1186                 :             : {
    1187                 :    37438642 :   struct comptypes_data data = { };
    1188                 :    37438642 :   bool ret = comptypes_internal (type1, type2, &data);
    1189                 :             : 
    1190                 :    37438642 :   return ret ? (data.warning_needed ? 2 : 1) : 0;
    1191                 :             : }
    1192                 :             : 
    1193                 :             : 
    1194                 :             : /* Like comptypes, but it returns non-zero only for identical
    1195                 :             :    types.  */
    1196                 :             : 
    1197                 :             : bool
    1198                 :         136 : comptypes_same_p (tree type1, tree type2)
    1199                 :             : {
    1200                 :         136 :   struct comptypes_data data = { };
    1201                 :         136 :   bool ret = comptypes_internal (type1, type2, &data);
    1202                 :             : 
    1203                 :         136 :   if (data.different_types_p)
    1204                 :          67 :     return false;
    1205                 :             : 
    1206                 :             :   return ret;
    1207                 :             : }
    1208                 :             : 
    1209                 :             : 
    1210                 :             : /* Like comptypes, but if it returns non-zero because enum and int are
    1211                 :             :    compatible, it sets *ENUM_AND_INT_P to true.  */
    1212                 :             : 
    1213                 :             : int
    1214                 :     5616778 : comptypes_check_enum_int (tree type1, tree type2, bool *enum_and_int_p)
    1215                 :             : {
    1216                 :     5616778 :   struct comptypes_data data = { };
    1217                 :     5616778 :   bool ret = comptypes_internal (type1, type2, &data);
    1218                 :     5616778 :   *enum_and_int_p = data.enum_and_int_p;
    1219                 :             : 
    1220                 :     5616778 :   return ret ? (data.warning_needed ? 2 : 1) : 0;
    1221                 :             : }
    1222                 :             : 
    1223                 :             : /* Like comptypes, but if it returns nonzero for different types, it
    1224                 :             :    sets *DIFFERENT_TYPES_P to true.  */
    1225                 :             : 
    1226                 :             : int
    1227                 :       95441 : comptypes_check_different_types (tree type1, tree type2,
    1228                 :             :                                  bool *different_types_p)
    1229                 :             : {
    1230                 :       95441 :   struct comptypes_data data = { };
    1231                 :       95441 :   bool ret = comptypes_internal (type1, type2, &data);
    1232                 :       95441 :   *different_types_p = data.different_types_p;
    1233                 :             : 
    1234                 :       95441 :   return ret ? (data.warning_needed ? 2 : 1) : 0;
    1235                 :             : }
    1236                 :             : 
    1237                 :             : 
    1238                 :             : /* Like comptypes, but if it returns nonzero for struct and union
    1239                 :             :    types considered equivalent for aliasing purposes.  */
    1240                 :             : 
    1241                 :             : bool
    1242                 :        1122 : comptypes_equiv_p (tree type1, tree type2)
    1243                 :             : {
    1244                 :        1122 :   struct comptypes_data data = { };
    1245                 :        1122 :   data.equiv = true;
    1246                 :        1122 :   bool ret = comptypes_internal (type1, type2, &data);
    1247                 :             : 
    1248                 :        1122 :   return ret;
    1249                 :             : }
    1250                 :             : 
    1251                 :             : 
    1252                 :             : /* Return true if TYPE1 and TYPE2 are compatible types for assignment
    1253                 :             :    or various other operations.  If they are compatible but a warning may
    1254                 :             :    be needed if you use them together, 'warning_needed' in DATA is set.
    1255                 :             :    If one type is an enum and the other a compatible integer type, then
    1256                 :             :    this sets 'enum_and_int_p' in DATA to true (it is never set to
    1257                 :             :    false).  If the types are compatible but different enough not to be
    1258                 :             :    permitted in C11 typedef redeclarations, then this sets
    1259                 :             :    'different_types_p' in DATA to true; it is never set to
    1260                 :             :    false, but may or may not be set if the types are incompatible.
    1261                 :             :    This differs from comptypes, in that we don't free the seen
    1262                 :             :    types.  */
    1263                 :             : 
    1264                 :             : static bool
    1265                 :    53128330 : comptypes_internal (const_tree type1, const_tree type2,
    1266                 :             :                     struct comptypes_data *data)
    1267                 :             : {
    1268                 :    53361584 :   const_tree t1 = type1;
    1269                 :    53361584 :   const_tree t2 = type2;
    1270                 :             : 
    1271                 :             :   /* Suppress errors caused by previously reported errors.  */
    1272                 :             : 
    1273                 :    53361584 :   if (t1 == t2 || !t1 || !t2
    1274                 :     7524456 :       || TREE_CODE (t1) == ERROR_MARK || TREE_CODE (t2) == ERROR_MARK)
    1275                 :             :     return true;
    1276                 :             : 
    1277                 :             :   /* Enumerated types are compatible with integer types, but this is
    1278                 :             :      not transitive: two enumerated types in the same translation unit
    1279                 :             :      are compatible with each other only if they are the same type.  */
    1280                 :             : 
    1281                 :     7524456 :   if (TREE_CODE (t1) == ENUMERAL_TYPE
    1282                 :         469 :       && COMPLETE_TYPE_P (t1)
    1283                 :     7524881 :       && TREE_CODE (t2) != ENUMERAL_TYPE)
    1284                 :             :     {
    1285                 :         369 :       t1 = ENUM_UNDERLYING_TYPE (t1);
    1286                 :         369 :       if (TREE_CODE (t2) != VOID_TYPE)
    1287                 :             :         {
    1288                 :         365 :           data->enum_and_int_p = true;
    1289                 :         365 :           data->different_types_p = true;
    1290                 :             :         }
    1291                 :             :     }
    1292                 :     7524087 :   else if (TREE_CODE (t2) == ENUMERAL_TYPE
    1293                 :        4244 :            && COMPLETE_TYPE_P (t2)
    1294                 :     7528325 :            && TREE_CODE (t1) != ENUMERAL_TYPE)
    1295                 :             :     {
    1296                 :        4182 :       t2 = ENUM_UNDERLYING_TYPE (t2);
    1297                 :        4182 :       if (TREE_CODE (t1) != VOID_TYPE)
    1298                 :             :         {
    1299                 :        3283 :           data->enum_and_int_p = true;
    1300                 :        3283 :           data->different_types_p = true;
    1301                 :             :         }
    1302                 :             :     }
    1303                 :             : 
    1304                 :     7524456 :   if (t1 == t2)
    1305                 :             :     return true;
    1306                 :             : 
    1307                 :             :   /* Different classes of types can't be compatible.  */
    1308                 :             : 
    1309                 :     7523737 :   if (TREE_CODE (t1) != TREE_CODE (t2))
    1310                 :             :     return false;
    1311                 :             : 
    1312                 :             :   /* Qualifiers must match. C99 6.7.3p9 */
    1313                 :             : 
    1314                 :     6430835 :   if (TYPE_QUALS (t1) != TYPE_QUALS (t2))
    1315                 :             :     return false;
    1316                 :             : 
    1317                 :             :   /* Allow for two different type nodes which have essentially the same
    1318                 :             :      definition.  Note that we already checked for equality of the type
    1319                 :             :      qualifiers (just above).  */
    1320                 :             : 
    1321                 :     6392125 :   if (TREE_CODE (t1) != ARRAY_TYPE
    1322                 :     6392125 :       && TYPE_MAIN_VARIANT (t1) == TYPE_MAIN_VARIANT (t2))
    1323                 :             :     return true;
    1324                 :             : 
    1325                 :     6061468 :   int attrval;
    1326                 :             : 
    1327                 :             :   /* 1 if no need for warning yet, 2 if warning cause has been seen.  */
    1328                 :     6061468 :   if (!(attrval = comp_type_attributes (t1, t2)))
    1329                 :             :      return false;
    1330                 :             : 
    1331                 :     6061106 :   if (2 == attrval)
    1332                 :         204 :     data->warning_needed = true;
    1333                 :             : 
    1334                 :     6061106 :   switch (TREE_CODE (t1))
    1335                 :             :     {
    1336                 :     2919284 :     case INTEGER_TYPE:
    1337                 :     2919284 :     case FIXED_POINT_TYPE:
    1338                 :     2919284 :     case REAL_TYPE:
    1339                 :     2919284 :     case BITINT_TYPE:
    1340                 :             :       /* With these nodes, we can't determine type equivalence by
    1341                 :             :          looking at what is stored in the nodes themselves, because
    1342                 :             :          two nodes might have different TYPE_MAIN_VARIANTs but still
    1343                 :             :          represent the same type.  For example, wchar_t and int could
    1344                 :             :          have the same properties (TYPE_PRECISION, TYPE_MIN_VALUE,
    1345                 :             :          TYPE_MAX_VALUE, etc.), but have different TYPE_MAIN_VARIANTs
    1346                 :             :          and are distinct types.  On the other hand, int and the
    1347                 :             :          following typedef
    1348                 :             : 
    1349                 :             :            typedef int INT __attribute((may_alias));
    1350                 :             : 
    1351                 :             :          have identical properties, different TYPE_MAIN_VARIANTs, but
    1352                 :             :          represent the same type.  The canonical type system keeps
    1353                 :             :          track of equivalence in this case, so we fall back on it.  */
    1354                 :     2919284 :       return TYPE_CANONICAL (t1) == TYPE_CANONICAL (t2);
    1355                 :             : 
    1356                 :      233254 :     case POINTER_TYPE:
    1357                 :             :       /* Do not remove mode information.  */
    1358                 :      233254 :       if (TYPE_MODE (t1) != TYPE_MODE (t2))
    1359                 :             :         return false;
    1360                 :      233254 :       return comptypes_internal (TREE_TYPE (t1), TREE_TYPE (t2), data);
    1361                 :             : 
    1362                 :     2610716 :     case FUNCTION_TYPE:
    1363                 :     2610716 :       return function_types_compatible_p (t1, t2, data);
    1364                 :             : 
    1365                 :       26798 :     case ARRAY_TYPE:
    1366                 :       26798 :       {
    1367                 :       26798 :         tree d1 = TYPE_DOMAIN (t1);
    1368                 :       26798 :         tree d2 = TYPE_DOMAIN (t2);
    1369                 :       26798 :         bool d1_variable, d2_variable;
    1370                 :       26798 :         bool d1_zero, d2_zero;
    1371                 :             : 
    1372                 :             :         /* Target types must match incl. qualifiers.  */
    1373                 :       26798 :         if (!comptypes_internal (TREE_TYPE (t1), TREE_TYPE (t2), data))
    1374                 :             :           return false;
    1375                 :             : 
    1376                 :       26153 :         if ((d1 == NULL_TREE) != (d2 == NULL_TREE))
    1377                 :        4545 :           data->different_types_p = true;
    1378                 :             :         /* Ignore size mismatches.  */
    1379                 :       26153 :         if (data->equiv)
    1380                 :             :           return true;
    1381                 :             :         /* Sizes must match unless one is missing or variable.  */
    1382                 :       26111 :         if (d1 == NULL_TREE || d2 == NULL_TREE || d1 == d2)
    1383                 :             :           return true;
    1384                 :             : 
    1385                 :       17108 :         d1_zero = !TYPE_MAX_VALUE (d1);
    1386                 :       17108 :         d2_zero = !TYPE_MAX_VALUE (d2);
    1387                 :             : 
    1388                 :       34216 :         d1_variable = (!d1_zero
    1389                 :       17108 :                        && (TREE_CODE (TYPE_MIN_VALUE (d1)) != INTEGER_CST
    1390                 :       17084 :                            || TREE_CODE (TYPE_MAX_VALUE (d1)) != INTEGER_CST));
    1391                 :       34216 :         d2_variable = (!d2_zero
    1392                 :       17108 :                        && (TREE_CODE (TYPE_MIN_VALUE (d2)) != INTEGER_CST
    1393                 :       16995 :                            || TREE_CODE (TYPE_MAX_VALUE (d2)) != INTEGER_CST));
    1394                 :       17108 :         d1_variable = d1_variable || (d1_zero && C_TYPE_VARIABLE_SIZE (t1));
    1395                 :       17108 :         d2_variable = d2_variable || (d2_zero && C_TYPE_VARIABLE_SIZE (t2));
    1396                 :             : 
    1397                 :       17108 :         if (d1_variable != d2_variable)
    1398                 :         446 :           data->different_types_p = true;
    1399                 :       17108 :         if (d1_variable || d2_variable)
    1400                 :             :           return true;
    1401                 :        3941 :         if (d1_zero && d2_zero)
    1402                 :             :           return true;
    1403                 :        3941 :         if (d1_zero || d2_zero
    1404                 :        3858 :             || !tree_int_cst_equal (TYPE_MIN_VALUE (d1), TYPE_MIN_VALUE (d2))
    1405                 :        7799 :             || !tree_int_cst_equal (TYPE_MAX_VALUE (d1), TYPE_MAX_VALUE (d2)))
    1406                 :        3941 :           return false;
    1407                 :             : 
    1408                 :             :         return true;
    1409                 :             :       }
    1410                 :             : 
    1411                 :        1741 :     case ENUMERAL_TYPE:
    1412                 :        1741 :     case RECORD_TYPE:
    1413                 :        1741 :     case UNION_TYPE:
    1414                 :             : 
    1415                 :        1741 :       if (!flag_isoc23)
    1416                 :             :         return false;
    1417                 :             : 
    1418                 :        1615 :       return tagged_types_tu_compatible_p (t1, t2, data);
    1419                 :             : 
    1420                 :      268830 :     case VECTOR_TYPE:
    1421                 :      537660 :       return known_eq (TYPE_VECTOR_SUBPARTS (t1), TYPE_VECTOR_SUBPARTS (t2))
    1422                 :      268830 :              && comptypes_internal (TREE_TYPE (t1), TREE_TYPE (t2), data);
    1423                 :             : 
    1424                 :             :     default:
    1425                 :             :       return false;
    1426                 :             :     }
    1427                 :             :   gcc_unreachable ();
    1428                 :             : }
    1429                 :             : 
    1430                 :             : /* Return true if TTL and TTR are pointers to types that are equivalent, ignoring
    1431                 :             :    their qualifiers, except for named address spaces.  If the pointers point to
    1432                 :             :    different named addresses, then we must determine if one address space is a
    1433                 :             :    subset of the other.  */
    1434                 :             : 
    1435                 :             : static bool
    1436                 :     1596886 : comp_target_types (location_t location, tree ttl, tree ttr)
    1437                 :             : {
    1438                 :     1596886 :   int val;
    1439                 :     1596886 :   int val_ped;
    1440                 :     1596886 :   tree mvl = TREE_TYPE (ttl);
    1441                 :     1596886 :   tree mvr = TREE_TYPE (ttr);
    1442                 :     1596886 :   addr_space_t asl = TYPE_ADDR_SPACE (mvl);
    1443                 :     1596886 :   addr_space_t asr = TYPE_ADDR_SPACE (mvr);
    1444                 :     1596886 :   addr_space_t as_common;
    1445                 :     1596886 :   bool enum_and_int_p;
    1446                 :             : 
    1447                 :             :   /* Fail if pointers point to incompatible address spaces.  */
    1448                 :     1596886 :   if (!addr_space_superset (asl, asr, &as_common))
    1449                 :             :     return 0;
    1450                 :             : 
    1451                 :             :   /* For pedantic record result of comptypes on arrays before losing
    1452                 :             :      qualifiers on the element type below. */
    1453                 :     1596886 :   val_ped = 1;
    1454                 :             : 
    1455                 :     1596886 :   if (TREE_CODE (mvl) == ARRAY_TYPE
    1456                 :        1934 :       && TREE_CODE (mvr) == ARRAY_TYPE)
    1457                 :        1911 :     val_ped = comptypes (mvl, mvr);
    1458                 :             : 
    1459                 :             :   /* Qualifiers on element types of array types that are
    1460                 :             :      pointer targets are lost by taking their TYPE_MAIN_VARIANT.  */
    1461                 :             : 
    1462                 :     1596886 :   mvl = (TYPE_ATOMIC (strip_array_types (mvl))
    1463                 :     3193636 :          ? c_build_qualified_type (TYPE_MAIN_VARIANT (mvl), TYPE_QUAL_ATOMIC)
    1464                 :     1596750 :          : TYPE_MAIN_VARIANT (mvl));
    1465                 :             : 
    1466                 :     1596886 :   mvr = (TYPE_ATOMIC (strip_array_types (mvr))
    1467                 :     3193632 :          ? c_build_qualified_type (TYPE_MAIN_VARIANT (mvr), TYPE_QUAL_ATOMIC)
    1468                 :     1596746 :          : TYPE_MAIN_VARIANT (mvr));
    1469                 :             : 
    1470                 :     1596886 :   enum_and_int_p = false;
    1471                 :     1596886 :   val = comptypes_check_enum_int (mvl, mvr, &enum_and_int_p);
    1472                 :             : 
    1473                 :     1596886 :   if (val == 1 && val_ped != 1)
    1474                 :         188 :     pedwarn_c11 (location, OPT_Wpedantic, "invalid use of pointers to arrays with different qualifiers "
    1475                 :             :                                           "in ISO C before C23");
    1476                 :             : 
    1477                 :     1596886 :   if (val == 2)
    1478                 :         126 :     pedwarn (location, OPT_Wpedantic, "types are not quite compatible");
    1479                 :             : 
    1480                 :     1596886 :   if (val == 1 && enum_and_int_p && warn_cxx_compat)
    1481                 :           2 :     warning_at (location, OPT_Wc___compat,
    1482                 :             :                 "pointer target types incompatible in C++");
    1483                 :             : 
    1484                 :     1596886 :   return val;
    1485                 :             : }
    1486                 :             : 
    1487                 :             : /* Subroutines of `comptypes'.  */
    1488                 :             : 
    1489                 :             : /* Return true if two 'struct', 'union', or 'enum' types T1 and T2 are
    1490                 :             :    compatible.  The two types are not the same (which has been
    1491                 :             :    checked earlier in comptypes_internal).  */
    1492                 :             : 
    1493                 :             : static bool
    1494                 :        1615 : tagged_types_tu_compatible_p (const_tree t1, const_tree t2,
    1495                 :             :                               struct comptypes_data *data)
    1496                 :             : {
    1497                 :        1615 :   tree s1, s2;
    1498                 :             : 
    1499                 :             :   /* We have to verify that the tags of the types are the same.  This
    1500                 :             :      is harder than it looks because this may be a typedef, so we have
    1501                 :             :      to go look at the original type.  It may even be a typedef of a
    1502                 :             :      typedef...
    1503                 :             :      In the case of compiler-created builtin structs the TYPE_DECL
    1504                 :             :      may be a dummy, with no DECL_ORIGINAL_TYPE.  Don't fault.  */
    1505                 :        1615 :   while (TYPE_NAME (t1)
    1506                 :        1057 :          && TREE_CODE (TYPE_NAME (t1)) == TYPE_DECL
    1507                 :        1635 :          && DECL_ORIGINAL_TYPE (TYPE_NAME (t1)))
    1508                 :          10 :     t1 = DECL_ORIGINAL_TYPE (TYPE_NAME (t1));
    1509                 :             : 
    1510                 :        3238 :   while (TYPE_NAME (t2)
    1511                 :        1073 :          && TREE_CODE (TYPE_NAME (t2)) == TYPE_DECL
    1512                 :        1623 :          && DECL_ORIGINAL_TYPE (TYPE_NAME (t2)))
    1513                 :           4 :     t2 = DECL_ORIGINAL_TYPE (TYPE_NAME (t2));
    1514                 :             : 
    1515                 :        1615 :   if (TYPE_NAME (t1) != TYPE_NAME (t2))
    1516                 :             :     return false;
    1517                 :             : 
    1518                 :        1324 :   if (!data->anon_field && NULL_TREE == TYPE_NAME (t1))
    1519                 :             :     return false;
    1520                 :             : 
    1521                 :         899 :   if (!data->anon_field && TYPE_STUB_DECL (t1) != TYPE_STUB_DECL (t2))
    1522                 :         676 :     data->different_types_p = true;
    1523                 :             : 
    1524                 :             :   /* Incomplete types are incompatible inside a TU.  */
    1525                 :         899 :   if (TYPE_SIZE (t1) == NULL || TYPE_SIZE (t2) == NULL)
    1526                 :             :     return false;
    1527                 :             : 
    1528                 :         895 :   if (ENUMERAL_TYPE != TREE_CODE (t1)
    1529                 :         895 :       && (TYPE_REVERSE_STORAGE_ORDER (t1)
    1530                 :         871 :           != TYPE_REVERSE_STORAGE_ORDER (t2)))
    1531                 :             :     return false;
    1532                 :             : 
    1533                 :             :   /* For types already being looked at in some active
    1534                 :             :      invocation of this function, assume compatibility.
    1535                 :             :      The cache is built as a linked list on the stack
    1536                 :             :      with the head of the list passed downwards.  */
    1537                 :         895 :   for (const struct tagged_tu_seen_cache *t = data->cache;
    1538                 :        1060 :        t != NULL; t = t->next)
    1539                 :         168 :     if (t->t1 == t1 && t->t2 == t2)
    1540                 :             :       return true;
    1541                 :             : 
    1542                 :         892 :   const struct tagged_tu_seen_cache entry = { data->cache, t1, t2 };
    1543                 :             : 
    1544                 :         892 :   switch (TREE_CODE (t1))
    1545                 :             :     {
    1546                 :          24 :     case ENUMERAL_TYPE:
    1547                 :          24 :       {
    1548                 :          24 :         if (!comptypes (ENUM_UNDERLYING_TYPE (t1), ENUM_UNDERLYING_TYPE (t2)))
    1549                 :             :           return false;
    1550                 :             : 
    1551                 :             :         /* Speed up the case where the type values are in the same order.  */
    1552                 :          20 :         tree tv1 = TYPE_VALUES (t1);
    1553                 :          20 :         tree tv2 = TYPE_VALUES (t2);
    1554                 :             : 
    1555                 :          20 :         if (tv1 == tv2)
    1556                 :             :           return true;
    1557                 :             : 
    1558                 :          33 :         for (;tv1 && tv2; tv1 = TREE_CHAIN (tv1), tv2 = TREE_CHAIN (tv2))
    1559                 :             :           {
    1560                 :          20 :             if (TREE_PURPOSE (tv1) != TREE_PURPOSE (tv2))
    1561                 :             :               break;
    1562                 :             : 
    1563                 :          17 :             if (simple_cst_equal (DECL_INITIAL (TREE_VALUE (tv1)),
    1564                 :          17 :                                   DECL_INITIAL (TREE_VALUE (tv2))) != 1)
    1565                 :             :               break;
    1566                 :             :           }
    1567                 :             : 
    1568                 :          20 :         if (tv1 == NULL_TREE && tv2 == NULL_TREE)
    1569                 :             :           return true;
    1570                 :             : 
    1571                 :           7 :         if (tv1 == NULL_TREE || tv2 == NULL_TREE)
    1572                 :             :           return false;
    1573                 :             : 
    1574                 :           7 :         if (list_length (TYPE_VALUES (t1)) != list_length (TYPE_VALUES (t2)))
    1575                 :             :           return false;
    1576                 :             : 
    1577                 :           9 :         for (s1 = TYPE_VALUES (t1); s1; s1 = TREE_CHAIN (s1))
    1578                 :             :           {
    1579                 :           8 :             s2 = purpose_member (TREE_PURPOSE (s1), TYPE_VALUES (t2));
    1580                 :             : 
    1581                 :           8 :             if (s2 == NULL
    1582                 :          14 :                 || simple_cst_equal (DECL_INITIAL (TREE_VALUE (s1)),
    1583                 :           6 :                                      DECL_INITIAL (TREE_VALUE (s2))) != 1)
    1584                 :           6 :               return false;
    1585                 :             :           }
    1586                 :             : 
    1587                 :             :         return true;
    1588                 :             :       }
    1589                 :             : 
    1590                 :         868 :     case UNION_TYPE:
    1591                 :         868 :     case RECORD_TYPE:
    1592                 :             : 
    1593                 :         868 :         if (list_length (TYPE_FIELDS (t1)) != list_length (TYPE_FIELDS (t2)))
    1594                 :             :           return false;
    1595                 :             : 
    1596                 :         866 :         if (data->equiv && (C_TYPE_VARIABLE_SIZE (t1) || C_TYPE_VARIABLE_SIZE (t2)))
    1597                 :             :           return false;
    1598                 :             : 
    1599                 :         796 :         for (s1 = TYPE_FIELDS (t1), s2 = TYPE_FIELDS (t2);
    1600                 :        1915 :              s1 && s2;
    1601                 :        1119 :              s1 = DECL_CHAIN (s1), s2 = DECL_CHAIN (s2))
    1602                 :             :           {
    1603                 :        1164 :             gcc_assert (TREE_CODE (s1) == FIELD_DECL);
    1604                 :        1164 :             gcc_assert (TREE_CODE (s2) == FIELD_DECL);
    1605                 :             : 
    1606                 :        1164 :             if (DECL_NAME (s1) != DECL_NAME (s2))
    1607                 :             :               return false;
    1608                 :             : 
    1609                 :        1154 :             if (DECL_ALIGN (s1) != DECL_ALIGN (s2))
    1610                 :             :               return false;
    1611                 :             : 
    1612                 :        1147 :             data->anon_field = !DECL_NAME (s1);
    1613                 :             : 
    1614                 :        1147 :             data->cache = &entry;
    1615                 :        1147 :             if (!comptypes_internal (TREE_TYPE (s1), TREE_TYPE (s2), data))
    1616                 :             :               return false;
    1617                 :             : 
    1618                 :        1121 :             tree st1 = TYPE_SIZE (TREE_TYPE (s1));
    1619                 :        1121 :             tree st2 = TYPE_SIZE (TREE_TYPE (s2));
    1620                 :             : 
    1621                 :        1121 :             if (data->equiv
    1622                 :         292 :                 && st1 && TREE_CODE (st1) == INTEGER_CST
    1623                 :         285 :                 && st2 && TREE_CODE (st2) == INTEGER_CST
    1624                 :        1404 :                 && !tree_int_cst_equal (st1, st2))
    1625                 :             :              return false;
    1626                 :             :           }
    1627                 :             :         return true;
    1628                 :             : 
    1629                 :           0 :     default:
    1630                 :           0 :       gcc_unreachable ();
    1631                 :             :     }
    1632                 :             : }
    1633                 :             : 
    1634                 :             : /* Return true if two function types F1 and F2 are compatible.
    1635                 :             :    If either type specifies no argument types,
    1636                 :             :    the other must specify a fixed number of self-promoting arg types.
    1637                 :             :    Otherwise, if one type specifies only the number of arguments,
    1638                 :             :    the other must specify that number of self-promoting arg types.
    1639                 :             :    Otherwise, the argument types must match.  */
    1640                 :             : 
    1641                 :             : static bool
    1642                 :     2610716 : function_types_compatible_p (const_tree f1, const_tree f2,
    1643                 :             :                              struct comptypes_data *data)
    1644                 :             : {
    1645                 :     2610716 :   tree args1, args2;
    1646                 :             :   /* 1 if no need for warning yet, 2 if warning cause has been seen.  */
    1647                 :     2610716 :   int val = 1;
    1648                 :     2610716 :   int val1;
    1649                 :     2610716 :   tree ret1, ret2;
    1650                 :             : 
    1651                 :     2610716 :   ret1 = TREE_TYPE (f1);
    1652                 :     2610716 :   ret2 = TREE_TYPE (f2);
    1653                 :             : 
    1654                 :             :   /* 'volatile' qualifiers on a function's return type used to mean
    1655                 :             :      the function is noreturn.  */
    1656                 :     2610716 :   if (TYPE_VOLATILE (ret1) != TYPE_VOLATILE (ret2))
    1657                 :          13 :     pedwarn (input_location, 0, "function return types not compatible due to %<volatile%>");
    1658                 :     2610716 :   if (TYPE_VOLATILE (ret1))
    1659                 :           5 :     ret1 = build_qualified_type (TYPE_MAIN_VARIANT (ret1),
    1660                 :           5 :                                  TYPE_QUALS (ret1) & ~TYPE_QUAL_VOLATILE);
    1661                 :     2610716 :   if (TYPE_VOLATILE (ret2))
    1662                 :           8 :     ret2 = build_qualified_type (TYPE_MAIN_VARIANT (ret2),
    1663                 :           8 :                                  TYPE_QUALS (ret2) & ~TYPE_QUAL_VOLATILE);
    1664                 :     2610716 :   val = comptypes_internal (ret1, ret2, data);
    1665                 :     2610716 :   if (val == 0)
    1666                 :             :     return 0;
    1667                 :             : 
    1668                 :     2608153 :   args1 = TYPE_ARG_TYPES (f1);
    1669                 :     2608153 :   args2 = TYPE_ARG_TYPES (f2);
    1670                 :             : 
    1671                 :     2608153 :   if ((args1 == NULL_TREE) != (args2 == NULL_TREE))
    1672                 :       23669 :     data->different_types_p = true;
    1673                 :             : 
    1674                 :             :   /* An unspecified parmlist matches any specified parmlist
    1675                 :             :      whose argument types don't need default promotions.  */
    1676                 :             : 
    1677                 :     2608153 :   if (args1 == NULL_TREE)
    1678                 :             :     {
    1679                 :       19272 :       if (TYPE_NO_NAMED_ARGS_STDARG_P (f1) != TYPE_NO_NAMED_ARGS_STDARG_P (f2))
    1680                 :             :         return 0;
    1681                 :       19270 :       if (!self_promoting_args_p (args2))
    1682                 :             :         return 0;
    1683                 :             :       /* If one of these types comes from a non-prototype fn definition,
    1684                 :             :          compare that with the other type's arglist.
    1685                 :             :          If they don't match, ask for a warning (but no error).  */
    1686                 :       18803 :       if (TYPE_ACTUAL_ARG_TYPES (f1)
    1687                 :       18803 :           && type_lists_compatible_p (args2, TYPE_ACTUAL_ARG_TYPES (f1),
    1688                 :             :                                       data) != 1)
    1689                 :             :         {
    1690                 :          11 :           val = 1;
    1691                 :          11 :           data->warning_needed = true;
    1692                 :             :         }
    1693                 :       18803 :       return val;
    1694                 :             :     }
    1695                 :     2588881 :   if (args2 == NULL_TREE)
    1696                 :             :     {
    1697                 :        4434 :       if (TYPE_NO_NAMED_ARGS_STDARG_P (f1) != TYPE_NO_NAMED_ARGS_STDARG_P (f2))
    1698                 :             :         return 0;
    1699                 :        4432 :       if (!self_promoting_args_p (args1))
    1700                 :             :         return 0;
    1701                 :        4358 :       if (TYPE_ACTUAL_ARG_TYPES (f2)
    1702                 :        4358 :           && type_lists_compatible_p (args1, TYPE_ACTUAL_ARG_TYPES (f2),
    1703                 :             :                                       data) != 1)
    1704                 :             :         {
    1705                 :           0 :           val = 1;
    1706                 :           0 :           data->warning_needed = true;
    1707                 :             :         }
    1708                 :        4358 :       return val;
    1709                 :             :     }
    1710                 :             : 
    1711                 :             :   /* Both types have argument lists: compare them and propagate results.  */
    1712                 :     2584447 :   val1 = type_lists_compatible_p (args1, args2, data);
    1713                 :     2584447 :   return val1;
    1714                 :             : }
    1715                 :             : 
    1716                 :             : /* Check two lists of types for compatibility, returning false for
    1717                 :             :    incompatible, true for compatible.  */
    1718                 :             : 
    1719                 :             : static bool
    1720                 :     2584489 : type_lists_compatible_p (const_tree args1, const_tree args2,
    1721                 :             :                          struct comptypes_data *data)
    1722                 :             : {
    1723                 :    16449255 :   while (1)
    1724                 :             :     {
    1725                 :     9516872 :       tree a1, mv1, a2, mv2;
    1726                 :     9516872 :       if (args1 == NULL_TREE && args2 == NULL_TREE)
    1727                 :             :         return true;
    1728                 :             :       /* If one list is shorter than the other,
    1729                 :             :          they fail to match.  */
    1730                 :     7068690 :       if (args1 == NULL_TREE || args2 == NULL_TREE)
    1731                 :             :         return 0;
    1732                 :     7068683 :       mv1 = a1 = TREE_VALUE (args1);
    1733                 :     7068683 :       mv2 = a2 = TREE_VALUE (args2);
    1734                 :     7068683 :       if (mv1 && mv1 != error_mark_node && TREE_CODE (mv1) != ARRAY_TYPE)
    1735                 :     7068682 :         mv1 = (TYPE_ATOMIC (mv1)
    1736                 :    14137351 :                ? c_build_qualified_type (TYPE_MAIN_VARIANT (mv1),
    1737                 :             :                                          TYPE_QUAL_ATOMIC)
    1738                 :     7068669 :                : TYPE_MAIN_VARIANT (mv1));
    1739                 :     7068683 :       if (mv2 && mv2 != error_mark_node && TREE_CODE (mv2) != ARRAY_TYPE)
    1740                 :     7068676 :         mv2 = (TYPE_ATOMIC (mv2)
    1741                 :    14137340 :                ? c_build_qualified_type (TYPE_MAIN_VARIANT (mv2),
    1742                 :             :                                          TYPE_QUAL_ATOMIC)
    1743                 :     7068664 :                : TYPE_MAIN_VARIANT (mv2));
    1744                 :             :       /* A null pointer instead of a type
    1745                 :             :          means there is supposed to be an argument
    1746                 :             :          but nothing is specified about what type it has.
    1747                 :             :          So match anything that self-promotes.  */
    1748                 :     7068683 :       if ((a1 == NULL_TREE) != (a2 == NULL_TREE))
    1749                 :           0 :         data->different_types_p = true;
    1750                 :     7068683 :       if (a1 == NULL_TREE)
    1751                 :             :         {
    1752                 :           0 :           if (c_type_promotes_to (a2) != a2)
    1753                 :             :             return 0;
    1754                 :             :         }
    1755                 :     7068683 :       else if (a2 == NULL_TREE)
    1756                 :             :         {
    1757                 :           0 :           if (c_type_promotes_to (a1) != a1)
    1758                 :             :             return 0;
    1759                 :             :         }
    1760                 :             :       /* If one of the lists has an error marker, ignore this arg.  */
    1761                 :     7068683 :       else if (TREE_CODE (a1) == ERROR_MARK
    1762                 :     7068682 :                || TREE_CODE (a2) == ERROR_MARK)
    1763                 :             :         ;
    1764                 :     7068675 :       else if (!comptypes_internal (mv1, mv2, data))
    1765                 :             :         {
    1766                 :      136397 :           data->different_types_p = true;
    1767                 :             :           /* Allow  wait (union {union wait *u; int *i} *)
    1768                 :             :              and  wait (union wait *)  to be compatible.  */
    1769                 :      136397 :           if (TREE_CODE (a1) == UNION_TYPE
    1770                 :          92 :               && (TYPE_NAME (a1) == NULL_TREE
    1771                 :          71 :                   || TYPE_TRANSPARENT_AGGR (a1))
    1772                 :          92 :               && TREE_CODE (TYPE_SIZE (a1)) == INTEGER_CST
    1773                 :      136489 :               && tree_int_cst_equal (TYPE_SIZE (a1),
    1774                 :          92 :                                      TYPE_SIZE (a2)))
    1775                 :             :             {
    1776                 :          92 :               tree memb;
    1777                 :          92 :               for (memb = TYPE_FIELDS (a1);
    1778                 :         120 :                    memb; memb = DECL_CHAIN (memb))
    1779                 :             :                 {
    1780                 :         118 :                   tree mv3 = TREE_TYPE (memb);
    1781                 :         118 :                   if (mv3 && mv3 != error_mark_node
    1782                 :         118 :                       && TREE_CODE (mv3) != ARRAY_TYPE)
    1783                 :         118 :                     mv3 = (TYPE_ATOMIC (mv3)
    1784                 :         236 :                            ? c_build_qualified_type (TYPE_MAIN_VARIANT (mv3),
    1785                 :             :                                                      TYPE_QUAL_ATOMIC)
    1786                 :         118 :                            : TYPE_MAIN_VARIANT (mv3));
    1787                 :         118 :                   if (comptypes_internal (mv3, mv2, data))
    1788                 :             :                     break;
    1789                 :             :                 }
    1790                 :             :               if (memb == NULL_TREE)
    1791                 :             :                 return 0;
    1792                 :             :             }
    1793                 :      136305 :           else if (TREE_CODE (a2) == UNION_TYPE
    1794                 :           9 :                    && (TYPE_NAME (a2) == NULL_TREE
    1795                 :           2 :                        || TYPE_TRANSPARENT_AGGR (a2))
    1796                 :           9 :                    && TREE_CODE (TYPE_SIZE (a2)) == INTEGER_CST
    1797                 :      136314 :                    && tree_int_cst_equal (TYPE_SIZE (a2),
    1798                 :           9 :                                           TYPE_SIZE (a1)))
    1799                 :             :             {
    1800                 :           9 :               tree memb;
    1801                 :           9 :               for (memb = TYPE_FIELDS (a2);
    1802                 :          13 :                    memb; memb = DECL_CHAIN (memb))
    1803                 :             :                 {
    1804                 :          11 :                   tree mv3 = TREE_TYPE (memb);
    1805                 :          11 :                   if (mv3 && mv3 != error_mark_node
    1806                 :          11 :                       && TREE_CODE (mv3) != ARRAY_TYPE)
    1807                 :          11 :                     mv3 = (TYPE_ATOMIC (mv3)
    1808                 :          22 :                            ? c_build_qualified_type (TYPE_MAIN_VARIANT (mv3),
    1809                 :             :                                                      TYPE_QUAL_ATOMIC)
    1810                 :          11 :                            : TYPE_MAIN_VARIANT (mv3));
    1811                 :          11 :                   if (comptypes_internal (mv3, mv1, data))
    1812                 :             :                     break;
    1813                 :             :                 }
    1814                 :             :               if (memb == NULL_TREE)
    1815                 :             :                 return 0;
    1816                 :             :             }
    1817                 :             :           else
    1818                 :      136296 :             return 0;
    1819                 :             :         }
    1820                 :             : 
    1821                 :     6932383 :       args1 = TREE_CHAIN (args1);
    1822                 :     6932383 :       args2 = TREE_CHAIN (args2);
    1823                 :     6932383 :     }
    1824                 :             : }
    1825                 :             : 
    1826                 :             : /* Compute the size to increment a pointer by.  When a function type or void
    1827                 :             :    type or incomplete type is passed, size_one_node is returned.
    1828                 :             :    This function does not emit any diagnostics; the caller is responsible
    1829                 :             :    for that.  */
    1830                 :             : 
    1831                 :             : static tree
    1832                 :      229560 : c_size_in_bytes (const_tree type)
    1833                 :             : {
    1834                 :      229560 :   enum tree_code code = TREE_CODE (type);
    1835                 :             : 
    1836                 :      229560 :   if (code == FUNCTION_TYPE || code == VOID_TYPE || code == ERROR_MARK
    1837                 :      229560 :       || !COMPLETE_TYPE_P (type))
    1838                 :         179 :     return size_one_node;
    1839                 :             : 
    1840                 :             :   /* Convert in case a char is more than one unit.  */
    1841                 :      229381 :   return size_binop_loc (input_location, CEIL_DIV_EXPR, TYPE_SIZE_UNIT (type),
    1842                 :      229381 :                          size_int (TYPE_PRECISION (char_type_node)
    1843                 :             :                                    / BITS_PER_UNIT));
    1844                 :             : }
    1845                 :             : 
    1846                 :             : /* Return either DECL or its known constant value (if it has one).  */
    1847                 :             : 
    1848                 :             : tree
    1849                 :    13891536 : decl_constant_value_1 (tree decl, bool in_init)
    1850                 :             : {
    1851                 :    13891536 :   if (/* Note that DECL_INITIAL isn't valid for a PARM_DECL.  */
    1852                 :    13891536 :       TREE_CODE (decl) != PARM_DECL
    1853                 :    13891536 :       && !TREE_THIS_VOLATILE (decl)
    1854                 :    13550576 :       && TREE_READONLY (decl)
    1855                 :       34000 :       && DECL_INITIAL (decl) != NULL_TREE
    1856                 :       33048 :       && !error_operand_p (DECL_INITIAL (decl))
    1857                 :             :       /* This is invalid if initial value is not constant.
    1858                 :             :          If it has either a function call, a memory reference,
    1859                 :             :          or a variable, then re-evaluating it could give different results.  */
    1860                 :       33039 :       && TREE_CONSTANT (DECL_INITIAL (decl))
    1861                 :             :       /* Check for cases where this is sub-optimal, even though valid.  */
    1862                 :    13911735 :       && (in_init || TREE_CODE (DECL_INITIAL (decl)) != CONSTRUCTOR))
    1863                 :       15986 :     return DECL_INITIAL (decl);
    1864                 :             :   return decl;
    1865                 :             : }
    1866                 :             : 
    1867                 :             : /* Return either DECL or its known constant value (if it has one).
    1868                 :             :    Like the above, but always return decl outside of functions.  */
    1869                 :             : 
    1870                 :             : tree
    1871                 :    13891379 : decl_constant_value (tree decl)
    1872                 :             : {
    1873                 :             :   /* Don't change a variable array bound or initial value to a constant
    1874                 :             :      in a place where a variable is invalid.  */
    1875                 :    13891379 :   return current_function_decl ? decl_constant_value_1 (decl, false) : decl;
    1876                 :             : }
    1877                 :             : 
    1878                 :             : /* Convert the array expression EXP to a pointer.  */
    1879                 :             : static tree
    1880                 :      798200 : array_to_pointer_conversion (location_t loc, tree exp)
    1881                 :             : {
    1882                 :      798200 :   tree orig_exp = exp;
    1883                 :      798200 :   tree type = TREE_TYPE (exp);
    1884                 :      798200 :   tree adr;
    1885                 :      798200 :   tree restype = TREE_TYPE (type);
    1886                 :      798200 :   tree ptrtype;
    1887                 :             : 
    1888                 :      798200 :   gcc_assert (TREE_CODE (type) == ARRAY_TYPE);
    1889                 :             : 
    1890                 :      798200 :   STRIP_TYPE_NOPS (exp);
    1891                 :             : 
    1892                 :      798200 :   copy_warning (exp, orig_exp);
    1893                 :             : 
    1894                 :      798200 :   ptrtype = build_pointer_type (restype);
    1895                 :             : 
    1896                 :      798200 :   if (INDIRECT_REF_P (exp))
    1897                 :        2677 :     return convert (ptrtype, TREE_OPERAND (exp, 0));
    1898                 :             : 
    1899                 :             :   /* In C++ array compound literals are temporary objects unless they are
    1900                 :             :      const or appear in namespace scope, so they are destroyed too soon
    1901                 :             :      to use them for much of anything  (c++/53220).  */
    1902                 :      795523 :   if (warn_cxx_compat && TREE_CODE (exp) == COMPOUND_LITERAL_EXPR)
    1903                 :             :     {
    1904                 :          48 :       tree decl = TREE_OPERAND (TREE_OPERAND (exp, 0), 0);
    1905                 :          48 :       if (!TREE_READONLY (decl) && !TREE_STATIC (decl))
    1906                 :          46 :         warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wc___compat,
    1907                 :             :                     "converting an array compound literal to a pointer "
    1908                 :             :                     "leads to a dangling pointer in C++");
    1909                 :             :     }
    1910                 :             : 
    1911                 :      795523 :   adr = build_unary_op (loc, ADDR_EXPR, exp, true);
    1912                 :      795523 :   return convert (ptrtype, adr);
    1913                 :             : }
    1914                 :             : 
    1915                 :             : /* Convert the function expression EXP to a pointer.  */
    1916                 :             : static tree
    1917                 :    43960699 : function_to_pointer_conversion (location_t loc, tree exp)
    1918                 :             : {
    1919                 :    43960699 :   tree orig_exp = exp;
    1920                 :             : 
    1921                 :    43960699 :   gcc_assert (TREE_CODE (TREE_TYPE (exp)) == FUNCTION_TYPE);
    1922                 :             : 
    1923                 :    43960699 :   STRIP_TYPE_NOPS (exp);
    1924                 :             : 
    1925                 :    43960699 :   copy_warning (exp, orig_exp);
    1926                 :             : 
    1927                 :    43960699 :   return build_unary_op (loc, ADDR_EXPR, exp, false);
    1928                 :             : }
    1929                 :             : 
    1930                 :             : /* Mark EXP as read, not just set, for set but not used -Wunused
    1931                 :             :    warning purposes.  */
    1932                 :             : 
    1933                 :             : void
    1934                 :   439519158 : mark_exp_read (tree exp)
    1935                 :             : {
    1936                 :   560108789 :   switch (TREE_CODE (exp))
    1937                 :             :     {
    1938                 :   197265869 :     case VAR_DECL:
    1939                 :   197265869 :     case PARM_DECL:
    1940                 :   197265869 :       DECL_READ_P (exp) = 1;
    1941                 :   197265869 :       break;
    1942                 :   117915826 :     case ARRAY_REF:
    1943                 :   117915826 :     case COMPONENT_REF:
    1944                 :   117915826 :     case MODIFY_EXPR:
    1945                 :   117915826 :     case REALPART_EXPR:
    1946                 :   117915826 :     case IMAGPART_EXPR:
    1947                 :   117915826 :     CASE_CONVERT:
    1948                 :   117915826 :     case ADDR_EXPR:
    1949                 :   117915826 :     case VIEW_CONVERT_EXPR:
    1950                 :   117915826 :       mark_exp_read (TREE_OPERAND (exp, 0));
    1951                 :   117915826 :       break;
    1952                 :      229838 :     case COMPOUND_EXPR:
    1953                 :             :       /* Pattern match what build_atomic_assign produces with modifycode
    1954                 :             :          NOP_EXPR.  */
    1955                 :      229838 :       if (VAR_P (TREE_OPERAND (exp, 1))
    1956                 :       27098 :           && DECL_ARTIFICIAL (TREE_OPERAND (exp, 1))
    1957                 :      256855 :           && TREE_CODE (TREE_OPERAND (exp, 0)) == COMPOUND_EXPR)
    1958                 :             :         {
    1959                 :        2112 :           tree t1 = TREE_OPERAND (TREE_OPERAND (exp, 0), 0);
    1960                 :        2112 :           tree t2 = TREE_OPERAND (TREE_OPERAND (exp, 0), 1);
    1961                 :        2112 :           if (TREE_CODE (t1) == TARGET_EXPR
    1962                 :        2104 :               && TARGET_EXPR_SLOT (t1) == TREE_OPERAND (exp, 1)
    1963                 :        4214 :               && TREE_CODE (t2) == CALL_EXPR)
    1964                 :             :             {
    1965                 :        2102 :               tree fndecl = get_callee_fndecl (t2);
    1966                 :        2102 :               tree arg = NULL_TREE;
    1967                 :        2102 :               if (fndecl
    1968                 :        2102 :                   && TREE_CODE (fndecl) == FUNCTION_DECL
    1969                 :        2102 :                   && fndecl_built_in_p (fndecl, BUILT_IN_NORMAL)
    1970                 :        4204 :                   && call_expr_nargs (t2) >= 2)
    1971                 :        2102 :                 switch (DECL_FUNCTION_CODE (fndecl))
    1972                 :             :                   {
    1973                 :         130 :                   case BUILT_IN_ATOMIC_STORE:
    1974                 :         130 :                     arg = CALL_EXPR_ARG (t2, 1);
    1975                 :         130 :                     break;
    1976                 :        1972 :                   case BUILT_IN_ATOMIC_STORE_1:
    1977                 :        1972 :                   case BUILT_IN_ATOMIC_STORE_2:
    1978                 :        1972 :                   case BUILT_IN_ATOMIC_STORE_4:
    1979                 :        1972 :                   case BUILT_IN_ATOMIC_STORE_8:
    1980                 :        1972 :                   case BUILT_IN_ATOMIC_STORE_16:
    1981                 :        1972 :                     arg = CALL_EXPR_ARG (t2, 0);
    1982                 :        1972 :                     break;
    1983                 :             :                   default:
    1984                 :             :                     break;
    1985                 :             :                   }
    1986                 :        2102 :               if (arg)
    1987                 :             :                 {
    1988                 :        2102 :                   STRIP_NOPS (arg);
    1989                 :        2102 :                   if (TREE_CODE (arg) == ADDR_EXPR
    1990                 :        2102 :                       && DECL_P (TREE_OPERAND (arg, 0))
    1991                 :        4204 :                       && TYPE_ATOMIC (TREE_TYPE (TREE_OPERAND (arg, 0))))
    1992                 :        2102 :                     mark_exp_read (TREE_OPERAND (arg, 0));
    1993                 :             :                 }
    1994                 :             :             }
    1995                 :             :         }
    1996                 :             :       /* FALLTHRU */
    1997                 :     2673395 :     case C_MAYBE_CONST_EXPR:
    1998                 :     2673395 :       mark_exp_read (TREE_OPERAND (exp, 1));
    1999                 :     2673395 :       break;
    2000                 :         445 :     case OMP_ARRAY_SECTION:
    2001                 :         445 :       mark_exp_read (TREE_OPERAND (exp, 0));
    2002                 :         445 :       if (TREE_OPERAND (exp, 1))
    2003                 :         312 :         mark_exp_read (TREE_OPERAND (exp, 1));
    2004                 :         445 :       if (TREE_OPERAND (exp, 2))
    2005                 :         410 :         mark_exp_read (TREE_OPERAND (exp, 2));
    2006                 :             :       break;
    2007                 :             :     default:
    2008                 :             :       break;
    2009                 :             :     }
    2010                 :   439519158 : }
    2011                 :             : 
    2012                 :             : /* Perform the default conversion of arrays and functions to pointers.
    2013                 :             :    Return the result of converting EXP.  For any other expression, just
    2014                 :             :    return EXP.
    2015                 :             : 
    2016                 :             :    LOC is the location of the expression.  */
    2017                 :             : 
    2018                 :             : struct c_expr
    2019                 :   321316928 : default_function_array_conversion (location_t loc, struct c_expr exp)
    2020                 :             : {
    2021                 :   321316928 :   tree orig_exp = exp.value;
    2022                 :   321316928 :   tree type = TREE_TYPE (exp.value);
    2023                 :   321316928 :   enum tree_code code = TREE_CODE (type);
    2024                 :             : 
    2025                 :   321316928 :   switch (code)
    2026                 :             :     {
    2027                 :             :     case ARRAY_TYPE:
    2028                 :             :       {
    2029                 :             :         bool not_lvalue = false;
    2030                 :             :         bool lvalue_array_p;
    2031                 :             : 
    2032                 :      753419 :         while ((TREE_CODE (exp.value) == NON_LVALUE_EXPR
    2033                 :      753419 :                 || CONVERT_EXPR_P (exp.value))
    2034                 :      753419 :                && TREE_TYPE (TREE_OPERAND (exp.value, 0)) == type)
    2035                 :             :           {
    2036                 :           0 :             if (TREE_CODE (exp.value) == NON_LVALUE_EXPR)
    2037                 :           0 :               not_lvalue = true;
    2038                 :           0 :             exp.value = TREE_OPERAND (exp.value, 0);
    2039                 :             :           }
    2040                 :             : 
    2041                 :      753419 :         copy_warning (exp.value, orig_exp);
    2042                 :             : 
    2043                 :      753419 :         lvalue_array_p = !not_lvalue && lvalue_p (exp.value);
    2044                 :      753419 :         if (!flag_isoc99 && !lvalue_array_p)
    2045                 :             :           {
    2046                 :             :             /* Before C99, non-lvalue arrays do not decay to pointers.
    2047                 :             :                Normally, using such an array would be invalid; but it can
    2048                 :             :                be used correctly inside sizeof or as a statement expression.
    2049                 :             :                Thus, do not give an error here; an error will result later.  */
    2050                 :         108 :             return exp;
    2051                 :             :           }
    2052                 :             : 
    2053                 :      753311 :         exp.value = array_to_pointer_conversion (loc, exp.value);
    2054                 :             :       }
    2055                 :      753311 :       break;
    2056                 :      761345 :     case FUNCTION_TYPE:
    2057                 :      761345 :       exp.value = function_to_pointer_conversion (loc, exp.value);
    2058                 :      761345 :       break;
    2059                 :             :     default:
    2060                 :             :       break;
    2061                 :             :     }
    2062                 :             : 
    2063                 :   321316820 :   return exp;
    2064                 :             : }
    2065                 :             : 
    2066                 :             : struct c_expr
    2067                 :      900345 : default_function_array_read_conversion (location_t loc, struct c_expr exp)
    2068                 :             : {
    2069                 :      900345 :   mark_exp_read (exp.value);
    2070                 :      900345 :   return default_function_array_conversion (loc, exp);
    2071                 :             : }
    2072                 :             : 
    2073                 :             : /* Return whether EXPR should be treated as an atomic lvalue for the
    2074                 :             :    purposes of load and store handling.  */
    2075                 :             : 
    2076                 :             : static bool
    2077                 :   322328457 : really_atomic_lvalue (tree expr)
    2078                 :             : {
    2079                 :   322328457 :   if (error_operand_p (expr))
    2080                 :             :     return false;
    2081                 :   322321147 :   if (!TYPE_ATOMIC (TREE_TYPE (expr)))
    2082                 :             :     return false;
    2083                 :       56779 :   if (!lvalue_p (expr))
    2084                 :             :     return false;
    2085                 :             : 
    2086                 :             :   /* Ignore _Atomic on register variables, since their addresses can't
    2087                 :             :      be taken so (a) atomicity is irrelevant and (b) the normal atomic
    2088                 :             :      sequences wouldn't work.  Ignore _Atomic on structures containing
    2089                 :             :      bit-fields, since accessing elements of atomic structures or
    2090                 :             :      unions is undefined behavior (C11 6.5.2.3#5), but it's unclear if
    2091                 :             :      it's undefined at translation time or execution time, and the
    2092                 :             :      normal atomic sequences again wouldn't work.  */
    2093                 :       56813 :   while (handled_component_p (expr))
    2094                 :             :     {
    2095                 :          36 :       if (TREE_CODE (expr) == COMPONENT_REF
    2096                 :          36 :           && DECL_C_BIT_FIELD (TREE_OPERAND (expr, 1)))
    2097                 :             :         return false;
    2098                 :          36 :       expr = TREE_OPERAND (expr, 0);
    2099                 :             :     }
    2100                 :       56777 :   if (DECL_P (expr) && C_DECL_REGISTER (expr))
    2101                 :             :     return false;
    2102                 :             :   return true;
    2103                 :             : }
    2104                 :             : 
    2105                 :             : /* If EXPR is a named constant (C23) derived from a constexpr variable
    2106                 :             :    - that is, a reference to such a variable, or a member extracted by
    2107                 :             :    a sequence of structure and union (but not array) member accesses
    2108                 :             :    (where union member accesses must access the same member as
    2109                 :             :    initialized) - then return the corresponding initializer;
    2110                 :             :    otherwise, return NULL_TREE.  */
    2111                 :             : 
    2112                 :             : static tree
    2113                 :   319254178 : maybe_get_constexpr_init (tree expr)
    2114                 :             : {
    2115                 :   319254178 :   tree decl = NULL_TREE;
    2116                 :   319254178 :   if (TREE_CODE (expr) == VAR_DECL)
    2117                 :             :     decl = expr;
    2118                 :   308015320 :   else if (TREE_CODE (expr) == COMPOUND_LITERAL_EXPR)
    2119                 :      774844 :     decl = COMPOUND_LITERAL_EXPR_DECL (expr);
    2120                 :      774844 :   if (decl
    2121                 :    12013702 :       && C_DECL_DECLARED_CONSTEXPR (decl)
    2122                 :         308 :       && DECL_INITIAL (decl) != NULL_TREE
    2123                 :      775152 :       && !error_operand_p (DECL_INITIAL (decl)))
    2124                 :         308 :     return DECL_INITIAL (decl);
    2125                 :   319253870 :   if (TREE_CODE (expr) != COMPONENT_REF)
    2126                 :             :     return NULL_TREE;
    2127                 :      827424 :   tree inner = maybe_get_constexpr_init (TREE_OPERAND (expr, 0));
    2128                 :      827424 :   if (inner == NULL_TREE)
    2129                 :             :     return NULL_TREE;
    2130                 :         125 :   while ((CONVERT_EXPR_P (inner) || TREE_CODE (inner) == NON_LVALUE_EXPR)
    2131                 :          47 :          && !error_operand_p (inner)
    2132                 :         219 :          && (TYPE_MAIN_VARIANT (TREE_TYPE (inner))
    2133                 :          47 :              == TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (inner, 0)))))
    2134                 :          47 :     inner = TREE_OPERAND (inner, 0);
    2135                 :         125 :   if (TREE_CODE (inner) != CONSTRUCTOR)
    2136                 :             :     return NULL_TREE;
    2137                 :         125 :   tree field = TREE_OPERAND (expr, 1);
    2138                 :         125 :   unsigned HOST_WIDE_INT cidx;
    2139                 :         125 :   tree cfield, cvalue;
    2140                 :         125 :   bool have_other_init = false;
    2141                 :         265 :   FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (inner), cidx, cfield, cvalue)
    2142                 :             :     {
    2143                 :         249 :       if (cfield == field)
    2144                 :         109 :         return cvalue;
    2145                 :         140 :       have_other_init = true;
    2146                 :             :     }
    2147                 :          16 :   if (TREE_CODE (TREE_TYPE (inner)) == UNION_TYPE
    2148                 :          16 :       && (have_other_init || field != TYPE_FIELDS (TREE_TYPE (inner))))
    2149                 :             :     return NULL_TREE;
    2150                 :             :   /* Return a default initializer.  */
    2151                 :          13 :   if (RECORD_OR_UNION_TYPE_P (TREE_TYPE (expr)))
    2152                 :           5 :     return build_constructor (TREE_TYPE (expr), NULL);
    2153                 :           8 :   return build_zero_cst (TREE_TYPE (expr));
    2154                 :             : }
    2155                 :             : 
    2156                 :             : /* Convert expression EXP (location LOC) from lvalue to rvalue,
    2157                 :             :    including converting functions and arrays to pointers if CONVERT_P.
    2158                 :             :    If READ_P, also mark the expression as having been read.  If
    2159                 :             :    FOR_INIT, constexpr expressions of structure and union type should
    2160                 :             :    be replaced by the corresponding CONSTRUCTOR; otherwise, only
    2161                 :             :    constexpr scalars (including elements of structures and unions) are
    2162                 :             :    replaced by their initializers.  */
    2163                 :             : 
    2164                 :             : struct c_expr
    2165                 :   318611622 : convert_lvalue_to_rvalue (location_t loc, struct c_expr exp,
    2166                 :             :                           bool convert_p, bool read_p, bool for_init)
    2167                 :             : {
    2168                 :   318611622 :   bool force_non_npc = false;
    2169                 :   318611622 :   if (read_p)
    2170                 :   279491375 :     mark_exp_read (exp.value);
    2171                 :   318611622 :   if (convert_p)
    2172                 :   318598690 :     exp = default_function_array_conversion (loc, exp);
    2173                 :   318611622 :   if (!VOID_TYPE_P (TREE_TYPE (exp.value)))
    2174                 :   316133625 :     exp.value = require_complete_type (loc, exp.value);
    2175                 :   318611622 :   if (for_init || !RECORD_OR_UNION_TYPE_P (TREE_TYPE (exp.value)))
    2176                 :             :     {
    2177                 :   318426754 :       tree init = maybe_get_constexpr_init (exp.value);
    2178                 :   318426754 :       if (init != NULL_TREE)
    2179                 :             :         {
    2180                 :             :           /* A named constant of pointer type or type nullptr_t is not
    2181                 :             :              a null pointer constant even if the initializer is
    2182                 :             :              one.  */
    2183                 :         305 :           if (TREE_CODE (init) == INTEGER_CST
    2184                 :         173 :               && !INTEGRAL_TYPE_P (TREE_TYPE (init))
    2185                 :         331 :               && integer_zerop (init))
    2186                 :             :             force_non_npc = true;
    2187                 :             :           exp.value = init;
    2188                 :             :         }
    2189                 :             :     }
    2190                 :   318611622 :   if (really_atomic_lvalue (exp.value))
    2191                 :             :     {
    2192                 :       26481 :       vec<tree, va_gc> *params;
    2193                 :       26481 :       tree nonatomic_type, tmp, tmp_addr, fndecl, func_call;
    2194                 :       26481 :       tree expr_type = TREE_TYPE (exp.value);
    2195                 :       26481 :       tree expr_addr = build_unary_op (loc, ADDR_EXPR, exp.value, false);
    2196                 :       26481 :       tree seq_cst = build_int_cst (integer_type_node, MEMMODEL_SEQ_CST);
    2197                 :             : 
    2198                 :       26481 :       gcc_assert (TYPE_ATOMIC (expr_type));
    2199                 :             : 
    2200                 :             :       /* Expansion of a generic atomic load may require an addition
    2201                 :             :          element, so allocate enough to prevent a resize.  */
    2202                 :       26481 :       vec_alloc (params, 4);
    2203                 :             : 
    2204                 :             :       /* Remove the qualifiers for the rest of the expressions and
    2205                 :             :          create the VAL temp variable to hold the RHS.  */
    2206                 :       26481 :       nonatomic_type = build_qualified_type (expr_type, TYPE_UNQUALIFIED);
    2207                 :       26481 :       tmp = create_tmp_var_raw (nonatomic_type);
    2208                 :       26481 :       tmp_addr = build_unary_op (loc, ADDR_EXPR, tmp, false);
    2209                 :       26481 :       TREE_ADDRESSABLE (tmp) = 1;
    2210                 :             :       /* Do not disable warnings for TMP even though it's artificial.
    2211                 :             :          -Winvalid-memory-model depends on it.  */
    2212                 :             : 
    2213                 :             :       /* Issue __atomic_load (&expr, &tmp, SEQ_CST);  */
    2214                 :       26481 :       fndecl = builtin_decl_explicit (BUILT_IN_ATOMIC_LOAD);
    2215                 :       26481 :       params->quick_push (expr_addr);
    2216                 :       26481 :       params->quick_push (tmp_addr);
    2217                 :       26481 :       params->quick_push (seq_cst);
    2218                 :       26481 :       func_call = c_build_function_call_vec (loc, vNULL, fndecl, params, NULL);
    2219                 :             : 
    2220                 :             :       /* EXPR is always read.  */
    2221                 :       26481 :       mark_exp_read (exp.value);
    2222                 :             : 
    2223                 :             :       /* Return tmp which contains the value loaded.  */
    2224                 :       26481 :       exp.value = build4 (TARGET_EXPR, nonatomic_type, tmp, func_call,
    2225                 :             :                           NULL_TREE, NULL_TREE);
    2226                 :             :     }
    2227                 :   318598690 :   if (convert_p && !error_operand_p (exp.value)
    2228                 :   637203046 :       && (TREE_CODE (TREE_TYPE (exp.value)) != ARRAY_TYPE))
    2229                 :   318591316 :     exp.value = convert (build_qualified_type (TREE_TYPE (exp.value), TYPE_UNQUALIFIED), exp.value);
    2230                 :   318611622 :   if (force_non_npc)
    2231                 :          24 :     exp.value = build1 (NOP_EXPR, TREE_TYPE (exp.value), exp.value);
    2232                 :             : 
    2233                 :   318611622 :   {
    2234                 :   318611622 :     tree false_value, true_value;
    2235                 :   318598690 :     if (convert_p && !error_operand_p (exp.value)
    2236                 :   637203046 :         && c_hardbool_type_attr (TREE_TYPE (exp.value),
    2237                 :             :                                  &false_value, &true_value))
    2238                 :             :       {
    2239                 :        3445 :         tree t = save_expr (exp.value);
    2240                 :             : 
    2241                 :        3445 :         mark_exp_read (exp.value);
    2242                 :             : 
    2243                 :        3445 :         tree trapfn = builtin_decl_explicit (BUILT_IN_TRAP);
    2244                 :        3445 :         tree expr = build_call_expr_loc (loc, trapfn, 0);
    2245                 :        3445 :         expr = build_compound_expr (loc, expr, boolean_true_node);
    2246                 :        3445 :         expr = fold_build3_loc (loc, COND_EXPR, boolean_type_node,
    2247                 :             :                                 fold_build2_loc (loc, NE_EXPR,
    2248                 :             :                                                  boolean_type_node,
    2249                 :             :                                                  t, true_value),
    2250                 :             :                                 expr, boolean_true_node);
    2251                 :        3445 :         expr = fold_build3_loc (loc, COND_EXPR, boolean_type_node,
    2252                 :             :                                 fold_build2_loc (loc, NE_EXPR,
    2253                 :             :                                                  boolean_type_node,
    2254                 :             :                                                  t, false_value),
    2255                 :             :                                 expr, boolean_false_node);
    2256                 :             : 
    2257                 :        3445 :         exp.value = expr;
    2258                 :             :       }
    2259                 :             :   }
    2260                 :             : 
    2261                 :   318611622 :   return exp;
    2262                 :             : }
    2263                 :             : 
    2264                 :             : /* EXP is an expression of integer type.  Apply the integer promotions
    2265                 :             :    to it and return the promoted value.  */
    2266                 :             : 
    2267                 :             : tree
    2268                 :    74155296 : perform_integral_promotions (tree exp)
    2269                 :             : {
    2270                 :    74155296 :   tree type = TREE_TYPE (exp);
    2271                 :    74155296 :   enum tree_code code = TREE_CODE (type);
    2272                 :             : 
    2273                 :    74155296 :   gcc_assert (INTEGRAL_TYPE_P (type));
    2274                 :             : 
    2275                 :             :   /* Convert enums to the result of applying the integer promotions to
    2276                 :             :      their underlying type.  */
    2277                 :    74155296 :   if (code == ENUMERAL_TYPE)
    2278                 :             :     {
    2279                 :      551208 :       type = ENUM_UNDERLYING_TYPE (type);
    2280                 :      551208 :       if (c_promoting_integer_type_p (type))
    2281                 :             :         {
    2282                 :        1298 :           if (TYPE_UNSIGNED (type)
    2283                 :        1298 :               && TYPE_PRECISION (type) == TYPE_PRECISION (integer_type_node))
    2284                 :           0 :             type = unsigned_type_node;
    2285                 :             :           else
    2286                 :        1298 :             type = integer_type_node;
    2287                 :             :         }
    2288                 :             : 
    2289                 :      551208 :       return convert (type, exp);
    2290                 :             :     }
    2291                 :             : 
    2292                 :             :   /* ??? This should no longer be needed now bit-fields have their
    2293                 :             :      proper types.  */
    2294                 :    73604088 :   if (TREE_CODE (exp) == COMPONENT_REF
    2295                 :    73604088 :       && DECL_C_BIT_FIELD (TREE_OPERAND (exp, 1)))
    2296                 :             :     {
    2297                 :       61785 :       if (TREE_CODE (DECL_BIT_FIELD_TYPE (TREE_OPERAND (exp, 1)))
    2298                 :             :           == BITINT_TYPE)
    2299                 :         142 :         return convert (DECL_BIT_FIELD_TYPE (TREE_OPERAND (exp, 1)), exp);
    2300                 :             :       /* If it's thinner than an int, promote it like a
    2301                 :             :          c_promoting_integer_type_p, otherwise leave it alone.  */
    2302                 :       61643 :       if (compare_tree_int (DECL_SIZE (TREE_OPERAND (exp, 1)),
    2303                 :       61643 :                             TYPE_PRECISION (integer_type_node)) < 0)
    2304                 :       53381 :         return convert (integer_type_node, exp);
    2305                 :             :     }
    2306                 :             : 
    2307                 :    73550565 :   if (c_promoting_integer_type_p (type))
    2308                 :             :     {
    2309                 :             :       /* Preserve unsignedness if not really getting any wider.  */
    2310                 :    20868612 :       if (TYPE_UNSIGNED (type)
    2311                 :    20868612 :           && TYPE_PRECISION (type) == TYPE_PRECISION (integer_type_node))
    2312                 :           0 :         return convert (unsigned_type_node, exp);
    2313                 :             : 
    2314                 :    20868612 :       return convert (integer_type_node, exp);
    2315                 :             :     }
    2316                 :             : 
    2317                 :             :   return exp;
    2318                 :             : }
    2319                 :             : 
    2320                 :             : 
    2321                 :             : /* Perform default promotions for C data used in expressions.
    2322                 :             :    Enumeral types or short or char are converted to int.
    2323                 :             :    In addition, manifest constants symbols are replaced by their values.  */
    2324                 :             : 
    2325                 :             : tree
    2326                 :    83263777 : default_conversion (tree exp)
    2327                 :             : {
    2328                 :    83263777 :   tree orig_exp;
    2329                 :    83263777 :   tree type = TREE_TYPE (exp);
    2330                 :    83263777 :   enum tree_code code = TREE_CODE (type);
    2331                 :    83263777 :   tree promoted_type;
    2332                 :             : 
    2333                 :    83263777 :   mark_exp_read (exp);
    2334                 :             : 
    2335                 :             :   /* Functions and arrays have been converted during parsing.  */
    2336                 :    83263777 :   gcc_assert (code != FUNCTION_TYPE);
    2337                 :    83263777 :   if (code == ARRAY_TYPE)
    2338                 :             :     return exp;
    2339                 :             : 
    2340                 :             :   /* Constants can be used directly unless they're not loadable.  */
    2341                 :    83263618 :   if (TREE_CODE (exp) == CONST_DECL)
    2342                 :           0 :     exp = DECL_INITIAL (exp);
    2343                 :             : 
    2344                 :             :   /* Strip no-op conversions.  */
    2345                 :    83263618 :   orig_exp = exp;
    2346                 :    83627218 :   STRIP_TYPE_NOPS (exp);
    2347                 :             : 
    2348                 :    83263618 :   copy_warning (exp, orig_exp);
    2349                 :             : 
    2350                 :    83263618 :   if (code == VOID_TYPE)
    2351                 :             :     {
    2352                 :           2 :       error_at (EXPR_LOC_OR_LOC (exp, input_location),
    2353                 :             :                 "void value not ignored as it ought to be");
    2354                 :           2 :       return error_mark_node;
    2355                 :             :     }
    2356                 :             : 
    2357                 :    83263616 :   exp = require_complete_type (EXPR_LOC_OR_LOC (exp, input_location), exp);
    2358                 :    83263616 :   if (exp == error_mark_node)
    2359                 :             :     return error_mark_node;
    2360                 :             : 
    2361                 :    83262722 :   promoted_type = targetm.promoted_type (type);
    2362                 :    83262722 :   if (promoted_type)
    2363                 :           0 :     return convert (promoted_type, exp);
    2364                 :             : 
    2365                 :    83262722 :   if (INTEGRAL_TYPE_P (type))
    2366                 :    73166039 :     return perform_integral_promotions (exp);
    2367                 :             : 
    2368                 :             :   return exp;
    2369                 :             : }
    2370                 :             : 
    2371                 :             : /* Look up COMPONENT in a structure or union TYPE.
    2372                 :             : 
    2373                 :             :    If the component name is not found, returns NULL_TREE.  Otherwise,
    2374                 :             :    the return value is a TREE_LIST, with each TREE_VALUE a FIELD_DECL
    2375                 :             :    stepping down the chain to the component, which is in the last
    2376                 :             :    TREE_VALUE of the list.  Normally the list is of length one, but if
    2377                 :             :    the component is embedded within (nested) anonymous structures or
    2378                 :             :    unions, the list steps down the chain to the component.  */
    2379                 :             : 
    2380                 :             : static tree
    2381                 :     2254147 : lookup_field (tree type, tree component)
    2382                 :             : {
    2383                 :     2254147 :   tree field;
    2384                 :             : 
    2385                 :             :   /* If TYPE_LANG_SPECIFIC is set, then it is a sorted array of pointers
    2386                 :             :      to the field elements.  Use a binary search on this array to quickly
    2387                 :             :      find the element.  Otherwise, do a linear search.  TYPE_LANG_SPECIFIC
    2388                 :             :      will always be set for structures which have many elements.
    2389                 :             : 
    2390                 :             :      Duplicate field checking replaces duplicates with NULL_TREE so
    2391                 :             :      TYPE_LANG_SPECIFIC arrays are potentially no longer sorted.  In that
    2392                 :             :      case just iterate using DECL_CHAIN.  */
    2393                 :             : 
    2394                 :     2540409 :   if (TYPE_LANG_SPECIFIC (type) && TYPE_LANG_SPECIFIC (type)->s
    2395                 :     2540409 :       && !seen_error ())
    2396                 :             :     {
    2397                 :      286241 :       int bot, top, half;
    2398                 :      286241 :       tree *field_array = &TYPE_LANG_SPECIFIC (type)->s->elts[0];
    2399                 :             : 
    2400                 :      286241 :       field = TYPE_FIELDS (type);
    2401                 :      286241 :       bot = 0;
    2402                 :      286241 :       top = TYPE_LANG_SPECIFIC (type)->s->len;
    2403                 :     1310673 :       while (top - bot > 1)
    2404                 :             :         {
    2405                 :     1283958 :           half = (top - bot + 1) >> 1;
    2406                 :     1283958 :           field = field_array[bot+half];
    2407                 :             : 
    2408                 :     1283958 :           if (DECL_NAME (field) == NULL_TREE)
    2409                 :             :             {
    2410                 :             :               /* Step through all anon unions in linear fashion.  */
    2411                 :           0 :               while (DECL_NAME (field_array[bot]) == NULL_TREE)
    2412                 :             :                 {
    2413                 :           0 :                   field = field_array[bot++];
    2414                 :           0 :                   if (RECORD_OR_UNION_TYPE_P (TREE_TYPE (field)))
    2415                 :             :                     {
    2416                 :           0 :                       tree anon = lookup_field (TREE_TYPE (field), component);
    2417                 :             : 
    2418                 :           0 :                       if (anon)
    2419                 :           0 :                         return tree_cons (NULL_TREE, field, anon);
    2420                 :             : 
    2421                 :             :                       /* The Plan 9 compiler permits referring
    2422                 :             :                          directly to an anonymous struct/union field
    2423                 :             :                          using a typedef name.  */
    2424                 :           0 :                       if (flag_plan9_extensions
    2425                 :           0 :                           && TYPE_NAME (TREE_TYPE (field)) != NULL_TREE
    2426                 :           0 :                           && (TREE_CODE (TYPE_NAME (TREE_TYPE (field)))
    2427                 :             :                               == TYPE_DECL)
    2428                 :           0 :                           && (DECL_NAME (TYPE_NAME (TREE_TYPE (field)))
    2429                 :             :                               == component))
    2430                 :             :                         break;
    2431                 :             :                     }
    2432                 :             :                 }
    2433                 :             : 
    2434                 :             :               /* Entire record is only anon unions.  */
    2435                 :           0 :               if (bot > top)
    2436                 :             :                 return NULL_TREE;
    2437                 :             : 
    2438                 :             :               /* Restart the binary search, with new lower bound.  */
    2439                 :           0 :               continue;
    2440                 :           0 :             }
    2441                 :             : 
    2442                 :     1283958 :           if (DECL_NAME (field) == component)
    2443                 :             :             break;
    2444                 :     1024432 :           if (DECL_NAME (field) < component)
    2445                 :             :             bot += half;
    2446                 :             :           else
    2447                 :      843821 :             top = bot + half;
    2448                 :             :         }
    2449                 :             : 
    2450                 :      286241 :       if (DECL_NAME (field_array[bot]) == component)
    2451                 :             :         field = field_array[bot];
    2452                 :      259526 :       else if (DECL_NAME (field) != component)
    2453                 :             :         return NULL_TREE;
    2454                 :             :     }
    2455                 :             :   else
    2456                 :             :     {
    2457                 :     5139373 :       for (field = TYPE_FIELDS (type); field; field = DECL_CHAIN (field))
    2458                 :             :         {
    2459                 :     5130744 :           if (DECL_NAME (field) == NULL_TREE
    2460                 :     5130744 :               && RECORD_OR_UNION_TYPE_P (TREE_TYPE (field)))
    2461                 :             :             {
    2462                 :       10483 :               tree anon = lookup_field (TREE_TYPE (field), component);
    2463                 :             : 
    2464                 :       10483 :               if (anon)
    2465                 :        1925 :                 return tree_cons (NULL_TREE, field, anon);
    2466                 :             : 
    2467                 :             :               /* The Plan 9 compiler permits referring directly to an
    2468                 :             :                  anonymous struct/union field using a typedef
    2469                 :             :                  name.  */
    2470                 :        8558 :               if (flag_plan9_extensions
    2471                 :          38 :                   && TYPE_NAME (TREE_TYPE (field)) != NULL_TREE
    2472                 :          36 :                   && TREE_CODE (TYPE_NAME (TREE_TYPE (field))) == TYPE_DECL
    2473                 :        8564 :                   && (DECL_NAME (TYPE_NAME (TREE_TYPE (field)))
    2474                 :             :                       == component))
    2475                 :             :                 break;
    2476                 :             :             }
    2477                 :             : 
    2478                 :     5128815 :           if (DECL_NAME (field) == component)
    2479                 :             :             break;
    2480                 :             :         }
    2481                 :             : 
    2482                 :     1965981 :       if (field == NULL_TREE)
    2483                 :             :         return NULL_TREE;
    2484                 :             :     }
    2485                 :             : 
    2486                 :     2243593 :   return tree_cons (NULL_TREE, field, NULL_TREE);
    2487                 :             : }
    2488                 :             : 
    2489                 :             : /* Recursively append candidate IDENTIFIER_NODEs to CANDIDATES.  */
    2490                 :             : 
    2491                 :             : static void
    2492                 :         101 : lookup_field_fuzzy_find_candidates (tree type, tree component,
    2493                 :             :                                     vec<tree> *candidates)
    2494                 :             : {
    2495                 :         101 :   tree field;
    2496                 :         259 :   for (field = TYPE_FIELDS (type); field; field = DECL_CHAIN (field))
    2497                 :             :     {
    2498                 :         158 :       if (DECL_NAME (field) == NULL_TREE
    2499                 :         158 :           && RECORD_OR_UNION_TYPE_P (TREE_TYPE (field)))
    2500                 :          30 :         lookup_field_fuzzy_find_candidates (TREE_TYPE (field), component,
    2501                 :             :                                             candidates);
    2502                 :             : 
    2503                 :         158 :       if (DECL_NAME (field))
    2504                 :         112 :         candidates->safe_push (DECL_NAME (field));
    2505                 :             :     }
    2506                 :         101 : }
    2507                 :             : 
    2508                 :             : /* Like "lookup_field", but find the closest matching IDENTIFIER_NODE,
    2509                 :             :    rather than returning a TREE_LIST for an exact match.  */
    2510                 :             : 
    2511                 :             : static tree
    2512                 :          71 : lookup_field_fuzzy (tree type, tree component)
    2513                 :             : {
    2514                 :          71 :   gcc_assert (TREE_CODE (component) == IDENTIFIER_NODE);
    2515                 :             : 
    2516                 :             :   /* First, gather a list of candidates.  */
    2517                 :          71 :   auto_vec <tree> candidates;
    2518                 :             : 
    2519                 :          71 :   lookup_field_fuzzy_find_candidates (type, component,
    2520                 :             :                                       &candidates);
    2521                 :             : 
    2522                 :          71 :   return find_closest_identifier (component, &candidates);
    2523                 :          71 : }
    2524                 :             : 
    2525                 :             : /* Support function for build_component_ref's error-handling.
    2526                 :             : 
    2527                 :             :    Given DATUM_TYPE, and "DATUM.COMPONENT", where DATUM is *not* a
    2528                 :             :    struct or union, should we suggest "DATUM->COMPONENT" as a hint?  */
    2529                 :             : 
    2530                 :             : static bool
    2531                 :          72 : should_suggest_deref_p (tree datum_type)
    2532                 :             : {
    2533                 :             :   /* We don't do it for Objective-C, since Objective-C 2.0 dot-syntax
    2534                 :             :      allows "." for ptrs; we could be handling a failed attempt
    2535                 :             :      to access a property.  */
    2536                 :          72 :   if (c_dialect_objc ())
    2537                 :             :     return false;
    2538                 :             : 
    2539                 :             :   /* Only suggest it for pointers...  */
    2540                 :          72 :   if (TREE_CODE (datum_type) != POINTER_TYPE)
    2541                 :             :     return false;
    2542                 :             : 
    2543                 :             :   /* ...to structs/unions.  */
    2544                 :           8 :   tree underlying_type = TREE_TYPE (datum_type);
    2545                 :           8 :   enum tree_code code = TREE_CODE (underlying_type);
    2546                 :           8 :   if (code == RECORD_TYPE || code == UNION_TYPE)
    2547                 :             :     return true;
    2548                 :             :   else
    2549                 :           1 :     return false;
    2550                 :             : }
    2551                 :             : 
    2552                 :             : /* Make an expression to refer to the COMPONENT field of structure or
    2553                 :             :    union value DATUM.  COMPONENT is an IDENTIFIER_NODE.  LOC is the
    2554                 :             :    location of the COMPONENT_REF.  COMPONENT_LOC is the location
    2555                 :             :    of COMPONENT.  ARROW_LOC is the location of the first -> operand if
    2556                 :             :    it is from -> operator.  */
    2557                 :             : 
    2558                 :             : tree
    2559                 :     2212563 : build_component_ref (location_t loc, tree datum, tree component,
    2560                 :             :                      location_t component_loc, location_t arrow_loc)
    2561                 :             : {
    2562                 :     2212563 :   tree type = TREE_TYPE (datum);
    2563                 :     2212563 :   enum tree_code code = TREE_CODE (type);
    2564                 :     2212563 :   tree field = NULL;
    2565                 :     2212563 :   tree ref;
    2566                 :     2212563 :   bool datum_lvalue = lvalue_p (datum);
    2567                 :             : 
    2568                 :     2212563 :   if (!objc_is_public (datum, component))
    2569                 :           0 :     return error_mark_node;
    2570                 :             : 
    2571                 :             :   /* Detect Objective-C property syntax object.property.  */
    2572                 :     2212563 :   if (c_dialect_objc ()
    2573                 :     2212563 :       && (ref = objc_maybe_build_component_ref (datum, component)))
    2574                 :             :     return ref;
    2575                 :             : 
    2576                 :             :   /* See if there is a field or component with name COMPONENT.  */
    2577                 :             : 
    2578                 :     2212563 :   if (code == RECORD_TYPE || code == UNION_TYPE)
    2579                 :             :     {
    2580                 :     2212491 :       if (!COMPLETE_TYPE_P (type))
    2581                 :             :         {
    2582                 :          15 :           c_incomplete_type_error (loc, NULL_TREE, type);
    2583                 :          15 :           return error_mark_node;
    2584                 :             :         }
    2585                 :             : 
    2586                 :     2212476 :       field = lookup_field (type, component);
    2587                 :             : 
    2588                 :     2212476 :       if (!field)
    2589                 :             :         {
    2590                 :          63 :           tree guessed_id = lookup_field_fuzzy (type, component);
    2591                 :          63 :           if (guessed_id)
    2592                 :             :             {
    2593                 :             :               /* Attempt to provide a fixit replacement hint, if
    2594                 :             :                  we have a valid range for the component.  */
    2595                 :          54 :               location_t reported_loc
    2596                 :          27 :                 = (component_loc != UNKNOWN_LOCATION) ? component_loc : loc;
    2597                 :          27 :               gcc_rich_location rich_loc (reported_loc);
    2598                 :          27 :               if (component_loc != UNKNOWN_LOCATION)
    2599                 :          27 :                 rich_loc.add_fixit_misspelled_id (component_loc, guessed_id);
    2600                 :          27 :               error_at (&rich_loc,
    2601                 :             :                         "%qT has no member named %qE; did you mean %qE?",
    2602                 :             :                         type, component, guessed_id);
    2603                 :          27 :             }
    2604                 :             :           else
    2605                 :          36 :             error_at (loc, "%qT has no member named %qE", type, component);
    2606                 :          63 :           return error_mark_node;
    2607                 :             :         }
    2608                 :             : 
    2609                 :             :       /* Accessing elements of atomic structures or unions is undefined
    2610                 :             :          behavior (C11 6.5.2.3#5).  */
    2611                 :     2212413 :       if (TYPE_ATOMIC (type) && c_inhibit_evaluation_warnings == 0)
    2612                 :             :         {
    2613                 :          18 :           if (code == RECORD_TYPE)
    2614                 :          12 :             warning_at (loc, 0, "accessing a member %qE of an atomic "
    2615                 :             :                         "structure %qE", component, datum);
    2616                 :             :           else
    2617                 :           6 :             warning_at (loc, 0, "accessing a member %qE of an atomic "
    2618                 :             :                         "union %qE", component, datum);
    2619                 :             :         }
    2620                 :             : 
    2621                 :             :       /* Chain the COMPONENT_REFs if necessary down to the FIELD.
    2622                 :             :          This might be better solved in future the way the C++ front
    2623                 :             :          end does it - by giving the anonymous entities each a
    2624                 :             :          separate name and type, and then have build_component_ref
    2625                 :             :          recursively call itself.  We can't do that here.  */
    2626                 :     2214321 :       do
    2627                 :             :         {
    2628                 :     2214321 :           tree subdatum = TREE_VALUE (field);
    2629                 :     2214321 :           int quals;
    2630                 :     2214321 :           tree subtype;
    2631                 :     2214321 :           bool use_datum_quals;
    2632                 :             : 
    2633                 :     2214321 :           if (TREE_TYPE (subdatum) == error_mark_node)
    2634                 :           0 :             return error_mark_node;
    2635                 :             : 
    2636                 :             :           /* If this is an rvalue, it does not have qualifiers in C
    2637                 :             :              standard terms and we must avoid propagating such
    2638                 :             :              qualifiers down to a non-lvalue array that is then
    2639                 :             :              converted to a pointer.  */
    2640                 :     4428642 :           use_datum_quals = (datum_lvalue
    2641                 :     2214321 :                              || TREE_CODE (TREE_TYPE (subdatum)) != ARRAY_TYPE);
    2642                 :             : 
    2643                 :     2214321 :           quals = TYPE_QUALS (strip_array_types (TREE_TYPE (subdatum)));
    2644                 :     2214321 :           if (use_datum_quals)
    2645                 :     2214063 :             quals |= TYPE_QUALS (TREE_TYPE (datum));
    2646                 :     2214321 :           subtype = c_build_qualified_type (TREE_TYPE (subdatum), quals);
    2647                 :             : 
    2648                 :     2214321 :           ref = build3 (COMPONENT_REF, subtype, datum, subdatum,
    2649                 :             :                         NULL_TREE);
    2650                 :     2214321 :           SET_EXPR_LOCATION (ref, loc);
    2651                 :     2214321 :           if (TREE_READONLY (subdatum)
    2652                 :     2214321 :               || (use_datum_quals && TREE_READONLY (datum)))
    2653                 :       29389 :             TREE_READONLY (ref) = 1;
    2654                 :     2214321 :           if (TREE_THIS_VOLATILE (subdatum)
    2655                 :     2213516 :               || (use_datum_quals && TREE_THIS_VOLATILE (datum)))
    2656                 :        2224 :             TREE_THIS_VOLATILE (ref) = 1;
    2657                 :             : 
    2658                 :     2214321 :           if (TREE_UNAVAILABLE (subdatum))
    2659                 :          10 :             error_unavailable_use (subdatum, NULL_TREE);
    2660                 :     2214311 :           else if (TREE_DEPRECATED (subdatum))
    2661                 :          16 :             warn_deprecated_use (subdatum, NULL_TREE);
    2662                 :             : 
    2663                 :     2214321 :           datum = ref;
    2664                 :             : 
    2665                 :     2214321 :           field = TREE_CHAIN (field);
    2666                 :             :         }
    2667                 :     2214321 :       while (field);
    2668                 :             : 
    2669                 :     2212413 :       return ref;
    2670                 :             :     }
    2671                 :          72 :   else if (should_suggest_deref_p (type))
    2672                 :             :     {
    2673                 :             :       /* Special-case the error message for "ptr.field" for the case
    2674                 :             :          where the user has confused "." vs "->".  */
    2675                 :           7 :       rich_location richloc (line_table, loc);
    2676                 :           7 :       if (INDIRECT_REF_P (datum) && arrow_loc != UNKNOWN_LOCATION)
    2677                 :             :         {
    2678                 :           2 :           richloc.add_fixit_insert_before (arrow_loc, "(*");
    2679                 :           2 :           richloc.add_fixit_insert_after (arrow_loc, ")");
    2680                 :           2 :           error_at (&richloc,
    2681                 :             :                     "%qE is a pointer to pointer; did you mean to dereference "
    2682                 :             :                     "it before applying %<->%> to it?",
    2683                 :           2 :                     TREE_OPERAND (datum, 0));
    2684                 :             :         }
    2685                 :             :       else
    2686                 :             :         {
    2687                 :             :           /* "loc" should be the "." token.  */
    2688                 :           5 :           richloc.add_fixit_replace ("->");
    2689                 :           5 :           error_at (&richloc,
    2690                 :             :                     "%qE is a pointer; did you mean to use %<->%>?",
    2691                 :             :                     datum);
    2692                 :             :         }
    2693                 :           7 :       return error_mark_node;
    2694                 :           7 :     }
    2695                 :          65 :   else if (code != ERROR_MARK)
    2696                 :           1 :     error_at (loc,
    2697                 :             :               "request for member %qE in something not a structure or union",
    2698                 :             :               component);
    2699                 :             : 
    2700                 :          65 :   return error_mark_node;
    2701                 :             : }
    2702                 :             : 
    2703                 :             : /* Given an expression PTR for a pointer, return an expression
    2704                 :             :    for the value pointed to.
    2705                 :             :    ERRORSTRING is the name of the operator to appear in error messages.
    2706                 :             : 
    2707                 :             :    LOC is the location to use for the generated tree.  */
    2708                 :             : 
    2709                 :             : tree
    2710                 :     2599869 : build_indirect_ref (location_t loc, tree ptr, ref_operator errstring)
    2711                 :             : {
    2712                 :     2599869 :   tree pointer = default_conversion (ptr);
    2713                 :     2599869 :   tree type = TREE_TYPE (pointer);
    2714                 :     2599869 :   tree ref;
    2715                 :             : 
    2716                 :     2599869 :   if (TREE_CODE (type) == POINTER_TYPE)
    2717                 :             :     {
    2718                 :     2599518 :       if (CONVERT_EXPR_P (pointer)
    2719                 :     1884166 :           || TREE_CODE (pointer) == VIEW_CONVERT_EXPR)
    2720                 :             :         {
    2721                 :             :           /* If a warning is issued, mark it to avoid duplicates from
    2722                 :             :              the backend.  This only needs to be done at
    2723                 :             :              warn_strict_aliasing > 2.  */
    2724                 :      715352 :           if (warn_strict_aliasing > 2)
    2725                 :      314958 :             if (strict_aliasing_warning (EXPR_LOCATION (pointer),
    2726                 :      314958 :                                          type, TREE_OPERAND (pointer, 0)))
    2727                 :           7 :               suppress_warning (pointer, OPT_Wstrict_aliasing_);
    2728                 :             :         }
    2729                 :             : 
    2730                 :     2599518 :       if (TREE_CODE (pointer) == ADDR_EXPR
    2731                 :     2599518 :           && (TREE_TYPE (TREE_OPERAND (pointer, 0))
    2732                 :       66745 :               == TREE_TYPE (type)))
    2733                 :             :         {
    2734                 :       66736 :           ref = TREE_OPERAND (pointer, 0);
    2735                 :       66736 :           protected_set_expr_location (ref, loc);
    2736                 :       66736 :           return ref;
    2737                 :             :         }
    2738                 :             :       else
    2739                 :             :         {
    2740                 :     2532782 :           tree t = TREE_TYPE (type);
    2741                 :             : 
    2742                 :     2532782 :           ref = build1 (INDIRECT_REF, t, pointer);
    2743                 :             : 
    2744                 :     2532782 :           if (VOID_TYPE_P (t) && c_inhibit_evaluation_warnings == 0)
    2745                 :         147 :             warning_at (loc, 0, "dereferencing %<void *%> pointer");
    2746                 :             : 
    2747                 :             :           /* We *must* set TREE_READONLY when dereferencing a pointer to const,
    2748                 :             :              so that we get the proper error message if the result is used
    2749                 :             :              to assign to.  Also, &* is supposed to be a no-op.
    2750                 :             :              And ANSI C seems to specify that the type of the result
    2751                 :             :              should be the const type.  */
    2752                 :             :           /* A de-reference of a pointer to const is not a const.  It is valid
    2753                 :             :              to change it via some other pointer.  */
    2754                 :     2532782 :           TREE_READONLY (ref) = TYPE_READONLY (t);
    2755                 :     2532782 :           TREE_SIDE_EFFECTS (ref)
    2756                 :     2532782 :             = TYPE_VOLATILE (t) || TREE_SIDE_EFFECTS (pointer);
    2757                 :     2532782 :           TREE_THIS_VOLATILE (ref) = TYPE_VOLATILE (t);
    2758                 :     2532782 :           protected_set_expr_location (ref, loc);
    2759                 :     2532782 :           return ref;
    2760                 :             :         }
    2761                 :             :     }
    2762                 :         351 :   else if (TREE_CODE (pointer) != ERROR_MARK)
    2763                 :         278 :     invalid_indirection_error (loc, type, errstring);
    2764                 :             : 
    2765                 :         351 :   return error_mark_node;
    2766                 :             : }
    2767                 :             : 
    2768                 :             : /* This handles expressions of the form "a[i]", which denotes
    2769                 :             :    an array reference.
    2770                 :             : 
    2771                 :             :    This is logically equivalent in C to *(a+i), but we may do it differently.
    2772                 :             :    If A is a variable or a member, we generate a primitive ARRAY_REF.
    2773                 :             :    This avoids forcing the array out of registers, and can work on
    2774                 :             :    arrays that are not lvalues (for example, members of structures returned
    2775                 :             :    by functions).
    2776                 :             : 
    2777                 :             :    For vector types, allow vector[i] but not i[vector], and create
    2778                 :             :    *(((type*)&vectortype) + i) for the expression.
    2779                 :             : 
    2780                 :             :    LOC is the location to use for the returned expression.  */
    2781                 :             : 
    2782                 :             : tree
    2783                 :     3330810 : build_array_ref (location_t loc, tree array, tree index)
    2784                 :             : {
    2785                 :     3330810 :   tree ret;
    2786                 :     3330810 :   bool swapped = false;
    2787                 :     3330810 :   if (TREE_TYPE (array) == error_mark_node
    2788                 :     3330810 :       || TREE_TYPE (index) == error_mark_node)
    2789                 :             :     return error_mark_node;
    2790                 :             : 
    2791                 :     3330702 :   if (TREE_CODE (TREE_TYPE (array)) != ARRAY_TYPE
    2792                 :     1887737 :       && TREE_CODE (TREE_TYPE (array)) != POINTER_TYPE
    2793                 :             :       /* Allow vector[index] but not index[vector].  */
    2794                 :     4294781 :       && !gnu_vector_type_p (TREE_TYPE (array)))
    2795                 :             :     {
    2796                 :         194 :       if (TREE_CODE (TREE_TYPE (index)) != ARRAY_TYPE
    2797                 :         194 :           && TREE_CODE (TREE_TYPE (index)) != POINTER_TYPE)
    2798                 :             :         {
    2799                 :           2 :           error_at (loc,
    2800                 :             :             "subscripted value is neither array nor pointer nor vector");
    2801                 :             : 
    2802                 :           2 :           return error_mark_node;
    2803                 :             :         }
    2804                 :         192 :       std::swap (array, index);
    2805                 :         192 :       swapped = true;
    2806                 :             :     }
    2807                 :             : 
    2808                 :     3330700 :   if (!INTEGRAL_TYPE_P (TREE_TYPE (index)))
    2809                 :             :     {
    2810                 :           2 :       error_at (loc, "array subscript is not an integer");
    2811                 :           2 :       return error_mark_node;
    2812                 :             :     }
    2813                 :             : 
    2814                 :     3330698 :   if (TREE_CODE (TREE_TYPE (TREE_TYPE (array))) == FUNCTION_TYPE)
    2815                 :             :     {
    2816                 :          10 :       error_at (loc, "subscripted value is pointer to function");
    2817                 :          10 :       return error_mark_node;
    2818                 :             :     }
    2819                 :             : 
    2820                 :             :   /* ??? Existing practice has been to warn only when the char
    2821                 :             :      index is syntactically the index, not for char[array].  */
    2822                 :     3330688 :   if (!swapped)
    2823                 :     3330502 :      warn_array_subscript_with_type_char (loc, index);
    2824                 :             : 
    2825                 :             :   /* Apply default promotions *after* noticing character types.  */
    2826                 :     3330688 :   index = default_conversion (index);
    2827                 :     3330688 :   if (index == error_mark_node)
    2828                 :             :     return error_mark_node;
    2829                 :             : 
    2830                 :     3330687 :   gcc_assert (TREE_CODE (TREE_TYPE (index)) == INTEGER_TYPE
    2831                 :             :               || TREE_CODE (TREE_TYPE (index)) == BITINT_TYPE);
    2832                 :             : 
    2833                 :     3330687 :   bool was_vector = VECTOR_TYPE_P (TREE_TYPE (array));
    2834                 :     3330687 :   bool non_lvalue = convert_vector_to_array_for_subscript (loc, &array, index);
    2835                 :             : 
    2836                 :     3330687 :   if (TREE_CODE (TREE_TYPE (array)) == ARRAY_TYPE)
    2837                 :             :     {
    2838                 :     2406857 :       tree rval, type;
    2839                 :             : 
    2840                 :             :       /* An array that is indexed by a non-constant
    2841                 :             :          cannot be stored in a register; we must be able to do
    2842                 :             :          address arithmetic on its address.
    2843                 :             :          Likewise an array of elements of variable size.  */
    2844                 :     2406857 :       if (TREE_CODE (index) != INTEGER_CST
    2845                 :     2406857 :           || (COMPLETE_TYPE_P (TREE_TYPE (TREE_TYPE (array)))
    2846                 :     1956264 :               && TREE_CODE (TYPE_SIZE (TREE_TYPE (TREE_TYPE (array)))) != INTEGER_CST))
    2847                 :             :         {
    2848                 :      451330 :           if (!c_mark_addressable (array, true))
    2849                 :           1 :             return error_mark_node;
    2850                 :             :         }
    2851                 :             :       /* An array that is indexed by a constant value which is not within
    2852                 :             :          the array bounds cannot be stored in a register either; because we
    2853                 :             :          would get a crash in store_bit_field/extract_bit_field when trying
    2854                 :             :          to access a non-existent part of the register.  */
    2855                 :     2406856 :       if (TREE_CODE (index) == INTEGER_CST
    2856                 :     1956264 :           && TYPE_DOMAIN (TREE_TYPE (array))
    2857                 :     4359794 :           && !int_fits_type_p (index, TYPE_DOMAIN (TREE_TYPE (array))))
    2858                 :             :         {
    2859                 :       60545 :           if (!c_mark_addressable (array))
    2860                 :           0 :             return error_mark_node;
    2861                 :             :         }
    2862                 :             : 
    2863                 :     2406856 :       if ((pedantic || warn_c90_c99_compat)
    2864                 :     2395168 :           && ! was_vector)
    2865                 :             :         {
    2866                 :     1442262 :           tree foo = array;
    2867                 :     2271993 :           while (TREE_CODE (foo) == COMPONENT_REF)
    2868                 :      829731 :             foo = TREE_OPERAND (foo, 0);
    2869                 :     1442262 :           if (VAR_P (foo) && C_DECL_REGISTER (foo))
    2870                 :           0 :             pedwarn (loc, OPT_Wpedantic,
    2871                 :             :                      "ISO C forbids subscripting %<register%> array");
    2872                 :     1442262 :           else if (!lvalue_p (foo))
    2873                 :         110 :             pedwarn_c90 (loc, OPT_Wpedantic,
    2874                 :             :                          "ISO C90 forbids subscripting non-lvalue "
    2875                 :             :                          "array");
    2876                 :             :         }
    2877                 :             : 
    2878                 :     2406856 :       if (TREE_CODE (TREE_TYPE (index)) == BITINT_TYPE
    2879                 :     2406856 :           && TYPE_PRECISION (TREE_TYPE (index)) > TYPE_PRECISION (sizetype))
    2880                 :           3 :         index = fold_convert (sizetype, index);
    2881                 :             : 
    2882                 :     2406856 :       type = TREE_TYPE (TREE_TYPE (array));
    2883                 :     2406856 :       rval = build4 (ARRAY_REF, type, array, index, NULL_TREE, NULL_TREE);
    2884                 :             :       /* Array ref is const/volatile if the array elements are
    2885                 :             :          or if the array is.  */
    2886                 :     7220568 :       TREE_READONLY (rval)
    2887                 :     2406856 :         |= (TYPE_READONLY (TREE_TYPE (TREE_TYPE (array)))
    2888                 :     2406856 :             | TREE_READONLY (array));
    2889                 :     7220568 :       TREE_SIDE_EFFECTS (rval)
    2890                 :     2406856 :         |= (TYPE_VOLATILE (TREE_TYPE (TREE_TYPE (array)))
    2891                 :     2406856 :             | TREE_SIDE_EFFECTS (array));
    2892                 :     4813712 :       TREE_THIS_VOLATILE (rval)
    2893                 :     2406856 :         |= (TYPE_VOLATILE (TREE_TYPE (TREE_TYPE (array)))
    2894                 :             :             /* This was added by rms on 16 Nov 91.
    2895                 :             :                It fixes  vol struct foo *a;  a->elts[1]
    2896                 :             :                in an inline function.
    2897                 :             :                Hope it doesn't break something else.  */
    2898                 :     2406856 :             | TREE_THIS_VOLATILE (array));
    2899                 :     2406856 :       ret = require_complete_type (loc, rval);
    2900                 :     2406856 :       protected_set_expr_location (ret, loc);
    2901                 :     2406856 :       if (non_lvalue)
    2902                 :       76111 :         ret = non_lvalue_loc (loc, ret);
    2903                 :     2406856 :       return ret;
    2904                 :             :     }
    2905                 :             :   else
    2906                 :             :     {
    2907                 :      923830 :       tree ar = default_conversion (array);
    2908                 :             : 
    2909                 :      923830 :       if (ar == error_mark_node)
    2910                 :             :         return ar;
    2911                 :             : 
    2912                 :      923830 :       gcc_assert (TREE_CODE (TREE_TYPE (ar)) == POINTER_TYPE);
    2913                 :      923830 :       gcc_assert (TREE_CODE (TREE_TYPE (TREE_TYPE (ar))) != FUNCTION_TYPE);
    2914                 :             : 
    2915                 :      923830 :       ret = build_indirect_ref (loc, build_binary_op (loc, PLUS_EXPR, ar,
    2916                 :             :                                                       index, false),
    2917                 :             :                                 RO_ARRAY_INDEXING);
    2918                 :      923830 :       if (non_lvalue)
    2919                 :           0 :         ret = non_lvalue_loc (loc, ret);
    2920                 :      923830 :       return ret;
    2921                 :             :     }
    2922                 :             : }
    2923                 :             : 
    2924                 :             : /* Build an OpenMP array section reference, creating an exact type for the
    2925                 :             :    resulting expression based on the element type and bounds if possible.  If
    2926                 :             :    we have variable bounds, create an incomplete array type for the result
    2927                 :             :    instead.  */
    2928                 :             : 
    2929                 :             : tree
    2930                 :        3619 : build_omp_array_section (location_t loc, tree array, tree index, tree length)
    2931                 :             : {
    2932                 :        3619 :   tree type = TREE_TYPE (array);
    2933                 :        3619 :   gcc_assert (type);
    2934                 :             : 
    2935                 :        3619 :   tree sectype, eltype = TREE_TYPE (type);
    2936                 :             : 
    2937                 :             :   /* It's not an array or pointer type.  Just reuse the type of the original
    2938                 :             :      expression as the type of the array section (an error will be raised
    2939                 :             :      anyway, later).  */
    2940                 :        3619 :   if (eltype == NULL_TREE || error_operand_p (eltype))
    2941                 :          11 :     sectype = TREE_TYPE (array);
    2942                 :             :   else
    2943                 :             :     {
    2944                 :        3608 :       tree idxtype = NULL_TREE;
    2945                 :             : 
    2946                 :        3608 :       if (index != NULL_TREE
    2947                 :        3608 :           && length != NULL_TREE
    2948                 :        2816 :           && INTEGRAL_TYPE_P (TREE_TYPE (index))
    2949                 :        6419 :           && INTEGRAL_TYPE_P (TREE_TYPE (length)))
    2950                 :             :         {
    2951                 :        2808 :           tree low = fold_convert (sizetype, index);
    2952                 :        2808 :           tree high = fold_convert (sizetype, length);
    2953                 :        2808 :           high = size_binop (PLUS_EXPR, low, high);
    2954                 :        2808 :           high = size_binop (MINUS_EXPR, high, size_one_node);
    2955                 :        2808 :           idxtype = build_range_type (sizetype, low, high);
    2956                 :             :         }
    2957                 :         131 :       else if ((index == NULL_TREE || integer_zerop (index))
    2958                 :         690 :                && length != NULL_TREE
    2959                 :        1338 :                && INTEGRAL_TYPE_P (TREE_TYPE (length)))
    2960                 :         525 :         idxtype = build_index_type (length);
    2961                 :             : 
    2962                 :        3608 :       gcc_assert (!error_operand_p (idxtype));
    2963                 :             : 
    2964                 :        3608 :       sectype = build_array_type (eltype, idxtype);
    2965                 :             :     }
    2966                 :             : 
    2967                 :        3619 :   return build3_loc (loc, OMP_ARRAY_SECTION, sectype, array, index, length);
    2968                 :             : }
    2969                 :             : 
    2970                 :             : 
    2971                 :             : /* Build an external reference to identifier ID.  FUN indicates
    2972                 :             :    whether this will be used for a function call.  LOC is the source
    2973                 :             :    location of the identifier.  This sets *TYPE to the type of the
    2974                 :             :    identifier, which is not the same as the type of the returned value
    2975                 :             :    for CONST_DECLs defined as enum constants.  If the type of the
    2976                 :             :    identifier is not available, *TYPE is set to NULL.  */
    2977                 :             : tree
    2978                 :   155294123 : build_external_ref (location_t loc, tree id, bool fun, tree *type)
    2979                 :             : {
    2980                 :   155294123 :   tree ref;
    2981                 :   155294123 :   tree decl = lookup_name (id);
    2982                 :             : 
    2983                 :             :   /* In Objective-C, an instance variable (ivar) may be preferred to
    2984                 :             :      whatever lookup_name() found.  */
    2985                 :   155294123 :   decl = objc_lookup_ivar (decl, id);
    2986                 :             : 
    2987                 :   155294123 :   *type = NULL;
    2988                 :   155294123 :   if (decl && decl != error_mark_node)
    2989                 :             :     {
    2990                 :   155287901 :       ref = decl;
    2991                 :   155287901 :       *type = TREE_TYPE (ref);
    2992                 :   155287901 :       if (DECL_P (decl) && C_DECL_UNDERSPECIFIED (decl))
    2993                 :           4 :         error_at (loc, "underspecified %qD referenced in its initializer",
    2994                 :             :                   decl);
    2995                 :             :     }
    2996                 :        6222 :   else if (fun)
    2997                 :             :     /* Implicit function declaration.  */
    2998                 :        4724 :     ref = implicitly_declare (loc, id);
    2999                 :        1498 :   else if (decl == error_mark_node)
    3000                 :             :     /* Don't complain about something that's already been
    3001                 :             :        complained about.  */
    3002                 :             :     return error_mark_node;
    3003                 :             :   else
    3004                 :             :     {
    3005                 :        1268 :       undeclared_variable (loc, id);
    3006                 :        1268 :       return error_mark_node;
    3007                 :             :     }
    3008                 :             : 
    3009                 :             :   /* For an OpenMP map clause, we can get better diagnostics for decls with
    3010                 :             :      unmappable types if we return the decl with an error_mark_node type,
    3011                 :             :      rather than returning error_mark_node for the decl itself.  */
    3012                 :   155292625 :   if (TREE_TYPE (ref) == error_mark_node
    3013                 :   155292625 :       && !c_omp_array_section_p)
    3014                 :             :     return error_mark_node;
    3015                 :             : 
    3016                 :   155292608 :   if (TREE_UNAVAILABLE (ref))
    3017                 :          14 :     error_unavailable_use (ref, NULL_TREE);
    3018                 :   155292594 :   else if (TREE_DEPRECATED (ref))
    3019                 :          49 :     warn_deprecated_use (ref, NULL_TREE);
    3020                 :             : 
    3021                 :             :   /* Recursive call does not count as usage.  */
    3022                 :   155292608 :   if (ref != current_function_decl)
    3023                 :             :     {
    3024                 :   155289942 :       TREE_USED (ref) = 1;
    3025                 :             :     }
    3026                 :             : 
    3027                 :   155292608 :   if (TREE_CODE (ref) == FUNCTION_DECL && !in_alignof)
    3028                 :             :     {
    3029                 :    44580063 :       if (!in_sizeof && !in_typeof)
    3030                 :    44037916 :         C_DECL_USED (ref) = 1;
    3031                 :      542147 :       else if (DECL_INITIAL (ref) == NULL_TREE
    3032                 :      535977 :                && DECL_EXTERNAL (ref)
    3033                 :     1078123 :                && !TREE_PUBLIC (ref))
    3034                 :          96 :         record_maybe_used_decl (ref);
    3035                 :             :     }
    3036                 :             : 
    3037                 :   155292608 :   if (TREE_CODE (ref) == CONST_DECL)
    3038                 :             :     {
    3039                 :      402730 :       used_types_insert (TREE_TYPE (ref));
    3040                 :             : 
    3041                 :      402730 :       if (warn_cxx_compat
    3042                 :         309 :           && TREE_CODE (TREE_TYPE (ref)) == ENUMERAL_TYPE
    3043                 :      403037 :           && C_TYPE_DEFINED_IN_STRUCT (TREE_TYPE (ref)))
    3044                 :             :         {
    3045                 :           1 :           warning_at (loc, OPT_Wc___compat,
    3046                 :             :                       ("enum constant defined in struct or union "
    3047                 :             :                        "is not visible in C++"));
    3048                 :           1 :           inform (DECL_SOURCE_LOCATION (ref), "enum constant defined here");
    3049                 :             :         }
    3050                 :             : 
    3051                 :      402730 :       ref = DECL_INITIAL (ref);
    3052                 :      402730 :       TREE_CONSTANT (ref) = 1;
    3053                 :             :     }
    3054                 :   154889878 :   else if (current_function_decl != NULL_TREE
    3055                 :   153481746 :            && !DECL_FILE_SCOPE_P (current_function_decl)
    3056                 :   154889878 :            && (VAR_OR_FUNCTION_DECL_P (ref)
    3057                 :             :                || TREE_CODE (ref) == PARM_DECL))
    3058                 :             :     {
    3059                 :       10060 :       tree context = decl_function_context (ref);
    3060                 :             : 
    3061                 :       10060 :       if (context != NULL_TREE && context != current_function_decl)
    3062                 :        1608 :         DECL_NONLOCAL (ref) = 1;
    3063                 :             :     }
    3064                 :             :   /* C99 6.7.4p3: An inline definition of a function with external
    3065                 :             :      linkage ... shall not contain a reference to an identifier with
    3066                 :             :      internal linkage.  */
    3067                 :   154879818 :   else if (current_function_decl != NULL_TREE
    3068                 :   153471686 :            && DECL_DECLARED_INLINE_P (current_function_decl)
    3069                 :   140337408 :            && DECL_EXTERNAL (current_function_decl)
    3070                 :   139610827 :            && VAR_OR_FUNCTION_DECL_P (ref)
    3071                 :    49790959 :            && (!VAR_P (ref) || TREE_STATIC (ref))
    3072                 :    40805231 :            && ! TREE_PUBLIC (ref)
    3073                 :   154879852 :            && DECL_CONTEXT (ref) != current_function_decl)
    3074                 :          25 :     record_inline_static (loc, current_function_decl, ref,
    3075                 :             :                           csi_internal);
    3076                 :             : 
    3077                 :             :   return ref;
    3078                 :             : }
    3079                 :             : 
    3080                 :             : /* Record details of decls possibly used inside sizeof or typeof.  */
    3081                 :             : struct maybe_used_decl
    3082                 :             : {
    3083                 :             :   /* The decl.  */
    3084                 :             :   tree decl;
    3085                 :             :   /* The level seen at (in_sizeof + in_typeof).  */
    3086                 :             :   int level;
    3087                 :             :   /* The next one at this level or above, or NULL.  */
    3088                 :             :   struct maybe_used_decl *next;
    3089                 :             : };
    3090                 :             : 
    3091                 :             : static struct maybe_used_decl *maybe_used_decls;
    3092                 :             : 
    3093                 :             : /* Record that DECL, an undefined static function reference seen
    3094                 :             :    inside sizeof or typeof, might be used if the operand of sizeof is
    3095                 :             :    a VLA type or the operand of typeof is a variably modified
    3096                 :             :    type.  */
    3097                 :             : 
    3098                 :             : static void
    3099                 :          96 : record_maybe_used_decl (tree decl)
    3100                 :             : {
    3101                 :          96 :   struct maybe_used_decl *t = XOBNEW (&parser_obstack, struct maybe_used_decl);
    3102                 :          96 :   t->decl = decl;
    3103                 :          96 :   t->level = in_sizeof + in_typeof;
    3104                 :          96 :   t->next = maybe_used_decls;
    3105                 :          96 :   maybe_used_decls = t;
    3106                 :          96 : }
    3107                 :             : 
    3108                 :             : /* Pop the stack of decls possibly used inside sizeof or typeof.  If
    3109                 :             :    USED is false, just discard them.  If it is true, mark them used
    3110                 :             :    (if no longer inside sizeof or typeof) or move them to the next
    3111                 :             :    level up (if still inside sizeof or typeof).  */
    3112                 :             : 
    3113                 :             : void
    3114                 :     1319942 : pop_maybe_used (bool used)
    3115                 :             : {
    3116                 :     1319942 :   struct maybe_used_decl *p = maybe_used_decls;
    3117                 :     1319942 :   int cur_level = in_sizeof + in_typeof;
    3118                 :     1320040 :   while (p && p->level > cur_level)
    3119                 :             :     {
    3120                 :          98 :       if (used)
    3121                 :             :         {
    3122                 :          11 :           if (cur_level == 0)
    3123                 :           9 :             C_DECL_USED (p->decl) = 1;
    3124                 :             :           else
    3125                 :           2 :             p->level = cur_level;
    3126                 :             :         }
    3127                 :          98 :       p = p->next;
    3128                 :             :     }
    3129                 :     1319942 :   if (!used || cur_level == 0)
    3130                 :     1319927 :     maybe_used_decls = p;
    3131                 :     1319942 : }
    3132                 :             : 
    3133                 :             : /* Return the result of sizeof applied to EXPR.  */
    3134                 :             : 
    3135                 :             : struct c_expr
    3136                 :      312517 : c_expr_sizeof_expr (location_t loc, struct c_expr expr)
    3137                 :             : {
    3138                 :      312517 :   struct c_expr ret;
    3139                 :      312517 :   if (expr.value == error_mark_node)
    3140                 :             :     {
    3141                 :         101 :       ret.value = error_mark_node;
    3142                 :         101 :       ret.original_code = ERROR_MARK;
    3143                 :         101 :       ret.original_type = NULL;
    3144                 :         101 :       ret.m_decimal = 0;
    3145                 :         101 :       pop_maybe_used (false);
    3146                 :             :     }
    3147                 :             :   else
    3148                 :             :     {
    3149                 :      312416 :       bool expr_const_operands = true;
    3150                 :             : 
    3151                 :      312416 :       if (TREE_CODE (expr.value) == PARM_DECL
    3152                 :      312416 :           && C_ARRAY_PARAMETER (expr.value))
    3153                 :             :         {
    3154                 :          55 :           auto_diagnostic_group d;
    3155                 :          55 :           if (warning_at (loc, OPT_Wsizeof_array_argument,
    3156                 :             :                           "%<sizeof%> on array function parameter %qE will "
    3157                 :             :                           "return size of %qT", expr.value,
    3158                 :          55 :                           TREE_TYPE (expr.value)))
    3159                 :          19 :             inform (DECL_SOURCE_LOCATION (expr.value), "declared here");
    3160                 :          55 :         }
    3161                 :      312416 :       tree folded_expr = c_fully_fold (expr.value, require_constant_value,
    3162                 :             :                                        &expr_const_operands);
    3163                 :      312416 :       ret.value = c_sizeof (loc, TREE_TYPE (folded_expr));
    3164                 :      312416 :       c_last_sizeof_arg = expr.value;
    3165                 :      312416 :       c_last_sizeof_loc = loc;
    3166                 :      312416 :       ret.original_code = SIZEOF_EXPR;
    3167                 :      312416 :       ret.original_type = NULL;
    3168                 :      312416 :       ret.m_decimal = 0;
    3169                 :      312416 :       if (C_TYPE_VARIABLE_SIZE (TREE_TYPE (folded_expr)))
    3170                 :             :         {
    3171                 :             :           /* sizeof is evaluated when given a vla (C99 6.5.3.4p2).  */
    3172                 :         262 :           ret.value = build2 (C_MAYBE_CONST_EXPR, TREE_TYPE (ret.value),
    3173                 :             :                               folded_expr, ret.value);
    3174                 :         262 :           C_MAYBE_CONST_EXPR_NON_CONST (ret.value) = !expr_const_operands;
    3175                 :         262 :           SET_EXPR_LOCATION (ret.value, loc);
    3176                 :             :         }
    3177                 :      312416 :       pop_maybe_used (C_TYPE_VARIABLE_SIZE (TREE_TYPE (folded_expr)));
    3178                 :             :     }
    3179                 :      312517 :   return ret;
    3180                 :             : }
    3181                 :             : 
    3182                 :             : /* Return the result of sizeof applied to T, a structure for the type
    3183                 :             :    name passed to sizeof (rather than the type itself).  LOC is the
    3184                 :             :    location of the original expression.  */
    3185                 :             : 
    3186                 :             : struct c_expr
    3187                 :      334900 : c_expr_sizeof_type (location_t loc, struct c_type_name *t)
    3188                 :             : {
    3189                 :      334900 :   tree type;
    3190                 :      334900 :   struct c_expr ret;
    3191                 :      334900 :   tree type_expr = NULL_TREE;
    3192                 :      334900 :   bool type_expr_const = true;
    3193                 :      334900 :   type = groktypename (t, &type_expr, &type_expr_const);
    3194                 :      334900 :   ret.value = c_sizeof (loc, type);
    3195                 :      334900 :   c_last_sizeof_arg = type;
    3196                 :      334900 :   c_last_sizeof_loc = loc;
    3197                 :      334900 :   ret.original_code = SIZEOF_EXPR;
    3198                 :      334900 :   ret.original_type = NULL;
    3199                 :      334900 :   ret.m_decimal = 0;
    3200                 :      334900 :   if (type == error_mark_node)
    3201                 :             :     {
    3202                 :           5 :       ret.value = error_mark_node;
    3203                 :           5 :       ret.original_code = ERROR_MARK;
    3204                 :             :     }
    3205                 :             :   else
    3206                 :      334870 :   if ((type_expr || TREE_CODE (ret.value) == INTEGER_CST)
    3207                 :      669709 :       && C_TYPE_VARIABLE_SIZE (type))
    3208                 :             :     {
    3209                 :             :       /* If the type is a [*] array, it is a VLA but is represented as
    3210                 :             :          having a size of zero.  In such a case we must ensure that
    3211                 :             :          the result of sizeof does not get folded to a constant by
    3212                 :             :          c_fully_fold, because if the size is evaluated the result is
    3213                 :             :          not constant and so constraints on zero or negative size
    3214                 :             :          arrays must not be applied when this sizeof call is inside
    3215                 :             :          another array declarator.  */
    3216                 :          11 :       if (!type_expr)
    3217                 :           3 :         type_expr = integer_zero_node;
    3218                 :          11 :       ret.value = build2 (C_MAYBE_CONST_EXPR, TREE_TYPE (ret.value),
    3219                 :             :                           type_expr, ret.value);
    3220                 :          11 :       C_MAYBE_CONST_EXPR_NON_CONST (ret.value) = !type_expr_const;
    3221                 :             :     }
    3222                 :      334900 :   pop_maybe_used (type != error_mark_node
    3223                 :      334900 :                   ? C_TYPE_VARIABLE_SIZE (type) : false);
    3224                 :      334900 :   return ret;
    3225                 :             : }
    3226                 :             : 
    3227                 :             : /* Build a function call to function FUNCTION with parameters PARAMS.
    3228                 :             :    The function call is at LOC.
    3229                 :             :    PARAMS is a list--a chain of TREE_LIST nodes--in which the
    3230                 :             :    TREE_VALUE of each node is a parameter-expression.
    3231                 :             :    FUNCTION's data type may be a function type or a pointer-to-function.  */
    3232                 :             : 
    3233                 :             : tree
    3234                 :           0 : build_function_call (location_t loc, tree function, tree params)
    3235                 :             : {
    3236                 :           0 :   vec<tree, va_gc> *v;
    3237                 :           0 :   tree ret;
    3238                 :             : 
    3239                 :           0 :   vec_alloc (v, list_length (params));
    3240                 :           0 :   for (; params; params = TREE_CHAIN (params))
    3241                 :           0 :     v->quick_push (TREE_VALUE (params));
    3242                 :           0 :   ret = c_build_function_call_vec (loc, vNULL, function, v, NULL);
    3243                 :           0 :   vec_free (v);
    3244                 :           0 :   return ret;
    3245                 :             : }
    3246                 :             : 
    3247                 :             : /* Give a note about the location of the declaration of DECL.  */
    3248                 :             : 
    3249                 :             : static void
    3250                 :         296 : inform_declaration (tree decl)
    3251                 :             : {
    3252                 :         296 :   if (decl && (TREE_CODE (decl) != FUNCTION_DECL
    3253                 :         285 :                || !DECL_IS_UNDECLARED_BUILTIN (decl)))
    3254                 :         214 :     inform (DECL_SOURCE_LOCATION (decl), "declared here");
    3255                 :         296 : }
    3256                 :             : 
    3257                 :             : /* Build a function call to function FUNCTION with parameters PARAMS.
    3258                 :             :    If FUNCTION is the result of resolving an overloaded target built-in,
    3259                 :             :    ORIG_FUNDECL is the original function decl, otherwise it is null.
    3260                 :             :    ORIGTYPES, if not NULL, is a vector of types; each element is
    3261                 :             :    either NULL or the original type of the corresponding element in
    3262                 :             :    PARAMS.  The original type may differ from TREE_TYPE of the
    3263                 :             :    parameter for enums.  FUNCTION's data type may be a function type
    3264                 :             :    or pointer-to-function.  This function changes the elements of
    3265                 :             :    PARAMS.  */
    3266                 :             : 
    3267                 :             : tree
    3268                 :    43261966 : build_function_call_vec (location_t loc, vec<location_t> arg_loc,
    3269                 :             :                          tree function, vec<tree, va_gc> *params,
    3270                 :             :                          vec<tree, va_gc> *origtypes, tree orig_fundecl)
    3271                 :             : {
    3272                 :    43261966 :   tree fntype, fundecl = NULL_TREE;
    3273                 :    43261966 :   tree name = NULL_TREE, result;
    3274                 :    43261966 :   tree tem;
    3275                 :    43261966 :   int nargs;
    3276                 :    43261966 :   tree *argarray;
    3277                 :             : 
    3278                 :             : 
    3279                 :             :   /* Strip NON_LVALUE_EXPRs, etc., since we aren't using as an lvalue.  */
    3280                 :    43261966 :   STRIP_TYPE_NOPS (function);
    3281                 :             : 
    3282                 :             :   /* Convert anything with function type to a pointer-to-function.  */
    3283                 :    43261966 :   if (TREE_CODE (function) == FUNCTION_DECL)
    3284                 :             :     {
    3285                 :    43185742 :       name = DECL_NAME (function);
    3286                 :             : 
    3287                 :    43185742 :       if (flag_tm)
    3288                 :         421 :         tm_malloc_replacement (function);
    3289                 :    43185742 :       fundecl = function;
    3290                 :    43185742 :       if (!orig_fundecl)
    3291                 :    43185742 :         orig_fundecl = fundecl;
    3292                 :             :       /* Atomic functions have type checking/casting already done.  They are 
    3293                 :             :          often rewritten and don't match the original parameter list.  */
    3294                 :    86371484 :       if (name && startswith (IDENTIFIER_POINTER (name), "__atomic_"))
    3295                 :             :         origtypes = NULL;
    3296                 :             :     }
    3297                 :    43261966 :   if (TREE_CODE (TREE_TYPE (function)) == FUNCTION_TYPE)
    3298                 :    43199354 :     function = function_to_pointer_conversion (loc, function);
    3299                 :             : 
    3300                 :             :   /* For Objective-C, convert any calls via a cast to OBJC_TYPE_REF
    3301                 :             :      expressions, like those used for ObjC messenger dispatches.  */
    3302                 :    43261966 :   if (params && !params->is_empty ())
    3303                 :    33530058 :     function = objc_rewrite_function_call (function, (*params)[0]);
    3304                 :             : 
    3305                 :    43261966 :   function = c_fully_fold (function, false, NULL);
    3306                 :             : 
    3307                 :    43261966 :   fntype = TREE_TYPE (function);
    3308                 :             : 
    3309                 :    43261966 :   if (TREE_CODE (fntype) == ERROR_MARK)
    3310                 :           3 :     return error_mark_node;
    3311                 :             : 
    3312                 :    43261963 :   if (!(TREE_CODE (fntype) == POINTER_TYPE
    3313                 :    43261929 :         && TREE_CODE (TREE_TYPE (fntype)) == FUNCTION_TYPE))
    3314                 :             :     {
    3315                 :          37 :       if (!flag_diagnostics_show_caret && !STATEMENT_CLASS_P (function))
    3316                 :          33 :         error_at (loc,
    3317                 :             :                   "called object %qE is not a function or function pointer",
    3318                 :             :                   function);
    3319                 :           4 :       else if (DECL_P (function))
    3320                 :             :         {
    3321                 :           1 :           error_at (loc,
    3322                 :             :                     "called object %qD is not a function or function pointer",
    3323                 :             :                     function);
    3324                 :           1 :           inform_declaration (function);
    3325                 :             :         }
    3326                 :             :       else
    3327                 :           3 :         error_at (loc,
    3328                 :             :                   "called object is not a function or function pointer");
    3329                 :          37 :       return error_mark_node;
    3330                 :             :     }
    3331                 :             : 
    3332                 :    43261926 :   if (fundecl && TREE_THIS_VOLATILE (fundecl))
    3333                 :      363387 :     current_function_returns_abnormally = 1;
    3334                 :             : 
    3335                 :             :   /* fntype now gets the type of function pointed to.  */
    3336                 :    43261926 :   fntype = TREE_TYPE (fntype);
    3337                 :    43261926 :   tree return_type = TREE_TYPE (fntype);
    3338                 :             : 
    3339                 :             :   /* Convert the parameters to the types declared in the
    3340                 :             :      function prototype, or apply default promotions.  */
    3341                 :             : 
    3342                 :    43261926 :   nargs = convert_arguments (loc, arg_loc, TYPE_ARG_TYPES (fntype), params,
    3343                 :             :                              origtypes, function, fundecl);
    3344                 :    43261926 :   if (nargs < 0)
    3345                 :         165 :     return error_mark_node;
    3346                 :             : 
    3347                 :             :   /* Check that the function is called through a compatible prototype.
    3348                 :             :      If it is not, warn.  */
    3349                 :    43260913 :   if (CONVERT_EXPR_P (function)
    3350                 :         863 :       && TREE_CODE (tem = TREE_OPERAND (function, 0)) == ADDR_EXPR
    3351                 :         200 :       && TREE_CODE (tem = TREE_OPERAND (tem, 0)) == FUNCTION_DECL
    3352                 :    43261931 :       && !comptypes (fntype, TREE_TYPE (tem)))
    3353                 :             :     {
    3354                 :             :       /* This situation leads to run-time undefined behavior.  We can't,
    3355                 :             :          therefore, simply error unless we can prove that all possible
    3356                 :             :          executions of the program must execute the code.  */
    3357                 :          19 :       warning_at (loc, 0, "function called through a non-compatible type");
    3358                 :             : 
    3359                 :          19 :       if (VOID_TYPE_P (return_type)
    3360                 :          19 :           && TYPE_QUALS (return_type) != TYPE_UNQUALIFIED)
    3361                 :           1 :         pedwarn (loc, 0,
    3362                 :             :                  "function with qualified void return type called");
    3363                 :             :      }
    3364                 :             : 
    3365                 :    43261761 :   argarray = vec_safe_address (params);
    3366                 :             : 
    3367                 :             :   /* Check that arguments to builtin functions match the expectations.  */
    3368                 :    43261761 :   if (fundecl
    3369                 :    43185586 :       && fndecl_built_in_p (fundecl)
    3370                 :    72136809 :       && !check_builtin_function_arguments (loc, arg_loc, fundecl,
    3371                 :             :                                             orig_fundecl, nargs, argarray))
    3372                 :         298 :     return error_mark_node;
    3373                 :             : 
    3374                 :             :   /* Check that the arguments to the function are valid.  */
    3375                 :    43261463 :   bool warned_p = check_function_arguments (loc, fundecl, fntype,
    3376                 :             :                                             nargs, argarray, &arg_loc);
    3377                 :             : 
    3378                 :    43261463 :   if (TYPE_QUALS (return_type) != TYPE_UNQUALIFIED
    3379                 :    43261463 :       && !VOID_TYPE_P (return_type))
    3380                 :          11 :     return_type = c_build_qualified_type (return_type, TYPE_UNQUALIFIED);
    3381                 :    43261463 :   if (name != NULL_TREE
    3382                 :    86446751 :       && startswith (IDENTIFIER_POINTER (name), "__builtin_"))
    3383                 :             :     {
    3384                 :    28164869 :       if (require_constant_value)
    3385                 :        3484 :         result
    3386                 :        3484 :           = fold_build_call_array_initializer_loc (loc, return_type,
    3387                 :             :                                                    function, nargs, argarray);
    3388                 :             :       else
    3389                 :    28161385 :         result = fold_build_call_array_loc (loc, return_type,
    3390                 :             :                                             function, nargs, argarray);
    3391                 :    28164869 :       if (TREE_CODE (result) == NOP_EXPR
    3392                 :    28164869 :           && TREE_CODE (TREE_OPERAND (result, 0)) == INTEGER_CST)
    3393                 :       25858 :         STRIP_TYPE_NOPS (result);
    3394                 :             :     }
    3395                 :             :   else
    3396                 :    15096594 :     result = build_call_array_loc (loc, return_type,
    3397                 :             :                                    function, nargs, argarray);
    3398                 :             :   /* If -Wnonnull warning has been diagnosed, avoid diagnosing it again
    3399                 :             :      later.  */
    3400                 :    43261463 :   if (warned_p && TREE_CODE (result) == CALL_EXPR)
    3401                 :         180 :     suppress_warning (result, OPT_Wnonnull);
    3402                 :             : 
    3403                 :             :   /* In this improbable scenario, a nested function returns a VM type.
    3404                 :             :      Create a TARGET_EXPR so that the call always has a LHS, much as
    3405                 :             :      what the C++ FE does for functions returning non-PODs.  */
    3406                 :    43261463 :   if (C_TYPE_VARIABLY_MODIFIED (TREE_TYPE (fntype)))
    3407                 :             :     {
    3408                 :          59 :       tree tmp = create_tmp_var_raw (TREE_TYPE (fntype));
    3409                 :          59 :       result = build4 (TARGET_EXPR, TREE_TYPE (fntype), tmp, result,
    3410                 :             :                        NULL_TREE, NULL_TREE);
    3411                 :             :     }
    3412                 :             : 
    3413                 :    43261463 :   if (VOID_TYPE_P (TREE_TYPE (result)))
    3414                 :             :     {
    3415                 :     2393665 :       if (TYPE_QUALS (TREE_TYPE (result)) != TYPE_UNQUALIFIED)
    3416                 :           2 :         pedwarn (loc, 0,
    3417                 :             :                  "function with qualified void return type called");
    3418                 :     2393665 :       return result;
    3419                 :             :     }
    3420                 :    40867798 :   return require_complete_type (loc, result);
    3421                 :             : }
    3422                 :             : 
    3423                 :             : /* Like build_function_call_vec, but call also resolve_overloaded_builtin.  */
    3424                 :             : 
    3425                 :             : tree
    3426                 :    43261523 : c_build_function_call_vec (location_t loc, const vec<location_t> &arg_loc,
    3427                 :             :                            tree function, vec<tree, va_gc> *params,
    3428                 :             :                            vec<tree, va_gc> *origtypes)
    3429                 :             : {
    3430                 :             :   /* Strip NON_LVALUE_EXPRs, etc., since we aren't using as an lvalue.  */
    3431                 :    43261534 :   STRIP_TYPE_NOPS (function);
    3432                 :             : 
    3433                 :             :   /* Convert anything with function type to a pointer-to-function.  */
    3434                 :    43261523 :   if (TREE_CODE (function) == FUNCTION_DECL)
    3435                 :             :     {
    3436                 :             :       /* Implement type-directed function overloading for builtins.
    3437                 :             :          resolve_overloaded_builtin and targetm.resolve_overloaded_builtin
    3438                 :             :          handle all the type checking.  The result is a complete expression
    3439                 :             :          that implements this function call.  */
    3440                 :    43185299 :       tree tem = resolve_overloaded_builtin (loc, function, params);
    3441                 :    43185299 :       if (tem)
    3442                 :             :         return tem;
    3443                 :             :     }
    3444                 :    43176651 :   return build_function_call_vec (loc, arg_loc, function, params, origtypes);
    3445                 :             : }
    3446                 :             : 
    3447                 :             : /* Helper for convert_arguments called to convert the VALue of argument
    3448                 :             :    number ARGNUM from ORIGTYPE to the corresponding parameter number
    3449                 :             :    PARMNUM and TYPE.
    3450                 :             :    PLOC is the location where the conversion is being performed.
    3451                 :             :    FUNCTION and FUNDECL are the same as in convert_arguments.
    3452                 :             :    VALTYPE is the original type of VAL before the conversion and,
    3453                 :             :    for EXCESS_PRECISION_EXPR, the operand of the expression.
    3454                 :             :    NPC is true if VAL represents the null pointer constant (VAL itself
    3455                 :             :    will have been folded to an integer constant).
    3456                 :             :    RNAME is the same as FUNCTION except in Objective C when it's
    3457                 :             :    the function selector.
    3458                 :             :    EXCESS_PRECISION is true when VAL was originally represented
    3459                 :             :    as EXCESS_PRECISION_EXPR.
    3460                 :             :    WARNOPT is the same as in convert_for_assignment.  */
    3461                 :             : 
    3462                 :             : static tree
    3463                 :   110011555 : convert_argument (location_t ploc, tree function, tree fundecl,
    3464                 :             :                   tree type, tree origtype, tree val, tree valtype,
    3465                 :             :                   bool npc, tree rname, int parmnum, int argnum,
    3466                 :             :                   bool excess_precision, int warnopt)
    3467                 :             : {
    3468                 :             :   /* Formal parm type is specified by a function prototype.  */
    3469                 :             : 
    3470                 :   110011555 :   if (type == error_mark_node || !COMPLETE_TYPE_P (type))
    3471                 :             :     {
    3472                 :           3 :       error_at (ploc, "type of formal parameter %d is incomplete",
    3473                 :             :                 parmnum + 1);
    3474                 :           3 :       return error_mark_node;
    3475                 :             :     }
    3476                 :             : 
    3477                 :             :   /* Optionally warn about conversions that differ from the default
    3478                 :             :      conversions.  */
    3479                 :   110011552 :   if (warn_traditional_conversion || warn_traditional)
    3480                 :             :     {
    3481                 :         193 :       if (INTEGRAL_TYPE_P (type)
    3482                 :         107 :           && SCALAR_FLOAT_TYPE_P (valtype))
    3483                 :          19 :         warning_at (ploc, OPT_Wtraditional_conversion,
    3484                 :             :                     "passing argument %d of %qE as integer rather "
    3485                 :             :                     "than floating due to prototype",
    3486                 :             :                     argnum, rname);
    3487                 :         193 :       if (INTEGRAL_TYPE_P (type)
    3488                 :         107 :           && TREE_CODE (valtype) == COMPLEX_TYPE)
    3489                 :           5 :         warning_at (ploc, OPT_Wtraditional_conversion,
    3490                 :             :                     "passing argument %d of %qE as integer rather "
    3491                 :             :                     "than complex due to prototype",
    3492                 :             :                     argnum, rname);
    3493                 :         188 :       else if (TREE_CODE (type) == COMPLEX_TYPE
    3494                 :          14 :                && SCALAR_FLOAT_TYPE_P (valtype))
    3495                 :           7 :         warning_at (ploc, OPT_Wtraditional_conversion,
    3496                 :             :                     "passing argument %d of %qE as complex rather "
    3497                 :             :                     "than floating due to prototype",
    3498                 :             :                     argnum, rname);
    3499                 :         181 :       else if (SCALAR_FLOAT_TYPE_P (type)
    3500                 :          71 :                && INTEGRAL_TYPE_P (valtype))
    3501                 :          19 :         warning_at (ploc, OPT_Wtraditional_conversion,
    3502                 :             :                     "passing argument %d of %qE as floating rather "
    3503                 :             :                     "than integer due to prototype",
    3504                 :             :                     argnum, rname);
    3505                 :         162 :       else if (TREE_CODE (type) == COMPLEX_TYPE
    3506                 :           7 :                && INTEGRAL_TYPE_P (valtype))
    3507                 :           5 :         warning_at (ploc, OPT_Wtraditional_conversion,
    3508                 :             :                     "passing argument %d of %qE as complex rather "
    3509                 :             :                     "than integer due to prototype",
    3510                 :             :                     argnum, rname);
    3511                 :         157 :       else if (SCALAR_FLOAT_TYPE_P (type)
    3512                 :          52 :                && TREE_CODE (valtype) == COMPLEX_TYPE)
    3513                 :           7 :         warning_at (ploc, OPT_Wtraditional_conversion,
    3514                 :             :                     "passing argument %d of %qE as floating rather "
    3515                 :             :                     "than complex due to prototype",
    3516                 :             :                     argnum, rname);
    3517                 :             :       /* ??? At some point, messages should be written about
    3518                 :             :          conversions between complex types, but that's too messy
    3519                 :             :          to do now.  */
    3520                 :         150 :       else if (SCALAR_FLOAT_TYPE_P (type)
    3521                 :          45 :                && SCALAR_FLOAT_TYPE_P (valtype))
    3522                 :             :         {
    3523                 :          45 :           unsigned int formal_prec = TYPE_PRECISION (type);
    3524                 :             : 
    3525                 :             :           /* Warn if any argument is passed as `float',
    3526                 :             :              since without a prototype it would be `double'.  */
    3527                 :          45 :           if (formal_prec == TYPE_PRECISION (float_type_node)
    3528                 :          45 :               && type != dfloat32_type_node)
    3529                 :           7 :             warning_at (ploc, 0,
    3530                 :             :                         "passing argument %d of %qE as %<float%> "
    3531                 :             :                         "rather than %<double%> due to prototype",
    3532                 :             :                         argnum, rname);
    3533                 :             : 
    3534                 :             :           /* Warn if mismatch between argument and prototype
    3535                 :             :              for decimal float types.  Warn of conversions with
    3536                 :             :              binary float types and of precision narrowing due to
    3537                 :             :              prototype.  */
    3538                 :          38 :           else if (type != valtype
    3539                 :          32 :                    && (type == dfloat32_type_node
    3540                 :          22 :                        || type == dfloat64_type_node
    3541                 :          12 :                        || type == dfloat128_type_node
    3542                 :           2 :                        || valtype == dfloat32_type_node
    3543                 :           2 :                        || valtype == dfloat64_type_node
    3544                 :           2 :                        || valtype == dfloat128_type_node)
    3545                 :          38 :                    && (formal_prec
    3546                 :          30 :                        <= TYPE_PRECISION (valtype)
    3547                 :          14 :                        || (type == dfloat128_type_node
    3548                 :          10 :                            && (valtype
    3549                 :          10 :                                != dfloat64_type_node
    3550                 :           8 :                                && (valtype
    3551                 :             :                                    != dfloat32_type_node)))
    3552                 :           8 :                        || (type == dfloat64_type_node
    3553                 :           4 :                            && (valtype
    3554                 :             :                                != dfloat32_type_node))))
    3555                 :          24 :             warning_at (ploc, 0,
    3556                 :             :                         "passing argument %d of %qE as %qT "
    3557                 :             :                         "rather than %qT due to prototype",
    3558                 :             :                         argnum, rname, type, valtype);
    3559                 :             : 
    3560                 :             :         }
    3561                 :             :       /* Detect integer changing in width or signedness.
    3562                 :             :          These warnings are only activated with
    3563                 :             :          -Wtraditional-conversion, not with -Wtraditional.  */
    3564                 :         105 :       else if (warn_traditional_conversion
    3565                 :         105 :                && INTEGRAL_TYPE_P (type)
    3566                 :         102 :                && INTEGRAL_TYPE_P (valtype))
    3567                 :             :         {
    3568                 :          83 :           unsigned int formal_prec = TYPE_PRECISION (type);
    3569                 :          83 :           tree would_have_been = default_conversion (val);
    3570                 :          83 :           tree type1 = TREE_TYPE (would_have_been);
    3571                 :             : 
    3572                 :          83 :           if (val == error_mark_node)
    3573                 :             :             /* VAL could have been of incomplete type.  */;
    3574                 :          83 :           else if (TREE_CODE (type) == ENUMERAL_TYPE
    3575                 :          83 :                    && (TYPE_MAIN_VARIANT (type)
    3576                 :           2 :                        == TYPE_MAIN_VARIANT (valtype)))
    3577                 :             :             /* No warning if function asks for enum
    3578                 :             :                and the actual arg is that enum type.  */
    3579                 :             :             ;
    3580                 :          81 :           else if (formal_prec != TYPE_PRECISION (type1))
    3581                 :          14 :             warning_at (ploc, OPT_Wtraditional_conversion,
    3582                 :             :                         "passing argument %d of %qE "
    3583                 :             :                         "with different width due to prototype",
    3584                 :             :                         argnum, rname);
    3585                 :          67 :           else if (TYPE_UNSIGNED (type) == TYPE_UNSIGNED (type1))
    3586                 :             :             ;
    3587                 :             :           /* Don't complain if the formal parameter type
    3588                 :             :              is an enum, because we can't tell now whether
    3589                 :             :              the value was an enum--even the same enum.  */
    3590                 :          32 :           else if (TREE_CODE (type) == ENUMERAL_TYPE)
    3591                 :             :             ;
    3592                 :          32 :           else if (TREE_CODE (val) == INTEGER_CST
    3593                 :           5 :                    && int_fits_type_p (val, type))
    3594                 :             :             /* Change in signedness doesn't matter
    3595                 :             :                if a constant value is unaffected.  */
    3596                 :             :             ;
    3597                 :             :           /* If the value is extended from a narrower
    3598                 :             :              unsigned type, it doesn't matter whether we
    3599                 :             :              pass it as signed or unsigned; the value
    3600                 :             :              certainly is the same either way.  */
    3601                 :          32 :           else if (TYPE_PRECISION (valtype) < TYPE_PRECISION (type)
    3602                 :          32 :                    && TYPE_UNSIGNED (valtype))
    3603                 :             :             ;
    3604                 :          32 :           else if (TYPE_UNSIGNED (type))
    3605                 :          17 :             warning_at (ploc, OPT_Wtraditional_conversion,
    3606                 :             :                         "passing argument %d of %qE "
    3607                 :             :                         "as unsigned due to prototype",
    3608                 :             :                         argnum, rname);
    3609                 :             :           else
    3610                 :          15 :             warning_at (ploc, OPT_Wtraditional_conversion,
    3611                 :             :                         "passing argument %d of %qE "
    3612                 :             :                         "as signed due to prototype",
    3613                 :             :                         argnum, rname);
    3614                 :             :         }
    3615                 :             :     }
    3616                 :             : 
    3617                 :             :   /* Possibly restore an EXCESS_PRECISION_EXPR for the
    3618                 :             :      sake of better warnings from convert_and_check.  */
    3619                 :   110011552 :   if (excess_precision)
    3620                 :         368 :     val = build1 (EXCESS_PRECISION_EXPR, valtype, val);
    3621                 :             : 
    3622                 :   110011552 :   tree parmval = convert_for_assignment (ploc, ploc, type,
    3623                 :             :                                          val, origtype, ic_argpass,
    3624                 :             :                                          npc, fundecl, function,
    3625                 :             :                                          parmnum + 1, warnopt);
    3626                 :             : 
    3627                 :   110011552 :   if (targetm.calls.promote_prototypes (fundecl ? TREE_TYPE (fundecl) : 0)
    3628                 :   110011552 :       && INTEGRAL_TYPE_P (type)
    3629                 :   149486169 :       && (TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node)))
    3630                 :    20261883 :     parmval = default_conversion (parmval);
    3631                 :             : 
    3632                 :             :   return parmval;
    3633                 :             : }
    3634                 :             : 
    3635                 :             : /* Convert the argument expressions in the vector VALUES
    3636                 :             :    to the types in the list TYPELIST.
    3637                 :             : 
    3638                 :             :    If TYPELIST is exhausted, or when an element has NULL as its type,
    3639                 :             :    perform the default conversions.
    3640                 :             : 
    3641                 :             :    ORIGTYPES is the original types of the expressions in VALUES.  This
    3642                 :             :    holds the type of enum values which have been converted to integral
    3643                 :             :    types.  It may be NULL.
    3644                 :             : 
    3645                 :             :    FUNCTION is a tree for the called function.  It is used only for
    3646                 :             :    error messages, where it is formatted with %qE.
    3647                 :             : 
    3648                 :             :    This is also where warnings about wrong number of args are generated.
    3649                 :             : 
    3650                 :             :    ARG_LOC are locations of function arguments (if any).
    3651                 :             : 
    3652                 :             :    Returns the actual number of arguments processed (which may be less
    3653                 :             :    than the length of VALUES in some error situations), or -1 on
    3654                 :             :    failure.  */
    3655                 :             : 
    3656                 :             : static int
    3657                 :    43261926 : convert_arguments (location_t loc, vec<location_t> arg_loc, tree typelist,
    3658                 :             :                    vec<tree, va_gc> *values, vec<tree, va_gc> *origtypes,
    3659                 :             :                    tree function, tree fundecl)
    3660                 :             : {
    3661                 :    43261926 :   unsigned int parmnum;
    3662                 :    43261926 :   bool error_args = false;
    3663                 :    43261926 :   const bool type_generic = fundecl
    3664                 :    43261926 :     && lookup_attribute ("type generic", TYPE_ATTRIBUTES (TREE_TYPE (fundecl)));
    3665                 :    43261926 :   bool type_generic_remove_excess_precision = false;
    3666                 :    43261926 :   bool type_generic_overflow_p = false;
    3667                 :    43261926 :   bool type_generic_bit_query = false;
    3668                 :    43261926 :   tree selector;
    3669                 :             : 
    3670                 :             :   /* Change pointer to function to the function itself for
    3671                 :             :      diagnostics.  */
    3672                 :    43261926 :   if (TREE_CODE (function) == ADDR_EXPR
    3673                 :    43261926 :       && TREE_CODE (TREE_OPERAND (function, 0)) == FUNCTION_DECL)
    3674                 :    43187853 :     function = TREE_OPERAND (function, 0);
    3675                 :             : 
    3676                 :             :   /* Handle an ObjC selector specially for diagnostics.  */
    3677                 :    43261926 :   selector = objc_message_selector ();
    3678                 :             : 
    3679                 :             :   /* For a call to a built-in function declared without a prototype,
    3680                 :             :      set to the built-in function's argument list.  */
    3681                 :    43261926 :   tree builtin_typelist = NULL_TREE;
    3682                 :             : 
    3683                 :             :   /* For type-generic built-in functions, determine whether excess
    3684                 :             :      precision should be removed (classification) or not
    3685                 :             :      (comparison).  */
    3686                 :    43261926 :   if (fundecl
    3687                 :    43261926 :       && fndecl_built_in_p (fundecl, BUILT_IN_NORMAL))
    3688                 :             :     {
    3689                 :     1365333 :       built_in_function code = DECL_FUNCTION_CODE (fundecl);
    3690                 :     1365333 :       if (C_DECL_BUILTIN_PROTOTYPE (fundecl))
    3691                 :             :         {
    3692                 :             :           /* For a call to a built-in function declared without a prototype
    3693                 :             :              use the types of the parameters of the internal built-in to
    3694                 :             :              match those of the arguments to.  */
    3695                 :      673199 :           if (tree bdecl = builtin_decl_explicit (code))
    3696                 :      673199 :             builtin_typelist = TYPE_ARG_TYPES (TREE_TYPE (bdecl));
    3697                 :             :         }
    3698                 :             : 
    3699                 :             :       /* For type-generic built-in functions, determine whether excess
    3700                 :             :          precision should be removed (classification) or not
    3701                 :             :          (comparison).  */
    3702                 :     1365333 :       if (type_generic)
    3703                 :       60290 :         switch (code)
    3704                 :             :           {
    3705                 :        5233 :           case BUILT_IN_ISFINITE:
    3706                 :        5233 :           case BUILT_IN_ISINF:
    3707                 :        5233 :           case BUILT_IN_ISINF_SIGN:
    3708                 :        5233 :           case BUILT_IN_ISNAN:
    3709                 :        5233 :           case BUILT_IN_ISNORMAL:
    3710                 :        5233 :           case BUILT_IN_ISSIGNALING:
    3711                 :        5233 :           case BUILT_IN_FPCLASSIFY:
    3712                 :        5233 :             type_generic_remove_excess_precision = true;
    3713                 :        5233 :             break;
    3714                 :             : 
    3715                 :       20996 :           case BUILT_IN_ADD_OVERFLOW_P:
    3716                 :       20996 :           case BUILT_IN_SUB_OVERFLOW_P:
    3717                 :       20996 :           case BUILT_IN_MUL_OVERFLOW_P:
    3718                 :             :             /* The last argument of these type-generic builtins
    3719                 :             :                should not be promoted.  */
    3720                 :       20996 :             type_generic_overflow_p = true;
    3721                 :       20996 :             break;
    3722                 :             : 
    3723                 :        1261 :           case BUILT_IN_CLZG:
    3724                 :        1261 :           case BUILT_IN_CTZG:
    3725                 :        1261 :           case BUILT_IN_CLRSBG:
    3726                 :        1261 :           case BUILT_IN_FFSG:
    3727                 :        1261 :           case BUILT_IN_PARITYG:
    3728                 :        1261 :           case BUILT_IN_POPCOUNTG:
    3729                 :             :             /* The first argument of these type-generic builtins
    3730                 :             :                should not be promoted.  */
    3731                 :        1261 :             type_generic_bit_query = true;
    3732                 :        1261 :             break;
    3733                 :             : 
    3734                 :             :           default:
    3735                 :             :             break;
    3736                 :             :           }
    3737                 :             :     }
    3738                 :             : 
    3739                 :             :   /* Scan the given expressions (VALUES) and types (TYPELIST), producing
    3740                 :             :      individual converted arguments.  */
    3741                 :             : 
    3742                 :    43261926 :   tree typetail, builtin_typetail, val;
    3743                 :    43261926 :   for (typetail = typelist,
    3744                 :    43261926 :          builtin_typetail = builtin_typelist,
    3745                 :    43261926 :          parmnum = 0;
    3746                 :   154199903 :        values && values->iterate (parmnum, &val);
    3747                 :             :        ++parmnum)
    3748                 :             :     {
    3749                 :             :       /* The type of the function parameter (if it was declared with one).  */
    3750                 :   220947666 :       tree type = typetail ? TREE_VALUE (typetail) : NULL_TREE;
    3751                 :             :       /* The type of the built-in function parameter (if the function
    3752                 :             :          is a built-in).  Used to detect type incompatibilities in
    3753                 :             :          calls to built-ins declared without a prototype.  */
    3754                 :   110938007 :       tree builtin_type = (builtin_typetail
    3755                 :   111947426 :                            ? TREE_VALUE (builtin_typetail) : NULL_TREE);
    3756                 :             :       /* The original type of the argument being passed to the function.  */
    3757                 :   110938007 :       tree valtype = TREE_TYPE (val);
    3758                 :             :       /* The called function (or function selector in Objective C).  */
    3759                 :   110938007 :       tree rname = function;
    3760                 :   110938007 :       int argnum = parmnum + 1;
    3761                 :   110938007 :       const char *invalid_func_diag;
    3762                 :             :       /* Set for EXCESS_PRECISION_EXPR arguments.  */
    3763                 :   110938007 :       bool excess_precision = false;
    3764                 :             :       /* The value of the argument after conversion to the type
    3765                 :             :          of the function parameter it is passed to.  */
    3766                 :   110938007 :       tree parmval;
    3767                 :             :       /* Some __atomic_* builtins have additional hidden argument at
    3768                 :             :          position 0.  */
    3769                 :   110938007 :       location_t ploc
    3770                 :   110672060 :         = !arg_loc.is_empty () && values->length () == arg_loc.length ()
    3771                 :   110938007 :           ? expansion_point_location_if_in_system_header (arg_loc[parmnum])
    3772                 :   110938007 :           : input_location;
    3773                 :             : 
    3774                 :   110938007 :       if (type == void_type_node)
    3775                 :             :         {
    3776                 :          27 :           if (selector)
    3777                 :           0 :             error_at (loc, "too many arguments to method %qE", selector);
    3778                 :             :           else
    3779                 :          27 :             error_at (loc, "too many arguments to function %qE", function);
    3780                 :          27 :           inform_declaration (fundecl);
    3781                 :          27 :           return error_args ? -1 : (int) parmnum;
    3782                 :             :         }
    3783                 :             : 
    3784                 :   110937980 :       if (builtin_type == void_type_node)
    3785                 :             :         {
    3786                 :          12 :           if (warning_at (loc, OPT_Wbuiltin_declaration_mismatch,
    3787                 :             :                           "too many arguments to built-in function %qE "
    3788                 :             :                           "expecting %d", function, parmnum))
    3789                 :          12 :             inform_declaration (fundecl);
    3790                 :             :           builtin_typetail = NULL_TREE;
    3791                 :             :         }
    3792                 :             : 
    3793                 :   110937980 :       if (selector && argnum > 2)
    3794                 :             :         {
    3795                 :           0 :           rname = selector;
    3796                 :           0 :           argnum -= 2;
    3797                 :             :         }
    3798                 :             : 
    3799                 :             :       /* Determine if VAL is a null pointer constant before folding it.  */
    3800                 :   110937980 :       bool npc = null_pointer_constant_p (val);
    3801                 :             : 
    3802                 :             :       /* If there is excess precision and a prototype, convert once to
    3803                 :             :          the required type rather than converting via the semantic
    3804                 :             :          type.  Likewise without a prototype a float value represented
    3805                 :             :          as long double should be converted once to double.  But for
    3806                 :             :          type-generic classification functions excess precision must
    3807                 :             :          be removed here.  */
    3808                 :   110937980 :       if (TREE_CODE (val) == EXCESS_PRECISION_EXPR
    3809                 :         421 :           && (type || !type_generic || !type_generic_remove_excess_precision))
    3810                 :             :         {
    3811                 :         401 :           val = TREE_OPERAND (val, 0);
    3812                 :         401 :           excess_precision = true;
    3813                 :             :         }
    3814                 :   110937980 :       val = c_fully_fold (val, false, NULL);
    3815                 :   221875961 :       STRIP_TYPE_NOPS (val);
    3816                 :             : 
    3817                 :   110937980 :       val = require_complete_type (ploc, val);
    3818                 :             : 
    3819                 :             :       /* Some floating-point arguments must be promoted to double when
    3820                 :             :          no type is specified by a prototype.  This applies to
    3821                 :             :          arguments of type float, and to architecture-specific types
    3822                 :             :          (ARM __fp16), but not to _FloatN or _FloatNx types.  */
    3823                 :   110937980 :       bool promote_float_arg = false;
    3824                 :   110937980 :       if (type == NULL_TREE
    3825                 :      928348 :           && TREE_CODE (valtype) == REAL_TYPE
    3826                 :      269326 :           && (TYPE_PRECISION (valtype)
    3827                 :      269326 :               <= TYPE_PRECISION (double_type_node))
    3828                 :      262055 :           && TYPE_MAIN_VARIANT (valtype) != double_type_node
    3829                 :      131215 :           && TYPE_MAIN_VARIANT (valtype) != long_double_type_node
    3830                 :   111069195 :           && !DECIMAL_FLOAT_MODE_P (TYPE_MODE (valtype)))
    3831                 :             :         {
    3832                 :             :           /* Promote this argument, unless it has a _FloatN or
    3833                 :             :              _FloatNx type.  */
    3834                 :     1026591 :           promote_float_arg = true;
    3835                 :     1026591 :           for (int i = 0; i < NUM_FLOATN_NX_TYPES; i++)
    3836                 :      899339 :             if (TYPE_MAIN_VARIANT (valtype) == FLOATN_NX_TYPE_NODE (i))
    3837                 :             :               {
    3838                 :             :                 promote_float_arg = false;
    3839                 :             :                 break;
    3840                 :             :               }
    3841                 :             :           /* Don't promote __bf16 either.  */
    3842                 :      130486 :           if (TYPE_MAIN_VARIANT (valtype) == bfloat16_type_node)
    3843                 :   110807571 :             promote_float_arg = false;
    3844                 :             :         }
    3845                 :             : 
    3846                 :   110937980 :       if (type != NULL_TREE)
    3847                 :             :         {
    3848                 :   110009632 :           tree origtype = (!origtypes) ? NULL_TREE : (*origtypes)[parmnum];
    3849                 :   110009632 :           parmval = convert_argument (ploc, function, fundecl, type, origtype,
    3850                 :             :                                       val, valtype, npc, rname, parmnum, argnum,
    3851                 :             :                                       excess_precision, 0);
    3852                 :             :         }
    3853                 :      928348 :       else if (promote_float_arg)
    3854                 :             :         {
    3855                 :      127175 :           if (type_generic)
    3856                 :             :             parmval = val;
    3857                 :             :           else
    3858                 :             :             {
    3859                 :             :               /* Convert `float' to `double'.  */
    3860                 :      124443 :               if (warn_double_promotion && !c_inhibit_evaluation_warnings)
    3861                 :           6 :                 warning_at (ploc, OPT_Wdouble_promotion,
    3862                 :             :                             "implicit conversion from %qT to %qT when passing "
    3863                 :             :                             "argument to function",
    3864                 :             :                             valtype, double_type_node);
    3865                 :      124443 :               parmval = convert (double_type_node, val);
    3866                 :             :             }
    3867                 :             :         }
    3868                 :      801173 :       else if ((excess_precision && !type_generic)
    3869                 :      801171 :                || (type_generic_overflow_p && parmnum == 2)
    3870                 :      780179 :                || (type_generic_bit_query && parmnum == 0))
    3871                 :             :         /* A "double" argument with excess precision being passed
    3872                 :             :            without a prototype or in variable arguments.
    3873                 :             :            The last argument of __builtin_*_overflow_p should not be
    3874                 :             :            promoted, similarly the first argument of
    3875                 :             :            __builtin_{clz,ctz,clrsb,ffs,parity,popcount}g.  */
    3876                 :       22249 :         parmval = convert (valtype, val);
    3877                 :     1557848 :       else if ((invalid_func_diag =
    3878                 :      778924 :                 targetm.calls.invalid_arg_for_unprototyped_fn (typelist, fundecl, val)))
    3879                 :             :         {
    3880                 :           0 :           error (invalid_func_diag);
    3881                 :           0 :           return -1;
    3882                 :             :         }
    3883                 :      778924 :       else if (TREE_CODE (val) == ADDR_EXPR && reject_gcc_builtin (val))
    3884                 :             :         {
    3885                 :             :           return -1;
    3886                 :             :         }
    3887                 :             :       else
    3888                 :             :         /* Convert `short' and `char' to full-size `int'.  */
    3889                 :      778921 :         parmval = default_conversion (val);
    3890                 :             : 
    3891                 :   110937977 :       (*values)[parmnum] = parmval;
    3892                 :   110937977 :       if (parmval == error_mark_node)
    3893                 :         101 :         error_args = true;
    3894                 :             : 
    3895                 :   110937977 :       if (!type && builtin_type && TREE_CODE (builtin_type) != VOID_TYPE)
    3896                 :             :         {
    3897                 :             :           /* For a call to a built-in function declared without a prototype,
    3898                 :             :              perform the conversions from the argument to the expected type
    3899                 :             :              but issue warnings rather than errors for any mismatches.
    3900                 :             :              Ignore the converted argument and use the PARMVAL obtained
    3901                 :             :              above by applying default conversions instead.  */
    3902                 :        1923 :           tree origtype = (!origtypes) ? NULL_TREE : (*origtypes)[parmnum];
    3903                 :        1923 :           convert_argument (ploc, function, fundecl, builtin_type, origtype,
    3904                 :             :                             val, valtype, npc, rname, parmnum, argnum,
    3905                 :             :                             excess_precision,
    3906                 :             :                             OPT_Wbuiltin_declaration_mismatch);
    3907                 :             :         }
    3908                 :             : 
    3909                 :   110937977 :       if (typetail)
    3910                 :   110009632 :         typetail = TREE_CHAIN (typetail);
    3911                 :             : 
    3912                 :   110937977 :       if (builtin_typetail)
    3913                 :     1009402 :         builtin_typetail = TREE_CHAIN (builtin_typetail);
    3914                 :             :     }
    3915                 :             : 
    3916                 :    76791915 :   gcc_assert (parmnum == vec_safe_length (values));
    3917                 :             : 
    3918                 :    86126694 :   if (typetail != NULL_TREE && TREE_VALUE (typetail) != void_type_node)
    3919                 :             :     {
    3920                 :          67 :       error_at (loc, "too few arguments to function %qE", function);
    3921                 :          67 :       inform_declaration (fundecl);
    3922                 :          67 :       return -1;
    3923                 :             :     }
    3924                 :             : 
    3925                 :    43899713 :   if (builtin_typetail && TREE_VALUE (builtin_typetail) != void_type_node)
    3926                 :             :     {
    3927                 :             :       unsigned nargs = parmnum;
    3928                 :        1133 :       for (tree t = builtin_typetail; t; t = TREE_CHAIN (t))
    3929                 :         782 :         ++nargs;
    3930                 :             : 
    3931                 :         351 :       if (warning_at (loc, OPT_Wbuiltin_declaration_mismatch,
    3932                 :             :                       "too few arguments to built-in function %qE "
    3933                 :             :                       "expecting %u", function, nargs - 1))
    3934                 :         189 :         inform_declaration (fundecl);
    3935                 :             :     }
    3936                 :             : 
    3937                 :    43261829 :   return error_args ? -1 : (int) parmnum;
    3938                 :             : }
    3939                 :             : 
    3940                 :             : /* This is the entry point used by the parser to build unary operators
    3941                 :             :    in the input.  CODE, a tree_code, specifies the unary operator, and
    3942                 :             :    ARG is the operand.  For unary plus, the C parser currently uses
    3943                 :             :    CONVERT_EXPR for code.
    3944                 :             : 
    3945                 :             :    LOC is the location to use for the tree generated.
    3946                 :             : */
    3947                 :             : 
    3948                 :             : struct c_expr
    3949                 :     7002617 : parser_build_unary_op (location_t loc, enum tree_code code, struct c_expr arg)
    3950                 :             : {
    3951                 :     7002617 :   struct c_expr result;
    3952                 :             : 
    3953                 :     7002617 :   result.original_code = code;
    3954                 :     7002617 :   result.original_type = NULL;
    3955                 :     7002617 :   result.m_decimal = 0;
    3956                 :             : 
    3957                 :     7002617 :   if (reject_gcc_builtin (arg.value))
    3958                 :             :     {
    3959                 :           2 :       result.value = error_mark_node;
    3960                 :             :     }
    3961                 :             :   else
    3962                 :             :     {
    3963                 :     7002615 :       result.value = build_unary_op (loc, code, arg.value, false);
    3964                 :             : 
    3965                 :     7002615 :       if (TREE_OVERFLOW_P (result.value) && !TREE_OVERFLOW_P (arg.value))
    3966                 :           5 :         overflow_warning (loc, result.value, arg.value);
    3967                 :             :     }
    3968                 :             : 
    3969                 :             :   /* We are typically called when parsing a prefix token at LOC acting on
    3970                 :             :      ARG.  Reflect this by updating the source range of the result to
    3971                 :             :      start at LOC and end at the end of ARG.  */
    3972                 :     7002617 :   set_c_expr_source_range (&result,
    3973                 :             :                            loc, arg.get_finish ());
    3974                 :             : 
    3975                 :     7002617 :   return result;
    3976                 :             : }
    3977                 :             : 
    3978                 :             : /* Returns true if TYPE is a character type, *not* including wchar_t.  */
    3979                 :             : 
    3980                 :             : bool
    3981                 :      110336 : char_type_p (tree type)
    3982                 :             : {
    3983                 :      110336 :   return (type == char_type_node
    3984                 :      103772 :           || type == unsigned_char_type_node
    3985                 :       97234 :           || type == signed_char_type_node
    3986                 :       97224 :           || type == char16_type_node
    3987                 :      201027 :           || type == char32_type_node);
    3988                 :             : }
    3989                 :             : 
    3990                 :             : /* This is the entry point used by the parser to build binary operators
    3991                 :             :    in the input.  CODE, a tree_code, specifies the binary operator, and
    3992                 :             :    ARG1 and ARG2 are the operands.  In addition to constructing the
    3993                 :             :    expression, we check for operands that were written with other binary
    3994                 :             :    operators in a way that is likely to confuse the user.
    3995                 :             : 
    3996                 :             :    LOCATION is the location of the binary operator.  */
    3997                 :             : 
    3998                 :             : struct c_expr
    3999                 :     8859886 : parser_build_binary_op (location_t location, enum tree_code code,
    4000                 :             :                         struct c_expr arg1, struct c_expr arg2)
    4001                 :             : {
    4002                 :     8859886 :   struct c_expr result;
    4003                 :     8859886 :   result.m_decimal = 0;
    4004                 :             : 
    4005                 :     8859886 :   enum tree_code code1 = arg1.original_code;
    4006                 :     8859886 :   enum tree_code code2 = arg2.original_code;
    4007                 :     8859886 :   tree type1 = (arg1.original_type
    4008                 :    14515724 :                 ? arg1.original_type
    4009                 :     5655838 :                 : TREE_TYPE (arg1.value));
    4010                 :     8859886 :   tree type2 = (arg2.original_type
    4011                 :    15406720 :                 ? arg2.original_type
    4012                 :     6546834 :                 : TREE_TYPE (arg2.value));
    4013                 :             : 
    4014                 :     8859886 :   result.value = build_binary_op (location, code,
    4015                 :             :                                   arg1.value, arg2.value, true);
    4016                 :     8859885 :   result.original_code = code;
    4017                 :     8859885 :   result.original_type = NULL;
    4018                 :     8859885 :   result.m_decimal = 0;
    4019                 :             : 
    4020                 :     8859885 :   if (TREE_CODE (result.value) == ERROR_MARK)
    4021                 :             :     {
    4022                 :        1291 :       set_c_expr_source_range (&result,
    4023                 :             :                                arg1.get_start (),
    4024                 :             :                                arg2.get_finish ());
    4025                 :        1291 :       return result;
    4026                 :             :     }
    4027                 :             : 
    4028                 :     8858594 :   if (location != UNKNOWN_LOCATION)
    4029                 :     8858594 :     protected_set_expr_location (result.value, location);
    4030                 :             : 
    4031                 :     8858594 :   set_c_expr_source_range (&result,
    4032                 :             :                            arg1.get_start (),
    4033                 :             :                            arg2.get_finish ());
    4034                 :             : 
    4035                 :             :   /* Check for cases such as x+y<<z which users are likely
    4036                 :             :      to misinterpret.  */
    4037                 :     8858594 :   if (warn_parentheses)
    4038                 :     1934573 :     warn_about_parentheses (location, code, code1, arg1.value, code2,
    4039                 :             :                             arg2.value);
    4040                 :             : 
    4041                 :     8858594 :   if (warn_logical_op)
    4042                 :         338 :     warn_logical_operator (location, code, TREE_TYPE (result.value),
    4043                 :             :                            code1, arg1.value, code2, arg2.value);
    4044                 :             : 
    4045                 :     8858594 :   if (warn_tautological_compare)
    4046                 :             :     {
    4047                 :     1933087 :       tree lhs = arg1.value;
    4048                 :     1933087 :       tree rhs = arg2.value;
    4049                 :     1933087 :       if (TREE_CODE (lhs) == C_MAYBE_CONST_EXPR)
    4050                 :             :         {
    4051                 :           2 :           if (C_MAYBE_CONST_EXPR_PRE (lhs) != NULL_TREE
    4052                 :           2 :               && TREE_SIDE_EFFECTS (C_MAYBE_CONST_EXPR_PRE (lhs)))
    4053                 :             :             lhs = NULL_TREE;
    4054                 :             :           else
    4055                 :           2 :             lhs = C_MAYBE_CONST_EXPR_EXPR (lhs);
    4056                 :             :         }
    4057                 :     1933087 :       if (TREE_CODE (rhs) == C_MAYBE_CONST_EXPR)
    4058                 :             :         {
    4059                 :           8 :           if (C_MAYBE_CONST_EXPR_PRE (rhs) != NULL_TREE
    4060                 :           8 :               && TREE_SIDE_EFFECTS (C_MAYBE_CONST_EXPR_PRE (rhs)))
    4061                 :             :             rhs = NULL_TREE;
    4062                 :             :           else
    4063                 :           8 :             rhs = C_MAYBE_CONST_EXPR_EXPR (rhs);
    4064                 :             :         }
    4065                 :     1933087 :       if (lhs != NULL_TREE && rhs != NULL_TREE)
    4066                 :     1933087 :         warn_tautological_cmp (location, code, lhs, rhs);
    4067                 :             :     }
    4068                 :             : 
    4069                 :     8858594 :   if (warn_logical_not_paren
    4070                 :     1933170 :       && TREE_CODE_CLASS (code) == tcc_comparison
    4071                 :      384478 :       && code1 == TRUTH_NOT_EXPR
    4072                 :      384478 :       && code2 != TRUTH_NOT_EXPR
    4073                 :             :       /* Avoid warning for !!x == y.  */
    4074                 :     8858720 :       && (TREE_CODE (arg1.value) != NE_EXPR
    4075                 :          19 :           || !integer_zerop (TREE_OPERAND (arg1.value, 1))))
    4076                 :             :     {
    4077                 :             :       /* Avoid warning for !b == y where b has _Bool type.  */
    4078                 :         107 :       tree t = integer_zero_node;
    4079                 :         107 :       if (TREE_CODE (arg1.value) == EQ_EXPR
    4080                 :          98 :           && integer_zerop (TREE_OPERAND (arg1.value, 1))
    4081                 :         205 :           && TREE_TYPE (TREE_OPERAND (arg1.value, 0)) == integer_type_node)
    4082                 :             :         {
    4083                 :          90 :           t = TREE_OPERAND (arg1.value, 0);
    4084                 :         199 :           do
    4085                 :             :             {
    4086                 :         199 :               if (TREE_TYPE (t) != integer_type_node)
    4087                 :             :                 break;
    4088                 :         180 :               if (TREE_CODE (t) == C_MAYBE_CONST_EXPR)
    4089                 :          90 :                 t = C_MAYBE_CONST_EXPR_EXPR (t);
    4090                 :          90 :               else if (CONVERT_EXPR_P (t))
    4091                 :          19 :                 t = TREE_OPERAND (t, 0);
    4092                 :             :               else
    4093                 :             :                 break;
    4094                 :             :             }
    4095                 :             :           while (1);
    4096                 :             :         }
    4097                 :         107 :       if (!C_BOOLEAN_TYPE_P (TREE_TYPE (t)))
    4098                 :          88 :         warn_logical_not_parentheses (location, code, arg1.value, arg2.value);
    4099                 :             :     }
    4100                 :             : 
    4101                 :             :   /* Warn about comparisons against string literals, with the exception
    4102                 :             :      of testing for equality or inequality of a string literal with NULL.  */
    4103                 :     8858594 :   if (code == EQ_EXPR || code == NE_EXPR)
    4104                 :             :     {
    4105                 :     1125121 :       if ((code1 == STRING_CST
    4106                 :          16 :            && !integer_zerop (tree_strip_nop_conversions (arg2.value)))
    4107                 :     1125132 :           || (code2 == STRING_CST
    4108                 :          20 :               && !integer_zerop (tree_strip_nop_conversions (arg1.value))))
    4109                 :          17 :         warning_at (location, OPT_Waddress,
    4110                 :             :                     "comparison with string literal results in unspecified behavior");
    4111                 :             :       /* Warn for ptr == '\0', it's likely that it should've been ptr[0].  */
    4112                 :     1125121 :       if (POINTER_TYPE_P (type1)
    4113                 :       88523 :           && null_pointer_constant_p (arg2.value)
    4114                 :     1144489 :           && char_type_p (type2))
    4115                 :             :         {
    4116                 :          10 :           auto_diagnostic_group d;
    4117                 :          10 :           if (warning_at (location, OPT_Wpointer_compare,
    4118                 :             :                             "comparison between pointer and zero character "
    4119                 :             :                             "constant"))
    4120                 :          10 :             inform (arg1.get_start (),
    4121                 :             :                       "did you mean to dereference the pointer?");
    4122                 :          10 :         }
    4123                 :     1125111 :       else if (POINTER_TYPE_P (type2)
    4124                 :       85847 :                && null_pointer_constant_p (arg1.value)
    4125                 :     1125366 :                && char_type_p (type1))
    4126                 :             :         {
    4127                 :          10 :           auto_diagnostic_group d;
    4128                 :          10 :           if (warning_at (location, OPT_Wpointer_compare,
    4129                 :             :                             "comparison between pointer and zero character "
    4130                 :             :                             "constant"))
    4131                 :          10 :             inform (arg2.get_start (),
    4132                 :             :                       "did you mean to dereference the pointer?");
    4133                 :          10 :         }
    4134                 :             :     }
    4135                 :     7733473 :   else if (TREE_CODE_CLASS (code) == tcc_comparison
    4136                 :      936651 :            && (code1 == STRING_CST || code2 == STRING_CST))
    4137                 :           0 :     warning_at (location, OPT_Waddress,
    4138                 :             :                 "comparison with string literal results in unspecified "
    4139                 :             :                 "behavior");
    4140                 :             : 
    4141                 :     8858594 :   if (warn_array_compare
    4142                 :     1932924 :       && TREE_CODE_CLASS (code) == tcc_comparison
    4143                 :      384262 :       && TREE_CODE (type1) == ARRAY_TYPE
    4144                 :          30 :       && TREE_CODE (type2) == ARRAY_TYPE)
    4145                 :           7 :     do_warn_array_compare (location, code, arg1.value, arg2.value);
    4146                 :             : 
    4147                 :     2005467 :   if (TREE_OVERFLOW_P (result.value)
    4148                 :         290 :       && !TREE_OVERFLOW_P (arg1.value)
    4149                 :     8858877 :       && !TREE_OVERFLOW_P (arg2.value))
    4150                 :         240 :     overflow_warning (location, result.value);
    4151                 :             : 
    4152                 :             :   /* Warn about comparisons of different enum types.  */
    4153                 :     8858593 :   if (warn_enum_compare
    4154                 :     1950831 :       && TREE_CODE_CLASS (code) == tcc_comparison
    4155                 :      387989 :       && TREE_CODE (type1) == ENUMERAL_TYPE
    4156                 :        6774 :       && TREE_CODE (type2) == ENUMERAL_TYPE
    4157                 :     8865325 :       && TYPE_MAIN_VARIANT (type1) != TYPE_MAIN_VARIANT (type2))
    4158                 :           2 :     warning_at (location, OPT_Wenum_compare,
    4159                 :             :                 "comparison between %qT and %qT",
    4160                 :             :                 type1, type2);
    4161                 :             : 
    4162                 :     8858593 :   if (warn_xor_used_as_pow
    4163                 :     8858593 :       && code == BIT_XOR_EXPR
    4164                 :       71349 :       && arg1.m_decimal
    4165                 :         708 :       && arg2.m_decimal)
    4166                 :         427 :     check_for_xor_used_as_pow (arg1.get_location (), arg1.value,
    4167                 :             :                                location,
    4168                 :             :                                arg2.get_location (), arg2.value);
    4169                 :             : 
    4170                 :             :   return result;
    4171                 :             : }
    4172                 :             : 
    4173                 :             : /* Return a tree for the difference of pointers OP0 and OP1.
    4174                 :             :    The resulting tree has type ptrdiff_t.  If POINTER_SUBTRACT sanitization is
    4175                 :             :    enabled, assign to INSTRUMENT_EXPR call to libsanitizer.  */
    4176                 :             : 
    4177                 :             : static tree
    4178                 :        3655 : pointer_diff (location_t loc, tree op0, tree op1, tree *instrument_expr)
    4179                 :             : {
    4180                 :        3655 :   tree restype = ptrdiff_type_node;
    4181                 :        3655 :   tree result, inttype;
    4182                 :             : 
    4183                 :        3655 :   addr_space_t as0 = TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (op0)));
    4184                 :        3655 :   addr_space_t as1 = TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (op1)));
    4185                 :        3655 :   tree target_type = TREE_TYPE (TREE_TYPE (op0));
    4186                 :        3655 :   tree orig_op0 = op0;
    4187                 :        3655 :   tree orig_op1 = op1;
    4188                 :             : 
    4189                 :             :   /* If the operands point into different address spaces, we need to
    4190                 :             :      explicitly convert them to pointers into the common address space
    4191                 :             :      before we can subtract the numerical address values.  */
    4192                 :        3655 :   if (as0 != as1)
    4193                 :             :     {
    4194                 :           0 :       addr_space_t as_common;
    4195                 :           0 :       tree common_type;
    4196                 :             : 
    4197                 :             :       /* Determine the common superset address space.  This is guaranteed
    4198                 :             :          to exist because the caller verified that comp_target_types
    4199                 :             :          returned non-zero.  */
    4200                 :           0 :       if (!addr_space_superset (as0, as1, &as_common))
    4201                 :           0 :         gcc_unreachable ();
    4202                 :             : 
    4203                 :           0 :       common_type = common_pointer_type (TREE_TYPE (op0), TREE_TYPE (op1));
    4204                 :           0 :       op0 = convert (common_type, op0);
    4205                 :           0 :       op1 = convert (common_type, op1);
    4206                 :             :     }
    4207                 :             : 
    4208                 :             :   /* Determine integer type result of the subtraction.  This will usually
    4209                 :             :      be the same as the result type (ptrdiff_t), but may need to be a wider
    4210                 :             :      type if pointers for the address space are wider than ptrdiff_t.  */
    4211                 :        3655 :   if (TYPE_PRECISION (restype) < TYPE_PRECISION (TREE_TYPE (op0)))
    4212                 :           0 :     inttype = c_common_type_for_size (TYPE_PRECISION (TREE_TYPE (op0)), 0);
    4213                 :             :   else
    4214                 :             :     inttype = restype;
    4215                 :             : 
    4216                 :        3655 :   if (VOID_TYPE_P (target_type))
    4217                 :         135 :     pedwarn (loc, OPT_Wpointer_arith,
    4218                 :             :              "pointer of type %<void *%> used in subtraction");
    4219                 :        3655 :   if (TREE_CODE (target_type) == FUNCTION_TYPE)
    4220                 :           4 :     pedwarn (loc, OPT_Wpointer_arith,
    4221                 :             :              "pointer to a function used in subtraction");
    4222                 :             : 
    4223                 :        3655 :   if (current_function_decl != NULL_TREE
    4224                 :        3655 :       && sanitize_flags_p (SANITIZE_POINTER_SUBTRACT))
    4225                 :             :     {
    4226                 :          63 :       op0 = save_expr (op0);
    4227                 :          63 :       op1 = save_expr (op1);
    4228                 :             : 
    4229                 :          63 :       tree tt = builtin_decl_explicit (BUILT_IN_ASAN_POINTER_SUBTRACT);
    4230                 :          63 :       *instrument_expr = build_call_expr_loc (loc, tt, 2, op0, op1);
    4231                 :             :     }
    4232                 :             : 
    4233                 :             :   /* First do the subtraction, then build the divide operator
    4234                 :             :      and only convert at the very end.
    4235                 :             :      Do not do default conversions in case restype is a short type.  */
    4236                 :             : 
    4237                 :             :   /* POINTER_DIFF_EXPR requires a signed integer type of the same size as
    4238                 :             :      pointers.  If some platform cannot provide that, or has a larger
    4239                 :             :      ptrdiff_type to support differences larger than half the address
    4240                 :             :      space, cast the pointers to some larger integer type and do the
    4241                 :             :      computations in that type.  */
    4242                 :        3655 :   if (TYPE_PRECISION (inttype) > TYPE_PRECISION (TREE_TYPE (op0)))
    4243                 :           0 :     op0 = build_binary_op (loc, MINUS_EXPR, convert (inttype, op0),
    4244                 :             :                            convert (inttype, op1), false);
    4245                 :             :   else
    4246                 :             :     {
    4247                 :             :       /* Cast away qualifiers.  */
    4248                 :        3655 :       op0 = convert (c_common_type (TREE_TYPE (op0), TREE_TYPE (op0)), op0);
    4249                 :        3655 :       op1 = convert (c_common_type (TREE_TYPE (op1), TREE_TYPE (op1)), op1);
    4250                 :        3655 :       op0 = build2_loc (loc, POINTER_DIFF_EXPR, inttype, op0, op1);
    4251                 :             :     }
    4252                 :             : 
    4253                 :             :   /* This generates an error if op1 is pointer to incomplete type.  */
    4254                 :        3655 :   if (!COMPLETE_OR_VOID_TYPE_P (TREE_TYPE (TREE_TYPE (orig_op1))))
    4255                 :           4 :     error_at (loc, "arithmetic on pointer to an incomplete type");
    4256                 :        3651 :   else if (verify_type_context (loc, TCTX_POINTER_ARITH,
    4257                 :        3651 :                                 TREE_TYPE (TREE_TYPE (orig_op0))))
    4258                 :        7302 :     verify_type_context (loc, TCTX_POINTER_ARITH,
    4259                 :        3651 :                          TREE_TYPE (TREE_TYPE (orig_op1)));
    4260                 :             : 
    4261                 :        3655 :   op1 = c_size_in_bytes (target_type);
    4262                 :             : 
    4263                 :        3655 :   if (pointer_to_zero_sized_aggr_p (TREE_TYPE (orig_op1)))
    4264                 :           4 :     error_at (loc, "arithmetic on pointer to an empty aggregate");
    4265                 :             : 
    4266                 :             :   /* Divide by the size, in easiest possible way.  */
    4267                 :        3655 :   result = fold_build2_loc (loc, EXACT_DIV_EXPR, inttype,
    4268                 :             :                             op0, convert (inttype, op1));
    4269                 :             : 
    4270                 :             :   /* Convert to final result type if necessary.  */
    4271                 :        3655 :   return convert (restype, result);
    4272                 :             : }
    4273                 :             : 
    4274                 :             : /* Expand atomic compound assignments into an appropriate sequence as
    4275                 :             :    specified by the C11 standard section 6.5.16.2.
    4276                 :             : 
    4277                 :             :        _Atomic T1 E1
    4278                 :             :        T2 E2
    4279                 :             :        E1 op= E2
    4280                 :             : 
    4281                 :             :   This sequence is used for all types for which these operations are
    4282                 :             :   supported.
    4283                 :             : 
    4284                 :             :   In addition, built-in versions of the 'fe' prefixed routines may
    4285                 :             :   need to be invoked for floating point (real, complex or vector) when
    4286                 :             :   floating-point exceptions are supported.  See 6.5.16.2 footnote 113.
    4287                 :             : 
    4288                 :             :   T1 newval;
    4289                 :             :   T1 old;
    4290                 :             :   T1 *addr
    4291                 :             :   T2 val
    4292                 :             :   fenv_t fenv
    4293                 :             : 
    4294                 :             :   addr = &E1;
    4295                 :             :   val = (E2);
    4296                 :             :   __atomic_load (addr, &old, SEQ_CST);
    4297                 :             :   feholdexcept (&fenv);
    4298                 :             : loop:
    4299                 :             :     newval = old op val;
    4300                 :             :     if (__atomic_compare_exchange_strong (addr, &old, &newval, SEQ_CST,
    4301                 :             :                                           SEQ_CST))
    4302                 :             :       goto done;
    4303                 :             :     feclearexcept (FE_ALL_EXCEPT);
    4304                 :             :     goto loop:
    4305                 :             : done:
    4306                 :             :   feupdateenv (&fenv);
    4307                 :             : 
    4308                 :             :   The compiler will issue the __atomic_fetch_* built-in when possible,
    4309                 :             :   otherwise it will generate the generic form of the atomic operations.
    4310                 :             :   This requires temp(s) and has their address taken.  The atomic processing
    4311                 :             :   is smart enough to figure out when the size of an object can utilize
    4312                 :             :   a lock-free version, and convert the built-in call to the appropriate
    4313                 :             :   lock-free routine.  The optimizers will then dispose of any temps that
    4314                 :             :   are no longer required, and lock-free implementations are utilized as
    4315                 :             :   long as there is target support for the required size.
    4316                 :             : 
    4317                 :             :   If the operator is NOP_EXPR, then this is a simple assignment, and
    4318                 :             :   an __atomic_store is issued to perform the assignment rather than
    4319                 :             :   the above loop.  */
    4320                 :             : 
    4321                 :             : /* Build an atomic assignment at LOC, expanding into the proper
    4322                 :             :    sequence to store LHS MODIFYCODE= RHS.  Return a value representing
    4323                 :             :    the result of the operation, unless RETURN_OLD_P, in which case
    4324                 :             :    return the old value of LHS (this is only for postincrement and
    4325                 :             :    postdecrement).  */
    4326                 :             : 
    4327                 :             : static tree
    4328                 :       30280 : build_atomic_assign (location_t loc, tree lhs, enum tree_code modifycode,
    4329                 :             :                      tree rhs, bool return_old_p)
    4330                 :             : {
    4331                 :       30280 :   tree fndecl, func_call;
    4332                 :       30280 :   vec<tree, va_gc> *params;
    4333                 :       30280 :   tree val, nonatomic_lhs_type, nonatomic_rhs_type, newval, newval_addr;
    4334                 :       30280 :   tree old, old_addr;
    4335                 :       30280 :   tree compound_stmt = NULL_TREE;
    4336                 :       30280 :   tree stmt, goto_stmt;
    4337                 :       30280 :   tree loop_label, loop_decl, done_label, done_decl;
    4338                 :             : 
    4339                 :       30280 :   tree lhs_type = TREE_TYPE (lhs);
    4340                 :       30280 :   tree lhs_addr = build_unary_op (loc, ADDR_EXPR, lhs, false);
    4341                 :       30280 :   tree seq_cst = build_int_cst (integer_type_node, MEMMODEL_SEQ_CST);
    4342                 :       30280 :   tree rhs_semantic_type = TREE_TYPE (rhs);
    4343                 :       30280 :   tree nonatomic_rhs_semantic_type;
    4344                 :       30280 :   tree rhs_type;
    4345                 :             : 
    4346                 :       30280 :   gcc_assert (TYPE_ATOMIC (lhs_type));
    4347                 :             : 
    4348                 :       30280 :   if (return_old_p)
    4349                 :        2299 :     gcc_assert (modifycode == PLUS_EXPR || modifycode == MINUS_EXPR);
    4350                 :             : 
    4351                 :             :   /* Allocate enough vector items for a compare_exchange.  */
    4352                 :       30280 :   vec_alloc (params, 6);
    4353                 :             : 
    4354                 :             :   /* Create a compound statement to hold the sequence of statements
    4355                 :             :      with a loop.  */
    4356                 :       30280 :   if (modifycode != NOP_EXPR)
    4357                 :             :     {
    4358                 :       19907 :       compound_stmt = c_begin_compound_stmt (false);
    4359                 :             : 
    4360                 :             :       /* For consistency with build_modify_expr on non-_Atomic,
    4361                 :             :          mark the lhs as read.  Also, it would be very hard to match
    4362                 :             :          such expressions in mark_exp_read.  */
    4363                 :       19907 :       mark_exp_read (lhs);
    4364                 :             :     }
    4365                 :             : 
    4366                 :             :   /* Remove any excess precision (which is only present here in the
    4367                 :             :      case of compound assignments).  */
    4368                 :       30280 :   if (TREE_CODE (rhs) == EXCESS_PRECISION_EXPR)
    4369                 :             :     {
    4370                 :           0 :       gcc_assert (modifycode != NOP_EXPR);
    4371                 :           0 :       rhs = TREE_OPERAND (rhs, 0);
    4372                 :             :     }
    4373                 :       30280 :   rhs_type = TREE_TYPE (rhs);
    4374                 :             : 
    4375                 :             :   /* Fold the RHS if it hasn't already been folded.  */
    4376                 :       30280 :   if (modifycode != NOP_EXPR)
    4377                 :       19907 :     rhs = c_fully_fold (rhs, false, NULL);
    4378                 :             : 
    4379                 :             :   /* Remove the qualifiers for the rest of the expressions and create
    4380                 :             :      the VAL temp variable to hold the RHS.  */
    4381                 :       30280 :   nonatomic_lhs_type = build_qualified_type (lhs_type, TYPE_UNQUALIFIED);
    4382                 :       30280 :   nonatomic_rhs_type = build_qualified_type (rhs_type, TYPE_UNQUALIFIED);
    4383                 :       30280 :   nonatomic_rhs_semantic_type = build_qualified_type (rhs_semantic_type,
    4384                 :             :                                                       TYPE_UNQUALIFIED);
    4385                 :       30280 :   val = create_tmp_var_raw (nonatomic_rhs_type);
    4386                 :       30280 :   TREE_ADDRESSABLE (val) = 1;
    4387                 :       30280 :   suppress_warning (val);
    4388                 :       30280 :   rhs = build4 (TARGET_EXPR, nonatomic_rhs_type, val, rhs, NULL_TREE,
    4389                 :             :                 NULL_TREE);
    4390                 :       30280 :   TREE_SIDE_EFFECTS (rhs) = 1;
    4391                 :       30280 :   SET_EXPR_LOCATION (rhs, loc);
    4392                 :       30280 :   if (modifycode != NOP_EXPR)
    4393                 :       19907 :     add_stmt (rhs);
    4394                 :             : 
    4395                 :             :   /* NOP_EXPR indicates it's a straight store of the RHS. Simply issue
    4396                 :             :      an atomic_store.  */
    4397                 :       30280 :   if (modifycode == NOP_EXPR)
    4398                 :             :     {
    4399                 :       10373 :       compound_stmt = rhs;
    4400                 :             :       /* Build __atomic_store (&lhs, &val, SEQ_CST)  */
    4401                 :       10373 :       rhs = build_unary_op (loc, ADDR_EXPR, val, false);
    4402                 :       10373 :       fndecl = builtin_decl_explicit (BUILT_IN_ATOMIC_STORE);
    4403                 :       10373 :       params->quick_push (lhs_addr);
    4404                 :       10373 :       params->quick_push (rhs);
    4405                 :       10373 :       params->quick_push (seq_cst);
    4406                 :       10373 :       func_call = c_build_function_call_vec (loc, vNULL, fndecl, params, NULL);
    4407                 :             : 
    4408                 :       10373 :       compound_stmt = build2 (COMPOUND_EXPR, void_type_node,
    4409                 :             :                               compound_stmt, func_call);
    4410                 :             : 
    4411                 :             :       /* VAL is the value which was stored, return a COMPOUND_STMT of
    4412                 :             :          the statement and that value.  */
    4413                 :       10373 :       return build2 (COMPOUND_EXPR, nonatomic_lhs_type, compound_stmt, val);
    4414                 :             :     }
    4415                 :             : 
    4416                 :             :   /* Attempt to implement the atomic operation as an __atomic_fetch_* or
    4417                 :             :      __atomic_*_fetch built-in rather than a CAS loop.  atomic_bool type
    4418                 :             :      isn't applicable for such builtins.  ??? Do we want to handle enums?  */
    4419                 :       19907 :   if ((TREE_CODE (lhs_type) == INTEGER_TYPE || POINTER_TYPE_P (lhs_type))
    4420                 :       13941 :       && TREE_CODE (rhs_type) == INTEGER_TYPE)
    4421                 :             :     {
    4422                 :       11713 :       built_in_function fncode;
    4423                 :       11713 :       switch (modifycode)
    4424                 :             :         {
    4425                 :        3075 :         case PLUS_EXPR:
    4426                 :        3075 :         case POINTER_PLUS_EXPR:
    4427                 :        3075 :           fncode = (return_old_p
    4428                 :        3075 :                     ? BUILT_IN_ATOMIC_FETCH_ADD_N
    4429                 :             :                     : BUILT_IN_ATOMIC_ADD_FETCH_N);
    4430                 :             :           break;
    4431                 :        2889 :         case MINUS_EXPR:
    4432                 :        2889 :           fncode = (return_old_p
    4433                 :        2889 :                     ? BUILT_IN_ATOMIC_FETCH_SUB_N
    4434                 :             :                     : BUILT_IN_ATOMIC_SUB_FETCH_N);
    4435                 :             :           break;
    4436                 :         609 :         case BIT_AND_EXPR:
    4437                 :         609 :           fncode = (return_old_p
    4438                 :         609 :                     ? BUILT_IN_ATOMIC_FETCH_AND_N
    4439                 :             :                     : BUILT_IN_ATOMIC_AND_FETCH_N);
    4440                 :             :           break;
    4441                 :         609 :         case BIT_IOR_EXPR:
    4442                 :         609 :           fncode = (return_old_p
    4443                 :         609 :                     ? BUILT_IN_ATOMIC_FETCH_OR_N
    4444                 :             :                     : BUILT_IN_ATOMIC_OR_FETCH_N);
    4445                 :             :           break;
    4446                 :         609 :         case BIT_XOR_EXPR:
    4447                 :         609 :           fncode = (return_old_p
    4448                 :         609 :                     ? BUILT_IN_ATOMIC_FETCH_XOR_N
    4449                 :             :                     : BUILT_IN_ATOMIC_XOR_FETCH_N);
    4450                 :             :           break;
    4451                 :        3922 :         default:
    4452                 :        3922 :           goto cas_loop;
    4453                 :             :         }
    4454                 :             : 
    4455                 :             :       /* We can only use "_1" through "_16" variants of the atomic fetch
    4456                 :             :          built-ins.  */
    4457                 :        7791 :       unsigned HOST_WIDE_INT size = tree_to_uhwi (TYPE_SIZE_UNIT (lhs_type));
    4458                 :        7791 :       if (size != 1 && size != 2 && size != 4 && size != 8 && size != 16)
    4459                 :           0 :         goto cas_loop;
    4460                 :             : 
    4461                 :             :       /* If this is a pointer type, we need to multiply by the size of
    4462                 :             :          the pointer target type.  */
    4463                 :        7791 :       if (POINTER_TYPE_P (lhs_type))
    4464                 :             :         {
    4465                 :        1018 :           if (!COMPLETE_TYPE_P (TREE_TYPE (lhs_type))
    4466                 :             :               /* ??? This would introduce -Wdiscarded-qualifiers
    4467                 :             :                  warning: __atomic_fetch_* expect volatile void *
    4468                 :             :                  type as the first argument.  (Assignments between
    4469                 :             :                  atomic and non-atomic objects are OK.) */
    4470                 :        1018 :               || TYPE_RESTRICT (lhs_type))
    4471                 :          17 :             goto cas_loop;
    4472                 :        1001 :           tree sz = TYPE_SIZE_UNIT (TREE_TYPE (lhs_type));
    4473                 :        1001 :           rhs = fold_build2_loc (loc, MULT_EXPR, ptrdiff_type_node,
    4474                 :             :                                  convert (ptrdiff_type_node, rhs),
    4475                 :             :                                  convert (ptrdiff_type_node, sz));
    4476                 :             :         }
    4477                 :             : 
    4478                 :             :       /* Build __atomic_fetch_* (&lhs, &val, SEQ_CST), or
    4479                 :             :          __atomic_*_fetch (&lhs, &val, SEQ_CST).  */
    4480                 :        7774 :       fndecl = builtin_decl_explicit (fncode);
    4481                 :        7774 :       params->quick_push (lhs_addr);
    4482                 :        7774 :       params->quick_push (rhs);
    4483                 :        7774 :       params->quick_push (seq_cst);
    4484                 :        7774 :       func_call = c_build_function_call_vec (loc, vNULL, fndecl, params, NULL);
    4485                 :             : 
    4486                 :        7774 :       newval = create_tmp_var_raw (nonatomic_lhs_type);
    4487                 :        7774 :       TREE_ADDRESSABLE (newval) = 1;
    4488                 :        7774 :       suppress_warning (newval);
    4489                 :        7774 :       rhs = build4 (TARGET_EXPR, nonatomic_lhs_type, newval, func_call,
    4490                 :             :                     NULL_TREE, NULL_TREE);
    4491                 :        7774 :       SET_EXPR_LOCATION (rhs, loc);
    4492                 :        7774 :       add_stmt (rhs);
    4493                 :             : 
    4494                 :             :       /* Finish the compound statement.  */
    4495                 :        7774 :       compound_stmt = c_end_compound_stmt (loc, compound_stmt, false);
    4496                 :             : 
    4497                 :             :       /* NEWVAL is the value which was stored, return a COMPOUND_STMT of
    4498                 :             :          the statement and that value.  */
    4499                 :        7774 :       return build2 (COMPOUND_EXPR, nonatomic_lhs_type, compound_stmt, newval);
    4500                 :             :     }
    4501                 :             : 
    4502                 :        8194 : cas_loop:
    4503                 :             :   /* Create the variables and labels required for the op= form.  */
    4504                 :       12133 :   old = create_tmp_var_raw (nonatomic_lhs_type);
    4505                 :       12133 :   old_addr = build_unary_op (loc, ADDR_EXPR, old, false);
    4506                 :       12133 :   TREE_ADDRESSABLE (old) = 1;
    4507                 :       12133 :   suppress_warning (old);
    4508                 :             : 
    4509                 :       12133 :   newval = create_tmp_var_raw (nonatomic_lhs_type);
    4510                 :       12133 :   newval_addr = build_unary_op (loc, ADDR_EXPR, newval, false);
    4511                 :       12133 :   TREE_ADDRESSABLE (newval) = 1;
    4512                 :       12133 :   suppress_warning (newval);
    4513                 :             : 
    4514                 :       12133 :   loop_decl = create_artificial_label (loc);
    4515                 :       12133 :   loop_label = build1 (LABEL_EXPR, void_type_node, loop_decl);
    4516                 :             : 
    4517                 :       12133 :   done_decl = create_artificial_label (loc);
    4518                 :       12133 :   done_label = build1 (LABEL_EXPR, void_type_node, done_decl);
    4519                 :             : 
    4520                 :             :   /* __atomic_load (addr, &old, SEQ_CST).  */
    4521                 :       12133 :   fndecl = builtin_decl_explicit (BUILT_IN_ATOMIC_LOAD);
    4522                 :       12133 :   params->quick_push (lhs_addr);
    4523                 :       12133 :   params->quick_push (old_addr);
    4524                 :       12133 :   params->quick_push (seq_cst);
    4525                 :       12133 :   func_call = c_build_function_call_vec (loc, vNULL, fndecl, params, NULL);
    4526                 :       12133 :   old = build4 (TARGET_EXPR, nonatomic_lhs_type, old, func_call, NULL_TREE,
    4527                 :             :                 NULL_TREE);
    4528                 :       12133 :   add_stmt (old);
    4529                 :       12133 :   params->truncate (0);
    4530                 :             : 
    4531                 :             :   /* Create the expressions for floating-point environment
    4532                 :             :      manipulation, if required.  */
    4533                 :       12133 :   bool need_fenv = (flag_trapping_math
    4534                 :       12133 :                     && (FLOAT_TYPE_P (lhs_type) || FLOAT_TYPE_P (rhs_type)));
    4535                 :       12133 :   tree hold_call = NULL_TREE, clear_call = NULL_TREE, update_call = NULL_TREE;
    4536                 :       12133 :   if (need_fenv)
    4537                 :        7054 :     targetm.atomic_assign_expand_fenv (&hold_call, &clear_call, &update_call);
    4538                 :             : 
    4539                 :       12133 :   if (hold_call)
    4540                 :        7054 :     add_stmt (hold_call);
    4541                 :             : 
    4542                 :             :   /* loop:  */
    4543                 :       12133 :   add_stmt (loop_label);
    4544                 :             : 
    4545                 :             :   /* newval = old + val;  */
    4546                 :       12133 :   if (rhs_type != rhs_semantic_type)
    4547                 :           0 :     val = build1 (EXCESS_PRECISION_EXPR, nonatomic_rhs_semantic_type, val);
    4548                 :       12133 :   rhs = build_binary_op (loc, modifycode, old, val, true);
    4549                 :       12133 :   if (TREE_CODE (rhs) == EXCESS_PRECISION_EXPR)
    4550                 :             :     {
    4551                 :           0 :       tree eptype = TREE_TYPE (rhs);
    4552                 :           0 :       rhs = c_fully_fold (TREE_OPERAND (rhs, 0), false, NULL);
    4553                 :           0 :       rhs = build1 (EXCESS_PRECISION_EXPR, eptype, rhs);
    4554                 :             :     }
    4555                 :             :   else
    4556                 :       12133 :     rhs = c_fully_fold (rhs, false, NULL);
    4557                 :       12133 :   rhs = convert_for_assignment (loc, UNKNOWN_LOCATION, nonatomic_lhs_type,
    4558                 :             :                                 rhs, NULL_TREE, ic_assign, false, NULL_TREE,
    4559                 :             :                                 NULL_TREE, 0);
    4560                 :       12133 :   if (rhs != error_mark_node)
    4561                 :             :     {
    4562                 :       12124 :       rhs = build4 (TARGET_EXPR, nonatomic_lhs_type, newval, rhs, NULL_TREE,
    4563                 :             :                     NULL_TREE);
    4564                 :       12124 :       SET_EXPR_LOCATION (rhs, loc);
    4565                 :       12124 :       add_stmt (rhs);
    4566                 :             :     }
    4567                 :             : 
    4568                 :             :   /* if (__atomic_compare_exchange (addr, &old, &new, false, SEQ_CST, SEQ_CST))
    4569                 :             :        goto done;  */
    4570                 :       12133 :   fndecl = builtin_decl_explicit (BUILT_IN_ATOMIC_COMPARE_EXCHANGE);
    4571                 :       12133 :   params->quick_push (lhs_addr);
    4572                 :       12133 :   params->quick_push (old_addr);
    4573                 :       12133 :   params->quick_push (newval_addr);
    4574                 :       12133 :   params->quick_push (integer_zero_node);
    4575                 :       12133 :   params->quick_push (seq_cst);
    4576                 :       12133 :   params->quick_push (seq_cst);
    4577                 :       12133 :   func_call = c_build_function_call_vec (loc, vNULL, fndecl, params, NULL);
    4578                 :             : 
    4579                 :       12133 :   goto_stmt = build1 (GOTO_EXPR, void_type_node, done_decl);
    4580                 :       12133 :   SET_EXPR_LOCATION (goto_stmt, loc);
    4581                 :             : 
    4582                 :       12133 :   stmt = build3 (COND_EXPR, void_type_node, func_call, goto_stmt, NULL_TREE);
    4583                 :       12133 :   SET_EXPR_LOCATION (stmt, loc);
    4584                 :       12133 :   add_stmt (stmt);
    4585                 :             : 
    4586                 :       12133 :   if (clear_call)
    4587                 :        7054 :     add_stmt (clear_call);
    4588                 :             : 
    4589                 :             :   /* goto loop;  */
    4590                 :       12133 :   goto_stmt  = build1 (GOTO_EXPR, void_type_node, loop_decl);
    4591                 :       12133 :   SET_EXPR_LOCATION (goto_stmt, loc);
    4592                 :       12133 :   add_stmt (goto_stmt);
    4593                 :             : 
    4594                 :             :   /* done:  */
    4595                 :       12133 :   add_stmt (done_label);
    4596                 :             : 
    4597                 :       12133 :   if (update_call)
    4598                 :        7054 :     add_stmt (update_call);
    4599                 :             : 
    4600                 :             :   /* Finish the compound statement.  */
    4601                 :       12133 :   compound_stmt = c_end_compound_stmt (loc, compound_stmt, false);
    4602                 :             : 
    4603                 :             :   /* NEWVAL is the value that was successfully stored, return a
    4604                 :             :      COMPOUND_EXPR of the statement and the appropriate value.  */
    4605                 :       23707 :   return build2 (COMPOUND_EXPR, nonatomic_lhs_type, compound_stmt,
    4606                 :       12133 :                  return_old_p ? old : newval);
    4607                 :             : }
    4608                 :             : 
    4609                 :             : /* Construct and perhaps optimize a tree representation
    4610                 :             :    for a unary operation.  CODE, a tree_code, specifies the operation
    4611                 :             :    and XARG is the operand.
    4612                 :             :    For any CODE other than ADDR_EXPR, NOCONVERT suppresses the default
    4613                 :             :    promotions (such as from short to int).
    4614                 :             :    For ADDR_EXPR, the default promotions are not applied; NOCONVERT allows
    4615                 :             :    non-lvalues; this is only used to handle conversion of non-lvalue arrays
    4616                 :             :    to pointers in C99.
    4617                 :             : 
    4618                 :             :    LOCATION is the location of the operator.  */
    4619                 :             : 
    4620                 :             : tree
    4621                 :    52667726 : build_unary_op (location_t location, enum tree_code code, tree xarg,
    4622                 :             :                 bool noconvert)
    4623                 :             : {
    4624                 :             :   /* No default_conversion here.  It causes trouble for ADDR_EXPR.  */
    4625                 :    52667726 :   tree arg = xarg;
    4626                 :    52667726 :   tree argtype = NULL_TREE;
    4627                 :    52667726 :   enum tree_code typecode;
    4628                 :    52667726 :   tree val;
    4629                 :    52667726 :   tree ret = error_mark_node;
    4630                 :    52667726 :   tree eptype = NULL_TREE;
    4631                 :    52667726 :   const char *invalid_op_diag;
    4632                 :    52667726 :   bool int_operands;
    4633                 :             : 
    4634                 :    52667726 :   int_operands = EXPR_INT_CONST_OPERANDS (xarg);
    4635                 :     5346926 :   if (int_operands)
    4636                 :     5346926 :     arg = remove_c_maybe_const_expr (arg);
    4637                 :             : 
    4638                 :    52667726 :   if (code != ADDR_EXPR)
    4639                 :     7347592 :     arg = require_complete_type (location, arg);
    4640                 :             : 
    4641                 :    52667726 :   typecode = TREE_CODE (TREE_TYPE (arg));
    4642                 :    52667726 :   if (typecode == ERROR_MARK)
    4643                 :          74 :     return error_mark_node;
    4644                 :    52667652 :   if (typecode == ENUMERAL_TYPE || typecode == BOOLEAN_TYPE)
    4645                 :       27941 :     typecode = INTEGER_TYPE;
    4646                 :             : 
    4647                 :   105335304 :   if ((invalid_op_diag
    4648                 :    52667652 :        = targetm.invalid_unary_op (code, TREE_TYPE (xarg))))
    4649                 :             :     {
    4650                 :           0 :       error_at (location, invalid_op_diag);
    4651                 :           0 :       return error_mark_node;
    4652                 :             :     }
    4653                 :             : 
    4654                 :    52667652 :   if (TREE_CODE (arg) == EXCESS_PRECISION_EXPR)
    4655                 :             :     {
    4656                 :         219 :       eptype = TREE_TYPE (arg);
    4657                 :         219 :       arg = TREE_OPERAND (arg, 0);
    4658                 :             :     }
    4659                 :             : 
    4660                 :    52667652 :   switch (code)
    4661                 :             :     {
    4662                 :       28529 :     case CONVERT_EXPR:
    4663                 :             :       /* This is used for unary plus, because a CONVERT_EXPR
    4664                 :             :          is enough to prevent anybody from looking inside for
    4665                 :             :          associativity, but won't generate any code.  */
    4666                 :       28534 :       if (!(typecode == INTEGER_TYPE || typecode == REAL_TYPE
    4667                 :           8 :             || typecode == FIXED_POINT_TYPE || typecode == COMPLEX_TYPE
    4668                 :           5 :             || typecode == BITINT_TYPE
    4669                 :           5 :             || gnu_vector_type_p (TREE_TYPE (arg))))
    4670                 :             :         {
    4671                 :           1 :           error_at (location, "wrong type argument to unary plus");
    4672                 :           1 :           return error_mark_node;
    4673                 :             :         }
    4674                 :       28528 :       else if (!noconvert)
    4675                 :       28528 :         arg = default_conversion (arg);
    4676                 :       28528 :       arg = non_lvalue_loc (location, arg);
    4677                 :       28528 :       break;
    4678                 :             : 
    4679                 :     5608551 :     case NEGATE_EXPR:
    4680                 :     6041925 :       if (!(typecode == INTEGER_TYPE || typecode == REAL_TYPE
    4681                 :      469757 :             || typecode == FIXED_POINT_TYPE || typecode == COMPLEX_TYPE
    4682                 :      438490 :             || typecode == BITINT_TYPE
    4683                 :      433374 :             || gnu_vector_type_p (TREE_TYPE (arg))))
    4684                 :             :         {
    4685                 :           1 :           error_at (location, "wrong type argument to unary minus");
    4686                 :           1 :           return error_mark_node;
    4687                 :             :         }
    4688                 :     5608550 :       else if (!noconvert)
    4689                 :     5608550 :         arg = default_conversion (arg);
    4690                 :             :       break;
    4691                 :             : 
    4692                 :      284931 :     case BIT_NOT_EXPR:
    4693                 :             :       /* ~ works on integer types and non float vectors. */
    4694                 :      284931 :       if (typecode == INTEGER_TYPE
    4695                 :      284931 :           || typecode == BITINT_TYPE
    4696                 :      284931 :           || (gnu_vector_type_p (TREE_TYPE (arg))
    4697                 :         243 :               && !VECTOR_FLOAT_TYPE_P (TREE_TYPE (arg))))
    4698                 :             :         {
    4699                 :             :           tree e = arg;
    4700                 :             : 
    4701                 :             :           /* Warn if the expression has boolean value.  */
    4702                 :      284348 :           while (TREE_CODE (e) == COMPOUND_EXPR)
    4703                 :          11 :             e = TREE_OPERAND (e, 1);
    4704                 :             : 
    4705                 :      568661 :           if ((C_BOOLEAN_TYPE_P (TREE_TYPE (arg))
    4706                 :      568661 :                || truth_value_p (TREE_CODE (e))))
    4707                 :             :             {
    4708                 :         134 :               auto_diagnostic_group d;
    4709                 :         134 :               if (warning_at (location, OPT_Wbool_operation,
    4710                 :             :                                 "%<~%> on a boolean expression"))
    4711                 :             :                 {
    4712                 :          12 :                   gcc_rich_location richloc (location);
    4713                 :          12 :                   richloc.add_fixit_insert_before (location, "!");
    4714                 :          12 :                   inform (&richloc, "did you mean to use logical not?");
    4715                 :          12 :                 }
    4716                 :         134 :             }
    4717                 :      284337 :           if (!noconvert)
    4718                 :      284337 :             arg = default_conversion (arg);
    4719                 :             :         }
    4720                 :         594 :       else if (typecode == COMPLEX_TYPE)
    4721                 :             :         {
    4722                 :         589 :           code = CONJ_EXPR;
    4723                 :         589 :           pedwarn (location, OPT_Wpedantic,
    4724                 :             :                    "ISO C does not support %<~%> for complex conjugation");
    4725                 :         589 :           if (!noconvert)
    4726                 :         589 :             arg = default_conversion (arg);
    4727                 :             :         }
    4728                 :             :       else
    4729                 :             :         {
    4730                 :           5 :           error_at (location, "wrong type argument to bit-complement");
    4731                 :           5 :           return error_mark_node;
    4732                 :             :         }
    4733                 :             :       break;
    4734                 :             : 
    4735                 :           3 :     case ABS_EXPR:
    4736                 :           3 :       if (!(typecode == INTEGER_TYPE || typecode == REAL_TYPE))
    4737                 :             :         {
    4738                 :           0 :           error_at (location, "wrong type argument to abs");
    4739                 :           0 :           return error_mark_node;
    4740                 :             :         }
    4741                 :           3 :       else if (!noconvert)
    4742                 :           3 :         arg = default_conversion (arg);
    4743                 :             :       break;
    4744                 :             : 
    4745                 :           7 :     case ABSU_EXPR:
    4746                 :           7 :       if (!(typecode == INTEGER_TYPE))
    4747                 :             :         {
    4748                 :           0 :           error_at (location, "wrong type argument to absu");
    4749                 :           0 :           return error_mark_node;
    4750                 :             :         }
    4751                 :           7 :       else if (!noconvert)
    4752                 :           7 :         arg = default_conversion (arg);
    4753                 :             :       break;
    4754                 :             : 
    4755                 :           0 :     case CONJ_EXPR:
    4756                 :             :       /* Conjugating a real value is a no-op, but allow it anyway.  */
    4757                 :           0 :       if (!(typecode == INTEGER_TYPE || typecode == REAL_TYPE
    4758                 :             :             || typecode == COMPLEX_TYPE))
    4759                 :             :         {
    4760                 :           0 :           error_at (location, "wrong type argument to conjugation");
    4761                 :           0 :           return error_mark_node;
    4762                 :             :         }
    4763                 :           0 :       else if (!noconvert)
    4764                 :           0 :         arg = default_conversion (arg);
    4765                 :             :       break;
    4766                 :             : 
    4767                 :      336170 :     case TRUTH_NOT_EXPR:
    4768                 :      336170 :       if (typecode != INTEGER_TYPE && typecode != FIXED_POINT_TYPE
    4769                 :        6526 :           && typecode != REAL_TYPE && typecode != POINTER_TYPE
    4770                 :          19 :           && typecode != COMPLEX_TYPE && typecode != NULLPTR_TYPE
    4771                 :          18 :           && typecode != BITINT_TYPE)
    4772                 :             :         {
    4773                 :          10 :           error_at (location,
    4774                 :             :                     "wrong type argument to unary exclamation mark");
    4775                 :          10 :           return error_mark_node;
    4776                 :             :         }
    4777                 :      336160 :       if (int_operands)
    4778                 :             :         {
    4779                 :      103467 :           arg = c_objc_common_truthvalue_conversion (location, xarg);
    4780                 :      103467 :           arg = remove_c_maybe_const_expr (arg);
    4781                 :             :         }
    4782                 :             :       else
    4783                 :      232693 :         arg = c_objc_common_truthvalue_conversion (location, arg);
    4784                 :      336160 :       ret = invert_truthvalue_loc (location, arg);
    4785                 :             :       /* If the TRUTH_NOT_EXPR has been folded, reset the location.  */
    4786                 :      336160 :       if (EXPR_P (ret) && EXPR_HAS_LOCATION (ret))
    4787                 :      232312 :         location = EXPR_LOCATION (ret);
    4788                 :      336160 :       goto return_build_unary_op;
    4789                 :             : 
    4790                 :      201068 :     case REALPART_EXPR:
    4791                 :      201068 :     case IMAGPART_EXPR:
    4792                 :      201068 :       ret = build_real_imag_expr (location, code, arg);
    4793                 :      201068 :       if (ret == error_mark_node)
    4794                 :             :         return error_mark_node;
    4795                 :      201060 :       if (eptype && TREE_CODE (eptype) == COMPLEX_TYPE)
    4796                 :           2 :         eptype = TREE_TYPE (eptype);
    4797                 :      201060 :       goto return_build_unary_op;
    4798                 :             : 
    4799                 :      888298 :     case PREINCREMENT_EXPR:
    4800                 :      888298 :     case POSTINCREMENT_EXPR:
    4801                 :      888298 :     case PREDECREMENT_EXPR:
    4802                 :      888298 :     case POSTDECREMENT_EXPR:
    4803                 :             : 
    4804                 :      888298 :       if (TREE_CODE (arg) == C_MAYBE_CONST_EXPR)
    4805                 :             :         {
    4806                 :           2 :           tree inner = build_unary_op (location, code,
    4807                 :           2 :                                        C_MAYBE_CONST_EXPR_EXPR (arg),
    4808                 :             :                                        noconvert);
    4809                 :           2 :           if (inner == error_mark_node)
    4810                 :             :             return error_mark_node;
    4811                 :           4 :           ret = build2 (C_MAYBE_CONST_EXPR, TREE_TYPE (inner),
    4812                 :           2 :                         C_MAYBE_CONST_EXPR_PRE (arg), inner);
    4813                 :           2 :           gcc_assert (!C_MAYBE_CONST_EXPR_INT_OPERANDS (arg));
    4814                 :           2 :           C_MAYBE_CONST_EXPR_NON_CONST (ret) = 1;
    4815                 :           2 :           goto return_build_unary_op;
    4816                 :             :         }
    4817                 :             : 
    4818                 :             :       /* Complain about anything that is not a true lvalue.  In
    4819                 :             :          Objective-C, skip this check for property_refs.  */
    4820                 :      888296 :       if (!objc_is_property_ref (arg)
    4821                 :     1776592 :           && !lvalue_or_else (location,
    4822                 :      888296 :                               arg, ((code == PREINCREMENT_EXPR
    4823                 :      888296 :                                      || code == POSTINCREMENT_EXPR)
    4824                 :             :                                     ? lv_increment
    4825                 :             :                                     : lv_decrement)))
    4826                 :          20 :         return error_mark_node;
    4827                 :             : 
    4828                 :      888276 :       if (warn_cxx_compat && TREE_CODE (TREE_TYPE (arg)) == ENUMERAL_TYPE)
    4829                 :             :         {
    4830                 :           4 :           if (code == PREINCREMENT_EXPR || code == POSTINCREMENT_EXPR)
    4831                 :           2 :             warning_at (location, OPT_Wc___compat,
    4832                 :             :                         "increment of enumeration value is invalid in C++");
    4833                 :             :           else
    4834                 :           2 :             warning_at (location, OPT_Wc___compat,
    4835                 :             :                         "decrement of enumeration value is invalid in C++");
    4836                 :             :         }
    4837                 :             : 
    4838                 :      888276 :       if (C_BOOLEAN_TYPE_P (TREE_TYPE (arg)))
    4839                 :             :         {
    4840                 :         264 :           if (code == PREINCREMENT_EXPR || code == POSTINCREMENT_EXPR)
    4841                 :         132 :             warning_at (location, OPT_Wbool_operation,
    4842                 :             :                         "increment of a boolean expression");
    4843                 :             :           else
    4844                 :         132 :             warning_at (location, OPT_Wbool_operation,
    4845                 :             :                         "decrement of a boolean expression");
    4846                 :             :         }
    4847                 :             : 
    4848                 :             :       /* Ensure the argument is fully folded inside any SAVE_EXPR.  */
    4849                 :      888276 :       arg = c_fully_fold (arg, false, NULL, true);
    4850                 :             : 
    4851                 :      888276 :       bool atomic_op;
    4852                 :      888276 :       atomic_op = really_atomic_lvalue (arg);
    4853                 :             : 
    4854                 :             :       /* Increment or decrement the real part of the value,
    4855                 :             :          and don't change the imaginary part.  */
    4856                 :      888276 :       if (typecode == COMPLEX_TYPE)
    4857                 :             :         {
    4858                 :          13 :           tree real, imag;
    4859                 :             : 
    4860                 :          13 :           pedwarn (location, OPT_Wpedantic,
    4861                 :             :                    "ISO C does not support %<++%> and %<--%> on complex types");
    4862                 :             : 
    4863                 :          13 :           if (!atomic_op)
    4864                 :             :             {
    4865                 :           9 :               arg = stabilize_reference (arg);
    4866                 :           9 :               real = build_unary_op (EXPR_LOCATION (arg), REALPART_EXPR, arg,
    4867                 :             :                                      true);
    4868                 :           9 :               imag = build_unary_op (EXPR_LOCATION (arg), IMAGPART_EXPR, arg,
    4869                 :             :                                      true);
    4870                 :           9 :               real = build_unary_op (EXPR_LOCATION (arg), code, real, true);
    4871                 :           9 :               if (real == error_mark_node || imag == error_mark_node)
    4872                 :             :                 return error_mark_node;
    4873                 :           9 :               ret = build2 (COMPLEX_EXPR, TREE_TYPE (arg),
    4874                 :             :                             real, imag);
    4875                 :           9 :               goto return_build_unary_op;
    4876                 :             :             }
    4877                 :             :         }
    4878                 :             : 
    4879                 :             :       /* Report invalid types.  */
    4880                 :             : 
    4881                 :      888267 :       if (typecode != POINTER_TYPE && typecode != FIXED_POINT_TYPE
    4882                 :      662362 :           && typecode != INTEGER_TYPE && typecode != REAL_TYPE
    4883                 :         143 :           && typecode != COMPLEX_TYPE && typecode != BITINT_TYPE
    4884                 :      888316 :           && !gnu_vector_type_p (TREE_TYPE (arg)))
    4885                 :             :         {
    4886                 :           5 :           if (code == PREINCREMENT_EXPR || code == POSTINCREMENT_EXPR)
    4887                 :           3 :             error_at (location, "wrong type argument to increment");
    4888                 :             :           else
    4889                 :           2 :             error_at (location, "wrong type argument to decrement");
    4890                 :             : 
    4891                 :           5 :           return error_mark_node;
    4892                 :             :         }
    4893                 :             : 
    4894                 :      888262 :       {
    4895                 :      888262 :         tree inc;
    4896                 :             : 
    4897                 :      888262 :         argtype = TREE_TYPE (arg);
    4898                 :             : 
    4899                 :             :         /* Compute the increment.  */
    4900                 :             : 
    4901                 :      888262 :         if (typecode == POINTER_TYPE)
    4902                 :             :           {
    4903                 :             :             /* If pointer target is an incomplete type,
    4904                 :             :                we just cannot know how to do the arithmetic.  */
    4905                 :      225905 :             if (!COMPLETE_OR_VOID_TYPE_P (TREE_TYPE (argtype)))
    4906                 :             :               {
    4907                 :          27 :                 if (code == PREINCREMENT_EXPR || code == POSTINCREMENT_EXPR)
    4908                 :          17 :                   error_at (location,
    4909                 :             :                             "increment of pointer to an incomplete type %qT",
    4910                 :          17 :                             TREE_TYPE (argtype));
    4911                 :             :                 else
    4912                 :          10 :                   error_at (location,
    4913                 :             :                             "decrement of pointer to an incomplete type %qT",
    4914                 :          10 :                             TREE_TYPE (argtype));
    4915                 :             :               }
    4916                 :      225878 :             else if (TREE_CODE (TREE_TYPE (argtype)) == FUNCTION_TYPE
    4917                 :      225878 :                      || VOID_TYPE_P (TREE_TYPE (argtype)))
    4918                 :             :               {
    4919                 :           9 :                 if (code == PREINCREMENT_EXPR || code == POSTINCREMENT_EXPR)
    4920                 :           5 :                   pedwarn (location, OPT_Wpointer_arith,
    4921                 :             :                            "wrong type argument to increment");
    4922                 :             :                 else
    4923                 :           4 :                   pedwarn (location, OPT_Wpointer_arith,
    4924                 :             :                            "wrong type argument to decrement");
    4925                 :             :               }
    4926                 :             :             else
    4927                 :      451738 :               verify_type_context (location, TCTX_POINTER_ARITH,
    4928                 :      225869 :                                    TREE_TYPE (argtype));
    4929                 :             : 
    4930                 :      225905 :             inc = c_size_in_bytes (TREE_TYPE (argtype));
    4931                 :      225905 :             inc = convert_to_ptrofftype_loc (location, inc);
    4932                 :             :           }
    4933                 :      662357 :         else if (FRACT_MODE_P (TYPE_MODE (argtype)))
    4934                 :             :           {
    4935                 :             :             /* For signed fract types, we invert ++ to -- or
    4936                 :             :                -- to ++, and change inc from 1 to -1, because
    4937                 :             :                it is not possible to represent 1 in signed fract constants.
    4938                 :             :                For unsigned fract types, the result always overflows and
    4939                 :             :                we get an undefined (original) or the maximum value.  */
    4940                 :           0 :             if (code == PREINCREMENT_EXPR)
    4941                 :             :               code = PREDECREMENT_EXPR;
    4942                 :             :             else if (code == PREDECREMENT_EXPR)
    4943                 :             :               code = PREINCREMENT_EXPR;
    4944                 :             :             else if (code == POSTINCREMENT_EXPR)
    4945                 :             :               code = POSTDECREMENT_EXPR;
    4946                 :             :             else /* code == POSTDECREMENT_EXPR  */
    4947                 :           0 :               code = POSTINCREMENT_EXPR;
    4948                 :             : 
    4949                 :           0 :             inc = integer_minus_one_node;
    4950                 :           0 :             inc = convert (argtype, inc);
    4951                 :             :           }
    4952                 :             :         else
    4953                 :             :           {
    4954                 :     1324714 :             inc = VECTOR_TYPE_P (argtype)
    4955                 :      662357 :               ? build_one_cst (argtype)
    4956                 :             :               : integer_one_node;
    4957                 :      662357 :             inc = convert (argtype, inc);
    4958                 :             :           }
    4959                 :             : 
    4960                 :             :         /* If 'arg' is an Objective-C PROPERTY_REF expression, then we
    4961                 :             :            need to ask Objective-C to build the increment or decrement
    4962                 :             :            expression for it.  */
    4963                 :      888262 :         if (objc_is_property_ref (arg))
    4964                 :           0 :           return objc_build_incr_expr_for_property_ref (location, code,
    4965                 :           0 :                                                         arg, inc);
    4966                 :             : 
    4967                 :             :         /* Report a read-only lvalue.  */
    4968                 :      888262 :         if (TYPE_READONLY (argtype))
    4969                 :             :           {
    4970                 :          20 :             readonly_error (location, arg,
    4971                 :          20 :                             ((code == PREINCREMENT_EXPR
    4972                 :          20 :                               || code == POSTINCREMENT_EXPR)
    4973                 :             :                              ? lv_increment : lv_decrement));
    4974                 :          20 :             return error_mark_node;
    4975                 :             :           }
    4976                 :      888242 :         else if (TREE_READONLY (arg))
    4977                 :           4 :           readonly_warning (arg,
    4978                 :           4 :                             ((code == PREINCREMENT_EXPR
    4979                 :           4 :                               || code == POSTINCREMENT_EXPR)
    4980                 :             :                              ? lv_increment : lv_decrement));
    4981                 :             : 
    4982                 :             :         /* If the argument is atomic, use the special code sequences for
    4983                 :             :            atomic compound assignment.  */
    4984                 :      888242 :         if (atomic_op)
    4985                 :             :           {
    4986                 :        4441 :             arg = stabilize_reference (arg);
    4987                 :        8882 :             ret = build_atomic_assign (location, arg,
    4988                 :        4441 :                                        ((code == PREINCREMENT_EXPR
    4989                 :        4441 :                                          || code == POSTINCREMENT_EXPR)
    4990                 :             :                                         ? PLUS_EXPR
    4991                 :             :                                         : MINUS_EXPR),
    4992                 :        4441 :                                        (FRACT_MODE_P (TYPE_MODE (argtype))
    4993                 :             :                                         ? inc
    4994                 :             :                                         : integer_one_node),
    4995                 :             :                                        (code == POSTINCREMENT_EXPR
    4996                 :        4441 :                                         || code == POSTDECREMENT_EXPR));
    4997                 :        4441 :             goto return_build_unary_op;
    4998                 :             :           }
    4999                 :             : 
    5000                 :      883801 :         if (C_BOOLEAN_TYPE_P (TREE_TYPE (arg)))
    5001                 :          56 :           val = boolean_increment (code, arg);
    5002                 :             :         else
    5003                 :      883745 :           val = build2 (code, TREE_TYPE (arg), arg, inc);
    5004                 :      883801 :         TREE_SIDE_EFFECTS (val) = 1;
    5005                 :      883801 :         if (TYPE_QUALS (TREE_TYPE (val)) != TYPE_UNQUALIFIED)
    5006                 :        3891 :           TREE_TYPE (val) = c_build_qualified_type (TREE_TYPE (val),
    5007                 :             :                                                     TYPE_UNQUALIFIED);
    5008                 :      883801 :         ret = val;
    5009                 :      883801 :         goto return_build_unary_op;
    5010                 :             :       }
    5011                 :             : 
    5012                 :    45320093 :     case ADDR_EXPR:
    5013                 :             :       /* Note that this operation never does default_conversion.  */
    5014                 :             : 
    5015                 :             :       /* The operand of unary '&' must be an lvalue (which excludes
    5016                 :             :          expressions of type void), or, in C99, the result of a [] or
    5017                 :             :          unary '*' operator.  */
    5018                 :    45320093 :       if (VOID_TYPE_P (TREE_TYPE (arg))
    5019                 :          25 :           && TYPE_QUALS (TREE_TYPE (arg)) == TYPE_UNQUALIFIED
    5020                 :    45320112 :           && (!INDIRECT_REF_P (arg) || !flag_isoc99))
    5021                 :          18 :         pedwarn (location, 0, "taking address of expression of type %<void%>");
    5022                 :             : 
    5023                 :             :       /* Let &* cancel out to simplify resulting code.  */
    5024                 :    45320093 :       if (INDIRECT_REF_P (arg))
    5025                 :             :         {
    5026                 :             :           /* Don't let this be an lvalue.  */
    5027                 :       21261 :           if (lvalue_p (TREE_OPERAND (arg, 0)))
    5028                 :       15827 :             return non_lvalue_loc (location, TREE_OPERAND (arg, 0));
    5029                 :        5434 :           ret = TREE_OPERAND (arg, 0);
    5030                 :        5434 :           goto return_build_unary_op;
    5031                 :             :         }
    5032                 :             : 
    5033                 :             :       /* Anything not already handled and not a true memory reference
    5034                 :             :          or a non-lvalue array is an error.  */
    5035                 :    45298832 :       if (typecode != FUNCTION_TYPE && !noconvert
    5036                 :    45298832 :           && !lvalue_or_else (location, arg, lv_addressof))
    5037                 :          17 :         return error_mark_node;
    5038                 :             : 
    5039                 :             :       /* Move address operations inside C_MAYBE_CONST_EXPR to simplify
    5040                 :             :          folding later.  */
    5041                 :    45298815 :       if (TREE_CODE (arg) == C_MAYBE_CONST_EXPR)
    5042                 :             :         {
    5043                 :           1 :           tree inner = build_unary_op (location, code,
    5044                 :           1 :                                        C_MAYBE_CONST_EXPR_EXPR (arg),
    5045                 :             :                                        noconvert);
    5046                 :           2 :           ret = build2 (C_MAYBE_CONST_EXPR, TREE_TYPE (inner),
    5047                 :           1 :                         C_MAYBE_CONST_EXPR_PRE (arg), inner);
    5048                 :           1 :           gcc_assert (!C_MAYBE_CONST_EXPR_INT_OPERANDS (arg));
    5049                 :           1 :           C_MAYBE_CONST_EXPR_NON_CONST (ret)
    5050                 :           1 :             = C_MAYBE_CONST_EXPR_NON_CONST (arg);
    5051                 :           1 :           goto return_build_unary_op;
    5052                 :             :         }
    5053                 :             : 
    5054                 :             :       /* Ordinary case; arg is a COMPONENT_REF or a decl.  */
    5055                 :    45298814 :       argtype = TREE_TYPE (arg);
    5056                 :             : 
    5057                 :             :       /* If the lvalue is const or volatile, merge that into the type
    5058                 :             :          to which the address will point.  This is only needed
    5059                 :             :          for function types.  */
    5060                 :    45298814 :       if ((DECL_P (arg) || REFERENCE_CLASS_P (arg))
    5061                 :    44824846 :           && (TREE_READONLY (arg) || TREE_THIS_VOLATILE (arg))
    5062                 :    71211827 :           && TREE_CODE (argtype) == FUNCTION_TYPE)
    5063                 :             :         {
    5064                 :    25835364 :           int orig_quals = TYPE_QUALS (strip_array_types (argtype));
    5065                 :    25835364 :           int quals = orig_quals;
    5066                 :             : 
    5067                 :    25835364 :           if (TREE_READONLY (arg))
    5068                 :    25472548 :             quals |= TYPE_QUAL_CONST;
    5069                 :    25835364 :           if (TREE_THIS_VOLATILE (arg))
    5070                 :      363568 :             quals |= TYPE_QUAL_VOLATILE;
    5071                 :             : 
    5072                 :    25835364 :           argtype = c_build_qualified_type (argtype, quals);
    5073                 :             :         }
    5074                 :             : 
    5075                 :    45298814 :       switch (TREE_CODE (arg))
    5076                 :             :         {
    5077                 :       62805 :         case COMPONENT_REF:
    5078                 :       62805 :           if (DECL_C_BIT_FIELD (TREE_OPERAND (arg, 1)))
    5079                 :             :             {
    5080                 :           8 :               error_at (location, "cannot take address of bit-field %qD",
    5081                 :           8 :                         TREE_OPERAND (arg, 1));
    5082                 :           8 :               return error_mark_node;
    5083                 :             :             }
    5084                 :             : 
    5085                 :             :           /* fall through */
    5086                 :             : 
    5087                 :      136152 :         case ARRAY_REF:
    5088                 :      136152 :           if (TYPE_REVERSE_STORAGE_ORDER (TREE_TYPE (TREE_OPERAND (arg, 0))))
    5089                 :             :             {
    5090                 :          78 :               if (!AGGREGATE_TYPE_P (TREE_TYPE (arg))
    5091                 :           7 :                   && !POINTER_TYPE_P (TREE_TYPE (arg))
    5092                 :          75 :                   && !VECTOR_TYPE_P (TREE_TYPE (arg)))
    5093                 :             :                 {
    5094                 :           6 :                   error_at (location, "cannot take address of scalar with "
    5095                 :             :                             "reverse storage order");
    5096                 :           6 :                   return error_mark_node;
    5097                 :             :                 }
    5098                 :             : 
    5099                 :          63 :               if (TREE_CODE (TREE_TYPE (arg)) == ARRAY_TYPE
    5100                 :          63 :                   && TYPE_REVERSE_STORAGE_ORDER (TREE_TYPE (arg)))
    5101                 :          58 :                 warning_at (location, OPT_Wscalar_storage_order,
    5102                 :             :                             "address of array with reverse scalar storage "
    5103                 :             :                             "order requested");
    5104                 :             :             }
    5105                 :             : 
    5106                 :    45298800 :         default:
    5107                 :    45298800 :           break;
    5108                 :             :         }
    5109                 :             : 
    5110                 :    45298800 :       if (!c_mark_addressable (arg))
    5111                 :          10 :         return error_mark_node;
    5112                 :             : 
    5113                 :    45298790 :       gcc_assert (TREE_CODE (arg) != COMPONENT_REF
    5114                 :             :                   || !DECL_C_BIT_FIELD (TREE_OPERAND (arg, 1)));
    5115                 :             : 
    5116                 :    45298790 :       argtype = build_pointer_type (argtype);
    5117                 :             : 
    5118                 :             :       /* ??? Cope with user tricks that amount to offsetof.  Delete this
    5119                 :             :          when we have proper support for integer constant expressions.  */
    5120                 :    45298790 :       val = get_base_address (arg);
    5121                 :    45298790 :       if (val && INDIRECT_REF_P (val)
    5122                 :    45320767 :           && TREE_CONSTANT (TREE_OPERAND (val, 0)))
    5123                 :             :         {
    5124                 :         537 :           ret = fold_offsetof (arg, argtype);
    5125                 :         537 :           goto return_build_unary_op;
    5126                 :             :         }
    5127                 :             : 
    5128                 :    45298253 :       val = build1 (ADDR_EXPR, argtype, arg);
    5129                 :             : 
    5130                 :    45298253 :       ret = val;
    5131                 :    45298253 :       goto return_build_unary_op;
    5132                 :             : 
    5133                 :           2 :     case PAREN_EXPR:
    5134                 :           2 :       ret = build1 (code, TREE_TYPE (arg), arg);
    5135                 :           2 :       goto return_build_unary_op;
    5136                 :             : 
    5137                 :           0 :     default:
    5138                 :           0 :       gcc_unreachable ();
    5139                 :             :     }
    5140                 :             : 
    5141                 :     5922014 :   if (argtype == NULL_TREE)
    5142                 :     5922014 :     argtype = TREE_TYPE (arg);
    5143                 :     5922014 :   if (TREE_CODE (arg) == INTEGER_CST)
    5144                 :     5239502 :     ret = (require_constant_value
    5145                 :     5239502 :            ? fold_build1_initializer_loc (location, code, argtype, arg)
    5146                 :     5221348 :            : fold_build1_loc (location, code, argtype, arg));
    5147                 :             :   else
    5148                 :      682512 :     ret = build1 (code, argtype, arg);
    5149                 :    52651714 :  return_build_unary_op:
    5150                 :    52651714 :   gcc_assert (ret != error_mark_node);
    5151                 :     5347399 :   if (TREE_CODE (ret) == INTEGER_CST && !TREE_OVERFLOW (ret)
    5152                 :    57999104 :       && !(TREE_CODE (xarg) == INTEGER_CST && !TREE_OVERFLOW (xarg)))
    5153                 :         560 :     ret = build1 (NOP_EXPR, TREE_TYPE (ret), ret);
    5154                 :    52651154 :   else if (TREE_CODE (ret) != INTEGER_CST && int_operands)
    5155                 :          74 :     ret = note_integer_operands (ret);
    5156                 :    52651714 :   if (eptype)
    5157                 :         219 :     ret = build1 (EXCESS_PRECISION_EXPR, eptype, ret);
    5158                 :    52651714 :   protected_set_expr_location (ret, location);
    5159                 :    52651714 :   return ret;
    5160                 :             : }
    5161                 :             : 
    5162                 :             : /* Return nonzero if REF is an lvalue valid for this language.
    5163                 :             :    Lvalues can be assigned, unless their type has TYPE_READONLY.
    5164                 :             :    Lvalues can have their address taken, unless they have C_DECL_REGISTER.  */
    5165                 :             : 
    5166                 :             : bool
    5167                 :   157750338 : lvalue_p (const_tree ref)
    5168                 :             : {
    5169                 :   159187728 :   const enum tree_code code = TREE_CODE (ref);
    5170                 :             : 
    5171                 :   159187728 :   switch (code)
    5172                 :             :     {
    5173                 :     1413752 :     case REALPART_EXPR:
    5174                 :     1413752 :     case IMAGPART_EXPR:
    5175                 :     1413752 :     case COMPONENT_REF:
    5176                 :     1413752 :       return lvalue_p (TREE_OPERAND (ref, 0));
    5177                 :             : 
    5178                 :       23638 :     case C_MAYBE_CONST_EXPR:
    5179                 :       23638 :       return lvalue_p (TREE_OPERAND (ref, 1));
    5180                 :             : 
    5181                 :             :     case COMPOUND_LITERAL_EXPR:
    5182                 :             :     case STRING_CST:
    5183                 :             :       return true;
    5184                 :             : 
    5185                 :    24137081 :     case MEM_REF:
    5186                 :    24137081 :     case TARGET_MEM_REF:
    5187                 :             :       /* MEM_REFs can appear from -fgimple parsing or folding, so allow them
    5188                 :             :          here as well.  */
    5189                 :    24137081 :     case INDIRECT_REF:
    5190                 :    24137081 :     case ARRAY_REF:
    5191                 :    24137081 :     case VAR_DECL:
    5192                 :    24137081 :     case PARM_DECL:
    5193                 :    24137081 :     case RESULT_DECL:
    5194                 :    24137081 :     case ERROR_MARK:
    5195                 :    24137081 :       return (TREE_CODE (TREE_TYPE (ref)) != FUNCTION_TYPE
    5196                 :    24137081 :               && TREE_CODE (TREE_TYPE (ref)) != METHOD_TYPE);
    5197                 :             : 
    5198                 :           6 :     case BIND_EXPR:
    5199                 :           6 :       return TREE_CODE (TREE_TYPE (ref)) == ARRAY_TYPE;
    5200                 :             : 
    5201                 :             :     default:
    5202                 :             :       return false;
    5203                 :             :     }
    5204                 :             : }
    5205                 :             : 
    5206                 :             : /* Give a warning for storing in something that is read-only in GCC
    5207                 :             :    terms but not const in ISO C terms.  */
    5208                 :             : 
    5209                 :             : static void
    5210                 :           6 : readonly_warning (tree arg, enum lvalue_use use)
    5211                 :             : {
    5212                 :           4 :   switch (use)
    5213                 :             :     {
    5214                 :           2 :     case lv_assign:
    5215                 :           2 :       warning (0, "assignment of read-only location %qE", arg);
    5216                 :           0 :       break;
    5217                 :           2 :     case lv_increment:
    5218                 :           2 :       warning (0, "increment of read-only location %qE", arg);
    5219                 :           2 :       break;
    5220                 :           2 :     case lv_decrement:
    5221                 :           2 :       warning (0, "decrement of read-only location %qE", arg);
    5222                 :           2 :       break;
    5223                 :           0 :     default:
    5224                 :           0 :       gcc_unreachable ();
    5225                 :             :     }
    5226                 :           6 :   return;
    5227                 :             : }
    5228                 :             : 
    5229                 :             : 
    5230                 :             : /* Return nonzero if REF is an lvalue valid for this language;
    5231                 :             :    otherwise, print an error message and return zero.  USE says
    5232                 :             :    how the lvalue is being used and so selects the error message.
    5233                 :             :    LOCATION is the location at which any error should be reported.  */
    5234                 :             : 
    5235                 :             : static int
    5236                 :     4542134 : lvalue_or_else (location_t loc, const_tree ref, enum lvalue_use use)
    5237                 :             : {
    5238                 :     4542134 :   int win = lvalue_p (ref);
    5239                 :             : 
    5240                 :     4542134 :   if (!win)
    5241                 :          69 :     lvalue_error (loc, use);
    5242                 :             : 
    5243                 :     4542134 :   return win;
    5244                 :             : }
    5245                 :             : 
    5246                 :             : /* Mark EXP saying that we need to be able to take the
    5247                 :             :    address of it; it should not be allocated in a register.
    5248                 :             :    Returns true if successful.  ARRAY_REF_P is true if this
    5249                 :             :    is for ARRAY_REF construction - in that case we don't want
    5250                 :             :    to look through VIEW_CONVERT_EXPR from VECTOR_TYPE to ARRAY_TYPE,
    5251                 :             :    it is fine to use ARRAY_REFs for vector subscripts on vector
    5252                 :             :    register variables.  */
    5253                 :             : 
    5254                 :             : bool
    5255                 :    45819366 : c_mark_addressable (tree exp, bool array_ref_p)
    5256                 :             : {
    5257                 :    45819366 :   tree x = exp;
    5258                 :             : 
    5259                 :    46391307 :   while (1)
    5260                 :    46391307 :     switch (TREE_CODE (x))
    5261                 :             :       {
    5262                 :        9896 :       case VIEW_CONVERT_EXPR:
    5263                 :        9896 :         if (array_ref_p
    5264                 :        9795 :             && TREE_CODE (TREE_TYPE (x)) == ARRAY_TYPE
    5265                 :       19691 :             && VECTOR_TYPE_P (TREE_TYPE (TREE_OPERAND (x, 0))))
    5266                 :             :           return true;
    5267                 :         101 :         x = TREE_OPERAND (x, 0);
    5268                 :         101 :         break;
    5269                 :             : 
    5270                 :      389001 :       case COMPONENT_REF:
    5271                 :      389001 :         if (DECL_C_BIT_FIELD (TREE_OPERAND (x, 1)))
    5272                 :             :           {
    5273                 :           6 :             error ("cannot take address of bit-field %qD",
    5274                 :           3 :                    TREE_OPERAND (x, 1));
    5275                 :           3 :             return false;
    5276                 :             :           }
    5277                 :             :         /* FALLTHRU */
    5278                 :      571840 :       case ADDR_EXPR:
    5279                 :      571840 :       case ARRAY_REF:
    5280                 :      571840 :       case REALPART_EXPR:
    5281                 :      571840 :       case IMAGPART_EXPR:
    5282                 :      571840 :         x = TREE_OPERAND (x, 0);
    5283                 :      571840 :         break;
    5284                 :             : 
    5285                 :         518 :       case COMPOUND_LITERAL_EXPR:
    5286                 :         518 :         if (C_DECL_REGISTER (COMPOUND_LITERAL_EXPR_DECL (x)))
    5287                 :             :           {
    5288                 :           2 :             error ("address of register compound literal requested");
    5289                 :           2 :             return false;
    5290                 :             :           }
    5291                 :         516 :         TREE_ADDRESSABLE (x) = 1;
    5292                 :         516 :         TREE_ADDRESSABLE (COMPOUND_LITERAL_EXPR_DECL (x)) = 1;
    5293                 :         516 :         return true;
    5294                 :             : 
    5295                 :           0 :       case CONSTRUCTOR:
    5296                 :           0 :         TREE_ADDRESSABLE (x) = 1;
    5297                 :           0 :         return true;
    5298                 :             : 
    5299                 :     1291054 :       case VAR_DECL:
    5300                 :     1291054 :       case CONST_DECL:
    5301                 :     1291054 :       case PARM_DECL:
    5302                 :     1291054 :       case RESULT_DECL:
    5303                 :     1291054 :         if (C_DECL_REGISTER (x)
    5304                 :     1291054 :             && DECL_NONLOCAL (x))
    5305                 :             :           {
    5306                 :           0 :             if (TREE_PUBLIC (x) || is_global_var (x))
    5307                 :             :               {
    5308                 :           0 :                 error
    5309                 :           0 :                   ("global register variable %qD used in nested function", x);
    5310                 :           0 :                 return false;
    5311                 :             :               }
    5312                 :           0 :             pedwarn (input_location, 0, "register variable %qD used in nested function", x);
    5313                 :             :           }
    5314                 :     1291054 :         else if (C_DECL_REGISTER (x))
    5315                 :             :           {
    5316                 :          11 :             if (TREE_PUBLIC (x) || is_global_var (x))
    5317                 :           4 :               error ("address of global register variable %qD requested", x);
    5318                 :             :             else
    5319                 :           7 :               error ("address of register variable %qD requested", x);
    5320                 :          11 :             return false;
    5321                 :             :           }
    5322                 :             : 
    5323                 :             :         /* FALLTHRU */
    5324                 :    45267384 :       case FUNCTION_DECL:
    5325                 :    45267384 :         TREE_ADDRESSABLE (x) = 1;
    5326                 :             :         /* FALLTHRU */
    5327                 :             :       default:
    5328                 :             :         return true;
    5329                 :             :     }
    5330                 :             : }
    5331                 :             : 
    5332                 :             : /* Convert EXPR to TYPE, warning about conversion problems with
    5333                 :             :    constants.  SEMANTIC_TYPE is the type this conversion would use
    5334                 :             :    without excess precision. If SEMANTIC_TYPE is NULL, this function
    5335                 :             :    is equivalent to convert_and_check. This function is a wrapper that
    5336                 :             :    handles conversions that may be different than
    5337                 :             :    the usual ones because of excess precision.  */
    5338                 :             : 
    5339                 :             : static tree
    5340                 :    22258374 : ep_convert_and_check (location_t loc, tree type, tree expr,
    5341                 :             :                       tree semantic_type)
    5342                 :             : {
    5343                 :    22258374 :   if (TREE_TYPE (expr) == type)
    5344                 :             :     return expr;
    5345                 :             : 
    5346                 :             :   /* For C11, integer conversions may have results with excess
    5347                 :             :      precision.  */
    5348                 :     1921916 :   if (flag_isoc11 || !semantic_type)
    5349                 :     1921912 :     return convert_and_check (loc, type, expr);
    5350                 :             : 
    5351                 :           4 :   if (TREE_CODE (TREE_TYPE (expr)) == INTEGER_TYPE
    5352                 :           4 :       && TREE_TYPE (expr) != semantic_type)
    5353                 :             :     {
    5354                 :             :       /* For integers, we need to check the real conversion, not
    5355                 :             :          the conversion to the excess precision type.  */
    5356                 :           4 :       expr = convert_and_check (loc, semantic_type, expr);
    5357                 :             :     }
    5358                 :             :   /* Result type is the excess precision type, which should be
    5359                 :             :      large enough, so do not check.  */
    5360                 :           4 :   return convert (type, expr);
    5361                 :             : }
    5362                 :             : 
    5363                 :             : /* If EXPR refers to a built-in declared without a prototype returns
    5364                 :             :    the actual type of the built-in and, if non-null, set *BLTIN to
    5365                 :             :    a pointer to the built-in.  Otherwise return the type of EXPR
    5366                 :             :    and clear *BLTIN if non-null.  */
    5367                 :             : 
    5368                 :             : static tree
    5369                 :     2600347 : type_or_builtin_type (tree expr, tree *bltin = NULL)
    5370                 :             : {
    5371                 :     2600347 :   tree dummy;
    5372                 :     2600347 :   if (!bltin)
    5373                 :           0 :     bltin = &dummy;
    5374                 :             : 
    5375                 :     2600347 :   *bltin = NULL_TREE;
    5376                 :             : 
    5377                 :     2600347 :   tree type = TREE_TYPE (expr);
    5378                 :     2600347 :   if (TREE_CODE (expr) != ADDR_EXPR)
    5379                 :             :     return type;
    5380                 :             : 
    5381                 :      206567 :   tree oper = TREE_OPERAND (expr, 0);
    5382                 :      206567 :   if (!DECL_P (oper)
    5383                 :      168659 :       || TREE_CODE (oper) != FUNCTION_DECL
    5384                 :      242983 :       || !fndecl_built_in_p (oper, BUILT_IN_NORMAL))
    5385                 :             :     return type;
    5386                 :             : 
    5387                 :        2079 :   built_in_function code = DECL_FUNCTION_CODE (oper);
    5388                 :        2079 :   if (!C_DECL_BUILTIN_PROTOTYPE (oper))
    5389                 :             :     return type;
    5390                 :             : 
    5391                 :        1977 :   if ((*bltin = builtin_decl_implicit (code)))
    5392                 :         991 :     type = build_pointer_type (TREE_TYPE (*bltin));
    5393                 :             : 
    5394                 :             :   return type;
    5395                 :             : }
    5396                 :             : 
    5397                 :             : /* Build and return a conditional expression IFEXP ? OP1 : OP2.  If
    5398                 :             :    IFEXP_BCP then the condition is a call to __builtin_constant_p, and
    5399                 :             :    if folded to an integer constant then the unselected half may
    5400                 :             :    contain arbitrary operations not normally permitted in constant
    5401                 :             :    expressions.  Set the location of the expression to LOC.  */
    5402                 :             : 
    5403                 :             : tree
    5404                 :      357702 : build_conditional_expr (location_t colon_loc, tree ifexp, bool ifexp_bcp,
    5405                 :             :                         tree op1, tree op1_original_type, location_t op1_loc,
    5406                 :             :                         tree op2, tree op2_original_type, location_t op2_loc)
    5407                 :             : {
    5408                 :      357702 :   tree type1;
    5409                 :      357702 :   tree type2;
    5410                 :      357702 :   enum tree_code code1;
    5411                 :      357702 :   enum tree_code code2;
    5412                 :      357702 :   tree result_type = NULL;
    5413                 :      357702 :   tree semantic_result_type = NULL;
    5414                 :      357702 :   tree orig_op1 = op1, orig_op2 = op2;
    5415                 :      357702 :   bool int_const, op1_int_operands, op2_int_operands, int_operands;
    5416                 :      357702 :   bool ifexp_int_operands;
    5417                 :      357702 :   tree ret;
    5418                 :             : 
    5419                 :      357702 :   op1_int_operands = EXPR_INT_CONST_OPERANDS (orig_op1);
    5420                 :      108707 :   if (op1_int_operands)
    5421                 :      108707 :     op1 = remove_c_maybe_const_expr (op1);
    5422                 :      357702 :   op2_int_operands = EXPR_INT_CONST_OPERANDS (orig_op2);
    5423                 :      133412 :   if (op2_int_operands)
    5424                 :      133412 :     op2 = remove_c_maybe_const_expr (op2);
    5425                 :      357702 :   ifexp_int_operands = EXPR_INT_CONST_OPERANDS (ifexp);
    5426                 :      209855 :   if (ifexp_int_operands)
    5427                 :      209855 :     ifexp = remove_c_maybe_const_expr (ifexp);
    5428                 :             : 
    5429                 :             :   /* Promote both alternatives.  */
    5430                 :             : 
    5431                 :      357702 :   if (TREE_CODE (TREE_TYPE (op1)) != VOID_TYPE)
    5432                 :      353821 :     op1 = default_conversion (op1);
    5433                 :      357702 :   if (TREE_CODE (TREE_TYPE (op2)) != VOID_TYPE)
    5434                 :      327898 :     op2 = default_conversion (op2);
    5435                 :             : 
    5436                 :      357702 :   if (TREE_CODE (ifexp) == ERROR_MARK
    5437                 :      357633 :       || TREE_CODE (TREE_TYPE (op1)) == ERROR_MARK
    5438                 :      715321 :       || TREE_CODE (TREE_TYPE (op2)) == ERROR_MARK)
    5439                 :          83 :     return error_mark_node;
    5440                 :             : 
    5441                 :      357619 :   tree bltin1 = NULL_TREE;
    5442                 :      357619 :   tree bltin2 = NULL_TREE;
    5443                 :      357619 :   type1 = type_or_builtin_type (op1, &bltin1);
    5444                 :      357619 :   code1 = TREE_CODE (type1);
    5445                 :      357619 :   type2 = type_or_builtin_type (op2, &bltin2);
    5446                 :      357619 :   code2 = TREE_CODE (type2);
    5447                 :             : 
    5448                 :      357619 :   if (code1 == POINTER_TYPE && reject_gcc_builtin (op1))
    5449                 :           1 :     return error_mark_node;
    5450                 :             : 
    5451                 :      357618 :   if (code2 == POINTER_TYPE && reject_gcc_builtin (op2))
    5452                 :           1 :     return error_mark_node;
    5453                 :             : 
    5454                 :             :   /* C90 does not permit non-lvalue arrays in conditional expressions.
    5455                 :             :      In C99 they will be pointers by now.  */
    5456                 :      357617 :   if (code1 == ARRAY_TYPE || code2 == ARRAY_TYPE)
    5457                 :             :     {
    5458                 :           1 :       error_at (colon_loc, "non-lvalue array in conditional expression");
    5459                 :           1 :       return error_mark_node;
    5460                 :             :     }
    5461                 :             : 
    5462                 :      357616 :   if ((TREE_CODE (op1) == EXCESS_PRECISION_EXPR
    5463                 :      357610 :        || TREE_CODE (op2) == EXCESS_PRECISION_EXPR)
    5464                 :           7 :       && (code1 == INTEGER_TYPE || code1 == REAL_TYPE
    5465                 :           0 :           || code1 == COMPLEX_TYPE || code1 == BITINT_TYPE)
    5466                 :           7 :       && (code2 == INTEGER_TYPE || code2 == REAL_TYPE
    5467                 :           0 :           || code2 == COMPLEX_TYPE || code2 == BITINT_TYPE))
    5468                 :             :     {
    5469                 :           7 :       semantic_result_type = c_common_type (type1, type2);
    5470                 :           7 :       if (TREE_CODE (op1) == EXCESS_PRECISION_EXPR)
    5471                 :             :         {
    5472                 :           6 :           op1 = TREE_OPERAND (op1, 0);
    5473                 :           6 :           type1 = TREE_TYPE (op1);
    5474                 :           6 :           gcc_assert (TREE_CODE (type1) == code1);
    5475                 :             :         }
    5476                 :           7 :       if (TREE_CODE (op2) == EXCESS_PRECISION_EXPR)
    5477                 :             :         {
    5478                 :           1 :           op2 = TREE_OPERAND (op2, 0);
    5479                 :           1 :           type2 = TREE_TYPE (op2);
    5480                 :           1 :           gcc_assert (TREE_CODE (type2) == code2);
    5481                 :             :         }
    5482                 :             :     }
    5483                 :             : 
    5484                 :      357616 :   if (warn_cxx_compat)
    5485                 :             :     {
    5486                 :         386 :       tree t1 = op1_original_type ? op1_original_type : TREE_TYPE (orig_op1);
    5487                 :         386 :       tree t2 = op2_original_type ? op2_original_type : TREE_TYPE (orig_op2);
    5488                 :             : 
    5489                 :         386 :       if (TREE_CODE (t1) == ENUMERAL_TYPE
    5490                 :           6 :           && TREE_CODE (t2) == ENUMERAL_TYPE
    5491                 :         392 :           && TYPE_MAIN_VARIANT (t1) != TYPE_MAIN_VARIANT (t2))
    5492                 :           2 :         warning_at (colon_loc, OPT_Wc___compat,
    5493                 :             :                     ("different enum types in conditional is "
    5494                 :             :                      "invalid in C++: %qT vs %qT"),
    5495                 :             :                     t1, t2);
    5496                 :             :     }
    5497                 :             : 
    5498                 :             :   /* Quickly detect the usual case where op1 and op2 have the same type
    5499                 :             :      after promotion.  */
    5500                 :      357616 :   if (TYPE_MAIN_VARIANT (type1) == TYPE_MAIN_VARIANT (type2))
    5501                 :             :     {
    5502                 :      253043 :       if (type1 == type2)
    5503                 :             :         result_type = type1;
    5504                 :             :       else
    5505                 :        5503 :         result_type = TYPE_MAIN_VARIANT (type1);
    5506                 :             :     }
    5507                 :      104573 :   else if ((code1 == INTEGER_TYPE || code1 == REAL_TYPE
    5508                 :       57029 :             || code1 == COMPLEX_TYPE || code1 == BITINT_TYPE)
    5509                 :       47589 :            && (code2 == INTEGER_TYPE || code2 == REAL_TYPE
    5510                 :       26146 :                || code2 == COMPLEX_TYPE || code2 == BITINT_TYPE))
    5511                 :             :     {
    5512                 :             :       /* In C11, a conditional expression between a floating-point
    5513                 :             :          type and an integer type should convert the integer type to
    5514                 :             :          the evaluation format of the floating-point type, with
    5515                 :             :          possible excess precision.  */
    5516                 :       21542 :       tree eptype1 = type1;
    5517                 :       21542 :       tree eptype2 = type2;
    5518                 :       21542 :       if (flag_isoc11)
    5519                 :             :         {
    5520                 :       21287 :           tree eptype;
    5521                 :        5557 :           if (ANY_INTEGRAL_TYPE_P (type1)
    5522                 :       21287 :               && (eptype = excess_precision_type (type2)) != NULL_TREE)
    5523                 :             :             {
    5524                 :           2 :               eptype2 = eptype;
    5525                 :           2 :               if (!semantic_result_type)
    5526                 :           2 :                 semantic_result_type = c_common_type (type1, type2);
    5527                 :             :             }
    5528                 :         369 :           else if (ANY_INTEGRAL_TYPE_P (type2)
    5529                 :       21285 :                    && (eptype = excess_precision_type (type1)) != NULL_TREE)
    5530                 :             :             {
    5531                 :           2 :               eptype1 = eptype;
    5532                 :           2 :               if (!semantic_result_type)
    5533                 :           2 :                 semantic_result_type = c_common_type (type1, type2);
    5534                 :             :             }
    5535                 :             :         }
    5536                 :       21542 :       result_type = c_common_type (eptype1, eptype2);
    5537                 :       21542 :       if (result_type == error_mark_node)
    5538                 :             :         return error_mark_node;
    5539                 :       21540 :       do_warn_double_promotion (result_type, type1, type2,
    5540                 :             :                                 "implicit conversion from %qT to %qT to "
    5541                 :             :                                 "match other result of conditional",
    5542                 :             :                                 colon_loc);
    5543                 :             : 
    5544                 :             :       /* If -Wsign-compare, warn here if type1 and type2 have
    5545                 :             :          different signedness.  We'll promote the signed to unsigned
    5546                 :             :          and later code won't know it used to be different.
    5547                 :             :          Do this check on the original types, so that explicit casts
    5548                 :             :          will be considered, but default promotions won't.  */
    5549                 :       21540 :       if (c_inhibit_evaluation_warnings == 0)
    5550                 :             :         {
    5551                 :       21349 :           int unsigned_op1 = TYPE_UNSIGNED (TREE_TYPE (orig_op1));
    5552                 :       21349 :           int unsigned_op2 = TYPE_UNSIGNED (TREE_TYPE (orig_op2));
    5553                 :             : 
    5554                 :       21349 :           if (unsigned_op1 ^ unsigned_op2)
    5555                 :             :             {
    5556                 :       12310 :               bool ovf;
    5557                 :             : 
    5558                 :             :               /* Do not warn if the result type is signed, since the
    5559                 :             :                  signed type will only be chosen if it can represent
    5560                 :             :                  all the values of the unsigned type.  */
    5561                 :       12310 :               if (!TYPE_UNSIGNED (result_type))
    5562                 :             :                 /* OK */;
    5563                 :             :               else
    5564                 :             :                 {
    5565                 :       12206 :                   bool op1_maybe_const = true;
    5566                 :       12206 :                   bool op2_maybe_const = true;
    5567                 :             : 
    5568                 :             :                   /* Do not warn if the signed quantity is an
    5569                 :             :                      unsuffixed integer literal (or some static
    5570                 :             :                      constant expression involving such literals) and
    5571                 :             :                      it is non-negative.  This warning requires the
    5572                 :             :                      operands to be folded for best results, so do
    5573                 :             :                      that folding in this case even without
    5574                 :             :                      warn_sign_compare to avoid warning options
    5575                 :             :                      possibly affecting code generation.  */
    5576                 :       12206 :                   c_inhibit_evaluation_warnings
    5577                 :       12206 :                     += (ifexp == truthvalue_false_node);
    5578                 :       12206 :                   op1 = c_fully_fold (op1, require_constant_value,
    5579                 :             :                                       &op1_maybe_const);
    5580                 :       12206 :                   c_inhibit_evaluation_warnings
    5581                 :       12206 :                     -= (ifexp == truthvalue_false_node);
    5582                 :             : 
    5583                 :       12206 :                   c_inhibit_evaluation_warnings
    5584                 :       12206 :                     += (ifexp == truthvalue_true_node);
    5585                 :       12206 :                   op2 = c_fully_fold (op2, require_constant_value,
    5586                 :             :                                       &op2_maybe_const);
    5587                 :       12206 :                   c_inhibit_evaluation_warnings
    5588                 :       12206 :                     -= (ifexp == truthvalue_true_node);
    5589                 :             : 
    5590                 :       12206 :                   if (warn_sign_compare)
    5591                 :             :                     {
    5592                 :        1229 :                       if ((unsigned_op2
    5593                 :         677 :                            && tree_expr_nonnegative_warnv_p (op1, &ovf))
    5594                 :        1232 :                           || (unsigned_op1
    5595                 :         552 :                               && tree_expr_nonnegative_warnv_p (op2, &ovf)))
    5596                 :             :                         /* OK */;
    5597                 :          10 :                       else if (unsigned_op2)
    5598                 :           3 :                         warning_at (op1_loc, OPT_Wsign_compare,
    5599                 :             :                                     "operand of %<?:%> changes signedness from "
    5600                 :             :                                     "%qT to %qT due to unsignedness of other "
    5601                 :           3 :                                     "operand", TREE_TYPE (orig_op1),
    5602                 :           3 :                                     TREE_TYPE (orig_op2));
    5603                 :             :                       else
    5604                 :           7 :                         warning_at (op2_loc, OPT_Wsign_compare,
    5605                 :             :                                     "operand of %<?:%> changes signedness from "
    5606                 :             :                                     "%qT to %qT due to unsignedness of other "
    5607                 :           7 :                                     "operand", TREE_TYPE (orig_op2),
    5608                 :           7 :                                     TREE_TYPE (orig_op1));
    5609                 :             :                     }
    5610                 :       12206 :                   if (!op1_maybe_const || TREE_CODE (op1) != INTEGER_CST)
    5611                 :        6897 :                     op1 = c_wrap_maybe_const (op1, !op1_maybe_const);
    5612                 :       12206 :                   if (!op2_maybe_const || TREE_CODE (op2) != INTEGER_CST)
    5613                 :        4209 :                     op2 = c_wrap_maybe_const (op2, !op2_maybe_const);
    5614                 :             :                 }
    5615                 :             :             }
    5616                 :             :         }
    5617                 :             :     }
    5618                 :       83031 :   else if (code1 == VOID_TYPE || code2 == VOID_TYPE)
    5619                 :             :     {
    5620                 :       25995 :       if (code1 != VOID_TYPE || code2 != VOID_TYPE)
    5621                 :       25995 :         pedwarn (colon_loc, OPT_Wpedantic,
    5622                 :             :                  "ISO C forbids conditional expr with only one void side");
    5623                 :       25995 :       result_type = void_type_node;
    5624                 :             :     }
    5625                 :       57036 :   else if (code1 == POINTER_TYPE && code2 == POINTER_TYPE)
    5626                 :             :     {
    5627                 :       56669 :       addr_space_t as1 = TYPE_ADDR_SPACE (TREE_TYPE (type1));
    5628                 :       56669 :       addr_space_t as2 = TYPE_ADDR_SPACE (TREE_TYPE (type2));
    5629                 :       56669 :       addr_space_t as_common;
    5630                 :             : 
    5631                 :       56669 :       if (comp_target_types (colon_loc, type1, type2))
    5632                 :        2562 :         result_type = common_pointer_type (type1, type2);
    5633                 :       54107 :       else if (null_pointer_constant_p (orig_op1))
    5634                 :             :         result_type = type2;
    5635                 :       51026 :       else if (null_pointer_constant_p (orig_op2))
    5636                 :             :         result_type = type1;
    5637                 :       24115 :       else if (!addr_space_superset (as1, as2, &as_common))
    5638                 :             :         {
    5639                 :           0 :           error_at (colon_loc, "pointers to disjoint address spaces "
    5640                 :             :                     "used in conditional expression");
    5641                 :           0 :           return error_mark_node;
    5642                 :             :         }
    5643                 :       24115 :       else if ((VOID_TYPE_P (TREE_TYPE (type1))
    5644                 :         318 :                 && !TYPE_ATOMIC (TREE_TYPE (type1)))
    5645                 :       24117 :                || (VOID_TYPE_P (TREE_TYPE (type2))
    5646                 :       23752 :                    && !TYPE_ATOMIC (TREE_TYPE (type2))))
    5647                 :             :         {
    5648                 :       24067 :           tree t1 = TREE_TYPE (type1);
    5649                 :       24067 :           tree t2 = TREE_TYPE (type2);
    5650                 :       24067 :           if (!(VOID_TYPE_P (t1)
    5651                 :         317 :                 && !TYPE_ATOMIC (t1)))
    5652                 :             :            {
    5653                 :             :              /* roles are swapped */
    5654                 :       23751 :              t1 = t2;
    5655                 :       23751 :              t2 = TREE_TYPE (type1);
    5656                 :             :            }
    5657                 :       24067 :           tree t2_stripped = strip_array_types (t2);
    5658                 :       24067 :           if ((TREE_CODE (t2) == ARRAY_TYPE)
    5659                 :       24067 :               && (TYPE_QUALS (t2_stripped) & ~TYPE_QUALS (t1)))
    5660                 :             :             {
    5661                 :          18 :               if (!flag_isoc23)
    5662                 :           6 :                 warning_at (colon_loc, OPT_Wdiscarded_array_qualifiers,
    5663                 :             :                             "pointer to array loses qualifier "
    5664                 :             :                             "in conditional expression");
    5665                 :          12 :               else if (warn_c11_c23_compat > 0)
    5666                 :           6 :                 warning_at (colon_loc, OPT_Wc11_c23_compat,
    5667                 :             :                             "pointer to array loses qualifier "
    5668                 :             :                             "in conditional expression in ISO C before C23");
    5669                 :             :             }
    5670                 :       24067 :           if (TREE_CODE (t2) == FUNCTION_TYPE)
    5671                 :           4 :             pedwarn (colon_loc, OPT_Wpedantic,
    5672                 :             :                      "ISO C forbids conditional expr between "
    5673                 :             :                      "%<void *%> and function pointer");
    5674                 :             :           /* for array, use qualifiers of element type */
    5675                 :       24067 :           if (flag_isoc23)
    5676                 :        5361 :             t2 = t2_stripped;
    5677                 :       24067 :           result_type = build_pointer_type (qualify_type (t1, t2));
    5678                 :             :         }
    5679                 :             :       /* Objective-C pointer comparisons are a bit more lenient.  */
    5680                 :          48 :       else if (objc_have_common_type (type1, type2, -3, NULL_TREE))
    5681                 :           0 :         result_type = objc_common_type (type1, type2);
    5682                 :             :       else
    5683                 :             :         {
    5684                 :          48 :           int qual = ENCODE_QUAL_ADDR_SPACE (as_common);
    5685                 :          48 :           diagnostic_t kind = DK_PERMERROR;
    5686                 :          48 :           if (!flag_isoc99)
    5687                 :             :             /* This downgrade to a warning ensures that -std=gnu89
    5688                 :             :                -pedantic-errors does not flag these mismatches between
    5689                 :             :                builtins as errors (as DK_PERMERROR would).  ISO C99
    5690                 :             :                and later do not have implicit function declarations,
    5691                 :             :                so the mismatch cannot occur naturally there.  */
    5692                 :           5 :             kind = bltin1 && bltin2 ? DK_WARNING : DK_PEDWARN;
    5693                 :          48 :           if (emit_diagnostic (kind, colon_loc, OPT_Wincompatible_pointer_types,
    5694                 :             :                                "pointer type mismatch "
    5695                 :             :                                "in conditional expression"))
    5696                 :             :             {
    5697                 :          46 :               inform (op1_loc, "first expression has type %qT", type1);
    5698                 :          46 :               inform (op2_loc, "second expression has type %qT", type2);
    5699                 :             :             }
    5700                 :          48 :           result_type = build_pointer_type
    5701                 :          48 :                           (build_qualified_type (void_type_node, qual));
    5702                 :             :         }
    5703                 :             :     }
    5704                 :         367 :   else if (code1 == POINTER_TYPE
    5705                 :         252 :            && (code2 == INTEGER_TYPE || code2 == BITINT_TYPE))
    5706                 :             :     {
    5707                 :         248 :       if (!null_pointer_constant_p (orig_op2))
    5708                 :          14 :         permerror_opt (colon_loc, OPT_Wint_conversion,
    5709                 :             :                        "pointer/integer type mismatch "
    5710                 :             :                        "in conditional expression");
    5711                 :             :       else
    5712                 :             :         {
    5713                 :         234 :           op2 = null_pointer_node;
    5714                 :             :         }
    5715                 :             :       result_type = type1;
    5716                 :             :     }
    5717                 :         119 :   else if (code2 == POINTER_TYPE
    5718                 :          85 :            && (code1 == INTEGER_TYPE || code1 == BITINT_TYPE))
    5719                 :             :     {
    5720                 :          81 :       if (!null_pointer_constant_p (orig_op1))
    5721                 :          14 :         permerror_opt (colon_loc, OPT_Wint_conversion,
    5722                 :             :                        "pointer/integer type mismatch "
    5723                 :             :                        "in conditional expression");
    5724                 :             :       else
    5725                 :             :         {
    5726                 :          67 :           op1 = null_pointer_node;
    5727                 :             :         }
    5728                 :             :       result_type = type2;
    5729                 :             :     }
    5730                 :             :   /* 6.5.15: "if one is a null pointer constant (other than a pointer) or has
    5731                 :             :      type nullptr_t and the other is a pointer, the result type is the pointer
    5732                 :             :      type."  */
    5733                 :          38 :   else if (code1 == NULLPTR_TYPE && code2 == POINTER_TYPE)
    5734                 :             :     result_type = type2;
    5735                 :          34 :   else if (code1 == POINTER_TYPE && code2 == NULLPTR_TYPE)
    5736                 :             :     result_type = type1;
    5737                 :           8 :   else if (RECORD_OR_UNION_TYPE_P (type1) && RECORD_OR_UNION_TYPE_P (type2)
    5738                 :          38 :            && comptypes (TYPE_MAIN_VARIANT (type1),
    5739                 :           8 :                          TYPE_MAIN_VARIANT (type2)))
    5740                 :           8 :     result_type = composite_type (TYPE_MAIN_VARIANT (type1),
    5741                 :           8 :                                   TYPE_MAIN_VARIANT (type2));
    5742                 :             : 
    5743                 :      357614 :   if (!result_type)
    5744                 :             :     {
    5745                 :          22 :       if (flag_cond_mismatch)
    5746                 :           0 :         result_type = void_type_node;
    5747                 :             :       else
    5748                 :             :         {
    5749                 :          22 :           error_at (colon_loc, "type mismatch in conditional expression");
    5750                 :          22 :           return error_mark_node;
    5751                 :             :         }
    5752                 :             :     }
    5753                 :             : 
    5754                 :             :   /* Merge const and volatile flags of the incoming types.  */
    5755                 :      357592 :   result_type
    5756                 :      357592 :     = build_type_variant (result_type,
    5757                 :             :                           TYPE_READONLY (type1) || TYPE_READONLY (type2),
    5758                 :             :                           TYPE_VOLATILE (type1) || TYPE_VOLATILE (type2));
    5759                 :             : 
    5760                 :      357592 :   op1 = ep_convert_and_check (colon_loc, result_type, op1,
    5761                 :             :                               semantic_result_type);
    5762                 :      357592 :   op2 = ep_convert_and_check (colon_loc, result_type, op2,
    5763                 :             :                               semantic_result_type);
    5764                 :             : 
    5765                 :      357592 :   if (ifexp_bcp && ifexp == truthvalue_true_node)
    5766                 :             :     {
    5767                 :          10 :       op2_int_operands = true;
    5768                 :          10 :       op1 = c_fully_fold (op1, require_constant_value, NULL);
    5769                 :             :     }
    5770                 :      357592 :   if (ifexp_bcp && ifexp == truthvalue_false_node)
    5771                 :             :     {
    5772                 :          49 :       op1_int_operands = true;
    5773                 :          49 :       op2 = c_fully_fold (op2, require_constant_value, NULL);
    5774                 :             :     }
    5775                 :      806921 :   int_const = int_operands = (ifexp_int_operands
    5776                 :      357592 :                               && op1_int_operands
    5777                 :      357592 :                               && op2_int_operands);
    5778                 :       91737 :   if (int_operands)
    5779                 :             :     {
    5780                 :       91737 :       int_const = ((ifexp == truthvalue_true_node
    5781                 :       55299 :                     && TREE_CODE (orig_op1) == INTEGER_CST
    5782                 :       55285 :                     && !TREE_OVERFLOW (orig_op1))
    5783                 :       91751 :                    || (ifexp == truthvalue_false_node
    5784                 :       36392 :                        && TREE_CODE (orig_op2) == INTEGER_CST
    5785                 :       36376 :                        && !TREE_OVERFLOW (orig_op2)));
    5786                 :             :     }
    5787                 :             : 
    5788                 :             :   /* Need to convert condition operand into a vector mask.  */
    5789                 :      357592 :   if (VECTOR_TYPE_P (TREE_TYPE (ifexp)))
    5790                 :             :     {
    5791                 :           0 :       tree vectype = TREE_TYPE (ifexp);
    5792                 :           0 :       tree elem_type = TREE_TYPE (vectype);
    5793                 :           0 :       tree zero = build_int_cst (elem_type, 0);
    5794                 :           0 :       tree zero_vec = build_vector_from_val (vectype, zero);
    5795                 :           0 :       tree cmp_type = truth_type_for (vectype);
    5796                 :           0 :       ifexp = build2 (NE_EXPR, cmp_type, ifexp, zero_vec);
    5797                 :             :     }
    5798                 :             : 
    5799                 :      357592 :   if (int_const || (ifexp_bcp && TREE_CODE (ifexp) == INTEGER_CST))
    5800                 :       91693 :     ret = fold_build3_loc (colon_loc, COND_EXPR, result_type, ifexp, op1, op2);
    5801                 :             :   else
    5802                 :             :     {
    5803                 :      265899 :       if (int_operands)
    5804                 :             :         {
    5805                 :             :           /* Use c_fully_fold here, since C_MAYBE_CONST_EXPR might be
    5806                 :             :              nested inside of the expression.  */
    5807                 :          76 :           op1 = c_fully_fold (op1, false, NULL);
    5808                 :          76 :           op2 = c_fully_fold (op2, false, NULL);
    5809                 :             :         }
    5810                 :      265899 :       ret = build3 (COND_EXPR, result_type, ifexp, op1, op2);
    5811                 :      265899 :       if (int_operands)
    5812                 :          76 :         ret = note_integer_operands (ret);
    5813                 :             :     }
    5814                 :      357592 :   if (semantic_result_type)
    5815                 :          11 :     ret = build1 (EXCESS_PRECISION_EXPR, semantic_result_type, ret);
    5816                 :             : 
    5817                 :      357592 :   protected_set_expr_location (ret, colon_loc);
    5818                 :             : 
    5819                 :             :   /* If the OP1 and OP2 are the same and don't have side-effects,
    5820                 :             :      warn here, because the COND_EXPR will be turned into OP1.  */
    5821                 :      357592 :   if (warn_duplicated_branches
    5822                 :          34 :       && TREE_CODE (ret) == COND_EXPR
    5823                 :      357626 :       && (op1 == op2 || operand_equal_p (op1, op2, OEP_ADDRESS_OF_SAME_FIELD)))
    5824                 :          13 :     warning_at (EXPR_LOCATION (ret), OPT_Wduplicated_branches,
    5825                 :             :                 "this condition has identical branches");
    5826                 :             : 
    5827                 :             :   return ret;
    5828                 :             : }
    5829                 :             : 
    5830                 :             : /* EXPR is an expression, location LOC, whose result is discarded.
    5831                 :             :    Warn if it is a call to a nodiscard function (or a COMPOUND_EXPR
    5832                 :             :    whose right-hand operand is such a call, possibly recursively).  */
    5833                 :             : 
    5834                 :             : static void
    5835                 :     6314173 : maybe_warn_nodiscard (location_t loc, tree expr)
    5836                 :             : {
    5837                 :     6314173 :   if (VOID_TYPE_P (TREE_TYPE (expr)))
    5838                 :             :     return;
    5839                 :     3804472 :   while (TREE_CODE (expr) == COMPOUND_EXPR)
    5840                 :             :     {
    5841                 :       47528 :       expr = TREE_OPERAND (expr, 1);
    5842                 :       47528 :       if (EXPR_HAS_LOCATION (expr))
    5843                 :       30449 :         loc = EXPR_LOCATION (expr);
    5844                 :             :     }
    5845                 :     3756944 :   if (TREE_CODE (expr) != CALL_EXPR)
    5846                 :             :     return;
    5847                 :      338745 :   tree fn = CALL_EXPR_FN (expr);
    5848                 :      338745 :   if (!fn)
    5849                 :             :     return;
    5850                 :      338732 :   tree attr;
    5851                 :      338732 :   if (TREE_CODE (fn) == ADDR_EXPR
    5852                 :      338076 :       && TREE_CODE (TREE_OPERAND (fn, 0)) == FUNCTION_DECL
    5853                 :      676808 :       && (attr = lookup_attribute ("nodiscard",
    5854                 :      338076 :                                    DECL_ATTRIBUTES (TREE_OPERAND (fn, 0)))))
    5855                 :             :     {
    5856                 :           3 :       fn = TREE_OPERAND (fn, 0);
    5857                 :           3 :       tree args = TREE_VALUE (attr);
    5858                 :           3 :       if (args)
    5859                 :           1 :         args = TREE_VALUE (args);
    5860                 :           3 :       auto_diagnostic_group d;
    5861                 :           3 :       int warned;
    5862                 :           3 :       if (args)
    5863                 :           1 :         warned = warning_at (loc, OPT_Wunused_result,
    5864                 :             :                              "ignoring return value of %qD, declared with "
    5865                 :             :                              "attribute %<nodiscard%>: %E", fn, args);
    5866                 :             :       else
    5867                 :           2 :         warned = warning_at (loc, OPT_Wunused_result,
    5868                 :             :                              "ignoring return value of %qD, declared with "
    5869                 :             :                              "attribute %<nodiscard%>", fn);
    5870                 :           3 :       if (warned)
    5871                 :           3 :         inform (DECL_SOURCE_LOCATION (fn), "declared here");
    5872                 :           3 :     }
    5873                 :             :   else
    5874                 :             :     {
    5875                 :      338729 :       tree rettype = TREE_TYPE (TREE_TYPE (TREE_TYPE (fn)));
    5876                 :      338729 :       attr = lookup_attribute ("nodiscard", TYPE_ATTRIBUTES (rettype));
    5877                 :      338729 :       if (!attr)
    5878                 :      338717 :         return;
    5879                 :          12 :       tree args = TREE_VALUE (attr);
    5880                 :          12 :       if (args)
    5881                 :           5 :         args = TREE_VALUE (args);
    5882                 :          12 :       auto_diagnostic_group d;
    5883                 :          12 :       int warned;
    5884                 :          12 :       if (args)
    5885                 :           5 :         warned = warning_at (loc, OPT_Wunused_result,
    5886                 :             :                              "ignoring return value of type %qT, declared "
    5887                 :             :                              "with attribute %<nodiscard%>: %E",
    5888                 :             :                              rettype, args);
    5889                 :             :       else
    5890                 :           7 :         warned = warning_at (loc, OPT_Wunused_result,
    5891                 :             :                              "ignoring return value of type %qT, declared "
    5892                 :             :                              "with attribute %<nodiscard%>", rettype);
    5893                 :          12 :       if (warned)
    5894                 :             :         {
    5895                 :          12 :           if (TREE_CODE (fn) == ADDR_EXPR)
    5896                 :             :             {
    5897                 :          11 :               fn = TREE_OPERAND (fn, 0);
    5898                 :          11 :               if (TREE_CODE (fn) == FUNCTION_DECL)
    5899                 :          11 :                 inform (DECL_SOURCE_LOCATION (fn),
    5900                 :             :                         "in call to %qD, declared here", fn);
    5901                 :             :             }
    5902                 :             :         }
    5903                 :          12 :     }
    5904                 :             : }
    5905                 :             : 
    5906                 :             : /* Return a compound expression that performs two expressions and
    5907                 :             :    returns the value of the second of them.
    5908                 :             : 
    5909                 :             :    LOC is the location of the COMPOUND_EXPR.  */
    5910                 :             : 
    5911                 :             : tree
    5912                 :      101927 : build_compound_expr (location_t loc, tree expr1, tree expr2)
    5913                 :             : {
    5914                 :      101927 :   bool expr1_int_operands, expr2_int_operands;
    5915                 :      101927 :   tree eptype = NULL_TREE;
    5916                 :      101927 :   tree ret;
    5917                 :             : 
    5918                 :      101927 :   expr1_int_operands = EXPR_INT_CONST_OPERANDS (expr1);
    5919                 :         313 :   if (expr1_int_operands)
    5920                 :         313 :     expr1 = remove_c_maybe_const_expr (expr1);
    5921                 :      101927 :   expr2_int_operands = EXPR_INT_CONST_OPERANDS (expr2);
    5922                 :       59744 :   if (expr2_int_operands)
    5923                 :       59744 :     expr2 = remove_c_maybe_const_expr (expr2);
    5924                 :             : 
    5925                 :      101927 :   if (TREE_CODE (expr1) == EXCESS_PRECISION_EXPR)
    5926                 :           0 :     expr1 = TREE_OPERAND (expr1, 0);
    5927                 :      101927 :   if (TREE_CODE (expr2) == EXCESS_PRECISION_EXPR)
    5928                 :             :     {
    5929                 :           1 :       eptype = TREE_TYPE (expr2);
    5930                 :           1 :       expr2 = TREE_OPERAND (expr2, 0);
    5931                 :             :     }
    5932                 :             : 
    5933                 :      101927 :   if (!TREE_SIDE_EFFECTS (expr1))
    5934                 :             :     {
    5935                 :             :       /* The left-hand operand of a comma expression is like an expression
    5936                 :             :          statement: with -Wunused, we should warn if it doesn't have
    5937                 :             :          any side-effects, unless it was explicitly cast to (void).  */
    5938                 :        6757 :       if (warn_unused_value)
    5939                 :             :         {
    5940                 :        1257 :           if (VOID_TYPE_P (TREE_TYPE (expr1))
    5941                 :        1257 :               && CONVERT_EXPR_P (expr1))
    5942                 :             :             ; /* (void) a, b */
    5943                 :          14 :           else if (VOID_TYPE_P (TREE_TYPE (expr1))
    5944                 :           4 :                    && TREE_CODE (expr1) == COMPOUND_EXPR
    5945                 :          17 :                    && CONVERT_EXPR_P (TREE_OPERAND (expr1, 1)))
    5946                 :             :             ; /* (void) a, (void) b, c */
    5947                 :             :           else
    5948                 :          11 :             warning_at (loc, OPT_Wunused_value,
    5949                 :             :                         "left-hand operand of comma expression has no effect");
    5950                 :             :         }
    5951                 :             :     }
    5952                 :       95170 :   else if (TREE_CODE (expr1) == COMPOUND_EXPR
    5953                 :       12792 :            && warn_unused_value)
    5954                 :             :     {
    5955                 :             :       tree r = expr1;
    5956                 :             :       location_t cloc = loc;
    5957                 :        4215 :       while (TREE_CODE (r) == COMPOUND_EXPR)
    5958                 :             :         {
    5959                 :        2108 :           if (EXPR_HAS_LOCATION (r))
    5960                 :        2108 :             cloc = EXPR_LOCATION (r);
    5961                 :        2108 :           r = TREE_OPERAND (r, 1);
    5962                 :             :         }
    5963                 :        2107 :       if (!TREE_SIDE_EFFECTS (r)
    5964                 :           3 :           && !VOID_TYPE_P (TREE_TYPE (r))
    5965                 :        2110 :           && !CONVERT_EXPR_P (r))
    5966                 :           3 :         warning_at (cloc, OPT_Wunused_value,
    5967                 :             :                     "right-hand operand of comma expression has no effect");
    5968                 :             :     }
    5969                 :             : 
    5970                 :             :   /* With -Wunused, we should also warn if the left-hand operand does have
    5971                 :             :      side-effects, but computes a value which is not used.  For example, in
    5972                 :             :      `foo() + bar(), baz()' the result of the `+' operator is not used,
    5973                 :             :      so we should issue a warning.  */
    5974                 :       93063 :   else if (warn_unused_value)
    5975                 :       34841 :     warn_if_unused_value (expr1, loc);
    5976                 :             : 
    5977                 :      101927 :   maybe_warn_nodiscard (loc, expr1);
    5978                 :             : 
    5979                 :      101927 :   if (expr2 == error_mark_node)
    5980                 :             :     return error_mark_node;
    5981                 :             : 
    5982                 :      101914 :   ret = build2 (COMPOUND_EXPR, TREE_TYPE (expr2), expr1, expr2);
    5983                 :             : 
    5984                 :      101914 :   if (flag_isoc99
    5985                 :             :       && expr1_int_operands
    5986                 :      101458 :       && expr2_int_operands)
    5987                 :         140 :     ret = note_integer_operands (ret);
    5988                 :             : 
    5989                 :      101914 :   if (eptype)
    5990                 :           1 :     ret = build1 (EXCESS_PRECISION_EXPR, eptype, ret);
    5991                 :             : 
    5992                 :      101914 :   protected_set_expr_location (ret, loc);
    5993                 :      101914 :   return ret;
    5994                 :             : }
    5995                 :             : 
    5996                 :             : /* Issue -Wcast-qual warnings when appropriate.  TYPE is the type to
    5997                 :             :    which we are casting.  OTYPE is the type of the expression being
    5998                 :             :    cast.  Both TYPE and OTYPE are pointer types.  LOC is the location
    5999                 :             :    of the cast.  -Wcast-qual appeared on the command line.  Named
    6000                 :             :    address space qualifiers are not handled here, because they result
    6001                 :             :    in different warnings.  */
    6002                 :             : 
    6003                 :             : static void
    6004                 :       12517 : handle_warn_cast_qual (location_t loc, tree type, tree otype)
    6005                 :             : {
    6006                 :       12517 :   tree in_type = type;
    6007                 :       12517 :   tree in_otype = otype;
    6008                 :       12517 :   int added = 0;
    6009                 :       12517 :   int discarded = 0;
    6010                 :       12687 :   bool is_const;
    6011                 :             : 
    6012                 :             :   /* Check that the qualifiers on IN_TYPE are a superset of the
    6013                 :             :      qualifiers of IN_OTYPE.  The outermost level of POINTER_TYPE
    6014                 :             :      nodes is uninteresting and we stop as soon as we hit a
    6015                 :             :      non-POINTER_TYPE node on either type.  */
    6016                 :       12687 :   do
    6017                 :             :     {
    6018                 :       12687 :       in_otype = TREE_TYPE (in_otype);
    6019                 :       12687 :       in_type = TREE_TYPE (in_type);
    6020                 :             : 
    6021                 :             :       /* GNU C allows cv-qualified function types.  'const' means the
    6022                 :             :          function is very pure, 'volatile' means it can't return.  We
    6023                 :             :          need to warn when such qualifiers are added, not when they're
    6024                 :             :          taken away.  */
    6025                 :       12687 :       if (TREE_CODE (in_otype) == FUNCTION_TYPE
    6026                 :          62 :           && TREE_CODE (in_type) == FUNCTION_TYPE)
    6027                 :          18 :         added |= (TYPE_QUALS_NO_ADDR_SPACE (in_type)
    6028                 :          18 :                   & ~TYPE_QUALS_NO_ADDR_SPACE (in_otype));
    6029                 :             :       else
    6030                 :       12669 :         discarded |= (TYPE_QUALS_NO_ADDR_SPACE (in_otype)
    6031                 :       12669 :                       & ~TYPE_QUALS_NO_ADDR_SPACE (in_type));
    6032                 :             :     }
    6033                 :       12687 :   while (TREE_CODE (in_type) == POINTER_TYPE
    6034                 :       12687 :          && TREE_CODE (in_otype) == POINTER_TYPE);
    6035                 :             : 
    6036                 :       12517 :   if (added)
    6037                 :           2 :     warning_at (loc, OPT_Wcast_qual,
    6038                 :             :                 "cast adds %q#v qualifier to function type", added);
    6039                 :             : 
    6040                 :       12517 :   if (discarded)
    6041                 :             :     /* There are qualifiers present in IN_OTYPE that are not present
    6042                 :             :        in IN_TYPE.  */
    6043                 :        1067 :     warning_at (loc, OPT_Wcast_qual,
    6044                 :             :                 "cast discards %qv qualifier from pointer target type",
    6045                 :             :                 discarded);
    6046                 :             : 
    6047                 :       12517 :   if (added || discarded)
    6048                 :             :     return;
    6049                 :             : 
    6050                 :             :   /* A cast from **T to const **T is unsafe, because it can cause a
    6051                 :             :      const value to be changed with no additional warning.  We only
    6052                 :             :      issue this warning if T is the same on both sides, and we only
    6053                 :             :      issue the warning if there are the same number of pointers on
    6054                 :             :      both sides, as otherwise the cast is clearly unsafe anyhow.  A
    6055                 :             :      cast is unsafe when a qualifier is added at one level and const
    6056                 :             :      is not present at all outer levels.
    6057                 :             : 
    6058                 :             :      To issue this warning, we check at each level whether the cast
    6059                 :             :      adds new qualifiers not already seen.  We don't need to special
    6060                 :             :      case function types, as they won't have the same
    6061                 :             :      TYPE_MAIN_VARIANT.  */
    6062                 :             : 
    6063                 :       11448 :   if (TYPE_MAIN_VARIANT (in_type) != TYPE_MAIN_VARIANT (in_otype))
    6064                 :             :     return;
    6065                 :          51 :   if (TREE_CODE (TREE_TYPE (type)) != POINTER_TYPE)
    6066                 :             :     return;
    6067                 :             : 
    6068                 :          48 :   in_type = type;
    6069                 :          48 :   in_otype = otype;
    6070                 :          48 :   is_const = TYPE_READONLY (TREE_TYPE (in_type));
    6071                 :         130 :   do
    6072                 :             :     {
    6073                 :         130 :       in_type = TREE_TYPE (in_type);
    6074                 :         130 :       in_otype = TREE_TYPE (in_otype);
    6075                 :         130 :       if ((TYPE_QUALS (in_type) &~ TYPE_QUALS (in_otype)) != 0
    6076                 :         130 :           && !is_const)
    6077                 :             :         {
    6078                 :          27 :           warning_at (loc, OPT_Wcast_qual,
    6079                 :             :                       "to be safe all intermediate pointers in cast from "
    6080                 :             :                       "%qT to %qT must be %<const%> qualified",
    6081                 :             :                       otype, type);
    6082                 :          27 :           break;
    6083                 :             :         }
    6084                 :         103 :       if (is_const)
    6085                 :          72 :         is_const = TYPE_READONLY (in_type);
    6086                 :             :     }
    6087                 :         103 :   while (TREE_CODE (in_type) == POINTER_TYPE);
    6088                 :             : }
    6089                 :             : 
    6090                 :             : /* Heuristic check if two parameter types can be considered ABI-equivalent.  */
    6091                 :             : 
    6092                 :             : static bool
    6093                 :        4030 : c_safe_arg_type_equiv_p (tree t1, tree t2)
    6094                 :             : {
    6095                 :        4030 :   if (error_operand_p (t1) || error_operand_p (t2))
    6096                 :             :     return true;
    6097                 :             : 
    6098                 :        4029 :   t1 = TYPE_MAIN_VARIANT (t1);
    6099                 :        4029 :   t2 = TYPE_MAIN_VARIANT (t2);
    6100                 :             : 
    6101                 :        4029 :   if (TREE_CODE (t1) == POINTER_TYPE
    6102                 :          98 :       && TREE_CODE (t2) == POINTER_TYPE)
    6103                 :             :     return true;
    6104                 :             : 
    6105                 :             :   /* The signedness of the parameter matters only when an integral
    6106                 :             :      type smaller than int is promoted to int, otherwise only the
    6107                 :             :      precision of the parameter matters.
    6108                 :             :      This check should make sure that the callee does not see
    6109                 :             :      undefined values in argument registers.  */
    6110                 :        3953 :   if (INTEGRAL_TYPE_P (t1)
    6111                 :         861 :       && INTEGRAL_TYPE_P (t2)
    6112                 :         293 :       && TYPE_PRECISION (t1) == TYPE_PRECISION (t2)
    6113                 :        4066 :       && (TYPE_UNSIGNED (t1) == TYPE_UNSIGNED (t2)
    6114                 :           0 :           || !targetm.calls.promote_prototypes (NULL_TREE)
    6115                 :           0 :           || TYPE_PRECISION (t1) >= TYPE_PRECISION (integer_type_node)))
    6116                 :         113 :     return true;
    6117                 :             : 
    6118                 :        3840 :   return comptypes (t1, t2);
    6119                 :             : }
    6120                 :             : 
    6121                 :             : /* Check if a type cast between two function types can be considered safe.  */
    6122                 :             : 
    6123                 :             : static bool
    6124                 :        7411 : c_safe_function_type_cast_p (tree t1, tree t2)
    6125                 :             : {
    6126                 :        7411 :   if (TREE_TYPE (t1) == void_type_node &&
    6127                 :        5436 :       TYPE_ARG_TYPES (t1) == void_list_node)
    6128                 :             :     return true;
    6129                 :             : 
    6130                 :        6654 :   if (TREE_TYPE (t2) == void_type_node &&
    6131                 :        4534 :       TYPE_ARG_TYPES (t2) == void_list_node)
    6132                 :             :     return true;
    6133                 :             : 
    6134                 :        3822 :   if (!c_safe_arg_type_equiv_p (TREE_TYPE (t1), TREE_TYPE (t2)))
    6135                 :             :     return false;
    6136                 :             : 
    6137                 :        1815 :   for (t1 = TYPE_ARG_TYPES (t1), t2 = TYPE_ARG_TYPES (t2);
    6138                 :        1919 :        t1 && t2;
    6139                 :         104 :        t1 = TREE_CHAIN (t1), t2 = TREE_CHAIN (t2))
    6140                 :         208 :     if (!c_safe_arg_type_equiv_p (TREE_VALUE (t1), TREE_VALUE (t2)))
    6141                 :             :       return false;
    6142                 :             : 
    6143                 :             :   return true;
    6144                 :             : }
    6145                 :             : 
    6146                 :             : /* Build an expression representing a cast to type TYPE of expression EXPR.
    6147                 :             :    LOC is the location of the cast-- typically the open paren of the cast.  */
    6148                 :             : 
    6149                 :             : tree
    6150                 :   103940351 : build_c_cast (location_t loc, tree type, tree expr)
    6151                 :             : {
    6152                 :   103940351 :   tree value;
    6153                 :             : 
    6154                 :   103940351 :   bool int_operands = EXPR_INT_CONST_OPERANDS (expr);
    6155                 :             : 
    6156                 :   103940351 :   if (TREE_CODE (expr) == EXCESS_PRECISION_EXPR)
    6157                 :          66 :     expr = TREE_OPERAND (expr, 0);
    6158                 :             : 
    6159                 :   103940351 :   value = expr;
    6160                 :   103940351 :   if (int_operands)
    6161                 :     5776825 :     value = remove_c_maybe_const_expr (value);
    6162                 :             : 
    6163                 :   103940351 :   if (type == error_mark_node || expr == error_mark_node)
    6164                 :             :     return error_mark_node;
    6165                 :             : 
    6166                 :             :   /* The ObjC front-end uses TYPE_MAIN_VARIANT to tie together types differing
    6167                 :             :      only in <protocol> qualifications.  But when constructing cast expressions,
    6168                 :             :      the protocols do matter and must be kept around.  */
    6169                 :   103939330 :   if (objc_is_object_ptr (type) && objc_is_object_ptr (TREE_TYPE (expr)))
    6170                 :           0 :     return build1 (NOP_EXPR, type, expr);
    6171                 :             : 
    6172                 :   103939330 :   type = TYPE_MAIN_VARIANT (type);
    6173                 :             : 
    6174                 :   103939330 :   if (TREE_CODE (type) == ARRAY_TYPE)
    6175                 :             :     {
    6176                 :           6 :       error_at (loc, "cast specifies array type");
    6177                 :           6 :       return error_mark_node;
    6178                 :             :     }
    6179                 :             : 
    6180                 :   103939324 :   if (TREE_CODE (type) == FUNCTION_TYPE)
    6181                 :             :     {
    6182                 :           6 :       error_at (loc, "cast specifies function type");
    6183                 :           6 :       return error_mark_node;
    6184                 :             :     }
    6185                 :             : 
    6186                 :   103939318 :   if (!VOID_TYPE_P (type))
    6187                 :             :     {
    6188                 :   103897330 :       value = require_complete_type (loc, value);
    6189                 :   103897330 :       if (value == error_mark_node)
    6190                 :             :         return error_mark_node;
    6191                 :             :     }
    6192                 :             : 
    6193                 :   103939318 :   if (type == TYPE_MAIN_VARIANT (TREE_TYPE (value)))
    6194                 :             :     {
    6195                 :    15204076 :       if (RECORD_OR_UNION_TYPE_P (type)
    6196                 :    15204076 :           && pedwarn (loc, OPT_Wpedantic,
    6197                 :             :                       "ISO C forbids casting nonscalar to the same type"))
    6198                 :             :               ;
    6199                 :    15204072 :       else if (warn_useless_cast)
    6200                 :           7 :         warning_at (loc, OPT_Wuseless_cast,
    6201                 :             :                     "useless cast to type %qT", type);
    6202                 :             : 
    6203                 :             :       /* Convert to remove any qualifiers from VALUE's type.  */
    6204                 :    15204076 :       value = convert (type, value);
    6205                 :             :     }
    6206                 :    88735242 :   else if (TREE_CODE (type) == UNION_TYPE)
    6207                 :             :     {
    6208                 :         128 :       tree field;
    6209                 :             : 
    6210                 :         182 :       for (field = TYPE_FIELDS (type); field; field = DECL_CHAIN (field))
    6211                 :         176 :         if (TREE_TYPE (field) != error_mark_node
    6212                 :         351 :             && comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (field)),
    6213                 :         175 :                           TYPE_MAIN_VARIANT (TREE_TYPE (value))))
    6214                 :             :           break;
    6215                 :             : 
    6216                 :         128 :       if (field)
    6217                 :             :         {
    6218                 :         122 :           tree t;
    6219                 :         122 :           bool maybe_const = true;
    6220                 :             : 
    6221                 :         122 :           pedwarn (loc, OPT_Wpedantic, "ISO C forbids casts to union type");
    6222                 :         122 :           t = c_fully_fold (value, false, &maybe_const);
    6223                 :         122 :           t = build_constructor_single (type, field, t);
    6224                 :         122 :           if (!maybe_const)
    6225                 :           8 :             t = c_wrap_maybe_const (t, true);
    6226                 :         122 :           t = digest_init (loc, type, t,
    6227                 :             :                            NULL_TREE, false, false, false, true, false, false);
    6228                 :         122 :           TREE_CONSTANT (t) = TREE_CONSTANT (value);
    6229                 :         122 :           return t;
    6230                 :             :         }
    6231                 :           6 :       error_at (loc, "cast to union type from type not present in union");
    6232                 :           6 :       return error_mark_node;
    6233                 :             :     }
    6234                 :             :   else
    6235                 :             :     {
    6236                 :    88735114 :       tree otype, ovalue;
    6237                 :             : 
    6238                 :    88735114 :       if (type == void_type_node)
    6239                 :             :         {
    6240                 :       16032 :           tree t = build1 (CONVERT_EXPR, type, value);
    6241                 :       16032 :           SET_EXPR_LOCATION (t, loc);
    6242                 :       16032 :           return t;
    6243                 :             :         }
    6244                 :             : 
    6245                 :    88719082 :       otype = TREE_TYPE (value);
    6246                 :             : 
    6247                 :             :       /* Optionally warn about potentially worrisome casts.  */
    6248                 :    88719082 :       if (warn_cast_qual
    6249                 :      169703 :           && TREE_CODE (type) == POINTER_TYPE
    6250                 :       25354 :           && TREE_CODE (otype) == POINTER_TYPE)
    6251                 :       12517 :         handle_warn_cast_qual (loc, type, otype);
    6252                 :             : 
    6253                 :             :       /* Warn about conversions between pointers to disjoint
    6254                 :             :          address spaces.  */
    6255                 :    88719082 :       if (TREE_CODE (type) == POINTER_TYPE
    6256                 :     3043352 :           && TREE_CODE (otype) == POINTER_TYPE
    6257                 :    91485939 :           && !null_pointer_constant_p (value))
    6258                 :             :         {
    6259                 :     2716640 :           addr_space_t as_to = TYPE_ADDR_SPACE (TREE_TYPE (type));
    6260                 :     2716640 :           addr_space_t as_from = TYPE_ADDR_SPACE (TREE_TYPE (otype));
    6261                 :     2716640 :           addr_space_t as_common;
    6262                 :             : 
    6263                 :     2716640 :           if (!addr_space_superset (as_to, as_from, &as_common))
    6264                 :             :             {
    6265                 :           0 :               if (ADDR_SPACE_GENERIC_P (as_from))
    6266                 :           0 :                 warning_at (loc, 0, "cast to %qs address space pointer "
    6267                 :             :                             "from disjoint generic address space pointer",
    6268                 :             :                             c_addr_space_name (as_to));
    6269                 :             : 
    6270                 :           0 :               else if (ADDR_SPACE_GENERIC_P (as_to))
    6271                 :           0 :                 warning_at (loc, 0, "cast to generic address space pointer "
    6272                 :             :                             "from disjoint %qs address space pointer",
    6273                 :             :                             c_addr_space_name (as_from));
    6274                 :             : 
    6275                 :             :               else
    6276                 :           0 :                 warning_at (loc, 0, "cast to %qs address space pointer "
    6277                 :             :                             "from disjoint %qs address space pointer",
    6278                 :             :                             c_addr_space_name (as_to),
    6279                 :             :                             c_addr_space_name (as_from));
    6280                 :             :             }
    6281                 :             : 
    6282                 :             :           /* Warn of new allocations that are not big enough for the target
    6283                 :             :              type.  */
    6284                 :     2716640 :           if (warn_alloc_size && TREE_CODE (value) == CALL_EXPR)
    6285                 :         785 :             if (tree fndecl = get_callee_fndecl (value))
    6286                 :         781 :               if (DECL_IS_MALLOC (fndecl))
    6287                 :             :                 {
    6288                 :         509 :                   tree attrs = TYPE_ATTRIBUTES (TREE_TYPE (fndecl));
    6289                 :         509 :                   tree alloc_size = lookup_attribute ("alloc_size", attrs);
    6290                 :         509 :                   if (alloc_size)
    6291                 :         151 :                     warn_for_alloc_size (loc, TREE_TYPE (type), value,
    6292                 :             :                                          alloc_size);
    6293                 :             :                 }
    6294                 :             :         }
    6295                 :             : 
    6296                 :             :       /* Warn about possible alignment problems.  */
    6297                 :    88719082 :       if ((STRICT_ALIGNMENT || warn_cast_align == 2)
    6298                 :           7 :           && TREE_CODE (type) == POINTER_TYPE
    6299                 :           7 :           && TREE_CODE (otype) == POINTER_TYPE
    6300                 :           7 :           && TREE_CODE (TREE_TYPE (otype)) != VOID_TYPE
    6301                 :           7 :           && TREE_CODE (TREE_TYPE (otype)) != FUNCTION_TYPE
    6302                 :             :           /* Don't warn about opaque types, where the actual alignment
    6303                 :             :              restriction is unknown.  */
    6304                 :          12 :           && !(RECORD_OR_UNION_TYPE_P (TREE_TYPE (otype))
    6305                 :           5 :                && TYPE_MODE (TREE_TYPE (otype)) == VOIDmode)
    6306                 :    88719096 :           && min_align_of_type (TREE_TYPE (type))
    6307                 :           7 :              > min_align_of_type (TREE_TYPE (otype)))
    6308                 :           5 :         warning_at (loc, OPT_Wcast_align,
    6309                 :             :                     "cast increases required alignment of target type");
    6310                 :             : 
    6311                 :    88719082 :       if ((TREE_CODE (type) == INTEGER_TYPE
    6312                 :    88719082 :            || TREE_CODE (type) == BITINT_TYPE)
    6313                 :     5938067 :           && TREE_CODE (otype) == POINTER_TYPE
    6314                 :    88743751 :           && TYPE_PRECISION (type) != TYPE_PRECISION (otype))
    6315                 :             :       /* Unlike conversion of integers to pointers, where the
    6316                 :             :          warning is disabled for converting constants because
    6317                 :             :          of cases such as SIG_*, warn about converting constant
    6318                 :             :          pointers to integers. In some cases it may cause unwanted
    6319                 :             :          sign extension, and a warning is appropriate.  */
    6320                 :        1442 :         warning_at (loc, OPT_Wpointer_to_int_cast,
    6321                 :             :                     "cast from pointer to integer of different size");
    6322                 :             : 
    6323                 :    88719082 :       if (TREE_CODE (value) == CALL_EXPR
    6324                 :    28980209 :           && TREE_CODE (type) != TREE_CODE (otype))
    6325                 :        2270 :         warning_at (loc, OPT_Wbad_function_cast,
    6326                 :             :                     "cast from function call of type %qT "
    6327                 :             :                     "to non-matching type %qT", otype, type);
    6328                 :             : 
    6329                 :    88719082 :       if (TREE_CODE (type) == POINTER_TYPE
    6330                 :     3043352 :           && (TREE_CODE (otype) == INTEGER_TYPE
    6331                 :     3043352 :               || TREE_CODE (otype) == BITINT_TYPE)
    6332                 :      276445 :           && TYPE_PRECISION (type) != TYPE_PRECISION (otype)
    6333                 :             :           /* Don't warn about converting any constant.  */
    6334                 :    88960409 :           && !TREE_CONSTANT (value))
    6335                 :         407 :         warning_at (loc,
    6336                 :             :                     OPT_Wint_to_pointer_cast, "cast to pointer from integer "
    6337                 :             :                     "of different size");
    6338                 :             : 
    6339                 :    88719082 :       if (warn_strict_aliasing <= 2)
    6340                 :    81089640 :         strict_aliasing_warning (EXPR_LOCATION (value), type, expr);
    6341                 :             : 
    6342                 :             :       /* If pedantic, warn for conversions between function and object
    6343                 :             :          pointer types, except for converting a null pointer constant
    6344                 :             :          to function pointer type.  */
    6345                 :    88719082 :       if (pedantic
    6346                 :      190381 :           && TREE_CODE (type) == POINTER_TYPE
    6347                 :      113894 :           && TREE_CODE (otype) == POINTER_TYPE
    6348                 :        2234 :           && TREE_CODE (TREE_TYPE (otype)) == FUNCTION_TYPE
    6349                 :    88719103 :           && TREE_CODE (TREE_TYPE (type)) != FUNCTION_TYPE)
    6350                 :          18 :         pedwarn (loc, OPT_Wpedantic, "ISO C forbids "
    6351                 :             :                  "conversion of function pointer to object pointer type");
    6352                 :             : 
    6353                 :    88719082 :       if (pedantic
    6354                 :      190381 :           && TREE_CODE (type) == POINTER_TYPE
    6355                 :      113894 :           && TREE_CODE (otype) == POINTER_TYPE
    6356                 :        2234 :           && TREE_CODE (TREE_TYPE (type)) == FUNCTION_TYPE
    6357                 :          13 :           && TREE_CODE (TREE_TYPE (otype)) != FUNCTION_TYPE
    6358                 :    88719092 :           && !null_pointer_constant_p (value))
    6359                 :           4 :         pedwarn (loc, OPT_Wpedantic, "ISO C forbids "
    6360                 :             :                  "conversion of object pointer to function pointer type");
    6361                 :             : 
    6362                 :    88719082 :       if (TREE_CODE (type) == POINTER_TYPE
    6363                 :     3043352 :           && TREE_CODE (otype) == POINTER_TYPE
    6364                 :     2766857 :           && TREE_CODE (TREE_TYPE (type)) == FUNCTION_TYPE
    6365                 :        8455 :           && TREE_CODE (TREE_TYPE (otype)) == FUNCTION_TYPE
    6366                 :    88726493 :           && !c_safe_function_type_cast_p (TREE_TYPE (type),
    6367                 :        7411 :                                            TREE_TYPE (otype)))
    6368                 :        2111 :         warning_at (loc, OPT_Wcast_function_type,
    6369                 :             :                     "cast between incompatible function types"
    6370                 :             :                     " from %qT to %qT", otype, type);
    6371                 :             : 
    6372                 :    88719082 :       ovalue = value;
    6373                 :             :       /* If converting to boolean a value with integer operands that
    6374                 :             :          is not itself represented as an INTEGER_CST, the call below
    6375                 :             :          to note_integer_operands may insert a C_MAYBE_CONST_EXPR, but
    6376                 :             :          build_binary_op as called by c_common_truthvalue_conversion
    6377                 :             :          may also insert a C_MAYBE_CONST_EXPR to indicate that a
    6378                 :             :          subexpression has been fully folded.  To avoid nested
    6379                 :             :          C_MAYBE_CONST_EXPR, ensure that
    6380                 :             :          c_objc_common_truthvalue_conversion receives an argument
    6381                 :             :          properly marked as having integer operands in that case.  */
    6382                 :    88719082 :       if (int_operands
    6383                 :     5593806 :           && TREE_CODE (value) != INTEGER_CST
    6384                 :    88719124 :           && (TREE_CODE (type) == BOOLEAN_TYPE
    6385                 :          28 :               || (TREE_CODE (type) == ENUMERAL_TYPE
    6386                 :          14 :                   && ENUM_UNDERLYING_TYPE (type) != NULL_TREE
    6387                 :          14 :                   && TREE_CODE (ENUM_UNDERLYING_TYPE (type)) == BOOLEAN_TYPE)))
    6388                 :          28 :         value = note_integer_operands (value);
    6389                 :    88719082 :       value = convert (type, value);
    6390                 :             : 
    6391                 :             :       /* Ignore any integer overflow caused by the cast.  */
    6392                 :    88719082 :       if (TREE_CODE (value) == INTEGER_CST && !FLOAT_TYPE_P (otype))
    6393                 :             :         {
    6394                 :     5538411 :           if (TREE_OVERFLOW_P (ovalue))
    6395                 :             :             {
    6396                 :           9 :               if (!TREE_OVERFLOW (value))
    6397                 :             :                 {
    6398                 :             :                   /* Avoid clobbering a shared constant.  */
    6399                 :           0 :                   value = copy_node (value);
    6400                 :           0 :                   TREE_OVERFLOW (value) = TREE_OVERFLOW (ovalue);
    6401                 :             :                 }
    6402                 :             :             }
    6403                 :     5538402 :           else if (TREE_OVERFLOW (value))
    6404                 :             :             /* Reset VALUE's overflow flags, ensuring constant sharing.  */
    6405                 :        3085 :             value = wide_int_to_tree (TREE_TYPE (value), wi::to_wide (value));
    6406                 :             :         }
    6407                 :             :     }
    6408                 :             : 
    6409                 :             :   /* Don't let a cast be an lvalue.  */
    6410                 :   103923158 :   if (lvalue_p (value))
    6411                 :       87882 :     value = non_lvalue_loc (loc, value);
    6412                 :             : 
    6413                 :             :   /* Don't allow the results of casting to floating-point or complex
    6414                 :             :      types be confused with actual constants, or casts involving
    6415                 :             :      integer and pointer types other than direct integer-to-integer
    6416                 :             :      and integer-to-pointer be confused with integer constant
    6417                 :             :      expressions and null pointer constants.  */
    6418                 :   103923158 :   if (TREE_CODE (value) == REAL_CST
    6419                 :   103873402 :       || TREE_CODE (value) == COMPLEX_CST
    6420                 :   207773937 :       || (TREE_CODE (value) == INTEGER_CST
    6421                 :     5778146 :           && !((TREE_CODE (expr) == INTEGER_CST
    6422                 :     5708243 :                 && INTEGRAL_TYPE_P (TREE_TYPE (expr)))
    6423                 :       62497 :                || TREE_CODE (expr) == REAL_CST
    6424                 :             :                || TREE_CODE (expr) == COMPLEX_CST)))
    6425                 :      130552 :       value = build1 (NOP_EXPR, type, value);
    6426                 :             : 
    6427                 :             :   /* If the expression has integer operands and so can occur in an
    6428                 :             :      unevaluated part of an integer constant expression, ensure the
    6429                 :             :      return value reflects this.  */
    6430                 :   103923158 :   if (int_operands
    6431                 :     5764583 :       && INTEGRAL_TYPE_P (type)
    6432                 :     5389836 :       && value != error_mark_node
    6433                 :   109312993 :       && !EXPR_INT_CONST_OPERANDS (value))
    6434                 :          11 :     value = note_integer_operands (value);
    6435                 :             : 
    6436                 :   103923158 :   protected_set_expr_location (value, loc);
    6437                 :   103923158 :   return value;
    6438                 :             : }
    6439                 :             : 
    6440                 :             : /* Interpret a cast of expression EXPR to type TYPE.  LOC is the
    6441                 :             :    location of the open paren of the cast, or the position of the cast
    6442                 :             :    expr.  */
    6443                 :             : tree
    6444                 :   103940005 : c_cast_expr (location_t loc, struct c_type_name *type_name, tree expr)
    6445                 :             : {
    6446                 :   103940005 :   tree type;
    6447                 :   103940005 :   tree type_expr = NULL_TREE;
    6448                 :   103940005 :   bool type_expr_const = true;
    6449                 :   103940005 :   tree ret;
    6450                 :   103940005 :   int saved_wsp = warn_strict_prototypes;
    6451                 :             : 
    6452                 :             :   /* This avoids warnings about unprototyped casts on
    6453                 :             :      integers.  E.g. "#define SIG_DFL (void(*)())0".  */
    6454                 :   103940005 :   if (TREE_CODE (expr) == INTEGER_CST)
    6455                 :     5827286 :     warn_strict_prototypes = 0;
    6456                 :   103940005 :   type = groktypename (type_name, &type_expr, &type_expr_const);
    6457                 :   103940005 :   warn_strict_prototypes = saved_wsp;
    6458                 :             : 
    6459                 :      764490 :   if (TREE_CODE (expr) == ADDR_EXPR && !VOID_TYPE_P (type)
    6460                 :   104704258 :       && reject_gcc_builtin (expr))
    6461                 :           2 :     return error_mark_node;
    6462                 :             : 
    6463                 :   103940003 :   ret = build_c_cast (loc, type, expr);
    6464                 :   103940003 :   if (type_expr)
    6465                 :             :     {
    6466                 :         194 :       bool inner_expr_const = true;
    6467                 :         194 :       ret = c_fully_fold (ret, require_constant_value, &inner_expr_const);
    6468                 :         194 :       ret = build2 (C_MAYBE_CONST_EXPR, TREE_TYPE (ret), type_expr, ret);
    6469                 :         388 :       C_MAYBE_CONST_EXPR_NON_CONST (ret) = !(type_expr_const
    6470                 :         120 :                                              && inner_expr_const);
    6471                 :         194 :       SET_EXPR_LOCATION (ret, loc);
    6472                 :             :     }
    6473                 :             : 
    6474                 :   103940003 :   if (!EXPR_HAS_LOCATION (ret))
    6475                 :     5712129 :     protected_set_expr_location (ret, loc);
    6476                 :             : 
    6477                 :             :   /* C++ does not permits types to be defined in a cast, but it
    6478                 :             :      allows references to incomplete types.  */
    6479                 :   103940003 :   if (warn_cxx_compat && type_name->specs->typespec_kind == ctsk_tagdef)
    6480                 :           1 :     warning_at (loc, OPT_Wc___compat,
    6481                 :             :                 "defining a type in a cast is invalid in C++");
    6482                 :             : 
    6483                 :             :   return ret;
    6484                 :             : }
    6485                 :             : 
    6486                 :             : /* Build an assignment expression of lvalue LHS from value RHS.
    6487                 :             :    If LHS_ORIGTYPE is not NULL, it is the original type of LHS, which
    6488                 :             :    may differ from TREE_TYPE (LHS) for an enum bitfield.
    6489                 :             :    MODIFYCODE is the code for a binary operator that we use
    6490                 :             :    to combine the old value of LHS with RHS to get the new value.
    6491                 :             :    Or else MODIFYCODE is NOP_EXPR meaning do a simple assignment.
    6492                 :             :    If RHS_ORIGTYPE is not NULL_TREE, it is the original type of RHS,
    6493                 :             :    which may differ from TREE_TYPE (RHS) for an enum value.
    6494                 :             : 
    6495                 :             :    LOCATION is the location of the MODIFYCODE operator.
    6496                 :             :    RHS_LOC is the location of the RHS.  */
    6497                 :             : 
    6498                 :             : tree
    6499                 :     2793273 : build_modify_expr (location_t location, tree lhs, tree lhs_origtype,
    6500                 :             :                    enum tree_code modifycode,
    6501                 :             :                    location_t rhs_loc, tree rhs, tree rhs_origtype)
    6502                 :             : {
    6503                 :     2793273 :   tree result;
    6504                 :     2793273 :   tree newrhs;
    6505                 :     2793273 :   tree rhseval = NULL_TREE;
    6506                 :     2793273 :   tree lhstype = TREE_TYPE (lhs);
    6507                 :     2793273 :   tree olhstype = lhstype;
    6508                 :     2793273 :   bool npc;
    6509                 :     2793273 :   bool is_atomic_op;
    6510                 :             : 
    6511                 :             :   /* Types that aren't fully specified cannot be used in assignments.  */
    6512                 :     2793273 :   lhs = require_complete_type (location, lhs);
    6513                 :             : 
    6514                 :             :   /* Avoid duplicate error messages from operands that had errors.  */
    6515                 :     2793273 :   if (TREE_CODE (lhs) == ERROR_MARK || TREE_CODE (rhs) == ERROR_MARK)
    6516                 :         432 :     return error_mark_node;
    6517                 :             : 
    6518                 :             :   /* Ensure an error for assigning a non-lvalue array to an array in
    6519                 :             :      C90.  */
    6520                 :     2792841 :   if (TREE_CODE (lhstype) == ARRAY_TYPE)
    6521                 :             :     {
    6522                 :           1 :       error_at (location, "assignment to expression with array type");
    6523                 :           1 :       return error_mark_node;
    6524                 :             :     }
    6525                 :             : 
    6526                 :             :   /* For ObjC properties, defer this check.  */
    6527                 :     2792840 :   if (!objc_is_property_ref (lhs) && !lvalue_or_else (location, lhs, lv_assign))
    6528                 :          31 :     return error_mark_node;
    6529                 :             : 
    6530                 :     2792809 :   is_atomic_op = really_atomic_lvalue (lhs);
    6531                 :             : 
    6532                 :     2792809 :   newrhs = rhs;
    6533                 :             : 
    6534                 :     2792809 :   if (TREE_CODE (lhs) == C_MAYBE_CONST_EXPR)
    6535                 :             :     {
    6536                 :           2 :       tree inner = build_modify_expr (location, C_MAYBE_CONST_EXPR_EXPR (lhs),
    6537                 :             :                                       lhs_origtype, modifycode, rhs_loc, rhs,
    6538                 :             :                                       rhs_origtype);
    6539                 :           2 :       if (inner == error_mark_node)
    6540                 :             :         return error_mark_node;
    6541                 :           4 :       result = build2 (C_MAYBE_CONST_EXPR, TREE_TYPE (inner),
    6542                 :           2 :                        C_MAYBE_CONST_EXPR_PRE (lhs), inner);
    6543                 :           2 :       gcc_assert (!C_MAYBE_CONST_EXPR_INT_OPERANDS (lhs));
    6544                 :           2 :       C_MAYBE_CONST_EXPR_NON_CONST (result) = 1;
    6545                 :           2 :       protected_set_expr_location (result, location);
    6546                 :           2 :       return result;
    6547                 :             :     }
    6548                 :             : 
    6549                 :             :   /* If a binary op has been requested, combine the old LHS value with the RHS
    6550                 :             :      producing the value we should actually store into the LHS.  */
    6551                 :             : 
    6552                 :     2792807 :   if (modifycode != NOP_EXPR)
    6553                 :             :     {
    6554                 :      189339 :       lhs = c_fully_fold (lhs, false, NULL, true);
    6555                 :      189339 :       lhs = stabilize_reference (lhs);
    6556                 :             : 
    6557                 :             :       /* Construct the RHS for any non-atomic compound assignemnt. */
    6558                 :      189339 :       if (!is_atomic_op)
    6559                 :             :         {
    6560                 :             :           /* If in LHS op= RHS the RHS has side-effects, ensure they
    6561                 :             :              are preevaluated before the rest of the assignment expression's
    6562                 :             :              side-effects, because RHS could contain e.g. function calls
    6563                 :             :              that modify LHS.  */
    6564                 :      173873 :           if (TREE_SIDE_EFFECTS (rhs))
    6565                 :             :             {
    6566                 :        8532 :               if (TREE_CODE (rhs) == EXCESS_PRECISION_EXPR)
    6567                 :          28 :                 newrhs = save_expr (TREE_OPERAND (rhs, 0));
    6568                 :             :               else
    6569                 :        8504 :                 newrhs = save_expr (rhs);
    6570                 :        8532 :               rhseval = newrhs;
    6571                 :        8532 :               if (TREE_CODE (rhs) == EXCESS_PRECISION_EXPR)
    6572                 :          28 :                 newrhs = build1 (EXCESS_PRECISION_EXPR, TREE_TYPE (rhs),
    6573                 :             :                                  newrhs);
    6574                 :             :             }
    6575                 :      173873 :           newrhs = build_binary_op (location,
    6576                 :             :                                     modifycode, lhs, newrhs, true);
    6577                 :             : 
    6578                 :             :           /* The original type of the right hand side is no longer
    6579                 :             :              meaningful.  */
    6580                 :      173873 :           rhs_origtype = NULL_TREE;
    6581                 :             :         }
    6582                 :             :     }
    6583                 :             : 
    6584                 :     2792807 :   if (c_dialect_objc ())
    6585                 :             :     {
    6586                 :             :       /* Check if we are modifying an Objective-C property reference;
    6587                 :             :          if so, we need to generate setter calls.  */
    6588                 :           0 :       if (TREE_CODE (newrhs) == EXCESS_PRECISION_EXPR)
    6589                 :           0 :         result = objc_maybe_build_modify_expr (lhs, TREE_OPERAND (newrhs, 0));
    6590                 :             :       else
    6591                 :           0 :         result = objc_maybe_build_modify_expr (lhs, newrhs);
    6592                 :           0 :       if (result)
    6593                 :           0 :         goto return_result;
    6594                 :             : 
    6595                 :             :       /* Else, do the check that we postponed for Objective-C.  */
    6596                 :           0 :       if (!lvalue_or_else (location, lhs, lv_assign))
    6597                 :           0 :         return error_mark_node;
    6598                 :             :     }
    6599                 :             : 
    6600                 :             :   /* Give an error for storing in something that is 'const'.  */
    6601                 :             : 
    6602                 :     2792807 :   if (TYPE_READONLY (lhstype)
    6603                 :     2792807 :       || (RECORD_OR_UNION_TYPE_P (lhstype)
    6604                 :       25215 :           && C_TYPE_FIELDS_READONLY (lhstype)))
    6605                 :             :     {
    6606                 :          87 :       readonly_error (location, lhs, lv_assign);
    6607                 :          87 :       return error_mark_node;
    6608                 :             :     }
    6609                 :     2792720 :   else if (TREE_READONLY (lhs))
    6610                 :           2 :     readonly_warning (lhs, lv_assign);
    6611                 :             : 
    6612                 :             :   /* If storing into a structure or union member,
    6613                 :             :      it has probably been given type `int'.
    6614                 :             :      Compute the type that would go with
    6615                 :             :      the actual amount of storage the member occupies.  */
    6616                 :             : 
    6617                 :     2792720 :   if (TREE_CODE (lhs) == COMPONENT_REF
    6618                 :      238712 :       && (TREE_CODE (lhstype) == INTEGER_TYPE
    6619                 :      238712 :           || TREE_CODE (lhstype) == BOOLEAN_TYPE
    6620                 :      105523 :           || SCALAR_FLOAT_TYPE_P (lhstype)
    6621                 :       83797 :           || TREE_CODE (lhstype) == ENUMERAL_TYPE))
    6622                 :      161885 :     lhstype = TREE_TYPE (get_unwidened (lhs, 0));
    6623                 :             : 
    6624                 :             :   /* If storing in a field that is in actuality a short or narrower than one,
    6625                 :             :      we must store in the field in its actual type.  */
    6626                 :             : 
    6627                 :     2792720 :   if (lhstype != TREE_TYPE (lhs))
    6628                 :             :     {
    6629                 :           0 :       lhs = copy_node (lhs);
    6630                 :           0 :       TREE_TYPE (lhs) = lhstype;
    6631                 :             :     }
    6632                 :             : 
    6633                 :             :   /* Issue -Wc++-compat warnings about an assignment to an enum type
    6634                 :             :      when LHS does not have its original type.  This happens for,
    6635                 :             :      e.g., an enum bitfield in a struct.  */
    6636                 :     2792720 :   if (warn_cxx_compat
    6637                 :        2896 :       && lhs_origtype != NULL_TREE
    6638                 :        2896 :       && lhs_origtype != lhstype
    6639                 :           7 :       && TREE_CODE (lhs_origtype) == ENUMERAL_TYPE)
    6640                 :             :     {
    6641                 :           4 :       tree checktype = (rhs_origtype != NULL_TREE
    6642                 :           4 :                         ? rhs_origtype
    6643                 :           0 :                         : TREE_TYPE (rhs));
    6644                 :           4 :       if (checktype != error_mark_node
    6645                 :           4 :           && (TYPE_MAIN_VARIANT (checktype) != TYPE_MAIN_VARIANT (lhs_origtype)
    6646                 :           2 :               || (is_atomic_op && modifycode != NOP_EXPR)))
    6647                 :           2 :         warning_at (location, OPT_Wc___compat,
    6648                 :             :                     "enum conversion in assignment is invalid in C++");
    6649                 :             :     }
    6650                 :             : 
    6651                 :             :   /* Remove qualifiers.  */
    6652                 :     2792720 :   lhstype = build_qualified_type (lhstype, TYPE_UNQUALIFIED);
    6653                 :     2792720 :   olhstype = build_qualified_type (olhstype, TYPE_UNQUALIFIED);
    6654                 :             : 
    6655                 :             :   /* Convert new value to destination type.  Fold it first, then
    6656                 :             :      restore any excess precision information, for the sake of
    6657                 :             :      conversion warnings.  */
    6658                 :             : 
    6659                 :     2792720 :   if (!(is_atomic_op && modifycode != NOP_EXPR))
    6660                 :             :     {
    6661                 :     2777254 :       tree rhs_semantic_type = NULL_TREE;
    6662                 :     2777254 :       if (!c_in_omp_for)
    6663                 :             :         {
    6664                 :     2762042 :           if (TREE_CODE (newrhs) == EXCESS_PRECISION_EXPR)
    6665                 :             :             {
    6666                 :         453 :               rhs_semantic_type = TREE_TYPE (newrhs);
    6667                 :         453 :               newrhs = TREE_OPERAND (newrhs, 0);
    6668                 :             :             }
    6669                 :     2762042 :           npc = null_pointer_constant_p (newrhs);
    6670                 :     2762042 :           newrhs = c_fully_fold (newrhs, false, NULL);
    6671                 :     2762042 :           if (rhs_semantic_type)
    6672                 :         453 :             newrhs = build1 (EXCESS_PRECISION_EXPR, rhs_semantic_type, newrhs);
    6673                 :             :         }
    6674                 :             :       else
    6675                 :       15212 :         npc = null_pointer_constant_p (newrhs);
    6676                 :     2777254 :       newrhs = convert_for_assignment (location, rhs_loc, lhstype, newrhs,
    6677                 :             :                                        rhs_origtype, ic_assign, npc,
    6678                 :             :                                        NULL_TREE, NULL_TREE, 0);
    6679                 :     2777254 :       if (TREE_CODE (newrhs) == ERROR_MARK)
    6680                 :         147 :         return error_mark_node;
    6681                 :             :     }
    6682                 :             : 
    6683                 :             :   /* Emit ObjC write barrier, if necessary.  */
    6684                 :     2792573 :   if (c_dialect_objc () && flag_objc_gc)
    6685                 :             :     {
    6686                 :           0 :       result = objc_generate_write_barrier (lhs, modifycode, newrhs);
    6687                 :           0 :       if (result)
    6688                 :             :         {
    6689                 :           0 :           protected_set_expr_location (result, location);
    6690                 :           0 :           goto return_result;
    6691                 :             :         }
    6692                 :             :     }
    6693                 :             : 
    6694                 :             :   /* Scan operands.  */
    6695                 :             : 
    6696                 :     2792573 :   if (is_atomic_op)
    6697                 :       25839 :     result = build_atomic_assign (location, lhs, modifycode, newrhs, false);
    6698                 :             :   else
    6699                 :             :     {
    6700                 :     2766734 :       result = build2 (MODIFY_EXPR, lhstype, lhs, newrhs);
    6701                 :     2766734 :       TREE_SIDE_EFFECTS (result) = 1;
    6702                 :     2766734 :       protected_set_expr_location (result, location);
    6703                 :             :     }
    6704                 :             : 
    6705                 :             :   /* If we got the LHS in a different type for storing in,
    6706                 :             :      convert the result back to the nominal type of LHS
    6707                 :             :      so that the value we return always has the same type
    6708                 :             :      as the LHS argument.  */
    6709                 :             : 
    6710                 :     2792573 :   if (olhstype == TREE_TYPE (result))
    6711                 :     2792573 :     goto return_result;
    6712                 :             : 
    6713                 :           0 :   result = convert_for_assignment (location, rhs_loc, olhstype, result,
    6714                 :             :                                    rhs_origtype, ic_assign, false, NULL_TREE,
    6715                 :             :                                    NULL_TREE, 0);
    6716                 :           0 :   protected_set_expr_location (result, location);
    6717                 :             : 
    6718                 :     2792573 : return_result:
    6719                 :     2792573 :   if (rhseval)
    6720                 :        8532 :     result = build2 (COMPOUND_EXPR, TREE_TYPE (result), rhseval, result);
    6721                 :             :   return result;
    6722                 :             : }
    6723                 :             : 
    6724                 :             : /* Return whether STRUCT_TYPE has an anonymous field with type TYPE.
    6725                 :             :    This is used to implement -fplan9-extensions.  */
    6726                 :             : 
    6727                 :             : static bool
    6728                 :          10 : find_anonymous_field_with_type (tree struct_type, tree type)
    6729                 :             : {
    6730                 :          10 :   tree field;
    6731                 :          10 :   bool found;
    6732                 :             : 
    6733                 :          10 :   gcc_assert (RECORD_OR_UNION_TYPE_P (struct_type));
    6734                 :          10 :   found = false;
    6735                 :          10 :   for (field = TYPE_FIELDS (struct_type);
    6736                 :          20 :        field != NULL_TREE;
    6737                 :          10 :        field = TREE_CHAIN (field))
    6738                 :             :     {
    6739                 :          10 :       tree fieldtype = (TYPE_ATOMIC (TREE_TYPE (field))
    6740                 :          20 :                         ? c_build_qualified_type (TREE_TYPE (field),
    6741                 :             :                                                   TYPE_QUAL_ATOMIC)
    6742                 :          10 :                         : TYPE_MAIN_VARIANT (TREE_TYPE (field)));
    6743                 :          10 :       if (DECL_NAME (field) == NULL
    6744                 :          10 :           && comptypes (type, fieldtype))
    6745                 :             :         {
    6746                 :           4 :           if (found)
    6747                 :             :             return false;
    6748                 :             :           found = true;
    6749                 :             :         }
    6750                 :           6 :       else if (DECL_NAME (field) == NULL
    6751                 :           2 :                && RECORD_OR_UNION_TYPE_P (TREE_TYPE (field))
    6752                 :           8 :                && find_anonymous_field_with_type (TREE_TYPE (field), type))
    6753                 :             :         {
    6754                 :           0 :           if (found)
    6755                 :             :             return false;
    6756                 :             :           found = true;
    6757                 :             :         }
    6758                 :             :     }
    6759                 :             :   return found;
    6760                 :             : }
    6761                 :             : 
    6762                 :             : /* RHS is an expression whose type is pointer to struct.  If there is
    6763                 :             :    an anonymous field in RHS with type TYPE, then return a pointer to
    6764                 :             :    that field in RHS.  This is used with -fplan9-extensions.  This
    6765                 :             :    returns NULL if no conversion could be found.  */
    6766                 :             : 
    6767                 :             : static tree
    6768                 :          12 : convert_to_anonymous_field (location_t location, tree type, tree rhs)
    6769                 :             : {
    6770                 :          12 :   tree rhs_struct_type, lhs_main_type;
    6771                 :          12 :   tree field, found_field;
    6772                 :          12 :   bool found_sub_field;
    6773                 :          12 :   tree ret;
    6774                 :             : 
    6775                 :          12 :   gcc_assert (POINTER_TYPE_P (TREE_TYPE (rhs)));
    6776                 :          12 :   rhs_struct_type = TREE_TYPE (TREE_TYPE (rhs));
    6777                 :          12 :   gcc_assert (RECORD_OR_UNION_TYPE_P (rhs_struct_type));
    6778                 :             : 
    6779                 :          12 :   gcc_assert (POINTER_TYPE_P (type));
    6780                 :          12 :   lhs_main_type = (TYPE_ATOMIC (TREE_TYPE (type))
    6781                 :          24 :                    ? c_build_qualified_type (TREE_TYPE (type),
    6782                 :             :                                              TYPE_QUAL_ATOMIC)
    6783                 :          12 :                    : TYPE_MAIN_VARIANT (TREE_TYPE (type)));
    6784                 :             : 
    6785                 :          12 :   found_field = NULL_TREE;
    6786                 :          12 :   found_sub_field = false;
    6787                 :          12 :   for (field = TYPE_FIELDS (rhs_struct_type);
    6788                 :          44 :        field != NULL_TREE;
    6789                 :          32 :        field = TREE_CHAIN (field))
    6790                 :             :     {
    6791                 :          36 :       if (DECL_NAME (field) != NULL_TREE
    6792                 :          36 :           || !RECORD_OR_UNION_TYPE_P (TREE_TYPE (field)))
    6793                 :          16 :         continue;
    6794                 :          20 :       tree fieldtype = (TYPE_ATOMIC (TREE_TYPE (field))
    6795                 :          40 :                         ? c_build_qualified_type (TREE_TYPE (field),
    6796                 :             :                                                   TYPE_QUAL_ATOMIC)
    6797                 :          20 :                         : TYPE_MAIN_VARIANT (TREE_TYPE (field)));
    6798                 :          20 :       if (comptypes (lhs_main_type, fieldtype))
    6799                 :             :         {
    6800                 :          12 :           if (found_field != NULL_TREE)
    6801                 :             :             return NULL_TREE;
    6802                 :             :           found_field = field;
    6803                 :             :         }
    6804                 :           8 :       else if (find_anonymous_field_with_type (TREE_TYPE (field),
    6805                 :             :                                                lhs_main_type))
    6806                 :             :         {
    6807                 :           4 :           if (found_field != NULL_TREE)
    6808                 :             :             return NULL_TREE;
    6809                 :             :           found_field = field;
    6810                 :             :           found_sub_field = true;
    6811                 :             :         }
    6812                 :             :     }
    6813                 :             : 
    6814                 :           8 :   if (found_field == NULL_TREE)
    6815                 :             :     return NULL_TREE;
    6816                 :             : 
    6817                 :           8 :   ret = fold_build3_loc (location, COMPONENT_REF, TREE_TYPE (found_field),
    6818                 :             :                          build_fold_indirect_ref (rhs), found_field,
    6819                 :             :                          NULL_TREE);
    6820                 :           8 :   ret = build_fold_addr_expr_loc (location, ret);
    6821                 :             : 
    6822                 :           8 :   if (found_sub_field)
    6823                 :             :     {
    6824                 :           2 :       ret = convert_to_anonymous_field (location, type, ret);
    6825                 :           2 :       gcc_assert (ret != NULL_TREE);
    6826                 :             :     }
    6827                 :             : 
    6828                 :             :   return ret;
    6829                 :             : }
    6830                 :             : 
    6831                 :             : /* Issue an error message for a bad initializer component.
    6832                 :             :    GMSGID identifies the message.
    6833                 :             :    The component name is taken from the spelling stack.  */
    6834                 :             : 
    6835                 :             : static void ATTRIBUTE_GCC_DIAG (2,0)
    6836                 :         891 : error_init (location_t loc, const char *gmsgid, ...)
    6837                 :             : {
    6838                 :         891 :   char *ofwhat;
    6839                 :             : 
    6840                 :         891 :   auto_diagnostic_group d;
    6841                 :             : 
    6842                 :             :   /* The gmsgid may be a format string with %< and %>. */
    6843                 :         891 :   va_list ap;
    6844                 :         891 :   va_start (ap, gmsgid);
    6845                 :         891 :   bool warned = emit_diagnostic_valist (DK_ERROR, loc, -1, gmsgid, &ap);
    6846                 :         891 :   va_end (ap);
    6847                 :             : 
    6848                 :         891 :   ofwhat = print_spelling ((char *) alloca (spelling_length () + 1));
    6849                 :         891 :   if (*ofwhat && warned)
    6850                 :         205 :     inform (loc, "(near initialization for %qs)", ofwhat);
    6851                 :         891 : }
    6852                 :             : 
    6853                 :             : /* Used to implement pedwarn_init and permerror_init.  */
    6854                 :             : 
    6855                 :             : static void ATTRIBUTE_GCC_DIAG (3,0)
    6856                 :        2375 : pedwarn_permerror_init (location_t loc, int opt, const char *gmsgid,
    6857                 :             :                         va_list *ap, diagnostic_t kind)
    6858                 :             : {
    6859                 :             :   /* Use the location where a macro was expanded rather than where
    6860                 :             :      it was defined to make sure macros defined in system headers
    6861                 :             :      but used incorrectly elsewhere are diagnosed.  */
    6862                 :        2375 :   location_t exploc = expansion_point_location_if_in_system_header (loc);
    6863                 :        2375 :   auto_diagnostic_group d;
    6864                 :        2375 :   bool warned = emit_diagnostic_valist (kind, exploc, opt, gmsgid, ap);
    6865                 :        2375 :   char *ofwhat = print_spelling ((char *) alloca (spelling_length () + 1));
    6866                 :        2375 :   if (*ofwhat && warned)
    6867                 :        1460 :     inform (exploc, "(near initialization for %qs)", ofwhat);
    6868                 :        2375 : }
    6869                 :             : 
    6870                 :             : /* Issue a pedantic warning for a bad initializer component.  OPT is
    6871                 :             :    the option OPT_* (from options.h) controlling this warning or 0 if
    6872                 :             :    it is unconditionally given.  GMSGID identifies the message.  The
    6873                 :             :    component name is taken from the spelling stack.  */
    6874                 :             : 
    6875                 :             : static void ATTRIBUTE_GCC_DIAG (3,0)
    6876                 :        2051 : pedwarn_init (location_t loc, int opt, const char *gmsgid, ...)
    6877                 :             : {
    6878                 :        2051 :   va_list ap;
    6879                 :        2051 :   va_start (ap, gmsgid);
    6880                 :        2051 :   pedwarn_permerror_init (loc, opt, gmsgid, &ap, DK_PEDWARN);
    6881                 :        2051 :   va_end (ap);
    6882                 :        2051 : }
    6883                 :             : 
    6884                 :             : /* Like pedwarn_init, but issue a permerror.  */
    6885                 :             : 
    6886                 :             : static void ATTRIBUTE_GCC_DIAG (3,0)
    6887                 :         324 : permerror_init (location_t loc, int opt, const char *gmsgid, ...)
    6888                 :             : {
    6889                 :         324 :   va_list ap;
    6890                 :         324 :   va_start (ap, gmsgid);
    6891                 :         324 :   pedwarn_permerror_init (loc, opt, gmsgid, &ap, DK_PERMERROR);
    6892                 :         324 :   va_end (ap);
    6893                 :         324 : }
    6894                 :             : 
    6895                 :             : /* Issue a warning for a bad initializer component.
    6896                 :             : 
    6897                 :             :    OPT is the OPT_W* value corresponding to the warning option that
    6898                 :             :    controls this warning.  GMSGID identifies the message.  The
    6899                 :             :    component name is taken from the spelling stack.  */
    6900                 :             : 
    6901                 :             : static void
    6902                 :         115 : warning_init (location_t loc, int opt, const char *gmsgid)
    6903                 :             : {
    6904                 :         115 :   char *ofwhat;
    6905                 :         115 :   bool warned;
    6906                 :             : 
    6907                 :         115 :   auto_diagnostic_group d;
    6908                 :             : 
    6909                 :             :   /* Use the location where a macro was expanded rather than where
    6910                 :             :      it was defined to make sure macros defined in system headers
    6911                 :             :      but used incorrectly elsewhere are diagnosed.  */
    6912                 :         115 :   location_t exploc = expansion_point_location_if_in_system_header (loc);
    6913                 :             : 
    6914                 :             :   /* The gmsgid may be a format string with %< and %>. */
    6915                 :         115 :   warned = warning_at (exploc, opt, gmsgid);
    6916                 :         115 :   ofwhat = print_spelling ((char *) alloca (spelling_length () + 1));
    6917                 :         115 :   if (*ofwhat && warned)
    6918                 :          93 :     inform (exploc, "(near initialization for %qs)", ofwhat);
    6919                 :         115 : }
    6920                 :             : 
    6921                 :             : /* If TYPE is an array type and EXPR is a parenthesized string
    6922                 :             :    constant, warn if pedantic that EXPR is being used to initialize an
    6923                 :             :    object of type TYPE.  */
    6924                 :             : 
    6925                 :             : void
    6926                 :     7012929 : maybe_warn_string_init (location_t loc, tree type, struct c_expr expr)
    6927                 :             : {
    6928                 :     7012929 :   if (pedantic
    6929                 :       70124 :       && TREE_CODE (type) == ARRAY_TYPE
    6930                 :         978 :       && TREE_CODE (expr.value) == STRING_CST
    6931                 :         353 :       && expr.original_code != STRING_CST)
    6932                 :          13 :     pedwarn_init (loc, OPT_Wpedantic,
    6933                 :             :                   "array initialized from parenthesized string constant");
    6934                 :     7012929 : }
    6935                 :             : 
    6936                 :             : /* Attempt to locate the parameter with the given index within FNDECL,
    6937                 :             :    returning DECL_SOURCE_LOCATION (FNDECL) if it can't be found.  */
    6938                 :             : 
    6939                 :             : static location_t
    6940                 :         923 : get_fndecl_argument_location (tree fndecl, int argnum)
    6941                 :             : {
    6942                 :         923 :   int i;
    6943                 :         923 :   tree param;
    6944                 :             : 
    6945                 :             :   /* Locate param by index within DECL_ARGUMENTS (fndecl).  */
    6946                 :         923 :   for (i = 0, param = DECL_ARGUMENTS (fndecl);
    6947                 :         997 :        i < argnum && param;
    6948                 :          74 :        i++, param = TREE_CHAIN (param))
    6949                 :             :     ;
    6950                 :             : 
    6951                 :             :   /* If something went wrong (e.g. if we have a builtin and thus no arguments),
    6952                 :             :      return DECL_SOURCE_LOCATION (FNDECL).  */
    6953                 :         923 :   if (param == NULL)
    6954                 :         653 :     return DECL_SOURCE_LOCATION (fndecl);
    6955                 :             : 
    6956                 :         270 :   return DECL_SOURCE_LOCATION (param);
    6957                 :             : }
    6958                 :             : 
    6959                 :             : /* Issue a note about a mismatching argument for parameter PARMNUM
    6960                 :             :    to FUNDECL, for types EXPECTED_TYPE and ACTUAL_TYPE.
    6961                 :             :    Attempt to issue the note at the pertinent parameter of the decl;
    6962                 :             :    failing that issue it at the location of FUNDECL; failing that
    6963                 :             :    issue it at PLOC.  */
    6964                 :             : 
    6965                 :             : static void
    6966                 :        1045 : inform_for_arg (tree fundecl, location_t ploc, int parmnum,
    6967                 :             :                 tree expected_type, tree actual_type)
    6968                 :             : {
    6969                 :        1045 :   location_t loc;
    6970                 :        1045 :   if (fundecl && !DECL_IS_UNDECLARED_BUILTIN (fundecl))
    6971                 :         923 :     loc = get_fndecl_argument_location (fundecl, parmnum - 1);
    6972                 :             :   else
    6973                 :             :     loc = ploc;
    6974                 :             : 
    6975                 :        1045 :   inform (loc,
    6976                 :             :           "expected %qT but argument is of type %qT",
    6977                 :             :           expected_type, actual_type);
    6978                 :        1045 : }
    6979                 :             : 
    6980                 :             : /* Issue a warning when an argument of ARGTYPE is passed to a built-in
    6981                 :             :    function FUNDECL declared without prototype to parameter PARMNUM of
    6982                 :             :    PARMTYPE when ARGTYPE does not promote to PARMTYPE.  */
    6983                 :             : 
    6984                 :             : static void
    6985                 :         418 : maybe_warn_builtin_no_proto_arg (location_t loc, tree fundecl, int parmnum,
    6986                 :             :                                  tree parmtype, tree argtype)
    6987                 :             : {
    6988                 :         418 :   tree_code parmcode = TREE_CODE (parmtype);
    6989                 :         418 :   tree_code argcode = TREE_CODE (argtype);
    6990                 :         418 :   tree promoted = c_type_promotes_to (argtype);
    6991                 :             : 
    6992                 :             :   /* Avoid warning for enum arguments that promote to an integer type
    6993                 :             :      of the same size/mode.  */
    6994                 :         418 :   if (parmcode == INTEGER_TYPE
    6995                 :         418 :       && argcode == ENUMERAL_TYPE
    6996                 :         418 :       && TYPE_MODE (parmtype) == TYPE_MODE (argtype))
    6997                 :             :     return;
    6998                 :             : 
    6999                 :         417 :   if ((parmcode == argcode
    7000                 :         222 :        || (parmcode == INTEGER_TYPE
    7001                 :             :            && argcode == ENUMERAL_TYPE))
    7002                 :         418 :       && TYPE_MAIN_VARIANT (parmtype) == TYPE_MAIN_VARIANT (promoted))
    7003                 :             :     return;
    7004                 :             : 
    7005                 :             :   /* This diagnoses even signed/unsigned mismatches.  Those might be
    7006                 :             :      safe in many cases but GCC may emit suboptimal code for them so
    7007                 :             :      warning on those cases drives efficiency improvements.  */
    7008                 :         398 :   if (warning_at (loc, OPT_Wbuiltin_declaration_mismatch,
    7009                 :         398 :                   TYPE_MAIN_VARIANT (promoted) == argtype
    7010                 :             :                   ? G_("%qD argument %d type is %qT where %qT is expected "
    7011                 :             :                        "in a call to built-in function declared without "
    7012                 :             :                        "prototype")
    7013                 :             :                   : G_("%qD argument %d promotes to %qT where %qT is expected "
    7014                 :             :                        "in a call to built-in function declared without "
    7015                 :             :                        "prototype"),
    7016                 :             :                   fundecl, parmnum, promoted, parmtype))
    7017                 :         150 :     inform (DECL_SOURCE_LOCATION (fundecl),
    7018                 :             :             "built-in %qD declared here",
    7019                 :             :             fundecl);
    7020                 :             : }
    7021                 :             : 
    7022                 :             : /* Convert value RHS to type TYPE as preparation for an assignment to
    7023                 :             :    an lvalue of type TYPE.  If ORIGTYPE is not NULL_TREE, it is the
    7024                 :             :    original type of RHS; this differs from TREE_TYPE (RHS) for enum
    7025                 :             :    types.  NULL_POINTER_CONSTANT says whether RHS was a null pointer
    7026                 :             :    constant before any folding.
    7027                 :             :    The real work of conversion is done by `convert'.
    7028                 :             :    The purpose of this function is to generate error messages
    7029                 :             :    for assignments that are not allowed in C.
    7030                 :             :    ERRTYPE says whether it is argument passing, assignment,
    7031                 :             :    initialization or return.
    7032                 :             : 
    7033                 :             :    In the following example, '~' denotes where EXPR_LOC and '^' where
    7034                 :             :    LOCATION point to:
    7035                 :             : 
    7036                 :             :      f (var);      [ic_argpass]
    7037                 :             :      ^  ~~~
    7038                 :             :      x = var;      [ic_assign]
    7039                 :             :        ^ ~~~;
    7040                 :             :      int x = var;  [ic_init]
    7041                 :             :              ^^^
    7042                 :             :      return x;     [ic_return]
    7043                 :             :             ^
    7044                 :             : 
    7045                 :             :    FUNCTION is a tree for the function being called.
    7046                 :             :    PARMNUM is the number of the argument, for printing in error messages.
    7047                 :             :    WARNOPT may be set to a warning option to issue the corresponding warning
    7048                 :             :    rather than an error for invalid conversions.  Used for calls to built-in
    7049                 :             :    functions declared without a prototype.  */
    7050                 :             : 
    7051                 :             : static tree
    7052                 :   146695645 : convert_for_assignment (location_t location, location_t expr_loc, tree type,
    7053                 :             :                         tree rhs, tree origtype, enum impl_conv errtype,
    7054                 :             :                         bool null_pointer_constant, tree fundecl,
    7055                 :             :                         tree function, int parmnum, int warnopt /* = 0 */)
    7056                 :             : {
    7057                 :   146695645 :   enum tree_code codel = TREE_CODE (type);
    7058                 :   146695645 :   tree orig_rhs = rhs;
    7059                 :   146695645 :   tree rhstype;
    7060                 :   146695645 :   enum tree_code coder;
    7061                 :   146695645 :   tree rname = NULL_TREE;
    7062                 :   146695645 :   bool objc_ok = false;
    7063                 :             : 
    7064                 :             :   /* Use the expansion point location to handle cases such as user's
    7065                 :             :      function returning a wrong-type macro defined in a system header.  */
    7066                 :   146695645 :   location = expansion_point_location_if_in_system_header (location);
    7067                 :             : 
    7068                 :   146695645 :   if (errtype == ic_argpass)
    7069                 :             :     {
    7070                 :   110011822 :       tree selector;
    7071                 :             :       /* Change pointer to function to the function itself for
    7072                 :             :          diagnostics.  */
    7073                 :   110011822 :       if (TREE_CODE (function) == ADDR_EXPR
    7074                 :   110011822 :           && TREE_CODE (TREE_OPERAND (function, 0)) == FUNCTION_DECL)
    7075                 :           0 :         function = TREE_OPERAND (function, 0);
    7076                 :             : 
    7077                 :             :       /* Handle an ObjC selector specially for diagnostics.  */
    7078                 :   110011822 :       selector = objc_message_selector ();
    7079                 :   110011822 :       rname = function;
    7080                 :   110011822 :       if (selector && parmnum > 2)
    7081                 :             :         {
    7082                 :           0 :           rname = selector;
    7083                 :           0 :           parmnum -= 2;
    7084                 :             :         }
    7085                 :             :     }
    7086                 :             : 
    7087                 :             :   /* This macro is used to emit diagnostics to ensure that all format
    7088                 :             :      strings are complete sentences, visible to gettext and checked at
    7089                 :             :      compile time.  */
    7090                 :             : #define PEDWARN_FOR_ASSIGNMENT(LOCATION, PLOC, OPT, AR, AS, IN, RE)      \
    7091                 :             :   do {                                                                   \
    7092                 :             :     switch (errtype)                                                     \
    7093                 :             :       {                                                                  \
    7094                 :             :       case ic_argpass:                                                   \
    7095                 :             :         {                                                               \
    7096                 :             :           auto_diagnostic_group d;                                              \
    7097                 :             :           if (pedwarn (PLOC, OPT, AR, parmnum, rname))          \
    7098                 :             :             inform_for_arg (fundecl, (PLOC), parmnum, type, rhstype); \
    7099                 :             :         }                                                               \
    7100                 :             :         break;                                                           \
    7101                 :             :       case ic_assign:                                                    \
    7102                 :             :         pedwarn (LOCATION, OPT, AS);                                     \
    7103                 :             :         break;                                                           \
    7104                 :             :       case ic_init:                                                      \
    7105                 :             :       case ic_init_const:                                                \
    7106                 :             :         pedwarn_init (LOCATION, OPT, IN);                                \
    7107                 :             :         break;                                                           \
    7108                 :             :       case ic_return:                                                    \
    7109                 :             :         pedwarn (LOCATION, OPT, RE);                                     \
    7110                 :             :         break;                                                           \
    7111                 :             :       default:                                                           \
    7112                 :             :         gcc_unreachable ();                                              \
    7113                 :             :       }                                                                  \
    7114                 :             :   } while (0)
    7115                 :             : 
    7116                 :             :   /* This macro is used to emit diagnostics to ensure that all format
    7117                 :             :      strings are complete sentences, visible to gettext and checked at
    7118                 :             :      compile time.  It can be called with 'pedwarn' or 'warning_at'.  */
    7119                 :             : #define WARNING_FOR_QUALIFIERS(PEDWARN, LOCATION, PLOC, OPT, AR, AS, IN, RE, QUALS) \
    7120                 :             :   do {                                                                   \
    7121                 :             :     switch (errtype)                                                     \
    7122                 :             :       {                                                                  \
    7123                 :             :       case ic_argpass:                                                   \
    7124                 :             :         {                                                                \
    7125                 :             :           auto_diagnostic_group d;                                       \
    7126                 :             :           if (PEDWARN) {                                                 \
    7127                 :             :             if (pedwarn (PLOC, OPT, AR, parmnum, rname, QUALS))          \
    7128                 :             :               inform_for_arg (fundecl, (PLOC), parmnum, type, rhstype);  \
    7129                 :             :           } else {                                                       \
    7130                 :             :             if (warning_at (PLOC, OPT, AR, parmnum, rname, QUALS))       \
    7131                 :             :               inform_for_arg (fundecl, (PLOC), parmnum, type, rhstype);  \
    7132                 :             :           }                                                              \
    7133                 :             :         }                                                                \
    7134                 :             :         break;                                                           \
    7135                 :             :       case ic_assign:                                                    \
    7136                 :             :         if (PEDWARN)                                                     \
    7137                 :             :           pedwarn (LOCATION, OPT, AS, QUALS);                            \
    7138                 :             :         else                                                             \
    7139                 :             :           warning_at (LOCATION, OPT, AS, QUALS);                         \
    7140                 :             :         break;                                                           \
    7141                 :             :       case ic_init:                                                      \
    7142                 :             :       case ic_init_const:                                                \
    7143                 :             :         if (PEDWARN)                                                     \
    7144                 :             :           pedwarn (LOCATION, OPT, IN, QUALS);                            \
    7145                 :             :         else                                                             \
    7146                 :             :           warning_at (LOCATION, OPT, IN, QUALS);                         \
    7147                 :             :         break;                                                           \
    7148                 :             :       case ic_return:                                                    \
    7149                 :             :         if (PEDWARN)                                                     \
    7150                 :             :           pedwarn (LOCATION, OPT, RE, QUALS);                            \
    7151                 :             :         else                                                             \
    7152                 :             :           warning_at (LOCATION, OPT, RE, QUALS);                         \
    7153                 :             :         break;                                                           \
    7154                 :             :       default:                                                           \
    7155                 :             :         gcc_unreachable ();                                              \
    7156                 :             :       }                                                                  \
    7157                 :             :   } while (0)
    7158                 :             : 
    7159                 :             :   /* This macro is used to emit diagnostics to ensure that all format
    7160                 :             :      strings are complete sentences, visible to gettext and checked at
    7161                 :             :      compile time.  It is the same as PEDWARN_FOR_ASSIGNMENT but with an
    7162                 :             :      extra parameter to enumerate qualifiers.  */
    7163                 :             : #define PEDWARN_FOR_QUALIFIERS(LOCATION, PLOC, OPT, AR, AS, IN, RE, QUALS) \
    7164                 :             :    WARNING_FOR_QUALIFIERS (true, LOCATION, PLOC, OPT, AR, AS, IN, RE, QUALS)
    7165                 :             : 
    7166                 :             : 
    7167                 :   146695645 :   if (TREE_CODE (rhs) == EXCESS_PRECISION_EXPR)
    7168                 :        1312 :     rhs = TREE_OPERAND (rhs, 0);
    7169                 :             : 
    7170                 :   146695645 :   rhstype = TREE_TYPE (rhs);
    7171                 :   146695645 :   coder = TREE_CODE (rhstype);
    7172                 :             : 
    7173                 :   146695645 :   if (coder == ERROR_MARK)
    7174                 :         340 :     return error_mark_node;
    7175                 :             : 
    7176                 :   146695305 :   if (c_dialect_objc ())
    7177                 :             :     {
    7178                 :           0 :       int parmno;
    7179                 :             : 
    7180                 :           0 :       switch (errtype)
    7181                 :             :         {
    7182                 :             :         case ic_return:
    7183                 :             :           parmno = 0;
    7184                 :             :           break;
    7185                 :             : 
    7186                 :             :         case ic_assign:
    7187                 :             :           parmno = -1;
    7188                 :             :           break;
    7189                 :             : 
    7190                 :             :         case ic_init:
    7191                 :             :         case ic_init_const:
    7192                 :             :           parmno = -2;
    7193                 :             :           break;
    7194                 :             : 
    7195                 :             :         default:
    7196                 :           0 :           parmno = parmnum;
    7197                 :             :           break;
    7198                 :             :         }
    7199                 :             : 
    7200                 :           0 :       objc_ok = objc_compare_types (type, rhstype, parmno, rname);
    7201                 :             :     }
    7202                 :             : 
    7203                 :   146695305 :   if (warn_cxx_compat)
    7204                 :             :     {
    7205                 :       22087 :       tree checktype = origtype != NULL_TREE ? origtype : rhstype;
    7206                 :       22087 :       if (checktype != error_mark_node
    7207                 :       22087 :           && TREE_CODE (type) == ENUMERAL_TYPE
    7208                 :       22193 :           && TYPE_MAIN_VARIANT (checktype) != TYPE_MAIN_VARIANT (type))
    7209                 :          45 :         switch (errtype)
    7210                 :             :           {
    7211                 :           8 :           case ic_argpass:
    7212                 :           8 :             if (pedwarn (expr_loc, OPT_Wc___compat, "enum conversion when "
    7213                 :             :                          "passing argument %d of %qE is invalid in C++",
    7214                 :             :                          parmnum, rname))
    7215                 :          16 :               inform ((fundecl && !DECL_IS_UNDECLARED_BUILTIN (fundecl))
    7216                 :           8 :                       ? DECL_SOURCE_LOCATION (fundecl) : expr_loc,
    7217                 :             :                       "expected %qT but argument is of type %qT",
    7218                 :             :                       type, rhstype);
    7219                 :             :             break;
    7220                 :          10 :           case ic_assign:
    7221                 :          10 :             pedwarn (location, OPT_Wc___compat, "enum conversion from %qT to "
    7222                 :             :                      "%qT in assignment is invalid in C++", rhstype, type);
    7223                 :          10 :             break;
    7224                 :          18 :           case ic_init:
    7225                 :          18 :           case ic_init_const:
    7226                 :          18 :             pedwarn_init (location, OPT_Wc___compat, "enum conversion from "
    7227                 :             :                           "%qT to %qT in initialization is invalid in C++",
    7228                 :             :                           rhstype, type);
    7229                 :          18 :             break;
    7230                 :           9 :           case ic_return:
    7231                 :           9 :             pedwarn (location, OPT_Wc___compat, "enum conversion from %qT to "
    7232                 :             :                      "%qT in return is invalid in C++", rhstype, type);
    7233                 :           9 :             break;
    7234                 :           0 :           default:
    7235                 :           0 :             gcc_unreachable ();
    7236                 :             :           }
    7237                 :             :     }
    7238                 :             : 
    7239                 :   146695305 :   if (warn_enum_conversion)
    7240                 :             :     {
    7241                 :    13292180 :       tree checktype = origtype != NULL_TREE ? origtype : rhstype;
    7242                 :    13292180 :       if (checktype != error_mark_node
    7243                 :    13292180 :           && TREE_CODE (checktype) == ENUMERAL_TYPE
    7244                 :       12693 :           && TREE_CODE (type) == ENUMERAL_TYPE
    7245                 :    13300144 :           && !comptypes (TYPE_MAIN_VARIANT (checktype), TYPE_MAIN_VARIANT (type)))
    7246                 :             :        {
    7247                 :           3 :           gcc_rich_location loc (location);
    7248                 :           3 :           warning_at (&loc, OPT_Wenum_conversion,
    7249                 :             :                       "implicit conversion from %qT to %qT",
    7250                 :             :                       checktype, type);
    7251                 :           3 :        }
    7252                 :             :     }
    7253                 :             : 
    7254                 :   146695305 :   if (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (rhstype))
    7255                 :             :     {
    7256                 :   130251900 :       warn_for_address_of_packed_member (type, orig_rhs);
    7257                 :   130251900 :       return rhs;
    7258                 :             :     }
    7259                 :             : 
    7260                 :    16443405 :   if (coder == VOID_TYPE)
    7261                 :             :     {
    7262                 :             :       /* Except for passing an argument to an unprototyped function,
    7263                 :             :          this is a constraint violation.  When passing an argument to
    7264                 :             :          an unprototyped function, it is compile-time undefined;
    7265                 :             :          making it a constraint in that case was rejected in
    7266                 :             :          DR#252.  */
    7267                 :          41 :       const char msg[] = "void value not ignored as it ought to be";
    7268                 :          41 :       if (warnopt)
    7269                 :           0 :         warning_at (location, warnopt, msg);
    7270                 :             :       else
    7271                 :          41 :         error_at (location, msg);
    7272                 :          41 :       return error_mark_node;
    7273                 :             :     }
    7274                 :    16443364 :   rhs = require_complete_type (location, rhs);
    7275                 :    16443364 :   if (rhs == error_mark_node)
    7276                 :             :     return error_mark_node;
    7277                 :             : 
    7278                 :    16443364 :   if (coder == POINTER_TYPE && reject_gcc_builtin (rhs))
    7279                 :           6 :     return error_mark_node;
    7280                 :             : 
    7281                 :             :   /* A non-reference type can convert to a reference.  This handles
    7282                 :             :      va_start, va_copy and possibly port built-ins.  */
    7283                 :    16443358 :   if (codel == REFERENCE_TYPE && coder != REFERENCE_TYPE)
    7284                 :             :     {
    7285                 :         270 :       if (!lvalue_p (rhs))
    7286                 :             :         {
    7287                 :           0 :           const char msg[] = "cannot pass rvalue to reference parameter";
    7288                 :           0 :           if (warnopt)
    7289                 :           0 :             warning_at (location, warnopt, msg);
    7290                 :             :           else
    7291                 :           0 :             error_at (location, msg);
    7292                 :           0 :           return error_mark_node;
    7293                 :             :         }
    7294                 :         270 :       if (!c_mark_addressable (rhs))
    7295                 :           0 :         return error_mark_node;
    7296                 :         270 :       rhs = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (rhs)), rhs);
    7297                 :         270 :       SET_EXPR_LOCATION (rhs, location);
    7298                 :             : 
    7299                 :         270 :       rhs = convert_for_assignment (location, expr_loc,
    7300                 :         270 :                                     build_pointer_type (TREE_TYPE (type)),
    7301                 :             :                                     rhs, origtype, errtype,
    7302                 :             :                                     null_pointer_constant, fundecl, function,
    7303                 :             :                                     parmnum, warnopt);
    7304                 :         270 :       if (rhs == error_mark_node)
    7305                 :             :         return error_mark_node;
    7306                 :             : 
    7307                 :         270 :       rhs = build1 (NOP_EXPR, type, rhs);
    7308                 :         270 :       SET_EXPR_LOCATION (rhs, location);
    7309                 :         270 :       return rhs;
    7310                 :             :     }
    7311                 :             :   /* Some types can interconvert without explicit casts.  */
    7312                 :    16443088 :   else if (codel == VECTOR_TYPE && coder == VECTOR_TYPE
    7313                 :    16443088 :            && vector_types_convertible_p (type, TREE_TYPE (rhs), true))
    7314                 :     7113757 :     return convert (type, rhs);
    7315                 :             :   /* Arithmetic types all interconvert, and enum is treated like int.  */
    7316                 :     9329331 :   else if ((codel == INTEGER_TYPE || codel == REAL_TYPE
    7317                 :     2125049 :             || codel == FIXED_POINT_TYPE
    7318                 :     2125049 :             || codel == ENUMERAL_TYPE || codel == COMPLEX_TYPE
    7319                 :     2043890 :             || codel == BOOLEAN_TYPE || codel == BITINT_TYPE)
    7320                 :     7382834 :            && (coder == INTEGER_TYPE || coder == REAL_TYPE
    7321                 :       78753 :                || coder == FIXED_POINT_TYPE
    7322                 :       78753 :                || coder == ENUMERAL_TYPE || coder == COMPLEX_TYPE
    7323                 :       36953 :                || coder == BOOLEAN_TYPE || coder == BITINT_TYPE))
    7324                 :             :     {
    7325                 :     7381730 :       if (warnopt && errtype == ic_argpass)
    7326                 :         418 :         maybe_warn_builtin_no_proto_arg (expr_loc, fundecl, parmnum, type,
    7327                 :             :                                          rhstype);
    7328                 :             : 
    7329                 :     7381730 :       bool save = in_late_binary_op;
    7330                 :     7344315 :       if (C_BOOLEAN_TYPE_P (type) || codel == COMPLEX_TYPE
    7331                 :    14677306 :           || (coder == REAL_TYPE
    7332                 :      254496 :               && (codel == INTEGER_TYPE || codel == ENUMERAL_TYPE)
    7333                 :       24045 :               && sanitize_flags_p (SANITIZE_FLOAT_CAST)))
    7334                 :       92898 :         in_late_binary_op = true;
    7335                 :    10677768 :       tree ret = convert_and_check (expr_loc != UNKNOWN_LOCATION
    7336                 :             :                                     ? expr_loc : location, type, orig_rhs,
    7337                 :             :                                     errtype == ic_init_const);
    7338                 :     7381730 :       in_late_binary_op = save;
    7339                 :     7381730 :       return ret;
    7340                 :             :     }
    7341                 :             : 
    7342                 :             :   /* Aggregates in different TUs might need conversion.  */
    7343                 :     1947601 :   if ((codel == RECORD_TYPE || codel == UNION_TYPE)
    7344                 :          91 :       && codel == coder
    7345                 :     1947614 :       && comptypes (TYPE_MAIN_VARIANT (type), TYPE_MAIN_VARIANT (rhstype)))
    7346                 :           4 :     return convert_and_check (expr_loc != UNKNOWN_LOCATION
    7347                 :           4 :                               ? expr_loc : location, type, rhs);
    7348                 :             : 
    7349                 :             :   /* Conversion to a transparent union or record from its member types.
    7350                 :             :      This applies only to function arguments.  */
    7351                 :     1947597 :   if (((codel == UNION_TYPE || codel == RECORD_TYPE)
    7352                 :          87 :       && TYPE_TRANSPARENT_AGGR (type))
    7353                 :     1947635 :       && errtype == ic_argpass)
    7354                 :             :     {
    7355                 :          38 :       tree memb, marginal_memb = NULL_TREE;
    7356                 :             : 
    7357                 :          48 :       for (memb = TYPE_FIELDS (type); memb ; memb = DECL_CHAIN (memb))
    7358                 :             :         {
    7359                 :          48 :           tree memb_type = TREE_TYPE (memb);
    7360                 :             : 
    7361                 :          48 :           if (comptypes (TYPE_MAIN_VARIANT (memb_type),
    7362                 :          48 :                          TYPE_MAIN_VARIANT (rhstype)))
    7363                 :             :             break;
    7364                 :             : 
    7365                 :          26 :           if (TREE_CODE (memb_type) != POINTER_TYPE)
    7366                 :           0 :             continue;
    7367                 :             : 
    7368                 :          26 :           if (coder == POINTER_TYPE)
    7369                 :             :             {
    7370                 :          26 :               tree ttl = TREE_TYPE (memb_type);
    7371                 :          26 :               tree ttr = TREE_TYPE (rhstype);
    7372                 :             : 
    7373                 :             :               /* Any non-function converts to a [const][volatile] void *
    7374                 :             :                  and vice versa; otherwise, targets must be the same.
    7375                 :             :                  Meanwhile, the lhs target must have all the qualifiers of
    7376                 :             :                  the rhs.  */
    7377                 :           0 :               if ((VOID_TYPE_P (ttl) && !TYPE_ATOMIC (ttl))
    7378                 :          26 :                   || (VOID_TYPE_P (ttr) && !TYPE_ATOMIC (ttr))
    7379                 :          45 :                   || comp_target_types (location, memb_type, rhstype))
    7380                 :             :                 {
    7381                 :          16 :                   int lquals = TYPE_QUALS (ttl) & ~TYPE_QUAL_ATOMIC;
    7382                 :          16 :                   int rquals = TYPE_QUALS (ttr) & ~TYPE_QUAL_ATOMIC;
    7383                 :             :                   /* If this type won't generate any warnings, use it.  */
    7384                 :          16 :                   if (lquals == rquals
    7385                 :          16 :                       || ((TREE_CODE (ttr) == FUNCTION_TYPE
    7386                 :           0 :                            && TREE_CODE (ttl) == FUNCTION_TYPE)
    7387                 :           0 :                           ? ((lquals | rquals) == rquals)
    7388                 :          16 :                           : ((lquals | rquals) == lquals)))
    7389                 :             :                     break;
    7390                 :             : 
    7391                 :             :                   /* Keep looking for a better type, but remember this one.  */
    7392                 :           0 :                   if (!marginal_memb)
    7393                 :          10 :                     marginal_memb = memb;
    7394                 :             :                 }
    7395                 :             :             }
    7396                 :             : 
    7397                 :             :           /* Can convert integer zero to any pointer type.  */
    7398                 :          10 :           if (null_pointer_constant)
    7399                 :             :             {
    7400                 :           0 :               rhs = null_pointer_node;
    7401                 :           0 :               break;
    7402                 :             :             }
    7403                 :             :         }
    7404                 :             : 
    7405                 :          38 :       if (memb || marginal_memb)
    7406                 :             :         {
    7407                 :          38 :           if (!memb)
    7408                 :             :             {
    7409                 :             :               /* We have only a marginally acceptable member type;
    7410                 :             :                  it needs a warning.  */
    7411                 :           0 :               tree ttl = TREE_TYPE (TREE_TYPE (marginal_memb));
    7412                 :           0 :               tree ttr = TREE_TYPE (rhstype);
    7413                 :             : 
    7414                 :             :               /* Const and volatile mean something different for function
    7415                 :             :                  types, so the usual warnings are not appropriate.  */
    7416                 :           0 :               if (TREE_CODE (ttr) == FUNCTION_TYPE
    7417                 :           0 :                   && TREE_CODE (ttl) == FUNCTION_TYPE)
    7418                 :             :                 {
    7419                 :             :                   /* Because const and volatile on functions are
    7420                 :             :                      restrictions that say the function will not do
    7421                 :             :                      certain things, it is okay to use a const or volatile
    7422                 :             :                      function where an ordinary one is wanted, but not
    7423                 :             :                      vice-versa.  */
    7424                 :           0 :                   if (TYPE_QUALS_NO_ADDR_SPACE (ttl)
    7425                 :           0 :                       & ~TYPE_QUALS_NO_ADDR_SPACE (ttr))
    7426                 :           0 :                     PEDWARN_FOR_QUALIFIERS (location, expr_loc,
    7427                 :             :                                             OPT_Wdiscarded_qualifiers,
    7428                 :             :                                             G_("passing argument %d of %qE "
    7429                 :             :                                                "makes %q#v qualified function "
    7430                 :             :                                                "pointer from unqualified"),
    7431                 :             :                                             G_("assignment makes %q#v qualified "
    7432                 :             :                                                "function pointer from "
    7433                 :             :                                                "unqualified"),
    7434                 :             :                                             G_("initialization makes %q#v qualified "
    7435                 :             :                                                "function pointer from "
    7436                 :             :                                                "unqualified"),
    7437                 :             :                                             G_("return makes %q#v qualified function "
    7438                 :             :                                                "pointer from unqualified"),
    7439                 :             :                                             TYPE_QUALS (ttl) & ~TYPE_QUALS (ttr));
    7440                 :             :                 }
    7441                 :           0 :               else if (TYPE_QUALS_NO_ADDR_SPACE (ttr)
    7442                 :           0 :                        & ~TYPE_QUALS_NO_ADDR_SPACE (ttl))
    7443                 :           0 :                 PEDWARN_FOR_QUALIFIERS (location, expr_loc,
    7444                 :             :                                         OPT_Wdiscarded_qualifiers,
    7445                 :             :                                         G_("passing argument %d of %qE discards "
    7446                 :             :                                            "%qv qualifier from pointer target type"),
    7447                 :             :                                         G_("assignment discards %qv qualifier "
    7448                 :             :                                            "from pointer target type"),
    7449                 :             :                                         G_("initialization discards %qv qualifier "
    7450                 :             :                                            "from pointer target type"),
    7451                 :             :                                         G_("return discards %qv qualifier from "
    7452                 :             :                                            "pointer target type"),
    7453                 :             :                                         TYPE_QUALS (ttr) & ~TYPE_QUALS (ttl));
    7454                 :             : 
    7455                 :             :               memb = marginal_memb;
    7456                 :             :             }
    7457                 :             : 
    7458                 :          38 :           if (!fundecl || !DECL_IN_SYSTEM_HEADER (fundecl))
    7459                 :          30 :             pedwarn (location, OPT_Wpedantic,
    7460                 :             :                      "ISO C prohibits argument conversion to union type");
    7461                 :             : 
    7462                 :          38 :           rhs = fold_convert_loc (location, TREE_TYPE (memb), rhs);
    7463                 :          38 :           return build_constructor_single (type, memb, rhs);
    7464                 :             :         }
    7465                 :             :     }
    7466                 :             : 
    7467                 :             :   /* Conversions among pointers */
    7468                 :     1947559 :   else if ((codel == POINTER_TYPE || codel == REFERENCE_TYPE)
    7469                 :     1946308 :            && (coder == codel))
    7470                 :             :     {
    7471                 :             :       /* If RHS refers to a built-in declared without a prototype
    7472                 :             :          BLTIN is the declaration of the built-in with a prototype
    7473                 :             :          and RHSTYPE is set to the actual type of the built-in.  */
    7474                 :     1885109 :       tree bltin;
    7475                 :     1885109 :       rhstype = type_or_builtin_type (rhs, &bltin);
    7476                 :             : 
    7477                 :     1885109 :       tree ttl = TREE_TYPE (type);
    7478                 :     1885109 :       tree ttr = TREE_TYPE (rhstype);
    7479                 :     1885109 :       tree mvl = ttl;
    7480                 :     1885109 :       tree mvr = ttr;
    7481                 :     1885109 :       bool is_opaque_pointer;
    7482                 :     1885109 :       bool target_cmp = false;   /* Cache comp_target_types () result.  */
    7483                 :     1885109 :       addr_space_t asl;
    7484                 :     1885109 :       addr_space_t asr;
    7485                 :             : 
    7486                 :     1885109 :       if (TREE_CODE (mvl) != ARRAY_TYPE)
    7487                 :     1884382 :         mvl = (TYPE_ATOMIC (mvl)
    7488                 :     3768669 :                ? c_build_qualified_type (TYPE_MAIN_VARIANT (mvl),
    7489                 :             :                                          TYPE_QUAL_ATOMIC)
    7490                 :     1884287 :                : TYPE_MAIN_VARIANT (mvl));
    7491                 :     1885109 :       if (TREE_CODE (mvr) != ARRAY_TYPE)
    7492                 :     1883037 :         mvr = (TYPE_ATOMIC (mvr)
    7493                 :     3751019 :                ? c_build_qualified_type (TYPE_MAIN_VARIANT (mvr),
    7494                 :             :                                          TYPE_QUAL_ATOMIC)
    7495                 :     1867982 :                : TYPE_MAIN_VARIANT (mvr));
    7496                 :             :       /* Opaque pointers are treated like void pointers.  */
    7497                 :     1885109 :       is_opaque_pointer = vector_targets_convertible_p (ttl, ttr);
    7498                 :             : 
    7499                 :             :       /* The Plan 9 compiler permits a pointer to a struct to be
    7500                 :             :          automatically converted into a pointer to an anonymous field
    7501                 :             :          within the struct.  */
    7502                 :     1885109 :       if (flag_plan9_extensions
    7503                 :          10 :           && RECORD_OR_UNION_TYPE_P (mvl)
    7504                 :          10 :           && RECORD_OR_UNION_TYPE_P (mvr)
    7505                 :          10 :           && mvl != mvr)
    7506                 :             :         {
    7507                 :          10 :           tree new_rhs = convert_to_anonymous_field (location, type, rhs);
    7508                 :          10 :           if (new_rhs != NULL_TREE)
    7509                 :             :             {
    7510                 :           6 :               rhs = new_rhs;
    7511                 :           6 :               rhstype = TREE_TYPE (rhs);
    7512                 :           6 :               coder = TREE_CODE (rhstype);
    7513                 :           6 :               ttr = TREE_TYPE (rhstype);
    7514                 :           6 :               mvr = TYPE_MAIN_VARIANT (ttr);
    7515                 :             :             }
    7516                 :             :         }
    7517                 :             : 
    7518                 :             :       /* C++ does not allow the implicit conversion void* -> T*.  However,
    7519                 :             :          for the purpose of reducing the number of false positives, we
    7520                 :             :          tolerate the special case of
    7521                 :             : 
    7522                 :             :                 int *p = NULL;
    7523                 :             : 
    7524                 :             :          where NULL is typically defined in C to be '(void *) 0'.  */
    7525                 :     1885109 :       if (VOID_TYPE_P (ttr) && rhs != null_pointer_node && !VOID_TYPE_P (ttl))
    7526                 :       24721 :         warning_at (errtype == ic_argpass ? expr_loc : location,
    7527                 :             :                     OPT_Wc___compat,
    7528                 :             :                     "request for implicit conversion "
    7529                 :             :                     "from %qT to %qT not permitted in C++", rhstype, type);
    7530                 :             : 
    7531                 :             :       /* Warn of new allocations that are not big enough for the target
    7532                 :             :          type.  */
    7533                 :     1885109 :       if (warn_alloc_size && TREE_CODE (rhs) == CALL_EXPR)
    7534                 :        4759 :         if (tree fndecl = get_callee_fndecl (rhs))
    7535                 :        4759 :           if (DECL_IS_MALLOC (fndecl))
    7536                 :             :             {
    7537                 :        3928 :               tree attrs = TYPE_ATTRIBUTES (TREE_TYPE (fndecl));
    7538                 :        3928 :               tree alloc_size = lookup_attribute ("alloc_size", attrs);
    7539                 :        3928 :               if (alloc_size)
    7540                 :         435 :                 warn_for_alloc_size (location, ttl, rhs, alloc_size);
    7541                 :             :             }
    7542                 :             : 
    7543                 :             :       /* See if the pointers point to incompatible address spaces.  */
    7544                 :     1885109 :       asl = TYPE_ADDR_SPACE (ttl);
    7545                 :     1885109 :       asr = TYPE_ADDR_SPACE (ttr);
    7546                 :     1885109 :       if (!null_pointer_constant_p (rhs)
    7547                 :     1885109 :           && asr != asl && !targetm.addr_space.subset_p (asr, asl))
    7548                 :             :         {
    7549                 :           3 :           auto_diagnostic_group d;
    7550                 :           3 :           bool diagnosed = true;
    7551                 :           3 :           switch (errtype)
    7552                 :             :             {
    7553                 :           1 :             case ic_argpass:
    7554                 :           1 :               {
    7555                 :           1 :                 const char msg[] = G_("passing argument %d of %qE from "
    7556                 :             :                                       "pointer to non-enclosed address space");
    7557                 :           1 :                 if (warnopt)
    7558                 :           0 :                   diagnosed
    7559                 :           0 :                     = warning_at (expr_loc, warnopt, msg, parmnum, rname);
    7560                 :             :                 else
    7561                 :           1 :                   error_at (expr_loc, msg, parmnum, rname);
    7562                 :           0 :               break;
    7563                 :             :               }
    7564                 :           0 :             case ic_assign:
    7565                 :           0 :               {
    7566                 :           0 :                 const char msg[] = G_("assignment from pointer to "
    7567                 :             :                                       "non-enclosed address space");
    7568                 :           0 :                 if (warnopt)
    7569                 :           0 :                   diagnosed = warning_at (location, warnopt, msg);
    7570                 :             :                 else
    7571                 :           0 :                   error_at (location, msg);
    7572                 :           0 :                 break;
    7573                 :             :               }
    7574                 :           0 :             case ic_init:
    7575                 :           0 :             case ic_init_const:
    7576                 :           0 :               {
    7577                 :           0 :                 const char msg[] = G_("initialization from pointer to "
    7578                 :             :                                       "non-enclosed address space");
    7579                 :           0 :                 if (warnopt)
    7580                 :           0 :                   diagnosed = warning_at (location, warnopt, msg);
    7581                 :             :                 else
    7582                 :           0 :                   error_at (location, msg);
    7583                 :           0 :                 break;
    7584                 :             :               }
    7585                 :           2 :             case ic_return:
    7586                 :           2 :               {
    7587                 :           2 :                 const char msg[] = G_("return from pointer to "
    7588                 :             :                                       "non-enclosed address space");
    7589                 :           2 :                 if (warnopt)
    7590                 :           0 :                   diagnosed = warning_at (location, warnopt, msg);
    7591                 :             :                 else
    7592                 :           2 :                   error_at (location, msg);
    7593                 :           0 :                 break;
    7594                 :             :               }
    7595                 :           0 :             default:
    7596                 :           0 :               gcc_unreachable ();
    7597                 :             :             }
    7598                 :           3 :           if (diagnosed)
    7599                 :             :             {
    7600                 :           3 :               if (errtype == ic_argpass)
    7601                 :           1 :                 inform_for_arg (fundecl, expr_loc, parmnum, type, rhstype);
    7602                 :             :               else
    7603                 :           2 :                 inform (location, "expected %qT but pointer is of type %qT",
    7604                 :             :                         type, rhstype);
    7605                 :             :             }
    7606                 :           3 :           return error_mark_node;
    7607                 :           3 :         }
    7608                 :             : 
    7609                 :             :       /* Check if the right-hand side has a format attribute but the
    7610                 :             :          left-hand side doesn't.  */
    7611                 :     1885106 :       if (warn_suggest_attribute_format
    7612                 :     1885106 :           && check_missing_format_attribute (type, rhstype))
    7613                 :             :         {
    7614                 :          16 :           switch (errtype)
    7615                 :             :           {
    7616                 :           4 :           case ic_argpass:
    7617                 :           4 :             warning_at (expr_loc, OPT_Wsuggest_attribute_format,
    7618                 :             :                         "argument %d of %qE might be "
    7619                 :             :                         "a candidate for a format attribute",
    7620                 :             :                         parmnum, rname);
    7621                 :           4 :             break;
    7622                 :           4 :           case ic_assign:
    7623                 :           4 :             warning_at (location, OPT_Wsuggest_attribute_format,
    7624                 :             :                         "assignment left-hand side might be "
    7625                 :             :                         "a candidate for a format attribute");
    7626                 :           4 :             break;
    7627                 :           4 :           case ic_init:
    7628                 :           4 :           case ic_init_const:
    7629                 :           4 :             warning_at (location, OPT_Wsuggest_attribute_format,
    7630                 :             :                         "initialization left-hand side might be "
    7631                 :             :                         "a candidate for a format attribute");
    7632                 :           4 :             break;
    7633                 :           4 :           case ic_return:
    7634                 :           4 :             warning_at (location, OPT_Wsuggest_attribute_format,
    7635                 :             :                         "return type might be "
    7636                 :             :                         "a candidate for a format attribute");
    7637                 :           4 :             break;
    7638                 :           0 :           default:
    7639                 :           0 :             gcc_unreachable ();
    7640                 :             :           }
    7641                 :             :         }
    7642                 :             : 
    7643                 :             :       /* See if the pointers point to incompatible scalar storage orders.  */
    7644                 :     1885106 :       if (warn_scalar_storage_order
    7645                 :     1882190 :           && !null_pointer_constant_p (rhs)
    7646                 :     5586216 :           && (AGGREGATE_TYPE_P (ttl) && TYPE_REVERSE_STORAGE_ORDER (ttl))
    7647                 :     1850555 :              != (AGGREGATE_TYPE_P (ttr) && TYPE_REVERSE_STORAGE_ORDER (ttr)))
    7648                 :             :         {
    7649                 :          18 :           tree t;
    7650                 :             : 
    7651                 :          18 :           switch (errtype)
    7652                 :             :           {
    7653                 :          11 :           case ic_argpass:
    7654                 :             :             /* Do not warn for built-in functions, for example memcpy, since we
    7655                 :             :                control how they behave and they can be useful in this area.  */
    7656                 :          11 :             if (TREE_CODE (rname) != FUNCTION_DECL
    7657                 :          11 :                 || !fndecl_built_in_p (rname))
    7658                 :           1 :               warning_at (location, OPT_Wscalar_storage_order,
    7659                 :             :                           "passing argument %d of %qE from incompatible "
    7660                 :             :                           "scalar storage order", parmnum, rname);
    7661                 :             :             break;
    7662                 :           3 :           case ic_assign:
    7663                 :             :             /* Do not warn if the RHS is a call to a function that returns a
    7664                 :             :                pointer that is not an alias.  */
    7665                 :           3 :             if (TREE_CODE (rhs) != CALL_EXPR
    7666                 :           2 :                 || (t = get_callee_fndecl (rhs)) == NULL_TREE
    7667                 :           5 :                 || !DECL_IS_MALLOC (t))
    7668                 :           1 :               warning_at (location, OPT_Wscalar_storage_order,
    7669                 :             :                           "assignment to %qT from pointer type %qT with "
    7670                 :             :                           "incompatible scalar storage order", type, rhstype);
    7671                 :             :             break;
    7672                 :           3 :           case ic_init:
    7673                 :           3 :           case ic_init_const:
    7674                 :             :             /* Likewise.  */
    7675                 :           3 :             if (TREE_CODE (rhs) != CALL_EXPR
    7676                 :           2 :                 || (t = get_callee_fndecl (rhs)) == NULL_TREE
    7677                 :           5 :                 || !DECL_IS_MALLOC (t))
    7678                 :           1 :               warning_at (location, OPT_Wscalar_storage_order,
    7679                 :             :                           "initialization of %qT from pointer type %qT with "
    7680                 :             :                           "incompatible scalar storage order", type, rhstype);
    7681                 :             :             break;
    7682                 :           1 :           case ic_return:
    7683                 :           1 :             warning_at (location, OPT_Wscalar_storage_order,
    7684                 :             :                         "returning %qT from pointer type with incompatible "
    7685                 :             :                         "scalar storage order %qT", rhstype, type);
    7686                 :           1 :             break;
    7687                 :           0 :           default:
    7688                 :           0 :             gcc_unreachable ();
    7689                 :             :           }
    7690                 :             :         }
    7691                 :             : 
    7692                 :             :       /* Any non-function converts to a [const][volatile] void *
    7693                 :             :          and vice versa; otherwise, targets must be the same.
    7694                 :             :          Meanwhile, the lhs target must have all the qualifiers of the rhs.  */
    7695                 :      433260 :       if ((VOID_TYPE_P (ttl) && !TYPE_ATOMIC (ttl))
    7696                 :     1451847 :           || (VOID_TYPE_P (ttr) && !TYPE_ATOMIC (ttr))
    7697                 :     1407143 :           || (target_cmp = comp_target_types (location, type, rhstype))
    7698                 :        1976 :           || is_opaque_pointer
    7699                 :     1889058 :           || ((c_common_unsigned_type (mvl)
    7700                 :        1976 :                == c_common_unsigned_type (mvr))
    7701                 :        2430 :               && (c_common_signed_type (mvl)
    7702                 :        1215 :                   == c_common_signed_type (mvr))
    7703                 :        1200 :               && TYPE_ATOMIC (mvl) == TYPE_ATOMIC (mvr)))
    7704                 :             :         {
    7705                 :             :           /* Warn about loss of qualifers from pointers to arrays with
    7706                 :             :              qualifiers on the element type. */
    7707                 :     1884322 :           if (TREE_CODE (ttr) == ARRAY_TYPE)
    7708                 :             :             {
    7709                 :        2021 :               ttr = strip_array_types (ttr);
    7710                 :        2021 :               ttl = strip_array_types (ttl);
    7711                 :             : 
    7712                 :        2021 :               if (TYPE_QUALS_NO_ADDR_SPACE_NO_ATOMIC (ttr)
    7713                 :        2021 :                   & ~TYPE_QUALS_NO_ADDR_SPACE_NO_ATOMIC (ttl))
    7714                 :         115 :                 WARNING_FOR_QUALIFIERS (flag_isoc23,
    7715                 :             :                                         location, expr_loc,
    7716                 :             :                                         OPT_Wdiscarded_array_qualifiers,
    7717                 :             :                                         G_("passing argument %d of %qE discards "
    7718                 :             :                                            "%qv qualifier from pointer target type"),
    7719                 :             :                                         G_("assignment discards %qv qualifier "
    7720                 :             :                                            "from pointer target type"),
    7721                 :             :                                         G_("initialization discards %qv qualifier "
    7722                 :             :                                            "from pointer target type"),
    7723                 :             :                                         G_("return discards %qv qualifier from "
    7724                 :             :                                            "pointer target type"),
    7725                 :             :                                         TYPE_QUALS (ttr) & ~TYPE_QUALS (ttl));
    7726                 :             :             }
    7727                 :     1882301 :           else if (pedantic
    7728                 :      137288 :               && ((VOID_TYPE_P (ttl) && TREE_CODE (ttr) == FUNCTION_TYPE)
    7729                 :      137268 :                   ||
    7730                 :             :                   (VOID_TYPE_P (ttr)
    7731                 :        2942 :                    && !null_pointer_constant
    7732                 :         178 :                    && TREE_CODE (ttl) == FUNCTION_TYPE)))
    7733                 :          34 :             PEDWARN_FOR_ASSIGNMENT (location, expr_loc, OPT_Wpedantic,
    7734                 :             :                                     G_("ISO C forbids passing argument %d of "
    7735                 :             :                                        "%qE between function pointer "
    7736                 :             :                                        "and %<void *%>"),
    7737                 :             :                                     G_("ISO C forbids assignment between "
    7738                 :             :                                        "function pointer and %<void *%>"),
    7739                 :             :                                     G_("ISO C forbids initialization between "
    7740                 :             :                                        "function pointer and %<void *%>"),
    7741                 :             :                                     G_("ISO C forbids return between function "
    7742                 :             :                                        "pointer and %<void *%>"));
    7743                 :             :           /* Const and volatile mean something different for function types,
    7744                 :             :              so the usual warnings are not appropriate.  */
    7745                 :     1882267 :           else if (TREE_CODE (ttr) != FUNCTION_TYPE
    7746                 :     1847167 :                    && TREE_CODE (ttl) != FUNCTION_TYPE)
    7747                 :             :             {
    7748                 :             :                /* Assignments between atomic and non-atomic objects are OK.  */
    7749                 :     1846550 :                bool warn_quals_ped = TYPE_QUALS_NO_ADDR_SPACE_NO_ATOMIC (ttr)
    7750                 :     1846550 :                                      & ~TYPE_QUALS_NO_ADDR_SPACE_NO_ATOMIC (ttl);
    7751                 :     1846550 :                bool warn_quals = TYPE_QUALS_NO_ADDR_SPACE_NO_ATOMIC (ttr)
    7752                 :     1846550 :                                  & ~TYPE_QUALS_NO_ADDR_SPACE_NO_ATOMIC (strip_array_types (ttl));
    7753                 :             : 
    7754                 :             :               /* Don't warn about loss of qualifier for conversions from
    7755                 :             :                  qualified void* to pointers to arrays with corresponding
    7756                 :             :                  qualifier on the element type (except for pedantic before C23). */
    7757                 :     1846550 :               if (warn_quals || (warn_quals_ped && pedantic && !flag_isoc23))
    7758                 :         697 :                 PEDWARN_FOR_QUALIFIERS (location, expr_loc,
    7759                 :             :                                         OPT_Wdiscarded_qualifiers,
    7760                 :             :                                         G_("passing argument %d of %qE discards "
    7761                 :             :                                            "%qv qualifier from pointer target type"),
    7762                 :             :                                         G_("assignment discards %qv qualifier "
    7763                 :             :                                            "from pointer target type"),
    7764                 :             :                                         G_("initialization discards %qv qualifier "
    7765                 :             :                                            "from pointer target type"),
    7766                 :             :                                         G_("return discards %qv qualifier from "
    7767                 :             :                                            "pointer target type"),
    7768                 :             :                                         TYPE_QUALS (ttr) & ~TYPE_QUALS (ttl));
    7769                 :          11 :               else if (warn_quals_ped)
    7770                 :          11 :                 pedwarn_c11 (location, OPT_Wc11_c23_compat,
    7771                 :             :                              "array with qualifier on the element is not qualified before C23");
    7772                 :             : 
    7773                 :             :               /* If this is not a case of ignoring a mismatch in signedness,
    7774                 :             :                  no warning.  */
    7775                 :     1845842 :               else if (VOID_TYPE_P (ttl) || VOID_TYPE_P (ttr)
    7776                 :     1399570 :                        || target_cmp)
    7777                 :             :                 ;
    7778                 :             :               /* If there is a mismatch, do warn.  */
    7779                 :        1192 :               else if (warn_pointer_sign)
    7780                 :          82 :                 switch (errtype)
    7781                 :             :                   {
    7782                 :          33 :                   case ic_argpass:
    7783                 :          33 :                     {
    7784                 :          33 :                       auto_diagnostic_group d;
    7785                 :          33 :                       range_label_for_type_mismatch rhs_label (rhstype, type);
    7786                 :          33 :                       gcc_rich_location richloc (expr_loc, &rhs_label);
    7787                 :          33 :                       if (pedwarn (&richloc, OPT_Wpointer_sign,
    7788                 :             :                                    "pointer targets in passing argument %d of "
    7789                 :             :                                    "%qE differ in signedness", parmnum, rname))
    7790                 :          33 :                         inform_for_arg (fundecl, expr_loc, parmnum, type,
    7791                 :             :                                         rhstype);
    7792                 :          33 :                     }
    7793                 :          33 :                     break;
    7794                 :          21 :                   case ic_assign:
    7795                 :          21 :                     pedwarn (location, OPT_Wpointer_sign,
    7796                 :             :                              "pointer targets in assignment from %qT to %qT "
    7797                 :             :                              "differ in signedness", rhstype, type);
    7798                 :          21 :                     break;
    7799                 :          14 :                   case ic_init:
    7800                 :          14 :                   case ic_init_const:
    7801                 :          14 :                     pedwarn_init (location, OPT_Wpointer_sign,
    7802                 :             :                                   "pointer targets in initialization of %qT "
    7803                 :             :                                   "from %qT differ in signedness", type,
    7804                 :             :                                   rhstype);
    7805                 :          14 :                     break;
    7806                 :          14 :                   case ic_return:
    7807                 :          14 :                     pedwarn (location, OPT_Wpointer_sign, "pointer targets in "
    7808                 :             :                              "returning %qT from a function with return type "
    7809                 :             :                              "%qT differ in signedness", rhstype, type);
    7810                 :          14 :                     break;
    7811                 :           0 :                   default:
    7812                 :           0 :                     gcc_unreachable ();
    7813                 :             :                   }
    7814                 :             :             }
    7815                 :       35717 :           else if (TREE_CODE (ttl) == FUNCTION_TYPE
    7816                 :        6761 :                    && TREE_CODE (ttr) == FUNCTION_TYPE)
    7817                 :             :             {
    7818                 :             :               /* Because const and volatile on functions are restrictions
    7819                 :             :                  that say the function will not do certain things,
    7820                 :             :                  it is okay to use a const or volatile function
    7821                 :             :                  where an ordinary one is wanted, but not vice-versa.  */
    7822                 :        6144 :               if (TYPE_QUALS_NO_ADDR_SPACE (ttl)
    7823                 :        6144 :                   & ~TYPE_QUALS_NO_ADDR_SPACE (ttr))
    7824                 :          18 :                 PEDWARN_FOR_QUALIFIERS (location, expr_loc,
    7825                 :             :                                         OPT_Wdiscarded_qualifiers,
    7826                 :             :                                         G_("passing argument %d of %qE makes "
    7827                 :             :                                            "%q#v qualified function pointer "
    7828                 :             :                                            "from unqualified"),
    7829                 :             :                                         G_("assignment makes %q#v qualified function "
    7830                 :             :                                            "pointer from unqualified"),
    7831                 :             :                                         G_("initialization makes %q#v qualified "
    7832                 :             :                                            "function pointer from unqualified"),
    7833                 :             :                                         G_("return makes %q#v qualified function "
    7834                 :             :                                            "pointer from unqualified"),
    7835                 :             :                                         TYPE_QUALS (ttl) & ~TYPE_QUALS (ttr));
    7836                 :             :             }
    7837                 :             :         }
    7838                 :             :       /* Avoid warning about the volatile ObjC EH puts on decls.  */
    7839                 :         784 :       else if (!objc_ok)
    7840                 :             :         {
    7841                 :         784 :           switch (errtype)
    7842                 :             :             {
    7843                 :         300 :             case ic_argpass:
    7844                 :         300 :               {
    7845                 :         300 :                 auto_diagnostic_group d;
    7846                 :         300 :                 range_label_for_type_mismatch rhs_label (rhstype, type);
    7847                 :         300 :                 gcc_rich_location richloc (expr_loc, &rhs_label);
    7848                 :         300 :                 if (permerror_opt (&richloc, OPT_Wincompatible_pointer_types,
    7849                 :             :                                    "passing argument %d of %qE from "
    7850                 :             :                                    "incompatible pointer type",
    7851                 :             :                                    parmnum, rname))
    7852                 :         168 :                   inform_for_arg (fundecl, expr_loc, parmnum, type, rhstype);
    7853                 :         300 :               }
    7854                 :         300 :               break;
    7855                 :         264 :             case ic_assign:
    7856                 :         264 :               if (bltin)
    7857                 :          11 :                 permerror_opt (location, OPT_Wincompatible_pointer_types,
    7858                 :             :                                "assignment to %qT from pointer to "
    7859                 :             :                                "%qD with incompatible type %qT",
    7860                 :             :                                type, bltin, rhstype);
    7861                 :             :               else
    7862                 :         253 :                 permerror_opt (location, OPT_Wincompatible_pointer_types,
    7863                 :             :                                "assignment to %qT from incompatible pointer "
    7864                 :             :                                "type %qT", type, rhstype);
    7865                 :             :               break;
    7866                 :         163 :             case ic_init:
    7867                 :         163 :             case ic_init_const:
    7868                 :         163 :               if (bltin)
    7869                 :          13 :                 permerror_init (location, OPT_Wincompatible_pointer_types,
    7870                 :             :                                 "initialization of %qT from pointer to "
    7871                 :             :                                 "%qD with incompatible type %qT",
    7872                 :             :                                 type, bltin, rhstype);
    7873                 :             :               else
    7874                 :         150 :                 permerror_init (location, OPT_Wincompatible_pointer_types,
    7875                 :             :                                 "initialization of %qT from incompatible "
    7876                 :             :                                 "pointer type %qT",
    7877                 :             :                                 type, rhstype);
    7878                 :             :               break;
    7879                 :          57 :             case ic_return:
    7880                 :          57 :               if (bltin)
    7881                 :          11 :                 permerror_opt (location, OPT_Wincompatible_pointer_types,
    7882                 :             :                                "returning pointer to %qD of type %qT from "
    7883                 :             :                                "a function with incompatible type %qT",
    7884                 :             :                                bltin, rhstype, type);
    7885                 :             :               else
    7886                 :          46 :                 permerror_opt (location, OPT_Wincompatible_pointer_types,
    7887                 :             :                                "returning %qT from a function with "
    7888                 :             :                                "incompatible return type %qT", rhstype, type);
    7889                 :             :               break;
    7890                 :           0 :             default:
    7891                 :           0 :               gcc_unreachable ();
    7892                 :             :             }
    7893                 :             :         }
    7894                 :             : 
    7895                 :             :       /* If RHS isn't an address, check pointer or array of packed
    7896                 :             :          struct or union.  */
    7897                 :     1885106 :       warn_for_address_of_packed_member (type, orig_rhs);
    7898                 :             : 
    7899                 :     1885106 :       return convert (type, rhs);
    7900                 :             :     }
    7901                 :       62450 :   else if (codel == POINTER_TYPE && coder == ARRAY_TYPE)
    7902                 :             :     {
    7903                 :             :       /* ??? This should not be an error when inlining calls to
    7904                 :             :          unprototyped functions.  */
    7905                 :           4 :       const char msg[] = "invalid use of non-lvalue array";
    7906                 :           4 :       if (warnopt)
    7907                 :           0 :         warning_at (location, warnopt, msg);
    7908                 :             :       else
    7909                 :           4 :         error_at (location, msg);
    7910                 :           4 :       return error_mark_node;
    7911                 :             :     }
    7912                 :       62446 :   else if (codel == POINTER_TYPE
    7913                 :       61195 :            && (coder == INTEGER_TYPE
    7914                 :       61195 :                || coder == NULLPTR_TYPE
    7915                 :          12 :                || coder == BITINT_TYPE))
    7916                 :             :     {
    7917                 :             :       /* An explicit constant 0 or type nullptr_t can convert to a pointer,
    7918                 :             :          or one that results from arithmetic, even including a cast to
    7919                 :             :          integer type.  */
    7920                 :       61187 :       if (!null_pointer_constant && coder != NULLPTR_TYPE)
    7921                 :         962 :         switch (errtype)
    7922                 :             :           {
    7923                 :         793 :           case ic_argpass:
    7924                 :         793 :             {
    7925                 :         793 :               auto_diagnostic_group d;
    7926                 :         793 :               range_label_for_type_mismatch rhs_label (rhstype, type);
    7927                 :         793 :               gcc_rich_location richloc (expr_loc, &rhs_label);
    7928                 :         793 :               if (permerror_opt (&richloc, OPT_Wint_conversion,
    7929                 :             :                                  "passing argument %d of %qE makes pointer "
    7930                 :             :                                  "from integer without a cast", parmnum, rname))
    7931                 :         432 :                 inform_for_arg (fundecl, expr_loc, parmnum, type, rhstype);
    7932                 :         793 :             }
    7933                 :         793 :             break;
    7934                 :          91 :           case ic_assign:
    7935                 :          91 :             permerror_opt (location, OPT_Wint_conversion,
    7936                 :             :                            "assignment to %qT from %qT makes pointer from "
    7937                 :             :                            "integer without a cast", type, rhstype);
    7938                 :          91 :             break;
    7939                 :          55 :           case ic_init:
    7940                 :          55 :           case ic_init_const:
    7941                 :          55 :             permerror_init (location, OPT_Wint_conversion,
    7942                 :             :                             "initialization of %qT from %qT makes pointer "
    7943                 :             :                             "from integer without a cast", type, rhstype);
    7944                 :          55 :             break;
    7945                 :          23 :           case ic_return:
    7946                 :          23 :             permerror_init (location, OPT_Wint_conversion,
    7947                 :             :                             "returning %qT from a function with return type "
    7948                 :             :                             "%qT makes pointer from integer without a cast",
    7949                 :             :                             rhstype, type);
    7950                 :          23 :             break;
    7951                 :           0 :           default:
    7952                 :           0 :             gcc_unreachable ();
    7953                 :             :           }
    7954                 :             : 
    7955                 :       61187 :       return convert (type, rhs);
    7956                 :             :     }
    7957                 :        1259 :   else if ((codel == INTEGER_TYPE || codel == BITINT_TYPE)
    7958                 :         534 :            && coder == POINTER_TYPE)
    7959                 :             :     {
    7960                 :         508 :       switch (errtype)
    7961                 :             :         {
    7962                 :         341 :         case ic_argpass:
    7963                 :         341 :           {
    7964                 :         341 :             auto_diagnostic_group d;
    7965                 :         341 :             range_label_for_type_mismatch rhs_label (rhstype, type);
    7966                 :         341 :             gcc_rich_location richloc (expr_loc, &rhs_label);
    7967                 :         341 :             if (permerror_opt (&richloc, OPT_Wint_conversion,
    7968                 :             :                                "passing argument %d of %qE makes integer from "
    7969                 :             :                                "pointer without a cast", parmnum, rname))
    7970                 :         320 :               inform_for_arg (fundecl, expr_loc, parmnum, type, rhstype);
    7971                 :         341 :           }
    7972                 :         341 :           break;
    7973                 :          49 :         case ic_assign:
    7974                 :          49 :           permerror_opt (location, OPT_Wint_conversion,
    7975                 :             :                          "assignment to %qT from %qT makes integer from "
    7976                 :             :                          "pointer without a cast", type, rhstype);
    7977                 :          49 :           break;
    7978                 :          83 :         case ic_init:
    7979                 :          83 :         case ic_init_const:
    7980                 :          83 :           permerror_init (location, OPT_Wint_conversion,
    7981                 :             :                           "initialization of %qT from %qT makes integer "
    7982                 :             :                           "from pointer without a cast", type, rhstype);
    7983                 :          83 :           break;
    7984                 :          35 :         case ic_return:
    7985                 :          35 :           permerror_opt (location, OPT_Wint_conversion, "returning %qT from a "
    7986                 :             :                          "function with return type %qT makes integer from "
    7987                 :             :                          "pointer without a cast", rhstype, type);
    7988                 :          35 :           break;
    7989                 :           0 :         default:
    7990                 :           0 :           gcc_unreachable ();
    7991                 :             :         }
    7992                 :             : 
    7993                 :         508 :       return convert (type, rhs);
    7994                 :             :     }
    7995                 :         611 :   else if (C_BOOLEAN_TYPE_P (type)
    7996                 :             :            /* The type nullptr_t may be converted to bool.  The
    7997                 :             :               result is false.  */
    7998                 :         753 :            && (coder == POINTER_TYPE || coder == NULLPTR_TYPE))
    7999                 :             :     {
    8000                 :         142 :       tree ret;
    8001                 :         142 :       bool save = in_late_binary_op;
    8002                 :         142 :       in_late_binary_op = true;
    8003                 :         142 :       ret = convert (type, rhs);
    8004                 :         142 :       in_late_binary_op = save;
    8005                 :         142 :       return ret;
    8006                 :             :     }
    8007                 :         609 :   else if (codel == NULLPTR_TYPE && null_pointer_constant)
    8008                 :           6 :     return convert (type, rhs);
    8009                 :             : 
    8010                 :         603 :   switch (errtype)
    8011                 :             :     {
    8012                 :          35 :     case ic_argpass:
    8013                 :          35 :       {
    8014                 :          35 :         auto_diagnostic_group d;
    8015                 :          35 :         range_label_for_type_mismatch rhs_label (rhstype, type);
    8016                 :          35 :         gcc_rich_location richloc (expr_loc, &rhs_label);
    8017                 :          35 :         const char msg[] = G_("incompatible type for argument %d of %qE");
    8018                 :          35 :         if (warnopt)
    8019                 :           8 :           warning_at (expr_loc, warnopt, msg, parmnum, rname);
    8020                 :             :         else
    8021                 :          27 :           error_at (&richloc, msg, parmnum, rname);
    8022                 :          35 :         inform_for_arg (fundecl, expr_loc, parmnum, type, rhstype);
    8023                 :          35 :       }
    8024                 :          35 :       break;
    8025                 :          95 :     case ic_assign:
    8026                 :          95 :       {
    8027                 :          95 :         const char msg[]
    8028                 :             :           = G_("incompatible types when assigning to type %qT from type %qT");
    8029                 :          95 :         if (warnopt)
    8030                 :           0 :           warning_at (expr_loc, 0, msg, type, rhstype);
    8031                 :             :         else
    8032                 :          95 :           error_at (expr_loc, msg, type, rhstype);
    8033                 :          95 :         break;
    8034                 :             :       }
    8035                 :         458 :     case ic_init:
    8036                 :         458 :     case ic_init_const:
    8037                 :         458 :       {
    8038                 :         458 :         const char msg[]
    8039                 :             :           = G_("incompatible types when initializing type %qT using type %qT");
    8040                 :         458 :         if (warnopt)
    8041                 :           0 :           warning_at (location, 0, msg, type, rhstype);
    8042                 :             :         else
    8043                 :         458 :           error_at (location, msg, type, rhstype);
    8044                 :         458 :         break;
    8045                 :             :       }
    8046                 :          15 :     case ic_return:
    8047                 :          15 :       {
    8048                 :          15 :         const char msg[]
    8049                 :             :           = G_("incompatible types when returning type %qT but %qT was expected");
    8050                 :          15 :         if (warnopt)
    8051                 :           0 :           warning_at (location, 0, msg, rhstype, type);
    8052                 :             :         else
    8053                 :          15 :           error_at (location, msg, rhstype, type);
    8054                 :          15 :         break;
    8055                 :             :       }
    8056                 :           0 :     default:
    8057                 :           0 :       gcc_unreachable ();
    8058                 :             :     }
    8059                 :             : 
    8060                 :         603 :   return error_mark_node;
    8061                 :             : }
    8062                 :             : 
    8063                 :             : /* If VALUE is a compound expr all of whose expressions are constant, then
    8064                 :             :    return its value.  Otherwise, return error_mark_node.
    8065                 :             : 
    8066                 :             :    This is for handling COMPOUND_EXPRs as initializer elements
    8067                 :             :    which is allowed with a warning when -pedantic is specified.  */
    8068                 :             : 
    8069                 :             : static tree
    8070                 :           2 : valid_compound_expr_initializer (tree value, tree endtype)
    8071                 :             : {
    8072                 :           2 :   if (TREE_CODE (value) == COMPOUND_EXPR)
    8073                 :             :     {
    8074                 :           1 :       if (valid_compound_expr_initializer (TREE_OPERAND (value, 0), endtype)
    8075                 :           1 :           == error_mark_node)
    8076                 :             :         return error_mark_node;
    8077                 :           0 :       return valid_compound_expr_initializer (TREE_OPERAND (value, 1),
    8078                 :           0 :                                               endtype);
    8079                 :             :     }
    8080                 :           1 :   else if (!initializer_constant_valid_p (value, endtype))
    8081                 :           1 :     return error_mark_node;
    8082                 :             :   else
    8083                 :             :     return value;
    8084                 :             : }
    8085                 :             : 
    8086                 :             : /* Perform appropriate conversions on the initial value of a variable,
    8087                 :             :    store it in the declaration DECL,
    8088                 :             :    and print any error messages that are appropriate.
    8089                 :             :    If ORIGTYPE is not NULL_TREE, it is the original type of INIT.
    8090                 :             :    If the init is invalid, store an ERROR_MARK.
    8091                 :             : 
    8092                 :             :    INIT_LOC is the location of the initial value.  */
    8093                 :             : 
    8094                 :             : void
    8095                 :     7004288 : store_init_value (location_t init_loc, tree decl, tree init, tree origtype)
    8096                 :             : {
    8097                 :     7004288 :   tree value, type;
    8098                 :     7004288 :   bool npc = false;
    8099                 :     7004288 :   bool int_const_expr = false;
    8100                 :     7004288 :   bool arith_const_expr = false;
    8101                 :             : 
    8102                 :             :   /* If variable's type was invalidly declared, just ignore it.  */
    8103                 :             : 
    8104                 :     7004288 :   type = TREE_TYPE (decl);
    8105                 :     7004288 :   if (TREE_CODE (type) == ERROR_MARK)
    8106                 :             :     return;
    8107                 :             : 
    8108                 :             :   /* Digest the specified initializer into an expression.  */
    8109                 :             : 
    8110                 :     7004281 :   if (init)
    8111                 :             :     {
    8112                 :     7004281 :       npc = null_pointer_constant_p (init);
    8113                 :     7004281 :       int_const_expr = (TREE_CODE (init) == INTEGER_CST
    8114                 :      393432 :                         && !TREE_OVERFLOW (init)
    8115                 :     7397677 :                         && INTEGRAL_TYPE_P (TREE_TYPE (init)));
    8116                 :             :       /* Not fully determined before folding.  */
    8117                 :             :       arith_const_expr = true;
    8118                 :             :     }
    8119                 :     7004281 :   bool constexpr_p = (VAR_P (decl)
    8120                 :     7004281 :                       && C_DECL_DECLARED_CONSTEXPR (decl));
    8121                 :     7004281 :   value = digest_init (init_loc, type, init, origtype, npc, int_const_expr,
    8122                 :             :                        arith_const_expr, true,
    8123                 :     7004281 :                        TREE_STATIC (decl) || constexpr_p, constexpr_p);
    8124                 :             : 
    8125                 :             :   /* Store the expression if valid; else report error.  */
    8126                 :             : 
    8127                 :     7004281 :   if (!in_system_header_at (input_location)
    8128                 :     7004281 :       && AGGREGATE_TYPE_P (TREE_TYPE (decl)) && !TREE_STATIC (decl))
    8129                 :       26727 :     warning (OPT_Wtraditional, "traditional C rejects automatic "
    8130                 :             :              "aggregate initialization");
    8131                 :             : 
    8132                 :     7004281 :   if (value != error_mark_node || TREE_CODE (decl) != FUNCTION_DECL)
    8133                 :     7004280 :     DECL_INITIAL (decl) = value;
    8134                 :             : 
    8135                 :             :   /* ANSI wants warnings about out-of-range constant initializers.  */
    8136                 :     7004292 :   STRIP_TYPE_NOPS (value);
    8137                 :     7004281 :   if (TREE_STATIC (decl))
    8138                 :      175468 :     constant_expression_warning (value);
    8139                 :             : 
    8140                 :             :   /* Check if we need to set array size from compound literal size.  */
    8141                 :     7004281 :   if (TREE_CODE (type) == ARRAY_TYPE
    8142                 :       25094 :       && TYPE_DOMAIN (type) == NULL_TREE
    8143                 :     7016394 :       && value != error_mark_node)
    8144                 :             :     {
    8145                 :             :       tree inside_init = init;
    8146                 :             : 
    8147                 :       11273 :       STRIP_TYPE_NOPS (inside_init);
    8148                 :       11273 :       inside_init = fold (inside_init);
    8149                 :             : 
    8150                 :       11273 :       if (TREE_CODE (inside_init) == COMPOUND_LITERAL_EXPR)
    8151                 :             :         {
    8152                 :          13 :           tree cldecl = COMPOUND_LITERAL_EXPR_DECL (inside_init);
    8153                 :             : 
    8154                 :          13 :           if (TYPE_DOMAIN (TREE_TYPE (cldecl)))
    8155                 :             :             {
    8156                 :             :               /* For int foo[] = (int [3]){1}; we need to set array size
    8157                 :             :                  now since later on array initializer will be just the
    8158                 :             :                  brace enclosed list of the compound literal.  */
    8159                 :          13 :               tree etype = strip_array_types (TREE_TYPE (decl));
    8160                 :          13 :               type = build_distinct_type_copy (TYPE_MAIN_VARIANT (type));
    8161                 :          13 :               TYPE_DOMAIN (type) = TYPE_DOMAIN (TREE_TYPE (cldecl));
    8162                 :          13 :               layout_type (type);
    8163                 :          13 :               layout_decl (cldecl, 0);
    8164                 :          13 :               TREE_TYPE (decl)
    8165                 :          26 :                 = c_build_qualified_type (type, TYPE_QUALS (etype));
    8166                 :             :             }
    8167                 :             :         }
    8168                 :             :     }
    8169                 :             : }
    8170                 :             : 
    8171                 :             : /* Methods for storing and printing names for error messages.  */
    8172                 :             : 
    8173                 :             : /* Implement a spelling stack that allows components of a name to be pushed
    8174                 :             :    and popped.  Each element on the stack is this structure.  */
    8175                 :             : 
    8176                 :             : struct spelling
    8177                 :             : {
    8178                 :             :   int kind;
    8179                 :             :   union
    8180                 :             :     {
    8181                 :             :       unsigned HOST_WIDE_INT i;
    8182                 :             :       const char *s;
    8183                 :             :     } u;
    8184                 :             : };
    8185                 :             : 
    8186                 :             : #define SPELLING_STRING 1
    8187                 :             : #define SPELLING_MEMBER 2
    8188                 :             : #define SPELLING_BOUNDS 3
    8189                 :             : 
    8190                 :             : static struct spelling *spelling;       /* Next stack element (unused).  */
    8191                 :             : static struct spelling *spelling_base;  /* Spelling stack base.  */
    8192                 :             : static int spelling_size;               /* Size of the spelling stack.  */
    8193                 :             : 
    8194                 :             : /* Macros to save and restore the spelling stack around push_... functions.
    8195                 :             :    Alternative to SAVE_SPELLING_STACK.  */
    8196                 :             : 
    8197                 :             : #define SPELLING_DEPTH() (spelling - spelling_base)
    8198                 :             : #define RESTORE_SPELLING_DEPTH(DEPTH) (spelling = spelling_base + (DEPTH))
    8199                 :             : 
    8200                 :             : /* Push an element on the spelling stack with type KIND and assign VALUE
    8201                 :             :    to MEMBER.  */
    8202                 :             : 
    8203                 :             : #define PUSH_SPELLING(KIND, VALUE, MEMBER)                              \
    8204                 :             : {                                                                       \
    8205                 :             :   int depth = SPELLING_DEPTH ();                                        \
    8206                 :             :                                                                         \
    8207                 :             :   if (depth >= spelling_size)                                                \
    8208                 :             :     {                                                                   \
    8209                 :             :       spelling_size += 10;                                              \
    8210                 :             :       spelling_base = XRESIZEVEC (struct spelling, spelling_base,       \
    8211                 :             :                                   spelling_size);                       \
    8212                 :             :       RESTORE_SPELLING_DEPTH (depth);                                   \
    8213                 :             :     }                                                                   \
    8214                 :             :                                                                         \
    8215                 :             :   spelling->kind = (KIND);                                           \
    8216                 :             :   spelling->MEMBER = (VALUE);                                                \
    8217                 :             :   spelling++;                                                           \
    8218                 :             : }
    8219                 :             : 
    8220                 :             : /* Push STRING on the stack.  Printed literally.  */
    8221                 :             : 
    8222                 :             : static void
    8223                 :     7001937 : push_string (const char *string)
    8224                 :             : {
    8225                 :     7001937 :   PUSH_SPELLING (SPELLING_STRING, string, u.s);
    8226                 :     7001937 : }
    8227                 :             : 
    8228                 :             : /* Push a member name on the stack.  Printed as '.' STRING.  */
    8229                 :             : 
    8230                 :             : static void
    8231                 :     1221790 : push_member_name (tree decl)
    8232                 :             : {
    8233                 :     1221790 :   const char *const string
    8234                 :     1221790 :     = (DECL_NAME (decl)
    8235                 :     1221790 :        ? identifier_to_locale (IDENTIFIER_POINTER (DECL_NAME (decl)))
    8236                 :         134 :        : _("<anonymous>"));
    8237                 :     1221790 :   PUSH_SPELLING (SPELLING_MEMBER, string, u.s);
    8238                 :     1221790 : }
    8239                 :             : 
    8240                 :             : /* Push an array bounds on the stack.  Printed as [BOUNDS].  */
    8241                 :             : 
    8242                 :             : static void
    8243                 :     2602458 : push_array_bounds (unsigned HOST_WIDE_INT bounds)
    8244                 :             : {
    8245                 :     2602458 :   PUSH_SPELLING (SPELLING_BOUNDS, bounds, u.i);
    8246                 :     2602458 : }
    8247                 :             : 
    8248                 :             : /* Compute the maximum size in bytes of the printed spelling.  */
    8249                 :             : 
    8250                 :             : static int
    8251                 :        3381 : spelling_length (void)
    8252                 :             : {
    8253                 :        3381 :   int size = 0;
    8254                 :        3381 :   struct spelling *p;
    8255                 :             : 
    8256                 :        7517 :   for (p = spelling_base; p < spelling; p++)
    8257                 :             :     {
    8258                 :        4136 :       if (p->kind == SPELLING_BOUNDS)
    8259                 :        1551 :         size += 25;
    8260                 :             :       else
    8261                 :        2585 :         size += strlen (p->u.s) + 1;
    8262                 :             :     }
    8263                 :             : 
    8264                 :        3381 :   return size;
    8265                 :             : }
    8266                 :             : 
    8267                 :             : /* Print the spelling to BUFFER and return it.  */
    8268                 :             : 
    8269                 :             : static char *
    8270                 :        3381 : print_spelling (char *buffer)
    8271                 :             : {
    8272                 :        3381 :   char *d = buffer;
    8273                 :        3381 :   struct spelling *p;
    8274                 :             : 
    8275                 :        7517 :   for (p = spelling_base; p < spelling; p++)
    8276                 :        4136 :     if (p->kind == SPELLING_BOUNDS)
    8277                 :             :       {
    8278                 :        1551 :         sprintf (d, "[" HOST_WIDE_INT_PRINT_UNSIGNED "]", p->u.i);
    8279                 :        1551 :         d += strlen (d);
    8280                 :             :       }
    8281                 :             :     else
    8282                 :             :       {
    8283                 :        2585 :         const char *s;
    8284                 :        2585 :         if (p->kind == SPELLING_MEMBER)
    8285                 :         488 :           *d++ = '.';
    8286                 :       19923 :         for (s = p->u.s; (*d = *s++); d++)
    8287                 :             :           ;
    8288                 :             :       }
    8289                 :        3381 :   *d++ = '\0';
    8290                 :        3381 :   return buffer;
    8291                 :             : }
    8292                 :             : 
    8293                 :             : /* Check whether INIT, a floating or integer constant, is
    8294                 :             :    representable in TYPE, a real floating type with the same radix or
    8295                 :             :    a decimal floating type initialized with a binary floating
    8296                 :             :    constant.  Return true if OK, false if not.  */
    8297                 :             : static bool
    8298                 :         360 : constexpr_init_fits_real_type (tree type, tree init)
    8299                 :             : {
    8300                 :         360 :   gcc_assert (SCALAR_FLOAT_TYPE_P (type));
    8301                 :         360 :   gcc_assert (TREE_CODE (init) == INTEGER_CST || TREE_CODE (init) == REAL_CST);
    8302                 :         360 :   if (TREE_CODE (init) == REAL_CST
    8303                 :         360 :       && TYPE_MODE (TREE_TYPE (init)) == TYPE_MODE (type))
    8304                 :             :     {
    8305                 :             :       /* Same mode, no conversion required except for the case of
    8306                 :             :          signaling NaNs if the types are incompatible (e.g. double and
    8307                 :             :          long double with the same mode).  */
    8308                 :         175 :       if (REAL_VALUE_ISSIGNALING_NAN (TREE_REAL_CST (init))
    8309                 :         193 :           && !comptypes (TYPE_MAIN_VARIANT (type),
    8310                 :          18 :                          TYPE_MAIN_VARIANT (TREE_TYPE (init))))
    8311                 :             :         return false;
    8312                 :         175 :       return true;
    8313                 :             :     }
    8314                 :         185 :   if (TREE_CODE (init) == INTEGER_CST)
    8315                 :             :     {
    8316                 :          54 :       tree converted = build_real_from_int_cst (type, init);
    8317                 :          54 :       bool fail = false;
    8318                 :         108 :       wide_int w = real_to_integer (&TREE_REAL_CST (converted), &fail,
    8319                 :          54 :                                     TYPE_PRECISION (TREE_TYPE (init)));
    8320                 :          68 :       return !fail && wi::eq_p (w, wi::to_wide (init));
    8321                 :          54 :     }
    8322                 :         131 :   if (REAL_VALUE_ISSIGNALING_NAN (TREE_REAL_CST (init)))
    8323                 :             :     return false;
    8324                 :         114 :   if ((REAL_VALUE_ISINF (TREE_REAL_CST (init))
    8325                 :          34 :        && MODE_HAS_INFINITIES (TYPE_MODE (type)))
    8326                 :         218 :       || (REAL_VALUE_ISNAN (TREE_REAL_CST (init))
    8327                 :          34 :           && MODE_HAS_NANS (TYPE_MODE (type))))
    8328                 :          20 :     return true;
    8329                 :          94 :   if (DECIMAL_FLOAT_TYPE_P (type)
    8330                 :         134 :       && !DECIMAL_FLOAT_TYPE_P (TREE_TYPE (init)))
    8331                 :             :     {
    8332                 :             :       /* This is valid if the real number represented by the
    8333                 :             :          initializer can be exactly represented in the decimal
    8334                 :             :          type.  Compare the values using MPFR.  */
    8335                 :           8 :       REAL_VALUE_TYPE t;
    8336                 :           8 :       real_convert (&t, TYPE_MODE (type), &TREE_REAL_CST (init));
    8337                 :           8 :       mpfr_t bin_val, dec_val;
    8338                 :           8 :       mpfr_init2 (bin_val, REAL_MODE_FORMAT (TYPE_MODE (TREE_TYPE (init)))->p);
    8339                 :           8 :       mpfr_init2 (dec_val, REAL_MODE_FORMAT (TYPE_MODE (TREE_TYPE (init)))->p);
    8340                 :           8 :       mpfr_from_real (bin_val, &TREE_REAL_CST (init), MPFR_RNDN);
    8341                 :           8 :       char string[256];
    8342                 :           8 :       real_to_decimal (string, &t, sizeof string, 0, 1);
    8343                 :           8 :       bool res = (mpfr_strtofr (dec_val, string, NULL, 10, MPFR_RNDN) == 0
    8344                 :           8 :                   && mpfr_equal_p (bin_val, dec_val));
    8345                 :           8 :       mpfr_clear (bin_val);
    8346                 :           8 :       mpfr_clear (dec_val);
    8347                 :           8 :       return res;
    8348                 :             :     }
    8349                 :             :   /* exact_real_truncate is not quite right here, since it doesn't
    8350                 :             :      allow even an exact conversion to subnormal values.  */
    8351                 :          86 :   REAL_VALUE_TYPE t;
    8352                 :          86 :   real_convert (&t, TYPE_MODE (type), &TREE_REAL_CST (init));
    8353                 :          86 :   return real_identical (&t, &TREE_REAL_CST (init));
    8354                 :             : }
    8355                 :             : 
    8356                 :             : /* Check whether INIT (location LOC) is valid as a 'constexpr'
    8357                 :             :    initializer for type TYPE, and give an error if not.  INIT has
    8358                 :             :    already been folded and verified to be constant.  INT_CONST_EXPR
    8359                 :             :    and ARITH_CONST_EXPR say whether it is an integer constant
    8360                 :             :    expression or arithmetic constant expression, respectively.  If
    8361                 :             :    TYPE is not a scalar type, this function does nothing.  */
    8362                 :             : 
    8363                 :             : static void
    8364                 :         861 : check_constexpr_init (location_t loc, tree type, tree init,
    8365                 :             :                       bool int_const_expr, bool arith_const_expr)
    8366                 :             : {
    8367                 :         861 :   if (POINTER_TYPE_P (type))
    8368                 :             :     {
    8369                 :             :       /* The initializer must be null.  */
    8370                 :          86 :       if (TREE_CODE (init) != INTEGER_CST || !integer_zerop (init))
    8371                 :           8 :         error_at (loc, "%<constexpr%> pointer initializer is not null");
    8372                 :          86 :       return;
    8373                 :             :     }
    8374                 :         775 :   if (INTEGRAL_TYPE_P (type))
    8375                 :             :     {
    8376                 :             :       /* The initializer must be an integer constant expression,
    8377                 :             :          representable in the target type.  */
    8378                 :         276 :       if (!int_const_expr)
    8379                 :           4 :         error_at (loc, "%<constexpr%> integer initializer is not an "
    8380                 :             :                   "integer constant expression");
    8381                 :         276 :       if (!int_fits_type_p (init, type))
    8382                 :           6 :         error_at (loc, "%<constexpr%> initializer not representable in "
    8383                 :             :                   "type of object");
    8384                 :         276 :       return;
    8385                 :             :     }
    8386                 :             :   /* We don't apply any extra checks to extension types such as vector
    8387                 :             :      or fixed-point types.  */
    8388                 :         499 :   if (TREE_CODE (type) != REAL_TYPE && TREE_CODE (type) != COMPLEX_TYPE)
    8389                 :             :     return;
    8390                 :         351 :   if (!arith_const_expr)
    8391                 :             :     {
    8392                 :           5 :       error_at (loc, "%<constexpr%> initializer is not an arithmetic "
    8393                 :             :                 "constant expression");
    8394                 :           5 :       return;
    8395                 :             :     }
    8396                 :             :   /* We don't apply any extra checks to complex integers.  */
    8397                 :         346 :   if (TREE_CODE (type) == COMPLEX_TYPE
    8398                 :         346 :       && TREE_CODE (TREE_TYPE (type)) != REAL_TYPE)
    8399                 :             :     return;
    8400                 :             :   /* Following N3082, a real type cannot be initialized from a complex
    8401                 :             :      type and a binary type cannot be initialized from a decimal type
    8402                 :             :      (but initializing a decimal type from a binary type is OK).
    8403                 :             :      Signaling NaN initializers are OK only if the types are
    8404                 :             :      compatible (not just the same mode); all quiet NaN and infinity
    8405                 :             :      initializations are considered to preserve the value.  */
    8406                 :         346 :   if (TREE_CODE (TREE_TYPE (init)) == COMPLEX_TYPE
    8407                 :         346 :       && SCALAR_FLOAT_TYPE_P (type))
    8408                 :             :     {
    8409                 :           6 :       error_at (loc, "%<constexpr%> initializer for a real type is of "
    8410                 :             :                 "complex type");
    8411                 :           6 :       return;
    8412                 :             :     }
    8413                 :         340 :   if (SCALAR_FLOAT_TYPE_P (type)
    8414                 :         298 :       && SCALAR_FLOAT_TYPE_P (TREE_TYPE (init))
    8415                 :         248 :       && DECIMAL_FLOAT_TYPE_P (TREE_TYPE (init))
    8416                 :         479 :       && !DECIMAL_FLOAT_TYPE_P (type))
    8417                 :             :     {
    8418                 :           6 :       error_at (loc, "%<constexpr%> initializer for a binary "
    8419                 :             :                 "floating-point type is of decimal type");
    8420                 :           6 :       return;
    8421                 :             :     }
    8422                 :         334 :   bool fits;
    8423                 :         334 :   if (TREE_CODE (type) == COMPLEX_TYPE)
    8424                 :             :     {
    8425                 :          42 :       switch (TREE_CODE (init))
    8426                 :             :         {
    8427                 :          10 :         case INTEGER_CST:
    8428                 :          10 :         case REAL_CST:
    8429                 :          10 :           fits = constexpr_init_fits_real_type (TREE_TYPE (type), init);
    8430                 :          10 :           break;
    8431                 :          32 :         case COMPLEX_CST:
    8432                 :          32 :           fits = (constexpr_init_fits_real_type (TREE_TYPE (type),
    8433                 :          32 :                                                  TREE_REALPART (init))
    8434                 :          58 :                   && constexpr_init_fits_real_type (TREE_TYPE (type),
    8435                 :          26 :                                                     TREE_IMAGPART (init)));
    8436                 :             :           break;
    8437                 :           0 :         default:
    8438                 :           0 :           gcc_unreachable ();
    8439                 :             :         }
    8440                 :             :     }
    8441                 :             :   else
    8442                 :         292 :     fits = constexpr_init_fits_real_type (type, init);
    8443                 :         302 :   if (!fits)
    8444                 :          65 :     error_at (loc, "%<constexpr%> initializer not representable in "
    8445                 :             :               "type of object");
    8446                 :             : }
    8447                 :             : 
    8448                 :             : /* Digest the parser output INIT as an initializer for type TYPE.
    8449                 :             :    Return a C expression of type TYPE to represent the initial value.
    8450                 :             : 
    8451                 :             :    If ORIGTYPE is not NULL_TREE, it is the original type of INIT.
    8452                 :             : 
    8453                 :             :    NULL_POINTER_CONSTANT is true if INIT is a null pointer constant,
    8454                 :             :    INT_CONST_EXPR is true if INIT is an integer constant expression,
    8455                 :             :    and ARITH_CONST_EXPR is true if INIT is, or might be, an arithmetic
    8456                 :             :    constant expression, false if it has already been determined in the
    8457                 :             :    caller that it is not (but folding may have made the value passed here
    8458                 :             :    indistinguishable from an arithmetic constant expression).
    8459                 :             : 
    8460                 :             :    If INIT is a string constant, STRICT_STRING is true if it is
    8461                 :             :    unparenthesized or we should not warn here for it being parenthesized.
    8462                 :             :    For other types of INIT, STRICT_STRING is not used.
    8463                 :             : 
    8464                 :             :    INIT_LOC is the location of the INIT.
    8465                 :             : 
    8466                 :             :    REQUIRE_CONSTANT requests an error if non-constant initializers or
    8467                 :             :    elements are seen.  REQUIRE_CONSTEXPR means the stricter requirements
    8468                 :             :    on initializers for 'constexpr' objects apply.  */
    8469                 :             : 
    8470                 :             : static tree
    8471                 :    16363608 : digest_init (location_t init_loc, tree type, tree init, tree origtype,
    8472                 :             :              bool null_pointer_constant, bool int_const_expr,
    8473                 :             :              bool arith_const_expr, bool strict_string,
    8474                 :             :              bool require_constant, bool require_constexpr)
    8475                 :             : {
    8476                 :    16363608 :   enum tree_code code = TREE_CODE (type);
    8477                 :    16363608 :   tree inside_init = init;
    8478                 :    16363608 :   tree semantic_type = NULL_TREE;
    8479                 :    16363608 :   bool maybe_const = true;
    8480                 :             : 
    8481                 :    16363608 :   if (type == error_mark_node
    8482                 :    16363608 :       || !init
    8483                 :    32727216 :       || error_operand_p (init))
    8484                 :             :     return error_mark_node;
    8485                 :             : 
    8486                 :    16370933 :   STRIP_TYPE_NOPS (inside_init);
    8487                 :             : 
    8488                 :    16362425 :   if (!c_in_omp_for)
    8489                 :             :     {
    8490                 :    16358378 :       if (TREE_CODE (inside_init) == EXCESS_PRECISION_EXPR)
    8491                 :             :         {
    8492                 :         405 :           semantic_type = TREE_TYPE (inside_init);
    8493                 :         405 :           inside_init = TREE_OPERAND (inside_init, 0);
    8494                 :             :         }
    8495                 :    16358378 :       inside_init = c_fully_fold (inside_init, require_constant, &maybe_const);
    8496                 :             :     }
    8497                 :             :   /* TODO: this may not detect all cases of expressions folding to
    8498                 :             :      constants that are not arithmetic constant expressions.  */
    8499                 :    16362425 :   if (!maybe_const)
    8500                 :             :     arith_const_expr = false;
    8501                 :    24417511 :   else if (!INTEGRAL_TYPE_P (TREE_TYPE (inside_init))
    8502                 :     5455122 :       && TREE_CODE (TREE_TYPE (inside_init)) != REAL_TYPE
    8503                 :    16325725 :       && TREE_CODE (TREE_TYPE (inside_init)) != COMPLEX_TYPE)
    8504                 :             :     arith_const_expr = false;
    8505                 :     8119084 :   else if (TREE_CODE (inside_init) != INTEGER_CST
    8506                 :             :       && TREE_CODE (inside_init) != REAL_CST
    8507                 :             :       && TREE_CODE (inside_init) != COMPLEX_CST)
    8508                 :             :     arith_const_expr = false;
    8509                 :     4922107 :   else if (TREE_OVERFLOW (inside_init))
    8510                 :    11440362 :     arith_const_expr = false;
    8511                 :             : 
    8512                 :             :   /* Initialization of an array of chars from a string constant
    8513                 :             :      optionally enclosed in braces.  */
    8514                 :             : 
    8515                 :    16362425 :   if (code == ARRAY_TYPE && inside_init
    8516                 :      185688 :       && TREE_CODE (inside_init) == STRING_CST)
    8517                 :             :     {
    8518                 :       11085 :       tree typ1
    8519                 :       11085 :         = (TYPE_ATOMIC (TREE_TYPE (type))
    8520                 :       22161 :            ? c_build_qualified_type (TYPE_MAIN_VARIANT (TREE_TYPE (type)),
    8521                 :             :                                      TYPE_QUAL_ATOMIC)
    8522                 :       11076 :            : TYPE_MAIN_VARIANT (TREE_TYPE (type)));
    8523                 :             :       /* Note that an array could be both an array of character type
    8524                 :             :          and an array of wchar_t if wchar_t is signed char or unsigned
    8525                 :             :          char.  */
    8526                 :       22170 :       bool char_array = (typ1 == char_type_node
    8527                 :         456 :                          || typ1 == signed_char_type_node
    8528                 :       11512 :                          || typ1 == unsigned_char_type_node);
    8529                 :       11085 :       bool wchar_array = !!comptypes (typ1, wchar_type_node);
    8530                 :       11085 :       bool char16_array = !!comptypes (typ1, char16_type_node);
    8531                 :       11085 :       bool char32_array = !!comptypes (typ1, char32_type_node);
    8532                 :             : 
    8533                 :       11085 :       if (char_array || wchar_array || char16_array || char32_array)
    8534                 :             :         {
    8535                 :       11065 :           struct c_expr expr;
    8536                 :       11065 :           tree typ2 = TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (inside_init)));
    8537                 :       11065 :           bool incompat_string_cst = false;
    8538                 :       11065 :           expr.value = inside_init;
    8539                 :       11065 :           expr.original_code = (strict_string ? STRING_CST : ERROR_MARK);
    8540                 :       11065 :           expr.original_type = NULL;
    8541                 :       11065 :           expr.m_decimal = 0;
    8542                 :       11065 :           maybe_warn_string_init (init_loc, type, expr);
    8543                 :             : 
    8544                 :       11065 :           if (TYPE_DOMAIN (type) && !TYPE_MAX_VALUE (TYPE_DOMAIN (type)))
    8545                 :          79 :             pedwarn_init (init_loc, OPT_Wpedantic,
    8546                 :             :                           "initialization of a flexible array member");
    8547                 :             : 
    8548                 :       11065 :           if (comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (inside_init)),
    8549                 :       11065 :                          TYPE_MAIN_VARIANT (type)))
    8550                 :             :             return inside_init;
    8551                 :             : 
    8552                 :        4050 :           if (char_array)
    8553                 :             :             {
    8554                 :        3955 :               if (typ2 != char_type_node && typ2 != char8_type_node)
    8555                 :             :                 incompat_string_cst = true;
    8556                 :             :             }
    8557                 :          95 :           else if (!comptypes (typ1, typ2))
    8558                 :             :             incompat_string_cst = true;
    8559                 :             : 
    8560                 :             :           if (incompat_string_cst)
    8561                 :             :             {
    8562                 :          50 :               error_init (init_loc, "cannot initialize array of %qT from "
    8563                 :             :                           "a string literal with type array of %qT",
    8564                 :             :                           typ1, typ2);
    8565                 :          50 :               return error_mark_node;
    8566                 :             :             }
    8567                 :             : 
    8568                 :        4000 :           if (require_constexpr
    8569                 :        4000 :               && TYPE_UNSIGNED (typ1) != TYPE_UNSIGNED (typ2))
    8570                 :             :             {
    8571                 :             :               /* Check if all characters of the string can be
    8572                 :             :                  represented in the type of the constexpr object being
    8573                 :             :                  initialized.  */
    8574                 :          24 :               unsigned HOST_WIDE_INT len = TREE_STRING_LENGTH (inside_init);
    8575                 :          24 :               const unsigned char *p =
    8576                 :          24 :                 (const unsigned char *) TREE_STRING_POINTER (inside_init);
    8577                 :          24 :               gcc_assert (CHAR_TYPE_SIZE == 8 && CHAR_BIT == 8);
    8578                 :          70 :               for (unsigned i = 0; i < len; i++)
    8579                 :          58 :                 if (p[i] > 127)
    8580                 :             :                   {
    8581                 :          12 :                     error_init (init_loc, "%<constexpr%> initializer not "
    8582                 :             :                                 "representable in type of object");
    8583                 :          12 :                     break;
    8584                 :             :                   }
    8585                 :             :             }
    8586                 :             : 
    8587                 :        4000 :           if (TYPE_DOMAIN (type) != NULL_TREE
    8588                 :        3925 :               && TYPE_SIZE (type) != NULL_TREE
    8589                 :        7878 :               && TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST)
    8590                 :             :             {
    8591                 :        3878 :               unsigned HOST_WIDE_INT len = TREE_STRING_LENGTH (inside_init);
    8592                 :        3878 :               unsigned unit = TYPE_PRECISION (typ1) / BITS_PER_UNIT;
    8593                 :             : 
    8594                 :             :               /* Subtract the size of a single (possibly wide) character
    8595                 :             :                  because it's ok to ignore the terminating null char
    8596                 :             :                  that is counted in the length of the constant.  */
    8597                 :        3878 :               if (compare_tree_int (TYPE_SIZE_UNIT (type), len - unit) < 0)
    8598                 :          54 :                 pedwarn_init (init_loc, 0,
    8599                 :             :                               ("initializer-string for array of %qT "
    8600                 :             :                                "is too long"), typ1);
    8601                 :        3824 :               else if (warn_cxx_compat
    8602                 :        3824 :                        && compare_tree_int (TYPE_SIZE_UNIT (type), len) < 0)
    8603                 :           1 :                 warning_at (init_loc, OPT_Wc___compat,
    8604                 :             :                             ("initializer-string for array of %qT "
    8605                 :             :                              "is too long for C++"), typ1);
    8606                 :        3878 :               if (compare_tree_int (TYPE_SIZE_UNIT (type), len) < 0)
    8607                 :             :                 {
    8608                 :         326 :                   unsigned HOST_WIDE_INT size
    8609                 :         326 :                     = tree_to_uhwi (TYPE_SIZE_UNIT (type));
    8610                 :         326 :                   const char *p = TREE_STRING_POINTER (inside_init);
    8611                 :             : 
    8612                 :         326 :                   inside_init = build_string (size, p);
    8613                 :             :                 }
    8614                 :             :             }
    8615                 :             : 
    8616                 :        4000 :           TREE_TYPE (inside_init) = type;
    8617                 :        4000 :           return inside_init;
    8618                 :             :         }
    8619                 :          20 :       else if (INTEGRAL_TYPE_P (typ1))
    8620                 :             :         {
    8621                 :          20 :           error_init (init_loc, "array of inappropriate type initialized "
    8622                 :             :                       "from string constant");
    8623                 :          20 :           return error_mark_node;
    8624                 :             :         }
    8625                 :             :     }
    8626                 :             : 
    8627                 :             :   /* Build a VECTOR_CST from a *constant* vector constructor.  If the
    8628                 :             :      vector constructor is not constant (e.g. {1,2,3,foo()}) then punt
    8629                 :             :      below and handle as a constructor.  */
    8630                 :    16351340 :   if (code == VECTOR_TYPE
    8631                 :     6086899 :       && VECTOR_TYPE_P (TREE_TYPE (inside_init))
    8632                 :     6086897 :       && vector_types_convertible_p (TREE_TYPE (inside_init), type, true)
    8633                 :    22438199 :       && TREE_CONSTANT (inside_init))
    8634                 :             :     {
    8635                 :      614187 :       if (TREE_CODE (inside_init) == VECTOR_CST
    8636                 :      614282 :           && comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (inside_init)),
    8637                 :          95 :                         TYPE_MAIN_VARIANT (type)))
    8638                 :             :         return inside_init;
    8639                 :             : 
    8640                 :      614092 :       if (TREE_CODE (inside_init) == CONSTRUCTOR)
    8641                 :             :         {
    8642                 :             :           unsigned HOST_WIDE_INT ix;
    8643                 :             :           tree value;
    8644                 :     4054371 :           bool constant_p = true;
    8645                 :             : 
    8646                 :             :           /* Iterate through elements and check if all constructor
    8647                 :             :              elements are *_CSTs.  */
    8648                 :     4054371 :           FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (inside_init), ix, value)
    8649                 :     3440332 :             if (!CONSTANT_CLASS_P (value))
    8650                 :             :               {
    8651                 :             :                 constant_p = false;
    8652                 :             :                 break;
    8653                 :             :               }
    8654                 :             : 
    8655                 :      614092 :           if (constant_p)
    8656                 :      614039 :             return build_vector_from_ctor (type,
    8657                 :      614039 :                                            CONSTRUCTOR_ELTS (inside_init));
    8658                 :             :         }
    8659                 :             :     }
    8660                 :             : 
    8661                 :    15737206 :   if (warn_sequence_point)
    8662                 :     2437957 :     verify_sequence_points (inside_init);
    8663                 :             : 
    8664                 :             :   /* Any type can be initialized
    8665                 :             :      from an expression of the same type, optionally with braces.  */
    8666                 :             : 
    8667                 :    15737206 :   if (inside_init && TREE_TYPE (inside_init) != NULL_TREE
    8668                 :    31474412 :       && (comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (inside_init)),
    8669                 :    15737206 :                      TYPE_MAIN_VARIANT (type))
    8670                 :     3043545 :           || (code == ARRAY_TYPE
    8671                 :         476 :               && comptypes (TREE_TYPE (inside_init), type))
    8672                 :     3043545 :           || (gnu_vector_type_p (type)
    8673                 :         159 :               && comptypes (TREE_TYPE (inside_init), type))
    8674                 :     3043545 :           || (code == POINTER_TYPE
    8675                 :       94412 :               && TREE_CODE (TREE_TYPE (inside_init)) == ARRAY_TYPE
    8676                 :        7508 :               && comptypes (TREE_TYPE (TREE_TYPE (inside_init)),
    8677                 :        7508 :                             TREE_TYPE (type)))))
    8678                 :             :     {
    8679                 :    12695631 :       if (code == POINTER_TYPE)
    8680                 :             :         {
    8681                 :      781647 :           if (TREE_CODE (TREE_TYPE (inside_init)) == ARRAY_TYPE)
    8682                 :             :             {
    8683                 :        1970 :               if (TREE_CODE (inside_init) == STRING_CST
    8684                 :          66 :                   || TREE_CODE (inside_init) == COMPOUND_LITERAL_EXPR)
    8685                 :        1968 :                 inside_init = array_to_pointer_conversion
    8686                 :        1968 :                   (init_loc, inside_init);
    8687                 :             :               else
    8688                 :             :                 {
    8689                 :           2 :                   error_init (init_loc, "invalid use of non-lvalue array");
    8690                 :           2 :                   return error_mark_node;
    8691                 :             :                 }
    8692                 :             :             }
    8693                 :             :         }
    8694                 :             : 
    8695                 :    12695629 :       if (code == VECTOR_TYPE || c_hardbool_type_attr (type))
    8696                 :             :         /* Although the types are compatible, we may require a
    8697                 :             :            conversion.  */
    8698                 :     5472662 :         inside_init = convert (type, inside_init);
    8699                 :             : 
    8700                 :    12695629 :       if ((code == RECORD_TYPE || code == UNION_TYPE)
    8701                 :    12695629 :           && !comptypes (TYPE_MAIN_VARIANT (type), TYPE_MAIN_VARIANT (TREE_TYPE (inside_init))))
    8702                 :             :         {
    8703                 :           0 :           error_init (init_loc, "invalid initializer");
    8704                 :           0 :           return error_mark_node;
    8705                 :             :         }
    8706                 :             : 
    8707                 :    12695629 :       if (require_constant
    8708                 :     2292330 :           && TREE_CODE (inside_init) == COMPOUND_LITERAL_EXPR)
    8709                 :             :         {
    8710                 :             :           /* As an extension, allow initializing objects with static storage
    8711                 :             :              duration with compound literals (which are then treated just as
    8712                 :             :              the brace enclosed list they contain).  Also allow this for
    8713                 :             :              vectors, as we can only assign them with compound literals.  */
    8714                 :          31 :           if (flag_isoc99 && code != VECTOR_TYPE)
    8715                 :           8 :             pedwarn_init (init_loc, OPT_Wpedantic, "initializer element "
    8716                 :             :                           "is not constant");
    8717                 :          31 :           tree decl = COMPOUND_LITERAL_EXPR_DECL (inside_init);
    8718                 :          31 :           inside_init = DECL_INITIAL (decl);
    8719                 :             :         }
    8720                 :             : 
    8721                 :    12695629 :       if (code == ARRAY_TYPE && TREE_CODE (inside_init) != STRING_CST
    8722                 :      174127 :           && TREE_CODE (inside_init) != CONSTRUCTOR)
    8723                 :             :         {
    8724                 :           2 :           error_init (init_loc, "array initialized from non-constant array "
    8725                 :             :                       "expression");
    8726                 :           2 :           return error_mark_node;
    8727                 :             :         }
    8728                 :             : 
    8729                 :             :       /* Compound expressions can only occur here if -Wpedantic or
    8730                 :             :          -pedantic-errors is specified.  In the later case, we always want
    8731                 :             :          an error.  In the former case, we simply want a warning.  */
    8732                 :    12695627 :       if (require_constant && pedantic
    8733                 :       19767 :           && TREE_CODE (inside_init) == COMPOUND_EXPR)
    8734                 :             :         {
    8735                 :           1 :           inside_init
    8736                 :           1 :             = valid_compound_expr_initializer (inside_init,
    8737                 :           1 :                                                TREE_TYPE (inside_init));
    8738                 :           1 :           if (inside_init == error_mark_node)
    8739                 :           1 :             error_init (init_loc, "initializer element is not constant");
    8740                 :             :           else
    8741                 :           0 :             pedwarn_init (init_loc, OPT_Wpedantic,
    8742                 :             :                           "initializer element is not constant");
    8743                 :           1 :           if (flag_pedantic_errors)
    8744                 :           0 :             inside_init = error_mark_node;
    8745                 :             :         }
    8746                 :     2292329 :       else if (require_constant
    8747                 :     2292329 :                && !initializer_constant_valid_p (inside_init,
    8748                 :     2292329 :                                                  TREE_TYPE (inside_init)))
    8749                 :             :         {
    8750                 :          94 :           error_init (init_loc, "initializer element is not constant");
    8751                 :          94 :           inside_init = error_mark_node;
    8752                 :             :         }
    8753                 :    12695532 :       else if (require_constant && !maybe_const)
    8754                 :         219 :         pedwarn_init (init_loc, OPT_Wpedantic,
    8755                 :             :                       "initializer element is not a constant expression");
    8756                 :    12695313 :       else if (require_constexpr)
    8757                 :         550 :         check_constexpr_init (init_loc, type, inside_init,
    8758                 :             :                               int_const_expr, arith_const_expr);
    8759                 :             : 
    8760                 :             :       /* Added to enable additional -Wsuggest-attribute=format warnings.  */
    8761                 :    12695627 :       if (TREE_CODE (TREE_TYPE (inside_init)) == POINTER_TYPE)
    8762                 :      847755 :         inside_init = convert_for_assignment (init_loc, UNKNOWN_LOCATION,
    8763                 :             :                                               type, inside_init, origtype,
    8764                 :             :                                               (require_constant
    8765                 :             :                                                ? ic_init_const
    8766                 :             :                                                : ic_init), null_pointer_constant,
    8767                 :             :                                               NULL_TREE, NULL_TREE, 0);
    8768                 :    12695627 :       return inside_init;
    8769                 :             :     }
    8770                 :             : 
    8771                 :             :   /* Handle scalar types, including conversions.  */
    8772                 :             : 
    8773                 :     3041575 :   if (code == INTEGER_TYPE || code == REAL_TYPE || code == FIXED_POINT_TYPE
    8774                 :      110265 :       || code == POINTER_TYPE || code == ENUMERAL_TYPE || code == BOOLEAN_TYPE
    8775                 :       10715 :       || code == COMPLEX_TYPE || code == VECTOR_TYPE || code == NULLPTR_TYPE
    8776                 :        8776 :       || code == BITINT_TYPE)
    8777                 :             :     {
    8778                 :     3041093 :       tree unconverted_init = inside_init;
    8779                 :     3041093 :       if (TREE_CODE (TREE_TYPE (init)) == ARRAY_TYPE
    8780                 :     3041093 :           && (TREE_CODE (init) == STRING_CST
    8781                 :           1 :               || TREE_CODE (init) == COMPOUND_LITERAL_EXPR))
    8782                 :        5539 :         inside_init = init = array_to_pointer_conversion (init_loc, init);
    8783                 :     3041093 :       if (semantic_type)
    8784                 :         400 :         inside_init = build1 (EXCESS_PRECISION_EXPR, semantic_type,
    8785                 :             :                               inside_init);
    8786                 :     3041093 :       inside_init
    8787                 :     5506790 :         = convert_for_assignment (init_loc, UNKNOWN_LOCATION, type,
    8788                 :             :                                   inside_init, origtype,
    8789                 :             :                                   require_constant ? ic_init_const : ic_init,
    8790                 :             :                                   null_pointer_constant, NULL_TREE, NULL_TREE,
    8791                 :             :                                   0);
    8792                 :             : 
    8793                 :             :       /* Check to see if we have already given an error message.  */
    8794                 :     3041093 :       if (inside_init == error_mark_node)
    8795                 :             :         ;
    8796                 :     3040635 :       else if (require_constant && !TREE_CONSTANT (inside_init))
    8797                 :             :         {
    8798                 :          36 :           error_init (init_loc, "initializer element is not constant");
    8799                 :          36 :           inside_init = error_mark_node;
    8800                 :             :         }
    8801                 :     3040599 :       else if (require_constant
    8802                 :     3615567 :                && !initializer_constant_valid_p (inside_init,
    8803                 :      574968 :                                                  TREE_TYPE (inside_init)))
    8804                 :             :         {
    8805                 :          10 :           error_init (init_loc, "initializer element is not computable at "
    8806                 :             :                       "load time");
    8807                 :          10 :           inside_init = error_mark_node;
    8808                 :             :         }
    8809                 :     3040589 :       else if (require_constant && !maybe_const)
    8810                 :           5 :         pedwarn_init (init_loc, OPT_Wpedantic,
    8811                 :             :                       "initializer element is not a constant expression");
    8812                 :     3040584 :       else if (require_constexpr)
    8813                 :         311 :         check_constexpr_init (init_loc, type, unconverted_init,
    8814                 :             :                               int_const_expr, arith_const_expr);
    8815                 :             : 
    8816                 :     3041093 :       return inside_init;
    8817                 :             :     }
    8818                 :             : 
    8819                 :             :   /* Come here only for records and arrays.  */
    8820                 :             : 
    8821                 :         482 :   if (COMPLETE_TYPE_P (type) && TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST)
    8822                 :             :     {
    8823                 :           0 :       error_init (init_loc,
    8824                 :             :                   "variable-sized object may not be initialized except "
    8825                 :             :                   "with an empty initializer");
    8826                 :           0 :       return error_mark_node;
    8827                 :             :     }
    8828                 :             : 
    8829                 :         482 :   error_init (init_loc, "invalid initializer");
    8830                 :         482 :   return error_mark_node;
    8831                 :             : }
    8832                 :             : 
    8833                 :             : /* Handle initializers that use braces.  */
    8834                 :             : 
    8835                 :             : /* Type of object we are accumulating a constructor for.
    8836                 :             :    This type is always a RECORD_TYPE, UNION_TYPE or ARRAY_TYPE.  */
    8837                 :             : static tree constructor_type;
    8838                 :             : 
    8839                 :             : /* For a RECORD_TYPE or UNION_TYPE, this is the chain of fields
    8840                 :             :    left to fill.  */
    8841                 :             : static tree constructor_fields;
    8842                 :             : 
    8843                 :             : /* For an ARRAY_TYPE, this is the specified index
    8844                 :             :    at which to store the next element we get.  */
    8845                 :             : static tree constructor_index;
    8846                 :             : 
    8847                 :             : /* For an ARRAY_TYPE, this is the maximum index.  */
    8848                 :             : static tree constructor_max_index;
    8849                 :             : 
    8850                 :             : /* For a RECORD_TYPE, this is the first field not yet written out.  */
    8851                 :             : static tree constructor_unfilled_fields;
    8852                 :             : 
    8853                 :             : /* For an ARRAY_TYPE, this is the index of the first element
    8854                 :             :    not yet written out.  */
    8855                 :             : static tree constructor_unfilled_index;
    8856                 :             : 
    8857                 :             : /* In a RECORD_TYPE, the byte index of the next consecutive field.
    8858                 :             :    This is so we can generate gaps between fields, when appropriate.  */
    8859                 :             : static tree constructor_bit_index;
    8860                 :             : 
    8861                 :             : /* If we are saving up the elements rather than allocating them,
    8862                 :             :    this is the list of elements so far (in reverse order,
    8863                 :             :    most recent first).  */
    8864                 :             : static vec<constructor_elt, va_gc> *constructor_elements;
    8865                 :             : 
    8866                 :             : /* 1 if constructor should be incrementally stored into a constructor chain,
    8867                 :             :    0 if all the elements should be kept in AVL tree.  */
    8868                 :             : static int constructor_incremental;
    8869                 :             : 
    8870                 :             : /* 1 if so far this constructor's elements are all compile-time constants.  */
    8871                 :             : static int constructor_constant;
    8872                 :             : 
    8873                 :             : /* 1 if so far this constructor's elements are all valid address constants.  */
    8874                 :             : static int constructor_simple;
    8875                 :             : 
    8876                 :             : /* 1 if this constructor has an element that cannot be part of a
    8877                 :             :    constant expression.  */
    8878                 :             : static int constructor_nonconst;
    8879                 :             : 
    8880                 :             : /* 1 if this constructor is erroneous so far.  */
    8881                 :             : static int constructor_erroneous;
    8882                 :             : 
    8883                 :             : /* 1 if this constructor is the universal zero initializer { 0 }.  */
    8884                 :             : static int constructor_zeroinit;
    8885                 :             : 
    8886                 :             : /* Structure for managing pending initializer elements, organized as an
    8887                 :             :    AVL tree.  */
    8888                 :             : 
    8889                 :             : struct init_node
    8890                 :             : {
    8891                 :             :   struct init_node *left, *right;
    8892                 :             :   struct init_node *parent;
    8893                 :             :   int balance;
    8894                 :             :   tree purpose;
    8895                 :             :   tree value;
    8896                 :             :   tree origtype;
    8897                 :             : };
    8898                 :             : 
    8899                 :             : /* Tree of pending elements at this constructor level.
    8900                 :             :    These are elements encountered out of order
    8901                 :             :    which belong at places we haven't reached yet in actually
    8902                 :             :    writing the output.
    8903                 :             :    Will never hold tree nodes across GC runs.  */
    8904                 :             : static struct init_node *constructor_pending_elts;
    8905                 :             : 
    8906                 :             : /* The SPELLING_DEPTH of this constructor.  */
    8907                 :             : static int constructor_depth;
    8908                 :             : 
    8909                 :             : /* DECL node for which an initializer is being read.
    8910                 :             :    0 means we are reading a constructor expression
    8911                 :             :    such as (struct foo) {...}.  */
    8912                 :             : static tree constructor_decl;
    8913                 :             : 
    8914                 :             : /* Nonzero if there were any member designators in this initializer.  */
    8915                 :             : static int constructor_designated;
    8916                 :             : 
    8917                 :             : /* Nesting depth of designator list.  */
    8918                 :             : static int designator_depth;
    8919                 :             : 
    8920                 :             : /* Nonzero if there were diagnosed errors in this designator list.  */
    8921                 :             : static int designator_erroneous;
    8922                 :             : 
    8923                 :             : 
    8924                 :             : /* This stack has a level for each implicit or explicit level of
    8925                 :             :    structuring in the initializer, including the outermost one.  It
    8926                 :             :    saves the values of most of the variables above.  */
    8927                 :             : 
    8928                 :             : struct constructor_range_stack;
    8929                 :             : 
    8930                 :             : struct constructor_stack
    8931                 :             : {
    8932                 :             :   struct constructor_stack *next;
    8933                 :             :   tree type;
    8934                 :             :   tree fields;
    8935                 :             :   tree index;
    8936                 :             :   tree max_index;
    8937                 :             :   tree unfilled_index;
    8938                 :             :   tree unfilled_fields;
    8939                 :             :   tree bit_index;
    8940                 :             :   vec<constructor_elt, va_gc> *elements;
    8941                 :             :   struct init_node *pending_elts;
    8942                 :             :   int offset;
    8943                 :             :   int depth;
    8944                 :             :   /* If value nonzero, this value should replace the entire
    8945                 :             :      constructor at this level.  */
    8946                 :             :   struct c_expr replacement_value;
    8947                 :             :   struct constructor_range_stack *range_stack;
    8948                 :             :   char constant;
    8949                 :             :   char simple;
    8950                 :             :   char nonconst;
    8951                 :             :   char implicit;
    8952                 :             :   char erroneous;
    8953                 :             :   char outer;
    8954                 :             :   char incremental;
    8955                 :             :   char designated;
    8956                 :             :   int designator_depth;
    8957                 :             : };
    8958                 :             : 
    8959                 :             : static struct constructor_stack *constructor_stack;
    8960                 :             : 
    8961                 :             : /* This stack represents designators from some range designator up to
    8962                 :             :    the last designator in the list.  */
    8963                 :             : 
    8964                 :             : struct constructor_range_stack
    8965                 :             : {
    8966                 :             :   struct constructor_range_stack *next, *prev;
    8967                 :             :   struct constructor_stack *stack;
    8968                 :             :   tree range_start;
    8969                 :             :   tree index;
    8970                 :             :   tree range_end;
    8971                 :             :   tree fields;
    8972                 :             : };
    8973                 :             : 
    8974                 :             : static struct constructor_range_stack *constructor_range_stack;
    8975                 :             : 
    8976                 :             : /* This stack records separate initializers that are nested.
    8977                 :             :    Nested initializers can't happen in ANSI C, but GNU C allows them
    8978                 :             :    in cases like { ... (struct foo) { ... } ... }.  */
    8979                 :             : 
    8980                 :             : struct initializer_stack
    8981                 :             : {
    8982                 :             :   struct initializer_stack *next;
    8983                 :             :   tree decl;
    8984                 :             :   struct constructor_stack *constructor_stack;
    8985                 :             :   struct constructor_range_stack *constructor_range_stack;
    8986                 :             :   vec<constructor_elt, va_gc> *elements;
    8987                 :             :   struct spelling *spelling;
    8988                 :             :   struct spelling *spelling_base;
    8989                 :             :   int spelling_size;
    8990                 :             :   char require_constant_value;
    8991                 :             :   char require_constant_elements;
    8992                 :             :   char require_constexpr_value;
    8993                 :             :   char designated;
    8994                 :             :   rich_location *missing_brace_richloc;
    8995                 :             : };
    8996                 :             : 
    8997                 :             : static struct initializer_stack *initializer_stack;
    8998                 :             : 
    8999                 :             : /* Prepare to parse and output the initializer for variable DECL.  */
    9000                 :             : 
    9001                 :             : void
    9002                 :     7001937 : start_init (tree decl, tree asmspec_tree ATTRIBUTE_UNUSED,
    9003                 :             :             bool init_require_constant, bool init_require_constexpr,
    9004                 :             :             rich_location *richloc)
    9005                 :             : {
    9006                 :     7001937 :   const char *locus;
    9007                 :     7001937 :   struct initializer_stack *p = XNEW (struct initializer_stack);
    9008                 :             : 
    9009                 :     7001937 :   p->decl = constructor_decl;
    9010                 :     7001937 :   p->require_constant_value = require_constant_value;
    9011                 :     7001937 :   p->require_constant_elements = require_constant_elements;
    9012                 :     7001937 :   p->require_constexpr_value = require_constexpr_value;
    9013                 :     7001937 :   p->constructor_stack = constructor_stack;
    9014                 :     7001937 :   p->constructor_range_stack = constructor_range_stack;
    9015                 :     7001937 :   p->elements = constructor_elements;
    9016                 :     7001937 :   p->spelling = spelling;
    9017                 :     7001937 :   p->spelling_base = spelling_base;
    9018                 :     7001937 :   p->spelling_size = spelling_size;
    9019                 :     7001937 :   p->next = initializer_stack;
    9020                 :     7001937 :   p->missing_brace_richloc = richloc;
    9021                 :     7001937 :   p->designated = constructor_designated;
    9022                 :     7001937 :   initializer_stack = p;
    9023                 :             : 
    9024                 :     7001937 :   constructor_decl = decl;
    9025                 :     7001937 :   constructor_designated = 0;
    9026                 :             : 
    9027                 :     7001937 :   require_constant_value = init_require_constant;
    9028                 :     7001937 :   require_constexpr_value = init_require_constexpr;
    9029                 :     7001937 :   if (decl != NULL_TREE && decl != error_mark_node)
    9030                 :             :     {
    9031                 :     6130862 :       require_constant_elements
    9032                 :     5958193 :         = ((init_require_constant || (pedantic && !flag_isoc99))
    9033                 :             :            /* For a scalar, you can always use any value to initialize,
    9034                 :             :               even within braces.  */
    9035                 :     6141743 :            && AGGREGATE_TYPE_P (TREE_TYPE (decl)));
    9036                 :     6130862 :       locus = identifier_to_locale (IDENTIFIER_POINTER (DECL_NAME (decl)));
    9037                 :             :     }
    9038                 :             :   else
    9039                 :             :     {
    9040                 :      871075 :       require_constant_elements = false;
    9041                 :      871075 :       locus = _("(anonymous)");
    9042                 :             :     }
    9043                 :             : 
    9044                 :     7001937 :   constructor_stack = 0;
    9045                 :     7001937 :   constructor_range_stack = 0;
    9046                 :             : 
    9047                 :     7001937 :   found_missing_braces = 0;
    9048                 :             : 
    9049                 :     7001937 :   spelling_base = 0;
    9050                 :     7001937 :   spelling_size = 0;
    9051                 :     7001937 :   RESTORE_SPELLING_DEPTH (0);
    9052                 :             : 
    9053                 :     7001937 :   if (locus)
    9054                 :     7001937 :     push_string (locus);
    9055                 :     7001937 : }
    9056                 :             : 
    9057                 :             : void
    9058                 :     7001935 : finish_init (void)
    9059                 :             : {
    9060                 :     7001935 :   struct initializer_stack *p = initializer_stack;
    9061                 :             : 
    9062                 :             :   /* Free the whole constructor stack of this initializer.  */
    9063                 :     7001935 :   while (constructor_stack)
    9064                 :             :     {
    9065                 :           0 :       struct constructor_stack *q = constructor_stack;
    9066                 :           0 :       constructor_stack = q->next;
    9067                 :           0 :       XDELETE (q);
    9068                 :             :     }
    9069                 :             : 
    9070                 :     7001935 :   gcc_assert (!constructor_range_stack);
    9071                 :             : 
    9072                 :             :   /* Pop back to the data of the outer initializer (if any).  */
    9073                 :     7001935 :   XDELETE (spelling_base);
    9074                 :             : 
    9075                 :     7001935 :   constructor_decl = p->decl;
    9076                 :     7001935 :   require_constant_value = p->require_constant_value;
    9077                 :     7001935 :   require_constant_elements = p->require_constant_elements;
    9078                 :     7001935 :   require_constexpr_value = p->require_constexpr_value;
    9079                 :     7001935 :   constructor_stack = p->constructor_stack;
    9080                 :     7001935 :   constructor_designated = p->designated;
    9081                 :     7001935 :   constructor_range_stack = p->constructor_range_stack;
    9082                 :     7001935 :   constructor_elements = p->elements;
    9083                 :     7001935 :   spelling = p->spelling;
    9084                 :     7001935 :   spelling_base = p->spelling_base;
    9085                 :     7001935 :   spelling_size = p->spelling_size;
    9086                 :     7001935 :   initializer_stack = p->next;
    9087                 :     7001935 :   XDELETE (p);
    9088                 :     7001935 : }
    9089                 :             : 
    9090                 :             : /* Call here when we see the initializer is surrounded by braces.
    9091                 :             :    This is instead of a call to push_init_level;
    9092                 :             :    it is matched by a call to pop_init_level.
    9093                 :             : 
    9094                 :             :    TYPE is the type to initialize, for a constructor expression.
    9095                 :             :    For an initializer for a decl, TYPE is zero.  */
    9096                 :             : 
    9097                 :             : void
    9098                 :      971407 : really_start_incremental_init (tree type)
    9099                 :             : {
    9100                 :      971407 :   struct constructor_stack *p = XNEW (struct constructor_stack);
    9101                 :             : 
    9102                 :      971407 :   if (type == NULL_TREE)
    9103                 :      102183 :     type = TREE_TYPE (constructor_decl);
    9104                 :             : 
    9105                 :      971407 :   if (VECTOR_TYPE_P (type)
    9106                 :      971407 :       && TYPE_VECTOR_OPAQUE (type))
    9107                 :           0 :     error ("opaque vector types cannot be initialized");
    9108                 :             : 
    9109                 :      971407 :   p->type = constructor_type;
    9110                 :      971407 :   p->fields = constructor_fields;
    9111                 :      971407 :   p->index = constructor_index;
    9112                 :      971407 :   p->max_index = constructor_max_index;
    9113                 :      971407 :   p->unfilled_index = constructor_unfilled_index;
    9114                 :      971407 :   p->unfilled_fields = constructor_unfilled_fields;
    9115                 :      971407 :   p->bit_index = constructor_bit_index;
    9116                 :      971407 :   p->elements = constructor_elements;
    9117                 :      971407 :   p->constant = constructor_constant;
    9118                 :      971407 :   p->simple = constructor_simple;
    9119                 :      971407 :   p->nonconst = constructor_nonconst;
    9120                 :      971407 :   p->erroneous = constructor_erroneous;
    9121                 :      971407 :   p->pending_elts = constructor_pending_elts;
    9122                 :      971407 :   p->depth = constructor_depth;
    9123                 :      971407 :   p->replacement_value.value = 0;
    9124                 :      971407 :   p->replacement_value.original_code = ERROR_MARK;
    9125                 :      971407 :   p->replacement_value.original_type = NULL;
    9126                 :      971407 :   p->implicit = 0;
    9127                 :      971407 :   p->range_stack = 0;
    9128                 :      971407 :   p->outer = 0;
    9129                 :      971407 :   p->incremental = constructor_incremental;
    9130                 :      971407 :   p->designated = constructor_designated;
    9131                 :      971407 :   p->designator_depth = designator_depth;
    9132                 :      971407 :   p->next = 0;
    9133                 :      971407 :   constructor_stack = p;
    9134                 :             : 
    9135                 :      971407 :   constructor_constant = 1;
    9136                 :      971407 :   constructor_simple = 1;
    9137                 :      971407 :   constructor_nonconst = 0;
    9138                 :      971407 :   constructor_depth = SPELLING_DEPTH ();
    9139                 :      971407 :   constructor_elements = NULL;
    9140                 :      971407 :   constructor_pending_elts = 0;
    9141                 :      971407 :   constructor_type = type;
    9142                 :      971407 :   constructor_incremental = 1;
    9143                 :      971407 :   constructor_designated = 0;
    9144                 :      971407 :   constructor_zeroinit = 1;
    9145                 :      971407 :   designator_depth = 0;
    9146                 :      971407 :   designator_erroneous = 0;
    9147                 :             : 
    9148                 :      971407 :   if (RECORD_OR_UNION_TYPE_P (constructor_type))
    9149                 :             :     {
    9150                 :       78879 :       constructor_fields = TYPE_FIELDS (constructor_type);
    9151                 :             :       /* Skip any nameless bit fields at the beginning.  */
    9152                 :       78879 :       while (constructor_fields != NULL_TREE
    9153                 :       78903 :              && DECL_UNNAMED_BIT_FIELD (constructor_fields))
    9154                 :          24 :         constructor_fields = DECL_CHAIN (constructor_fields);
    9155                 :             : 
    9156                 :       78879 :       constructor_unfilled_fields = constructor_fields;
    9157                 :       78879 :       constructor_bit_index = bitsize_zero_node;
    9158                 :             :     }
    9159                 :      892528 :   else if (TREE_CODE (constructor_type) == ARRAY_TYPE)
    9160                 :             :     {
    9161                 :       17060 :       if (TYPE_DOMAIN (constructor_type))
    9162                 :             :         {
    9163                 :        8982 :           constructor_max_index
    9164                 :        8982 :             = TYPE_MAX_VALUE (TYPE_DOMAIN (constructor_type));
    9165                 :             : 
    9166                 :             :           /* Detect non-empty initializations of zero-length arrays.  */
    9167                 :        8982 :           if (constructor_max_index == NULL_TREE
    9168                 :        8982 :               && TYPE_SIZE (constructor_type))
    9169                 :         190 :             constructor_max_index = integer_minus_one_node;
    9170                 :             : 
    9171                 :             :           /* constructor_max_index needs to be an INTEGER_CST.  Attempts
    9172                 :             :              to initialize VLAs with a nonempty initializer will cause a
    9173                 :             :              proper error; avoid tree checking errors as well by setting a
    9174                 :             :              safe value.  */
    9175                 :        8982 :           if (constructor_max_index
    9176                 :        8982 :               && TREE_CODE (constructor_max_index) != INTEGER_CST)
    9177                 :          50 :             constructor_max_index = integer_minus_one_node;
    9178                 :             : 
    9179                 :        8982 :           constructor_index
    9180                 :        8982 :             = convert (bitsizetype,
    9181                 :        8982 :                        TYPE_MIN_VALUE (TYPE_DOMAIN (constructor_type)));
    9182                 :             :         }
    9183                 :             :       else
    9184                 :             :         {
    9185                 :        8078 :           constructor_index = bitsize_zero_node;
    9186                 :        8078 :           constructor_max_index = NULL_TREE;
    9187                 :             :         }
    9188                 :             : 
    9189                 :       17060 :       constructor_unfilled_index = constructor_index;
    9190                 :             :     }
    9191                 :      875468 :   else if (gnu_vector_type_p (constructor_type))
    9192                 :             :     {
    9193                 :             :       /* Vectors are like simple fixed-size arrays.  */
    9194                 :     1749906 :       constructor_max_index =
    9195                 :      874953 :         bitsize_int (TYPE_VECTOR_SUBPARTS (constructor_type) - 1);
    9196                 :      874953 :       constructor_index = bitsize_zero_node;
    9197                 :      874953 :       constructor_unfilled_index = constructor_index;
    9198                 :             :     }
    9199                 :             :   else
    9200                 :             :     {
    9201                 :             :       /* Handle the case of int x = {5}; */
    9202                 :         515 :       constructor_fields = constructor_type;
    9203                 :         515 :       constructor_unfilled_fields = constructor_type;
    9204                 :             :     }
    9205                 :      971407 : }
    9206                 :             : 
    9207                 :             : extern location_t last_init_list_comma;
    9208                 :             : 
    9209                 :             : /* Called when we see an open brace for a nested initializer.  Finish
    9210                 :             :    off any pending levels with implicit braces.  */
    9211                 :             : void
    9212                 :      339088 : finish_implicit_inits (location_t loc, struct obstack *braced_init_obstack)
    9213                 :             : {
    9214                 :      339090 :   while (constructor_stack->implicit)
    9215                 :             :     {
    9216                 :         173 :       if (RECORD_OR_UNION_TYPE_P (constructor_type)
    9217                 :         130 :           && constructor_fields == NULL_TREE)
    9218                 :           0 :         process_init_element (input_location,
    9219                 :             :                               pop_init_level (loc, 1, braced_init_obstack,
    9220                 :             :                                               last_init_list_comma),
    9221                 :             :                               true, braced_init_obstack);
    9222                 :         173 :       else if (TREE_CODE (constructor_type) == ARRAY_TYPE
    9223                 :          43 :                && constructor_max_index
    9224                 :         216 :                && tree_int_cst_lt (constructor_max_index,
    9225                 :             :                                    constructor_index))
    9226                 :           2 :         process_init_element (input_location,
    9227                 :             :                               pop_init_level (loc, 1, braced_init_obstack,
    9228                 :             :                                               last_init_list_comma),
    9229                 :             :                               true, braced_init_obstack);
    9230                 :             :       else
    9231                 :             :         break;
    9232                 :             :     }
    9233                 :      339088 : }
    9234                 :             : 
    9235                 :             : /* Push down into a subobject, for initialization.
    9236                 :             :    If this is for an explicit set of braces, IMPLICIT is 0.
    9237                 :             :    If it is because the next element belongs at a lower level,
    9238                 :             :    IMPLICIT is 1 (or 2 if the push is because of designator list).  */
    9239                 :             : 
    9240                 :             : void
    9241                 :     1041633 : push_init_level (location_t loc, int implicit,
    9242                 :             :                  struct obstack *braced_init_obstack)
    9243                 :             : {
    9244                 :     1041633 :   struct constructor_stack *p;
    9245                 :     1041633 :   tree value = NULL_TREE;
    9246                 :             : 
    9247                 :             :   /* Unless this is an explicit brace, we need to preserve previous
    9248                 :             :      content if any.  */
    9249                 :     1041633 :   if (implicit)
    9250                 :             :     {
    9251                 :      703198 :       if (RECORD_OR_UNION_TYPE_P (constructor_type) && constructor_fields)
    9252                 :         564 :         value = find_init_member (constructor_fields, braced_init_obstack);
    9253                 :      702634 :       else if (TREE_CODE (constructor_type) == ARRAY_TYPE)
    9254                 :      702634 :         value = find_init_member (constructor_index, braced_init_obstack);
    9255                 :             :     }
    9256                 :             : 
    9257                 :     1041633 :   p = XNEW (struct constructor_stack);
    9258                 :     1041633 :   p->type = constructor_type;
    9259                 :     1041633 :   p->fields = constructor_fields;
    9260                 :     1041633 :   p->index = constructor_index;
    9261                 :     1041633 :   p->max_index = constructor_max_index;
    9262                 :     1041633 :   p->unfilled_index = constructor_unfilled_index;
    9263                 :     1041633 :   p->unfilled_fields = constructor_unfilled_fields;
    9264                 :     1041633 :   p->bit_index = constructor_bit_index;
    9265                 :     1041633 :   p->elements = constructor_elements;
    9266                 :     1041633 :   p->constant = constructor_constant;
    9267                 :     1041633 :   p->simple = constructor_simple;
    9268                 :     1041633 :   p->nonconst = constructor_nonconst;
    9269                 :     1041633 :   p->erroneous = constructor_erroneous;
    9270                 :     1041633 :   p->pending_elts = constructor_pending_elts;
    9271                 :     1041633 :   p->depth = constructor_depth;
    9272                 :     1041633 :   p->replacement_value.value = NULL_TREE;
    9273                 :     1041633 :   p->replacement_value.original_code = ERROR_MARK;
    9274                 :     1041633 :   p->replacement_value.original_type = NULL;
    9275                 :     1041633 :   p->implicit = implicit;
    9276                 :     1041633 :   p->outer = 0;
    9277                 :     1041633 :   p->incremental = constructor_incremental;
    9278                 :     1041633 :   p->designated = constructor_designated;
    9279                 :     1041633 :   p->designator_depth = designator_depth;
    9280                 :     1041633 :   p->next = constructor_stack;
    9281                 :     1041633 :   p->range_stack = 0;
    9282                 :     1041633 :   constructor_stack = p;
    9283                 :             : 
    9284                 :     1041633 :   constructor_constant = 1;
    9285                 :     1041633 :   constructor_simple = 1;
    9286                 :     1041633 :   constructor_nonconst = 0;
    9287                 :     1041633 :   constructor_depth = SPELLING_DEPTH ();
    9288                 :     1041633 :   constructor_elements = NULL;
    9289                 :     1041633 :   constructor_incremental = 1;
    9290                 :             :   /* If the upper initializer is designated, then mark this as
    9291                 :             :      designated too to prevent bogus warnings.  */
    9292                 :     1041633 :   constructor_designated = p->designated;
    9293                 :     1041633 :   constructor_pending_elts = 0;
    9294                 :     1041633 :   if (!implicit)
    9295                 :             :     {
    9296                 :      338435 :       p->range_stack = constructor_range_stack;
    9297                 :      338435 :       constructor_range_stack = 0;
    9298                 :      338435 :       designator_depth = 0;
    9299                 :      338435 :       designator_erroneous = 0;
    9300                 :             :     }
    9301                 :             : 
    9302                 :             :   /* Don't die if an entire brace-pair level is superfluous
    9303                 :             :      in the containing level.  */
    9304                 :     1041633 :   if (constructor_type == NULL_TREE)
    9305                 :             :     ;
    9306                 :     1041633 :   else if (RECORD_OR_UNION_TYPE_P (constructor_type))
    9307                 :             :     {
    9308                 :             :       /* Don't die if there are extra init elts at the end.  */
    9309                 :      157749 :       if (constructor_fields == NULL_TREE)
    9310                 :          51 :         constructor_type = NULL_TREE;
    9311                 :             :       else
    9312                 :             :         {
    9313                 :      157698 :           constructor_type = TREE_TYPE (constructor_fields);
    9314                 :      157698 :           push_member_name (constructor_fields);
    9315                 :      157698 :           constructor_depth++;
    9316                 :             :         }
    9317                 :             :     }
    9318                 :      883884 :   else if (TREE_CODE (constructor_type) == ARRAY_TYPE)
    9319                 :             :     {
    9320                 :      883846 :       constructor_type = TREE_TYPE (constructor_type);
    9321                 :      883846 :       push_array_bounds (tree_to_uhwi (constructor_index));
    9322                 :      883846 :       constructor_depth++;
    9323                 :             :     }
    9324                 :             : 
    9325                 :     1041633 :   if (constructor_type == NULL_TREE)
    9326                 :             :     {
    9327                 :          51 :       error_init (loc, "extra brace group at end of initializer");
    9328                 :          51 :       constructor_fields = NULL_TREE;
    9329                 :          51 :       constructor_unfilled_fields = NULL_TREE;
    9330                 :          51 :       return;
    9331                 :             :     }
    9332                 :             : 
    9333                 :     1041582 :   if (value && TREE_CODE (value) == CONSTRUCTOR)
    9334                 :             :     {
    9335                 :         164 :       constructor_constant = TREE_CONSTANT (value);
    9336                 :         164 :       constructor_simple = TREE_STATIC (value);
    9337                 :         164 :       constructor_nonconst = CONSTRUCTOR_NON_CONST (value);
    9338                 :         164 :       constructor_elements = CONSTRUCTOR_ELTS (value);
    9339                 :         164 :       if (!vec_safe_is_empty (constructor_elements)
    9340                 :         164 :           && (TREE_CODE (constructor_type) == RECORD_TYPE
    9341                 :         164 :               || TREE_CODE (constructor_type) == ARRAY_TYPE))
    9342                 :         118 :         set_nonincremental_init (braced_init_obstack);
    9343                 :             :     }
    9344                 :             : 
    9345                 :     1041582 :   if (implicit == 1)
    9346                 :             :     {
    9347                 :      702545 :       found_missing_braces = 1;
    9348                 :      702545 :       if (initializer_stack->missing_brace_richloc)
    9349                 :      702545 :         initializer_stack->missing_brace_richloc->add_fixit_insert_before
    9350                 :      702545 :           (loc, "{");
    9351                 :             :     }
    9352                 :             : 
    9353                 :     1041582 :   if (RECORD_OR_UNION_TYPE_P (constructor_type))
    9354                 :             :     {
    9355                 :      879321 :       constructor_fields = TYPE_FIELDS (constructor_type);
    9356                 :             :       /* Skip any nameless bit fields at the beginning.  */
    9357                 :      879321 :       while (constructor_fields != NULL_TREE
    9358                 :      879385 :              && DECL_UNNAMED_BIT_FIELD (constructor_fields))
    9359                 :          64 :         constructor_fields = DECL_CHAIN (constructor_fields);
    9360                 :             : 
    9361                 :      879321 :       constructor_unfilled_fields = constructor_fields;
    9362                 :      879321 :       constructor_bit_index = bitsize_zero_node;
    9363                 :             :     }
    9364                 :      162261 :   else if (gnu_vector_type_p (constructor_type))
    9365                 :             :     {
    9366                 :             :       /* Vectors are like simple fixed-size arrays.  */
    9367                 :        9592 :       constructor_max_index =
    9368                 :        4796 :         bitsize_int (TYPE_VECTOR_SUBPARTS (constructor_type) - 1);
    9369                 :        4796 :       constructor_index = bitsize_int (0);
    9370                 :        4796 :       constructor_unfilled_index = constructor_index;
    9371                 :             :     }
    9372                 :      157465 :   else if (TREE_CODE (constructor_type) == ARRAY_TYPE)
    9373                 :             :     {
    9374                 :      157407 :       if (TYPE_DOMAIN (constructor_type))
    9375                 :             :         {
    9376                 :      157407 :           constructor_max_index
    9377                 :      157407 :             = TYPE_MAX_VALUE (TYPE_DOMAIN (constructor_type));
    9378                 :             : 
    9379                 :             :           /* Detect non-empty initializations of zero-length arrays.  */
    9380                 :      157407 :           if (constructor_max_index == NULL_TREE
    9381                 :      157407 :               && TYPE_SIZE (constructor_type))
    9382                 :         135 :             constructor_max_index = integer_minus_one_node;
    9383                 :             : 
    9384                 :             :           /* constructor_max_index needs to be an INTEGER_CST.  Attempts
    9385                 :             :              to initialize VLAs will cause a proper error; avoid tree
    9386                 :             :              checking errors as well by setting a safe value.  */
    9387                 :      157407 :           if (constructor_max_index
    9388                 :      157190 :               && TREE_CODE (constructor_max_index) != INTEGER_CST)
    9389                 :           0 :             constructor_max_index = integer_minus_one_node;
    9390                 :             : 
    9391                 :      157407 :           constructor_index
    9392                 :      157407 :             = convert (bitsizetype,
    9393                 :      157407 :                        TYPE_MIN_VALUE (TYPE_DOMAIN (constructor_type)));
    9394                 :             :         }
    9395                 :             :       else
    9396                 :           0 :         constructor_index = bitsize_zero_node;
    9397                 :             : 
    9398                 :      157407 :       constructor_unfilled_index = constructor_index;
    9399                 :      157407 :       if (value && TREE_CODE (value) == STRING_CST)
    9400                 :             :         {
    9401                 :             :           /* We need to split the char/wchar array into individual
    9402                 :             :              characters, so that we don't have to special case it
    9403                 :             :              everywhere.  */
    9404                 :           7 :           set_nonincremental_init_from_string (value, braced_init_obstack);
    9405                 :             :         }
    9406                 :             :     }
    9407                 :             :   else
    9408                 :             :     {
    9409                 :          58 :       if (constructor_type != error_mark_node)
    9410                 :          29 :         warning_init (input_location, 0, "braces around scalar initializer");
    9411                 :          58 :       constructor_fields = constructor_type;
    9412                 :          58 :       constructor_unfilled_fields = constructor_type;
    9413                 :             :     }
    9414                 :             : }
    9415                 :             : 
    9416                 :             : /* At the end of an implicit or explicit brace level,
    9417                 :             :    finish up that level of constructor.  If a single expression
    9418                 :             :    with redundant braces initialized that level, return the
    9419                 :             :    c_expr structure for that expression.  Otherwise, the original_code
    9420                 :             :    element is set to ERROR_MARK.
    9421                 :             :    If we were outputting the elements as they are read, return 0 as the value
    9422                 :             :    from inner levels (process_init_element ignores that),
    9423                 :             :    but return error_mark_node as the value from the outermost level
    9424                 :             :    (that's what we want to put in DECL_INITIAL).
    9425                 :             :    Otherwise, return a CONSTRUCTOR expression as the value.  */
    9426                 :             : 
    9427                 :             : struct c_expr
    9428                 :     2013040 : pop_init_level (location_t loc, int implicit,
    9429                 :             :                 struct obstack *braced_init_obstack,
    9430                 :             :                 location_t insert_before)
    9431                 :             : {
    9432                 :     2013040 :   struct constructor_stack *p;
    9433                 :     2013040 :   struct c_expr ret;
    9434                 :     2013040 :   ret.value = NULL_TREE;
    9435                 :     2013040 :   ret.original_code = ERROR_MARK;
    9436                 :     2013040 :   ret.original_type = NULL;
    9437                 :     2013040 :   ret.m_decimal = 0;
    9438                 :             : 
    9439                 :     2013040 :   if (implicit == 0)
    9440                 :             :     {
    9441                 :             :       /* When we come to an explicit close brace,
    9442                 :             :          pop any inner levels that didn't have explicit braces.  */
    9443                 :     1310619 :       while (constructor_stack->implicit)
    9444                 :         777 :         process_init_element (input_location,
    9445                 :             :                               pop_init_level (loc, 1, braced_init_obstack,
    9446                 :             :                                               insert_before),
    9447                 :             :                               true, braced_init_obstack);
    9448                 :     1309842 :       gcc_assert (!constructor_range_stack);
    9449                 :             :     }
    9450                 :             :   else
    9451                 :      703198 :     if (initializer_stack->missing_brace_richloc)
    9452                 :      703198 :       initializer_stack->missing_brace_richloc->add_fixit_insert_before
    9453                 :      703198 :         (insert_before, "}");
    9454                 :             : 
    9455                 :             :   /* Now output all pending elements.  */
    9456                 :     2013040 :   constructor_incremental = 1;
    9457                 :     2013040 :   output_pending_init_elements (1, braced_init_obstack);
    9458                 :             : 
    9459                 :     2013040 :   p = constructor_stack;
    9460                 :             : 
    9461                 :             :   /* Error for initializing a flexible array member, or a zero-length
    9462                 :             :      array member in an inappropriate context.  */
    9463                 :     2012989 :   if (constructor_type && constructor_fields
    9464                 :      158130 :       && TREE_CODE (constructor_type) == ARRAY_TYPE
    9465                 :      151603 :       && TYPE_DOMAIN (constructor_type)
    9466                 :     2164635 :       && !TYPE_MAX_VALUE (TYPE_DOMAIN (constructor_type)))
    9467                 :             :     {
    9468                 :             :       /* Silently discard empty initializations.  The parser will
    9469                 :             :          already have pedwarned for empty brackets.  */
    9470                 :         247 :       if (integer_zerop (constructor_unfilled_index))
    9471                 :          72 :         constructor_type = NULL_TREE;
    9472                 :             :       else
    9473                 :             :         {
    9474                 :         175 :           gcc_assert (!TYPE_SIZE (constructor_type));
    9475                 :             : 
    9476                 :         175 :           if (constructor_depth > 2)
    9477                 :          24 :             error_init (loc, "initialization of flexible array member in a nested context");
    9478                 :             :           else
    9479                 :         151 :             pedwarn_init (loc, OPT_Wpedantic,
    9480                 :             :                           "initialization of a flexible array member");
    9481                 :             : 
    9482                 :             :           /* We have already issued an error message for the existence
    9483                 :             :              of a flexible array member not at the end of the structure.
    9484                 :             :              Discard the initializer so that we do not die later.  */
    9485                 :         175 :           if (DECL_CHAIN (constructor_fields) != NULL_TREE)
    9486                 :           0 :             constructor_type = NULL_TREE;
    9487                 :             :         }
    9488                 :             :     }
    9489                 :             : 
    9490                 :     2013040 :   switch (vec_safe_length (constructor_elements))
    9491                 :             :     {
    9492                 :        4299 :     case 0:
    9493                 :             :       /* Initialization with { } counts as zeroinit.  */
    9494                 :        4299 :       constructor_zeroinit = 1;
    9495                 :        4299 :       break;
    9496                 :      912512 :     case 1:
    9497                 :             :       /* This might be zeroinit as well.  */
    9498                 :      912512 :       if (integer_zerop ((*constructor_elements)[0].value))
    9499                 :        1783 :         constructor_zeroinit = 1;
    9500                 :             :       break;
    9501                 :     1096229 :     default:
    9502                 :             :       /* If the constructor has more than one element, it can't be { 0 }.  */
    9503                 :     1096229 :       constructor_zeroinit = 0;
    9504                 :     1096229 :       break;
    9505                 :             :     }
    9506                 :             : 
    9507                 :             :   /* Warn when some structs are initialized with direct aggregation.  */
    9508                 :     2013040 :   if (!implicit && found_missing_braces && warn_missing_braces
    9509                 :          37 :       && !constructor_zeroinit)
    9510                 :             :     {
    9511                 :          18 :       gcc_assert (initializer_stack->missing_brace_richloc);
    9512                 :          18 :       warning_at (initializer_stack->missing_brace_richloc,
    9513                 :             :                   OPT_Wmissing_braces,
    9514                 :             :                   "missing braces around initializer");
    9515                 :             :     }
    9516                 :             : 
    9517                 :             :   /* Warn when some struct elements are implicitly initialized to zero.  */
    9518                 :     2013040 :   if (warn_missing_field_initializers
    9519                 :      423356 :       && constructor_type
    9520                 :      423328 :       && TREE_CODE (constructor_type) == RECORD_TYPE
    9521                 :      193387 :       && constructor_unfilled_fields)
    9522                 :             :     {
    9523                 :             :         /* Do not warn for flexible array members or zero-length arrays.  */
    9524                 :          43 :         while (constructor_unfilled_fields
    9525                 :          43 :                && (!DECL_SIZE (constructor_unfilled_fields)
    9526                 :          43 :                    || integer_zerop (DECL_SIZE (constructor_unfilled_fields))))
    9527                 :           0 :           constructor_unfilled_fields = DECL_CHAIN (constructor_unfilled_fields);
    9528                 :             : 
    9529                 :          43 :         if (constructor_unfilled_fields
    9530                 :             :             /* Do not warn if this level of the initializer uses member
    9531                 :             :                designators; it is likely to be deliberate.  */
    9532                 :          43 :             && !constructor_designated
    9533                 :             :             /* Do not warn about initializing with { 0 } or with { }.  */
    9534                 :          24 :             && !constructor_zeroinit)
    9535                 :             :           {
    9536                 :          10 :             if (warning_at (input_location, OPT_Wmissing_field_initializers,
    9537                 :             :                             "missing initializer for field %qD of %qT",
    9538                 :             :                             constructor_unfilled_fields,
    9539                 :             :                             constructor_type))
    9540                 :          10 :               inform (DECL_SOURCE_LOCATION (constructor_unfilled_fields),
    9541                 :             :                       "%qD declared here", constructor_unfilled_fields);
    9542                 :             :           }
    9543                 :             :     }
    9544                 :             : 
    9545                 :             :   /* Pad out the end of the structure.  */
    9546                 :     2013040 :   if (p->replacement_value.value)
    9547                 :             :     /* If this closes a superfluous brace pair,
    9548                 :             :        just pass out the element between them.  */
    9549                 :         102 :     ret = p->replacement_value;
    9550                 :     2012938 :   else if (constructor_type == NULL_TREE)
    9551                 :             :     ;
    9552                 :     2012823 :   else if (!RECORD_OR_UNION_TYPE_P (constructor_type)
    9553                 :     2012823 :            && TREE_CODE (constructor_type) != ARRAY_TYPE
    9554                 :     2012823 :            && !gnu_vector_type_p (constructor_type))
    9555                 :             :     {
    9556                 :             :       /* A nonincremental scalar initializer--just return
    9557                 :             :          the element, after verifying there is just one.
    9558                 :             :          Empty scalar initializers are supported in C23.  */
    9559                 :         573 :       if (vec_safe_is_empty (constructor_elements))
    9560                 :             :         {
    9561                 :         206 :           if (constructor_erroneous || constructor_type == error_mark_node)
    9562                 :          94 :             ret.value = error_mark_node;
    9563                 :         112 :           else if (TREE_CODE (constructor_type) == FUNCTION_TYPE)
    9564                 :             :             {
    9565                 :           2 :               error_init (loc, "invalid initializer");
    9566                 :           2 :               ret.value = error_mark_node;
    9567                 :             :             }
    9568                 :         110 :           else if (TREE_CODE (constructor_type) == POINTER_TYPE)
    9569                 :             :             /* Ensure this is a null pointer constant in the case of a
    9570                 :             :                'constexpr' object initialized with {}.  */
    9571                 :          32 :             ret.value = build_zero_cst (ptr_type_node);
    9572                 :             :           else
    9573                 :          78 :             ret.value = build_zero_cst (constructor_type);
    9574                 :             :         }
    9575                 :         367 :       else if (vec_safe_length (constructor_elements) != 1)
    9576                 :             :         {
    9577                 :           0 :           error_init (loc, "extra elements in scalar initializer");
    9578                 :           0 :           ret.value = (*constructor_elements)[0].value;
    9579                 :             :         }
    9580                 :             :       else
    9581                 :         367 :         ret.value = (*constructor_elements)[0].value;
    9582                 :             :     }
    9583                 :             :   else
    9584                 :             :     {
    9585                 :     2012250 :       if (constructor_erroneous)
    9586                 :         372 :         ret.value = error_mark_node;
    9587                 :             :       else
    9588                 :             :         {
    9589                 :     2011878 :           ret.value = build_constructor (constructor_type,
    9590                 :             :                                          constructor_elements);
    9591                 :     2011878 :           if (constructor_constant)
    9592                 :     1715212 :             TREE_CONSTANT (ret.value) = 1;
    9593                 :     2011878 :           if (constructor_constant && constructor_simple)
    9594                 :     1715174 :             TREE_STATIC (ret.value) = 1;
    9595                 :     2011878 :           if (constructor_nonconst)
    9596                 :         549 :             CONSTRUCTOR_NON_CONST (ret.value) = 1;
    9597                 :             :         }
    9598                 :             :     }
    9599                 :             : 
    9600                 :     2013040 :   if (ret.value && TREE_CODE (ret.value) != CONSTRUCTOR)
    9601                 :             :     {
    9602                 :        1047 :       if (constructor_nonconst)
    9603                 :          15 :         ret.original_code = C_MAYBE_CONST_EXPR;
    9604                 :        1032 :       else if (ret.original_code == C_MAYBE_CONST_EXPR)
    9605                 :           0 :         ret.original_code = ERROR_MARK;
    9606                 :             :     }
    9607                 :             : 
    9608                 :     2013040 :   constructor_type = p->type;
    9609                 :     2013040 :   constructor_fields = p->fields;
    9610                 :     2013040 :   constructor_index = p->index;
    9611                 :     2013040 :   constructor_max_index = p->max_index;
    9612                 :     2013040 :   constructor_unfilled_index = p->unfilled_index;
    9613                 :     2013040 :   constructor_unfilled_fields = p->unfilled_fields;
    9614                 :     2013040 :   constructor_bit_index = p->bit_index;
    9615                 :     2013040 :   constructor_elements = p->elements;
    9616                 :     2013040 :   constructor_constant = p->constant;
    9617                 :     2013040 :   constructor_simple = p->simple;
    9618                 :     2013040 :   constructor_nonconst = p->nonconst;
    9619                 :     2013040 :   constructor_erroneous = p->erroneous;
    9620                 :     2013040 :   constructor_incremental = p->incremental;
    9621                 :     2013040 :   constructor_designated = p->designated;
    9622                 :     2013040 :   designator_depth = p->designator_depth;
    9623                 :     2013040 :   constructor_pending_elts = p->pending_elts;
    9624                 :     2013040 :   constructor_depth = p->depth;
    9625                 :     2013040 :   if (!p->implicit)
    9626                 :     1309842 :     constructor_range_stack = p->range_stack;
    9627                 :     2013040 :   RESTORE_SPELLING_DEPTH (constructor_depth);
    9628                 :             : 
    9629                 :     2013040 :   constructor_stack = p->next;
    9630                 :     2013040 :   XDELETE (p);
    9631                 :             : 
    9632                 :     2013040 :   if (ret.value == NULL_TREE && constructor_stack == 0)
    9633                 :           0 :     ret.value = error_mark_node;
    9634                 :     2013040 :   return ret;
    9635                 :             : }
    9636                 :             : 
    9637                 :             : /* Common handling for both array range and field name designators.
    9638                 :             :    ARRAY argument is nonzero for array ranges.  Returns false for success.  */
    9639                 :             : 
    9640                 :             : static bool
    9641                 :       31750 : set_designator (location_t loc, bool array,
    9642                 :             :                 struct obstack *braced_init_obstack)
    9643                 :             : {
    9644                 :       31750 :   tree subtype;
    9645                 :       31750 :   enum tree_code subcode;
    9646                 :             : 
    9647                 :             :   /* Don't die if an entire brace-pair level is superfluous
    9648                 :             :      in the containing level, or for an erroneous type.  */
    9649                 :       31750 :   if (constructor_type == NULL_TREE || constructor_type == error_mark_node)
    9650                 :             :     return true;
    9651                 :             : 
    9652                 :             :   /* If there were errors in this designator list already, bail out
    9653                 :             :      silently.  */
    9654                 :       31741 :   if (designator_erroneous)
    9655                 :             :     return true;
    9656                 :             : 
    9657                 :             :   /* Likewise for an initializer for a variable-size type.  Those are
    9658                 :             :      diagnosed in the parser, except for empty initializer braces.  */
    9659                 :       31741 :   if (COMPLETE_TYPE_P (constructor_type)
    9660                 :       31741 :       && TREE_CODE (TYPE_SIZE (constructor_type)) != INTEGER_CST)
    9661                 :             :     return true;
    9662                 :             : 
    9663                 :       31731 :   if (!designator_depth)
    9664                 :             :     {
    9665                 :       31402 :       gcc_assert (!constructor_range_stack);
    9666                 :             : 
    9667                 :             :       /* Designator list starts at the level of closest explicit
    9668                 :             :          braces.  */
    9669                 :       31582 :       while (constructor_stack->implicit)
    9670                 :         180 :         process_init_element (input_location,
    9671                 :             :                               pop_init_level (loc, 1, braced_init_obstack,
    9672                 :             :                                               last_init_list_comma),
    9673                 :             :                               true, braced_init_obstack);
    9674                 :       31402 :       constructor_designated = 1;
    9675                 :       31402 :       return false;
    9676                 :             :     }
    9677                 :             : 
    9678                 :         329 :   switch (TREE_CODE (constructor_type))
    9679                 :             :     {
    9680                 :         252 :     case  RECORD_TYPE:
    9681                 :         252 :     case  UNION_TYPE:
    9682                 :         252 :       subtype = TREE_TYPE (constructor_fields);
    9683                 :         252 :       if (subtype != error_mark_node)
    9684                 :         252 :         subtype = TYPE_MAIN_VARIANT (subtype);
    9685                 :             :       break;
    9686                 :          77 :     case ARRAY_TYPE:
    9687                 :          77 :       subtype = TYPE_MAIN_VARIANT (TREE_TYPE (constructor_type));
    9688                 :          77 :       break;
    9689                 :           0 :     default:
    9690                 :           0 :       gcc_unreachable ();
    9691                 :             :     }
    9692                 :             : 
    9693                 :         329 :   subcode = TREE_CODE (subtype);
    9694                 :         329 :   if (array && subcode != ARRAY_TYPE)
    9695                 :             :     {
    9696                 :           1 :       error_init (loc, "array index in non-array initializer");
    9697                 :           1 :       return true;
    9698                 :             :     }
    9699                 :         328 :   else if (!array && subcode != RECORD_TYPE && subcode != UNION_TYPE)
    9700                 :             :     {
    9701                 :           0 :       error_init (loc, "field name not in record or union initializer");
    9702                 :           0 :       return true;
    9703                 :             :     }
    9704                 :             : 
    9705                 :         328 :   constructor_designated = 1;
    9706                 :         328 :   finish_implicit_inits (loc, braced_init_obstack);
    9707                 :         328 :   push_init_level (loc, 2, braced_init_obstack);
    9708                 :         328 :   return false;
    9709                 :             : }
    9710                 :             : 
    9711                 :             : /* If there are range designators in designator list, push a new designator
    9712                 :             :    to constructor_range_stack.  RANGE_END is end of such stack range or
    9713                 :             :    NULL_TREE if there is no range designator at this level.  */
    9714                 :             : 
    9715                 :             : static void
    9716                 :          48 : push_range_stack (tree range_end, struct obstack * braced_init_obstack)
    9717                 :             : {
    9718                 :          48 :   struct constructor_range_stack *p;
    9719                 :             : 
    9720                 :          96 :   p = (struct constructor_range_stack *)
    9721                 :          48 :     obstack_alloc (braced_init_obstack,
    9722                 :             :                    sizeof (struct constructor_range_stack));
    9723                 :          48 :   p->prev = constructor_range_stack;
    9724                 :          48 :   p->next = 0;
    9725                 :          48 :   p->fields = constructor_fields;
    9726                 :          48 :   p->range_start = constructor_index;
    9727                 :          48 :   p->index = constructor_index;
    9728                 :          48 :   p->stack = constructor_stack;
    9729                 :          48 :   p->range_end = range_end;
    9730                 :          48 :   if (constructor_range_stack)
    9731                 :          19 :     constructor_range_stack->next = p;
    9732                 :          48 :   constructor_range_stack = p;
    9733                 :          48 : }
    9734                 :             : 
    9735                 :             : /* Within an array initializer, specify the next index to be initialized.
    9736                 :             :    FIRST is that index.  If LAST is nonzero, then initialize a range
    9737                 :             :    of indices, running from FIRST through LAST.  */
    9738                 :             : 
    9739                 :             : void
    9740                 :         525 : set_init_index (location_t loc, tree first, tree last,
    9741                 :             :                 struct obstack *braced_init_obstack)
    9742                 :             : {
    9743                 :         525 :   if (set_designator (loc, true, braced_init_obstack))
    9744                 :             :     return;
    9745                 :             : 
    9746                 :         522 :   designator_erroneous = 1;
    9747                 :             : 
    9748                 :        1044 :   if (!INTEGRAL_TYPE_P (TREE_TYPE (first))
    9749                 :        1033 :       || (last && !INTEGRAL_TYPE_P (TREE_TYPE (last))))
    9750                 :             :     {
    9751                 :          12 :       error_init (loc, "array index in initializer not of integer type");
    9752                 :          12 :       return;
    9753                 :             :     }
    9754                 :             : 
    9755                 :         510 :   if (TREE_CODE (first) != INTEGER_CST)
    9756                 :             :     {
    9757                 :           6 :       first = c_fully_fold (first, false, NULL);
    9758                 :           6 :       if (TREE_CODE (first) == INTEGER_CST)
    9759                 :           5 :         pedwarn_init (loc, OPT_Wpedantic,
    9760                 :             :                       "array index in initializer is not "
    9761                 :             :                       "an integer constant expression");
    9762                 :             :     }
    9763                 :             : 
    9764                 :         510 :   if (last && TREE_CODE (last) != INTEGER_CST)
    9765                 :             :     {
    9766                 :           2 :       last = c_fully_fold (last, false, NULL);
    9767                 :           2 :       if (TREE_CODE (last) == INTEGER_CST)
    9768                 :           1 :         pedwarn_init (loc, OPT_Wpedantic,
    9769                 :             :                       "array index in initializer is not "
    9770                 :             :                       "an integer constant expression");
    9771                 :             :     }
    9772                 :             : 
    9773                 :         510 :   if (TREE_CODE (first) != INTEGER_CST)
    9774                 :           1 :     error_init (loc, "nonconstant array index in initializer");
    9775                 :         509 :   else if (last != NULL_TREE && TREE_CODE (last) != INTEGER_CST)
    9776                 :           1 :     error_init (loc, "nonconstant array index in initializer");
    9777                 :         508 :   else if (TREE_CODE (constructor_type) != ARRAY_TYPE)
    9778                 :           9 :     error_init (loc, "array index in non-array initializer");
    9779                 :         499 :   else if (tree_int_cst_sgn (first) == -1)
    9780                 :          15 :     error_init (loc, "array index in initializer exceeds array bounds");
    9781                 :         484 :   else if (constructor_max_index
    9782                 :         484 :            && tree_int_cst_lt (constructor_max_index, first))
    9783                 :           7 :     error_init (loc, "array index in initializer exceeds array bounds");
    9784                 :             :   else
    9785                 :             :     {
    9786                 :         477 :       constant_expression_warning (first);
    9787                 :         477 :       if (last)
    9788                 :          43 :         constant_expression_warning (last);
    9789                 :         477 :       constructor_index = convert (bitsizetype, first);
    9790                 :         477 :       if (tree_int_cst_lt (constructor_index, first))
    9791                 :             :         {
    9792                 :           0 :           constructor_index = copy_node (constructor_index);
    9793                 :           0 :           TREE_OVERFLOW (constructor_index) = 1;
    9794                 :             :         }
    9795                 :             : 
    9796                 :         477 :       if (last)
    9797                 :             :         {
    9798                 :          43 :           if (tree_int_cst_equal (first, last))
    9799                 :             :             last = NULL_TREE;
    9800                 :          42 :           else if (tree_int_cst_lt (last, first))
    9801                 :             :             {
    9802                 :           2 :               error_init (loc, "empty index range in initializer");
    9803                 :           2 :               last = NULL_TREE;
    9804                 :             :             }
    9805                 :             :           else
    9806                 :             :             {
    9807                 :          40 :               last = convert (bitsizetype, last);
    9808                 :          40 :               if (constructor_max_index != NULL_TREE
    9809                 :          40 :                   && tree_int_cst_lt (constructor_max_index, last))
    9810                 :             :                 {
    9811                 :           3 :                   error_init (loc, "array index range in initializer exceeds "
    9812                 :             :                               "array bounds");
    9813                 :           3 :                   last = NULL_TREE;
    9814                 :             :                 }
    9815                 :             :             }
    9816                 :             :         }
    9817                 :             : 
    9818                 :         477 :       designator_depth++;
    9819                 :         477 :       designator_erroneous = 0;
    9820                 :         477 :       if (constructor_range_stack || last)
    9821                 :          37 :         push_range_stack (last, braced_init_obstack);
    9822                 :             :     }
    9823                 :             : }
    9824                 :             : 
    9825                 :             : /* Within a struct initializer, specify the next field to be initialized.  */
    9826                 :             : 
    9827                 :             : void
    9828                 :       31208 : set_init_label (location_t loc, tree fieldname, location_t fieldname_loc,
    9829                 :             :                 struct obstack *braced_init_obstack)
    9830                 :             : {
    9831                 :       31208 :   tree field;
    9832                 :             : 
    9833                 :       31208 :   if (set_designator (loc, false, braced_init_obstack))
    9834                 :             :     return;
    9835                 :             : 
    9836                 :       31191 :   designator_erroneous = 1;
    9837                 :             : 
    9838                 :       31191 :   if (!RECORD_OR_UNION_TYPE_P (constructor_type))
    9839                 :             :     {
    9840                 :           3 :       error_init (loc, "field name not in record or union initializer");
    9841                 :           3 :       return;
    9842                 :             :     }
    9843                 :             : 
    9844                 :       31188 :   field = lookup_field (constructor_type, fieldname);
    9845                 :             : 
    9846                 :       31188 :   if (field == NULL_TREE)
    9847                 :             :     {
    9848                 :           8 :       tree guessed_id = lookup_field_fuzzy (constructor_type, fieldname);
    9849                 :           8 :       if (guessed_id)
    9850                 :             :         {
    9851                 :           4 :           gcc_rich_location rich_loc (fieldname_loc);
    9852                 :           4 :           rich_loc.add_fixit_misspelled_id (fieldname_loc, guessed_id);
    9853                 :           4 :           error_at (&rich_loc,
    9854                 :             :                     "%qT has no member named %qE; did you mean %qE?",
    9855                 :             :                     constructor_type, fieldname, guessed_id);
    9856                 :           4 :         }
    9857                 :             :       else
    9858                 :           4 :         error_at (fieldname_loc, "%qT has no member named %qE",
    9859                 :             :                   constructor_type, fieldname);
    9860                 :             :     }
    9861                 :             :   else
    9862                 :       31197 :     do
    9863                 :             :       {
    9864                 :       31197 :         constructor_fields = TREE_VALUE (field);
    9865                 :       31197 :         designator_depth++;
    9866                 :       31197 :         designator_erroneous = 0;
    9867                 :       31197 :         if (constructor_range_stack)
    9868                 :          11 :           push_range_stack (NULL_TREE, braced_init_obstack);
    9869                 :       31197 :         field = TREE_CHAIN (field);
    9870                 :       31197 :         if (field)
    9871                 :             :           {
    9872                 :          17 :             if (set_designator (loc, false, braced_init_obstack))
    9873                 :             :               return;
    9874                 :             :           }
    9875                 :             :       }
    9876                 :       31197 :     while (field != NULL_TREE);
    9877                 :             : }
    9878                 :             : 
    9879                 :             : /* Add a new initializer to the tree of pending initializers.  PURPOSE
    9880                 :             :    identifies the initializer, either array index or field in a structure.
    9881                 :             :    VALUE is the value of that index or field.  If ORIGTYPE is not
    9882                 :             :    NULL_TREE, it is the original type of VALUE.
    9883                 :             : 
    9884                 :             :    IMPLICIT is true if value comes from pop_init_level (1),
    9885                 :             :    the new initializer has been merged with the existing one
    9886                 :             :    and thus no warnings should be emitted about overriding an
    9887                 :             :    existing initializer.  */
    9888                 :             : 
    9889                 :             : static void
    9890                 :        2093 : add_pending_init (location_t loc, tree purpose, tree value, tree origtype,
    9891                 :             :                   bool implicit, struct obstack *braced_init_obstack)
    9892                 :             : {
    9893                 :        2093 :   struct init_node *p, **q, *r;
    9894                 :             : 
    9895                 :        2093 :   q = &constructor_pending_elts;
    9896                 :        2093 :   p = 0;
    9897                 :             : 
    9898                 :        2093 :   if (TREE_CODE (constructor_type) == ARRAY_TYPE)
    9899                 :             :     {
    9900                 :        1280 :       while (*q != 0)
    9901                 :             :         {
    9902                 :         765 :           p = *q;
    9903                 :         765 :           if (tree_int_cst_lt (purpose, p->purpose))
    9904                 :          52 :             q = &p->left;
    9905                 :         713 :           else if (tree_int_cst_lt (p->purpose, purpose))
    9906                 :         651 :             q = &p->right;
    9907                 :             :           else
    9908                 :             :             {
    9909                 :          62 :               if (!implicit)
    9910                 :             :                 {
    9911                 :          27 :                   if (TREE_SIDE_EFFECTS (p->value))
    9912                 :           5 :                     warning_init (loc, OPT_Woverride_init_side_effects,
    9913                 :             :                                   "initialized field with side-effects "
    9914                 :             :                                   "overwritten");
    9915                 :          22 :                   else if (warn_override_init)
    9916                 :           6 :                     warning_init (loc, OPT_Woverride_init,
    9917                 :             :                                   "initialized field overwritten");
    9918                 :             :                 }
    9919                 :          62 :               p->value = value;
    9920                 :          62 :               p->origtype = origtype;
    9921                 :          62 :               return;
    9922                 :             :             }
    9923                 :             :         }
    9924                 :             :     }
    9925                 :             :   else
    9926                 :             :     {
    9927                 :        1516 :       tree bitpos;
    9928                 :             : 
    9929                 :        1516 :       bitpos = bit_position (purpose);
    9930                 :        4293 :       while (*q != NULL)
    9931                 :             :         {
    9932                 :        1383 :           p = *q;
    9933                 :        1383 :           if (tree_int_cst_lt (bitpos, bit_position (p->purpose)))
    9934                 :          27 :             q = &p->left;
    9935                 :        1356 :           else if (p->purpose != purpose)
    9936                 :        1234 :             q = &p->right;
    9937                 :             :           else
    9938                 :             :             {
    9939                 :         122 :               if (!implicit)
    9940                 :             :                 {
    9941                 :          28 :                   if (TREE_SIDE_EFFECTS (p->value))
    9942                 :           4 :                     warning_init (loc, OPT_Woverride_init_side_effects,
    9943                 :             :                                   "initialized field with side-effects "
    9944                 :             :                                   "overwritten");
    9945                 :          24 :                   else if (warn_override_init)
    9946                 :           6 :                     warning_init (loc, OPT_Woverride_init,
    9947                 :             :                                   "initialized field overwritten");
    9948                 :             :                 }
    9949                 :         122 :               p->value = value;
    9950                 :         122 :               p->origtype = origtype;
    9951                 :         122 :               return;
    9952                 :             :             }
    9953                 :             :         }
    9954                 :             :     }
    9955                 :             : 
    9956                 :        1909 :   r = (struct init_node *) obstack_alloc (braced_init_obstack,
    9957                 :             :                                           sizeof (struct init_node));
    9958                 :        1909 :   r->purpose = purpose;
    9959                 :        1909 :   r->value = value;
    9960                 :        1909 :   r->origtype = origtype;
    9961                 :             : 
    9962                 :        1909 :   *q = r;
    9963                 :        1909 :   r->parent = p;
    9964                 :        1909 :   r->left = 0;
    9965                 :        1909 :   r->right = 0;
    9966                 :        1909 :   r->balance = 0;
    9967                 :             : 
    9968                 :        3083 :   while (p)
    9969                 :             :     {
    9970                 :        1607 :       struct init_node *s;
    9971                 :             : 
    9972                 :        1607 :       if (r == p->left)
    9973                 :             :         {
    9974                 :          68 :           if (p->balance == 0)
    9975                 :          53 :             p->balance = -1;
    9976                 :          15 :           else if (p->balance < 0)
    9977                 :             :             {
    9978                 :          12 :               if (r->balance < 0)
    9979                 :             :                 {
    9980                 :             :                   /* L rotation.  */
    9981                 :           9 :                   p->left = r->right;
    9982                 :           9 :                   if (p->left)
    9983                 :           0 :                     p->left->parent = p;
    9984                 :           9 :                   r->right = p;
    9985                 :             : 
    9986                 :           9 :                   p->balance = 0;
    9987                 :           9 :                   r->balance = 0;
    9988                 :             : 
    9989                 :           9 :                   s = p->parent;
    9990                 :           9 :                   p->parent = r;
    9991                 :           9 :                   r->parent = s;
    9992                 :           9 :                   if (s)
    9993                 :             :                     {
    9994                 :           2 :                       if (s->left == p)
    9995                 :           2 :                         s->left = r;
    9996                 :             :                       else
    9997                 :           0 :                         s->right = r;
    9998                 :             :                     }
    9999                 :             :                   else
   10000                 :           7 :                     constructor_pending_elts = r;
   10001                 :             :                 }
   10002                 :             :               else
   10003                 :             :                 {
   10004                 :             :                   /* LR rotation.  */
   10005                 :           3 :                   struct init_node *t = r->right;
   10006                 :             : 
   10007                 :           3 :                   r->right = t->left;
   10008                 :           3 :                   if (r->right)
   10009                 :           0 :                     r->right->parent = r;
   10010                 :           3 :                   t->left = r;
   10011                 :             : 
   10012                 :           3 :                   p->left = t->right;
   10013                 :           3 :                   if (p->left)
   10014                 :           0 :                     p->left->parent = p;
   10015                 :           3 :                   t->right = p;
   10016                 :             : 
   10017                 :           3 :                   p->balance = t->balance < 0;
   10018                 :           3 :                   r->balance = -(t->balance > 0);
   10019                 :           3 :                   t->balance = 0;
   10020                 :             : 
   10021                 :           3 :                   s = p->parent;
   10022                 :           3 :                   p->parent = t;
   10023                 :           3 :                   r->parent = t;
   10024                 :           3 :                   t->parent = s;
   10025                 :           3 :                   if (s)
   10026                 :             :                     {
   10027                 :           0 :                       if (s->left == p)
   10028                 :           0 :                         s->left = t;
   10029                 :             :                       else
   10030                 :           0 :                         s->right = t;
   10031                 :             :                     }
   10032                 :             :                   else
   10033                 :           3 :                     constructor_pending_elts = t;
   10034                 :             :                 }
   10035                 :             :               break;
   10036                 :             :             }
   10037                 :             :           else
   10038                 :             :             {
   10039                 :             :               /* p->balance == +1; growth of left side balances the node.  */
   10040                 :           3 :               p->balance = 0;
   10041                 :           3 :               break;
   10042                 :             :             }
   10043                 :             :         }
   10044                 :             :       else /* r == p->right */
   10045                 :             :         {
   10046                 :        1539 :           if (p->balance == 0)
   10047                 :             :             /* Growth propagation from right side.  */
   10048                 :        1121 :             p->balance++;
   10049                 :         418 :           else if (p->balance > 0)
   10050                 :             :             {
   10051                 :         409 :               if (r->balance > 0)
   10052                 :             :                 {
   10053                 :             :                   /* R rotation.  */
   10054                 :         409 :                   p->right = r->left;
   10055                 :         409 :                   if (p->right)
   10056                 :          96 :                     p->right->parent = p;
   10057                 :         409 :                   r->left = p;
   10058                 :             : 
   10059                 :         409 :                   p->balance = 0;
   10060                 :         409 :                   r->balance = 0;
   10061                 :             : 
   10062                 :         409 :                   s = p->parent;
   10063                 :         409 :                   p->parent = r;
   10064                 :         409 :                   r->parent = s;
   10065                 :         409 :                   if (s)
   10066                 :             :                     {
   10067                 :         222 :                       if (s->left == p)
   10068                 :           0 :                         s->left = r;
   10069                 :             :                       else
   10070                 :         222 :                         s->right = r;
   10071                 :             :                     }
   10072                 :             :                   else
   10073                 :         187 :                     constructor_pending_elts = r;
   10074                 :             :                 }
   10075                 :             :               else /* r->balance == -1 */
   10076                 :             :                 {
   10077                 :             :                   /* RL rotation */
   10078                 :           0 :                   struct init_node *t = r->left;
   10079                 :             : 
   10080                 :           0 :                   r->left = t->right;
   10081                 :           0 :                   if (r->left)
   10082                 :           0 :                     r->left->parent = r;
   10083                 :           0 :                   t->right = r;
   10084                 :             : 
   10085                 :           0 :                   p->right = t->left;
   10086                 :           0 :                   if (p->right)
   10087                 :           0 :                     p->right->parent = p;
   10088                 :           0 :                   t->left = p;
   10089                 :             : 
   10090                 :           0 :                   r->balance = (t->balance < 0);
   10091                 :           0 :                   p->balance = -(t->balance > 0);
   10092                 :           0 :                   t->balance = 0;
   10093                 :             : 
   10094                 :           0 :                   s = p->parent;
   10095                 :           0 :                   p->parent = t;
   10096                 :           0 :                   r->parent = t;
   10097                 :           0 :                   t->parent = s;
   10098                 :           0 :                   if (s)
   10099                 :             :                     {
   10100                 :           0 :                       if (s->left == p)
   10101                 :           0 :                         s->left = t;
   10102                 :             :                       else
   10103                 :           0 :                         s->right = t;
   10104                 :             :                     }
   10105                 :             :                   else
   10106                 :           0 :                     constructor_pending_elts = t;
   10107                 :             :                 }
   10108                 :             :               break;
   10109                 :             :             }
   10110                 :             :           else
   10111                 :             :             {
   10112                 :             :               /* p->balance == -1; growth of right side balances the node.  */
   10113                 :           9 :               p->balance = 0;
   10114                 :           9 :               break;
   10115                 :             :             }
   10116                 :             :         }
   10117                 :             : 
   10118                 :        1174 :       r = p;
   10119                 :        1174 :       p = p->parent;
   10120                 :             :     }
   10121                 :             : }
   10122                 :             : 
   10123                 :             : /* Build AVL tree from a sorted chain.  */
   10124                 :             : 
   10125                 :             : static void
   10126                 :         176 : set_nonincremental_init (struct obstack * braced_init_obstack)
   10127                 :             : {
   10128                 :         176 :   unsigned HOST_WIDE_INT ix;
   10129                 :         176 :   tree index, value;
   10130                 :             : 
   10131                 :         176 :   if (TREE_CODE (constructor_type) != RECORD_TYPE
   10132                 :         176 :       && TREE_CODE (constructor_type) != ARRAY_TYPE)
   10133                 :             :     return;
   10134                 :             : 
   10135                 :         749 :   FOR_EACH_CONSTRUCTOR_ELT (constructor_elements, ix, index, value)
   10136                 :         573 :     add_pending_init (input_location, index, value, NULL_TREE, true,
   10137                 :             :                       braced_init_obstack);
   10138                 :         176 :   constructor_elements = NULL;
   10139                 :         176 :   if (TREE_CODE (constructor_type) == RECORD_TYPE)
   10140                 :             :     {
   10141                 :         108 :       constructor_unfilled_fields = TYPE_FIELDS (constructor_type);
   10142                 :             :       /* Skip any nameless bit fields at the beginning.  */
   10143                 :         108 :       while (constructor_unfilled_fields != NULL_TREE
   10144                 :         108 :              && DECL_UNNAMED_BIT_FIELD (constructor_unfilled_fields))
   10145                 :           0 :         constructor_unfilled_fields = TREE_CHAIN (constructor_unfilled_fields);
   10146                 :             : 
   10147                 :             :     }
   10148                 :          68 :   else if (TREE_CODE (constructor_type) == ARRAY_TYPE)
   10149                 :             :     {
   10150                 :          68 :       if (TYPE_DOMAIN (constructor_type))
   10151                 :          49 :         constructor_unfilled_index
   10152                 :          49 :             = convert (bitsizetype,
   10153                 :          49 :                        TYPE_MIN_VALUE (TYPE_DOMAIN (constructor_type)));
   10154                 :             :       else
   10155                 :          19 :         constructor_unfilled_index = bitsize_zero_node;
   10156                 :             :     }
   10157                 :         176 :   constructor_incremental = 0;
   10158                 :             : }
   10159                 :             : 
   10160                 :             : /* Build AVL tree from a string constant.  */
   10161                 :             : 
   10162                 :             : static void
   10163                 :           7 : set_nonincremental_init_from_string (tree str,
   10164                 :             :                                      struct obstack * braced_init_obstack)
   10165                 :             : {
   10166                 :           7 :   tree value, purpose, type;
   10167                 :           7 :   HOST_WIDE_INT val[2];
   10168                 :           7 :   const char *p, *end;
   10169                 :           7 :   int byte, wchar_bytes, charwidth, bitpos;
   10170                 :             : 
   10171                 :           7 :   gcc_assert (TREE_CODE (constructor_type) == ARRAY_TYPE);
   10172                 :             : 
   10173                 :           7 :   wchar_bytes = TYPE_PRECISION (TREE_TYPE (TREE_TYPE (str))) / BITS_PER_UNIT;
   10174                 :           7 :   charwidth = TYPE_PRECISION (char_type_node);
   10175                 :           7 :   gcc_assert ((size_t) wchar_bytes * charwidth
   10176                 :             :               <= ARRAY_SIZE (val) * HOST_BITS_PER_WIDE_INT);
   10177                 :           7 :   type = TREE_TYPE (constructor_type);
   10178                 :           7 :   p = TREE_STRING_POINTER (str);
   10179                 :           7 :   end = p + TREE_STRING_LENGTH (str);
   10180                 :             : 
   10181                 :           7 :   for (purpose = bitsize_zero_node;
   10182                 :             :        p < end
   10183                 :          52 :        && !(constructor_max_index
   10184                 :          20 :             && tree_int_cst_lt (constructor_max_index, purpose));
   10185                 :          25 :        purpose = size_binop (PLUS_EXPR, purpose, bitsize_one_node))
   10186                 :             :     {
   10187                 :          25 :       if (wchar_bytes == 1)
   10188                 :             :         {
   10189                 :           9 :           val[0] = (unsigned char) *p++;
   10190                 :           9 :           val[1] = 0;
   10191                 :             :         }
   10192                 :             :       else
   10193                 :             :         {
   10194                 :          16 :           val[1] = 0;
   10195                 :          16 :           val[0] = 0;
   10196                 :          64 :           for (byte = 0; byte < wchar_bytes; byte++)
   10197                 :             :             {
   10198                 :          48 :               if (BYTES_BIG_ENDIAN)
   10199                 :             :                 bitpos = (wchar_bytes - byte - 1) * charwidth;
   10200                 :             :               else
   10201                 :          48 :                 bitpos = byte * charwidth;
   10202                 :          48 :               val[bitpos / HOST_BITS_PER_WIDE_INT]
   10203                 :          48 :                 |= ((unsigned HOST_WIDE_INT) ((unsigned char) *p++))
   10204                 :          48 :                    << (bitpos % HOST_BITS_PER_WIDE_INT);
   10205                 :             :             }
   10206                 :             :         }
   10207                 :             : 
   10208                 :          25 :       if (!TYPE_UNSIGNED (type))
   10209                 :             :         {
   10210                 :          13 :           bitpos = ((wchar_bytes - 1) * charwidth) + HOST_BITS_PER_CHAR;
   10211                 :          13 :           if (bitpos < HOST_BITS_PER_WIDE_INT)
   10212                 :             :             {
   10213                 :          13 :               if (val[0] & (HOST_WIDE_INT_1 << (bitpos - 1)))
   10214                 :             :                 {
   10215                 :           0 :                   val[0] |= HOST_WIDE_INT_M1U << bitpos;
   10216                 :           0 :                   val[1] = -1;
   10217                 :             :                 }
   10218                 :             :             }
   10219                 :           0 :           else if (bitpos == HOST_BITS_PER_WIDE_INT)
   10220                 :             :             {
   10221                 :           0 :               if (val[0] < 0)
   10222                 :           0 :                 val[1] = -1;
   10223                 :             :             }
   10224                 :           0 :           else if (val[1] & (HOST_WIDE_INT_1
   10225                 :           0 :                              << (bitpos - 1 - HOST_BITS_PER_WIDE_INT)))
   10226                 :           0 :             val[1] |= HOST_WIDE_INT_M1U << (bitpos - HOST_BITS_PER_WIDE_INT);
   10227                 :             :         }
   10228                 :             : 
   10229                 :          25 :       value = wide_int_to_tree (type,
   10230                 :          25 :                                 wide_int::from_array (val, 2,
   10231                 :             :                                                       HOST_BITS_PER_WIDE_INT * 2));
   10232                 :          25 :       add_pending_init (input_location, purpose, value, NULL_TREE, true,
   10233                 :             :                         braced_init_obstack);
   10234                 :             :     }
   10235                 :             : 
   10236                 :           7 :   constructor_incremental = 0;
   10237                 :           7 : }
   10238                 :             : 
   10239                 :             : /* Return value of FIELD in pending initializer or NULL_TREE if the field was
   10240                 :             :    not initialized yet.  */
   10241                 :             : 
   10242                 :             : static tree
   10243                 :      703198 : find_init_member (tree field, struct obstack * braced_init_obstack)
   10244                 :             : {
   10245                 :      703198 :   struct init_node *p;
   10246                 :             : 
   10247                 :      703198 :   if (TREE_CODE (constructor_type) == ARRAY_TYPE)
   10248                 :             :     {
   10249                 :      702634 :       if (constructor_incremental
   10250                 :      702634 :           && tree_int_cst_lt (field, constructor_unfilled_index))
   10251                 :          14 :         set_nonincremental_init (braced_init_obstack);
   10252                 :             : 
   10253                 :      702634 :       p = constructor_pending_elts;
   10254                 :      702673 :       while (p)
   10255                 :             :         {
   10256                 :          74 :           if (tree_int_cst_lt (field, p->purpose))
   10257                 :           3 :             p = p->left;
   10258                 :          71 :           else if (tree_int_cst_lt (p->purpose, field))
   10259                 :          36 :             p = p->right;
   10260                 :             :           else
   10261                 :          35 :             return p->value;
   10262                 :             :         }
   10263                 :             :     }
   10264                 :         564 :   else if (TREE_CODE (constructor_type) == RECORD_TYPE)
   10265                 :             :     {
   10266                 :         445 :       tree bitpos = bit_position (field);
   10267                 :             : 
   10268                 :         445 :       if (constructor_incremental
   10269                 :         445 :           && (!constructor_unfilled_fields
   10270                 :         359 :               || tree_int_cst_lt (bitpos,
   10271                 :         359 :                                   bit_position (constructor_unfilled_fields))))
   10272                 :          24 :         set_nonincremental_init (braced_init_obstack);
   10273                 :             : 
   10274                 :         445 :       p = constructor_pending_elts;
   10275                 :         466 :       while (p)
   10276                 :             :         {
   10277                 :         107 :           if (field == p->purpose)
   10278                 :          86 :             return p->value;
   10279                 :          21 :           else if (tree_int_cst_lt (bitpos, bit_position (p->purpose)))
   10280                 :           3 :             p = p->left;
   10281                 :             :           else
   10282                 :          18 :             p = p->right;
   10283                 :             :         }
   10284                 :             :     }
   10285                 :         119 :   else if (TREE_CODE (constructor_type) == UNION_TYPE)
   10286                 :             :     {
   10287                 :         119 :       if (!vec_safe_is_empty (constructor_elements)
   10288                 :          50 :           && (constructor_elements->last ().index == field))
   10289                 :          50 :         return constructor_elements->last ().value;
   10290                 :             :     }
   10291                 :             :   return NULL_TREE;
   10292                 :             : }
   10293                 :             : 
   10294                 :             : /* "Output" the next constructor element.
   10295                 :             :    At top level, really output it to assembler code now.
   10296                 :             :    Otherwise, collect it in a list from which we will make a CONSTRUCTOR.
   10297                 :             :    If ORIGTYPE is not NULL_TREE, it is the original type of VALUE.
   10298                 :             :    TYPE is the data type that the containing data type wants here.
   10299                 :             :    FIELD is the field (a FIELD_DECL) or the index that this element fills.
   10300                 :             :    If VALUE is a string constant, STRICT_STRING is true if it is
   10301                 :             :    unparenthesized or we should not warn here for it being parenthesized.
   10302                 :             :    For other types of VALUE, STRICT_STRING is not used.
   10303                 :             : 
   10304                 :             :    PENDING if true means output pending elements that belong
   10305                 :             :    right after this element.  (PENDING is normally true;
   10306                 :             :    it is false while outputting pending elements, to avoid recursion.)
   10307                 :             : 
   10308                 :             :    IMPLICIT is true if value comes from pop_init_level (1),
   10309                 :             :    the new initializer has been merged with the existing one
   10310                 :             :    and thus no warnings should be emitted about overriding an
   10311                 :             :    existing initializer.  */
   10312                 :             : 
   10313                 :             : static void
   10314                 :     9359560 : output_init_element (location_t loc, tree value, tree origtype,
   10315                 :             :                      bool strict_string, tree type, tree field, bool pending,
   10316                 :             :                      bool implicit, struct obstack * braced_init_obstack)
   10317                 :             : {
   10318                 :     9359560 :   tree semantic_type = NULL_TREE;
   10319                 :     9359560 :   bool maybe_const = true;
   10320                 :     9359560 :   bool npc, int_const_expr, arith_const_expr;
   10321                 :             : 
   10322                 :     9359560 :   if (type == error_mark_node || value == error_mark_node)
   10323                 :             :     {
   10324                 :         344 :       constructor_erroneous = 1;
   10325                 :        1926 :       return;
   10326                 :             :     }
   10327                 :     9359216 :   if (TREE_CODE (TREE_TYPE (value)) == ARRAY_TYPE
   10328                 :      198561 :       && (TREE_CODE (value) == STRING_CST
   10329                 :      157451 :           || TREE_CODE (value) == COMPOUND_LITERAL_EXPR)
   10330                 :       41118 :       && !(TREE_CODE (value) == STRING_CST
   10331                 :       41110 :            && TREE_CODE (type) == ARRAY_TYPE
   10332                 :        3736 :            && INTEGRAL_TYPE_P (TREE_TYPE (type)))
   10333                 :     9396598 :       && !comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (value)),
   10334                 :       37382 :                      TYPE_MAIN_VARIANT (type)))
   10335                 :       37382 :     value = array_to_pointer_conversion (input_location, value);
   10336                 :             : 
   10337                 :     9359216 :   if (TREE_CODE (value) == COMPOUND_LITERAL_EXPR
   10338                 :         178 :       && require_constant_value && pending)
   10339                 :             :     {
   10340                 :             :       /* As an extension, allow initializing objects with static storage
   10341                 :             :          duration with compound literals (which are then treated just as
   10342                 :             :          the brace enclosed list they contain).  */
   10343                 :         114 :       if (flag_isoc99)
   10344                 :          24 :         pedwarn_init (loc, OPT_Wpedantic, "initializer element is not "
   10345                 :             :                       "constant");
   10346                 :         114 :       tree decl = COMPOUND_LITERAL_EXPR_DECL (value);
   10347                 :         114 :       value = DECL_INITIAL (decl);
   10348                 :             :     }
   10349                 :             : 
   10350                 :     9359216 :   npc = null_pointer_constant_p (value);
   10351                 :    18718432 :   int_const_expr = (TREE_CODE (value) == INTEGER_CST
   10352                 :     4126452 :                     && !TREE_OVERFLOW (value)
   10353                 :    13485667 :                     && INTEGRAL_TYPE_P (TREE_TYPE (value)));
   10354                 :             :   /* Not fully determined before folding.  */
   10355                 :     9359216 :   arith_const_expr = true;
   10356                 :     9359216 :   if (TREE_CODE (value) == EXCESS_PRECISION_EXPR)
   10357                 :             :     {
   10358                 :          16 :       semantic_type = TREE_TYPE (value);
   10359                 :          16 :       value = TREE_OPERAND (value, 0);
   10360                 :             :     }
   10361                 :     9359216 :   value = c_fully_fold (value, require_constant_value, &maybe_const);
   10362                 :             :   /* TODO: this may not detect all cases of expressions folding to
   10363                 :             :      constants that are not arithmetic constant expressions.  */
   10364                 :     9359216 :   if (!maybe_const)
   10365                 :             :     arith_const_expr = false;
   10366                 :    18716293 :   else if (!INTEGRAL_TYPE_P (TREE_TYPE (value))
   10367                 :     3085632 :       && TREE_CODE (TREE_TYPE (value)) != REAL_TYPE
   10368                 :    11196489 :       && TREE_CODE (TREE_TYPE (value)) != COMPLEX_TYPE)
   10369                 :             :     arith_const_expr = false;
   10370                 :     7534589 :   else if (TREE_CODE (value) != INTEGER_CST
   10371                 :             :       && TREE_CODE (value) != REAL_CST
   10372                 :             :       && TREE_CODE (value) != COMPLEX_CST)
   10373                 :             :     arith_const_expr = false;
   10374                 :     4482565 :   else if (TREE_OVERFLOW (value))
   10375                 :     4876652 :     arith_const_expr = false;
   10376                 :             : 
   10377                 :     9359216 :   if (value == error_mark_node)
   10378                 :           0 :     constructor_erroneous = 1;
   10379                 :     9359216 :   else if (!TREE_CONSTANT (value))
   10380                 :     3071253 :     constructor_constant = 0;
   10381                 :     6287963 :   else if (!initializer_constant_valid_p (value,
   10382                 :     6287963 :                                           TREE_TYPE (value),
   10383                 :     6287963 :                                           AGGREGATE_TYPE_P (constructor_type)
   10384                 :     6287963 :                                           && TYPE_REVERSE_STORAGE_ORDER
   10385                 :             :                                              (constructor_type))
   10386                 :     6287963 :            || (RECORD_OR_UNION_TYPE_P (constructor_type)
   10387                 :     1034871 :                && DECL_C_BIT_FIELD (field)
   10388                 :        7842 :                && TREE_CODE (value) != INTEGER_CST))
   10389                 :          76 :     constructor_simple = 0;
   10390                 :     9359216 :   if (!maybe_const)
   10391                 :         968 :     constructor_nonconst = 1;
   10392                 :             : 
   10393                 :             :   /* Digest the initializer and issue any errors about incompatible
   10394                 :             :      types before issuing errors about non-constant initializers.  */
   10395                 :     9359216 :   tree new_value = value;
   10396                 :     9359216 :   if (semantic_type)
   10397                 :          16 :     new_value = build1 (EXCESS_PRECISION_EXPR, semantic_type, value);
   10398                 :             :   /* In the case of braces around a scalar initializer, the result of
   10399                 :             :      this initializer processing goes through digest_init again at the
   10400                 :             :      outer level.  In the case of a constexpr initializer for a
   10401                 :             :      pointer, avoid converting a null pointer constant to something
   10402                 :             :      that is not a null pointer constant to avoid a spurious error
   10403                 :             :      from that second processing.  */
   10404                 :     9359216 :   if (!require_constexpr_value
   10405                 :         385 :       || !npc
   10406                 :          69 :       || TREE_CODE (constructor_type) != POINTER_TYPE)
   10407                 :     9359205 :     new_value = digest_init (loc, type, new_value, origtype, npc,
   10408                 :             :                              int_const_expr, arith_const_expr, strict_string,
   10409                 :             :                              require_constant_value, require_constexpr_value);
   10410                 :     9359216 :   if (new_value == error_mark_node)
   10411                 :             :     {
   10412                 :          76 :       constructor_erroneous = 1;
   10413                 :          76 :       return;
   10414                 :             :     }
   10415                 :     9359140 :   if (require_constant_value || require_constant_elements)
   10416                 :     2707284 :     constant_expression_warning (new_value);
   10417                 :             : 
   10418                 :             :   /* Proceed to check the constness of the original initializer.  */
   10419                 :     9359140 :   if (!initializer_constant_valid_p (value, TREE_TYPE (value)))
   10420                 :             :     {
   10421                 :     3071278 :       if (require_constant_value)
   10422                 :             :         {
   10423                 :           0 :           error_init (loc, "initializer element is not constant");
   10424                 :           0 :           value = error_mark_node;
   10425                 :             :         }
   10426                 :     3071278 :       else if (require_constant_elements)
   10427                 :           9 :         pedwarn (loc, OPT_Wpedantic,
   10428                 :             :                  "initializer element is not computable at load time");
   10429                 :             :     }
   10430                 :     6287862 :   else if (!maybe_const
   10431                 :          53 :            && (require_constant_value || require_constant_elements))
   10432                 :          27 :     pedwarn_init (loc, OPT_Wpedantic,
   10433                 :             :                   "initializer element is not a constant expression");
   10434                 :             :   /* digest_init has already carried out the additional checks
   10435                 :             :      required for 'constexpr' initializers (using the information
   10436                 :             :      passed to it about whether the original initializer was certain
   10437                 :             :      kinds of constant expression), so that check does not need to be
   10438                 :             :      repeated here.  */
   10439                 :             : 
   10440                 :             :   /* Issue -Wc++-compat warnings about initializing a bitfield with
   10441                 :             :      enum type.  */
   10442                 :     9359140 :   if (warn_cxx_compat
   10443                 :        2650 :       && field != NULL_TREE
   10444                 :        2650 :       && TREE_CODE (field) == FIELD_DECL
   10445                 :         286 :       && DECL_BIT_FIELD_TYPE (field) != NULL_TREE
   10446                 :          21 :       && (TYPE_MAIN_VARIANT (DECL_BIT_FIELD_TYPE (field))
   10447                 :          21 :           != TYPE_MAIN_VARIANT (type))
   10448                 :     9359161 :       && TREE_CODE (DECL_BIT_FIELD_TYPE (field)) == ENUMERAL_TYPE)
   10449                 :             :     {
   10450                 :          21 :       tree checktype = origtype != NULL_TREE ? origtype : TREE_TYPE (value);
   10451                 :          21 :       if (checktype != error_mark_node
   10452                 :          21 :           && (TYPE_MAIN_VARIANT (checktype)
   10453                 :          21 :               != TYPE_MAIN_VARIANT (DECL_BIT_FIELD_TYPE (field))))
   10454                 :           9 :         warning_init (loc, OPT_Wc___compat,
   10455                 :             :                       "enum conversion in initialization is invalid in C++");
   10456                 :             :     }
   10457                 :             : 
   10458                 :             :   /* If this field is empty and does not have side effects (and is not at
   10459                 :             :      the end of structure), don't do anything other than checking the
   10460                 :             :      initializer.  */
   10461                 :     9359140 :   if (field
   10462                 :     9359140 :       && (TREE_TYPE (field) == error_mark_node
   10463                 :     9358773 :           || (COMPLETE_TYPE_P (TREE_TYPE (field))
   10464                 :     9358521 :               && integer_zerop (TYPE_SIZE (TREE_TYPE (field)))
   10465                 :          55 :               && !TREE_SIDE_EFFECTS (new_value)
   10466                 :          26 :               && (TREE_CODE (constructor_type) == ARRAY_TYPE
   10467                 :          26 :                   || DECL_CHAIN (field)))))
   10468                 :          11 :     return;
   10469                 :             : 
   10470                 :             :   /* Finally, set VALUE to the initializer value digested above.  */
   10471                 :     9359129 :   value = new_value;
   10472                 :             : 
   10473                 :             :   /* If this element doesn't come next in sequence,
   10474                 :             :      put it on constructor_pending_elts.  */
   10475                 :     9359129 :   if (TREE_CODE (constructor_type) == ARRAY_TYPE
   10476                 :     9359129 :       && (!constructor_incremental
   10477                 :     1718706 :           || !tree_int_cst_equal (field, constructor_unfilled_index)))
   10478                 :             :     {
   10479                 :         337 :       if (constructor_incremental
   10480                 :         337 :           && tree_int_cst_lt (field, constructor_unfilled_index))
   10481                 :          11 :         set_nonincremental_init (braced_init_obstack);
   10482                 :             : 
   10483                 :         337 :       add_pending_init (loc, field, value, origtype, implicit,
   10484                 :             :                         braced_init_obstack);
   10485                 :         337 :       return;
   10486                 :             :     }
   10487                 :     9358792 :   else if (TREE_CODE (constructor_type) == RECORD_TYPE
   10488                 :     1036222 :            && (!constructor_incremental
   10489                 :     1036059 :                || field != constructor_unfilled_fields))
   10490                 :             :     {
   10491                 :             :       /* We do this for records but not for unions.  In a union,
   10492                 :             :          no matter which field is specified, it can be initialized
   10493                 :             :          right away since it starts at the beginning of the union.  */
   10494                 :        1158 :       if (constructor_incremental)
   10495                 :             :         {
   10496                 :         995 :           if (!constructor_unfilled_fields)
   10497                 :           5 :             set_nonincremental_init (braced_init_obstack);
   10498                 :             :           else
   10499                 :             :             {
   10500                 :         990 :               tree bitpos, unfillpos;
   10501                 :             : 
   10502                 :         990 :               bitpos = bit_position (field);
   10503                 :         990 :               unfillpos = bit_position (constructor_unfilled_fields);
   10504                 :             : 
   10505                 :         990 :               if (tree_int_cst_lt (bitpos, unfillpos))
   10506                 :           4 :                 set_nonincremental_init (braced_init_obstack);
   10507                 :             :             }
   10508                 :             :         }
   10509                 :             : 
   10510                 :        1158 :       add_pending_init (loc, field, value, origtype, implicit,
   10511                 :             :                         braced_init_obstack);
   10512                 :        1158 :       return;
   10513                 :             :     }
   10514                 :     9357634 :   else if (TREE_CODE (constructor_type) == UNION_TYPE
   10515                 :     9357634 :            && !vec_safe_is_empty (constructor_elements))
   10516                 :             :     {
   10517                 :          62 :       if (!implicit)
   10518                 :             :         {
   10519                 :          12 :           if (TREE_SIDE_EFFECTS (constructor_elements->last ().value))
   10520                 :           3 :             warning_init (loc, OPT_Woverride_init_side_effects,
   10521                 :             :                           "initialized field with side-effects overwritten");
   10522                 :           9 :           else if (warn_override_init)
   10523                 :           6 :             warning_init (loc, OPT_Woverride_init,
   10524                 :             :                           "initialized field overwritten");
   10525                 :             :         }
   10526                 :             : 
   10527                 :             :       /* We can have just one union field set.  */
   10528                 :          62 :       constructor_elements = NULL;
   10529                 :             :     }
   10530                 :             : 
   10531                 :             :   /* Otherwise, output this element either to
   10532                 :             :      constructor_elements or to the assembler file.  */
   10533                 :             : 
   10534                 :     9357634 :   constructor_elt celt = {field, value};
   10535                 :     9357634 :   vec_safe_push (constructor_elements, celt);
   10536                 :             : 
   10537                 :             :   /* Advance the variable that indicates sequential elements output.  */
   10538                 :     9357634 :   if (TREE_CODE (constructor_type) == ARRAY_TYPE)
   10539                 :     1718448 :     constructor_unfilled_index
   10540                 :     1718448 :       = size_binop_loc (input_location, PLUS_EXPR, constructor_unfilled_index,
   10541                 :             :                         bitsize_one_node);
   10542                 :     7639186 :   else if (TREE_CODE (constructor_type) == RECORD_TYPE)
   10543                 :             :     {
   10544                 :     1035064 :       constructor_unfilled_fields
   10545                 :     1035064 :         = DECL_CHAIN (constructor_unfilled_fields);
   10546                 :             : 
   10547                 :             :       /* Skip any nameless bit fields.  */
   10548                 :     1035064 :       while (constructor_unfilled_fields != NULL_TREE
   10549                 :     1035163 :              && DECL_UNNAMED_BIT_FIELD (constructor_unfilled_fields))
   10550                 :         198 :         constructor_unfilled_fields =
   10551                 :          99 :           DECL_CHAIN (constructor_unfilled_fields);
   10552                 :             :     }
   10553                 :     6604122 :   else if (TREE_CODE (constructor_type) == UNION_TYPE)
   10554                 :       29234 :     constructor_unfilled_fields = NULL_TREE;
   10555                 :             : 
   10556                 :             :   /* Now output any pending elements which have become next.  */
   10557                 :     9357634 :   if (pending)
   10558                 :     9355717 :     output_pending_init_elements (0, braced_init_obstack);
   10559                 :             : }
   10560                 :             : 
   10561                 :             : /* For two FIELD_DECLs in the same chain, return -1 if field1
   10562                 :             :    comes before field2, 1 if field1 comes after field2 and
   10563                 :             :    0 if field1 == field2.  */
   10564                 :             : 
   10565                 :             : static int
   10566                 :        3476 : init_field_decl_cmp (tree field1, tree field2)
   10567                 :             : {
   10568                 :        3476 :   if (field1 == field2)
   10569                 :             :     return 0;
   10570                 :             : 
   10571                 :        1914 :   tree bitpos1 = bit_position (field1);
   10572                 :        1914 :   tree bitpos2 = bit_position (field2);
   10573                 :        1914 :   if (tree_int_cst_equal (bitpos1, bitpos2))
   10574                 :             :     {
   10575                 :             :       /* If one of the fields has non-zero bitsize, then that
   10576                 :             :          field must be the last one in a sequence of zero
   10577                 :             :          sized fields, fields after it will have bigger
   10578                 :             :          bit_position.  */
   10579                 :          15 :       if (TREE_TYPE (field1) != error_mark_node
   10580                 :          15 :           && COMPLETE_TYPE_P (TREE_TYPE (field1))
   10581                 :          30 :           && integer_nonzerop (TREE_TYPE (field1)))
   10582                 :             :         return 1;
   10583                 :          15 :       if (TREE_TYPE (field2) != error_mark_node
   10584                 :          15 :           && COMPLETE_TYPE_P (TREE_TYPE (field2))
   10585                 :          30 :           && integer_nonzerop (TREE_TYPE (field2)))
   10586                 :             :         return -1;
   10587                 :             :       /* Otherwise, fallback to DECL_CHAIN walk to find out
   10588                 :             :          which field comes earlier.  Walk chains of both
   10589                 :             :          fields, so that if field1 and field2 are close to each
   10590                 :             :          other in either order, it is found soon even for large
   10591                 :             :          sequences of zero sized fields.  */
   10592                 :             :       tree f1 = field1, f2 = field2;
   10593                 :          15 :       while (1)
   10594                 :             :         {
   10595                 :          15 :           f1 = DECL_CHAIN (f1);
   10596                 :          15 :           f2 = DECL_CHAIN (f2);
   10597                 :          15 :           if (f1 == NULL_TREE)
   10598                 :             :             {
   10599                 :           7 :               gcc_assert (f2);
   10600                 :             :               return 1;
   10601                 :             :             }
   10602                 :           8 :           if (f2 == NULL_TREE)
   10603                 :             :             return -1;
   10604                 :           1 :           if (f1 == field2)
   10605                 :             :             return -1;
   10606                 :           0 :           if (f2 == field1)
   10607                 :             :             return 1;
   10608                 :           0 :           if (!tree_int_cst_equal (bit_position (f1), bitpos1))
   10609                 :             :             return 1;
   10610                 :           0 :           if (!tree_int_cst_equal (bit_position (f2), bitpos1))
   10611                 :             :             return -1;
   10612                 :             :         }
   10613                 :             :     }
   10614                 :        1899 :   else if (tree_int_cst_lt (bitpos1, bitpos2))
   10615                 :             :     return -1;
   10616                 :             :   else
   10617                 :             :     return 1;
   10618                 :             : }
   10619                 :             : 
   10620                 :             : /* Output any pending elements which have become next.
   10621                 :             :    As we output elements, constructor_unfilled_{fields,index}
   10622                 :             :    advances, which may cause other elements to become next;
   10623                 :             :    if so, they too are output.
   10624                 :             : 
   10625                 :             :    If ALL is 0, we return when there are
   10626                 :             :    no more pending elements to output now.
   10627                 :             : 
   10628                 :             :    If ALL is 1, we output space as necessary so that
   10629                 :             :    we can output all the pending elements.  */
   10630                 :             : static void
   10631                 :    11368757 : output_pending_init_elements (int all, struct obstack * braced_init_obstack)
   10632                 :             : {
   10633                 :    11368757 :   struct init_node *elt = constructor_pending_elts;
   10634                 :    11369698 :   tree next;
   10635                 :             : 
   10636                 :    11369698 :  retry:
   10637                 :             : 
   10638                 :             :   /* Look through the whole pending tree.
   10639                 :             :      If we find an element that should be output now,
   10640                 :             :      output it.  Otherwise, set NEXT to the element
   10641                 :             :      that comes first among those still pending.  */
   10642                 :             : 
   10643                 :    11369698 :   next = NULL_TREE;
   10644                 :    11373247 :   while (elt)
   10645                 :             :     {
   10646                 :        5318 :       if (TREE_CODE (constructor_type) == ARRAY_TYPE)
   10647                 :             :         {
   10648                 :        1337 :           if (tree_int_cst_equal (elt->purpose,
   10649                 :             :                                   constructor_unfilled_index))
   10650                 :         515 :             output_init_element (input_location, elt->value, elt->origtype,
   10651                 :         515 :                                  true, TREE_TYPE (constructor_type),
   10652                 :             :                                  constructor_unfilled_index, false, false,
   10653                 :             :                                  braced_init_obstack);
   10654                 :         822 :           else if (tree_int_cst_lt (constructor_unfilled_index,
   10655                 :         822 :                                     elt->purpose))
   10656                 :             :             {
   10657                 :             :               /* Advance to the next smaller node.  */
   10658                 :         294 :               if (elt->left)
   10659                 :             :                 elt = elt->left;
   10660                 :             :               else
   10661                 :             :                 {
   10662                 :             :                   /* We have reached the smallest node bigger than the
   10663                 :             :                      current unfilled index.  Fill the space first.  */
   10664                 :         168 :                   next = elt->purpose;
   10665                 :         168 :                   break;
   10666                 :             :                 }
   10667                 :             :             }
   10668                 :             :           else
   10669                 :             :             {
   10670                 :             :               /* Advance to the next bigger node.  */
   10671                 :         528 :               if (elt->right)
   10672                 :             :                 elt = elt->right;
   10673                 :             :               else
   10674                 :             :                 {
   10675                 :             :                   /* We have reached the biggest node in a subtree.  Find
   10676                 :             :                      the parent of it, which is the next bigger node.  */
   10677                 :         528 :                   while (elt->parent && elt->parent->right == elt)
   10678                 :             :                     elt = elt->parent;
   10679                 :         343 :                   elt = elt->parent;
   10680                 :         469 :                   if (elt && tree_int_cst_lt (constructor_unfilled_index,
   10681                 :         126 :                                               elt->purpose))
   10682                 :             :                     {
   10683                 :          16 :                       next = elt->purpose;
   10684                 :          16 :                       break;
   10685                 :             :                     }
   10686                 :             :                 }
   10687                 :             :             }
   10688                 :             :         }
   10689                 :        3981 :       else if (RECORD_OR_UNION_TYPE_P (constructor_type))
   10690                 :             :         {
   10691                 :             :           /* If the current record is complete we are done.  */
   10692                 :        3981 :           if (constructor_unfilled_fields == NULL_TREE)
   10693                 :             :             break;
   10694                 :             : 
   10695                 :        3249 :           int cmp = init_field_decl_cmp (constructor_unfilled_fields,
   10696                 :             :                                          elt->purpose);
   10697                 :        3249 :           if (cmp == 0)
   10698                 :        1402 :             output_init_element (input_location, elt->value, elt->origtype,
   10699                 :        1402 :                                  true, TREE_TYPE (elt->purpose),
   10700                 :             :                                  elt->purpose, false, false,
   10701                 :             :                                  braced_init_obstack);
   10702                 :        1847 :           else if (cmp < 0)
   10703                 :             :             {
   10704                 :             :               /* Advance to the next smaller node.  */
   10705                 :        1020 :               if (elt->left)
   10706                 :             :                 elt = elt->left;
   10707                 :             :               else
   10708                 :             :                 {
   10709                 :             :                   /* We have reached the smallest node bigger than the
   10710                 :             :                      current unfilled field.  Fill the space first.  */
   10711                 :         786 :                   next = elt->purpose;
   10712                 :         786 :                   break;
   10713                 :             :                 }
   10714                 :             :             }
   10715                 :             :           else
   10716                 :             :             {
   10717                 :             :               /* Advance to the next bigger node.  */
   10718                 :         827 :               if (elt->right)
   10719                 :             :                 elt = elt->right;
   10720                 :             :               else
   10721                 :             :                 {
   10722                 :             :                   /* We have reached the biggest node in a subtree.  Find
   10723                 :             :                      the parent of it, which is the next bigger node.  */
   10724                 :         643 :                   while (elt->parent && elt->parent->right == elt)
   10725                 :             :                     elt = elt->parent;
   10726                 :         455 :                   elt = elt->parent;
   10727                 :         455 :                   if (elt
   10728                 :         455 :                       && init_field_decl_cmp (constructor_unfilled_fields,
   10729                 :             :                                               elt->purpose) < 0)
   10730                 :             :                     {
   10731                 :          67 :                       next = elt->purpose;
   10732                 :          67 :                       break;
   10733                 :             :                     }
   10734                 :             :                 }
   10735                 :             :             }
   10736                 :             :         }
   10737                 :             :     }
   10738                 :             : 
   10739                 :             :   /* Ordinarily return, but not if we want to output all
   10740                 :             :      and there are elements left.  */
   10741                 :    11369698 :   if (!(all && next != NULL_TREE))
   10742                 :    11368757 :     return;
   10743                 :             : 
   10744                 :             :   /* If it's not incremental, just skip over the gap, so that after
   10745                 :             :      jumping to retry we will output the next successive element.  */
   10746                 :         941 :   if (RECORD_OR_UNION_TYPE_P (constructor_type))
   10747                 :         787 :     constructor_unfilled_fields = next;
   10748                 :         154 :   else if (TREE_CODE (constructor_type) == ARRAY_TYPE)
   10749                 :         154 :     constructor_unfilled_index = next;
   10750                 :             : 
   10751                 :             :   /* ELT now points to the node in the pending tree with the next
   10752                 :             :      initializer to output.  */
   10753                 :         941 :   goto retry;
   10754                 :             : }
   10755                 :             : 
   10756                 :             : /* Expression VALUE coincides with the start of type TYPE in a braced
   10757                 :             :    initializer.  Return true if we should treat VALUE as initializing
   10758                 :             :    the first element of TYPE, false if we should treat it as initializing
   10759                 :             :    TYPE as a whole.
   10760                 :             : 
   10761                 :             :    If the initializer is clearly invalid, the question becomes:
   10762                 :             :    which choice gives the best error message?  */
   10763                 :             : 
   10764                 :             : static bool
   10765                 :     3481650 : initialize_elementwise_p (tree type, tree value)
   10766                 :             : {
   10767                 :     3481650 :   if (type == error_mark_node || value == error_mark_node)
   10768                 :             :     return false;
   10769                 :             : 
   10770                 :     3481327 :   gcc_checking_assert (TYPE_MAIN_VARIANT (type) == type);
   10771                 :             : 
   10772                 :     3481327 :   tree value_type = TREE_TYPE (value);
   10773                 :     3481327 :   if (value_type == error_mark_node)
   10774                 :             :     return false;
   10775                 :             : 
   10776                 :             :   /* GNU vectors can be initialized elementwise.  However, treat any
   10777                 :             :      kind of vector value as initializing the vector type as a whole,
   10778                 :             :      regardless of whether the value is a GNU vector.  Such initializers
   10779                 :             :      are valid if and only if they would have been valid in a non-braced
   10780                 :             :      initializer like:
   10781                 :             : 
   10782                 :             :         TYPE foo = VALUE;
   10783                 :             : 
   10784                 :             :      so recursing into the vector type would be at best confusing or at
   10785                 :             :      worst wrong.  For example, when -flax-vector-conversions is in effect,
   10786                 :             :      it's possible to initialize a V8HI from a V4SI, even though the vectors
   10787                 :             :      have different element types and different numbers of elements.  */
   10788                 :     3481327 :   if (gnu_vector_type_p (type))
   10789                 :       19056 :     return !VECTOR_TYPE_P (value_type);
   10790                 :             : 
   10791                 :     3462271 :   if (AGGREGATE_TYPE_P (type))
   10792                 :     1739605 :     return !comptypes (type, TYPE_MAIN_VARIANT (value_type));
   10793                 :             : 
   10794                 :             :   return false;
   10795                 :             : }
   10796                 :             : 
   10797                 :             : /* Add one non-braced element to the current constructor level.
   10798                 :             :    This adjusts the current position within the constructor's type.
   10799                 :             :    This may also start or terminate implicit levels
   10800                 :             :    to handle a partly-braced initializer.
   10801                 :             : 
   10802                 :             :    Once this has found the correct level for the new element,
   10803                 :             :    it calls output_init_element.
   10804                 :             : 
   10805                 :             :    IMPLICIT is true if value comes from pop_init_level (1),
   10806                 :             :    the new initializer has been merged with the existing one
   10807                 :             :    and thus no warnings should be emitted about overriding an
   10808                 :             :    existing initializer.  */
   10809                 :             : 
   10810                 :             : void
   10811                 :     9359153 : process_init_element (location_t loc, struct c_expr value, bool implicit,
   10812                 :             :                       struct obstack * braced_init_obstack)
   10813                 :             : {
   10814                 :     9359153 :   tree orig_value = value.value;
   10815                 :    18718306 :   int string_flag
   10816                 :     9359153 :     = (orig_value != NULL_TREE && TREE_CODE (orig_value) == STRING_CST);
   10817                 :     9359153 :   bool strict_string = value.original_code == STRING_CST;
   10818                 :     9359153 :   bool was_designated = designator_depth != 0;
   10819                 :             : 
   10820                 :     9359153 :   designator_depth = 0;
   10821                 :     9359153 :   designator_erroneous = 0;
   10822                 :             : 
   10823                 :     9359153 :   if (!implicit && value.value && !integer_zerop (value.value))
   10824                 :     7366405 :     constructor_zeroinit = 0;
   10825                 :             : 
   10826                 :             :   /* Handle superfluous braces around string cst as in
   10827                 :             :      char x[] = {"foo"}; */
   10828                 :     9359153 :   if (constructor_type
   10829                 :     9359025 :       && !was_designated
   10830                 :     9327350 :       && TREE_CODE (constructor_type) == ARRAY_TYPE
   10831                 :     1718305 :       && INTEGRAL_TYPE_P (TREE_TYPE (constructor_type))
   10832                 :    10109830 :       && integer_zerop (constructor_unfilled_index))
   10833                 :             :     {
   10834                 :      162039 :       if (constructor_stack->replacement_value.value)
   10835                 :             :         {
   10836                 :           8 :           error_init (loc, "excess elements in %qT initializer", constructor_type);
   10837                 :           8 :           return;
   10838                 :             :         }
   10839                 :      162031 :       else if (string_flag)
   10840                 :             :         {
   10841                 :         102 :           constructor_stack->replacement_value = value;
   10842                 :         102 :           return;
   10843                 :             :         }
   10844                 :             :     }
   10845                 :             : 
   10846                 :     9359043 :   if (constructor_stack->replacement_value.value != NULL_TREE)
   10847                 :             :     {
   10848                 :           0 :       error_init (loc, "excess elements in struct initializer");
   10849                 :           0 :       return;
   10850                 :             :     }
   10851                 :             : 
   10852                 :             :   /* Ignore elements of a brace group if it is entirely superfluous
   10853                 :             :      and has already been diagnosed, or if the type is erroneous.  */
   10854                 :     9359043 :   if (constructor_type == NULL_TREE || constructor_type == error_mark_node)
   10855                 :             :     return;
   10856                 :             : 
   10857                 :             :   /* Ignore elements of an initializer for a variable-size type.
   10858                 :             :      Those are diagnosed in the parser (empty initializer braces are OK).  */
   10859                 :     9358838 :   if (COMPLETE_TYPE_P (constructor_type)
   10860                 :     9358838 :       && !poly_int_tree_p (TYPE_SIZE (constructor_type)))
   10861                 :             :     return;
   10862                 :             : 
   10863                 :     8655588 :   if (!implicit && warn_designated_init && !was_designated
   10864                 :     8624241 :       && TREE_CODE (constructor_type) == RECORD_TYPE
   10865                 :    10391807 :       && lookup_attribute ("designated_init",
   10866                 :     1033021 :                            TYPE_ATTRIBUTES (constructor_type)))
   10867                 :          47 :     warning_init (loc,
   10868                 :             :                   OPT_Wdesignated_init,
   10869                 :             :                   "positional initialization of field "
   10870                 :             :                   "in %<struct%> declared with %<designated_init%> attribute");
   10871                 :             : 
   10872                 :             :   /* If we've exhausted any levels that didn't have braces,
   10873                 :             :      pop them now.  */
   10874                 :    10060700 :   while (constructor_stack->implicit)
   10875                 :             :     {
   10876                 :      704672 :       if (RECORD_OR_UNION_TYPE_P (constructor_type)
   10877                 :      702546 :           && constructor_fields == NULL_TREE)
   10878                 :      701699 :         process_init_element (loc,
   10879                 :             :                               pop_init_level (loc, 1, braced_init_obstack,
   10880                 :             :                                               last_init_list_comma),
   10881                 :             :                               true, braced_init_obstack);
   10882                 :        2973 :       else if ((TREE_CODE (constructor_type) == ARRAY_TYPE
   10883                 :        1427 :                 || gnu_vector_type_p (constructor_type))
   10884                 :        2126 :                && constructor_max_index
   10885                 :        5072 :                && tree_int_cst_lt (constructor_max_index,
   10886                 :             :                                    constructor_index))
   10887                 :         215 :         process_init_element (loc,
   10888                 :             :                               pop_init_level (loc, 1, braced_init_obstack,
   10889                 :             :                                               last_init_list_comma),
   10890                 :             :                               true, braced_init_obstack);
   10891                 :             :       else
   10892                 :             :         break;
   10893                 :             :     }
   10894                 :             : 
   10895                 :             :   /* In the case of [LO ... HI] = VALUE, only evaluate VALUE once.  */
   10896                 :     9358786 :   if (constructor_range_stack)
   10897                 :             :     {
   10898                 :             :       /* If value is a compound literal and we'll be just using its
   10899                 :             :          content, don't put it into a SAVE_EXPR.  */
   10900                 :          29 :       if (TREE_CODE (value.value) != COMPOUND_LITERAL_EXPR
   10901                 :           3 :           || !require_constant_value)
   10902                 :             :         {
   10903                 :          26 :           tree semantic_type = NULL_TREE;
   10904                 :          26 :           if (TREE_CODE (value.value) == EXCESS_PRECISION_EXPR)
   10905                 :             :             {
   10906                 :           0 :               semantic_type = TREE_TYPE (value.value);
   10907                 :           0 :               value.value = TREE_OPERAND (value.value, 0);
   10908                 :             :             }
   10909                 :          26 :           value.value = save_expr (value.value);
   10910                 :          26 :           if (semantic_type)
   10911                 :           0 :             value.value = build1 (EXCESS_PRECISION_EXPR, semantic_type,
   10912                 :             :                                   value.value);
   10913                 :             :         }
   10914                 :             :     }
   10915                 :             : 
   10916                 :    10061717 :   while (1)
   10917                 :             :     {
   10918                 :    10061717 :       if (TREE_CODE (constructor_type) == RECORD_TYPE)
   10919                 :             :         {
   10920                 :     1036481 :           tree fieldtype;
   10921                 :     1036481 :           enum tree_code fieldcode;
   10922                 :             : 
   10923                 :     1036481 :           if (constructor_fields == NULL_TREE)
   10924                 :             :             {
   10925                 :        1280 :               pedwarn_init (loc, 0, "excess elements in struct initializer");
   10926                 :        1280 :               break;
   10927                 :             :             }
   10928                 :             : 
   10929                 :     1035201 :           fieldtype = TREE_TYPE (constructor_fields);
   10930                 :     1035201 :           if (fieldtype != error_mark_node)
   10931                 :     1035199 :             fieldtype = TYPE_MAIN_VARIANT (fieldtype);
   10932                 :     1035201 :           fieldcode = TREE_CODE (fieldtype);
   10933                 :             : 
   10934                 :             :           /* Error for non-static initialization of a flexible array member.  */
   10935                 :     1035201 :           if (fieldcode == ARRAY_TYPE
   10936                 :      154940 :               && !require_constant_value
   10937                 :         939 :               && TYPE_SIZE (fieldtype) == NULL_TREE
   10938                 :     1035211 :               && DECL_CHAIN (constructor_fields) == NULL_TREE)
   10939                 :             :             {
   10940                 :          10 :               error_init (loc, "non-static initialization of a flexible "
   10941                 :             :                           "array member");
   10942                 :          10 :               break;
   10943                 :             :             }
   10944                 :             : 
   10945                 :             :           /* Error for initialization of a flexible array member with
   10946                 :             :              a string constant if the structure is in an array.  E.g.:
   10947                 :             :              struct S { int x; char y[]; };
   10948                 :             :              struct S s[] = { { 1, "foo" } };
   10949                 :             :              is invalid.  */
   10950                 :     1035191 :           if (string_flag
   10951                 :     1035191 :               && fieldcode == ARRAY_TYPE
   10952                 :        3317 :               && constructor_depth > 1
   10953                 :         489 :               && TYPE_SIZE (fieldtype) == NULL_TREE
   10954                 :     1035238 :               && DECL_CHAIN (constructor_fields) == NULL_TREE)
   10955                 :             :             {
   10956                 :          47 :               bool in_array_p = false;
   10957                 :          47 :               for (struct constructor_stack *p = constructor_stack;
   10958                 :          73 :                    p && p->type; p = p->next)
   10959                 :          59 :                 if (TREE_CODE (p->type) == ARRAY_TYPE)
   10960                 :             :                   {
   10961                 :             :                     in_array_p = true;
   10962                 :             :                     break;
   10963                 :             :                   }
   10964                 :          47 :               if (in_array_p)
   10965                 :             :                 {
   10966                 :          33 :                   error_init (loc, "initialization of flexible array "
   10967                 :             :                               "member in a nested context");
   10968                 :          33 :                   break;
   10969                 :             :                 }
   10970                 :             :             }
   10971                 :             : 
   10972                 :             :           /* Accept a string constant to initialize a subarray.  */
   10973                 :     1035158 :           if (value.value != NULL_TREE
   10974                 :     1035097 :               && fieldcode == ARRAY_TYPE
   10975                 :      154836 :               && INTEGRAL_TYPE_P (TREE_TYPE (fieldtype))
   10976                 :     1189657 :               && string_flag)
   10977                 :             :             value.value = orig_value;
   10978                 :             :           /* Otherwise, if we have come to a subaggregate,
   10979                 :             :              and we don't have an element of its type, push into it.  */
   10980                 :     1032117 :           else if (value.value != NULL_TREE
   10981                 :     1031874 :                    && initialize_elementwise_p (fieldtype, value.value))
   10982                 :             :             {
   10983                 :         243 :               push_init_level (loc, 1, braced_init_obstack);
   10984                 :         243 :               continue;
   10985                 :             :             }
   10986                 :             : 
   10987                 :     1034915 :           if (value.value)
   10988                 :             :             {
   10989                 :     1034854 :               push_member_name (constructor_fields);
   10990                 :     1034854 :               output_init_element (loc, value.value, value.original_type,
   10991                 :             :                                    strict_string, fieldtype,
   10992                 :             :                                    constructor_fields, true, implicit,
   10993                 :             :                                    braced_init_obstack);
   10994                 :     1034854 :               RESTORE_SPELLING_DEPTH (constructor_depth);
   10995                 :             :             }
   10996                 :             :           else
   10997                 :             :             /* Do the bookkeeping for an element that was
   10998                 :             :                directly output as a constructor.  */
   10999                 :             :             {
   11000                 :             :               /* For a record, keep track of end position of last field.  */
   11001                 :          61 :               if (DECL_SIZE (constructor_fields))
   11002                 :          30 :                 constructor_bit_index
   11003                 :          30 :                   = size_binop_loc (input_location, PLUS_EXPR,
   11004                 :             :                                     bit_position (constructor_fields),
   11005                 :          30 :                                     DECL_SIZE (constructor_fields));
   11006                 :             : 
   11007                 :             :               /* If the current field was the first one not yet written out,
   11008                 :             :                  it isn't now, so update.  */
   11009                 :          61 :               if (constructor_unfilled_fields == constructor_fields)
   11010                 :             :                 {
   11011                 :          52 :                   constructor_unfilled_fields = DECL_CHAIN (constructor_fields);
   11012                 :             :                   /* Skip any nameless bit fields.  */
   11013                 :          52 :                   while (constructor_unfilled_fields != 0
   11014                 :          52 :                          && (DECL_UNNAMED_BIT_FIELD
   11015                 :             :                              (constructor_unfilled_fields)))
   11016                 :           0 :                     constructor_unfilled_fields =
   11017                 :           0 :                       DECL_CHAIN (constructor_unfilled_fields);
   11018                 :             :                 }
   11019                 :             :             }
   11020                 :             : 
   11021                 :     1034915 :           constructor_fields = DECL_CHAIN (constructor_fields);
   11022                 :             :           /* Skip any nameless bit fields at the beginning.  */
   11023                 :     1034915 :           while (constructor_fields != NULL_TREE
   11024                 :     1035014 :                  && DECL_UNNAMED_BIT_FIELD (constructor_fields))
   11025                 :          99 :             constructor_fields = DECL_CHAIN (constructor_fields);
   11026                 :             :         }
   11027                 :     9025236 :       else if (TREE_CODE (constructor_type) == UNION_TYPE)
   11028                 :             :         {
   11029                 :       29287 :           tree fieldtype;
   11030                 :       29287 :           enum tree_code fieldcode;
   11031                 :             : 
   11032                 :       29287 :           if (constructor_fields == NULL_TREE)
   11033                 :             :             {
   11034                 :           3 :               pedwarn_init (loc, 0,
   11035                 :             :                             "excess elements in union initializer");
   11036                 :           3 :               break;
   11037                 :             :             }
   11038                 :             : 
   11039                 :       29284 :           fieldtype = TREE_TYPE (constructor_fields);
   11040                 :       29284 :           if (fieldtype != error_mark_node)
   11041                 :       29284 :             fieldtype = TYPE_MAIN_VARIANT (fieldtype);
   11042                 :       29284 :           fieldcode = TREE_CODE (fieldtype);
   11043                 :             : 
   11044                 :             :           /* Warn that traditional C rejects initialization of unions.
   11045                 :             :              We skip the warning if the value is zero.  This is done
   11046                 :             :              under the assumption that the zero initializer in user
   11047                 :             :              code appears conditioned on e.g. __STDC__ to avoid
   11048                 :             :              "missing initializer" warnings and relies on default
   11049                 :             :              initialization to zero in the traditional C case.
   11050                 :             :              We also skip the warning if the initializer is designated,
   11051                 :             :              again on the assumption that this must be conditional on
   11052                 :             :              __STDC__ anyway (and we've already complained about the
   11053                 :             :              member-designator already).  */
   11054                 :       30574 :           if (!in_system_header_at (input_location) && !constructor_designated
   11055                 :       30013 :               && !(value.value && (integer_zerop (value.value)
   11056                 :         642 :                                    || real_zerop (value.value))))
   11057                 :         635 :             warning (OPT_Wtraditional, "traditional C rejects initialization "
   11058                 :             :                      "of unions");
   11059                 :             : 
   11060                 :             :           /* Accept a string constant to initialize a subarray.  */
   11061                 :       29284 :           if (value.value != NULL_TREE
   11062                 :       29284 :               && fieldcode == ARRAY_TYPE
   11063                 :          75 :               && INTEGRAL_TYPE_P (TREE_TYPE (fieldtype))
   11064                 :       29354 :               && string_flag)
   11065                 :             :             value.value = orig_value;
   11066                 :             :           /* Otherwise, if we have come to a subaggregate,
   11067                 :             :              and we don't have an element of its type, push into it.  */
   11068                 :       29329 :           else if (value.value != NULL_TREE
   11069                 :       29283 :                    && initialize_elementwise_p (fieldtype, value.value))
   11070                 :             :             {
   11071                 :          46 :               push_init_level (loc, 1, braced_init_obstack);
   11072                 :          46 :               continue;
   11073                 :             :             }
   11074                 :             : 
   11075                 :       29238 :           if (value.value)
   11076                 :             :             {
   11077                 :       29238 :               push_member_name (constructor_fields);
   11078                 :       29238 :               output_init_element (loc, value.value, value.original_type,
   11079                 :             :                                    strict_string, fieldtype,
   11080                 :             :                                    constructor_fields, true, implicit,
   11081                 :             :                                    braced_init_obstack);
   11082                 :       29238 :               RESTORE_SPELLING_DEPTH (constructor_depth);
   11083                 :             :             }
   11084                 :             :           else
   11085                 :             :             /* Do the bookkeeping for an element that was
   11086                 :             :                directly output as a constructor.  */
   11087                 :             :             {
   11088                 :           0 :               constructor_bit_index = DECL_SIZE (constructor_fields);
   11089                 :           0 :               constructor_unfilled_fields = DECL_CHAIN (constructor_fields);
   11090                 :             :             }
   11091                 :             : 
   11092                 :       29238 :           constructor_fields = NULL_TREE;
   11093                 :             :         }
   11094                 :     8995949 :       else if (TREE_CODE (constructor_type) == ARRAY_TYPE)
   11095                 :             :         {
   11096                 :     2420981 :           tree elttype = TYPE_MAIN_VARIANT (TREE_TYPE (constructor_type));
   11097                 :     2420981 :           enum tree_code eltcode = TREE_CODE (elttype);
   11098                 :             : 
   11099                 :             :           /* Accept a string constant to initialize a subarray.  */
   11100                 :     2420981 :           if (value.value != NULL_TREE
   11101                 :     2420981 :               && eltcode == ARRAY_TYPE
   11102                 :        6717 :               && INTEGRAL_TYPE_P (TREE_TYPE (elttype))
   11103                 :     2426308 :               && string_flag)
   11104                 :             :             value.value = orig_value;
   11105                 :             :           /* Otherwise, if we have come to a subaggregate,
   11106                 :             :              and we don't have an element of its type, push into it.  */
   11107                 :     3122810 :           else if (value.value != NULL_TREE
   11108                 :     2420554 :                    && initialize_elementwise_p (elttype, value.value))
   11109                 :             :             {
   11110                 :      702256 :               push_init_level (loc, 1, braced_init_obstack);
   11111                 :      702256 :               continue;
   11112                 :             :             }
   11113                 :             : 
   11114                 :     1718725 :           if (constructor_max_index != NULL_TREE
   11115                 :     1718725 :               && (tree_int_cst_lt (constructor_max_index, constructor_index)
   11116                 :      669124 :                   || integer_all_onesp (constructor_max_index)))
   11117                 :             :             {
   11118                 :         113 :               pedwarn_init (loc, 0,
   11119                 :             :                             "excess elements in array initializer");
   11120                 :         113 :               break;
   11121                 :             :             }
   11122                 :             : 
   11123                 :             :           /* Now output the actual element.  */
   11124                 :     1718612 :           if (value.value)
   11125                 :             :             {
   11126                 :     1718612 :               push_array_bounds (tree_to_uhwi (constructor_index));
   11127                 :     1718612 :               output_init_element (loc, value.value, value.original_type,
   11128                 :             :                                    strict_string, elttype,
   11129                 :             :                                    constructor_index, true, implicit,
   11130                 :             :                                    braced_init_obstack);
   11131                 :     1718612 :               RESTORE_SPELLING_DEPTH (constructor_depth);
   11132                 :             :             }
   11133                 :             : 
   11134                 :     1718612 :           constructor_index
   11135                 :     1718612 :             = size_binop_loc (input_location, PLUS_EXPR,
   11136                 :             :                               constructor_index, bitsize_one_node);
   11137                 :             : 
   11138                 :     1718612 :           if (!value.value)
   11139                 :             :             /* If we are doing the bookkeeping for an element that was
   11140                 :             :                directly output as a constructor, we must update
   11141                 :             :                constructor_unfilled_index.  */
   11142                 :           0 :             constructor_unfilled_index = constructor_index;
   11143                 :             :         }
   11144                 :     6574968 :       else if (gnu_vector_type_p (constructor_type))
   11145                 :             :         {
   11146                 :     6574546 :           tree elttype = TYPE_MAIN_VARIANT (TREE_TYPE (constructor_type));
   11147                 :             : 
   11148                 :             :          /* Do a basic check of initializer size.  Note that vectors
   11149                 :             :             always have a fixed size derived from their type.  */
   11150                 :     6574546 :           if (tree_int_cst_lt (constructor_max_index, constructor_index))
   11151                 :             :             {
   11152                 :           2 :               pedwarn_init (loc, 0,
   11153                 :             :                             "excess elements in vector initializer");
   11154                 :           2 :               break;
   11155                 :             :             }
   11156                 :             : 
   11157                 :             :           /* Now output the actual element.  */
   11158                 :     6574544 :           if (value.value)
   11159                 :             :             {
   11160                 :     6574544 :               if (TREE_CODE (value.value) == VECTOR_CST)
   11161                 :           0 :                 elttype = TYPE_MAIN_VARIANT (constructor_type);
   11162                 :     6574544 :               output_init_element (loc, value.value, value.original_type,
   11163                 :             :                                    strict_string, elttype,
   11164                 :             :                                    constructor_index, true, implicit,
   11165                 :             :                                    braced_init_obstack);
   11166                 :             :             }
   11167                 :             : 
   11168                 :     6574544 :           constructor_index
   11169                 :     6574544 :             = size_binop_loc (input_location,
   11170                 :             :                               PLUS_EXPR, constructor_index, bitsize_one_node);
   11171                 :             : 
   11172                 :     6574544 :           if (!value.value)
   11173                 :             :             /* If we are doing the bookkeeping for an element that was
   11174                 :             :                directly output as a constructor, we must update
   11175                 :             :                constructor_unfilled_index.  */
   11176                 :           0 :             constructor_unfilled_index = constructor_index;
   11177                 :             :         }
   11178                 :             : 
   11179                 :             :       /* Handle the sole element allowed in a braced initializer
   11180                 :             :          for a scalar variable.  */
   11181                 :         422 :       else if (constructor_type != error_mark_node
   11182                 :         422 :                && constructor_fields == NULL_TREE)
   11183                 :             :         {
   11184                 :          27 :           pedwarn_init (loc, 0,
   11185                 :             :                         "excess elements in scalar initializer");
   11186                 :          27 :           break;
   11187                 :             :         }
   11188                 :             :       else
   11189                 :             :         {
   11190                 :         395 :           if (value.value)
   11191                 :         395 :             output_init_element (loc, value.value, value.original_type,
   11192                 :             :                                  strict_string, constructor_type,
   11193                 :             :                                  NULL_TREE, true, implicit,
   11194                 :             :                                  braced_init_obstack);
   11195                 :         395 :           constructor_fields = NULL_TREE;
   11196                 :             :         }
   11197                 :             : 
   11198                 :             :       /* Handle range initializers either at this level or anywhere higher
   11199                 :             :          in the designator stack.  */
   11200                 :     9357704 :       if (constructor_range_stack)
   11201                 :             :         {
   11202                 :         386 :           struct constructor_range_stack *p, *range_stack;
   11203                 :         386 :           int finish = 0;
   11204                 :             : 
   11205                 :         386 :           range_stack = constructor_range_stack;
   11206                 :         386 :           constructor_range_stack = 0;
   11207                 :         386 :           while (constructor_stack != range_stack->stack)
   11208                 :             :             {
   11209                 :           0 :               gcc_assert (constructor_stack->implicit);
   11210                 :           0 :               process_init_element (loc,
   11211                 :             :                                     pop_init_level (loc, 1,
   11212                 :             :                                                     braced_init_obstack,
   11213                 :             :                                                     last_init_list_comma),
   11214                 :             :                                     true, braced_init_obstack);
   11215                 :             :             }
   11216                 :         325 :           for (p = range_stack;
   11217                 :         711 :                !p->range_end || tree_int_cst_equal (p->index, p->range_end);
   11218                 :         325 :                p = p->prev)
   11219                 :             :             {
   11220                 :         325 :               gcc_assert (constructor_stack->implicit);
   11221                 :         325 :               process_init_element (loc,
   11222                 :             :                                     pop_init_level (loc, 1,
   11223                 :             :                                                     braced_init_obstack,
   11224                 :             :                                                     last_init_list_comma),
   11225                 :             :                                     true, braced_init_obstack);
   11226                 :             :             }
   11227                 :             : 
   11228                 :         386 :           p->index = size_binop_loc (input_location,
   11229                 :             :                                      PLUS_EXPR, p->index, bitsize_one_node);
   11230                 :         386 :           if (tree_int_cst_equal (p->index, p->range_end) && !p->prev)
   11231                 :          37 :             finish = 1;
   11232                 :             : 
   11233                 :         711 :           while (1)
   11234                 :             :             {
   11235                 :         711 :               constructor_index = p->index;
   11236                 :         711 :               constructor_fields = p->fields;
   11237                 :         711 :               if (finish && p->range_end && p->index == p->range_start)
   11238                 :             :                 {
   11239                 :           8 :                   finish = 0;
   11240                 :           8 :                   p->prev = 0;
   11241                 :             :                 }
   11242                 :         711 :               p = p->next;
   11243                 :         711 :               if (!p)
   11244                 :             :                 break;
   11245                 :         325 :               finish_implicit_inits (loc, braced_init_obstack);
   11246                 :         325 :               push_init_level (loc, 2, braced_init_obstack);
   11247                 :         325 :               p->stack = constructor_stack;
   11248                 :         325 :               if (p->range_end && tree_int_cst_equal (p->index, p->range_end))
   11249                 :          33 :                 p->index = p->range_start;
   11250                 :             :             }
   11251                 :             : 
   11252                 :         386 :           if (!finish)
   11253                 :         357 :             constructor_range_stack = range_stack;
   11254                 :         386 :           continue;
   11255                 :         386 :         }
   11256                 :             : 
   11257                 :             :       break;
   11258                 :             :     }
   11259                 :             : 
   11260                 :     9358786 :   constructor_range_stack = 0;
   11261                 :             : }
   11262                 :             : 
   11263                 :             : /* Build a complete asm-statement, whose components are a CV_QUALIFIER
   11264                 :             :    (guaranteed to be 'volatile' or null) and ARGS (represented using
   11265                 :             :    an ASM_EXPR node).  */
   11266                 :             : tree
   11267                 :      198399 : build_asm_stmt (bool is_volatile, tree args)
   11268                 :             : {
   11269                 :      198399 :   if (is_volatile)
   11270                 :      159267 :     ASM_VOLATILE_P (args) = 1;
   11271                 :      198399 :   return add_stmt (args);
   11272                 :             : }
   11273                 :             : 
   11274                 :             : /* Build an asm-expr, whose components are a STRING, some OUTPUTS,
   11275                 :             :    some INPUTS, and some CLOBBERS.  The latter three may be NULL.
   11276                 :             :    SIMPLE indicates whether there was anything at all after the
   11277                 :             :    string in the asm expression -- asm("blah") and asm("blah" : )
   11278                 :             :    are subtly different.  We use a ASM_EXPR node to represent this.
   11279                 :             :    LOC is the location of the asm, and IS_INLINE says whether this
   11280                 :             :    is asm inline.  */
   11281                 :             : tree
   11282                 :      198399 : build_asm_expr (location_t loc, tree string, tree outputs, tree inputs,
   11283                 :             :                 tree clobbers, tree labels, bool simple, bool is_inline)
   11284                 :             : {
   11285                 :      198399 :   tree tail;
   11286                 :      198399 :   tree args;
   11287                 :      198399 :   int i;
   11288                 :      198399 :   const char *constraint;
   11289                 :      198399 :   const char **oconstraints;
   11290                 :      198399 :   bool allows_mem, allows_reg, is_inout;
   11291                 :      198399 :   int ninputs, noutputs;
   11292                 :             : 
   11293                 :      198399 :   ninputs = list_length (inputs);
   11294                 :      198399 :   noutputs = list_length (outputs);
   11295                 :      198399 :   oconstraints = (const char **) alloca (noutputs * sizeof (const char *));
   11296                 :             : 
   11297                 :      198399 :   string = resolve_asm_operand_names (string, outputs, inputs, labels);
   11298                 :             : 
   11299                 :             :   /* Remove output conversions that change the type but not the mode.  */
   11300                 :      532429 :   for (i = 0, tail = outputs; tail; ++i, tail = TREE_CHAIN (tail))
   11301                 :             :     {
   11302                 :      334030 :       tree output = TREE_VALUE (tail);
   11303                 :             : 
   11304                 :      334030 :       output = c_fully_fold (output, false, NULL, true);
   11305                 :             : 
   11306                 :             :       /* ??? Really, this should not be here.  Users should be using a
   11307                 :             :          proper lvalue, dammit.  But there's a long history of using casts
   11308                 :             :          in the output operands.  In cases like longlong.h, this becomes a
   11309                 :             :          primitive form of typechecking -- if the cast can be removed, then
   11310                 :             :          the output operand had a type of the proper width; otherwise we'll
   11311                 :             :          get an error.  Gross, but ...  */
   11312                 :      334030 :       STRIP_NOPS (output);
   11313                 :             : 
   11314                 :      334030 :       if (!lvalue_or_else (loc, output, lv_asm))
   11315                 :           1 :         output = error_mark_node;
   11316                 :             : 
   11317                 :      334030 :       if (output != error_mark_node
   11318                 :      334030 :           && (TREE_READONLY (output)
   11319                 :      334027 :               || TYPE_READONLY (TREE_TYPE (output))
   11320                 :      334027 :               || (RECORD_OR_UNION_TYPE_P (TREE_TYPE (output))
   11321                 :         111 :                   && C_TYPE_FIELDS_READONLY (TREE_TYPE (output)))))
   11322                 :           2 :         readonly_error (loc, output, lv_asm);
   11323                 :             : 
   11324                 :      334030 :       constraint = TREE_STRING_POINTER (TREE_VALUE (TREE_PURPOSE (tail)));
   11325                 :      334030 :       oconstraints[i] = constraint;
   11326                 :             : 
   11327                 :      334030 :       if (parse_output_constraint (&constraint, i, ninputs, noutputs,
   11328                 :             :                                    &allows_mem, &allows_reg, &is_inout))
   11329                 :             :         {
   11330                 :             :           /* If the operand is going to end up in memory,
   11331                 :             :              mark it addressable.  */
   11332                 :      334024 :           if (!allows_reg && !c_mark_addressable (output))
   11333                 :           3 :             output = error_mark_node;
   11334                 :        1074 :           if (!(!allows_reg && allows_mem)
   11335                 :      332950 :               && output != error_mark_node
   11336                 :      666973 :               && VOID_TYPE_P (TREE_TYPE (output)))
   11337                 :             :             {
   11338                 :           4 :               error_at (loc, "invalid use of void expression");
   11339                 :           4 :               output = error_mark_node;
   11340                 :             :             }
   11341                 :             :         }
   11342                 :             :       else
   11343                 :           6 :         output = error_mark_node;
   11344                 :             : 
   11345                 :      334030 :       TREE_VALUE (tail) = output;
   11346                 :             :     }
   11347                 :             : 
   11348                 :      549598 :   for (i = 0, tail = inputs; tail; ++i, tail = TREE_CHAIN (tail))
   11349                 :             :     {
   11350                 :      351199 :       tree input;
   11351                 :             : 
   11352                 :      351199 :       constraint = TREE_STRING_POINTER (TREE_VALUE (TREE_PURPOSE (tail)));
   11353                 :      351199 :       input = TREE_VALUE (tail);
   11354                 :             : 
   11355                 :      351199 :       if (parse_input_constraint (&constraint, i, ninputs, noutputs, 0,
   11356                 :             :                                   oconstraints, &allows_mem, &allows_reg))
   11357                 :             :         {
   11358                 :             :           /* If the operand is going to end up in memory,
   11359                 :             :              mark it addressable.  */
   11360                 :      351198 :           if (!allows_reg && allows_mem)
   11361                 :             :             {
   11362                 :        1028 :               input = c_fully_fold (input, false, NULL, true);
   11363                 :             : 
   11364                 :             :               /* Strip the nops as we allow this case.  FIXME, this really
   11365                 :             :                  should be rejected or made deprecated.  */
   11366                 :        1028 :               STRIP_NOPS (input);
   11367                 :        1028 :               if (!c_mark_addressable (input))
   11368                 :           2 :                 input = error_mark_node;
   11369                 :             :             }
   11370                 :             :           else
   11371                 :             :             {
   11372                 :      350170 :               struct c_expr expr;
   11373                 :      350170 :               memset (&expr, 0, sizeof (expr));
   11374                 :      350170 :               expr.value = input;
   11375                 :      350170 :               expr = convert_lvalue_to_rvalue (loc, expr, true, false);
   11376                 :      350170 :               input = c_fully_fold (expr.value, false, NULL);
   11377                 :             : 
   11378                 :      350170 :               if (input != error_mark_node && VOID_TYPE_P (TREE_TYPE (input)))
   11379                 :             :                 {
   11380                 :           4 :                   error_at (loc, "invalid use of void expression");
   11381                 :           4 :                   input = error_mark_node;
   11382                 :             :                 }
   11383                 :             :             }
   11384                 :             :         }
   11385                 :             :       else
   11386                 :           1 :         input = error_mark_node;
   11387                 :             : 
   11388                 :      351199 :       TREE_VALUE (tail) = input;
   11389                 :             :     }
   11390                 :             : 
   11391                 :      198399 :   args = build_stmt (loc, ASM_EXPR, string, outputs, inputs, clobbers, labels);
   11392                 :             : 
   11393                 :             :   /* asm statements without outputs, including simple ones, are treated
   11394                 :             :      as volatile.  */
   11395                 :      198399 :   ASM_INPUT_P (args) = simple;
   11396                 :      198399 :   ASM_VOLATILE_P (args) = (noutputs == 0);
   11397                 :      198399 :   ASM_INLINE_P (args) = is_inline;
   11398                 :             : 
   11399                 :      198399 :   return args;
   11400                 :             : }
   11401                 :             : 
   11402                 :             : /* Generate a goto statement to LABEL.  LOC is the location of the
   11403                 :             :    GOTO.  */
   11404                 :             : 
   11405                 :             : tree
   11406                 :       81991 : c_finish_goto_label (location_t loc, tree label)
   11407                 :             : {
   11408                 :       81991 :   tree decl = lookup_label_for_goto (loc, label);
   11409                 :       81991 :   if (!decl)
   11410                 :             :     return NULL_TREE;
   11411                 :       81991 :   TREE_USED (decl) = 1;
   11412                 :       81991 :   {
   11413                 :       81991 :     add_stmt (build_predict_expr (PRED_GOTO, NOT_TAKEN));
   11414                 :       81991 :     tree t = build1 (GOTO_EXPR, void_type_node, decl);
   11415                 :       81991 :     SET_EXPR_LOCATION (t, loc);
   11416                 :       81991 :     return add_stmt (t);
   11417                 :             :   }
   11418                 :             : }
   11419                 :             : 
   11420                 :             : /* Generate a computed goto statement to EXPR.  LOC is the location of
   11421                 :             :    the GOTO.  */
   11422                 :             : 
   11423                 :             : tree
   11424                 :         925 : c_finish_goto_ptr (location_t loc, c_expr val)
   11425                 :             : {
   11426                 :         925 :   tree expr = val.value;
   11427                 :         925 :   tree t;
   11428                 :         925 :   pedwarn (loc, OPT_Wpedantic, "ISO C forbids %<goto *expr;%>");
   11429                 :         925 :   if (expr != error_mark_node
   11430                 :         924 :       && !POINTER_TYPE_P (TREE_TYPE (expr))
   11431                 :         930 :       && !null_pointer_constant_p (expr))
   11432                 :             :     {
   11433                 :           2 :       error_at (val.get_location (),
   11434                 :             :                 "computed goto must be pointer type");
   11435                 :           2 :       expr = build_zero_cst (ptr_type_node);
   11436                 :             :     }
   11437                 :         925 :   expr = c_fully_fold (expr, false, NULL);
   11438                 :         925 :   expr = convert (ptr_type_node, expr);
   11439                 :         925 :   t = build1 (GOTO_EXPR, void_type_node, expr);
   11440                 :         925 :   SET_EXPR_LOCATION (t, loc);
   11441                 :         925 :   return add_stmt (t);
   11442                 :             : }
   11443                 :             : 
   11444                 :             : /* Generate a C `return' statement.  RETVAL is the expression for what
   11445                 :             :    to return, or a null pointer for `return;' with no value.  LOC is
   11446                 :             :    the location of the return statement, or the location of the expression,
   11447                 :             :    if the statement has any.  If ORIGTYPE is not NULL_TREE, it
   11448                 :             :    is the original type of RETVAL.  */
   11449                 :             : 
   11450                 :             : tree
   11451                 :    30091753 : c_finish_return (location_t loc, tree retval, tree origtype)
   11452                 :             : {
   11453                 :    30091753 :   tree valtype = TREE_TYPE (TREE_TYPE (current_function_decl)), ret_stmt;
   11454                 :    30091753 :   bool no_warning = false;
   11455                 :    30091753 :   bool npc = false;
   11456                 :             : 
   11457                 :             :   /* Use the expansion point to handle cases such as returning NULL
   11458                 :             :      in a function returning void.  */
   11459                 :    30091753 :   location_t xloc = expansion_point_location_if_in_system_header (loc);
   11460                 :             : 
   11461                 :    30091753 :   if (TREE_THIS_VOLATILE (current_function_decl))
   11462                 :          22 :     warning_at (xloc, 0,
   11463                 :             :                 "function declared %<noreturn%> has a %<return%> statement");
   11464                 :             : 
   11465                 :    30091753 :   if (retval)
   11466                 :             :     {
   11467                 :    30071960 :       tree semantic_type = NULL_TREE;
   11468                 :    30071960 :       npc = null_pointer_constant_p (retval);
   11469                 :    30071960 :       if (TREE_CODE (retval) == EXCESS_PRECISION_EXPR)
   11470                 :             :         {
   11471                 :          91 :           semantic_type = TREE_TYPE (retval);
   11472                 :          91 :           retval = TREE_OPERAND (retval, 0);
   11473                 :             :         }
   11474                 :    30071960 :       retval = c_fully_fold (retval, false, NULL);
   11475                 :    30071960 :       if (semantic_type
   11476                 :    30071960 :           && valtype != NULL_TREE
   11477                 :          91 :           && TREE_CODE (valtype) != VOID_TYPE)
   11478                 :          91 :         retval = build1 (EXCESS_PRECISION_EXPR, semantic_type, retval);
   11479                 :             :     }
   11480                 :             : 
   11481                 :    30071960 :   if (!retval)
   11482                 :             :     {
   11483                 :       19793 :       current_function_returns_null = 1;
   11484                 :       19793 :       if ((warn_return_type >= 0 || flag_isoc99)
   11485                 :       19668 :           && valtype != NULL_TREE && TREE_CODE (valtype) != VOID_TYPE)
   11486                 :             :         {
   11487                 :          46 :           no_warning = true;
   11488                 :          47 :           if (emit_diagnostic (flag_isoc99 ? DK_PERMERROR : DK_WARNING,
   11489                 :             :                                loc, OPT_Wreturn_mismatch,
   11490                 :             :                                "%<return%> with no value,"
   11491                 :             :                                " in function returning non-void"))
   11492                 :          27 :             inform (DECL_SOURCE_LOCATION (current_function_decl),
   11493                 :             :                     "declared here");
   11494                 :             :         }
   11495                 :             :     }
   11496                 :    30071960 :   else if (valtype == NULL_TREE || VOID_TYPE_P (valtype))
   11497                 :             :     {
   11498                 :         260 :       current_function_returns_null = 1;
   11499                 :         260 :       bool warned_here;
   11500                 :         260 :       if (TREE_CODE (TREE_TYPE (retval)) != VOID_TYPE)
   11501                 :          64 :         warned_here = permerror_opt
   11502                 :          64 :           (xloc, OPT_Wreturn_mismatch,
   11503                 :             :            "%<return%> with a value, in function returning void");
   11504                 :             :       else
   11505                 :         196 :         warned_here = pedwarn
   11506                 :         196 :           (xloc, OPT_Wpedantic, "ISO C forbids "
   11507                 :             :            "%<return%> with expression, in function returning void");
   11508                 :         260 :       if (warned_here)
   11509                 :          43 :         inform (DECL_SOURCE_LOCATION (current_function_decl),
   11510                 :             :                 "declared here");
   11511                 :             :     }
   11512                 :             :   else
   11513                 :             :     {
   11514                 :    30071700 :       tree t = convert_for_assignment (loc, UNKNOWN_LOCATION, valtype,
   11515                 :             :                                        retval, origtype, ic_return,
   11516                 :             :                                        npc, NULL_TREE, NULL_TREE, 0);
   11517                 :    30071700 :       tree res = DECL_RESULT (current_function_decl);
   11518                 :    30071700 :       tree inner;
   11519                 :    30071700 :       bool save;
   11520                 :             : 
   11521                 :    30071700 :       current_function_returns_value = 1;
   11522                 :    30071700 :       if (t == error_mark_node)
   11523                 :             :         return NULL_TREE;
   11524                 :             : 
   11525                 :    30071405 :       save = in_late_binary_op;
   11526                 :    60135400 :       if (C_BOOLEAN_TYPE_P (TREE_TYPE (res))
   11527                 :    30063974 :           || TREE_CODE (TREE_TYPE (res)) == COMPLEX_TYPE
   11528                 :    60134116 :           || (SCALAR_FLOAT_TYPE_P (TREE_TYPE (t))
   11529                 :      328488 :               && (TREE_CODE (TREE_TYPE (res)) == INTEGER_TYPE
   11530                 :      328488 :                   || TREE_CODE (TREE_TYPE (res)) == ENUMERAL_TYPE)
   11531                 :           0 :               && sanitize_flags_p (SANITIZE_FLOAT_CAST)))
   11532                 :        8694 :         in_late_binary_op = true;
   11533                 :    30071405 :       inner = t = convert (TREE_TYPE (res), t);
   11534                 :    30071405 :       in_late_binary_op = save;
   11535                 :             : 
   11536                 :             :       /* Strip any conversions, additions, and subtractions, and see if
   11537                 :             :          we are returning the address of a local variable.  Warn if so.  */
   11538                 :    33151707 :       while (1)
   11539                 :             :         {
   11540                 :    33151707 :           switch (TREE_CODE (inner))
   11541                 :             :             {
   11542                 :     3078956 :             CASE_CONVERT:
   11543                 :     3078956 :             case NON_LVALUE_EXPR:
   11544                 :     3078956 :             case PLUS_EXPR:
   11545                 :     3078956 :             case POINTER_PLUS_EXPR:
   11546                 :     3078956 :               inner = TREE_OPERAND (inner, 0);
   11547                 :     3078956 :               continue;
   11548                 :             : 
   11549                 :        1351 :             case MINUS_EXPR:
   11550                 :             :               /* If the second operand of the MINUS_EXPR has a pointer
   11551                 :             :                  type (or is converted from it), this may be valid, so
   11552                 :             :                  don't give a warning.  */
   11553                 :        1351 :               {
   11554                 :        1351 :                 tree op1 = TREE_OPERAND (inner, 1);
   11555                 :             : 
   11556                 :        2921 :                 while (!POINTER_TYPE_P (TREE_TYPE (op1))
   11557                 :        3145 :                        && (CONVERT_EXPR_P (op1)
   11558                 :        1346 :                            || TREE_CODE (op1) == NON_LVALUE_EXPR))
   11559                 :         224 :                   op1 = TREE_OPERAND (op1, 0);
   11560                 :             : 
   11561                 :        1351 :                 if (POINTER_TYPE_P (TREE_TYPE (op1)))
   11562                 :             :                   break;
   11563                 :             : 
   11564                 :        1346 :                 inner = TREE_OPERAND (inner, 0);
   11565                 :        1346 :                 continue;
   11566                 :        1346 :               }
   11567                 :             : 
   11568                 :        2644 :             case ADDR_EXPR:
   11569                 :        2644 :               inner = TREE_OPERAND (inner, 0);
   11570                 :             : 
   11571                 :        2644 :               while (REFERENCE_CLASS_P (inner)
   11572                 :        3488 :                      && !INDIRECT_REF_P (inner))
   11573                 :         844 :                 inner = TREE_OPERAND (inner, 0);
   11574                 :             : 
   11575                 :        2644 :               if (DECL_P (inner)
   11576                 :        1489 :                   && !DECL_EXTERNAL (inner)
   11577                 :         866 :                   && !TREE_STATIC (inner)
   11578                 :         132 :                   && DECL_CONTEXT (inner) == current_function_decl
   11579                 :        2697 :                   && POINTER_TYPE_P (TREE_TYPE (TREE_TYPE (current_function_decl))))
   11580                 :             :                 {
   11581                 :          13 :                   if (TREE_CODE (inner) == LABEL_DECL)
   11582                 :           4 :                     warning_at (loc, OPT_Wreturn_local_addr,
   11583                 :             :                                 "function returns address of label");
   11584                 :             :                   else
   11585                 :             :                     {
   11586                 :           9 :                       warning_at (loc, OPT_Wreturn_local_addr,
   11587                 :             :                                   "function returns address of local variable");
   11588                 :           9 :                       tree zero = build_zero_cst (TREE_TYPE (res));
   11589                 :           9 :                       t = build2 (COMPOUND_EXPR, TREE_TYPE (res), t, zero);
   11590                 :             :                     }
   11591                 :             :                 }
   11592                 :             :               break;
   11593                 :             : 
   11594                 :             :             default:
   11595                 :             :               break;
   11596                 :     3078956 :             }
   11597                 :             : 
   11598                 :    30071405 :           break;
   11599                 :             :         }
   11600                 :             : 
   11601                 :    30071405 :       retval = build2 (MODIFY_EXPR, TREE_TYPE (res), res, t);
   11602                 :    30071405 :       SET_EXPR_LOCATION (retval, loc);
   11603                 :             : 
   11604                 :    30071405 :       if (warn_sequence_point)
   11605                 :     2649874 :         verify_sequence_points (retval);
   11606                 :             :     }
   11607                 :             : 
   11608                 :    30091458 :   ret_stmt = build_stmt (loc, RETURN_EXPR, retval);
   11609                 :    30091458 :   if (no_warning)
   11610                 :          46 :     suppress_warning (ret_stmt, OPT_Wreturn_type);
   11611                 :    30091458 :   return add_stmt (ret_stmt);
   11612                 :             : }
   11613                 :             : 
   11614                 :             : struct c_switch {
   11615                 :             :   /* The SWITCH_STMT being built.  */
   11616                 :             :   tree switch_stmt;
   11617                 :             : 
   11618                 :             :   /* The original type of the testing expression, i.e. before the
   11619                 :             :      default conversion is applied.  */
   11620                 :             :   tree orig_type;
   11621                 :             : 
   11622                 :             :   /* A splay-tree mapping the low element of a case range to the high
   11623                 :             :      element, or NULL_TREE if there is no high element.  Used to
   11624                 :             :      determine whether or not a new case label duplicates an old case
   11625                 :             :      label.  We need a tree, rather than simply a hash table, because
   11626                 :             :      of the GNU case range extension.  */
   11627                 :             :   splay_tree cases;
   11628                 :             : 
   11629                 :             :   /* The bindings at the point of the switch.  This is used for
   11630                 :             :      warnings crossing decls when branching to a case label.  */
   11631                 :             :   struct c_spot_bindings *bindings;
   11632                 :             : 
   11633                 :             :   /* Whether the switch includes any break statements.  */
   11634                 :             :   bool break_stmt_seen_p;
   11635                 :             : 
   11636                 :             :   /* The next node on the stack.  */
   11637                 :             :   struct c_switch *next;
   11638                 :             : 
   11639                 :             :   /* Remember whether the controlling expression had boolean type
   11640                 :             :      before integer promotions for the sake of -Wswitch-bool.  */
   11641                 :             :   bool bool_cond_p;
   11642                 :             : };
   11643                 :             : 
   11644                 :             : /* A stack of the currently active switch statements.  The innermost
   11645                 :             :    switch statement is on the top of the stack.  There is no need to
   11646                 :             :    mark the stack for garbage collection because it is only active
   11647                 :             :    during the processing of the body of a function, and we never
   11648                 :             :    collect at that point.  */
   11649                 :             : 
   11650                 :             : struct c_switch *c_switch_stack;
   11651                 :             : 
   11652                 :             : /* Start a C switch statement, testing expression EXP.  Return the new
   11653                 :             :    SWITCH_STMT.  SWITCH_LOC is the location of the `switch'.
   11654                 :             :    SWITCH_COND_LOC is the location of the switch's condition.
   11655                 :             :    EXPLICIT_CAST_P is true if the expression EXP has an explicit cast.  */
   11656                 :             : 
   11657                 :             : tree
   11658                 :       36174 : c_start_switch (location_t switch_loc,
   11659                 :             :                 location_t switch_cond_loc,
   11660                 :             :                 tree exp, bool explicit_cast_p)
   11661                 :             : {
   11662                 :       36174 :   tree orig_type = error_mark_node;
   11663                 :       36174 :   bool bool_cond_p = false;
   11664                 :       36174 :   struct c_switch *cs;
   11665                 :             : 
   11666                 :       36174 :   if (exp != error_mark_node)
   11667                 :             :     {
   11668                 :       36165 :       orig_type = TREE_TYPE (exp);
   11669                 :             : 
   11670                 :       36165 :       if (!INTEGRAL_TYPE_P (orig_type))
   11671                 :             :         {
   11672                 :          10 :           if (orig_type != error_mark_node)
   11673                 :             :             {
   11674                 :          10 :               error_at (switch_cond_loc, "switch quantity not an integer");
   11675                 :          10 :               orig_type = error_mark_node;
   11676                 :             :             }
   11677                 :          10 :           exp = integer_zero_node;
   11678                 :             :         }
   11679                 :             :       else
   11680                 :             :         {
   11681                 :       36155 :           tree type = TYPE_MAIN_VARIANT (orig_type);
   11682                 :       36155 :           tree e = exp;
   11683                 :             : 
   11684                 :             :           /* Warn if the condition has boolean value.  */
   11685                 :       36157 :           while (TREE_CODE (e) == COMPOUND_EXPR)
   11686                 :           2 :             e = TREE_OPERAND (e, 1);
   11687                 :             : 
   11688                 :       36130 :           if ((C_BOOLEAN_TYPE_P (type)
   11689                 :       36130 :                || truth_value_p (TREE_CODE (e)))
   11690                 :             :               /* Explicit cast to int suppresses this warning.  */
   11691                 :       36177 :               && !(TREE_CODE (type) == INTEGER_TYPE
   11692                 :             :                    && explicit_cast_p))
   11693                 :             :             bool_cond_p = true;
   11694                 :             : 
   11695                 :       36155 :           if (!in_system_header_at (input_location)
   11696                 :       36155 :               && (type == long_integer_type_node
   11697                 :       11649 :                   || type == long_unsigned_type_node))
   11698                 :         254 :             warning_at (switch_cond_loc,
   11699                 :             :                         OPT_Wtraditional, "%<long%> switch expression not "
   11700                 :             :                         "converted to %<int%> in ISO C");
   11701                 :             : 
   11702                 :       36155 :           exp = c_fully_fold (exp, false, NULL);
   11703                 :       36155 :           exp = default_conversion (exp);
   11704                 :             : 
   11705                 :       36155 :           if (warn_sequence_point)
   11706                 :        6044 :             verify_sequence_points (exp);
   11707                 :             :         }
   11708                 :             :     }
   11709                 :             : 
   11710                 :             :   /* Add this new SWITCH_STMT to the stack.  */
   11711                 :       36174 :   cs = XNEW (struct c_switch);
   11712                 :       36174 :   cs->switch_stmt = build_stmt (switch_loc, SWITCH_STMT, exp,
   11713                 :             :                                 NULL_TREE, orig_type, NULL_TREE);
   11714                 :       36174 :   cs->orig_type = orig_type;
   11715                 :       36174 :   cs->cases = splay_tree_new (case_compare, NULL, NULL);
   11716                 :       36174 :   cs->bindings = c_get_switch_bindings ();
   11717                 :       36174 :   cs->break_stmt_seen_p = false;
   11718                 :       36174 :   cs->bool_cond_p = bool_cond_p;
   11719                 :       36174 :   cs->next = c_switch_stack;
   11720                 :       36174 :   c_switch_stack = cs;
   11721                 :             : 
   11722                 :       36174 :   return add_stmt (cs->switch_stmt);
   11723                 :             : }
   11724                 :             : 
   11725                 :             : /* Process a case label at location LOC, with attributes ATTRS.  */
   11726                 :             : 
   11727                 :             : tree
   11728                 :     1021417 : do_case (location_t loc, tree low_value, tree high_value, tree attrs)
   11729                 :             : {
   11730                 :     1021417 :   tree label = NULL_TREE;
   11731                 :             : 
   11732                 :     1021417 :   if (low_value && TREE_CODE (low_value) != INTEGER_CST)
   11733                 :             :     {
   11734                 :          87 :       low_value = c_fully_fold (low_value, false, NULL);
   11735                 :          87 :       if (TREE_CODE (low_value) == INTEGER_CST)
   11736                 :           9 :         pedwarn (loc, OPT_Wpedantic,
   11737                 :             :                  "case label is not an integer constant expression");
   11738                 :             :     }
   11739                 :             : 
   11740                 :     1021417 :   if (high_value && TREE_CODE (high_value) != INTEGER_CST)
   11741                 :             :     {
   11742                 :           0 :       high_value = c_fully_fold (high_value, false, NULL);
   11743                 :           0 :       if (TREE_CODE (high_value) == INTEGER_CST)
   11744                 :           0 :         pedwarn (input_location, OPT_Wpedantic,
   11745                 :             :                  "case label is not an integer constant expression");
   11746                 :             :     }
   11747                 :             : 
   11748                 :     1021417 :   if (c_switch_stack == NULL)
   11749                 :             :     {
   11750                 :           3 :       if (low_value)
   11751                 :           2 :         error_at (loc, "case label not within a switch statement");
   11752                 :             :       else
   11753                 :           1 :         error_at (loc, "%<default%> label not within a switch statement");
   11754                 :           3 :       return NULL_TREE;
   11755                 :             :     }
   11756                 :             : 
   11757                 :     1021414 :   if (c_check_switch_jump_warnings (c_switch_stack->bindings,
   11758                 :     1021414 :                                     EXPR_LOCATION (c_switch_stack->switch_stmt),
   11759                 :             :                                     loc))
   11760                 :             :     return NULL_TREE;
   11761                 :             : 
   11762                 :     1021405 :   label = c_add_case_label (loc, c_switch_stack->cases,
   11763                 :     1021405 :                             SWITCH_STMT_COND (c_switch_stack->switch_stmt),
   11764                 :             :                             low_value, high_value, attrs);
   11765                 :     1021405 :   if (label == error_mark_node)
   11766                 :         103 :     label = NULL_TREE;
   11767                 :             :   return label;
   11768                 :             : }
   11769                 :             : 
   11770                 :             : /* Finish the switch statement.  TYPE is the original type of the
   11771                 :             :    controlling expression of the switch, or NULL_TREE.  */
   11772                 :             : 
   11773                 :             : void
   11774                 :       36174 : c_finish_switch (tree body, tree type)
   11775                 :             : {
   11776                 :       36174 :   struct c_switch *cs = c_switch_stack;
   11777                 :       36174 :   location_t switch_location;
   11778                 :             : 
   11779                 :       36174 :   SWITCH_STMT_BODY (cs->switch_stmt) = body;
   11780                 :             : 
   11781                 :             :   /* Emit warnings as needed.  */
   11782                 :       36174 :   switch_location = EXPR_LOCATION (cs->switch_stmt);
   11783                 :       42328 :   c_do_switch_warnings (cs->cases, switch_location,
   11784                 :        6154 :                         type ? type : SWITCH_STMT_TYPE (cs->switch_stmt),
   11785                 :       36174 :                         SWITCH_STMT_COND (cs->switch_stmt), cs->bool_cond_p);
   11786                 :       36174 :   if (c_switch_covers_all_cases_p (cs->cases,
   11787                 :       36174 :                                    SWITCH_STMT_TYPE (cs->switch_stmt)))
   11788                 :       32318 :     SWITCH_STMT_ALL_CASES_P (cs->switch_stmt) = 1;
   11789                 :       36174 :   SWITCH_STMT_NO_BREAK_P (cs->switch_stmt) = !cs->break_stmt_seen_p;
   11790                 :             : 
   11791                 :             :   /* Pop the stack.  */
   11792                 :       36174 :   c_switch_stack = cs->next;
   11793                 :       36174 :   splay_tree_delete (cs->cases);
   11794                 :       36174 :   c_release_switch_bindings (cs->bindings);
   11795                 :       36174 :   XDELETE (cs);
   11796                 :       36174 : }
   11797                 :             : 
   11798                 :             : /* Emit an if statement.  IF_LOCUS is the location of the 'if'.  COND,
   11799                 :             :    THEN_BLOCK and ELSE_BLOCK are expressions to be used; ELSE_BLOCK
   11800                 :             :    may be null.  */
   11801                 :             : 
   11802                 :             : void
   11803                 :     1235787 : c_finish_if_stmt (location_t if_locus, tree cond, tree then_block,
   11804                 :             :                   tree else_block)
   11805                 :             : {
   11806                 :     1235787 :   tree stmt;
   11807                 :             : 
   11808                 :     1235787 :   stmt = build3 (COND_EXPR, void_type_node, cond, then_block, else_block);
   11809                 :     1235787 :   SET_EXPR_LOCATION (stmt, if_locus);
   11810                 :     1235787 :   add_stmt (stmt);
   11811                 :     1235787 : }
   11812                 :             : 
   11813                 :             : tree
   11814                 :      180999 : c_finish_bc_stmt (location_t loc, tree label, bool is_break)
   11815                 :             : {
   11816                 :             :   /* In switch statements break is sometimes stylistically used after
   11817                 :             :      a return statement.  This can lead to spurious warnings about
   11818                 :             :      control reaching the end of a non-void function when it is
   11819                 :             :      inlined.  Note that we are calling block_may_fallthru with
   11820                 :             :      language specific tree nodes; this works because
   11821                 :             :      block_may_fallthru returns true when given something it does not
   11822                 :             :      understand.  */
   11823                 :      180999 :   bool skip = !block_may_fallthru (cur_stmt_list);
   11824                 :             : 
   11825                 :      180999 :   if (is_break)
   11826                 :      168204 :     switch (in_statement)
   11827                 :             :       {
   11828                 :           9 :       case 0:
   11829                 :           9 :         error_at (loc, "break statement not within loop or switch");
   11830                 :           9 :         return NULL_TREE;
   11831                 :           4 :       case IN_OMP_BLOCK:
   11832                 :           4 :         error_at (loc, "invalid exit from OpenMP structured block");
   11833                 :           4 :         return NULL_TREE;
   11834                 :           7 :       case IN_OMP_FOR:
   11835                 :           7 :         error_at (loc, "break statement used with OpenMP for loop");
   11836                 :           7 :         return NULL_TREE;
   11837                 :             :       case IN_ITERATION_STMT:
   11838                 :             :       case IN_OBJC_FOREACH:
   11839                 :             :         break;
   11840                 :      154073 :       default:
   11841                 :      154073 :         gcc_assert (in_statement & IN_SWITCH_STMT);
   11842                 :      154073 :         c_switch_stack->break_stmt_seen_p = true;
   11843                 :      154073 :         break;
   11844                 :             :       }
   11845                 :             :   else
   11846                 :       12795 :     switch (in_statement & ~IN_SWITCH_STMT)
   11847                 :             :       {
   11848                 :           7 :       case 0:
   11849                 :           7 :         error_at (loc, "continue statement not within a loop");
   11850                 :           7 :         return NULL_TREE;
   11851                 :           4 :       case IN_OMP_BLOCK:
   11852                 :           4 :         error_at (loc, "invalid exit from OpenMP structured block");
   11853                 :           4 :         return NULL_TREE;
   11854                 :             :       case IN_ITERATION_STMT:
   11855                 :             :       case IN_OMP_FOR:
   11856                 :             :       case IN_OBJC_FOREACH:
   11857                 :             :         break;
   11858                 :           0 :       default:
   11859                 :           0 :         gcc_unreachable ();
   11860                 :             :       }
   11861                 :             : 
   11862                 :      180968 :   if (skip)
   11863                 :             :     return NULL_TREE;
   11864                 :      180304 :   else if ((in_statement & IN_OBJC_FOREACH)
   11865                 :           0 :            && !(is_break && (in_statement & IN_SWITCH_STMT)))
   11866                 :             :     {
   11867                 :             :       /* The foreach expander produces low-level code using gotos instead
   11868                 :             :          of a structured loop construct.  */
   11869                 :           0 :       gcc_assert (label);
   11870                 :           0 :       return add_stmt (build_stmt (loc, GOTO_EXPR, label));
   11871                 :             :     }
   11872                 :      193088 :   return add_stmt (build_stmt (loc, (is_break ? BREAK_STMT : CONTINUE_STMT)));
   11873                 :             : }
   11874                 :             : 
   11875                 :             : /* A helper routine for c_process_expr_stmt and c_finish_stmt_expr.  */
   11876                 :             : 
   11877                 :             : static void
   11878                 :     6212246 : emit_side_effect_warnings (location_t loc, tree expr)
   11879                 :             : {
   11880                 :     6212246 :   maybe_warn_nodiscard (loc, expr);
   11881                 :     6212246 :   if (!warn_unused_value)
   11882                 :             :     return;
   11883                 :     1262391 :   if (expr == error_mark_node)
   11884                 :             :     ;
   11885                 :     1262316 :   else if (!TREE_SIDE_EFFECTS (expr))
   11886                 :             :     {
   11887                 :        6412 :       if (!VOID_TYPE_P (TREE_TYPE (expr))
   11888                 :        6412 :           && !warning_suppressed_p (expr, OPT_Wunused_value))
   11889                 :          28 :         warning_at (loc, OPT_Wunused_value, "statement with no effect");
   11890                 :             :     }
   11891                 :     1255904 :   else if (TREE_CODE (expr) == COMPOUND_EXPR)
   11892                 :             :     {
   11893                 :             :       tree r = expr;
   11894                 :             :       location_t cloc = loc;
   11895                 :       10963 :       while (TREE_CODE (r) == COMPOUND_EXPR)
   11896                 :             :         {
   11897                 :        5497 :           if (EXPR_HAS_LOCATION (r))
   11898                 :        4971 :             cloc = EXPR_LOCATION (r);
   11899                 :        5497 :           r = TREE_OPERAND (r, 1);
   11900                 :             :         }
   11901                 :        5466 :       if (!TREE_SIDE_EFFECTS (r)
   11902                 :          33 :           && !VOID_TYPE_P (TREE_TYPE (r))
   11903                 :          24 :           && !CONVERT_EXPR_P (r)
   11904                 :          24 :           && !warning_suppressed_p (r, OPT_Wunused_value)
   11905                 :        5478 :           && !warning_suppressed_p (expr, OPT_Wunused_value))
   11906                 :           8 :         warning_at (cloc, OPT_Wunused_value,
   11907                 :             :                     "right-hand operand of comma expression has no effect");
   11908                 :             :     }
   11909                 :             :   else
   11910                 :     1250438 :     warn_if_unused_value (expr, loc);
   11911                 :             : }
   11912                 :             : 
   11913                 :             : /* Process an expression as if it were a complete statement.  Emit
   11914                 :             :    diagnostics, but do not call ADD_STMT.  LOC is the location of the
   11915                 :             :    statement.  */
   11916                 :             : 
   11917                 :             : tree
   11918                 :     6088962 : c_process_expr_stmt (location_t loc, tree expr)
   11919                 :             : {
   11920                 :     6088962 :   tree exprv;
   11921                 :             : 
   11922                 :     6088962 :   if (!expr)
   11923                 :             :     return NULL_TREE;
   11924                 :             : 
   11925                 :     6084972 :   expr = c_fully_fold (expr, false, NULL);
   11926                 :             : 
   11927                 :     6084972 :   if (warn_sequence_point)
   11928                 :     1258260 :     verify_sequence_points (expr);
   11929                 :             : 
   11930                 :     6084972 :   if (TREE_TYPE (expr) != error_mark_node
   11931                 :     6082567 :       && !COMPLETE_OR_VOID_TYPE_P (TREE_TYPE (expr))
   11932                 :     6084972 :       && TREE_CODE (TREE_TYPE (expr)) != ARRAY_TYPE)
   11933                 :           0 :     error_at (loc, "expression statement has incomplete type");
   11934                 :             : 
   11935                 :             :   /* If we're not processing a statement expression, warn about unused values.
   11936                 :             :      Warnings for statement expressions will be emitted later, once we figure
   11937                 :             :      out which is the result.  */
   11938                 :     6084972 :   if (!STATEMENT_LIST_STMT_EXPR (cur_stmt_list)
   11939                 :     6084972 :       && (warn_unused_value || warn_unused_result))
   11940                 :     5998380 :     emit_side_effect_warnings (EXPR_LOC_OR_LOC (expr, loc), expr);
   11941                 :             : 
   11942                 :             :   exprv = expr;
   11943                 :     6122191 :   while (TREE_CODE (exprv) == COMPOUND_EXPR)
   11944                 :       37220 :     exprv = TREE_OPERAND (exprv, 1);
   11945                 :     6095388 :   while (CONVERT_EXPR_P (exprv))
   11946                 :       10417 :     exprv = TREE_OPERAND (exprv, 0);
   11947                 :     6084971 :   if (DECL_P (exprv)
   11948                 :     6085516 :       || handled_component_p (exprv)
   11949                 :    12151166 :       || TREE_CODE (exprv) == ADDR_EXPR)
   11950                 :       19321 :     mark_exp_read (exprv);
   11951                 :             : 
   11952                 :             :   /* If the expression is not of a type to which we cannot assign a line
   11953                 :             :      number, wrap the thing in a no-op NOP_EXPR.  */
   11954                 :     6084971 :   if (DECL_P (expr) || CONSTANT_CLASS_P (expr))
   11955                 :             :     {
   11956                 :       14442 :       expr = build1 (NOP_EXPR, TREE_TYPE (expr), expr);
   11957                 :       14442 :       SET_EXPR_LOCATION (expr, loc);
   11958                 :             :     }
   11959                 :             : 
   11960                 :             :   return expr;
   11961                 :             : }
   11962                 :             : 
   11963                 :             : /* Emit an expression as a statement.  LOC is the location of the
   11964                 :             :    expression.  */
   11965                 :             : 
   11966                 :             : tree
   11967                 :     5810003 : c_finish_expr_stmt (location_t loc, tree expr)
   11968                 :             : {
   11969                 :     5810003 :   if (expr)
   11970                 :     5799185 :     return add_stmt (c_process_expr_stmt (loc, expr));
   11971                 :             :   else
   11972                 :             :     return NULL;
   11973                 :             : }
   11974                 :             : 
   11975                 :             : /* Do the opposite and emit a statement as an expression.  To begin,
   11976                 :             :    create a new binding level and return it.  */
   11977                 :             : 
   11978                 :             : tree
   11979                 :       33080 : c_begin_stmt_expr (void)
   11980                 :             : {
   11981                 :       33080 :   tree ret;
   11982                 :             : 
   11983                 :             :   /* We must force a BLOCK for this level so that, if it is not expanded
   11984                 :             :      later, there is a way to turn off the entire subtree of blocks that
   11985                 :             :      are contained in it.  */
   11986                 :       33080 :   keep_next_level ();
   11987                 :       33080 :   ret = c_begin_compound_stmt (true);
   11988                 :             : 
   11989                 :       33080 :   c_bindings_start_stmt_expr (c_switch_stack == NULL
   11990                 :             :                               ? NULL
   11991                 :             :                               : c_switch_stack->bindings);
   11992                 :             : 
   11993                 :             :   /* Mark the current statement list as belonging to a statement list.  */
   11994                 :       33080 :   STATEMENT_LIST_STMT_EXPR (ret) = 1;
   11995                 :             : 
   11996                 :       33080 :   return ret;
   11997                 :             : }
   11998                 :             : 
   11999                 :             : /* LOC is the location of the compound statement to which this body
   12000                 :             :    belongs.  */
   12001                 :             : 
   12002                 :             : tree
   12003                 :       33080 : c_finish_stmt_expr (location_t loc, tree body)
   12004                 :             : {
   12005                 :       33080 :   tree last, type, tmp, val;
   12006                 :       33080 :   tree *last_p;
   12007                 :             : 
   12008                 :       33080 :   body = c_end_compound_stmt (loc, body, true);
   12009                 :             : 
   12010                 :       33080 :   c_bindings_end_stmt_expr (c_switch_stack == NULL
   12011                 :             :                             ? NULL
   12012                 :             :                             : c_switch_stack->bindings);
   12013                 :             : 
   12014                 :             :   /* Locate the last statement in BODY.  See c_end_compound_stmt
   12015                 :             :      about always returning a BIND_EXPR.  */
   12016                 :       33080 :   last_p = &BIND_EXPR_BODY (body);
   12017                 :       33080 :   last = BIND_EXPR_BODY (body);
   12018                 :             : 
   12019                 :       33080 :  continue_searching:
   12020                 :       33080 :   if (TREE_CODE (last) == STATEMENT_LIST)
   12021                 :             :     {
   12022                 :       25664 :       tree_stmt_iterator l = tsi_last (last);
   12023                 :             : 
   12024                 :       25670 :       while (!tsi_end_p (l) && TREE_CODE (tsi_stmt (l)) == DEBUG_BEGIN_STMT)
   12025                 :           6 :         tsi_prev (&l);
   12026                 :             : 
   12027                 :             :       /* This can happen with degenerate cases like ({ }).  No value.  */
   12028                 :       25664 :       if (tsi_end_p (l))
   12029                 :         387 :         return body;
   12030                 :             : 
   12031                 :             :       /* If we're supposed to generate side effects warnings, process
   12032                 :             :          all of the statements except the last.  */
   12033                 :       25277 :       if (warn_unused_value || warn_unused_result)
   12034                 :             :         {
   12035                 :       25277 :           for (tree_stmt_iterator i = tsi_start (last);
   12036                 :      274671 :                tsi_stmt (i) != tsi_stmt (l); tsi_next (&i))
   12037                 :             :             {
   12038                 :      249394 :               location_t tloc;
   12039                 :      249394 :               tree t = tsi_stmt (i);
   12040                 :             : 
   12041                 :      249394 :               tloc = EXPR_HAS_LOCATION (t) ? EXPR_LOCATION (t) : loc;
   12042                 :      249394 :               emit_side_effect_warnings (tloc, t);
   12043                 :             :             }
   12044                 :             :         }
   12045                 :       25277 :       last_p = tsi_stmt_ptr (l);
   12046                 :       25277 :       last = *last_p;
   12047                 :             :     }
   12048                 :             : 
   12049                 :             :   /* If the end of the list is exception related, then the list was split
   12050                 :             :      by a call to push_cleanup.  Continue searching.  */
   12051                 :       32693 :   if (TREE_CODE (last) == TRY_FINALLY_EXPR
   12052                 :       32693 :       || TREE_CODE (last) == TRY_CATCH_EXPR)
   12053                 :             :     {
   12054                 :           0 :       last_p = &TREE_OPERAND (last, 0);
   12055                 :           0 :       last = *last_p;
   12056                 :           0 :       goto continue_searching;
   12057                 :             :     }
   12058                 :             : 
   12059                 :       32693 :   if (last == error_mark_node)
   12060                 :             :     return last;
   12061                 :             : 
   12062                 :             :   /* In the case that the BIND_EXPR is not necessary, return the
   12063                 :             :      expression out from inside it.  */
   12064                 :       32684 :   if ((last == BIND_EXPR_BODY (body)
   12065                 :             :        /* Skip nested debug stmts.  */
   12066                 :       25276 :        || last == expr_first (BIND_EXPR_BODY (body)))
   12067                 :       42073 :       && BIND_EXPR_VARS (body) == NULL)
   12068                 :             :     {
   12069                 :             :       /* Even if this looks constant, do not allow it in a constant
   12070                 :             :          expression.  */
   12071                 :        9380 :       last = c_wrap_maybe_const (last, true);
   12072                 :             :       /* Do not warn if the return value of a statement expression is
   12073                 :             :          unused.  */
   12074                 :        9380 :       suppress_warning (last, OPT_Wunused);
   12075                 :        9380 :       return last;
   12076                 :             :     }
   12077                 :             : 
   12078                 :             :   /* Extract the type of said expression.  */
   12079                 :       23304 :   type = TREE_TYPE (last);
   12080                 :             : 
   12081                 :             :   /* If we're not returning a value at all, then the BIND_EXPR that
   12082                 :             :      we already have is a fine expression to return.  */
   12083                 :       23304 :   if (!type || VOID_TYPE_P (type))
   12084                 :             :     return body;
   12085                 :             : 
   12086                 :             :   /* Now that we've located the expression containing the value, it seems
   12087                 :             :      silly to make voidify_wrapper_expr repeat the process.  Create a
   12088                 :             :      temporary of the appropriate type and stick it in a TARGET_EXPR.  */
   12089                 :       18014 :   tmp = create_tmp_var_raw (type);
   12090                 :             : 
   12091                 :             :   /* Unwrap a no-op NOP_EXPR as added by c_finish_expr_stmt.  This avoids
   12092                 :             :      tree_expr_nonnegative_p giving up immediately.  */
   12093                 :       18014 :   val = last;
   12094                 :       18014 :   if (TREE_CODE (val) == NOP_EXPR
   12095                 :       18014 :       && TREE_TYPE (val) == TREE_TYPE (TREE_OPERAND (val, 0)))
   12096                 :        3652 :     val = TREE_OPERAND (val, 0);
   12097                 :             : 
   12098                 :       18014 :   *last_p = build2 (MODIFY_EXPR, void_type_node, tmp, val);
   12099                 :       18014 :   SET_EXPR_LOCATION (*last_p, EXPR_LOCATION (last));
   12100                 :             : 
   12101                 :       18014 :   {
   12102                 :       18014 :     tree t = build4 (TARGET_EXPR, type, tmp, body, NULL_TREE, NULL_TREE);
   12103                 :       18014 :     SET_EXPR_LOCATION (t, loc);
   12104                 :       18014 :     return t;
   12105                 :             :   }
   12106                 :             : }
   12107                 :             : 
   12108                 :             : /* Begin and end compound statements.  This is as simple as pushing
   12109                 :             :    and popping new statement lists from the tree.  */
   12110                 :             : 
   12111                 :             : tree
   12112                 :    36423266 : c_begin_compound_stmt (bool do_scope)
   12113                 :             : {
   12114                 :    36423266 :   tree stmt = push_stmt_list ();
   12115                 :    36423266 :   if (do_scope)
   12116                 :    36327365 :     push_scope ();
   12117                 :    36423266 :   return stmt;
   12118                 :             : }
   12119                 :             : 
   12120                 :             : /* End a compound statement.  STMT is the statement.  LOC is the
   12121                 :             :    location of the compound statement-- this is usually the location
   12122                 :             :    of the opening brace.  */
   12123                 :             : 
   12124                 :             : tree
   12125                 :    36423265 : c_end_compound_stmt (location_t loc, tree stmt, bool do_scope)
   12126                 :             : {
   12127                 :    36423265 :   tree block = NULL;
   12128                 :             : 
   12129                 :    36423265 :   if (do_scope)
   12130                 :             :     {
   12131                 :    36327364 :       if (c_dialect_objc ())
   12132                 :           0 :         objc_clear_super_receiver ();
   12133                 :    36327364 :       block = pop_scope ();
   12134                 :             :     }
   12135                 :             : 
   12136                 :    36423265 :   stmt = pop_stmt_list (stmt);
   12137                 :    36423265 :   stmt = c_build_bind_expr (loc, block, stmt);
   12138                 :             : 
   12139                 :             :   /* If this compound statement is nested immediately inside a statement
   12140                 :             :      expression, then force a BIND_EXPR to be created.  Otherwise we'll
   12141                 :             :      do the wrong thing for ({ { 1; } }) or ({ 1; { } }).  In particular,
   12142                 :             :      STATEMENT_LISTs merge, and thus we can lose track of what statement
   12143                 :             :      was really last.  */
   12144                 :    72846530 :   if (building_stmt_list_p ()
   12145                 :    36423180 :       && STATEMENT_LIST_STMT_EXPR (cur_stmt_list)
   12146                 :    36544229 :       && TREE_CODE (stmt) != BIND_EXPR)
   12147                 :             :     {
   12148                 :      119225 :       stmt = build3 (BIND_EXPR, void_type_node, NULL, stmt, NULL);
   12149                 :      119225 :       TREE_SIDE_EFFECTS (stmt) = 1;
   12150                 :      119225 :       SET_EXPR_LOCATION (stmt, loc);
   12151                 :             :     }
   12152                 :             : 
   12153                 :    36423265 :   return stmt;
   12154                 :             : }
   12155                 :             : 
   12156                 :             : /* Queue a cleanup.  CLEANUP is an expression/statement to be executed
   12157                 :             :    when the current scope is exited.  EH_ONLY is true when this is not
   12158                 :             :    meant to apply to normal control flow transfer.  */
   12159                 :             : 
   12160                 :             : void
   12161                 :          95 : push_cleanup (tree decl, tree cleanup, bool eh_only)
   12162                 :             : {
   12163                 :          95 :   enum tree_code code;
   12164                 :          95 :   tree stmt, list;
   12165                 :          95 :   bool stmt_expr;
   12166                 :             : 
   12167                 :          95 :   code = eh_only ? TRY_CATCH_EXPR : TRY_FINALLY_EXPR;
   12168                 :          95 :   stmt = build_stmt (DECL_SOURCE_LOCATION (decl), code, NULL, cleanup);
   12169                 :          95 :   add_stmt (stmt);
   12170                 :          95 :   stmt_expr = STATEMENT_LIST_STMT_EXPR (cur_stmt_list);
   12171                 :          95 :   list = push_stmt_list ();
   12172                 :          95 :   TREE_OPERAND (stmt, 0) = list;
   12173                 :          95 :   STATEMENT_LIST_STMT_EXPR (list) = stmt_expr;
   12174                 :          95 : }
   12175                 :             : 
   12176                 :             : /* Build a vector comparison of ARG0 and ARG1 using CODE opcode
   12177                 :             :    into a value of TYPE type.  Comparison is done via VEC_COND_EXPR.  */
   12178                 :             : 
   12179                 :             : static tree
   12180                 :       97769 : build_vec_cmp (tree_code code, tree type,
   12181                 :             :                tree arg0, tree arg1)
   12182                 :             : {
   12183                 :       97769 :   tree zero_vec = build_zero_cst (type);
   12184                 :       97769 :   tree minus_one_vec = build_minus_one_cst (type);
   12185                 :       97769 :   tree cmp_type = truth_type_for (TREE_TYPE (arg0));
   12186                 :       97769 :   tree cmp = build2 (code, cmp_type, arg0, arg1);
   12187                 :       97769 :   return build3 (VEC_COND_EXPR, type, cmp, minus_one_vec, zero_vec);
   12188                 :             : }
   12189                 :             : 
   12190                 :             : /* Possibly warn about an address of OP never being NULL in a comparison
   12191                 :             :    operation CODE involving null.  */
   12192                 :             : 
   12193                 :             : static void
   12194                 :       47784 : maybe_warn_for_null_address (location_t loc, tree op, tree_code code)
   12195                 :             : {
   12196                 :             :   /* Prevent warnings issued for macro expansion.  */
   12197                 :       47784 :   if (!warn_address
   12198                 :       27756 :       || warning_suppressed_p (op, OPT_Waddress)
   12199                 :       75272 :       || from_macro_expansion_at (loc))
   12200                 :       22992 :     return;
   12201                 :             : 
   12202                 :       24792 :   if (TREE_CODE (op) == NOP_EXPR)
   12203                 :             :     {
   12204                 :             :       /* Allow casts to intptr_t to suppress the warning.  */
   12205                 :        1035 :       tree type = TREE_TYPE (op);
   12206                 :        1035 :       if (TREE_CODE (type) == INTEGER_TYPE)
   12207                 :             :         return;
   12208                 :        1035 :       op = TREE_OPERAND (op, 0);
   12209                 :             :     }
   12210                 :             : 
   12211                 :       24792 :   if (TREE_CODE (op) == POINTER_PLUS_EXPR)
   12212                 :             :     {
   12213                 :             :       /* Allow a cast to void* to suppress the warning.  */
   12214                 :          24 :       tree type = TREE_TYPE (TREE_TYPE (op));
   12215                 :          24 :       if (VOID_TYPE_P (type))
   12216                 :             :         return;
   12217                 :             : 
   12218                 :             :       /* Adding any value to a null pointer, including zero, is undefined
   12219                 :             :          in C.  This includes the expression &p[0] where p is the null
   12220                 :             :          pointer, although &p[0] will have been folded to p by this point
   12221                 :             :          and so not diagnosed.  */
   12222                 :          24 :       if (code == EQ_EXPR)
   12223                 :          22 :         warning_at (loc, OPT_Waddress,
   12224                 :             :                     "the comparison will always evaluate as %<false%> "
   12225                 :             :                     "for the pointer operand in %qE must not be NULL",
   12226                 :             :                     op);
   12227                 :             :       else
   12228                 :           2 :         warning_at (loc, OPT_Waddress,
   12229                 :             :                     "the comparison will always evaluate as %<true%> "
   12230                 :             :                     "for the pointer operand in %qE must not be NULL",
   12231                 :             :                     op);
   12232                 :             : 
   12233                 :          24 :       return;
   12234                 :             :     }
   12235                 :             : 
   12236                 :       24768 :   if (TREE_CODE (op) != ADDR_EXPR)
   12237                 :             :     return;
   12238                 :             : 
   12239                 :         254 :   op = TREE_OPERAND (op, 0);
   12240                 :             : 
   12241                 :         254 :   if (TREE_CODE (op) == IMAGPART_EXPR
   12242                 :         254 :       || TREE_CODE (op) == REALPART_EXPR)
   12243                 :             :     {
   12244                 :             :       /* The address of either complex part may not be null.  */
   12245                 :          14 :       if (code == EQ_EXPR)
   12246                 :           9 :         warning_at (loc, OPT_Waddress,
   12247                 :             :                     "the comparison will always evaluate as %<false%> "
   12248                 :             :                     "for the address of %qE will never be NULL",
   12249                 :             :                     op);
   12250                 :             :       else
   12251                 :           5 :         warning_at (loc, OPT_Waddress,
   12252                 :             :                     "the comparison will always evaluate as %<true%> "
   12253                 :             :                     "for the address of %qE will never be NULL",
   12254                 :             :                     op);
   12255                 :          14 :       return;
   12256                 :             :     }
   12257                 :             : 
   12258                 :             :   /* Set to true in the loop below if OP dereferences is operand.
   12259                 :             :      In such a case the ultimate target need not be a decl for
   12260                 :             :      the null [in]equality test to be constant.  */
   12261                 :             :   bool deref = false;
   12262                 :             : 
   12263                 :             :   /* Get the outermost array or object, or member.  */
   12264                 :         294 :   while (handled_component_p (op))
   12265                 :             :     {
   12266                 :          72 :       if (TREE_CODE (op) == COMPONENT_REF)
   12267                 :             :         {
   12268                 :             :           /* Get the member (its address is never null).  */
   12269                 :          18 :           op = TREE_OPERAND (op, 1);
   12270                 :          18 :           break;
   12271                 :             :         }
   12272                 :             : 
   12273                 :             :       /* Get the outer array/object to refer to in the warning.  */
   12274                 :          54 :       op = TREE_OPERAND (op, 0);
   12275                 :          54 :       deref = true;
   12276                 :             :     }
   12277                 :             : 
   12278                 :         192 :   if ((!deref && !decl_with_nonnull_addr_p (op))
   12279                 :         371 :       || from_macro_expansion_at (loc))
   12280                 :         109 :     return;
   12281                 :             : 
   12282                 :         131 :   bool w;
   12283                 :         131 :   if (code == EQ_EXPR)
   12284                 :          93 :     w = warning_at (loc, OPT_Waddress,
   12285                 :             :                     "the comparison will always evaluate as %<false%> "
   12286                 :             :                     "for the address of %qE will never be NULL",
   12287                 :             :                     op);
   12288                 :             :   else
   12289                 :          38 :     w = warning_at (loc, OPT_Waddress,
   12290                 :             :                     "the comparison will always evaluate as %<true%> "
   12291                 :             :                     "for the address of %qE will never be NULL",
   12292                 :             :                     op);
   12293                 :             : 
   12294                 :         131 :   if (w && DECL_P (op))
   12295                 :         120 :     inform (DECL_SOURCE_LOCATION (op), "%qD declared here", op);
   12296                 :             : }
   12297                 :             : 
   12298                 :             : /* Build a binary-operation expression without default conversions.
   12299                 :             :    CODE is the kind of expression to build.
   12300                 :             :    LOCATION is the operator's location.
   12301                 :             :    This function differs from `build' in several ways:
   12302                 :             :    the data type of the result is computed and recorded in it,
   12303                 :             :    warnings are generated if arg data types are invalid,
   12304                 :             :    special handling for addition and subtraction of pointers is known,
   12305                 :             :    and some optimization is done (operations on narrow ints
   12306                 :             :    are done in the narrower type when that gives the same result).
   12307                 :             :    Constant folding is also done before the result is returned.
   12308                 :             : 
   12309                 :             :    Note that the operands will never have enumeral types, or function
   12310                 :             :    or array types, because either they will have the default conversions
   12311                 :             :    performed or they have both just been converted to some other type in which
   12312                 :             :    the arithmetic is to be done.  */
   12313                 :             : 
   12314                 :             : tree
   12315                 :    15853855 : build_binary_op (location_t location, enum tree_code code,
   12316                 :             :                  tree orig_op0, tree orig_op1, bool convert_p)
   12317                 :             : {
   12318                 :    15853855 :   tree type0, type1, orig_type0, orig_type1;
   12319                 :    15853855 :   tree eptype;
   12320                 :    15853855 :   enum tree_code code0, code1;
   12321                 :    15853855 :   tree op0, op1;
   12322                 :    15853855 :   tree ret = error_mark_node;
   12323                 :    15853855 :   const char *invalid_op_diag;
   12324                 :    15853855 :   bool op0_int_operands, op1_int_operands;
   12325                 :    15853855 :   bool int_const, int_const_or_overflow, int_operands;
   12326                 :             : 
   12327                 :             :   /* Expression code to give to the expression when it is built.
   12328                 :             :      Normally this is CODE, which is what the caller asked for,
   12329                 :             :      but in some special cases we change it.  */
   12330                 :    15853855 :   enum tree_code resultcode = code;
   12331                 :             : 
   12332                 :             :   /* Data type in which the computation is to be performed.
   12333                 :             :      In the simplest cases this is the common type of the arguments.  */
   12334                 :    15853855 :   tree result_type = NULL;
   12335                 :             : 
   12336                 :             :   /* When the computation is in excess precision, the type of the
   12337                 :             :      final EXCESS_PRECISION_EXPR.  */
   12338                 :    15853855 :   tree semantic_result_type = NULL;
   12339                 :             : 
   12340                 :             :   /* Nonzero means operands have already been type-converted
   12341                 :             :      in whatever way is necessary.
   12342                 :             :      Zero means they need to be converted to RESULT_TYPE.  */
   12343                 :    15853855 :   int converted = 0;
   12344                 :             : 
   12345                 :             :   /* Nonzero means create the expression with this type, rather than
   12346                 :             :      RESULT_TYPE.  */
   12347                 :    15853855 :   tree build_type = NULL_TREE;
   12348                 :             : 
   12349                 :             :   /* Nonzero means after finally constructing the expression
   12350                 :             :      convert it to this type.  */
   12351                 :    15853855 :   tree final_type = NULL_TREE;
   12352                 :             : 
   12353                 :             :   /* Nonzero if this is an operation like MIN or MAX which can
   12354                 :             :      safely be computed in short if both args are promoted shorts.
   12355                 :             :      Also implies COMMON.
   12356                 :             :      -1 indicates a bitwise operation; this makes a difference
   12357                 :             :      in the exact conditions for when it is safe to do the operation
   12358                 :             :      in a narrower mode.  */
   12359                 :    15853855 :   int shorten = 0;
   12360                 :             : 
   12361                 :             :   /* Nonzero if this is a comparison operation;
   12362                 :             :      if both args are promoted shorts, compare the original shorts.
   12363                 :             :      Also implies COMMON.  */
   12364                 :    15853855 :   int short_compare = 0;
   12365                 :             : 
   12366                 :             :   /* Nonzero if this is a right-shift operation, which can be computed on the
   12367                 :             :      original short and then promoted if the operand is a promoted short.  */
   12368                 :    15853855 :   int short_shift = 0;
   12369                 :             : 
   12370                 :             :   /* Nonzero means set RESULT_TYPE to the common type of the args.  */
   12371                 :    15853855 :   int common = 0;
   12372                 :             : 
   12373                 :             :   /* True means types are compatible as far as ObjC is concerned.  */
   12374                 :    15853855 :   bool objc_ok;
   12375                 :             : 
   12376                 :             :   /* True means this is an arithmetic operation that may need excess
   12377                 :             :      precision.  */
   12378                 :    15853855 :   bool may_need_excess_precision;
   12379                 :             : 
   12380                 :             :   /* True means this is a boolean operation that converts both its
   12381                 :             :      operands to truth-values.  */
   12382                 :    15853855 :   bool boolean_op = false;
   12383                 :             : 
   12384                 :             :   /* Remember whether we're doing / or %.  */
   12385                 :    15853855 :   bool doing_div_or_mod = false;
   12386                 :             : 
   12387                 :             :   /* Remember whether we're doing << or >>.  */
   12388                 :    15853855 :   bool doing_shift = false;
   12389                 :             : 
   12390                 :             :   /* Tree holding instrumentation expression.  */
   12391                 :    15853855 :   tree instrument_expr = NULL;
   12392                 :             : 
   12393                 :    15853855 :   if (location == UNKNOWN_LOCATION)
   12394                 :       18697 :     location = input_location;
   12395                 :             : 
   12396                 :    15853855 :   op0 = orig_op0;
   12397                 :    15853855 :   op1 = orig_op1;
   12398                 :             : 
   12399                 :    15853855 :   op0_int_operands = EXPR_INT_CONST_OPERANDS (orig_op0);
   12400                 :     7569136 :   if (op0_int_operands)
   12401                 :     7569136 :     op0 = remove_c_maybe_const_expr (op0);
   12402                 :    15853855 :   op1_int_operands = EXPR_INT_CONST_OPERANDS (orig_op1);
   12403                 :    10668390 :   if (op1_int_operands)
   12404                 :    10668390 :     op1 = remove_c_maybe_const_expr (op1);
   12405                 :    15853855 :   int_operands = (op0_int_operands && op1_int_operands);
   12406                 :    15853855 :   if (int_operands)
   12407                 :             :     {
   12408                 :    14813109 :       int_const_or_overflow = (TREE_CODE (orig_op0) == INTEGER_CST
   12409                 :     7421721 :                                && TREE_CODE (orig_op1) == INTEGER_CST);
   12410                 :     7391388 :       int_const = (int_const_or_overflow
   12411                 :     7391388 :                    && !TREE_OVERFLOW (orig_op0)
   12412                 :     7391353 :                    && !TREE_OVERFLOW (orig_op1));
   12413                 :             :     }
   12414                 :             :   else
   12415                 :             :     int_const = int_const_or_overflow = false;
   12416                 :             : 
   12417                 :             :   /* Do not apply default conversion in mixed vector/scalar expression.  */
   12418                 :    15853855 :   if (convert_p
   12419                 :    15853855 :       && VECTOR_TYPE_P (TREE_TYPE (op0)) == VECTOR_TYPE_P (TREE_TYPE (op1)))
   12420                 :             :     {
   12421                 :     9586673 :       op0 = default_conversion (op0);
   12422                 :     9586673 :       op1 = default_conversion (op1);
   12423                 :             :     }
   12424                 :             : 
   12425                 :    15853855 :   orig_type0 = type0 = TREE_TYPE (op0);
   12426                 :             : 
   12427                 :    15853855 :   orig_type1 = type1 = TREE_TYPE (op1);
   12428                 :             : 
   12429                 :             :   /* The expression codes of the data types of the arguments tell us
   12430                 :             :      whether the arguments are integers, floating, pointers, etc.  */
   12431                 :    15853855 :   code0 = TREE_CODE (type0);
   12432                 :    15853855 :   code1 = TREE_CODE (type1);
   12433                 :             : 
   12434                 :             :   /* Strip NON_LVALUE_EXPRs, etc., since we aren't using as an lvalue.  */
   12435                 :    15853857 :   STRIP_TYPE_NOPS (op0);
   12436                 :    15853858 :   STRIP_TYPE_NOPS (op1);
   12437                 :             : 
   12438                 :             :   /* If an error was already reported for one of the arguments,
   12439                 :             :      avoid reporting another error.  */
   12440                 :             : 
   12441                 :    15853855 :   if (code0 == ERROR_MARK || code1 == ERROR_MARK)
   12442                 :         707 :     return error_mark_node;
   12443                 :             : 
   12444                 :    15853148 :   if (code0 == POINTER_TYPE
   12445                 :    15853148 :       && reject_gcc_builtin (op0, EXPR_LOCATION (orig_op0)))
   12446                 :          11 :     return error_mark_node;
   12447                 :             : 
   12448                 :    15853137 :   if (code1 == POINTER_TYPE
   12449                 :    15853137 :       && reject_gcc_builtin (op1, EXPR_LOCATION (orig_op1)))
   12450                 :          11 :     return error_mark_node;
   12451                 :             : 
   12452                 :    31706252 :   if ((invalid_op_diag
   12453                 :    15853126 :        = targetm.invalid_binary_op (code, type0, type1)))
   12454                 :             :     {
   12455                 :           0 :       error_at (location, invalid_op_diag);
   12456                 :           0 :       return error_mark_node;
   12457                 :             :     }
   12458                 :             : 
   12459                 :    15853126 :   switch (code)
   12460                 :             :     {
   12461                 :             :     case PLUS_EXPR:
   12462                 :             :     case MINUS_EXPR:
   12463                 :             :     case MULT_EXPR:
   12464                 :             :     case TRUNC_DIV_EXPR:
   12465                 :             :     case CEIL_DIV_EXPR:
   12466                 :             :     case FLOOR_DIV_EXPR:
   12467                 :             :     case ROUND_DIV_EXPR:
   12468                 :             :     case EXACT_DIV_EXPR:
   12469                 :             :       may_need_excess_precision = true;
   12470                 :             :       break;
   12471                 :             : 
   12472                 :     2586166 :     case EQ_EXPR:
   12473                 :     2586166 :     case NE_EXPR:
   12474                 :     2586166 :     case LE_EXPR:
   12475                 :     2586166 :     case GE_EXPR:
   12476                 :     2586166 :     case LT_EXPR:
   12477                 :     2586166 :     case GT_EXPR:
   12478                 :             :       /* Excess precision for implicit conversions of integers to
   12479                 :             :          floating point in C11 and later.  */
   12480                 :     2586166 :       may_need_excess_precision = (flag_isoc11
   12481                 :     2586166 :                                    && (ANY_INTEGRAL_TYPE_P (type0)
   12482                 :      472260 :                                        || ANY_INTEGRAL_TYPE_P (type1)));
   12483                 :             :       break;
   12484                 :             : 
   12485                 :             :     default:
   12486                 :    15853126 :       may_need_excess_precision = false;
   12487                 :             :       break;
   12488                 :             :     }
   12489                 :    15853126 :   if (TREE_CODE (op0) == EXCESS_PRECISION_EXPR)
   12490                 :             :     {
   12491                 :         168 :       op0 = TREE_OPERAND (op0, 0);
   12492                 :         168 :       type0 = TREE_TYPE (op0);
   12493                 :             :     }
   12494                 :    15852958 :   else if (may_need_excess_precision
   12495                 :    15852958 :            && (eptype = excess_precision_type (type0)) != NULL_TREE)
   12496                 :             :     {
   12497                 :         753 :       type0 = eptype;
   12498                 :         753 :       op0 = convert (eptype, op0);
   12499                 :             :     }
   12500                 :    15853126 :   if (TREE_CODE (op1) == EXCESS_PRECISION_EXPR)
   12501                 :             :     {
   12502                 :         869 :       op1 = TREE_OPERAND (op1, 0);
   12503                 :         869 :       type1 = TREE_TYPE (op1);
   12504                 :             :     }
   12505                 :    15852257 :   else if (may_need_excess_precision
   12506                 :    15852257 :            && (eptype = excess_precision_type (type1)) != NULL_TREE)
   12507                 :             :     {
   12508                 :         575 :       type1 = eptype;
   12509                 :         575 :       op1 = convert (eptype, op1);
   12510                 :             :     }
   12511                 :             : 
   12512                 :    15853126 :   objc_ok = objc_compare_types (type0, type1, -3, NULL_TREE);
   12513                 :             : 
   12514                 :             :   /* In case when one of the operands of the binary operation is
   12515                 :             :      a vector and another is a scalar -- convert scalar to vector.  */
   12516                 :    17376261 :   if ((gnu_vector_type_p (type0) && code1 != VECTOR_TYPE)
   12517                 :    17374540 :       || (gnu_vector_type_p (type1) && code0 != VECTOR_TYPE))
   12518                 :             :     {
   12519                 :        2283 :       enum stv_conv convert_flag = scalar_to_vector (location, code, orig_op0,
   12520                 :             :                                                      orig_op1, true);
   12521                 :             : 
   12522                 :        2283 :       switch (convert_flag)
   12523                 :             :         {
   12524                 :          12 :           case stv_error:
   12525                 :          12 :             return error_mark_node;
   12526                 :         549 :           case stv_firstarg:
   12527                 :         549 :             {
   12528                 :         549 :               bool maybe_const = true;
   12529                 :         549 :               tree sc;
   12530                 :         549 :               sc = c_fully_fold (op0, false, &maybe_const);
   12531                 :         549 :               sc = save_expr (sc);
   12532                 :         549 :               sc = convert (TREE_TYPE (type1), sc);
   12533                 :         549 :               op0 = build_vector_from_val (type1, sc);
   12534                 :         549 :               if (!maybe_const)
   12535                 :          93 :                 op0 = c_wrap_maybe_const (op0, true);
   12536                 :         549 :               orig_type0 = type0 = TREE_TYPE (op0);
   12537                 :         549 :               code0 = TREE_CODE (type0);
   12538                 :         549 :               converted = 1;
   12539                 :         549 :               break;
   12540                 :             :             }
   12541                 :         953 :           case stv_secondarg:
   12542                 :         953 :             {
   12543                 :         953 :               bool maybe_const = true;
   12544                 :         953 :               tree sc;
   12545                 :         953 :               sc = c_fully_fold (op1, false, &maybe_const);
   12546                 :         953 :               sc = save_expr (sc);
   12547                 :         953 :               sc = convert (TREE_TYPE (type0), sc);
   12548                 :         953 :               op1 = build_vector_from_val (type0, sc);
   12549                 :         953 :               if (!maybe_const)
   12550                 :          29 :                 op1 = c_wrap_maybe_const (op1, true);
   12551                 :         953 :               orig_type1 = type1 = TREE_TYPE (op1);
   12552                 :         953 :               code1 = TREE_CODE (type1);
   12553                 :         953 :               converted = 1;
   12554                 :         953 :               break;
   12555                 :             :             }
   12556                 :             :           default:
   12557                 :             :             break;
   12558                 :             :         }
   12559                 :             :     }
   12560                 :             : 
   12561                 :    15853114 :   switch (code)
   12562                 :             :     {
   12563                 :     8141462 :     case PLUS_EXPR:
   12564                 :             :       /* Handle the pointer + int case.  */
   12565                 :     8141462 :       if (code0 == POINTER_TYPE
   12566                 :     1189374 :           && (code1 == INTEGER_TYPE || code1 == BITINT_TYPE))
   12567                 :             :         {
   12568                 :     1189368 :           ret = pointer_int_sum (location, PLUS_EXPR, op0, op1);
   12569                 :     1189368 :           goto return_build_binary_op;
   12570                 :             :         }
   12571                 :     6952094 :       else if (code1 == POINTER_TYPE
   12572                 :        1298 :                && (code0 == INTEGER_TYPE || code0 == BITINT_TYPE))
   12573                 :             :         {
   12574                 :        1292 :           ret = pointer_int_sum (location, PLUS_EXPR, op1, op0);
   12575                 :        1292 :           goto return_build_binary_op;
   12576                 :             :         }
   12577                 :             :       else
   12578                 :             :         common = 1;
   12579                 :             :       break;
   12580                 :             : 
   12581                 :      783581 :     case MINUS_EXPR:
   12582                 :             :       /* Subtraction of two similar pointers.
   12583                 :             :          We must subtract them as integers, then divide by object size.  */
   12584                 :      783581 :       if (code0 == POINTER_TYPE && code1 == POINTER_TYPE
   12585                 :      783581 :           && comp_target_types (location, type0, type1))
   12586                 :             :         {
   12587                 :        3655 :           ret = pointer_diff (location, op0, op1, &instrument_expr);
   12588                 :        3655 :           goto return_build_binary_op;
   12589                 :             :         }
   12590                 :             :       /* Handle pointer minus int.  Just like pointer plus int.  */
   12591                 :      779926 :       else if (code0 == POINTER_TYPE
   12592                 :       27550 :                && (code1 == INTEGER_TYPE || code1 == BITINT_TYPE))
   12593                 :             :         {
   12594                 :       27538 :           ret = pointer_int_sum (location, MINUS_EXPR, op0, op1);
   12595                 :       27538 :           goto return_build_binary_op;
   12596                 :             :         }
   12597                 :             :       else
   12598                 :             :         common = 1;
   12599                 :             :       break;
   12600                 :             : 
   12601                 :             :     case MULT_EXPR:
   12602                 :             :       common = 1;
   12603                 :             :       break;
   12604                 :             : 
   12605                 :      279898 :     case TRUNC_DIV_EXPR:
   12606                 :      279898 :     case CEIL_DIV_EXPR:
   12607                 :      279898 :     case FLOOR_DIV_EXPR:
   12608                 :      279898 :     case ROUND_DIV_EXPR:
   12609                 :      279898 :     case EXACT_DIV_EXPR:
   12610                 :      279898 :       doing_div_or_mod = true;
   12611                 :      279898 :       warn_for_div_by_zero (location, op1);
   12612                 :             : 
   12613                 :      279897 :       if ((code0 == INTEGER_TYPE || code0 == REAL_TYPE
   12614                 :       48145 :            || code0 == FIXED_POINT_TYPE || code0 == BITINT_TYPE
   12615                 :       46177 :            || code0 == COMPLEX_TYPE
   12616                 :       44131 :            || gnu_vector_type_p (type0))
   12617                 :      328041 :           && (code1 == INTEGER_TYPE || code1 == REAL_TYPE
   12618                 :       45723 :               || code1 == FIXED_POINT_TYPE || code1 == BITINT_TYPE
   12619                 :       45590 :               || code1 == COMPLEX_TYPE
   12620                 :       44133 :               || gnu_vector_type_p (type1)))
   12621                 :             :         {
   12622                 :      279893 :           enum tree_code tcode0 = code0, tcode1 = code1;
   12623                 :             : 
   12624                 :      279893 :           if (code0 == COMPLEX_TYPE || code0 == VECTOR_TYPE)
   12625                 :       46176 :             tcode0 = TREE_CODE (TREE_TYPE (TREE_TYPE (op0)));
   12626                 :      279893 :           if (code1 == COMPLEX_TYPE || code1 == VECTOR_TYPE)
   12627                 :       45587 :             tcode1 = TREE_CODE (TREE_TYPE (TREE_TYPE (op1)));
   12628                 :             : 
   12629                 :      279893 :           if (!(((tcode0 == INTEGER_TYPE || tcode0 == BITINT_TYPE)
   12630                 :      211697 :                  && (tcode1 == INTEGER_TYPE || tcode1 == BITINT_TYPE))
   12631                 :       80222 :                 || (tcode0 == FIXED_POINT_TYPE && tcode1 == FIXED_POINT_TYPE)))
   12632                 :             :             resultcode = RDIV_EXPR;
   12633                 :             :           else
   12634                 :             :             /* Although it would be tempting to shorten always here, that
   12635                 :             :                loses on some targets, since the modulo instruction is
   12636                 :             :                undefined if the quotient can't be represented in the
   12637                 :             :                computation mode.  We shorten only if unsigned or if
   12638                 :             :                dividing by something we know != -1.  */
   12639                 :      199671 :             shorten = may_shorten_divmod (op0, op1);
   12640                 :             :           common = 1;
   12641                 :             :         }
   12642                 :             :       break;
   12643                 :             : 
   12644                 :     1464672 :     case BIT_AND_EXPR:
   12645                 :     1464672 :     case BIT_IOR_EXPR:
   12646                 :     1464672 :     case BIT_XOR_EXPR:
   12647                 :     1464672 :       if ((code0 == INTEGER_TYPE || code0 == BITINT_TYPE)
   12648                 :      952391 :           && (code1 == INTEGER_TYPE || code1 == BITINT_TYPE))
   12649                 :             :         shorten = -1;
   12650                 :             :       /* Allow vector types which are not floating point types.   */
   12651                 :      512317 :       else if (gnu_vector_type_p (type0)
   12652                 :      512240 :                && gnu_vector_type_p (type1)
   12653                 :      512240 :                && !VECTOR_FLOAT_TYPE_P (type0)
   12654                 :     1024554 :                && !VECTOR_FLOAT_TYPE_P (type1))
   12655                 :             :         common = 1;
   12656                 :             :       break;
   12657                 :             : 
   12658                 :       56147 :     case TRUNC_MOD_EXPR:
   12659                 :       56147 :     case FLOOR_MOD_EXPR:
   12660                 :       56147 :       doing_div_or_mod = true;
   12661                 :       56147 :       warn_for_div_by_zero (location, op1);
   12662                 :             : 
   12663                 :       56147 :       if (gnu_vector_type_p (type0)
   12664                 :         295 :           && gnu_vector_type_p (type1)
   12665                 :         295 :           && TREE_CODE (TREE_TYPE (type0)) == INTEGER_TYPE
   12666                 :       56442 :           && TREE_CODE (TREE_TYPE (type1)) == INTEGER_TYPE)
   12667                 :             :         common = 1;
   12668                 :       55852 :       else if ((code0 == INTEGER_TYPE || code0 == BITINT_TYPE)
   12669                 :       55851 :                && (code1 == INTEGER_TYPE || code1 == BITINT_TYPE))
   12670                 :             :         {
   12671                 :             :           /* Although it would be tempting to shorten always here, that loses
   12672                 :             :              on some targets, since the modulo instruction is undefined if the
   12673                 :             :              quotient can't be represented in the computation mode.  We shorten
   12674                 :             :              only if unsigned or if dividing by something we know != -1.  */
   12675                 :       55851 :           shorten = may_shorten_divmod (op0, op1);
   12676                 :       55851 :           common = 1;
   12677                 :             :         }
   12678                 :             :       break;
   12679                 :             : 
   12680                 :      481231 :     case TRUTH_ANDIF_EXPR:
   12681                 :      481231 :     case TRUTH_ORIF_EXPR:
   12682                 :      481231 :     case TRUTH_AND_EXPR:
   12683                 :      481231 :     case TRUTH_OR_EXPR:
   12684                 :      481231 :     case TRUTH_XOR_EXPR:
   12685                 :      481231 :       if ((code0 == INTEGER_TYPE || code0 == POINTER_TYPE
   12686                 :           0 :            || code0 == REAL_TYPE || code0 == COMPLEX_TYPE
   12687                 :           0 :            || code0 == FIXED_POINT_TYPE || code0 == NULLPTR_TYPE
   12688                 :           0 :            || code0 == BITINT_TYPE)
   12689                 :      481231 :           && (code1 == INTEGER_TYPE || code1 == POINTER_TYPE
   12690                 :         154 :               || code1 == REAL_TYPE || code1 == COMPLEX_TYPE
   12691                 :          18 :               || code1 == FIXED_POINT_TYPE || code1 == NULLPTR_TYPE
   12692                 :          16 :               || code1 == BITINT_TYPE))
   12693                 :             :         {
   12694                 :             :           /* Result of these operations is always an int,
   12695                 :             :              but that does not mean the operands should be
   12696                 :             :              converted to ints!  */
   12697                 :      481231 :           result_type = integer_type_node;
   12698                 :      481231 :           if (op0_int_operands)
   12699                 :             :             {
   12700                 :       90211 :               op0 = c_objc_common_truthvalue_conversion (location, orig_op0);
   12701                 :       90211 :               op0 = remove_c_maybe_const_expr (op0);
   12702                 :             :             }
   12703                 :             :           else
   12704                 :      391020 :             op0 = c_objc_common_truthvalue_conversion (location, op0);
   12705                 :      481231 :           if (op1_int_operands)
   12706                 :             :             {
   12707                 :       51720 :               op1 = c_objc_common_truthvalue_conversion (location, orig_op1);
   12708                 :       51720 :               op1 = remove_c_maybe_const_expr (op1);
   12709                 :             :             }
   12710                 :             :           else
   12711                 :      429511 :             op1 = c_objc_common_truthvalue_conversion (location, op1);
   12712                 :             :           converted = 1;
   12713                 :             :           boolean_op = true;
   12714                 :             :         }
   12715                 :      481231 :       if (code == TRUTH_ANDIF_EXPR)
   12716                 :             :         {
   12717                 :      207477 :           int_const_or_overflow = (int_operands
   12718                 :       43741 :                                    && TREE_CODE (orig_op0) == INTEGER_CST
   12719                 :      207493 :                                    && (op0 == truthvalue_false_node
   12720                 :        9958 :                                        || TREE_CODE (orig_op1) == INTEGER_CST));
   12721                 :             :           int_const = (int_const_or_overflow
   12722                 :       43714 :                        && !TREE_OVERFLOW (orig_op0)
   12723                 :       43714 :                        && (op0 == truthvalue_false_node
   12724                 :        9942 :                            || !TREE_OVERFLOW (orig_op1)));
   12725                 :             :         }
   12726                 :      317468 :       else if (code == TRUTH_ORIF_EXPR)
   12727                 :             :         {
   12728                 :      324036 :           int_const_or_overflow = (int_operands
   12729                 :        6719 :                                    && TREE_CODE (orig_op0) == INTEGER_CST
   12730                 :      324059 :                                    && (op0 == truthvalue_true_node
   12731                 :        2036 :                                        || TREE_CODE (orig_op1) == INTEGER_CST));
   12732                 :             :           int_const = (int_const_or_overflow
   12733                 :        6689 :                        && !TREE_OVERFLOW (orig_op0)
   12734                 :        6689 :                        && (op0 == truthvalue_true_node
   12735                 :        2013 :                            || !TREE_OVERFLOW (orig_op1)));
   12736                 :             :         }
   12737                 :             :       break;
   12738                 :             : 
   12739                 :             :       /* Shift operations: result has same type as first operand;
   12740                 :             :          always convert second operand to int.
   12741                 :             :          Also set SHORT_SHIFT if shifting rightward.  */
   12742                 :             : 
   12743                 :      193736 :     case RSHIFT_EXPR:
   12744                 :      193736 :       if (gnu_vector_type_p (type0)
   12745                 :         737 :           && gnu_vector_type_p (type1)
   12746                 :         247 :           && TREE_CODE (TREE_TYPE (type0)) == INTEGER_TYPE
   12747                 :         245 :           && TREE_CODE (TREE_TYPE (type1)) == INTEGER_TYPE
   12748                 :      193981 :           && known_eq (TYPE_VECTOR_SUBPARTS (type0),
   12749                 :             :                        TYPE_VECTOR_SUBPARTS (type1)))
   12750                 :             :         {
   12751                 :             :           result_type = type0;
   12752                 :             :           converted = 1;
   12753                 :             :         }
   12754                 :      193493 :       else if ((code0 == INTEGER_TYPE || code0 == FIXED_POINT_TYPE
   12755                 :        1004 :                 || code0 == BITINT_TYPE
   12756                 :         498 :                 || (gnu_vector_type_p (type0)
   12757                 :         494 :                     && TREE_CODE (TREE_TYPE (type0)) == INTEGER_TYPE))
   12758                 :      194490 :                && (code1 == INTEGER_TYPE || code1 == BITINT_TYPE))
   12759                 :             :         {
   12760                 :      193484 :           doing_shift = true;
   12761                 :      193484 :           if (TREE_CODE (op1) == INTEGER_CST)
   12762                 :             :             {
   12763                 :      164895 :               if (tree_int_cst_sgn (op1) < 0)
   12764                 :             :                 {
   12765                 :         245 :                   int_const = false;
   12766                 :         245 :                   if (c_inhibit_evaluation_warnings == 0)
   12767                 :         105 :                     warning_at (location, OPT_Wshift_count_negative,
   12768                 :             :                                 "right shift count is negative");
   12769                 :             :                 }
   12770                 :      164650 :               else if (code0 == VECTOR_TYPE)
   12771                 :             :                 {
   12772                 :         417 :                   if (compare_tree_int (op1,
   12773                 :         417 :                                         TYPE_PRECISION (TREE_TYPE (type0)))
   12774                 :             :                       >= 0)
   12775                 :             :                     {
   12776                 :          16 :                       int_const = false;
   12777                 :          16 :                       if (c_inhibit_evaluation_warnings == 0)
   12778                 :          16 :                         warning_at (location, OPT_Wshift_count_overflow,
   12779                 :             :                                     "right shift count >= width of vector element");
   12780                 :             :                     }
   12781                 :             :                 }
   12782                 :             :               else
   12783                 :             :                 {
   12784                 :      164233 :                   if (!integer_zerop (op1))
   12785                 :      163875 :                     short_shift = 1;
   12786                 :             : 
   12787                 :      164233 :                   if (compare_tree_int (op1, TYPE_PRECISION (type0)) >= 0)
   12788                 :             :                     {
   12789                 :         584 :                       int_const = false;
   12790                 :         584 :                       if (c_inhibit_evaluation_warnings == 0)
   12791                 :          50 :                         warning_at (location, OPT_Wshift_count_overflow,
   12792                 :             :                                     "right shift count >= width of type");
   12793                 :             :                     }
   12794                 :             :                 }
   12795                 :             :             }
   12796                 :             : 
   12797                 :             :           /* Use the type of the value to be shifted.  */
   12798                 :             :           result_type = type0;
   12799                 :             :           /* Avoid converting op1 to result_type later.  */
   12800                 :             :           converted = 1;
   12801                 :             :         }
   12802                 :             :       break;
   12803                 :             : 
   12804                 :      712192 :     case LSHIFT_EXPR:
   12805                 :      712192 :       if (gnu_vector_type_p (type0)
   12806                 :         579 :           && gnu_vector_type_p (type1)
   12807                 :         306 :           && TREE_CODE (TREE_TYPE (type0)) == INTEGER_TYPE
   12808                 :         304 :           && TREE_CODE (TREE_TYPE (type1)) == INTEGER_TYPE
   12809                 :      712495 :           && known_eq (TYPE_VECTOR_SUBPARTS (type0),
   12810                 :             :                        TYPE_VECTOR_SUBPARTS (type1)))
   12811                 :             :         {
   12812                 :             :           result_type = type0;
   12813                 :             :           converted = 1;
   12814                 :             :         }
   12815                 :      711891 :       else if ((code0 == INTEGER_TYPE || code0 == FIXED_POINT_TYPE
   12816                 :         701 :                 || code0 == BITINT_TYPE
   12817                 :         284 :                 || (gnu_vector_type_p (type0)
   12818                 :         278 :                     && TREE_CODE (TREE_TYPE (type0)) == INTEGER_TYPE))
   12819                 :      712583 :                && (code1 == INTEGER_TYPE || code1 == BITINT_TYPE))
   12820                 :             :         {
   12821                 :      711877 :           doing_shift = true;
   12822                 :      711877 :           if (TREE_CODE (op0) == INTEGER_CST
   12823                 :      399094 :               && tree_int_cst_sgn (op0) < 0
   12824                 :      712625 :               && !TYPE_OVERFLOW_WRAPS (type0))
   12825                 :             :             {
   12826                 :             :               /* Don't reject a left shift of a negative value in a context
   12827                 :             :                  where a constant expression is needed in C90.  */
   12828                 :         711 :               if (flag_isoc99)
   12829                 :         665 :                 int_const = false;
   12830                 :         711 :               if (c_inhibit_evaluation_warnings == 0)
   12831                 :         711 :                 warning_at (location, OPT_Wshift_negative_value,
   12832                 :             :                             "left shift of negative value");
   12833                 :             :             }
   12834                 :      711877 :           if (TREE_CODE (op1) == INTEGER_CST)
   12835                 :             :             {
   12836                 :      650924 :               if (tree_int_cst_sgn (op1) < 0)
   12837                 :             :                 {
   12838                 :         281 :                   int_const = false;
   12839                 :         281 :                   if (c_inhibit_evaluation_warnings == 0)
   12840                 :         103 :                     warning_at (location, OPT_Wshift_count_negative,
   12841                 :             :                                 "left shift count is negative");
   12842                 :             :                 }
   12843                 :      650643 :               else if (code0 == VECTOR_TYPE)
   12844                 :             :                 {
   12845                 :         211 :                   if (compare_tree_int (op1,
   12846                 :         211 :                                         TYPE_PRECISION (TREE_TYPE (type0)))
   12847                 :             :                       >= 0)
   12848                 :             :                     {
   12849                 :           6 :                       int_const = false;
   12850                 :           6 :                       if (c_inhibit_evaluation_warnings == 0)
   12851                 :           6 :                         warning_at (location, OPT_Wshift_count_overflow,
   12852                 :             :                                     "left shift count >= width of vector element");
   12853                 :             :                     }
   12854                 :             :                 }
   12855                 :      650432 :               else if (compare_tree_int (op1, TYPE_PRECISION (type0)) >= 0)
   12856                 :             :                 {
   12857                 :       29731 :                   int_const = false;
   12858                 :       29731 :                   if (c_inhibit_evaluation_warnings == 0)
   12859                 :         111 :                     warning_at (location, OPT_Wshift_count_overflow,
   12860                 :             :                                 "left shift count >= width of type");
   12861                 :             :                 }
   12862                 :      620701 :               else if (TREE_CODE (op0) == INTEGER_CST
   12863                 :      336006 :                        && maybe_warn_shift_overflow (location, op0, op1)
   12864                 :      635316 :                        && flag_isoc99)
   12865                 :             :                 int_const = false;
   12866                 :             :             }
   12867                 :             : 
   12868                 :             :           /* Use the type of the value to be shifted.  */
   12869                 :             :           result_type = type0;
   12870                 :             :           /* Avoid converting op1 to result_type later.  */
   12871                 :             :           converted = 1;
   12872                 :             :         }
   12873                 :             :       break;
   12874                 :             : 
   12875                 :     1649459 :     case EQ_EXPR:
   12876                 :     1649459 :     case NE_EXPR:
   12877                 :     1649459 :       if (gnu_vector_type_p (type0) && gnu_vector_type_p (type1))
   12878                 :             :         {
   12879                 :       40527 :           tree intt;
   12880                 :       40527 :           if (!vector_types_compatible_elements_p (type0, type1))
   12881                 :             :             {
   12882                 :           4 :               error_at (location, "comparing vectors with different "
   12883                 :             :                                   "element types");
   12884                 :           4 :               return error_mark_node;
   12885                 :             :             }
   12886                 :             : 
   12887                 :       40523 :           if (maybe_ne (TYPE_VECTOR_SUBPARTS (type0),
   12888                 :       81046 :                         TYPE_VECTOR_SUBPARTS (type1)))
   12889                 :             :             {
   12890                 :           1 :               error_at (location, "comparing vectors with different "
   12891                 :             :                                   "number of elements");
   12892                 :           1 :               return error_mark_node;
   12893                 :             :             }
   12894                 :             : 
   12895                 :             :           /* It's not precisely specified how the usual arithmetic
   12896                 :             :              conversions apply to the vector types.  Here, we use
   12897                 :             :              the unsigned type if one of the operands is signed and
   12898                 :             :              the other one is unsigned.  */
   12899                 :       40522 :           if (TYPE_UNSIGNED (type0) != TYPE_UNSIGNED (type1))
   12900                 :             :             {
   12901                 :           4 :               if (!TYPE_UNSIGNED (type0))
   12902                 :           4 :                 op0 = build1 (VIEW_CONVERT_EXPR, type1, op0);
   12903                 :             :               else
   12904                 :           0 :                 op1 = build1 (VIEW_CONVERT_EXPR, type0, op1);
   12905                 :           4 :               warning_at (location, OPT_Wsign_compare, "comparison between "
   12906                 :             :                           "types %qT and %qT", type0, type1);
   12907                 :             :             }
   12908                 :             : 
   12909                 :             :           /* Always construct signed integer vector type.  */
   12910                 :      121566 :           intt = c_common_type_for_size (GET_MODE_BITSIZE
   12911                 :       81044 :                                          (SCALAR_TYPE_MODE
   12912                 :             :                                           (TREE_TYPE (type0))), 0);
   12913                 :       40522 :           if (!intt)
   12914                 :             :             {
   12915                 :           0 :               error_at (location, "could not find an integer type "
   12916                 :             :                                   "of the same size as %qT",
   12917                 :           0 :                         TREE_TYPE (type0));
   12918                 :           0 :               return error_mark_node;
   12919                 :             :             }
   12920                 :       40522 :           result_type = build_opaque_vector_type (intt,
   12921                 :       40522 :                                                   TYPE_VECTOR_SUBPARTS (type0));
   12922                 :       40522 :           converted = 1;
   12923                 :       40522 :           ret = build_vec_cmp (resultcode, result_type, op0, op1);
   12924                 :       40522 :           goto return_build_binary_op;
   12925                 :             :         }
   12926                 :     1608932 :       if (FLOAT_TYPE_P (type0) || FLOAT_TYPE_P (type1))
   12927                 :      249510 :         warning_at (location,
   12928                 :             :                     OPT_Wfloat_equal,
   12929                 :             :                     "comparing floating-point with %<==%> or %<!=%> is unsafe");
   12930                 :             :       /* Result of comparison is always int,
   12931                 :             :          but don't convert the args to int!  */
   12932                 :     1608932 :       build_type = integer_type_node;
   12933                 :     1608932 :       if ((code0 == INTEGER_TYPE || code0 == REAL_TYPE || code0 == BITINT_TYPE
   12934                 :      151461 :            || code0 == FIXED_POINT_TYPE || code0 == COMPLEX_TYPE)
   12935                 :     1492157 :           && (code1 == INTEGER_TYPE || code1 == REAL_TYPE
   12936                 :             :               || code1 == BITINT_TYPE
   12937                 :             :               || code1 == FIXED_POINT_TYPE || code1 == COMPLEX_TYPE))
   12938                 :             :         short_compare = 1;
   12939                 :      117030 :       else if (code0 == POINTER_TYPE
   12940                 :      117030 :                && (code1 == NULLPTR_TYPE
   12941                 :      116703 :                    || null_pointer_constant_p (orig_op1)))
   12942                 :             :         {
   12943                 :       47507 :           maybe_warn_for_null_address (location, op0, code);
   12944                 :       47507 :           result_type = type0;
   12945                 :             :         }
   12946                 :       69523 :       else if (code1 == POINTER_TYPE
   12947                 :       69523 :                && (code0 == NULLPTR_TYPE
   12948                 :       69434 :                    || null_pointer_constant_p (orig_op0)))
   12949                 :             :         {
   12950                 :         277 :           maybe_warn_for_null_address (location, op1, code);
   12951                 :         277 :           result_type = type1;
   12952                 :             :         }
   12953                 :       69246 :       else if (code0 == POINTER_TYPE && code1 == POINTER_TYPE)
   12954                 :             :         {
   12955                 :       69169 :           tree tt0 = TREE_TYPE (type0);
   12956                 :       69169 :           tree tt1 = TREE_TYPE (type1);
   12957                 :       69169 :           addr_space_t as0 = TYPE_ADDR_SPACE (tt0);
   12958                 :       69169 :           addr_space_t as1 = TYPE_ADDR_SPACE (tt1);
   12959                 :       69169 :           addr_space_t as_common = ADDR_SPACE_GENERIC;
   12960                 :             : 
   12961                 :             :           /* Anything compares with void *.  void * compares with anything.
   12962                 :             :              Otherwise, the targets must be compatible
   12963                 :             :              and both must be object or both incomplete.  */
   12964                 :       69169 :           if (comp_target_types (location, type0, type1))
   12965                 :       47902 :             result_type = common_pointer_type (type0, type1);
   12966                 :       21267 :           else if (!addr_space_superset (as0, as1, &as_common))
   12967                 :             :             {
   12968                 :           0 :               error_at (location, "comparison of pointers to "
   12969                 :             :                         "disjoint address spaces");
   12970                 :           0 :               return error_mark_node;
   12971                 :             :             }
   12972                 :       21267 :           else if (VOID_TYPE_P (tt0) && !TYPE_ATOMIC (tt0))
   12973                 :             :             {
   12974                 :       21086 :               if (pedantic && TREE_CODE (tt1) == FUNCTION_TYPE)
   12975                 :           4 :                 pedwarn (location, OPT_Wpedantic, "ISO C forbids "
   12976                 :             :                          "comparison of %<void *%> with function pointer");
   12977                 :             :             }
   12978                 :         181 :           else if (VOID_TYPE_P (tt1) && !TYPE_ATOMIC (tt1))
   12979                 :             :             {
   12980                 :         133 :               if (pedantic && TREE_CODE (tt0) == FUNCTION_TYPE)
   12981                 :           4 :                 pedwarn (location, OPT_Wpedantic, "ISO C forbids "
   12982                 :             :                          "comparison of %<void *%> with function pointer");
   12983                 :             :             }
   12984                 :             :           else
   12985                 :             :             /* Avoid warning about the volatile ObjC EH puts on decls.  */
   12986                 :          48 :             if (!objc_ok)
   12987                 :          48 :               pedwarn (location, OPT_Wcompare_distinct_pointer_types,
   12988                 :             :                        "comparison of distinct pointer types lacks a cast");
   12989                 :             : 
   12990                 :       47958 :           if (result_type == NULL_TREE)
   12991                 :             :             {
   12992                 :       21267 :               int qual = ENCODE_QUAL_ADDR_SPACE (as_common);
   12993                 :       21267 :               result_type = build_pointer_type
   12994                 :       21267 :                               (build_qualified_type (void_type_node, qual));
   12995                 :             :             }
   12996                 :             :         }
   12997                 :          77 :       else if (code0 == POINTER_TYPE
   12998                 :          25 :                && (code1 == INTEGER_TYPE || code1 == BITINT_TYPE))
   12999                 :             :         {
   13000                 :          25 :           result_type = type0;
   13001                 :          25 :           pedwarn (location, 0, "comparison between pointer and integer");
   13002                 :             :         }
   13003                 :          52 :       else if ((code0 == INTEGER_TYPE || code0 == BITINT_TYPE)
   13004                 :          19 :                && code1 == POINTER_TYPE)
   13005                 :             :         {
   13006                 :           8 :           result_type = type1;
   13007                 :           8 :           pedwarn (location, 0, "comparison between pointer and integer");
   13008                 :             :         }
   13009                 :             :       /* 6.5.9: One of the following shall hold:
   13010                 :             :          -- both operands have type nullptr_t;  */
   13011                 :          44 :       else if (code0 == NULLPTR_TYPE && code1 == NULLPTR_TYPE)
   13012                 :             :         {
   13013                 :          14 :           result_type = nullptr_type_node;
   13014                 :             :           /* No need to convert the operands to result_type later.  */
   13015                 :          14 :           converted = 1;
   13016                 :             :         }
   13017                 :             :     /* -- one operand has type nullptr_t and the other is a null pointer
   13018                 :             :        constant.  We will have to convert the former to the type of the
   13019                 :             :        latter, because during gimplification we can't have mismatching
   13020                 :             :        comparison operand type.  We convert from nullptr_t to the other
   13021                 :             :        type, since only nullptr_t can be converted to nullptr_t.  Also,
   13022                 :             :        even a constant 0 is a null pointer constant, so we may have to
   13023                 :             :        create a pointer type from its type.  */
   13024                 :          30 :       else if (code0 == NULLPTR_TYPE && null_pointer_constant_p (orig_op1))
   13025                 :          17 :         result_type = (INTEGRAL_TYPE_P (type1)
   13026                 :          17 :                        ? build_pointer_type (type1) : type1);
   13027                 :          13 :       else if (code1 == NULLPTR_TYPE && null_pointer_constant_p (orig_op0))
   13028                 :           9 :         result_type = (INTEGRAL_TYPE_P (type0)
   13029                 :           9 :                        ? build_pointer_type (type0) : type0);
   13030                 :     4757495 :       if ((C_BOOLEAN_TYPE_P (TREE_TYPE (orig_op0))
   13031                 :     3148538 :            || truth_value_p (TREE_CODE (orig_op0)))
   13032                 :     3210808 :           ^ (C_BOOLEAN_TYPE_P (TREE_TYPE (orig_op1))
   13033                 :     3210808 :              || truth_value_p (TREE_CODE (orig_op1))))
   13034                 :       66518 :         maybe_warn_bool_compare (location, code, orig_op0, orig_op1);
   13035                 :             :       break;
   13036                 :             : 
   13037                 :      936703 :     case LE_EXPR:
   13038                 :      936703 :     case GE_EXPR:
   13039                 :      936703 :     case LT_EXPR:
   13040                 :      936703 :     case GT_EXPR:
   13041                 :      936703 :       if (gnu_vector_type_p (type0) && gnu_vector_type_p (type1))
   13042                 :             :         {
   13043                 :       57252 :           tree intt;
   13044                 :       57252 :           if (!vector_types_compatible_elements_p (type0, type1))
   13045                 :             :             {
   13046                 :           5 :               error_at (location, "comparing vectors with different "
   13047                 :             :                                   "element types");
   13048                 :           5 :               return error_mark_node;
   13049                 :             :             }
   13050                 :             : 
   13051                 :       57247 :           if (maybe_ne (TYPE_VECTOR_SUBPARTS (type0),
   13052                 :      114494 :                         TYPE_VECTOR_SUBPARTS (type1)))
   13053                 :             :             {
   13054                 :           0 :               error_at (location, "comparing vectors with different "
   13055                 :             :                                   "number of elements");
   13056                 :           0 :               return error_mark_node;
   13057                 :             :             }
   13058                 :             : 
   13059                 :             :           /* It's not precisely specified how the usual arithmetic
   13060                 :             :              conversions apply to the vector types.  Here, we use
   13061                 :             :              the unsigned type if one of the operands is signed and
   13062                 :             :              the other one is unsigned.  */
   13063                 :       57247 :           if (TYPE_UNSIGNED (type0) != TYPE_UNSIGNED (type1))
   13064                 :             :             {
   13065                 :          15 :               if (!TYPE_UNSIGNED (type0))
   13066                 :           8 :                 op0 = build1 (VIEW_CONVERT_EXPR, type1, op0);
   13067                 :             :               else
   13068                 :           7 :                 op1 = build1 (VIEW_CONVERT_EXPR, type0, op1);
   13069                 :          15 :               warning_at (location, OPT_Wsign_compare, "comparison between "
   13070                 :             :                           "types %qT and %qT", type0, type1);
   13071                 :             :             }
   13072                 :             : 
   13073                 :             :           /* Always construct signed integer vector type.  */
   13074                 :      171741 :           intt = c_common_type_for_size (GET_MODE_BITSIZE
   13075                 :      114494 :                                          (SCALAR_TYPE_MODE
   13076                 :             :                                           (TREE_TYPE (type0))), 0);
   13077                 :       57247 :           if (!intt)
   13078                 :             :             {
   13079                 :           0 :               error_at (location, "could not find an integer type "
   13080                 :             :                                   "of the same size as %qT",
   13081                 :           0 :                         TREE_TYPE (type0));
   13082                 :           0 :               return error_mark_node;
   13083                 :             :             }
   13084                 :       57247 :           result_type = build_opaque_vector_type (intt,
   13085                 :       57247 :                                                   TYPE_VECTOR_SUBPARTS (type0));
   13086                 :       57247 :           converted = 1;
   13087                 :       57247 :           ret = build_vec_cmp (resultcode, result_type, op0, op1);
   13088                 :       57247 :           goto return_build_binary_op;
   13089                 :             :         }
   13090                 :      879451 :       build_type = integer_type_node;
   13091                 :      879451 :       if ((code0 == INTEGER_TYPE || code0 == REAL_TYPE
   13092                 :       60772 :            || code0 == BITINT_TYPE || code0 == FIXED_POINT_TYPE)
   13093                 :      819207 :           && (code1 == INTEGER_TYPE || code1 == REAL_TYPE
   13094                 :             :               || code1 == BITINT_TYPE || code1 == FIXED_POINT_TYPE))
   13095                 :             :         short_compare = 1;
   13096                 :       60276 :       else if (code0 == POINTER_TYPE && code1 == POINTER_TYPE)
   13097                 :             :         {
   13098                 :       60219 :           addr_space_t as0 = TYPE_ADDR_SPACE (TREE_TYPE (type0));
   13099                 :       60219 :           addr_space_t as1 = TYPE_ADDR_SPACE (TREE_TYPE (type1));
   13100                 :       60219 :           addr_space_t as_common;
   13101                 :             : 
   13102                 :       60219 :           if (comp_target_types (location, type0, type1))
   13103                 :             :             {
   13104                 :       60106 :               result_type = common_pointer_type (type0, type1);
   13105                 :       60106 :               if (!COMPLETE_TYPE_P (TREE_TYPE (type0))
   13106                 :       60106 :                   != !COMPLETE_TYPE_P (TREE_TYPE (type1)))
   13107                 :          32 :                 pedwarn_c99 (location, OPT_Wpedantic,
   13108                 :             :                              "comparison of complete and incomplete pointers");
   13109                 :       60074 :               else if (TREE_CODE (TREE_TYPE (type0)) == FUNCTION_TYPE)
   13110                 :           0 :                 pedwarn (location, OPT_Wpedantic, "ISO C forbids "
   13111                 :             :                          "ordered comparisons of pointers to functions");
   13112                 :       60074 :               else if (null_pointer_constant_p (orig_op0)
   13113                 :       60074 :                        || null_pointer_constant_p (orig_op1))
   13114                 :           8 :                 warning_at (location, OPT_Wextra,
   13115                 :             :                             "ordered comparison of pointer with null pointer");
   13116                 :             : 
   13117                 :             :             }
   13118                 :         113 :           else if (!addr_space_superset (as0, as1, &as_common))
   13119                 :             :             {
   13120                 :           0 :               error_at (location, "comparison of pointers to "
   13121                 :             :                         "disjoint address spaces");
   13122                 :           0 :               return error_mark_node;
   13123                 :             :             }
   13124                 :             :           else
   13125                 :             :             {
   13126                 :         113 :               int qual = ENCODE_QUAL_ADDR_SPACE (as_common);
   13127                 :         113 :               result_type = build_pointer_type
   13128                 :         113 :                               (build_qualified_type (void_type_node, qual));
   13129                 :         113 :               pedwarn (location, OPT_Wcompare_distinct_pointer_types,
   13130                 :             :                        "comparison of distinct pointer types lacks a cast");
   13131                 :             :             }
   13132                 :             :         }
   13133                 :          57 :       else if (code0 == POINTER_TYPE && null_pointer_constant_p (orig_op1))
   13134                 :             :         {
   13135                 :          17 :           result_type = type0;
   13136                 :          17 :           if (pedantic)
   13137                 :          11 :             pedwarn (location, OPT_Wpedantic,
   13138                 :             :                      "ordered comparison of pointer with integer zero");
   13139                 :           6 :           else if (extra_warnings)
   13140                 :           1 :             warning_at (location, OPT_Wextra,
   13141                 :             :                         "ordered comparison of pointer with integer zero");
   13142                 :             :         }
   13143                 :          40 :       else if (code1 == POINTER_TYPE && null_pointer_constant_p (orig_op0))
   13144                 :             :         {
   13145                 :          12 :           result_type = type1;
   13146                 :          12 :           if (pedantic)
   13147                 :           2 :             pedwarn (location, OPT_Wpedantic,
   13148                 :             :                      "ordered comparison of pointer with integer zero");
   13149                 :          10 :           else if (extra_warnings)
   13150                 :           1 :             warning_at (location, OPT_Wextra,
   13151                 :             :                         "ordered comparison of pointer with integer zero");
   13152                 :             :         }
   13153                 :          28 :       else if (code0 == POINTER_TYPE
   13154                 :           8 :                && (code1 == INTEGER_TYPE || code1 == BITINT_TYPE))
   13155                 :             :         {
   13156                 :           8 :           result_type = type0;
   13157                 :           8 :           pedwarn (location, 0, "comparison between pointer and integer");
   13158                 :             :         }
   13159                 :          20 :       else if ((code0 == INTEGER_TYPE || code0 == BITINT_TYPE)
   13160                 :          20 :                && code1 == POINTER_TYPE)
   13161                 :             :         {
   13162                 :          18 :           result_type = type1;
   13163                 :          18 :           pedwarn (location, 0, "comparison between pointer and integer");
   13164                 :             :         }
   13165                 :             : 
   13166                 :      879451 :       if ((code0 == POINTER_TYPE || code1 == POINTER_TYPE)
   13167                 :       60274 :           && current_function_decl != NULL_TREE
   13168                 :      939714 :           && sanitize_flags_p (SANITIZE_POINTER_COMPARE))
   13169                 :             :         {
   13170                 :          35 :           op0 = save_expr (op0);
   13171                 :          35 :           op1 = save_expr (op1);
   13172                 :             : 
   13173                 :          35 :           tree tt = builtin_decl_explicit (BUILT_IN_ASAN_POINTER_COMPARE);
   13174                 :          35 :           instrument_expr = build_call_expr_loc (location, tt, 2, op0, op1);
   13175                 :             :         }
   13176                 :             : 
   13177                 :     2638269 :       if ((C_BOOLEAN_TYPE_P (TREE_TYPE (orig_op0))
   13178                 :     1758818 :            || truth_value_p (TREE_CODE (orig_op0)))
   13179                 :     1758829 :           ^ (C_BOOLEAN_TYPE_P (TREE_TYPE (orig_op1))
   13180                 :     1758829 :              || truth_value_p (TREE_CODE (orig_op1))))
   13181                 :         490 :         maybe_warn_bool_compare (location, code, orig_op0, orig_op1);
   13182                 :             :       break;
   13183                 :             : 
   13184                 :          43 :     case MIN_EXPR:
   13185                 :          43 :     case MAX_EXPR:
   13186                 :             :       /* Used for OpenMP atomics.  */
   13187                 :          43 :       gcc_assert (flag_openmp);
   13188                 :             :       common = 1;
   13189                 :             :       break;
   13190                 :             : 
   13191                 :           0 :     default:
   13192                 :           0 :       gcc_unreachable ();
   13193                 :             :     }
   13194                 :             : 
   13195                 :    14533481 :   if (code0 == ERROR_MARK || code1 == ERROR_MARK)
   13196                 :           0 :     return error_mark_node;
   13197                 :             : 
   13198                 :    14533481 :   if (gnu_vector_type_p (type0)
   13199                 :     1425901 :       && gnu_vector_type_p (type1)
   13200                 :    15958618 :       && (!tree_int_cst_equal (TYPE_SIZE (type0), TYPE_SIZE (type1))
   13201                 :     1425117 :           || !vector_types_compatible_elements_p (type0, type1)))
   13202                 :             :     {
   13203                 :          26 :       gcc_rich_location richloc (location);
   13204                 :          26 :       maybe_range_label_for_tree_type_mismatch
   13205                 :          26 :         label_for_op0 (orig_op0, orig_op1),
   13206                 :          26 :         label_for_op1 (orig_op1, orig_op0);
   13207                 :          26 :       richloc.maybe_add_expr (orig_op0, &label_for_op0);
   13208                 :          26 :       richloc.maybe_add_expr (orig_op1, &label_for_op1);
   13209                 :          26 :       binary_op_error (&richloc, code, type0, type1);
   13210                 :          26 :       return error_mark_node;
   13211                 :          26 :     }
   13212                 :             : 
   13213                 :    14533455 :   if ((code0 == INTEGER_TYPE || code0 == REAL_TYPE || code0 == COMPLEX_TYPE
   13214                 :     1669890 :        || code0 == FIXED_POINT_TYPE || code0 == BITINT_TYPE
   13215                 :     1603305 :        || gnu_vector_type_p (type0))
   13216                 :    16025915 :       && (code1 == INTEGER_TYPE || code1 == REAL_TYPE || code1 == COMPLEX_TYPE
   13217                 :     1517582 :           || code1 == FIXED_POINT_TYPE || code1 == BITINT_TYPE
   13218                 :     1427124 :           || gnu_vector_type_p (type1)))
   13219                 :             :     {
   13220                 :    14354017 :       bool first_complex = (code0 == COMPLEX_TYPE);
   13221                 :    14354017 :       bool second_complex = (code1 == COMPLEX_TYPE);
   13222                 :    14354017 :       int none_complex = (!first_complex && !second_complex);
   13223                 :             : 
   13224                 :    14354017 :       if (shorten || common || short_compare)
   13225                 :             :         {
   13226                 :    12968511 :           result_type = c_common_type (type0, type1);
   13227                 :    12968511 :           do_warn_double_promotion (result_type, type0, type1,
   13228                 :             :                                     "implicit conversion from %qT to %qT "
   13229                 :             :                                     "to match other operand of binary "
   13230                 :             :                                     "expression",
   13231                 :             :                                     location);
   13232                 :    12968511 :           if (result_type == error_mark_node)
   13233                 :             :             return error_mark_node;
   13234                 :             :         }
   13235                 :             : 
   13236                 :    14353995 :       if (first_complex != second_complex
   13237                 :       81777 :           && (code == PLUS_EXPR
   13238                 :             :               || code == MINUS_EXPR
   13239                 :       81777 :               || code == MULT_EXPR
   13240                 :       17309 :               || (code == TRUNC_DIV_EXPR && first_complex))
   13241                 :       65882 :           && TREE_CODE (TREE_TYPE (result_type)) == REAL_TYPE
   13242                 :    14416210 :           && flag_signed_zeros)
   13243                 :             :         {
   13244                 :             :           /* An operation on mixed real/complex operands must be
   13245                 :             :              handled specially, but the language-independent code can
   13246                 :             :              more easily optimize the plain complex arithmetic if
   13247                 :             :              -fno-signed-zeros.  */
   13248                 :       61971 :           tree real_type = TREE_TYPE (result_type);
   13249                 :       61971 :           tree real, imag;
   13250                 :       61971 :           if (type0 != orig_type0 || type1 != orig_type1)
   13251                 :             :             {
   13252                 :          94 :               gcc_assert (may_need_excess_precision && common);
   13253                 :          94 :               semantic_result_type = c_common_type (orig_type0, orig_type1);
   13254                 :             :             }
   13255                 :       61971 :           if (first_complex)
   13256                 :             :             {
   13257                 :        8258 :               if (TREE_TYPE (op0) != result_type)
   13258                 :        1793 :                 op0 = convert_and_check (location, result_type, op0);
   13259                 :        8258 :               if (TREE_TYPE (op1) != real_type)
   13260                 :        4600 :                 op1 = convert_and_check (location, real_type, op1);
   13261                 :             :             }
   13262                 :             :           else
   13263                 :             :             {
   13264                 :       53713 :               if (TREE_TYPE (op0) != real_type)
   13265                 :        2698 :                 op0 = convert_and_check (location, real_type, op0);
   13266                 :       53713 :               if (TREE_TYPE (op1) != result_type)
   13267                 :        1881 :                 op1 = convert_and_check (location, result_type, op1);
   13268                 :             :             }
   13269                 :       61971 :           if (TREE_CODE (op0) == ERROR_MARK || TREE_CODE (op1) == ERROR_MARK)
   13270                 :           0 :             return error_mark_node;
   13271                 :       61971 :           if (first_complex)
   13272                 :             :             {
   13273                 :        8258 :               op0 = save_expr (op0);
   13274                 :        8258 :               real = build_unary_op (EXPR_LOCATION (orig_op0), REALPART_EXPR,
   13275                 :             :                                      op0, true);
   13276                 :        8258 :               imag = build_unary_op (EXPR_LOCATION (orig_op0), IMAGPART_EXPR,
   13277                 :             :                                      op0, true);
   13278                 :        8258 :               switch (code)
   13279                 :             :                 {
   13280                 :        3501 :                 case MULT_EXPR:
   13281                 :        3501 :                 case TRUNC_DIV_EXPR:
   13282                 :        3501 :                   op1 = save_expr (op1);
   13283                 :        3501 :                   imag = build2 (resultcode, real_type, imag, op1);
   13284                 :             :                   /* Fall through.  */
   13285                 :        8258 :                 case PLUS_EXPR:
   13286                 :        8258 :                 case MINUS_EXPR:
   13287                 :        8258 :                   real = build2 (resultcode, real_type, real, op1);
   13288                 :        8258 :                   break;
   13289                 :           0 :                 default:
   13290                 :           0 :                   gcc_unreachable();
   13291                 :             :                 }
   13292                 :             :             }
   13293                 :             :           else
   13294                 :             :             {
   13295                 :       53713 :               op1 = save_expr (op1);
   13296                 :       53713 :               real = build_unary_op (EXPR_LOCATION (orig_op1), REALPART_EXPR,
   13297                 :             :                                      op1, true);
   13298                 :       53713 :               imag = build_unary_op (EXPR_LOCATION (orig_op1), IMAGPART_EXPR,
   13299                 :             :                                      op1, true);
   13300                 :       53713 :               switch (code)
   13301                 :             :                 {
   13302                 :        2021 :                 case MULT_EXPR:
   13303                 :        2021 :                   op0 = save_expr (op0);
   13304                 :        2021 :                   imag = build2 (resultcode, real_type, op0, imag);
   13305                 :             :                   /* Fall through.  */
   13306                 :       31981 :                 case PLUS_EXPR:
   13307                 :       31981 :                   real = build2 (resultcode, real_type, op0, real);
   13308                 :       31981 :                   break;
   13309                 :       21732 :                 case MINUS_EXPR:
   13310                 :       21732 :                   real = build2 (resultcode, real_type, op0, real);
   13311                 :       21732 :                   imag = build1 (NEGATE_EXPR, real_type, imag);
   13312                 :       21732 :                   break;
   13313                 :           0 :                 default:
   13314                 :           0 :                   gcc_unreachable();
   13315                 :             :                 }
   13316                 :             :             }
   13317                 :       61971 :           ret = build2 (COMPLEX_EXPR, result_type, real, imag);
   13318                 :       61971 :           goto return_build_binary_op;
   13319                 :             :         }
   13320                 :             : 
   13321                 :             :       /* For certain operations (which identify themselves by shorten != 0)
   13322                 :             :          if both args were extended from the same smaller type,
   13323                 :             :          do the arithmetic in that type and then extend.
   13324                 :             : 
   13325                 :             :          shorten !=0 and !=1 indicates a bitwise operation.
   13326                 :             :          For them, this optimization is safe only if
   13327                 :             :          both args are zero-extended or both are sign-extended.
   13328                 :             :          Otherwise, we might change the result.
   13329                 :             :          Eg, (short)-1 | (unsigned short)-1 is (int)-1
   13330                 :             :          but calculated in (unsigned short) it would be (unsigned short)-1.  */
   13331                 :             : 
   13332                 :    14292024 :       if (shorten && none_complex)
   13333                 :             :         {
   13334                 :     1201816 :           final_type = result_type;
   13335                 :     1201816 :           result_type = shorten_binary_op (result_type, op0, op1,
   13336                 :             :                                            shorten == -1);
   13337                 :             :         }
   13338                 :             : 
   13339                 :             :       /* Shifts can be shortened if shifting right.  */
   13340                 :             : 
   13341                 :    14292024 :       if (short_shift)
   13342                 :             :         {
   13343                 :      163875 :           int unsigned_arg;
   13344                 :      163875 :           tree arg0 = get_narrower (op0, &unsigned_arg);
   13345                 :             : 
   13346                 :      163875 :           final_type = result_type;
   13347                 :             : 
   13348                 :      163875 :           if (arg0 == op0 && final_type == TREE_TYPE (op0))
   13349                 :      106774 :             unsigned_arg = TYPE_UNSIGNED (TREE_TYPE (op0));
   13350                 :             : 
   13351                 :      163875 :           if (TYPE_PRECISION (TREE_TYPE (arg0)) < TYPE_PRECISION (result_type)
   13352                 :        2264 :               && tree_int_cst_sgn (op1) > 0
   13353                 :             :               /* We can shorten only if the shift count is less than the
   13354                 :             :                  number of bits in the smaller type size.  */
   13355                 :        2264 :               && compare_tree_int (op1, TYPE_PRECISION (TREE_TYPE (arg0))) < 0
   13356                 :             :               /* We cannot drop an unsigned shift after sign-extension.  */
   13357                 :      166015 :               && (!TYPE_UNSIGNED (final_type) || unsigned_arg))
   13358                 :             :             {
   13359                 :             :               /* Do an unsigned shift if the operand was zero-extended.  */
   13360                 :        2126 :               result_type
   13361                 :        2126 :                 = c_common_signed_or_unsigned_type (unsigned_arg,
   13362                 :        2126 :                                                     TREE_TYPE (arg0));
   13363                 :             :               /* Convert value-to-be-shifted to that type.  */
   13364                 :        2126 :               if (TREE_TYPE (op0) != result_type)
   13365                 :        2126 :                 op0 = convert (result_type, op0);
   13366                 :             :               converted = 1;
   13367                 :             :             }
   13368                 :             :         }
   13369                 :             : 
   13370                 :             :       /* Comparison operations are shortened too but differently.
   13371                 :             :          They identify themselves by setting short_compare = 1.  */
   13372                 :             : 
   13373                 :    14292024 :       if (short_compare)
   13374                 :             :         {
   13375                 :             :           /* Don't write &op0, etc., because that would prevent op0
   13376                 :             :              from being kept in a register.
   13377                 :             :              Instead, make copies of the our local variables and
   13378                 :             :              pass the copies by reference, then copy them back afterward.  */
   13379                 :     2311075 :           tree xop0 = op0, xop1 = op1, xresult_type = result_type;
   13380                 :     2311075 :           enum tree_code xresultcode = resultcode;
   13381                 :     2311075 :           tree val
   13382                 :     2311075 :             = shorten_compare (location, &xop0, &xop1, &xresult_type,
   13383                 :             :                                &xresultcode);
   13384                 :             : 
   13385                 :     2311075 :           if (val != NULL_TREE)
   13386                 :             :             {
   13387                 :       11472 :               ret = val;
   13388                 :       11472 :               goto return_build_binary_op;
   13389                 :             :             }
   13390                 :             : 
   13391                 :     2299603 :           op0 = xop0, op1 = xop1;
   13392                 :     2299603 :           converted = 1;
   13393                 :     2299603 :           resultcode = xresultcode;
   13394                 :             : 
   13395                 :     2299603 :           if (c_inhibit_evaluation_warnings == 0 && !c_in_omp_for)
   13396                 :             :             {
   13397                 :     2186377 :               bool op0_maybe_const = true;
   13398                 :     2186377 :               bool op1_maybe_const = true;
   13399                 :     2186377 :               tree orig_op0_folded, orig_op1_folded;
   13400                 :             : 
   13401                 :     2186377 :               if (in_late_binary_op)
   13402                 :             :                 {
   13403                 :             :                   orig_op0_folded = orig_op0;
   13404                 :             :                   orig_op1_folded = orig_op1;
   13405                 :             :                 }
   13406                 :             :               else
   13407                 :             :                 {
   13408                 :             :                   /* Fold for the sake of possible warnings, as in
   13409                 :             :                      build_conditional_expr.  This requires the
   13410                 :             :                      "original" values to be folded, not just op0 and
   13411                 :             :                      op1.  */
   13412                 :     2180816 :                   c_inhibit_evaluation_warnings++;
   13413                 :     2180816 :                   op0 = c_fully_fold (op0, require_constant_value,
   13414                 :             :                                       &op0_maybe_const);
   13415                 :     2180816 :                   op1 = c_fully_fold (op1, require_constant_value,
   13416                 :             :                                       &op1_maybe_const);
   13417                 :     2180816 :                   c_inhibit_evaluation_warnings--;
   13418                 :     2180816 :                   orig_op0_folded = c_fully_fold (orig_op0,
   13419                 :             :                                                   require_constant_value,
   13420                 :             :                                                   NULL);
   13421                 :     2180816 :                   orig_op1_folded = c_fully_fold (orig_op1,
   13422                 :             :                                                   require_constant_value,
   13423                 :             :                                                   NULL);
   13424                 :             :                 }
   13425                 :             : 
   13426                 :     2186377 :               if (warn_sign_compare)
   13427                 :      347408 :                 warn_for_sign_compare (location, orig_op0_folded,
   13428                 :             :                                        orig_op1_folded, op0, op1,
   13429                 :             :                                        result_type, resultcode);
   13430                 :     2186377 :               if (!in_late_binary_op && !int_operands)
   13431                 :             :                 {
   13432                 :     2010640 :                   if (!op0_maybe_const || TREE_CODE (op0) != INTEGER_CST)
   13433                 :     2007233 :                     op0 = c_wrap_maybe_const (op0, !op0_maybe_const);
   13434                 :     2010640 :                   if (!op1_maybe_const || TREE_CODE (op1) != INTEGER_CST)
   13435                 :      804100 :                     op1 = c_wrap_maybe_const (op1, !op1_maybe_const);
   13436                 :             :                 }
   13437                 :             :             }
   13438                 :             :         }
   13439                 :             :     }
   13440                 :             : 
   13441                 :             :   /* At this point, RESULT_TYPE must be nonzero to avoid an error message.
   13442                 :             :      If CONVERTED is zero, both args will be converted to type RESULT_TYPE.
   13443                 :             :      Then the expression will be built.
   13444                 :             :      It will be given type FINAL_TYPE if that is nonzero;
   13445                 :             :      otherwise, it will be given type RESULT_TYPE.  */
   13446                 :             : 
   13447                 :    14459990 :   if (!result_type)
   13448                 :             :     {
   13449                 :             :       /* Favor showing any expression locations that are available. */
   13450                 :         510 :       op_location_t oploc (location, UNKNOWN_LOCATION);
   13451                 :         510 :       binary_op_rich_location richloc (oploc, orig_op0, orig_op1, true);
   13452                 :         510 :       binary_op_error (&richloc, code, TREE_TYPE (op0), TREE_TYPE (op1));
   13453                 :         510 :       return error_mark_node;
   13454                 :         510 :     }
   13455                 :             : 
   13456                 :    14459480 :   if (build_type == NULL_TREE)
   13457                 :             :     {
   13458                 :    11982577 :       build_type = result_type;
   13459                 :    11982577 :       if ((type0 != orig_type0 || type1 != orig_type1)
   13460                 :         780 :           && !boolean_op)
   13461                 :             :         {
   13462                 :         780 :           gcc_assert (may_need_excess_precision && common);
   13463                 :         780 :           semantic_result_type = c_common_type (orig_type0, orig_type1);
   13464                 :             :         }
   13465                 :             :     }
   13466                 :             : 
   13467                 :    14459480 :   if (!converted)
   13468                 :             :     {
   13469                 :    10771595 :       op0 = ep_convert_and_check (location, result_type, op0,
   13470                 :             :                                   semantic_result_type);
   13471                 :    10771595 :       op1 = ep_convert_and_check (location, result_type, op1,
   13472                 :             :                                   semantic_result_type);
   13473                 :             : 
   13474                 :             :       /* This can happen if one operand has a vector type, and the other
   13475                 :             :          has a different type.  */
   13476                 :    10771595 :       if (TREE_CODE (op0) == ERROR_MARK || TREE_CODE (op1) == ERROR_MARK)
   13477                 :           3 :         return error_mark_node;
   13478                 :             :     }
   13479                 :             : 
   13480                 :    14459477 :   if (sanitize_flags_p ((SANITIZE_SHIFT
   13481                 :             :                          | SANITIZE_DIVIDE
   13482                 :             :                          | SANITIZE_FLOAT_DIVIDE
   13483                 :             :                          | SANITIZE_SI_OVERFLOW))
   13484                 :       21434 :       && current_function_decl != NULL_TREE
   13485                 :       18139 :       && (doing_div_or_mod || doing_shift)
   13486                 :    14462093 :       && !require_constant_value)
   13487                 :             :     {
   13488                 :             :       /* OP0 and/or OP1 might have side-effects.  */
   13489                 :        2560 :       op0 = save_expr (op0);
   13490                 :        2560 :       op1 = save_expr (op1);
   13491                 :        2560 :       op0 = c_fully_fold (op0, false, NULL);
   13492                 :        2560 :       op1 = c_fully_fold (op1, false, NULL);
   13493                 :        2560 :       if (doing_div_or_mod && (sanitize_flags_p ((SANITIZE_DIVIDE
   13494                 :             :                                                   | SANITIZE_FLOAT_DIVIDE
   13495                 :             :                                                   | SANITIZE_SI_OVERFLOW))))
   13496                 :         899 :         instrument_expr = ubsan_instrument_division (location, op0, op1);
   13497                 :        1661 :       else if (doing_shift && sanitize_flags_p (SANITIZE_SHIFT))
   13498                 :        1481 :         instrument_expr = ubsan_instrument_shift (location, code, op0, op1);
   13499                 :             :     }
   13500                 :             : 
   13501                 :             :   /* Treat expressions in initializers specially as they can't trap.  */
   13502                 :    14459477 :   if (int_const_or_overflow)
   13503                 :     7380271 :     ret = (require_constant_value
   13504                 :     7380271 :            ? fold_build2_initializer_loc (location, resultcode, build_type,
   13505                 :             :                                           op0, op1)
   13506                 :     7334214 :            : fold_build2_loc (location, resultcode, build_type, op0, op1));
   13507                 :             :   else
   13508                 :     7079206 :     ret = build2 (resultcode, build_type, op0, op1);
   13509                 :    14459477 :   if (final_type != NULL_TREE)
   13510                 :     1365691 :     ret = convert (final_type, ret);
   13511                 :             : 
   13512                 :    13093786 :  return_build_binary_op:
   13513                 :    15852542 :   gcc_assert (ret != error_mark_node);
   13514                 :    15852542 :   if (TREE_CODE (ret) == INTEGER_CST && !TREE_OVERFLOW (ret) && !int_const)
   13515                 :       15666 :     ret = (int_operands
   13516                 :       15666 :            ? note_integer_operands (ret)
   13517                 :         420 :            : build1 (NOP_EXPR, TREE_TYPE (ret), ret));
   13518                 :    15836876 :   else if (TREE_CODE (ret) != INTEGER_CST && int_operands
   13519                 :       60324 :            && !in_late_binary_op)
   13520                 :       60324 :     ret = note_integer_operands (ret);
   13521                 :    15852542 :   protected_set_expr_location (ret, location);
   13522                 :             : 
   13523                 :    15852542 :   if (instrument_expr != NULL)
   13524                 :        1434 :     ret = fold_build2 (COMPOUND_EXPR, TREE_TYPE (ret),
   13525                 :             :                        instrument_expr, ret);
   13526                 :             : 
   13527                 :    15852542 :   if (semantic_result_type)
   13528                 :         874 :     ret = build1_loc (location, EXCESS_PRECISION_EXPR,
   13529                 :             :                       semantic_result_type, ret);
   13530                 :             : 
   13531                 :             :   return ret;
   13532                 :             : }
   13533                 :             : 
   13534                 :             : 
   13535                 :             : /* Convert EXPR to be a truth-value (type TYPE), validating its type for this
   13536                 :             :    purpose.  LOCATION is the source location for the expression.  */
   13537                 :             : 
   13538                 :             : tree
   13539                 :     3874168 : c_objc_common_truthvalue_conversion (location_t location, tree expr, tree type)
   13540                 :             : {
   13541                 :     3874168 :   bool int_const, int_operands;
   13542                 :             : 
   13543                 :     3874168 :   switch (TREE_CODE (TREE_TYPE (expr)))
   13544                 :             :     {
   13545                 :          72 :     case ARRAY_TYPE:
   13546                 :          72 :       error_at (location, "used array that cannot be converted to pointer where scalar is required");
   13547                 :          72 :       return error_mark_node;
   13548                 :             : 
   13549                 :          82 :     case RECORD_TYPE:
   13550                 :          82 :       error_at (location, "used struct type value where scalar is required");
   13551                 :          82 :       return error_mark_node;
   13552                 :             : 
   13553                 :          83 :     case UNION_TYPE:
   13554                 :          83 :       error_at (location, "used union type value where scalar is required");
   13555                 :          83 :       return error_mark_node;
   13556                 :             : 
   13557                 :          22 :     case VOID_TYPE:
   13558                 :          22 :       error_at (location, "void value not ignored as it ought to be");
   13559                 :          22 :       return error_mark_node;
   13560                 :             : 
   13561                 :       28404 :     case POINTER_TYPE:
   13562                 :       28404 :       if (reject_gcc_builtin (expr))
   13563                 :           3 :         return error_mark_node;
   13564                 :             :       break;
   13565                 :             : 
   13566                 :           0 :     case FUNCTION_TYPE:
   13567                 :           0 :       gcc_unreachable ();
   13568                 :             : 
   13569                 :           8 :     case VECTOR_TYPE:
   13570                 :           8 :       error_at (location, "used vector type where scalar is required");
   13571                 :           8 :       return error_mark_node;
   13572                 :             : 
   13573                 :             :     default:
   13574                 :             :       break;
   13575                 :             :     }
   13576                 :             : 
   13577                 :             :   /* Conversion of a floating constant to boolean goes through here
   13578                 :             :      and yields an integer constant expression.  Otherwise, the result
   13579                 :             :      is only an integer constant expression if the argument is.  */
   13580                 :      760142 :   int_const = ((TREE_CODE (expr) == INTEGER_CST && !TREE_OVERFLOW (expr))
   13581                 :     3873974 :                || ((TREE_CODE (expr) == REAL_CST
   13582                 :     3113458 :                     || TREE_CODE (expr) == COMPLEX_CST)
   13583                 :         374 :                    && (TREE_CODE (type) == BOOLEAN_TYPE
   13584                 :          15 :                        || (TREE_CODE (type) == ENUMERAL_TYPE
   13585                 :           5 :                            && ENUM_UNDERLYING_TYPE (type) != NULL_TREE
   13586                 :           5 :                            && (TREE_CODE (ENUM_UNDERLYING_TYPE (type))
   13587                 :             :                                == BOOLEAN_TYPE)))));
   13588                 :     3873898 :   int_operands = EXPR_INT_CONST_OPERANDS (expr);
   13589                 :      760293 :   if (int_operands && TREE_CODE (expr) != INTEGER_CST)
   13590                 :             :     {
   13591                 :         287 :       expr = remove_c_maybe_const_expr (expr);
   13592                 :         287 :       expr = build2 (NE_EXPR, type, expr,
   13593                 :         287 :                      convert (TREE_TYPE (expr), integer_zero_node));
   13594                 :         287 :       expr = note_integer_operands (expr);
   13595                 :             :     }
   13596                 :             :   else
   13597                 :             :     {
   13598                 :             :       /* ??? Should we also give an error for vectors rather than leaving
   13599                 :             :          those to give errors later?  */
   13600                 :     3873611 :       expr = c_common_truthvalue_conversion (location, expr);
   13601                 :     3873611 :       expr = fold_convert_loc (location, type, expr);
   13602                 :             :     }
   13603                 :             : 
   13604                 :     3873898 :   if (TREE_CODE (expr) == INTEGER_CST && int_operands && !int_const)
   13605                 :             :     {
   13606                 :          76 :       if (TREE_OVERFLOW (expr))
   13607                 :             :         return expr;
   13608                 :             :       else
   13609                 :          76 :         return note_integer_operands (expr);
   13610                 :             :     }
   13611                 :     3873822 :   if (TREE_CODE (expr) == INTEGER_CST && !int_const)
   13612                 :         743 :     return build1 (NOP_EXPR, TREE_TYPE (expr), expr);
   13613                 :             :   return expr;
   13614                 :             : }
   13615                 :             : 
   13616                 :             : 
   13617                 :             : /* Convert EXPR to a contained DECL, updating *TC, *TI and *SE as
   13618                 :             :    required.  */
   13619                 :             : 
   13620                 :             : tree
   13621                 :   104402362 : c_expr_to_decl (tree expr, bool *tc ATTRIBUTE_UNUSED, bool *se)
   13622                 :             : {
   13623                 :   104402362 :   if (TREE_CODE (expr) == COMPOUND_LITERAL_EXPR)
   13624                 :             :     {
   13625                 :         639 :       tree decl = COMPOUND_LITERAL_EXPR_DECL (expr);
   13626                 :             :       /* Executing a compound literal inside a function reinitializes
   13627                 :             :          it.  */
   13628                 :         639 :       if (!TREE_STATIC (decl))
   13629                 :         383 :         *se = true;
   13630                 :         639 :       return decl;
   13631                 :             :     }
   13632                 :             :   else
   13633                 :             :     return expr;
   13634                 :             : }
   13635                 :             : 
   13636                 :             : /* Generate OMP construct CODE, with BODY and CLAUSES as its compound
   13637                 :             :    statement.  LOC is the location of the construct.  */
   13638                 :             : 
   13639                 :             : tree
   13640                 :        1982 : c_finish_omp_construct (location_t loc, enum tree_code code, tree body,
   13641                 :             :                         tree clauses)
   13642                 :             : {
   13643                 :        1982 :   body = c_end_compound_stmt (loc, body, true);
   13644                 :             : 
   13645                 :        1982 :   tree stmt = make_node (code);
   13646                 :        1982 :   TREE_TYPE (stmt) = void_type_node;
   13647                 :        1982 :   OMP_BODY (stmt) = body;
   13648                 :        1982 :   OMP_CLAUSES (stmt) = clauses;
   13649                 :        1982 :   SET_EXPR_LOCATION (stmt, loc);
   13650                 :             : 
   13651                 :        1982 :   return add_stmt (stmt);
   13652                 :             : }
   13653                 :             : 
   13654                 :             : /* Generate OACC_DATA, with CLAUSES and BLOCK as its compound
   13655                 :             :    statement.  LOC is the location of the OACC_DATA.  */
   13656                 :             : 
   13657                 :             : tree
   13658                 :         465 : c_finish_oacc_data (location_t loc, tree clauses, tree block)
   13659                 :             : {
   13660                 :         465 :   tree stmt;
   13661                 :             : 
   13662                 :         465 :   block = c_end_compound_stmt (loc, block, true);
   13663                 :             : 
   13664                 :         465 :   stmt = make_node (OACC_DATA);
   13665                 :         465 :   TREE_TYPE (stmt) = void_type_node;
   13666                 :         465 :   OACC_DATA_CLAUSES (stmt) = clauses;
   13667                 :         465 :   OACC_DATA_BODY (stmt) = block;
   13668                 :         465 :   SET_EXPR_LOCATION (stmt, loc);
   13669                 :             : 
   13670                 :         465 :   return add_stmt (stmt);
   13671                 :             : }
   13672                 :             : 
   13673                 :             : /* Generate OACC_HOST_DATA, with CLAUSES and BLOCK as its compound
   13674                 :             :    statement.  LOC is the location of the OACC_HOST_DATA.  */
   13675                 :             : 
   13676                 :             : tree
   13677                 :          21 : c_finish_oacc_host_data (location_t loc, tree clauses, tree block)
   13678                 :             : {
   13679                 :          21 :   tree stmt;
   13680                 :             : 
   13681                 :          21 :   block = c_end_compound_stmt (loc, block, true);
   13682                 :             : 
   13683                 :          21 :   stmt = make_node (OACC_HOST_DATA);
   13684                 :          21 :   TREE_TYPE (stmt) = void_type_node;
   13685                 :          21 :   OACC_HOST_DATA_CLAUSES (stmt) = clauses;
   13686                 :          21 :   OACC_HOST_DATA_BODY (stmt) = block;
   13687                 :          21 :   SET_EXPR_LOCATION (stmt, loc);
   13688                 :             : 
   13689                 :          21 :   return add_stmt (stmt);
   13690                 :             : }
   13691                 :             : 
   13692                 :             : /* Like c_begin_compound_stmt, except force the retention of the BLOCK.  */
   13693                 :             : 
   13694                 :             : tree
   13695                 :       11518 : c_begin_omp_parallel (void)
   13696                 :             : {
   13697                 :       11518 :   tree block;
   13698                 :             : 
   13699                 :       11518 :   keep_next_level ();
   13700                 :       11518 :   block = c_begin_compound_stmt (true);
   13701                 :             : 
   13702                 :       11518 :   return block;
   13703                 :             : }
   13704                 :             : 
   13705                 :             : /* Generate OMP_PARALLEL, with CLAUSES and BLOCK as its compound
   13706                 :             :    statement.  LOC is the location of the OMP_PARALLEL.  */
   13707                 :             : 
   13708                 :             : tree
   13709                 :        5433 : c_finish_omp_parallel (location_t loc, tree clauses, tree block)
   13710                 :             : {
   13711                 :        5433 :   tree stmt;
   13712                 :             : 
   13713                 :        5433 :   block = c_end_compound_stmt (loc, block, true);
   13714                 :             : 
   13715                 :        5433 :   stmt = make_node (OMP_PARALLEL);
   13716                 :        5433 :   TREE_TYPE (stmt) = void_type_node;
   13717                 :        5433 :   OMP_PARALLEL_CLAUSES (stmt) = clauses;
   13718                 :        5433 :   OMP_PARALLEL_BODY (stmt) = block;
   13719                 :        5433 :   SET_EXPR_LOCATION (stmt, loc);
   13720                 :             : 
   13721                 :        5433 :   return add_stmt (stmt);
   13722                 :             : }
   13723                 :             : 
   13724                 :             : /* Like c_begin_compound_stmt, except force the retention of the BLOCK.  */
   13725                 :             : 
   13726                 :             : tree
   13727                 :         892 : c_begin_omp_task (void)
   13728                 :             : {
   13729                 :         892 :   tree block;
   13730                 :             : 
   13731                 :         892 :   keep_next_level ();
   13732                 :         892 :   block = c_begin_compound_stmt (true);
   13733                 :             : 
   13734                 :         892 :   return block;
   13735                 :             : }
   13736                 :             : 
   13737                 :             : /* Generate OMP_TASK, with CLAUSES and BLOCK as its compound
   13738                 :             :    statement.  LOC is the location of the #pragma.  */
   13739                 :             : 
   13740                 :             : tree
   13741                 :         892 : c_finish_omp_task (location_t loc, tree clauses, tree block)
   13742                 :             : {
   13743                 :         892 :   tree stmt;
   13744                 :             : 
   13745                 :         892 :   block = c_end_compound_stmt (loc, block, true);
   13746                 :             : 
   13747                 :         892 :   stmt = make_node (OMP_TASK);
   13748                 :         892 :   TREE_TYPE (stmt) = void_type_node;
   13749                 :         892 :   OMP_TASK_CLAUSES (stmt) = clauses;
   13750                 :         892 :   OMP_TASK_BODY (stmt) = block;
   13751                 :         892 :   SET_EXPR_LOCATION (stmt, loc);
   13752                 :             : 
   13753                 :         892 :   return add_stmt (stmt);
   13754                 :             : }
   13755                 :             : 
   13756                 :             : /* Generate GOMP_cancel call for #pragma omp cancel.  */
   13757                 :             : 
   13758                 :             : void
   13759                 :         213 : c_finish_omp_cancel (location_t loc, tree clauses)
   13760                 :             : {
   13761                 :         213 :   tree fn = builtin_decl_explicit (BUILT_IN_GOMP_CANCEL);
   13762                 :         213 :   int mask = 0;
   13763                 :         213 :   if (omp_find_clause (clauses, OMP_CLAUSE_PARALLEL))
   13764                 :             :     mask = 1;
   13765                 :         150 :   else if (omp_find_clause (clauses, OMP_CLAUSE_FOR))
   13766                 :             :     mask = 2;
   13767                 :         101 :   else if (omp_find_clause (clauses, OMP_CLAUSE_SECTIONS))
   13768                 :             :     mask = 4;
   13769                 :          58 :   else if (omp_find_clause (clauses, OMP_CLAUSE_TASKGROUP))
   13770                 :             :     mask = 8;
   13771                 :             :   else
   13772                 :             :     {
   13773                 :           0 :       error_at (loc, "%<#pragma omp cancel%> must specify one of "
   13774                 :             :                      "%<parallel%>, %<for%>, %<sections%> or %<taskgroup%> "
   13775                 :             :                      "clauses");
   13776                 :           0 :       return;
   13777                 :             :     }
   13778                 :         213 :   tree ifc = omp_find_clause (clauses, OMP_CLAUSE_IF);
   13779                 :         213 :   if (ifc != NULL_TREE)
   13780                 :             :     {
   13781                 :          31 :       if (OMP_CLAUSE_IF_MODIFIER (ifc) != ERROR_MARK
   13782                 :          31 :           && OMP_CLAUSE_IF_MODIFIER (ifc) != VOID_CST)
   13783                 :           2 :         error_at (OMP_CLAUSE_LOCATION (ifc),
   13784                 :             :                   "expected %<cancel%> %<if%> clause modifier");
   13785                 :             :       else
   13786                 :             :         {
   13787                 :          29 :           tree ifc2 = omp_find_clause (OMP_CLAUSE_CHAIN (ifc), OMP_CLAUSE_IF);
   13788                 :          29 :           if (ifc2 != NULL_TREE)
   13789                 :             :             {
   13790                 :           1 :               gcc_assert (OMP_CLAUSE_IF_MODIFIER (ifc) == VOID_CST
   13791                 :             :                           && OMP_CLAUSE_IF_MODIFIER (ifc2) != ERROR_MARK
   13792                 :             :                           && OMP_CLAUSE_IF_MODIFIER (ifc2) != VOID_CST);
   13793                 :           1 :               error_at (OMP_CLAUSE_LOCATION (ifc2),
   13794                 :             :                         "expected %<cancel%> %<if%> clause modifier");
   13795                 :             :             }
   13796                 :             :         }
   13797                 :             : 
   13798                 :          31 :       tree type = TREE_TYPE (OMP_CLAUSE_IF_EXPR (ifc));
   13799                 :          62 :       ifc = fold_build2_loc (OMP_CLAUSE_LOCATION (ifc), NE_EXPR,
   13800                 :          31 :                              boolean_type_node, OMP_CLAUSE_IF_EXPR (ifc),
   13801                 :             :                              build_zero_cst (type));
   13802                 :             :     }
   13803                 :             :   else
   13804                 :         182 :     ifc = boolean_true_node;
   13805                 :         213 :   tree stmt = build_call_expr_loc (loc, fn, 2,
   13806                 :             :                                    build_int_cst (integer_type_node, mask),
   13807                 :             :                                    ifc);
   13808                 :         213 :   add_stmt (stmt);
   13809                 :             : }
   13810                 :             : 
   13811                 :             : /* Generate GOMP_cancellation_point call for
   13812                 :             :    #pragma omp cancellation point.  */
   13813                 :             : 
   13814                 :             : void
   13815                 :         167 : c_finish_omp_cancellation_point (location_t loc, tree clauses)
   13816                 :             : {
   13817                 :         167 :   tree fn = builtin_decl_explicit (BUILT_IN_GOMP_CANCELLATION_POINT);
   13818                 :         167 :   int mask = 0;
   13819                 :         167 :   if (omp_find_clause (clauses, OMP_CLAUSE_PARALLEL))
   13820                 :             :     mask = 1;
   13821                 :         123 :   else if (omp_find_clause (clauses, OMP_CLAUSE_FOR))
   13822                 :             :     mask = 2;
   13823                 :          88 :   else if (omp_find_clause (clauses, OMP_CLAUSE_SECTIONS))
   13824                 :             :     mask = 4;
   13825                 :          53 :   else if (omp_find_clause (clauses, OMP_CLAUSE_TASKGROUP))
   13826                 :             :     mask = 8;
   13827                 :             :   else
   13828                 :             :     {
   13829                 :           1 :       error_at (loc, "%<#pragma omp cancellation point%> must specify one of "
   13830                 :             :                      "%<parallel%>, %<for%>, %<sections%> or %<taskgroup%> "
   13831                 :             :                      "clauses");
   13832                 :           1 :       return;
   13833                 :             :     }
   13834                 :         166 :   tree stmt = build_call_expr_loc (loc, fn, 1,
   13835                 :             :                                    build_int_cst (integer_type_node, mask));
   13836                 :         166 :   add_stmt (stmt);
   13837                 :             : }
   13838                 :             : 
   13839                 :             : /* Helper function for handle_omp_array_sections.  Called recursively
   13840                 :             :    to handle multiple array-section-subscripts.  C is the clause,
   13841                 :             :    T current expression (initially OMP_CLAUSE_DECL), which is either
   13842                 :             :    a TREE_LIST for array-section-subscript (TREE_PURPOSE is low-bound
   13843                 :             :    expression if specified, TREE_VALUE length expression if specified,
   13844                 :             :    TREE_CHAIN is what it has been specified after, or some decl.
   13845                 :             :    TYPES vector is populated with array section types, MAYBE_ZERO_LEN
   13846                 :             :    set to true if any of the array-section-subscript could have length
   13847                 :             :    of zero (explicit or implicit), FIRST_NON_ONE is the index of the
   13848                 :             :    first array-section-subscript which is known not to have length
   13849                 :             :    of one.  Given say:
   13850                 :             :    map(a[:b][2:1][:c][:2][:d][e:f][2:5])
   13851                 :             :    FIRST_NON_ONE will be 3, array-section-subscript [:b], [2:1] and [:c]
   13852                 :             :    all are or may have length of 1, array-section-subscript [:2] is the
   13853                 :             :    first one known not to have length 1.  For array-section-subscript
   13854                 :             :    <= FIRST_NON_ONE we diagnose non-contiguous arrays if low bound isn't
   13855                 :             :    0 or length isn't the array domain max + 1, for > FIRST_NON_ONE we
   13856                 :             :    can if MAYBE_ZERO_LEN is false.  MAYBE_ZERO_LEN will be true in the above
   13857                 :             :    case though, as some lengths could be zero.  */
   13858                 :             : 
   13859                 :             : static tree
   13860                 :        6068 : handle_omp_array_sections_1 (tree c, tree t, vec<tree> &types,
   13861                 :             :                              bool &maybe_zero_len, unsigned int &first_non_one,
   13862                 :             :                              enum c_omp_region_type ort)
   13863                 :             : {
   13864                 :        6068 :   tree ret, low_bound, length, type;
   13865                 :        6068 :   bool openacc = (ort & C_ORT_ACC) != 0;
   13866                 :        6068 :   if (TREE_CODE (t) != OMP_ARRAY_SECTION)
   13867                 :             :     {
   13868                 :        2829 :       if (error_operand_p (t))
   13869                 :           2 :         return error_mark_node;
   13870                 :        2827 :       c_omp_address_inspector ai (OMP_CLAUSE_LOCATION (c), t);
   13871                 :        2827 :       ret = t;
   13872                 :        2827 :       if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_AFFINITY
   13873                 :        2728 :           && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_DEPEND
   13874                 :        5248 :           && TYPE_ATOMIC (strip_array_types (TREE_TYPE (t))))
   13875                 :             :         {
   13876                 :           6 :           error_at (OMP_CLAUSE_LOCATION (c), "%<_Atomic%> %qE in %qs clause",
   13877                 :           6 :                     t, omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   13878                 :           6 :           return error_mark_node;
   13879                 :             :         }
   13880                 :        2821 :       if (!ai.check_clause (c))
   13881                 :           0 :         return error_mark_node;
   13882                 :        2821 :       else if (ai.component_access_p ()
   13883                 :        3067 :                && (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP
   13884                 :          15 :                    || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_TO
   13885                 :          11 :                    || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_FROM))
   13886                 :         246 :         t = ai.get_root_term (true);
   13887                 :             :       else
   13888                 :        2575 :         t = ai.unconverted_ref_origin ();
   13889                 :        2821 :       if (t == error_mark_node)
   13890                 :             :         return error_mark_node;
   13891                 :        2821 :       if (!VAR_P (t)
   13892                 :         700 :           && (ort == C_ORT_ACC || !EXPR_P (t))
   13893                 :         699 :           && TREE_CODE (t) != PARM_DECL)
   13894                 :             :         {
   13895                 :           5 :           if (DECL_P (t))
   13896                 :           5 :             error_at (OMP_CLAUSE_LOCATION (c),
   13897                 :             :                       "%qD is not a variable in %qs clause", t,
   13898                 :           5 :                       omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   13899                 :             :           else
   13900                 :           0 :             error_at (OMP_CLAUSE_LOCATION (c),
   13901                 :             :                       "%qE is not a variable in %qs clause", t,
   13902                 :           0 :                       omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   13903                 :           5 :           return error_mark_node;
   13904                 :             :         }
   13905                 :        2816 :       else if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_AFFINITY
   13906                 :        2718 :                && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_DEPEND
   13907                 :        5228 :                && TYPE_ATOMIC (TREE_TYPE (t)))
   13908                 :             :         {
   13909                 :           0 :           error_at (OMP_CLAUSE_LOCATION (c), "%<_Atomic%> %qD in %qs clause",
   13910                 :           0 :                     t, omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   13911                 :           0 :           return error_mark_node;
   13912                 :             :         }
   13913                 :        2816 :       else if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_AFFINITY
   13914                 :        2718 :                && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_DEPEND
   13915                 :        2412 :                && VAR_P (t)
   13916                 :        4721 :                && DECL_THREAD_LOCAL_P (t))
   13917                 :             :         {
   13918                 :           3 :           error_at (OMP_CLAUSE_LOCATION (c),
   13919                 :             :                     "%qD is threadprivate variable in %qs clause", t,
   13920                 :           3 :                     omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   13921                 :           3 :           return error_mark_node;
   13922                 :             :         }
   13923                 :        2813 :       if ((OMP_CLAUSE_CODE (c) == OMP_CLAUSE_AFFINITY
   13924                 :        2715 :            || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND)
   13925                 :         404 :           && TYPE_ATOMIC (TREE_TYPE (t))
   13926                 :        2815 :           && POINTER_TYPE_P (TREE_TYPE (t)))
   13927                 :             :         {
   13928                 :             :           /* If the array section is pointer based and the pointer
   13929                 :             :              itself is _Atomic qualified, we need to atomically load
   13930                 :             :              the pointer.  */
   13931                 :           2 :           c_expr expr;
   13932                 :           2 :           memset (&expr, 0, sizeof (expr));
   13933                 :           2 :           expr.value = ret;
   13934                 :           2 :           expr = convert_lvalue_to_rvalue (OMP_CLAUSE_LOCATION (c),
   13935                 :             :                                            expr, false, false);
   13936                 :           2 :           ret = expr.value;
   13937                 :             :         }
   13938                 :        2813 :       return ret;
   13939                 :        2827 :     }
   13940                 :             : 
   13941                 :        3239 :   ret = handle_omp_array_sections_1 (c, TREE_OPERAND (t, 0), types,
   13942                 :             :                                      maybe_zero_len, first_non_one, ort);
   13943                 :        3239 :   if (ret == error_mark_node || ret == NULL_TREE)
   13944                 :             :     return ret;
   13945                 :             : 
   13946                 :        3174 :   type = TREE_TYPE (ret);
   13947                 :        3174 :   low_bound = TREE_OPERAND (t, 1);
   13948                 :        3174 :   length = TREE_OPERAND (t, 2);
   13949                 :             : 
   13950                 :        3174 :   if (low_bound == error_mark_node || length == error_mark_node)
   13951                 :             :     return error_mark_node;
   13952                 :             : 
   13953                 :        3174 :   if (low_bound && !INTEGRAL_TYPE_P (TREE_TYPE (low_bound)))
   13954                 :             :     {
   13955                 :          13 :       error_at (OMP_CLAUSE_LOCATION (c),
   13956                 :             :                 "low bound %qE of array section does not have integral type",
   13957                 :             :                 low_bound);
   13958                 :          13 :       return error_mark_node;
   13959                 :             :     }
   13960                 :        3161 :   if (length && !INTEGRAL_TYPE_P (TREE_TYPE (length)))
   13961                 :             :     {
   13962                 :          12 :       error_at (OMP_CLAUSE_LOCATION (c),
   13963                 :             :                 "length %qE of array section does not have integral type",
   13964                 :             :                 length);
   13965                 :          12 :       return error_mark_node;
   13966                 :             :     }
   13967                 :        3149 :   if (low_bound
   13968                 :        2641 :       && TREE_CODE (low_bound) == INTEGER_CST
   13969                 :        5516 :       && TYPE_PRECISION (TREE_TYPE (low_bound))
   13970                 :        2367 :          > TYPE_PRECISION (sizetype))
   13971                 :           0 :     low_bound = fold_convert (sizetype, low_bound);
   13972                 :        3149 :   if (length
   13973                 :        2961 :       && TREE_CODE (length) == INTEGER_CST
   13974                 :        5226 :       && TYPE_PRECISION (TREE_TYPE (length))
   13975                 :        2077 :          > TYPE_PRECISION (sizetype))
   13976                 :           0 :     length = fold_convert (sizetype, length);
   13977                 :        3149 :   if (low_bound == NULL_TREE)
   13978                 :         508 :     low_bound = integer_zero_node;
   13979                 :        3149 :   if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP
   13980                 :        3149 :       && (OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_ATTACH
   13981                 :        1788 :           || OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_DETACH))
   13982                 :             :     {
   13983                 :          10 :       if (length != integer_one_node)
   13984                 :             :         {
   13985                 :           6 :           error_at (OMP_CLAUSE_LOCATION (c),
   13986                 :             :                     "expected single pointer in %qs clause",
   13987                 :             :                     user_omp_clause_code_name (c, openacc));
   13988                 :           6 :           return error_mark_node;
   13989                 :             :         }
   13990                 :             :     }
   13991                 :        3143 :   if (length != NULL_TREE)
   13992                 :             :     {
   13993                 :        2959 :       if (!integer_nonzerop (length))
   13994                 :             :         {
   13995                 :         911 :           if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_AFFINITY
   13996                 :             :               || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND
   13997                 :             :               || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION
   13998                 :             :               || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_IN_REDUCTION
   13999                 :             :               || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_TASK_REDUCTION)
   14000                 :             :             {
   14001                 :         180 :               if (integer_zerop (length))
   14002                 :             :                 {
   14003                 :          12 :                   error_at (OMP_CLAUSE_LOCATION (c),
   14004                 :             :                             "zero length array section in %qs clause",
   14005                 :          12 :                             omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   14006                 :          12 :                   return error_mark_node;
   14007                 :             :                 }
   14008                 :             :             }
   14009                 :             :           else
   14010                 :         731 :             maybe_zero_len = true;
   14011                 :             :         }
   14012                 :        2947 :       if (first_non_one == types.length ()
   14013                 :        2947 :           && (TREE_CODE (length) != INTEGER_CST || integer_onep (length)))
   14014                 :        1489 :         first_non_one++;
   14015                 :             :     }
   14016                 :        3131 :   if (TREE_CODE (type) == ARRAY_TYPE)
   14017                 :             :     {
   14018                 :        1470 :       if (length == NULL_TREE
   14019                 :        1470 :           && (TYPE_DOMAIN (type) == NULL_TREE
   14020                 :         168 :               || TYPE_MAX_VALUE (TYPE_DOMAIN (type)) == NULL_TREE))
   14021                 :             :         {
   14022                 :           8 :           error_at (OMP_CLAUSE_LOCATION (c),
   14023                 :             :                     "for unknown bound array type length expression must "
   14024                 :             :                     "be specified");
   14025                 :           8 :           return error_mark_node;
   14026                 :             :         }
   14027                 :        1462 :       if (TREE_CODE (low_bound) == INTEGER_CST
   14028                 :        1462 :           && tree_int_cst_sgn (low_bound) == -1)
   14029                 :             :         {
   14030                 :          35 :           error_at (OMP_CLAUSE_LOCATION (c),
   14031                 :             :                     "negative low bound in array section in %qs clause",
   14032                 :          35 :                     omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   14033                 :          35 :           return error_mark_node;
   14034                 :             :         }
   14035                 :        1427 :       if (length != NULL_TREE
   14036                 :        1271 :           && TREE_CODE (length) == INTEGER_CST
   14037                 :        2258 :           && tree_int_cst_sgn (length) == -1)
   14038                 :             :         {
   14039                 :          35 :           error_at (OMP_CLAUSE_LOCATION (c),
   14040                 :             :                     "negative length in array section in %qs clause",
   14041                 :          35 :                     omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   14042                 :          35 :           return error_mark_node;
   14043                 :             :         }
   14044                 :        1392 :       if (TYPE_DOMAIN (type)
   14045                 :        1381 :           && TYPE_MAX_VALUE (TYPE_DOMAIN (type))
   14046                 :        2773 :           && TREE_CODE (TYPE_MAX_VALUE (TYPE_DOMAIN (type)))
   14047                 :             :                         == INTEGER_CST)
   14048                 :             :         {
   14049                 :        1035 :           tree size
   14050                 :        1035 :             = fold_convert (sizetype, TYPE_MAX_VALUE (TYPE_DOMAIN (type)));
   14051                 :        1035 :           size = size_binop (PLUS_EXPR, size, size_one_node);
   14052                 :        1035 :           if (TREE_CODE (low_bound) == INTEGER_CST)
   14053                 :             :             {
   14054                 :         850 :               if (tree_int_cst_lt (size, low_bound))
   14055                 :             :                 {
   14056                 :          10 :                   error_at (OMP_CLAUSE_LOCATION (c),
   14057                 :             :                             "low bound %qE above array section size "
   14058                 :             :                             "in %qs clause", low_bound,
   14059                 :          10 :                             omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   14060                 :          10 :                   return error_mark_node;
   14061                 :             :                 }
   14062                 :         840 :               if (tree_int_cst_equal (size, low_bound))
   14063                 :             :                 {
   14064                 :           5 :                   if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_AFFINITY
   14065                 :             :                       || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND
   14066                 :             :                       || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION
   14067                 :             :                       || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_IN_REDUCTION
   14068                 :             :                       || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_TASK_REDUCTION)
   14069                 :             :                     {
   14070                 :           5 :                       error_at (OMP_CLAUSE_LOCATION (c),
   14071                 :             :                                 "zero length array section in %qs clause",
   14072                 :           5 :                                 omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   14073                 :           5 :                       return error_mark_node;
   14074                 :             :                     }
   14075                 :           0 :                   maybe_zero_len = true;
   14076                 :             :                 }
   14077                 :         835 :               else if (length == NULL_TREE
   14078                 :         256 :                        && first_non_one == types.length ()
   14079                 :         890 :                        && tree_int_cst_equal
   14080                 :          55 :                             (TYPE_MAX_VALUE (TYPE_DOMAIN (type)),
   14081                 :             :                              low_bound))
   14082                 :          30 :                 first_non_one++;
   14083                 :             :             }
   14084                 :         185 :           else if (length == NULL_TREE)
   14085                 :             :             {
   14086                 :           3 :               if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_AFFINITY
   14087                 :             :                   && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_DEPEND
   14088                 :             :                   && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_REDUCTION
   14089                 :             :                   && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_IN_REDUCTION
   14090                 :             :                   && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_TASK_REDUCTION)
   14091                 :           0 :                 maybe_zero_len = true;
   14092                 :           6 :               if (first_non_one == types.length ())
   14093                 :           1 :                 first_non_one++;
   14094                 :             :             }
   14095                 :        1020 :           if (length && TREE_CODE (length) == INTEGER_CST)
   14096                 :             :             {
   14097                 :         773 :               if (tree_int_cst_lt (size, length))
   14098                 :             :                 {
   14099                 :          11 :                   error_at (OMP_CLAUSE_LOCATION (c),
   14100                 :             :                             "length %qE above array section size "
   14101                 :             :                             "in %qs clause", length,
   14102                 :          11 :                             omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   14103                 :          11 :                   return error_mark_node;
   14104                 :             :                 }
   14105                 :         762 :               if (TREE_CODE (low_bound) == INTEGER_CST)
   14106                 :             :                 {
   14107                 :         664 :                   tree lbpluslen
   14108                 :         664 :                     = size_binop (PLUS_EXPR,
   14109                 :             :                                   fold_convert (sizetype, low_bound),
   14110                 :             :                                   fold_convert (sizetype, length));
   14111                 :         664 :                   if (TREE_CODE (lbpluslen) == INTEGER_CST
   14112                 :         664 :                       && tree_int_cst_lt (size, lbpluslen))
   14113                 :             :                     {
   14114                 :          10 :                       error_at (OMP_CLAUSE_LOCATION (c),
   14115                 :             :                                 "high bound %qE above array section size "
   14116                 :             :                                 "in %qs clause", lbpluslen,
   14117                 :          10 :                                 omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   14118                 :          10 :                       return error_mark_node;
   14119                 :             :                     }
   14120                 :             :                 }
   14121                 :             :             }
   14122                 :             :         }
   14123                 :         357 :       else if (length == NULL_TREE)
   14124                 :             :         {
   14125                 :          10 :           if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_AFFINITY
   14126                 :             :               && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_DEPEND
   14127                 :             :               && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_REDUCTION
   14128                 :             :               && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_IN_REDUCTION
   14129                 :             :               && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_TASK_REDUCTION)
   14130                 :           0 :             maybe_zero_len = true;
   14131                 :          20 :           if (first_non_one == types.length ())
   14132                 :          10 :             first_non_one++;
   14133                 :             :         }
   14134                 :             : 
   14135                 :             :       /* For [lb:] we will need to evaluate lb more than once.  */
   14136                 :         903 :       if (length == NULL_TREE && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_DEPEND)
   14137                 :             :         {
   14138                 :         127 :           tree lb = save_expr (low_bound);
   14139                 :         127 :           if (lb != low_bound)
   14140                 :             :             {
   14141                 :           2 :               TREE_OPERAND (t, 1) = lb;
   14142                 :           2 :               low_bound = lb;
   14143                 :             :             }
   14144                 :             :         }
   14145                 :             :     }
   14146                 :        1661 :   else if (TREE_CODE (type) == POINTER_TYPE)
   14147                 :             :     {
   14148                 :        1651 :       if (length == NULL_TREE)
   14149                 :             :         {
   14150                 :          10 :           if (TREE_CODE (ret) == PARM_DECL && C_ARRAY_PARAMETER (ret))
   14151                 :           8 :             error_at (OMP_CLAUSE_LOCATION (c),
   14152                 :             :                       "for array function parameter length expression "
   14153                 :             :                       "must be specified");
   14154                 :             :           else
   14155                 :           2 :             error_at (OMP_CLAUSE_LOCATION (c),
   14156                 :             :                       "for pointer type length expression must be specified");
   14157                 :          10 :           return error_mark_node;
   14158                 :             :         }
   14159                 :        1641 :       if (length != NULL_TREE
   14160                 :        1641 :           && TREE_CODE (length) == INTEGER_CST
   14161                 :        1197 :           && tree_int_cst_sgn (length) == -1)
   14162                 :             :         {
   14163                 :          20 :           error_at (OMP_CLAUSE_LOCATION (c),
   14164                 :             :                     "negative length in array section in %qs clause",
   14165                 :          20 :                     omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   14166                 :          20 :           return error_mark_node;
   14167                 :             :         }
   14168                 :             :       /* If there is a pointer type anywhere but in the very first
   14169                 :             :          array-section-subscript, the array section could be non-contiguous.  */
   14170                 :        1621 :       if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_DEPEND
   14171                 :        1460 :           && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_AFFINITY
   14172                 :        3052 :           && TREE_CODE (TREE_OPERAND (t, 0)) == OMP_ARRAY_SECTION)
   14173                 :             :         {
   14174                 :             :           /* If any prior dimension has a non-one length, then deem this
   14175                 :             :              array section as non-contiguous.  */
   14176                 :          15 :           for (tree d = TREE_OPERAND (t, 0);
   14177                 :          26 :                TREE_CODE (d) == OMP_ARRAY_SECTION;
   14178                 :          11 :                d = TREE_OPERAND (d, 0))
   14179                 :             :             {
   14180                 :          15 :               tree d_length = TREE_OPERAND (d, 2);
   14181                 :          15 :               if (d_length == NULL_TREE || !integer_onep (d_length))
   14182                 :             :                 {
   14183                 :           4 :                   error_at (OMP_CLAUSE_LOCATION (c),
   14184                 :             :                             "array section is not contiguous in %qs clause",
   14185                 :           4 :                             omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   14186                 :           4 :                   return error_mark_node;
   14187                 :             :                 }
   14188                 :             :             }
   14189                 :             :         }
   14190                 :             :     }
   14191                 :             :   else
   14192                 :             :     {
   14193                 :          10 :       error_at (OMP_CLAUSE_LOCATION (c),
   14194                 :             :                 "%qE does not have pointer or array type", ret);
   14195                 :          10 :       return error_mark_node;
   14196                 :             :     }
   14197                 :        2973 :   if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_DEPEND)
   14198                 :        2664 :     types.safe_push (TREE_TYPE (ret));
   14199                 :             :   /* We will need to evaluate lb more than once.  */
   14200                 :        2973 :   tree lb = save_expr (low_bound);
   14201                 :        2973 :   if (lb != low_bound)
   14202                 :             :     {
   14203                 :         262 :       TREE_OPERAND (t, 1) = lb;
   14204                 :         262 :       low_bound = lb;
   14205                 :             :     }
   14206                 :        2973 :   ret = build_array_ref (OMP_CLAUSE_LOCATION (c), ret, low_bound);
   14207                 :        2973 :   return ret;
   14208                 :             : }
   14209                 :             : 
   14210                 :             : /* Handle array sections for clause C.  */
   14211                 :             : 
   14212                 :             : static bool
   14213                 :        2829 : handle_omp_array_sections (tree &c, enum c_omp_region_type ort)
   14214                 :             : {
   14215                 :        2829 :   bool maybe_zero_len = false;
   14216                 :        2829 :   unsigned int first_non_one = 0;
   14217                 :        2829 :   auto_vec<tree, 10> types;
   14218                 :        2829 :   tree *tp = &OMP_CLAUSE_DECL (c);
   14219                 :        2829 :   if ((OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND
   14220                 :        2522 :        || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_AFFINITY)
   14221                 :         406 :       && TREE_CODE (*tp) == TREE_LIST
   14222                 :          66 :       && TREE_PURPOSE (*tp)
   14223                 :        2895 :       && TREE_CODE (TREE_PURPOSE (*tp)) == TREE_VEC)
   14224                 :          66 :     tp = &TREE_VALUE (*tp);
   14225                 :        2829 :   tree first = handle_omp_array_sections_1 (c, *tp, types,
   14226                 :             :                                             maybe_zero_len, first_non_one,
   14227                 :             :                                             ort);
   14228                 :        2829 :   if (first == error_mark_node)
   14229                 :             :     return true;
   14230                 :        2612 :   if (first == NULL_TREE)
   14231                 :             :     return false;
   14232                 :        2612 :   if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND
   14233                 :        2612 :       || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_AFFINITY)
   14234                 :             :     {
   14235                 :         329 :       tree t = *tp;
   14236                 :         329 :       tree tem = NULL_TREE;
   14237                 :             :       /* Need to evaluate side effects in the length expressions
   14238                 :             :          if any.  */
   14239                 :         329 :       while (TREE_CODE (t) == TREE_LIST)
   14240                 :             :         {
   14241                 :           0 :           if (TREE_VALUE (t) && TREE_SIDE_EFFECTS (TREE_VALUE (t)))
   14242                 :             :             {
   14243                 :           0 :               if (tem == NULL_TREE)
   14244                 :             :                 tem = TREE_VALUE (t);
   14245                 :             :               else
   14246                 :           0 :                 tem = build2 (COMPOUND_EXPR, TREE_TYPE (tem),
   14247                 :           0 :                               TREE_VALUE (t), tem);
   14248                 :             :             }
   14249                 :           0 :           t = TREE_CHAIN (t);
   14250                 :             :         }
   14251                 :         329 :       if (tem)
   14252                 :           0 :         first = build2 (COMPOUND_EXPR, TREE_TYPE (first), tem, first);
   14253                 :         329 :       first = c_fully_fold (first, false, NULL, true);
   14254                 :         329 :       *tp = first;
   14255                 :             :     }
   14256                 :             :   else
   14257                 :             :     {
   14258                 :        2283 :       unsigned int num = types.length (), i;
   14259                 :        2283 :       tree t, side_effects = NULL_TREE, size = NULL_TREE;
   14260                 :        2283 :       tree condition = NULL_TREE;
   14261                 :             : 
   14262                 :        2283 :       if (int_size_in_bytes (TREE_TYPE (first)) <= 0)
   14263                 :           3 :         maybe_zero_len = true;
   14264                 :             : 
   14265                 :        4738 :       for (i = num, t = OMP_CLAUSE_DECL (c); i > 0;
   14266                 :        2455 :            t = TREE_OPERAND (t, 0))
   14267                 :             :         {
   14268                 :        2470 :           tree low_bound = TREE_OPERAND (t, 1);
   14269                 :        2470 :           tree length = TREE_OPERAND (t, 2);
   14270                 :             : 
   14271                 :        2470 :           i--;
   14272                 :        2470 :           if (low_bound
   14273                 :        2075 :               && TREE_CODE (low_bound) == INTEGER_CST
   14274                 :        4374 :               && TYPE_PRECISION (TREE_TYPE (low_bound))
   14275                 :        1904 :                  > TYPE_PRECISION (sizetype))
   14276                 :           0 :             low_bound = fold_convert (sizetype, low_bound);
   14277                 :        2470 :           if (length
   14278                 :        2378 :               && TREE_CODE (length) == INTEGER_CST
   14279                 :        3982 :               && TYPE_PRECISION (TREE_TYPE (length))
   14280                 :        1512 :                  > TYPE_PRECISION (sizetype))
   14281                 :           0 :             length = fold_convert (sizetype, length);
   14282                 :        2470 :           if (low_bound == NULL_TREE)
   14283                 :         395 :             low_bound = integer_zero_node;
   14284                 :        2470 :           if (!maybe_zero_len && i > first_non_one)
   14285                 :             :             {
   14286                 :         108 :               if (integer_nonzerop (low_bound))
   14287                 :           6 :                 goto do_warn_noncontiguous;
   14288                 :         102 :               if (length != NULL_TREE
   14289                 :          49 :                   && TREE_CODE (length) == INTEGER_CST
   14290                 :          49 :                   && TYPE_DOMAIN (types[i])
   14291                 :          49 :                   && TYPE_MAX_VALUE (TYPE_DOMAIN (types[i]))
   14292                 :         151 :                   && TREE_CODE (TYPE_MAX_VALUE (TYPE_DOMAIN (types[i])))
   14293                 :             :                      == INTEGER_CST)
   14294                 :             :                 {
   14295                 :          49 :                   tree size;
   14296                 :          49 :                   size = size_binop (PLUS_EXPR,
   14297                 :             :                                      TYPE_MAX_VALUE (TYPE_DOMAIN (types[i])),
   14298                 :             :                                      size_one_node);
   14299                 :          49 :                   if (!tree_int_cst_equal (length, size))
   14300                 :             :                     {
   14301                 :           7 :                      do_warn_noncontiguous:
   14302                 :          26 :                       error_at (OMP_CLAUSE_LOCATION (c),
   14303                 :             :                                 "array section is not contiguous in %qs "
   14304                 :             :                                 "clause",
   14305                 :          13 :                                 omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   14306                 :        2283 :                       return true;
   14307                 :             :                     }
   14308                 :             :                 }
   14309                 :          95 :               if (length != NULL_TREE
   14310                 :          95 :                   && TREE_SIDE_EFFECTS (length))
   14311                 :             :                 {
   14312                 :           0 :                   if (side_effects == NULL_TREE)
   14313                 :             :                     side_effects = length;
   14314                 :             :                   else
   14315                 :           0 :                     side_effects = build2 (COMPOUND_EXPR,
   14316                 :           0 :                                            TREE_TYPE (side_effects),
   14317                 :             :                                            length, side_effects);
   14318                 :             :                 }
   14319                 :             :             }
   14320                 :             :           else
   14321                 :             :             {
   14322                 :        2362 :               tree l;
   14323                 :             : 
   14324                 :        2362 :               if (i > first_non_one
   14325                 :        2362 :                   && ((length && integer_nonzerop (length))
   14326                 :           0 :                       || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION
   14327                 :             :                       || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_IN_REDUCTION
   14328                 :             :                       || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_TASK_REDUCTION))
   14329                 :           0 :                 continue;
   14330                 :        2362 :               if (length)
   14331                 :        2329 :                 l = fold_convert (sizetype, length);
   14332                 :             :               else
   14333                 :             :                 {
   14334                 :          33 :                   l = size_binop (PLUS_EXPR,
   14335                 :             :                                   TYPE_MAX_VALUE (TYPE_DOMAIN (types[i])),
   14336                 :             :                                   size_one_node);
   14337                 :          33 :                   l = size_binop (MINUS_EXPR, l,
   14338                 :             :                                   fold_convert (sizetype, low_bound));
   14339                 :             :                 }
   14340                 :        2362 :               if (i > first_non_one)
   14341                 :             :                 {
   14342                 :           0 :                   l = fold_build2 (NE_EXPR, boolean_type_node, l,
   14343                 :             :                                    size_zero_node);
   14344                 :           0 :                   if (condition == NULL_TREE)
   14345                 :             :                     condition = l;
   14346                 :             :                   else
   14347                 :           0 :                     condition = fold_build2 (BIT_AND_EXPR, boolean_type_node,
   14348                 :             :                                              l, condition);
   14349                 :             :                 }
   14350                 :        2362 :               else if (size == NULL_TREE)
   14351                 :             :                 {
   14352                 :        2270 :                   size = size_in_bytes (TREE_TYPE (types[i]));
   14353                 :        2270 :                   tree eltype = TREE_TYPE (types[num - 1]);
   14354                 :        2290 :                   while (TREE_CODE (eltype) == ARRAY_TYPE)
   14355                 :          20 :                     eltype = TREE_TYPE (eltype);
   14356                 :        2270 :                   if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION
   14357                 :        2035 :                       || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_IN_REDUCTION
   14358                 :        4045 :                       || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_TASK_REDUCTION)
   14359                 :             :                     {
   14360                 :         539 :                       if (integer_zerop (size)
   14361                 :        1076 :                           || integer_zerop (size_in_bytes (eltype)))
   14362                 :             :                         {
   14363                 :           4 :                           error_at (OMP_CLAUSE_LOCATION (c),
   14364                 :             :                                     "zero length array section in %qs clause",
   14365                 :           2 :                                     omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   14366                 :           2 :                           return error_mark_node;
   14367                 :             :                         }
   14368                 :         537 :                       size = size_binop (EXACT_DIV_EXPR, size,
   14369                 :             :                                          size_in_bytes (eltype));
   14370                 :             :                     }
   14371                 :        2268 :                   size = size_binop (MULT_EXPR, size, l);
   14372                 :        2268 :                   if (condition)
   14373                 :           0 :                     size = fold_build3 (COND_EXPR, sizetype, condition,
   14374                 :             :                                         size, size_zero_node);
   14375                 :             :                 }
   14376                 :             :               else
   14377                 :          92 :                 size = size_binop (MULT_EXPR, size, l);
   14378                 :             :             }
   14379                 :             :         }
   14380                 :        2268 :       if (side_effects)
   14381                 :           0 :         size = build2 (COMPOUND_EXPR, sizetype, side_effects, size);
   14382                 :        2268 :       if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION
   14383                 :        2035 :           || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_IN_REDUCTION
   14384                 :        4043 :           || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_TASK_REDUCTION)
   14385                 :             :         {
   14386                 :         537 :           size = size_binop (MINUS_EXPR, size, size_one_node);
   14387                 :         537 :           size = c_fully_fold (size, false, NULL);
   14388                 :         537 :           size = save_expr (size);
   14389                 :         537 :           tree index_type = build_index_type (size);
   14390                 :         537 :           tree eltype = TREE_TYPE (first);
   14391                 :         549 :           while (TREE_CODE (eltype) == ARRAY_TYPE)
   14392                 :          12 :             eltype = TREE_TYPE (eltype);
   14393                 :         537 :           tree type = build_array_type (eltype, index_type);
   14394                 :         537 :           tree ptype = build_pointer_type (eltype);
   14395                 :         537 :           if (TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE)
   14396                 :         296 :             t = build_fold_addr_expr (t);
   14397                 :         537 :           tree t2 = build_fold_addr_expr (first);
   14398                 :         537 :           t2 = fold_convert_loc (OMP_CLAUSE_LOCATION (c),
   14399                 :             :                                  ptrdiff_type_node, t2);
   14400                 :         537 :           t2 = fold_build2_loc (OMP_CLAUSE_LOCATION (c), MINUS_EXPR,
   14401                 :             :                                 ptrdiff_type_node, t2,
   14402                 :         537 :                                 fold_convert_loc (OMP_CLAUSE_LOCATION (c),
   14403                 :             :                                                   ptrdiff_type_node, t));
   14404                 :         537 :           t2 = c_fully_fold (t2, false, NULL);
   14405                 :         537 :           if (tree_fits_shwi_p (t2))
   14406                 :         398 :             t = build2 (MEM_REF, type, t,
   14407                 :         398 :                         build_int_cst (ptype, tree_to_shwi (t2)));
   14408                 :             :           else
   14409                 :             :             {
   14410                 :         139 :               t2 = fold_convert_loc (OMP_CLAUSE_LOCATION (c), sizetype, t2);
   14411                 :         139 :               t = build2_loc (OMP_CLAUSE_LOCATION (c), POINTER_PLUS_EXPR,
   14412                 :         139 :                               TREE_TYPE (t), t, t2);
   14413                 :         139 :               t = build2 (MEM_REF, type, t, build_int_cst (ptype, 0));
   14414                 :             :             }
   14415                 :         537 :           OMP_CLAUSE_DECL (c) = t;
   14416                 :         537 :           return false;
   14417                 :             :         }
   14418                 :        1731 :       first = c_fully_fold (first, false, NULL);
   14419                 :        1731 :       OMP_CLAUSE_DECL (c) = first;
   14420                 :        1731 :       if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_HAS_DEVICE_ADDR)
   14421                 :             :         return false;
   14422                 :             :       /* Don't set OMP_CLAUSE_SIZE for bare attach/detach clauses.  */
   14423                 :        1720 :       if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_MAP
   14424                 :        1720 :           || (OMP_CLAUSE_MAP_KIND (c) != GOMP_MAP_ATTACH
   14425                 :        1592 :               && OMP_CLAUSE_MAP_KIND (c) != GOMP_MAP_DETACH
   14426                 :        1590 :               && OMP_CLAUSE_MAP_KIND (c) != GOMP_MAP_FORCE_DETACH))
   14427                 :             :         {
   14428                 :        1716 :           if (size)
   14429                 :        1716 :             size = c_fully_fold (size, false, NULL);
   14430                 :        1716 :           OMP_CLAUSE_SIZE (c) = size;
   14431                 :             :         }
   14432                 :             : 
   14433                 :        1720 :       if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_MAP)
   14434                 :             :         return false;
   14435                 :             : 
   14436                 :        1594 :       auto_vec<omp_addr_token *, 10> addr_tokens;
   14437                 :             : 
   14438                 :        1594 :       if (!omp_parse_expr (addr_tokens, first))
   14439                 :        1594 :         return true;
   14440                 :             : 
   14441                 :        1594 :       c_omp_address_inspector ai (OMP_CLAUSE_LOCATION (c), t);
   14442                 :             : 
   14443                 :        1594 :       tree nc = ai.expand_map_clause (c, first, addr_tokens, ort);
   14444                 :        1594 :       if (nc != error_mark_node)
   14445                 :             :         {
   14446                 :        1594 :           using namespace omp_addr_tokenizer;
   14447                 :             : 
   14448                 :        1594 :           if (ai.maybe_zero_length_array_section (c))
   14449                 :        1590 :             OMP_CLAUSE_MAP_MAYBE_ZERO_LENGTH_ARRAY_SECTION (c) = 1;
   14450                 :             : 
   14451                 :             :           /* !!! If we're accessing a base decl via chained access
   14452                 :             :              methods (e.g. multiple indirections), duplicate clause
   14453                 :             :              detection won't work properly.  Skip it in that case.  */
   14454                 :        1594 :           if ((addr_tokens[0]->type == STRUCTURE_BASE
   14455                 :        1362 :                || addr_tokens[0]->type == ARRAY_BASE)
   14456                 :        1594 :               && addr_tokens[0]->u.structure_base_kind == BASE_DECL
   14457                 :        1594 :               && addr_tokens[1]->type == ACCESS_METHOD
   14458                 :        3188 :               && omp_access_chain_p (addr_tokens, 1))
   14459                 :          27 :             c = nc;
   14460                 :             : 
   14461                 :        1594 :           return false;
   14462                 :             :         }
   14463                 :             :     }
   14464                 :             :   return false;
   14465                 :        2829 : }
   14466                 :             : 
   14467                 :             : /* Helper function of finish_omp_clauses.  Clone STMT as if we were making
   14468                 :             :    an inline call.  But, remap
   14469                 :             :    the OMP_DECL1 VAR_DECL (omp_out resp. omp_orig) to PLACEHOLDER
   14470                 :             :    and OMP_DECL2 VAR_DECL (omp_in resp. omp_priv) to DECL.  */
   14471                 :             : 
   14472                 :             : static tree
   14473                 :         510 : c_clone_omp_udr (tree stmt, tree omp_decl1, tree omp_decl2,
   14474                 :             :                  tree decl, tree placeholder)
   14475                 :             : {
   14476                 :         510 :   copy_body_data id;
   14477                 :         510 :   hash_map<tree, tree> decl_map;
   14478                 :             : 
   14479                 :         510 :   decl_map.put (omp_decl1, placeholder);
   14480                 :         510 :   decl_map.put (omp_decl2, decl);
   14481                 :         510 :   memset (&id, 0, sizeof (id));
   14482                 :         510 :   id.src_fn = DECL_CONTEXT (omp_decl1);
   14483                 :         510 :   id.dst_fn = current_function_decl;
   14484                 :         510 :   id.src_cfun = DECL_STRUCT_FUNCTION (id.src_fn);
   14485                 :         510 :   id.decl_map = &decl_map;
   14486                 :             : 
   14487                 :         510 :   id.copy_decl = copy_decl_no_change;
   14488                 :         510 :   id.transform_call_graph_edges = CB_CGE_DUPLICATE;
   14489                 :         510 :   id.transform_new_cfg = true;
   14490                 :         510 :   id.transform_return_to_modify = false;
   14491                 :         510 :   id.eh_lp_nr = 0;
   14492                 :         510 :   walk_tree (&stmt, copy_tree_body_r, &id, NULL);
   14493                 :         510 :   return stmt;
   14494                 :         510 : }
   14495                 :             : 
   14496                 :             : /* Helper function of c_finish_omp_clauses, called via walk_tree.
   14497                 :             :    Find OMP_CLAUSE_PLACEHOLDER (passed in DATA) in *TP.  */
   14498                 :             : 
   14499                 :             : static tree
   14500                 :        1123 : c_find_omp_placeholder_r (tree *tp, int *, void *data)
   14501                 :             : {
   14502                 :        1123 :   if (*tp == (tree) data)
   14503                 :          28 :     return *tp;
   14504                 :             :   return NULL_TREE;
   14505                 :             : }
   14506                 :             : 
   14507                 :             : /* Similarly, but also walk aggregate fields.  */
   14508                 :             : 
   14509                 :             : struct c_find_omp_var_s { tree var; hash_set<tree> *pset; };
   14510                 :             : 
   14511                 :             : static tree
   14512                 :         192 : c_find_omp_var_r (tree *tp, int *, void *data)
   14513                 :             : {
   14514                 :         192 :   if (*tp == ((struct c_find_omp_var_s *) data)->var)
   14515                 :             :     return *tp;
   14516                 :         184 :   if (RECORD_OR_UNION_TYPE_P (*tp))
   14517                 :             :     {
   14518                 :           2 :       tree field;
   14519                 :           2 :       hash_set<tree> *pset = ((struct c_find_omp_var_s *) data)->pset;
   14520                 :             : 
   14521                 :           2 :       for (field = TYPE_FIELDS (*tp); field;
   14522                 :           0 :            field = DECL_CHAIN (field))
   14523                 :           2 :         if (TREE_CODE (field) == FIELD_DECL)
   14524                 :             :           {
   14525                 :           2 :             tree ret = walk_tree (&DECL_FIELD_OFFSET (field),
   14526                 :             :                                   c_find_omp_var_r, data, pset);
   14527                 :           2 :             if (ret)
   14528                 :           0 :               return ret;
   14529                 :           2 :             ret = walk_tree (&DECL_SIZE (field), c_find_omp_var_r, data, pset);
   14530                 :           2 :             if (ret)
   14531                 :           0 :               return ret;
   14532                 :           2 :             ret = walk_tree (&DECL_SIZE_UNIT (field), c_find_omp_var_r, data,
   14533                 :             :                              pset);
   14534                 :           2 :             if (ret)
   14535                 :           0 :               return ret;
   14536                 :           2 :             ret = walk_tree (&TREE_TYPE (field), c_find_omp_var_r, data, pset);
   14537                 :           2 :             if (ret)
   14538                 :           2 :               return ret;
   14539                 :             :           }
   14540                 :             :     }
   14541                 :         182 :   else if (INTEGRAL_TYPE_P (*tp))
   14542                 :          27 :     return walk_tree (&TYPE_MAX_VALUE (*tp), c_find_omp_var_r, data,
   14543                 :             :                       ((struct c_find_omp_var_s *) data)->pset);
   14544                 :             :   return NULL_TREE;
   14545                 :             : }
   14546                 :             : 
   14547                 :             : /* Finish OpenMP iterators ITER.  Return true if they are errorneous
   14548                 :             :    and clauses containing them should be removed.  */
   14549                 :             : 
   14550                 :             : static bool
   14551                 :         111 : c_omp_finish_iterators (tree iter)
   14552                 :             : {
   14553                 :         111 :   bool ret = false;
   14554                 :         243 :   for (tree it = iter; it; it = TREE_CHAIN (it))
   14555                 :             :     {
   14556                 :         132 :       tree var = TREE_VEC_ELT (it, 0);
   14557                 :         132 :       tree begin = TREE_VEC_ELT (it, 1);
   14558                 :         132 :       tree end = TREE_VEC_ELT (it, 2);
   14559                 :         132 :       tree step = TREE_VEC_ELT (it, 3);
   14560                 :         132 :       tree orig_step;
   14561                 :         132 :       tree type = TREE_TYPE (var);
   14562                 :         132 :       location_t loc = DECL_SOURCE_LOCATION (var);
   14563                 :         132 :       if (type == error_mark_node)
   14564                 :             :         {
   14565                 :           0 :           ret = true;
   14566                 :          34 :           continue;
   14567                 :             :         }
   14568                 :         132 :       if (!INTEGRAL_TYPE_P (type) && !POINTER_TYPE_P (type))
   14569                 :             :         {
   14570                 :           6 :           error_at (loc, "iterator %qD has neither integral nor pointer type",
   14571                 :             :                     var);
   14572                 :           6 :           ret = true;
   14573                 :           6 :           continue;
   14574                 :             :         }
   14575                 :         126 :       else if (TYPE_ATOMIC (type))
   14576                 :             :         {
   14577                 :           2 :           error_at (loc, "iterator %qD has %<_Atomic%> qualified type", var);
   14578                 :           2 :           ret = true;
   14579                 :           2 :           continue;
   14580                 :             :         }
   14581                 :         124 :       else if (TYPE_READONLY (type))
   14582                 :             :         {
   14583                 :           4 :           error_at (loc, "iterator %qD has const qualified type", var);
   14584                 :           4 :           ret = true;
   14585                 :           4 :           continue;
   14586                 :             :         }
   14587                 :         120 :       else if (step == error_mark_node
   14588                 :         120 :                || TREE_TYPE (step) == error_mark_node)
   14589                 :             :         {
   14590                 :           0 :           ret = true;
   14591                 :           0 :           continue;
   14592                 :             :         }
   14593                 :         120 :       else if (!INTEGRAL_TYPE_P (TREE_TYPE (step)))
   14594                 :             :         {
   14595                 :           6 :           error_at (EXPR_LOC_OR_LOC (step, loc),
   14596                 :             :                     "iterator step with non-integral type");
   14597                 :           4 :           ret = true;
   14598                 :           4 :           continue;
   14599                 :             :         }
   14600                 :         116 :       begin = c_fully_fold (build_c_cast (loc, type, begin), false, NULL);
   14601                 :         116 :       end = c_fully_fold (build_c_cast (loc, type, end), false, NULL);
   14602                 :         116 :       orig_step = save_expr (c_fully_fold (step, false, NULL));
   14603                 :         116 :       tree stype = POINTER_TYPE_P (type) ? sizetype : type;
   14604                 :         116 :       step = c_fully_fold (build_c_cast (loc, stype, orig_step), false, NULL);
   14605                 :         116 :       if (POINTER_TYPE_P (type))
   14606                 :             :         {
   14607                 :          14 :           begin = save_expr (begin);
   14608                 :          14 :           step = pointer_int_sum (loc, PLUS_EXPR, begin, step);
   14609                 :          14 :           step = fold_build2_loc (loc, MINUS_EXPR, sizetype,
   14610                 :             :                                   fold_convert (sizetype, step),
   14611                 :             :                                   fold_convert (sizetype, begin));
   14612                 :          14 :           step = fold_convert (ssizetype, step);
   14613                 :             :         }
   14614                 :         116 :       if (integer_zerop (step))
   14615                 :             :         {
   14616                 :           6 :           error_at (loc, "iterator %qD has zero step", var);
   14617                 :           6 :           ret = true;
   14618                 :           6 :           continue;
   14619                 :             :         }
   14620                 :             : 
   14621                 :         110 :       if (begin == error_mark_node
   14622                 :         108 :           || end == error_mark_node
   14623                 :         106 :           || step == error_mark_node
   14624                 :         106 :           || orig_step == error_mark_node)
   14625                 :             :         {
   14626                 :           4 :           ret = true;
   14627                 :           4 :           continue;
   14628                 :             :         }
   14629                 :         106 :       hash_set<tree> pset;
   14630                 :         106 :       tree it2;
   14631                 :         123 :       for (it2 = TREE_CHAIN (it); it2; it2 = TREE_CHAIN (it2))
   14632                 :             :         {
   14633                 :          25 :           tree var2 = TREE_VEC_ELT (it2, 0);
   14634                 :          25 :           tree begin2 = TREE_VEC_ELT (it2, 1);
   14635                 :          25 :           tree end2 = TREE_VEC_ELT (it2, 2);
   14636                 :          25 :           tree step2 = TREE_VEC_ELT (it2, 3);
   14637                 :          25 :           tree type2 = TREE_TYPE (var2);
   14638                 :          25 :           location_t loc2 = DECL_SOURCE_LOCATION (var2);
   14639                 :          25 :           struct c_find_omp_var_s data = { var, &pset };
   14640                 :          25 :           if (walk_tree (&type2, c_find_omp_var_r, &data, &pset))
   14641                 :             :             {
   14642                 :           2 :               error_at (loc2,
   14643                 :             :                         "type of iterator %qD refers to outer iterator %qD",
   14644                 :             :                         var2, var);
   14645                 :          10 :               break;
   14646                 :             :             }
   14647                 :          23 :           else if (walk_tree (&begin2, c_find_omp_var_r, &data, &pset))
   14648                 :             :             {
   14649                 :           2 :               error_at (EXPR_LOC_OR_LOC (begin2, loc2),
   14650                 :             :                         "begin expression refers to outer iterator %qD", var);
   14651                 :           2 :               break;
   14652                 :             :             }
   14653                 :          21 :           else if (walk_tree (&end2, c_find_omp_var_r, &data, &pset))
   14654                 :             :             {
   14655                 :           2 :               error_at (EXPR_LOC_OR_LOC (end2, loc2),
   14656                 :             :                         "end expression refers to outer iterator %qD", var);
   14657                 :           2 :               break;
   14658                 :             :             }
   14659                 :          19 :           else if (walk_tree (&step2, c_find_omp_var_r, &data, &pset))
   14660                 :             :             {
   14661                 :           2 :               error_at (EXPR_LOC_OR_LOC (step2, loc2),
   14662                 :             :                         "step expression refers to outer iterator %qD", var);
   14663                 :           2 :               break;
   14664                 :             :             }
   14665                 :             :         }
   14666                 :         106 :       if (it2)
   14667                 :             :         {
   14668                 :           8 :           ret = true;
   14669                 :           8 :           continue;
   14670                 :             :         }
   14671                 :          98 :       TREE_VEC_ELT (it, 1) = begin;
   14672                 :          98 :       TREE_VEC_ELT (it, 2) = end;
   14673                 :          98 :       TREE_VEC_ELT (it, 3) = step;
   14674                 :          98 :       TREE_VEC_ELT (it, 4) = orig_step;
   14675                 :         106 :     }
   14676                 :         111 :   return ret;
   14677                 :             : }
   14678                 :             : 
   14679                 :             : /* Ensure that pointers are used in OpenACC attach and detach clauses.
   14680                 :             :    Return true if an error has been detected.  */
   14681                 :             : 
   14682                 :             : static bool
   14683                 :        8904 : c_oacc_check_attachments (tree c)
   14684                 :             : {
   14685                 :        8904 :   if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_MAP)
   14686                 :             :     return false;
   14687                 :             : 
   14688                 :             :   /* OpenACC attach / detach clauses must be pointers.  */
   14689                 :        5923 :   if (OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_ATTACH
   14690                 :        5923 :       || OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_DETACH)
   14691                 :             :     {
   14692                 :          54 :       tree t = OMP_CLAUSE_DECL (c);
   14693                 :             : 
   14694                 :          60 :       while (TREE_CODE (t) == OMP_ARRAY_SECTION)
   14695                 :           6 :         t = TREE_OPERAND (t, 0);
   14696                 :             : 
   14697                 :          54 :       if (TREE_CODE (TREE_TYPE (t)) != POINTER_TYPE)
   14698                 :             :         {
   14699                 :           6 :           error_at (OMP_CLAUSE_LOCATION (c), "expected pointer in %qs clause",
   14700                 :             :                     user_omp_clause_code_name (c, true));
   14701                 :           6 :           return true;
   14702                 :             :         }
   14703                 :             :     }
   14704                 :             : 
   14705                 :             :   return false;
   14706                 :             : }
   14707                 :             : 
   14708                 :             : /* For all elements of CLAUSES, validate them against their constraints.
   14709                 :             :    Remove any elements from the list that are invalid.  */
   14710                 :             : 
   14711                 :             : tree
   14712                 :       27372 : c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
   14713                 :             : {
   14714                 :       27372 :   bitmap_head generic_head, firstprivate_head, lastprivate_head;
   14715                 :       27372 :   bitmap_head aligned_head, map_head, map_field_head, map_firstprivate_head;
   14716                 :       27372 :   bitmap_head oacc_reduction_head, is_on_device_head;
   14717                 :       27372 :   tree c, t, type, *pc;
   14718                 :       27372 :   tree simdlen = NULL_TREE, safelen = NULL_TREE;
   14719                 :       27372 :   bool branch_seen = false;
   14720                 :       27372 :   bool copyprivate_seen = false;
   14721                 :       27372 :   bool mergeable_seen = false;
   14722                 :       27372 :   tree *detach_seen = NULL;
   14723                 :       27372 :   bool linear_variable_step_check = false;
   14724                 :       27372 :   tree *nowait_clause = NULL;
   14725                 :       27372 :   tree ordered_clause = NULL_TREE;
   14726                 :       27372 :   tree schedule_clause = NULL_TREE;
   14727                 :       27372 :   bool oacc_async = false;
   14728                 :       27372 :   tree last_iterators = NULL_TREE;
   14729                 :       27372 :   bool last_iterators_remove = false;
   14730                 :       27372 :   tree *nogroup_seen = NULL;
   14731                 :       27372 :   tree *order_clause = NULL;
   14732                 :             :   /* 1 if normal/task reduction has been seen, -1 if inscan reduction
   14733                 :             :      has been seen, -2 if mixed inscan/normal reduction diagnosed.  */
   14734                 :       27372 :   int reduction_seen = 0;
   14735                 :       27372 :   bool allocate_seen = false;
   14736                 :       27372 :   bool implicit_moved = false;
   14737                 :       27372 :   bool target_in_reduction_seen = false;
   14738                 :       27372 :   bool openacc = (ort & C_ORT_ACC) != 0;
   14739                 :             : 
   14740                 :       27372 :   bitmap_obstack_initialize (NULL);
   14741                 :       27372 :   bitmap_initialize (&generic_head, &bitmap_default_obstack);
   14742                 :       27372 :   bitmap_initialize (&firstprivate_head, &bitmap_default_obstack);
   14743                 :       27372 :   bitmap_initialize (&lastprivate_head, &bitmap_default_obstack);
   14744                 :       27372 :   bitmap_initialize (&aligned_head, &bitmap_default_obstack);
   14745                 :             :   /* If ort == C_ORT_OMP_DECLARE_SIMD used as uniform_head instead.  */
   14746                 :       27372 :   bitmap_initialize (&map_head, &bitmap_default_obstack);
   14747                 :       27372 :   bitmap_initialize (&map_field_head, &bitmap_default_obstack);
   14748                 :       27372 :   bitmap_initialize (&map_firstprivate_head, &bitmap_default_obstack);
   14749                 :             :   /* If ort == C_ORT_OMP used as nontemporal_head or use_device_xxx_head
   14750                 :             :      instead and for ort == C_ORT_OMP_TARGET used as in_reduction_head.  */
   14751                 :       27372 :   bitmap_initialize (&oacc_reduction_head, &bitmap_default_obstack);
   14752                 :       27372 :   bitmap_initialize (&is_on_device_head, &bitmap_default_obstack);
   14753                 :             : 
   14754                 :       27372 :   if (openacc)
   14755                 :       11352 :     for (c = clauses; c; c = OMP_CLAUSE_CHAIN (c))
   14756                 :        6813 :       if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_ASYNC)
   14757                 :             :         {
   14758                 :             :           oacc_async = true;
   14759                 :             :           break;
   14760                 :             :         }
   14761                 :             : 
   14762                 :       27372 :   tree *grp_start_p = NULL, grp_sentinel = NULL_TREE;
   14763                 :             : 
   14764                 :       72789 :   for (pc = &clauses, c = clauses; c ; c = *pc)
   14765                 :             :     {
   14766                 :       45417 :       bool remove = false;
   14767                 :       45417 :       bool need_complete = false;
   14768                 :       45417 :       bool need_implicitly_determined = false;
   14769                 :             : 
   14770                 :             :       /* We've reached the end of a list of expanded nodes.  Reset the group
   14771                 :             :          start pointer.  */
   14772                 :       45417 :       if (c == grp_sentinel)
   14773                 :        2318 :         grp_start_p = NULL;
   14774                 :             : 
   14775                 :       45417 :       switch (OMP_CLAUSE_CODE (c))
   14776                 :             :         {
   14777                 :        1137 :         case OMP_CLAUSE_SHARED:
   14778                 :        1137 :           need_implicitly_determined = true;
   14779                 :        1137 :           goto check_dup_generic;
   14780                 :             : 
   14781                 :         796 :         case OMP_CLAUSE_PRIVATE:
   14782                 :         796 :           need_complete = true;
   14783                 :         796 :           need_implicitly_determined = true;
   14784                 :         796 :           goto check_dup_generic;
   14785                 :             : 
   14786                 :        3265 :         case OMP_CLAUSE_REDUCTION:
   14787                 :        3265 :           if (reduction_seen == 0)
   14788                 :        2697 :             reduction_seen = OMP_CLAUSE_REDUCTION_INSCAN (c) ? -1 : 1;
   14789                 :         568 :           else if (reduction_seen != -2
   14790                 :        1136 :                    && reduction_seen != (OMP_CLAUSE_REDUCTION_INSCAN (c)
   14791                 :         568 :                                          ? -1 : 1))
   14792                 :             :             {
   14793                 :           2 :               error_at (OMP_CLAUSE_LOCATION (c),
   14794                 :             :                         "%<inscan%> and non-%<inscan%> %<reduction%> clauses "
   14795                 :             :                         "on the same construct");
   14796                 :           2 :               reduction_seen = -2;
   14797                 :             :             }
   14798                 :             :           /* FALLTHRU */
   14799                 :        3928 :         case OMP_CLAUSE_IN_REDUCTION:
   14800                 :        3928 :         case OMP_CLAUSE_TASK_REDUCTION:
   14801                 :        3928 :           need_implicitly_determined = true;
   14802                 :        3928 :           t = OMP_CLAUSE_DECL (c);
   14803                 :        3928 :           if (TREE_CODE (t) == OMP_ARRAY_SECTION)
   14804                 :             :             {
   14805                 :         553 :               if (handle_omp_array_sections (c, ort))
   14806                 :             :                 {
   14807                 :             :                   remove = true;
   14808                 :             :                   break;
   14809                 :             :                 }
   14810                 :             : 
   14811                 :         537 :               t = OMP_CLAUSE_DECL (c);
   14812                 :         537 :               if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION
   14813                 :         537 :                   && OMP_CLAUSE_REDUCTION_INSCAN (c))
   14814                 :             :                 {
   14815                 :           1 :                   error_at (OMP_CLAUSE_LOCATION (c),
   14816                 :             :                             "%<inscan%> %<reduction%> clause with array "
   14817                 :             :                             "section");
   14818                 :           1 :                   remove = true;
   14819                 :           1 :                   break;
   14820                 :             :                 }
   14821                 :             :             }
   14822                 :        3911 :           t = require_complete_type (OMP_CLAUSE_LOCATION (c), t);
   14823                 :        3911 :           if (t == error_mark_node)
   14824                 :             :             {
   14825                 :             :               remove = true;
   14826                 :             :               break;
   14827                 :             :             }
   14828                 :        3909 :           if (oacc_async)
   14829                 :           3 :             c_mark_addressable (t);
   14830                 :        3909 :           type = TREE_TYPE (t);
   14831                 :        3909 :           if (TREE_CODE (t) == MEM_REF)
   14832                 :         536 :             type = TREE_TYPE (type);
   14833                 :        3909 :           if (TREE_CODE (type) == ARRAY_TYPE)
   14834                 :             :             {
   14835                 :          74 :               tree oatype = type;
   14836                 :          74 :               gcc_assert (TREE_CODE (t) != MEM_REF);
   14837                 :         148 :               while (TREE_CODE (type) == ARRAY_TYPE)
   14838                 :          74 :                 type = TREE_TYPE (type);
   14839                 :          74 :               if (integer_zerop (TYPE_SIZE_UNIT (type)))
   14840                 :             :                 {
   14841                 :           1 :                   error_at (OMP_CLAUSE_LOCATION (c),
   14842                 :             :                             "%qD in %<reduction%> clause is a zero size array",
   14843                 :             :                             t);
   14844                 :           1 :                   remove = true;
   14845                 :           1 :                   break;
   14846                 :             :                 }
   14847                 :          73 :               tree size = size_binop (EXACT_DIV_EXPR, TYPE_SIZE_UNIT (oatype),
   14848                 :             :                                       TYPE_SIZE_UNIT (type));
   14849                 :          73 :               if (integer_zerop (size))
   14850                 :             :                 {
   14851                 :           1 :                   error_at (OMP_CLAUSE_LOCATION (c),
   14852                 :             :                             "%qD in %<reduction%> clause is a zero size array",
   14853                 :             :                             t);
   14854                 :           1 :                   remove = true;
   14855                 :           1 :                   break;
   14856                 :             :                 }
   14857                 :          72 :               size = size_binop (MINUS_EXPR, size, size_one_node);
   14858                 :          72 :               size = save_expr (size);
   14859                 :          72 :               tree index_type = build_index_type (size);
   14860                 :          72 :               tree atype = build_array_type (TYPE_MAIN_VARIANT (type),
   14861                 :             :                                              index_type);
   14862                 :          72 :               atype = c_build_qualified_type (atype, TYPE_QUALS (type));
   14863                 :          72 :               tree ptype = build_pointer_type (type);
   14864                 :          72 :               if (TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE)
   14865                 :          72 :                 t = build_fold_addr_expr (t);
   14866                 :          72 :               t = build2 (MEM_REF, atype, t, build_int_cst (ptype, 0));
   14867                 :          72 :               OMP_CLAUSE_DECL (c) = t;
   14868                 :             :             }
   14869                 :        3907 :           if (TYPE_ATOMIC (type))
   14870                 :             :             {
   14871                 :           3 :               error_at (OMP_CLAUSE_LOCATION (c),
   14872                 :             :                         "%<_Atomic%> %qE in %<reduction%> clause", t);
   14873                 :           3 :               remove = true;
   14874                 :           3 :               break;
   14875                 :             :             }
   14876                 :        3904 :           if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_REDUCTION
   14877                 :        3904 :               || OMP_CLAUSE_REDUCTION_TASK (c))
   14878                 :             :             {
   14879                 :             :               /* Disallow zero sized or potentially zero sized task
   14880                 :             :                  reductions.  */
   14881                 :         870 :               if (integer_zerop (TYPE_SIZE_UNIT (type)))
   14882                 :             :                 {
   14883                 :           6 :                   error_at (OMP_CLAUSE_LOCATION (c),
   14884                 :             :                             "zero sized type %qT in %qs clause", type,
   14885                 :           3 :                             omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   14886                 :           3 :                   remove = true;
   14887                 :           3 :                   break;
   14888                 :             :                 }
   14889                 :         867 :               else if (TREE_CODE (TYPE_SIZE_UNIT (type)) != INTEGER_CST)
   14890                 :             :                 {
   14891                 :           0 :                   error_at (OMP_CLAUSE_LOCATION (c),
   14892                 :             :                             "variable sized type %qT in %qs clause", type,
   14893                 :           0 :                             omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   14894                 :           0 :                   remove = true;
   14895                 :           0 :                   break;
   14896                 :             :                 }
   14897                 :             :             }
   14898                 :        3901 :           if (OMP_CLAUSE_REDUCTION_PLACEHOLDER (c) == NULL_TREE
   14899                 :        3901 :               && (FLOAT_TYPE_P (type)
   14900                 :        3360 :                   || TREE_CODE (type) == COMPLEX_TYPE))
   14901                 :             :             {
   14902                 :         329 :               enum tree_code r_code = OMP_CLAUSE_REDUCTION_CODE (c);
   14903                 :         329 :               const char *r_name = NULL;
   14904                 :             : 
   14905                 :         329 :               switch (r_code)
   14906                 :             :                 {
   14907                 :             :                 case PLUS_EXPR:
   14908                 :             :                 case MULT_EXPR:
   14909                 :             :                 case MINUS_EXPR:
   14910                 :             :                 case TRUTH_ANDIF_EXPR:
   14911                 :             :                 case TRUTH_ORIF_EXPR:
   14912                 :             :                   break;
   14913                 :          13 :                 case MIN_EXPR:
   14914                 :          13 :                   if (TREE_CODE (type) == COMPLEX_TYPE)
   14915                 :             :                     r_name = "min";
   14916                 :             :                   break;
   14917                 :          38 :                 case MAX_EXPR:
   14918                 :          38 :                   if (TREE_CODE (type) == COMPLEX_TYPE)
   14919                 :             :                     r_name = "max";
   14920                 :             :                   break;
   14921                 :           3 :                 case BIT_AND_EXPR:
   14922                 :           3 :                   r_name = "&";
   14923                 :           3 :                   break;
   14924                 :           2 :                 case BIT_XOR_EXPR:
   14925                 :           2 :                   r_name = "^";
   14926                 :           2 :                   break;
   14927                 :             :                 case BIT_IOR_EXPR:
   14928                 :             :                   r_name = "|";
   14929                 :             :                   break;
   14930                 :           0 :                 default:
   14931                 :           0 :                   gcc_unreachable ();
   14932                 :             :                 }
   14933                 :           5 :               if (r_name)
   14934                 :             :                 {
   14935                 :          12 :                   error_at (OMP_CLAUSE_LOCATION (c),
   14936                 :             :                             "%qE has invalid type for %<reduction(%s)%>",
   14937                 :             :                             t, r_name);
   14938                 :          12 :                   remove = true;
   14939                 :          12 :                   break;
   14940                 :             :                 }
   14941                 :             :             }
   14942                 :        3572 :           else if (OMP_CLAUSE_REDUCTION_PLACEHOLDER (c) == error_mark_node)
   14943                 :             :             {
   14944                 :           2 :               error_at (OMP_CLAUSE_LOCATION (c),
   14945                 :             :                         "user defined reduction not found for %qE", t);
   14946                 :           2 :               remove = true;
   14947                 :           2 :               break;
   14948                 :             :             }
   14949                 :        3570 :           else if (OMP_CLAUSE_REDUCTION_PLACEHOLDER (c))
   14950                 :             :             {
   14951                 :         277 :               tree list = OMP_CLAUSE_REDUCTION_PLACEHOLDER (c);
   14952                 :         277 :               type = TYPE_MAIN_VARIANT (type);
   14953                 :         277 :               tree placeholder = build_decl (OMP_CLAUSE_LOCATION (c),
   14954                 :             :                                              VAR_DECL, NULL_TREE, type);
   14955                 :         277 :               tree decl_placeholder = NULL_TREE;
   14956                 :         277 :               OMP_CLAUSE_REDUCTION_PLACEHOLDER (c) = placeholder;
   14957                 :         277 :               DECL_ARTIFICIAL (placeholder) = 1;
   14958                 :         277 :               DECL_IGNORED_P (placeholder) = 1;
   14959                 :         277 :               if (TREE_CODE (t) == MEM_REF)
   14960                 :             :                 {
   14961                 :          56 :                   decl_placeholder = build_decl (OMP_CLAUSE_LOCATION (c),
   14962                 :             :                                                  VAR_DECL, NULL_TREE, type);
   14963                 :          56 :                   OMP_CLAUSE_REDUCTION_DECL_PLACEHOLDER (c) = decl_placeholder;
   14964                 :          56 :                   DECL_ARTIFICIAL (decl_placeholder) = 1;
   14965                 :          56 :                   DECL_IGNORED_P (decl_placeholder) = 1;
   14966                 :             :                 }
   14967                 :         277 :               if (TREE_ADDRESSABLE (TREE_VEC_ELT (list, 0)))
   14968                 :          42 :                 c_mark_addressable (placeholder);
   14969                 :         277 :               if (TREE_ADDRESSABLE (TREE_VEC_ELT (list, 1)))
   14970                 :          76 :                 c_mark_addressable (decl_placeholder ? decl_placeholder
   14971                 :          34 :                                     : OMP_CLAUSE_DECL (c));
   14972                 :         277 :               OMP_CLAUSE_REDUCTION_MERGE (c)
   14973                 :         775 :                 = c_clone_omp_udr (TREE_VEC_ELT (list, 2),
   14974                 :         277 :                                    TREE_VEC_ELT (list, 0),
   14975                 :         277 :                                    TREE_VEC_ELT (list, 1),
   14976                 :             :                                    decl_placeholder ? decl_placeholder
   14977                 :         221 :                                    : OMP_CLAUSE_DECL (c), placeholder);
   14978                 :         277 :               OMP_CLAUSE_REDUCTION_MERGE (c)
   14979                 :         277 :                 = build3_loc (OMP_CLAUSE_LOCATION (c), BIND_EXPR,
   14980                 :             :                               void_type_node, NULL_TREE,
   14981                 :         277 :                               OMP_CLAUSE_REDUCTION_MERGE (c), NULL_TREE);
   14982                 :         277 :               TREE_SIDE_EFFECTS (OMP_CLAUSE_REDUCTION_MERGE (c)) = 1;
   14983                 :         277 :               if (TREE_VEC_LENGTH (list) == 6)
   14984                 :             :                 {
   14985                 :         233 :                   if (TREE_ADDRESSABLE (TREE_VEC_ELT (list, 3)))
   14986                 :          70 :                     c_mark_addressable (decl_placeholder ? decl_placeholder
   14987                 :          33 :                                         : OMP_CLAUSE_DECL (c));
   14988                 :         233 :                   if (TREE_ADDRESSABLE (TREE_VEC_ELT (list, 4)))
   14989                 :          27 :                     c_mark_addressable (placeholder);
   14990                 :         233 :                   tree init = TREE_VEC_ELT (list, 5);
   14991                 :         233 :                   if (init == error_mark_node)
   14992                 :         197 :                     init = DECL_INITIAL (TREE_VEC_ELT (list, 3));
   14993                 :         233 :                   OMP_CLAUSE_REDUCTION_INIT (c)
   14994                 :         651 :                     = c_clone_omp_udr (init, TREE_VEC_ELT (list, 4),
   14995                 :         233 :                                        TREE_VEC_ELT (list, 3),
   14996                 :             :                                        decl_placeholder ? decl_placeholder
   14997                 :         185 :                                        : OMP_CLAUSE_DECL (c), placeholder);
   14998                 :         233 :                   if (TREE_VEC_ELT (list, 5) == error_mark_node)
   14999                 :             :                     {
   15000                 :         197 :                       tree v = decl_placeholder ? decl_placeholder : t;
   15001                 :         197 :                       OMP_CLAUSE_REDUCTION_INIT (c)
   15002                 :         394 :                         = build2 (INIT_EXPR, TREE_TYPE (v), v,
   15003                 :         197 :                                   OMP_CLAUSE_REDUCTION_INIT (c));
   15004                 :             :                     }
   15005                 :         233 :                   if (walk_tree (&OMP_CLAUSE_REDUCTION_INIT (c),
   15006                 :             :                                  c_find_omp_placeholder_r,
   15007                 :             :                                  placeholder, NULL))
   15008                 :          28 :                     OMP_CLAUSE_REDUCTION_OMP_ORIG_REF (c) = 1;
   15009                 :             :                 }
   15010                 :             :               else
   15011                 :             :                 {
   15012                 :          44 :                   tree init;
   15013                 :          44 :                   tree v = decl_placeholder ? decl_placeholder : t;
   15014                 :          44 :                   if (AGGREGATE_TYPE_P (TREE_TYPE (v)))
   15015                 :          34 :                     init = build_constructor (TREE_TYPE (v), NULL);
   15016                 :             :                   else
   15017                 :          10 :                     init = fold_convert (TREE_TYPE (v), integer_zero_node);
   15018                 :          44 :                   OMP_CLAUSE_REDUCTION_INIT (c)
   15019                 :          88 :                     = build2 (INIT_EXPR, TREE_TYPE (v), v, init);
   15020                 :             :                 }
   15021                 :         277 :               OMP_CLAUSE_REDUCTION_INIT (c)
   15022                 :         277 :                 = build3_loc (OMP_CLAUSE_LOCATION (c), BIND_EXPR,
   15023                 :             :                               void_type_node, NULL_TREE,
   15024                 :         277 :                                OMP_CLAUSE_REDUCTION_INIT (c), NULL_TREE);
   15025                 :         277 :               TREE_SIDE_EFFECTS (OMP_CLAUSE_REDUCTION_INIT (c)) = 1;
   15026                 :             :             }
   15027                 :        3887 :           if (TREE_CODE (t) == MEM_REF)
   15028                 :             :             {
   15029                 :         607 :               if (TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (t))) == NULL_TREE
   15030                 :         607 :                   || TREE_CODE (TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (t))))
   15031                 :             :                      != INTEGER_CST)
   15032                 :             :                 {
   15033                 :           0 :                   sorry ("variable length element type in array "
   15034                 :             :                          "%<reduction%> clause");
   15035                 :           0 :                   remove = true;
   15036                 :           0 :                   break;
   15037                 :             :                 }
   15038                 :         607 :               t = TREE_OPERAND (t, 0);
   15039                 :         607 :               if (TREE_CODE (t) == POINTER_PLUS_EXPR)
   15040                 :         139 :                 t = TREE_OPERAND (t, 0);
   15041                 :         607 :               if (TREE_CODE (t) == ADDR_EXPR)
   15042                 :         367 :                 t = TREE_OPERAND (t, 0);
   15043                 :             :             }
   15044                 :        3887 :           goto check_dup_generic_t;
   15045                 :             : 
   15046                 :          24 :         case OMP_CLAUSE_COPYPRIVATE:
   15047                 :          24 :           copyprivate_seen = true;
   15048                 :          24 :           if (nowait_clause)
   15049                 :             :             {
   15050                 :           1 :               error_at (OMP_CLAUSE_LOCATION (*nowait_clause),
   15051                 :             :                         "%<nowait%> clause must not be used together "
   15052                 :             :                         "with %<copyprivate%>");
   15053                 :           1 :               *nowait_clause = OMP_CLAUSE_CHAIN (*nowait_clause);
   15054                 :           1 :               nowait_clause = NULL;
   15055                 :             :             }
   15056                 :          24 :           goto check_dup_generic;
   15057                 :             : 
   15058                 :          99 :         case OMP_CLAUSE_COPYIN:
   15059                 :          99 :           t = OMP_CLAUSE_DECL (c);
   15060                 :          99 :           if (!VAR_P (t) || !DECL_THREAD_LOCAL_P (t))
   15061                 :             :             {
   15062                 :           5 :               error_at (OMP_CLAUSE_LOCATION (c),
   15063                 :             :                         "%qE must be %<threadprivate%> for %<copyin%>", t);
   15064                 :           5 :               remove = true;
   15065                 :           5 :               break;
   15066                 :             :             }
   15067                 :          94 :           goto check_dup_generic;
   15068                 :             : 
   15069                 :         478 :         case OMP_CLAUSE_LINEAR:
   15070                 :         478 :           if (ort != C_ORT_OMP_DECLARE_SIMD)
   15071                 :         327 :             need_implicitly_determined = true;
   15072                 :         478 :           t = OMP_CLAUSE_DECL (c);
   15073                 :         478 :           if (ort != C_ORT_OMP_DECLARE_SIMD
   15074                 :         327 :               && OMP_CLAUSE_LINEAR_KIND (c) != OMP_CLAUSE_LINEAR_DEFAULT
   15075                 :         483 :               && OMP_CLAUSE_LINEAR_OLD_LINEAR_MODIFIER (c))
   15076                 :             :             {
   15077                 :           5 :               error_at (OMP_CLAUSE_LOCATION (c),
   15078                 :             :                         "modifier should not be specified in %<linear%> "
   15079                 :             :                         "clause on %<simd%> or %<for%> constructs when not "
   15080                 :             :                         "using OpenMP 5.2 modifiers");
   15081                 :           5 :               OMP_CLAUSE_LINEAR_KIND (c) = OMP_CLAUSE_LINEAR_DEFAULT;
   15082                 :             :             }
   15083                 :         956 :           if (!INTEGRAL_TYPE_P (TREE_TYPE (t))
   15084                 :         501 :               && TREE_CODE (TREE_TYPE (t)) != POINTER_TYPE)
   15085                 :             :             {
   15086                 :           1 :               error_at (OMP_CLAUSE_LOCATION (c),
   15087                 :             :                         "linear clause applied to non-integral non-pointer "
   15088                 :           1 :                         "variable with type %qT", TREE_TYPE (t));
   15089                 :           1 :               remove = true;
   15090                 :           1 :               break;
   15091                 :             :             }
   15092                 :         477 :           if (TYPE_ATOMIC (TREE_TYPE (t)))
   15093                 :             :             {
   15094                 :           3 :               error_at (OMP_CLAUSE_LOCATION (c),
   15095                 :             :                         "%<_Atomic%> %qD in %<linear%> clause", t);
   15096                 :           3 :               remove = true;
   15097                 :           3 :               break;
   15098                 :             :             }
   15099                 :         474 :           if (ort == C_ORT_OMP_DECLARE_SIMD)
   15100                 :             :             {
   15101                 :         150 :               tree s = OMP_CLAUSE_LINEAR_STEP (c);
   15102                 :         150 :               if (TREE_CODE (s) == PARM_DECL)
   15103                 :             :                 {
   15104                 :           9 :                   OMP_CLAUSE_LINEAR_VARIABLE_STRIDE (c) = 1;
   15105                 :             :                   /* map_head bitmap is used as uniform_head if
   15106                 :             :                      declare_simd.  */
   15107                 :           9 :                   if (!bitmap_bit_p (&map_head, DECL_UID (s)))
   15108                 :           5 :                     linear_variable_step_check = true;
   15109                 :           9 :                   goto check_dup_generic;
   15110                 :             :                 }
   15111                 :         141 :               if (TREE_CODE (s) != INTEGER_CST)
   15112                 :             :                 {
   15113                 :           7 :                   error_at (OMP_CLAUSE_LOCATION (c),
   15114                 :             :                             "%<linear%> clause step %qE is neither constant "
   15115                 :             :                             "nor a parameter", s);
   15116                 :           7 :                   remove = true;
   15117                 :           7 :                   break;
   15118                 :             :                 }
   15119                 :             :             }
   15120                 :         458 :           if (TREE_CODE (TREE_TYPE (OMP_CLAUSE_DECL (c))) == POINTER_TYPE)
   15121                 :             :             {
   15122                 :          20 :               tree s = OMP_CLAUSE_LINEAR_STEP (c);
   15123                 :          20 :               s = pointer_int_sum (OMP_CLAUSE_LOCATION (c), PLUS_EXPR,
   15124                 :          20 :                                    OMP_CLAUSE_DECL (c), s);
   15125                 :          20 :               s = fold_build2_loc (OMP_CLAUSE_LOCATION (c), MINUS_EXPR,
   15126                 :             :                                    sizetype, fold_convert (sizetype, s),
   15127                 :          20 :                                    fold_convert
   15128                 :             :                                      (sizetype, OMP_CLAUSE_DECL (c)));
   15129                 :          20 :               if (s == error_mark_node)
   15130                 :           0 :                 s = size_one_node;
   15131                 :          20 :               OMP_CLAUSE_LINEAR_STEP (c) = s;
   15132                 :             :             }
   15133                 :             :           else
   15134                 :         438 :             OMP_CLAUSE_LINEAR_STEP (c)
   15135                 :         876 :               = fold_convert (TREE_TYPE (t), OMP_CLAUSE_LINEAR_STEP (c));
   15136                 :         458 :           goto check_dup_generic;
   15137                 :             : 
   15138                 :        2794 :         check_dup_generic:
   15139                 :        2794 :           t = OMP_CLAUSE_DECL (c);
   15140                 :        6768 :         check_dup_generic_t:
   15141                 :        6768 :           if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL)
   15142                 :             :             {
   15143                 :           4 :               error_at (OMP_CLAUSE_LOCATION (c),
   15144                 :             :                         "%qE is not a variable in clause %qs", t,
   15145                 :           2 :                         omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   15146                 :           2 :               remove = true;
   15147                 :             :             }
   15148                 :         914 :           else if ((openacc && OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION)
   15149                 :        5958 :                    || (ort == C_ORT_OMP
   15150                 :        5266 :                        && (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_USE_DEVICE_PTR
   15151                 :        5256 :                            || (OMP_CLAUSE_CODE (c)
   15152                 :             :                                == OMP_CLAUSE_USE_DEVICE_ADDR)))
   15153                 :       12678 :                    || (ort == C_ORT_OMP_TARGET
   15154                 :         326 :                        && OMP_CLAUSE_CODE (c) == OMP_CLAUSE_IN_REDUCTION))
   15155                 :             :             {
   15156                 :         964 :               if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_IN_REDUCTION
   15157                 :         964 :                   && (bitmap_bit_p (&generic_head, DECL_UID (t))
   15158                 :         109 :                       || bitmap_bit_p (&firstprivate_head, DECL_UID (t))))
   15159                 :             :                 {
   15160                 :           2 :                   error_at (OMP_CLAUSE_LOCATION (c),
   15161                 :             :                             "%qD appears more than once in data-sharing "
   15162                 :             :                             "clauses", t);
   15163                 :           2 :                   remove = true;
   15164                 :           2 :                   break;
   15165                 :             :                 }
   15166                 :         962 :               if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_IN_REDUCTION)
   15167                 :         108 :                 target_in_reduction_seen = true;
   15168                 :         962 :               if (bitmap_bit_p (&oacc_reduction_head, DECL_UID (t)))
   15169                 :             :                 {
   15170                 :           4 :                   error_at (OMP_CLAUSE_LOCATION (c),
   15171                 :             :                             openacc
   15172                 :             :                             ? "%qD appears more than once in reduction clauses"
   15173                 :             :                             : "%qD appears more than once in data clauses",
   15174                 :             :                             t);
   15175                 :           2 :                   remove = true;
   15176                 :             :                 }
   15177                 :             :               else
   15178                 :         960 :                 bitmap_set_bit (&oacc_reduction_head, DECL_UID (t));
   15179                 :             :             }
   15180                 :        5802 :           else if (bitmap_bit_p (&generic_head, DECL_UID (t))
   15181                 :        5780 :                    || bitmap_bit_p (&firstprivate_head, DECL_UID (t))
   15182                 :        5779 :                    || bitmap_bit_p (&lastprivate_head, DECL_UID (t))
   15183                 :       11581 :                    || bitmap_bit_p (&map_firstprivate_head, DECL_UID (t)))
   15184                 :             :             {
   15185                 :          23 :               error_at (OMP_CLAUSE_LOCATION (c),
   15186                 :             :                         "%qE appears more than once in data clauses", t);
   15187                 :          23 :               remove = true;
   15188                 :             :             }
   15189                 :        5779 :           else if ((OMP_CLAUSE_CODE (c) == OMP_CLAUSE_PRIVATE
   15190                 :             :                     || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_HAS_DEVICE_ADDR
   15191                 :             :                     || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_IS_DEVICE_PTR)
   15192                 :         958 :                    && bitmap_bit_p (&map_head, DECL_UID (t)))
   15193                 :             :             {
   15194                 :           3 :               if (openacc)
   15195                 :           0 :                 error_at (OMP_CLAUSE_LOCATION (c),
   15196                 :             :                           "%qD appears more than once in data clauses", t);
   15197                 :             :               else
   15198                 :           3 :                 error_at (OMP_CLAUSE_LOCATION (c),
   15199                 :             :                           "%qD appears both in data and map clauses", t);
   15200                 :             :               remove = true;
   15201                 :             :             }
   15202                 :             :           else
   15203                 :        5776 :             bitmap_set_bit (&generic_head, DECL_UID (t));
   15204                 :             :           break;
   15205                 :             : 
   15206                 :        1305 :         case OMP_CLAUSE_FIRSTPRIVATE:
   15207                 :        1305 :           if (OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT (c) && !implicit_moved)
   15208                 :             :             {
   15209                 :         183 :             move_implicit:
   15210                 :         183 :               implicit_moved = true;
   15211                 :             :               /* Move firstprivate and map clauses with
   15212                 :             :                  OMP_CLAUSE_{FIRSTPRIVATE,MAP}_IMPLICIT set to the end of
   15213                 :             :                  clauses chain.  */
   15214                 :         183 :               tree cl1 = NULL_TREE, cl2 = NULL_TREE;
   15215                 :         183 :               tree *pc1 = pc, *pc2 = &cl1, *pc3 = &cl2;
   15216                 :        1066 :               while (*pc1)
   15217                 :         883 :                 if (OMP_CLAUSE_CODE (*pc1) == OMP_CLAUSE_FIRSTPRIVATE
   15218                 :         883 :                     && OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT (*pc1))
   15219                 :             :                   {
   15220                 :         113 :                     *pc3 = *pc1;
   15221                 :         113 :                     pc3 = &OMP_CLAUSE_CHAIN (*pc3);
   15222                 :         113 :                     *pc1 = OMP_CLAUSE_CHAIN (*pc1);
   15223                 :             :                   }
   15224                 :         770 :                 else if (OMP_CLAUSE_CODE (*pc1) == OMP_CLAUSE_MAP
   15225                 :         770 :                          && OMP_CLAUSE_MAP_IMPLICIT (*pc1))
   15226                 :             :                   {
   15227                 :         161 :                     *pc2 = *pc1;
   15228                 :         161 :                     pc2 = &OMP_CLAUSE_CHAIN (*pc2);
   15229                 :         161 :                     *pc1 = OMP_CLAUSE_CHAIN (*pc1);
   15230                 :             :                   }
   15231                 :             :                 else
   15232                 :         609 :                   pc1 = &OMP_CLAUSE_CHAIN (*pc1);
   15233                 :         183 :               *pc3 = NULL;
   15234                 :         183 :               *pc2 = cl2;
   15235                 :         183 :               *pc1 = cl1;
   15236                 :         183 :               continue;
   15237                 :         183 :             }
   15238                 :        1210 :           t = OMP_CLAUSE_DECL (c);
   15239                 :        1210 :           need_complete = true;
   15240                 :        1210 :           need_implicitly_determined = true;
   15241                 :        1210 :           if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL)
   15242                 :             :             {
   15243                 :           1 :               error_at (OMP_CLAUSE_LOCATION (c),
   15244                 :             :                         "%qE is not a variable in clause %<firstprivate%>", t);
   15245                 :           1 :               remove = true;
   15246                 :             :             }
   15247                 :        1209 :           else if (OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT (c)
   15248                 :         113 :                    && !OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT_TARGET (c)
   15249                 :        1315 :                    && bitmap_bit_p (&map_firstprivate_head, DECL_UID (t)))
   15250                 :             :             remove = true;
   15251                 :        1209 :           else if (bitmap_bit_p (&generic_head, DECL_UID (t))
   15252                 :        1207 :                    || bitmap_bit_p (&firstprivate_head, DECL_UID (t))
   15253                 :        2415 :                    || bitmap_bit_p (&map_firstprivate_head, DECL_UID (t)))
   15254                 :             :             {
   15255                 :           4 :               error_at (OMP_CLAUSE_LOCATION (c),
   15256                 :             :                         "%qE appears more than once in data clauses", t);
   15257                 :           4 :               remove = true;
   15258                 :             :             }
   15259                 :        1205 :           else if (bitmap_bit_p (&map_head, DECL_UID (t))
   15260                 :        1205 :                    || bitmap_bit_p (&map_field_head, DECL_UID (t)))
   15261                 :             :             {
   15262                 :           7 :               if (openacc)
   15263                 :           0 :                 error_at (OMP_CLAUSE_LOCATION (c),
   15264                 :             :                           "%qD appears more than once in data clauses", t);
   15265                 :           7 :               else if (OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT (c)
   15266                 :           7 :                        && !OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT_TARGET (c))
   15267                 :             :                 /* Silently drop the clause.  */;
   15268                 :             :               else
   15269                 :           6 :                 error_at (OMP_CLAUSE_LOCATION (c),
   15270                 :             :                           "%qD appears both in data and map clauses", t);
   15271                 :             :               remove = true;
   15272                 :             :             }
   15273                 :             :           else
   15274                 :        1198 :             bitmap_set_bit (&firstprivate_head, DECL_UID (t));
   15275                 :             :           break;
   15276                 :             : 
   15277                 :        1519 :         case OMP_CLAUSE_LASTPRIVATE:
   15278                 :        1519 :           t = OMP_CLAUSE_DECL (c);
   15279                 :        1519 :           need_complete = true;
   15280                 :        1519 :           need_implicitly_determined = true;
   15281                 :        1519 :           if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL)
   15282                 :             :             {
   15283                 :           0 :               error_at (OMP_CLAUSE_LOCATION (c),
   15284                 :             :                         "%qE is not a variable in clause %<lastprivate%>", t);
   15285                 :           0 :               remove = true;
   15286                 :             :             }
   15287                 :        1519 :           else if (bitmap_bit_p (&generic_head, DECL_UID (t))
   15288                 :        1519 :                    || bitmap_bit_p (&lastprivate_head, DECL_UID (t)))
   15289                 :             :             {
   15290                 :           3 :               error_at (OMP_CLAUSE_LOCATION (c),
   15291                 :             :                      "%qE appears more than once in data clauses", t);
   15292                 :           3 :               remove = true;
   15293                 :             :             }
   15294                 :             :           else
   15295                 :        1516 :             bitmap_set_bit (&lastprivate_head, DECL_UID (t));
   15296                 :             :           break;
   15297                 :             : 
   15298                 :         253 :         case OMP_CLAUSE_ALIGNED:
   15299                 :         253 :           t = OMP_CLAUSE_DECL (c);
   15300                 :         253 :           if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL)
   15301                 :             :             {
   15302                 :           0 :               error_at (OMP_CLAUSE_LOCATION (c),
   15303                 :             :                         "%qE is not a variable in %<aligned%> clause", t);
   15304                 :           0 :               remove = true;
   15305                 :             :             }
   15306                 :         289 :           else if (!POINTER_TYPE_P (TREE_TYPE (t))
   15307                 :         289 :                    && TREE_CODE (TREE_TYPE (t)) != ARRAY_TYPE)
   15308                 :             :             {
   15309                 :           7 :               error_at (OMP_CLAUSE_LOCATION (c),
   15310                 :             :                         "%qE in %<aligned%> clause is neither a pointer nor "
   15311                 :             :                         "an array", t);
   15312                 :           7 :               remove = true;
   15313                 :             :             }
   15314                 :         246 :           else if (TYPE_ATOMIC (TREE_TYPE (t)))
   15315                 :             :             {
   15316                 :           1 :               error_at (OMP_CLAUSE_LOCATION (c),
   15317                 :             :                         "%<_Atomic%> %qD in %<aligned%> clause", t);
   15318                 :           1 :               remove = true;
   15319                 :           1 :               break;
   15320                 :             :             }
   15321                 :         245 :           else if (bitmap_bit_p (&aligned_head, DECL_UID (t)))
   15322                 :             :             {
   15323                 :           0 :               error_at (OMP_CLAUSE_LOCATION (c),
   15324                 :             :                         "%qE appears more than once in %<aligned%> clauses",
   15325                 :             :                         t);
   15326                 :           0 :               remove = true;
   15327                 :             :             }
   15328                 :             :           else
   15329                 :         245 :             bitmap_set_bit (&aligned_head, DECL_UID (t));
   15330                 :             :           break;
   15331                 :             : 
   15332                 :         125 :         case OMP_CLAUSE_NONTEMPORAL:
   15333                 :         125 :           t = OMP_CLAUSE_DECL (c);
   15334                 :         125 :           if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL)
   15335                 :             :             {
   15336                 :           0 :               error_at (OMP_CLAUSE_LOCATION (c),
   15337                 :             :                         "%qE is not a variable in %<nontemporal%> clause", t);
   15338                 :           0 :               remove = true;
   15339                 :             :             }
   15340                 :         125 :           else if (bitmap_bit_p (&oacc_reduction_head, DECL_UID (t)))
   15341                 :             :             {
   15342                 :           2 :               error_at (OMP_CLAUSE_LOCATION (c),
   15343                 :             :                         "%qE appears more than once in %<nontemporal%> "
   15344                 :             :                         "clauses", t);
   15345                 :           2 :               remove = true;
   15346                 :             :             }
   15347                 :             :           else
   15348                 :         123 :             bitmap_set_bit (&oacc_reduction_head, DECL_UID (t));
   15349                 :             :           break;
   15350                 :             : 
   15351                 :         780 :         case OMP_CLAUSE_ALLOCATE:
   15352                 :         780 :           t = OMP_CLAUSE_DECL (c);
   15353                 :         780 :           if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL)
   15354                 :             :             {
   15355                 :           1 :               error_at (OMP_CLAUSE_LOCATION (c),
   15356                 :             :                         "%qE is not a variable in %<allocate%> clause", t);
   15357                 :           1 :               remove = true;
   15358                 :             :             }
   15359                 :         779 :           else if (bitmap_bit_p (&aligned_head, DECL_UID (t)))
   15360                 :             :             {
   15361                 :           2 :               warning_at (OMP_CLAUSE_LOCATION (c), 0,
   15362                 :             :                           "%qE appears more than once in %<allocate%> clauses",
   15363                 :             :                           t);
   15364                 :           2 :               remove = true;
   15365                 :             :             }
   15366                 :             :           else
   15367                 :             :             {
   15368                 :         777 :               bitmap_set_bit (&aligned_head, DECL_UID (t));
   15369                 :         777 :               if (!OMP_CLAUSE_ALLOCATE_COMBINED (c))
   15370                 :         679 :                 allocate_seen = true;
   15371                 :             :             }
   15372                 :             :           break;
   15373                 :             : 
   15374                 :         331 :         case OMP_CLAUSE_DOACROSS:
   15375                 :         331 :           t = OMP_CLAUSE_DECL (c);
   15376                 :         331 :           if (t == NULL_TREE)
   15377                 :             :             break;
   15378                 :         156 :           if (OMP_CLAUSE_DOACROSS_KIND (c) == OMP_CLAUSE_DOACROSS_SINK)
   15379                 :             :             {
   15380                 :         156 :               gcc_assert (TREE_CODE (t) == TREE_LIST);
   15381                 :        1289 :               for (; t; t = TREE_CHAIN (t))
   15382                 :             :                 {
   15383                 :        1133 :                   tree decl = TREE_VALUE (t);
   15384                 :        1133 :                   if (TREE_CODE (TREE_TYPE (decl)) == POINTER_TYPE)
   15385                 :             :                     {
   15386                 :           3 :                       tree offset = TREE_PURPOSE (t);
   15387                 :           3 :                       bool neg = wi::neg_p (wi::to_wide (offset));
   15388                 :           3 :                       offset = fold_unary (ABS_EXPR, TREE_TYPE (offset), offset);
   15389                 :           6 :                       tree t2 = pointer_int_sum (OMP_CLAUSE_LOCATION (c),
   15390                 :             :                                                  neg ? MINUS_EXPR : PLUS_EXPR,
   15391                 :             :                                                  decl, offset);
   15392                 :           3 :                       t2 = fold_build2_loc (OMP_CLAUSE_LOCATION (c), MINUS_EXPR,
   15393                 :             :                                             sizetype,
   15394                 :             :                                             fold_convert (sizetype, t2),
   15395                 :             :                                             fold_convert (sizetype, decl));
   15396                 :           3 :                       if (t2 == error_mark_node)
   15397                 :             :                         {
   15398                 :             :                           remove = true;
   15399                 :             :                           break;
   15400                 :             :                         }
   15401                 :           3 :                       TREE_PURPOSE (t) = t2;
   15402                 :             :                     }
   15403                 :             :                 }
   15404                 :             :               break;
   15405                 :             :             }
   15406                 :           0 :           gcc_unreachable ();
   15407                 :         837 :         case OMP_CLAUSE_DEPEND:
   15408                 :         837 :         case OMP_CLAUSE_AFFINITY:
   15409                 :         837 :           t = OMP_CLAUSE_DECL (c);
   15410                 :         837 :           if (TREE_CODE (t) == TREE_LIST
   15411                 :         131 :               && TREE_PURPOSE (t)
   15412                 :         968 :               && TREE_CODE (TREE_PURPOSE (t)) == TREE_VEC)
   15413                 :             :             {
   15414                 :         131 :               if (TREE_PURPOSE (t) != last_iterators)
   15415                 :         111 :                 last_iterators_remove
   15416                 :         111 :                   = c_omp_finish_iterators (TREE_PURPOSE (t));
   15417                 :         131 :               last_iterators = TREE_PURPOSE (t);
   15418                 :         131 :               t = TREE_VALUE (t);
   15419                 :         131 :               if (last_iterators_remove)
   15420                 :          34 :                 t = error_mark_node;
   15421                 :             :             }
   15422                 :             :           else
   15423                 :             :             last_iterators = NULL_TREE;
   15424                 :         837 :           if (TREE_CODE (t) == OMP_ARRAY_SECTION)
   15425                 :             :             {
   15426                 :         406 :               if (handle_omp_array_sections (c, ort))
   15427                 :             :                 remove = true;
   15428                 :         329 :               else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND
   15429                 :         329 :                        && OMP_CLAUSE_DEPEND_KIND (c) == OMP_CLAUSE_DEPEND_DEPOBJ)
   15430                 :             :                 {
   15431                 :           1 :                   error_at (OMP_CLAUSE_LOCATION (c),
   15432                 :             :                             "%<depend%> clause with %<depobj%> dependence "
   15433                 :             :                             "type on array section");
   15434                 :           1 :                   remove = true;
   15435                 :             :                 }
   15436                 :             :               break;
   15437                 :             :             }
   15438                 :         431 :           if (t == error_mark_node)
   15439                 :             :             remove = true;
   15440                 :         397 :           else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND
   15441                 :         397 :                    && t == ridpointers[RID_OMP_ALL_MEMORY])
   15442                 :             :             {
   15443                 :          15 :               if (OMP_CLAUSE_DEPEND_KIND (c) != OMP_CLAUSE_DEPEND_OUT
   15444                 :          15 :                   && OMP_CLAUSE_DEPEND_KIND (c) != OMP_CLAUSE_DEPEND_INOUT)
   15445                 :             :                 {
   15446                 :           3 :                   error_at (OMP_CLAUSE_LOCATION (c),
   15447                 :             :                             "%<omp_all_memory%> used with %<depend%> kind "
   15448                 :             :                             "other than %<out%> or %<inout%>");
   15449                 :           3 :                   remove = true;
   15450                 :             :                 }
   15451                 :             :             }
   15452                 :         382 :           else if (!lvalue_p (t))
   15453                 :             :             {
   15454                 :           4 :               error_at (OMP_CLAUSE_LOCATION (c),
   15455                 :             :                         "%qE is not lvalue expression nor array section in "
   15456                 :             :                         "%qs clause", t,
   15457                 :           2 :                         omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   15458                 :           2 :               remove = true;
   15459                 :             :             }
   15460                 :         380 :           else if (TREE_CODE (t) == COMPONENT_REF
   15461                 :         380 :                    && DECL_C_BIT_FIELD (TREE_OPERAND (t, 1)))
   15462                 :             :             {
   15463                 :           2 :               gcc_assert (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND
   15464                 :             :                           || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_AFFINITY);
   15465                 :           2 :               error_at (OMP_CLAUSE_LOCATION (c),
   15466                 :             :                         "bit-field %qE in %qs clause", t,
   15467                 :           2 :                         omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   15468                 :           2 :               remove = true;
   15469                 :             :             }
   15470                 :         378 :           else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND
   15471                 :         378 :                    && OMP_CLAUSE_DEPEND_KIND (c) == OMP_CLAUSE_DEPEND_DEPOBJ)
   15472                 :             :             {
   15473                 :          17 :               if (!c_omp_depend_t_p (TREE_TYPE (t)))
   15474                 :             :                 {
   15475                 :           2 :                   error_at (OMP_CLAUSE_LOCATION (c),
   15476                 :             :                             "%qE does not have %<omp_depend_t%> type in "
   15477                 :             :                             "%<depend%> clause with %<depobj%> dependence "
   15478                 :             :                             "type", t);
   15479                 :           2 :                   remove = true;
   15480                 :             :                 }
   15481                 :             :             }
   15482                 :         361 :           else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND
   15483                 :         361 :                    && c_omp_depend_t_p (TREE_TYPE (t)))
   15484                 :             :             {
   15485                 :           2 :               error_at (OMP_CLAUSE_LOCATION (c),
   15486                 :             :                         "%qE should not have %<omp_depend_t%> type in "
   15487                 :             :                         "%<depend%> clause with dependence type other than "
   15488                 :             :                         "%<depobj%>", t);
   15489                 :           2 :               remove = true;
   15490                 :             :             }
   15491                 :          11 :           if (!remove)
   15492                 :             :             {
   15493                 :         386 :               if (t == ridpointers[RID_OMP_ALL_MEMORY])
   15494                 :          12 :                 t = null_pointer_node;
   15495                 :             :               else
   15496                 :             :                 {
   15497                 :         374 :                   tree addr = build_unary_op (OMP_CLAUSE_LOCATION (c),
   15498                 :             :                                               ADDR_EXPR, t, false);
   15499                 :         374 :                   if (addr == error_mark_node)
   15500                 :             :                     {
   15501                 :             :                       remove = true;
   15502                 :             :                       break;
   15503                 :             :                     }
   15504                 :         374 :                   t = build_indirect_ref (OMP_CLAUSE_LOCATION (c), addr,
   15505                 :             :                                           RO_UNARY_STAR);
   15506                 :         374 :                   if (t == error_mark_node)
   15507                 :             :                     {
   15508                 :             :                       remove = true;
   15509                 :             :                       break;
   15510                 :             :                     }
   15511                 :             :                 }
   15512                 :         386 :               if (TREE_CODE (OMP_CLAUSE_DECL (c)) == TREE_LIST
   15513                 :          31 :                   && TREE_PURPOSE (OMP_CLAUSE_DECL (c))
   15514                 :         417 :                   && (TREE_CODE (TREE_PURPOSE (OMP_CLAUSE_DECL (c)))
   15515                 :             :                       == TREE_VEC))
   15516                 :          31 :                 TREE_VALUE (OMP_CLAUSE_DECL (c)) = t;
   15517                 :             :               else
   15518                 :         355 :                 OMP_CLAUSE_DECL (c) = t;
   15519                 :             :             }
   15520                 :             :           break;
   15521                 :             : 
   15522                 :        6033 :         case OMP_CLAUSE_MAP:
   15523                 :        6033 :           if (OMP_CLAUSE_MAP_IMPLICIT (c) && !implicit_moved)
   15524                 :          88 :             goto move_implicit;
   15525                 :             :           /* FALLTHRU */
   15526                 :        8928 :         case OMP_CLAUSE_TO:
   15527                 :        8928 :         case OMP_CLAUSE_FROM:
   15528                 :        8928 :         case OMP_CLAUSE__CACHE_:
   15529                 :        8928 :           {
   15530                 :        8928 :             using namespace omp_addr_tokenizer;
   15531                 :        8928 :             auto_vec<omp_addr_token *, 10> addr_tokens;
   15532                 :             : 
   15533                 :        8928 :             t = OMP_CLAUSE_DECL (c);
   15534                 :        8928 :             if (TREE_CODE (t) == OMP_ARRAY_SECTION)
   15535                 :             :               {
   15536                 :        1859 :                 grp_start_p = pc;
   15537                 :        1859 :                 grp_sentinel = OMP_CLAUSE_CHAIN (c);
   15538                 :             : 
   15539                 :        1859 :                 if (handle_omp_array_sections (c, ort))
   15540                 :             :                   remove = true;
   15541                 :             :                 else
   15542                 :             :                   {
   15543                 :        1720 :                     t = OMP_CLAUSE_DECL (c);
   15544                 :        1720 :                     if (!omp_mappable_type (TREE_TYPE (t)))
   15545                 :             :                       {
   15546                 :           2 :                         error_at (OMP_CLAUSE_LOCATION (c),
   15547                 :             :                                   "array section does not have mappable type "
   15548                 :             :                                   "in %qs clause",
   15549                 :           1 :                                   omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   15550                 :           1 :                         remove = true;
   15551                 :             :                       }
   15552                 :        1719 :                     else if (TYPE_ATOMIC (TREE_TYPE (t)))
   15553                 :             :                       {
   15554                 :           2 :                         error_at (OMP_CLAUSE_LOCATION (c),
   15555                 :             :                                   "%<_Atomic%> %qE in %qs clause", t,
   15556                 :           1 :                                   omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   15557                 :           1 :                         remove = true;
   15558                 :             :                       }
   15559                 :        2351 :                     while (TREE_CODE (t) == ARRAY_REF)
   15560                 :         631 :                       t = TREE_OPERAND (t, 0);
   15561                 :             : 
   15562                 :        1720 :                     c_omp_address_inspector ai (OMP_CLAUSE_LOCATION (c), t);
   15563                 :             : 
   15564                 :        1720 :                     if (!omp_parse_expr (addr_tokens, t))
   15565                 :             :                       {
   15566                 :           0 :                         sorry_at (OMP_CLAUSE_LOCATION (c),
   15567                 :             :                                   "unsupported map expression %qE",
   15568                 :           0 :                                   OMP_CLAUSE_DECL (c));
   15569                 :           0 :                         remove = true;
   15570                 :           0 :                         break;
   15571                 :             :                       }
   15572                 :             : 
   15573                 :             :                     /* This check is to determine if this will be the only map
   15574                 :             :                        node created for this clause.  Otherwise, we'll check
   15575                 :             :                        the following FIRSTPRIVATE_POINTER or ATTACH_DETACH
   15576                 :             :                        node on the next iteration(s) of the loop.   */
   15577                 :        3422 :                     if (addr_tokens.length () >= 4
   15578                 :         247 :                         && addr_tokens[0]->type == STRUCTURE_BASE
   15579                 :         247 :                         && addr_tokens[0]->u.structure_base_kind == BASE_DECL
   15580                 :         247 :                         && addr_tokens[1]->type == ACCESS_METHOD
   15581                 :         247 :                         && addr_tokens[2]->type == COMPONENT_SELECTOR
   15582                 :         247 :                         && addr_tokens[3]->type == ACCESS_METHOD
   15583                 :        1910 :                         && (addr_tokens[3]->u.access_kind == ACCESS_DIRECT
   15584                 :         138 :                             || (addr_tokens[3]->u.access_kind
   15585                 :             :                                 == ACCESS_INDEXED_ARRAY)))
   15586                 :             :                       {
   15587                 :          54 :                         tree rt = addr_tokens[1]->expr;
   15588                 :             : 
   15589                 :          54 :                         gcc_assert (DECL_P (rt));
   15590                 :             : 
   15591                 :          54 :                         if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP
   15592                 :          49 :                             && OMP_CLAUSE_MAP_IMPLICIT (c)
   15593                 :          54 :                             && (bitmap_bit_p (&map_head, DECL_UID (rt))
   15594                 :           0 :                                 || bitmap_bit_p (&map_field_head, DECL_UID (rt))
   15595                 :           0 :                                 || bitmap_bit_p (&map_firstprivate_head,
   15596                 :           0 :                                                  DECL_UID (rt))))
   15597                 :             :                           {
   15598                 :             :                             remove = true;
   15599                 :             :                             break;
   15600                 :             :                           }
   15601                 :          54 :                         if (bitmap_bit_p (&map_field_head, DECL_UID (rt)))
   15602                 :             :                           break;
   15603                 :          36 :                         if (bitmap_bit_p (&map_head, DECL_UID (rt)))
   15604                 :             :                           {
   15605                 :           0 :                             if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_MAP)
   15606                 :           0 :                               error_at (OMP_CLAUSE_LOCATION (c),
   15607                 :             :                                         "%qD appears more than once in motion "
   15608                 :             :                                         "clauses", rt);
   15609                 :           0 :                             else if (openacc)
   15610                 :           0 :                               error_at (OMP_CLAUSE_LOCATION (c),
   15611                 :             :                                         "%qD appears more than once in data "
   15612                 :             :                                         "clauses", rt);
   15613                 :             :                             else
   15614                 :           0 :                               error_at (OMP_CLAUSE_LOCATION (c),
   15615                 :             :                                         "%qD appears more than once in map "
   15616                 :             :                                         "clauses", rt);
   15617                 :             :                             remove = true;
   15618                 :             :                           }
   15619                 :             :                         else
   15620                 :             :                           {
   15621                 :          36 :                             bitmap_set_bit (&map_head, DECL_UID (rt));
   15622                 :          36 :                             bitmap_set_bit (&map_field_head, DECL_UID (rt));
   15623                 :             :                           }
   15624                 :             :                       }
   15625                 :        1720 :                   }
   15626                 :        1841 :                 if (c_oacc_check_attachments (c))
   15627                 :           2 :                   remove = true;
   15628                 :        1841 :                 if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP
   15629                 :        1677 :                     && (OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_ATTACH
   15630                 :        1666 :                         || OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_DETACH)
   15631                 :        1859 :                     && !OMP_CLAUSE_SIZE (c))
   15632                 :             :                   /* In this case, we have a single array element which is a
   15633                 :             :                      pointer, and we already set OMP_CLAUSE_SIZE in
   15634                 :             :                      handle_omp_array_sections above.  For attach/detach
   15635                 :             :                      clauses, reset the OMP_CLAUSE_SIZE (representing a bias)
   15636                 :             :                      to zero here.  */
   15637                 :          10 :                   OMP_CLAUSE_SIZE (c) = size_zero_node;
   15638                 :             :                 break;
   15639                 :             :               }
   15640                 :        7069 :             else if (!omp_parse_expr (addr_tokens, t))
   15641                 :             :               {
   15642                 :           0 :                 sorry_at (OMP_CLAUSE_LOCATION (c),
   15643                 :             :                           "unsupported map expression %qE",
   15644                 :           0 :                           OMP_CLAUSE_DECL (c));
   15645                 :           0 :                 remove = true;
   15646                 :           0 :                 break;
   15647                 :             :               }
   15648                 :        7069 :             if (t == error_mark_node)
   15649                 :             :               {
   15650                 :             :                 remove = true;
   15651                 :             :                 break;
   15652                 :             :               }
   15653                 :             :             /* OpenACC attach / detach clauses must be pointers.  */
   15654                 :        7063 :             if (c_oacc_check_attachments (c))
   15655                 :             :               {
   15656                 :             :                 remove = true;
   15657                 :             :                 break;
   15658                 :             :               }
   15659                 :        7059 :             if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP
   15660                 :        4242 :                 && (OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_ATTACH
   15661                 :        4221 :                     || OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_DETACH)
   15662                 :        7091 :                 && !OMP_CLAUSE_SIZE (c))
   15663                 :             :               /* For attach/detach clauses, set OMP_CLAUSE_SIZE (representing a
   15664                 :             :                  bias) to zero here, so it is not set erroneously to the pointer
   15665                 :             :                  size later on in gimplify.cc.  */
   15666                 :          28 :               OMP_CLAUSE_SIZE (c) = size_zero_node;
   15667                 :             : 
   15668                 :        7059 :             c_omp_address_inspector ai (OMP_CLAUSE_LOCATION (c), t);
   15669                 :             : 
   15670                 :        7059 :             if (!ai.check_clause (c))
   15671                 :             :               {
   15672                 :             :                 remove = true;
   15673                 :             :                 break;
   15674                 :             :               }
   15675                 :             : 
   15676                 :        7051 :             if (!ai.map_supported_p ())
   15677                 :             :               {
   15678                 :          10 :                 sorry_at (OMP_CLAUSE_LOCATION (c),
   15679                 :             :                           "unsupported map expression %qE",
   15680                 :           5 :                           OMP_CLAUSE_DECL (c));
   15681                 :           5 :                 remove = true;
   15682                 :           5 :                 break;
   15683                 :             :               }
   15684                 :             : 
   15685                 :       14092 :             gcc_assert ((addr_tokens[0]->type == ARRAY_BASE
   15686                 :             :                          || addr_tokens[0]->type == STRUCTURE_BASE)
   15687                 :             :                         && addr_tokens[1]->type == ACCESS_METHOD);
   15688                 :             : 
   15689                 :        7046 :             t = addr_tokens[1]->expr;
   15690                 :             : 
   15691                 :        7046 :             if (addr_tokens[0]->u.structure_base_kind != BASE_DECL)
   15692                 :           0 :               goto skip_decl_checks;
   15693                 :             : 
   15694                 :             :             /* For OpenMP, we can access a struct "t" and "t.d" on the same
   15695                 :             :                mapping.  OpenACC allows multiple fields of the same structure
   15696                 :             :                to be written.  */
   15697                 :        7046 :             if (addr_tokens[0]->type == STRUCTURE_BASE
   15698                 :        7046 :                 && (bitmap_bit_p (&map_field_head, DECL_UID (t))
   15699                 :         194 :                     || (!openacc && bitmap_bit_p (&map_head, DECL_UID (t)))))
   15700                 :         184 :               goto skip_decl_checks;
   15701                 :             : 
   15702                 :        6862 :             if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL)
   15703                 :             :               {
   15704                 :           3 :                 if (ort != C_ORT_ACC && EXPR_P (t))
   15705                 :             :                   break;
   15706                 :             : 
   15707                 :           6 :                 error_at (OMP_CLAUSE_LOCATION (c),
   15708                 :             :                           "%qE is not a variable in %qs clause", t,
   15709                 :           3 :                           omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   15710                 :           3 :                 remove = true;
   15711                 :             :               }
   15712                 :        6859 :             else if (VAR_P (t) && DECL_THREAD_LOCAL_P (t))
   15713                 :             :               {
   15714                 :           0 :                 error_at (OMP_CLAUSE_LOCATION (c),
   15715                 :             :                           "%qD is threadprivate variable in %qs clause", t,
   15716                 :           0 :                           omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   15717                 :           0 :                 remove = true;
   15718                 :             :               }
   15719                 :        6859 :             else if ((OMP_CLAUSE_CODE (c) != OMP_CLAUSE_MAP
   15720                 :        4049 :                       || (OMP_CLAUSE_MAP_KIND (c)
   15721                 :             :                           != GOMP_MAP_FIRSTPRIVATE_POINTER))
   15722                 :        9909 :                      && !c_mark_addressable (t))
   15723                 :             :               remove = true;
   15724                 :        6859 :             else if (!(OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP
   15725                 :        4049 :                        && (OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_POINTER
   15726                 :        4049 :                            || (OMP_CLAUSE_MAP_KIND (c)
   15727                 :             :                                == GOMP_MAP_FIRSTPRIVATE_POINTER)
   15728                 :        3050 :                            || (OMP_CLAUSE_MAP_KIND (c)
   15729                 :             :                                == GOMP_MAP_FORCE_DEVICEPTR)))
   15730                 :        5807 :                      && t == OMP_CLAUSE_DECL (c)
   15731                 :       12474 :                      && !omp_mappable_type (TREE_TYPE (t)))
   15732                 :             :               {
   15733                 :          16 :                 error_at (OMP_CLAUSE_LOCATION (c),
   15734                 :             :                           "%qD does not have a mappable type in %qs clause", t,
   15735                 :           8 :                           omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   15736                 :           8 :                 remove = true;
   15737                 :             :               }
   15738                 :        6851 :             else if (TREE_TYPE (t) == error_mark_node)
   15739                 :             :               remove = true;
   15740                 :        6850 :             else if (TYPE_ATOMIC (strip_array_types (TREE_TYPE (t))))
   15741                 :             :               {
   15742                 :           8 :                 error_at (OMP_CLAUSE_LOCATION (c),
   15743                 :             :                           "%<_Atomic%> %qE in %qs clause", t,
   15744                 :           4 :                           omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   15745                 :           4 :                 remove = true;
   15746                 :             :               }
   15747                 :        6846 :             else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP
   15748                 :        4039 :                      && OMP_CLAUSE_MAP_IMPLICIT (c)
   15749                 :        7007 :                      && (bitmap_bit_p (&map_head, DECL_UID (t))
   15750                 :         126 :                          || bitmap_bit_p (&map_field_head, DECL_UID (t))
   15751                 :         126 :                          || bitmap_bit_p (&map_firstprivate_head,
   15752                 :         126 :                                           DECL_UID (t))))
   15753                 :             :               remove = true;
   15754                 :        6810 :             else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP
   15755                 :        6810 :                      && (OMP_CLAUSE_MAP_KIND (c)
   15756                 :             :                          == GOMP_MAP_FIRSTPRIVATE_POINTER))
   15757                 :             :               {
   15758                 :         997 :                 if (bitmap_bit_p (&generic_head, DECL_UID (t))
   15759                 :         997 :                     || bitmap_bit_p (&firstprivate_head, DECL_UID (t))
   15760                 :        1993 :                     || bitmap_bit_p (&map_firstprivate_head, DECL_UID (t)))
   15761                 :             :                   {
   15762                 :           4 :                     error_at (OMP_CLAUSE_LOCATION (c),
   15763                 :             :                               "%qD appears more than once in data clauses", t);
   15764                 :           4 :                     remove = true;
   15765                 :             :                   }
   15766                 :         993 :                 else if (bitmap_bit_p (&map_head, DECL_UID (t))
   15767                 :           4 :                          && !bitmap_bit_p (&map_field_head, DECL_UID (t))
   15768                 :         995 :                          && openacc)
   15769                 :             :                   {
   15770                 :           1 :                     error_at (OMP_CLAUSE_LOCATION (c),
   15771                 :             :                               "%qD appears more than once in data clauses", t);
   15772                 :           1 :                     remove = true;
   15773                 :             :                   }
   15774                 :             :                 else
   15775                 :         992 :                   bitmap_set_bit (&map_firstprivate_head, DECL_UID (t));
   15776                 :             :               }
   15777                 :        5813 :             else if (bitmap_bit_p (&map_head, DECL_UID (t))
   15778                 :          50 :                      && !bitmap_bit_p (&map_field_head, DECL_UID (t))
   15779                 :          13 :                      && ort != C_ORT_OMP
   15780                 :        5826 :                      && ort != C_ORT_OMP_EXIT_DATA)
   15781                 :             :               {
   15782                 :          10 :                 if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_MAP)
   15783                 :           0 :                   error_at (OMP_CLAUSE_LOCATION (c),
   15784                 :             :                             "%qD appears more than once in motion clauses", t);
   15785                 :          10 :                 else if (openacc)
   15786                 :           7 :                   error_at (OMP_CLAUSE_LOCATION (c),
   15787                 :             :                             "%qD appears more than once in data clauses", t);
   15788                 :             :                 else
   15789                 :           3 :                   error_at (OMP_CLAUSE_LOCATION (c),
   15790                 :             :                             "%qD appears more than once in map clauses", t);
   15791                 :             :                 remove = true;
   15792                 :             :               }
   15793                 :        5803 :             else if (openacc && bitmap_bit_p (&generic_head, DECL_UID (t)))
   15794                 :             :               {
   15795                 :           0 :                 error_at (OMP_CLAUSE_LOCATION (c),
   15796                 :             :                           "%qD appears more than once in data clauses", t);
   15797                 :           0 :                 remove = true;
   15798                 :             :               }
   15799                 :        5803 :             else if (bitmap_bit_p (&firstprivate_head, DECL_UID (t))
   15800                 :        5803 :                      || bitmap_bit_p (&is_on_device_head, DECL_UID (t)))
   15801                 :             :               {
   15802                 :           9 :                 if (openacc)
   15803                 :           0 :                   error_at (OMP_CLAUSE_LOCATION (c),
   15804                 :             :                             "%qD appears more than once in data clauses", t);
   15805                 :             :                 else
   15806                 :           9 :                   error_at (OMP_CLAUSE_LOCATION (c),
   15807                 :             :                             "%qD appears both in data and map clauses", t);
   15808                 :             :                 remove = true;
   15809                 :             :               }
   15810                 :        5794 :             else if (!omp_access_chain_p (addr_tokens, 1))
   15811                 :             :               {
   15812                 :        5794 :                 bitmap_set_bit (&map_head, DECL_UID (t));
   15813                 :        5794 :                 if (t != OMP_CLAUSE_DECL (c)
   15814                 :        5794 :                     && TREE_CODE (OMP_CLAUSE_DECL (c)) == COMPONENT_REF)
   15815                 :         188 :                   bitmap_set_bit (&map_field_head, DECL_UID (t));
   15816                 :             :               }
   15817                 :             : 
   15818                 :           0 :           skip_decl_checks:
   15819                 :             :             /* If we call omp_expand_map_clause in handle_omp_array_sections,
   15820                 :             :                the containing loop (here) iterates through the new nodes
   15821                 :             :                created by that expansion.  Avoid expanding those again (just
   15822                 :             :                by checking the node type).  */
   15823                 :        7046 :             if (!remove
   15824                 :        7046 :                 && ort != C_ORT_DECLARE_SIMD
   15825                 :        7046 :                 && (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_MAP
   15826                 :        4157 :                     || (OMP_CLAUSE_MAP_KIND (c) != GOMP_MAP_FIRSTPRIVATE_POINTER
   15827                 :        3165 :                         && (OMP_CLAUSE_MAP_KIND (c)
   15828                 :             :                             != GOMP_MAP_FIRSTPRIVATE_REFERENCE)
   15829                 :        3165 :                         && OMP_CLAUSE_MAP_KIND (c) != GOMP_MAP_ALWAYS_POINTER
   15830                 :        3165 :                         && OMP_CLAUSE_MAP_KIND (c) != GOMP_MAP_ATTACH_DETACH
   15831                 :        2938 :                         && OMP_CLAUSE_MAP_KIND (c) != GOMP_MAP_ATTACH
   15832                 :        2917 :                         && OMP_CLAUSE_MAP_KIND (c) != GOMP_MAP_DETACH)))
   15833                 :             :               {
   15834                 :        5719 :                 grp_start_p = pc;
   15835                 :        5719 :                 grp_sentinel = OMP_CLAUSE_CHAIN (c);
   15836                 :        5719 :                 tree nc = ai.expand_map_clause (c, OMP_CLAUSE_DECL (c),
   15837                 :             :                                                 addr_tokens, ort);
   15838                 :        5719 :                 if (nc != error_mark_node)
   15839                 :        5719 :                   c = nc;
   15840                 :             :               }
   15841                 :        8941 :           }
   15842                 :        7046 :           break;
   15843                 :             : 
   15844                 :         213 :         case OMP_CLAUSE_ENTER:
   15845                 :         213 :         case OMP_CLAUSE_LINK:
   15846                 :         213 :           t = OMP_CLAUSE_DECL (c);
   15847                 :         213 :           const char *cname;
   15848                 :         213 :           cname = omp_clause_code_name[OMP_CLAUSE_CODE (c)];
   15849                 :         213 :           if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_ENTER
   15850                 :         213 :               && OMP_CLAUSE_ENTER_TO (c))
   15851                 :             :             cname = "to";
   15852                 :         213 :           if (TREE_CODE (t) == FUNCTION_DECL
   15853                 :         213 :               && OMP_CLAUSE_CODE (c) == OMP_CLAUSE_ENTER)
   15854                 :             :             ;
   15855                 :         136 :           else if (!VAR_P (t))
   15856                 :             :             {
   15857                 :           1 :               if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_ENTER)
   15858                 :           0 :                 error_at (OMP_CLAUSE_LOCATION (c),
   15859                 :             :                           "%qE is neither a variable nor a function name in "
   15860                 :             :                           "clause %qs", t, cname);
   15861                 :             :               else
   15862                 :           1 :                 error_at (OMP_CLAUSE_LOCATION (c),
   15863                 :             :                           "%qE is not a variable in clause %qs", t, cname);
   15864                 :             :               remove = true;
   15865                 :             :             }
   15866                 :         135 :           else if (DECL_THREAD_LOCAL_P (t))
   15867                 :             :             {
   15868                 :           2 :               error_at (OMP_CLAUSE_LOCATION (c),
   15869                 :             :                         "%qD is threadprivate variable in %qs clause", t,
   15870                 :             :                         cname);
   15871                 :           2 :               remove = true;
   15872                 :             :             }
   15873                 :         133 :           else if (!omp_mappable_type (TREE_TYPE (t)))
   15874                 :             :             {
   15875                 :           6 :               error_at (OMP_CLAUSE_LOCATION (c),
   15876                 :             :                         "%qD does not have a mappable type in %qs clause", t,
   15877                 :             :                         cname);
   15878                 :           6 :               remove = true;
   15879                 :             :             }
   15880                 :           8 :           if (remove)
   15881                 :             :             break;
   15882                 :         204 :           if (bitmap_bit_p (&generic_head, DECL_UID (t)))
   15883                 :             :             {
   15884                 :           8 :               error_at (OMP_CLAUSE_LOCATION (c),
   15885                 :             :                         "%qE appears more than once on the same "
   15886                 :             :                         "%<declare target%> directive", t);
   15887                 :           8 :               remove = true;
   15888                 :             :             }
   15889                 :             :           else
   15890                 :         196 :             bitmap_set_bit (&generic_head, DECL_UID (t));
   15891                 :             :           break;
   15892                 :             : 
   15893                 :         117 :         case OMP_CLAUSE_UNIFORM:
   15894                 :         117 :           t = OMP_CLAUSE_DECL (c);
   15895                 :         117 :           if (TREE_CODE (t) != PARM_DECL)
   15896                 :             :             {
   15897                 :           0 :               if (DECL_P (t))
   15898                 :           0 :                 error_at (OMP_CLAUSE_LOCATION (c),
   15899                 :             :                           "%qD is not an argument in %<uniform%> clause", t);
   15900                 :             :               else
   15901                 :           0 :                 error_at (OMP_CLAUSE_LOCATION (c),
   15902                 :             :                           "%qE is not an argument in %<uniform%> clause", t);
   15903                 :             :               remove = true;
   15904                 :             :               break;
   15905                 :             :             }
   15906                 :             :           /* map_head bitmap is used as uniform_head if declare_simd.  */
   15907                 :         117 :           bitmap_set_bit (&map_head, DECL_UID (t));
   15908                 :         117 :           goto check_dup_generic;
   15909                 :             : 
   15910                 :         123 :         case OMP_CLAUSE_IS_DEVICE_PTR:
   15911                 :         123 :         case OMP_CLAUSE_USE_DEVICE_PTR:
   15912                 :         123 :           t = OMP_CLAUSE_DECL (c);
   15913                 :         123 :           if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_IS_DEVICE_PTR)
   15914                 :          86 :             bitmap_set_bit (&is_on_device_head, DECL_UID (t));
   15915                 :         123 :           if (TREE_CODE (TREE_TYPE (t)) != POINTER_TYPE)
   15916                 :             :             {
   15917                 :          17 :               if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_USE_DEVICE_PTR
   15918                 :          17 :                   && !openacc)
   15919                 :             :                 {
   15920                 :           1 :                   error_at (OMP_CLAUSE_LOCATION (c),
   15921                 :             :                             "%qs variable is not a pointer",
   15922                 :           1 :                             omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   15923                 :           1 :                   remove = true;
   15924                 :             :                 }
   15925                 :          16 :               else if (TREE_CODE (TREE_TYPE (t)) != ARRAY_TYPE)
   15926                 :             :                 {
   15927                 :           3 :                   error_at (OMP_CLAUSE_LOCATION (c),
   15928                 :             :                             "%qs variable is neither a pointer nor an array",
   15929                 :           3 :                             omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   15930                 :           3 :                   remove = true;
   15931                 :             :                 }
   15932                 :             :             }
   15933                 :         123 :           goto check_dup_generic;
   15934                 :             : 
   15935                 :          87 :         case OMP_CLAUSE_HAS_DEVICE_ADDR:
   15936                 :          87 :           t = OMP_CLAUSE_DECL (c);
   15937                 :          87 :           if (TREE_CODE (t) == OMP_ARRAY_SECTION)
   15938                 :             :             {
   15939                 :          11 :               if (handle_omp_array_sections (c, ort))
   15940                 :             :                 remove = true;
   15941                 :             :               else
   15942                 :             :                 {
   15943                 :          11 :                   t = OMP_CLAUSE_DECL (c);
   15944                 :          24 :                   while (TREE_CODE (t) == ARRAY_REF)
   15945                 :          13 :                     t = TREE_OPERAND (t, 0);
   15946                 :             :                 }
   15947                 :             :             }
   15948                 :          87 :           bitmap_set_bit (&is_on_device_head, DECL_UID (t));
   15949                 :          87 :           if (VAR_P (t) || TREE_CODE (t) == PARM_DECL)
   15950                 :          87 :             c_mark_addressable (t);
   15951                 :          87 :           goto check_dup_generic_t;
   15952                 :             : 
   15953                 :          36 :         case OMP_CLAUSE_USE_DEVICE_ADDR:
   15954                 :          36 :           t = OMP_CLAUSE_DECL (c);
   15955                 :          36 :           if (VAR_P (t) || TREE_CODE (t) == PARM_DECL)
   15956                 :          36 :             c_mark_addressable (t);
   15957                 :          36 :           goto check_dup_generic;
   15958                 :             : 
   15959                 :        4576 :         case OMP_CLAUSE_NOWAIT:
   15960                 :        4576 :           if (copyprivate_seen)
   15961                 :             :             {
   15962                 :           1 :               error_at (OMP_CLAUSE_LOCATION (c),
   15963                 :             :                         "%<nowait%> clause must not be used together "
   15964                 :             :                         "with %<copyprivate%>");
   15965                 :           1 :               remove = true;
   15966                 :           1 :               break;
   15967                 :             :             }
   15968                 :        4575 :           nowait_clause = pc;
   15969                 :        4575 :           pc = &OMP_CLAUSE_CHAIN (c);
   15970                 :        4575 :           continue;
   15971                 :             : 
   15972                 :         522 :         case OMP_CLAUSE_ORDER:
   15973                 :         522 :           if (ordered_clause)
   15974                 :             :             {
   15975                 :           2 :               error_at (OMP_CLAUSE_LOCATION (c),
   15976                 :             :                         "%<order%> clause must not be used together "
   15977                 :             :                         "with %<ordered%>");
   15978                 :           2 :               remove = true;
   15979                 :           2 :               break;
   15980                 :             :             }
   15981                 :         520 :           else if (order_clause)
   15982                 :             :             {
   15983                 :             :               /* Silently remove duplicates.  */
   15984                 :             :               remove = true;
   15985                 :             :               break;
   15986                 :             :             }
   15987                 :         512 :           order_clause = pc;
   15988                 :         512 :           pc = &OMP_CLAUSE_CHAIN (c);
   15989                 :         512 :           continue;
   15990                 :             : 
   15991                 :          32 :         case OMP_CLAUSE_DETACH:
   15992                 :          32 :           t = OMP_CLAUSE_DECL (c);
   15993                 :          32 :           if (detach_seen)
   15994                 :             :             {
   15995                 :           1 :               error_at (OMP_CLAUSE_LOCATION (c),
   15996                 :             :                         "too many %qs clauses on a task construct",
   15997                 :             :                         "detach");
   15998                 :           1 :               remove = true;
   15999                 :           1 :               break;
   16000                 :             :             }
   16001                 :          31 :           detach_seen = pc;
   16002                 :          31 :           pc = &OMP_CLAUSE_CHAIN (c);
   16003                 :          31 :           c_mark_addressable (t);
   16004                 :          31 :           continue;
   16005                 :             : 
   16006                 :       14158 :         case OMP_CLAUSE_IF:
   16007                 :       14158 :         case OMP_CLAUSE_SELF:
   16008                 :       14158 :         case OMP_CLAUSE_NUM_THREADS:
   16009                 :       14158 :         case OMP_CLAUSE_NUM_TEAMS:
   16010                 :       14158 :         case OMP_CLAUSE_THREAD_LIMIT:
   16011                 :       14158 :         case OMP_CLAUSE_DEFAULT:
   16012                 :       14158 :         case OMP_CLAUSE_UNTIED:
   16013                 :       14158 :         case OMP_CLAUSE_COLLAPSE:
   16014                 :       14158 :         case OMP_CLAUSE_FINAL:
   16015                 :       14158 :         case OMP_CLAUSE_DEVICE:
   16016                 :       14158 :         case OMP_CLAUSE_DIST_SCHEDULE:
   16017                 :       14158 :         case OMP_CLAUSE_PARALLEL:
   16018                 :       14158 :         case OMP_CLAUSE_FOR:
   16019                 :       14158 :         case OMP_CLAUSE_SECTIONS:
   16020                 :       14158 :         case OMP_CLAUSE_TASKGROUP:
   16021                 :       14158 :         case OMP_CLAUSE_PROC_BIND:
   16022                 :       14158 :         case OMP_CLAUSE_DEVICE_TYPE:
   16023                 :       14158 :         case OMP_CLAUSE_PRIORITY:
   16024                 :       14158 :         case OMP_CLAUSE_GRAINSIZE:
   16025                 :       14158 :         case OMP_CLAUSE_NUM_TASKS:
   16026                 :       14158 :         case OMP_CLAUSE_THREADS:
   16027                 :       14158 :         case OMP_CLAUSE_SIMD:
   16028                 :       14158 :         case OMP_CLAUSE_HINT:
   16029                 :       14158 :         case OMP_CLAUSE_FILTER:
   16030                 :       14158 :         case OMP_CLAUSE_DEFAULTMAP:
   16031                 :       14158 :         case OMP_CLAUSE_BIND:
   16032                 :       14158 :         case OMP_CLAUSE_NUM_GANGS:
   16033                 :       14158 :         case OMP_CLAUSE_NUM_WORKERS:
   16034                 :       14158 :         case OMP_CLAUSE_VECTOR_LENGTH:
   16035                 :       14158 :         case OMP_CLAUSE_ASYNC:
   16036                 :       14158 :         case OMP_CLAUSE_WAIT:
   16037                 :       14158 :         case OMP_CLAUSE_AUTO:
   16038                 :       14158 :         case OMP_CLAUSE_INDEPENDENT:
   16039                 :       14158 :         case OMP_CLAUSE_SEQ:
   16040                 :       14158 :         case OMP_CLAUSE_GANG:
   16041                 :       14158 :         case OMP_CLAUSE_WORKER:
   16042                 :       14158 :         case OMP_CLAUSE_VECTOR:
   16043                 :       14158 :         case OMP_CLAUSE_TILE:
   16044                 :       14158 :         case OMP_CLAUSE_IF_PRESENT:
   16045                 :       14158 :         case OMP_CLAUSE_FINALIZE:
   16046                 :       14158 :         case OMP_CLAUSE_NOHOST:
   16047                 :       14158 :         case OMP_CLAUSE_INDIRECT:
   16048                 :       14158 :           pc = &OMP_CLAUSE_CHAIN (c);
   16049                 :       14158 :           continue;
   16050                 :             : 
   16051                 :          78 :         case OMP_CLAUSE_MERGEABLE:
   16052                 :          78 :           mergeable_seen = true;
   16053                 :          78 :           pc = &OMP_CLAUSE_CHAIN (c);
   16054                 :          78 :           continue;
   16055                 :             : 
   16056                 :          18 :         case OMP_CLAUSE_NOGROUP:
   16057                 :          18 :           nogroup_seen = pc;
   16058                 :          18 :           pc = &OMP_CLAUSE_CHAIN (c);
   16059                 :          18 :           continue;
   16060                 :             : 
   16061                 :        3447 :         case OMP_CLAUSE_SCHEDULE:
   16062                 :        3447 :           schedule_clause = c;
   16063                 :        3447 :           pc = &OMP_CLAUSE_CHAIN (c);
   16064                 :        3447 :           continue;
   16065                 :             : 
   16066                 :         285 :         case OMP_CLAUSE_ORDERED:
   16067                 :         285 :           ordered_clause = c;
   16068                 :         285 :           if (order_clause)
   16069                 :             :             {
   16070                 :           2 :               error_at (OMP_CLAUSE_LOCATION (*order_clause),
   16071                 :             :                         "%<order%> clause must not be used together "
   16072                 :             :                         "with %<ordered%>");
   16073                 :           2 :               *order_clause = OMP_CLAUSE_CHAIN (*order_clause);
   16074                 :           2 :               order_clause = NULL;
   16075                 :             :             }
   16076                 :         285 :           pc = &OMP_CLAUSE_CHAIN (c);
   16077                 :         285 :           continue;
   16078                 :             : 
   16079                 :         223 :         case OMP_CLAUSE_SAFELEN:
   16080                 :         223 :           safelen = c;
   16081                 :         223 :           pc = &OMP_CLAUSE_CHAIN (c);
   16082                 :         223 :           continue;
   16083                 :         311 :         case OMP_CLAUSE_SIMDLEN:
   16084                 :         311 :           simdlen = c;
   16085                 :         311 :           pc = &OMP_CLAUSE_CHAIN (c);
   16086                 :         311 :           continue;
   16087                 :             : 
   16088                 :         196 :         case OMP_CLAUSE_INBRANCH:
   16089                 :         196 :         case OMP_CLAUSE_NOTINBRANCH:
   16090                 :         196 :           if (branch_seen)
   16091                 :             :             {
   16092                 :           1 :               error_at (OMP_CLAUSE_LOCATION (c),
   16093                 :             :                         "%<inbranch%> clause is incompatible with "
   16094                 :             :                         "%<notinbranch%>");
   16095                 :           1 :               remove = true;
   16096                 :           1 :               break;
   16097                 :             :             }
   16098                 :         195 :           branch_seen = true;
   16099                 :         195 :           pc = &OMP_CLAUSE_CHAIN (c);
   16100                 :         195 :           continue;
   16101                 :             : 
   16102                 :         367 :         case OMP_CLAUSE_INCLUSIVE:
   16103                 :         367 :         case OMP_CLAUSE_EXCLUSIVE:
   16104                 :         367 :           need_complete = true;
   16105                 :         367 :           need_implicitly_determined = true;
   16106                 :         367 :           t = OMP_CLAUSE_DECL (c);
   16107                 :         367 :           if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL)
   16108                 :             :             {
   16109                 :           0 :               error_at (OMP_CLAUSE_LOCATION (c),
   16110                 :             :                         "%qE is not a variable in clause %qs", t,
   16111                 :           0 :                         omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   16112                 :           0 :               remove = true;
   16113                 :             :             }
   16114                 :             :           break;
   16115                 :             : 
   16116                 :           0 :         default:
   16117                 :           0 :           gcc_unreachable ();
   16118                 :       23833 :         }
   16119                 :             : 
   16120                 :       21401 :       if (!remove)
   16121                 :             :         {
   16122                 :       20885 :           t = OMP_CLAUSE_DECL (c);
   16123                 :             : 
   16124                 :       20885 :           if (need_complete)
   16125                 :             :             {
   16126                 :        3871 :               t = require_complete_type (OMP_CLAUSE_LOCATION (c), t);
   16127                 :        3871 :               if (t == error_mark_node)
   16128                 :           7 :                 remove = true;
   16129                 :             :             }
   16130                 :             : 
   16131                 :       20885 :           if (need_implicitly_determined)
   16132                 :             :             {
   16133                 :        9213 :               const char *share_name = NULL;
   16134                 :             : 
   16135                 :        9213 :               if (VAR_P (t) && DECL_THREAD_LOCAL_P (t))
   16136                 :             :                 share_name = "threadprivate";
   16137                 :        9207 :               else switch (c_omp_predetermined_sharing (t))
   16138                 :             :                 {
   16139                 :             :                 case OMP_CLAUSE_DEFAULT_UNSPECIFIED:
   16140                 :             :                   break;
   16141                 :          20 :                 case OMP_CLAUSE_DEFAULT_SHARED:
   16142                 :          20 :                   if ((OMP_CLAUSE_CODE (c) == OMP_CLAUSE_SHARED
   16143                 :          12 :                        || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_FIRSTPRIVATE)
   16144                 :          28 :                       && c_omp_predefined_variable (t))
   16145                 :             :                     /* The __func__ variable and similar function-local
   16146                 :             :                        predefined variables may be listed in a shared or
   16147                 :             :                        firstprivate clause.  */
   16148                 :             :                     break;
   16149                 :             :                   share_name = "shared";
   16150                 :             :                   break;
   16151                 :             :                 case OMP_CLAUSE_DEFAULT_PRIVATE:
   16152                 :             :                   share_name = "private";
   16153                 :             :                   break;
   16154                 :           0 :                 default:
   16155                 :           0 :                   gcc_unreachable ();
   16156                 :             :                 }
   16157                 :             :               if (share_name)
   16158                 :             :                 {
   16159                 :          20 :                   error_at (OMP_CLAUSE_LOCATION (c),
   16160                 :             :                             "%qE is predetermined %qs for %qs",
   16161                 :             :                             t, share_name,
   16162                 :          10 :                             omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   16163                 :          10 :                   remove = true;
   16164                 :             :                 }
   16165                 :        9203 :               else if (TREE_READONLY (t)
   16166                 :          23 :                        && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_SHARED
   16167                 :        9216 :                        && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_FIRSTPRIVATE)
   16168                 :             :                 {
   16169                 :           4 :                   error_at (OMP_CLAUSE_LOCATION (c),
   16170                 :             :                             "%<const%> qualified %qE may appear only in "
   16171                 :             :                             "%<shared%> or %<firstprivate%> clauses", t);
   16172                 :           4 :                   remove = true;
   16173                 :             :                 }
   16174                 :             :             }
   16175                 :             :         }
   16176                 :             : 
   16177                 :       20885 :       if (remove)
   16178                 :             :         {
   16179                 :         537 :           if (grp_start_p)
   16180                 :             :             {
   16181                 :             :               /* If we found a clause to remove, we want to remove the whole
   16182                 :             :                  expanded group, otherwise gimplify
   16183                 :             :                  (omp_resolve_clause_dependencies) can get confused.  */
   16184                 :         152 :               *grp_start_p = grp_sentinel;
   16185                 :         152 :               pc = grp_start_p;
   16186                 :         152 :               grp_start_p = NULL;
   16187                 :             :             }
   16188                 :             :           else
   16189                 :         385 :             *pc = OMP_CLAUSE_CHAIN (c);
   16190                 :             :         }
   16191                 :             :       else
   16192                 :       20864 :         pc = &OMP_CLAUSE_CHAIN (c);
   16193                 :             :     }
   16194                 :             : 
   16195                 :       27372 :   if (simdlen
   16196                 :       27372 :       && safelen
   16197                 :       27489 :       && tree_int_cst_lt (OMP_CLAUSE_SAFELEN_EXPR (safelen),
   16198                 :         117 :                           OMP_CLAUSE_SIMDLEN_EXPR (simdlen)))
   16199                 :             :     {
   16200                 :           0 :       error_at (OMP_CLAUSE_LOCATION (simdlen),
   16201                 :             :                 "%<simdlen%> clause value is bigger than "
   16202                 :             :                 "%<safelen%> clause value");
   16203                 :           0 :       OMP_CLAUSE_SIMDLEN_EXPR (simdlen)
   16204                 :           0 :         = OMP_CLAUSE_SAFELEN_EXPR (safelen);
   16205                 :             :     }
   16206                 :             : 
   16207                 :       27372 :   if (ordered_clause
   16208                 :       27372 :       && schedule_clause
   16209                 :       27372 :       && (OMP_CLAUSE_SCHEDULE_KIND (schedule_clause)
   16210                 :             :           & OMP_CLAUSE_SCHEDULE_NONMONOTONIC))
   16211                 :             :     {
   16212                 :           7 :       error_at (OMP_CLAUSE_LOCATION (schedule_clause),
   16213                 :             :                 "%<nonmonotonic%> schedule modifier specified together "
   16214                 :             :                 "with %<ordered%> clause");
   16215                 :          14 :       OMP_CLAUSE_SCHEDULE_KIND (schedule_clause)
   16216                 :           7 :         = (enum omp_clause_schedule_kind)
   16217                 :           7 :           (OMP_CLAUSE_SCHEDULE_KIND (schedule_clause)
   16218                 :             :            & ~OMP_CLAUSE_SCHEDULE_NONMONOTONIC);
   16219                 :             :     }
   16220                 :             : 
   16221                 :       27372 :   if (reduction_seen < 0 && ordered_clause)
   16222                 :             :     {
   16223                 :           2 :       error_at (OMP_CLAUSE_LOCATION (ordered_clause),
   16224                 :             :                 "%qs clause specified together with %<inscan%> "
   16225                 :             :                 "%<reduction%> clause", "ordered");
   16226                 :           2 :       reduction_seen = -2;
   16227                 :             :     }
   16228                 :             : 
   16229                 :       27372 :   if (reduction_seen < 0 && schedule_clause)
   16230                 :             :     {
   16231                 :           3 :       error_at (OMP_CLAUSE_LOCATION (schedule_clause),
   16232                 :             :                 "%qs clause specified together with %<inscan%> "
   16233                 :             :                 "%<reduction%> clause", "schedule");
   16234                 :           3 :       reduction_seen = -2;
   16235                 :             :     }
   16236                 :             : 
   16237                 :       27372 :   if (linear_variable_step_check
   16238                 :       27372 :       || reduction_seen == -2
   16239                 :             :       || allocate_seen
   16240                 :       27360 :       || target_in_reduction_seen)
   16241                 :        5130 :     for (pc = &clauses, c = clauses; c ; c = *pc)
   16242                 :             :       {
   16243                 :        4546 :         bool remove = false;
   16244                 :        4546 :         if (allocate_seen)
   16245                 :        4388 :           switch (OMP_CLAUSE_CODE (c))
   16246                 :             :             {
   16247                 :         430 :             case OMP_CLAUSE_REDUCTION:
   16248                 :         430 :             case OMP_CLAUSE_IN_REDUCTION:
   16249                 :         430 :             case OMP_CLAUSE_TASK_REDUCTION:
   16250                 :         430 :               if (TREE_CODE (OMP_CLAUSE_DECL (c)) == MEM_REF)
   16251                 :             :                 {
   16252                 :          23 :                   t = TREE_OPERAND (OMP_CLAUSE_DECL (c), 0);
   16253                 :          23 :                   if (TREE_CODE (t) == POINTER_PLUS_EXPR)
   16254                 :           0 :                     t = TREE_OPERAND (t, 0);
   16255                 :          23 :                   if (TREE_CODE (t) == ADDR_EXPR
   16256                 :          10 :                       || INDIRECT_REF_P (t))
   16257                 :          13 :                     t = TREE_OPERAND (t, 0);
   16258                 :          23 :                   if (DECL_P (t))
   16259                 :          23 :                     bitmap_clear_bit (&aligned_head, DECL_UID (t));
   16260                 :             :                   break;
   16261                 :             :                 }
   16262                 :             :               /* FALLTHRU */
   16263                 :        1297 :             case OMP_CLAUSE_PRIVATE:
   16264                 :        1297 :             case OMP_CLAUSE_FIRSTPRIVATE:
   16265                 :        1297 :             case OMP_CLAUSE_LASTPRIVATE:
   16266                 :        1297 :             case OMP_CLAUSE_LINEAR:
   16267                 :        1297 :               if (DECL_P (OMP_CLAUSE_DECL (c)))
   16268                 :        2594 :                 bitmap_clear_bit (&aligned_head,
   16269                 :        1297 :                                   DECL_UID (OMP_CLAUSE_DECL (c)));
   16270                 :             :               break;
   16271                 :             :             default:
   16272                 :             :               break;
   16273                 :             :             }
   16274                 :        4546 :         if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_LINEAR
   16275                 :          29 :             && OMP_CLAUSE_LINEAR_VARIABLE_STRIDE (c)
   16276                 :        4553 :             && !bitmap_bit_p (&map_head,
   16277                 :           7 :                               DECL_UID (OMP_CLAUSE_LINEAR_STEP (c))))
   16278                 :             :           {
   16279                 :           2 :             error_at (OMP_CLAUSE_LOCATION (c),
   16280                 :             :                       "%<linear%> clause step is a parameter %qD not "
   16281                 :             :                       "specified in %<uniform%> clause",
   16282                 :           2 :                       OMP_CLAUSE_LINEAR_STEP (c));
   16283                 :           2 :             remove = true;
   16284                 :             :           }
   16285                 :        4544 :         else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION
   16286                 :        4544 :                  && reduction_seen == -2)
   16287                 :           9 :           OMP_CLAUSE_REDUCTION_INSCAN (c) = 0;
   16288                 :        4546 :         if (target_in_reduction_seen
   16289                 :        4546 :             && OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP)
   16290                 :             :           {
   16291                 :         256 :             tree t = OMP_CLAUSE_DECL (c);
   16292                 :         256 :             while (handled_component_p (t)
   16293                 :             :                    || INDIRECT_REF_P (t)
   16294                 :             :                    || TREE_CODE (t) == ADDR_EXPR
   16295                 :             :                    || TREE_CODE (t) == MEM_REF
   16296                 :         288 :                    || TREE_CODE (t) == NON_LVALUE_EXPR)
   16297                 :          32 :               t = TREE_OPERAND (t, 0);
   16298                 :         256 :             if (DECL_P (t)
   16299                 :         256 :                 && bitmap_bit_p (&oacc_reduction_head, DECL_UID (t)))
   16300                 :         138 :               OMP_CLAUSE_MAP_IN_REDUCTION (c) = 1;
   16301                 :             :           }
   16302                 :             : 
   16303                 :        4546 :         if (remove)
   16304                 :           2 :           *pc = OMP_CLAUSE_CHAIN (c);
   16305                 :             :         else
   16306                 :        4544 :           pc = &OMP_CLAUSE_CHAIN (c);
   16307                 :             :       }
   16308                 :             : 
   16309                 :         584 :   if (allocate_seen)
   16310                 :        4946 :     for (pc = &clauses, c = clauses; c ; c = *pc)
   16311                 :             :       {
   16312                 :        4388 :         bool remove = false;
   16313                 :        4388 :         if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_ALLOCATE
   16314                 :         699 :             && !OMP_CLAUSE_ALLOCATE_COMBINED (c)
   16315                 :        5067 :             && bitmap_bit_p (&aligned_head, DECL_UID (OMP_CLAUSE_DECL (c))))
   16316                 :             :           {
   16317                 :           3 :             error_at (OMP_CLAUSE_LOCATION (c),
   16318                 :             :                       "%qD specified in %<allocate%> clause but not in "
   16319                 :           3 :                       "an explicit privatization clause", OMP_CLAUSE_DECL (c));
   16320                 :           3 :             remove = true;
   16321                 :             :           }
   16322                 :        4388 :         if (remove)
   16323                 :           3 :           *pc = OMP_CLAUSE_CHAIN (c);
   16324                 :             :         else
   16325                 :        4385 :           pc = &OMP_CLAUSE_CHAIN (c);
   16326                 :             :       }
   16327                 :             : 
   16328                 :       27372 :   if (nogroup_seen && reduction_seen)
   16329                 :             :     {
   16330                 :           1 :       error_at (OMP_CLAUSE_LOCATION (*nogroup_seen),
   16331                 :             :                 "%<nogroup%> clause must not be used together with "
   16332                 :             :                 "%<reduction%> clause");
   16333                 :           1 :       *nogroup_seen = OMP_CLAUSE_CHAIN (*nogroup_seen);
   16334                 :             :     }
   16335                 :             : 
   16336                 :       27372 :   if (detach_seen)
   16337                 :             :     {
   16338                 :          31 :       if (mergeable_seen)
   16339                 :             :         {
   16340                 :           2 :           error_at (OMP_CLAUSE_LOCATION (*detach_seen),
   16341                 :             :                     "%<detach%> clause must not be used together with "
   16342                 :             :                     "%<mergeable%> clause");
   16343                 :           2 :           *detach_seen = OMP_CLAUSE_CHAIN (*detach_seen);
   16344                 :             :         }
   16345                 :             :       else
   16346                 :             :         {
   16347                 :          29 :           tree detach_decl = OMP_CLAUSE_DECL (*detach_seen);
   16348                 :             : 
   16349                 :          79 :           for (pc = &clauses, c = clauses; c ; c = *pc)
   16350                 :             :             {
   16351                 :          50 :               bool remove = false;
   16352                 :          50 :               if ((OMP_CLAUSE_CODE (c) == OMP_CLAUSE_SHARED
   16353                 :          48 :                    || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_PRIVATE
   16354                 :          48 :                    || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_FIRSTPRIVATE
   16355                 :          44 :                    || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_LASTPRIVATE)
   16356                 :          54 :                   && OMP_CLAUSE_DECL (c) == detach_decl)
   16357                 :             :                 {
   16358                 :           2 :                   error_at (OMP_CLAUSE_LOCATION (c),
   16359                 :             :                             "the event handle of a %<detach%> clause "
   16360                 :             :                             "should not be in a data-sharing clause");
   16361                 :           2 :                   remove = true;
   16362                 :             :                 }
   16363                 :          50 :               if (remove)
   16364                 :           2 :                 *pc = OMP_CLAUSE_CHAIN (c);
   16365                 :             :               else
   16366                 :          48 :                 pc = &OMP_CLAUSE_CHAIN (c);
   16367                 :             :             }
   16368                 :             :         }
   16369                 :             :     }
   16370                 :             : 
   16371                 :       27372 :   bitmap_obstack_release (NULL);
   16372                 :       27372 :   return clauses;
   16373                 :             : }
   16374                 :             : 
   16375                 :             : /* Return code to initialize DST with a copy constructor from SRC.
   16376                 :             :    C doesn't have copy constructors nor assignment operators, only for
   16377                 :             :    _Atomic vars we need to perform __atomic_load from src into a temporary
   16378                 :             :    followed by __atomic_store of the temporary to dst.  */
   16379                 :             : 
   16380                 :             : tree
   16381                 :       17877 : c_omp_clause_copy_ctor (tree clause, tree dst, tree src)
   16382                 :             : {
   16383                 :       17877 :   if (!really_atomic_lvalue (dst) && !really_atomic_lvalue (src))
   16384                 :       17873 :     return build2 (MODIFY_EXPR, TREE_TYPE (dst), dst, src);
   16385                 :             : 
   16386                 :           4 :   location_t loc = OMP_CLAUSE_LOCATION (clause);
   16387                 :           4 :   tree type = TREE_TYPE (dst);
   16388                 :           4 :   tree nonatomic_type = build_qualified_type (type, TYPE_UNQUALIFIED);
   16389                 :           4 :   tree tmp = create_tmp_var (nonatomic_type);
   16390                 :           4 :   tree tmp_addr = build_fold_addr_expr (tmp);
   16391                 :           4 :   TREE_ADDRESSABLE (tmp) = 1;
   16392                 :           4 :   suppress_warning (tmp);
   16393                 :           4 :   tree src_addr = build_fold_addr_expr (src);
   16394                 :           4 :   tree dst_addr = build_fold_addr_expr (dst);
   16395                 :           4 :   tree seq_cst = build_int_cst (integer_type_node, MEMMODEL_SEQ_CST);
   16396                 :           4 :   vec<tree, va_gc> *params;
   16397                 :             :   /* Expansion of a generic atomic load may require an addition
   16398                 :             :      element, so allocate enough to prevent a resize.  */
   16399                 :           4 :   vec_alloc (params, 4);
   16400                 :             : 
   16401                 :             :   /* Build __atomic_load (&src, &tmp, SEQ_CST);  */
   16402                 :           4 :   tree fndecl = builtin_decl_explicit (BUILT_IN_ATOMIC_LOAD);
   16403                 :           4 :   params->quick_push (src_addr);
   16404                 :           4 :   params->quick_push (tmp_addr);
   16405                 :           4 :   params->quick_push (seq_cst);
   16406                 :           4 :   tree load = c_build_function_call_vec (loc, vNULL, fndecl, params, NULL);
   16407                 :             : 
   16408                 :           4 :   vec_alloc (params, 4);
   16409                 :             : 
   16410                 :             :   /* Build __atomic_store (&dst, &tmp, SEQ_CST);  */
   16411                 :           4 :   fndecl = builtin_decl_explicit (BUILT_IN_ATOMIC_STORE);
   16412                 :           4 :   params->quick_push (dst_addr);
   16413                 :           4 :   params->quick_push (tmp_addr);
   16414                 :           4 :   params->quick_push (seq_cst);
   16415                 :           4 :   tree store = c_build_function_call_vec (loc, vNULL, fndecl, params, NULL);
   16416                 :           4 :   return build2 (COMPOUND_EXPR, void_type_node, load, store);
   16417                 :             : }
   16418                 :             : 
   16419                 :             : /* Create a transaction node.  */
   16420                 :             : 
   16421                 :             : tree
   16422                 :         135 : c_finish_transaction (location_t loc, tree block, int flags)
   16423                 :             : {
   16424                 :         135 :   tree stmt = build_stmt (loc, TRANSACTION_EXPR, block);
   16425                 :         135 :   if (flags & TM_STMT_ATTR_OUTER)
   16426                 :          10 :     TRANSACTION_EXPR_OUTER (stmt) = 1;
   16427                 :         135 :   if (flags & TM_STMT_ATTR_RELAXED)
   16428                 :          31 :     TRANSACTION_EXPR_RELAXED (stmt) = 1;
   16429                 :         135 :   return add_stmt (stmt);
   16430                 :             : }
   16431                 :             : 
   16432                 :             : /* Make a variant type in the proper way for C/C++, propagating qualifiers
   16433                 :             :    down to the element type of an array.  If ORIG_QUAL_TYPE is not
   16434                 :             :    NULL, then it should be used as the qualified type
   16435                 :             :    ORIG_QUAL_INDIRECT levels down in array type derivation (to
   16436                 :             :    preserve information about the typedef name from which an array
   16437                 :             :    type was derived).  */
   16438                 :             : 
   16439                 :             : tree
   16440                 :    60715814 : c_build_qualified_type (tree type, int type_quals, tree orig_qual_type,
   16441                 :             :                         size_t orig_qual_indirect)
   16442                 :             : {
   16443                 :    60715814 :   if (type == error_mark_node)
   16444                 :             :     return type;
   16445                 :             : 
   16446                 :    60715671 :   if (TREE_CODE (type) == ARRAY_TYPE)
   16447                 :             :     {
   16448                 :     2887256 :       tree t;
   16449                 :     2887256 :       tree element_type = c_build_qualified_type (TREE_TYPE (type),
   16450                 :             :                                                   type_quals, orig_qual_type,
   16451                 :             :                                                   orig_qual_indirect - 1);
   16452                 :             : 
   16453                 :             :       /* See if we already have an identically qualified type.  */
   16454                 :     2887256 :       if (orig_qual_type && orig_qual_indirect == 0)
   16455                 :             :         t = orig_qual_type;
   16456                 :             :       else
   16457                 :     4138365 :         for (t = TYPE_MAIN_VARIANT (type); t; t = TYPE_NEXT_VARIANT (t))
   16458                 :             :           {
   16459                 :     4020053 :             if (TYPE_QUALS (strip_array_types (t)) == type_quals
   16460                 :     2789226 :                 && TYPE_NAME (t) == TYPE_NAME (type)
   16461                 :     2768915 :                 && TYPE_CONTEXT (t) == TYPE_CONTEXT (type)
   16462                 :     6788968 :                 && attribute_list_equal (TYPE_ATTRIBUTES (t),
   16463                 :     2768915 :                                          TYPE_ATTRIBUTES (type)))
   16464                 :             :               break;
   16465                 :             :           }
   16466                 :     2887227 :       if (!t)
   16467                 :             :         {
   16468                 :      118312 :           tree domain = TYPE_DOMAIN (type);
   16469                 :             : 
   16470                 :      118312 :           t = build_variant_type_copy (type);
   16471                 :      118312 :           TREE_TYPE (t) = element_type;
   16472                 :      118312 :           TYPE_ADDR_SPACE (t) = TYPE_ADDR_SPACE (element_type);
   16473                 :             : 
   16474                 :      118312 :           if (TYPE_STRUCTURAL_EQUALITY_P (element_type)
   16475                 :      118312 :               || (domain && TYPE_STRUCTURAL_EQUALITY_P (domain)))
   16476                 :         179 :             SET_TYPE_STRUCTURAL_EQUALITY (t);
   16477                 :      118133 :           else if (TYPE_CANONICAL (element_type) != element_type
   16478                 :      118133 :                    || (domain && TYPE_CANONICAL (domain) != domain))
   16479                 :             :             {
   16480                 :        2058 :               tree unqualified_canon
   16481                 :        3915 :                 = build_array_type (TYPE_CANONICAL (element_type),
   16482                 :        1857 :                                     domain? TYPE_CANONICAL (domain)
   16483                 :             :                                           : NULL_TREE);
   16484                 :        2058 :               if (TYPE_REVERSE_STORAGE_ORDER (type))
   16485                 :             :                 {
   16486                 :           0 :                   unqualified_canon
   16487                 :           0 :                     = build_distinct_type_copy (unqualified_canon);
   16488                 :           0 :                   TYPE_REVERSE_STORAGE_ORDER (unqualified_canon) = 1;
   16489                 :             :                 }
   16490                 :        2058 :               TYPE_CANONICAL (t)
   16491                 :        4116 :                 = c_build_qualified_type (unqualified_canon, type_quals);
   16492                 :             :             }
   16493                 :             :           else
   16494                 :      116075 :             TYPE_CANONICAL (t) = t;
   16495                 :             :         }
   16496                 :     2887256 :       return t;
   16497                 :             :     }
   16498                 :             : 
   16499                 :             :   /* A restrict-qualified pointer type must be a pointer to object or
   16500                 :             :      incomplete type.  Note that the use of POINTER_TYPE_P also allows
   16501                 :             :      REFERENCE_TYPEs, which is appropriate for C++.  */
   16502                 :    57828415 :   if ((type_quals & TYPE_QUAL_RESTRICT)
   16503                 :    57828415 :       && (!POINTER_TYPE_P (type)
   16504                 :     3004830 :           || !C_TYPE_OBJECT_OR_INCOMPLETE_P (TREE_TYPE (type))))
   16505                 :             :     {
   16506                 :           3 :       error ("invalid use of %<restrict%>");
   16507                 :           3 :       type_quals &= ~TYPE_QUAL_RESTRICT;
   16508                 :             :     }
   16509                 :             : 
   16510                 :    57828415 :   tree var_type = (orig_qual_type && orig_qual_indirect == 0
   16511                 :    57828415 :                    ? orig_qual_type
   16512                 :    57828401 :                    : build_qualified_type (type, type_quals));
   16513                 :             :   /* A variant type does not inherit the list of incomplete vars from the
   16514                 :             :      type main variant.  */
   16515                 :    57828415 :   if ((RECORD_OR_UNION_TYPE_P (var_type)
   16516                 :    56157982 :        || TREE_CODE (var_type) == ENUMERAL_TYPE)
   16517                 :    57903975 :       && TYPE_MAIN_VARIANT (var_type) != var_type)
   16518                 :     1191090 :     C_TYPE_INCOMPLETE_VARS (var_type) = 0;
   16519                 :             :   return var_type;
   16520                 :             : }
   16521                 :             : 
   16522                 :             : /* Build a VA_ARG_EXPR for the C parser.  */
   16523                 :             : 
   16524                 :             : tree
   16525                 :       19895 : c_build_va_arg (location_t loc1, tree expr, location_t loc2, tree type)
   16526                 :             : {
   16527                 :       19895 :   if (error_operand_p (type))
   16528                 :           2 :     return error_mark_node;
   16529                 :             :   /* VA_ARG_EXPR cannot be used for a scalar va_list with reverse storage
   16530                 :             :      order because it takes the address of the expression.  */
   16531                 :       19893 :   else if (handled_component_p (expr)
   16532                 :          31 :            && reverse_storage_order_for_component_p (expr))
   16533                 :             :     {
   16534                 :           0 :       error_at (loc1, "cannot use %<va_arg%> with reverse storage order");
   16535                 :           0 :       return error_mark_node;
   16536                 :             :     }
   16537                 :       19893 :   else if (!COMPLETE_TYPE_P (type))
   16538                 :             :     {
   16539                 :          11 :       error_at (loc2, "second argument to %<va_arg%> is of incomplete "
   16540                 :             :                 "type %qT", type);
   16541                 :          11 :       return error_mark_node;
   16542                 :             :     }
   16543                 :       19882 :   else if (TREE_CODE (type) == FUNCTION_TYPE)
   16544                 :             :     {
   16545                 :           1 :       error_at (loc2, "second argument to %<va_arg%> is a function type %qT",
   16546                 :             :                 type);
   16547                 :           1 :       return error_mark_node;
   16548                 :             :     }
   16549                 :       19881 :   else if (warn_cxx_compat && TREE_CODE (type) == ENUMERAL_TYPE)
   16550                 :           1 :     warning_at (loc2, OPT_Wc___compat,
   16551                 :             :                 "C++ requires promoted type, not enum type, in %<va_arg%>");
   16552                 :       19881 :   return build_va_arg (loc2, expr, type);
   16553                 :             : }
   16554                 :             : 
   16555                 :             : /* Return truthvalue of whether T1 is the same tree structure as T2.
   16556                 :             :    Return 1 if they are the same. Return false if they are different.  */
   16557                 :             : 
   16558                 :             : bool
   16559                 :        1854 : c_tree_equal (tree t1, tree t2)
   16560                 :             : {
   16561                 :        1883 :   enum tree_code code1, code2;
   16562                 :             : 
   16563                 :        1883 :   if (t1 == t2)
   16564                 :             :     return true;
   16565                 :         661 :   if (!t1 || !t2)
   16566                 :             :     return false;
   16567                 :             : 
   16568                 :         681 :   for (code1 = TREE_CODE (t1); code1 == NON_LVALUE_EXPR;
   16569                 :          20 :        code1 = TREE_CODE (t1))
   16570                 :          20 :     t1 = TREE_OPERAND (t1, 0);
   16571                 :         682 :   for (code2 = TREE_CODE (t2); code2 == NON_LVALUE_EXPR;
   16572                 :          21 :        code2 = TREE_CODE (t2))
   16573                 :          21 :     t2 = TREE_OPERAND (t2, 0);
   16574                 :             : 
   16575                 :             :   /* They might have become equal now.  */
   16576                 :         661 :   if (t1 == t2)
   16577                 :             :     return true;
   16578                 :             : 
   16579                 :         640 :   if (code1 != code2)
   16580                 :             :     return false;
   16581                 :             : 
   16582                 :         379 :   if (CONSTANT_CLASS_P (t1) && !comptypes (TREE_TYPE (t1), TREE_TYPE (t2)))
   16583                 :             :     return false;
   16584                 :             : 
   16585                 :         379 :   switch (code1)
   16586                 :             :     {
   16587                 :           2 :     case INTEGER_CST:
   16588                 :           2 :       return wi::to_wide (t1) == wi::to_wide (t2);
   16589                 :             : 
   16590                 :          10 :     case REAL_CST:
   16591                 :          10 :       return real_equal (&TREE_REAL_CST (t1), &TREE_REAL_CST (t2));
   16592                 :             : 
   16593                 :           0 :     case STRING_CST:
   16594                 :           0 :       return TREE_STRING_LENGTH (t1) == TREE_STRING_LENGTH (t2)
   16595                 :           0 :         && !memcmp (TREE_STRING_POINTER (t1), TREE_STRING_POINTER (t2),
   16596                 :           0 :                     TREE_STRING_LENGTH (t1));
   16597                 :             : 
   16598                 :           0 :     case FIXED_CST:
   16599                 :           0 :       return FIXED_VALUES_IDENTICAL (TREE_FIXED_CST (t1),
   16600                 :             :                                      TREE_FIXED_CST (t2));
   16601                 :             : 
   16602                 :           0 :     case COMPLEX_CST:
   16603                 :           0 :       return c_tree_equal (TREE_REALPART (t1), TREE_REALPART (t2))
   16604                 :           0 :              && c_tree_equal (TREE_IMAGPART (t1), TREE_IMAGPART (t2));
   16605                 :             : 
   16606                 :           0 :     case VECTOR_CST:
   16607                 :           0 :       return operand_equal_p (t1, t2, OEP_ONLY_CONST);
   16608                 :             : 
   16609                 :           0 :     case CONSTRUCTOR:
   16610                 :             :       /* We need to do this when determining whether or not two
   16611                 :             :          non-type pointer to member function template arguments
   16612                 :             :          are the same.  */
   16613                 :           0 :       if (!comptypes (TREE_TYPE (t1), TREE_TYPE (t2))
   16614                 :           0 :           || CONSTRUCTOR_NELTS (t1) != CONSTRUCTOR_NELTS (t2))
   16615                 :             :         return false;
   16616                 :             :       {
   16617                 :             :         tree field, value;
   16618                 :             :         unsigned int i;
   16619                 :           0 :         FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (t1), i, field, value)
   16620                 :             :           {
   16621                 :           0 :             constructor_elt *elt2 = CONSTRUCTOR_ELT (t2, i);
   16622                 :           0 :             if (!c_tree_equal (field, elt2->index)
   16623                 :           0 :                 || !c_tree_equal (value, elt2->value))
   16624                 :           0 :               return false;
   16625                 :             :           }
   16626                 :             :       }
   16627                 :             :       return true;
   16628                 :             : 
   16629                 :           0 :     case TREE_LIST:
   16630                 :           0 :       if (!c_tree_equal (TREE_PURPOSE (t1), TREE_PURPOSE (t2)))
   16631                 :             :         return false;
   16632                 :           0 :       if (!c_tree_equal (TREE_VALUE (t1), TREE_VALUE (t2)))
   16633                 :             :         return false;
   16634                 :           0 :       return c_tree_equal (TREE_CHAIN (t1), TREE_CHAIN (t2));
   16635                 :             : 
   16636                 :           0 :     case SAVE_EXPR:
   16637                 :           0 :       return c_tree_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0));
   16638                 :             : 
   16639                 :          25 :     case CALL_EXPR:
   16640                 :          25 :       {
   16641                 :          25 :         tree arg1, arg2;
   16642                 :          25 :         call_expr_arg_iterator iter1, iter2;
   16643                 :          25 :         if (!c_tree_equal (CALL_EXPR_FN (t1), CALL_EXPR_FN (t2)))
   16644                 :             :           return false;
   16645                 :          50 :         for (arg1 = first_call_expr_arg (t1, &iter1),
   16646                 :          25 :                arg2 = first_call_expr_arg (t2, &iter2);
   16647                 :          25 :              arg1 && arg2;
   16648                 :           0 :              arg1 = next_call_expr_arg (&iter1),
   16649                 :           0 :                arg2 = next_call_expr_arg (&iter2))
   16650                 :           0 :           if (!c_tree_equal (arg1, arg2))
   16651                 :             :             return false;
   16652                 :          25 :         if (arg1 || arg2)
   16653                 :             :           return false;
   16654                 :             :         return true;
   16655                 :             :       }
   16656                 :             : 
   16657                 :           0 :     case TARGET_EXPR:
   16658                 :           0 :       {
   16659                 :           0 :         tree o1 = TREE_OPERAND (t1, 0);
   16660                 :           0 :         tree o2 = TREE_OPERAND (t2, 0);
   16661                 :             : 
   16662                 :             :         /* Special case: if either target is an unallocated VAR_DECL,
   16663                 :             :            it means that it's going to be unified with whatever the
   16664                 :             :            TARGET_EXPR is really supposed to initialize, so treat it
   16665                 :             :            as being equivalent to anything.  */
   16666                 :           0 :         if (VAR_P (o1) && DECL_NAME (o1) == NULL_TREE
   16667                 :           0 :             && !DECL_RTL_SET_P (o1))
   16668                 :             :           /*Nop*/;
   16669                 :           0 :         else if (VAR_P (o2) && DECL_NAME (o2) == NULL_TREE
   16670                 :           0 :                  && !DECL_RTL_SET_P (o2))
   16671                 :             :           /*Nop*/;
   16672                 :           0 :         else if (!c_tree_equal (o1, o2))
   16673                 :             :           return false;
   16674                 :             : 
   16675                 :           0 :         return c_tree_equal (TREE_OPERAND (t1, 1), TREE_OPERAND (t2, 1));
   16676                 :             :       }
   16677                 :             : 
   16678                 :          29 :     case COMPONENT_REF:
   16679                 :          29 :       if (TREE_OPERAND (t1, 1) != TREE_OPERAND (t2, 1))
   16680                 :             :         return false;
   16681                 :          29 :       return c_tree_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0));
   16682                 :             : 
   16683                 :             :     case PARM_DECL:
   16684                 :             :     case VAR_DECL:
   16685                 :             :     case CONST_DECL:
   16686                 :             :     case FIELD_DECL:
   16687                 :             :     case FUNCTION_DECL:
   16688                 :             :     case IDENTIFIER_NODE:
   16689                 :             :     case SSA_NAME:
   16690                 :             :       return false;
   16691                 :             : 
   16692                 :           0 :     case TREE_VEC:
   16693                 :           0 :       {
   16694                 :           0 :         unsigned ix;
   16695                 :           0 :         if (TREE_VEC_LENGTH (t1) != TREE_VEC_LENGTH (t2))
   16696                 :             :           return false;
   16697                 :           0 :         for (ix = TREE_VEC_LENGTH (t1); ix--;)
   16698                 :           0 :           if (!c_tree_equal (TREE_VEC_ELT (t1, ix),
   16699                 :           0 :                              TREE_VEC_ELT (t2, ix)))
   16700                 :             :             return false;
   16701                 :             :         return true;
   16702                 :             :       }
   16703                 :             : 
   16704                 :          22 :     CASE_CONVERT:
   16705                 :          22 :       if (!comptypes (TREE_TYPE (t1), TREE_TYPE (t2)))
   16706                 :             :         return false;
   16707                 :             :       break;
   16708                 :             : 
   16709                 :             :     default:
   16710                 :             :       break;
   16711                 :             :     }
   16712                 :             : 
   16713                 :         131 :   switch (TREE_CODE_CLASS (code1))
   16714                 :             :     {
   16715                 :         131 :     case tcc_unary:
   16716                 :         131 :     case tcc_binary:
   16717                 :         131 :     case tcc_comparison:
   16718                 :         131 :     case tcc_expression:
   16719                 :         131 :     case tcc_vl_exp:
   16720                 :         131 :     case tcc_reference:
   16721                 :         131 :     case tcc_statement:
   16722                 :         131 :       {
   16723                 :         131 :         int i, n = TREE_OPERAND_LENGTH (t1);
   16724                 :             : 
   16725                 :         131 :         switch (code1)
   16726                 :             :           {
   16727                 :           0 :           case PREINCREMENT_EXPR:
   16728                 :           0 :           case PREDECREMENT_EXPR:
   16729                 :           0 :           case POSTINCREMENT_EXPR:
   16730                 :           0 :           case POSTDECREMENT_EXPR:
   16731                 :           0 :             n = 1;
   16732                 :           0 :             break;
   16733                 :          16 :           case ARRAY_REF:
   16734                 :          16 :             n = 2;
   16735                 :          16 :             break;
   16736                 :             :           default:
   16737                 :             :             break;
   16738                 :             :           }
   16739                 :             : 
   16740                 :         131 :         if (TREE_CODE_CLASS (code1) == tcc_vl_exp
   16741                 :         131 :             && n != TREE_OPERAND_LENGTH (t2))
   16742                 :             :           return false;
   16743                 :             : 
   16744                 :         305 :         for (i = 0; i < n; ++i)
   16745                 :         186 :           if (!c_tree_equal (TREE_OPERAND (t1, i), TREE_OPERAND (t2, i)))
   16746                 :             :             return false;
   16747                 :             : 
   16748                 :             :         return true;
   16749                 :             :       }
   16750                 :             : 
   16751                 :           0 :     case tcc_type:
   16752                 :           0 :       return comptypes (t1, t2);
   16753                 :           0 :     default:
   16754                 :           0 :       gcc_unreachable ();
   16755                 :             :     }
   16756                 :             : }
   16757                 :             : 
   16758                 :             : /* Returns true when the function declaration FNDECL is implicit,
   16759                 :             :    introduced as a result of a call to an otherwise undeclared
   16760                 :             :    function, and false otherwise.  */
   16761                 :             : 
   16762                 :             : bool
   16763                 :        2013 : c_decl_implicit (const_tree fndecl)
   16764                 :             : {
   16765                 :        2013 :   return C_DECL_IMPLICIT (fndecl);
   16766                 :             : }
        

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.