LCOV - code coverage report
Current view: top level - gcc/c - c-typeck.cc (source / functions) Coverage Total Hit
Test: gcc.info Lines: 93.6 % 8881 8312
Test Date: 2025-06-21 16:26:05 Functions: 99.5 % 194 193
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-2025 Free Software Foundation, Inc.
       3                 :             : 
       4                 :             : This file is part of GCC.
       5                 :             : 
       6                 :             : GCC is free software; you can redistribute it and/or modify it under
       7                 :             : the terms of the GNU General Public License as published by the Free
       8                 :             : Software Foundation; either version 3, or (at your option) any later
       9                 :             : version.
      10                 :             : 
      11                 :             : GCC is distributed in the hope that it will be useful, but WITHOUT ANY
      12                 :             : WARRANTY; without even the implied warranty of MERCHANTABILITY or
      13                 :             : FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
      14                 :             : for more details.
      15                 :             : 
      16                 :             : You should have received a copy of the GNU General Public License
      17                 :             : along with GCC; see the file COPYING3.  If not see
      18                 :             : <http://www.gnu.org/licenses/>.  */
      19                 :             : 
      20                 :             : 
      21                 :             : /* This file is part of the C front end.
      22                 :             :    It contains routines to build C expressions given their operands,
      23                 :             :    including computing the types of the result, C-specific error checks,
      24                 :             :    and some optimization.  */
      25                 :             : 
      26                 :             : #include "config.h"
      27                 :             : #include "system.h"
      28                 :             : #include "coretypes.h"
      29                 :             : #include "memmodel.h"
      30                 :             : #include "target.h"
      31                 :             : #include "function.h"
      32                 :             : #include "bitmap.h"
      33                 :             : #include "c-tree.h"
      34                 :             : #include "gimple-expr.h"
      35                 :             : #include "predict.h"
      36                 :             : #include "stor-layout.h"
      37                 :             : #include "trans-mem.h"
      38                 :             : #include "varasm.h"
      39                 :             : #include "stmt.h"
      40                 :             : #include "langhooks.h"
      41                 :             : #include "c-lang.h"
      42                 :             : #include "intl.h"
      43                 :             : #include "tree-iterator.h"
      44                 :             : #include "gimplify.h"
      45                 :             : #include "tree-inline.h"
      46                 :             : #include "omp-general.h"
      47                 :             : #include "c-family/c-objc.h"
      48                 :             : #include "c-family/c-ubsan.h"
      49                 :             : #include "gomp-constants.h"
      50                 :             : #include "spellcheck-tree.h"
      51                 :             : #include "c-family/c-type-mismatch.h"
      52                 :             : #include "stringpool.h"
      53                 :             : #include "attribs.h"
      54                 :             : #include "asan.h"
      55                 :             : #include "realmpfr.h"
      56                 :             : #include "tree-pretty-print-markup.h"
      57                 :             : #include "gcc-urlifier.h"
      58                 :             : 
      59                 :             : /* Possible cases of implicit conversions.  Used to select diagnostic messages
      60                 :             :    and control folding initializers in convert_for_assignment.  */
      61                 :             : enum impl_conv {
      62                 :             :   ic_argpass,
      63                 :             :   ic_assign,
      64                 :             :   ic_init,
      65                 :             :   ic_init_const,
      66                 :             :   ic_return
      67                 :             : };
      68                 :             : 
      69                 :             : /* The level of nesting inside "__alignof__".  */
      70                 :             : int in_alignof;
      71                 :             : 
      72                 :             : /* The level of nesting inside "sizeof".  */
      73                 :             : int in_sizeof;
      74                 :             : 
      75                 :             : /* The level of nesting inside "countof".  */
      76                 :             : int in_countof;
      77                 :             : 
      78                 :             : /* The level of nesting inside "typeof".  */
      79                 :             : int in_typeof;
      80                 :             : 
      81                 :             : /* True when parsing OpenMP loop expressions.  */
      82                 :             : bool c_in_omp_for;
      83                 :             : 
      84                 :             : /* True when parsing OpenMP map clause.  */
      85                 :             : bool c_omp_array_section_p;
      86                 :             : 
      87                 :             : /* The argument of last parsed sizeof expression, only to be tested
      88                 :             :    if expr.original_code == SIZEOF_EXPR.  */
      89                 :             : tree c_last_sizeof_arg;
      90                 :             : location_t c_last_sizeof_loc;
      91                 :             : 
      92                 :             : /* Nonzero if we might need to print a "missing braces around
      93                 :             :    initializer" message within this initializer.  */
      94                 :             : static int found_missing_braces;
      95                 :             : 
      96                 :             : static bool require_constant_value;
      97                 :             : static bool require_constant_elements;
      98                 :             : static bool require_constexpr_value;
      99                 :             : 
     100                 :             : static tree qualify_type (tree, tree);
     101                 :             : struct comptypes_data;
     102                 :             : static bool tagged_types_tu_compatible_p (const_tree, const_tree,
     103                 :             :                                           struct comptypes_data *);
     104                 :             : static bool comp_target_types (location_t, tree, tree);
     105                 :             : static bool function_types_compatible_p (const_tree, const_tree,
     106                 :             :                                          struct comptypes_data *);
     107                 :             : static bool type_lists_compatible_p (const_tree, const_tree,
     108                 :             :                                      struct comptypes_data *);
     109                 :             : static int convert_arguments (location_t, vec<location_t>, tree,
     110                 :             :                               vec<tree, va_gc> *, vec<tree, va_gc> *, tree,
     111                 :             :                               tree);
     112                 :             : static tree pointer_diff (location_t, tree, tree, tree *);
     113                 :             : static tree convert_for_assignment (location_t, location_t, tree, tree, tree,
     114                 :             :                                     enum impl_conv, bool, tree, tree, int,
     115                 :             :                                     int = 0);
     116                 :             : static tree valid_compound_expr_initializer (tree, tree);
     117                 :             : static void push_string (const char *);
     118                 :             : static void push_member_name (tree);
     119                 :             : static int spelling_length (void);
     120                 :             : static char *print_spelling (char *);
     121                 :             : static void warning_init (location_t, int, const char *);
     122                 :             : static tree digest_init (location_t, tree, tree, tree, tree, bool, bool, bool,
     123                 :             :                          bool, bool, bool);
     124                 :             : static void output_init_element (location_t, tree, tree, bool, tree, tree, bool,
     125                 :             :                                  bool, struct obstack *);
     126                 :             : static void output_pending_init_elements (int, struct obstack *);
     127                 :             : static bool set_designator (location_t, bool, struct obstack *);
     128                 :             : static void push_range_stack (tree, struct obstack *);
     129                 :             : static void add_pending_init (location_t, tree, tree, tree, bool,
     130                 :             :                               struct obstack *);
     131                 :             : static void set_nonincremental_init (struct obstack *);
     132                 :             : static void set_nonincremental_init_from_string (tree, struct obstack *);
     133                 :             : static tree find_init_member (tree, struct obstack *);
     134                 :             : static void readonly_warning (tree, enum lvalue_use);
     135                 :             : static int lvalue_or_else (location_t, const_tree, enum lvalue_use);
     136                 :             : static void record_maybe_used_decl (tree);
     137                 :             : static bool comptypes_internal (const_tree, const_tree,
     138                 :             :                                 struct comptypes_data *data);
     139                 :             : static bool comptypes_check_for_composite (tree t1, tree t2);
     140                 :             : 
     141                 :             : /* Return true if EXP is a null pointer constant, false otherwise.  */
     142                 :             : 
     143                 :             : bool
     144                 :   183822121 : null_pointer_constant_p (const_tree expr)
     145                 :             : {
     146                 :             :   /* This should really operate on c_expr structures, but they aren't
     147                 :             :      yet available everywhere required.  */
     148                 :   183822121 :   tree type = TREE_TYPE (expr);
     149                 :             : 
     150                 :             :   /* An integer constant expression with the value 0, such an expression
     151                 :             :      cast to type void*, or the predefined constant nullptr, are a null
     152                 :             :      pointer constant.  */
     153                 :   183822121 :   if (expr == nullptr_node)
     154                 :             :     return true;
     155                 :             : 
     156                 :   183821481 :   return (TREE_CODE (expr) == INTEGER_CST
     157                 :    18652125 :           && !TREE_OVERFLOW (expr)
     158                 :    18652028 :           && integer_zerop (expr)
     159                 :   187671442 :           && (INTEGRAL_TYPE_P (type)
     160                 :      329233 :               || (TREE_CODE (type) == POINTER_TYPE
     161                 :      329231 :                   && VOID_TYPE_P (TREE_TYPE (type))
     162                 :      254163 :                   && TYPE_QUALS (TREE_TYPE (type)) == TYPE_UNQUALIFIED)));
     163                 :             : }
     164                 :             : 
     165                 :             : /* EXPR may appear in an unevaluated part of an integer constant
     166                 :             :    expression, but not in an evaluated part.  Wrap it in a
     167                 :             :    C_MAYBE_CONST_EXPR, or mark it with TREE_OVERFLOW if it is just an
     168                 :             :    INTEGER_CST and we cannot create a C_MAYBE_CONST_EXPR.  */
     169                 :             : 
     170                 :             : static tree
     171                 :       62358 : note_integer_operands (tree expr)
     172                 :             : {
     173                 :       62358 :   tree ret;
     174                 :       62358 :   if (TREE_CODE (expr) == INTEGER_CST && in_late_binary_op)
     175                 :             :     {
     176                 :          22 :       ret = copy_node (expr);
     177                 :          22 :       TREE_OVERFLOW (ret) = 1;
     178                 :             :     }
     179                 :             :   else
     180                 :             :     {
     181                 :       62336 :       ret = build2 (C_MAYBE_CONST_EXPR, TREE_TYPE (expr), NULL_TREE, expr);
     182                 :       62336 :       C_MAYBE_CONST_EXPR_INT_OPERANDS (ret) = 1;
     183                 :             :     }
     184                 :       62358 :   return ret;
     185                 :             : }
     186                 :             : 
     187                 :             : /* Having checked whether EXPR may appear in an unevaluated part of an
     188                 :             :    integer constant expression and found that it may, remove any
     189                 :             :    C_MAYBE_CONST_EXPR noting this fact and return the resulting
     190                 :             :    expression.  */
     191                 :             : 
     192                 :             : static inline tree
     193                 :    32905136 : remove_c_maybe_const_expr (tree expr)
     194                 :             : {
     195                 :    32905136 :   if (TREE_CODE (expr) == C_MAYBE_CONST_EXPR)
     196                 :       61506 :     return C_MAYBE_CONST_EXPR_EXPR (expr);
     197                 :             :   else
     198                 :             :     return expr;
     199                 :             : }
     200                 :             : 
     201                 :             : /* This is a cache to hold if two types are seen.  */
     202                 :             : 
     203                 :             : struct tagged_tu_seen_cache {
     204                 :             :   const struct tagged_tu_seen_cache * next;
     205                 :             :   const_tree t1;
     206                 :             :   const_tree t2;
     207                 :             : };
     208                 :             : 
     209                 :             : /* Do `exp = require_complete_type (loc, exp);' to make sure exp
     210                 :             :    does not have an incomplete type.  (That includes void types.)
     211                 :             :    LOC is the location of the use.  */
     212                 :             : 
     213                 :             : tree
     214                 :   752408863 : require_complete_type (location_t loc, tree value)
     215                 :             : {
     216                 :   752408863 :   tree type = TREE_TYPE (value);
     217                 :             : 
     218                 :   752408863 :   if (error_operand_p (value))
     219                 :        9024 :     return error_mark_node;
     220                 :             : 
     221                 :             :   /* First, detect a valid value with a complete type.  */
     222                 :   752399839 :   if (COMPLETE_TYPE_P (type))
     223                 :             :     return value;
     224                 :             : 
     225                 :         142 :   c_incomplete_type_error (loc, value, type);
     226                 :         142 :   return error_mark_node;
     227                 :             : }
     228                 :             : 
     229                 :             : /* Print an error message for invalid use of an incomplete type.
     230                 :             :    VALUE is the expression that was used (or 0 if that isn't known)
     231                 :             :    and TYPE is the type that was invalid.  LOC is the location for
     232                 :             :    the error.  */
     233                 :             : 
     234                 :             : void
     235                 :         198 : c_incomplete_type_error (location_t loc, const_tree value, const_tree type)
     236                 :             : {
     237                 :             :   /* Avoid duplicate error message.  */
     238                 :         198 :   if (TREE_CODE (type) == ERROR_MARK)
     239                 :             :     return;
     240                 :             : 
     241                 :         198 :   if (value != NULL_TREE && (VAR_P (value) || TREE_CODE (value) == PARM_DECL))
     242                 :          88 :     error_at (loc, "%qD has an incomplete type %qT", value, type);
     243                 :             :   else
     244                 :             :     {
     245                 :         110 :     retry:
     246                 :             :       /* We must print an error message.  Be clever about what it says.  */
     247                 :             : 
     248                 :         110 :       switch (TREE_CODE (type))
     249                 :             :         {
     250                 :          70 :         case RECORD_TYPE:
     251                 :          70 :         case UNION_TYPE:
     252                 :          70 :         case ENUMERAL_TYPE:
     253                 :          70 :           break;
     254                 :             : 
     255                 :          34 :         case VOID_TYPE:
     256                 :          34 :           error_at (loc, "invalid use of void expression");
     257                 :          34 :           return;
     258                 :             : 
     259                 :           6 :         case ARRAY_TYPE:
     260                 :           6 :           if (TYPE_DOMAIN (type))
     261                 :             :             {
     262                 :           3 :               if (TYPE_MAX_VALUE (TYPE_DOMAIN (type)) == NULL)
     263                 :             :                 {
     264                 :           3 :                   error_at (loc, "invalid use of flexible array member");
     265                 :           3 :                   return;
     266                 :             :                 }
     267                 :           0 :               type = TREE_TYPE (type);
     268                 :           0 :               goto retry;
     269                 :             :             }
     270                 :           3 :           error_at (loc, "invalid use of array with unspecified bounds");
     271                 :           3 :           return;
     272                 :             : 
     273                 :           0 :         default:
     274                 :           0 :           gcc_unreachable ();
     275                 :             :         }
     276                 :             : 
     277                 :          70 :       if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
     278                 :          68 :         error_at (loc, "invalid use of undefined type %qT", type);
     279                 :             :       else
     280                 :             :         /* If this type has a typedef-name, the TYPE_NAME is a TYPE_DECL.  */
     281                 :           2 :         error_at (loc, "invalid use of incomplete typedef %qT", type);
     282                 :             :     }
     283                 :             : }
     284                 :             : 
     285                 :             : /* Given a type, apply default promotions wrt unnamed function
     286                 :             :    arguments and return the new type.  */
     287                 :             : 
     288                 :             : tree
     289                 :   120588506 : c_type_promotes_to (tree type)
     290                 :             : {
     291                 :   120588506 :   tree ret = NULL_TREE;
     292                 :             : 
     293                 :   120588506 :   if (TYPE_MAIN_VARIANT (type) == float_type_node)
     294                 :     1383988 :     ret = double_type_node;
     295                 :   119204518 :   else if (c_promoting_integer_type_p (type))
     296                 :             :     {
     297                 :             :       /* Preserve unsignedness if not really getting any wider.  */
     298                 :    18174376 :       if (TYPE_UNSIGNED (type)
     299                 :    18174376 :           && (TYPE_PRECISION (type) == TYPE_PRECISION (integer_type_node)))
     300                 :           0 :         ret = unsigned_type_node;
     301                 :             :       else
     302                 :    18174376 :         ret = integer_type_node;
     303                 :             :     }
     304                 :             : 
     305                 :    19558364 :   if (ret != NULL_TREE)
     306                 :    19558364 :     return (TYPE_ATOMIC (type)
     307                 :    19558364 :             ? c_build_qualified_type (ret, TYPE_QUAL_ATOMIC)
     308                 :             :             : ret);
     309                 :             : 
     310                 :             :   return type;
     311                 :             : }
     312                 :             : 
     313                 :             : /* Return true if between two named address spaces, whether there is a superset
     314                 :             :    named address space that encompasses both address spaces.  If there is a
     315                 :             :    superset, return which address space is the superset.  */
     316                 :             : 
     317                 :             : static bool
     318                 :     7068405 : addr_space_superset (addr_space_t as1, addr_space_t as2, addr_space_t *common)
     319                 :             : {
     320                 :     7068405 :   if (as1 == as2)
     321                 :             :     {
     322                 :     7068405 :       *common = as1;
     323                 :     7068405 :       return true;
     324                 :             :     }
     325                 :           0 :   else if (targetm.addr_space.subset_p (as1, as2))
     326                 :             :     {
     327                 :           0 :       *common = as2;
     328                 :           0 :       return true;
     329                 :             :     }
     330                 :           0 :   else if (targetm.addr_space.subset_p (as2, as1))
     331                 :             :     {
     332                 :           0 :       *common = as1;
     333                 :           0 :       return true;
     334                 :             :     }
     335                 :             :   else
     336                 :             :     return false;
     337                 :             : }
     338                 :             : 
     339                 :             : /* Return a variant of TYPE which has all the type qualifiers of LIKE
     340                 :             :    as well as those of TYPE.  */
     341                 :             : 
     342                 :             : static tree
     343                 :     2394492 : qualify_type (tree type, tree like)
     344                 :             : {
     345                 :     2394492 :   addr_space_t as_type = TYPE_ADDR_SPACE (type);
     346                 :     2394492 :   addr_space_t as_like = TYPE_ADDR_SPACE (like);
     347                 :     2394492 :   addr_space_t as_common;
     348                 :             : 
     349                 :             :   /* If the two named address spaces are different, determine the common
     350                 :             :      superset address space.  If there isn't one, raise an error.  */
     351                 :     2394492 :   if (!addr_space_superset (as_type, as_like, &as_common))
     352                 :             :     {
     353                 :           0 :       as_common = as_type;
     354                 :           0 :       error ("%qT and %qT are in disjoint named address spaces",
     355                 :             :              type, like);
     356                 :             :     }
     357                 :             : 
     358                 :     4788984 :   return c_build_qualified_type (type,
     359                 :     2394492 :                                  TYPE_QUALS_NO_ADDR_SPACE (type)
     360                 :     2394492 :                                  | TYPE_QUALS_NO_ADDR_SPACE_NO_ATOMIC (like)
     361                 :     2394492 :                                  | ENCODE_QUAL_ADDR_SPACE (as_common));
     362                 :             : }
     363                 :             : 
     364                 :             : 
     365                 :             : /* Check consistency of type TYPE.  For derived types, we test that
     366                 :             :    C_TYPE_VARIABLE_SIZE and C_TYPE_VARIABLY_MODIFIED are consistent with
     367                 :             :    the requirements of the base type.  We also check that arrays with a
     368                 :             :    non-constant length are marked with C_TYPE_VARIABLE_SIZE. If any
     369                 :             :    inconsistency is detected false is returned and true otherwise.  */
     370                 :             : 
     371                 :             : static bool
     372                 :   135416967 : c_verify_type (tree type)
     373                 :             : {
     374                 :   135416967 :   switch (TREE_CODE (type))
     375                 :             :     {
     376                 :    63669645 :     case POINTER_TYPE:
     377                 :    63669645 :     case FUNCTION_TYPE:
     378                 :             :       /* Pointer and funcions can not have variable size.  */
     379                 :    63669645 :       if (C_TYPE_VARIABLE_SIZE (type))
     380                 :             :         return false;
     381                 :             :       /* Pointer and funcions are variably modified if and only if the
     382                 :             :          return / target type is variably modified.  */
     383                 :    63669645 :       if (C_TYPE_VARIABLY_MODIFIED (type)
     384                 :    63669645 :           != C_TYPE_VARIABLY_MODIFIED (TREE_TYPE (type)))
     385                 :           0 :         return false;
     386                 :             :       break;
     387                 :      892357 :     case ARRAY_TYPE:
     388                 :             :       /* An array has variable size if and only if it has a non-constant
     389                 :             :          dimensions or its element type has variable size.  */
     390                 :      892357 :       if ((C_TYPE_VARIABLE_SIZE (TREE_TYPE (type))
     391                 :      892357 :            || (TYPE_DOMAIN (type) && TYPE_MAX_VALUE (TYPE_DOMAIN (type))
     392                 :      867171 :                && TREE_CODE (TYPE_MAX_VALUE (TYPE_DOMAIN (type)))
     393                 :             :                   != INTEGER_CST))
     394                 :      892357 :           != C_TYPE_VARIABLE_SIZE (type))
     395                 :             :         return false;
     396                 :             :       /* If the element type or the array has variable size, then the
     397                 :             :          array has variable size and is variably modified.  */
     398                 :      892357 :       if (C_TYPE_VARIABLE_SIZE (TREE_TYPE (type))
     399                 :      892357 :           || C_TYPE_VARIABLE_SIZE (type))
     400                 :             :         {
     401                 :       27568 :           if (!C_TYPE_VARIABLE_SIZE (type))
     402                 :             :             return false;
     403                 :       27568 :           if (!C_TYPE_VARIABLY_MODIFIED (type))
     404                 :             :             return false;
     405                 :             :         }
     406                 :             :       /* If the element type is variably modified, then also the array.  */
     407                 :      892357 :       if (C_TYPE_VARIABLY_MODIFIED (TREE_TYPE (type))
     408                 :      892357 :           && !C_TYPE_VARIABLY_MODIFIED (type))
     409                 :           0 :         return false;
     410                 :             :       break;
     411                 :             :     default:
     412                 :             :       break;
     413                 :             :     }
     414                 :             :   return true;
     415                 :             : }
     416                 :             : 
     417                 :             : /* Propagate C_TYPE_VARIABLY_MODIFIED and C_TYPE_VARIABLE_SIZE
     418                 :             :    from a base type to a newly built derived or qualified type.  */
     419                 :             : 
     420                 :             : static tree
     421                 :   128886527 : c_set_type_bits (tree new_type, tree old_type)
     422                 :             : {
     423                 :   128886527 :   gcc_checking_assert (c_verify_type (old_type));
     424                 :             : 
     425                 :   128886527 :   if (C_TYPE_VARIABLY_MODIFIED (old_type))
     426                 :       27199 :     C_TYPE_VARIABLY_MODIFIED (new_type) = true;
     427                 :             : 
     428                 :   128886527 :   if (TREE_CODE (new_type) == ARRAY_TYPE && C_TYPE_VARIABLE_SIZE (old_type))
     429                 :             :     {
     430                 :       16720 :       C_TYPE_VARIABLY_MODIFIED (new_type) = true;
     431                 :       16720 :       C_TYPE_VARIABLE_SIZE (new_type) = true;
     432                 :             :     }
     433                 :   128886527 :   return new_type;
     434                 :             : }
     435                 :             : 
     436                 :             : /* Build a pointer type using the default pointer mode.  */
     437                 :             : 
     438                 :             : tree
     439                 :    69795964 : c_build_pointer_type (tree to_type)
     440                 :             : {
     441                 :    69795964 :   addr_space_t as = to_type == error_mark_node ? ADDR_SPACE_GENERIC
     442                 :    69795964 :                                                : TYPE_ADDR_SPACE (to_type);
     443                 :    69795964 :   machine_mode pointer_mode;
     444                 :             : 
     445                 :    69795964 :   if (as != ADDR_SPACE_GENERIC || c_default_pointer_mode == VOIDmode)
     446                 :    69795964 :     pointer_mode = targetm.addr_space.pointer_mode (as);
     447                 :             :   else
     448                 :             :     pointer_mode = c_default_pointer_mode;
     449                 :             : 
     450                 :    69795964 :   return c_build_pointer_type_for_mode (to_type, pointer_mode, false);
     451                 :             : }
     452                 :             : 
     453                 :             : /* Build a pointer type using the given mode.  */
     454                 :             : 
     455                 :             : tree
     456                 :    69804706 : c_build_pointer_type_for_mode (tree type, machine_mode mode, bool m)
     457                 :             : {
     458                 :    69804706 :   tree ret = build_pointer_type_for_mode (type, mode, m);
     459                 :    69804706 :   return c_set_type_bits (ret, type);
     460                 :             : }
     461                 :             : 
     462                 :             : /* Build a function type.  */
     463                 :             : 
     464                 :             : tree
     465                 :    51324358 : c_build_function_type (tree type, tree args, bool no)
     466                 :             : {
     467                 :    51324358 :   tree ret = build_function_type (type, args, no);
     468                 :    51324358 :   return c_set_type_bits (ret, type);
     469                 :             : }
     470                 :             : 
     471                 :             : /* Build an array type.  This sets typeless storage as required
     472                 :             :    by C2Y and C_TYPE_VARIABLY_MODIFIED and C_TYPE_VARIABLE_SIZE
     473                 :             :    based on the element type and domain.  */
     474                 :             : 
     475                 :             : tree
     476                 :     1134937 : c_build_array_type (tree type, tree domain)
     477                 :             : {
     478                 :     1134937 :   int type_quals = TYPE_QUALS (type);
     479                 :             : 
     480                 :             :   /* Identify typeless storage as introduced in C2Y
     481                 :             :      and supported also in earlier language modes.  */
     482                 :     1697435 :   bool typeless = (char_type_p (type) && !(type_quals & TYPE_QUAL_ATOMIC))
     483                 :     1134937 :                   || (AGGREGATE_TYPE_P (type) && TYPE_TYPELESS_STORAGE (type));
     484                 :             : 
     485                 :     1134937 :   tree ret = build_array_type (type, domain, typeless);
     486                 :             : 
     487                 :     1050959 :   if (domain && TYPE_MAX_VALUE (domain)
     488                 :     2098272 :       && TREE_CODE (TYPE_MAX_VALUE (domain)) != INTEGER_CST)
     489                 :             :     {
     490                 :       23937 :       C_TYPE_VARIABLE_SIZE (ret) = 1;
     491                 :       23937 :       C_TYPE_VARIABLY_MODIFIED (ret) = 1;
     492                 :             :     }
     493                 :             : 
     494                 :     1134937 :   return c_set_type_bits (ret, type);
     495                 :             : }
     496                 :             : 
     497                 :             : 
     498                 :             : /* Build an array type of unspecified size.  */
     499                 :             : tree
     500                 :         142 : c_build_array_type_unspecified (tree type)
     501                 :             : {
     502                 :         142 :   tree upper = build2 (COMPOUND_EXPR, TREE_TYPE (size_zero_node),
     503                 :             :                        integer_zero_node, size_zero_node);
     504                 :         142 :   return c_build_array_type (type, build_index_type (upper));
     505                 :             : }
     506                 :             : 
     507                 :             : 
     508                 :             : tree
     509                 :     6622526 : c_build_type_attribute_qual_variant (tree type, tree attrs, int quals)
     510                 :             : {
     511                 :     6622526 :   tree ret = build_type_attribute_qual_variant (type, attrs, quals);
     512                 :     6622526 :   return c_set_type_bits (ret, type);
     513                 :             : }
     514                 :             : 
     515                 :             : tree
     516                 :     6622328 : c_build_type_attribute_variant (tree type, tree attrs)
     517                 :             : {
     518                 :     6622328 :   return c_build_type_attribute_qual_variant (type, attrs, TYPE_QUALS (type));
     519                 :             : }
     520                 :             : 
     521                 :             : /* Reconstruct a complex derived type.  This is used to re-construct types
     522                 :             :    with the vector attribute.  It is called via a langhook.  */
     523                 :             : 
     524                 :             : tree
     525                 :      483391 : c_reconstruct_complex_type (tree type, tree bottom)
     526                 :             : {
     527                 :      483391 :   tree inner, outer;
     528                 :             : 
     529                 :      483391 :   if (TREE_CODE (type) == POINTER_TYPE)
     530                 :             :     {
     531                 :          16 :       inner = c_reconstruct_complex_type (TREE_TYPE (type), bottom);
     532                 :          16 :       outer = c_build_pointer_type_for_mode (inner, TYPE_MODE (type),
     533                 :          16 :                                              TYPE_REF_CAN_ALIAS_ALL (type));
     534                 :             :     }
     535                 :             :   else if (TREE_CODE (type) == ARRAY_TYPE)
     536                 :             :     {
     537                 :          13 :       inner = c_reconstruct_complex_type (TREE_TYPE (type), bottom);
     538                 :          13 :       outer = c_build_array_type (inner, TYPE_DOMAIN (type));
     539                 :             : 
     540                 :          13 :       gcc_checking_assert (C_TYPE_VARIABLE_SIZE (type)
     541                 :             :                            == C_TYPE_VARIABLE_SIZE (outer));
     542                 :          13 :       gcc_checking_assert (C_TYPE_VARIABLY_MODIFIED (outer)
     543                 :             :                            == C_TYPE_VARIABLY_MODIFIED (type));
     544                 :             :     }
     545                 :             :   else if (TREE_CODE (type) == FUNCTION_TYPE)
     546                 :             :     {
     547                 :         169 :       inner = c_reconstruct_complex_type (TREE_TYPE (type), bottom);
     548                 :         169 :       outer = c_build_function_type (inner, TYPE_ARG_TYPES (type),
     549                 :         169 :                                      TYPE_NO_NAMED_ARGS_STDARG_P (type));
     550                 :             :     }
     551                 :             :   else if (TREE_CODE (type) == REFERENCE_TYPE
     552                 :             :            || TREE_CODE (type) == OFFSET_TYPE)
     553                 :           0 :     gcc_unreachable ();
     554                 :             :   else
     555                 :             :     return bottom;
     556                 :             : 
     557                 :         198 :   return c_build_type_attribute_qual_variant (outer, TYPE_ATTRIBUTES (type),
     558                 :         396 :                                               TYPE_QUALS (type));
     559                 :             : }
     560                 :             : 
     561                 :             : /* If NTYPE is a type of a non-variadic function with a prototype
     562                 :             :    and OTYPE is a type of a function without a prototype and ATTRS
     563                 :             :    contains attribute format, diagnosess and removes it from ATTRS.
     564                 :             :    Returns the result of build_type_attribute_variant of NTYPE and
     565                 :             :    the (possibly) modified ATTRS.  */
     566                 :             : 
     567                 :             : static tree
     568                 :        9693 : c_build_functype_attribute_variant (tree ntype, tree otype, tree attrs)
     569                 :             : {
     570                 :        9693 :   if (!prototype_p (otype)
     571                 :        9681 :       && prototype_p (ntype)
     572                 :       19344 :       && lookup_attribute ("format", attrs))
     573                 :             :     {
     574                 :          14 :       warning_at (input_location, OPT_Wattributes,
     575                 :             :                   "%qs attribute can only be applied to variadic functions",
     576                 :             :                   "format");
     577                 :          14 :       attrs = remove_attribute ("format", attrs);
     578                 :             :     }
     579                 :        9693 :   return c_build_type_attribute_variant (ntype, attrs);
     580                 :             : 
     581                 :             : }
     582                 :             : 
     583                 :             : /* Given a type which could be a typedef name, make sure to return the
     584                 :             :    original type.  See set_underlying_type. */
     585                 :             : static const_tree
     586                 :    60395647 : c_type_original (const_tree t)
     587                 :             : {
     588                 :             :   /* It may even be a typedef of a typedef...
     589                 :             :      In the case of compiler-created builtin structs the TYPE_DECL
     590                 :             :      may be a dummy, with no DECL_ORIGINAL_TYPE.  Don't fault.  */
     591                 :    60395647 :   while (TYPE_NAME (t)
     592                 :    31599346 :          && TREE_CODE (TYPE_NAME (t)) == TYPE_DECL
     593                 :    60399527 :          && DECL_ORIGINAL_TYPE (TYPE_NAME (t)))
     594                 :        1939 :     t = DECL_ORIGINAL_TYPE (TYPE_NAME (t));
     595                 :    60395647 :   return t;
     596                 :             : }
     597                 :             : 
     598                 :             : /* Return the tag for a tagged type.  */
     599                 :             : tree
     600                 :    60395647 : c_type_tag (const_tree t)
     601                 :             : {
     602                 :    60395647 :   gcc_assert (RECORD_OR_UNION_TYPE_P (t) || TREE_CODE (t) == ENUMERAL_TYPE);
     603                 :    60395647 :   const_tree orig = c_type_original (t);
     604                 :    60395647 :   tree name = TYPE_NAME (orig);
     605                 :    60395647 :   if (!name)
     606                 :             :     return NULL_TREE;
     607                 :    31597407 :   if (TREE_CODE (name) == TYPE_DECL)
     608                 :             :     {
     609                 :             :       /* A TYPE_DECL added by add_decl_expr.  */
     610                 :           2 :       gcc_checking_assert (!DECL_NAME (name));
     611                 :             :       return NULL_TREE;
     612                 :             :     }
     613                 :    31597405 :   gcc_checking_assert (TREE_CODE (name) == IDENTIFIER_NODE);
     614                 :             :   return name;
     615                 :             : }
     616                 :             : 
     617                 :             : /* Remove qualifiers but not atomic.  For arrays remove qualifiers
     618                 :             :    on the element type but also do not remove atomic.  */
     619                 :             : static tree
     620                 :    58985423 : remove_qualifiers (tree t)
     621                 :             : {
     622                 :    58985423 :   if (!t || t == error_mark_node)
     623                 :             :     return t;
     624                 :    58985398 :   return TYPE_ATOMIC (strip_array_types (t))
     625                 :    58985398 :          ? c_build_qualified_type (TYPE_MAIN_VARIANT (t), TYPE_QUAL_ATOMIC)
     626                 :    58969853 :          : TYPE_MAIN_VARIANT (t);
     627                 :             : }
     628                 :             : 
     629                 :             : 
     630                 :             : /* Return the composite type of two compatible types.
     631                 :             : 
     632                 :             :    We assume that comptypes has already been done and returned
     633                 :             :    nonzero; if that isn't so, this may crash.  In particular, we
     634                 :             :    assume that qualifiers match.  */
     635                 :             : 
     636                 :             : struct composite_cache {
     637                 :             :   tree t1;
     638                 :             :   tree t2;
     639                 :             :   tree composite;
     640                 :             :   struct composite_cache* next;
     641                 :             : };
     642                 :             : 
     643                 :             : tree
     644                 :    11983426 : composite_type_internal (tree t1, tree t2, struct composite_cache* cache)
     645                 :             : {
     646                 :    11983426 :   enum tree_code code1;
     647                 :    11983426 :   enum tree_code code2;
     648                 :    11983426 :   tree attributes;
     649                 :             : 
     650                 :             :   /* Save time if the two types are the same.  */
     651                 :             : 
     652                 :    11983426 :   if (t1 == t2) return t1;
     653                 :             : 
     654                 :             :   /* If one type is nonsense, use the other.  */
     655                 :     2421280 :   if (t1 == error_mark_node)
     656                 :             :     return t2;
     657                 :     2421276 :   if (t2 == error_mark_node)
     658                 :             :     return t1;
     659                 :             : 
     660                 :     2421274 :   code1 = TREE_CODE (t1);
     661                 :     2421274 :   code2 = TREE_CODE (t2);
     662                 :             : 
     663                 :             :   /* Merge the attributes.  */
     664                 :     2421274 :   attributes = targetm.merge_type_attributes (t1, t2);
     665                 :             : 
     666                 :             :   /* If one is an enumerated type and the other is the compatible
     667                 :             :      integer type, the composite type might be either of the two
     668                 :             :      (DR#013 question 3).  For consistency, use the enumerated type as
     669                 :             :      the composite type.  */
     670                 :             : 
     671                 :     2421274 :   if (code1 == ENUMERAL_TYPE
     672                 :         196 :       && (code2 == INTEGER_TYPE
     673                 :         196 :           || code2 == BOOLEAN_TYPE))
     674                 :             :     return t1;
     675                 :     2421078 :   if (code2 == ENUMERAL_TYPE
     676                 :          69 :       && (code1 == INTEGER_TYPE
     677                 :          69 :           || code1 == BOOLEAN_TYPE))
     678                 :             :     return t2;
     679                 :             : 
     680                 :     2421009 :   gcc_assert (code1 == code2);
     681                 :             : 
     682                 :     2421009 :   switch (code1)
     683                 :             :     {
     684                 :        6325 :     case POINTER_TYPE:
     685                 :             :       /* For two pointers, do this recursively on the target type.  */
     686                 :        6325 :       {
     687                 :        6325 :         tree pointed_to_1 = TREE_TYPE (t1);
     688                 :        6325 :         tree pointed_to_2 = TREE_TYPE (t2);
     689                 :        6325 :         tree target = composite_type_internal (pointed_to_1,
     690                 :             :                                                pointed_to_2, cache);
     691                 :        6325 :         t1 = c_build_pointer_type_for_mode (target, TYPE_MODE (t1), false);
     692                 :        6325 :         t1 = c_build_type_attribute_variant (t1, attributes);
     693                 :        6325 :         return qualify_type (t1, t2);
     694                 :             :       }
     695                 :             : 
     696                 :       10911 :     case ARRAY_TYPE:
     697                 :       10911 :       {
     698                 :       10911 :         tree elt = composite_type_internal (TREE_TYPE (t1), TREE_TYPE (t2),
     699                 :             :                                             cache);
     700                 :       10911 :         int quals;
     701                 :       10911 :         tree unqual_elt;
     702                 :       10911 :         tree d1 = TYPE_DOMAIN (t1);
     703                 :       10911 :         tree d2 = TYPE_DOMAIN (t2);
     704                 :       10911 :         bool d1_variable, d2_variable;
     705                 :       10911 :         bool d1_zero, d2_zero;
     706                 :       10911 :         bool t1_complete, t2_complete;
     707                 :             : 
     708                 :             :         /* We should not have any type quals on arrays at all.  */
     709                 :       10911 :         gcc_assert (!TYPE_QUALS_NO_ADDR_SPACE (t1)
     710                 :             :                     && !TYPE_QUALS_NO_ADDR_SPACE (t2));
     711                 :             : 
     712                 :       10911 :         t1_complete = COMPLETE_TYPE_P (t1);
     713                 :       10911 :         t2_complete = COMPLETE_TYPE_P (t2);
     714                 :             : 
     715                 :       10911 :         d1_zero = d1 == NULL_TREE || !TYPE_MAX_VALUE (d1);
     716                 :       10911 :         d2_zero = d2 == NULL_TREE || !TYPE_MAX_VALUE (d2);
     717                 :             : 
     718                 :       21822 :         d1_variable = (!d1_zero
     719                 :       10911 :                        && (TREE_CODE (TYPE_MIN_VALUE (d1)) != INTEGER_CST
     720                 :       10326 :                            || TREE_CODE (TYPE_MAX_VALUE (d1)) != INTEGER_CST));
     721                 :       21822 :         d2_variable = (!d2_zero
     722                 :       10911 :                        && (TREE_CODE (TYPE_MIN_VALUE (d2)) != INTEGER_CST
     723                 :       10584 :                            || TREE_CODE (TYPE_MAX_VALUE (d2)) != INTEGER_CST));
     724                 :             : 
     725                 :       10911 :         bool use1 = TYPE_DOMAIN (t1)
     726                 :       10911 :                     && (d2_variable || d2_zero || !d1_variable);
     727                 :       10911 :         bool use2 = TYPE_DOMAIN (t2)
     728                 :       10911 :                     && (d1_variable || d1_zero || !d2_variable);
     729                 :             : 
     730                 :             :         /* If the first is an unspecified size pick the other one.  */
     731                 :        8929 :         if (d2_variable && c_type_unspecified_p (t1))
     732                 :             :           {
     733                 :          28 :             gcc_assert (use1 && use2);
     734                 :             :             use1 = false;
     735                 :             :           }
     736                 :             : 
     737                 :             :         /* Save space: see if the result is identical to one of the args.  */
     738                 :       10911 :         if (elt == TREE_TYPE (t1) && use1)
     739                 :       10125 :           return c_build_type_attribute_variant (t1, attributes);
     740                 :         786 :         if (elt == TREE_TYPE (t2) && use2)
     741                 :         673 :           return c_build_type_attribute_variant (t2, attributes);
     742                 :             : 
     743                 :         156 :         if (elt == TREE_TYPE (t1) && !TYPE_DOMAIN (t2) && !TYPE_DOMAIN (t1))
     744                 :          10 :           return c_build_type_attribute_variant (t1, attributes);
     745                 :         111 :         if (elt == TREE_TYPE (t2) && !TYPE_DOMAIN (t2) && !TYPE_DOMAIN (t1))
     746                 :           2 :           return c_build_type_attribute_variant (t2, attributes);
     747                 :             : 
     748                 :             :         /* Merge the element types, and have a size if either arg has
     749                 :             :            one.  We may have qualifiers on the element types.  To set
     750                 :             :            up TYPE_MAIN_VARIANT correctly, we need to form the
     751                 :             :            composite of the unqualified types and add the qualifiers
     752                 :             :            back at the end.  */
     753                 :         101 :         quals = TYPE_QUALS (strip_array_types (elt));
     754                 :         101 :         unqual_elt = c_build_qualified_type (elt, TYPE_UNQUALIFIED);
     755                 :         202 :         t1 = c_build_array_type (unqual_elt, TYPE_DOMAIN (use1 ? t1 : t2));
     756                 :             : 
     757                 :             :         /* Check that a type which has a varying outermost dimension
     758                 :             :            got marked has having a variable size.  */
     759                 :         101 :         bool varsize = (d1_variable && d2_variable)
     760                 :          81 :                        || (d1_variable && !t2_complete)
     761                 :         171 :                        || (d2_variable && !t1_complete);
     762                 :          51 :         gcc_checking_assert (!varsize || C_TYPE_VARIABLE_SIZE (t1));
     763                 :             : 
     764                 :             :         /* Ensure a composite type involving a zero-length array type
     765                 :             :            is a zero-length type not an incomplete type.  */
     766                 :         101 :         if (d1_zero && d2_zero
     767                 :          16 :             && (t1_complete || t2_complete)
     768                 :         102 :             && !COMPLETE_TYPE_P (t1))
     769                 :             :           {
     770                 :           1 :             TYPE_SIZE (t1) = bitsize_zero_node;
     771                 :           1 :             TYPE_SIZE_UNIT (t1) = size_zero_node;
     772                 :             :           }
     773                 :         101 :         t1 = c_build_qualified_type (t1, quals);
     774                 :         101 :         return c_build_type_attribute_variant (t1, attributes);
     775                 :             :       }
     776                 :             : 
     777                 :         162 :     case RECORD_TYPE:
     778                 :         162 :     case UNION_TYPE:
     779                 :         162 :       if (flag_isoc23 && !comptypes_same_p (t1, t2))
     780                 :             :         {
     781                 :             :           /* Go to the original type to get the right tag.  */
     782                 :         101 :           tree tag = c_type_tag (t1);
     783                 :             : 
     784                 :         101 :           gcc_checking_assert (COMPLETE_TYPE_P (t1) && COMPLETE_TYPE_P (t2));
     785                 :         101 :           gcc_checking_assert (!tag || comptypes (t1, t2));
     786                 :             : 
     787                 :             :           /* If a composite type for these two types is already under
     788                 :             :              construction, return it.  */
     789                 :             : 
     790                 :         246 :           for (struct composite_cache *c = cache; c != NULL; c = c->next)
     791                 :         152 :             if ((c->t1 == t1 && c->t2 == t2) || (c->t1 == t2 && c->t2 == t1))
     792                 :           7 :                return c->composite;
     793                 :             : 
     794                 :             :           /* Otherwise, create a new type node and link it into the cache.  */
     795                 :             : 
     796                 :          94 :           tree n = make_node (code1);
     797                 :          94 :           SET_TYPE_STRUCTURAL_EQUALITY (n);
     798                 :          94 :           TYPE_NAME (n) = tag;
     799                 :             : 
     800                 :          94 :           struct composite_cache cache2 = { t1, t2, n, cache };
     801                 :          94 :           cache = &cache2;
     802                 :             : 
     803                 :          94 :           tree f1 = TYPE_FIELDS (t1);
     804                 :          94 :           tree f2 = TYPE_FIELDS (t2);
     805                 :          94 :           tree fields = NULL_TREE;
     806                 :             : 
     807                 :         214 :           for (tree a = f1, b = f2; a && b;
     808                 :         120 :                a = DECL_CHAIN (a), b = DECL_CHAIN (b))
     809                 :             :             {
     810                 :         120 :               tree ta = TREE_TYPE (a);
     811                 :         120 :               tree tb = TREE_TYPE (b);
     812                 :             : 
     813                 :         120 :               if (DECL_C_BIT_FIELD (a))
     814                 :             :                 {
     815                 :          19 :                   ta = DECL_BIT_FIELD_TYPE (a);
     816                 :          19 :                   tb = DECL_BIT_FIELD_TYPE (b);
     817                 :             :                 }
     818                 :             : 
     819                 :         120 :               gcc_assert (DECL_NAME (a) == DECL_NAME (b));
     820                 :         120 :               gcc_checking_assert (!DECL_NAME (a) || comptypes (ta, tb));
     821                 :             : 
     822                 :         120 :               tree t = composite_type_internal (ta, tb, cache);
     823                 :         120 :               tree f = build_decl (input_location, FIELD_DECL, DECL_NAME (a), t);
     824                 :             : 
     825                 :         120 :               DECL_PACKED (f) = DECL_PACKED (a);
     826                 :         120 :               SET_DECL_ALIGN (f, DECL_ALIGN (a));
     827                 :         120 :               DECL_ATTRIBUTES (f) = DECL_ATTRIBUTES (a);
     828                 :         120 :               C_DECL_VARIABLE_SIZE (f) = C_TYPE_VARIABLE_SIZE (t);
     829                 :             : 
     830                 :         120 :               decl_attributes (&f, DECL_ATTRIBUTES (f), 0);
     831                 :             : 
     832                 :         120 :               finish_decl (f, input_location, NULL, NULL, NULL);
     833                 :             : 
     834                 :         120 :               if (DECL_C_BIT_FIELD (a))
     835                 :             :                 {
     836                 :             :                   /* This will be processed by finish_struct.  */
     837                 :          19 :                   SET_DECL_C_BIT_FIELD (f);
     838                 :          19 :                   DECL_INITIAL (f) = build_int_cst (integer_type_node,
     839                 :          19 :                                                     tree_to_uhwi (DECL_SIZE (a)));
     840                 :          19 :                   DECL_NONADDRESSABLE_P (f) = true;
     841                 :          19 :                   DECL_PADDING_P (f) = !DECL_NAME (a);
     842                 :             :                 }
     843                 :             : 
     844                 :         120 :               DECL_CHAIN (f) = fields;
     845                 :         120 :               fields = f;
     846                 :             :             }
     847                 :             : 
     848                 :          94 :           fields = nreverse (fields);
     849                 :             : 
     850                 :             :           /* Setup the struct/union type.  Because we inherit all variably
     851                 :             :              modified components, we can ignore the size expression.  */
     852                 :          94 :           tree expr = NULL_TREE;
     853                 :             : 
     854                 :             :           /* Set TYPE_STUB_DECL for debugging symbols.  */
     855                 :          94 :           TYPE_STUB_DECL (n) = pushdecl (build_decl (input_location, TYPE_DECL,
     856                 :             :                                                      NULL_TREE, n));
     857                 :             : 
     858                 :          94 :           n = finish_struct (input_location, n, fields, attributes, NULL,
     859                 :             :                              &expr);
     860                 :             : 
     861                 :          94 :           return qualify_type (n, t1);
     862                 :             :         }
     863                 :             :       /* FALLTHRU */
     864                 :          61 :     case ENUMERAL_TYPE:
     865                 :          61 :       if (attributes != NULL)
     866                 :             :         {
     867                 :             :           /* Try harder not to create a new aggregate type.  */
     868                 :           4 :           if (attribute_list_equal (TYPE_ATTRIBUTES (t1), attributes))
     869                 :             :             return t1;
     870                 :           0 :           if (attribute_list_equal (TYPE_ATTRIBUTES (t2), attributes))
     871                 :             :             return t2;
     872                 :             :         }
     873                 :          57 :       return c_build_type_attribute_variant (t1, attributes);
     874                 :             : 
     875                 :     2363023 :     case FUNCTION_TYPE:
     876                 :             :       /* Function types: prefer the one that specified arg types.
     877                 :             :          If both do, merge the arg types.  Also merge the return types.  */
     878                 :     2363023 :       {
     879                 :     2363023 :         tree valtype = composite_type_internal (TREE_TYPE (t1),
     880                 :     2363023 :                                                 TREE_TYPE (t2), cache);
     881                 :     2363023 :         tree p1 = TYPE_ARG_TYPES (t1);
     882                 :     2363023 :         tree p2 = TYPE_ARG_TYPES (t2);
     883                 :     2363023 :         int len;
     884                 :     2363023 :         tree newargs, n;
     885                 :     2363023 :         int i;
     886                 :             : 
     887                 :             :         /* Save space: see if the result is identical to one of the args.  */
     888                 :     2363023 :         if (valtype == TREE_TYPE (t1) && !TYPE_ARG_TYPES (t2))
     889                 :        9176 :           return c_build_functype_attribute_variant (t1, t2, attributes);
     890                 :     2353847 :         if (valtype == TREE_TYPE (t2) && !TYPE_ARG_TYPES (t1))
     891                 :         517 :           return c_build_functype_attribute_variant (t2, t1, attributes);
     892                 :             : 
     893                 :             :         /* Simple way if one arg fails to specify argument types.  */
     894                 :     2353330 :         if (TYPE_ARG_TYPES (t1) == NULL_TREE)
     895                 :             :           {
     896                 :           9 :             t1 = c_build_function_type (valtype, TYPE_ARG_TYPES (t2),
     897                 :           9 :                                         TYPE_NO_NAMED_ARGS_STDARG_P (t2));
     898                 :           9 :             t1 = c_build_type_attribute_variant (t1, attributes);
     899                 :           9 :             return qualify_type (t1, t2);
     900                 :             :          }
     901                 :     2353321 :         if (TYPE_ARG_TYPES (t2) == NULL_TREE)
     902                 :             :           {
     903                 :           1 :             t1 = c_build_function_type (valtype, TYPE_ARG_TYPES (t1),
     904                 :           1 :                                         TYPE_NO_NAMED_ARGS_STDARG_P (t1));
     905                 :           1 :             t1 = c_build_type_attribute_variant (t1, attributes);
     906                 :           1 :             return qualify_type (t1, t2);
     907                 :             :           }
     908                 :             : 
     909                 :             :         /* If both args specify argument types, we must merge the two
     910                 :             :            lists, argument by argument.  */
     911                 :             : 
     912                 :             :         for (len = 0, newargs = p1;
     913                 :     6226089 :              newargs && newargs != void_list_node;
     914                 :     3872769 :              len++, newargs = TREE_CHAIN (newargs))
     915                 :             :           ;
     916                 :             : 
     917                 :     6226089 :         for (i = 0; i < len; i++)
     918                 :     3872769 :           newargs = tree_cons (NULL_TREE, NULL_TREE, newargs);
     919                 :             : 
     920                 :             :         n = newargs;
     921                 :             : 
     922                 :     6226089 :         for (; p1 && p1 != void_list_node;
     923                 :     3872769 :              p1 = TREE_CHAIN (p1), p2 = TREE_CHAIN (p2), n = TREE_CHAIN (n))
     924                 :             :           {
     925                 :     3872769 :              tree mv1 = remove_qualifiers (TREE_VALUE (p1));
     926                 :     3872769 :              tree mv2 = remove_qualifiers (TREE_VALUE (p2));
     927                 :             : 
     928                 :             :             /* A null type means arg type is not specified.
     929                 :             :                Take whatever the other function type has.  */
     930                 :     3872769 :             if (TREE_VALUE (p1) == NULL_TREE)
     931                 :             :               {
     932                 :           0 :                 TREE_VALUE (n) = TREE_VALUE (p2);
     933                 :           0 :                 goto parm_done;
     934                 :             :               }
     935                 :     3872769 :             if (TREE_VALUE (p2) == NULL_TREE)
     936                 :             :               {
     937                 :           0 :                 TREE_VALUE (n) = TREE_VALUE (p1);
     938                 :           0 :                 goto parm_done;
     939                 :             :               }
     940                 :             : 
     941                 :             :             /* Given  wait (union {union wait *u; int *i} *)
     942                 :             :                and  wait (union wait *),
     943                 :             :                prefer  union wait *  as type of parm.  */
     944                 :     3872769 :             if (TREE_CODE (TREE_VALUE (p1)) == UNION_TYPE
     945                 :     3872769 :                 && TREE_VALUE (p1) != TREE_VALUE (p2))
     946                 :             :               {
     947                 :          30 :                 tree memb;
     948                 :          30 :                 for (memb = TYPE_FIELDS (TREE_VALUE (p1));
     949                 :          38 :                      memb; memb = DECL_CHAIN (memb))
     950                 :             :                   {
     951                 :          38 :                     tree mv3 = TREE_TYPE (memb);
     952                 :          38 :                     if (mv3 && mv3 != error_mark_node
     953                 :          38 :                         && TREE_CODE (mv3) != ARRAY_TYPE)
     954                 :          38 :                       mv3 = TYPE_MAIN_VARIANT (mv3);
     955                 :          38 :                     if (comptypes (mv3, mv2))
     956                 :             :                       {
     957                 :          60 :                         TREE_VALUE (n) = composite_type_internal (TREE_TYPE (memb),
     958                 :          30 :                                                                   TREE_VALUE (p2),
     959                 :             :                                                                   cache);
     960                 :          30 :                         pedwarn (input_location, OPT_Wpedantic,
     961                 :             :                                  "function types not truly compatible in ISO C");
     962                 :          30 :                         goto parm_done;
     963                 :             :                       }
     964                 :             :                   }
     965                 :             :               }
     966                 :     3872739 :             if (TREE_CODE (TREE_VALUE (p2)) == UNION_TYPE
     967                 :     3872739 :                 && TREE_VALUE (p2) != TREE_VALUE (p1))
     968                 :             :               {
     969                 :          30 :                 tree memb;
     970                 :          30 :                 for (memb = TYPE_FIELDS (TREE_VALUE (p2));
     971                 :          38 :                      memb; memb = DECL_CHAIN (memb))
     972                 :             :                   {
     973                 :          38 :                     tree mv3 = TREE_TYPE (memb);
     974                 :          38 :                     if (mv3 && mv3 != error_mark_node
     975                 :          38 :                         && TREE_CODE (mv3) != ARRAY_TYPE)
     976                 :          38 :                       mv3 = TYPE_MAIN_VARIANT (mv3);
     977                 :          38 :                     if (comptypes (mv3, mv1))
     978                 :             :                       {
     979                 :          30 :                         TREE_VALUE (n)
     980                 :          30 :                                 = composite_type_internal (TREE_TYPE (memb),
     981                 :          30 :                                                            TREE_VALUE (p1),
     982                 :             :                                                            cache);
     983                 :          30 :                         pedwarn (input_location, OPT_Wpedantic,
     984                 :             :                                  "function types not truly compatible in ISO C");
     985                 :          30 :                         goto parm_done;
     986                 :             :                       }
     987                 :             :                   }
     988                 :             :               }
     989                 :     3872709 :             TREE_VALUE (n) = composite_type_internal (mv1, mv2, cache);
     990                 :     3872769 :           parm_done: ;
     991                 :             :           }
     992                 :             : 
     993                 :     2353320 :         t1 = c_build_function_type (valtype, newargs);
     994                 :     2353320 :         t1 = qualify_type (t1, t2);
     995                 :             :       }
     996                 :             :       /* FALLTHRU */
     997                 :             : 
     998                 :     2393908 :     default:
     999                 :     2393908 :       return c_build_type_attribute_variant (t1, attributes);
    1000                 :             :     }
    1001                 :             : }
    1002                 :             : 
    1003                 :             : tree
    1004                 :     5730278 : composite_type (tree t1, tree t2)
    1005                 :             : {
    1006                 :     5730278 :   gcc_checking_assert (comptypes_check_for_composite (t1, t2));
    1007                 :             : 
    1008                 :     5730278 :   struct composite_cache cache = { };
    1009                 :     5730278 :   tree n = composite_type_internal (t1, t2, &cache);
    1010                 :             : 
    1011                 :     5730278 :   gcc_checking_assert (comptypes_check_for_composite (n, t1));
    1012                 :     5730278 :   gcc_checking_assert (comptypes_check_for_composite (n, t2));
    1013                 :     5730278 :   return n;
    1014                 :             : }
    1015                 :             : 
    1016                 :             : /* Return the type of a conditional expression between pointers to
    1017                 :             :    possibly differently qualified versions of compatible types.
    1018                 :             : 
    1019                 :             :    We assume that comp_target_types has already been done and returned
    1020                 :             :    true; if that isn't so, this may crash.  */
    1021                 :             : 
    1022                 :             : static tree
    1023                 :      113659 : common_pointer_type (tree t1, tree t2)
    1024                 :             : {
    1025                 :      113659 :   tree attributes;
    1026                 :      113659 :   unsigned target_quals;
    1027                 :      113659 :   addr_space_t as1, as2, as_common;
    1028                 :      113659 :   int quals1, quals2;
    1029                 :             : 
    1030                 :             :   /* Save time if the two types are the same.  */
    1031                 :             : 
    1032                 :      113659 :   if (t1 == t2) return t1;
    1033                 :             : 
    1034                 :             :   /* If one type is nonsense, use the other.  */
    1035                 :        4428 :   if (t1 == error_mark_node)
    1036                 :             :     return t2;
    1037                 :        4428 :   if (t2 == error_mark_node)
    1038                 :             :     return t1;
    1039                 :             : 
    1040                 :        4428 :   gcc_assert (TREE_CODE (t1) == POINTER_TYPE
    1041                 :             :               && TREE_CODE (t2) == POINTER_TYPE);
    1042                 :             : 
    1043                 :             :   /* Merge the attributes.  */
    1044                 :        4428 :   attributes = targetm.merge_type_attributes (t1, t2);
    1045                 :             : 
    1046                 :             :   /* Find the composite type of the target types, and combine the
    1047                 :             :      qualifiers of the two types' targets.  */
    1048                 :        4428 :   tree pointed_to_1 = TREE_TYPE (t1);
    1049                 :        4428 :   tree pointed_to_2 = TREE_TYPE (t2);
    1050                 :        4428 :   tree target = composite_type (TYPE_MAIN_VARIANT (pointed_to_1),
    1051                 :        4428 :                                 TYPE_MAIN_VARIANT (pointed_to_2));
    1052                 :             : 
    1053                 :             :   /* Strip array types to get correct qualifier for pointers to arrays */
    1054                 :        4428 :   quals1 = TYPE_QUALS_NO_ADDR_SPACE (strip_array_types (pointed_to_1));
    1055                 :        4428 :   quals2 = TYPE_QUALS_NO_ADDR_SPACE (strip_array_types (pointed_to_2));
    1056                 :             : 
    1057                 :             :   /* For function types do not merge const qualifiers, but drop them
    1058                 :             :      if used inconsistently.  The middle-end uses these to mark const
    1059                 :             :      and noreturn functions.  */
    1060                 :        4428 :   if (TREE_CODE (pointed_to_1) == FUNCTION_TYPE)
    1061                 :        2129 :     target_quals = (quals1 & quals2);
    1062                 :             :   else
    1063                 :        2299 :     target_quals = (quals1 | quals2);
    1064                 :             : 
    1065                 :             :   /* If the two named address spaces are different, determine the common
    1066                 :             :      superset address space.  This is guaranteed to exist due to the
    1067                 :             :      assumption that comp_target_type returned true.  */
    1068                 :        4428 :   as1 = TYPE_ADDR_SPACE (pointed_to_1);
    1069                 :        4428 :   as2 = TYPE_ADDR_SPACE (pointed_to_2);
    1070                 :        4428 :   if (!addr_space_superset (as1, as2, &as_common))
    1071                 :           0 :     gcc_unreachable ();
    1072                 :             : 
    1073                 :        4428 :   target_quals |= ENCODE_QUAL_ADDR_SPACE (as_common);
    1074                 :             : 
    1075                 :        4428 :   t1 = c_build_pointer_type (c_build_qualified_type (target, target_quals));
    1076                 :        4428 :   return c_build_type_attribute_variant (t1, attributes);
    1077                 :             : }
    1078                 :             : 
    1079                 :             : /* Return the common type for two arithmetic types under the usual
    1080                 :             :    arithmetic conversions.  The default conversions have already been
    1081                 :             :    applied, and enumerated types converted to their compatible integer
    1082                 :             :    types.  The resulting type is unqualified and has no attributes.
    1083                 :             : 
    1084                 :             :    This is the type for the result of most arithmetic operations
    1085                 :             :    if the operands have the given two types.  */
    1086                 :             : 
    1087                 :             : static tree
    1088                 :    13584450 : c_common_type (tree t1, tree t2)
    1089                 :             : {
    1090                 :    13584450 :   enum tree_code code1;
    1091                 :    13584450 :   enum tree_code code2;
    1092                 :             : 
    1093                 :             :   /* If one type is nonsense, use the other.  */
    1094                 :    13584450 :   if (t1 == error_mark_node)
    1095                 :             :     return t2;
    1096                 :    13584450 :   if (t2 == error_mark_node)
    1097                 :             :     return t1;
    1098                 :             : 
    1099                 :    13584450 :   if (TYPE_QUALS (t1) != TYPE_UNQUALIFIED)
    1100                 :       38285 :     t1 = TYPE_MAIN_VARIANT (t1);
    1101                 :             : 
    1102                 :    13584450 :   if (TYPE_QUALS (t2) != TYPE_UNQUALIFIED)
    1103                 :       47715 :     t2 = TYPE_MAIN_VARIANT (t2);
    1104                 :             : 
    1105                 :    13584450 :   if (TYPE_ATTRIBUTES (t1) != NULL_TREE)
    1106                 :             :     {
    1107                 :      183671 :       tree attrs = affects_type_identity_attributes (TYPE_ATTRIBUTES (t1));
    1108                 :      183671 :       t1 = c_build_type_attribute_variant (t1, attrs);
    1109                 :             :     }
    1110                 :             : 
    1111                 :    13584450 :   if (TYPE_ATTRIBUTES (t2) != NULL_TREE)
    1112                 :             :     {
    1113                 :      183150 :       tree attrs = affects_type_identity_attributes (TYPE_ATTRIBUTES (t2));
    1114                 :      183150 :       t2 = c_build_type_attribute_variant (t2, attrs);
    1115                 :             :     }
    1116                 :             : 
    1117                 :             :   /* Save time if the two types are the same.  */
    1118                 :             : 
    1119                 :    13584450 :   if (t1 == t2) return t1;
    1120                 :             : 
    1121                 :     2285170 :   code1 = TREE_CODE (t1);
    1122                 :     2285170 :   code2 = TREE_CODE (t2);
    1123                 :             : 
    1124                 :     2285170 :   gcc_assert (code1 == VECTOR_TYPE || code1 == COMPLEX_TYPE
    1125                 :             :               || code1 == FIXED_POINT_TYPE || code1 == REAL_TYPE
    1126                 :             :               || code1 == INTEGER_TYPE || code1 == BITINT_TYPE);
    1127                 :     2285170 :   gcc_assert (code2 == VECTOR_TYPE || code2 == COMPLEX_TYPE
    1128                 :             :               || code2 == FIXED_POINT_TYPE || code2 == REAL_TYPE
    1129                 :             :               || code2 == INTEGER_TYPE || code2 == BITINT_TYPE);
    1130                 :             : 
    1131                 :             :   /* When one operand is a decimal float type, the other operand cannot be
    1132                 :             :      a generic float type or a complex type.  We also disallow vector types
    1133                 :             :      here.  */
    1134                 :     2285170 :   if ((DECIMAL_FLOAT_TYPE_P (t1) || DECIMAL_FLOAT_TYPE_P (t2))
    1135                 :     2287593 :       && !(DECIMAL_FLOAT_TYPE_P (t1) && DECIMAL_FLOAT_TYPE_P (t2)))
    1136                 :             :     {
    1137                 :        1080 :       if (code1 == VECTOR_TYPE || code2 == VECTOR_TYPE)
    1138                 :             :         {
    1139                 :           3 :           error ("cannot mix operands of decimal floating and vector types");
    1140                 :           3 :           return error_mark_node;
    1141                 :             :         }
    1142                 :        1077 :       if (code1 == COMPLEX_TYPE || code2 == COMPLEX_TYPE)
    1143                 :             :         {
    1144                 :           5 :           error ("cannot mix operands of decimal floating and complex types");
    1145                 :           5 :           return error_mark_node;
    1146                 :             :         }
    1147                 :        1072 :       if (code1 == REAL_TYPE && code2 == REAL_TYPE)
    1148                 :             :         {
    1149                 :          16 :           error ("cannot mix operands of decimal floating "
    1150                 :             :                  "and other floating types");
    1151                 :          16 :           return error_mark_node;
    1152                 :             :         }
    1153                 :             :     }
    1154                 :             : 
    1155                 :             :   /* If one type is a vector type, return that type.  (How the usual
    1156                 :             :      arithmetic conversions apply to the vector types extension is not
    1157                 :             :      precisely specified.)  */
    1158                 :     2285146 :   if (code1 == VECTOR_TYPE)
    1159                 :             :     return t1;
    1160                 :             : 
    1161                 :     2284868 :   if (code2 == VECTOR_TYPE)
    1162                 :             :     return t2;
    1163                 :             : 
    1164                 :             :   /* If one type is complex, form the common type of the non-complex
    1165                 :             :      components, then make that complex.  Use T1 or T2 if it is the
    1166                 :             :      required type.  */
    1167                 :     2284865 :   if (code1 == COMPLEX_TYPE || code2 == COMPLEX_TYPE)
    1168                 :             :     {
    1169                 :       89315 :       tree subtype1 = code1 == COMPLEX_TYPE ? TREE_TYPE (t1) : t1;
    1170                 :       89315 :       tree subtype2 = code2 == COMPLEX_TYPE ? TREE_TYPE (t2) : t2;
    1171                 :       89315 :       tree subtype = c_common_type (subtype1, subtype2);
    1172                 :             : 
    1173                 :       89315 :       if (code1 == COMPLEX_TYPE && TREE_TYPE (t1) == subtype)
    1174                 :             :         return t1;
    1175                 :       59200 :       else if (code2 == COMPLEX_TYPE && TREE_TYPE (t2) == subtype)
    1176                 :             :         return t2;
    1177                 :        3241 :       else if (TREE_CODE (subtype) == BITINT_TYPE)
    1178                 :             :         {
    1179                 :           8 :           sorry ("%<_Complex _BitInt(%d)%> unsupported",
    1180                 :           4 :                  TYPE_PRECISION (subtype));
    1181                 :           6 :           return code1 == COMPLEX_TYPE ? t1 : t2;
    1182                 :             :         }
    1183                 :             :       else
    1184                 :        3237 :         return build_complex_type (subtype);
    1185                 :             :     }
    1186                 :             : 
    1187                 :             :   /* If only one is real, use it as the result.  */
    1188                 :             : 
    1189                 :     2195550 :   if (code1 == REAL_TYPE && code2 != REAL_TYPE)
    1190                 :             :     return t1;
    1191                 :             : 
    1192                 :     2071138 :   if (code2 == REAL_TYPE && code1 != REAL_TYPE)
    1193                 :             :     return t2;
    1194                 :             : 
    1195                 :             :   /* If both are real and either are decimal floating point types, use
    1196                 :             :      the decimal floating point type with the greater precision. */
    1197                 :             : 
    1198                 :     2040836 :   if (code1 == REAL_TYPE && code2 == REAL_TYPE)
    1199                 :             :     {
    1200                 :      102626 :       if (TYPE_MAIN_VARIANT (t1) == dfloat128_type_node
    1201                 :      102626 :           || TYPE_MAIN_VARIANT (t2) == dfloat128_type_node)
    1202                 :             :         return dfloat128_type_node;
    1203                 :             :       /* And prefer _Decimal128 over _Decimal64x which has in GCC's
    1204                 :             :          implementation the same mode.  */
    1205                 :      102077 :       else if (TYPE_MAIN_VARIANT (t1) == dfloat64x_type_node
    1206                 :      102077 :                || TYPE_MAIN_VARIANT (t2) == dfloat64x_type_node)
    1207                 :             :         return dfloat64x_type_node;
    1208                 :      102073 :       else if (TYPE_MAIN_VARIANT (t1) == dfloat64_type_node
    1209                 :      102073 :                || TYPE_MAIN_VARIANT (t2) == dfloat64_type_node)
    1210                 :             :         return dfloat64_type_node;
    1211                 :      101628 :       else if (TYPE_MAIN_VARIANT (t1) == dfloat32_type_node
    1212                 :      101628 :                || TYPE_MAIN_VARIANT (t2) == dfloat32_type_node)
    1213                 :             :         return dfloat32_type_node;
    1214                 :             :     }
    1215                 :             : 
    1216                 :             :   /* Deal with fixed-point types.  */
    1217                 :     2039493 :   if (code1 == FIXED_POINT_TYPE || code2 == FIXED_POINT_TYPE)
    1218                 :             :     {
    1219                 :           0 :       unsigned int unsignedp = 0, satp = 0;
    1220                 :           0 :       scalar_mode m1, m2;
    1221                 :           0 :       unsigned int fbit1, ibit1, fbit2, ibit2, max_fbit, max_ibit;
    1222                 :             : 
    1223                 :           0 :       m1 = SCALAR_TYPE_MODE (t1);
    1224                 :           0 :       m2 = SCALAR_TYPE_MODE (t2);
    1225                 :             : 
    1226                 :             :       /* If one input type is saturating, the result type is saturating.  */
    1227                 :           0 :       if (TYPE_SATURATING (t1) || TYPE_SATURATING (t2))
    1228                 :             :         satp = 1;
    1229                 :             : 
    1230                 :             :       /* If both fixed-point types are unsigned, the result type is unsigned.
    1231                 :             :          When mixing fixed-point and integer types, follow the sign of the
    1232                 :             :          fixed-point type.
    1233                 :             :          Otherwise, the result type is signed.  */
    1234                 :           0 :       if ((TYPE_UNSIGNED (t1) && TYPE_UNSIGNED (t2)
    1235                 :           0 :            && code1 == FIXED_POINT_TYPE && code2 == FIXED_POINT_TYPE)
    1236                 :           0 :           || (code1 == FIXED_POINT_TYPE && code2 != FIXED_POINT_TYPE
    1237                 :           0 :               && TYPE_UNSIGNED (t1))
    1238                 :           0 :           || (code1 != FIXED_POINT_TYPE && code2 == FIXED_POINT_TYPE
    1239                 :           0 :               && TYPE_UNSIGNED (t2)))
    1240                 :             :         unsignedp = 1;
    1241                 :             : 
    1242                 :             :       /* The result type is signed.  */
    1243                 :           0 :       if (unsignedp == 0)
    1244                 :             :         {
    1245                 :             :           /* If the input type is unsigned, we need to convert to the
    1246                 :             :              signed type.  */
    1247                 :           0 :           if (code1 == FIXED_POINT_TYPE && TYPE_UNSIGNED (t1))
    1248                 :             :             {
    1249                 :           0 :               enum mode_class mclass = (enum mode_class) 0;
    1250                 :           0 :               if (GET_MODE_CLASS (m1) == MODE_UFRACT)
    1251                 :             :                 mclass = MODE_FRACT;
    1252                 :           0 :               else if (GET_MODE_CLASS (m1) == MODE_UACCUM)
    1253                 :             :                 mclass = MODE_ACCUM;
    1254                 :             :               else
    1255                 :           0 :                 gcc_unreachable ();
    1256                 :           0 :               m1 = as_a <scalar_mode>
    1257                 :           0 :                 (mode_for_size (GET_MODE_PRECISION (m1), mclass, 0));
    1258                 :             :             }
    1259                 :           0 :           if (code2 == FIXED_POINT_TYPE && TYPE_UNSIGNED (t2))
    1260                 :             :             {
    1261                 :           0 :               enum mode_class mclass = (enum mode_class) 0;
    1262                 :           0 :               if (GET_MODE_CLASS (m2) == MODE_UFRACT)
    1263                 :             :                 mclass = MODE_FRACT;
    1264                 :           0 :               else if (GET_MODE_CLASS (m2) == MODE_UACCUM)
    1265                 :             :                 mclass = MODE_ACCUM;
    1266                 :             :               else
    1267                 :           0 :                 gcc_unreachable ();
    1268                 :           0 :               m2 = as_a <scalar_mode>
    1269                 :           0 :                 (mode_for_size (GET_MODE_PRECISION (m2), mclass, 0));
    1270                 :             :             }
    1271                 :             :         }
    1272                 :             : 
    1273                 :           0 :       if (code1 == FIXED_POINT_TYPE)
    1274                 :             :         {
    1275                 :           0 :           fbit1 = GET_MODE_FBIT (m1);
    1276                 :           0 :           ibit1 = GET_MODE_IBIT (m1);
    1277                 :             :         }
    1278                 :             :       else
    1279                 :             :         {
    1280                 :           0 :           fbit1 = 0;
    1281                 :             :           /* Signed integers need to subtract one sign bit.  */
    1282                 :           0 :           ibit1 = TYPE_PRECISION (t1) - (!TYPE_UNSIGNED (t1));
    1283                 :             :         }
    1284                 :             : 
    1285                 :           0 :       if (code2 == FIXED_POINT_TYPE)
    1286                 :             :         {
    1287                 :           0 :           fbit2 = GET_MODE_FBIT (m2);
    1288                 :           0 :           ibit2 = GET_MODE_IBIT (m2);
    1289                 :             :         }
    1290                 :             :       else
    1291                 :             :         {
    1292                 :           0 :           fbit2 = 0;
    1293                 :             :           /* Signed integers need to subtract one sign bit.  */
    1294                 :           0 :           ibit2 = TYPE_PRECISION (t2) - (!TYPE_UNSIGNED (t2));
    1295                 :             :         }
    1296                 :             : 
    1297                 :           0 :       max_ibit = ibit1 >= ibit2 ?  ibit1 : ibit2;
    1298                 :           0 :       max_fbit = fbit1 >= fbit2 ?  fbit1 : fbit2;
    1299                 :           0 :       return c_common_fixed_point_type_for_size (max_ibit, max_fbit, unsignedp,
    1300                 :             :                                                  satp);
    1301                 :             :     }
    1302                 :             : 
    1303                 :             :   /* Both real or both integers; use the one with greater precision.  */
    1304                 :             : 
    1305                 :     2039493 :   if (TYPE_PRECISION (t1) > TYPE_PRECISION (t2))
    1306                 :             :     return t1;
    1307                 :     1075981 :   else if (TYPE_PRECISION (t2) > TYPE_PRECISION (t1))
    1308                 :             :     return t2;
    1309                 :             : 
    1310                 :             :   /* Same precision.  Prefer long longs to longs to ints when the
    1311                 :             :      same precision, following the C99 rules on integer type rank
    1312                 :             :      (which are equivalent to the C90 rules for C90 types).  */
    1313                 :             : 
    1314                 :      723773 :   if (TYPE_MAIN_VARIANT (t1) == long_long_unsigned_type_node
    1315                 :      723773 :       || TYPE_MAIN_VARIANT (t2) == long_long_unsigned_type_node)
    1316                 :             :     return long_long_unsigned_type_node;
    1317                 :             : 
    1318                 :      636736 :   if (TYPE_MAIN_VARIANT (t1) == long_long_integer_type_node
    1319                 :      636736 :       || TYPE_MAIN_VARIANT (t2) == long_long_integer_type_node)
    1320                 :             :     {
    1321                 :       14729 :       if (TYPE_UNSIGNED (t1) || TYPE_UNSIGNED (t2))
    1322                 :         361 :         return long_long_unsigned_type_node;
    1323                 :             :       else
    1324                 :             :         return long_long_integer_type_node;
    1325                 :             :     }
    1326                 :             : 
    1327                 :      622007 :   if (TYPE_MAIN_VARIANT (t1) == long_unsigned_type_node
    1328                 :      622007 :       || TYPE_MAIN_VARIANT (t2) == long_unsigned_type_node)
    1329                 :             :     return long_unsigned_type_node;
    1330                 :             : 
    1331                 :      523062 :   if (TYPE_MAIN_VARIANT (t1) == long_integer_type_node
    1332                 :      523062 :       || TYPE_MAIN_VARIANT (t2) == long_integer_type_node)
    1333                 :             :     {
    1334                 :             :       /* But preserve unsignedness from the other type,
    1335                 :             :          since long cannot hold all the values of an unsigned int.  */
    1336                 :       26195 :       if (TYPE_UNSIGNED (t1) || TYPE_UNSIGNED (t2))
    1337                 :         131 :         return long_unsigned_type_node;
    1338                 :             :       else
    1339                 :             :         return long_integer_type_node;
    1340                 :             :     }
    1341                 :             : 
    1342                 :             :   /* For floating types of the same TYPE_PRECISION (which we here
    1343                 :             :      assume means either the same set of values, or sets of values
    1344                 :             :      neither a subset of the other, with behavior being undefined in
    1345                 :             :      the latter case), follow the rules from TS 18661-3: prefer
    1346                 :             :      interchange types _FloatN, then standard types long double,
    1347                 :             :      double, float, then extended types _FloatNx.  For extended types,
    1348                 :             :      check them starting with _Float128x as that seems most consistent
    1349                 :             :      in spirit with preferring long double to double; for interchange
    1350                 :             :      types, also check in that order for consistency although it's not
    1351                 :             :      possible for more than one of them to have the same
    1352                 :             :      precision.  */
    1353                 :      496867 :   tree mv1 = TYPE_MAIN_VARIANT (t1);
    1354                 :      496867 :   tree mv2 = TYPE_MAIN_VARIANT (t2);
    1355                 :             : 
    1356                 :     2483769 :   for (int i = NUM_FLOATN_TYPES - 1; i >= 0; i--)
    1357                 :     1987065 :     if (mv1 == FLOATN_TYPE_NODE (i) || mv2 == FLOATN_TYPE_NODE (i))
    1358                 :             :       return FLOATN_TYPE_NODE (i);
    1359                 :             : 
    1360                 :             :   /* Likewise, prefer long double to double even if same size.  */
    1361                 :      496704 :   if (mv1 == long_double_type_node || mv2 == long_double_type_node)
    1362                 :             :     return long_double_type_node;
    1363                 :             : 
    1364                 :             :   /* Likewise, prefer double to float even if same size.
    1365                 :             :      We got a couple of embedded targets with 32 bit doubles, and the
    1366                 :             :      pdp11 might have 64 bit floats.  */
    1367                 :      496462 :   if (mv1 == double_type_node || mv2 == double_type_node)
    1368                 :             :     return double_type_node;
    1369                 :             : 
    1370                 :      495890 :   if (mv1 == float_type_node || mv2 == float_type_node)
    1371                 :             :     return float_type_node;
    1372                 :             : 
    1373                 :     1974884 :   for (int i = NUM_FLOATNX_TYPES - 1; i >= 0; i--)
    1374                 :     1481163 :     if (mv1 == FLOATNX_TYPE_NODE (i) || mv2 == FLOATNX_TYPE_NODE (i))
    1375                 :             :       return FLOATNX_TYPE_NODE (i);
    1376                 :             : 
    1377                 :      493721 :   if ((code1 == BITINT_TYPE || code2 == BITINT_TYPE) && code1 != code2)
    1378                 :             :     {
    1379                 :             :       /* Prefer any other integral types over bit-precise integer types.  */
    1380                 :          10 :       if (TYPE_UNSIGNED (t1) == TYPE_UNSIGNED (t2))
    1381                 :           6 :         return code1 == BITINT_TYPE ? t2 : t1;
    1382                 :             :       /* If BITINT_TYPE is unsigned and the other type is signed
    1383                 :             :          non-BITINT_TYPE with the same precision, the latter has higher rank.
    1384                 :             :          In that case:
    1385                 :             :          Otherwise, both operands are converted to the unsigned integer type
    1386                 :             :          corresponding to the type of the operand with signed integer type.  */
    1387                 :           8 :       if (TYPE_UNSIGNED (code1 == BITINT_TYPE ? t1 : t2))
    1388                 :           5 :         return c_common_unsigned_type (code1 == BITINT_TYPE ? t2 : t1);
    1389                 :             :     }
    1390                 :             : 
    1391                 :             :   /* Otherwise prefer the unsigned one.  */
    1392                 :             : 
    1393                 :      493713 :   if (TYPE_UNSIGNED (t1))
    1394                 :             :     return t1;
    1395                 :             :   else
    1396                 :             :     return t2;
    1397                 :             : }
    1398                 :             : 
    1399                 :             : /* Wrapper around c_common_type that is used by c-common.cc and other
    1400                 :             :    front end optimizations that remove promotions.  ENUMERAL_TYPEs
    1401                 :             :    are allowed here and are converted to their compatible integer types.
    1402                 :             :    BOOLEAN_TYPEs are allowed here and return either boolean_type_node or
    1403                 :             :    preferably a non-Boolean type as the common type.  */
    1404                 :             : tree
    1405                 :       99953 : common_type (tree t1, tree t2)
    1406                 :             : {
    1407                 :       99953 :   if (TREE_CODE (t1) == ENUMERAL_TYPE)
    1408                 :           0 :     t1 = ENUM_UNDERLYING_TYPE (t1);
    1409                 :       99953 :   if (TREE_CODE (t2) == ENUMERAL_TYPE)
    1410                 :           1 :     t2 = ENUM_UNDERLYING_TYPE (t2);
    1411                 :             : 
    1412                 :             :   /* If both types are BOOLEAN_TYPE, then return boolean_type_node.  */
    1413                 :       99953 :   if (TREE_CODE (t1) == BOOLEAN_TYPE
    1414                 :         584 :       && TREE_CODE (t2) == BOOLEAN_TYPE)
    1415                 :         584 :     return boolean_type_node;
    1416                 :             : 
    1417                 :             :   /* If either type is BOOLEAN_TYPE, then return the other.  */
    1418                 :       99369 :   if (TREE_CODE (t1) == BOOLEAN_TYPE)
    1419                 :             :     return t2;
    1420                 :       99369 :   if (TREE_CODE (t2) == BOOLEAN_TYPE)
    1421                 :             :     return t1;
    1422                 :             : 
    1423                 :       99369 :   return c_common_type (t1, t2);
    1424                 :             : }
    1425                 :             : 
    1426                 :             : 
    1427                 :             : 
    1428                 :             : /* Helper function for comptypes.  For two compatible types, return 1
    1429                 :             :    if they pass consistency checks.  In particular we test that
    1430                 :             :    TYPE_CANONICAL is set correctly, i.e. the two types can alias.  */
    1431                 :             : 
    1432                 :             : static bool
    1433                 :    42769770 : comptypes_verify (tree type1, tree type2)
    1434                 :             : {
    1435                 :    42769770 :   if (type1 == type2 || !type1 || !type2
    1436                 :     3265221 :       || TREE_CODE (type1) == ERROR_MARK || TREE_CODE (type2) == ERROR_MARK)
    1437                 :             :     return true;
    1438                 :             : 
    1439                 :     3265220 :   gcc_checking_assert (c_verify_type (type1));
    1440                 :     3265220 :   gcc_checking_assert (c_verify_type (type2));
    1441                 :             : 
    1442                 :     3265220 :   if (TYPE_CANONICAL (type1) != TYPE_CANONICAL (type2)
    1443                 :      380922 :       && !TYPE_STRUCTURAL_EQUALITY_P (type1)
    1444                 :     3644497 :       && !TYPE_STRUCTURAL_EQUALITY_P (type2))
    1445                 :             :     {
    1446                 :             :       /* FIXME: check other types. */
    1447                 :      379090 :       if (RECORD_OR_UNION_TYPE_P (type1)
    1448                 :      379090 :           || TREE_CODE (type1) == ENUMERAL_TYPE
    1449                 :      379090 :           || TREE_CODE (type2) == ENUMERAL_TYPE)
    1450                 :           0 :         return false;
    1451                 :             :     }
    1452                 :             :   return true;
    1453                 :             : }
    1454                 :             : 
    1455                 :             : struct comptypes_data {
    1456                 :             : 
    1457                 :             :   /* output */
    1458                 :             :   bool enum_and_int_p;
    1459                 :             :   bool different_types_p;
    1460                 :             :   bool warning_needed;
    1461                 :             : 
    1462                 :             :   /* context */
    1463                 :             :   bool anon_field;
    1464                 :             :   bool pointedto;
    1465                 :             : 
    1466                 :             :   /* configuration */
    1467                 :             :   bool equiv;
    1468                 :             :   bool ignore_promoting_args;
    1469                 :             : 
    1470                 :             :   const struct tagged_tu_seen_cache* cache;
    1471                 :             : };
    1472                 :             : 
    1473                 :             : 
    1474                 :             : /* Helper function for composite_type.  This function ignores when the
    1475                 :             :    function type of an old-style declaration is incompatible with a type
    1476                 :             :    of a declaration with prototype because some are arguments are not
    1477                 :             :    self-promoting.  This is ignored only for function types but not
    1478                 :             :    ignored in a nested context.  */
    1479                 :             : 
    1480                 :             : static bool
    1481                 :    17190834 : comptypes_check_for_composite (tree t1, tree t2)
    1482                 :             : {
    1483                 :    17190834 :   struct comptypes_data data = { };
    1484                 :    17190834 :   data.ignore_promoting_args = FUNCTION_TYPE == TREE_CODE (t1);
    1485                 :    17190834 :   return comptypes_internal (t1, t2, &data);
    1486                 :             : }
    1487                 :             : 
    1488                 :             : 
    1489                 :             : /* C implementation of compatible_types_for_indirection_note_p.  */
    1490                 :             : 
    1491                 :             : bool
    1492                 :         761 : compatible_types_for_indirection_note_p (tree type1, tree type2)
    1493                 :             : {
    1494                 :         761 :   return comptypes (type1, type2) == 1;
    1495                 :             : }
    1496                 :             : 
    1497                 :             : /* Return 1 if TYPE1 and TYPE2 are compatible types for assignment
    1498                 :             :    or various other operations.  Return 2 if they are compatible
    1499                 :             :    but a warning may be needed if you use them together.  */
    1500                 :             : 
    1501                 :             : int
    1502                 :    54648942 : comptypes (tree type1, tree type2)
    1503                 :             : {
    1504                 :    54648942 :   struct comptypes_data data = { };
    1505                 :    54648942 :   bool ret = comptypes_internal (type1, type2, &data);
    1506                 :             : 
    1507                 :    54648942 :   gcc_checking_assert (!ret || comptypes_verify (type1, type2));
    1508                 :             : 
    1509                 :    36584017 :   return ret ? (data.warning_needed ? 2 : 1) : 0;
    1510                 :             : }
    1511                 :             : 
    1512                 :             : 
    1513                 :             : /* Like comptypes, but it returns non-zero only for identical
    1514                 :             :    types.  */
    1515                 :             : 
    1516                 :             : bool
    1517                 :         275 : comptypes_same_p (tree type1, tree type2)
    1518                 :             : {
    1519                 :         275 :   struct comptypes_data data = { };
    1520                 :         275 :   bool ret = comptypes_internal (type1, type2, &data);
    1521                 :             : 
    1522                 :         275 :   gcc_checking_assert (!ret || comptypes_verify (type1, type2));
    1523                 :             : 
    1524                 :         275 :   if (data.different_types_p)
    1525                 :         103 :     return false;
    1526                 :             : 
    1527                 :             :   return ret;
    1528                 :             : }
    1529                 :             : 
    1530                 :             : 
    1531                 :             : /* Like comptypes, but if it returns non-zero because enum and int are
    1532                 :             :    compatible, it sets *ENUM_AND_INT_P to true.  */
    1533                 :             : 
    1534                 :             : int
    1535                 :     6384354 : comptypes_check_enum_int (tree type1, tree type2, bool *enum_and_int_p)
    1536                 :             : {
    1537                 :     6384354 :   struct comptypes_data data = { };
    1538                 :     6384354 :   bool ret = comptypes_internal (type1, type2, &data);
    1539                 :     6384354 :   *enum_and_int_p = data.enum_and_int_p;
    1540                 :             : 
    1541                 :     6384354 :   gcc_checking_assert (!ret || comptypes_verify (type1, type2));
    1542                 :             : 
    1543                 :     6141034 :   return ret ? (data.warning_needed ? 2 : 1) : 0;
    1544                 :             : }
    1545                 :             : 
    1546                 :             : /* Like comptypes, but if it returns nonzero for different types, it
    1547                 :             :    sets *DIFFERENT_TYPES_P to true.  */
    1548                 :             : 
    1549                 :             : int
    1550                 :       44481 : comptypes_check_different_types (tree type1, tree type2,
    1551                 :             :                                  bool *different_types_p)
    1552                 :             : {
    1553                 :       44481 :   struct comptypes_data data = { };
    1554                 :       44481 :   bool ret = comptypes_internal (type1, type2, &data);
    1555                 :       44481 :   *different_types_p = data.different_types_p;
    1556                 :             : 
    1557                 :       44481 :   gcc_checking_assert (!ret || comptypes_verify (type1, type2));
    1558                 :             : 
    1559                 :       44481 :   return ret ? (data.warning_needed ? 2 : 1) : 0;
    1560                 :             : }
    1561                 :             : 
    1562                 :             : 
    1563                 :             : /* Like comptypes, but if it returns true for struct and union types
    1564                 :             :    considered equivalent for aliasing purposes, i.e. for setting
    1565                 :             :    TYPE_CANONICAL after completing a struct or union.
    1566                 :             : 
    1567                 :             :    This function must return false only for types which are not
    1568                 :             :    compatible according to C language semantics (cf. comptypes),
    1569                 :             :    otherwise the middle-end would make incorrect aliasing decisions.
    1570                 :             :    It may return true for some similar types that are not compatible
    1571                 :             :    according to those stricter rules.
    1572                 :             : 
    1573                 :             :    In particular, we ignore size expression in arrays so that the
    1574                 :             :    following structs are in the same equivalence class:
    1575                 :             : 
    1576                 :             :    struct foo { char (*buf)[]; };
    1577                 :             :    struct foo { char (*buf)[3]; };
    1578                 :             :    struct foo { char (*buf)[4]; };
    1579                 :             : 
    1580                 :             :    We also treat unions / structs with members which are pointers to
    1581                 :             :    structures or unions with the same tag as equivalent (if they are not
    1582                 :             :    incompatible for other reasons).  Although incomplete structure
    1583                 :             :    or union types are not compatible to any other type, they may become
    1584                 :             :    compatible to different types when completed.  To avoid having to update
    1585                 :             :    TYPE_CANONICAL at this point, we only consider the tag when forming
    1586                 :             :    the equivalence classes.  For example, the following types with tag
    1587                 :             :    'foo' are all considered equivalent:
    1588                 :             : 
    1589                 :             :    struct bar;
    1590                 :             :    struct foo { struct bar *x };
    1591                 :             :    struct foo { struct bar { int a; } *x };
    1592                 :             :    struct foo { struct bar { char b; } *x };  */
    1593                 :             : 
    1594                 :             : bool
    1595                 :    14258060 : comptypes_equiv_p (tree type1, tree type2)
    1596                 :             : {
    1597                 :    14258060 :   struct comptypes_data data = { };
    1598                 :    14258060 :   data.equiv = true;
    1599                 :    14258060 :   bool ret = comptypes_internal (type1, type2, &data);
    1600                 :             : 
    1601                 :             :   /* check that different equivance classes are assigned only
    1602                 :             :      to types that are not compatible.  */
    1603                 :    14258060 :   gcc_checking_assert (ret || !comptypes (type1, type2));
    1604                 :             : 
    1605                 :    14258060 :   return ret;
    1606                 :             : }
    1607                 :             : 
    1608                 :             : 
    1609                 :             : /* Return true if TYPE1 and TYPE2 are compatible types for assignment
    1610                 :             :    or various other operations.  If they are compatible but a warning may
    1611                 :             :    be needed if you use them together, 'warning_needed' in DATA is set.
    1612                 :             :    If one type is an enum and the other a compatible integer type, then
    1613                 :             :    this sets 'enum_and_int_p' in DATA to true (it is never set to
    1614                 :             :    false).  If the types are compatible but different enough not to be
    1615                 :             :    permitted in C11 typedef redeclarations, then this sets
    1616                 :             :    'different_types_p' in DATA to true; it is never set to
    1617                 :             :    false, but may or may not be set if the types are incompatible.
    1618                 :             :    If two functions types are not compatible only because one is
    1619                 :             :    an old-style definition that does not have self-promoting arguments,
    1620                 :             :    then this can be ignored by setting 'ignore_promoting_args_p'.
    1621                 :             :    For 'equiv' we can compute equivalency classes (see above).
    1622                 :             :    This differs from comptypes, in that we don't free the seen
    1623                 :             :    types.  */
    1624                 :             : 
    1625                 :             : static bool
    1626                 :   126358219 : comptypes_internal (const_tree type1, const_tree type2,
    1627                 :             :                     struct comptypes_data *data)
    1628                 :             : {
    1629                 :   126629215 :   const_tree t1 = type1;
    1630                 :   126629215 :   const_tree t2 = type2;
    1631                 :             : 
    1632                 :             :   /* Suppress errors caused by previously reported errors.  */
    1633                 :             : 
    1634                 :   126629215 :   if (t1 == t2 || !t1 || !t2
    1635                 :    43537834 :       || TREE_CODE (t1) == ERROR_MARK || TREE_CODE (t2) == ERROR_MARK)
    1636                 :             :     return true;
    1637                 :             : 
    1638                 :             :   /* Enumerated types are compatible with integer types, but this is
    1639                 :             :      not transitive: two enumerated types in the same translation unit
    1640                 :             :      are compatible with each other only if they are the same type.  */
    1641                 :             : 
    1642                 :    43537831 :   if (TREE_CODE (t1) == ENUMERAL_TYPE
    1643                 :        1012 :       && COMPLETE_TYPE_P (t1)
    1644                 :    43538799 :       && TREE_CODE (t2) != ENUMERAL_TYPE)
    1645                 :             :     {
    1646                 :         856 :       t1 = ENUM_UNDERLYING_TYPE (t1);
    1647                 :         856 :       if (TREE_CODE (t2) != VOID_TYPE)
    1648                 :             :         {
    1649                 :         852 :           data->enum_and_int_p = true;
    1650                 :         852 :           data->different_types_p = true;
    1651                 :             :         }
    1652                 :             :     }
    1653                 :    43536975 :   else if (TREE_CODE (t2) == ENUMERAL_TYPE
    1654                 :        4530 :            && COMPLETE_TYPE_P (t2)
    1655                 :    43541499 :            && TREE_CODE (t1) != ENUMERAL_TYPE)
    1656                 :             :     {
    1657                 :        4412 :       t2 = ENUM_UNDERLYING_TYPE (t2);
    1658                 :        4412 :       if (TREE_CODE (t1) != VOID_TYPE)
    1659                 :             :         {
    1660                 :        3513 :           data->enum_and_int_p = true;
    1661                 :        3513 :           data->different_types_p = true;
    1662                 :             :         }
    1663                 :             :     }
    1664                 :             : 
    1665                 :    43537831 :   if (t1 == t2)
    1666                 :             :     return true;
    1667                 :             : 
    1668                 :             :   /* Different classes of types can't be compatible.  */
    1669                 :             : 
    1670                 :    43536530 :   if (TREE_CODE (t1) != TREE_CODE (t2))
    1671                 :             :     return false;
    1672                 :             : 
    1673                 :             :   /* Qualifiers must match. C99 6.7.3p9 */
    1674                 :             : 
    1675                 :    35693709 :   if (TYPE_QUALS (t1) != TYPE_QUALS (t2))
    1676                 :             :     return false;
    1677                 :             : 
    1678                 :             :   /* Allow for two different type nodes which have essentially the same
    1679                 :             :      definition.  Note that we already checked for equality of the type
    1680                 :             :      qualifiers (just above).  */
    1681                 :             : 
    1682                 :    35654534 :   if (TREE_CODE (t1) != ARRAY_TYPE
    1683                 :    35654534 :       && TYPE_MAIN_VARIANT (t1) == TYPE_MAIN_VARIANT (t2))
    1684                 :             :     return true;
    1685                 :             : 
    1686                 :    35324134 :   int attrval;
    1687                 :             : 
    1688                 :             :   /* 1 if no need for warning yet, 2 if warning cause has been seen.  */
    1689                 :    35324134 :   if (!(attrval = comp_type_attributes (t1, t2)))
    1690                 :             :      return false;
    1691                 :             : 
    1692                 :    35323779 :   if (2 == attrval)
    1693                 :         336 :     data->warning_needed = true;
    1694                 :             : 
    1695                 :    35323779 :   switch (TREE_CODE (t1))
    1696                 :             :     {
    1697                 :     3293507 :     case INTEGER_TYPE:
    1698                 :     3293507 :     case FIXED_POINT_TYPE:
    1699                 :     3293507 :     case REAL_TYPE:
    1700                 :     3293507 :     case BITINT_TYPE:
    1701                 :             :       /* With these nodes, we can't determine type equivalence by
    1702                 :             :          looking at what is stored in the nodes themselves, because
    1703                 :             :          two nodes might have different TYPE_MAIN_VARIANTs but still
    1704                 :             :          represent the same type.  For example, wchar_t and int could
    1705                 :             :          have the same properties (TYPE_PRECISION, TYPE_MIN_VALUE,
    1706                 :             :          TYPE_MAX_VALUE, etc.), but have different TYPE_MAIN_VARIANTs
    1707                 :             :          and are distinct types.  On the other hand, int and the
    1708                 :             :          following typedef
    1709                 :             : 
    1710                 :             :            typedef int INT __attribute((may_alias));
    1711                 :             : 
    1712                 :             :          have identical properties, different TYPE_MAIN_VARIANTs, but
    1713                 :             :          represent the same type.  The canonical type system keeps
    1714                 :             :          track of equivalence in this case, so we fall back on it.  */
    1715                 :     3293507 :       return TYPE_CANONICAL (t1) == TYPE_CANONICAL (t2);
    1716                 :             : 
    1717                 :      270996 :     case POINTER_TYPE:
    1718                 :             :       /* Do not remove mode information.  */
    1719                 :      270996 :       if (TYPE_MODE (t1) != TYPE_MODE (t2))
    1720                 :             :         return false;
    1721                 :      270996 :       data->pointedto = true;
    1722                 :      270996 :       return comptypes_internal (TREE_TYPE (t1), TREE_TYPE (t2), data);
    1723                 :             : 
    1724                 :     8247856 :     case FUNCTION_TYPE:
    1725                 :     8247856 :       return function_types_compatible_p (t1, t2, data);
    1726                 :             : 
    1727                 :      150282 :     case ARRAY_TYPE:
    1728                 :      150282 :       {
    1729                 :      150282 :         tree d1 = TYPE_DOMAIN (t1);
    1730                 :      150282 :         tree d2 = TYPE_DOMAIN (t2);
    1731                 :      150282 :         bool d1_variable, d2_variable;
    1732                 :      150282 :         bool d1_zero, d2_zero;
    1733                 :             : 
    1734                 :             :         /* Target types must match incl. qualifiers.  */
    1735                 :      150282 :         if (!comptypes_internal (TREE_TYPE (t1), TREE_TYPE (t2), data))
    1736                 :             :           return false;
    1737                 :             : 
    1738                 :      116748 :         if ((d1 == NULL_TREE) != (d2 == NULL_TREE))
    1739                 :        6165 :           data->different_types_p = true;
    1740                 :             :         /* Ignore size mismatches when forming equivalence classes.  */
    1741                 :      116748 :         if (data->equiv)
    1742                 :             :           return true;
    1743                 :             :         /* Sizes must match unless one is missing or variable.  */
    1744                 :       49415 :         if (d1 == NULL_TREE || d2 == NULL_TREE || d1 == d2)
    1745                 :             :           return true;
    1746                 :             : 
    1747                 :       33331 :         d1_zero = !TYPE_MAX_VALUE (d1);
    1748                 :       33331 :         d2_zero = !TYPE_MAX_VALUE (d2);
    1749                 :             : 
    1750                 :       66662 :         d1_variable = (!d1_zero
    1751                 :       33331 :                        && (TREE_CODE (TYPE_MIN_VALUE (d1)) != INTEGER_CST
    1752                 :       33325 :                            || TREE_CODE (TYPE_MAX_VALUE (d1)) != INTEGER_CST));
    1753                 :       66662 :         d2_variable = (!d2_zero
    1754                 :       33331 :                        && (TREE_CODE (TYPE_MIN_VALUE (d2)) != INTEGER_CST
    1755                 :       33235 :                            || TREE_CODE (TYPE_MAX_VALUE (d2)) != INTEGER_CST));
    1756                 :             : 
    1757                 :       33331 :         if (d1_variable != d2_variable)
    1758                 :         740 :           data->different_types_p = true;
    1759                 :       33331 :         if (d1_variable || d2_variable)
    1760                 :             :           return true;
    1761                 :        4038 :         if (d1_zero && d2_zero)
    1762                 :             :           return true;
    1763                 :        4038 :         if (d1_zero || d2_zero
    1764                 :        3942 :             || !tree_int_cst_equal (TYPE_MIN_VALUE (d1), TYPE_MIN_VALUE (d2))
    1765                 :        7980 :             || !tree_int_cst_equal (TYPE_MAX_VALUE (d1), TYPE_MAX_VALUE (d2)))
    1766                 :        4038 :           return false;
    1767                 :             : 
    1768                 :             :         return true;
    1769                 :             :       }
    1770                 :             : 
    1771                 :    22844290 :     case ENUMERAL_TYPE:
    1772                 :    22844290 :     case RECORD_TYPE:
    1773                 :    22844290 :     case UNION_TYPE:
    1774                 :             : 
    1775                 :    22844290 :       if (!flag_isoc23)
    1776                 :             :         return false;
    1777                 :             : 
    1778                 :    22844244 :       return tagged_types_tu_compatible_p (t1, t2, data);
    1779                 :             : 
    1780                 :      516283 :     case VECTOR_TYPE:
    1781                 :     1032566 :       return known_eq (TYPE_VECTOR_SUBPARTS (t1), TYPE_VECTOR_SUBPARTS (t2))
    1782                 :      516283 :              && comptypes_internal (TREE_TYPE (t1), TREE_TYPE (t2), data);
    1783                 :             : 
    1784                 :             :     default:
    1785                 :             :       return false;
    1786                 :             :     }
    1787                 :             :   gcc_unreachable ();
    1788                 :             : }
    1789                 :             : 
    1790                 :             : /* Return true if TTL and TTR are pointers to types that are equivalent, ignoring
    1791                 :             :    their qualifiers, except for named address spaces.  If the pointers point to
    1792                 :             :    different named addresses, then we must determine if one address space is a
    1793                 :             :    subset of the other.  */
    1794                 :             : 
    1795                 :             : static bool
    1796                 :     1730522 : comp_target_types (location_t location, tree ttl, tree ttr)
    1797                 :             : {
    1798                 :     1730522 :   int val;
    1799                 :     1730522 :   int val_ped;
    1800                 :     1730522 :   tree mvl = TREE_TYPE (ttl);
    1801                 :     1730522 :   tree mvr = TREE_TYPE (ttr);
    1802                 :     1730522 :   addr_space_t asl = TYPE_ADDR_SPACE (mvl);
    1803                 :     1730522 :   addr_space_t asr = TYPE_ADDR_SPACE (mvr);
    1804                 :     1730522 :   addr_space_t as_common;
    1805                 :     1730522 :   bool enum_and_int_p;
    1806                 :             : 
    1807                 :             :   /* Fail if pointers point to incompatible address spaces.  */
    1808                 :     1730522 :   if (!addr_space_superset (asl, asr, &as_common))
    1809                 :             :     return 0;
    1810                 :             : 
    1811                 :             :   /* For pedantic record result of comptypes on arrays before losing
    1812                 :             :      qualifiers on the element type below. */
    1813                 :     1730522 :   val_ped = 1;
    1814                 :             : 
    1815                 :     1730522 :   if (TREE_CODE (mvl) == ARRAY_TYPE
    1816                 :        1953 :       && TREE_CODE (mvr) == ARRAY_TYPE)
    1817                 :        1930 :     val_ped = comptypes (mvl, mvr);
    1818                 :             : 
    1819                 :             :   /* Qualifiers on element types of array types that are
    1820                 :             :      pointer targets are also removed.  */
    1821                 :     1730522 :   mvl = remove_qualifiers (mvl);
    1822                 :     1730522 :   mvr = remove_qualifiers (mvr);
    1823                 :             : 
    1824                 :     1730522 :   enum_and_int_p = false;
    1825                 :     1730522 :   val = comptypes_check_enum_int (mvl, mvr, &enum_and_int_p);
    1826                 :             : 
    1827                 :     1730522 :   if (val == 1 && val_ped != 1)
    1828                 :         190 :     pedwarn_c11 (location, OPT_Wpedantic, "invalid use of pointers to arrays with different qualifiers "
    1829                 :             :                                           "in ISO C before C23");
    1830                 :             : 
    1831                 :     1730522 :   if (val == 2)
    1832                 :         126 :     pedwarn (location, OPT_Wpedantic, "types are not quite compatible");
    1833                 :             : 
    1834                 :     1730522 :   if (val == 1 && enum_and_int_p && warn_cxx_compat)
    1835                 :           2 :     warning_at (location, OPT_Wc___compat,
    1836                 :             :                 "pointer target types incompatible in C++");
    1837                 :             : 
    1838                 :     1730522 :   return val;
    1839                 :             : }
    1840                 :             : 
    1841                 :             : /* Subroutines of `comptypes'.  */
    1842                 :             : 
    1843                 :             : /* Return true if two 'struct', 'union', or 'enum' types T1 and T2 are
    1844                 :             :    compatible.  The two types are not the same (which has been
    1845                 :             :    checked earlier in comptypes_internal).  */
    1846                 :             : 
    1847                 :             : static bool
    1848                 :    22844244 : tagged_types_tu_compatible_p (const_tree t1, const_tree t2,
    1849                 :             :                               struct comptypes_data *data)
    1850                 :             : {
    1851                 :    22844244 :   tree s1, s2;
    1852                 :             : 
    1853                 :    22844244 :   if (c_type_tag (t1) != c_type_tag (t2))
    1854                 :             :     return false;
    1855                 :             : 
    1856                 :             :   /* When forming equivalence classes for TYPE_CANONICAL in C23, we treat
    1857                 :             :      structs with the same tag as equivalent, but only when they are targets
    1858                 :             :      of pointers inside other structs.  */
    1859                 :    18889795 :   if (data->equiv && data->pointedto)
    1860                 :             :     return true;
    1861                 :             : 
    1862                 :             :   /* Different types without tag are incompatible except as an anonymous
    1863                 :             :      field or when forming equivalence classes for TYPE_CANONICAL.  */
    1864                 :    18889761 :   if (!data->anon_field && !data->equiv && NULL_TREE == c_type_tag (t1))
    1865                 :             :     return false;
    1866                 :             : 
    1867                 :    14005218 :   if (!data->anon_field && TYPE_STUB_DECL (t1) != TYPE_STUB_DECL (t2))
    1868                 :    14004268 :     data->different_types_p = true;
    1869                 :             : 
    1870                 :             :   /* Incomplete types are incompatible inside a TU.  */
    1871                 :    14005218 :   if (TYPE_SIZE (t1) == NULL || TYPE_SIZE (t2) == NULL)
    1872                 :             :     return false;
    1873                 :             : 
    1874                 :    14005208 :   if (ENUMERAL_TYPE != TREE_CODE (t1)
    1875                 :    14005208 :       && (TYPE_REVERSE_STORAGE_ORDER (t1)
    1876                 :    14005153 :           != TYPE_REVERSE_STORAGE_ORDER (t2)))
    1877                 :             :     return false;
    1878                 :             : 
    1879                 :    14005198 :   if (TYPE_USER_ALIGN (t1) != TYPE_USER_ALIGN (t2))
    1880                 :      140822 :     data->different_types_p = true;
    1881                 :             : 
    1882                 :             :   /* For types already being looked at in some active
    1883                 :             :      invocation of this function, assume compatibility.
    1884                 :             :      The cache is built as a linked list on the stack
    1885                 :             :      with the head of the list passed downwards.  */
    1886                 :    14005198 :   for (const struct tagged_tu_seen_cache *t = data->cache;
    1887                 :    14014022 :        t != NULL; t = t->next)
    1888                 :        8935 :     if (t->t1 == t1 && t->t2 == t2)
    1889                 :             :       return true;
    1890                 :             : 
    1891                 :    14005087 :   const struct tagged_tu_seen_cache entry = { data->cache, t1, t2 };
    1892                 :             : 
    1893                 :    14005087 :   switch (TREE_CODE (t1))
    1894                 :             :     {
    1895                 :          55 :     case ENUMERAL_TYPE:
    1896                 :          55 :       {
    1897                 :          55 :         if (!comptypes (ENUM_UNDERLYING_TYPE (t1), ENUM_UNDERLYING_TYPE (t2)))
    1898                 :             :           return false;
    1899                 :             : 
    1900                 :             :         /* Speed up the case where the type values are in the same order.  */
    1901                 :          51 :         tree tv1 = TYPE_VALUES (t1);
    1902                 :          51 :         tree tv2 = TYPE_VALUES (t2);
    1903                 :             : 
    1904                 :          51 :         if (tv1 == tv2)
    1905                 :             :           return true;
    1906                 :             : 
    1907                 :          97 :         for (;tv1 && tv2; tv1 = TREE_CHAIN (tv1), tv2 = TREE_CHAIN (tv2))
    1908                 :             :           {
    1909                 :          58 :             if (TREE_PURPOSE (tv1) != TREE_PURPOSE (tv2))
    1910                 :             :               break;
    1911                 :             : 
    1912                 :          51 :             if (simple_cst_equal (DECL_INITIAL (TREE_VALUE (tv1)),
    1913                 :          51 :                                   DECL_INITIAL (TREE_VALUE (tv2))) != 1)
    1914                 :             :               break;
    1915                 :             :           }
    1916                 :             : 
    1917                 :          51 :         if (tv1 == NULL_TREE && tv2 == NULL_TREE)
    1918                 :             :           return true;
    1919                 :             : 
    1920                 :          12 :         if (tv1 == NULL_TREE || tv2 == NULL_TREE)
    1921                 :             :           return false;
    1922                 :             : 
    1923                 :          12 :         if (list_length (TYPE_VALUES (t1)) != list_length (TYPE_VALUES (t2)))
    1924                 :             :           return false;
    1925                 :             : 
    1926                 :          20 :         for (s1 = TYPE_VALUES (t1); s1; s1 = TREE_CHAIN (s1))
    1927                 :             :           {
    1928                 :          16 :             s2 = purpose_member (TREE_PURPOSE (s1), TYPE_VALUES (t2));
    1929                 :             : 
    1930                 :          16 :             if (s2 == NULL
    1931                 :          29 :                 || simple_cst_equal (DECL_INITIAL (TREE_VALUE (s1)),
    1932                 :          13 :                                      DECL_INITIAL (TREE_VALUE (s2))) != 1)
    1933                 :           8 :               return false;
    1934                 :             :           }
    1935                 :             : 
    1936                 :             :         return true;
    1937                 :             :       }
    1938                 :             : 
    1939                 :    14005032 :     case UNION_TYPE:
    1940                 :    14005032 :     case RECORD_TYPE:
    1941                 :             : 
    1942                 :    14005032 :         if (list_length (TYPE_FIELDS (t1)) != list_length (TYPE_FIELDS (t2)))
    1943                 :             :           return false;
    1944                 :             : 
    1945                 :    12167934 :         for (s1 = TYPE_FIELDS (t1), s2 = TYPE_FIELDS (t2);
    1946                 :    13677160 :              s1 && s2;
    1947                 :     1509226 :              s1 = DECL_CHAIN (s1), s2 = DECL_CHAIN (s2))
    1948                 :             :           {
    1949                 :    13614413 :             gcc_assert (TREE_CODE (s1) == FIELD_DECL);
    1950                 :    13614413 :             gcc_assert (TREE_CODE (s2) == FIELD_DECL);
    1951                 :             : 
    1952                 :    13614413 :             tree ft1 = TREE_TYPE (s1);
    1953                 :    13614413 :             tree ft2 = TREE_TYPE (s2);
    1954                 :             : 
    1955                 :    13614413 :             if (DECL_NAME (s1) != DECL_NAME (s2))
    1956                 :             :               return false;
    1957                 :             : 
    1958                 :    12040122 :             if (DECL_ALIGN (s1) != DECL_ALIGN (s2))
    1959                 :             :               return false;
    1960                 :             : 
    1961                 :     3192639 :             if (DECL_C_BIT_FIELD (s1) != DECL_C_BIT_FIELD (s2))
    1962                 :             :                return false;
    1963                 :             : 
    1964                 :     3192619 :             if (DECL_C_BIT_FIELD (s1))
    1965                 :             :               {
    1966                 :         496 :                 if (!tree_int_cst_equal (DECL_SIZE (s1), DECL_SIZE (s2)))
    1967                 :             :                   return false;
    1968                 :             : 
    1969                 :         342 :                 ft1 = DECL_BIT_FIELD_TYPE (s1);
    1970                 :         342 :                 ft2 = DECL_BIT_FIELD_TYPE (s2);
    1971                 :             :               }
    1972                 :             : 
    1973                 :     3192465 :             if (TREE_CODE (ft1) == ERROR_MARK || TREE_CODE (ft2) == ERROR_MARK)
    1974                 :             :               return false;
    1975                 :             : 
    1976                 :     3192464 :             data->anon_field = !DECL_NAME (s1);
    1977                 :     3192464 :             data->pointedto = false;
    1978                 :             : 
    1979                 :     3192464 :             const struct tagged_tu_seen_cache *cache = data->cache;
    1980                 :     3192464 :             data->cache = &entry;
    1981                 :     3192464 :             bool ret = comptypes_internal (ft1, ft2, data);
    1982                 :     3192464 :             data->cache = cache;
    1983                 :     3192464 :             if (!ret)
    1984                 :             :               return false;
    1985                 :             : 
    1986                 :     1576492 :             tree st1 = TYPE_SIZE (TREE_TYPE (s1));
    1987                 :     1576492 :             tree st2 = TYPE_SIZE (TREE_TYPE (s2));
    1988                 :             : 
    1989                 :     1576492 :             if (data->equiv
    1990                 :      983389 :                 && st1 && TREE_CODE (st1) == INTEGER_CST
    1991                 :      983353 :                 && st2 && TREE_CODE (st2) == INTEGER_CST
    1992                 :     2559842 :                 && !tree_int_cst_equal (st1, st2))
    1993                 :             :              return false;
    1994                 :             : 
    1995                 :     1509243 :             tree counted_by1 = lookup_attribute ("counted_by",
    1996                 :     1509243 :                                                  DECL_ATTRIBUTES (s1));
    1997                 :     1509243 :             tree counted_by2 = lookup_attribute ("counted_by",
    1998                 :     1509243 :                                                  DECL_ATTRIBUTES (s2));
    1999                 :             :             /* If there is no counted_by attribute for both fields.  */
    2000                 :     1509243 :             if (!counted_by1 && !counted_by2)
    2001                 :     1509216 :               continue;
    2002                 :             : 
    2003                 :             :             /* If only one field has counted_by attribute.  */
    2004                 :          27 :             if ((counted_by1 && !counted_by2)
    2005                 :          27 :                 || (!counted_by1 && counted_by2))
    2006                 :             :               return false;
    2007                 :             : 
    2008                 :             :             /* Now both s1 and s2 have counted_by attributes, check
    2009                 :             :                whether they are the same.  */
    2010                 :             : 
    2011                 :          21 :             tree counted_by_field1
    2012                 :          21 :               = lookup_field (t1, TREE_VALUE (TREE_VALUE (counted_by1)));
    2013                 :          21 :             tree counted_by_field2
    2014                 :          21 :               = lookup_field (t2, TREE_VALUE (TREE_VALUE (counted_by2)));
    2015                 :             : 
    2016                 :          21 :             gcc_assert (counted_by_field1 && counted_by_field2);
    2017                 :             : 
    2018                 :          42 :             while (TREE_CHAIN (counted_by_field1))
    2019                 :          21 :               counted_by_field1 = TREE_CHAIN (counted_by_field1);
    2020                 :          38 :             while (TREE_CHAIN (counted_by_field2))
    2021                 :          17 :               counted_by_field2 = TREE_CHAIN (counted_by_field2);
    2022                 :             : 
    2023                 :          21 :             if (DECL_NAME (TREE_VALUE (counted_by_field1))
    2024                 :          21 :                 != DECL_NAME (TREE_VALUE (counted_by_field2)))
    2025                 :             :               return false;
    2026                 :             :           }
    2027                 :             :         return true;
    2028                 :             : 
    2029                 :           0 :     default:
    2030                 :           0 :       gcc_unreachable ();
    2031                 :             :     }
    2032                 :             : }
    2033                 :             : 
    2034                 :             : /* Return true if two function types F1 and F2 are compatible.
    2035                 :             :    If either type specifies no argument types,
    2036                 :             :    the other must specify a fixed number of self-promoting arg types.
    2037                 :             :    Otherwise, if one type specifies only the number of arguments,
    2038                 :             :    the other must specify that number of self-promoting arg types.
    2039                 :             :    Otherwise, the argument types must match.  */
    2040                 :             : 
    2041                 :             : static bool
    2042                 :     8247856 : function_types_compatible_p (const_tree f1, const_tree f2,
    2043                 :             :                              struct comptypes_data *data)
    2044                 :             : {
    2045                 :     8247856 :   tree ret1 = TREE_TYPE (f1);
    2046                 :     8247856 :   tree ret2 = TREE_TYPE (f2);
    2047                 :             : 
    2048                 :             :   /* 'volatile' qualifiers on a function's return type used to mean
    2049                 :             :      the function is noreturn.  */
    2050                 :     8247856 :   if (TYPE_VOLATILE (ret1) != TYPE_VOLATILE (ret2))
    2051                 :          29 :     pedwarn (input_location, 0, "function return types not compatible due to %<volatile%>");
    2052                 :     8247856 :   if (TYPE_VOLATILE (ret1))
    2053                 :          15 :     ret1 = build_qualified_type (TYPE_MAIN_VARIANT (ret1),
    2054                 :          15 :                                  TYPE_QUALS (ret1) & ~TYPE_QUAL_VOLATILE);
    2055                 :     8247856 :   if (TYPE_VOLATILE (ret2))
    2056                 :          18 :     ret2 = build_qualified_type (TYPE_MAIN_VARIANT (ret2),
    2057                 :          18 :                                  TYPE_QUALS (ret2) & ~TYPE_QUAL_VOLATILE);
    2058                 :             : 
    2059                 :     8247856 :   bool ignore_pargs = data->ignore_promoting_args;
    2060                 :     8247856 :   data->ignore_promoting_args = false;
    2061                 :             : 
    2062                 :     8247856 :   if (!comptypes_internal (ret1, ret2, data))
    2063                 :             :     return false;
    2064                 :             : 
    2065                 :     8245269 :   data->ignore_promoting_args = ignore_pargs;
    2066                 :             : 
    2067                 :     8245269 :   tree args1 = TYPE_ARG_TYPES (f1);
    2068                 :     8245269 :   tree args2 = TYPE_ARG_TYPES (f2);
    2069                 :             : 
    2070                 :     8245269 :   if ((args1 == NULL_TREE) != (args2 == NULL_TREE))
    2071                 :       40965 :     data->different_types_p = true;
    2072                 :             : 
    2073                 :             :   /* An unspecified parmlist matches any specified parmlist
    2074                 :             :      whose argument types don't need default promotions.  */
    2075                 :             : 
    2076                 :     8245269 :   if (args1 == NULL_TREE)
    2077                 :             :     {
    2078                 :       21626 :       if (TYPE_NO_NAMED_ARGS_STDARG_P (f1) != TYPE_NO_NAMED_ARGS_STDARG_P (f2))
    2079                 :             :         return false;
    2080                 :       21621 :       if (!(data->ignore_promoting_args || self_promoting_args_p (args2)))
    2081                 :             :         return false;
    2082                 :       21151 :       data->ignore_promoting_args = false;
    2083                 :             :       /* If one of these types comes from a non-prototype fn definition,
    2084                 :             :          compare that with the other type's arglist.
    2085                 :             :          If they don't match, ask for a warning (but no error).  */
    2086                 :       21151 :       if (TYPE_ACTUAL_ARG_TYPES (f1)
    2087                 :       21151 :           && !type_lists_compatible_p (args2, TYPE_ACTUAL_ARG_TYPES (f1), data))
    2088                 :          12 :          data->warning_needed = true;
    2089                 :       21151 :       return true;
    2090                 :             :     }
    2091                 :     8223643 :   if (args2 == NULL_TREE)
    2092                 :             :     {
    2093                 :       19421 :       if (TYPE_NO_NAMED_ARGS_STDARG_P (f1) != TYPE_NO_NAMED_ARGS_STDARG_P (f2))
    2094                 :             :         return false;
    2095                 :       19417 :       if (!(data->ignore_promoting_args || self_promoting_args_p (args1)))
    2096                 :             :         return false;
    2097                 :       19356 :       data->ignore_promoting_args = false;
    2098                 :       19356 :       if (TYPE_ACTUAL_ARG_TYPES (f2)
    2099                 :       19356 :           && !type_lists_compatible_p (args1, TYPE_ACTUAL_ARG_TYPES (f2), data))
    2100                 :           1 :         data->warning_needed = true;
    2101                 :       19356 :       return true;
    2102                 :             :     }
    2103                 :             : 
    2104                 :             :   /* Both types have argument lists: compare them and propagate results.  */
    2105                 :     8204222 :   return type_lists_compatible_p (args1, args2, data);
    2106                 :             : }
    2107                 :             : 
    2108                 :             : /* Check two lists of types for compatibility, returning false for
    2109                 :             :    incompatible, true for compatible.  */
    2110                 :             : 
    2111                 :             : static bool
    2112                 :     8204298 : type_lists_compatible_p (const_tree args1, const_tree args2,
    2113                 :             :                          struct comptypes_data *data)
    2114                 :             : {
    2115                 :    51737996 :   while (1)
    2116                 :             :     {
    2117                 :    29971147 :       if (args1 == NULL_TREE && args2 == NULL_TREE)
    2118                 :             :         return true;
    2119                 :             :       /* If one list is shorter than the other,
    2120                 :             :          they fail to match.  */
    2121                 :    21909540 :       if (args1 == NULL_TREE || args2 == NULL_TREE)
    2122                 :             :         return false;
    2123                 :    21909533 :       tree a1 = TREE_VALUE (args1);
    2124                 :    21909533 :       tree a2 = TREE_VALUE (args2);
    2125                 :    21909533 :       tree mv1 = remove_qualifiers (a1);
    2126                 :    21909533 :       tree mv2 = remove_qualifiers (a2);
    2127                 :             :       /* A null pointer instead of a type
    2128                 :             :          means there is supposed to be an argument
    2129                 :             :          but nothing is specified about what type it has.
    2130                 :             :          So match anything that self-promotes.  */
    2131                 :    21909533 :       if ((a1 == NULL_TREE) != (a2 == NULL_TREE))
    2132                 :           0 :         data->different_types_p = true;
    2133                 :    21909533 :       if (a1 == NULL_TREE)
    2134                 :             :         {
    2135                 :           0 :           if (c_type_promotes_to (a2) != a2)
    2136                 :             :             return false;
    2137                 :             :         }
    2138                 :    21909533 :       else if (a2 == NULL_TREE)
    2139                 :             :         {
    2140                 :           0 :           if (c_type_promotes_to (a1) != a1)
    2141                 :             :             return false;
    2142                 :             :         }
    2143                 :             :       /* If one of the lists has an error marker, ignore this arg.  */
    2144                 :    21909533 :       else if (TREE_CODE (a1) == ERROR_MARK
    2145                 :    21909529 :                || TREE_CODE (a2) == ERROR_MARK)
    2146                 :             :         ;
    2147                 :    21909513 :       else if (!comptypes_internal (mv1, mv2, data))
    2148                 :             :         {
    2149                 :      142901 :           data->different_types_p = true;
    2150                 :             :           /* Allow  wait (union {union wait *u; int *i} *)
    2151                 :             :              and  wait (union wait *)  to be compatible.  */
    2152                 :      142901 :           if (TREE_CODE (a1) == UNION_TYPE
    2153                 :         122 :               && (TYPE_NAME (a1) == NULL_TREE
    2154                 :          94 :                   || TYPE_TRANSPARENT_AGGR (a1))
    2155                 :         122 :               && TREE_CODE (TYPE_SIZE (a1)) == INTEGER_CST
    2156                 :      143023 :               && tree_int_cst_equal (TYPE_SIZE (a1),
    2157                 :         122 :                                      TYPE_SIZE (a2)))
    2158                 :             :             {
    2159                 :         122 :               tree memb;
    2160                 :         122 :               for (memb = TYPE_FIELDS (a1);
    2161                 :         158 :                    memb; memb = DECL_CHAIN (memb))
    2162                 :             :                 {
    2163                 :         156 :                   tree mv3 = remove_qualifiers (TREE_TYPE (memb));
    2164                 :         156 :                   if (comptypes_internal (mv3, mv2, data))
    2165                 :             :                     break;
    2166                 :             :                 }
    2167                 :             :               if (memb == NULL_TREE)
    2168                 :             :                 return false;
    2169                 :             :             }
    2170                 :      142779 :           else if (TREE_CODE (a2) == UNION_TYPE
    2171                 :          99 :                    && (TYPE_NAME (a2) == NULL_TREE
    2172                 :          71 :                        || TYPE_TRANSPARENT_AGGR (a2))
    2173                 :          99 :                    && TREE_CODE (TYPE_SIZE (a2)) == INTEGER_CST
    2174                 :      142878 :                    && tree_int_cst_equal (TYPE_SIZE (a2),
    2175                 :          99 :                                           TYPE_SIZE (a1)))
    2176                 :             :             {
    2177                 :          99 :               tree memb;
    2178                 :          99 :               for (memb = TYPE_FIELDS (a2);
    2179                 :         127 :                    memb; memb = DECL_CHAIN (memb))
    2180                 :             :                 {
    2181                 :         125 :                   tree mv3 = remove_qualifiers (TREE_TYPE (memb));
    2182                 :         125 :                   if (comptypes_internal (mv3, mv1, data))
    2183                 :             :                     break;
    2184                 :             :                 }
    2185                 :             :               if (memb == NULL_TREE)
    2186                 :             :                 return false;
    2187                 :             :             }
    2188                 :             :           else
    2189                 :      142680 :             return false;
    2190                 :             :         }
    2191                 :             : 
    2192                 :    21766849 :       args1 = TREE_CHAIN (args1);
    2193                 :    21766849 :       args2 = TREE_CHAIN (args2);
    2194                 :    21766849 :     }
    2195                 :             : }
    2196                 :             : 
    2197                 :             : /* Compute the size to increment a pointer by.  When a function type or void
    2198                 :             :    type or incomplete type is passed, size_one_node is returned.
    2199                 :             :    This function does not emit any diagnostics; the caller is responsible
    2200                 :             :    for that.  */
    2201                 :             : 
    2202                 :             : static tree
    2203                 :      232556 : c_size_in_bytes (const_tree type)
    2204                 :             : {
    2205                 :      232556 :   enum tree_code code = TREE_CODE (type);
    2206                 :             : 
    2207                 :      232556 :   if (code == FUNCTION_TYPE || code == VOID_TYPE || code == ERROR_MARK
    2208                 :      232556 :       || !COMPLETE_TYPE_P (type))
    2209                 :         180 :     return size_one_node;
    2210                 :             : 
    2211                 :             :   /* Convert in case a char is more than one unit.  */
    2212                 :      232376 :   return size_binop_loc (input_location, CEIL_DIV_EXPR, TYPE_SIZE_UNIT (type),
    2213                 :      232376 :                          size_int (TYPE_PRECISION (char_type_node)
    2214                 :             :                                    / BITS_PER_UNIT));
    2215                 :             : }
    2216                 :             : 
    2217                 :             : /* Return either DECL or its known constant value (if it has one).  */
    2218                 :             : 
    2219                 :             : tree
    2220                 :    13963113 : decl_constant_value_1 (tree decl, bool in_init)
    2221                 :             : {
    2222                 :    13963113 :   if (/* Note that DECL_INITIAL isn't valid for a PARM_DECL.  */
    2223                 :    13963113 :       TREE_CODE (decl) != PARM_DECL
    2224                 :    13963113 :       && !TREE_THIS_VOLATILE (decl)
    2225                 :    13619715 :       && TREE_READONLY (decl)
    2226                 :       35611 :       && DECL_INITIAL (decl) != NULL_TREE
    2227                 :       34600 :       && !error_operand_p (DECL_INITIAL (decl))
    2228                 :             :       /* This is invalid if initial value is not constant.
    2229                 :             :          If it has either a function call, a memory reference,
    2230                 :             :          or a variable, then re-evaluating it could give different results.  */
    2231                 :       34591 :       && TREE_CONSTANT (DECL_INITIAL (decl))
    2232                 :             :       /* Check for cases where this is sub-optimal, even though valid.  */
    2233                 :    13984866 :       && (in_init || TREE_CODE (DECL_INITIAL (decl)) != CONSTRUCTOR))
    2234                 :       16558 :     return DECL_INITIAL (decl);
    2235                 :             :   return decl;
    2236                 :             : }
    2237                 :             : 
    2238                 :             : /* Return either DECL or its known constant value (if it has one).
    2239                 :             :    Like the above, but always return decl outside of functions.  */
    2240                 :             : 
    2241                 :             : tree
    2242                 :    13962928 : decl_constant_value (tree decl)
    2243                 :             : {
    2244                 :             :   /* Don't change a variable array bound or initial value to a constant
    2245                 :             :      in a place where a variable is invalid.  */
    2246                 :    13962928 :   return current_function_decl ? decl_constant_value_1 (decl, false) : decl;
    2247                 :             : }
    2248                 :             : 
    2249                 :             : /* Convert the array expression EXP to a pointer.  */
    2250                 :             : static tree
    2251                 :      809700 : array_to_pointer_conversion (location_t loc, tree exp)
    2252                 :             : {
    2253                 :      809700 :   tree orig_exp = exp;
    2254                 :      809700 :   tree type = TREE_TYPE (exp);
    2255                 :      809700 :   tree adr;
    2256                 :      809700 :   tree restype = TREE_TYPE (type);
    2257                 :      809700 :   tree ptrtype;
    2258                 :             : 
    2259                 :      809700 :   gcc_assert (TREE_CODE (type) == ARRAY_TYPE);
    2260                 :             : 
    2261                 :      809700 :   STRIP_TYPE_NOPS (exp);
    2262                 :             : 
    2263                 :      809700 :   copy_warning (exp, orig_exp);
    2264                 :             : 
    2265                 :      809700 :   ptrtype = c_build_pointer_type (restype);
    2266                 :             : 
    2267                 :      809700 :   if (INDIRECT_REF_P (exp))
    2268                 :        2877 :     return convert (ptrtype, TREE_OPERAND (exp, 0));
    2269                 :             : 
    2270                 :             :   /* In C++ array compound literals are temporary objects unless they are
    2271                 :             :      const or appear in namespace scope, so they are destroyed too soon
    2272                 :             :      to use them for much of anything  (c++/53220).  */
    2273                 :      806823 :   if (warn_cxx_compat && TREE_CODE (exp) == COMPOUND_LITERAL_EXPR)
    2274                 :             :     {
    2275                 :          48 :       tree decl = TREE_OPERAND (TREE_OPERAND (exp, 0), 0);
    2276                 :          48 :       if (!TREE_READONLY (decl) && !TREE_STATIC (decl))
    2277                 :          46 :         warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wc___compat,
    2278                 :             :                     "converting an array compound literal to a pointer "
    2279                 :             :                     "leads to a dangling pointer in C++");
    2280                 :             :     }
    2281                 :             : 
    2282                 :      806823 :   adr = build_unary_op (loc, ADDR_EXPR, exp, true);
    2283                 :      806823 :   return convert (ptrtype, adr);
    2284                 :             : }
    2285                 :             : 
    2286                 :             : /* Convert the function expression EXP to a pointer.  */
    2287                 :             : static tree
    2288                 :    49272312 : function_to_pointer_conversion (location_t loc, tree exp)
    2289                 :             : {
    2290                 :    49272312 :   tree orig_exp = exp;
    2291                 :             : 
    2292                 :    49272312 :   gcc_assert (TREE_CODE (TREE_TYPE (exp)) == FUNCTION_TYPE);
    2293                 :             : 
    2294                 :    49272312 :   STRIP_TYPE_NOPS (exp);
    2295                 :             : 
    2296                 :    49272312 :   copy_warning (exp, orig_exp);
    2297                 :             : 
    2298                 :    49272312 :   return build_unary_op (loc, ADDR_EXPR, exp, false);
    2299                 :             : }
    2300                 :             : 
    2301                 :             : /* Mark EXP as read, not just set, for set but not used -Wunused
    2302                 :             :    warning purposes.  */
    2303                 :             : 
    2304                 :             : void
    2305                 :   476347650 : mark_exp_read (tree exp)
    2306                 :             : {
    2307                 :   598625909 :   switch (TREE_CODE (exp))
    2308                 :             :     {
    2309                 :   197691095 :     case VAR_DECL:
    2310                 :   197691095 :     case PARM_DECL:
    2311                 :   197691095 :       DECL_READ_P (exp) = 1;
    2312                 :   197691095 :       break;
    2313                 :   119601369 :     case ARRAY_REF:
    2314                 :   119601369 :     case COMPONENT_REF:
    2315                 :   119601369 :     case MODIFY_EXPR:
    2316                 :   119601369 :     case REALPART_EXPR:
    2317                 :   119601369 :     case IMAGPART_EXPR:
    2318                 :   119601369 :     CASE_CONVERT:
    2319                 :   119601369 :     case ADDR_EXPR:
    2320                 :   119601369 :     case VIEW_CONVERT_EXPR:
    2321                 :   119601369 :       mark_exp_read (TREE_OPERAND (exp, 0));
    2322                 :   119601369 :       break;
    2323                 :      230222 :     case COMPOUND_EXPR:
    2324                 :             :       /* Pattern match what build_atomic_assign produces with modifycode
    2325                 :             :          NOP_EXPR.  */
    2326                 :      230222 :       if (VAR_P (TREE_OPERAND (exp, 1))
    2327                 :       27101 :           && DECL_ARTIFICIAL (TREE_OPERAND (exp, 1))
    2328                 :      257239 :           && TREE_CODE (TREE_OPERAND (exp, 0)) == COMPOUND_EXPR)
    2329                 :             :         {
    2330                 :        2112 :           tree t1 = TREE_OPERAND (TREE_OPERAND (exp, 0), 0);
    2331                 :        2112 :           tree t2 = TREE_OPERAND (TREE_OPERAND (exp, 0), 1);
    2332                 :        2112 :           if (TREE_CODE (t1) == TARGET_EXPR
    2333                 :        2104 :               && TARGET_EXPR_SLOT (t1) == TREE_OPERAND (exp, 1)
    2334                 :        4214 :               && TREE_CODE (t2) == CALL_EXPR)
    2335                 :             :             {
    2336                 :        2102 :               tree fndecl = get_callee_fndecl (t2);
    2337                 :        2102 :               tree arg = NULL_TREE;
    2338                 :        2102 :               if (fndecl
    2339                 :        2102 :                   && TREE_CODE (fndecl) == FUNCTION_DECL
    2340                 :        2102 :                   && fndecl_built_in_p (fndecl, BUILT_IN_NORMAL)
    2341                 :        4204 :                   && call_expr_nargs (t2) >= 2)
    2342                 :        2102 :                 switch (DECL_FUNCTION_CODE (fndecl))
    2343                 :             :                   {
    2344                 :         130 :                   case BUILT_IN_ATOMIC_STORE:
    2345                 :         130 :                     arg = CALL_EXPR_ARG (t2, 1);
    2346                 :         130 :                     break;
    2347                 :        1972 :                   case BUILT_IN_ATOMIC_STORE_1:
    2348                 :        1972 :                   case BUILT_IN_ATOMIC_STORE_2:
    2349                 :        1972 :                   case BUILT_IN_ATOMIC_STORE_4:
    2350                 :        1972 :                   case BUILT_IN_ATOMIC_STORE_8:
    2351                 :        1972 :                   case BUILT_IN_ATOMIC_STORE_16:
    2352                 :        1972 :                     arg = CALL_EXPR_ARG (t2, 0);
    2353                 :        1972 :                     break;
    2354                 :             :                   default:
    2355                 :             :                     break;
    2356                 :             :                   }
    2357                 :        2102 :               if (arg)
    2358                 :             :                 {
    2359                 :        2102 :                   STRIP_NOPS (arg);
    2360                 :        2102 :                   if (TREE_CODE (arg) == ADDR_EXPR
    2361                 :        2102 :                       && DECL_P (TREE_OPERAND (arg, 0))
    2362                 :        4204 :                       && TYPE_ATOMIC (TREE_TYPE (TREE_OPERAND (arg, 0))))
    2363                 :        2102 :                     mark_exp_read (TREE_OPERAND (arg, 0));
    2364                 :             :                 }
    2365                 :             :             }
    2366                 :             :         }
    2367                 :             :       /* FALLTHRU */
    2368                 :     2676365 :     case C_MAYBE_CONST_EXPR:
    2369                 :     2676365 :       mark_exp_read (TREE_OPERAND (exp, 1));
    2370                 :     2676365 :       break;
    2371                 :         560 :     case OMP_ARRAY_SECTION:
    2372                 :         560 :       mark_exp_read (TREE_OPERAND (exp, 0));
    2373                 :         560 :       if (TREE_OPERAND (exp, 1))
    2374                 :         377 :         mark_exp_read (TREE_OPERAND (exp, 1));
    2375                 :         560 :       if (TREE_OPERAND (exp, 2))
    2376                 :         525 :         mark_exp_read (TREE_OPERAND (exp, 2));
    2377                 :             :       break;
    2378                 :             :     default:
    2379                 :             :       break;
    2380                 :             :     }
    2381                 :   476347650 : }
    2382                 :             : 
    2383                 :             : /* Perform the default conversion of arrays and functions to pointers.
    2384                 :             :    Return the result of converting EXP.  For any other expression, just
    2385                 :             :    return EXP.
    2386                 :             : 
    2387                 :             :    LOC is the location of the expression.  */
    2388                 :             : 
    2389                 :             : struct c_expr
    2390                 :   352551145 : default_function_array_conversion (location_t loc, struct c_expr exp)
    2391                 :             : {
    2392                 :   352551145 :   tree orig_exp = exp.value;
    2393                 :   352551145 :   tree type = TREE_TYPE (exp.value);
    2394                 :   352551145 :   enum tree_code code = TREE_CODE (type);
    2395                 :             : 
    2396                 :   352551145 :   switch (code)
    2397                 :             :     {
    2398                 :             :     case ARRAY_TYPE:
    2399                 :             :       {
    2400                 :             :         bool not_lvalue = false;
    2401                 :             :         bool lvalue_array_p;
    2402                 :             : 
    2403                 :      762898 :         while ((TREE_CODE (exp.value) == NON_LVALUE_EXPR
    2404                 :      762898 :                 || CONVERT_EXPR_P (exp.value))
    2405                 :      762898 :                && TREE_TYPE (TREE_OPERAND (exp.value, 0)) == type)
    2406                 :             :           {
    2407                 :           0 :             if (TREE_CODE (exp.value) == NON_LVALUE_EXPR)
    2408                 :           0 :               not_lvalue = true;
    2409                 :           0 :             exp.value = TREE_OPERAND (exp.value, 0);
    2410                 :             :           }
    2411                 :             : 
    2412                 :      762898 :         copy_warning (exp.value, orig_exp);
    2413                 :             : 
    2414                 :      762898 :         lvalue_array_p = !not_lvalue && lvalue_p (exp.value);
    2415                 :      762898 :         if (!flag_isoc99 && !lvalue_array_p)
    2416                 :             :           {
    2417                 :             :             /* Before C99, non-lvalue arrays do not decay to pointers.
    2418                 :             :                Normally, using such an array would be invalid; but it can
    2419                 :             :                be used correctly inside sizeof or as a statement expression.
    2420                 :             :                Thus, do not give an error here; an error will result later.  */
    2421                 :         108 :             return exp;
    2422                 :             :           }
    2423                 :             : 
    2424                 :      762790 :         exp.value = array_to_pointer_conversion (loc, exp.value);
    2425                 :             :       }
    2426                 :      762790 :       break;
    2427                 :      761627 :     case FUNCTION_TYPE:
    2428                 :      761627 :       exp.value = function_to_pointer_conversion (loc, exp.value);
    2429                 :      761627 :       break;
    2430                 :             :     default:
    2431                 :             :       break;
    2432                 :             :     }
    2433                 :             : 
    2434                 :   352551037 :   return exp;
    2435                 :             : }
    2436                 :             : 
    2437                 :             : struct c_expr
    2438                 :      925261 : default_function_array_read_conversion (location_t loc, struct c_expr exp)
    2439                 :             : {
    2440                 :      925261 :   mark_exp_read (exp.value);
    2441                 :      925261 :   return default_function_array_conversion (loc, exp);
    2442                 :             : }
    2443                 :             : 
    2444                 :             : /* Return whether EXPR should be treated as an atomic lvalue for the
    2445                 :             :    purposes of load and store handling.  */
    2446                 :             : 
    2447                 :             : static bool
    2448                 :   353618900 : really_atomic_lvalue (tree expr)
    2449                 :             : {
    2450                 :   353618900 :   if (error_operand_p (expr))
    2451                 :             :     return false;
    2452                 :   353611280 :   if (!TYPE_ATOMIC (TREE_TYPE (expr)))
    2453                 :             :     return false;
    2454                 :       56796 :   if (!lvalue_p (expr))
    2455                 :             :     return false;
    2456                 :             : 
    2457                 :             :   /* Ignore _Atomic on register variables, since their addresses can't
    2458                 :             :      be taken so (a) atomicity is irrelevant and (b) the normal atomic
    2459                 :             :      sequences wouldn't work.  Ignore _Atomic on structures containing
    2460                 :             :      bit-fields, since accessing elements of atomic structures or
    2461                 :             :      unions is undefined behavior (C11 6.5.2.3#5), but it's unclear if
    2462                 :             :      it's undefined at translation time or execution time, and the
    2463                 :             :      normal atomic sequences again wouldn't work.  */
    2464                 :       56830 :   while (handled_component_p (expr))
    2465                 :             :     {
    2466                 :          36 :       if (TREE_CODE (expr) == COMPONENT_REF
    2467                 :          36 :           && DECL_C_BIT_FIELD (TREE_OPERAND (expr, 1)))
    2468                 :             :         return false;
    2469                 :          36 :       expr = TREE_OPERAND (expr, 0);
    2470                 :             :     }
    2471                 :       56794 :   if (DECL_P (expr) && C_DECL_REGISTER (expr))
    2472                 :             :     return false;
    2473                 :             :   return true;
    2474                 :             : }
    2475                 :             : 
    2476                 :             : /* If EXPR is a named constant (C23) derived from a constexpr variable
    2477                 :             :    - that is, a reference to such a variable, or a member extracted by
    2478                 :             :    a sequence of structure and union (but not array) member accesses
    2479                 :             :    (where union member accesses must access the same member as
    2480                 :             :    initialized) - then return the corresponding initializer;
    2481                 :             :    otherwise, return NULL_TREE.  */
    2482                 :             : 
    2483                 :             : static tree
    2484                 :   350491148 : maybe_get_constexpr_init (tree expr)
    2485                 :             : {
    2486                 :   350491148 :   tree decl = NULL_TREE;
    2487                 :   350491148 :   if (TREE_CODE (expr) == VAR_DECL)
    2488                 :             :     decl = expr;
    2489                 :   339170248 :   else if (TREE_CODE (expr) == COMPOUND_LITERAL_EXPR)
    2490                 :      802307 :     decl = COMPOUND_LITERAL_EXPR_DECL (expr);
    2491                 :      802307 :   if (decl
    2492                 :    12123207 :       && C_DECL_DECLARED_CONSTEXPR (decl)
    2493                 :         350 :       && DECL_INITIAL (decl) != NULL_TREE
    2494                 :      802657 :       && !error_operand_p (DECL_INITIAL (decl)))
    2495                 :         350 :     return DECL_INITIAL (decl);
    2496                 :   350490798 :   if (TREE_CODE (expr) != COMPONENT_REF)
    2497                 :             :     return NULL_TREE;
    2498                 :      846502 :   tree inner = maybe_get_constexpr_init (TREE_OPERAND (expr, 0));
    2499                 :      846502 :   if (inner == NULL_TREE)
    2500                 :             :     return NULL_TREE;
    2501                 :         126 :   while ((CONVERT_EXPR_P (inner) || TREE_CODE (inner) == NON_LVALUE_EXPR)
    2502                 :          47 :          && !error_operand_p (inner)
    2503                 :         220 :          && (TYPE_MAIN_VARIANT (TREE_TYPE (inner))
    2504                 :          47 :              == TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (inner, 0)))))
    2505                 :          47 :     inner = TREE_OPERAND (inner, 0);
    2506                 :         126 :   if (TREE_CODE (inner) != CONSTRUCTOR)
    2507                 :             :     return NULL_TREE;
    2508                 :         126 :   tree field = TREE_OPERAND (expr, 1);
    2509                 :         126 :   unsigned HOST_WIDE_INT cidx;
    2510                 :         126 :   tree cfield, cvalue;
    2511                 :         126 :   bool have_other_init = false;
    2512                 :         266 :   FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (inner), cidx, cfield, cvalue)
    2513                 :             :     {
    2514                 :         250 :       if (cfield == field)
    2515                 :             :         return cvalue;
    2516                 :         140 :       have_other_init = true;
    2517                 :             :     }
    2518                 :          16 :   if (TREE_CODE (TREE_TYPE (inner)) == UNION_TYPE
    2519                 :          16 :       && (have_other_init || field != TYPE_FIELDS (TREE_TYPE (inner))))
    2520                 :             :     return NULL_TREE;
    2521                 :             :   /* Return a default initializer.  */
    2522                 :          13 :   if (RECORD_OR_UNION_TYPE_P (TREE_TYPE (expr)))
    2523                 :           5 :     return build_constructor (TREE_TYPE (expr), NULL);
    2524                 :           8 :   return build_zero_cst (TREE_TYPE (expr));
    2525                 :             : }
    2526                 :             : 
    2527                 :             : /* Convert expression EXP (location LOC) from lvalue to rvalue,
    2528                 :             :    including converting functions and arrays to pointers if CONVERT_P.
    2529                 :             :    If READ_P, also mark the expression as having been read.  If
    2530                 :             :    FOR_INIT, constexpr expressions of structure and union type should
    2531                 :             :    be replaced by the corresponding CONSTRUCTOR; otherwise, only
    2532                 :             :    constexpr scalars (including elements of structures and unions) are
    2533                 :             :    replaced by their initializers.  */
    2534                 :             : 
    2535                 :             : struct c_expr
    2536                 :   349830655 : convert_lvalue_to_rvalue (location_t loc, struct c_expr exp,
    2537                 :             :                           bool convert_p, bool read_p, bool for_init)
    2538                 :             : {
    2539                 :   349830655 :   bool force_non_npc = false;
    2540                 :   349830655 :   if (read_p)
    2541                 :   306931065 :     mark_exp_read (exp.value);
    2542                 :   349830655 :   if (convert_p)
    2543                 :   349817531 :     exp = default_function_array_conversion (loc, exp);
    2544                 :   349830655 :   if (!VOID_TYPE_P (TREE_TYPE (exp.value)))
    2545                 :   347402518 :     exp.value = require_complete_type (loc, exp.value);
    2546                 :   349830655 :   if (for_init || !RECORD_OR_UNION_TYPE_P (TREE_TYPE (exp.value)))
    2547                 :             :     {
    2548                 :   349644646 :       tree init = maybe_get_constexpr_init (exp.value);
    2549                 :   349644646 :       if (init != NULL_TREE)
    2550                 :             :         {
    2551                 :             :           /* A named constant of pointer type or type nullptr_t is not
    2552                 :             :              a null pointer constant even if the initializer is
    2553                 :             :              one.  */
    2554                 :         347 :           if (TREE_CODE (init) == INTEGER_CST
    2555                 :         212 :               && !INTEGRAL_TYPE_P (TREE_TYPE (init))
    2556                 :         373 :               && integer_zerop (init))
    2557                 :             :             force_non_npc = true;
    2558                 :             :           exp.value = init;
    2559                 :             :         }
    2560                 :             :     }
    2561                 :   349830655 :   if (really_atomic_lvalue (exp.value))
    2562                 :             :     {
    2563                 :       26495 :       vec<tree, va_gc> *params;
    2564                 :       26495 :       tree nonatomic_type, tmp, tmp_addr, fndecl, func_call;
    2565                 :       26495 :       tree expr_type = TREE_TYPE (exp.value);
    2566                 :       26495 :       tree expr_addr = build_unary_op (loc, ADDR_EXPR, exp.value, false);
    2567                 :       26495 :       tree seq_cst = build_int_cst (integer_type_node, MEMMODEL_SEQ_CST);
    2568                 :             : 
    2569                 :       26495 :       gcc_assert (TYPE_ATOMIC (expr_type));
    2570                 :             : 
    2571                 :             :       /* Expansion of a generic atomic load may require an addition
    2572                 :             :          element, so allocate enough to prevent a resize.  */
    2573                 :       26495 :       vec_alloc (params, 4);
    2574                 :             : 
    2575                 :             :       /* Remove the qualifiers for the rest of the expressions and
    2576                 :             :          create the VAL temp variable to hold the RHS.  */
    2577                 :       26495 :       nonatomic_type = build_qualified_type (expr_type, TYPE_UNQUALIFIED);
    2578                 :       26495 :       tmp = create_tmp_var_raw (nonatomic_type);
    2579                 :       26495 :       tmp_addr = build_unary_op (loc, ADDR_EXPR, tmp, false);
    2580                 :       26495 :       TREE_ADDRESSABLE (tmp) = 1;
    2581                 :             :       /* Do not disable warnings for TMP even though it's artificial.
    2582                 :             :          -Winvalid-memory-model depends on it.  */
    2583                 :             : 
    2584                 :             :       /* Issue __atomic_load (&expr, &tmp, SEQ_CST);  */
    2585                 :       26495 :       fndecl = builtin_decl_explicit (BUILT_IN_ATOMIC_LOAD);
    2586                 :       26495 :       params->quick_push (expr_addr);
    2587                 :       26495 :       params->quick_push (tmp_addr);
    2588                 :       26495 :       params->quick_push (seq_cst);
    2589                 :       26495 :       func_call = c_build_function_call_vec (loc, vNULL, fndecl, params, NULL);
    2590                 :             : 
    2591                 :             :       /* EXPR is always read.  */
    2592                 :       26495 :       mark_exp_read (exp.value);
    2593                 :             : 
    2594                 :             :       /* Return tmp which contains the value loaded.  */
    2595                 :       26495 :       exp.value = build4 (TARGET_EXPR, nonatomic_type, tmp, func_call,
    2596                 :             :                           NULL_TREE, NULL_TREE);
    2597                 :             :     }
    2598                 :   349817531 :   if (convert_p && !error_operand_p (exp.value)
    2599                 :   699640610 :       && (TREE_CODE (TREE_TYPE (exp.value)) != ARRAY_TYPE))
    2600                 :   349809847 :     exp.value = convert (build_qualified_type (TREE_TYPE (exp.value), TYPE_UNQUALIFIED), exp.value);
    2601                 :   349830655 :   if (force_non_npc)
    2602                 :          24 :     exp.value = build1 (NOP_EXPR, TREE_TYPE (exp.value), exp.value);
    2603                 :             : 
    2604                 :   349830655 :   {
    2605                 :   349830655 :     tree false_value, true_value;
    2606                 :   349817531 :     if (convert_p && !error_operand_p (exp.value)
    2607                 :   699640610 :         && c_hardbool_type_attr (TREE_TYPE (exp.value),
    2608                 :             :                                  &false_value, &true_value))
    2609                 :             :       {
    2610                 :        3445 :         tree t = save_expr (exp.value);
    2611                 :             : 
    2612                 :        3445 :         mark_exp_read (exp.value);
    2613                 :             : 
    2614                 :        3445 :         tree trapfn = builtin_decl_explicit (BUILT_IN_TRAP);
    2615                 :        3445 :         tree expr = build_call_expr_loc (loc, trapfn, 0);
    2616                 :        3445 :         expr = build_compound_expr (loc, expr, boolean_true_node);
    2617                 :        3445 :         expr = fold_build3_loc (loc, COND_EXPR, boolean_type_node,
    2618                 :             :                                 fold_build2_loc (loc, NE_EXPR,
    2619                 :             :                                                  boolean_type_node,
    2620                 :             :                                                  t, true_value),
    2621                 :             :                                 expr, boolean_true_node);
    2622                 :        3445 :         expr = fold_build3_loc (loc, COND_EXPR, boolean_type_node,
    2623                 :             :                                 fold_build2_loc (loc, NE_EXPR,
    2624                 :             :                                                  boolean_type_node,
    2625                 :             :                                                  t, false_value),
    2626                 :             :                                 expr, boolean_false_node);
    2627                 :             : 
    2628                 :        3445 :         exp.value = expr;
    2629                 :             :       }
    2630                 :             :   }
    2631                 :             : 
    2632                 :   349830655 :   return exp;
    2633                 :             : }
    2634                 :             : 
    2635                 :             : /* EXP is an expression of integer type.  Apply the integer promotions
    2636                 :             :    to it and return the promoted value.  */
    2637                 :             : 
    2638                 :             : tree
    2639                 :    74222788 : perform_integral_promotions (tree exp)
    2640                 :             : {
    2641                 :    74222788 :   tree type = TREE_TYPE (exp);
    2642                 :    74222788 :   enum tree_code code = TREE_CODE (type);
    2643                 :             : 
    2644                 :    74222788 :   gcc_assert (INTEGRAL_TYPE_P (type));
    2645                 :             : 
    2646                 :             :   /* Convert enums to the result of applying the integer promotions to
    2647                 :             :      their underlying type.  */
    2648                 :    74222788 :   if (code == ENUMERAL_TYPE)
    2649                 :             :     {
    2650                 :      634196 :       type = ENUM_UNDERLYING_TYPE (type);
    2651                 :      634196 :       if (c_promoting_integer_type_p (type))
    2652                 :             :         {
    2653                 :          92 :           if (TYPE_UNSIGNED (type)
    2654                 :          92 :               && TYPE_PRECISION (type) == TYPE_PRECISION (integer_type_node))
    2655                 :           0 :             type = unsigned_type_node;
    2656                 :             :           else
    2657                 :          92 :             type = integer_type_node;
    2658                 :             :         }
    2659                 :             : 
    2660                 :      634196 :       return convert (type, exp);
    2661                 :             :     }
    2662                 :             : 
    2663                 :             :   /* ??? This should no longer be needed now bit-fields have their
    2664                 :             :      proper types.  */
    2665                 :    73588592 :   if (TREE_CODE (exp) == COMPONENT_REF
    2666                 :    73588592 :       && DECL_C_BIT_FIELD (TREE_OPERAND (exp, 1)))
    2667                 :             :     {
    2668                 :       62144 :       if (TREE_CODE (DECL_BIT_FIELD_TYPE (TREE_OPERAND (exp, 1)))
    2669                 :             :           == BITINT_TYPE)
    2670                 :         454 :         return convert (DECL_BIT_FIELD_TYPE (TREE_OPERAND (exp, 1)), exp);
    2671                 :             :       /* If it's thinner than an int, promote it like a
    2672                 :             :          c_promoting_integer_type_p, otherwise leave it alone.  */
    2673                 :       61690 :       if (compare_tree_int (DECL_SIZE (TREE_OPERAND (exp, 1)),
    2674                 :       61690 :                             TYPE_PRECISION (integer_type_node)) < 0)
    2675                 :       53428 :         return convert (integer_type_node, exp);
    2676                 :             :     }
    2677                 :             : 
    2678                 :    73534710 :   if (c_promoting_integer_type_p (type))
    2679                 :             :     {
    2680                 :             :       /* Preserve unsignedness if not really getting any wider.  */
    2681                 :      622666 :       if (TYPE_UNSIGNED (type)
    2682                 :      622666 :           && TYPE_PRECISION (type) == TYPE_PRECISION (integer_type_node))
    2683                 :           0 :         return convert (unsigned_type_node, exp);
    2684                 :             : 
    2685                 :      622666 :       return convert (integer_type_node, exp);
    2686                 :             :     }
    2687                 :             : 
    2688                 :             :   return exp;
    2689                 :             : }
    2690                 :             : 
    2691                 :             : 
    2692                 :             : /* Perform default promotions for C data used in expressions.
    2693                 :             :    Enumeral types or short or char are converted to int.
    2694                 :             :    In addition, manifest constants symbols are replaced by their values.  */
    2695                 :             : 
    2696                 :             : tree
    2697                 :    83527676 : default_conversion (tree exp)
    2698                 :             : {
    2699                 :    83527676 :   tree orig_exp;
    2700                 :    83527676 :   tree type = TREE_TYPE (exp);
    2701                 :    83527676 :   enum tree_code code = TREE_CODE (type);
    2702                 :    83527676 :   tree promoted_type;
    2703                 :             : 
    2704                 :    83527676 :   mark_exp_read (exp);
    2705                 :             : 
    2706                 :             :   /* Functions and arrays have been converted during parsing.  */
    2707                 :    83527676 :   gcc_assert (code != FUNCTION_TYPE);
    2708                 :    83527676 :   if (code == ARRAY_TYPE)
    2709                 :             :     return exp;
    2710                 :             : 
    2711                 :             :   /* Constants can be used directly unless they're not loadable.  */
    2712                 :    83527517 :   if (TREE_CODE (exp) == CONST_DECL)
    2713                 :           0 :     exp = DECL_INITIAL (exp);
    2714                 :             : 
    2715                 :             :   /* Strip no-op conversions.  */
    2716                 :    83527517 :   orig_exp = exp;
    2717                 :    83893461 :   STRIP_TYPE_NOPS (exp);
    2718                 :             : 
    2719                 :    83527517 :   copy_warning (exp, orig_exp);
    2720                 :             : 
    2721                 :    83527517 :   if (code == VOID_TYPE)
    2722                 :             :     {
    2723                 :           2 :       error_at (EXPR_LOC_OR_LOC (exp, input_location),
    2724                 :             :                 "void value not ignored as it ought to be");
    2725                 :           2 :       return error_mark_node;
    2726                 :             :     }
    2727                 :             : 
    2728                 :    83527515 :   exp = require_complete_type (EXPR_LOC_OR_LOC (exp, input_location), exp);
    2729                 :    83527515 :   if (exp == error_mark_node)
    2730                 :             :     return error_mark_node;
    2731                 :             : 
    2732                 :    83526617 :   promoted_type = targetm.promoted_type (type);
    2733                 :    83526617 :   if (promoted_type)
    2734                 :           0 :     return convert (promoted_type, exp);
    2735                 :             : 
    2736                 :    83526617 :   if (INTEGRAL_TYPE_P (type))
    2737                 :    73231338 :     return perform_integral_promotions (exp);
    2738                 :             : 
    2739                 :             :   return exp;
    2740                 :             : }
    2741                 :             : 
    2742                 :             : /* Look up COMPONENT in a structure or union TYPE.
    2743                 :             : 
    2744                 :             :    If the component name is not found, returns NULL_TREE.  Otherwise,
    2745                 :             :    the return value is a TREE_LIST, with each TREE_VALUE a FIELD_DECL
    2746                 :             :    stepping down the chain to the component, which is in the last
    2747                 :             :    TREE_VALUE of the list.  Normally the list is of length one, but if
    2748                 :             :    the component is embedded within (nested) anonymous structures or
    2749                 :             :    unions, the list steps down the chain to the component.  */
    2750                 :             : 
    2751                 :             : tree
    2752                 :     2267574 : lookup_field (const_tree type, tree component)
    2753                 :             : {
    2754                 :     2267574 :   tree field;
    2755                 :             : 
    2756                 :             :   /* If TYPE_LANG_SPECIFIC is set, then it is a sorted array of pointers
    2757                 :             :      to the field elements.  Use a binary search on this array to quickly
    2758                 :             :      find the element.  Otherwise, do a linear search.  TYPE_LANG_SPECIFIC
    2759                 :             :      will always be set for structures which have many elements.
    2760                 :             : 
    2761                 :             :      Duplicate field checking replaces duplicates with NULL_TREE so
    2762                 :             :      TYPE_LANG_SPECIFIC arrays are potentially no longer sorted.  In that
    2763                 :             :      case just iterate using DECL_CHAIN.  */
    2764                 :             : 
    2765                 :     2563800 :   if (TYPE_LANG_SPECIFIC (type) && TYPE_LANG_SPECIFIC (type)->s
    2766                 :     2563800 :       && !seen_error ())
    2767                 :             :     {
    2768                 :      296205 :       int bot, top, half;
    2769                 :      296205 :       tree *field_array = &TYPE_LANG_SPECIFIC (type)->s->elts[0];
    2770                 :             : 
    2771                 :      296205 :       field = TYPE_FIELDS (type);
    2772                 :      296205 :       bot = 0;
    2773                 :      296205 :       top = TYPE_LANG_SPECIFIC (type)->s->len;
    2774                 :     1349018 :       while (top - bot > 1)
    2775                 :             :         {
    2776                 :     1319988 :           half = (top - bot + 1) >> 1;
    2777                 :     1319988 :           field = field_array[bot+half];
    2778                 :             : 
    2779                 :     1319988 :           if (DECL_NAME (field) == NULL_TREE)
    2780                 :             :             {
    2781                 :             :               /* Step through all anon unions in linear fashion.  */
    2782                 :           0 :               while (DECL_NAME (field_array[bot]) == NULL_TREE)
    2783                 :             :                 {
    2784                 :           0 :                   field = field_array[bot++];
    2785                 :           0 :                   if (RECORD_OR_UNION_TYPE_P (TREE_TYPE (field)))
    2786                 :             :                     {
    2787                 :           0 :                       tree anon = lookup_field (TREE_TYPE (field), component);
    2788                 :             : 
    2789                 :           0 :                       if (anon)
    2790                 :           0 :                         return tree_cons (NULL_TREE, field, anon);
    2791                 :             : 
    2792                 :             :                       /* The Plan 9 compiler permits referring
    2793                 :             :                          directly to an anonymous struct/union field
    2794                 :             :                          using a typedef name.  */
    2795                 :           0 :                       if (flag_plan9_extensions
    2796                 :           0 :                           && TYPE_NAME (TREE_TYPE (field)) != NULL_TREE
    2797                 :           0 :                           && (TREE_CODE (TYPE_NAME (TREE_TYPE (field)))
    2798                 :             :                               == TYPE_DECL)
    2799                 :           0 :                           && (DECL_NAME (TYPE_NAME (TREE_TYPE (field)))
    2800                 :             :                               == component))
    2801                 :             :                         break;
    2802                 :             :                     }
    2803                 :             :                 }
    2804                 :             : 
    2805                 :             :               /* Entire record is only anon unions.  */
    2806                 :           0 :               if (bot > top)
    2807                 :             :                 return NULL_TREE;
    2808                 :             : 
    2809                 :             :               /* Restart the binary search, with new lower bound.  */
    2810                 :           0 :               continue;
    2811                 :           0 :             }
    2812                 :             : 
    2813                 :     1319988 :           if (DECL_NAME (field) == component)
    2814                 :             :             break;
    2815                 :     1052813 :           if (DECL_NAME (field) < component)
    2816                 :             :             bot += half;
    2817                 :             :           else
    2818                 :      851940 :             top = bot + half;
    2819                 :             :         }
    2820                 :             : 
    2821                 :      296205 :       if (DECL_NAME (field_array[bot]) == component)
    2822                 :             :         field = field_array[bot];
    2823                 :      267175 :       else if (DECL_NAME (field) != component)
    2824                 :             :         return NULL_TREE;
    2825                 :             :     }
    2826                 :             :   else
    2827                 :             :     {
    2828                 :     5162997 :       for (field = TYPE_FIELDS (type); field; field = DECL_CHAIN (field))
    2829                 :             :         {
    2830                 :     5154261 :           if (DECL_NAME (field) == NULL_TREE
    2831                 :     5154261 :               && RECORD_OR_UNION_TYPE_P (TREE_TYPE (field)))
    2832                 :             :             {
    2833                 :       10851 :               tree anon = lookup_field (TREE_TYPE (field), component);
    2834                 :             : 
    2835                 :       10851 :               if (anon)
    2836                 :        2189 :                 return tree_cons (NULL_TREE, field, anon);
    2837                 :             : 
    2838                 :             :               /* The Plan 9 compiler permits referring directly to an
    2839                 :             :                  anonymous struct/union field using a typedef
    2840                 :             :                  name.  */
    2841                 :        8662 :               if (flag_plan9_extensions
    2842                 :          38 :                   && TYPE_NAME (TREE_TYPE (field)) != NULL_TREE
    2843                 :          36 :                   && TREE_CODE (TYPE_NAME (TREE_TYPE (field))) == TYPE_DECL
    2844                 :        8668 :                   && (DECL_NAME (TYPE_NAME (TREE_TYPE (field)))
    2845                 :             :                       == component))
    2846                 :             :                 break;
    2847                 :             :             }
    2848                 :             : 
    2849                 :     5152068 :           if (DECL_NAME (field) == component)
    2850                 :             :             break;
    2851                 :             :         }
    2852                 :             : 
    2853                 :     1969180 :       if (field == NULL_TREE)
    2854                 :             :         return NULL_TREE;
    2855                 :             :     }
    2856                 :             : 
    2857                 :     2256649 :   return tree_cons (NULL_TREE, field, NULL_TREE);
    2858                 :             : }
    2859                 :             : 
    2860                 :             : /* Recursively append candidate IDENTIFIER_NODEs to CANDIDATES.  */
    2861                 :             : 
    2862                 :             : static void
    2863                 :         102 : lookup_field_fuzzy_find_candidates (tree type, tree component,
    2864                 :             :                                     vec<tree> *candidates)
    2865                 :             : {
    2866                 :         102 :   tree field;
    2867                 :         260 :   for (field = TYPE_FIELDS (type); field; field = DECL_CHAIN (field))
    2868                 :             :     {
    2869                 :         158 :       if (DECL_NAME (field) == NULL_TREE
    2870                 :         158 :           && RECORD_OR_UNION_TYPE_P (TREE_TYPE (field)))
    2871                 :          30 :         lookup_field_fuzzy_find_candidates (TREE_TYPE (field), component,
    2872                 :             :                                             candidates);
    2873                 :             : 
    2874                 :         158 :       if (DECL_NAME (field))
    2875                 :         112 :         candidates->safe_push (DECL_NAME (field));
    2876                 :             :     }
    2877                 :         102 : }
    2878                 :             : 
    2879                 :             : /* Like "lookup_field", but find the closest matching IDENTIFIER_NODE,
    2880                 :             :    rather than returning a TREE_LIST for an exact match.  */
    2881                 :             : 
    2882                 :             : static tree
    2883                 :          72 : lookup_field_fuzzy (tree type, tree component)
    2884                 :             : {
    2885                 :          72 :   gcc_assert (TREE_CODE (component) == IDENTIFIER_NODE);
    2886                 :             : 
    2887                 :             :   /* First, gather a list of candidates.  */
    2888                 :          72 :   auto_vec <tree> candidates;
    2889                 :             : 
    2890                 :          72 :   lookup_field_fuzzy_find_candidates (type, component,
    2891                 :             :                                       &candidates);
    2892                 :             : 
    2893                 :          72 :   return find_closest_identifier (component, &candidates);
    2894                 :          72 : }
    2895                 :             : 
    2896                 :             : /* Support function for build_component_ref's error-handling.
    2897                 :             : 
    2898                 :             :    Given DATUM_TYPE, and "DATUM.COMPONENT", where DATUM is *not* a
    2899                 :             :    struct or union, should we suggest "DATUM->COMPONENT" as a hint?  */
    2900                 :             : 
    2901                 :             : static bool
    2902                 :          72 : should_suggest_deref_p (tree datum_type)
    2903                 :             : {
    2904                 :             :   /* We don't do it for Objective-C, since Objective-C 2.0 dot-syntax
    2905                 :             :      allows "." for ptrs; we could be handling a failed attempt
    2906                 :             :      to access a property.  */
    2907                 :          72 :   if (c_dialect_objc ())
    2908                 :             :     return false;
    2909                 :             : 
    2910                 :             :   /* Only suggest it for pointers...  */
    2911                 :          72 :   if (TREE_CODE (datum_type) != POINTER_TYPE)
    2912                 :             :     return false;
    2913                 :             : 
    2914                 :             :   /* ...to structs/unions.  */
    2915                 :           8 :   tree underlying_type = TREE_TYPE (datum_type);
    2916                 :           8 :   enum tree_code code = TREE_CODE (underlying_type);
    2917                 :           8 :   if (code == RECORD_TYPE || code == UNION_TYPE)
    2918                 :             :     return true;
    2919                 :             :   else
    2920                 :           1 :     return false;
    2921                 :             : }
    2922                 :             : 
    2923                 :             : /* For a SUBDATUM field of a structure or union DATUM, generate a REF to
    2924                 :             :    the object that represents its counted_by per the attribute counted_by
    2925                 :             :    attached to this field if it's a flexible array member field, otherwise
    2926                 :             :    return NULL_TREE.
    2927                 :             :    Set COUNTED_BY_TYPE to the TYPE of the counted_by field.
    2928                 :             :    For example, if:
    2929                 :             : 
    2930                 :             :     struct P {
    2931                 :             :       int k;
    2932                 :             :       int x[] __attribute__ ((counted_by (k)));
    2933                 :             :     } *p;
    2934                 :             : 
    2935                 :             :     for:
    2936                 :             :     p->x
    2937                 :             : 
    2938                 :             :     the ref to the object that represents its element count will be:
    2939                 :             : 
    2940                 :             :     &(p->k)
    2941                 :             : 
    2942                 :             : */
    2943                 :             : static tree
    2944                 :     2175095 : build_counted_by_ref (tree datum, tree subdatum, tree *counted_by_type)
    2945                 :             : {
    2946                 :     2175095 :   tree type = TREE_TYPE (datum);
    2947                 :     2175095 :   if (!c_flexible_array_member_type_p (TREE_TYPE (subdatum)))
    2948                 :             :     return NULL_TREE;
    2949                 :             : 
    2950                 :       70297 :   tree attr_counted_by = lookup_attribute ("counted_by",
    2951                 :       70297 :                                            DECL_ATTRIBUTES (subdatum));
    2952                 :       70297 :   tree counted_by_ref = NULL_TREE;
    2953                 :       70297 :   *counted_by_type = NULL_TREE;
    2954                 :       70297 :   if (attr_counted_by)
    2955                 :             :     {
    2956                 :         151 :       tree field_id = TREE_VALUE (TREE_VALUE (attr_counted_by));
    2957                 :         151 :       counted_by_ref
    2958                 :         151 :         = build_component_ref (UNKNOWN_LOCATION,
    2959                 :             :                                datum, field_id,
    2960                 :             :                                UNKNOWN_LOCATION, UNKNOWN_LOCATION);
    2961                 :         151 :       counted_by_ref = build_fold_addr_expr (counted_by_ref);
    2962                 :             : 
    2963                 :             :       /* Get the TYPE of the counted_by field.  */
    2964                 :         151 :       tree counted_by_field = lookup_field (type, field_id);
    2965                 :         151 :       gcc_assert (counted_by_field);
    2966                 :             : 
    2967                 :         197 :       do
    2968                 :             :         {
    2969                 :         197 :           *counted_by_type = TREE_TYPE (TREE_VALUE (counted_by_field));
    2970                 :         197 :           counted_by_field = TREE_CHAIN (counted_by_field);
    2971                 :             :         }
    2972                 :         197 :       while (counted_by_field);
    2973                 :             :     }
    2974                 :             :   return counted_by_ref;
    2975                 :             : }
    2976                 :             : 
    2977                 :             : /* Given a COMPONENT_REF REF with the location LOC, the corresponding
    2978                 :             :    COUNTED_BY_REF, and the COUNTED_BY_TYPE, generate an INDIRECT_REF
    2979                 :             :    to a call to the internal function .ACCESS_WITH_SIZE.
    2980                 :             : 
    2981                 :             :    REF
    2982                 :             : 
    2983                 :             :    to:
    2984                 :             : 
    2985                 :             :    (*.ACCESS_WITH_SIZE (REF, COUNTED_BY_REF, 1, (TYPE_OF_SIZE)0, -1,
    2986                 :             :                         (TYPE_OF_ARRAY *)0))
    2987                 :             : 
    2988                 :             :    NOTE: The return type of this function is the POINTER type pointing
    2989                 :             :    to the original flexible array type.
    2990                 :             :    Then the type of the INDIRECT_REF is the original flexible array type.
    2991                 :             : 
    2992                 :             :    The type of the first argument of this function is a POINTER type
    2993                 :             :    to the original flexible array type.
    2994                 :             : 
    2995                 :             :    The 4th argument of the call is a constant 0 with the TYPE of the
    2996                 :             :    object pointed by COUNTED_BY_REF.
    2997                 :             : 
    2998                 :             :    The 6th argument of the call is a constant 0 with the pointer TYPE
    2999                 :             :    to the original flexible array type.
    3000                 :             : 
    3001                 :             :   */
    3002                 :             : static tree
    3003                 :         151 : build_access_with_size_for_counted_by (location_t loc, tree ref,
    3004                 :             :                                        tree counted_by_ref,
    3005                 :             :                                        tree counted_by_type)
    3006                 :             : {
    3007                 :         151 :   gcc_assert (c_flexible_array_member_type_p (TREE_TYPE (ref)));
    3008                 :             :   /* The result type of the call is a pointer to the flexible array type.  */
    3009                 :         151 :   tree result_type = c_build_pointer_type (TREE_TYPE (ref));
    3010                 :         151 :   tree first_param
    3011                 :         151 :     = c_fully_fold (array_to_pointer_conversion (loc, ref), false, NULL);
    3012                 :         151 :   tree second_param
    3013                 :         151 :     = c_fully_fold (counted_by_ref, false, NULL);
    3014                 :             : 
    3015                 :         151 :   tree call
    3016                 :         151 :     = build_call_expr_internal_loc (loc, IFN_ACCESS_WITH_SIZE,
    3017                 :             :                                     result_type, 6,
    3018                 :             :                                     first_param,
    3019                 :             :                                     second_param,
    3020                 :             :                                     build_int_cst (integer_type_node, 1),
    3021                 :             :                                     build_int_cst (counted_by_type, 0),
    3022                 :             :                                     build_int_cst (integer_type_node, -1),
    3023                 :             :                                     build_int_cst (result_type, 0));
    3024                 :             :   /* Wrap the call with an INDIRECT_REF with the flexible array type.  */
    3025                 :         151 :   call = build1 (INDIRECT_REF, TREE_TYPE (ref), call);
    3026                 :         151 :   SET_EXPR_LOCATION (call, loc);
    3027                 :         151 :   return call;
    3028                 :             : }
    3029                 :             : 
    3030                 :             : /* For the COMPONENT_REF ref, check whether it has a counted_by attribute,
    3031                 :             :    if so, wrap this COMPONENT_REF with the corresponding CALL to the
    3032                 :             :    function .ACCESS_WITH_SIZE.
    3033                 :             :    Otherwise, return the ref itself.  */
    3034                 :             : 
    3035                 :             : tree
    3036                 :     2175095 : handle_counted_by_for_component_ref (location_t loc, tree ref)
    3037                 :             : {
    3038                 :     2175095 :   gcc_assert (TREE_CODE (ref) == COMPONENT_REF);
    3039                 :     2175095 :   tree datum = TREE_OPERAND (ref, 0);
    3040                 :     2175095 :   tree subdatum = TREE_OPERAND (ref, 1);
    3041                 :     2175095 :   tree counted_by_type = NULL_TREE;
    3042                 :     2175095 :   tree counted_by_ref = build_counted_by_ref (datum, subdatum,
    3043                 :             :                                               &counted_by_type);
    3044                 :     2175095 :   if (counted_by_ref)
    3045                 :         151 :     ref = build_access_with_size_for_counted_by (loc, ref,
    3046                 :             :                                                  counted_by_ref,
    3047                 :             :                                                  counted_by_type);
    3048                 :     2175095 :   return ref;
    3049                 :             : }
    3050                 :             : 
    3051                 :             : /* Make an expression to refer to the COMPONENT field of structure or
    3052                 :             :    union value DATUM.  COMPONENT is an IDENTIFIER_NODE.  LOC is the
    3053                 :             :    location of the COMPONENT_REF.  COMPONENT_LOC is the location
    3054                 :             :    of COMPONENT.  ARROW_LOC is the location of the first -> operand if
    3055                 :             :    it is from -> operator.
    3056                 :             :    If HANDLE_COUNTED_BY is true, check the counted_by attribute and generate
    3057                 :             :    a call to .ACCESS_WITH_SIZE.  Otherwise, ignore the attribute.  */
    3058                 :             : 
    3059                 :             : tree
    3060                 :     2224695 : build_component_ref (location_t loc, tree datum, tree component,
    3061                 :             :                      location_t component_loc, location_t arrow_loc,
    3062                 :             :                      bool handle_counted_by)
    3063                 :             : {
    3064                 :     2224695 :   tree type = TREE_TYPE (datum);
    3065                 :     2224695 :   enum tree_code code = TREE_CODE (type);
    3066                 :     2224695 :   tree field = NULL;
    3067                 :     2224695 :   tree ref;
    3068                 :     2224695 :   bool datum_lvalue = lvalue_p (datum);
    3069                 :             : 
    3070                 :     2224695 :   if (!objc_is_public (datum, component))
    3071                 :           0 :     return error_mark_node;
    3072                 :             : 
    3073                 :             :   /* Detect Objective-C property syntax object.property.  */
    3074                 :     2224695 :   if (c_dialect_objc ()
    3075                 :     2224695 :       && (ref = objc_maybe_build_component_ref (datum, component)))
    3076                 :             :     return ref;
    3077                 :             : 
    3078                 :             :   /* See if there is a field or component with name COMPONENT.  */
    3079                 :             : 
    3080                 :     2224695 :   if (code == RECORD_TYPE || code == UNION_TYPE)
    3081                 :             :     {
    3082                 :     2224623 :       if (!COMPLETE_TYPE_P (type))
    3083                 :             :         {
    3084                 :          15 :           c_incomplete_type_error (loc, NULL_TREE, type);
    3085                 :          15 :           return error_mark_node;
    3086                 :             :         }
    3087                 :             : 
    3088                 :     2224608 :       field = lookup_field (type, component);
    3089                 :             : 
    3090                 :     2224608 :       if (!field)
    3091                 :             :         {
    3092                 :          64 :           tree guessed_id = lookup_field_fuzzy (type, component);
    3093                 :          64 :           if (guessed_id)
    3094                 :             :             {
    3095                 :             :               /* Attempt to provide a fixit replacement hint, if
    3096                 :             :                  we have a valid range for the component.  */
    3097                 :           0 :               location_t reported_loc
    3098                 :          27 :                 = (component_loc != UNKNOWN_LOCATION) ? component_loc : loc;
    3099                 :          27 :               gcc_rich_location rich_loc (reported_loc);
    3100                 :          27 :               if (component_loc != UNKNOWN_LOCATION)
    3101                 :          27 :                 rich_loc.add_fixit_misspelled_id (component_loc, guessed_id);
    3102                 :          27 :               error_at (&rich_loc,
    3103                 :             :                         "%qT has no member named %qE; did you mean %qE?",
    3104                 :             :                         type, component, guessed_id);
    3105                 :          27 :             }
    3106                 :             :           else
    3107                 :          37 :             error_at (loc, "%qT has no member named %qE", type, component);
    3108                 :          64 :           return error_mark_node;
    3109                 :             :         }
    3110                 :             : 
    3111                 :             :       /* Accessing elements of atomic structures or unions is undefined
    3112                 :             :          behavior (C11 6.5.2.3#5).  */
    3113                 :     2224544 :       if (TYPE_ATOMIC (type) && c_inhibit_evaluation_warnings == 0)
    3114                 :             :         {
    3115                 :          18 :           if (code == RECORD_TYPE)
    3116                 :          12 :             warning_at (loc, 0, "accessing a member %qE of an atomic "
    3117                 :             :                         "structure %qE", component, datum);
    3118                 :             :           else
    3119                 :           6 :             warning_at (loc, 0, "accessing a member %qE of an atomic "
    3120                 :             :                         "union %qE", component, datum);
    3121                 :             :         }
    3122                 :             : 
    3123                 :             :       /* Chain the COMPONENT_REFs if necessary down to the FIELD.
    3124                 :             :          This might be better solved in future the way the C++ front
    3125                 :             :          end does it - by giving the anonymous entities each a
    3126                 :             :          separate name and type, and then have build_component_ref
    3127                 :             :          recursively call itself.  We can't do that here.  */
    3128                 :     2226586 :       do
    3129                 :             :         {
    3130                 :     2226586 :           tree subdatum = TREE_VALUE (field);
    3131                 :     2226586 :           int quals;
    3132                 :     2226586 :           tree subtype;
    3133                 :     2226586 :           bool use_datum_quals;
    3134                 :             :           /* Do not handle counted_by when in typeof and alignof operator.  */
    3135                 :     2226586 :           handle_counted_by = handle_counted_by && !in_typeof && !in_alignof;
    3136                 :             : 
    3137                 :     2226586 :           if (TREE_TYPE (subdatum) == error_mark_node)
    3138                 :             :             return error_mark_node;
    3139                 :             : 
    3140                 :             :           /* If this is an rvalue, it does not have qualifiers in C
    3141                 :             :              standard terms and we must avoid propagating such
    3142                 :             :              qualifiers down to a non-lvalue array that is then
    3143                 :             :              converted to a pointer.  */
    3144                 :     4453172 :           use_datum_quals = (datum_lvalue
    3145                 :     2226586 :                              || TREE_CODE (TREE_TYPE (subdatum)) != ARRAY_TYPE);
    3146                 :             : 
    3147                 :     2226586 :           quals = TYPE_QUALS (strip_array_types (TREE_TYPE (subdatum)));
    3148                 :     2226586 :           if (use_datum_quals)
    3149                 :     2226324 :             quals |= TYPE_QUALS (TREE_TYPE (datum));
    3150                 :     2226586 :           subtype = c_build_qualified_type (TREE_TYPE (subdatum), quals);
    3151                 :             : 
    3152                 :     2226586 :           ref = build3 (COMPONENT_REF, subtype, datum, subdatum,
    3153                 :             :                         NULL_TREE);
    3154                 :     2226586 :           SET_EXPR_LOCATION (ref, loc);
    3155                 :             : 
    3156                 :     2226586 :           if (handle_counted_by)
    3157                 :     2175085 :             ref = handle_counted_by_for_component_ref (loc, ref);
    3158                 :             : 
    3159                 :     2226586 :           if (TREE_READONLY (subdatum)
    3160                 :     2226586 :               || (use_datum_quals && TREE_READONLY (datum)))
    3161                 :       30352 :             TREE_READONLY (ref) = 1;
    3162                 :     2226586 :           if (TREE_THIS_VOLATILE (subdatum)
    3163                 :     2225752 :               || (use_datum_quals && TREE_THIS_VOLATILE (datum)))
    3164                 :        2253 :             TREE_THIS_VOLATILE (ref) = 1;
    3165                 :             : 
    3166                 :     2226586 :           if (TREE_UNAVAILABLE (subdatum))
    3167                 :          10 :             error_unavailable_use (subdatum, NULL_TREE);
    3168                 :     2226576 :           else if (TREE_DEPRECATED (subdatum))
    3169                 :          16 :             warn_deprecated_use (subdatum, NULL_TREE);
    3170                 :             : 
    3171                 :     2226586 :           datum = ref;
    3172                 :             : 
    3173                 :     2226586 :           field = TREE_CHAIN (field);
    3174                 :             :         }
    3175                 :     2226586 :       while (field);
    3176                 :             : 
    3177                 :             :       return ref;
    3178                 :             :     }
    3179                 :          72 :   else if (should_suggest_deref_p (type))
    3180                 :             :     {
    3181                 :             :       /* Special-case the error message for "ptr.field" for the case
    3182                 :             :          where the user has confused "." vs "->".  */
    3183                 :           7 :       rich_location richloc (line_table, loc);
    3184                 :           7 :       if (INDIRECT_REF_P (datum) && arrow_loc != UNKNOWN_LOCATION)
    3185                 :             :         {
    3186                 :           2 :           richloc.add_fixit_insert_before (arrow_loc, "(*");
    3187                 :           2 :           richloc.add_fixit_insert_after (arrow_loc, ")");
    3188                 :           2 :           error_at (&richloc,
    3189                 :             :                     "%qE is a pointer to pointer; did you mean to dereference "
    3190                 :             :                     "it before applying %<->%> to it?",
    3191                 :           2 :                     TREE_OPERAND (datum, 0));
    3192                 :             :         }
    3193                 :             :       else
    3194                 :             :         {
    3195                 :             :           /* "loc" should be the "." token.  */
    3196                 :           5 :           richloc.add_fixit_replace ("->");
    3197                 :           5 :           error_at (&richloc,
    3198                 :             :                     "%qE is a pointer; did you mean to use %<->%>?",
    3199                 :             :                     datum);
    3200                 :             :         }
    3201                 :           7 :       return error_mark_node;
    3202                 :           7 :     }
    3203                 :          65 :   else if (code != ERROR_MARK)
    3204                 :           1 :     error_at (loc,
    3205                 :             :               "request for member %qE in something not a structure or union",
    3206                 :             :               component);
    3207                 :             : 
    3208                 :          65 :   return error_mark_node;
    3209                 :             : }
    3210                 :             : 
    3211                 :             : /* Given an expression PTR for a pointer, return an expression
    3212                 :             :    for the value pointed to.
    3213                 :             :    ERRORSTRING is the name of the operator to appear in error messages.
    3214                 :             : 
    3215                 :             :    LOC is the location to use for the generated tree.  */
    3216                 :             : 
    3217                 :             : tree
    3218                 :     2675129 : build_indirect_ref (location_t loc, tree ptr, ref_operator errstring)
    3219                 :             : {
    3220                 :     2675129 :   tree pointer = default_conversion (ptr);
    3221                 :     2675129 :   tree type = TREE_TYPE (pointer);
    3222                 :     2675129 :   tree ref;
    3223                 :             : 
    3224                 :     2675129 :   if (TREE_CODE (type) == POINTER_TYPE)
    3225                 :             :     {
    3226                 :     2674778 :       if (CONVERT_EXPR_P (pointer)
    3227                 :     1906469 :           || TREE_CODE (pointer) == VIEW_CONVERT_EXPR)
    3228                 :             :         {
    3229                 :             :           /* If a warning is issued, mark it to avoid duplicates from
    3230                 :             :              the backend.  This only needs to be done at
    3231                 :             :              warn_strict_aliasing > 2.  */
    3232                 :      768309 :           if (warn_strict_aliasing > 2)
    3233                 :      334825 :             if (strict_aliasing_warning (EXPR_LOCATION (pointer),
    3234                 :      334825 :                                          type, TREE_OPERAND (pointer, 0)))
    3235                 :           7 :               suppress_warning (pointer, OPT_Wstrict_aliasing_);
    3236                 :             :         }
    3237                 :             : 
    3238                 :     2674778 :       if (TREE_CODE (pointer) == ADDR_EXPR
    3239                 :     2674778 :           && (TREE_TYPE (TREE_OPERAND (pointer, 0))
    3240                 :       66764 :               == TREE_TYPE (type)))
    3241                 :             :         {
    3242                 :       66755 :           ref = TREE_OPERAND (pointer, 0);
    3243                 :       66755 :           protected_set_expr_location (ref, loc);
    3244                 :       66755 :           return ref;
    3245                 :             :         }
    3246                 :             :       else
    3247                 :             :         {
    3248                 :     2608023 :           tree t = TREE_TYPE (type);
    3249                 :             : 
    3250                 :     2608023 :           ref = build1 (INDIRECT_REF, t, pointer);
    3251                 :             : 
    3252                 :     2608023 :           if (VOID_TYPE_P (t) && c_inhibit_evaluation_warnings == 0)
    3253                 :         147 :             warning_at (loc, 0, "dereferencing %<void *%> pointer");
    3254                 :             : 
    3255                 :             :           /* We *must* set TREE_READONLY when dereferencing a pointer to const,
    3256                 :             :              so that we get the proper error message if the result is used
    3257                 :             :              to assign to.  Also, &* is supposed to be a no-op.
    3258                 :             :              And ANSI C seems to specify that the type of the result
    3259                 :             :              should be the const type.  */
    3260                 :             :           /* A de-reference of a pointer to const is not a const.  It is valid
    3261                 :             :              to change it via some other pointer.  */
    3262                 :     2608023 :           TREE_READONLY (ref) = TYPE_READONLY (t);
    3263                 :     2608023 :           TREE_SIDE_EFFECTS (ref)
    3264                 :     2608023 :             = TYPE_VOLATILE (t) || TREE_SIDE_EFFECTS (pointer);
    3265                 :     2608023 :           TREE_THIS_VOLATILE (ref) = TYPE_VOLATILE (t);
    3266                 :     2608023 :           protected_set_expr_location (ref, loc);
    3267                 :     2608023 :           return ref;
    3268                 :             :         }
    3269                 :             :     }
    3270                 :         351 :   else if (TREE_CODE (pointer) != ERROR_MARK)
    3271                 :         278 :     invalid_indirection_error (loc, type, errstring);
    3272                 :             : 
    3273                 :         351 :   return error_mark_node;
    3274                 :             : }
    3275                 :             : 
    3276                 :             : /* This handles expressions of the form "a[i]", which denotes
    3277                 :             :    an array reference.
    3278                 :             : 
    3279                 :             :    This is logically equivalent in C to *(a+i), but we may do it differently.
    3280                 :             :    If A is a variable or a member, we generate a primitive ARRAY_REF.
    3281                 :             :    This avoids forcing the array out of registers, and can work on
    3282                 :             :    arrays that are not lvalues (for example, members of structures returned
    3283                 :             :    by functions).
    3284                 :             : 
    3285                 :             :    For vector types, allow vector[i] but not i[vector], and create
    3286                 :             :    *(((type*)&vectortype) + i) for the expression.
    3287                 :             : 
    3288                 :             :    LOC is the location to use for the returned expression.  */
    3289                 :             : 
    3290                 :             : tree
    3291                 :     3392458 : build_array_ref (location_t loc, tree array, tree index)
    3292                 :             : {
    3293                 :     3392458 :   tree ret;
    3294                 :     3392458 :   bool swapped = false;
    3295                 :     3392458 :   if (TREE_TYPE (array) == error_mark_node
    3296                 :     3392458 :       || TREE_TYPE (index) == error_mark_node)
    3297                 :             :     return error_mark_node;
    3298                 :             : 
    3299                 :     3392350 :   if (TREE_CODE (TREE_TYPE (array)) != ARRAY_TYPE
    3300                 :     1937212 :       && TREE_CODE (TREE_TYPE (array)) != POINTER_TYPE
    3301                 :             :       /* Allow vector[index] but not index[vector].  */
    3302                 :     4389362 :       && !gnu_vector_type_p (TREE_TYPE (array)))
    3303                 :             :     {
    3304                 :         194 :       if (TREE_CODE (TREE_TYPE (index)) != ARRAY_TYPE
    3305                 :         194 :           && TREE_CODE (TREE_TYPE (index)) != POINTER_TYPE)
    3306                 :             :         {
    3307                 :           2 :           error_at (loc,
    3308                 :             :             "subscripted value is neither array nor pointer nor vector");
    3309                 :             : 
    3310                 :           2 :           return error_mark_node;
    3311                 :             :         }
    3312                 :         192 :       std::swap (array, index);
    3313                 :         192 :       swapped = true;
    3314                 :             :     }
    3315                 :             : 
    3316                 :     3392348 :   if (!INTEGRAL_TYPE_P (TREE_TYPE (index)))
    3317                 :             :     {
    3318                 :           2 :       error_at (loc, "array subscript is not an integer");
    3319                 :           2 :       return error_mark_node;
    3320                 :             :     }
    3321                 :             : 
    3322                 :     3392346 :   if (TREE_CODE (TREE_TYPE (TREE_TYPE (array))) == FUNCTION_TYPE)
    3323                 :             :     {
    3324                 :          10 :       error_at (loc, "subscripted value is pointer to function");
    3325                 :          10 :       return error_mark_node;
    3326                 :             :     }
    3327                 :             : 
    3328                 :             :   /* ??? Existing practice has been to warn only when the char
    3329                 :             :      index is syntactically the index, not for char[array].  */
    3330                 :     3392336 :   if (!swapped)
    3331                 :     3392150 :      warn_array_subscript_with_type_char (loc, index);
    3332                 :             : 
    3333                 :             :   /* Apply default promotions *after* noticing character types.  */
    3334                 :     3392336 :   index = default_conversion (index);
    3335                 :     3392336 :   if (index == error_mark_node)
    3336                 :             :     return error_mark_node;
    3337                 :             : 
    3338                 :     3392335 :   gcc_assert (TREE_CODE (TREE_TYPE (index)) == INTEGER_TYPE
    3339                 :             :               || TREE_CODE (TREE_TYPE (index)) == BITINT_TYPE);
    3340                 :             : 
    3341                 :     3392335 :   bool was_vector = VECTOR_TYPE_P (TREE_TYPE (array));
    3342                 :     3392335 :   bool non_lvalue = convert_vector_to_array_for_subscript (loc, &array, index);
    3343                 :             : 
    3344                 :     3392335 :   if (TREE_CODE (TREE_TYPE (array)) == ARRAY_TYPE)
    3345                 :             :     {
    3346                 :     2451963 :       tree rval, type;
    3347                 :             : 
    3348                 :             :       /* An array that is indexed by a non-constant
    3349                 :             :          cannot be stored in a register; we must be able to do
    3350                 :             :          address arithmetic on its address.
    3351                 :             :          Likewise an array of elements of variable size.  */
    3352                 :     2451963 :       if (TREE_CODE (index) != INTEGER_CST
    3353                 :     2451963 :           || (COMPLETE_TYPE_P (TREE_TYPE (TREE_TYPE (array)))
    3354                 :     1989565 :               && TREE_CODE (TYPE_SIZE (TREE_TYPE (TREE_TYPE (array)))) != INTEGER_CST))
    3355                 :             :         {
    3356                 :      463135 :           if (!c_mark_addressable (array, true))
    3357                 :           1 :             return error_mark_node;
    3358                 :             :         }
    3359                 :             :       /* An array that is indexed by a constant value which is not within
    3360                 :             :          the array bounds cannot be stored in a register either; because we
    3361                 :             :          would get a crash in store_bit_field/extract_bit_field when trying
    3362                 :             :          to access a non-existent part of the register.  */
    3363                 :     2451962 :       if (TREE_CODE (index) == INTEGER_CST
    3364                 :     1989565 :           && TYPE_DOMAIN (TREE_TYPE (array))
    3365                 :     4438171 :           && !int_fits_type_p (index, TYPE_DOMAIN (TREE_TYPE (array))))
    3366                 :             :         {
    3367                 :       60557 :           if (!c_mark_addressable (array))
    3368                 :           0 :             return error_mark_node;
    3369                 :             :         }
    3370                 :             : 
    3371                 :     2451962 :       if ((pedantic || warn_c90_c99_compat)
    3372                 :     2429118 :           && ! was_vector)
    3373                 :             :         {
    3374                 :     1454432 :           tree foo = array;
    3375                 :     2274175 :           while (TREE_CODE (foo) == COMPONENT_REF)
    3376                 :      819743 :             foo = TREE_OPERAND (foo, 0);
    3377                 :     1454432 :           if (VAR_P (foo) && C_DECL_REGISTER (foo))
    3378                 :           0 :             pedwarn (loc, OPT_Wpedantic,
    3379                 :             :                      "ISO C forbids subscripting %<register%> array");
    3380                 :     1454432 :           else if (!lvalue_p (foo))
    3381                 :         118 :             pedwarn_c90 (loc, OPT_Wpedantic,
    3382                 :             :                          "ISO C90 forbids subscripting non-lvalue "
    3383                 :             :                          "array");
    3384                 :             :         }
    3385                 :             : 
    3386                 :     2451962 :       if (TREE_CODE (TREE_TYPE (index)) == BITINT_TYPE
    3387                 :     2451962 :           && TYPE_PRECISION (TREE_TYPE (index)) > TYPE_PRECISION (sizetype))
    3388                 :           3 :         index = fold_convert (sizetype, index);
    3389                 :             : 
    3390                 :     2451962 :       type = TREE_TYPE (TREE_TYPE (array));
    3391                 :     2451962 :       rval = build4 (ARRAY_REF, type, array, index, NULL_TREE, NULL_TREE);
    3392                 :             :       /* Array ref is const/volatile if the array elements are
    3393                 :             :          or if the array is.  */
    3394                 :     7355886 :       TREE_READONLY (rval)
    3395                 :     2451962 :         |= (TYPE_READONLY (TREE_TYPE (TREE_TYPE (array)))
    3396                 :     2451962 :             | TREE_READONLY (array));
    3397                 :     7355886 :       TREE_SIDE_EFFECTS (rval)
    3398                 :     2451962 :         |= (TYPE_VOLATILE (TREE_TYPE (TREE_TYPE (array)))
    3399                 :     2451962 :             | TREE_SIDE_EFFECTS (array));
    3400                 :     4903924 :       TREE_THIS_VOLATILE (rval)
    3401                 :     2451962 :         |= (TYPE_VOLATILE (TREE_TYPE (TREE_TYPE (array)))
    3402                 :             :             /* This was added by rms on 16 Nov 91.
    3403                 :             :                It fixes  vol struct foo *a;  a->elts[1]
    3404                 :             :                in an inline function.
    3405                 :             :                Hope it doesn't break something else.  */
    3406                 :     2451962 :             | TREE_THIS_VOLATILE (array));
    3407                 :     2451962 :       ret = require_complete_type (loc, rval);
    3408                 :     2451962 :       protected_set_expr_location (ret, loc);
    3409                 :     2451962 :       if (non_lvalue)
    3410                 :      102796 :         ret = non_lvalue_loc (loc, ret);
    3411                 :     2451962 :       return ret;
    3412                 :             :     }
    3413                 :             :   else
    3414                 :             :     {
    3415                 :      940372 :       tree ar = default_conversion (array);
    3416                 :             : 
    3417                 :      940372 :       if (ar == error_mark_node)
    3418                 :             :         return ar;
    3419                 :             : 
    3420                 :      940372 :       gcc_assert (TREE_CODE (TREE_TYPE (ar)) == POINTER_TYPE);
    3421                 :      940372 :       gcc_assert (TREE_CODE (TREE_TYPE (TREE_TYPE (ar))) != FUNCTION_TYPE);
    3422                 :             : 
    3423                 :      940372 :       ret = build_indirect_ref (loc, build_binary_op (loc, PLUS_EXPR, ar,
    3424                 :             :                                                       index, false),
    3425                 :             :                                 RO_ARRAY_INDEXING);
    3426                 :      940372 :       if (non_lvalue)
    3427                 :           0 :         ret = non_lvalue_loc (loc, ret);
    3428                 :      940372 :       return ret;
    3429                 :             :     }
    3430                 :             : }
    3431                 :             : 
    3432                 :             : /* Build an OpenMP array section reference, creating an exact type for the
    3433                 :             :    resulting expression based on the element type and bounds if possible.  If
    3434                 :             :    we have variable bounds, create an incomplete array type for the result
    3435                 :             :    instead.  */
    3436                 :             : 
    3437                 :             : tree
    3438                 :        3879 : build_omp_array_section (location_t loc, tree array, tree index, tree length)
    3439                 :             : {
    3440                 :        3879 :   tree type = TREE_TYPE (array);
    3441                 :        3879 :   gcc_assert (type);
    3442                 :             : 
    3443                 :        3879 :   tree sectype, eltype = TREE_TYPE (type);
    3444                 :             : 
    3445                 :             :   /* It's not an array or pointer type.  Just reuse the type of the original
    3446                 :             :      expression as the type of the array section (an error will be raised
    3447                 :             :      anyway, later).  */
    3448                 :        3879 :   if (eltype == NULL_TREE || error_operand_p (eltype))
    3449                 :          12 :     sectype = TREE_TYPE (array);
    3450                 :             :   else
    3451                 :             :     {
    3452                 :        3867 :       tree idxtype = NULL_TREE;
    3453                 :             : 
    3454                 :        3867 :       if (index != NULL_TREE
    3455                 :        3867 :           && length != NULL_TREE
    3456                 :        2967 :           && INTEGRAL_TYPE_P (TREE_TYPE (index))
    3457                 :        6829 :           && INTEGRAL_TYPE_P (TREE_TYPE (length)))
    3458                 :             :         {
    3459                 :        2955 :           tree low = fold_convert (sizetype, index);
    3460                 :        2955 :           tree high = fold_convert (sizetype, length);
    3461                 :        2955 :           high = size_binop (PLUS_EXPR, low, high);
    3462                 :        2955 :           high = size_binop (MINUS_EXPR, high, size_one_node);
    3463                 :        2955 :           idxtype = build_range_type (sizetype, low, high);
    3464                 :             :         }
    3465                 :         135 :       else if ((index == NULL_TREE || integer_zerop (index))
    3466                 :         802 :                && length != NULL_TREE
    3467                 :        1562 :                && INTEGRAL_TYPE_P (TREE_TYPE (length)))
    3468                 :         633 :         idxtype = build_index_type (length);
    3469                 :             : 
    3470                 :        3867 :       gcc_assert (!error_operand_p (idxtype));
    3471                 :             : 
    3472                 :        3867 :       sectype = c_build_array_type (eltype, idxtype);
    3473                 :             :     }
    3474                 :             : 
    3475                 :        3879 :   return build3_loc (loc, OMP_ARRAY_SECTION, sectype, array, index, length);
    3476                 :             : }
    3477                 :             : 
    3478                 :             : 
    3479                 :             : /* Build an external reference to identifier ID.  FUN indicates
    3480                 :             :    whether this will be used for a function call.  LOC is the source
    3481                 :             :    location of the identifier.  This sets *TYPE to the type of the
    3482                 :             :    identifier, which is not the same as the type of the returned value
    3483                 :             :    for CONST_DECLs defined as enum constants.  If the type of the
    3484                 :             :    identifier is not available, *TYPE is set to NULL.  */
    3485                 :             : tree
    3486                 :   170375189 : build_external_ref (location_t loc, tree id, bool fun, tree *type)
    3487                 :             : {
    3488                 :   170375189 :   tree ref;
    3489                 :   170375189 :   tree decl = lookup_name (id);
    3490                 :             : 
    3491                 :             :   /* In Objective-C, an instance variable (ivar) may be preferred to
    3492                 :             :      whatever lookup_name() found.  */
    3493                 :   170375189 :   decl = objc_lookup_ivar (decl, id);
    3494                 :             : 
    3495                 :   170375189 :   *type = NULL;
    3496                 :   170375189 :   if (decl && decl != error_mark_node)
    3497                 :             :     {
    3498                 :   170368831 :       ref = decl;
    3499                 :   170368831 :       *type = TREE_TYPE (ref);
    3500                 :   170368831 :       if (DECL_P (decl) && C_DECL_UNDERSPECIFIED (decl))
    3501                 :           4 :         error_at (loc, "underspecified %qD referenced in its initializer",
    3502                 :             :                   decl);
    3503                 :             :     }
    3504                 :        6358 :   else if (fun)
    3505                 :             :     /* Implicit function declaration.  */
    3506                 :        4729 :     ref = implicitly_declare (loc, id);
    3507                 :        1629 :   else if (decl == error_mark_node)
    3508                 :             :     /* Don't complain about something that's already been
    3509                 :             :        complained about.  */
    3510                 :             :     return error_mark_node;
    3511                 :             :   else
    3512                 :             :     {
    3513                 :        1399 :       undeclared_variable (loc, id);
    3514                 :        1399 :       return error_mark_node;
    3515                 :             :     }
    3516                 :             : 
    3517                 :             :   /* For an OpenMP map clause, we can get better diagnostics for decls with
    3518                 :             :      unmappable types if we return the decl with an error_mark_node type,
    3519                 :             :      rather than returning error_mark_node for the decl itself.  */
    3520                 :   170373560 :   if (TREE_TYPE (ref) == error_mark_node
    3521                 :   170373560 :       && !c_omp_array_section_p)
    3522                 :             :     return error_mark_node;
    3523                 :             : 
    3524                 :   170373543 :   if (TREE_UNAVAILABLE (ref))
    3525                 :          14 :     error_unavailable_use (ref, NULL_TREE);
    3526                 :   170373529 :   else if (TREE_DEPRECATED (ref))
    3527                 :          49 :     warn_deprecated_use (ref, NULL_TREE);
    3528                 :             : 
    3529                 :             :   /* Recursive call does not count as usage.  */
    3530                 :   170373543 :   if (ref != current_function_decl)
    3531                 :             :     {
    3532                 :   170370945 :       TREE_USED (ref) = 1;
    3533                 :             :     }
    3534                 :             : 
    3535                 :   170373543 :   if (TREE_CODE (ref) == FUNCTION_DECL && !in_alignof)
    3536                 :             :     {
    3537                 :    49962694 :       if (!in_sizeof && !in_typeof && !in_countof)
    3538                 :    49338095 :         C_DECL_USED (ref) = 1;
    3539                 :      624599 :       else if (DECL_INITIAL (ref) == NULL_TREE
    3540                 :      618501 :                && DECL_EXTERNAL (ref)
    3541                 :     1243099 :                && !TREE_PUBLIC (ref))
    3542                 :         100 :         record_maybe_used_decl (ref);
    3543                 :             :     }
    3544                 :             : 
    3545                 :   170373543 :   if (TREE_CODE (ref) == CONST_DECL)
    3546                 :             :     {
    3547                 :      410086 :       used_types_insert (TREE_TYPE (ref));
    3548                 :             : 
    3549                 :      410086 :       if (warn_cxx_compat
    3550                 :         377 :           && TREE_CODE (TREE_TYPE (ref)) == ENUMERAL_TYPE
    3551                 :      410461 :           && C_TYPE_DEFINED_IN_STRUCT (TREE_TYPE (ref)))
    3552                 :             :         {
    3553                 :           1 :           warning_at (loc, OPT_Wc___compat,
    3554                 :             :                       ("enum constant defined in struct or union "
    3555                 :             :                        "is not visible in C++"));
    3556                 :           1 :           inform (DECL_SOURCE_LOCATION (ref), "enum constant defined here");
    3557                 :             :         }
    3558                 :             : 
    3559                 :      410086 :       ref = DECL_INITIAL (ref);
    3560                 :      410086 :       TREE_CONSTANT (ref) = 1;
    3561                 :             :     }
    3562                 :   169963457 :   else if (current_function_decl != NULL_TREE
    3563                 :   168468024 :            && !DECL_FILE_SCOPE_P (current_function_decl)
    3564                 :   169963457 :            && (VAR_OR_FUNCTION_DECL_P (ref)
    3565                 :             :                || TREE_CODE (ref) == PARM_DECL))
    3566                 :             :     {
    3567                 :       10083 :       tree context = decl_function_context (ref);
    3568                 :             : 
    3569                 :       10083 :       if (context != NULL_TREE && context != current_function_decl)
    3570                 :        1612 :         DECL_NONLOCAL (ref) = 1;
    3571                 :             :     }
    3572                 :             :   /* C99 6.7.4p3: An inline definition of a function with external
    3573                 :             :      linkage ... shall not contain a reference to an identifier with
    3574                 :             :      internal linkage.  */
    3575                 :   169953374 :   else if (current_function_decl != NULL_TREE
    3576                 :   168457941 :            && DECL_DECLARED_INLINE_P (current_function_decl)
    3577                 :   155096137 :            && DECL_EXTERNAL (current_function_decl)
    3578                 :   154343456 :            && VAR_OR_FUNCTION_DECL_P (ref)
    3579                 :    54994842 :            && (!VAR_P (ref) || TREE_STATIC (ref))
    3580                 :    46077708 :            && ! TREE_PUBLIC (ref)
    3581                 :   169953408 :            && DECL_CONTEXT (ref) != current_function_decl)
    3582                 :          25 :     record_inline_static (loc, current_function_decl, ref,
    3583                 :             :                           csi_internal);
    3584                 :             : 
    3585                 :             :   return ref;
    3586                 :             : }
    3587                 :             : 
    3588                 :             : /* Record details of decls possibly used inside sizeof or typeof.  */
    3589                 :             : struct maybe_used_decl
    3590                 :             : {
    3591                 :             :   /* The decl.  */
    3592                 :             :   tree decl;
    3593                 :             :   /* The level seen at (in_sizeof + in_typeof + in_countof).  */
    3594                 :             :   int level;
    3595                 :             :   /* The next one at this level or above, or NULL.  */
    3596                 :             :   struct maybe_used_decl *next;
    3597                 :             : };
    3598                 :             : 
    3599                 :             : static struct maybe_used_decl *maybe_used_decls;
    3600                 :             : 
    3601                 :             : /* Record that DECL, an undefined static function reference seen
    3602                 :             :    inside sizeof or typeof, might be used if the operand of sizeof is
    3603                 :             :    a VLA type or the operand of typeof is a variably modified
    3604                 :             :    type.  */
    3605                 :             : 
    3606                 :             : static void
    3607                 :         100 : record_maybe_used_decl (tree decl)
    3608                 :             : {
    3609                 :         100 :   struct maybe_used_decl *t = XOBNEW (&parser_obstack, struct maybe_used_decl);
    3610                 :         100 :   t->decl = decl;
    3611                 :         100 :   t->level = in_sizeof + in_typeof + in_countof;
    3612                 :         100 :   t->next = maybe_used_decls;
    3613                 :         100 :   maybe_used_decls = t;
    3614                 :         100 : }
    3615                 :             : 
    3616                 :             : /* Pop the stack of decls possibly used inside sizeof or typeof.  If
    3617                 :             :    USED is false, just discard them.  If it is true, mark them used
    3618                 :             :    (if no longer inside sizeof or typeof) or move them to the next
    3619                 :             :    level up (if still inside sizeof or typeof).  */
    3620                 :             : 
    3621                 :             : void
    3622                 :     1437649 : pop_maybe_used (bool used)
    3623                 :             : {
    3624                 :     1437649 :   struct maybe_used_decl *p = maybe_used_decls;
    3625                 :     1437649 :   int cur_level = in_sizeof + in_typeof + in_countof;
    3626                 :     1437752 :   while (p && p->level > cur_level)
    3627                 :             :     {
    3628                 :         103 :       if (used)
    3629                 :             :         {
    3630                 :          13 :           if (cur_level == 0)
    3631                 :          10 :             C_DECL_USED (p->decl) = 1;
    3632                 :             :           else
    3633                 :           3 :             p->level = cur_level;
    3634                 :             :         }
    3635                 :         103 :       p = p->next;
    3636                 :             :     }
    3637                 :     1437649 :   if (!used || cur_level == 0)
    3638                 :     1437633 :     maybe_used_decls = p;
    3639                 :     1437649 : }
    3640                 :             : 
    3641                 :             : /* Return the result of sizeof applied to EXPR.  */
    3642                 :             : 
    3643                 :             : struct c_expr
    3644                 :      301043 : c_expr_sizeof_expr (location_t loc, struct c_expr expr)
    3645                 :             : {
    3646                 :      301043 :   struct c_expr ret;
    3647                 :      301043 :   if (expr.value == error_mark_node)
    3648                 :             :     {
    3649                 :         109 :       ret.value = error_mark_node;
    3650                 :         109 :       ret.original_code = ERROR_MARK;
    3651                 :         109 :       ret.original_type = NULL;
    3652                 :         109 :       ret.m_decimal = 0;
    3653                 :         109 :       pop_maybe_used (false);
    3654                 :             :     }
    3655                 :             :   else
    3656                 :             :     {
    3657                 :      300934 :       bool expr_const_operands = true;
    3658                 :             : 
    3659                 :      300934 :       if (TREE_CODE (expr.value) == PARM_DECL
    3660                 :      300934 :           && C_ARRAY_PARAMETER (expr.value))
    3661                 :             :         {
    3662                 :          55 :           auto_diagnostic_group d;
    3663                 :          55 :           if (warning_at (loc, OPT_Wsizeof_array_argument,
    3664                 :             :                           "%<sizeof%> on array function parameter %qE will "
    3665                 :             :                           "return size of %qT", expr.value,
    3666                 :          55 :                           TREE_TYPE (expr.value)))
    3667                 :          19 :             inform (DECL_SOURCE_LOCATION (expr.value), "declared here");
    3668                 :          55 :         }
    3669                 :      300934 :       tree folded_expr = c_fully_fold (expr.value, require_constant_value,
    3670                 :             :                                        &expr_const_operands);
    3671                 :      300934 :       ret.value = c_sizeof (loc, TREE_TYPE (folded_expr));
    3672                 :      300934 :       c_last_sizeof_arg = expr.value;
    3673                 :      300934 :       c_last_sizeof_loc = loc;
    3674                 :      300934 :       ret.original_code = SIZEOF_EXPR;
    3675                 :      300934 :       ret.original_type = NULL;
    3676                 :      300934 :       ret.m_decimal = 0;
    3677                 :      300934 :       if (C_TYPE_VARIABLE_SIZE (TREE_TYPE (folded_expr)))
    3678                 :             :         {
    3679                 :             :           /* sizeof is evaluated when given a vla (C99 6.5.3.4p2).  */
    3680                 :         271 :           ret.value = build2 (C_MAYBE_CONST_EXPR, TREE_TYPE (ret.value),
    3681                 :             :                               folded_expr, ret.value);
    3682                 :         271 :           C_MAYBE_CONST_EXPR_NON_CONST (ret.value) = !expr_const_operands;
    3683                 :         271 :           SET_EXPR_LOCATION (ret.value, loc);
    3684                 :             :         }
    3685                 :      300934 :       pop_maybe_used (C_TYPE_VARIABLE_SIZE (TREE_TYPE (folded_expr)));
    3686                 :             :     }
    3687                 :      301043 :   return ret;
    3688                 :             : }
    3689                 :             : 
    3690                 :             : /* Return the result of sizeof applied to T, a structure for the type
    3691                 :             :    name passed to sizeof (rather than the type itself).  LOC is the
    3692                 :             :    location of the original expression.  */
    3693                 :             : 
    3694                 :             : struct c_expr
    3695                 :      329472 : c_expr_sizeof_type (location_t loc, struct c_type_name *t)
    3696                 :             : {
    3697                 :      329472 :   tree type;
    3698                 :      329472 :   struct c_expr ret;
    3699                 :      329472 :   tree type_expr = NULL_TREE;
    3700                 :      329472 :   bool type_expr_const = true;
    3701                 :      329472 :   type = groktypename (t, &type_expr, &type_expr_const);
    3702                 :      329472 :   ret.value = c_sizeof (loc, type);
    3703                 :      329472 :   c_last_sizeof_arg = type;
    3704                 :      329472 :   c_last_sizeof_loc = loc;
    3705                 :      329472 :   ret.original_code = SIZEOF_EXPR;
    3706                 :      329472 :   ret.original_type = NULL;
    3707                 :      329472 :   ret.m_decimal = 0;
    3708                 :      329472 :   if (type == error_mark_node)
    3709                 :             :     {
    3710                 :           5 :       ret.value = error_mark_node;
    3711                 :           5 :       ret.original_code = ERROR_MARK;
    3712                 :             :     }
    3713                 :             :   else
    3714                 :      329425 :   if ((type_expr || TREE_CODE (ret.value) == INTEGER_CST)
    3715                 :      658832 :       && C_TYPE_VARIABLE_SIZE (type))
    3716                 :             :     {
    3717                 :             :       /* If the type is a [*] array, it is a VLA but is represented as
    3718                 :             :          having a size of zero.  In such a case we must ensure that
    3719                 :             :          the result of sizeof does not get folded to a constant by
    3720                 :             :          c_fully_fold, because if the size is evaluated the result is
    3721                 :             :          not constant and so constraints on zero or negative size
    3722                 :             :          arrays must not be applied when this sizeof call is inside
    3723                 :             :          another array declarator.  */
    3724                 :          41 :       if (!type_expr)
    3725                 :          16 :         type_expr = integer_zero_node;
    3726                 :          41 :       ret.value = build2 (C_MAYBE_CONST_EXPR, TREE_TYPE (ret.value),
    3727                 :             :                           type_expr, ret.value);
    3728                 :          41 :       C_MAYBE_CONST_EXPR_NON_CONST (ret.value) = !type_expr_const;
    3729                 :             :     }
    3730                 :      329472 :   pop_maybe_used (type != error_mark_node
    3731                 :      329472 :                   ? C_TYPE_VARIABLE_SIZE (type) : false);
    3732                 :      329472 :   return ret;
    3733                 :             : }
    3734                 :             : 
    3735                 :             : static bool
    3736                 :         136 : is_top_array_vla (tree type)
    3737                 :             : {
    3738                 :         136 :   bool zero, var;
    3739                 :         136 :   tree d;
    3740                 :             : 
    3741                 :         136 :   if (TREE_CODE (type) != ARRAY_TYPE)
    3742                 :             :     return false;
    3743                 :         118 :   if (!COMPLETE_TYPE_P (type))
    3744                 :             :     return false;
    3745                 :             : 
    3746                 :         114 :   d = TYPE_DOMAIN (type);
    3747                 :         114 :   zero = !TYPE_MAX_VALUE (d);
    3748                 :         114 :   if (zero)
    3749                 :             :     return false;
    3750                 :             : 
    3751                 :          98 :   var = (TREE_CODE (TYPE_MIN_VALUE (d)) != INTEGER_CST
    3752                 :          98 :          || TREE_CODE (TYPE_MAX_VALUE (d)) != INTEGER_CST);
    3753                 :             :   return var;
    3754                 :             : }
    3755                 :             : 
    3756                 :             : /* Return the result of countof applied to EXPR.  */
    3757                 :             : 
    3758                 :             : struct c_expr
    3759                 :          53 : c_expr_countof_expr (location_t loc, struct c_expr expr)
    3760                 :             : {
    3761                 :          53 :   struct c_expr ret;
    3762                 :          53 :   if (expr.value == error_mark_node)
    3763                 :             :     {
    3764                 :           1 :       ret.value = error_mark_node;
    3765                 :           1 :       ret.original_code = ERROR_MARK;
    3766                 :           1 :       ret.original_type = NULL;
    3767                 :           1 :       ret.m_decimal = 0;
    3768                 :           1 :       pop_maybe_used (false);
    3769                 :             :     }
    3770                 :             :   else
    3771                 :             :     {
    3772                 :          52 :       bool expr_const_operands = true;
    3773                 :             : 
    3774                 :          52 :       tree folded_expr = c_fully_fold (expr.value, require_constant_value,
    3775                 :             :                                        &expr_const_operands);
    3776                 :          52 :       ret.value = c_countof_type (loc, TREE_TYPE (folded_expr));
    3777                 :          52 :       c_last_sizeof_arg = expr.value;
    3778                 :          52 :       c_last_sizeof_loc = loc;
    3779                 :          52 :       ret.original_code = COUNTOF_EXPR;
    3780                 :          52 :       ret.original_type = NULL;
    3781                 :          52 :       ret.m_decimal = 0;
    3782                 :          52 :       if (is_top_array_vla (TREE_TYPE (folded_expr)))
    3783                 :             :         {
    3784                 :             :           /* countof is evaluated when given a vla.  */
    3785                 :          11 :           ret.value = build2 (C_MAYBE_CONST_EXPR, TREE_TYPE (ret.value),
    3786                 :             :                               folded_expr, ret.value);
    3787                 :          11 :           C_MAYBE_CONST_EXPR_NON_CONST (ret.value) = !expr_const_operands;
    3788                 :          11 :           SET_EXPR_LOCATION (ret.value, loc);
    3789                 :             :         }
    3790                 :          52 :       pop_maybe_used (is_top_array_vla (TREE_TYPE (folded_expr)));
    3791                 :             :     }
    3792                 :          53 :   return ret;
    3793                 :             : }
    3794                 :             : 
    3795                 :             : /* Return the result of countof applied to T, a structure for the type
    3796                 :             :    name passed to countof (rather than the type itself).  LOC is the
    3797                 :             :    location of the original expression.  */
    3798                 :             : 
    3799                 :             : struct c_expr
    3800                 :          18 : c_expr_countof_type (location_t loc, struct c_type_name *t)
    3801                 :             : {
    3802                 :          18 :   tree type;
    3803                 :          18 :   struct c_expr ret;
    3804                 :          18 :   tree type_expr = NULL_TREE;
    3805                 :          18 :   bool type_expr_const = true;
    3806                 :          18 :   type = groktypename (t, &type_expr, &type_expr_const);
    3807                 :          18 :   ret.value = c_countof_type (loc, type);
    3808                 :          18 :   c_last_sizeof_arg = type;
    3809                 :          18 :   c_last_sizeof_loc = loc;
    3810                 :          18 :   ret.original_code = COUNTOF_EXPR;
    3811                 :          18 :   ret.original_type = NULL;
    3812                 :          18 :   ret.m_decimal = 0;
    3813                 :          18 :   if (type == error_mark_node)
    3814                 :             :     {
    3815                 :           0 :       ret.value = error_mark_node;
    3816                 :           0 :       ret.original_code = ERROR_MARK;
    3817                 :             :     }
    3818                 :             :   else
    3819                 :           8 :   if ((type_expr || TREE_CODE (ret.value) == INTEGER_CST)
    3820                 :          22 :       && is_top_array_vla (type))
    3821                 :             :     {
    3822                 :             :       /* If the type is a [*] array, it is a VLA but is represented as
    3823                 :             :          having a size of zero.  In such a case we must ensure that
    3824                 :             :          the result of countof does not get folded to a constant by
    3825                 :             :          c_fully_fold, because if the number of elements is evaluated
    3826                 :             :          the result is not constant and so
    3827                 :             :          constraints on zero or negative size arrays must not be applied
    3828                 :             :          when this countof call is inside another array declarator.  */
    3829                 :           6 :       if (!type_expr)
    3830                 :           0 :         type_expr = integer_zero_node;
    3831                 :           6 :       ret.value = build2 (C_MAYBE_CONST_EXPR, TREE_TYPE (ret.value),
    3832                 :             :                           type_expr, ret.value);
    3833                 :           6 :       C_MAYBE_CONST_EXPR_NON_CONST (ret.value) = !type_expr_const;
    3834                 :             :     }
    3835                 :          18 :   pop_maybe_used (type != error_mark_node ? is_top_array_vla (type) : false);
    3836                 :          18 :   return ret;
    3837                 :             : }
    3838                 :             : 
    3839                 :             : /* Build a function call to function FUNCTION with parameters PARAMS.
    3840                 :             :    The function call is at LOC.
    3841                 :             :    PARAMS is a list--a chain of TREE_LIST nodes--in which the
    3842                 :             :    TREE_VALUE of each node is a parameter-expression.
    3843                 :             :    FUNCTION's data type may be a function type or a pointer-to-function.  */
    3844                 :             : 
    3845                 :             : tree
    3846                 :           0 : build_function_call (location_t loc, tree function, tree params)
    3847                 :             : {
    3848                 :           0 :   vec<tree, va_gc> *v;
    3849                 :           0 :   tree ret;
    3850                 :             : 
    3851                 :           0 :   vec_alloc (v, list_length (params));
    3852                 :           0 :   for (; params; params = TREE_CHAIN (params))
    3853                 :           0 :     v->quick_push (TREE_VALUE (params));
    3854                 :           0 :   ret = c_build_function_call_vec (loc, vNULL, function, v, NULL);
    3855                 :           0 :   vec_free (v);
    3856                 :           0 :   return ret;
    3857                 :             : }
    3858                 :             : 
    3859                 :             : /* Give a note about the location of the declaration of DECL,
    3860                 :             :    or, failing that, a pertinent declaration for FUNCTION_EXPR.  */
    3861                 :             : 
    3862                 :             : static void
    3863                 :         299 : inform_declaration (tree decl, tree function_expr)
    3864                 :             : {
    3865                 :         299 :   if (decl && (TREE_CODE (decl) != FUNCTION_DECL
    3866                 :         278 :                || !DECL_IS_UNDECLARED_BUILTIN (decl)))
    3867                 :         207 :     inform (DECL_SOURCE_LOCATION (decl), "declared here");
    3868                 :          92 :   else if (function_expr)
    3869                 :          92 :     switch (TREE_CODE (function_expr))
    3870                 :             :       {
    3871                 :             :       default:
    3872                 :             :         break;
    3873                 :          13 :       case COMPONENT_REF:
    3874                 :             :         /* Show the decl of the pertinent field (e.g. for callback
    3875                 :             :            fields in a struct.  */
    3876                 :          13 :         {
    3877                 :          13 :           tree field_decl = TREE_OPERAND (function_expr, 1);
    3878                 :          13 :           if (location_t loc = DECL_SOURCE_LOCATION (field_decl))
    3879                 :          13 :             inform (loc, "declared here");
    3880                 :             :         }
    3881                 :             :         break;
    3882                 :             :       }
    3883                 :         299 : }
    3884                 :             : 
    3885                 :             : /* C implementation of callback for use when checking param types.  */
    3886                 :             : 
    3887                 :             : static bool
    3888                 :           2 : comp_parm_types (tree wanted_type, tree actual_type)
    3889                 :             : {
    3890                 :           2 :   return comptypes (wanted_type, actual_type);
    3891                 :             : }
    3892                 :             : 
    3893                 :             : /* Build a function call to function FUNCTION with parameters PARAMS.
    3894                 :             :    If FUNCTION is the result of resolving an overloaded target built-in,
    3895                 :             :    ORIG_FUNDECL is the original function decl, otherwise it is null.
    3896                 :             :    ORIGTYPES, if not NULL, is a vector of types; each element is
    3897                 :             :    either NULL or the original type of the corresponding element in
    3898                 :             :    PARAMS.  The original type may differ from TREE_TYPE of the
    3899                 :             :    parameter for enums.  FUNCTION's data type may be a function type
    3900                 :             :    or pointer-to-function.  This function changes the elements of
    3901                 :             :    PARAMS.  */
    3902                 :             : 
    3903                 :             : tree
    3904                 :    48573451 : build_function_call_vec (location_t loc, vec<location_t> arg_loc,
    3905                 :             :                          tree function, vec<tree, va_gc> *params,
    3906                 :             :                          vec<tree, va_gc> *origtypes, tree orig_fundecl)
    3907                 :             : {
    3908                 :    48573451 :   tree fntype, fundecl = NULL_TREE;
    3909                 :    48573451 :   tree name = NULL_TREE, result;
    3910                 :    48573451 :   tree tem;
    3911                 :    48573451 :   int nargs;
    3912                 :    48573451 :   tree *argarray;
    3913                 :             : 
    3914                 :             : 
    3915                 :             :   /* Strip NON_LVALUE_EXPRs, etc., since we aren't using as an lvalue.  */
    3916                 :    48573451 :   STRIP_TYPE_NOPS (function);
    3917                 :             : 
    3918                 :             :   /* Convert anything with function type to a pointer-to-function.  */
    3919                 :    48573451 :   if (TREE_CODE (function) == FUNCTION_DECL)
    3920                 :             :     {
    3921                 :    48496480 :       name = DECL_NAME (function);
    3922                 :             : 
    3923                 :    48496480 :       if (flag_tm)
    3924                 :         421 :         tm_malloc_replacement (function);
    3925                 :    48496480 :       fundecl = function;
    3926                 :    48496480 :       if (!orig_fundecl)
    3927                 :    48496480 :         orig_fundecl = fundecl;
    3928                 :             :       /* Atomic functions have type checking/casting already done.  They are
    3929                 :             :          often rewritten and don't match the original parameter list.  */
    3930                 :    96992960 :       if (name && startswith (IDENTIFIER_POINTER (name), "__atomic_"))
    3931                 :             :         origtypes = NULL;
    3932                 :             :     }
    3933                 :    48573451 :   if (TREE_CODE (TREE_TYPE (function)) == FUNCTION_TYPE)
    3934                 :    48510685 :     function = function_to_pointer_conversion (loc, function);
    3935                 :             : 
    3936                 :             :   /* For Objective-C, convert any calls via a cast to OBJC_TYPE_REF
    3937                 :             :      expressions, like those used for ObjC messenger dispatches.  */
    3938                 :    48573451 :   if (params && !params->is_empty ())
    3939                 :    37176518 :     function = objc_rewrite_function_call (function, (*params)[0]);
    3940                 :             : 
    3941                 :    48573451 :   function = c_fully_fold (function, false, NULL);
    3942                 :             : 
    3943                 :    48573451 :   fntype = TREE_TYPE (function);
    3944                 :             : 
    3945                 :    48573451 :   if (TREE_CODE (fntype) == ERROR_MARK)
    3946                 :           3 :     return error_mark_node;
    3947                 :             : 
    3948                 :    48573448 :   if (!(TREE_CODE (fntype) == POINTER_TYPE
    3949                 :    48573414 :         && TREE_CODE (TREE_TYPE (fntype)) == FUNCTION_TYPE))
    3950                 :             :     {
    3951                 :          37 :       if (!flag_diagnostics_show_caret && !STATEMENT_CLASS_P (function))
    3952                 :          33 :         error_at (loc,
    3953                 :             :                   "called object %qE is not a function or function pointer",
    3954                 :             :                   function);
    3955                 :           4 :       else if (DECL_P (function))
    3956                 :             :         {
    3957                 :           1 :           auto_diagnostic_group d;
    3958                 :           1 :           error_at (loc,
    3959                 :             :                     "called object %qD is not a function or function pointer",
    3960                 :             :                     function);
    3961                 :           1 :           inform_declaration (function, NULL_TREE);
    3962                 :           1 :         }
    3963                 :             :       else
    3964                 :           3 :         error_at (loc,
    3965                 :             :                   "called object is not a function or function pointer");
    3966                 :          37 :       return error_mark_node;
    3967                 :             :     }
    3968                 :             : 
    3969                 :    48573411 :   if (fundecl && TREE_THIS_VOLATILE (fundecl))
    3970                 :      369968 :     current_function_returns_abnormally = 1;
    3971                 :             : 
    3972                 :             :   /* fntype now gets the type of function pointed to.  */
    3973                 :    48573411 :   fntype = TREE_TYPE (fntype);
    3974                 :    48573411 :   tree return_type = TREE_TYPE (fntype);
    3975                 :             : 
    3976                 :             :   /* Convert the parameters to the types declared in the
    3977                 :             :      function prototype, or apply default promotions.  */
    3978                 :             : 
    3979                 :    48573411 :   nargs = convert_arguments (loc, arg_loc, fntype, params,
    3980                 :             :                              origtypes, function, fundecl);
    3981                 :    48573411 :   if (nargs < 0)
    3982                 :         178 :     return error_mark_node;
    3983                 :             : 
    3984                 :             :   /* Check that the function is called through a compatible prototype.
    3985                 :             :      If it is not, warn.  */
    3986                 :    48572370 :   if (CONVERT_EXPR_P (function)
    3987                 :         878 :       && TREE_CODE (tem = TREE_OPERAND (function, 0)) == ADDR_EXPR
    3988                 :         215 :       && TREE_CODE (tem = TREE_OPERAND (tem, 0)) == FUNCTION_DECL
    3989                 :    48573418 :       && !comptypes (fntype, TREE_TYPE (tem)))
    3990                 :             :     {
    3991                 :             :       /* This situation leads to run-time undefined behavior.  We can't,
    3992                 :             :          therefore, simply error unless we can prove that all possible
    3993                 :             :          executions of the program must execute the code.  */
    3994                 :          20 :       warning_at (loc, 0, "function called through a non-compatible type");
    3995                 :             : 
    3996                 :          20 :       if (VOID_TYPE_P (return_type)
    3997                 :          20 :           && TYPE_QUALS (return_type) != TYPE_UNQUALIFIED)
    3998                 :           1 :         pedwarn (loc, 0,
    3999                 :             :                  "function with qualified void return type called");
    4000                 :             :      }
    4001                 :             : 
    4002                 :    48573233 :   argarray = vec_safe_address (params);
    4003                 :             : 
    4004                 :             :   /* Check that arguments to builtin functions match the expectations.  */
    4005                 :    48573233 :   if (fundecl
    4006                 :    48496317 :       && fndecl_built_in_p (fundecl)
    4007                 :    80938641 :       && !check_builtin_function_arguments (loc, arg_loc, fundecl,
    4008                 :             :                                             orig_fundecl, nargs, argarray))
    4009                 :         298 :     return error_mark_node;
    4010                 :             : 
    4011                 :             :   /* Check that the arguments to the function are valid.  */
    4012                 :    48572935 :   bool warned_p = check_function_arguments (loc, fundecl, fntype,
    4013                 :             :                                             nargs, argarray, &arg_loc,
    4014                 :             :                                             comp_parm_types);
    4015                 :             : 
    4016                 :    48572935 :   if (TYPE_QUALS (return_type) != TYPE_UNQUALIFIED
    4017                 :    48572935 :       && !VOID_TYPE_P (return_type))
    4018                 :          11 :     return_type = c_build_qualified_type (return_type, TYPE_UNQUALIFIED);
    4019                 :    48572935 :   if (name != NULL_TREE
    4020                 :    97068954 :       && startswith (IDENTIFIER_POINTER (name), "__builtin_"))
    4021                 :             :     {
    4022                 :    31651152 :       if (require_constant_value)
    4023                 :        3488 :         result
    4024                 :        3488 :           = fold_build_call_array_initializer_loc (loc, return_type,
    4025                 :             :                                                    function, nargs, argarray);
    4026                 :             :       else
    4027                 :    31647664 :         result = fold_build_call_array_loc (loc, return_type,
    4028                 :             :                                             function, nargs, argarray);
    4029                 :    31651152 :       if (TREE_CODE (result) == NOP_EXPR
    4030                 :    31651152 :           && TREE_CODE (TREE_OPERAND (result, 0)) == INTEGER_CST)
    4031                 :       26336 :         STRIP_TYPE_NOPS (result);
    4032                 :             :     }
    4033                 :             :   else
    4034                 :    16921783 :     result = build_call_array_loc (loc, return_type,
    4035                 :             :                                    function, nargs, argarray);
    4036                 :             :   /* If -Wnonnull warning has been diagnosed, avoid diagnosing it again
    4037                 :             :      later.  */
    4038                 :    48572935 :   if (warned_p && TREE_CODE (result) == CALL_EXPR)
    4039                 :         197 :     suppress_warning (result, OPT_Wnonnull);
    4040                 :             : 
    4041                 :             :   /* In this improbable scenario, a nested function returns a VM type.
    4042                 :             :      Create a TARGET_EXPR so that the call always has a LHS, much as
    4043                 :             :      what the C++ FE does for functions returning non-PODs.  */
    4044                 :    48572935 :   if (C_TYPE_VARIABLY_MODIFIED (TREE_TYPE (fntype)))
    4045                 :             :     {
    4046                 :          79 :       tree tmp = create_tmp_var_raw (TREE_TYPE (fntype));
    4047                 :          79 :       result = build4 (TARGET_EXPR, TREE_TYPE (fntype), tmp, result,
    4048                 :             :                        NULL_TREE, NULL_TREE);
    4049                 :             :     }
    4050                 :             : 
    4051                 :    48572935 :   if (VOID_TYPE_P (TREE_TYPE (result)))
    4052                 :             :     {
    4053                 :     2342804 :       if (TYPE_QUALS (TREE_TYPE (result)) != TYPE_UNQUALIFIED)
    4054                 :           2 :         pedwarn (loc, 0,
    4055                 :             :                  "function with qualified void return type called");
    4056                 :     2342804 :       return result;
    4057                 :             :     }
    4058                 :    46230131 :   return require_complete_type (loc, result);
    4059                 :             : }
    4060                 :             : 
    4061                 :             : /* Like build_function_call_vec, but call also resolve_overloaded_builtin.  */
    4062                 :             : 
    4063                 :             : tree
    4064                 :    48573008 : c_build_function_call_vec (location_t loc, const vec<location_t> &arg_loc,
    4065                 :             :                            tree function, vec<tree, va_gc> *params,
    4066                 :             :                            vec<tree, va_gc> *origtypes)
    4067                 :             : {
    4068                 :             :   /* Strip NON_LVALUE_EXPRs, etc., since we aren't using as an lvalue.  */
    4069                 :    48573019 :   STRIP_TYPE_NOPS (function);
    4070                 :             : 
    4071                 :             :   /* Convert anything with function type to a pointer-to-function.  */
    4072                 :    48573008 :   if (TREE_CODE (function) == FUNCTION_DECL)
    4073                 :             :     {
    4074                 :             :       /* Implement type-directed function overloading for builtins.
    4075                 :             :          resolve_overloaded_builtin and targetm.resolve_overloaded_builtin
    4076                 :             :          handle all the type checking.  The result is a complete expression
    4077                 :             :          that implements this function call.  */
    4078                 :    48496037 :       tree tem = resolve_overloaded_builtin (loc, function, params);
    4079                 :    48496037 :       if (tem)
    4080                 :             :         return tem;
    4081                 :             :     }
    4082                 :    48488093 :   return build_function_call_vec (loc, arg_loc, function, params, origtypes);
    4083                 :             : }
    4084                 :             : 
    4085                 :             : /* Helper for convert_arguments called to convert the VALue of argument
    4086                 :             :    number ARGNUM from ORIGTYPE to the corresponding parameter number
    4087                 :             :    PARMNUM and TYPE.
    4088                 :             :    PLOC is the location where the conversion is being performed.
    4089                 :             :    FUNCTION and FUNDECL are the same as in convert_arguments.
    4090                 :             :    VALTYPE is the original type of VAL before the conversion and,
    4091                 :             :    for EXCESS_PRECISION_EXPR, the operand of the expression.
    4092                 :             :    NPC is true if VAL represents the null pointer constant (VAL itself
    4093                 :             :    will have been folded to an integer constant).
    4094                 :             :    RNAME is the same as FUNCTION except in Objective C when it's
    4095                 :             :    the function selector.
    4096                 :             :    EXCESS_PRECISION is true when VAL was originally represented
    4097                 :             :    as EXCESS_PRECISION_EXPR.
    4098                 :             :    WARNOPT is the same as in convert_for_assignment.  */
    4099                 :             : 
    4100                 :             : static tree
    4101                 :   122285004 : convert_argument (location_t ploc, tree function, tree fundecl,
    4102                 :             :                   tree type, tree origtype, tree val, tree valtype,
    4103                 :             :                   bool npc, tree rname, int parmnum, int argnum,
    4104                 :             :                   bool excess_precision, int warnopt)
    4105                 :             : {
    4106                 :             :   /* Formal parm type is specified by a function prototype.  */
    4107                 :             : 
    4108                 :   122285004 :   if (type == error_mark_node || !COMPLETE_TYPE_P (type))
    4109                 :             :     {
    4110                 :           3 :       error_at (ploc, "type of formal parameter %d is incomplete",
    4111                 :             :                 parmnum + 1);
    4112                 :           3 :       return error_mark_node;
    4113                 :             :     }
    4114                 :             : 
    4115                 :             :   /* Optionally warn about conversions that differ from the default
    4116                 :             :      conversions.  */
    4117                 :   122285001 :   if (warn_traditional_conversion || warn_traditional)
    4118                 :             :     {
    4119                 :         193 :       if (INTEGRAL_TYPE_P (type)
    4120                 :         107 :           && SCALAR_FLOAT_TYPE_P (valtype))
    4121                 :          19 :         warning_at (ploc, OPT_Wtraditional_conversion,
    4122                 :             :                     "passing argument %d of %qE as integer rather "
    4123                 :             :                     "than floating due to prototype",
    4124                 :             :                     argnum, rname);
    4125                 :         193 :       if (INTEGRAL_TYPE_P (type)
    4126                 :         107 :           && TREE_CODE (valtype) == COMPLEX_TYPE)
    4127                 :           5 :         warning_at (ploc, OPT_Wtraditional_conversion,
    4128                 :             :                     "passing argument %d of %qE as integer rather "
    4129                 :             :                     "than complex due to prototype",
    4130                 :             :                     argnum, rname);
    4131                 :         188 :       else if (TREE_CODE (type) == COMPLEX_TYPE
    4132                 :          14 :                && SCALAR_FLOAT_TYPE_P (valtype))
    4133                 :           7 :         warning_at (ploc, OPT_Wtraditional_conversion,
    4134                 :             :                     "passing argument %d of %qE as complex rather "
    4135                 :             :                     "than floating due to prototype",
    4136                 :             :                     argnum, rname);
    4137                 :         181 :       else if (SCALAR_FLOAT_TYPE_P (type)
    4138                 :          71 :                && INTEGRAL_TYPE_P (valtype))
    4139                 :          19 :         warning_at (ploc, OPT_Wtraditional_conversion,
    4140                 :             :                     "passing argument %d of %qE as floating rather "
    4141                 :             :                     "than integer due to prototype",
    4142                 :             :                     argnum, rname);
    4143                 :         162 :       else if (TREE_CODE (type) == COMPLEX_TYPE
    4144                 :           7 :                && INTEGRAL_TYPE_P (valtype))
    4145                 :           5 :         warning_at (ploc, OPT_Wtraditional_conversion,
    4146                 :             :                     "passing argument %d of %qE as complex rather "
    4147                 :             :                     "than integer due to prototype",
    4148                 :             :                     argnum, rname);
    4149                 :         157 :       else if (SCALAR_FLOAT_TYPE_P (type)
    4150                 :          52 :                && TREE_CODE (valtype) == COMPLEX_TYPE)
    4151                 :           7 :         warning_at (ploc, OPT_Wtraditional_conversion,
    4152                 :             :                     "passing argument %d of %qE as floating rather "
    4153                 :             :                     "than complex due to prototype",
    4154                 :             :                     argnum, rname);
    4155                 :             :       /* ??? At some point, messages should be written about
    4156                 :             :          conversions between complex types, but that's too messy
    4157                 :             :          to do now.  */
    4158                 :         150 :       else if (SCALAR_FLOAT_TYPE_P (type)
    4159                 :          45 :                && SCALAR_FLOAT_TYPE_P (valtype))
    4160                 :             :         {
    4161                 :          45 :           unsigned int formal_prec = TYPE_PRECISION (type);
    4162                 :             : 
    4163                 :             :           /* Warn if any argument is passed as `float',
    4164                 :             :              since without a prototype it would be `double'.  */
    4165                 :          45 :           if (formal_prec == TYPE_PRECISION (float_type_node)
    4166                 :          45 :               && type != dfloat32_type_node)
    4167                 :           7 :             warning_at (ploc, 0,
    4168                 :             :                         "passing argument %d of %qE as %<float%> "
    4169                 :             :                         "rather than %<double%> due to prototype",
    4170                 :             :                         argnum, rname);
    4171                 :             : 
    4172                 :             :           /* Warn if mismatch between argument and prototype
    4173                 :             :              for decimal float types.  Warn of conversions with
    4174                 :             :              binary float types and of precision narrowing due to
    4175                 :             :              prototype.  */
    4176                 :          38 :           else if (type != valtype
    4177                 :          32 :                    && (type == dfloat32_type_node
    4178                 :          22 :                        || type == dfloat64_type_node
    4179                 :          12 :                        || type == dfloat128_type_node
    4180                 :           2 :                        || valtype == dfloat32_type_node
    4181                 :           2 :                        || valtype == dfloat64_type_node
    4182                 :           2 :                        || valtype == dfloat128_type_node)
    4183                 :          38 :                    && (formal_prec
    4184                 :          30 :                        <= TYPE_PRECISION (valtype)
    4185                 :          14 :                        || (type == dfloat128_type_node
    4186                 :          10 :                            && (valtype
    4187                 :          10 :                                != dfloat64_type_node
    4188                 :           8 :                                && (valtype
    4189                 :             :                                    != dfloat32_type_node)))
    4190                 :           8 :                        || (type == dfloat64_type_node
    4191                 :           4 :                            && (valtype
    4192                 :             :                                != dfloat32_type_node))))
    4193                 :          24 :             warning_at (ploc, 0,
    4194                 :             :                         "passing argument %d of %qE as %qT "
    4195                 :             :                         "rather than %qT due to prototype",
    4196                 :             :                         argnum, rname, type, valtype);
    4197                 :             : 
    4198                 :             :         }
    4199                 :             :       /* Detect integer changing in width or signedness.
    4200                 :             :          These warnings are only activated with
    4201                 :             :          -Wtraditional-conversion, not with -Wtraditional.  */
    4202                 :         105 :       else if (warn_traditional_conversion
    4203                 :         105 :                && INTEGRAL_TYPE_P (type)
    4204                 :         102 :                && INTEGRAL_TYPE_P (valtype))
    4205                 :             :         {
    4206                 :          83 :           unsigned int formal_prec = TYPE_PRECISION (type);
    4207                 :          83 :           tree would_have_been = default_conversion (val);
    4208                 :          83 :           tree type1 = TREE_TYPE (would_have_been);
    4209                 :             : 
    4210                 :          83 :           if (val == error_mark_node)
    4211                 :             :             /* VAL could have been of incomplete type.  */;
    4212                 :          83 :           else if (TREE_CODE (type) == ENUMERAL_TYPE
    4213                 :          83 :                    && (TYPE_MAIN_VARIANT (type)
    4214                 :           2 :                        == TYPE_MAIN_VARIANT (valtype)))
    4215                 :             :             /* No warning if function asks for enum
    4216                 :             :                and the actual arg is that enum type.  */
    4217                 :             :             ;
    4218                 :          81 :           else if (formal_prec != TYPE_PRECISION (type1))
    4219                 :          14 :             warning_at (ploc, OPT_Wtraditional_conversion,
    4220                 :             :                         "passing argument %d of %qE "
    4221                 :             :                         "with different width due to prototype",
    4222                 :             :                         argnum, rname);
    4223                 :          67 :           else if (TYPE_UNSIGNED (type) == TYPE_UNSIGNED (type1))
    4224                 :             :             ;
    4225                 :             :           /* Don't complain if the formal parameter type
    4226                 :             :              is an enum, because we can't tell now whether
    4227                 :             :              the value was an enum--even the same enum.  */
    4228                 :          32 :           else if (TREE_CODE (type) == ENUMERAL_TYPE)
    4229                 :             :             ;
    4230                 :          32 :           else if (TREE_CODE (val) == INTEGER_CST
    4231                 :           5 :                    && int_fits_type_p (val, type))
    4232                 :             :             /* Change in signedness doesn't matter
    4233                 :             :                if a constant value is unaffected.  */
    4234                 :             :             ;
    4235                 :             :           /* If the value is extended from a narrower
    4236                 :             :              unsigned type, it doesn't matter whether we
    4237                 :             :              pass it as signed or unsigned; the value
    4238                 :             :              certainly is the same either way.  */
    4239                 :          32 :           else if (TYPE_PRECISION (valtype) < TYPE_PRECISION (type)
    4240                 :          32 :                    && TYPE_UNSIGNED (valtype))
    4241                 :             :             ;
    4242                 :          32 :           else if (TYPE_UNSIGNED (type))
    4243                 :          17 :             warning_at (ploc, OPT_Wtraditional_conversion,
    4244                 :             :                         "passing argument %d of %qE "
    4245                 :             :                         "as unsigned due to prototype",
    4246                 :             :                         argnum, rname);
    4247                 :             :           else
    4248                 :          15 :             warning_at (ploc, OPT_Wtraditional_conversion,
    4249                 :             :                         "passing argument %d of %qE "
    4250                 :             :                         "as signed due to prototype",
    4251                 :             :                         argnum, rname);
    4252                 :             :         }
    4253                 :             :     }
    4254                 :             : 
    4255                 :             :   /* Possibly restore an EXCESS_PRECISION_EXPR for the
    4256                 :             :      sake of better warnings from convert_and_check.  */
    4257                 :   122285001 :   if (excess_precision)
    4258                 :         370 :     val = build1 (EXCESS_PRECISION_EXPR, valtype, val);
    4259                 :             : 
    4260                 :   122285001 :   tree parmval = convert_for_assignment (ploc, ploc, type,
    4261                 :             :                                          val, origtype, ic_argpass,
    4262                 :             :                                          npc, fundecl, function,
    4263                 :             :                                          parmnum + 1, warnopt);
    4264                 :   122285001 :   return parmval;
    4265                 :             : }
    4266                 :             : 
    4267                 :             : /* Convert the argument expressions in the vector VALUES
    4268                 :             :    to the types in the list TYPE_ARG_TYPES (FNTYPE).
    4269                 :             : 
    4270                 :             :    If the list is exhausted, or when an element has NULL as its type,
    4271                 :             :    perform the default conversions.
    4272                 :             : 
    4273                 :             :    ORIGTYPES is the original types of the expressions in VALUES.  This
    4274                 :             :    holds the type of enum values which have been converted to integral
    4275                 :             :    types.  It may be NULL.
    4276                 :             : 
    4277                 :             :    FUNCTION is a tree for the called function.  It is used only for
    4278                 :             :    error messages, where it is formatted with %qE.
    4279                 :             : 
    4280                 :             :    This is also where warnings about wrong number of args are generated.
    4281                 :             : 
    4282                 :             :    ARG_LOC are locations of function arguments (if any).
    4283                 :             : 
    4284                 :             :    Returns the actual number of arguments processed (which may be less
    4285                 :             :    than the length of VALUES in some error situations), or -1 on
    4286                 :             :    failure.  */
    4287                 :             : 
    4288                 :             : static int
    4289                 :    48573411 : convert_arguments (location_t loc, vec<location_t> arg_loc, tree fntype,
    4290                 :             :                    vec<tree, va_gc> *values, vec<tree, va_gc> *origtypes,
    4291                 :             :                    tree function, tree fundecl)
    4292                 :             : {
    4293                 :    48573411 :   tree typelist = TYPE_ARG_TYPES (fntype);
    4294                 :    48573411 :   unsigned int parmnum;
    4295                 :    48573411 :   bool error_args = false;
    4296                 :    48573411 :   const bool type_generic = fundecl
    4297                 :    48573411 :     && lookup_attribute ("type generic", TYPE_ATTRIBUTES (TREE_TYPE (fundecl)));
    4298                 :    48573411 :   bool type_generic_remove_excess_precision = false;
    4299                 :    48573411 :   bool type_generic_overflow_p = false;
    4300                 :    48573411 :   bool type_generic_bit_query = false;
    4301                 :    48573411 :   tree selector;
    4302                 :             : 
    4303                 :             :   /* Change pointer to function to the function itself for
    4304                 :             :      diagnostics.  */
    4305                 :    48573411 :   if (TREE_CODE (function) == ADDR_EXPR
    4306                 :    48573411 :       && TREE_CODE (TREE_OPERAND (function, 0)) == FUNCTION_DECL)
    4307                 :    48498578 :     function = TREE_OPERAND (function, 0);
    4308                 :             : 
    4309                 :             :   /* Handle an ObjC selector specially for diagnostics.  */
    4310                 :    48573411 :   selector = objc_message_selector ();
    4311                 :             : 
    4312                 :             :   /* For a call to a built-in function declared without a prototype,
    4313                 :             :      set to the built-in function's argument list.  */
    4314                 :    48573411 :   tree builtin_typelist = NULL_TREE;
    4315                 :             : 
    4316                 :             :   /* For type-generic built-in functions, determine whether excess
    4317                 :             :      precision should be removed (classification) or not
    4318                 :             :      (comparison).  */
    4319                 :    48573411 :   if (fundecl
    4320                 :    48573411 :       && fndecl_built_in_p (fundecl, BUILT_IN_NORMAL))
    4321                 :             :     {
    4322                 :     1382599 :       built_in_function code = DECL_FUNCTION_CODE (fundecl);
    4323                 :     1382599 :       if (C_DECL_BUILTIN_PROTOTYPE (fundecl))
    4324                 :             :         {
    4325                 :             :           /* For a call to a built-in function declared without a prototype
    4326                 :             :              use the types of the parameters of the internal built-in to
    4327                 :             :              match those of the arguments to.  */
    4328                 :      681273 :           if (tree bdecl = builtin_decl_explicit (code))
    4329                 :      681273 :             builtin_typelist = TYPE_ARG_TYPES (TREE_TYPE (bdecl));
    4330                 :             :         }
    4331                 :             : 
    4332                 :             :       /* For type-generic built-in functions, determine whether excess
    4333                 :             :          precision should be removed (classification) or not
    4334                 :             :          (comparison).  */
    4335                 :     1382599 :       if (type_generic)
    4336                 :       60627 :         switch (code)
    4337                 :             :           {
    4338                 :        5305 :           case BUILT_IN_ISFINITE:
    4339                 :        5305 :           case BUILT_IN_ISINF:
    4340                 :        5305 :           case BUILT_IN_ISINF_SIGN:
    4341                 :        5305 :           case BUILT_IN_ISNAN:
    4342                 :        5305 :           case BUILT_IN_ISNORMAL:
    4343                 :        5305 :           case BUILT_IN_ISSIGNALING:
    4344                 :        5305 :           case BUILT_IN_FPCLASSIFY:
    4345                 :        5305 :             type_generic_remove_excess_precision = true;
    4346                 :        5305 :             break;
    4347                 :             : 
    4348                 :       21012 :           case BUILT_IN_ADD_OVERFLOW_P:
    4349                 :       21012 :           case BUILT_IN_SUB_OVERFLOW_P:
    4350                 :       21012 :           case BUILT_IN_MUL_OVERFLOW_P:
    4351                 :             :             /* The last argument of these type-generic builtins
    4352                 :             :                should not be promoted.  */
    4353                 :       21012 :             type_generic_overflow_p = true;
    4354                 :       21012 :             break;
    4355                 :             : 
    4356                 :        1278 :           case BUILT_IN_CLZG:
    4357                 :        1278 :           case BUILT_IN_CTZG:
    4358                 :        1278 :           case BUILT_IN_CLRSBG:
    4359                 :        1278 :           case BUILT_IN_FFSG:
    4360                 :        1278 :           case BUILT_IN_PARITYG:
    4361                 :        1278 :           case BUILT_IN_POPCOUNTG:
    4362                 :             :             /* The first argument of these type-generic builtins
    4363                 :             :                should not be promoted.  */
    4364                 :        1278 :             type_generic_bit_query = true;
    4365                 :        1278 :             break;
    4366                 :             : 
    4367                 :             :           default:
    4368                 :             :             break;
    4369                 :             :           }
    4370                 :             :     }
    4371                 :             : 
    4372                 :             :   /* Scan the given expressions (VALUES) and types (TYPELIST), producing
    4373                 :             :      individual converted arguments.  */
    4374                 :             : 
    4375                 :    48573411 :   tree typetail, builtin_typetail, val;
    4376                 :    48573411 :   for (typetail = typelist,
    4377                 :    48573411 :          builtin_typetail = builtin_typelist,
    4378                 :    48573411 :          parmnum = 0;
    4379                 :   171790887 :        values && values->iterate (parmnum, &val);
    4380                 :             :        ++parmnum)
    4381                 :             :     {
    4382                 :             :       /* The type of the function parameter (if it was declared with one).  */
    4383                 :   245500630 :       tree type = typetail ? TREE_VALUE (typetail) : NULL_TREE;
    4384                 :             :       /* The type of the built-in function parameter (if the function
    4385                 :             :          is a built-in).  Used to detect type incompatibilities in
    4386                 :             :          calls to built-ins declared without a prototype.  */
    4387                 :   123217512 :       tree builtin_type = (builtin_typetail
    4388                 :   124242817 :                            ? TREE_VALUE (builtin_typetail) : NULL_TREE);
    4389                 :             :       /* The original type of the argument being passed to the function.  */
    4390                 :   123217512 :       tree valtype = TREE_TYPE (val);
    4391                 :             :       /* The called function (or function selector in Objective C).  */
    4392                 :   123217512 :       tree rname = function;
    4393                 :   123217512 :       int argnum = parmnum + 1;
    4394                 :   123217512 :       const char *invalid_func_diag;
    4395                 :             :       /* Set for EXCESS_PRECISION_EXPR arguments.  */
    4396                 :   123217512 :       bool excess_precision = false;
    4397                 :             :       /* The value of the argument after conversion to the type
    4398                 :             :          of the function parameter it is passed to.  */
    4399                 :   123217512 :       tree parmval;
    4400                 :             :       /* Some __atomic_* builtins have additional hidden argument at
    4401                 :             :          position 0.  */
    4402                 :   123217512 :       location_t ploc
    4403                 :   122951459 :         = !arg_loc.is_empty () && values->length () == arg_loc.length ()
    4404                 :   122950859 :           ? expansion_point_location_if_in_system_header (arg_loc[parmnum])
    4405                 :   123217512 :           : input_location;
    4406                 :             : 
    4407                 :   123217512 :       if (type == void_type_node)
    4408                 :             :         {
    4409                 :          33 :           auto_diagnostic_group d;
    4410                 :          33 :           int num_expected = parmnum;
    4411                 :          33 :           int num_actual = values->length ();
    4412                 :          33 :           gcc_rich_location rich_loc (loc);
    4413                 :          33 :           if (ploc != input_location)
    4414                 :          32 :             rich_loc.add_range (ploc);
    4415                 :          33 :           if (selector)
    4416                 :           0 :             error_at (&rich_loc,
    4417                 :             :                       "too many arguments to method %qE; expected %i, have %i",
    4418                 :             :                       selector, num_expected, num_actual);
    4419                 :             :           else
    4420                 :          33 :             error_at (&rich_loc,
    4421                 :             :                       "too many arguments to function %qE; expected %i, have %i",
    4422                 :             :                       function, num_expected, num_actual);
    4423                 :          33 :           inform_declaration (fundecl, function);
    4424                 :          65 :           return error_args ? -1 : (int) parmnum;
    4425                 :          33 :         }
    4426                 :             : 
    4427                 :   123217479 :       if (builtin_type == void_type_node)
    4428                 :             :         {
    4429                 :          12 :           auto_diagnostic_group d;
    4430                 :          12 :           if (warning_at (loc, OPT_Wbuiltin_declaration_mismatch,
    4431                 :             :                           "too many arguments to built-in function %qE "
    4432                 :             :                           "expecting %d", function, parmnum))
    4433                 :          12 :             inform_declaration (fundecl, function);
    4434                 :          12 :           builtin_typetail = NULL_TREE;
    4435                 :          12 :         }
    4436                 :             : 
    4437                 :       89687 :       if (!typetail && parmnum == 0 && !TYPE_NO_NAMED_ARGS_STDARG_P (fntype)
    4438                 :   123307049 :           && !(fundecl && fndecl_built_in_p (fundecl)))
    4439                 :             :         {
    4440                 :        6962 :           auto_diagnostic_group d;
    4441                 :        6962 :           bool warned;
    4442                 :        6962 :           if (selector)
    4443                 :           0 :             warned = warning_at (loc, OPT_Wdeprecated_non_prototype,
    4444                 :             :                                  "ISO C23 does not allow arguments"
    4445                 :             :                                  " for method %qE declared without parameters",
    4446                 :             :                                  function);
    4447                 :             :           else
    4448                 :        6962 :             warned = warning_at (loc, OPT_Wdeprecated_non_prototype,
    4449                 :             :                                  "ISO C23 does not allow arguments"
    4450                 :             :                                  " for function %qE declared without parameters",
    4451                 :             :                                  function);
    4452                 :        6962 :           if (warned)
    4453                 :           4 :             inform_declaration (fundecl, function);
    4454                 :        6962 :         }
    4455                 :             : 
    4456                 :   123217479 :       if (selector && argnum > 2)
    4457                 :             :         {
    4458                 :           0 :           rname = selector;
    4459                 :           0 :           argnum -= 2;
    4460                 :             :         }
    4461                 :             : 
    4462                 :             :       /* Determine if VAL is a null pointer constant before folding it.  */
    4463                 :   123217479 :       bool npc = null_pointer_constant_p (val);
    4464                 :             : 
    4465                 :             :       /* If there is excess precision and a prototype, convert once to
    4466                 :             :          the required type rather than converting via the semantic
    4467                 :             :          type.  Likewise without a prototype a float value represented
    4468                 :             :          as long double should be converted once to double.  But for
    4469                 :             :          type-generic classification functions excess precision must
    4470                 :             :          be removed here.  */
    4471                 :   123217479 :       if (TREE_CODE (val) == EXCESS_PRECISION_EXPR
    4472                 :         423 :           && (type || !type_generic || !type_generic_remove_excess_precision))
    4473                 :             :         {
    4474                 :         403 :           val = TREE_OPERAND (val, 0);
    4475                 :         403 :           excess_precision = true;
    4476                 :             :         }
    4477                 :   123217479 :       val = c_fully_fold (val, false, NULL);
    4478                 :   246434959 :       STRIP_TYPE_NOPS (val);
    4479                 :             : 
    4480                 :   123217479 :       val = require_complete_type (ploc, val);
    4481                 :             : 
    4482                 :             :       /* Some floating-point arguments must be promoted to double when
    4483                 :             :          no type is specified by a prototype.  This applies to
    4484                 :             :          arguments of type float, and to architecture-specific types
    4485                 :             :          (ARM __fp16), but not to _FloatN or _FloatNx types.  */
    4486                 :   123217479 :       bool promote_float_arg = false;
    4487                 :   123217479 :       if (type == NULL_TREE
    4488                 :      934394 :           && TREE_CODE (valtype) == REAL_TYPE
    4489                 :      269526 :           && (TYPE_PRECISION (valtype)
    4490                 :      269526 :               <= TYPE_PRECISION (double_type_node))
    4491                 :      262244 :           && TYPE_MAIN_VARIANT (valtype) != double_type_node
    4492                 :      131343 :           && TYPE_MAIN_VARIANT (valtype) != long_double_type_node
    4493                 :   123348822 :           && !DECIMAL_FLOAT_MODE_P (TYPE_MODE (valtype)))
    4494                 :             :         {
    4495                 :             :           /* Promote this argument, unless it has a _FloatN or
    4496                 :             :              _FloatNx type.  */
    4497                 :     1027603 :           promote_float_arg = true;
    4498                 :     1027603 :           for (int i = 0; i < NUM_FLOATN_NX_TYPES; i++)
    4499                 :      900219 :             if (TYPE_MAIN_VARIANT (valtype) == FLOATN_NX_TYPE_NODE (i))
    4500                 :             :               {
    4501                 :             :                 promote_float_arg = false;
    4502                 :             :                 break;
    4503                 :             :               }
    4504                 :             :           /* Don't promote __bf16 either.  */
    4505                 :      130610 :           if (TYPE_MAIN_VARIANT (valtype) == bfloat16_type_node)
    4506                 :   123086939 :             promote_float_arg = false;
    4507                 :             :         }
    4508                 :             : 
    4509                 :   123217479 :       if (type != NULL_TREE)
    4510                 :             :         {
    4511                 :   122283085 :           tree origtype = (!origtypes) ? NULL_TREE : (*origtypes)[parmnum];
    4512                 :   122283085 :           parmval = convert_argument (ploc, function, fundecl, type, origtype,
    4513                 :             :                                       val, valtype, npc, rname, parmnum, argnum,
    4514                 :             :                                       excess_precision, 0);
    4515                 :             :         }
    4516                 :      934394 :       else if (promote_float_arg)
    4517                 :             :         {
    4518                 :      127314 :           if (type_generic)
    4519                 :             :             parmval = val;
    4520                 :             :           else
    4521                 :             :             {
    4522                 :             :               /* Convert `float' to `double'.  */
    4523                 :      124446 :               if (warn_double_promotion && !c_inhibit_evaluation_warnings)
    4524                 :           6 :                 warning_at (ploc, OPT_Wdouble_promotion,
    4525                 :             :                             "implicit conversion from %qT to %qT when passing "
    4526                 :             :                             "argument to function",
    4527                 :             :                             valtype, double_type_node);
    4528                 :      124446 :               parmval = convert (double_type_node, val);
    4529                 :             :             }
    4530                 :             :         }
    4531                 :      807080 :       else if ((excess_precision && !type_generic)
    4532                 :      807078 :                || (type_generic_overflow_p && parmnum == 2)
    4533                 :      786070 :                || (type_generic_bit_query && parmnum == 0))
    4534                 :             :         /* A "double" argument with excess precision being passed
    4535                 :             :            without a prototype or in variable arguments.
    4536                 :             :            The last argument of __builtin_*_overflow_p should not be
    4537                 :             :            promoted, similarly the first argument of
    4538                 :             :            __builtin_{clz,ctz,clrsb,ffs,parity,popcount}g.  */
    4539                 :       22282 :         parmval = convert (valtype, val);
    4540                 :     1569596 :       else if ((invalid_func_diag =
    4541                 :      784798 :                 targetm.calls.invalid_arg_for_unprototyped_fn (typelist, fundecl, val)))
    4542                 :             :         {
    4543                 :           0 :           error (invalid_func_diag);
    4544                 :           0 :           return -1;
    4545                 :             :         }
    4546                 :      784798 :       else if (TREE_CODE (val) == ADDR_EXPR && reject_gcc_builtin (val))
    4547                 :             :         {
    4548                 :             :           return -1;
    4549                 :             :         }
    4550                 :             :       else
    4551                 :             :         /* Convert `short' and `char' to full-size `int'.  */
    4552                 :      784795 :         parmval = default_conversion (val);
    4553                 :             : 
    4554                 :   123217476 :       (*values)[parmnum] = parmval;
    4555                 :   123217476 :       if (parmval == error_mark_node)
    4556                 :         105 :         error_args = true;
    4557                 :             : 
    4558                 :   123217476 :       if (!type && builtin_type && TREE_CODE (builtin_type) != VOID_TYPE)
    4559                 :             :         {
    4560                 :             :           /* For a call to a built-in function declared without a prototype,
    4561                 :             :              perform the conversions from the argument to the expected type
    4562                 :             :              but issue warnings rather than errors for any mismatches.
    4563                 :             :              Ignore the converted argument and use the PARMVAL obtained
    4564                 :             :              above by applying default conversions instead.  */
    4565                 :        1919 :           tree origtype = (!origtypes) ? NULL_TREE : (*origtypes)[parmnum];
    4566                 :        1919 :           convert_argument (ploc, function, fundecl, builtin_type, origtype,
    4567                 :             :                             val, valtype, npc, rname, parmnum, argnum,
    4568                 :             :                             excess_precision,
    4569                 :             :                             OPT_Wbuiltin_declaration_mismatch);
    4570                 :             :         }
    4571                 :             : 
    4572                 :   123217476 :       if (typetail)
    4573                 :   122283085 :         typetail = TREE_CHAIN (typetail);
    4574                 :             : 
    4575                 :   123217476 :       if (builtin_typetail)
    4576                 :     1025288 :         builtin_typetail = TREE_CHAIN (builtin_typetail);
    4577                 :             :     }
    4578                 :             : 
    4579                 :    85749848 :   gcc_assert (parmnum == vec_safe_length (values));
    4580                 :             : 
    4581                 :    96818634 :   if (typetail != NULL_TREE && TREE_VALUE (typetail) != void_type_node)
    4582                 :             :     {
    4583                 :             :       /* Not enough args.
    4584                 :             :          Determine minimum number of arguments required.  */
    4585                 :             :       int min_expected_num = 0;
    4586                 :         231 :       bool at_least_p = false;
    4587                 :             :       tree iter = typelist;
    4588                 :         386 :       while (true)
    4589                 :             :         {
    4590                 :         231 :           if (!iter)
    4591                 :             :             {
    4592                 :             :               /* Variadic arguments; stop iterating.  */
    4593                 :             :               at_least_p = true;
    4594                 :             :               break;
    4595                 :             :             }
    4596                 :         222 :           if (iter == void_list_node)
    4597                 :             :             /* End of arguments; stop iterating.  */
    4598                 :             :             break;
    4599                 :         155 :           ++min_expected_num;
    4600                 :         155 :           iter = TREE_CHAIN (iter);
    4601                 :             :         }
    4602                 :          76 :       auto_diagnostic_group d;
    4603                 :          76 :       int actual_num = vec_safe_length (values);
    4604                 :         143 :       error_at (loc,
    4605                 :             :                 at_least_p
    4606                 :             :                 ? G_("too few arguments to function %qE; expected at least %i, have %i")
    4607                 :             :                 : G_("too few arguments to function %qE; expected %i, have %i"),
    4608                 :             :                 function, min_expected_num, actual_num);
    4609                 :          76 :       inform_declaration (fundecl, function);
    4610                 :          76 :       return -1;
    4611                 :          76 :     }
    4612                 :             : 
    4613                 :    49218945 :   if (builtin_typetail && TREE_VALUE (builtin_typetail) != void_type_node)
    4614                 :             :     {
    4615                 :             :       unsigned nargs = parmnum;
    4616                 :         616 :       for (tree t = builtin_typetail; t; t = TREE_CHAIN (t))
    4617                 :         428 :         ++nargs;
    4618                 :             : 
    4619                 :         188 :       auto_diagnostic_group d;
    4620                 :         188 :       if (warning_at (loc, OPT_Wbuiltin_declaration_mismatch,
    4621                 :             :                       "too few arguments to built-in function %qE "
    4622                 :             :                       "expecting %u", function, nargs - 1))
    4623                 :         173 :         inform_declaration (fundecl, function);
    4624                 :         188 :     }
    4625                 :             : 
    4626                 :    48573299 :   return error_args ? -1 : (int) parmnum;
    4627                 :             : }
    4628                 :             : 
    4629                 :             : /* This is the entry point used by the parser to build unary operators
    4630                 :             :    in the input.  CODE, a tree_code, specifies the unary operator, and
    4631                 :             :    ARG is the operand.  For unary plus, the C parser currently uses
    4632                 :             :    CONVERT_EXPR for code.
    4633                 :             : 
    4634                 :             :    LOC is the location to use for the tree generated.
    4635                 :             : */
    4636                 :             : 
    4637                 :             : struct c_expr
    4638                 :     7959129 : parser_build_unary_op (location_t loc, enum tree_code code, struct c_expr arg)
    4639                 :             : {
    4640                 :     7959129 :   struct c_expr result;
    4641                 :             : 
    4642                 :     7959129 :   result.original_code = code;
    4643                 :     7959129 :   result.original_type = NULL;
    4644                 :     7959129 :   result.m_decimal = 0;
    4645                 :             : 
    4646                 :     7959129 :   if (reject_gcc_builtin (arg.value))
    4647                 :             :     {
    4648                 :           2 :       result.value = error_mark_node;
    4649                 :             :     }
    4650                 :             :   else
    4651                 :             :     {
    4652                 :     7959127 :       result.value = build_unary_op (loc, code, arg.value, false);
    4653                 :             : 
    4654                 :     7959127 :       if (TREE_OVERFLOW_P (result.value) && !TREE_OVERFLOW_P (arg.value))
    4655                 :           5 :         overflow_warning (loc, result.value, arg.value);
    4656                 :             :     }
    4657                 :             : 
    4658                 :             :   /* We are typically called when parsing a prefix token at LOC acting on
    4659                 :             :      ARG.  Reflect this by updating the source range of the result to
    4660                 :             :      start at LOC and end at the end of ARG.  */
    4661                 :     7959129 :   set_c_expr_source_range (&result,
    4662                 :             :                            loc, arg.get_finish ());
    4663                 :             : 
    4664                 :     7959129 :   return result;
    4665                 :             : }
    4666                 :             : 
    4667                 :             : /* Returns true if TYPE is a character type, *not* including wchar_t.  */
    4668                 :             : 
    4669                 :             : bool
    4670                 :     1240185 : char_type_p (tree type)
    4671                 :             : {
    4672                 :     1240185 :   return (type == char_type_node
    4673                 :      956212 :           || type == unsigned_char_type_node
    4674                 :      922275 :           || type == signed_char_type_node
    4675                 :      921436 :           || type == char16_type_node
    4676                 :     1948119 :           || type == char32_type_node);
    4677                 :             : }
    4678                 :             : 
    4679                 :             : /* This is the entry point used by the parser to build binary operators
    4680                 :             :    in the input.  CODE, a tree_code, specifies the binary operator, and
    4681                 :             :    ARG1 and ARG2 are the operands.  In addition to constructing the
    4682                 :             :    expression, we check for operands that were written with other binary
    4683                 :             :    operators in a way that is likely to confuse the user.
    4684                 :             : 
    4685                 :             :    LOCATION is the location of the binary operator.  */
    4686                 :             : 
    4687                 :             : struct c_expr
    4688                 :     9137306 : parser_build_binary_op (location_t location, enum tree_code code,
    4689                 :             :                         struct c_expr arg1, struct c_expr arg2)
    4690                 :             : {
    4691                 :     9137306 :   struct c_expr result;
    4692                 :     9137306 :   result.m_decimal = 0;
    4693                 :             : 
    4694                 :     9137306 :   enum tree_code code1 = arg1.original_code;
    4695                 :     9137306 :   enum tree_code code2 = arg2.original_code;
    4696                 :     9137306 :   tree type1 = (arg1.original_type
    4697                 :     9137306 :                 ? arg1.original_type
    4698                 :     5876778 :                 : TREE_TYPE (arg1.value));
    4699                 :     9137306 :   tree type2 = (arg2.original_type
    4700                 :     9137306 :                 ? arg2.original_type
    4701                 :     6745543 :                 : TREE_TYPE (arg2.value));
    4702                 :             : 
    4703                 :     9137306 :   result.value = build_binary_op (location, code,
    4704                 :             :                                   arg1.value, arg2.value, true);
    4705                 :     9137305 :   result.original_code = code;
    4706                 :     9137305 :   result.original_type = NULL;
    4707                 :     9137305 :   result.m_decimal = 0;
    4708                 :             : 
    4709                 :     9137305 :   if (TREE_CODE (result.value) == ERROR_MARK)
    4710                 :             :     {
    4711                 :        1295 :       set_c_expr_source_range (&result,
    4712                 :             :                                arg1.get_start (),
    4713                 :             :                                arg2.get_finish ());
    4714                 :        1295 :       return result;
    4715                 :             :     }
    4716                 :             : 
    4717                 :     9136010 :   if (location != UNKNOWN_LOCATION)
    4718                 :     9136010 :     protected_set_expr_location (result.value, location);
    4719                 :             : 
    4720                 :     9136010 :   set_c_expr_source_range (&result,
    4721                 :             :                            arg1.get_start (),
    4722                 :             :                            arg2.get_finish ());
    4723                 :             : 
    4724                 :             :   /* Check for cases such as x+y<<z which users are likely
    4725                 :             :      to misinterpret.  */
    4726                 :     9136010 :   if (warn_parentheses)
    4727                 :     1999801 :     warn_about_parentheses (location, code, code1, arg1.value, code2,
    4728                 :             :                             arg2.value);
    4729                 :             : 
    4730                 :     9136010 :   if (warn_logical_op)
    4731                 :         340 :     warn_logical_operator (location, code, TREE_TYPE (result.value),
    4732                 :             :                            code1, arg1.value, code2, arg2.value);
    4733                 :             : 
    4734                 :     9136010 :   if (warn_tautological_compare)
    4735                 :             :     {
    4736                 :     1998314 :       tree lhs = arg1.value;
    4737                 :     1998314 :       tree rhs = arg2.value;
    4738                 :     1998314 :       if (TREE_CODE (lhs) == C_MAYBE_CONST_EXPR)
    4739                 :             :         {
    4740                 :           2 :           if (C_MAYBE_CONST_EXPR_PRE (lhs) != NULL_TREE
    4741                 :           2 :               && TREE_SIDE_EFFECTS (C_MAYBE_CONST_EXPR_PRE (lhs)))
    4742                 :             :             lhs = NULL_TREE;
    4743                 :             :           else
    4744                 :           2 :             lhs = C_MAYBE_CONST_EXPR_EXPR (lhs);
    4745                 :             :         }
    4746                 :     1998314 :       if (TREE_CODE (rhs) == C_MAYBE_CONST_EXPR)
    4747                 :             :         {
    4748                 :          12 :           if (C_MAYBE_CONST_EXPR_PRE (rhs) != NULL_TREE
    4749                 :          12 :               && TREE_SIDE_EFFECTS (C_MAYBE_CONST_EXPR_PRE (rhs)))
    4750                 :             :             rhs = NULL_TREE;
    4751                 :             :           else
    4752                 :          12 :             rhs = C_MAYBE_CONST_EXPR_EXPR (rhs);
    4753                 :             :         }
    4754                 :     1998314 :       if (lhs != NULL_TREE && rhs != NULL_TREE)
    4755                 :     1998314 :         warn_tautological_cmp (location, code, lhs, rhs);
    4756                 :             :     }
    4757                 :             : 
    4758                 :     9136010 :   if (warn_logical_not_paren
    4759                 :     1998397 :       && TREE_CODE_CLASS (code) == tcc_comparison
    4760                 :      403922 :       && code1 == TRUTH_NOT_EXPR
    4761                 :      403922 :       && code2 != TRUTH_NOT_EXPR
    4762                 :             :       /* Avoid warning for !!x == y.  */
    4763                 :     9136136 :       && (TREE_CODE (arg1.value) != NE_EXPR
    4764                 :          19 :           || !integer_zerop (TREE_OPERAND (arg1.value, 1))))
    4765                 :             :     {
    4766                 :             :       /* Avoid warning for !b == y where b has _Bool type.  */
    4767                 :         107 :       tree t = integer_zero_node;
    4768                 :         107 :       if (TREE_CODE (arg1.value) == EQ_EXPR
    4769                 :          98 :           && integer_zerop (TREE_OPERAND (arg1.value, 1))
    4770                 :         205 :           && TREE_TYPE (TREE_OPERAND (arg1.value, 0)) == integer_type_node)
    4771                 :             :         {
    4772                 :          90 :           t = TREE_OPERAND (arg1.value, 0);
    4773                 :         199 :           do
    4774                 :             :             {
    4775                 :         199 :               if (TREE_TYPE (t) != integer_type_node)
    4776                 :             :                 break;
    4777                 :         180 :               if (TREE_CODE (t) == C_MAYBE_CONST_EXPR)
    4778                 :          90 :                 t = C_MAYBE_CONST_EXPR_EXPR (t);
    4779                 :          90 :               else if (CONVERT_EXPR_P (t))
    4780                 :          19 :                 t = TREE_OPERAND (t, 0);
    4781                 :             :               else
    4782                 :             :                 break;
    4783                 :             :             }
    4784                 :             :           while (1);
    4785                 :             :         }
    4786                 :         107 :       if (!C_BOOLEAN_TYPE_P (TREE_TYPE (t)))
    4787                 :          88 :         warn_logical_not_parentheses (location, code, arg1.value, arg2.value);
    4788                 :             :     }
    4789                 :             : 
    4790                 :             :   /* Warn about comparisons against string literals, with the exception
    4791                 :             :      of testing for equality or inequality of a string literal with NULL.  */
    4792                 :     9136010 :   if (code == EQ_EXPR || code == NE_EXPR)
    4793                 :             :     {
    4794                 :     1145996 :       if ((code1 == STRING_CST
    4795                 :          16 :            && !integer_zerop (tree_strip_nop_conversions (arg2.value)))
    4796                 :     1146007 :           || (code2 == STRING_CST
    4797                 :          20 :               && !integer_zerop (tree_strip_nop_conversions (arg1.value))))
    4798                 :          17 :         warning_at (location, OPT_Waddress,
    4799                 :             :                     "comparison with string literal results in unspecified behavior");
    4800                 :             :       /* Warn for ptr == '\0', it's likely that it should've been ptr[0].  */
    4801                 :     1145996 :       if (POINTER_TYPE_P (type1)
    4802                 :       90147 :           && null_pointer_constant_p (arg2.value)
    4803                 :     1166783 :           && char_type_p (type2))
    4804                 :             :         {
    4805                 :          18 :           auto_diagnostic_group d;
    4806                 :          18 :           if (warning_at (location, OPT_Wpointer_compare,
    4807                 :             :                             "comparison between pointer and zero character "
    4808                 :             :                             "constant"))
    4809                 :          10 :             inform (arg1.get_start (),
    4810                 :             :                       "did you mean to dereference the pointer?");
    4811                 :          18 :         }
    4812                 :     1145978 :       else if (POINTER_TYPE_P (type2)
    4813                 :       87501 :                && null_pointer_constant_p (arg1.value)
    4814                 :     1146240 :                && char_type_p (type1))
    4815                 :             :         {
    4816                 :          10 :           auto_diagnostic_group d;
    4817                 :          10 :           if (warning_at (location, OPT_Wpointer_compare,
    4818                 :             :                             "comparison between pointer and zero character "
    4819                 :             :                             "constant"))
    4820                 :          10 :             inform (arg2.get_start (),
    4821                 :             :                       "did you mean to dereference the pointer?");
    4822                 :          10 :         }
    4823                 :             :     }
    4824                 :     7990014 :   else if (TREE_CODE_CLASS (code) == tcc_comparison
    4825                 :      971602 :            && (code1 == STRING_CST || code2 == STRING_CST))
    4826                 :           0 :     warning_at (location, OPT_Waddress,
    4827                 :             :                 "comparison with string literal results in unspecified "
    4828                 :             :                 "behavior");
    4829                 :             : 
    4830                 :     9136010 :   if (warn_zero_as_null_pointer_constant
    4831                 :          18 :       && c_inhibit_evaluation_warnings == 0
    4832                 :          18 :       && TREE_CODE_CLASS (code) == tcc_comparison)
    4833                 :             :     {
    4834                 :          18 :       if ((TREE_CODE (type1) == POINTER_TYPE
    4835                 :          14 :            || TREE_CODE (type1) == NULLPTR_TYPE)
    4836                 :           6 :           && TREE_CODE (type2) == INTEGER_TYPE
    4837                 :          24 :           && null_pointer_constant_p (arg2.value))
    4838                 :           6 :         warning_at (arg2.get_location(), OPT_Wzero_as_null_pointer_constant,
    4839                 :             :                     "zero as null pointer constant");
    4840                 :             : 
    4841                 :          18 :       if ((TREE_CODE (type2) == POINTER_TYPE
    4842                 :          12 :            || TREE_CODE (type2) == NULLPTR_TYPE)
    4843                 :           8 :           && TREE_CODE (type1) == INTEGER_TYPE
    4844                 :          26 :           && null_pointer_constant_p (arg1.value))
    4845                 :           8 :         warning_at (arg1.get_location(), OPT_Wzero_as_null_pointer_constant,
    4846                 :             :                     "zero as null pointer constant");
    4847                 :             :     }
    4848                 :             : 
    4849                 :     9136010 :   if (warn_array_compare
    4850                 :     1998152 :       && TREE_CODE_CLASS (code) == tcc_comparison
    4851                 :      403707 :       && TREE_CODE (type1) == ARRAY_TYPE
    4852                 :          38 :       && TREE_CODE (type2) == ARRAY_TYPE)
    4853                 :          15 :     do_warn_array_compare (location, code, arg1.value, arg2.value);
    4854                 :             : 
    4855                 :     2150562 :   if (TREE_OVERFLOW_P (result.value)
    4856                 :         290 :       && !TREE_OVERFLOW_P (arg1.value)
    4857                 :     9136293 :       && !TREE_OVERFLOW_P (arg2.value))
    4858                 :         240 :     overflow_warning (location, result.value);
    4859                 :             : 
    4860                 :             :   /* Warn about comparisons of different enum types.  */
    4861                 :     9136009 :   if (warn_enum_compare
    4862                 :     2017990 :       && TREE_CODE_CLASS (code) == tcc_comparison
    4863                 :      408112 :       && TREE_CODE (type1) == ENUMERAL_TYPE
    4864                 :        6966 :       && TREE_CODE (type2) == ENUMERAL_TYPE
    4865                 :     9142913 :       && TYPE_MAIN_VARIANT (type1) != TYPE_MAIN_VARIANT (type2))
    4866                 :           2 :     warning_at (location, OPT_Wenum_compare,
    4867                 :             :                 "comparison between %qT and %qT",
    4868                 :             :                 type1, type2);
    4869                 :             : 
    4870                 :     9136009 :   if (warn_xor_used_as_pow
    4871                 :     9136009 :       && code == BIT_XOR_EXPR
    4872                 :       74958 :       && arg1.m_decimal
    4873                 :         722 :       && arg2.m_decimal)
    4874                 :         427 :     check_for_xor_used_as_pow (arg1.get_location (), arg1.value,
    4875                 :             :                                location,
    4876                 :             :                                arg2.get_location (), arg2.value);
    4877                 :             : 
    4878                 :             :   return result;
    4879                 :             : }
    4880                 :             : 
    4881                 :             : /* Return a tree for the difference of pointers OP0 and OP1.
    4882                 :             :    The resulting tree has type ptrdiff_t.  If POINTER_SUBTRACT sanitization is
    4883                 :             :    enabled, assign to INSTRUMENT_EXPR call to libsanitizer.  */
    4884                 :             : 
    4885                 :             : static tree
    4886                 :        3619 : pointer_diff (location_t loc, tree op0, tree op1, tree *instrument_expr)
    4887                 :             : {
    4888                 :        3619 :   tree restype = ptrdiff_type_node;
    4889                 :        3619 :   tree result, inttype;
    4890                 :             : 
    4891                 :        3619 :   addr_space_t as0 = TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (op0)));
    4892                 :        3619 :   addr_space_t as1 = TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (op1)));
    4893                 :        3619 :   tree target_type = TREE_TYPE (TREE_TYPE (op0));
    4894                 :        3619 :   tree orig_op0 = op0;
    4895                 :        3619 :   tree orig_op1 = op1;
    4896                 :             : 
    4897                 :             :   /* If the operands point into different address spaces, we need to
    4898                 :             :      explicitly convert them to pointers into the common address space
    4899                 :             :      before we can subtract the numerical address values.  */
    4900                 :        3619 :   if (as0 != as1)
    4901                 :             :     {
    4902                 :           0 :       addr_space_t as_common;
    4903                 :           0 :       tree common_type;
    4904                 :             : 
    4905                 :             :       /* Determine the common superset address space.  This is guaranteed
    4906                 :             :          to exist because the caller verified that comp_target_types
    4907                 :             :          returned non-zero.  */
    4908                 :           0 :       if (!addr_space_superset (as0, as1, &as_common))
    4909                 :           0 :         gcc_unreachable ();
    4910                 :             : 
    4911                 :           0 :       common_type = common_pointer_type (TREE_TYPE (op0), TREE_TYPE (op1));
    4912                 :           0 :       op0 = convert (common_type, op0);
    4913                 :           0 :       op1 = convert (common_type, op1);
    4914                 :             :     }
    4915                 :             : 
    4916                 :             :   /* Determine integer type result of the subtraction.  This will usually
    4917                 :             :      be the same as the result type (ptrdiff_t), but may need to be a wider
    4918                 :             :      type if pointers for the address space are wider than ptrdiff_t.  */
    4919                 :        3619 :   if (TYPE_PRECISION (restype) < TYPE_PRECISION (TREE_TYPE (op0)))
    4920                 :           0 :     inttype = c_common_type_for_size (TYPE_PRECISION (TREE_TYPE (op0)), 0);
    4921                 :             :   else
    4922                 :             :     inttype = restype;
    4923                 :             : 
    4924                 :        3619 :   if (VOID_TYPE_P (target_type))
    4925                 :         135 :     pedwarn (loc, OPT_Wpointer_arith,
    4926                 :             :              "pointer of type %<void *%> used in subtraction");
    4927                 :        3619 :   if (TREE_CODE (target_type) == FUNCTION_TYPE)
    4928                 :           4 :     pedwarn (loc, OPT_Wpointer_arith,
    4929                 :             :              "pointer to a function used in subtraction");
    4930                 :             : 
    4931                 :        3619 :   if (current_function_decl != NULL_TREE
    4932                 :        3619 :       && sanitize_flags_p (SANITIZE_POINTER_SUBTRACT))
    4933                 :             :     {
    4934                 :          70 :       op0 = save_expr (c_fully_fold (op0, false, NULL));
    4935                 :          70 :       op1 = save_expr (c_fully_fold (op1, false, NULL));
    4936                 :             : 
    4937                 :          70 :       tree tt = builtin_decl_explicit (BUILT_IN_ASAN_POINTER_SUBTRACT);
    4938                 :          70 :       *instrument_expr = build_call_expr_loc (loc, tt, 2, op0, op1);
    4939                 :             :     }
    4940                 :             : 
    4941                 :             :   /* First do the subtraction, then build the divide operator
    4942                 :             :      and only convert at the very end.
    4943                 :             :      Do not do default conversions in case restype is a short type.  */
    4944                 :             : 
    4945                 :             :   /* POINTER_DIFF_EXPR requires a signed integer type of the same size as
    4946                 :             :      pointers.  If some platform cannot provide that, or has a larger
    4947                 :             :      ptrdiff_type to support differences larger than half the address
    4948                 :             :      space, cast the pointers to some larger integer type and do the
    4949                 :             :      computations in that type.  */
    4950                 :        3619 :   if (TYPE_PRECISION (inttype) > TYPE_PRECISION (TREE_TYPE (op0)))
    4951                 :           0 :     op0 = build_binary_op (loc, MINUS_EXPR, convert (inttype, op0),
    4952                 :             :                            convert (inttype, op1), false);
    4953                 :             :   else
    4954                 :             :     {
    4955                 :             :       /* Cast away qualifiers.  */
    4956                 :        3619 :       op0 = convert (c_common_type (TREE_TYPE (op0), TREE_TYPE (op0)), op0);
    4957                 :        3619 :       op1 = convert (c_common_type (TREE_TYPE (op1), TREE_TYPE (op1)), op1);
    4958                 :        3619 :       op0 = build2_loc (loc, POINTER_DIFF_EXPR, inttype, op0, op1);
    4959                 :             :     }
    4960                 :             : 
    4961                 :             :   /* This generates an error if op1 is pointer to incomplete type.  */
    4962                 :        3619 :   if (!COMPLETE_OR_VOID_TYPE_P (TREE_TYPE (TREE_TYPE (orig_op1))))
    4963                 :           4 :     error_at (loc, "arithmetic on pointer to an incomplete type");
    4964                 :        3615 :   else if (verify_type_context (loc, TCTX_POINTER_ARITH,
    4965                 :        3615 :                                 TREE_TYPE (TREE_TYPE (orig_op0))))
    4966                 :        7230 :     verify_type_context (loc, TCTX_POINTER_ARITH,
    4967                 :        3615 :                          TREE_TYPE (TREE_TYPE (orig_op1)));
    4968                 :             : 
    4969                 :        3619 :   op1 = c_size_in_bytes (target_type);
    4970                 :             : 
    4971                 :        3619 :   if (pointer_to_zero_sized_aggr_p (TREE_TYPE (orig_op1)))
    4972                 :           4 :     error_at (loc, "arithmetic on pointer to an empty aggregate");
    4973                 :             : 
    4974                 :             :   /* Divide by the size, in easiest possible way.  */
    4975                 :        3619 :   result = fold_build2_loc (loc, EXACT_DIV_EXPR, inttype,
    4976                 :             :                             op0, convert (inttype, op1));
    4977                 :             : 
    4978                 :             :   /* Convert to final result type if necessary.  */
    4979                 :        3619 :   return convert (restype, result);
    4980                 :             : }
    4981                 :             : 
    4982                 :             : /* Expand atomic compound assignments into an appropriate sequence as
    4983                 :             :    specified by the C11 standard section 6.5.16.2.
    4984                 :             : 
    4985                 :             :        _Atomic T1 E1
    4986                 :             :        T2 E2
    4987                 :             :        E1 op= E2
    4988                 :             : 
    4989                 :             :   This sequence is used for all types for which these operations are
    4990                 :             :   supported.
    4991                 :             : 
    4992                 :             :   In addition, built-in versions of the 'fe' prefixed routines may
    4993                 :             :   need to be invoked for floating point (real, complex or vector) when
    4994                 :             :   floating-point exceptions are supported.  See 6.5.16.2 footnote 113.
    4995                 :             : 
    4996                 :             :   T1 newval;
    4997                 :             :   T1 old;
    4998                 :             :   T1 *addr
    4999                 :             :   T2 val
    5000                 :             :   fenv_t fenv
    5001                 :             : 
    5002                 :             :   addr = &E1;
    5003                 :             :   val = (E2);
    5004                 :             :   __atomic_load (addr, &old, SEQ_CST);
    5005                 :             :   feholdexcept (&fenv);
    5006                 :             : loop:
    5007                 :             :     newval = old op val;
    5008                 :             :     if (__atomic_compare_exchange_strong (addr, &old, &newval, SEQ_CST,
    5009                 :             :                                           SEQ_CST))
    5010                 :             :       goto done;
    5011                 :             :     feclearexcept (FE_ALL_EXCEPT);
    5012                 :             :     goto loop:
    5013                 :             : done:
    5014                 :             :   feupdateenv (&fenv);
    5015                 :             : 
    5016                 :             :   The compiler will issue the __atomic_fetch_* built-in when possible,
    5017                 :             :   otherwise it will generate the generic form of the atomic operations.
    5018                 :             :   This requires temp(s) and has their address taken.  The atomic processing
    5019                 :             :   is smart enough to figure out when the size of an object can utilize
    5020                 :             :   a lock-free version, and convert the built-in call to the appropriate
    5021                 :             :   lock-free routine.  The optimizers will then dispose of any temps that
    5022                 :             :   are no longer required, and lock-free implementations are utilized as
    5023                 :             :   long as there is target support for the required size.
    5024                 :             : 
    5025                 :             :   If the operator is NOP_EXPR, then this is a simple assignment, and
    5026                 :             :   an __atomic_store is issued to perform the assignment rather than
    5027                 :             :   the above loop.  */
    5028                 :             : 
    5029                 :             : /* Build an atomic assignment at LOC, expanding into the proper
    5030                 :             :    sequence to store LHS MODIFYCODE= RHS.  Return a value representing
    5031                 :             :    the result of the operation, unless RETURN_OLD_P, in which case
    5032                 :             :    return the old value of LHS (this is only for postincrement and
    5033                 :             :    postdecrement).  */
    5034                 :             : 
    5035                 :             : static tree
    5036                 :       30283 : build_atomic_assign (location_t loc, tree lhs, enum tree_code modifycode,
    5037                 :             :                      tree rhs, bool return_old_p)
    5038                 :             : {
    5039                 :       30283 :   tree fndecl, func_call;
    5040                 :       30283 :   vec<tree, va_gc> *params;
    5041                 :       30283 :   tree val, nonatomic_lhs_type, nonatomic_rhs_type, newval, newval_addr;
    5042                 :       30283 :   tree old, old_addr;
    5043                 :       30283 :   tree compound_stmt = NULL_TREE;
    5044                 :       30283 :   tree stmt, goto_stmt;
    5045                 :       30283 :   tree loop_label, loop_decl, done_label, done_decl;
    5046                 :             : 
    5047                 :       30283 :   tree lhs_type = TREE_TYPE (lhs);
    5048                 :       30283 :   tree lhs_addr = build_unary_op (loc, ADDR_EXPR, lhs, false);
    5049                 :       30283 :   tree seq_cst = build_int_cst (integer_type_node, MEMMODEL_SEQ_CST);
    5050                 :       30283 :   tree rhs_semantic_type = TREE_TYPE (rhs);
    5051                 :       30283 :   tree nonatomic_rhs_semantic_type;
    5052                 :       30283 :   tree rhs_type;
    5053                 :             : 
    5054                 :       30283 :   gcc_assert (TYPE_ATOMIC (lhs_type));
    5055                 :             : 
    5056                 :       30283 :   if (return_old_p)
    5057                 :        2299 :     gcc_assert (modifycode == PLUS_EXPR || modifycode == MINUS_EXPR);
    5058                 :             : 
    5059                 :             :   /* Allocate enough vector items for a compare_exchange.  */
    5060                 :       30283 :   vec_alloc (params, 6);
    5061                 :             : 
    5062                 :             :   /* Create a compound statement to hold the sequence of statements
    5063                 :             :      with a loop.  */
    5064                 :       30283 :   if (modifycode != NOP_EXPR)
    5065                 :             :     {
    5066                 :       19910 :       compound_stmt = c_begin_compound_stmt (false);
    5067                 :             : 
    5068                 :             :       /* For consistency with build_modify_expr on non-_Atomic,
    5069                 :             :          mark the lhs as read.  Also, it would be very hard to match
    5070                 :             :          such expressions in mark_exp_read.  */
    5071                 :       19910 :       mark_exp_read (lhs);
    5072                 :             :     }
    5073                 :             : 
    5074                 :             :   /* Remove any excess precision (which is only present here in the
    5075                 :             :      case of compound assignments).  */
    5076                 :       30283 :   if (TREE_CODE (rhs) == EXCESS_PRECISION_EXPR)
    5077                 :             :     {
    5078                 :           0 :       gcc_assert (modifycode != NOP_EXPR);
    5079                 :           0 :       rhs = TREE_OPERAND (rhs, 0);
    5080                 :             :     }
    5081                 :       30283 :   rhs_type = TREE_TYPE (rhs);
    5082                 :             : 
    5083                 :             :   /* Fold the RHS if it hasn't already been folded.  */
    5084                 :       30283 :   if (modifycode != NOP_EXPR)
    5085                 :       19910 :     rhs = c_fully_fold (rhs, false, NULL);
    5086                 :             : 
    5087                 :             :   /* Remove the qualifiers for the rest of the expressions and create
    5088                 :             :      the VAL temp variable to hold the RHS.  */
    5089                 :       30283 :   nonatomic_lhs_type = build_qualified_type (lhs_type, TYPE_UNQUALIFIED);
    5090                 :       30283 :   nonatomic_rhs_type = build_qualified_type (rhs_type, TYPE_UNQUALIFIED);
    5091                 :       30283 :   nonatomic_rhs_semantic_type = build_qualified_type (rhs_semantic_type,
    5092                 :             :                                                       TYPE_UNQUALIFIED);
    5093                 :       30283 :   val = create_tmp_var_raw (nonatomic_rhs_type);
    5094                 :       30283 :   TREE_ADDRESSABLE (val) = 1;
    5095                 :       30283 :   suppress_warning (val);
    5096                 :       30283 :   rhs = build4 (TARGET_EXPR, nonatomic_rhs_type, val, rhs, NULL_TREE,
    5097                 :             :                 NULL_TREE);
    5098                 :       30283 :   TREE_SIDE_EFFECTS (rhs) = 1;
    5099                 :       30283 :   SET_EXPR_LOCATION (rhs, loc);
    5100                 :       30283 :   if (modifycode != NOP_EXPR)
    5101                 :       19910 :     add_stmt (rhs);
    5102                 :             : 
    5103                 :             :   /* NOP_EXPR indicates it's a straight store of the RHS. Simply issue
    5104                 :             :      an atomic_store.  */
    5105                 :       30283 :   if (modifycode == NOP_EXPR)
    5106                 :             :     {
    5107                 :       10373 :       compound_stmt = rhs;
    5108                 :             :       /* Build __atomic_store (&lhs, &val, SEQ_CST)  */
    5109                 :       10373 :       rhs = build_unary_op (loc, ADDR_EXPR, val, false);
    5110                 :       10373 :       fndecl = builtin_decl_explicit (BUILT_IN_ATOMIC_STORE);
    5111                 :       10373 :       params->quick_push (lhs_addr);
    5112                 :       10373 :       params->quick_push (rhs);
    5113                 :       10373 :       params->quick_push (seq_cst);
    5114                 :       10373 :       func_call = c_build_function_call_vec (loc, vNULL, fndecl, params, NULL);
    5115                 :             : 
    5116                 :       10373 :       compound_stmt = build2 (COMPOUND_EXPR, void_type_node,
    5117                 :             :                               compound_stmt, func_call);
    5118                 :             : 
    5119                 :             :       /* VAL is the value which was stored, return a COMPOUND_STMT of
    5120                 :             :          the statement and that value.  */
    5121                 :       10373 :       return build2 (COMPOUND_EXPR, nonatomic_lhs_type, compound_stmt, val);
    5122                 :             :     }
    5123                 :             : 
    5124                 :             :   /* Attempt to implement the atomic operation as an __atomic_fetch_* or
    5125                 :             :      __atomic_*_fetch built-in rather than a CAS loop.  atomic_bool type
    5126                 :             :      isn't applicable for such builtins.  ??? Do we want to handle enums?  */
    5127                 :       19910 :   if ((TREE_CODE (lhs_type) == INTEGER_TYPE || POINTER_TYPE_P (lhs_type))
    5128                 :       13941 :       && TREE_CODE (rhs_type) == INTEGER_TYPE)
    5129                 :             :     {
    5130                 :       11713 :       built_in_function fncode;
    5131                 :       11713 :       switch (modifycode)
    5132                 :             :         {
    5133                 :        3075 :         case PLUS_EXPR:
    5134                 :        3075 :         case POINTER_PLUS_EXPR:
    5135                 :        2124 :           fncode = (return_old_p
    5136                 :        3075 :                     ? BUILT_IN_ATOMIC_FETCH_ADD_N
    5137                 :             :                     : BUILT_IN_ATOMIC_ADD_FETCH_N);
    5138                 :             :           break;
    5139                 :        2889 :         case MINUS_EXPR:
    5140                 :        2094 :           fncode = (return_old_p
    5141                 :        2889 :                     ? BUILT_IN_ATOMIC_FETCH_SUB_N
    5142                 :             :                     : BUILT_IN_ATOMIC_SUB_FETCH_N);
    5143                 :             :           break;
    5144                 :         609 :         case BIT_AND_EXPR:
    5145                 :         609 :           fncode = (return_old_p
    5146                 :         609 :                     ? BUILT_IN_ATOMIC_FETCH_AND_N
    5147                 :             :                     : BUILT_IN_ATOMIC_AND_FETCH_N);
    5148                 :             :           break;
    5149                 :         609 :         case BIT_IOR_EXPR:
    5150                 :         609 :           fncode = (return_old_p
    5151                 :         609 :                     ? BUILT_IN_ATOMIC_FETCH_OR_N
    5152                 :             :                     : BUILT_IN_ATOMIC_OR_FETCH_N);
    5153                 :             :           break;
    5154                 :         609 :         case BIT_XOR_EXPR:
    5155                 :         609 :           fncode = (return_old_p
    5156                 :         609 :                     ? BUILT_IN_ATOMIC_FETCH_XOR_N
    5157                 :             :                     : BUILT_IN_ATOMIC_XOR_FETCH_N);
    5158                 :             :           break;
    5159                 :        3922 :         default:
    5160                 :        3922 :           goto cas_loop;
    5161                 :             :         }
    5162                 :             : 
    5163                 :             :       /* We can only use "_1" through "_16" variants of the atomic fetch
    5164                 :             :          built-ins.  */
    5165                 :        7791 :       unsigned HOST_WIDE_INT size = tree_to_uhwi (TYPE_SIZE_UNIT (lhs_type));
    5166                 :        7791 :       if (size != 1 && size != 2 && size != 4 && size != 8 && size != 16)
    5167                 :           0 :         goto cas_loop;
    5168                 :             : 
    5169                 :             :       /* If this is a pointer type, we need to multiply by the size of
    5170                 :             :          the pointer target type.  */
    5171                 :        7791 :       if (POINTER_TYPE_P (lhs_type))
    5172                 :             :         {
    5173                 :        1018 :           if (!COMPLETE_TYPE_P (TREE_TYPE (lhs_type))
    5174                 :             :               /* ??? This would introduce -Wdiscarded-qualifiers
    5175                 :             :                  warning: __atomic_fetch_* expect volatile void *
    5176                 :             :                  type as the first argument.  (Assignments between
    5177                 :             :                  atomic and non-atomic objects are OK.) */
    5178                 :        1018 :               || TYPE_RESTRICT (lhs_type))
    5179                 :          17 :             goto cas_loop;
    5180                 :        1001 :           tree sz = TYPE_SIZE_UNIT (TREE_TYPE (lhs_type));
    5181                 :        1001 :           rhs = fold_build2_loc (loc, MULT_EXPR, ptrdiff_type_node,
    5182                 :             :                                  convert (ptrdiff_type_node, rhs),
    5183                 :             :                                  convert (ptrdiff_type_node, sz));
    5184                 :             :         }
    5185                 :             : 
    5186                 :             :       /* Build __atomic_fetch_* (&lhs, &val, SEQ_CST), or
    5187                 :             :          __atomic_*_fetch (&lhs, &val, SEQ_CST).  */
    5188                 :        7774 :       fndecl = builtin_decl_explicit (fncode);
    5189                 :        7774 :       params->quick_push (lhs_addr);
    5190                 :        7774 :       params->quick_push (rhs);
    5191                 :        7774 :       params->quick_push (seq_cst);
    5192                 :        7774 :       func_call = c_build_function_call_vec (loc, vNULL, fndecl, params, NULL);
    5193                 :             : 
    5194                 :        7774 :       newval = create_tmp_var_raw (nonatomic_lhs_type);
    5195                 :        7774 :       TREE_ADDRESSABLE (newval) = 1;
    5196                 :        7774 :       suppress_warning (newval);
    5197                 :        7774 :       rhs = build4 (TARGET_EXPR, nonatomic_lhs_type, newval, func_call,
    5198                 :             :                     NULL_TREE, NULL_TREE);
    5199                 :        7774 :       SET_EXPR_LOCATION (rhs, loc);
    5200                 :        7774 :       add_stmt (rhs);
    5201                 :             : 
    5202                 :             :       /* Finish the compound statement.  */
    5203                 :        7774 :       compound_stmt = c_end_compound_stmt (loc, compound_stmt, false);
    5204                 :             : 
    5205                 :             :       /* NEWVAL is the value which was stored, return a COMPOUND_STMT of
    5206                 :             :          the statement and that value.  */
    5207                 :        7774 :       return build2 (COMPOUND_EXPR, nonatomic_lhs_type, compound_stmt, newval);
    5208                 :             :     }
    5209                 :             : 
    5210                 :        8197 : cas_loop:
    5211                 :             :   /* Create the variables and labels required for the op= form.  */
    5212                 :       12136 :   old = create_tmp_var_raw (nonatomic_lhs_type);
    5213                 :       12136 :   old_addr = build_unary_op (loc, ADDR_EXPR, old, false);
    5214                 :       12136 :   TREE_ADDRESSABLE (old) = 1;
    5215                 :       12136 :   suppress_warning (old);
    5216                 :             : 
    5217                 :       12136 :   newval = create_tmp_var_raw (nonatomic_lhs_type);
    5218                 :       12136 :   newval_addr = build_unary_op (loc, ADDR_EXPR, newval, false);
    5219                 :       12136 :   TREE_ADDRESSABLE (newval) = 1;
    5220                 :       12136 :   suppress_warning (newval);
    5221                 :             : 
    5222                 :       12136 :   loop_decl = create_artificial_label (loc);
    5223                 :       12136 :   loop_label = build1 (LABEL_EXPR, void_type_node, loop_decl);
    5224                 :             : 
    5225                 :       12136 :   done_decl = create_artificial_label (loc);
    5226                 :       12136 :   done_label = build1 (LABEL_EXPR, void_type_node, done_decl);
    5227                 :             : 
    5228                 :             :   /* __atomic_load (addr, &old, SEQ_CST).  */
    5229                 :       12136 :   fndecl = builtin_decl_explicit (BUILT_IN_ATOMIC_LOAD);
    5230                 :       12136 :   params->quick_push (lhs_addr);
    5231                 :       12136 :   params->quick_push (old_addr);
    5232                 :       12136 :   params->quick_push (seq_cst);
    5233                 :       12136 :   func_call = c_build_function_call_vec (loc, vNULL, fndecl, params, NULL);
    5234                 :       12136 :   old = build4 (TARGET_EXPR, nonatomic_lhs_type, old, func_call, NULL_TREE,
    5235                 :             :                 NULL_TREE);
    5236                 :       12136 :   add_stmt (old);
    5237                 :       12136 :   params->truncate (0);
    5238                 :             : 
    5239                 :             :   /* Create the expressions for floating-point environment
    5240                 :             :      manipulation, if required.  */
    5241                 :       12136 :   bool need_fenv = (flag_trapping_math
    5242                 :       12136 :                     && (FLOAT_TYPE_P (lhs_type) || FLOAT_TYPE_P (rhs_type)));
    5243                 :       12136 :   tree hold_call = NULL_TREE, clear_call = NULL_TREE, update_call = NULL_TREE;
    5244                 :       12136 :   if (need_fenv)
    5245                 :        7054 :     targetm.atomic_assign_expand_fenv (&hold_call, &clear_call, &update_call);
    5246                 :             : 
    5247                 :       12136 :   if (hold_call)
    5248                 :        7054 :     add_stmt (hold_call);
    5249                 :             : 
    5250                 :             :   /* loop:  */
    5251                 :       12136 :   add_stmt (loop_label);
    5252                 :             : 
    5253                 :             :   /* newval = old + val;  */
    5254                 :       12136 :   if (rhs_type != rhs_semantic_type)
    5255                 :           0 :     val = build1 (EXCESS_PRECISION_EXPR, nonatomic_rhs_semantic_type, val);
    5256                 :       12136 :   rhs = build_binary_op (loc, modifycode, old, val, true);
    5257                 :       12136 :   if (TREE_CODE (rhs) == EXCESS_PRECISION_EXPR)
    5258                 :             :     {
    5259                 :           0 :       tree eptype = TREE_TYPE (rhs);
    5260                 :           0 :       rhs = c_fully_fold (TREE_OPERAND (rhs, 0), false, NULL);
    5261                 :           0 :       rhs = build1 (EXCESS_PRECISION_EXPR, eptype, rhs);
    5262                 :             :     }
    5263                 :             :   else
    5264                 :       12136 :     rhs = c_fully_fold (rhs, false, NULL);
    5265                 :       12136 :   rhs = convert_for_assignment (loc, UNKNOWN_LOCATION, nonatomic_lhs_type,
    5266                 :             :                                 rhs, NULL_TREE, ic_assign, false, NULL_TREE,
    5267                 :             :                                 NULL_TREE, 0);
    5268                 :             :   /* The temporary variable for NEWVAL is only gimplified correctly (in
    5269                 :             :      particular, given a DECL_CONTEXT) if used in a TARGET_EXPR.  To avoid
    5270                 :             :      subsequent ICEs in nested function processing after an error, ensure such
    5271                 :             :      a TARGET_EXPR is built even after an error.  */
    5272                 :       12136 :   if (rhs == error_mark_node)
    5273                 :          10 :     rhs = old;
    5274                 :       12136 :   rhs = build4 (TARGET_EXPR, nonatomic_lhs_type, newval, rhs, NULL_TREE,
    5275                 :             :                 NULL_TREE);
    5276                 :       12136 :   SET_EXPR_LOCATION (rhs, loc);
    5277                 :       12136 :   add_stmt (rhs);
    5278                 :             : 
    5279                 :             :   /* if (__atomic_compare_exchange (addr, &old, &new, false, SEQ_CST, SEQ_CST))
    5280                 :             :        goto done;  */
    5281                 :       12136 :   fndecl = builtin_decl_explicit (BUILT_IN_ATOMIC_COMPARE_EXCHANGE);
    5282                 :       12136 :   params->quick_push (lhs_addr);
    5283                 :       12136 :   params->quick_push (old_addr);
    5284                 :       12136 :   params->quick_push (newval_addr);
    5285                 :       12136 :   params->quick_push (integer_zero_node);
    5286                 :       12136 :   params->quick_push (seq_cst);
    5287                 :       12136 :   params->quick_push (seq_cst);
    5288                 :       12136 :   func_call = c_build_function_call_vec (loc, vNULL, fndecl, params, NULL);
    5289                 :             : 
    5290                 :       12136 :   goto_stmt = build1 (GOTO_EXPR, void_type_node, done_decl);
    5291                 :       12136 :   SET_EXPR_LOCATION (goto_stmt, loc);
    5292                 :             : 
    5293                 :       12136 :   stmt = build3 (COND_EXPR, void_type_node, func_call, goto_stmt, NULL_TREE);
    5294                 :       12136 :   SET_EXPR_LOCATION (stmt, loc);
    5295                 :       12136 :   add_stmt (stmt);
    5296                 :             : 
    5297                 :       12136 :   if (clear_call)
    5298                 :        7054 :     add_stmt (clear_call);
    5299                 :             : 
    5300                 :             :   /* goto loop;  */
    5301                 :       12136 :   goto_stmt  = build1 (GOTO_EXPR, void_type_node, loop_decl);
    5302                 :       12136 :   SET_EXPR_LOCATION (goto_stmt, loc);
    5303                 :       12136 :   add_stmt (goto_stmt);
    5304                 :             : 
    5305                 :             :   /* done:  */
    5306                 :       12136 :   add_stmt (done_label);
    5307                 :             : 
    5308                 :       12136 :   if (update_call)
    5309                 :        7054 :     add_stmt (update_call);
    5310                 :             : 
    5311                 :             :   /* Finish the compound statement.  */
    5312                 :       12136 :   compound_stmt = c_end_compound_stmt (loc, compound_stmt, false);
    5313                 :             : 
    5314                 :             :   /* NEWVAL is the value that was successfully stored, return a
    5315                 :             :      COMPOUND_EXPR of the statement and the appropriate value.  */
    5316                 :       23713 :   return build2 (COMPOUND_EXPR, nonatomic_lhs_type, compound_stmt,
    5317                 :       12136 :                  return_old_p ? old : newval);
    5318                 :             : }
    5319                 :             : 
    5320                 :             : /* Construct and perhaps optimize a tree representation
    5321                 :             :    for a unary operation.  CODE, a tree_code, specifies the operation
    5322                 :             :    and XARG is the operand.
    5323                 :             :    For any CODE other than ADDR_EXPR, NOCONVERT suppresses the default
    5324                 :             :    promotions (such as from short to int).
    5325                 :             :    For ADDR_EXPR, the default promotions are not applied; NOCONVERT allows
    5326                 :             :    non-lvalues; this is only used to handle conversion of non-lvalue arrays
    5327                 :             :    to pointers in C99.
    5328                 :             : 
    5329                 :             :    LOCATION is the location of the operator.  */
    5330                 :             : 
    5331                 :             : tree
    5332                 :    58957148 : build_unary_op (location_t location, enum tree_code code, tree xarg,
    5333                 :             :                 bool noconvert)
    5334                 :             : {
    5335                 :             :   /* No default_conversion here.  It causes trouble for ADDR_EXPR.  */
    5336                 :    58957148 :   tree arg = xarg;
    5337                 :    58957148 :   tree argtype = NULL_TREE;
    5338                 :    58957148 :   enum tree_code typecode;
    5339                 :    58957148 :   tree val;
    5340                 :    58957148 :   tree ret = error_mark_node;
    5341                 :    58957148 :   tree eptype = NULL_TREE;
    5342                 :    58957148 :   const char *invalid_op_diag;
    5343                 :    58957148 :   bool int_operands;
    5344                 :             : 
    5345                 :    58957148 :   int_operands = EXPR_INT_CONST_OPERANDS (xarg);
    5346                 :     6285664 :   if (int_operands)
    5347                 :     6285664 :     arg = remove_c_maybe_const_expr (arg);
    5348                 :             : 
    5349                 :    58957148 :   if (code != ADDR_EXPR)
    5350                 :     8316915 :     arg = require_complete_type (location, arg);
    5351                 :             : 
    5352                 :    58957148 :   typecode = TREE_CODE (TREE_TYPE (arg));
    5353                 :    58957148 :   if (typecode == ERROR_MARK)
    5354                 :          74 :     return error_mark_node;
    5355                 :    58957074 :   if (typecode == ENUMERAL_TYPE || typecode == BOOLEAN_TYPE)
    5356                 :       28152 :     typecode = INTEGER_TYPE;
    5357                 :             : 
    5358                 :   117914148 :   if ((invalid_op_diag
    5359                 :    58957074 :        = targetm.invalid_unary_op (code, TREE_TYPE (xarg))))
    5360                 :             :     {
    5361                 :           0 :       error_at (location, invalid_op_diag);
    5362                 :           0 :       return error_mark_node;
    5363                 :             :     }
    5364                 :             : 
    5365                 :    58957074 :   if (TREE_CODE (arg) == EXCESS_PRECISION_EXPR)
    5366                 :             :     {
    5367                 :         235 :       eptype = TREE_TYPE (arg);
    5368                 :         235 :       arg = TREE_OPERAND (arg, 0);
    5369                 :             :     }
    5370                 :             : 
    5371                 :    58957074 :   switch (code)
    5372                 :             :     {
    5373                 :       28531 :     case CONVERT_EXPR:
    5374                 :             :       /* This is used for unary plus, because a CONVERT_EXPR
    5375                 :             :          is enough to prevent anybody from looking inside for
    5376                 :             :          associativity, but won't generate any code.  */
    5377                 :       28536 :       if (!(typecode == INTEGER_TYPE || typecode == REAL_TYPE
    5378                 :           8 :             || typecode == FIXED_POINT_TYPE || typecode == COMPLEX_TYPE
    5379                 :           5 :             || typecode == BITINT_TYPE
    5380                 :           5 :             || gnu_vector_type_p (TREE_TYPE (arg))))
    5381                 :             :         {
    5382                 :           1 :           error_at (location, "wrong type argument to unary plus");
    5383                 :           1 :           return error_mark_node;
    5384                 :             :         }
    5385                 :       28530 :       else if (!noconvert)
    5386                 :       28530 :         arg = default_conversion (arg);
    5387                 :       28530 :       arg = non_lvalue_loc (location, arg);
    5388                 :       28530 :       break;
    5389                 :             : 
    5390                 :     6512845 :     case NEGATE_EXPR:
    5391                 :     6948912 :       if (!(typecode == INTEGER_TYPE || typecode == REAL_TYPE
    5392                 :      472552 :             || typecode == FIXED_POINT_TYPE || typecode == COMPLEX_TYPE
    5393                 :      441285 :             || typecode == BITINT_TYPE
    5394                 :      436067 :             || gnu_vector_type_p (TREE_TYPE (arg))))
    5395                 :             :         {
    5396                 :           1 :           error_at (location, "wrong type argument to unary minus");
    5397                 :           1 :           return error_mark_node;
    5398                 :             :         }
    5399                 :     6512844 :       else if (!noconvert)
    5400                 :     6512838 :         arg = default_conversion (arg);
    5401                 :             :       break;
    5402                 :             : 
    5403                 :      288412 :     case BIT_NOT_EXPR:
    5404                 :             :       /* ~ works on integer types and non float vectors. */
    5405                 :      288412 :       if (typecode == INTEGER_TYPE
    5406                 :      288412 :           || typecode == BITINT_TYPE
    5407                 :      288412 :           || (gnu_vector_type_p (TREE_TYPE (arg))
    5408                 :        2057 :               && !VECTOR_FLOAT_TYPE_P (TREE_TYPE (arg))))
    5409                 :             :         {
    5410                 :             :           tree e = arg;
    5411                 :             : 
    5412                 :             :           /* Warn if the expression has boolean value.  */
    5413                 :      287813 :           while (TREE_CODE (e) == COMPOUND_EXPR)
    5414                 :          11 :             e = TREE_OPERAND (e, 1);
    5415                 :             : 
    5416                 :      575590 :           if ((C_BOOLEAN_TYPE_P (TREE_TYPE (arg))
    5417                 :      575590 :                || truth_value_p (TREE_CODE (e))))
    5418                 :             :             {
    5419                 :         145 :               auto_diagnostic_group d;
    5420                 :         145 :               if (warning_at (location, OPT_Wbool_operation,
    5421                 :             :                                 "%<~%> on a boolean expression"))
    5422                 :             :                 {
    5423                 :          12 :                   gcc_rich_location richloc (location);
    5424                 :          12 :                   richloc.add_fixit_insert_before (location, "!");
    5425                 :          12 :                   inform (&richloc, "did you mean to use logical not?");
    5426                 :          12 :                 }
    5427                 :         145 :             }
    5428                 :      287802 :           if (!noconvert)
    5429                 :      287799 :             arg = default_conversion (arg);
    5430                 :             :         }
    5431                 :         610 :       else if (typecode == COMPLEX_TYPE)
    5432                 :             :         {
    5433                 :         605 :           code = CONJ_EXPR;
    5434                 :         605 :           pedwarn (location, OPT_Wpedantic,
    5435                 :             :                    "ISO C does not support %<~%> for complex conjugation");
    5436                 :         605 :           if (!noconvert)
    5437                 :         605 :             arg = default_conversion (arg);
    5438                 :             :         }
    5439                 :             :       else
    5440                 :             :         {
    5441                 :           5 :           error_at (location, "wrong type argument to bit-complement");
    5442                 :           5 :           return error_mark_node;
    5443                 :             :         }
    5444                 :             :       break;
    5445                 :             : 
    5446                 :           3 :     case ABS_EXPR:
    5447                 :           3 :       if (!(typecode == INTEGER_TYPE || typecode == REAL_TYPE))
    5448                 :             :         {
    5449                 :           0 :           error_at (location, "wrong type argument to abs");
    5450                 :           0 :           return error_mark_node;
    5451                 :             :         }
    5452                 :           3 :       else if (!noconvert)
    5453                 :           0 :         arg = default_conversion (arg);
    5454                 :             :       break;
    5455                 :             : 
    5456                 :           7 :     case ABSU_EXPR:
    5457                 :           7 :       if (!(typecode == INTEGER_TYPE))
    5458                 :             :         {
    5459                 :           0 :           error_at (location, "wrong type argument to absu");
    5460                 :           0 :           return error_mark_node;
    5461                 :             :         }
    5462                 :           7 :       else if (!noconvert)
    5463                 :           0 :         arg = default_conversion (arg);
    5464                 :             :       break;
    5465                 :             : 
    5466                 :           0 :     case CONJ_EXPR:
    5467                 :             :       /* Conjugating a real value is a no-op, but allow it anyway.  */
    5468                 :           0 :       if (!(typecode == INTEGER_TYPE || typecode == REAL_TYPE
    5469                 :             :             || typecode == COMPLEX_TYPE))
    5470                 :             :         {
    5471                 :           0 :           error_at (location, "wrong type argument to conjugation");
    5472                 :           0 :           return error_mark_node;
    5473                 :             :         }
    5474                 :           0 :       else if (!noconvert)
    5475                 :           0 :         arg = default_conversion (arg);
    5476                 :             :       break;
    5477                 :             : 
    5478                 :      373271 :     case TRUTH_NOT_EXPR:
    5479                 :      373271 :       if (typecode != INTEGER_TYPE && typecode != FIXED_POINT_TYPE
    5480                 :        6964 :           && typecode != REAL_TYPE && typecode != POINTER_TYPE
    5481                 :          21 :           && typecode != COMPLEX_TYPE && typecode != NULLPTR_TYPE
    5482                 :          18 :           && typecode != BITINT_TYPE)
    5483                 :             :         {
    5484                 :          10 :           error_at (location,
    5485                 :             :                     "wrong type argument to unary exclamation mark");
    5486                 :          10 :           return error_mark_node;
    5487                 :             :         }
    5488                 :      373261 :       if (int_operands)
    5489                 :             :         {
    5490                 :      139572 :           arg = c_objc_common_truthvalue_conversion (location, xarg);
    5491                 :      139572 :           arg = remove_c_maybe_const_expr (arg);
    5492                 :             :         }
    5493                 :             :       else
    5494                 :      233689 :         arg = c_objc_common_truthvalue_conversion (location, arg);
    5495                 :      373261 :       ret = invert_truthvalue_loc (location, arg);
    5496                 :             :       /* If the TRUTH_NOT_EXPR has been folded, reset the location.  */
    5497                 :      373261 :       if (EXPR_P (ret) && EXPR_HAS_LOCATION (ret))
    5498                 :      233294 :         location = EXPR_LOCATION (ret);
    5499                 :      373261 :       goto return_build_unary_op;
    5500                 :             : 
    5501                 :      201157 :     case REALPART_EXPR:
    5502                 :      201157 :     case IMAGPART_EXPR:
    5503                 :      201157 :       ret = build_real_imag_expr (location, code, arg);
    5504                 :      201157 :       if (ret == error_mark_node)
    5505                 :             :         return error_mark_node;
    5506                 :      201149 :       if (eptype && TREE_CODE (eptype) == COMPLEX_TYPE)
    5507                 :           2 :         eptype = TREE_TYPE (eptype);
    5508                 :      201149 :       goto return_build_unary_op;
    5509                 :             : 
    5510                 :      912646 :     case PREINCREMENT_EXPR:
    5511                 :      912646 :     case POSTINCREMENT_EXPR:
    5512                 :      912646 :     case PREDECREMENT_EXPR:
    5513                 :      912646 :     case POSTDECREMENT_EXPR:
    5514                 :             : 
    5515                 :      912646 :       if (TREE_CODE (arg) == C_MAYBE_CONST_EXPR)
    5516                 :             :         {
    5517                 :           2 :           tree inner = build_unary_op (location, code,
    5518                 :           2 :                                        C_MAYBE_CONST_EXPR_EXPR (arg),
    5519                 :             :                                        noconvert);
    5520                 :           2 :           if (inner == error_mark_node)
    5521                 :             :             return error_mark_node;
    5522                 :           4 :           ret = build2 (C_MAYBE_CONST_EXPR, TREE_TYPE (inner),
    5523                 :           2 :                         C_MAYBE_CONST_EXPR_PRE (arg), inner);
    5524                 :           2 :           gcc_assert (!C_MAYBE_CONST_EXPR_INT_OPERANDS (arg));
    5525                 :           2 :           C_MAYBE_CONST_EXPR_NON_CONST (ret) = 1;
    5526                 :           2 :           goto return_build_unary_op;
    5527                 :             :         }
    5528                 :             : 
    5529                 :             :       /* Complain about anything that is not a true lvalue.  In
    5530                 :             :          Objective-C, skip this check for property_refs.  */
    5531                 :      912644 :       if (!objc_is_property_ref (arg)
    5532                 :     1825288 :           && !lvalue_or_else (location,
    5533                 :      912644 :                               arg, ((code == PREINCREMENT_EXPR
    5534                 :      912644 :                                      || code == POSTINCREMENT_EXPR)
    5535                 :             :                                     ? lv_increment
    5536                 :             :                                     : lv_decrement)))
    5537                 :          22 :         return error_mark_node;
    5538                 :             : 
    5539                 :      912622 :       if (warn_cxx_compat && TREE_CODE (TREE_TYPE (arg)) == ENUMERAL_TYPE)
    5540                 :             :         {
    5541                 :           4 :           if (code == PREINCREMENT_EXPR || code == POSTINCREMENT_EXPR)
    5542                 :           2 :             warning_at (location, OPT_Wc___compat,
    5543                 :             :                         "increment of enumeration value is invalid in C++");
    5544                 :             :           else
    5545                 :           2 :             warning_at (location, OPT_Wc___compat,
    5546                 :             :                         "decrement of enumeration value is invalid in C++");
    5547                 :             :         }
    5548                 :             : 
    5549                 :      912622 :       if (C_BOOLEAN_TYPE_P (TREE_TYPE (arg)))
    5550                 :             :         {
    5551                 :         264 :           if (code == PREINCREMENT_EXPR || code == POSTINCREMENT_EXPR)
    5552                 :         132 :             warning_at (location, OPT_Wbool_operation,
    5553                 :             :                         "increment of a boolean expression");
    5554                 :             :           else
    5555                 :         132 :             warning_at (location, OPT_Wbool_operation,
    5556                 :             :                         "decrement of a boolean expression");
    5557                 :             :         }
    5558                 :             : 
    5559                 :             :       /* Ensure the argument is fully folded inside any SAVE_EXPR.  */
    5560                 :      912622 :       arg = c_fully_fold (arg, false, NULL, true);
    5561                 :             : 
    5562                 :      912622 :       bool atomic_op;
    5563                 :      912622 :       atomic_op = really_atomic_lvalue (arg);
    5564                 :             : 
    5565                 :             :       /* Increment or decrement the real part of the value,
    5566                 :             :          and don't change the imaginary part.  */
    5567                 :      912622 :       if (typecode == COMPLEX_TYPE)
    5568                 :             :         {
    5569                 :          57 :           tree real, imag;
    5570                 :             : 
    5571                 :          57 :           pedwarn_c23 (location, OPT_Wpedantic,
    5572                 :             :                        "ISO C does not support %<++%> and %<--%> on complex "
    5573                 :             :                        "types before C2Y");
    5574                 :             : 
    5575                 :          57 :           if (!atomic_op)
    5576                 :             :             {
    5577                 :          53 :               arg = stabilize_reference (arg);
    5578                 :          53 :               real = build_unary_op (EXPR_LOCATION (arg), REALPART_EXPR, arg,
    5579                 :             :                                      true);
    5580                 :          53 :               imag = build_unary_op (EXPR_LOCATION (arg), IMAGPART_EXPR, arg,
    5581                 :             :                                      true);
    5582                 :          53 :               real = build_unary_op (EXPR_LOCATION (arg), code, real, true);
    5583                 :          53 :               if (real == error_mark_node || imag == error_mark_node)
    5584                 :             :                 return error_mark_node;
    5585                 :          53 :               ret = build2 (COMPLEX_EXPR, TREE_TYPE (arg),
    5586                 :             :                             real, imag);
    5587                 :          53 :               goto return_build_unary_op;
    5588                 :             :             }
    5589                 :             :         }
    5590                 :             : 
    5591                 :             :       /* Report invalid types.  */
    5592                 :             : 
    5593                 :      912569 :       if (typecode != POINTER_TYPE && typecode != FIXED_POINT_TYPE
    5594                 :      683632 :           && typecode != INTEGER_TYPE && typecode != REAL_TYPE
    5595                 :         143 :           && typecode != COMPLEX_TYPE && typecode != BITINT_TYPE
    5596                 :      912618 :           && !gnu_vector_type_p (TREE_TYPE (arg)))
    5597                 :             :         {
    5598                 :           5 :           if (code == PREINCREMENT_EXPR || code == POSTINCREMENT_EXPR)
    5599                 :           3 :             error_at (location, "wrong type argument to increment");
    5600                 :             :           else
    5601                 :           2 :             error_at (location, "wrong type argument to decrement");
    5602                 :             : 
    5603                 :           5 :           return error_mark_node;
    5604                 :             :         }
    5605                 :             : 
    5606                 :      912564 :       {
    5607                 :      912564 :         tree inc;
    5608                 :             : 
    5609                 :      912564 :         argtype = TREE_TYPE (arg);
    5610                 :             : 
    5611                 :             :         /* Compute the increment.  */
    5612                 :             : 
    5613                 :      912564 :         if (typecode == POINTER_TYPE)
    5614                 :             :           {
    5615                 :             :             /* If pointer target is an incomplete type,
    5616                 :             :                we just cannot know how to do the arithmetic.  */
    5617                 :      228937 :             if (!COMPLETE_OR_VOID_TYPE_P (TREE_TYPE (argtype)))
    5618                 :             :               {
    5619                 :          27 :                 if (code == PREINCREMENT_EXPR || code == POSTINCREMENT_EXPR)
    5620                 :          17 :                   error_at (location,
    5621                 :             :                             "increment of pointer to an incomplete type %qT",
    5622                 :          17 :                             TREE_TYPE (argtype));
    5623                 :             :                 else
    5624                 :          10 :                   error_at (location,
    5625                 :             :                             "decrement of pointer to an incomplete type %qT",
    5626                 :          10 :                             TREE_TYPE (argtype));
    5627                 :             :               }
    5628                 :      228910 :             else if (TREE_CODE (TREE_TYPE (argtype)) == FUNCTION_TYPE
    5629                 :      228910 :                      || VOID_TYPE_P (TREE_TYPE (argtype)))
    5630                 :             :               {
    5631                 :          10 :                 if (code == PREINCREMENT_EXPR || code == POSTINCREMENT_EXPR)
    5632                 :           6 :                   pedwarn (location, OPT_Wpointer_arith,
    5633                 :             :                            "wrong type argument to increment");
    5634                 :             :                 else
    5635                 :           4 :                   pedwarn (location, OPT_Wpointer_arith,
    5636                 :             :                            "wrong type argument to decrement");
    5637                 :             :               }
    5638                 :             :             else
    5639                 :      457800 :               verify_type_context (location, TCTX_POINTER_ARITH,
    5640                 :      228900 :                                    TREE_TYPE (argtype));
    5641                 :             : 
    5642                 :      228937 :             inc = c_size_in_bytes (TREE_TYPE (argtype));
    5643                 :      228937 :             inc = convert_to_ptrofftype_loc (location, inc);
    5644                 :             :           }
    5645                 :      683627 :         else if (FRACT_MODE_P (TYPE_MODE (argtype)))
    5646                 :             :           {
    5647                 :             :             /* For signed fract types, we invert ++ to -- or
    5648                 :             :                -- to ++, and change inc from 1 to -1, because
    5649                 :             :                it is not possible to represent 1 in signed fract constants.
    5650                 :             :                For unsigned fract types, the result always overflows and
    5651                 :             :                we get an undefined (original) or the maximum value.  */
    5652                 :           0 :             if (code == PREINCREMENT_EXPR)
    5653                 :             :               code = PREDECREMENT_EXPR;
    5654                 :             :             else if (code == PREDECREMENT_EXPR)
    5655                 :             :               code = PREINCREMENT_EXPR;
    5656                 :             :             else if (code == POSTINCREMENT_EXPR)
    5657                 :             :               code = POSTDECREMENT_EXPR;
    5658                 :             :             else /* code == POSTDECREMENT_EXPR  */
    5659                 :           0 :               code = POSTINCREMENT_EXPR;
    5660                 :             : 
    5661                 :           0 :             inc = integer_minus_one_node;
    5662                 :           0 :             inc = convert (argtype, inc);
    5663                 :             :           }
    5664                 :             :         else
    5665                 :             :           {
    5666                 :      683583 :             inc = VECTOR_TYPE_P (argtype)
    5667                 :      683627 :               ? build_one_cst (argtype)
    5668                 :             :               : integer_one_node;
    5669                 :      683627 :             inc = convert (argtype, inc);
    5670                 :             :           }
    5671                 :             : 
    5672                 :             :         /* If 'arg' is an Objective-C PROPERTY_REF expression, then we
    5673                 :             :            need to ask Objective-C to build the increment or decrement
    5674                 :             :            expression for it.  */
    5675                 :      912564 :         if (objc_is_property_ref (arg))
    5676                 :           0 :           return objc_build_incr_expr_for_property_ref (location, code,
    5677                 :           0 :                                                         arg, inc);
    5678                 :             : 
    5679                 :             :         /* Report a read-only lvalue.  */
    5680                 :      912564 :         if (TYPE_READONLY (argtype))
    5681                 :             :           {
    5682                 :          20 :             readonly_error (location, arg,
    5683                 :          20 :                             ((code == PREINCREMENT_EXPR
    5684                 :          20 :                               || code == POSTINCREMENT_EXPR)
    5685                 :             :                              ? lv_increment : lv_decrement));
    5686                 :          20 :             return error_mark_node;
    5687                 :             :           }
    5688                 :      912544 :         else if (TREE_READONLY (arg))
    5689                 :           4 :           readonly_warning (arg,
    5690                 :           4 :                             ((code == PREINCREMENT_EXPR
    5691                 :           4 :                               || code == POSTINCREMENT_EXPR)
    5692                 :             :                              ? lv_increment : lv_decrement));
    5693                 :             : 
    5694                 :             :         /* If the argument is atomic, use the special code sequences for
    5695                 :             :            atomic compound assignment.  */
    5696                 :      912544 :         if (atomic_op)
    5697                 :             :           {
    5698                 :        4441 :             arg = stabilize_reference (arg);
    5699                 :        8882 :             ret = build_atomic_assign (location, arg,
    5700                 :        4441 :                                        ((code == PREINCREMENT_EXPR
    5701                 :        4441 :                                          || code == POSTINCREMENT_EXPR)
    5702                 :             :                                         ? PLUS_EXPR
    5703                 :             :                                         : MINUS_EXPR),
    5704                 :        4441 :                                        (FRACT_MODE_P (TYPE_MODE (argtype))
    5705                 :             :                                         ? inc
    5706                 :             :                                         : integer_one_node),
    5707                 :             :                                        (code == POSTINCREMENT_EXPR
    5708                 :        4441 :                                         || code == POSTDECREMENT_EXPR));
    5709                 :        4441 :             goto return_build_unary_op;
    5710                 :             :           }
    5711                 :             : 
    5712                 :      908103 :         if (C_BOOLEAN_TYPE_P (TREE_TYPE (arg)))
    5713                 :          56 :           val = boolean_increment (code, arg);
    5714                 :             :         else
    5715                 :      908047 :           val = build2 (code, TREE_TYPE (arg), arg, inc);
    5716                 :      908103 :         TREE_SIDE_EFFECTS (val) = 1;
    5717                 :      908103 :         if (TYPE_QUALS (TREE_TYPE (val)) != TYPE_UNQUALIFIED)
    5718                 :        3905 :           TREE_TYPE (val) = c_build_qualified_type (TREE_TYPE (val),
    5719                 :             :                                                     TYPE_UNQUALIFIED);
    5720                 :      908103 :         ret = val;
    5721                 :      908103 :         goto return_build_unary_op;
    5722                 :             :       }
    5723                 :             : 
    5724                 :    50640192 :     case ADDR_EXPR:
    5725                 :             :       /* Note that this operation never does default_conversion.  */
    5726                 :             : 
    5727                 :             :       /* The operand of unary '&' must be an lvalue (which excludes
    5728                 :             :          expressions of type void), or, in C99, the result of a [] or
    5729                 :             :          unary '*' operator.  */
    5730                 :    50640192 :       if (VOID_TYPE_P (TREE_TYPE (arg))
    5731                 :          25 :           && TYPE_QUALS (TREE_TYPE (arg)) == TYPE_UNQUALIFIED
    5732                 :    50640211 :           && (!INDIRECT_REF_P (arg) || !flag_isoc99))
    5733                 :          18 :         pedwarn (location, 0, "taking address of expression of type %<void%>");
    5734                 :             : 
    5735                 :             :       /* Let &* cancel out to simplify resulting code.  */
    5736                 :    50640192 :       if (INDIRECT_REF_P (arg))
    5737                 :             :         {
    5738                 :             :           /* Don't let this be an lvalue.  */
    5739                 :       21747 :           if (lvalue_p (TREE_OPERAND (arg, 0)))
    5740                 :       16400 :             return non_lvalue_loc (location, TREE_OPERAND (arg, 0));
    5741                 :        5347 :           ret = TREE_OPERAND (arg, 0);
    5742                 :        5347 :           goto return_build_unary_op;
    5743                 :             :         }
    5744                 :             : 
    5745                 :             :       /* Anything not already handled and not a true memory reference
    5746                 :             :          or a non-lvalue array is an error.  */
    5747                 :    50618445 :       if (typecode != FUNCTION_TYPE && !noconvert
    5748                 :    50618445 :           && !lvalue_or_else (location, arg, lv_addressof))
    5749                 :          17 :         return error_mark_node;
    5750                 :             : 
    5751                 :             :       /* Move address operations inside C_MAYBE_CONST_EXPR to simplify
    5752                 :             :          folding later.  */
    5753                 :    50618428 :       if (TREE_CODE (arg) == C_MAYBE_CONST_EXPR)
    5754                 :             :         {
    5755                 :           1 :           tree inner = build_unary_op (location, code,
    5756                 :           1 :                                        C_MAYBE_CONST_EXPR_EXPR (arg),
    5757                 :             :                                        noconvert);
    5758                 :           2 :           ret = build2 (C_MAYBE_CONST_EXPR, TREE_TYPE (inner),
    5759                 :           1 :                         C_MAYBE_CONST_EXPR_PRE (arg), inner);
    5760                 :           1 :           gcc_assert (!C_MAYBE_CONST_EXPR_INT_OPERANDS (arg));
    5761                 :           1 :           C_MAYBE_CONST_EXPR_NON_CONST (ret)
    5762                 :           1 :             = C_MAYBE_CONST_EXPR_NON_CONST (arg);
    5763                 :           1 :           goto return_build_unary_op;
    5764                 :             :         }
    5765                 :             : 
    5766                 :             :       /* Ordinary case; arg is a COMPONENT_REF or a decl, or a call to
    5767                 :             :          .ACCESS_WITH_SIZE.  */
    5768                 :    50618427 :       if (is_access_with_size_p (arg))
    5769                 :           0 :         arg = TREE_OPERAND (TREE_OPERAND (CALL_EXPR_ARG (arg, 0), 0), 0);
    5770                 :             : 
    5771                 :    50618427 :       argtype = TREE_TYPE (arg);
    5772                 :             : 
    5773                 :             :       /* If the lvalue is const or volatile, merge that into the type
    5774                 :             :          to which the address will point.  This is only needed
    5775                 :             :          for function types.  */
    5776                 :    50618427 :       if ((DECL_P (arg) || REFERENCE_CLASS_P (arg))
    5777                 :    50136572 :           && (TREE_READONLY (arg) || TREE_THIS_VOLATILE (arg))
    5778                 :    79897796 :           && TREE_CODE (argtype) == FUNCTION_TYPE)
    5779                 :             :         {
    5780                 :    29201070 :           int orig_quals = TYPE_QUALS (strip_array_types (argtype));
    5781                 :    29201070 :           int quals = orig_quals;
    5782                 :             : 
    5783                 :    29201070 :           if (TREE_READONLY (arg))
    5784                 :    28831747 :             quals |= TYPE_QUAL_CONST;
    5785                 :    29201070 :           if (TREE_THIS_VOLATILE (arg))
    5786                 :      370155 :             quals |= TYPE_QUAL_VOLATILE;
    5787                 :             : 
    5788                 :    29201070 :           argtype = c_build_qualified_type (argtype, quals);
    5789                 :             :         }
    5790                 :             : 
    5791                 :    50618427 :       switch (TREE_CODE (arg))
    5792                 :             :         {
    5793                 :       63476 :         case COMPONENT_REF:
    5794                 :       63476 :           if (DECL_C_BIT_FIELD (TREE_OPERAND (arg, 1)))
    5795                 :             :             {
    5796                 :           8 :               error_at (location, "cannot take address of bit-field %qD",
    5797                 :           8 :                         TREE_OPERAND (arg, 1));
    5798                 :           8 :               return error_mark_node;
    5799                 :             :             }
    5800                 :             : 
    5801                 :             :           /* fall through */
    5802                 :             : 
    5803                 :      137485 :         case ARRAY_REF:
    5804                 :      137485 :           if (TYPE_REVERSE_STORAGE_ORDER (TREE_TYPE (TREE_OPERAND (arg, 0))))
    5805                 :             :             {
    5806                 :          78 :               if (!AGGREGATE_TYPE_P (TREE_TYPE (arg))
    5807                 :           7 :                   && !POINTER_TYPE_P (TREE_TYPE (arg))
    5808                 :          75 :                   && !VECTOR_TYPE_P (TREE_TYPE (arg)))
    5809                 :             :                 {
    5810                 :           6 :                   error_at (location, "cannot take address of scalar with "
    5811                 :             :                             "reverse storage order");
    5812                 :           6 :                   return error_mark_node;
    5813                 :             :                 }
    5814                 :             : 
    5815                 :          63 :               if (TREE_CODE (TREE_TYPE (arg)) == ARRAY_TYPE
    5816                 :          63 :                   && TYPE_REVERSE_STORAGE_ORDER (TREE_TYPE (arg)))
    5817                 :          58 :                 warning_at (location, OPT_Wscalar_storage_order,
    5818                 :             :                             "address of array with reverse scalar storage "
    5819                 :             :                             "order requested");
    5820                 :             :             }
    5821                 :             : 
    5822                 :    50618413 :         default:
    5823                 :    50618413 :           break;
    5824                 :             :         }
    5825                 :             : 
    5826                 :    50618413 :       if (!c_mark_addressable (arg))
    5827                 :          10 :         return error_mark_node;
    5828                 :             : 
    5829                 :    50618403 :       gcc_assert (TREE_CODE (arg) != COMPONENT_REF
    5830                 :             :                   || !DECL_C_BIT_FIELD (TREE_OPERAND (arg, 1)));
    5831                 :             : 
    5832                 :    50618403 :       argtype = c_build_pointer_type (argtype);
    5833                 :             : 
    5834                 :             :       /* ??? Cope with user tricks that amount to offsetof.  Delete this
    5835                 :             :          when we have proper support for integer constant expressions.  */
    5836                 :    50618403 :       val = get_base_address (arg);
    5837                 :    50618403 :       if (val && INDIRECT_REF_P (val)
    5838                 :    50641015 :           && TREE_CONSTANT (TREE_OPERAND (val, 0)))
    5839                 :             :         {
    5840                 :         538 :           ret = fold_offsetof (arg, argtype);
    5841                 :         538 :           goto return_build_unary_op;
    5842                 :             :         }
    5843                 :             : 
    5844                 :    50617865 :       val = build1 (ADDR_EXPR, argtype, arg);
    5845                 :             : 
    5846                 :    50617865 :       ret = val;
    5847                 :    50617865 :       goto return_build_unary_op;
    5848                 :             : 
    5849                 :          10 :     case PAREN_EXPR:
    5850                 :          10 :       ret = build1 (code, TREE_TYPE (arg), arg);
    5851                 :          10 :       goto return_build_unary_op;
    5852                 :             : 
    5853                 :           0 :     default:
    5854                 :           0 :       gcc_unreachable ();
    5855                 :             :     }
    5856                 :             : 
    5857                 :     6829791 :   if (argtype == NULL_TREE)
    5858                 :     6829791 :     argtype = TREE_TYPE (arg);
    5859                 :     6829791 :   if (TREE_CODE (arg) == INTEGER_CST)
    5860                 :     6142133 :     ret = (require_constant_value
    5861                 :     6142133 :            ? fold_build1_initializer_loc (location, code, argtype, arg)
    5862                 :     6123846 :            : fold_build1_loc (location, code, argtype, arg));
    5863                 :             :   else
    5864                 :      687658 :     ret = build1 (code, argtype, arg);
    5865                 :    58940561 :  return_build_unary_op:
    5866                 :    58940561 :   gcc_assert (ret != error_mark_node);
    5867                 :     6286140 :   if (TREE_CODE (ret) == INTEGER_CST && !TREE_OVERFLOW (ret)
    5868                 :    65226692 :       && !(TREE_CODE (xarg) == INTEGER_CST && !TREE_OVERFLOW (xarg)))
    5869                 :         562 :     ret = build1 (NOP_EXPR, TREE_TYPE (ret), ret);
    5870                 :    58939999 :   else if (TREE_CODE (ret) != INTEGER_CST && int_operands)
    5871                 :          74 :     ret = note_integer_operands (ret);
    5872                 :    58940561 :   if (eptype)
    5873                 :         235 :     ret = build1 (EXCESS_PRECISION_EXPR, eptype, ret);
    5874                 :    58940561 :   protected_set_expr_location (ret, location);
    5875                 :    58940561 :   return ret;
    5876                 :             : }
    5877                 :             : 
    5878                 :             : /* Return nonzero if REF is an lvalue valid for this language.
    5879                 :             :    Lvalues can be assigned, unless their type has TYPE_READONLY.
    5880                 :             :    Lvalues can have their address taken, unless they have C_DECL_REGISTER.  */
    5881                 :             : 
    5882                 :             : bool
    5883                 :   174633315 : lvalue_p (const_tree ref)
    5884                 :             : {
    5885                 :   176111768 :   const enum tree_code code = TREE_CODE (ref);
    5886                 :             : 
    5887                 :   176111768 :   switch (code)
    5888                 :             :     {
    5889                 :     1454563 :     case REALPART_EXPR:
    5890                 :     1454563 :     case IMAGPART_EXPR:
    5891                 :     1454563 :     case COMPONENT_REF:
    5892                 :     1454563 :       return lvalue_p (TREE_OPERAND (ref, 0));
    5893                 :             : 
    5894                 :       23890 :     case C_MAYBE_CONST_EXPR:
    5895                 :       23890 :       return lvalue_p (TREE_OPERAND (ref, 1));
    5896                 :             : 
    5897                 :             :     case COMPOUND_LITERAL_EXPR:
    5898                 :             :     case STRING_CST:
    5899                 :             :       return true;
    5900                 :             : 
    5901                 :    25236215 :     case MEM_REF:
    5902                 :    25236215 :     case TARGET_MEM_REF:
    5903                 :             :       /* MEM_REFs can appear from -fgimple parsing or folding, so allow them
    5904                 :             :          here as well.  */
    5905                 :    25236215 :     case INDIRECT_REF:
    5906                 :    25236215 :     case ARRAY_REF:
    5907                 :    25236215 :     case VAR_DECL:
    5908                 :    25236215 :     case PARM_DECL:
    5909                 :    25236215 :     case RESULT_DECL:
    5910                 :    25236215 :     case ERROR_MARK:
    5911                 :    25236215 :       return (TREE_CODE (TREE_TYPE (ref)) != FUNCTION_TYPE
    5912                 :    25236215 :               && TREE_CODE (TREE_TYPE (ref)) != METHOD_TYPE);
    5913                 :             : 
    5914                 :           6 :     case BIND_EXPR:
    5915                 :           6 :       return TREE_CODE (TREE_TYPE (ref)) == ARRAY_TYPE;
    5916                 :             : 
    5917                 :     6992185 :     case CALL_EXPR:
    5918                 :     6992185 :       return is_access_with_size_p (ref);
    5919                 :             : 
    5920                 :             :     default:
    5921                 :             :       return false;
    5922                 :             :     }
    5923                 :             : }
    5924                 :             : 
    5925                 :             : /* Give a warning for storing in something that is read-only in GCC
    5926                 :             :    terms but not const in ISO C terms.  */
    5927                 :             : 
    5928                 :             : static void
    5929                 :           5 : readonly_warning (tree arg, enum lvalue_use use)
    5930                 :             : {
    5931                 :           5 :   switch (use)
    5932                 :             :     {
    5933                 :           1 :     case lv_assign:
    5934                 :           1 :       warning (0, "assignment of read-only location %qE", arg);
    5935                 :           1 :       break;
    5936                 :           2 :     case lv_increment:
    5937                 :           2 :       warning (0, "increment of read-only location %qE", arg);
    5938                 :           2 :       break;
    5939                 :           2 :     case lv_decrement:
    5940                 :           2 :       warning (0, "decrement of read-only location %qE", arg);
    5941                 :           2 :       break;
    5942                 :           0 :     default:
    5943                 :           0 :       gcc_unreachable ();
    5944                 :             :     }
    5945                 :           5 :   return;
    5946                 :             : }
    5947                 :             : 
    5948                 :             : 
    5949                 :             : /* Return nonzero if REF is an lvalue valid for this language;
    5950                 :             :    otherwise, print an error message and return zero.  USE says
    5951                 :             :    how the lvalue is being used and so selects the error message.
    5952                 :             :    LOCATION is the location at which any error should be reported.  */
    5953                 :             : 
    5954                 :             : static int
    5955                 :     4613558 : lvalue_or_else (location_t loc, const_tree ref, enum lvalue_use use)
    5956                 :             : {
    5957                 :     4613558 :   int win = lvalue_p (ref);
    5958                 :             : 
    5959                 :     4613558 :   if (!win)
    5960                 :          74 :     lvalue_error (loc, use);
    5961                 :             : 
    5962                 :     4613558 :   return win;
    5963                 :             : }
    5964                 :             : 
    5965                 :             : /* Mark EXP saying that we need to be able to take the
    5966                 :             :    address of it; it should not be allocated in a register.
    5967                 :             :    Returns true if successful.  ARRAY_REF_P is true if this
    5968                 :             :    is for ARRAY_REF construction - in that case we don't want
    5969                 :             :    to look through VIEW_CONVERT_EXPR from VECTOR_TYPE to ARRAY_TYPE,
    5970                 :             :    it is fine to use ARRAY_REFs for vector subscripts on vector
    5971                 :             :    register variables.  */
    5972                 :             : 
    5973                 :             : bool
    5974                 :    51151100 : c_mark_addressable (tree exp, bool array_ref_p)
    5975                 :             : {
    5976                 :    51151100 :   tree x = exp;
    5977                 :             : 
    5978                 :    51719865 :   while (1)
    5979                 :    51719865 :     switch (TREE_CODE (x))
    5980                 :             :       {
    5981                 :        9942 :       case VIEW_CONVERT_EXPR:
    5982                 :        9942 :         if (array_ref_p
    5983                 :        9841 :             && TREE_CODE (TREE_TYPE (x)) == ARRAY_TYPE
    5984                 :       19783 :             && VECTOR_TYPE_P (TREE_TYPE (TREE_OPERAND (x, 0))))
    5985                 :             :           return true;
    5986                 :         101 :         x = TREE_OPERAND (x, 0);
    5987                 :         101 :         break;
    5988                 :             : 
    5989                 :      384879 :       case COMPONENT_REF:
    5990                 :      384879 :         if (DECL_C_BIT_FIELD (TREE_OPERAND (x, 1)))
    5991                 :             :           {
    5992                 :           6 :             error ("cannot take address of bit-field %qD",
    5993                 :           3 :                    TREE_OPERAND (x, 1));
    5994                 :           3 :             return false;
    5995                 :             :           }
    5996                 :             :         /* FALLTHRU */
    5997                 :      568664 :       case ADDR_EXPR:
    5998                 :      568664 :       case ARRAY_REF:
    5999                 :      568664 :       case REALPART_EXPR:
    6000                 :      568664 :       case IMAGPART_EXPR:
    6001                 :      568664 :         x = TREE_OPERAND (x, 0);
    6002                 :      568664 :         break;
    6003                 :             : 
    6004                 :         534 :       case COMPOUND_LITERAL_EXPR:
    6005                 :         534 :         if (C_DECL_REGISTER (COMPOUND_LITERAL_EXPR_DECL (x)))
    6006                 :             :           {
    6007                 :           2 :             error ("address of register compound literal requested");
    6008                 :           2 :             return false;
    6009                 :             :           }
    6010                 :         532 :         TREE_ADDRESSABLE (x) = 1;
    6011                 :         532 :         TREE_ADDRESSABLE (COMPOUND_LITERAL_EXPR_DECL (x)) = 1;
    6012                 :         532 :         return true;
    6013                 :             : 
    6014                 :           0 :       case CONSTRUCTOR:
    6015                 :           0 :         TREE_ADDRESSABLE (x) = 1;
    6016                 :           0 :         return true;
    6017                 :             : 
    6018                 :     1298299 :       case VAR_DECL:
    6019                 :     1298299 :       case CONST_DECL:
    6020                 :     1298299 :       case PARM_DECL:
    6021                 :     1298299 :       case RESULT_DECL:
    6022                 :     1298299 :         if (C_DECL_REGISTER (x)
    6023                 :     1298299 :             && DECL_NONLOCAL (x))
    6024                 :             :           {
    6025                 :           0 :             if (TREE_PUBLIC (x) || is_global_var (x))
    6026                 :             :               {
    6027                 :           0 :                 error
    6028                 :           0 :                   ("global register variable %qD used in nested function", x);
    6029                 :           0 :                 return false;
    6030                 :             :               }
    6031                 :           0 :             pedwarn (input_location, 0, "register variable %qD used in nested function", x);
    6032                 :             :           }
    6033                 :     1298299 :         else if (C_DECL_REGISTER (x))
    6034                 :             :           {
    6035                 :          11 :             if (TREE_PUBLIC (x) || is_global_var (x))
    6036                 :           4 :               error ("address of global register variable %qD requested", x);
    6037                 :             :             else
    6038                 :           7 :               error ("address of register variable %qD requested", x);
    6039                 :          11 :             return false;
    6040                 :             :           }
    6041                 :             : 
    6042                 :             :         /* FALLTHRU */
    6043                 :    50585530 :       case FUNCTION_DECL:
    6044                 :    50585530 :         TREE_ADDRESSABLE (x) = 1;
    6045                 :             :         /* FALLTHRU */
    6046                 :             :       default:
    6047                 :             :         return true;
    6048                 :             :     }
    6049                 :             : }
    6050                 :             : 
    6051                 :             : /* Convert EXPR to TYPE, warning about conversion problems with
    6052                 :             :    constants.  SEMANTIC_TYPE is the type this conversion would use
    6053                 :             :    without excess precision. If SEMANTIC_TYPE is NULL, this function
    6054                 :             :    is equivalent to convert_and_check. This function is a wrapper that
    6055                 :             :    handles conversions that may be different than
    6056                 :             :    the usual ones because of excess precision.  */
    6057                 :             : 
    6058                 :             : static tree
    6059                 :    22976554 : ep_convert_and_check (location_t loc, tree type, tree expr,
    6060                 :             :                       tree semantic_type)
    6061                 :             : {
    6062                 :    22976554 :   if (TREE_TYPE (expr) == type)
    6063                 :             :     return expr;
    6064                 :             : 
    6065                 :             :   /* For C11, integer conversions may have results with excess
    6066                 :             :      precision.  */
    6067                 :     2023565 :   if (flag_isoc11 || !semantic_type)
    6068                 :     2023561 :     return convert_and_check (loc, type, expr);
    6069                 :             : 
    6070                 :           4 :   if (TREE_CODE (TREE_TYPE (expr)) == INTEGER_TYPE
    6071                 :           4 :       && TREE_TYPE (expr) != semantic_type)
    6072                 :             :     {
    6073                 :             :       /* For integers, we need to check the real conversion, not
    6074                 :             :          the conversion to the excess precision type.  */
    6075                 :           4 :       expr = convert_and_check (loc, semantic_type, expr);
    6076                 :             :     }
    6077                 :             :   /* Result type is the excess precision type, which should be
    6078                 :             :      large enough, so do not check.  */
    6079                 :           4 :   return convert (type, expr);
    6080                 :             : }
    6081                 :             : 
    6082                 :             : /* If EXPR refers to a built-in declared without a prototype returns
    6083                 :             :    the actual type of the built-in and, if non-null, set *BLTIN to
    6084                 :             :    a pointer to the built-in.  Otherwise return the type of EXPR
    6085                 :             :    and clear *BLTIN if non-null.  */
    6086                 :             : 
    6087                 :             : static tree
    6088                 :     2782740 : type_or_builtin_type (tree expr, tree *bltin = NULL)
    6089                 :             : {
    6090                 :     2782740 :   tree dummy;
    6091                 :     2782740 :   if (!bltin)
    6092                 :           0 :     bltin = &dummy;
    6093                 :             : 
    6094                 :     2782740 :   *bltin = NULL_TREE;
    6095                 :             : 
    6096                 :     2782740 :   tree type = TREE_TYPE (expr);
    6097                 :     2782740 :   if (TREE_CODE (expr) != ADDR_EXPR)
    6098                 :             :     return type;
    6099                 :             : 
    6100                 :      207251 :   tree oper = TREE_OPERAND (expr, 0);
    6101                 :      207251 :   if (!DECL_P (oper)
    6102                 :      169173 :       || TREE_CODE (oper) != FUNCTION_DECL
    6103                 :      243633 :       || !fndecl_built_in_p (oper, BUILT_IN_NORMAL))
    6104                 :             :     return type;
    6105                 :             : 
    6106                 :        2085 :   built_in_function code = DECL_FUNCTION_CODE (oper);
    6107                 :        2085 :   if (!C_DECL_BUILTIN_PROTOTYPE (oper))
    6108                 :             :     return type;
    6109                 :             : 
    6110                 :        1977 :   if ((*bltin = builtin_decl_implicit (code)))
    6111                 :         991 :     type = c_build_pointer_type (TREE_TYPE (*bltin));
    6112                 :             : 
    6113                 :             :   return type;
    6114                 :             : }
    6115                 :             : 
    6116                 :             : /* Build and return a conditional expression IFEXP ? OP1 : OP2.  If
    6117                 :             :    IFEXP_BCP then the condition is a call to __builtin_constant_p, and
    6118                 :             :    if folded to an integer constant then the unselected half may
    6119                 :             :    contain arbitrary operations not normally permitted in constant
    6120                 :             :    expressions.  Set the location of the expression to LOC.  */
    6121                 :             : 
    6122                 :             : tree
    6123                 :      401590 : build_conditional_expr (location_t colon_loc, tree ifexp, bool ifexp_bcp,
    6124                 :             :                         tree op1, tree op1_original_type, location_t op1_loc,
    6125                 :             :                         tree op2, tree op2_original_type, location_t op2_loc)
    6126                 :             : {
    6127                 :      401590 :   tree type1;
    6128                 :      401590 :   tree type2;
    6129                 :      401590 :   enum tree_code code1;
    6130                 :      401590 :   enum tree_code code2;
    6131                 :      401590 :   tree result_type = NULL;
    6132                 :      401590 :   tree semantic_result_type = NULL;
    6133                 :      401590 :   tree orig_op1 = op1, orig_op2 = op2;
    6134                 :      401590 :   bool int_const, op1_int_operands, op2_int_operands, int_operands;
    6135                 :      401590 :   bool ifexp_int_operands;
    6136                 :      401590 :   tree ret;
    6137                 :             : 
    6138                 :      401590 :   op1_int_operands = EXPR_INT_CONST_OPERANDS (orig_op1);
    6139                 :      114403 :   if (op1_int_operands)
    6140                 :      114403 :     op1 = remove_c_maybe_const_expr (op1);
    6141                 :      401590 :   op2_int_operands = EXPR_INT_CONST_OPERANDS (orig_op2);
    6142                 :      147258 :   if (op2_int_operands)
    6143                 :      147258 :     op2 = remove_c_maybe_const_expr (op2);
    6144                 :      401590 :   ifexp_int_operands = EXPR_INT_CONST_OPERANDS (ifexp);
    6145                 :      242102 :   if (ifexp_int_operands)
    6146                 :      242102 :     ifexp = remove_c_maybe_const_expr (ifexp);
    6147                 :             : 
    6148                 :             :   /* Promote both alternatives.  */
    6149                 :             : 
    6150                 :      401590 :   if (TREE_CODE (TREE_TYPE (op1)) != VOID_TYPE)
    6151                 :      397695 :     op1 = default_conversion (op1);
    6152                 :      401590 :   if (TREE_CODE (TREE_TYPE (op2)) != VOID_TYPE)
    6153                 :      371772 :     op2 = default_conversion (op2);
    6154                 :             : 
    6155                 :      401590 :   if (TREE_CODE (ifexp) == ERROR_MARK
    6156                 :      401521 :       || TREE_CODE (TREE_TYPE (op1)) == ERROR_MARK
    6157                 :      803097 :       || TREE_CODE (TREE_TYPE (op2)) == ERROR_MARK)
    6158                 :          83 :     return error_mark_node;
    6159                 :             : 
    6160                 :      401507 :   tree bltin1 = NULL_TREE;
    6161                 :      401507 :   tree bltin2 = NULL_TREE;
    6162                 :      401507 :   type1 = type_or_builtin_type (op1, &bltin1);
    6163                 :      401507 :   code1 = TREE_CODE (type1);
    6164                 :      401507 :   type2 = type_or_builtin_type (op2, &bltin2);
    6165                 :      401507 :   code2 = TREE_CODE (type2);
    6166                 :             : 
    6167                 :      401507 :   if (code1 == POINTER_TYPE && reject_gcc_builtin (op1))
    6168                 :           1 :     return error_mark_node;
    6169                 :             : 
    6170                 :      401506 :   if (code2 == POINTER_TYPE && reject_gcc_builtin (op2))
    6171                 :           1 :     return error_mark_node;
    6172                 :             : 
    6173                 :             :   /* C90 does not permit non-lvalue arrays in conditional expressions.
    6174                 :             :      In C99 they will be pointers by now.  */
    6175                 :      401505 :   if (code1 == ARRAY_TYPE || code2 == ARRAY_TYPE)
    6176                 :             :     {
    6177                 :           1 :       error_at (colon_loc, "non-lvalue array in conditional expression");
    6178                 :           1 :       return error_mark_node;
    6179                 :             :     }
    6180                 :             : 
    6181                 :      401504 :   if ((TREE_CODE (op1) == EXCESS_PRECISION_EXPR
    6182                 :      401498 :        || TREE_CODE (op2) == EXCESS_PRECISION_EXPR)
    6183                 :           7 :       && (code1 == INTEGER_TYPE || code1 == REAL_TYPE
    6184                 :           0 :           || code1 == COMPLEX_TYPE || code1 == BITINT_TYPE)
    6185                 :           7 :       && (code2 == INTEGER_TYPE || code2 == REAL_TYPE
    6186                 :           0 :           || code2 == COMPLEX_TYPE || code2 == BITINT_TYPE))
    6187                 :             :     {
    6188                 :           7 :       semantic_result_type = c_common_type (type1, type2);
    6189                 :           7 :       if (TREE_CODE (op1) == EXCESS_PRECISION_EXPR)
    6190                 :             :         {
    6191                 :           6 :           op1 = TREE_OPERAND (op1, 0);
    6192                 :           6 :           type1 = TREE_TYPE (op1);
    6193                 :           6 :           gcc_assert (TREE_CODE (type1) == code1);
    6194                 :             :         }
    6195                 :           7 :       if (TREE_CODE (op2) == EXCESS_PRECISION_EXPR)
    6196                 :             :         {
    6197                 :           1 :           op2 = TREE_OPERAND (op2, 0);
    6198                 :           1 :           type2 = TREE_TYPE (op2);
    6199                 :           1 :           gcc_assert (TREE_CODE (type2) == code2);
    6200                 :             :         }
    6201                 :             :     }
    6202                 :             : 
    6203                 :      401504 :   if (warn_cxx_compat)
    6204                 :             :     {
    6205                 :         412 :       tree t1 = op1_original_type ? op1_original_type : TREE_TYPE (orig_op1);
    6206                 :         412 :       tree t2 = op2_original_type ? op2_original_type : TREE_TYPE (orig_op2);
    6207                 :             : 
    6208                 :         412 :       if (TREE_CODE (t1) == ENUMERAL_TYPE
    6209                 :           6 :           && TREE_CODE (t2) == ENUMERAL_TYPE
    6210                 :         418 :           && TYPE_MAIN_VARIANT (t1) != TYPE_MAIN_VARIANT (t2))
    6211                 :           2 :         warning_at (colon_loc, OPT_Wc___compat,
    6212                 :             :                     ("different enum types in conditional is "
    6213                 :             :                      "invalid in C++: %qT vs %qT"),
    6214                 :             :                     t1, t2);
    6215                 :             :     }
    6216                 :             : 
    6217                 :      401504 :   if (warn_zero_as_null_pointer_constant
    6218                 :          14 :       && c_inhibit_evaluation_warnings == 0)
    6219                 :             :     {
    6220                 :          14 :       if ((code1 == POINTER_TYPE || code1 == NULLPTR_TYPE)
    6221                 :          14 :           && code2 == INTEGER_TYPE && null_pointer_constant_p (orig_op2))
    6222                 :           2 :         warning_at (op2_loc, OPT_Wzero_as_null_pointer_constant,
    6223                 :             :                     "zero as null pointer constant");
    6224                 :             : 
    6225                 :          14 :       if ((code2 == POINTER_TYPE || code2 == NULLPTR_TYPE)
    6226                 :          14 :           && code1 == INTEGER_TYPE && null_pointer_constant_p (orig_op1))
    6227                 :           2 :         warning_at (op1_loc, OPT_Wzero_as_null_pointer_constant,
    6228                 :             :                     "zero as null pointer constant");
    6229                 :             :     }
    6230                 :             : 
    6231                 :             :   /* Quickly detect the usual case where op1 and op2 have the same type
    6232                 :             :      after promotion.  */
    6233                 :      401504 :   if (TYPE_MAIN_VARIANT (type1) == TYPE_MAIN_VARIANT (type2))
    6234                 :             :     {
    6235                 :      268492 :       if (type1 == type2)
    6236                 :             :         result_type = type1;
    6237                 :             :       else
    6238                 :        6249 :         result_type = TYPE_MAIN_VARIANT (type1);
    6239                 :             :     }
    6240                 :      133012 :   else if ((code1 == INTEGER_TYPE || code1 == REAL_TYPE
    6241                 :       79818 :             || code1 == COMPLEX_TYPE || code1 == BITINT_TYPE)
    6242                 :       53239 :            && (code2 == INTEGER_TYPE || code2 == REAL_TYPE
    6243                 :       26148 :                || code2 == COMPLEX_TYPE || code2 == BITINT_TYPE))
    6244                 :             :     {
    6245                 :             :       /* In C11, a conditional expression between a floating-point
    6246                 :             :          type and an integer type should convert the integer type to
    6247                 :             :          the evaluation format of the floating-point type, with
    6248                 :             :          possible excess precision.  */
    6249                 :       27190 :       tree eptype1 = type1;
    6250                 :       27190 :       tree eptype2 = type2;
    6251                 :       27190 :       if (flag_isoc11)
    6252                 :             :         {
    6253                 :       26878 :           tree eptype;
    6254                 :       10834 :           if (ANY_INTEGRAL_TYPE_P (type1)
    6255                 :       26878 :               && (eptype = excess_precision_type (type2)) != NULL_TREE)
    6256                 :             :             {
    6257                 :           2 :               eptype2 = eptype;
    6258                 :           2 :               if (!semantic_result_type)
    6259                 :           2 :                 semantic_result_type = c_common_type (type1, type2);
    6260                 :             :             }
    6261                 :         369 :           else if (ANY_INTEGRAL_TYPE_P (type2)
    6262                 :       26876 :                    && (eptype = excess_precision_type (type1)) != NULL_TREE)
    6263                 :             :             {
    6264                 :        4618 :               eptype1 = eptype;
    6265                 :        4618 :               if (!semantic_result_type)
    6266                 :        4618 :                 semantic_result_type = c_common_type (type1, type2);
    6267                 :             :             }
    6268                 :             :         }
    6269                 :       27190 :       result_type = c_common_type (eptype1, eptype2);
    6270                 :       27190 :       if (result_type == error_mark_node)
    6271                 :             :         return error_mark_node;
    6272                 :       27188 :       do_warn_double_promotion (result_type, type1, type2,
    6273                 :             :                                 "implicit conversion from %qT to %qT to "
    6274                 :             :                                 "match other result of conditional",
    6275                 :             :                                 colon_loc);
    6276                 :             : 
    6277                 :             :       /* If -Wsign-compare, warn here if type1 and type2 have
    6278                 :             :          different signedness.  We'll promote the signed to unsigned
    6279                 :             :          and later code won't know it used to be different.
    6280                 :             :          Do this check on the original types, so that explicit casts
    6281                 :             :          will be considered, but default promotions won't.  */
    6282                 :       27188 :       if (c_inhibit_evaluation_warnings == 0)
    6283                 :             :         {
    6284                 :       26997 :           int unsigned_op1 = TYPE_UNSIGNED (TREE_TYPE (orig_op1));
    6285                 :       26997 :           int unsigned_op2 = TYPE_UNSIGNED (TREE_TYPE (orig_op2));
    6286                 :             : 
    6287                 :       26997 :           if (unsigned_op1 ^ unsigned_op2)
    6288                 :             :             {
    6289                 :       12588 :               bool ovf;
    6290                 :             : 
    6291                 :             :               /* Do not warn if the result type is signed, since the
    6292                 :             :                  signed type will only be chosen if it can represent
    6293                 :             :                  all the values of the unsigned type.  */
    6294                 :       12588 :               if (!TYPE_UNSIGNED (result_type))
    6295                 :             :                 /* OK */;
    6296                 :             :               else
    6297                 :             :                 {
    6298                 :       12484 :                   bool op1_maybe_const = true;
    6299                 :       12484 :                   bool op2_maybe_const = true;
    6300                 :             : 
    6301                 :             :                   /* Do not warn if the signed quantity is an
    6302                 :             :                      unsuffixed integer literal (or some static
    6303                 :             :                      constant expression involving such literals) and
    6304                 :             :                      it is non-negative.  This warning requires the
    6305                 :             :                      operands to be folded for best results, so do
    6306                 :             :                      that folding in this case even without
    6307                 :             :                      warn_sign_compare to avoid warning options
    6308                 :             :                      possibly affecting code generation.  */
    6309                 :       12484 :                   c_inhibit_evaluation_warnings
    6310                 :       12484 :                     += (ifexp == truthvalue_false_node);
    6311                 :       12484 :                   op1 = c_fully_fold (op1, require_constant_value,
    6312                 :             :                                       &op1_maybe_const);
    6313                 :       12484 :                   c_inhibit_evaluation_warnings
    6314                 :       12484 :                     -= (ifexp == truthvalue_false_node);
    6315                 :             : 
    6316                 :       12484 :                   c_inhibit_evaluation_warnings
    6317                 :       12484 :                     += (ifexp == truthvalue_true_node);
    6318                 :       12484 :                   op2 = c_fully_fold (op2, require_constant_value,
    6319                 :             :                                       &op2_maybe_const);
    6320                 :       12484 :                   c_inhibit_evaluation_warnings
    6321                 :       12484 :                     -= (ifexp == truthvalue_true_node);
    6322                 :             : 
    6323                 :       12484 :                   if (warn_sign_compare)
    6324                 :             :                     {
    6325                 :        1241 :                       if ((unsigned_op2
    6326                 :         681 :                            && tree_expr_nonnegative_warnv_p (op1, &ovf))
    6327                 :        1244 :                           || (unsigned_op1
    6328                 :         560 :                               && tree_expr_nonnegative_warnv_p (op2, &ovf)))
    6329                 :             :                         /* OK */;
    6330                 :          10 :                       else if (unsigned_op2)
    6331                 :           3 :                         warning_at (op1_loc, OPT_Wsign_compare,
    6332                 :             :                                     "operand of %<?:%> changes signedness from "
    6333                 :             :                                     "%qT to %qT due to unsignedness of other "
    6334                 :           3 :                                     "operand", TREE_TYPE (orig_op1),
    6335                 :           3 :                                     TREE_TYPE (orig_op2));
    6336                 :             :                       else
    6337                 :           7 :                         warning_at (op2_loc, OPT_Wsign_compare,
    6338                 :             :                                     "operand of %<?:%> changes signedness from "
    6339                 :             :                                     "%qT to %qT due to unsignedness of other "
    6340                 :           7 :                                     "operand", TREE_TYPE (orig_op2),
    6341                 :           7 :                                     TREE_TYPE (orig_op1));
    6342                 :             :                     }
    6343                 :       12484 :                   if (!op1_maybe_const || TREE_CODE (op1) != INTEGER_CST)
    6344                 :        7144 :                     op1 = c_wrap_maybe_const (op1, !op1_maybe_const);
    6345                 :       12484 :                   if (!op2_maybe_const || TREE_CODE (op2) != INTEGER_CST)
    6346                 :        4375 :                     op2 = c_wrap_maybe_const (op2, !op2_maybe_const);
    6347                 :             :                 }
    6348                 :             :             }
    6349                 :             :         }
    6350                 :             :     }
    6351                 :      105822 :   else if (code1 == VOID_TYPE || code2 == VOID_TYPE)
    6352                 :             :     {
    6353                 :       25995 :       if (code1 != VOID_TYPE || code2 != VOID_TYPE)
    6354                 :       25995 :         pedwarn (colon_loc, OPT_Wpedantic,
    6355                 :             :                  "ISO C forbids conditional expr with only one void side");
    6356                 :       25995 :       result_type = void_type_node;
    6357                 :             :     }
    6358                 :       79827 :   else if (code1 == POINTER_TYPE && code2 == POINTER_TYPE)
    6359                 :             :     {
    6360                 :       79436 :       addr_space_t as1 = TYPE_ADDR_SPACE (TREE_TYPE (type1));
    6361                 :       79436 :       addr_space_t as2 = TYPE_ADDR_SPACE (TREE_TYPE (type2));
    6362                 :       79436 :       addr_space_t as_common;
    6363                 :             : 
    6364                 :       79436 :       if (comp_target_types (colon_loc, type1, type2))
    6365                 :        2584 :         result_type = common_pointer_type (type1, type2);
    6366                 :       76852 :       else if (null_pointer_constant_p (orig_op1))
    6367                 :             :         result_type = type2;
    6368                 :       72696 :       else if (null_pointer_constant_p (orig_op2))
    6369                 :             :         result_type = type1;
    6370                 :       34791 :       else if (!addr_space_superset (as1, as2, &as_common))
    6371                 :             :         {
    6372                 :           0 :           error_at (colon_loc, "pointers to disjoint address spaces "
    6373                 :             :                     "used in conditional expression");
    6374                 :           0 :           return error_mark_node;
    6375                 :             :         }
    6376                 :       34791 :       else if ((VOID_TYPE_P (TREE_TYPE (type1))
    6377                 :         322 :                 && !TYPE_ATOMIC (TREE_TYPE (type1)))
    6378                 :       34793 :                || (VOID_TYPE_P (TREE_TYPE (type2))
    6379                 :       34424 :                    && !TYPE_ATOMIC (TREE_TYPE (type2))))
    6380                 :             :         {
    6381                 :       34743 :           tree t1 = TREE_TYPE (type1);
    6382                 :       34743 :           tree t2 = TREE_TYPE (type2);
    6383                 :       34743 :           if (!(VOID_TYPE_P (t1)
    6384                 :         321 :                 && !TYPE_ATOMIC (t1)))
    6385                 :             :            {
    6386                 :             :              /* roles are swapped */
    6387                 :       34423 :              t1 = t2;
    6388                 :       34423 :              t2 = TREE_TYPE (type1);
    6389                 :             :            }
    6390                 :       34743 :           tree t2_stripped = strip_array_types (t2);
    6391                 :       34743 :           if ((TREE_CODE (t2) == ARRAY_TYPE)
    6392                 :       34743 :               && (TYPE_QUALS (t2_stripped) & ~TYPE_QUALS (t1)))
    6393                 :             :             {
    6394                 :          18 :               if (!flag_isoc23)
    6395                 :           6 :                 warning_at (colon_loc, OPT_Wdiscarded_array_qualifiers,
    6396                 :             :                             "pointer to array loses qualifier "
    6397                 :             :                             "in conditional expression");
    6398                 :          12 :               else if (warn_c11_c23_compat > 0)
    6399                 :           6 :                 warning_at (colon_loc, OPT_Wc11_c23_compat,
    6400                 :             :                             "pointer to array loses qualifier "
    6401                 :             :                             "in conditional expression in ISO C before C23");
    6402                 :             :             }
    6403                 :       34743 :           if (TREE_CODE (t2) == FUNCTION_TYPE)
    6404                 :           4 :             pedwarn (colon_loc, OPT_Wpedantic,
    6405                 :             :                      "ISO C forbids conditional expr between "
    6406                 :             :                      "%<void *%> and function pointer");
    6407                 :             :           /* for array, use qualifiers of element type */
    6408                 :       34743 :           if (flag_isoc23)
    6409                 :       11002 :             t2 = t2_stripped;
    6410                 :       34743 :           result_type = c_build_pointer_type (qualify_type (t1, t2));
    6411                 :             :         }
    6412                 :             :       /* Objective-C pointer comparisons are a bit more lenient.  */
    6413                 :          48 :       else if (objc_have_common_type (type1, type2, -3, NULL_TREE))
    6414                 :           0 :         result_type = objc_common_type (type1, type2);
    6415                 :             :       else
    6416                 :             :         {
    6417                 :          48 :           int qual = ENCODE_QUAL_ADDR_SPACE (as_common);
    6418                 :          48 :           diagnostic_t kind = DK_PERMERROR;
    6419                 :          48 :           if (!flag_isoc99)
    6420                 :             :             /* This downgrade to a warning ensures that -std=gnu89
    6421                 :             :                -pedantic-errors does not flag these mismatches between
    6422                 :             :                builtins as errors (as DK_PERMERROR would).  ISO C99
    6423                 :             :                and later do not have implicit function declarations,
    6424                 :             :                so the mismatch cannot occur naturally there.  */
    6425                 :           5 :             kind = bltin1 && bltin2 ? DK_WARNING : DK_PEDWARN;
    6426                 :          48 :           if (emit_diagnostic (kind, colon_loc, OPT_Wincompatible_pointer_types,
    6427                 :             :                                "pointer type mismatch "
    6428                 :             :                                "in conditional expression"))
    6429                 :             :             {
    6430                 :          46 :               inform (op1_loc, "first expression has type %qT", type1);
    6431                 :          46 :               inform (op2_loc, "second expression has type %qT", type2);
    6432                 :             :             }
    6433                 :          48 :           result_type = c_build_pointer_type
    6434                 :          48 :                           (c_build_qualified_type (void_type_node, qual));
    6435                 :             :         }
    6436                 :             :     }
    6437                 :         391 :   else if (code1 == POINTER_TYPE
    6438                 :         274 :            && (code2 == INTEGER_TYPE || code2 == BITINT_TYPE))
    6439                 :             :     {
    6440                 :         270 :       if (!null_pointer_constant_p (orig_op2))
    6441                 :          14 :         permerror_opt (colon_loc, OPT_Wint_conversion,
    6442                 :             :                        "pointer/integer type mismatch "
    6443                 :             :                        "in conditional expression");
    6444                 :             :       else
    6445                 :             :         {
    6446                 :         256 :           op2 = null_pointer_node;
    6447                 :             :         }
    6448                 :             :       result_type = type1;
    6449                 :             :     }
    6450                 :         121 :   else if (code2 == POINTER_TYPE
    6451                 :          87 :            && (code1 == INTEGER_TYPE || code1 == BITINT_TYPE))
    6452                 :             :     {
    6453                 :          83 :       if (!null_pointer_constant_p (orig_op1))
    6454                 :          14 :         permerror_opt (colon_loc, OPT_Wint_conversion,
    6455                 :             :                        "pointer/integer type mismatch "
    6456                 :             :                        "in conditional expression");
    6457                 :             :       else
    6458                 :             :         {
    6459                 :          69 :           op1 = null_pointer_node;
    6460                 :             :         }
    6461                 :             :       result_type = type2;
    6462                 :             :     }
    6463                 :             :   /* 6.5.15: "if one is a null pointer constant (other than a pointer) or has
    6464                 :             :      type nullptr_t and the other is a pointer, the result type is the pointer
    6465                 :             :      type."  */
    6466                 :          38 :   else if (code1 == NULLPTR_TYPE && code2 == POINTER_TYPE)
    6467                 :             :     result_type = type2;
    6468                 :          34 :   else if (code1 == POINTER_TYPE && code2 == NULLPTR_TYPE)
    6469                 :             :     result_type = type1;
    6470                 :           8 :   else if (RECORD_OR_UNION_TYPE_P (type1) && RECORD_OR_UNION_TYPE_P (type2)
    6471                 :          38 :            && comptypes (TYPE_MAIN_VARIANT (type1),
    6472                 :           8 :                          TYPE_MAIN_VARIANT (type2)))
    6473                 :           8 :     result_type = composite_type (TYPE_MAIN_VARIANT (type1),
    6474                 :           8 :                                   TYPE_MAIN_VARIANT (type2));
    6475                 :             : 
    6476                 :      401480 :   if (!result_type)
    6477                 :             :     {
    6478                 :          22 :       if (flag_cond_mismatch)
    6479                 :           0 :         result_type = void_type_node;
    6480                 :             :       else
    6481                 :             :         {
    6482                 :          22 :           error_at (colon_loc, "type mismatch in conditional expression");
    6483                 :          22 :           return error_mark_node;
    6484                 :             :         }
    6485                 :             :     }
    6486                 :             : 
    6487                 :             :   /* Merge const and volatile flags of the incoming types.  */
    6488                 :      401480 :   result_type
    6489                 :      401480 :     = build_type_variant (result_type,
    6490                 :             :                           TYPE_READONLY (type1) || TYPE_READONLY (type2),
    6491                 :             :                           TYPE_VOLATILE (type1) || TYPE_VOLATILE (type2));
    6492                 :             : 
    6493                 :      401480 :   op1 = ep_convert_and_check (colon_loc, result_type, op1,
    6494                 :             :                               semantic_result_type);
    6495                 :      401480 :   op2 = ep_convert_and_check (colon_loc, result_type, op2,
    6496                 :             :                               semantic_result_type);
    6497                 :             : 
    6498                 :      401480 :   if (ifexp_bcp && ifexp == truthvalue_true_node)
    6499                 :             :     {
    6500                 :          10 :       op2_int_operands = true;
    6501                 :          10 :       op1 = c_fully_fold (op1, require_constant_value, NULL);
    6502                 :             :     }
    6503                 :          59 :   if (ifexp_bcp && ifexp == truthvalue_false_node)
    6504                 :             :     {
    6505                 :          49 :       op1_int_operands = true;
    6506                 :          49 :       op2 = c_fully_fold (op2, require_constant_value, NULL);
    6507                 :             :     }
    6508                 :      899979 :   int_const = int_operands = (ifexp_int_operands
    6509                 :      401480 :                               && op1_int_operands
    6510                 :      401480 :                               && op2_int_operands);
    6511                 :       97019 :   if (int_operands)
    6512                 :             :     {
    6513                 :       97019 :       int_const = ((ifexp == truthvalue_true_node
    6514                 :       58623 :                     && TREE_CODE (orig_op1) == INTEGER_CST
    6515                 :       58609 :                     && !TREE_OVERFLOW (orig_op1))
    6516                 :       97033 :                    || (ifexp == truthvalue_false_node
    6517                 :       38350 :                        && TREE_CODE (orig_op2) == INTEGER_CST
    6518                 :       38334 :                        && !TREE_OVERFLOW (orig_op2)));
    6519                 :             :     }
    6520                 :             : 
    6521                 :             :   /* Need to convert condition operand into a vector mask.  */
    6522                 :      401480 :   if (VECTOR_TYPE_P (TREE_TYPE (ifexp)))
    6523                 :             :     {
    6524                 :           0 :       tree vectype = TREE_TYPE (ifexp);
    6525                 :           0 :       tree elem_type = TREE_TYPE (vectype);
    6526                 :           0 :       tree zero = build_int_cst (elem_type, 0);
    6527                 :           0 :       tree zero_vec = build_vector_from_val (vectype, zero);
    6528                 :           0 :       tree cmp_type = truth_type_for (vectype);
    6529                 :           0 :       ifexp = build2 (NE_EXPR, cmp_type, ifexp, zero_vec);
    6530                 :             :     }
    6531                 :             : 
    6532                 :      401480 :   if (int_const || (ifexp_bcp && TREE_CODE (ifexp) == INTEGER_CST))
    6533                 :       96975 :     ret = fold_build3_loc (colon_loc, COND_EXPR, result_type, ifexp, op1, op2);
    6534                 :             :   else
    6535                 :             :     {
    6536                 :      304505 :       if (int_operands)
    6537                 :             :         {
    6538                 :             :           /* Use c_fully_fold here, since C_MAYBE_CONST_EXPR might be
    6539                 :             :              nested inside of the expression.  */
    6540                 :          76 :           op1 = c_fully_fold (op1, false, NULL);
    6541                 :          76 :           op2 = c_fully_fold (op2, false, NULL);
    6542                 :             :         }
    6543                 :      304505 :       ret = build3 (COND_EXPR, result_type, ifexp, op1, op2);
    6544                 :      304505 :       if (int_operands)
    6545                 :          76 :         ret = note_integer_operands (ret);
    6546                 :             :     }
    6547                 :      401480 :   if (semantic_result_type)
    6548                 :        4627 :     ret = build1 (EXCESS_PRECISION_EXPR, semantic_result_type, ret);
    6549                 :             : 
    6550                 :      401480 :   protected_set_expr_location (ret, colon_loc);
    6551                 :             : 
    6552                 :             :   /* If the OP1 and OP2 are the same and don't have side-effects,
    6553                 :             :      warn here, because the COND_EXPR will be turned into OP1.  */
    6554                 :      401480 :   if (warn_duplicated_branches
    6555                 :          34 :       && TREE_CODE (ret) == COND_EXPR
    6556                 :      401514 :       && (op1 == op2 || operand_equal_p (op1, op2, OEP_ADDRESS_OF_SAME_FIELD)))
    6557                 :          13 :     warning_at (EXPR_LOCATION (ret), OPT_Wduplicated_branches,
    6558                 :             :                 "this condition has identical branches");
    6559                 :             : 
    6560                 :             :   return ret;
    6561                 :             : }
    6562                 :             : 
    6563                 :             : /* EXPR is an expression, location LOC, whose result is discarded.
    6564                 :             :    Warn if it is a call to a nodiscard function (or a COMPOUND_EXPR
    6565                 :             :    whose right-hand operand is such a call, possibly recursively).  */
    6566                 :             : 
    6567                 :             : static void
    6568                 :     6331159 : maybe_warn_nodiscard (location_t loc, tree expr)
    6569                 :             : {
    6570                 :     6331159 :   if (VOID_TYPE_P (TREE_TYPE (expr)))
    6571                 :             :     return;
    6572                 :     3872882 :   while (TREE_CODE (expr) == COMPOUND_EXPR)
    6573                 :             :     {
    6574                 :       48890 :       expr = TREE_OPERAND (expr, 1);
    6575                 :       48890 :       if (EXPR_HAS_LOCATION (expr))
    6576                 :       31799 :         loc = EXPR_LOCATION (expr);
    6577                 :             :     }
    6578                 :     3823992 :   if (TREE_CODE (expr) != CALL_EXPR)
    6579                 :             :     return;
    6580                 :      341670 :   tree fn = CALL_EXPR_FN (expr);
    6581                 :      341670 :   if (!fn)
    6582                 :             :     return;
    6583                 :      341657 :   tree attr;
    6584                 :      341657 :   if (TREE_CODE (fn) == ADDR_EXPR
    6585                 :      340992 :       && TREE_CODE (TREE_OPERAND (fn, 0)) == FUNCTION_DECL
    6586                 :      682649 :       && (attr = lookup_attribute ("nodiscard",
    6587                 :      340992 :                                    DECL_ATTRIBUTES (TREE_OPERAND (fn, 0)))))
    6588                 :             :     {
    6589                 :           3 :       fn = TREE_OPERAND (fn, 0);
    6590                 :           3 :       tree args = TREE_VALUE (attr);
    6591                 :           3 :       if (args)
    6592                 :           1 :         args = TREE_VALUE (args);
    6593                 :           3 :       auto_diagnostic_group d;
    6594                 :           3 :       auto_urlify_attributes sentinel;
    6595                 :           3 :       int warned;
    6596                 :           3 :       if (args)
    6597                 :           1 :         warned = warning_at (loc, OPT_Wunused_result,
    6598                 :             :                              "ignoring return value of %qD, declared with "
    6599                 :             :                              "attribute %<nodiscard%>: %E", fn, args);
    6600                 :             :       else
    6601                 :           2 :         warned = warning_at (loc, OPT_Wunused_result,
    6602                 :             :                              "ignoring return value of %qD, declared with "
    6603                 :             :                              "attribute %<nodiscard%>", fn);
    6604                 :           3 :       if (warned)
    6605                 :           3 :         inform (DECL_SOURCE_LOCATION (fn), "declared here");
    6606                 :           3 :     }
    6607                 :             :   else
    6608                 :             :     {
    6609                 :      341654 :       tree rettype = TREE_TYPE (TREE_TYPE (TREE_TYPE (fn)));
    6610                 :      341654 :       attr = lookup_attribute ("nodiscard", TYPE_ATTRIBUTES (rettype));
    6611                 :      341654 :       if (!attr)
    6612                 :      341642 :         return;
    6613                 :          12 :       tree args = TREE_VALUE (attr);
    6614                 :          12 :       if (args)
    6615                 :           5 :         args = TREE_VALUE (args);
    6616                 :          12 :       auto_diagnostic_group d;
    6617                 :          12 :       auto_urlify_attributes sentinel;
    6618                 :          12 :       int warned;
    6619                 :          12 :       if (args)
    6620                 :           5 :         warned = warning_at (loc, OPT_Wunused_result,
    6621                 :             :                              "ignoring return value of type %qT, declared "
    6622                 :             :                              "with attribute %<nodiscard%>: %E",
    6623                 :             :                              rettype, args);
    6624                 :             :       else
    6625                 :           7 :         warned = warning_at (loc, OPT_Wunused_result,
    6626                 :             :                              "ignoring return value of type %qT, declared "
    6627                 :             :                              "with attribute %<nodiscard%>", rettype);
    6628                 :          12 :       if (warned)
    6629                 :             :         {
    6630                 :          12 :           if (TREE_CODE (fn) == ADDR_EXPR)
    6631                 :             :             {
    6632                 :          11 :               fn = TREE_OPERAND (fn, 0);
    6633                 :          11 :               if (TREE_CODE (fn) == FUNCTION_DECL)
    6634                 :          11 :                 inform (DECL_SOURCE_LOCATION (fn),
    6635                 :             :                         "in call to %qD, declared here", fn);
    6636                 :             :             }
    6637                 :             :         }
    6638                 :          12 :     }
    6639                 :             : }
    6640                 :             : 
    6641                 :             : /* Return a compound expression that performs two expressions and
    6642                 :             :    returns the value of the second of them.
    6643                 :             : 
    6644                 :             :    LOC is the location of the COMPOUND_EXPR.  */
    6645                 :             : 
    6646                 :             : tree
    6647                 :      103543 : build_compound_expr (location_t loc, tree expr1, tree expr2)
    6648                 :             : {
    6649                 :      103543 :   bool expr1_int_operands, expr2_int_operands;
    6650                 :      103543 :   tree eptype = NULL_TREE;
    6651                 :      103543 :   tree ret;
    6652                 :             : 
    6653                 :      103543 :   expr1_int_operands = EXPR_INT_CONST_OPERANDS (expr1);
    6654                 :         325 :   if (expr1_int_operands)
    6655                 :         325 :     expr1 = remove_c_maybe_const_expr (expr1);
    6656                 :      103543 :   expr2_int_operands = EXPR_INT_CONST_OPERANDS (expr2);
    6657                 :       59787 :   if (expr2_int_operands)
    6658                 :       59787 :     expr2 = remove_c_maybe_const_expr (expr2);
    6659                 :             : 
    6660                 :      103543 :   if (TREE_CODE (expr1) == EXCESS_PRECISION_EXPR)
    6661                 :           0 :     expr1 = TREE_OPERAND (expr1, 0);
    6662                 :      103543 :   if (TREE_CODE (expr2) == EXCESS_PRECISION_EXPR)
    6663                 :             :     {
    6664                 :           1 :       eptype = TREE_TYPE (expr2);
    6665                 :           1 :       expr2 = TREE_OPERAND (expr2, 0);
    6666                 :             :     }
    6667                 :             : 
    6668                 :      103543 :   if (!TREE_SIDE_EFFECTS (expr1))
    6669                 :             :     {
    6670                 :             :       /* The left-hand operand of a comma expression is like an expression
    6671                 :             :          statement: with -Wunused, we should warn if it doesn't have
    6672                 :             :          any side-effects, unless it was explicitly cast to (void).  */
    6673                 :        7035 :       if (warn_unused_value)
    6674                 :             :         {
    6675                 :        1241 :           if (VOID_TYPE_P (TREE_TYPE (expr1))
    6676                 :        1241 :               && CONVERT_EXPR_P (expr1))
    6677                 :             :             ; /* (void) a, b */
    6678                 :          14 :           else if (VOID_TYPE_P (TREE_TYPE (expr1))
    6679                 :           4 :                    && TREE_CODE (expr1) == COMPOUND_EXPR
    6680                 :          17 :                    && CONVERT_EXPR_P (TREE_OPERAND (expr1, 1)))
    6681                 :             :             ; /* (void) a, (void) b, c */
    6682                 :             :           else
    6683                 :          11 :             warning_at (loc, OPT_Wunused_value,
    6684                 :             :                         "left-hand operand of comma expression has no effect");
    6685                 :             :         }
    6686                 :             :     }
    6687                 :       96508 :   else if (TREE_CODE (expr1) == COMPOUND_EXPR
    6688                 :       13104 :            && warn_unused_value)
    6689                 :             :     {
    6690                 :             :       tree r = expr1;
    6691                 :             :       location_t cloc = loc;
    6692                 :        4833 :       while (TREE_CODE (r) == COMPOUND_EXPR)
    6693                 :             :         {
    6694                 :        2417 :           if (EXPR_HAS_LOCATION (r))
    6695                 :        2417 :             cloc = EXPR_LOCATION (r);
    6696                 :        2417 :           r = TREE_OPERAND (r, 1);
    6697                 :             :         }
    6698                 :        2416 :       if (!TREE_SIDE_EFFECTS (r)
    6699                 :           4 :           && !VOID_TYPE_P (TREE_TYPE (r))
    6700                 :        2420 :           && !CONVERT_EXPR_P (r))
    6701                 :           4 :         warning_at (cloc, OPT_Wunused_value,
    6702                 :             :                     "right-hand operand of comma expression has no effect");
    6703                 :             :     }
    6704                 :             : 
    6705                 :             :   /* With -Wunused, we should also warn if the left-hand operand does have
    6706                 :             :      side-effects, but computes a value which is not used.  For example, in
    6707                 :             :      `foo() + bar(), baz()' the result of the `+' operator is not used,
    6708                 :             :      so we should issue a warning.  */
    6709                 :       94092 :   else if (warn_unused_value)
    6710                 :       35362 :     warn_if_unused_value (expr1, loc);
    6711                 :             : 
    6712                 :      103543 :   maybe_warn_nodiscard (loc, expr1);
    6713                 :             : 
    6714                 :      103543 :   if (expr2 == error_mark_node)
    6715                 :             :     return error_mark_node;
    6716                 :             : 
    6717                 :      103530 :   ret = build2 (COMPOUND_EXPR, TREE_TYPE (expr2), expr1, expr2);
    6718                 :             : 
    6719                 :      103530 :   if (flag_isoc99
    6720                 :             :       && expr1_int_operands
    6721                 :      103074 :       && expr2_int_operands)
    6722                 :         152 :     ret = note_integer_operands (ret);
    6723                 :             : 
    6724                 :      103530 :   if (eptype)
    6725                 :           1 :     ret = build1 (EXCESS_PRECISION_EXPR, eptype, ret);
    6726                 :             : 
    6727                 :      103530 :   protected_set_expr_location (ret, loc);
    6728                 :      103530 :   return ret;
    6729                 :             : }
    6730                 :             : 
    6731                 :             : /* Issue -Wcast-qual warnings when appropriate.  TYPE is the type to
    6732                 :             :    which we are casting.  OTYPE is the type of the expression being
    6733                 :             :    cast.  Both TYPE and OTYPE are pointer types.  LOC is the location
    6734                 :             :    of the cast.  -Wcast-qual appeared on the command line.  Named
    6735                 :             :    address space qualifiers are not handled here, because they result
    6736                 :             :    in different warnings.  */
    6737                 :             : 
    6738                 :             : static void
    6739                 :       13369 : handle_warn_cast_qual (location_t loc, tree type, tree otype)
    6740                 :             : {
    6741                 :       13369 :   tree in_type = type;
    6742                 :       13369 :   tree in_otype = otype;
    6743                 :       13369 :   int added = 0;
    6744                 :       13369 :   int discarded = 0;
    6745                 :       13539 :   bool is_const;
    6746                 :             : 
    6747                 :             :   /* Check that the qualifiers on IN_TYPE are a superset of the
    6748                 :             :      qualifiers of IN_OTYPE.  The outermost level of POINTER_TYPE
    6749                 :             :      nodes is uninteresting and we stop as soon as we hit a
    6750                 :             :      non-POINTER_TYPE node on either type.  */
    6751                 :       13539 :   do
    6752                 :             :     {
    6753                 :       13539 :       in_otype = TREE_TYPE (in_otype);
    6754                 :       13539 :       in_type = TREE_TYPE (in_type);
    6755                 :             : 
    6756                 :             :       /* GNU C allows cv-qualified function types.  'const' means the
    6757                 :             :          function is very pure, 'volatile' means it can't return.  We
    6758                 :             :          need to warn when such qualifiers are added, not when they're
    6759                 :             :          taken away.  */
    6760                 :       13539 :       if (TREE_CODE (in_otype) == FUNCTION_TYPE
    6761                 :          26 :           && TREE_CODE (in_type) == FUNCTION_TYPE)
    6762                 :          18 :         added |= (TYPE_QUALS_NO_ADDR_SPACE (in_type)
    6763                 :          18 :                   & ~TYPE_QUALS_NO_ADDR_SPACE (in_otype));
    6764                 :             :       else
    6765                 :       13521 :         discarded |= (TYPE_QUALS_NO_ADDR_SPACE (in_otype)
    6766                 :       13521 :                       & ~TYPE_QUALS_NO_ADDR_SPACE (in_type));
    6767                 :             :     }
    6768                 :       13539 :   while (TREE_CODE (in_type) == POINTER_TYPE
    6769                 :       13539 :          && TREE_CODE (in_otype) == POINTER_TYPE);
    6770                 :             : 
    6771                 :       13369 :   if (added)
    6772                 :           2 :     warning_at (loc, OPT_Wcast_qual,
    6773                 :             :                 "cast adds %q#v qualifier to function type", added);
    6774                 :             : 
    6775                 :       13369 :   if (discarded)
    6776                 :             :     /* There are qualifiers present in IN_OTYPE that are not present
    6777                 :             :        in IN_TYPE.  */
    6778                 :        1117 :     warning_at (loc, OPT_Wcast_qual,
    6779                 :             :                 "cast discards %qv qualifier from pointer target type",
    6780                 :             :                 discarded);
    6781                 :             : 
    6782                 :       13369 :   if (added || discarded)
    6783                 :             :     return;
    6784                 :             : 
    6785                 :             :   /* A cast from **T to const **T is unsafe, because it can cause a
    6786                 :             :      const value to be changed with no additional warning.  We only
    6787                 :             :      issue this warning if T is the same on both sides, and we only
    6788                 :             :      issue the warning if there are the same number of pointers on
    6789                 :             :      both sides, as otherwise the cast is clearly unsafe anyhow.  A
    6790                 :             :      cast is unsafe when a qualifier is added at one level and const
    6791                 :             :      is not present at all outer levels.
    6792                 :             : 
    6793                 :             :      To issue this warning, we check at each level whether the cast
    6794                 :             :      adds new qualifiers not already seen.  We don't need to special
    6795                 :             :      case function types, as they won't have the same
    6796                 :             :      TYPE_MAIN_VARIANT.  */
    6797                 :             : 
    6798                 :       12250 :   if (TYPE_MAIN_VARIANT (in_type) != TYPE_MAIN_VARIANT (in_otype))
    6799                 :             :     return;
    6800                 :          51 :   if (TREE_CODE (TREE_TYPE (type)) != POINTER_TYPE)
    6801                 :             :     return;
    6802                 :             : 
    6803                 :          48 :   in_type = type;
    6804                 :          48 :   in_otype = otype;
    6805                 :          48 :   is_const = TYPE_READONLY (TREE_TYPE (in_type));
    6806                 :         130 :   do
    6807                 :             :     {
    6808                 :         130 :       in_type = TREE_TYPE (in_type);
    6809                 :         130 :       in_otype = TREE_TYPE (in_otype);
    6810                 :         130 :       if ((TYPE_QUALS (in_type) &~ TYPE_QUALS (in_otype)) != 0
    6811                 :         130 :           && !is_const)
    6812                 :             :         {
    6813                 :          27 :           warning_at (loc, OPT_Wcast_qual,
    6814                 :             :                       "to be safe all intermediate pointers in cast from "
    6815                 :             :                       "%qT to %qT must be %<const%> qualified",
    6816                 :             :                       otype, type);
    6817                 :          27 :           break;
    6818                 :             :         }
    6819                 :         103 :       if (is_const)
    6820                 :          72 :         is_const = TYPE_READONLY (in_type);
    6821                 :             :     }
    6822                 :         103 :   while (TREE_CODE (in_type) == POINTER_TYPE);
    6823                 :             : }
    6824                 :             : 
    6825                 :             : /* Heuristic check if two parameter types can be considered ABI-equivalent.  */
    6826                 :             : 
    6827                 :             : static bool
    6828                 :        1067 : c_safe_arg_type_equiv_p (tree t1, tree t2)
    6829                 :             : {
    6830                 :        1067 :   if (error_operand_p (t1) || error_operand_p (t2))
    6831                 :             :     return true;
    6832                 :             : 
    6833                 :        1066 :   t1 = TYPE_MAIN_VARIANT (t1);
    6834                 :        1066 :   t2 = TYPE_MAIN_VARIANT (t2);
    6835                 :             : 
    6836                 :        1066 :   if (TREE_CODE (t1) == POINTER_TYPE
    6837                 :         114 :       && TREE_CODE (t2) == POINTER_TYPE)
    6838                 :             :     return true;
    6839                 :             : 
    6840                 :             :   /* Only the precision of the parameter matters.  This check should
    6841                 :             :      make sure that the callee does not see undefined values in argument
    6842                 :             :      registers.  */
    6843                 :         974 :   if (INTEGRAL_TYPE_P (t1)
    6844                 :         869 :       && INTEGRAL_TYPE_P (t2)
    6845                 :        1275 :       && TYPE_PRECISION (t1) == TYPE_PRECISION (t2))
    6846                 :             :     return true;
    6847                 :             : 
    6848                 :         853 :   return comptypes (t1, t2);
    6849                 :             : }
    6850                 :             : 
    6851                 :             : /* Check if a type cast between two function types can be considered safe.  */
    6852                 :             : 
    6853                 :             : static bool
    6854                 :        7420 : c_safe_function_type_cast_p (tree t1, tree t2)
    6855                 :             : {
    6856                 :        7420 :   if (TREE_TYPE (t1) == void_type_node &&
    6857                 :        5437 :       TYPE_ARG_TYPES (t1) == void_list_node)
    6858                 :             :     return true;
    6859                 :             : 
    6860                 :        3665 :   if (TREE_TYPE (t2) == void_type_node &&
    6861                 :        2862 :       TYPE_ARG_TYPES (t2) == void_list_node)
    6862                 :             :     return true;
    6863                 :             : 
    6864                 :         835 :   if (!c_safe_arg_type_equiv_p (TREE_TYPE (t1), TREE_TYPE (t2)))
    6865                 :             :     return false;
    6866                 :             : 
    6867                 :         153 :   for (t1 = TYPE_ARG_TYPES (t1), t2 = TYPE_ARG_TYPES (t2);
    6868                 :         281 :        t1 && t2;
    6869                 :         128 :        t1 = TREE_CHAIN (t1), t2 = TREE_CHAIN (t2))
    6870                 :         232 :     if (!c_safe_arg_type_equiv_p (TREE_VALUE (t1), TREE_VALUE (t2)))
    6871                 :             :       return false;
    6872                 :             : 
    6873                 :             :   return true;
    6874                 :             : }
    6875                 :             : 
    6876                 :             : /* Build an expression representing a cast to type TYPE of expression EXPR.
    6877                 :             :    LOC is the location of the cast-- typically the open paren of the cast.  */
    6878                 :             : 
    6879                 :             : tree
    6880                 :   116974911 : build_c_cast (location_t loc, tree type, tree expr)
    6881                 :             : {
    6882                 :   116974911 :   tree value;
    6883                 :             : 
    6884                 :   116974911 :   bool int_operands = EXPR_INT_CONST_OPERANDS (expr);
    6885                 :             : 
    6886                 :   116974911 :   if (TREE_CODE (expr) == EXCESS_PRECISION_EXPR)
    6887                 :          66 :     expr = TREE_OPERAND (expr, 0);
    6888                 :             : 
    6889                 :   116974911 :   value = expr;
    6890                 :   116974911 :   if (int_operands)
    6891                 :     6699927 :     value = remove_c_maybe_const_expr (value);
    6892                 :             : 
    6893                 :   116974911 :   if (type == error_mark_node || expr == error_mark_node)
    6894                 :             :     return error_mark_node;
    6895                 :             : 
    6896                 :             :   /* The ObjC front-end uses TYPE_MAIN_VARIANT to tie together types differing
    6897                 :             :      only in <protocol> qualifications.  But when constructing cast expressions,
    6898                 :             :      the protocols do matter and must be kept around.  */
    6899                 :   116973890 :   if (objc_is_object_ptr (type) && objc_is_object_ptr (TREE_TYPE (expr)))
    6900                 :           0 :     return build1 (NOP_EXPR, type, expr);
    6901                 :             : 
    6902                 :   116973890 :   type = TYPE_MAIN_VARIANT (type);
    6903                 :             : 
    6904                 :   116973890 :   if (TREE_CODE (type) == ARRAY_TYPE)
    6905                 :             :     {
    6906                 :          13 :       error_at (loc, "cast specifies array type");
    6907                 :          13 :       return error_mark_node;
    6908                 :             :     }
    6909                 :             : 
    6910                 :   116973877 :   if (TREE_CODE (type) == FUNCTION_TYPE)
    6911                 :             :     {
    6912                 :           6 :       error_at (loc, "cast specifies function type");
    6913                 :           6 :       return error_mark_node;
    6914                 :             :     }
    6915                 :             : 
    6916                 :   116973871 :   if (!VOID_TYPE_P (type))
    6917                 :             :     {
    6918                 :   116931388 :       value = require_complete_type (loc, value);
    6919                 :   116931388 :       if (value == error_mark_node)
    6920                 :             :         return error_mark_node;
    6921                 :             :     }
    6922                 :             : 
    6923                 :   116973871 :   if (type == TYPE_MAIN_VARIANT (TREE_TYPE (value)))
    6924                 :             :     {
    6925                 :    17606433 :       if (RECORD_OR_UNION_TYPE_P (type)
    6926                 :    17606433 :           && pedwarn (loc, OPT_Wpedantic,
    6927                 :             :                       "ISO C forbids casting nonscalar to the same type"))
    6928                 :             :               ;
    6929                 :    17606429 :       else if (warn_useless_cast)
    6930                 :           7 :         warning_at (loc, OPT_Wuseless_cast,
    6931                 :             :                     "useless cast to type %qT", type);
    6932                 :             : 
    6933                 :             :       /* Convert to remove any qualifiers from VALUE's type.  */
    6934                 :    17606433 :       value = convert (type, value);
    6935                 :             :     }
    6936                 :    99367438 :   else if (TREE_CODE (type) == UNION_TYPE)
    6937                 :             :     {
    6938                 :         128 :       tree field;
    6939                 :             : 
    6940                 :         182 :       for (field = TYPE_FIELDS (type); field; field = DECL_CHAIN (field))
    6941                 :         176 :         if (TREE_TYPE (field) != error_mark_node
    6942                 :         351 :             && comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (field)),
    6943                 :         175 :                           TYPE_MAIN_VARIANT (TREE_TYPE (value))))
    6944                 :             :           break;
    6945                 :             : 
    6946                 :         128 :       if (field)
    6947                 :             :         {
    6948                 :         122 :           tree t;
    6949                 :         122 :           bool maybe_const = true;
    6950                 :             : 
    6951                 :         122 :           pedwarn (loc, OPT_Wpedantic, "ISO C forbids casts to union type");
    6952                 :         122 :           t = c_fully_fold (value, false, &maybe_const);
    6953                 :         122 :           t = build_constructor_single (type, field, t);
    6954                 :         122 :           if (!maybe_const)
    6955                 :           8 :             t = c_wrap_maybe_const (t, true);
    6956                 :         122 :           t = digest_init (loc, field, type, t,
    6957                 :             :                            NULL_TREE, false, false, false, true, false, false);
    6958                 :         122 :           TREE_CONSTANT (t) = TREE_CONSTANT (value);
    6959                 :         122 :           return t;
    6960                 :             :         }
    6961                 :           6 :       error_at (loc, "cast to union type from type not present in union");
    6962                 :           6 :       return error_mark_node;
    6963                 :             :     }
    6964                 :             :   else
    6965                 :             :     {
    6966                 :    99367310 :       tree otype, ovalue;
    6967                 :             : 
    6968                 :    99367310 :       if (type == void_type_node)
    6969                 :             :         {
    6970                 :       16527 :           tree t = build1 (CONVERT_EXPR, type, value);
    6971                 :       16527 :           SET_EXPR_LOCATION (t, loc);
    6972                 :       16527 :           return t;
    6973                 :             :         }
    6974                 :             : 
    6975                 :    99350783 :       otype = TREE_TYPE (value);
    6976                 :             : 
    6977                 :             :       /* Optionally warn about potentially worrisome casts.  */
    6978                 :    99350783 :       if (warn_cast_qual
    6979                 :      179221 :           && TREE_CODE (type) == POINTER_TYPE
    6980                 :       26387 :           && TREE_CODE (otype) == POINTER_TYPE)
    6981                 :       13369 :         handle_warn_cast_qual (loc, type, otype);
    6982                 :             : 
    6983                 :             :       /* Warn about conversions between pointers to disjoint
    6984                 :             :          address spaces.  */
    6985                 :    99350783 :       if (TREE_CODE (type) == POINTER_TYPE
    6986                 :     3276795 :           && TREE_CODE (otype) == POINTER_TYPE
    6987                 :   102286132 :           && !null_pointer_constant_p (value))
    6988                 :             :         {
    6989                 :     2882776 :           addr_space_t as_to = TYPE_ADDR_SPACE (TREE_TYPE (type));
    6990                 :     2882776 :           addr_space_t as_from = TYPE_ADDR_SPACE (TREE_TYPE (otype));
    6991                 :     2882776 :           addr_space_t as_common;
    6992                 :             : 
    6993                 :     2882776 :           if (!addr_space_superset (as_to, as_from, &as_common))
    6994                 :             :             {
    6995                 :           0 :               if (ADDR_SPACE_GENERIC_P (as_from))
    6996                 :           0 :                 warning_at (loc, 0, "cast to %qs address space pointer "
    6997                 :             :                             "from disjoint generic address space pointer",
    6998                 :             :                             c_addr_space_name (as_to));
    6999                 :             : 
    7000                 :           0 :               else if (ADDR_SPACE_GENERIC_P (as_to))
    7001                 :           0 :                 warning_at (loc, 0, "cast to generic address space pointer "
    7002                 :             :                             "from disjoint %qs address space pointer",
    7003                 :             :                             c_addr_space_name (as_from));
    7004                 :             : 
    7005                 :             :               else
    7006                 :           0 :                 warning_at (loc, 0, "cast to %qs address space pointer "
    7007                 :             :                             "from disjoint %qs address space pointer",
    7008                 :             :                             c_addr_space_name (as_to),
    7009                 :             :                             c_addr_space_name (as_from));
    7010                 :             :             }
    7011                 :             : 
    7012                 :             :           /* Warn of new allocations that are not big enough for the target
    7013                 :             :              type.  */
    7014                 :     2882776 :           if (warn_alloc_size && TREE_CODE (value) == CALL_EXPR)
    7015                 :         805 :             if (tree fndecl = get_callee_fndecl (value))
    7016                 :         801 :               if (DECL_IS_MALLOC (fndecl))
    7017                 :             :                 {
    7018                 :         517 :                   tree attrs = TYPE_ATTRIBUTES (TREE_TYPE (fndecl));
    7019                 :         517 :                   tree alloc_size = lookup_attribute ("alloc_size", attrs);
    7020                 :         517 :                   if (alloc_size)
    7021                 :         159 :                     warn_for_alloc_size (loc, TREE_TYPE (type), value,
    7022                 :             :                                          alloc_size);
    7023                 :             :                 }
    7024                 :             :         }
    7025                 :             : 
    7026                 :             :       /* Warn about possible alignment problems.  */
    7027                 :    99350783 :       if ((STRICT_ALIGNMENT || warn_cast_align == 2)
    7028                 :           7 :           && TREE_CODE (type) == POINTER_TYPE
    7029                 :           7 :           && TREE_CODE (otype) == POINTER_TYPE
    7030                 :           7 :           && TREE_CODE (TREE_TYPE (otype)) != VOID_TYPE
    7031                 :           7 :           && TREE_CODE (TREE_TYPE (otype)) != FUNCTION_TYPE
    7032                 :             :           /* Don't warn about opaque types, where the actual alignment
    7033                 :             :              restriction is unknown.  */
    7034                 :          12 :           && !(RECORD_OR_UNION_TYPE_P (TREE_TYPE (otype))
    7035                 :           5 :                && TYPE_MODE (TREE_TYPE (otype)) == VOIDmode)
    7036                 :    99350797 :           && min_align_of_type (TREE_TYPE (type))
    7037                 :           7 :              > min_align_of_type (TREE_TYPE (otype)))
    7038                 :           5 :         warning_at (loc, OPT_Wcast_align,
    7039                 :             :                     "cast increases required alignment of target type");
    7040                 :             : 
    7041                 :    99350783 :       if ((TREE_CODE (type) == INTEGER_TYPE
    7042                 :    99350783 :            || TREE_CODE (type) == BITINT_TYPE)
    7043                 :     6904366 :           && TREE_CODE (otype) == POINTER_TYPE
    7044                 :    99375645 :           && TYPE_PRECISION (type) != TYPE_PRECISION (otype))
    7045                 :             :       /* Unlike conversion of integers to pointers, where the
    7046                 :             :          warning is disabled for converting constants because
    7047                 :             :          of cases such as SIG_*, warn about converting constant
    7048                 :             :          pointers to integers. In some cases it may cause unwanted
    7049                 :             :          sign extension, and a warning is appropriate.  */
    7050                 :        1449 :         warning_at (loc, OPT_Wpointer_to_int_cast,
    7051                 :             :                     "cast from pointer to integer of different size");
    7052                 :             : 
    7053                 :    99350783 :       if (TREE_CODE (value) == CALL_EXPR
    7054                 :    33726380 :           && TREE_CODE (type) != TREE_CODE (otype))
    7055                 :        2284 :         warning_at (loc, OPT_Wbad_function_cast,
    7056                 :             :                     "cast from function call of type %qT "
    7057                 :             :                     "to non-matching type %qT", otype, type);
    7058                 :             : 
    7059                 :    99350783 :       if (TREE_CODE (type) == POINTER_TYPE
    7060                 :     3276795 :           && (TREE_CODE (otype) == INTEGER_TYPE
    7061                 :     3276795 :               || TREE_CODE (otype) == BITINT_TYPE)
    7062                 :      341368 :           && TYPE_PRECISION (type) != TYPE_PRECISION (otype)
    7063                 :             :           /* Don't warn about converting any constant.  */
    7064                 :    99655301 :           && !TREE_CONSTANT (value))
    7065                 :         407 :         warning_at (loc,
    7066                 :         407 :                     OPT_Wint_to_pointer_cast, "cast to pointer from integer "
    7067                 :             :                     "of different size");
    7068                 :             : 
    7069                 :    99350783 :       if (warn_strict_aliasing <= 2)
    7070                 :    90838074 :         strict_aliasing_warning (EXPR_LOCATION (value), type, expr);
    7071                 :             : 
    7072                 :             :       /* If pedantic, warn for conversions between function and object
    7073                 :             :          pointer types, except for converting a null pointer constant
    7074                 :             :          to function pointer type.  */
    7075                 :    99350783 :       if (pedantic
    7076                 :      238799 :           && TREE_CODE (type) == POINTER_TYPE
    7077                 :      144158 :           && TREE_CODE (otype) == POINTER_TYPE
    7078                 :        2769 :           && TREE_CODE (TREE_TYPE (otype)) == FUNCTION_TYPE
    7079                 :    99350804 :           && TREE_CODE (TREE_TYPE (type)) != FUNCTION_TYPE)
    7080                 :          18 :         pedwarn (loc, OPT_Wpedantic, "ISO C forbids "
    7081                 :             :                  "conversion of function pointer to object pointer type");
    7082                 :             : 
    7083                 :    99350783 :       if (pedantic
    7084                 :      238799 :           && TREE_CODE (type) == POINTER_TYPE
    7085                 :      144158 :           && TREE_CODE (otype) == POINTER_TYPE
    7086                 :        2769 :           && TREE_CODE (TREE_TYPE (type)) == FUNCTION_TYPE
    7087                 :          13 :           && TREE_CODE (TREE_TYPE (otype)) != FUNCTION_TYPE
    7088                 :    99350793 :           && !null_pointer_constant_p (value))
    7089                 :           4 :         pedwarn (loc, OPT_Wpedantic, "ISO C forbids "
    7090                 :             :                  "conversion of object pointer to function pointer type");
    7091                 :             : 
    7092                 :    99350783 :       if (TREE_CODE (type) == POINTER_TYPE
    7093                 :     3276795 :           && TREE_CODE (otype) == POINTER_TYPE
    7094                 :     2935349 :           && TREE_CODE (TREE_TYPE (type)) == FUNCTION_TYPE
    7095                 :        8482 :           && TREE_CODE (TREE_TYPE (otype)) == FUNCTION_TYPE
    7096                 :    99358203 :           && !c_safe_function_type_cast_p (TREE_TYPE (type),
    7097                 :        7420 :                                            TREE_TYPE (otype)))
    7098                 :         786 :         warning_at (loc, OPT_Wcast_function_type,
    7099                 :             :                     "cast between incompatible function types"
    7100                 :             :                     " from %qT to %qT", otype, type);
    7101                 :             : 
    7102                 :    99350783 :       ovalue = value;
    7103                 :             :       /* If converting to boolean a value with integer operands that
    7104                 :             :          is not itself represented as an INTEGER_CST, the call below
    7105                 :             :          to note_integer_operands may insert a C_MAYBE_CONST_EXPR, but
    7106                 :             :          build_binary_op as called by c_common_truthvalue_conversion
    7107                 :             :          may also insert a C_MAYBE_CONST_EXPR to indicate that a
    7108                 :             :          subexpression has been fully folded.  To avoid nested
    7109                 :             :          C_MAYBE_CONST_EXPR, ensure that
    7110                 :             :          c_objc_common_truthvalue_conversion receives an argument
    7111                 :             :          properly marked as having integer operands in that case.  */
    7112                 :    99350783 :       if (int_operands
    7113                 :     6512366 :           && TREE_CODE (value) != INTEGER_CST
    7114                 :    99350825 :           && (TREE_CODE (type) == BOOLEAN_TYPE
    7115                 :          28 :               || (TREE_CODE (type) == ENUMERAL_TYPE
    7116                 :          14 :                   && ENUM_UNDERLYING_TYPE (type) != NULL_TREE
    7117                 :          14 :                   && TREE_CODE (ENUM_UNDERLYING_TYPE (type)) == BOOLEAN_TYPE)))
    7118                 :          28 :         value = note_integer_operands (value);
    7119                 :    99350783 :       value = convert (type, value);
    7120                 :             : 
    7121                 :             :       /* Ignore any integer overflow caused by the cast.  */
    7122                 :    99350783 :       if (TREE_CODE (value) == INTEGER_CST && !FLOAT_TYPE_P (otype))
    7123                 :             :         {
    7124                 :     6458866 :           if (TREE_OVERFLOW_P (ovalue))
    7125                 :             :             {
    7126                 :           9 :               if (!TREE_OVERFLOW (value))
    7127                 :             :                 {
    7128                 :             :                   /* Avoid clobbering a shared constant.  */
    7129                 :           0 :                   value = copy_node (value);
    7130                 :           0 :                   TREE_OVERFLOW (value) = TREE_OVERFLOW (ovalue);
    7131                 :             :                 }
    7132                 :             :             }
    7133                 :     6458857 :           else if (TREE_OVERFLOW (value))
    7134                 :             :             /* Reset VALUE's overflow flags, ensuring constant sharing.  */
    7135                 :        3085 :             value = wide_int_to_tree (TREE_TYPE (value), wi::to_wide (value));
    7136                 :             :         }
    7137                 :             :     }
    7138                 :             : 
    7139                 :             :   /* Don't let a cast be an lvalue.  */
    7140                 :   116957216 :   if (lvalue_p (value))
    7141                 :       88504 :     value = non_lvalue_loc (loc, value);
    7142                 :             : 
    7143                 :             :   /* Don't allow the results of casting to floating-point or complex
    7144                 :             :      types be confused with actual constants, or casts involving
    7145                 :             :      integer and pointer types other than direct integer-to-integer
    7146                 :             :      and integer-to-pointer be confused with integer constant
    7147                 :             :      expressions and null pointer constants.  */
    7148                 :   116957216 :   if (TREE_CODE (value) == REAL_CST
    7149                 :   116907438 :       || TREE_CODE (value) == COMPLEX_CST
    7150                 :   233842031 :       || (TREE_CODE (value) == INTEGER_CST
    7151                 :     6705273 :           && !((TREE_CODE (expr) == INTEGER_CST
    7152                 :     6632964 :                 && INTEGRAL_TYPE_P (TREE_TYPE (expr)))
    7153                 :       64906 :                || TREE_CODE (expr) == REAL_CST
    7154                 :             :                || TREE_CODE (expr) == COMPLEX_CST)))
    7155                 :      132940 :       value = build1 (NOP_EXPR, type, value);
    7156                 :             : 
    7157                 :             :   /* If the expression has integer operands and so can occur in an
    7158                 :             :      unevaluated part of an integer constant expression, ensure the
    7159                 :             :      return value reflects this.  */
    7160                 :   116957216 :   if (int_operands
    7161                 :     6687403 :       && INTEGRAL_TYPE_P (type)
    7162                 :     6247344 :       && value != error_mark_node
    7163                 :   123204559 :       && !EXPR_INT_CONST_OPERANDS (value))
    7164                 :          11 :     value = note_integer_operands (value);
    7165                 :             : 
    7166                 :   116957216 :   protected_set_expr_location (value, loc);
    7167                 :   116957216 :   return value;
    7168                 :             : }
    7169                 :             : 
    7170                 :             : /* Interpret a cast of expression EXPR to type TYPE.  LOC is the
    7171                 :             :    location of the open paren of the cast, or the position of the cast
    7172                 :             :    expr.  */
    7173                 :             : tree
    7174                 :   116974565 : c_cast_expr (location_t loc, struct c_type_name *type_name, tree expr)
    7175                 :             : {
    7176                 :   116974565 :   tree type;
    7177                 :   116974565 :   tree type_expr = NULL_TREE;
    7178                 :   116974565 :   bool type_expr_const = true;
    7179                 :   116974565 :   tree ret;
    7180                 :   116974565 :   int saved_wsp = warn_strict_prototypes;
    7181                 :             : 
    7182                 :             :   /* This avoids warnings about unprototyped casts on
    7183                 :             :      integers.  E.g. "#define SIG_DFL (void(*)())0".  */
    7184                 :   116974565 :   if (TREE_CODE (expr) == INTEGER_CST)
    7185                 :     6752757 :     warn_strict_prototypes = 0;
    7186                 :   116974565 :   type = groktypename (type_name, &type_expr, &type_expr_const);
    7187                 :   116974565 :   warn_strict_prototypes = saved_wsp;
    7188                 :             : 
    7189                 :      764514 :   if (TREE_CODE (expr) == ADDR_EXPR && !VOID_TYPE_P (type)
    7190                 :   117738842 :       && reject_gcc_builtin (expr))
    7191                 :           2 :     return error_mark_node;
    7192                 :             : 
    7193                 :   116974563 :   ret = build_c_cast (loc, type, expr);
    7194                 :   116974563 :   if (ret == error_mark_node)
    7195                 :             :     return error_mark_node;
    7196                 :             : 
    7197                 :   116973413 :   if (type_expr)
    7198                 :             :     {
    7199                 :         203 :       bool inner_expr_const = true;
    7200                 :         203 :       ret = c_fully_fold (ret, require_constant_value, &inner_expr_const);
    7201                 :         203 :       ret = build2 (C_MAYBE_CONST_EXPR, TREE_TYPE (ret), type_expr, ret);
    7202                 :         406 :       C_MAYBE_CONST_EXPR_NON_CONST (ret) = !(type_expr_const
    7203                 :         129 :                                              && inner_expr_const);
    7204                 :         203 :       SET_EXPR_LOCATION (ret, loc);
    7205                 :             :     }
    7206                 :             : 
    7207                 :   116973413 :   if (!EXPR_HAS_LOCATION (ret))
    7208                 :     6633831 :     protected_set_expr_location (ret, loc);
    7209                 :             : 
    7210                 :             :   /* C++ does not permits types to be defined in a cast, but it
    7211                 :             :      allows references to incomplete types.  */
    7212                 :   116973413 :   if (warn_cxx_compat && type_name->specs->typespec_kind == ctsk_tagdef)
    7213                 :           1 :     warning_at (loc, OPT_Wc___compat,
    7214                 :             :                 "defining a type in a cast is invalid in C++");
    7215                 :             : 
    7216                 :             :   return ret;
    7217                 :             : }
    7218                 :             : 
    7219                 :             : /* Build an assignment expression of lvalue LHS from value RHS.
    7220                 :             :    If LHS_ORIGTYPE is not NULL, it is the original type of LHS, which
    7221                 :             :    may differ from TREE_TYPE (LHS) for an enum bitfield.
    7222                 :             :    MODIFYCODE is the code for a binary operator that we use
    7223                 :             :    to combine the old value of LHS with RHS to get the new value.
    7224                 :             :    Or else MODIFYCODE is NOP_EXPR meaning do a simple assignment.
    7225                 :             :    If RHS_ORIGTYPE is not NULL_TREE, it is the original type of RHS,
    7226                 :             :    which may differ from TREE_TYPE (RHS) for an enum value.
    7227                 :             : 
    7228                 :             :    LOCATION is the location of the MODIFYCODE operator.
    7229                 :             :    RHS_LOC is the location of the RHS.  */
    7230                 :             : 
    7231                 :             : tree
    7232                 :     2838713 : build_modify_expr (location_t location, tree lhs, tree lhs_origtype,
    7233                 :             :                    enum tree_code modifycode,
    7234                 :             :                    location_t rhs_loc, tree rhs, tree rhs_origtype)
    7235                 :             : {
    7236                 :     2838713 :   tree result;
    7237                 :     2838713 :   tree newrhs;
    7238                 :     2838713 :   tree rhseval = NULL_TREE;
    7239                 :     2838713 :   tree lhstype = TREE_TYPE (lhs);
    7240                 :     2838713 :   tree olhstype = lhstype;
    7241                 :     2838713 :   bool npc;
    7242                 :     2838713 :   bool is_atomic_op;
    7243                 :             : 
    7244                 :             :   /* Types that aren't fully specified cannot be used in assignments.  */
    7245                 :     2838713 :   lhs = require_complete_type (location, lhs);
    7246                 :     2838713 :   rhs = require_complete_type (location, rhs);
    7247                 :             : 
    7248                 :             :   /* Avoid duplicate error messages from operands that had errors.  */
    7249                 :     2838713 :   if (TREE_CODE (lhs) == ERROR_MARK || TREE_CODE (rhs) == ERROR_MARK)
    7250                 :         472 :     return error_mark_node;
    7251                 :             : 
    7252                 :             :   /* Ensure an error for assigning a non-lvalue array to an array in
    7253                 :             :      C90.  */
    7254                 :     2838241 :   if (TREE_CODE (lhstype) == ARRAY_TYPE)
    7255                 :             :     {
    7256                 :           1 :       error_at (location, "assignment to expression with array type");
    7257                 :           1 :       return error_mark_node;
    7258                 :             :     }
    7259                 :             : 
    7260                 :             :   /* For ObjC properties, defer this check.  */
    7261                 :     2838240 :   if (!objc_is_property_ref (lhs) && !lvalue_or_else (location, lhs, lv_assign))
    7262                 :          31 :     return error_mark_node;
    7263                 :             : 
    7264                 :     2838209 :   is_atomic_op = really_atomic_lvalue (lhs);
    7265                 :             : 
    7266                 :     2838209 :   newrhs = rhs;
    7267                 :             : 
    7268                 :     2838209 :   if (TREE_CODE (lhs) == C_MAYBE_CONST_EXPR)
    7269                 :             :     {
    7270                 :           2 :       tree inner = build_modify_expr (location, C_MAYBE_CONST_EXPR_EXPR (lhs),
    7271                 :             :                                       lhs_origtype, modifycode, rhs_loc, rhs,
    7272                 :             :                                       rhs_origtype);
    7273                 :           2 :       if (inner == error_mark_node)
    7274                 :             :         return error_mark_node;
    7275                 :           4 :       result = build2 (C_MAYBE_CONST_EXPR, TREE_TYPE (inner),
    7276                 :           2 :                        C_MAYBE_CONST_EXPR_PRE (lhs), inner);
    7277                 :           2 :       gcc_assert (!C_MAYBE_CONST_EXPR_INT_OPERANDS (lhs));
    7278                 :           2 :       C_MAYBE_CONST_EXPR_NON_CONST (result) = 1;
    7279                 :           2 :       protected_set_expr_location (result, location);
    7280                 :           2 :       return result;
    7281                 :             :     }
    7282                 :             : 
    7283                 :             :   /* If a binary op has been requested, combine the old LHS value with the RHS
    7284                 :             :      producing the value we should actually store into the LHS.  */
    7285                 :             : 
    7286                 :     2838207 :   if (modifycode != NOP_EXPR)
    7287                 :             :     {
    7288                 :      209593 :       lhs = c_fully_fold (lhs, false, NULL, true);
    7289                 :      209593 :       lhs = stabilize_reference (lhs);
    7290                 :             : 
    7291                 :             :       /* Construct the RHS for any non-atomic compound assignemnt. */
    7292                 :      209593 :       if (!is_atomic_op)
    7293                 :             :         {
    7294                 :             :           /* If in LHS op= RHS the RHS has side-effects, ensure they
    7295                 :             :              are preevaluated before the rest of the assignment expression's
    7296                 :             :              side-effects, because RHS could contain e.g. function calls
    7297                 :             :              that modify LHS.  */
    7298                 :      194124 :           if (TREE_SIDE_EFFECTS (rhs))
    7299                 :             :             {
    7300                 :        8601 :               if (TREE_CODE (rhs) == EXCESS_PRECISION_EXPR)
    7301                 :          28 :                 newrhs = save_expr (TREE_OPERAND (rhs, 0));
    7302                 :             :               else
    7303                 :        8573 :                 newrhs = save_expr (rhs);
    7304                 :        8601 :               rhseval = newrhs;
    7305                 :        8601 :               if (TREE_CODE (rhs) == EXCESS_PRECISION_EXPR)
    7306                 :          28 :                 newrhs = build1 (EXCESS_PRECISION_EXPR, TREE_TYPE (rhs),
    7307                 :             :                                  newrhs);
    7308                 :             :             }
    7309                 :      194124 :           newrhs = build_binary_op (location,
    7310                 :             :                                     modifycode, lhs, newrhs, true);
    7311                 :             : 
    7312                 :             :           /* The original type of the right hand side is no longer
    7313                 :             :              meaningful.  */
    7314                 :      194124 :           rhs_origtype = NULL_TREE;
    7315                 :             :         }
    7316                 :             :     }
    7317                 :             : 
    7318                 :     2838207 :   if (c_dialect_objc ())
    7319                 :             :     {
    7320                 :             :       /* Check if we are modifying an Objective-C property reference;
    7321                 :             :          if so, we need to generate setter calls.  */
    7322                 :           0 :       if (TREE_CODE (newrhs) == EXCESS_PRECISION_EXPR)
    7323                 :           0 :         result = objc_maybe_build_modify_expr (lhs, TREE_OPERAND (newrhs, 0));
    7324                 :             :       else
    7325                 :           0 :         result = objc_maybe_build_modify_expr (lhs, newrhs);
    7326                 :           0 :       if (result)
    7327                 :           0 :         goto return_result;
    7328                 :             : 
    7329                 :             :       /* Else, do the check that we postponed for Objective-C.  */
    7330                 :           0 :       if (!lvalue_or_else (location, lhs, lv_assign))
    7331                 :           0 :         return error_mark_node;
    7332                 :             :     }
    7333                 :             : 
    7334                 :             :   /* Give an error for storing in something that is 'const'.  */
    7335                 :             : 
    7336                 :     2838207 :   if (TYPE_READONLY (lhstype)
    7337                 :     2838207 :       || (RECORD_OR_UNION_TYPE_P (lhstype)
    7338                 :       25476 :           && C_TYPE_FIELDS_READONLY (lhstype)))
    7339                 :             :     {
    7340                 :          88 :       readonly_error (location, lhs, lv_assign);
    7341                 :          88 :       return error_mark_node;
    7342                 :             :     }
    7343                 :     2838119 :   else if (TREE_READONLY (lhs))
    7344                 :           1 :     readonly_warning (lhs, lv_assign);
    7345                 :             : 
    7346                 :             :   /* If storing into a structure or union member,
    7347                 :             :      it has probably been given type `int'.
    7348                 :             :      Compute the type that would go with
    7349                 :             :      the actual amount of storage the member occupies.  */
    7350                 :             : 
    7351                 :     2838119 :   if (TREE_CODE (lhs) == COMPONENT_REF
    7352                 :      243597 :       && (TREE_CODE (lhstype) == INTEGER_TYPE
    7353                 :      243597 :           || TREE_CODE (lhstype) == BOOLEAN_TYPE
    7354                 :      106620 :           || SCALAR_FLOAT_TYPE_P (lhstype)
    7355                 :       84759 :           || TREE_CODE (lhstype) == ENUMERAL_TYPE))
    7356                 :      165812 :     lhstype = TREE_TYPE (get_unwidened (lhs, 0));
    7357                 :             : 
    7358                 :             :   /* If storing in a field that is in actuality a short or narrower than one,
    7359                 :             :      we must store in the field in its actual type.  */
    7360                 :             : 
    7361                 :     2838119 :   if (lhstype != TREE_TYPE (lhs))
    7362                 :             :     {
    7363                 :           0 :       lhs = copy_node (lhs);
    7364                 :           0 :       TREE_TYPE (lhs) = lhstype;
    7365                 :             :     }
    7366                 :             : 
    7367                 :             :   /* Issue -Wc++-compat warnings about an assignment to an enum type
    7368                 :             :      when LHS does not have its original type.  This happens for,
    7369                 :             :      e.g., an enum bitfield in a struct.  */
    7370                 :     2838119 :   if (warn_cxx_compat
    7371                 :        3001 :       && lhs_origtype != NULL_TREE
    7372                 :        3001 :       && lhs_origtype != lhstype
    7373                 :           7 :       && TREE_CODE (lhs_origtype) == ENUMERAL_TYPE)
    7374                 :             :     {
    7375                 :           4 :       tree checktype = (rhs_origtype != NULL_TREE
    7376                 :           4 :                         ? rhs_origtype
    7377                 :           0 :                         : TREE_TYPE (rhs));
    7378                 :           4 :       if (checktype != error_mark_node
    7379                 :           4 :           && (TYPE_MAIN_VARIANT (checktype) != TYPE_MAIN_VARIANT (lhs_origtype)
    7380                 :           2 :               || (is_atomic_op && modifycode != NOP_EXPR)))
    7381                 :           2 :         warning_at (location, OPT_Wc___compat,
    7382                 :             :                     "enum conversion in assignment is invalid in C++");
    7383                 :             :     }
    7384                 :             : 
    7385                 :             :   /* Remove qualifiers.  */
    7386                 :     2838119 :   lhstype = c_build_qualified_type (lhstype, TYPE_UNQUALIFIED);
    7387                 :     2838119 :   olhstype = c_build_qualified_type (olhstype, TYPE_UNQUALIFIED);
    7388                 :             : 
    7389                 :             :   /* Convert new value to destination type.  Fold it first, then
    7390                 :             :      restore any excess precision information, for the sake of
    7391                 :             :      conversion warnings.  */
    7392                 :             : 
    7393                 :     2838119 :   if (!(is_atomic_op && modifycode != NOP_EXPR))
    7394                 :             :     {
    7395                 :     2822650 :       tree rhs_semantic_type = NULL_TREE;
    7396                 :     2822650 :       if (!c_in_omp_for)
    7397                 :             :         {
    7398                 :     2806357 :           if (TREE_CODE (newrhs) == EXCESS_PRECISION_EXPR)
    7399                 :             :             {
    7400                 :        5069 :               rhs_semantic_type = TREE_TYPE (newrhs);
    7401                 :        5069 :               newrhs = TREE_OPERAND (newrhs, 0);
    7402                 :             :             }
    7403                 :     2806357 :           npc = null_pointer_constant_p (newrhs);
    7404                 :     2806357 :           newrhs = c_fully_fold (newrhs, false, NULL);
    7405                 :     2806357 :           if (rhs_semantic_type)
    7406                 :        5069 :             newrhs = build1 (EXCESS_PRECISION_EXPR, rhs_semantic_type, newrhs);
    7407                 :             :         }
    7408                 :             :       else
    7409                 :       16293 :         npc = null_pointer_constant_p (newrhs);
    7410                 :     2822650 :       newrhs = convert_for_assignment (location, rhs_loc, lhstype, newrhs,
    7411                 :             :                                        rhs_origtype, ic_assign, npc,
    7412                 :             :                                        NULL_TREE, NULL_TREE, 0);
    7413                 :     2822650 :       if (TREE_CODE (newrhs) == ERROR_MARK)
    7414                 :         116 :         return error_mark_node;
    7415                 :             :     }
    7416                 :             : 
    7417                 :             :   /* Emit ObjC write barrier, if necessary.  */
    7418                 :     2838003 :   if (c_dialect_objc () && flag_objc_gc)
    7419                 :             :     {
    7420                 :           0 :       result = objc_generate_write_barrier (lhs, modifycode, newrhs);
    7421                 :           0 :       if (result)
    7422                 :             :         {
    7423                 :           0 :           protected_set_expr_location (result, location);
    7424                 :           0 :           goto return_result;
    7425                 :             :         }
    7426                 :             :     }
    7427                 :             : 
    7428                 :             :   /* Scan operands.  */
    7429                 :             : 
    7430                 :     2838003 :   if (is_atomic_op)
    7431                 :       25842 :     result = build_atomic_assign (location, lhs, modifycode, newrhs, false);
    7432                 :             :   else
    7433                 :             :     {
    7434                 :     2812161 :       result = build2 (MODIFY_EXPR, lhstype, lhs, newrhs);
    7435                 :     2812161 :       TREE_SIDE_EFFECTS (result) = 1;
    7436                 :     2812161 :       protected_set_expr_location (result, location);
    7437                 :             :     }
    7438                 :             : 
    7439                 :             :   /* If we got the LHS in a different type for storing in,
    7440                 :             :      convert the result back to the nominal type of LHS
    7441                 :             :      so that the value we return always has the same type
    7442                 :             :      as the LHS argument.  */
    7443                 :             : 
    7444                 :     2838003 :   if (olhstype == TREE_TYPE (result))
    7445                 :     2838003 :     goto return_result;
    7446                 :             : 
    7447                 :           0 :   result = convert_for_assignment (location, rhs_loc, olhstype, result,
    7448                 :             :                                    rhs_origtype, ic_assign, false, NULL_TREE,
    7449                 :             :                                    NULL_TREE, 0);
    7450                 :           0 :   protected_set_expr_location (result, location);
    7451                 :             : 
    7452                 :     2838003 : return_result:
    7453                 :     2838003 :   if (rhseval)
    7454                 :        8601 :     result = build2 (COMPOUND_EXPR, TREE_TYPE (result), rhseval, result);
    7455                 :             :   return result;
    7456                 :             : }
    7457                 :             : 
    7458                 :             : /* Return whether STRUCT_TYPE has an anonymous field with type TYPE.
    7459                 :             :    This is used to implement -fplan9-extensions.  */
    7460                 :             : 
    7461                 :             : static bool
    7462                 :          10 : find_anonymous_field_with_type (tree struct_type, tree type)
    7463                 :             : {
    7464                 :          10 :   tree field;
    7465                 :          10 :   bool found;
    7466                 :             : 
    7467                 :          10 :   gcc_assert (RECORD_OR_UNION_TYPE_P (struct_type));
    7468                 :          10 :   found = false;
    7469                 :          10 :   for (field = TYPE_FIELDS (struct_type);
    7470                 :          20 :        field != NULL_TREE;
    7471                 :          10 :        field = TREE_CHAIN (field))
    7472                 :             :     {
    7473                 :          10 :       tree fieldtype = remove_qualifiers (TREE_TYPE (field));
    7474                 :          10 :       if (DECL_NAME (field) == NULL
    7475                 :          10 :           && comptypes (type, fieldtype))
    7476                 :             :         {
    7477                 :           4 :           if (found)
    7478                 :             :             return false;
    7479                 :             :           found = true;
    7480                 :             :         }
    7481                 :           6 :       else if (DECL_NAME (field) == NULL
    7482                 :           2 :                && RECORD_OR_UNION_TYPE_P (TREE_TYPE (field))
    7483                 :           8 :                && find_anonymous_field_with_type (TREE_TYPE (field), type))
    7484                 :             :         {
    7485                 :           0 :           if (found)
    7486                 :             :             return false;
    7487                 :             :           found = true;
    7488                 :             :         }
    7489                 :             :     }
    7490                 :             :   return found;
    7491                 :             : }
    7492                 :             : 
    7493                 :             : /* RHS is an expression whose type is pointer to struct.  If there is
    7494                 :             :    an anonymous field in RHS with type TYPE, then return a pointer to
    7495                 :             :    that field in RHS.  This is used with -fplan9-extensions.  This
    7496                 :             :    returns NULL if no conversion could be found.  */
    7497                 :             : 
    7498                 :             : static tree
    7499                 :          12 : convert_to_anonymous_field (location_t location, tree type, tree rhs)
    7500                 :             : {
    7501                 :          12 :   tree rhs_struct_type, lhs_main_type;
    7502                 :          12 :   tree field, found_field;
    7503                 :          12 :   bool found_sub_field;
    7504                 :          12 :   tree ret;
    7505                 :             : 
    7506                 :          12 :   gcc_assert (POINTER_TYPE_P (TREE_TYPE (rhs)));
    7507                 :          12 :   rhs_struct_type = TREE_TYPE (TREE_TYPE (rhs));
    7508                 :          12 :   gcc_assert (RECORD_OR_UNION_TYPE_P (rhs_struct_type));
    7509                 :             : 
    7510                 :          12 :   gcc_assert (POINTER_TYPE_P (type));
    7511                 :          12 :   lhs_main_type = remove_qualifiers (TREE_TYPE (type));
    7512                 :             : 
    7513                 :          12 :   found_field = NULL_TREE;
    7514                 :          12 :   found_sub_field = false;
    7515                 :          12 :   for (field = TYPE_FIELDS (rhs_struct_type);
    7516                 :          44 :        field != NULL_TREE;
    7517                 :          32 :        field = TREE_CHAIN (field))
    7518                 :             :     {
    7519                 :          36 :       if (DECL_NAME (field) != NULL_TREE
    7520                 :          36 :           || !RECORD_OR_UNION_TYPE_P (TREE_TYPE (field)))
    7521                 :          16 :         continue;
    7522                 :          20 :       tree fieldtype = remove_qualifiers (TREE_TYPE (field));
    7523                 :          20 :       if (comptypes (lhs_main_type, fieldtype))
    7524                 :             :         {
    7525                 :          12 :           if (found_field != NULL_TREE)
    7526                 :             :             return NULL_TREE;
    7527                 :             :           found_field = field;
    7528                 :             :         }
    7529                 :           8 :       else if (find_anonymous_field_with_type (TREE_TYPE (field),
    7530                 :             :                                                lhs_main_type))
    7531                 :             :         {
    7532                 :           4 :           if (found_field != NULL_TREE)
    7533                 :             :             return NULL_TREE;
    7534                 :             :           found_field = field;
    7535                 :             :           found_sub_field = true;
    7536                 :             :         }
    7537                 :             :     }
    7538                 :             : 
    7539                 :           8 :   if (found_field == NULL_TREE)
    7540                 :             :     return NULL_TREE;
    7541                 :             : 
    7542                 :           8 :   ret = fold_build3_loc (location, COMPONENT_REF, TREE_TYPE (found_field),
    7543                 :             :                          build_fold_indirect_ref (rhs), found_field,
    7544                 :             :                          NULL_TREE);
    7545                 :           8 :   ret = build_fold_addr_expr_loc (location, ret);
    7546                 :             : 
    7547                 :           8 :   if (found_sub_field)
    7548                 :             :     {
    7549                 :           2 :       ret = convert_to_anonymous_field (location, type, ret);
    7550                 :           2 :       gcc_assert (ret != NULL_TREE);
    7551                 :             :     }
    7552                 :             : 
    7553                 :             :   return ret;
    7554                 :             : }
    7555                 :             : 
    7556                 :             : /* Issue an error message for a bad initializer component.
    7557                 :             :    GMSGID identifies the message.
    7558                 :             :    The component name is taken from the spelling stack.  */
    7559                 :             : 
    7560                 :             : static void ATTRIBUTE_GCC_DIAG (2,0)
    7561                 :         906 : error_init (location_t loc, const char *gmsgid, ...)
    7562                 :             : {
    7563                 :         906 :   char *ofwhat;
    7564                 :             : 
    7565                 :         906 :   auto_diagnostic_group d;
    7566                 :             : 
    7567                 :             :   /* The gmsgid may be a format string with %< and %>. */
    7568                 :         906 :   va_list ap;
    7569                 :         906 :   va_start (ap, gmsgid);
    7570                 :         906 :   bool warned = emit_diagnostic_valist (DK_ERROR, loc, -1, gmsgid, &ap);
    7571                 :         906 :   va_end (ap);
    7572                 :             : 
    7573                 :         906 :   ofwhat = print_spelling ((char *) alloca (spelling_length () + 1));
    7574                 :         906 :   if (*ofwhat && warned)
    7575                 :         220 :     inform (loc, "(near initialization for %qs)", ofwhat);
    7576                 :         906 : }
    7577                 :             : 
    7578                 :             : /* Used to implement pedwarn_init and permerror_init.  */
    7579                 :             : 
    7580                 :             : static bool ATTRIBUTE_GCC_DIAG (3,0)
    7581                 :        2511 : pedwarn_permerror_init (location_t loc, int opt, const char *gmsgid,
    7582                 :             :                         va_list *ap, diagnostic_t kind)
    7583                 :             : {
    7584                 :             :   /* Use the location where a macro was expanded rather than where
    7585                 :             :      it was defined to make sure macros defined in system headers
    7586                 :             :      but used incorrectly elsewhere are diagnosed.  */
    7587                 :        2511 :   location_t exploc = expansion_point_location_if_in_system_header (loc);
    7588                 :        2511 :   auto_diagnostic_group d;
    7589                 :        2511 :   bool warned = emit_diagnostic_valist (kind, exploc, opt, gmsgid, ap);
    7590                 :        2511 :   if (warned)
    7591                 :             :     {
    7592                 :        1798 :       char *ofwhat = print_spelling ((char *) alloca (spelling_length () + 1));
    7593                 :        1798 :       if (*ofwhat)
    7594                 :        1479 :         inform (exploc, "(near initialization for %qs)", ofwhat);
    7595                 :             :     }
    7596                 :        5022 :   return warned;
    7597                 :        2511 : }
    7598                 :             : 
    7599                 :             : /* Issue a pedantic warning for a bad initializer component.  OPT is
    7600                 :             :    the option OPT_* (from options.h) controlling this warning or 0 if
    7601                 :             :    it is unconditionally given.  GMSGID identifies the message.  The
    7602                 :             :    component name is taken from the spelling stack.  */
    7603                 :             : 
    7604                 :             : static bool ATTRIBUTE_GCC_DIAG (3,0)
    7605                 :        2184 : pedwarn_init (location_t loc, int opt, const char *gmsgid, ...)
    7606                 :             : {
    7607                 :        2184 :   va_list ap;
    7608                 :        2184 :   va_start (ap, gmsgid);
    7609                 :        2184 :   bool warned = pedwarn_permerror_init (loc, opt, gmsgid, &ap, DK_PEDWARN);
    7610                 :        2184 :   va_end (ap);
    7611                 :        2184 :   return warned;
    7612                 :             : }
    7613                 :             : 
    7614                 :             : /* Like pedwarn_init, but issue a permerror.  */
    7615                 :             : 
    7616                 :             : static bool ATTRIBUTE_GCC_DIAG (3,0)
    7617                 :         327 : permerror_init (location_t loc, int opt, const char *gmsgid, ...)
    7618                 :             : {
    7619                 :         327 :   va_list ap;
    7620                 :         327 :   va_start (ap, gmsgid);
    7621                 :         327 :   bool warned = pedwarn_permerror_init (loc, opt, gmsgid, &ap, DK_PERMERROR);
    7622                 :         327 :   va_end (ap);
    7623                 :         327 :   return warned;
    7624                 :             : }
    7625                 :             : 
    7626                 :             : /* Issue a warning for a bad initializer component.
    7627                 :             : 
    7628                 :             :    OPT is the OPT_W* value corresponding to the warning option that
    7629                 :             :    controls this warning.  GMSGID identifies the message.  The
    7630                 :             :    component name is taken from the spelling stack.  */
    7631                 :             : 
    7632                 :             : static void
    7633                 :         146 : warning_init (location_t loc, int opt, const char *gmsgid)
    7634                 :             : {
    7635                 :         146 :   char *ofwhat;
    7636                 :         146 :   bool warned;
    7637                 :             : 
    7638                 :         146 :   auto_diagnostic_group d;
    7639                 :             : 
    7640                 :             :   /* Use the location where a macro was expanded rather than where
    7641                 :             :      it was defined to make sure macros defined in system headers
    7642                 :             :      but used incorrectly elsewhere are diagnosed.  */
    7643                 :         146 :   location_t exploc = expansion_point_location_if_in_system_header (loc);
    7644                 :             : 
    7645                 :             :   /* The gmsgid may be a format string with %< and %>. */
    7646                 :         146 :   warned = warning_at (exploc, opt, gmsgid);
    7647                 :         146 :   if (warned)
    7648                 :             :     {
    7649                 :         124 :       ofwhat = print_spelling ((char *) alloca (spelling_length () + 1));
    7650                 :         124 :       if (*ofwhat)
    7651                 :         124 :         inform (exploc, "(near initialization for %qs)", ofwhat);
    7652                 :             :     }
    7653                 :         146 : }
    7654                 :             : 
    7655                 :             : /* If TYPE is an array type and EXPR is a parenthesized string
    7656                 :             :    constant, warn if pedantic that EXPR is being used to initialize an
    7657                 :             :    object of type TYPE.  */
    7658                 :             : 
    7659                 :             : void
    7660                 :     7099415 : maybe_warn_string_init (location_t loc, tree type, struct c_expr expr)
    7661                 :             : {
    7662                 :     7099415 :   if (pedantic
    7663                 :       80203 :       && TREE_CODE (type) == ARRAY_TYPE
    7664                 :        1008 :       && TREE_CODE (expr.value) == STRING_CST
    7665                 :         353 :       && expr.original_code != STRING_CST)
    7666                 :          13 :     pedwarn_init (loc, OPT_Wpedantic,
    7667                 :             :                   "array initialized from parenthesized string constant");
    7668                 :     7099415 : }
    7669                 :             : 
    7670                 :             : /* Attempt to locate the parameter with the given index within FNDECL,
    7671                 :             :    returning DECL_SOURCE_LOCATION (FNDECL) if it can't be found.  */
    7672                 :             : 
    7673                 :             : static location_t
    7674                 :         936 : get_fndecl_argument_location (tree fndecl, int argnum)
    7675                 :             : {
    7676                 :         936 :   int i;
    7677                 :         936 :   tree param;
    7678                 :             : 
    7679                 :             :   /* Locate param by index within DECL_ARGUMENTS (fndecl).  */
    7680                 :         936 :   for (i = 0, param = DECL_ARGUMENTS (fndecl);
    7681                 :        1015 :        i < argnum && param;
    7682                 :          79 :        i++, param = TREE_CHAIN (param))
    7683                 :             :     ;
    7684                 :             : 
    7685                 :             :   /* If something went wrong (e.g. if we have a builtin and thus no arguments),
    7686                 :             :      return DECL_SOURCE_LOCATION (FNDECL).  */
    7687                 :         936 :   if (param == NULL)
    7688                 :         653 :     return DECL_SOURCE_LOCATION (fndecl);
    7689                 :             : 
    7690                 :         283 :   return DECL_SOURCE_LOCATION (param);
    7691                 :             : }
    7692                 :             : 
    7693                 :             : /* Issue a note about a mismatching argument for parameter PARMNUM
    7694                 :             :    to FUNDECL, for types EXPECTED_TYPE and ACTUAL_TYPE.
    7695                 :             :    Attempt to issue the note at the pertinent parameter of the decl;
    7696                 :             :    failing that issue it at the location of FUNDECL; failing that
    7697                 :             :    issue it at PLOC.
    7698                 :             :    Use highlight_colors::actual for the ACTUAL_TYPE
    7699                 :             :    and highlight_colors::expected for EXPECTED_TYPE and the
    7700                 :             :    parameter of FUNDECL*/
    7701                 :             : 
    7702                 :             : static void
    7703                 :        1060 : inform_for_arg (tree fundecl, location_t ploc, int parmnum,
    7704                 :             :                 tree expected_type, tree actual_type)
    7705                 :             : {
    7706                 :        1060 :   location_t loc;
    7707                 :        1060 :   if (fundecl && !DECL_IS_UNDECLARED_BUILTIN (fundecl))
    7708                 :         936 :     loc = get_fndecl_argument_location (fundecl, parmnum - 1);
    7709                 :             :   else
    7710                 :             :     loc = ploc;
    7711                 :             : 
    7712                 :        1060 :   gcc_rich_location richloc (loc, nullptr, highlight_colors::expected);
    7713                 :             : 
    7714                 :        1060 :   pp_markup::element_expected_type elem_expected_type (expected_type);
    7715                 :        1060 :   pp_markup::element_actual_type elem_actual_type (actual_type);
    7716                 :        1060 :   inform (&richloc,
    7717                 :             :           "expected %e but argument is of type %e",
    7718                 :             :           &elem_expected_type, &elem_actual_type);
    7719                 :        1060 : }
    7720                 :             : 
    7721                 :             : /* Issue a warning when an argument of ARGTYPE is passed to a built-in
    7722                 :             :    function FUNDECL declared without prototype to parameter PARMNUM of
    7723                 :             :    PARMTYPE when ARGTYPE does not promote to PARMTYPE.  */
    7724                 :             : 
    7725                 :             : static void
    7726                 :         418 : maybe_warn_builtin_no_proto_arg (location_t loc, tree fundecl, int parmnum,
    7727                 :             :                                  tree parmtype, tree argtype)
    7728                 :             : {
    7729                 :         418 :   tree_code parmcode = TREE_CODE (parmtype);
    7730                 :         418 :   tree_code argcode = TREE_CODE (argtype);
    7731                 :         418 :   tree promoted = c_type_promotes_to (argtype);
    7732                 :             : 
    7733                 :             :   /* Avoid warning for enum arguments that promote to an integer type
    7734                 :             :      of the same size/mode.  */
    7735                 :         418 :   if (parmcode == INTEGER_TYPE
    7736                 :         418 :       && argcode == ENUMERAL_TYPE
    7737                 :         418 :       && TYPE_MODE (parmtype) == TYPE_MODE (argtype))
    7738                 :             :     return;
    7739                 :             : 
    7740                 :         417 :   if ((parmcode == argcode
    7741                 :         222 :        || (parmcode == INTEGER_TYPE
    7742                 :             :            && argcode == ENUMERAL_TYPE))
    7743                 :         418 :       && TYPE_MAIN_VARIANT (parmtype) == TYPE_MAIN_VARIANT (promoted))
    7744                 :             :     return;
    7745                 :             : 
    7746                 :             :   /* This diagnoses even signed/unsigned mismatches.  Those might be
    7747                 :             :      safe in many cases but GCC may emit suboptimal code for them so
    7748                 :             :      warning on those cases drives efficiency improvements.  */
    7749                 :         398 :   if (warning_at (loc, OPT_Wbuiltin_declaration_mismatch,
    7750                 :         398 :                   TYPE_MAIN_VARIANT (promoted) == argtype
    7751                 :             :                   ? G_("%qD argument %d type is %qT where %qT is expected "
    7752                 :             :                        "in a call to built-in function declared without "
    7753                 :             :                        "prototype")
    7754                 :             :                   : G_("%qD argument %d promotes to %qT where %qT is expected "
    7755                 :             :                        "in a call to built-in function declared without "
    7756                 :             :                        "prototype"),
    7757                 :             :                   fundecl, parmnum, promoted, parmtype))
    7758                 :         150 :     inform (DECL_SOURCE_LOCATION (fundecl),
    7759                 :             :             "built-in %qD declared here",
    7760                 :             :             fundecl);
    7761                 :             : }
    7762                 :             : 
    7763                 :             : /* Print a declaration in quotes, with the given highlight_color.
    7764                 :             :    Analogous to handler for %qD, but with a specific highlight color.  */
    7765                 :             : 
    7766                 :         195 : class pp_element_quoted_decl : public pp_element
    7767                 :             : {
    7768                 :             : public:
    7769                 :         195 :   pp_element_quoted_decl (tree decl, const char *highlight_color)
    7770                 :         195 :   : m_decl (decl),
    7771                 :         195 :     m_highlight_color (highlight_color)
    7772                 :             :   {
    7773                 :             :   }
    7774                 :             : 
    7775                 :         195 :   void add_to_phase_2 (pp_markup::context &ctxt) override
    7776                 :             :   {
    7777                 :         195 :     ctxt.begin_quote ();
    7778                 :         195 :     ctxt.begin_highlight_color (m_highlight_color);
    7779                 :             : 
    7780                 :         195 :     print_decl (ctxt);
    7781                 :             : 
    7782                 :         195 :     ctxt.end_highlight_color ();
    7783                 :         195 :     ctxt.end_quote ();
    7784                 :         195 :   }
    7785                 :             : 
    7786                 :         195 :   void print_decl (pp_markup::context &ctxt)
    7787                 :             :   {
    7788                 :         195 :     pretty_printer *const pp = &ctxt.m_pp;
    7789                 :         195 :     pp->set_padding (pp_none);
    7790                 :         195 :     if (DECL_NAME (m_decl))
    7791                 :         195 :       pp_identifier (pp, lang_hooks.decl_printable_name (m_decl, 2));
    7792                 :             :     else
    7793                 :           0 :       pp_string (pp, _("({anonymous})"));
    7794                 :         195 :   }
    7795                 :             : 
    7796                 :             : private:
    7797                 :             :   tree m_decl;
    7798                 :             :   const char *m_highlight_color;
    7799                 :             : };
    7800                 :             : 
    7801                 :             : /* If TYPE is from a typedef, issue a note showing the location
    7802                 :             :    to the user.
    7803                 :             :    Use HIGHLIGHT_COLOR as the highlight color.  */
    7804                 :             : 
    7805                 :             : static void
    7806                 :        1174 : maybe_inform_typedef_location (tree type, const char *highlight_color)
    7807                 :             : {
    7808                 :        1174 :   if (!typedef_variant_p (type))
    7809                 :        1142 :     return;
    7810                 :             : 
    7811                 :          32 :   tree typedef_decl = TYPE_NAME (type);
    7812                 :          32 :   gcc_assert (TREE_CODE (typedef_decl) == TYPE_DECL);
    7813                 :          32 :   gcc_rich_location richloc (DECL_SOURCE_LOCATION (typedef_decl),
    7814                 :          32 :                              nullptr, highlight_color);
    7815                 :          32 :   pp_element_quoted_decl e_typedef_decl (typedef_decl, highlight_color);
    7816                 :          32 :   inform (&richloc, "%e declared here", &e_typedef_decl);
    7817                 :          32 : }
    7818                 :             : 
    7819                 :             : /* Convert value RHS to type TYPE as preparation for an assignment to
    7820                 :             :    an lvalue of type TYPE.  If ORIGTYPE is not NULL_TREE, it is the
    7821                 :             :    original type of RHS; this differs from TREE_TYPE (RHS) for enum
    7822                 :             :    types.  NULL_POINTER_CONSTANT says whether RHS was a null pointer
    7823                 :             :    constant before any folding.
    7824                 :             :    The real work of conversion is done by `convert'.
    7825                 :             :    The purpose of this function is to generate error messages
    7826                 :             :    for assignments that are not allowed in C.
    7827                 :             :    ERRTYPE says whether it is argument passing, assignment,
    7828                 :             :    initialization or return.
    7829                 :             : 
    7830                 :             :    In the following example, '~' denotes where EXPR_LOC and '^' where
    7831                 :             :    LOCATION point to:
    7832                 :             : 
    7833                 :             :      f (var);      [ic_argpass]
    7834                 :             :      ^  ~~~
    7835                 :             :      x = var;      [ic_assign]
    7836                 :             :        ^ ~~~;
    7837                 :             :      int x = var;  [ic_init]
    7838                 :             :              ^^^
    7839                 :             :      return x;     [ic_return]
    7840                 :             :             ^
    7841                 :             : 
    7842                 :             :    FUNCTION is a tree for the function being called.
    7843                 :             :    PARMNUM is the number of the argument, for printing in error messages.
    7844                 :             :    WARNOPT may be set to a warning option to issue the corresponding warning
    7845                 :             :    rather than an error for invalid conversions.  Used for calls to built-in
    7846                 :             :    functions declared without a prototype.  */
    7847                 :             : 
    7848                 :             : static tree
    7849                 :   162673312 : convert_for_assignment (location_t location, location_t expr_loc, tree type,
    7850                 :             :                         tree rhs, tree origtype, enum impl_conv errtype,
    7851                 :             :                         bool null_pointer_constant, tree fundecl,
    7852                 :             :                         tree function, int parmnum, int warnopt /* = 0 */)
    7853                 :             : {
    7854                 :   162673312 :   enum tree_code codel = TREE_CODE (type);
    7855                 :   162673312 :   tree orig_rhs = rhs;
    7856                 :   162673312 :   tree rhstype;
    7857                 :   162673312 :   enum tree_code coder;
    7858                 :   162673312 :   tree rname = NULL_TREE;
    7859                 :   162673312 :   bool objc_ok = false;
    7860                 :             : 
    7861                 :             :   /* Use the expansion point location to handle cases such as user's
    7862                 :             :      function returning a wrong-type macro defined in a system header.  */
    7863                 :   162673312 :   location = expansion_point_location_if_in_system_header (location);
    7864                 :             : 
    7865                 :   162673312 :   if (errtype == ic_argpass)
    7866                 :             :     {
    7867                 :   122285271 :       tree selector;
    7868                 :             :       /* Change pointer to function to the function itself for
    7869                 :             :          diagnostics.  */
    7870                 :   122285271 :       if (TREE_CODE (function) == ADDR_EXPR
    7871                 :   122285271 :           && TREE_CODE (TREE_OPERAND (function, 0)) == FUNCTION_DECL)
    7872                 :           0 :         function = TREE_OPERAND (function, 0);
    7873                 :             : 
    7874                 :             :       /* Handle an ObjC selector specially for diagnostics.  */
    7875                 :   122285271 :       selector = objc_message_selector ();
    7876                 :   122285271 :       rname = function;
    7877                 :   122285271 :       if (selector && parmnum > 2)
    7878                 :             :         {
    7879                 :           0 :           rname = selector;
    7880                 :           0 :           parmnum -= 2;
    7881                 :             :         }
    7882                 :             :     }
    7883                 :             : 
    7884                 :             :   /* This macro is used to emit diagnostics to ensure that all format
    7885                 :             :      strings are complete sentences, visible to gettext and checked at
    7886                 :             :      compile time.  */
    7887                 :             : #define PEDWARN_FOR_ASSIGNMENT(LOCATION, PLOC, OPT, AR, AS, IN, RE)      \
    7888                 :             :   do {                                                                   \
    7889                 :             :     switch (errtype)                                                     \
    7890                 :             :       {                                                                  \
    7891                 :             :       case ic_argpass:                                                   \
    7892                 :             :         {                                                               \
    7893                 :             :           auto_diagnostic_group d;                                              \
    7894                 :             :           if (pedwarn (PLOC, OPT, AR, parmnum, rname))          \
    7895                 :             :             inform_for_arg (fundecl, (PLOC), parmnum, type, rhstype); \
    7896                 :             :         }                                                               \
    7897                 :             :         break;                                                           \
    7898                 :             :       case ic_assign:                                                    \
    7899                 :             :         pedwarn (LOCATION, OPT, AS);                                     \
    7900                 :             :         break;                                                           \
    7901                 :             :       case ic_init:                                                      \
    7902                 :             :       case ic_init_const:                                                \
    7903                 :             :         pedwarn_init (LOCATION, OPT, IN);                                \
    7904                 :             :         break;                                                           \
    7905                 :             :       case ic_return:                                                    \
    7906                 :             :         pedwarn (LOCATION, OPT, RE);                                     \
    7907                 :             :         break;                                                           \
    7908                 :             :       default:                                                           \
    7909                 :             :         gcc_unreachable ();                                              \
    7910                 :             :       }                                                                  \
    7911                 :             :   } while (0)
    7912                 :             : 
    7913                 :             :   /* This macro is used to emit diagnostics to ensure that all format
    7914                 :             :      strings are complete sentences, visible to gettext and checked at
    7915                 :             :      compile time.  It can be called with 'pedwarn' or 'warning_at'.  */
    7916                 :             : #define WARNING_FOR_QUALIFIERS(PEDWARN, LOCATION, PLOC, OPT, AR, AS, IN, RE, QUALS) \
    7917                 :             :   do {                                                                   \
    7918                 :             :     switch (errtype)                                                     \
    7919                 :             :       {                                                                  \
    7920                 :             :       case ic_argpass:                                                   \
    7921                 :             :         {                                                                \
    7922                 :             :           auto_diagnostic_group d;                                       \
    7923                 :             :           if (PEDWARN) {                                                 \
    7924                 :             :             if (pedwarn (PLOC, OPT, AR, parmnum, rname, QUALS))          \
    7925                 :             :               inform_for_arg (fundecl, (PLOC), parmnum, type, rhstype);  \
    7926                 :             :           } else {                                                       \
    7927                 :             :             if (warning_at (PLOC, OPT, AR, parmnum, rname, QUALS))       \
    7928                 :             :               inform_for_arg (fundecl, (PLOC), parmnum, type, rhstype);  \
    7929                 :             :           }                                                              \
    7930                 :             :         }                                                                \
    7931                 :             :         break;                                                           \
    7932                 :             :       case ic_assign:                                                    \
    7933                 :             :         if (PEDWARN)                                                     \
    7934                 :             :           pedwarn (LOCATION, OPT, AS, QUALS);                            \
    7935                 :             :         else                                                             \
    7936                 :             :           warning_at (LOCATION, OPT, AS, QUALS);                         \
    7937                 :             :         break;                                                           \
    7938                 :             :       case ic_init:                                                      \
    7939                 :             :       case ic_init_const:                                                \
    7940                 :             :         if (PEDWARN)                                                     \
    7941                 :             :           pedwarn (LOCATION, OPT, IN, QUALS);                            \
    7942                 :             :         else                                                             \
    7943                 :             :           warning_at (LOCATION, OPT, IN, QUALS);                         \
    7944                 :             :         break;                                                           \
    7945                 :             :       case ic_return:                                                    \
    7946                 :             :         if (PEDWARN)                                                     \
    7947                 :             :           pedwarn (LOCATION, OPT, RE, QUALS);                            \
    7948                 :             :         else                                                             \
    7949                 :             :           warning_at (LOCATION, OPT, RE, QUALS);                         \
    7950                 :             :         break;                                                           \
    7951                 :             :       default:                                                           \
    7952                 :             :         gcc_unreachable ();                                              \
    7953                 :             :       }                                                                  \
    7954                 :             :   } while (0)
    7955                 :             : 
    7956                 :             :   /* This macro is used to emit diagnostics to ensure that all format
    7957                 :             :      strings are complete sentences, visible to gettext and checked at
    7958                 :             :      compile time.  It is the same as PEDWARN_FOR_ASSIGNMENT but with an
    7959                 :             :      extra parameter to enumerate qualifiers.  */
    7960                 :             : #define PEDWARN_FOR_QUALIFIERS(LOCATION, PLOC, OPT, AR, AS, IN, RE, QUALS) \
    7961                 :             :    WARNING_FOR_QUALIFIERS (true, LOCATION, PLOC, OPT, AR, AS, IN, RE, QUALS)
    7962                 :             : 
    7963                 :             : 
    7964                 :   162673312 :   if (TREE_CODE (rhs) == EXCESS_PRECISION_EXPR)
    7965                 :        5963 :     rhs = TREE_OPERAND (rhs, 0);
    7966                 :             : 
    7967                 :   162673312 :   rhstype = TREE_TYPE (rhs);
    7968                 :   162673312 :   coder = TREE_CODE (rhstype);
    7969                 :             : 
    7970                 :   162673312 :   if (coder == ERROR_MARK)
    7971                 :         347 :     return error_mark_node;
    7972                 :             : 
    7973                 :   162672965 :   if (c_dialect_objc ())
    7974                 :             :     {
    7975                 :           0 :       int parmno;
    7976                 :             : 
    7977                 :           0 :       switch (errtype)
    7978                 :             :         {
    7979                 :             :         case ic_return:
    7980                 :             :           parmno = 0;
    7981                 :             :           break;
    7982                 :             : 
    7983                 :             :         case ic_assign:
    7984                 :             :           parmno = -1;
    7985                 :             :           break;
    7986                 :             : 
    7987                 :             :         case ic_init:
    7988                 :             :         case ic_init_const:
    7989                 :             :           parmno = -2;
    7990                 :             :           break;
    7991                 :             : 
    7992                 :             :         default:
    7993                 :           0 :           parmno = parmnum;
    7994                 :             :           break;
    7995                 :             :         }
    7996                 :             : 
    7997                 :           0 :       objc_ok = objc_compare_types (type, rhstype, parmno, rname);
    7998                 :             :     }
    7999                 :             : 
    8000                 :   162672965 :   if (warn_cxx_compat)
    8001                 :             :     {
    8002                 :       28622 :       tree checktype = origtype != NULL_TREE ? origtype : rhstype;
    8003                 :       28622 :       if (checktype != error_mark_node
    8004                 :       28622 :           && TREE_CODE (type) == ENUMERAL_TYPE
    8005                 :       28728 :           && TYPE_MAIN_VARIANT (checktype) != TYPE_MAIN_VARIANT (type))
    8006                 :          45 :         switch (errtype)
    8007                 :             :           {
    8008                 :           8 :           case ic_argpass:
    8009                 :           8 :             if (pedwarn (expr_loc, OPT_Wc___compat, "enum conversion when "
    8010                 :             :                          "passing argument %d of %qE is invalid in C++",
    8011                 :             :                          parmnum, rname))
    8012                 :          16 :               inform ((fundecl && !DECL_IS_UNDECLARED_BUILTIN (fundecl))
    8013                 :           8 :                       ? DECL_SOURCE_LOCATION (fundecl) : expr_loc,
    8014                 :             :                       "expected %qT but argument is of type %qT",
    8015                 :             :                       type, rhstype);
    8016                 :             :             break;
    8017                 :          10 :           case ic_assign:
    8018                 :          10 :             pedwarn (location, OPT_Wc___compat, "enum conversion from %qT to "
    8019                 :             :                      "%qT in assignment is invalid in C++", rhstype, type);
    8020                 :          10 :             break;
    8021                 :          18 :           case ic_init:
    8022                 :          18 :           case ic_init_const:
    8023                 :          18 :             pedwarn_init (location, OPT_Wc___compat, "enum conversion from "
    8024                 :             :                           "%qT to %qT in initialization is invalid in C++",
    8025                 :             :                           rhstype, type);
    8026                 :          18 :             break;
    8027                 :           9 :           case ic_return:
    8028                 :           9 :             pedwarn (location, OPT_Wc___compat, "enum conversion from %qT to "
    8029                 :             :                      "%qT in return is invalid in C++", rhstype, type);
    8030                 :           9 :             break;
    8031                 :           0 :           default:
    8032                 :           0 :             gcc_unreachable ();
    8033                 :             :           }
    8034                 :             :     }
    8035                 :             : 
    8036                 :   162672965 :   if (warn_enum_conversion)
    8037                 :             :     {
    8038                 :    14563737 :       tree checktype = origtype != NULL_TREE ? origtype : rhstype;
    8039                 :    14563737 :       if (checktype != error_mark_node
    8040                 :    14563737 :           && TREE_CODE (checktype) == ENUMERAL_TYPE
    8041                 :       12661 :           && TREE_CODE (type) == ENUMERAL_TYPE
    8042                 :    14571913 :           && !comptypes (TYPE_MAIN_VARIANT (checktype), TYPE_MAIN_VARIANT (type)))
    8043                 :             :        {
    8044                 :           3 :           gcc_rich_location loc (location);
    8045                 :           3 :           warning_at (&loc, OPT_Wenum_conversion,
    8046                 :             :                       "implicit conversion from %qT to %qT",
    8047                 :             :                       checktype, type);
    8048                 :           3 :        }
    8049                 :             :     }
    8050                 :             : 
    8051                 :   162672965 :   if (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (rhstype))
    8052                 :             :     {
    8053                 :   144027520 :       warn_for_address_of_packed_member (type, orig_rhs);
    8054                 :   144027520 :       if (type != rhstype)
    8055                 :             :         /* Convert RHS to TYPE in order to not lose TYPE in diagnostics.  */
    8056                 :    35890189 :         rhs = convert (type, rhs);
    8057                 :   144027520 :       return rhs;
    8058                 :             :     }
    8059                 :             : 
    8060                 :    18645445 :   if (coder == VOID_TYPE)
    8061                 :             :     {
    8062                 :             :       /* Except for passing an argument to an unprototyped function,
    8063                 :             :          this is a constraint violation.  When passing an argument to
    8064                 :             :          an unprototyped function, it is compile-time undefined;
    8065                 :             :          making it a constraint in that case was rejected in
    8066                 :             :          DR#252.  */
    8067                 :           8 :       const char msg[] = "void value not ignored as it ought to be";
    8068                 :           8 :       if (warnopt)
    8069                 :           0 :         warning_at (location, warnopt, msg);
    8070                 :             :       else
    8071                 :           8 :         error_at (location, msg);
    8072                 :           8 :       return error_mark_node;
    8073                 :             :     }
    8074                 :    18645437 :   rhs = require_complete_type (location, rhs);
    8075                 :    18645437 :   if (rhs == error_mark_node)
    8076                 :             :     return error_mark_node;
    8077                 :             : 
    8078                 :    18645437 :   if (coder == POINTER_TYPE && reject_gcc_builtin (rhs))
    8079                 :           6 :     return error_mark_node;
    8080                 :             : 
    8081                 :             :   /* A non-reference type can convert to a reference.  This handles
    8082                 :             :      va_start, va_copy and possibly port built-ins.  */
    8083                 :    18645431 :   if (codel == REFERENCE_TYPE && coder != REFERENCE_TYPE)
    8084                 :             :     {
    8085                 :         270 :       if (!lvalue_p (rhs))
    8086                 :             :         {
    8087                 :           0 :           const char msg[] = "cannot pass rvalue to reference parameter";
    8088                 :           0 :           if (warnopt)
    8089                 :           0 :             warning_at (location, warnopt, msg);
    8090                 :             :           else
    8091                 :           0 :             error_at (location, msg);
    8092                 :           0 :           return error_mark_node;
    8093                 :             :         }
    8094                 :         270 :       if (!c_mark_addressable (rhs))
    8095                 :           0 :         return error_mark_node;
    8096                 :         270 :       rhs = build1 (ADDR_EXPR, c_build_pointer_type (TREE_TYPE (rhs)), rhs);
    8097                 :         270 :       SET_EXPR_LOCATION (rhs, location);
    8098                 :             : 
    8099                 :         270 :       rhs = convert_for_assignment (location, expr_loc,
    8100                 :         270 :                                     c_build_pointer_type (TREE_TYPE (type)),
    8101                 :             :                                     rhs, origtype, errtype,
    8102                 :             :                                     null_pointer_constant, fundecl, function,
    8103                 :             :                                     parmnum, warnopt);
    8104                 :         270 :       if (rhs == error_mark_node)
    8105                 :             :         return error_mark_node;
    8106                 :             : 
    8107                 :         270 :       rhs = build1 (NOP_EXPR, type, rhs);
    8108                 :         270 :       SET_EXPR_LOCATION (rhs, location);
    8109                 :         270 :       return rhs;
    8110                 :             :     }
    8111                 :             :   /* Some types can interconvert without explicit casts.  */
    8112                 :    18645161 :   else if (codel == VECTOR_TYPE && coder == VECTOR_TYPE
    8113                 :    18645161 :            && vector_types_convertible_p (type, TREE_TYPE (rhs), true))
    8114                 :     9048738 :     return convert (type, rhs);
    8115                 :             :   /* Arithmetic types all interconvert, and enum is treated like int.  */
    8116                 :     9596423 :   else if ((codel == INTEGER_TYPE || codel == REAL_TYPE
    8117                 :     2230459 :             || codel == FIXED_POINT_TYPE
    8118                 :     2230459 :             || codel == ENUMERAL_TYPE || codel == COMPLEX_TYPE
    8119                 :     2148446 :             || codel == BOOLEAN_TYPE || codel == BITINT_TYPE)
    8120                 :     7539017 :            && (coder == INTEGER_TYPE || coder == REAL_TYPE
    8121                 :       79476 :                || coder == FIXED_POINT_TYPE
    8122                 :       79476 :                || coder == ENUMERAL_TYPE || coder == COMPLEX_TYPE
    8123                 :       37507 :                || coder == BOOLEAN_TYPE || coder == BITINT_TYPE))
    8124                 :             :     {
    8125                 :     7537900 :       if (warnopt && errtype == ic_argpass)
    8126                 :         418 :         maybe_warn_builtin_no_proto_arg (expr_loc, fundecl, parmnum, type,
    8127                 :             :                                          rhstype);
    8128                 :             : 
    8129                 :     7537900 :       bool save = in_late_binary_op;
    8130                 :     7507342 :       if (C_BOOLEAN_TYPE_P (type) || codel == COMPLEX_TYPE
    8131                 :    14996419 :           || (coder == REAL_TYPE
    8132                 :      271380 :               && (codel == INTEGER_TYPE || codel == ENUMERAL_TYPE)
    8133                 :       24096 :               && sanitize_flags_p (SANITIZE_FLOAT_CAST)))
    8134                 :       86125 :         in_late_binary_op = true;
    8135                 :    10845867 :       tree ret = convert_and_check (expr_loc != UNKNOWN_LOCATION
    8136                 :             :                                     ? expr_loc : location, type, orig_rhs,
    8137                 :             :                                     errtype == ic_init_const);
    8138                 :     7537900 :       in_late_binary_op = save;
    8139                 :     7537900 :       return ret;
    8140                 :             :     }
    8141                 :             : 
    8142                 :             :   /* Aggregates in different TUs might need conversion.  */
    8143                 :     2058523 :   if ((codel == RECORD_TYPE || codel == UNION_TYPE)
    8144                 :          95 :       && codel == coder
    8145                 :     2058540 :       && comptypes (TYPE_MAIN_VARIANT (type), TYPE_MAIN_VARIANT (rhstype)))
    8146                 :           6 :     return convert_and_check (expr_loc != UNKNOWN_LOCATION
    8147                 :           6 :                               ? expr_loc : location, type, rhs);
    8148                 :             : 
    8149                 :             :   /* Conversion to a transparent union or record from its member types.
    8150                 :             :      This applies only to function arguments.  */
    8151                 :     2058517 :   if (((codel == UNION_TYPE || codel == RECORD_TYPE)
    8152                 :          89 :       && TYPE_TRANSPARENT_AGGR (type))
    8153                 :     2058555 :       && errtype == ic_argpass)
    8154                 :             :     {
    8155                 :          38 :       tree memb, marginal_memb = NULL_TREE;
    8156                 :             : 
    8157                 :          48 :       for (memb = TYPE_FIELDS (type); memb ; memb = DECL_CHAIN (memb))
    8158                 :             :         {
    8159                 :          48 :           tree memb_type = TREE_TYPE (memb);
    8160                 :             : 
    8161                 :          48 :           if (comptypes (TYPE_MAIN_VARIANT (memb_type),
    8162                 :          48 :                          TYPE_MAIN_VARIANT (rhstype)))
    8163                 :             :             break;
    8164                 :             : 
    8165                 :          26 :           if (TREE_CODE (memb_type) != POINTER_TYPE)
    8166                 :           0 :             continue;
    8167                 :             : 
    8168                 :          26 :           if (coder == POINTER_TYPE)
    8169                 :             :             {
    8170                 :          26 :               tree ttl = TREE_TYPE (memb_type);
    8171                 :          26 :               tree ttr = TREE_TYPE (rhstype);
    8172                 :             : 
    8173                 :             :               /* Any non-function converts to a [const][volatile] void *
    8174                 :             :                  and vice versa; otherwise, targets must be the same.
    8175                 :             :                  Meanwhile, the lhs target must have all the qualifiers of
    8176                 :             :                  the rhs.  */
    8177                 :           0 :               if ((VOID_TYPE_P (ttl) && !TYPE_ATOMIC (ttl))
    8178                 :          26 :                   || (VOID_TYPE_P (ttr) && !TYPE_ATOMIC (ttr))
    8179                 :          45 :                   || comp_target_types (location, memb_type, rhstype))
    8180                 :             :                 {
    8181                 :          16 :                   int lquals = TYPE_QUALS (ttl) & ~TYPE_QUAL_ATOMIC;
    8182                 :          16 :                   int rquals = TYPE_QUALS (ttr) & ~TYPE_QUAL_ATOMIC;
    8183                 :             :                   /* If this type won't generate any warnings, use it.  */
    8184                 :          16 :                   if (lquals == rquals
    8185                 :          16 :                       || ((TREE_CODE (ttr) == FUNCTION_TYPE
    8186                 :           0 :                            && TREE_CODE (ttl) == FUNCTION_TYPE)
    8187                 :           0 :                           ? ((lquals | rquals) == rquals)
    8188                 :          16 :                           : ((lquals | rquals) == lquals)))
    8189                 :             :                     break;
    8190                 :             : 
    8191                 :             :                   /* Keep looking for a better type, but remember this one.  */
    8192                 :           0 :                   if (!marginal_memb)
    8193                 :          10 :                     marginal_memb = memb;
    8194                 :             :                 }
    8195                 :             :             }
    8196                 :             : 
    8197                 :             :           /* Can convert integer zero to any pointer type.  */
    8198                 :          10 :           if (null_pointer_constant)
    8199                 :             :             {
    8200                 :           0 :               rhs = null_pointer_node;
    8201                 :           0 :               break;
    8202                 :             :             }
    8203                 :             :         }
    8204                 :             : 
    8205                 :          38 :       if (memb || marginal_memb)
    8206                 :             :         {
    8207                 :          38 :           if (!memb)
    8208                 :             :             {
    8209                 :             :               /* We have only a marginally acceptable member type;
    8210                 :             :                  it needs a warning.  */
    8211                 :           0 :               tree ttl = TREE_TYPE (TREE_TYPE (marginal_memb));
    8212                 :           0 :               tree ttr = TREE_TYPE (rhstype);
    8213                 :             : 
    8214                 :             :               /* Const and volatile mean something different for function
    8215                 :             :                  types, so the usual warnings are not appropriate.  */
    8216                 :           0 :               if (TREE_CODE (ttr) == FUNCTION_TYPE
    8217                 :           0 :                   && TREE_CODE (ttl) == FUNCTION_TYPE)
    8218                 :             :                 {
    8219                 :             :                   /* Because const and volatile on functions are
    8220                 :             :                      restrictions that say the function will not do
    8221                 :             :                      certain things, it is okay to use a const or volatile
    8222                 :             :                      function where an ordinary one is wanted, but not
    8223                 :             :                      vice-versa.  */
    8224                 :           0 :                   if (TYPE_QUALS_NO_ADDR_SPACE (ttl)
    8225                 :           0 :                       & ~TYPE_QUALS_NO_ADDR_SPACE (ttr))
    8226                 :           0 :                     PEDWARN_FOR_QUALIFIERS (location, expr_loc,
    8227                 :             :                                             OPT_Wdiscarded_qualifiers,
    8228                 :             :                                             G_("passing argument %d of %qE "
    8229                 :             :                                                "makes %q#v qualified function "
    8230                 :             :                                                "pointer from unqualified"),
    8231                 :             :                                             G_("assignment makes %q#v qualified "
    8232                 :             :                                                "function pointer from "
    8233                 :             :                                                "unqualified"),
    8234                 :             :                                             G_("initialization makes %q#v qualified "
    8235                 :             :                                                "function pointer from "
    8236                 :             :                                                "unqualified"),
    8237                 :             :                                             G_("return makes %q#v qualified function "
    8238                 :             :                                                "pointer from unqualified"),
    8239                 :             :                                             TYPE_QUALS (ttl) & ~TYPE_QUALS (ttr));
    8240                 :             :                 }
    8241                 :           0 :               else if (TYPE_QUALS_NO_ADDR_SPACE (ttr)
    8242                 :           0 :                        & ~TYPE_QUALS_NO_ADDR_SPACE (ttl))
    8243                 :           0 :                 PEDWARN_FOR_QUALIFIERS (location, expr_loc,
    8244                 :             :                                         OPT_Wdiscarded_qualifiers,
    8245                 :             :                                         G_("passing argument %d of %qE discards "
    8246                 :             :                                            "%qv qualifier from pointer target type"),
    8247                 :             :                                         G_("assignment discards %qv qualifier "
    8248                 :             :                                            "from pointer target type"),
    8249                 :             :                                         G_("initialization discards %qv qualifier "
    8250                 :             :                                            "from pointer target type"),
    8251                 :             :                                         G_("return discards %qv qualifier from "
    8252                 :             :                                            "pointer target type"),
    8253                 :             :                                         TYPE_QUALS (ttr) & ~TYPE_QUALS (ttl));
    8254                 :             : 
    8255                 :             :               memb = marginal_memb;
    8256                 :             :             }
    8257                 :             : 
    8258                 :          38 :           if (!fundecl || !DECL_IN_SYSTEM_HEADER (fundecl))
    8259                 :          30 :             pedwarn (location, OPT_Wpedantic,
    8260                 :             :                      "ISO C prohibits argument conversion to union type");
    8261                 :             : 
    8262                 :          38 :           rhs = fold_convert_loc (location, TREE_TYPE (memb), rhs);
    8263                 :          38 :           return build_constructor_single (type, memb, rhs);
    8264                 :             :         }
    8265                 :             :     }
    8266                 :             : 
    8267                 :             :   /* Conversions among pointers */
    8268                 :     2058479 :   else if ((codel == POINTER_TYPE || codel == REFERENCE_TYPE)
    8269                 :     2057213 :            && (coder == codel))
    8270                 :             :     {
    8271                 :             :       /* If RHS refers to a built-in declared without a prototype
    8272                 :             :          BLTIN is the declaration of the built-in with a prototype
    8273                 :             :          and RHSTYPE is set to the actual type of the built-in.  */
    8274                 :     1979726 :       tree bltin;
    8275                 :     1979726 :       rhstype = type_or_builtin_type (rhs, &bltin);
    8276                 :             : 
    8277                 :     1979726 :       tree ttl = TREE_TYPE (type);
    8278                 :     1979726 :       tree ttr = TREE_TYPE (rhstype);
    8279                 :     1979726 :       bool is_opaque_pointer;
    8280                 :     1979726 :       bool target_cmp = false;   /* Cache comp_target_types () result.  */
    8281                 :     1979726 :       addr_space_t asl;
    8282                 :     1979726 :       addr_space_t asr;
    8283                 :             : 
    8284                 :     1979726 :       tree mvl = remove_qualifiers (ttl);
    8285                 :     1979726 :       tree mvr = remove_qualifiers (ttr);
    8286                 :             : 
    8287                 :             :       /* Opaque pointers are treated like void pointers.  */
    8288                 :     1979726 :       is_opaque_pointer = vector_targets_convertible_p (ttl, ttr);
    8289                 :             : 
    8290                 :             :       /* The Plan 9 compiler permits a pointer to a struct to be
    8291                 :             :          automatically converted into a pointer to an anonymous field
    8292                 :             :          within the struct.  */
    8293                 :     1979726 :       if (flag_plan9_extensions
    8294                 :          10 :           && RECORD_OR_UNION_TYPE_P (mvl)
    8295                 :          10 :           && RECORD_OR_UNION_TYPE_P (mvr)
    8296                 :          10 :           && mvl != mvr)
    8297                 :             :         {
    8298                 :          10 :           tree new_rhs = convert_to_anonymous_field (location, type, rhs);
    8299                 :          10 :           if (new_rhs != NULL_TREE)
    8300                 :             :             {
    8301                 :           6 :               rhs = new_rhs;
    8302                 :           6 :               rhstype = TREE_TYPE (rhs);
    8303                 :           6 :               coder = TREE_CODE (rhstype);
    8304                 :           6 :               ttr = TREE_TYPE (rhstype);
    8305                 :           6 :               mvr = TYPE_MAIN_VARIANT (ttr);
    8306                 :             :             }
    8307                 :             :         }
    8308                 :             : 
    8309                 :             :       /* C++ does not allow the implicit conversion void* -> T*.  However,
    8310                 :             :          for the purpose of reducing the number of false positives, we
    8311                 :             :          tolerate the special case of
    8312                 :             : 
    8313                 :             :                 int *p = NULL;
    8314                 :             : 
    8315                 :             :          where NULL is typically defined in C to be '(void *) 0'.  */
    8316                 :     1979726 :       if (VOID_TYPE_P (ttr) && rhs != null_pointer_node && !VOID_TYPE_P (ttl))
    8317                 :       26377 :         warning_at (errtype == ic_argpass ? expr_loc : location,
    8318                 :       13972 :                     OPT_Wc___compat,
    8319                 :             :                     "request for implicit conversion "
    8320                 :             :                     "from %qT to %qT not permitted in C++", rhstype, type);
    8321                 :             : 
    8322                 :             :       /* Warn of new allocations that are not big enough for the target
    8323                 :             :          type.  */
    8324                 :     1979726 :       if (warn_alloc_size && TREE_CODE (rhs) == CALL_EXPR)
    8325                 :        5455 :         if (tree fndecl = get_callee_fndecl (rhs))
    8326                 :        5455 :           if (DECL_IS_MALLOC (fndecl))
    8327                 :             :             {
    8328                 :        4601 :               tree attrs = TYPE_ATTRIBUTES (TREE_TYPE (fndecl));
    8329                 :        4601 :               tree alloc_size = lookup_attribute ("alloc_size", attrs);
    8330                 :        4601 :               if (alloc_size)
    8331                 :         447 :                 warn_for_alloc_size (location, ttl, rhs, alloc_size);
    8332                 :             :             }
    8333                 :             : 
    8334                 :             :       /* See if the pointers point to incompatible address spaces.  */
    8335                 :     1979726 :       asl = TYPE_ADDR_SPACE (ttl);
    8336                 :     1979726 :       asr = TYPE_ADDR_SPACE (ttr);
    8337                 :     1979726 :       if (!null_pointer_constant_p (rhs)
    8338                 :     1979726 :           && asr != asl && !targetm.addr_space.subset_p (asr, asl))
    8339                 :             :         {
    8340                 :           3 :           auto_diagnostic_group d;
    8341                 :           3 :           bool diagnosed = true;
    8342                 :           3 :           switch (errtype)
    8343                 :             :             {
    8344                 :           1 :             case ic_argpass:
    8345                 :           1 :               {
    8346                 :           1 :                 const char msg[] = G_("passing argument %d of %qE from "
    8347                 :             :                                       "pointer to non-enclosed address space");
    8348                 :           1 :                 if (warnopt)
    8349                 :           0 :                   diagnosed
    8350                 :           0 :                     = warning_at (expr_loc, warnopt, msg, parmnum, rname);
    8351                 :             :                 else
    8352                 :           1 :                   error_at (expr_loc, msg, parmnum, rname);
    8353                 :           0 :               break;
    8354                 :             :               }
    8355                 :           0 :             case ic_assign:
    8356                 :           0 :               {
    8357                 :           0 :                 const char msg[] = G_("assignment from pointer to "
    8358                 :             :                                       "non-enclosed address space");
    8359                 :           0 :                 if (warnopt)
    8360                 :           0 :                   diagnosed = warning_at (location, warnopt, msg);
    8361                 :             :                 else
    8362                 :           0 :                   error_at (location, msg);
    8363                 :           0 :                 break;
    8364                 :             :               }
    8365                 :           0 :             case ic_init:
    8366                 :           0 :             case ic_init_const:
    8367                 :           0 :               {
    8368                 :           0 :                 const char msg[] = G_("initialization from pointer to "
    8369                 :             :                                       "non-enclosed address space");
    8370                 :           0 :                 if (warnopt)
    8371                 :           0 :                   diagnosed = warning_at (location, warnopt, msg);
    8372                 :             :                 else
    8373                 :           0 :                   error_at (location, msg);
    8374                 :           0 :                 break;
    8375                 :             :               }
    8376                 :           2 :             case ic_return:
    8377                 :           2 :               {
    8378                 :           2 :                 const char msg[] = G_("return from pointer to "
    8379                 :             :                                       "non-enclosed address space");
    8380                 :           2 :                 if (warnopt)
    8381                 :           0 :                   diagnosed = warning_at (location, warnopt, msg);
    8382                 :             :                 else
    8383                 :           2 :                   error_at (location, msg);
    8384                 :           0 :                 break;
    8385                 :             :               }
    8386                 :           0 :             default:
    8387                 :           0 :               gcc_unreachable ();
    8388                 :             :             }
    8389                 :           3 :           if (diagnosed)
    8390                 :             :             {
    8391                 :           3 :               if (errtype == ic_argpass)
    8392                 :           1 :                 inform_for_arg (fundecl, expr_loc, parmnum, type, rhstype);
    8393                 :             :               else
    8394                 :           2 :                 inform (location, "expected %qT but pointer is of type %qT",
    8395                 :             :                         type, rhstype);
    8396                 :             :             }
    8397                 :           3 :           return error_mark_node;
    8398                 :           3 :         }
    8399                 :             : 
    8400                 :             :       /* Check if the right-hand side has a format attribute but the
    8401                 :             :          left-hand side doesn't.  */
    8402                 :     1979723 :       if (warn_suggest_attribute_format
    8403                 :     1979723 :           && check_missing_format_attribute (type, rhstype))
    8404                 :             :         {
    8405                 :          16 :           switch (errtype)
    8406                 :             :           {
    8407                 :           4 :           case ic_argpass:
    8408                 :           4 :             warning_at (expr_loc, OPT_Wsuggest_attribute_format,
    8409                 :             :                         "argument %d of %qE might be "
    8410                 :             :                         "a candidate for a format attribute",
    8411                 :             :                         parmnum, rname);
    8412                 :           4 :             break;
    8413                 :           4 :           case ic_assign:
    8414                 :           4 :             warning_at (location, OPT_Wsuggest_attribute_format,
    8415                 :             :                         "assignment left-hand side might be "
    8416                 :             :                         "a candidate for a format attribute");
    8417                 :           4 :             break;
    8418                 :           4 :           case ic_init:
    8419                 :           4 :           case ic_init_const:
    8420                 :           4 :             warning_at (location, OPT_Wsuggest_attribute_format,
    8421                 :             :                         "initialization left-hand side might be "
    8422                 :             :                         "a candidate for a format attribute");
    8423                 :           4 :             break;
    8424                 :           4 :           case ic_return:
    8425                 :           4 :             warning_at (location, OPT_Wsuggest_attribute_format,
    8426                 :             :                         "return type might be "
    8427                 :             :                         "a candidate for a format attribute");
    8428                 :           4 :             break;
    8429                 :           0 :           default:
    8430                 :           0 :             gcc_unreachable ();
    8431                 :             :           }
    8432                 :             :         }
    8433                 :             : 
    8434                 :             :       /* See if the pointers point to incompatible scalar storage orders.  */
    8435                 :     1979723 :       if (warn_scalar_storage_order
    8436                 :     1976807 :           && !null_pointer_constant_p (rhs)
    8437                 :     5868437 :           && (AGGREGATE_TYPE_P (ttl) && TYPE_REVERSE_STORAGE_ORDER (ttl))
    8438                 :     1944357 :              != (AGGREGATE_TYPE_P (ttr) && TYPE_REVERSE_STORAGE_ORDER (ttr)))
    8439                 :             :         {
    8440                 :          18 :           tree t;
    8441                 :             : 
    8442                 :          18 :           switch (errtype)
    8443                 :             :           {
    8444                 :          11 :           case ic_argpass:
    8445                 :             :             /* Do not warn for built-in functions, for example memcpy, since we
    8446                 :             :                control how they behave and they can be useful in this area.  */
    8447                 :          11 :             if (TREE_CODE (rname) != FUNCTION_DECL
    8448                 :          11 :                 || !fndecl_built_in_p (rname))
    8449                 :           1 :               warning_at (location, OPT_Wscalar_storage_order,
    8450                 :             :                           "passing argument %d of %qE from incompatible "
    8451                 :             :                           "scalar storage order", parmnum, rname);
    8452                 :             :             break;
    8453                 :           3 :           case ic_assign:
    8454                 :             :             /* Do not warn if the RHS is a call to a function that returns a
    8455                 :             :                pointer that is not an alias.  */
    8456                 :           3 :             if (TREE_CODE (rhs) != CALL_EXPR
    8457                 :           2 :                 || (t = get_callee_fndecl (rhs)) == NULL_TREE
    8458                 :           5 :                 || !DECL_IS_MALLOC (t))
    8459                 :           1 :               warning_at (location, OPT_Wscalar_storage_order,
    8460                 :             :                           "assignment to %qT from pointer type %qT with "
    8461                 :             :                           "incompatible scalar storage order", type, rhstype);
    8462                 :             :             break;
    8463                 :           3 :           case ic_init:
    8464                 :           3 :           case ic_init_const:
    8465                 :             :             /* Likewise.  */
    8466                 :           3 :             if (TREE_CODE (rhs) != CALL_EXPR
    8467                 :           2 :                 || (t = get_callee_fndecl (rhs)) == NULL_TREE
    8468                 :           5 :                 || !DECL_IS_MALLOC (t))
    8469                 :           1 :               warning_at (location, OPT_Wscalar_storage_order,
    8470                 :             :                           "initialization of %qT from pointer type %qT with "
    8471                 :             :                           "incompatible scalar storage order", type, rhstype);
    8472                 :             :             break;
    8473                 :           1 :           case ic_return:
    8474                 :           1 :             warning_at (location, OPT_Wscalar_storage_order,
    8475                 :             :                         "returning %qT from pointer type with incompatible "
    8476                 :             :                         "scalar storage order %qT", rhstype, type);
    8477                 :           1 :             break;
    8478                 :           0 :           default:
    8479                 :           0 :             gcc_unreachable ();
    8480                 :             :           }
    8481                 :             :         }
    8482                 :             : 
    8483                 :             :       /* Any non-function converts to a [const][volatile] void *
    8484                 :             :          and vice versa; otherwise, targets must be the same.
    8485                 :             :          Meanwhile, the lhs target must have all the qualifiers of the rhs.  */
    8486                 :      418467 :       if ((VOID_TYPE_P (ttl) && !TYPE_ATOMIC (ttl))
    8487                 :     1561257 :           || (VOID_TYPE_P (ttr) && !TYPE_ATOMIC (ttr))
    8488                 :     1514965 :           || (target_cmp = comp_target_types (location, type, rhstype))
    8489                 :        2005 :           || is_opaque_pointer
    8490                 :     1983733 :           || ((c_common_unsigned_type (mvl)
    8491                 :        2005 :                == c_common_unsigned_type (mvr))
    8492                 :        2462 :               && (c_common_signed_type (mvl)
    8493                 :        1231 :                   == c_common_signed_type (mvr))
    8494                 :        1216 :               && TYPE_ATOMIC (mvl) == TYPE_ATOMIC (mvr)))
    8495                 :             :         {
    8496                 :             :           /* Warn about loss of qualifers from pointers to arrays with
    8497                 :             :              qualifiers on the element type. */
    8498                 :     1978926 :           if (TREE_CODE (ttr) == ARRAY_TYPE)
    8499                 :             :             {
    8500                 :        2089 :               ttr = strip_array_types (ttr);
    8501                 :        2089 :               ttl = strip_array_types (ttl);
    8502                 :             : 
    8503                 :        2089 :               if (TYPE_QUALS_NO_ADDR_SPACE_NO_ATOMIC (ttr)
    8504                 :        2089 :                   & ~TYPE_QUALS_NO_ADDR_SPACE_NO_ATOMIC (ttl))
    8505                 :         115 :                 WARNING_FOR_QUALIFIERS (flag_isoc23,
    8506                 :             :                                         location, expr_loc,
    8507                 :             :                                         OPT_Wdiscarded_array_qualifiers,
    8508                 :             :                                         G_("passing argument %d of %qE discards "
    8509                 :             :                                            "%qv qualifier from pointer target type"),
    8510                 :             :                                         G_("assignment discards %qv qualifier "
    8511                 :             :                                            "from pointer target type"),
    8512                 :             :                                         G_("initialization discards %qv qualifier "
    8513                 :             :                                            "from pointer target type"),
    8514                 :             :                                         G_("return discards %qv qualifier from "
    8515                 :             :                                            "pointer target type"),
    8516                 :             :                                         TYPE_QUALS (ttr) & ~TYPE_QUALS (ttl));
    8517                 :             :             }
    8518                 :     1976837 :           else if (pedantic
    8519                 :      146033 :               && ((VOID_TYPE_P (ttl) && TREE_CODE (ttr) == FUNCTION_TYPE)
    8520                 :      146013 :                   ||
    8521                 :             :                   (VOID_TYPE_P (ttr)
    8522                 :        2952 :                    && !null_pointer_constant
    8523                 :         178 :                    && TREE_CODE (ttl) == FUNCTION_TYPE)))
    8524                 :          34 :             PEDWARN_FOR_ASSIGNMENT (location, expr_loc, OPT_Wpedantic,
    8525                 :             :                                     G_("ISO C forbids passing argument %d of "
    8526                 :             :                                        "%qE between function pointer "
    8527                 :             :                                        "and %<void *%>"),
    8528                 :             :                                     G_("ISO C forbids assignment between "
    8529                 :             :                                        "function pointer and %<void *%>"),
    8530                 :             :                                     G_("ISO C forbids initialization between "
    8531                 :             :                                        "function pointer and %<void *%>"),
    8532                 :             :                                     G_("ISO C forbids return between function "
    8533                 :             :                                        "pointer and %<void *%>"));
    8534                 :             :           /* Const and volatile mean something different for function types,
    8535                 :             :              so the usual warnings are not appropriate.  */
    8536                 :     1976803 :           else if (TREE_CODE (ttr) != FUNCTION_TYPE
    8537                 :     1944391 :                    && TREE_CODE (ttl) != FUNCTION_TYPE)
    8538                 :             :             {
    8539                 :             :                /* Assignments between atomic and non-atomic objects are OK.  */
    8540                 :     1943726 :                bool warn_quals_ped = TYPE_QUALS_NO_ADDR_SPACE_NO_ATOMIC (ttr)
    8541                 :     1943726 :                                      & ~TYPE_QUALS_NO_ADDR_SPACE_NO_ATOMIC (ttl);
    8542                 :     1943726 :                bool warn_quals = TYPE_QUALS_NO_ADDR_SPACE_NO_ATOMIC (ttr)
    8543                 :     1943726 :                                  & ~TYPE_QUALS_NO_ADDR_SPACE_NO_ATOMIC (strip_array_types (ttl));
    8544                 :             : 
    8545                 :             :               /* Don't warn about loss of qualifier for conversions from
    8546                 :             :                  qualified void* to pointers to arrays with corresponding
    8547                 :             :                  qualifier on the element type (except for pedantic before C23). */
    8548                 :     1943726 :               if (warn_quals || (warn_quals_ped && pedantic && !flag_isoc23))
    8549                 :         697 :                 PEDWARN_FOR_QUALIFIERS (location, expr_loc,
    8550                 :             :                                         OPT_Wdiscarded_qualifiers,
    8551                 :             :                                         G_("passing argument %d of %qE discards "
    8552                 :             :                                            "%qv qualifier from pointer target type"),
    8553                 :             :                                         G_("assignment discards %qv qualifier "
    8554                 :             :                                            "from pointer target type"),
    8555                 :             :                                         G_("initialization discards %qv qualifier "
    8556                 :             :                                            "from pointer target type"),
    8557                 :             :                                         G_("return discards %qv qualifier from "
    8558                 :             :                                            "pointer target type"),
    8559                 :             :                                         TYPE_QUALS (ttr) & ~TYPE_QUALS (ttl));
    8560                 :          11 :               else if (warn_quals_ped)
    8561                 :          11 :                 pedwarn_c11 (location, OPT_Wc11_c23_compat,
    8562                 :             :                              "array with qualifier on the element is not qualified before C23");
    8563                 :             : 
    8564                 :             :               /* If this is not a case of ignoring a mismatch in signedness,
    8565                 :             :                  no warning.  */
    8566                 :     1943018 :               else if (VOID_TYPE_P (ttl) || VOID_TYPE_P (ttr)
    8567                 :     1510063 :                        || target_cmp)
    8568                 :             :                 ;
    8569                 :             :               /* If there is a mismatch, do warn.  */
    8570                 :        1208 :               else if (warn_pointer_sign)
    8571                 :          82 :                 switch (errtype)
    8572                 :             :                   {
    8573                 :          33 :                   case ic_argpass:
    8574                 :          33 :                     {
    8575                 :          33 :                       auto_diagnostic_group d;
    8576                 :          33 :                       range_label_for_type_mismatch rhs_label (rhstype, type);
    8577                 :          33 :                       gcc_rich_location richloc (expr_loc, &rhs_label,
    8578                 :          33 :                                                  highlight_colors::actual);
    8579                 :          33 :                       if (pedwarn (&richloc, OPT_Wpointer_sign,
    8580                 :             :                                    "pointer targets in passing argument %d of "
    8581                 :             :                                    "%qE differ in signedness", parmnum, rname))
    8582                 :          33 :                         inform_for_arg (fundecl, expr_loc, parmnum, type,
    8583                 :             :                                         rhstype);
    8584                 :          33 :                     }
    8585                 :          33 :                     break;
    8586                 :          21 :                   case ic_assign:
    8587                 :          21 :                     pedwarn (location, OPT_Wpointer_sign,
    8588                 :             :                              "pointer targets in assignment from %qT to %qT "
    8589                 :             :                              "differ in signedness", rhstype, type);
    8590                 :          21 :                     break;
    8591                 :          14 :                   case ic_init:
    8592                 :          14 :                   case ic_init_const:
    8593                 :          14 :                     pedwarn_init (location, OPT_Wpointer_sign,
    8594                 :             :                                   "pointer targets in initialization of %qT "
    8595                 :             :                                   "from %qT differ in signedness", type,
    8596                 :             :                                   rhstype);
    8597                 :          14 :                     break;
    8598                 :          14 :                   case ic_return:
    8599                 :          14 :                     pedwarn (location, OPT_Wpointer_sign, "pointer targets in "
    8600                 :             :                              "returning %qT from a function with return type "
    8601                 :             :                              "%qT differ in signedness", rhstype, type);
    8602                 :          14 :                     break;
    8603                 :           0 :                   default:
    8604                 :           0 :                     gcc_unreachable ();
    8605                 :             :                   }
    8606                 :             :             }
    8607                 :       33077 :           else if (TREE_CODE (ttl) == FUNCTION_TYPE
    8608                 :        4116 :                    && TREE_CODE (ttr) == FUNCTION_TYPE)
    8609                 :             :             {
    8610                 :             :               /* Because const and volatile on functions are restrictions
    8611                 :             :                  that say the function will not do certain things,
    8612                 :             :                  it is okay to use a const or volatile function
    8613                 :             :                  where an ordinary one is wanted, but not vice-versa.  */
    8614                 :        3451 :               if (TYPE_QUALS_NO_ADDR_SPACE (ttl)
    8615                 :        3451 :                   & ~TYPE_QUALS_NO_ADDR_SPACE (ttr))
    8616                 :          18 :                 PEDWARN_FOR_QUALIFIERS (location, expr_loc,
    8617                 :             :                                         OPT_Wdiscarded_qualifiers,
    8618                 :             :                                         G_("passing argument %d of %qE makes "
    8619                 :             :                                            "%q#v qualified function pointer "
    8620                 :             :                                            "from unqualified"),
    8621                 :             :                                         G_("assignment makes %q#v qualified function "
    8622                 :             :                                            "pointer from unqualified"),
    8623                 :             :                                         G_("initialization makes %q#v qualified "
    8624                 :             :                                            "function pointer from unqualified"),
    8625                 :             :                                         G_("return makes %q#v qualified function "
    8626                 :             :                                            "pointer from unqualified"),
    8627                 :             :                                         TYPE_QUALS (ttl) & ~TYPE_QUALS (ttr));
    8628                 :             :             }
    8629                 :             :         }
    8630                 :             :       /* Avoid warning about the volatile ObjC EH puts on decls.  */
    8631                 :         797 :       else if (!objc_ok)
    8632                 :             :         {
    8633                 :         797 :           auto_diagnostic_group d;
    8634                 :         797 :           bool warned = false;
    8635                 :         797 :           pp_markup::element_expected_type e_type (type);
    8636                 :         797 :           pp_markup::element_actual_type e_rhstype (rhstype);
    8637                 :         797 :           switch (errtype)
    8638                 :             :             {
    8639                 :         306 :             case ic_argpass:
    8640                 :         306 :               {
    8641                 :         306 :                 range_label_for_type_mismatch rhs_label (rhstype, type);
    8642                 :         306 :                 gcc_rich_location richloc (expr_loc, &rhs_label,
    8643                 :         306 :                                            highlight_colors::actual);
    8644                 :         306 :                 warned
    8645                 :         306 :                   = permerror_opt (&richloc, OPT_Wincompatible_pointer_types,
    8646                 :             :                                    "passing argument %d of %qE from "
    8647                 :             :                                    "incompatible pointer type",
    8648                 :             :                                    parmnum, rname);
    8649                 :         306 :                 if (warned)
    8650                 :         174 :                   inform_for_arg (fundecl, expr_loc, parmnum, type, rhstype);
    8651                 :         306 :               }
    8652                 :         306 :               break;
    8653                 :         267 :             case ic_assign:
    8654                 :         267 :               if (bltin)
    8655                 :          11 :                 warned
    8656                 :          11 :                   = permerror_opt (location, OPT_Wincompatible_pointer_types,
    8657                 :             :                                    "assignment to %e from pointer to "
    8658                 :             :                                    "%qD with incompatible type %e",
    8659                 :             :                                    &e_type, bltin, &e_rhstype);
    8660                 :             :               else
    8661                 :         256 :                 warned
    8662                 :         256 :                   = permerror_opt (location, OPT_Wincompatible_pointer_types,
    8663                 :             :                                    "assignment to %e from incompatible "
    8664                 :             :                                    "pointer type %e",
    8665                 :             :                                    &e_type, &e_rhstype);
    8666                 :             :               break;
    8667                 :         165 :             case ic_init:
    8668                 :         165 :             case ic_init_const:
    8669                 :         165 :               if (bltin)
    8670                 :          13 :                 warned
    8671                 :          13 :                   = permerror_init (location, OPT_Wincompatible_pointer_types,
    8672                 :             :                                     "initialization of %e from pointer to "
    8673                 :             :                                     "%qD with incompatible type %e",
    8674                 :             :                                     &e_type, bltin, &e_rhstype);
    8675                 :             :               else
    8676                 :         152 :                 warned
    8677                 :         152 :                   = permerror_init (location, OPT_Wincompatible_pointer_types,
    8678                 :             :                                     "initialization of %e from incompatible "
    8679                 :             :                                     "pointer type %e",
    8680                 :             :                                     &e_type, &e_rhstype);
    8681                 :             :               break;
    8682                 :          59 :             case ic_return:
    8683                 :          59 :               if (bltin)
    8684                 :          11 :                 warned
    8685                 :          11 :                   = permerror_opt (location, OPT_Wincompatible_pointer_types,
    8686                 :             :                                    "returning pointer to %qD of type %e from "
    8687                 :             :                                    "a function with incompatible type %e",
    8688                 :             :                                    bltin, &e_rhstype, &e_type);
    8689                 :             :               else
    8690                 :          48 :                 warned
    8691                 :          48 :                   = permerror_opt (location, OPT_Wincompatible_pointer_types,
    8692                 :             :                                    "returning %e from a function with "
    8693                 :             :                                    "incompatible return type %e",
    8694                 :             :                                    &e_rhstype, &e_type);
    8695                 :             :               break;
    8696                 :           0 :             default:
    8697                 :           0 :               gcc_unreachable ();
    8698                 :             :             }
    8699                 :         797 :           if (warned)
    8700                 :             :             {
    8701                 :             :               /* If the mismatching function type is a pointer to a function,
    8702                 :             :                  try to show the decl of the function.  */
    8703                 :         587 :               if (TREE_CODE (rhs) == ADDR_EXPR
    8704                 :         587 :                   && TREE_CODE (TREE_OPERAND (rhs, 0)) == FUNCTION_DECL)
    8705                 :             :                 {
    8706                 :         189 :                   tree rhs_fndecl = TREE_OPERAND (rhs, 0);
    8707                 :         189 :                   if (!DECL_IS_UNDECLARED_BUILTIN (rhs_fndecl))
    8708                 :             :                     {
    8709                 :         163 :                       gcc_rich_location richloc
    8710                 :         163 :                         (DECL_SOURCE_LOCATION (rhs_fndecl), nullptr,
    8711                 :         163 :                          highlight_colors::actual);
    8712                 :         163 :                       pp_element_quoted_decl e_rhs_fndecl
    8713                 :         163 :                         (rhs_fndecl, highlight_colors::actual);
    8714                 :         163 :                       inform (&richloc,
    8715                 :             :                               "%e declared here", &e_rhs_fndecl);
    8716                 :         163 :                     }
    8717                 :             :                 }
    8718                 :             :               /* If either/both of the types are typedefs, show the decl.  */
    8719                 :         587 :               maybe_inform_typedef_location (type,
    8720                 :             :                                              highlight_colors::expected);
    8721                 :         587 :               maybe_inform_typedef_location (rhstype,
    8722                 :             :                                              highlight_colors::actual);
    8723                 :             :             }
    8724                 :         797 :         }
    8725                 :             : 
    8726                 :             :       /* If RHS isn't an address, check pointer or array of packed
    8727                 :             :          struct or union.  */
    8728                 :     1979723 :       warn_for_address_of_packed_member (type, orig_rhs);
    8729                 :             : 
    8730                 :     1979723 :       return convert (type, rhs);
    8731                 :             :     }
    8732                 :       78753 :   else if (codel == POINTER_TYPE && coder == ARRAY_TYPE)
    8733                 :             :     {
    8734                 :             :       /* ??? This should not be an error when inlining calls to
    8735                 :             :          unprototyped functions.  */
    8736                 :           4 :       const char msg[] = "invalid use of non-lvalue array";
    8737                 :           4 :       if (warnopt)
    8738                 :           0 :         warning_at (location, warnopt, msg);
    8739                 :             :       else
    8740                 :           4 :         error_at (location, msg);
    8741                 :           4 :       return error_mark_node;
    8742                 :             :     }
    8743                 :       78749 :   else if (codel == POINTER_TYPE
    8744                 :       77483 :            && (coder == INTEGER_TYPE
    8745                 :       77483 :                || coder == ENUMERAL_TYPE
    8746                 :         600 :                || coder == BOOLEAN_TYPE
    8747                 :         600 :                || coder == NULLPTR_TYPE
    8748                 :          20 :                || coder == BITINT_TYPE))
    8749                 :             :     {
    8750                 :       77475 :       if (null_pointer_constant && c_inhibit_evaluation_warnings == 0
    8751                 :       76477 :           && coder == INTEGER_TYPE)
    8752                 :       75880 :         warning_at (location, OPT_Wzero_as_null_pointer_constant,
    8753                 :             :                     "zero as null pointer constant");
    8754                 :             : 
    8755                 :             :       /* An explicit constant 0 or type nullptr_t can convert to a pointer,
    8756                 :             :          or one that results from arithmetic, even including a cast to
    8757                 :             :          integer type.  */
    8758                 :       77475 :       if (!null_pointer_constant && coder != NULLPTR_TYPE)
    8759                 :         972 :         switch (errtype)
    8760                 :             :           {
    8761                 :         800 :           case ic_argpass:
    8762                 :         800 :             {
    8763                 :         800 :               auto_diagnostic_group d;
    8764                 :         800 :               range_label_for_type_mismatch rhs_label (rhstype, type);
    8765                 :         800 :               gcc_rich_location richloc (expr_loc, &rhs_label,
    8766                 :         800 :                                          highlight_colors::actual);
    8767                 :         800 :               if (permerror_opt (&richloc, OPT_Wint_conversion,
    8768                 :             :                                  "passing argument %d of %qE makes pointer "
    8769                 :             :                                  "from integer without a cast", parmnum, rname))
    8770                 :             :                 {
    8771                 :         439 :                   maybe_emit_indirection_note (expr_loc, rhs, type);
    8772                 :         439 :                   inform_for_arg (fundecl, expr_loc, parmnum, type, rhstype);
    8773                 :             :                 }
    8774                 :         800 :             }
    8775                 :         800 :             break;
    8776                 :          93 :           case ic_assign:
    8777                 :          93 :             permerror_opt (location, OPT_Wint_conversion,
    8778                 :             :                            "assignment to %qT from %qT makes pointer from "
    8779                 :             :                            "integer without a cast", type, rhstype);
    8780                 :          93 :             break;
    8781                 :          56 :           case ic_init:
    8782                 :          56 :           case ic_init_const:
    8783                 :          56 :             permerror_init (location, OPT_Wint_conversion,
    8784                 :             :                             "initialization of %qT from %qT makes pointer "
    8785                 :             :                             "from integer without a cast", type, rhstype);
    8786                 :          56 :             break;
    8787                 :          23 :           case ic_return:
    8788                 :          23 :             permerror_init (location, OPT_Wint_conversion,
    8789                 :             :                             "returning %qT from a function with return type "
    8790                 :             :                             "%qT makes pointer from integer without a cast",
    8791                 :             :                             rhstype, type);
    8792                 :          23 :             break;
    8793                 :           0 :           default:
    8794                 :           0 :             gcc_unreachable ();
    8795                 :             :           }
    8796                 :             : 
    8797                 :       77475 :       return convert (type, rhs);
    8798                 :             :     }
    8799                 :        1274 :   else if ((codel == INTEGER_TYPE || codel == BITINT_TYPE)
    8800                 :         539 :            && coder == POINTER_TYPE)
    8801                 :             :     {
    8802                 :         513 :       switch (errtype)
    8803                 :             :         {
    8804                 :         343 :         case ic_argpass:
    8805                 :         343 :           {
    8806                 :         343 :             auto_diagnostic_group d;
    8807                 :         343 :             range_label_for_type_mismatch rhs_label (rhstype, type);
    8808                 :         343 :             gcc_rich_location richloc (expr_loc, &rhs_label,
    8809                 :         343 :                                        highlight_colors::actual);
    8810                 :         343 :             if (permerror_opt (&richloc, OPT_Wint_conversion,
    8811                 :             :                                "passing argument %d of %qE makes integer from "
    8812                 :             :                                "pointer without a cast", parmnum, rname))
    8813                 :             :               {
    8814                 :         322 :                 maybe_emit_indirection_note (expr_loc, rhs, type);
    8815                 :         322 :                 inform_for_arg (fundecl, expr_loc, parmnum, type, rhstype);
    8816                 :             :               }
    8817                 :         343 :           }
    8818                 :         343 :           break;
    8819                 :          52 :         case ic_assign:
    8820                 :          52 :           permerror_opt (location, OPT_Wint_conversion,
    8821                 :             :                          "assignment to %qT from %qT makes integer from "
    8822                 :             :                          "pointer without a cast", type, rhstype);
    8823                 :          52 :           break;
    8824                 :          83 :         case ic_init:
    8825                 :          83 :         case ic_init_const:
    8826                 :          83 :           permerror_init (location, OPT_Wint_conversion,
    8827                 :             :                           "initialization of %qT from %qT makes integer "
    8828                 :             :                           "from pointer without a cast", type, rhstype);
    8829                 :          83 :           break;
    8830                 :          35 :         case ic_return:
    8831                 :          35 :           permerror_opt (location, OPT_Wint_conversion, "returning %qT from a "
    8832                 :             :                          "function with return type %qT makes integer from "
    8833                 :             :                          "pointer without a cast", rhstype, type);
    8834                 :          35 :           break;
    8835                 :           0 :         default:
    8836                 :           0 :           gcc_unreachable ();
    8837                 :             :         }
    8838                 :             : 
    8839                 :         513 :       return convert (type, rhs);
    8840                 :             :     }
    8841                 :         613 :   else if (C_BOOLEAN_TYPE_P (type)
    8842                 :             :            /* The type nullptr_t may be converted to bool.  The
    8843                 :             :               result is false.  */
    8844                 :         763 :            && (coder == POINTER_TYPE || coder == NULLPTR_TYPE))
    8845                 :             :     {
    8846                 :         150 :       tree ret;
    8847                 :         150 :       bool save = in_late_binary_op;
    8848                 :         150 :       in_late_binary_op = true;
    8849                 :         150 :       ret = convert (type, rhs);
    8850                 :         150 :       in_late_binary_op = save;
    8851                 :         150 :       return ret;
    8852                 :             :     }
    8853                 :         611 :   else if (codel == NULLPTR_TYPE && null_pointer_constant)
    8854                 :           6 :     return convert (type, rhs);
    8855                 :             : 
    8856                 :         605 :   switch (errtype)
    8857                 :             :     {
    8858                 :          35 :     case ic_argpass:
    8859                 :          35 :       {
    8860                 :          35 :         auto_diagnostic_group d;
    8861                 :          35 :         range_label_for_type_mismatch rhs_label (rhstype, type);
    8862                 :          35 :         gcc_rich_location richloc (expr_loc, &rhs_label,
    8863                 :          35 :                                    highlight_colors::actual);
    8864                 :          35 :         const char msg[] = G_("incompatible type for argument %d of %qE");
    8865                 :          35 :         if (warnopt)
    8866                 :           8 :           warning_at (expr_loc, warnopt, msg, parmnum, rname);
    8867                 :             :         else
    8868                 :          27 :           error_at (&richloc, msg, parmnum, rname);
    8869                 :          35 :         inform_for_arg (fundecl, expr_loc, parmnum, type, rhstype);
    8870                 :          35 :       }
    8871                 :          35 :       break;
    8872                 :          97 :     case ic_assign:
    8873                 :          97 :       {
    8874                 :          97 :         const char msg[]
    8875                 :             :           = G_("incompatible types when assigning to type %qT from type %qT");
    8876                 :          97 :         if (warnopt)
    8877                 :           0 :           warning_at (expr_loc, 0, msg, type, rhstype);
    8878                 :             :         else
    8879                 :          97 :           error_at (expr_loc, msg, type, rhstype);
    8880                 :          97 :         break;
    8881                 :             :       }
    8882                 :         458 :     case ic_init:
    8883                 :         458 :     case ic_init_const:
    8884                 :         458 :       {
    8885                 :         458 :         const char msg[]
    8886                 :             :           = G_("incompatible types when initializing type %qT using type %qT");
    8887                 :         458 :         if (warnopt)
    8888                 :           0 :           warning_at (location, 0, msg, type, rhstype);
    8889                 :             :         else
    8890                 :         458 :           error_at (location, msg, type, rhstype);
    8891                 :         458 :         break;
    8892                 :             :       }
    8893                 :          15 :     case ic_return:
    8894                 :          15 :       {
    8895                 :          15 :         const char msg[]
    8896                 :             :           = G_("incompatible types when returning type %qT but %qT was expected");
    8897                 :          15 :         if (warnopt)
    8898                 :           0 :           warning_at (location, 0, msg, rhstype, type);
    8899                 :             :         else
    8900                 :          15 :           error_at (location, msg, rhstype, type);
    8901                 :          15 :         break;
    8902                 :             :       }
    8903                 :           0 :     default:
    8904                 :           0 :       gcc_unreachable ();
    8905                 :             :     }
    8906                 :             : 
    8907                 :         605 :   return error_mark_node;
    8908                 :             : }
    8909                 :             : 
    8910                 :             : /* If VALUE is a compound expr all of whose expressions are constant, then
    8911                 :             :    return its value.  Otherwise, return error_mark_node.
    8912                 :             : 
    8913                 :             :    This is for handling COMPOUND_EXPRs as initializer elements
    8914                 :             :    which is allowed with a warning when -pedantic is specified.  */
    8915                 :             : 
    8916                 :             : static tree
    8917                 :           2 : valid_compound_expr_initializer (tree value, tree endtype)
    8918                 :             : {
    8919                 :           2 :   if (TREE_CODE (value) == COMPOUND_EXPR)
    8920                 :             :     {
    8921                 :           1 :       if (valid_compound_expr_initializer (TREE_OPERAND (value, 0), endtype)
    8922                 :           1 :           == error_mark_node)
    8923                 :             :         return error_mark_node;
    8924                 :           0 :       return valid_compound_expr_initializer (TREE_OPERAND (value, 1),
    8925                 :           0 :                                               endtype);
    8926                 :             :     }
    8927                 :           1 :   else if (!initializer_constant_valid_p (value, endtype))
    8928                 :           1 :     return error_mark_node;
    8929                 :             :   else
    8930                 :             :     return value;
    8931                 :             : }
    8932                 :             : 
    8933                 :             : /* Perform appropriate conversions on the initial value of a variable,
    8934                 :             :    store it in the declaration DECL,
    8935                 :             :    and print any error messages that are appropriate.
    8936                 :             :    If ORIGTYPE is not NULL_TREE, it is the original type of INIT.
    8937                 :             :    If the init is invalid, store an ERROR_MARK.
    8938                 :             : 
    8939                 :             :    INIT_LOC is the location of the initial value.  */
    8940                 :             : 
    8941                 :             : void
    8942                 :     7090662 : store_init_value (location_t init_loc, tree decl, tree init, tree origtype)
    8943                 :             : {
    8944                 :     7090662 :   tree value, type;
    8945                 :     7090662 :   bool npc = false;
    8946                 :     7090662 :   bool int_const_expr = false;
    8947                 :     7090662 :   bool arith_const_expr = false;
    8948                 :             : 
    8949                 :             :   /* If variable's type was invalidly declared, just ignore it.  */
    8950                 :             : 
    8951                 :     7090662 :   type = TREE_TYPE (decl);
    8952                 :     7090662 :   if (TREE_CODE (type) == ERROR_MARK)
    8953                 :             :     return;
    8954                 :             : 
    8955                 :             :   /* Digest the specified initializer into an expression.  */
    8956                 :             : 
    8957                 :     7090655 :   if (init)
    8958                 :             :     {
    8959                 :     7090655 :       npc = null_pointer_constant_p (init);
    8960                 :     7090655 :       int_const_expr = (TREE_CODE (init) == INTEGER_CST
    8961                 :      408187 :                         && !TREE_OVERFLOW (init)
    8962                 :     7498806 :                         && INTEGRAL_TYPE_P (TREE_TYPE (init)));
    8963                 :             :       /* Not fully determined before folding.  */
    8964                 :             :       arith_const_expr = true;
    8965                 :             :     }
    8966                 :     7090655 :   bool constexpr_p = (VAR_P (decl)
    8967                 :     7090655 :                       && C_DECL_DECLARED_CONSTEXPR (decl));
    8968                 :     7090655 :   value = digest_init (init_loc, decl, type, init, origtype, npc,
    8969                 :             :                        int_const_expr, arith_const_expr, true,
    8970                 :     7090655 :                        TREE_STATIC (decl) || constexpr_p, constexpr_p);
    8971                 :             : 
    8972                 :             :   /* Store the expression if valid; else report error.  */
    8973                 :             : 
    8974                 :     7090655 :   if (!in_system_header_at (input_location)
    8975                 :     7090655 :       && AGGREGATE_TYPE_P (TREE_TYPE (decl)) && !TREE_STATIC (decl))
    8976                 :       27281 :     warning (OPT_Wtraditional, "traditional C rejects automatic "
    8977                 :             :              "aggregate initialization");
    8978                 :             : 
    8979                 :     7090655 :   if (value != error_mark_node || TREE_CODE (decl) != FUNCTION_DECL)
    8980                 :     7090654 :     DECL_INITIAL (decl) = value;
    8981                 :             : 
    8982                 :             :   /* ANSI wants warnings about out-of-range constant initializers.  */
    8983                 :     7090666 :   STRIP_TYPE_NOPS (value);
    8984                 :     7090655 :   if (TREE_STATIC (decl))
    8985                 :      179436 :     constant_expression_warning (value);
    8986                 :             : 
    8987                 :             :   /* Check if we need to set array size from compound literal size.  */
    8988                 :     7090655 :   if (TREE_CODE (type) == ARRAY_TYPE
    8989                 :       25816 :       && TYPE_DOMAIN (type) == NULL_TREE
    8990                 :     7102956 :       && value != error_mark_node)
    8991                 :             :     {
    8992                 :             :       tree inside_init = init;
    8993                 :             : 
    8994                 :       11461 :       STRIP_TYPE_NOPS (inside_init);
    8995                 :       11461 :       inside_init = fold (inside_init);
    8996                 :             : 
    8997                 :       11461 :       if (TREE_CODE (inside_init) == COMPOUND_LITERAL_EXPR)
    8998                 :             :         {
    8999                 :          13 :           tree cldecl = COMPOUND_LITERAL_EXPR_DECL (inside_init);
    9000                 :             : 
    9001                 :          13 :           if (TYPE_DOMAIN (TREE_TYPE (cldecl)))
    9002                 :             :             {
    9003                 :             :               /* For int foo[] = (int [3]){1}; we need to set array size
    9004                 :             :                  now since later on array initializer will be just the
    9005                 :             :                  brace enclosed list of the compound literal.  */
    9006                 :          13 :               tree etype = strip_array_types (TREE_TYPE (decl));
    9007                 :          13 :               type = build_distinct_type_copy (TYPE_MAIN_VARIANT (type));
    9008                 :          13 :               TYPE_DOMAIN (type) = TYPE_DOMAIN (TREE_TYPE (cldecl));
    9009                 :          13 :               layout_type (type);
    9010                 :          13 :               layout_decl (cldecl, 0);
    9011                 :          13 :               TREE_TYPE (decl)
    9012                 :          26 :                 = c_build_qualified_type (type, TYPE_QUALS (etype));
    9013                 :             :             }
    9014                 :             :         }
    9015                 :             :     }
    9016                 :             : }
    9017                 :             : 
    9018                 :             : /* Methods for storing and printing names for error messages.  */
    9019                 :             : 
    9020                 :             : /* Implement a spelling stack that allows components of a name to be pushed
    9021                 :             :    and popped.  Each element on the stack is this structure.  */
    9022                 :             : 
    9023                 :             : struct spelling
    9024                 :             : {
    9025                 :             :   int kind;
    9026                 :             :   union
    9027                 :             :     {
    9028                 :             :       unsigned HOST_WIDE_INT i;
    9029                 :             :       const char *s;
    9030                 :             :     } u;
    9031                 :             : };
    9032                 :             : 
    9033                 :             : #define SPELLING_STRING 1
    9034                 :             : #define SPELLING_MEMBER 2
    9035                 :             : #define SPELLING_BOUNDS 3
    9036                 :             : 
    9037                 :             : static struct spelling *spelling;       /* Next stack element (unused).  */
    9038                 :             : static struct spelling *spelling_base;  /* Spelling stack base.  */
    9039                 :             : static int spelling_size;               /* Size of the spelling stack.  */
    9040                 :             : 
    9041                 :             : /* Macros to save and restore the spelling stack around push_... functions.
    9042                 :             :    Alternative to SAVE_SPELLING_STACK.  */
    9043                 :             : 
    9044                 :             : #define SPELLING_DEPTH() (spelling - spelling_base)
    9045                 :             : #define RESTORE_SPELLING_DEPTH(DEPTH) (spelling = spelling_base + (DEPTH))
    9046                 :             : 
    9047                 :             : /* Push an element on the spelling stack with type KIND and assign VALUE
    9048                 :             :    to MEMBER.  */
    9049                 :             : 
    9050                 :             : #define PUSH_SPELLING(KIND, VALUE, MEMBER)                              \
    9051                 :             : {                                                                       \
    9052                 :             :   int depth = SPELLING_DEPTH ();                                        \
    9053                 :             :                                                                         \
    9054                 :             :   if (depth >= spelling_size)                                                \
    9055                 :             :     {                                                                   \
    9056                 :             :       spelling_size += 10;                                              \
    9057                 :             :       spelling_base = XRESIZEVEC (struct spelling, spelling_base,       \
    9058                 :             :                                   spelling_size);                       \
    9059                 :             :       RESTORE_SPELLING_DEPTH (depth);                                   \
    9060                 :             :     }                                                                   \
    9061                 :             :                                                                         \
    9062                 :             :   spelling->kind = (KIND);                                           \
    9063                 :             :   spelling->MEMBER = (VALUE);                                                \
    9064                 :             :   spelling++;                                                           \
    9065                 :             : }
    9066                 :             : 
    9067                 :             : /* Push STRING on the stack.  Printed literally.  */
    9068                 :             : 
    9069                 :             : static void
    9070                 :     7088102 : push_string (const char *string)
    9071                 :             : {
    9072                 :     7088102 :   PUSH_SPELLING (SPELLING_STRING, string, u.s);
    9073                 :     7088102 : }
    9074                 :             : 
    9075                 :             : /* Push a member name on the stack.  Printed as '.' STRING.  */
    9076                 :             : 
    9077                 :             : static void
    9078                 :     1225149 : push_member_name (tree decl)
    9079                 :             : {
    9080                 :     1225149 :   const char *const string
    9081                 :     1225149 :     = (DECL_NAME (decl)
    9082                 :     1225149 :        ? identifier_to_locale (IDENTIFIER_POINTER (DECL_NAME (decl)))
    9083                 :         194 :        : _("<anonymous>"));
    9084                 :     1225149 :   PUSH_SPELLING (SPELLING_MEMBER, string, u.s);
    9085                 :     1225149 : }
    9086                 :             : 
    9087                 :             : /* Push an array bounds on the stack.  Printed as [BOUNDS].  */
    9088                 :             : 
    9089                 :             : static void
    9090                 :     2597263 : push_array_bounds (unsigned HOST_WIDE_INT bounds)
    9091                 :             : {
    9092                 :     2597263 :   PUSH_SPELLING (SPELLING_BOUNDS, bounds, u.i);
    9093                 :     2597263 : }
    9094                 :             : 
    9095                 :             : /* Compute the maximum size in bytes of the printed spelling.  */
    9096                 :             : 
    9097                 :             : static int
    9098                 :        2828 : spelling_length (void)
    9099                 :             : {
    9100                 :        2828 :   int size = 0;
    9101                 :        2828 :   struct spelling *p;
    9102                 :             : 
    9103                 :        6316 :   for (p = spelling_base; p < spelling; p++)
    9104                 :             :     {
    9105                 :        3488 :       if (p->kind == SPELLING_BOUNDS)
    9106                 :        1475 :         size += 25;
    9107                 :             :       else
    9108                 :        2013 :         size += strlen (p->u.s) + 1;
    9109                 :             :     }
    9110                 :             : 
    9111                 :        2828 :   return size;
    9112                 :             : }
    9113                 :             : 
    9114                 :             : /* Print the spelling to BUFFER and return it.  */
    9115                 :             : 
    9116                 :             : static char *
    9117                 :        2828 : print_spelling (char *buffer)
    9118                 :             : {
    9119                 :        2828 :   char *d = buffer;
    9120                 :        2828 :   struct spelling *p;
    9121                 :             : 
    9122                 :        6316 :   for (p = spelling_base; p < spelling; p++)
    9123                 :        3488 :     if (p->kind == SPELLING_BOUNDS)
    9124                 :             :       {
    9125                 :        1475 :         sprintf (d, "[" HOST_WIDE_INT_PRINT_UNSIGNED "]", p->u.i);
    9126                 :        1475 :         d += strlen (d);
    9127                 :             :       }
    9128                 :             :     else
    9129                 :             :       {
    9130                 :        2013 :         const char *s;
    9131                 :        2013 :         if (p->kind == SPELLING_MEMBER)
    9132                 :         190 :           *d++ = '.';
    9133                 :       16603 :         for (s = p->u.s; (*d = *s++); d++)
    9134                 :             :           ;
    9135                 :             :       }
    9136                 :        2828 :   *d++ = '\0';
    9137                 :        2828 :   return buffer;
    9138                 :             : }
    9139                 :             : 
    9140                 :             : /* Check whether INIT, a floating or integer constant, is
    9141                 :             :    representable in TYPE, a real floating type with the same radix or
    9142                 :             :    a decimal floating type initialized with a binary floating
    9143                 :             :    constant.  Return true if OK, false if not.  */
    9144                 :             : static bool
    9145                 :         362 : constexpr_init_fits_real_type (tree type, tree init)
    9146                 :             : {
    9147                 :         362 :   gcc_assert (SCALAR_FLOAT_TYPE_P (type));
    9148                 :         362 :   gcc_assert (TREE_CODE (init) == INTEGER_CST || TREE_CODE (init) == REAL_CST);
    9149                 :         362 :   if (TREE_CODE (init) == REAL_CST
    9150                 :         362 :       && TYPE_MODE (TREE_TYPE (init)) == TYPE_MODE (type))
    9151                 :             :     {
    9152                 :             :       /* Same mode, no conversion required except for the case of
    9153                 :             :          signaling NaNs if the types are incompatible (e.g. double and
    9154                 :             :          long double with the same mode).  */
    9155                 :         177 :       if (REAL_VALUE_ISSIGNALING_NAN (TREE_REAL_CST (init))
    9156                 :         195 :           && !comptypes (TYPE_MAIN_VARIANT (type),
    9157                 :          18 :                          TYPE_MAIN_VARIANT (TREE_TYPE (init))))
    9158                 :             :         return false;
    9159                 :         177 :       return true;
    9160                 :             :     }
    9161                 :         185 :   if (TREE_CODE (init) == INTEGER_CST)
    9162                 :             :     {
    9163                 :          54 :       tree converted = build_real_from_int_cst (type, init);
    9164                 :          54 :       bool fail = false;
    9165                 :         108 :       wide_int w = real_to_integer (&TREE_REAL_CST (converted), &fail,
    9166                 :          54 :                                     TYPE_PRECISION (TREE_TYPE (init)));
    9167                 :          68 :       return !fail && wi::eq_p (w, wi::to_wide (init));
    9168                 :          54 :     }
    9169                 :         131 :   if (REAL_VALUE_ISSIGNALING_NAN (TREE_REAL_CST (init)))
    9170                 :             :     return false;
    9171                 :         114 :   if ((REAL_VALUE_ISINF (TREE_REAL_CST (init))
    9172                 :          34 :        && MODE_HAS_INFINITIES (TYPE_MODE (type)))
    9173                 :         218 :       || (REAL_VALUE_ISNAN (TREE_REAL_CST (init))
    9174                 :          34 :           && MODE_HAS_NANS (TYPE_MODE (type))))
    9175                 :          20 :     return true;
    9176                 :          94 :   if (DECIMAL_FLOAT_TYPE_P (type)
    9177                 :         134 :       && !DECIMAL_FLOAT_TYPE_P (TREE_TYPE (init)))
    9178                 :             :     {
    9179                 :             :       /* This is valid if the real number represented by the
    9180                 :             :          initializer can be exactly represented in the decimal
    9181                 :             :          type.  Compare the values using MPFR.  */
    9182                 :           8 :       REAL_VALUE_TYPE t;
    9183                 :           8 :       real_convert (&t, TYPE_MODE (type), &TREE_REAL_CST (init));
    9184                 :           8 :       mpfr_t bin_val, dec_val;
    9185                 :           8 :       mpfr_init2 (bin_val, REAL_MODE_FORMAT (TYPE_MODE (TREE_TYPE (init)))->p);
    9186                 :           8 :       mpfr_init2 (dec_val, REAL_MODE_FORMAT (TYPE_MODE (TREE_TYPE (init)))->p);
    9187                 :           8 :       mpfr_from_real (bin_val, &TREE_REAL_CST (init), MPFR_RNDN);
    9188                 :           8 :       char string[256];
    9189                 :           8 :       real_to_decimal (string, &t, sizeof string, 0, 1);
    9190                 :           8 :       bool res = (mpfr_strtofr (dec_val, string, NULL, 10, MPFR_RNDN) == 0
    9191                 :           8 :                   && mpfr_equal_p (bin_val, dec_val));
    9192                 :           8 :       mpfr_clear (bin_val);
    9193                 :           8 :       mpfr_clear (dec_val);
    9194                 :           8 :       return res;
    9195                 :             :     }
    9196                 :             :   /* exact_real_truncate is not quite right here, since it doesn't
    9197                 :             :      allow even an exact conversion to subnormal values.  */
    9198                 :          86 :   REAL_VALUE_TYPE t;
    9199                 :          86 :   real_convert (&t, TYPE_MODE (type), &TREE_REAL_CST (init));
    9200                 :          86 :   return real_identical (&t, &TREE_REAL_CST (init));
    9201                 :             : }
    9202                 :             : 
    9203                 :             : /* Check whether INIT (location LOC) is valid as a 'constexpr'
    9204                 :             :    initializer for type TYPE, and give an error if not.  INIT has
    9205                 :             :    already been folded and verified to be constant.  INT_CONST_EXPR
    9206                 :             :    and ARITH_CONST_EXPR say whether it is an integer constant
    9207                 :             :    expression or arithmetic constant expression, respectively.  If
    9208                 :             :    TYPE is not a scalar type, this function does nothing.  */
    9209                 :             : 
    9210                 :             : static void
    9211                 :         898 : check_constexpr_init (location_t loc, tree type, tree init,
    9212                 :             :                       bool int_const_expr, bool arith_const_expr)
    9213                 :             : {
    9214                 :         898 :   if (POINTER_TYPE_P (type))
    9215                 :             :     {
    9216                 :             :       /* The initializer must be null.  */
    9217                 :          86 :       if (TREE_CODE (init) != INTEGER_CST || !integer_zerop (init))
    9218                 :           8 :         error_at (loc, "%<constexpr%> pointer initializer is not null");
    9219                 :          86 :       return;
    9220                 :             :     }
    9221                 :         812 :   if (INTEGRAL_TYPE_P (type))
    9222                 :             :     {
    9223                 :             :       /* The initializer must be an integer constant expression,
    9224                 :             :          representable in the target type.  */
    9225                 :         305 :       if (!int_const_expr)
    9226                 :             :         {
    9227                 :          13 :           if (TREE_CODE (init) == RAW_DATA_CST
    9228                 :          13 :               && TYPE_PRECISION (type) == CHAR_BIT)
    9229                 :             :             {
    9230                 :           4 :               if (!TYPE_UNSIGNED (type))
    9231                 :         137 :                 for (unsigned int i = 0;
    9232                 :         140 :                      i < (unsigned) RAW_DATA_LENGTH (init); ++i)
    9233                 :         138 :                   if (RAW_DATA_SCHAR_ELT (init, i) < 0)
    9234                 :             :                     {
    9235                 :           1 :                       error_at (loc, "%<constexpr%> initializer not "
    9236                 :             :                                 "representable in type of object");
    9237                 :           1 :                       break;
    9238                 :             :                     }
    9239                 :             :             }
    9240                 :             :           else
    9241                 :           9 :             error_at (loc, "%<constexpr%> integer initializer is not an "
    9242                 :             :                       "integer constant expression");
    9243                 :             :         }
    9244                 :         292 :       else if (!int_fits_type_p (init, type))
    9245                 :           6 :         error_at (loc, "%<constexpr%> initializer not representable in "
    9246                 :             :                   "type of object");
    9247                 :         305 :       return;
    9248                 :             :     }
    9249                 :             :   /* We don't apply any extra checks to extension types such as vector
    9250                 :             :      or fixed-point types.  */
    9251                 :         507 :   if (TREE_CODE (type) != REAL_TYPE && TREE_CODE (type) != COMPLEX_TYPE)
    9252                 :             :     return;
    9253                 :         353 :   if (!arith_const_expr)
    9254                 :             :     {
    9255                 :           5 :       error_at (loc, "%<constexpr%> initializer is not an arithmetic "
    9256                 :             :                 "constant expression");
    9257                 :           5 :       return;
    9258                 :             :     }
    9259                 :             :   /* We don't apply any extra checks to complex integers.  */
    9260                 :         348 :   if (TREE_CODE (type) == COMPLEX_TYPE
    9261                 :         348 :       && TREE_CODE (TREE_TYPE (type)) != REAL_TYPE)
    9262                 :             :     return;
    9263                 :             :   /* Following N3082, a real type cannot be initialized from a complex
    9264                 :             :      type and a binary type cannot be initialized from a decimal type
    9265                 :             :      (but initializing a decimal type from a binary type is OK).
    9266                 :             :      Signaling NaN initializers are OK only if the types are
    9267                 :             :      compatible (not just the same mode); all quiet NaN and infinity
    9268                 :             :      initializations are considered to preserve the value.  */
    9269                 :         348 :   if (TREE_CODE (TREE_TYPE (init)) == COMPLEX_TYPE
    9270                 :         348 :       && SCALAR_FLOAT_TYPE_P (type))
    9271                 :             :     {
    9272                 :           6 :       error_at (loc, "%<constexpr%> initializer for a real type is of "
    9273                 :             :                 "complex type");
    9274                 :           6 :       return;
    9275                 :             :     }
    9276                 :         342 :   if (SCALAR_FLOAT_TYPE_P (type)
    9277                 :         300 :       && SCALAR_FLOAT_TYPE_P (TREE_TYPE (init))
    9278                 :         250 :       && DECIMAL_FLOAT_TYPE_P (TREE_TYPE (init))
    9279                 :         481 :       && !DECIMAL_FLOAT_TYPE_P (type))
    9280                 :             :     {
    9281                 :           6 :       error_at (loc, "%<constexpr%> initializer for a binary "
    9282                 :             :                 "floating-point type is of decimal type");
    9283                 :           6 :       return;
    9284                 :             :     }
    9285                 :         336 :   bool fits;
    9286                 :         336 :   if (TREE_CODE (type) == COMPLEX_TYPE)
    9287                 :             :     {
    9288                 :          42 :       switch (TREE_CODE (init))
    9289                 :             :         {
    9290                 :          10 :         case INTEGER_CST:
    9291                 :          10 :         case REAL_CST:
    9292                 :          10 :           fits = constexpr_init_fits_real_type (TREE_TYPE (type), init);
    9293                 :          10 :           break;
    9294                 :          32 :         case COMPLEX_CST:
    9295                 :          32 :           fits = (constexpr_init_fits_real_type (TREE_TYPE (type),
    9296                 :          32 :                                                  TREE_REALPART (init))
    9297                 :          58 :                   && constexpr_init_fits_real_type (TREE_TYPE (type),
    9298                 :          26 :                                                     TREE_IMAGPART (init)));
    9299                 :             :           break;
    9300                 :           0 :         default:
    9301                 :           0 :           gcc_unreachable ();
    9302                 :             :         }
    9303                 :             :     }
    9304                 :             :   else
    9305                 :         294 :     fits = constexpr_init_fits_real_type (type, init);
    9306                 :         304 :   if (!fits)
    9307                 :          65 :     error_at (loc, "%<constexpr%> initializer not representable in "
    9308                 :             :               "type of object");
    9309                 :             : }
    9310                 :             : 
    9311                 :             : /* Digest the parser output INIT as an initializer for type TYPE
    9312                 :             :    initializing DECL.
    9313                 :             :    Return a C expression of type TYPE to represent the initial value.
    9314                 :             : 
    9315                 :             :    If ORIGTYPE is not NULL_TREE, it is the original type of INIT.
    9316                 :             : 
    9317                 :             :    NULL_POINTER_CONSTANT is true if INIT is a null pointer constant,
    9318                 :             :    INT_CONST_EXPR is true if INIT is an integer constant expression,
    9319                 :             :    and ARITH_CONST_EXPR is true if INIT is, or might be, an arithmetic
    9320                 :             :    constant expression, false if it has already been determined in the
    9321                 :             :    caller that it is not (but folding may have made the value passed here
    9322                 :             :    indistinguishable from an arithmetic constant expression).
    9323                 :             : 
    9324                 :             :    If INIT is a string constant, STRICT_STRING is true if it is
    9325                 :             :    unparenthesized or we should not warn here for it being parenthesized.
    9326                 :             :    For other types of INIT, STRICT_STRING is not used.
    9327                 :             : 
    9328                 :             :    INIT_LOC is the location of the INIT.
    9329                 :             : 
    9330                 :             :    REQUIRE_CONSTANT requests an error if non-constant initializers or
    9331                 :             :    elements are seen.  REQUIRE_CONSTEXPR means the stricter requirements
    9332                 :             :    on initializers for 'constexpr' objects apply.  */
    9333                 :             : 
    9334                 :             : static tree
    9335                 :    16545762 : digest_init (location_t init_loc, tree decl, tree type, tree init,
    9336                 :             :              tree origtype, bool null_pointer_constant, bool int_const_expr,
    9337                 :             :              bool arith_const_expr, bool strict_string,
    9338                 :             :              bool require_constant, bool require_constexpr)
    9339                 :             : {
    9340                 :    16545762 :   enum tree_code code = TREE_CODE (type);
    9341                 :    16545762 :   tree inside_init = init;
    9342                 :    16545762 :   tree semantic_type = NULL_TREE;
    9343                 :    16545762 :   bool maybe_const = true;
    9344                 :             : 
    9345                 :    16545762 :   if (type == error_mark_node
    9346                 :    16545762 :       || !init
    9347                 :    33091524 :       || error_operand_p (init))
    9348                 :             :     return error_mark_node;
    9349                 :             : 
    9350                 :    16552994 :   STRIP_TYPE_NOPS (inside_init);
    9351                 :             : 
    9352                 :             :   /* If require_constant is TRUE,  when the initializer is a call to
    9353                 :             :      .ACCESS_WITH_SIZE, use the first argument as the initializer.
    9354                 :             :      For example:
    9355                 :             :      y = (char *) .ACCESS_WITH_SIZE ((char *) &static_annotated.c,...)
    9356                 :             :      will be converted to
    9357                 :             :      y = &static_annotated.c.  */
    9358                 :             : 
    9359                 :    16544449 :   if (require_constant
    9360                 :     2888769 :       && TREE_CODE (inside_init) == NOP_EXPR
    9361                 :      736213 :       && TREE_CODE (TREE_OPERAND (inside_init, 0)) == CALL_EXPR
    9362                 :    16544451 :       && is_access_with_size_p (TREE_OPERAND (inside_init, 0)))
    9363                 :           2 :     inside_init
    9364                 :           2 :       = get_ref_from_access_with_size (TREE_OPERAND (inside_init, 0));
    9365                 :             : 
    9366                 :    16544449 :   if (!c_in_omp_for)
    9367                 :             :     {
    9368                 :    16539713 :       if (TREE_CODE (inside_init) == EXCESS_PRECISION_EXPR)
    9369                 :             :         {
    9370                 :         437 :           semantic_type = TREE_TYPE (inside_init);
    9371                 :         437 :           inside_init = TREE_OPERAND (inside_init, 0);
    9372                 :             :         }
    9373                 :    16539713 :       inside_init = c_fully_fold (inside_init, require_constant, &maybe_const);
    9374                 :             :     }
    9375                 :             :   /* TODO: this may not detect all cases of expressions folding to
    9376                 :             :      constants that are not arithmetic constant expressions.  */
    9377                 :    16544449 :   if (!maybe_const)
    9378                 :             :     arith_const_expr = false;
    9379                 :    24722840 :   else if (!INTEGRAL_TYPE_P (TREE_TYPE (inside_init))
    9380                 :     5561937 :            && TREE_CODE (TREE_TYPE (inside_init)) != REAL_TYPE
    9381                 :    16521847 :            && TREE_CODE (TREE_TYPE (inside_init)) != COMPLEX_TYPE)
    9382                 :             :     arith_const_expr = false;
    9383                 :     8228911 :   else if (TREE_CODE (inside_init) != INTEGER_CST
    9384                 :             :            && TREE_CODE (inside_init) != REAL_CST
    9385                 :             :            && TREE_CODE (inside_init) != COMPLEX_CST
    9386                 :             :            && TREE_CODE (inside_init) != RAW_DATA_CST)
    9387                 :             :     arith_const_expr = false;
    9388                 :     4976157 :   else if (TREE_OVERFLOW (inside_init))
    9389                 :    11568336 :     arith_const_expr = false;
    9390                 :             : 
    9391                 :             :   /* Initialization of an array of chars from a string constant
    9392                 :             :      optionally enclosed in braces.  */
    9393                 :             : 
    9394                 :    16544449 :   if (code == ARRAY_TYPE && inside_init
    9395                 :      187462 :       && TREE_CODE (inside_init) == STRING_CST)
    9396                 :             :     {
    9397                 :       11406 :       tree typ1
    9398                 :       11406 :         = (TYPE_ATOMIC (TREE_TYPE (type))
    9399                 :       11406 :            ? c_build_qualified_type (TYPE_MAIN_VARIANT (TREE_TYPE (type)),
    9400                 :             :                                      TYPE_QUAL_ATOMIC)
    9401                 :       11397 :            : TYPE_MAIN_VARIANT (TREE_TYPE (type)));
    9402                 :             :       /* Note that an array could be both an array of character type
    9403                 :             :          and an array of wchar_t if wchar_t is signed char or unsigned
    9404                 :             :          char.  */
    9405                 :       22812 :       bool char_array = (typ1 == char_type_node
    9406                 :         462 :                          || typ1 == signed_char_type_node
    9407                 :       11839 :                          || typ1 == unsigned_char_type_node);
    9408                 :       11406 :       bool wchar_array = !!comptypes (typ1, wchar_type_node);
    9409                 :       11406 :       bool char16_array = !!comptypes (typ1, char16_type_node);
    9410                 :       11406 :       bool char32_array = !!comptypes (typ1, char32_type_node);
    9411                 :             : 
    9412                 :       11406 :       if (char_array || wchar_array || char16_array || char32_array)
    9413                 :             :         {
    9414                 :       11386 :           struct c_expr expr;
    9415                 :       11386 :           tree typ2 = TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (inside_init)));
    9416                 :       11386 :           bool incompat_string_cst = false;
    9417                 :       11386 :           expr.value = inside_init;
    9418                 :       11386 :           expr.original_code = (strict_string ? STRING_CST : ERROR_MARK);
    9419                 :       11386 :           expr.original_type = NULL;
    9420                 :       11386 :           expr.m_decimal = 0;
    9421                 :       11386 :           maybe_warn_string_init (init_loc, type, expr);
    9422                 :             : 
    9423                 :       11386 :           if (TYPE_DOMAIN (type) && !TYPE_MAX_VALUE (TYPE_DOMAIN (type)))
    9424                 :          91 :             pedwarn_init (init_loc, OPT_Wpedantic,
    9425                 :             :                           "initialization of a flexible array member");
    9426                 :             : 
    9427                 :       11386 :           if (comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (inside_init)),
    9428                 :       11386 :                          TYPE_MAIN_VARIANT (type)))
    9429                 :             :             return inside_init;
    9430                 :             : 
    9431                 :        4137 :           if (char_array)
    9432                 :             :             {
    9433                 :        4042 :               if (typ2 != char_type_node && typ2 != char8_type_node)
    9434                 :             :                 incompat_string_cst = true;
    9435                 :             :             }
    9436                 :          95 :           else if (!comptypes (typ1, typ2))
    9437                 :             :             incompat_string_cst = true;
    9438                 :             : 
    9439                 :             :           if (incompat_string_cst)
    9440                 :             :             {
    9441                 :          50 :               error_init (init_loc, "cannot initialize array of %qT from "
    9442                 :             :                           "a string literal with type array of %qT",
    9443                 :             :                           typ1, typ2);
    9444                 :          50 :               return error_mark_node;
    9445                 :             :             }
    9446                 :             : 
    9447                 :        4087 :           if (require_constexpr
    9448                 :        4087 :               && TYPE_UNSIGNED (typ1) != TYPE_UNSIGNED (typ2))
    9449                 :             :             {
    9450                 :             :               /* Check if all characters of the string can be
    9451                 :             :                  represented in the type of the constexpr object being
    9452                 :             :                  initialized.  */
    9453                 :          24 :               unsigned HOST_WIDE_INT len = TREE_STRING_LENGTH (inside_init);
    9454                 :          24 :               const unsigned char *p =
    9455                 :          24 :                 (const unsigned char *) TREE_STRING_POINTER (inside_init);
    9456                 :          24 :               gcc_assert (CHAR_TYPE_SIZE == 8 && CHAR_BIT == 8);
    9457                 :          70 :               for (unsigned i = 0; i < len; i++)
    9458                 :          58 :                 if (p[i] > 127)
    9459                 :             :                   {
    9460                 :          12 :                     error_init (init_loc, "%<constexpr%> initializer not "
    9461                 :             :                                 "representable in type of object");
    9462                 :          12 :                     break;
    9463                 :             :                   }
    9464                 :             :             }
    9465                 :             : 
    9466                 :        4087 :           if (TYPE_DOMAIN (type) != NULL_TREE
    9467                 :        4010 :               && TYPE_SIZE (type) != NULL_TREE
    9468                 :        8038 :               && TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST)
    9469                 :             :             {
    9470                 :        3951 :               unsigned HOST_WIDE_INT len = TREE_STRING_LENGTH (inside_init);
    9471                 :             : 
    9472                 :        3951 :               if (compare_tree_int (TYPE_SIZE_UNIT (type), len) < 0)
    9473                 :             :                 {
    9474                 :         395 :                   unsigned HOST_WIDE_INT avail
    9475                 :         395 :                     = tree_to_uhwi (TYPE_SIZE_UNIT (type));
    9476                 :         395 :                   unsigned unit = TYPE_PRECISION (typ1) / BITS_PER_UNIT;
    9477                 :         395 :                   const char *p = TREE_STRING_POINTER (inside_init);
    9478                 :             : 
    9479                 :             :                   /* Construct truncated string.  */
    9480                 :         395 :                   inside_init = build_string (avail, p);
    9481                 :             : 
    9482                 :             :                   /* Subtract the size of a single (possibly wide) character
    9483                 :             :                      because it may be ok to ignore the terminating NUL char
    9484                 :             :                      that is counted in the length of the constant.  */
    9485                 :         395 :                   if (len - unit > avail)
    9486                 :          63 :                     pedwarn_init (init_loc, 0,
    9487                 :             :                                   "initializer-string for array of %qT "
    9488                 :             :                                   "is too long (%wu chars into %wu "
    9489                 :             :                                   "available)", typ1, len, avail);
    9490                 :         332 :                   else if (warn_cxx_compat)
    9491                 :           9 :                     warning_at (init_loc, OPT_Wc___compat,
    9492                 :             :                                 "initializer-string for array of %qT "
    9493                 :             :                                 "is too long for C++ (%wu chars into %wu "
    9494                 :             :                                 "available)", typ1, len, avail);
    9495                 :         323 :                   else if (warn_unterminated_string_initialization
    9496                 :         323 :                            && get_attr_nonstring_decl (decl) == NULL_TREE)
    9497                 :          22 :                     warning_at (init_loc,
    9498                 :          22 :                                 OPT_Wunterminated_string_initialization,
    9499                 :             :                                 "initializer-string for array of %qT "
    9500                 :             :                                 "truncates NUL terminator but destination "
    9501                 :             :                                 "lacks %qs attribute (%wu chars into %wu "
    9502                 :             :                                 "available)", typ1, "nonstring", len, avail);
    9503                 :             :                 }
    9504                 :             :             }
    9505                 :             : 
    9506                 :        4087 :           TREE_TYPE (inside_init) = type;
    9507                 :        4087 :           return inside_init;
    9508                 :             :         }
    9509                 :          20 :       else if (INTEGRAL_TYPE_P (typ1))
    9510                 :             :         {
    9511                 :          20 :           error_init (init_loc, "array of inappropriate type initialized "
    9512                 :             :                       "from string constant");
    9513                 :          20 :           return error_mark_node;
    9514                 :             :         }
    9515                 :             :     }
    9516                 :             : 
    9517                 :             :   /* Build a VECTOR_CST from a *constant* vector constructor.  If the
    9518                 :             :      vector constructor is not constant (e.g. {1,2,3,foo()}) then punt
    9519                 :             :      below and handle as a constructor.  */
    9520                 :    16533043 :   if (code == VECTOR_TYPE
    9521                 :     6150431 :       && VECTOR_TYPE_P (TREE_TYPE (inside_init))
    9522                 :     6150429 :       && vector_types_convertible_p (TREE_TYPE (inside_init), type, true)
    9523                 :    22683434 :       && TREE_CONSTANT (inside_init))
    9524                 :             :     {
    9525                 :      618087 :       if (TREE_CODE (inside_init) == VECTOR_CST
    9526                 :      618184 :           && comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (inside_init)),
    9527                 :          97 :                         TYPE_MAIN_VARIANT (type)))
    9528                 :             :         return inside_init;
    9529                 :             : 
    9530                 :      617990 :       if (TREE_CODE (inside_init) == CONSTRUCTOR)
    9531                 :             :         {
    9532                 :             :           unsigned HOST_WIDE_INT ix;
    9533                 :             :           tree value;
    9534                 :     4078803 :           bool constant_p = true;
    9535                 :             : 
    9536                 :             :           /* Iterate through elements and check if all constructor
    9537                 :             :              elements are *_CSTs.  */
    9538                 :     4078803 :           FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (inside_init), ix, value)
    9539                 :     3460869 :             if (!CONSTANT_CLASS_P (value))
    9540                 :             :               {
    9541                 :             :                 constant_p = false;
    9542                 :             :                 break;
    9543                 :             :               }
    9544                 :             : 
    9545                 :      617990 :           if (constant_p)
    9546                 :      617934 :             return build_vector_from_ctor (type,
    9547                 :      617934 :                                            CONSTRUCTOR_ELTS (inside_init));
    9548                 :             :         }
    9549                 :             :     }
    9550                 :             : 
    9551                 :    15915012 :   if (warn_sequence_point)
    9552                 :     2446918 :     verify_sequence_points (inside_init);
    9553                 :             : 
    9554                 :             :   /* Any type can be initialized
    9555                 :             :      from an expression of the same type, optionally with braces.  */
    9556                 :             : 
    9557                 :    15915012 :   if (inside_init && TREE_TYPE (inside_init) != NULL_TREE
    9558                 :    31830024 :       && (comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (inside_init)),
    9559                 :    15915012 :                      TYPE_MAIN_VARIANT (type))
    9560                 :     3070915 :           || (code == ARRAY_TYPE
    9561                 :         476 :               && comptypes (TREE_TYPE (inside_init), type))
    9562                 :     3070915 :           || (gnu_vector_type_p (type)
    9563                 :         159 :               && comptypes (TREE_TYPE (inside_init), type))
    9564                 :     3070915 :           || (code == POINTER_TYPE
    9565                 :      111632 :               && TREE_CODE (TREE_TYPE (inside_init)) == ARRAY_TYPE
    9566                 :        9260 :               && comptypes (TREE_TYPE (TREE_TYPE (inside_init)),
    9567                 :        9260 :                             TREE_TYPE (type)))))
    9568                 :             :     {
    9569                 :    12846071 :       if (code == POINTER_TYPE)
    9570                 :             :         {
    9571                 :      783290 :           if (TREE_CODE (TREE_TYPE (inside_init)) == ARRAY_TYPE)
    9572                 :             :             {
    9573                 :        1974 :               if (TREE_CODE (inside_init) == STRING_CST
    9574                 :          66 :                   || TREE_CODE (inside_init) == COMPOUND_LITERAL_EXPR)
    9575                 :        1972 :                 inside_init = array_to_pointer_conversion
    9576                 :        1972 :                   (init_loc, inside_init);
    9577                 :             :               else
    9578                 :             :                 {
    9579                 :           2 :                   error_init (init_loc, "invalid use of non-lvalue array");
    9580                 :           2 :                   return error_mark_node;
    9581                 :             :                 }
    9582                 :             :             }
    9583                 :             :         }
    9584                 :             : 
    9585                 :    12846069 :       if (code == VECTOR_TYPE || c_hardbool_type_attr (type))
    9586                 :             :         /* Although the types are compatible, we may require a
    9587                 :             :            conversion.  */
    9588                 :     5532297 :         inside_init = convert (type, inside_init);
    9589                 :             : 
    9590                 :    12846069 :       if ((code == RECORD_TYPE || code == UNION_TYPE)
    9591                 :    12846069 :           && !comptypes (TYPE_MAIN_VARIANT (type), TYPE_MAIN_VARIANT (TREE_TYPE (inside_init))))
    9592                 :             :         {
    9593                 :           0 :           error_init (init_loc, "invalid initializer");
    9594                 :           0 :           return error_mark_node;
    9595                 :             :         }
    9596                 :             : 
    9597                 :    12846069 :       if (require_constant
    9598                 :     2296586 :           && TREE_CODE (inside_init) == COMPOUND_LITERAL_EXPR)
    9599                 :             :         {
    9600                 :             :           /* As an extension, allow initializing objects with static storage
    9601                 :             :              duration with compound literals (which are then treated just as
    9602                 :             :              the brace enclosed list they contain).  Also allow this for
    9603                 :             :              vectors, as we can only assign them with compound literals.  */
    9604                 :          31 :           if (flag_isoc99 && code != VECTOR_TYPE)
    9605                 :           8 :             pedwarn_init (init_loc, OPT_Wpedantic, "initializer element "
    9606                 :             :                           "is not constant");
    9607                 :          31 :           tree decl = COMPOUND_LITERAL_EXPR_DECL (inside_init);
    9608                 :          31 :           inside_init = DECL_INITIAL (decl);
    9609                 :             :         }
    9610                 :             : 
    9611                 :    12846069 :       if (code == ARRAY_TYPE && TREE_CODE (inside_init) != STRING_CST
    9612                 :      175580 :           && TREE_CODE (inside_init) != CONSTRUCTOR)
    9613                 :             :         {
    9614                 :           2 :           error_init (init_loc, "array initialized from non-constant array "
    9615                 :             :                       "expression");
    9616                 :           2 :           return error_mark_node;
    9617                 :             :         }
    9618                 :             : 
    9619                 :             :       /* Compound expressions can only occur here if -Wpedantic or
    9620                 :             :          -pedantic-errors is specified.  In the later case, we always want
    9621                 :             :          an error.  In the former case, we simply want a warning.  */
    9622                 :    12846067 :       if (require_constant && pedantic
    9623                 :       20187 :           && TREE_CODE (inside_init) == COMPOUND_EXPR)
    9624                 :             :         {
    9625                 :           1 :           inside_init
    9626                 :           1 :             = valid_compound_expr_initializer (inside_init,
    9627                 :           1 :                                                TREE_TYPE (inside_init));
    9628                 :           1 :           if (inside_init == error_mark_node)
    9629                 :           1 :             error_init (init_loc, "initializer element is not constant");
    9630                 :             :           else
    9631                 :           0 :             pedwarn_init (init_loc, OPT_Wpedantic,
    9632                 :             :                           "initializer element is not constant");
    9633                 :           1 :           if (flag_pedantic_errors)
    9634                 :           0 :             inside_init = error_mark_node;
    9635                 :             :         }
    9636                 :     2296585 :       else if (require_constant
    9637                 :     2296585 :                && !initializer_constant_valid_p (inside_init,
    9638                 :     2296585 :                                                  TREE_TYPE (inside_init)))
    9639                 :             :         {
    9640                 :          94 :           error_init (init_loc, "initializer element is not constant");
    9641                 :          94 :           inside_init = error_mark_node;
    9642                 :             :         }
    9643                 :    12845972 :       else if (require_constant && !maybe_const)
    9644                 :         219 :         pedwarn_init (init_loc, OPT_Wpedantic,
    9645                 :             :                       "initializer element is not a constant expression");
    9646                 :    12845753 :       else if (require_constexpr)
    9647                 :         574 :         check_constexpr_init (init_loc, type, inside_init,
    9648                 :             :                               int_const_expr, arith_const_expr);
    9649                 :             : 
    9650                 :             :       /* Added to enable additional -Wsuggest-attribute=format warnings.  */
    9651                 :    12846067 :       if (TREE_CODE (TREE_TYPE (inside_init)) == POINTER_TYPE)
    9652                 :      850973 :         inside_init = convert_for_assignment (init_loc, UNKNOWN_LOCATION,
    9653                 :             :                                               type, inside_init, origtype,
    9654                 :             :                                               (require_constant
    9655                 :             :                                                ? ic_init_const
    9656                 :             :                                                : ic_init), null_pointer_constant,
    9657                 :             :                                               NULL_TREE, NULL_TREE, 0);
    9658                 :    12846067 :       if (TREE_CODE (inside_init) == RAW_DATA_CST
    9659                 :         252 :           && c_inhibit_evaluation_warnings == 0
    9660                 :         252 :           && warn_conversion
    9661                 :           1 :           && !TYPE_UNSIGNED (type)
    9662                 :    12846068 :           && TYPE_PRECISION (type) == CHAR_BIT)
    9663                 :         303 :         for (unsigned int i = 0;
    9664                 :         304 :              i < (unsigned) RAW_DATA_LENGTH (inside_init); ++i)
    9665                 :         303 :           if (RAW_DATA_SCHAR_ELT (inside_init, i) < 0)
    9666                 :          10 :             warning_at (init_loc, OPT_Wconversion,
    9667                 :             :                         "conversion from %qT to %qT changes value from "
    9668                 :             :                         "%qd to %qd",
    9669                 :             :                         integer_type_node, type,
    9670                 :          10 :                         RAW_DATA_UCHAR_ELT (inside_init, i),
    9671                 :          10 :                         RAW_DATA_SCHAR_ELT (inside_init, i));
    9672                 :    12846067 :       return inside_init;
    9673                 :             :     }
    9674                 :             : 
    9675                 :             :   /* Handle scalar types, including conversions.  */
    9676                 :             : 
    9677                 :     3068941 :   if (code == INTEGER_TYPE || code == REAL_TYPE || code == FIXED_POINT_TYPE
    9678                 :      127485 :       || code == POINTER_TYPE || code == ENUMERAL_TYPE || code == BOOLEAN_TYPE
    9679                 :       10985 :       || code == COMPLEX_TYPE || code == VECTOR_TYPE || code == NULLPTR_TYPE
    9680                 :        8953 :       || code == BITINT_TYPE)
    9681                 :             :     {
    9682                 :     3068459 :       tree unconverted_init = inside_init;
    9683                 :     3068459 :       if (TREE_CODE (TREE_TYPE (init)) == ARRAY_TYPE
    9684                 :     3068459 :           && (TREE_CODE (init) == STRING_CST
    9685                 :           1 :               || TREE_CODE (init) == COMPOUND_LITERAL_EXPR))
    9686                 :        7287 :         inside_init = init = array_to_pointer_conversion (init_loc, init);
    9687                 :     3068459 :       if (semantic_type)
    9688                 :         432 :         inside_init = build1 (EXCESS_PRECISION_EXPR, semantic_type,
    9689                 :             :                               inside_init);
    9690                 :     3068459 :       inside_init
    9691                 :     5559250 :         = convert_for_assignment (init_loc, UNKNOWN_LOCATION, type,
    9692                 :             :                                   inside_init, origtype,
    9693                 :             :                                   require_constant ? ic_init_const : ic_init,
    9694                 :             :                                   null_pointer_constant, NULL_TREE, NULL_TREE,
    9695                 :             :                                   0);
    9696                 :             : 
    9697                 :             :       /* Check to see if we have already given an error message.  */
    9698                 :     3068459 :       if (inside_init == error_mark_node)
    9699                 :             :         ;
    9700                 :     3068001 :       else if (require_constant && !TREE_CONSTANT (inside_init))
    9701                 :             :         {
    9702                 :          36 :           error_init (init_loc, "initializer element is not constant");
    9703                 :          36 :           inside_init = error_mark_node;
    9704                 :             :         }
    9705                 :     3067965 :       else if (require_constant
    9706                 :     3645205 :                && !initializer_constant_valid_p (inside_init,
    9707                 :      577240 :                                                  TREE_TYPE (inside_init)))
    9708                 :             :         {
    9709                 :          10 :           error_init (init_loc, "initializer element is not computable at "
    9710                 :             :                       "load time");
    9711                 :          10 :           inside_init = error_mark_node;
    9712                 :             :         }
    9713                 :     3067955 :       else if (require_constant && !maybe_const)
    9714                 :           5 :         pedwarn_init (init_loc, OPT_Wpedantic,
    9715                 :             :                       "initializer element is not a constant expression");
    9716                 :     3067950 :       else if (require_constexpr)
    9717                 :         324 :         check_constexpr_init (init_loc, type, unconverted_init,
    9718                 :             :                               int_const_expr, arith_const_expr);
    9719                 :             : 
    9720                 :     3068459 :       return inside_init;
    9721                 :             :     }
    9722                 :             : 
    9723                 :             :   /* Come here only for records and arrays.  */
    9724                 :             : 
    9725                 :         482 :   if (COMPLETE_TYPE_P (type) && TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST)
    9726                 :             :     {
    9727                 :           0 :       error_init (init_loc,
    9728                 :             :                   "variable-sized object may not be initialized except "
    9729                 :             :                   "with an empty initializer");
    9730                 :           0 :       return error_mark_node;
    9731                 :             :     }
    9732                 :             : 
    9733                 :         482 :   error_init (init_loc, "invalid initializer");
    9734                 :         482 :   return error_mark_node;
    9735                 :             : }
    9736                 :             : 
    9737                 :             : /* Handle initializers that use braces.  */
    9738                 :             : 
    9739                 :             : /* Type of object we are accumulating a constructor for.
    9740                 :             :    This type is always a RECORD_TYPE, UNION_TYPE or ARRAY_TYPE.  */
    9741                 :             : static tree constructor_type;
    9742                 :             : 
    9743                 :             : /* For a RECORD_TYPE or UNION_TYPE, this is the chain of fields
    9744                 :             :    left to fill.  */
    9745                 :             : static tree constructor_fields;
    9746                 :             : 
    9747                 :             : /* For an ARRAY_TYPE, this is the specified index
    9748                 :             :    at which to store the next element we get.  */
    9749                 :             : static tree constructor_index;
    9750                 :             : 
    9751                 :             : /* For an ARRAY_TYPE, this is the maximum index.  */
    9752                 :             : static tree constructor_max_index;
    9753                 :             : 
    9754                 :             : /* For a RECORD_TYPE, this is the first field not yet written out.  */
    9755                 :             : static tree constructor_unfilled_fields;
    9756                 :             : 
    9757                 :             : /* For an ARRAY_TYPE, this is the index of the first element
    9758                 :             :    not yet written out.  */
    9759                 :             : static tree constructor_unfilled_index;
    9760                 :             : 
    9761                 :             : /* In a RECORD_TYPE, the byte index of the next consecutive field.
    9762                 :             :    This is so we can generate gaps between fields, when appropriate.  */
    9763                 :             : static tree constructor_bit_index;
    9764                 :             : 
    9765                 :             : /* If we are saving up the elements rather than allocating them,
    9766                 :             :    this is the list of elements so far (in reverse order,
    9767                 :             :    most recent first).  */
    9768                 :             : static vec<constructor_elt, va_gc> *constructor_elements;
    9769                 :             : 
    9770                 :             : /* 1 if constructor should be incrementally stored into a constructor chain,
    9771                 :             :    0 if all the elements should be kept in AVL tree.  */
    9772                 :             : static int constructor_incremental;
    9773                 :             : 
    9774                 :             : /* 1 if so far this constructor's elements are all compile-time constants.  */
    9775                 :             : static int constructor_constant;
    9776                 :             : 
    9777                 :             : /* 1 if so far this constructor's elements are all valid address constants.  */
    9778                 :             : static int constructor_simple;
    9779                 :             : 
    9780                 :             : /* 1 if this constructor has an element that cannot be part of a
    9781                 :             :    constant expression.  */
    9782                 :             : static int constructor_nonconst;
    9783                 :             : 
    9784                 :             : /* 1 if this constructor is erroneous so far.  */
    9785                 :             : static int constructor_erroneous;
    9786                 :             : 
    9787                 :             : /* 1 if this constructor is the universal zero initializer { 0 }.  */
    9788                 :             : static int constructor_zeroinit;
    9789                 :             : 
    9790                 :             : /* 1 if this constructor should have padding bits zeroed (C23 {}.  */
    9791                 :             : static bool constructor_zero_padding_bits;
    9792                 :             : 
    9793                 :             : /* Structure for managing pending initializer elements, organized as an
    9794                 :             :    AVL tree.  */
    9795                 :             : 
    9796                 :             : struct init_node
    9797                 :             : {
    9798                 :             :   struct init_node *left, *right;
    9799                 :             :   struct init_node *parent;
    9800                 :             :   int balance;
    9801                 :             :   tree purpose;
    9802                 :             :   tree value;
    9803                 :             :   tree origtype;
    9804                 :             : };
    9805                 :             : 
    9806                 :             : /* Tree of pending elements at this constructor level.
    9807                 :             :    These are elements encountered out of order
    9808                 :             :    which belong at places we haven't reached yet in actually
    9809                 :             :    writing the output.
    9810                 :             :    Will never hold tree nodes across GC runs.  */
    9811                 :             : static struct init_node *constructor_pending_elts;
    9812                 :             : 
    9813                 :             : /* The SPELLING_DEPTH of this constructor.  */
    9814                 :             : static int constructor_depth;
    9815                 :             : 
    9816                 :             : /* DECL node for which an initializer is being read.
    9817                 :             :    0 means we are reading a constructor expression
    9818                 :             :    such as (struct foo) {...}.  */
    9819                 :             : static tree constructor_decl;
    9820                 :             : 
    9821                 :             : /* Nonzero if there were any member designators in this initializer.  */
    9822                 :             : static int constructor_designated;
    9823                 :             : 
    9824                 :             : /* Nesting depth of designator list.  */
    9825                 :             : static int designator_depth;
    9826                 :             : 
    9827                 :             : /* Nonzero if there were diagnosed errors in this designator list.  */
    9828                 :             : static int designator_erroneous;
    9829                 :             : 
    9830                 :             : 
    9831                 :             : /* This stack has a level for each implicit or explicit level of
    9832                 :             :    structuring in the initializer, including the outermost one.  It
    9833                 :             :    saves the values of most of the variables above.  */
    9834                 :             : 
    9835                 :             : struct constructor_range_stack;
    9836                 :             : 
    9837                 :             : struct constructor_stack
    9838                 :             : {
    9839                 :             :   struct constructor_stack *next;
    9840                 :             :   tree type;
    9841                 :             :   tree fields;
    9842                 :             :   tree index;
    9843                 :             :   tree max_index;
    9844                 :             :   tree unfilled_index;
    9845                 :             :   tree unfilled_fields;
    9846                 :             :   tree bit_index;
    9847                 :             :   vec<constructor_elt, va_gc> *elements;
    9848                 :             :   struct init_node *pending_elts;
    9849                 :             :   int offset;
    9850                 :             :   int depth;
    9851                 :             :   /* If value nonzero, this value should replace the entire
    9852                 :             :      constructor at this level.  */
    9853                 :             :   struct c_expr replacement_value;
    9854                 :             :   struct constructor_range_stack *range_stack;
    9855                 :             :   char constant;
    9856                 :             :   char simple;
    9857                 :             :   char nonconst;
    9858                 :             :   char implicit;
    9859                 :             :   char erroneous;
    9860                 :             :   char outer;
    9861                 :             :   char incremental;
    9862                 :             :   char designated;
    9863                 :             :   bool zero_padding_bits;
    9864                 :             :   int designator_depth;
    9865                 :             : };
    9866                 :             : 
    9867                 :             : static struct constructor_stack *constructor_stack;
    9868                 :             : 
    9869                 :             : /* This stack represents designators from some range designator up to
    9870                 :             :    the last designator in the list.  */
    9871                 :             : 
    9872                 :             : struct constructor_range_stack
    9873                 :             : {
    9874                 :             :   struct constructor_range_stack *next, *prev;
    9875                 :             :   struct constructor_stack *stack;
    9876                 :             :   tree range_start;
    9877                 :             :   tree index;
    9878                 :             :   tree range_end;
    9879                 :             :   tree fields;
    9880                 :             : };
    9881                 :             : 
    9882                 :             : static struct constructor_range_stack *constructor_range_stack;
    9883                 :             : 
    9884                 :             : /* This stack records separate initializers that are nested.
    9885                 :             :    Nested initializers can't happen in ANSI C, but GNU C allows them
    9886                 :             :    in cases like { ... (struct foo) { ... } ... }.  */
    9887                 :             : 
    9888                 :             : struct initializer_stack
    9889                 :             : {
    9890                 :             :   struct initializer_stack *next;
    9891                 :             :   tree decl;
    9892                 :             :   struct constructor_stack *constructor_stack;
    9893                 :             :   struct constructor_range_stack *constructor_range_stack;
    9894                 :             :   vec<constructor_elt, va_gc> *elements;
    9895                 :             :   struct spelling *spelling;
    9896                 :             :   struct spelling *spelling_base;
    9897                 :             :   int spelling_size;
    9898                 :             :   char require_constant_value;
    9899                 :             :   char require_constant_elements;
    9900                 :             :   char require_constexpr_value;
    9901                 :             :   char designated;
    9902                 :             :   rich_location *missing_brace_richloc;
    9903                 :             : };
    9904                 :             : 
    9905                 :             : static struct initializer_stack *initializer_stack;
    9906                 :             : 
    9907                 :             : /* Prepare to parse and output the initializer for variable DECL.  */
    9908                 :             : 
    9909                 :             : void
    9910                 :     7088102 : start_init (tree decl, tree asmspec_tree ATTRIBUTE_UNUSED,
    9911                 :             :             bool init_require_constant, bool init_require_constexpr,
    9912                 :             :             rich_location *richloc)
    9913                 :             : {
    9914                 :     7088102 :   const char *locus;
    9915                 :     7088102 :   struct initializer_stack *p = XNEW (struct initializer_stack);
    9916                 :             : 
    9917                 :     7088102 :   p->decl = constructor_decl;
    9918                 :     7088102 :   p->require_constant_value = require_constant_value;
    9919                 :     7088102 :   p->require_constant_elements = require_constant_elements;
    9920                 :     7088102 :   p->require_constexpr_value = require_constexpr_value;
    9921                 :     7088102 :   p->constructor_stack = constructor_stack;
    9922                 :     7088102 :   p->constructor_range_stack = constructor_range_stack;
    9923                 :     7088102 :   p->elements = constructor_elements;
    9924                 :     7088102 :   p->spelling = spelling;
    9925                 :     7088102 :   p->spelling_base = spelling_base;
    9926                 :     7088102 :   p->spelling_size = spelling_size;
    9927                 :     7088102 :   p->next = initializer_stack;
    9928                 :     7088102 :   p->missing_brace_richloc = richloc;
    9929                 :     7088102 :   p->designated = constructor_designated;
    9930                 :     7088102 :   initializer_stack = p;
    9931                 :             : 
    9932                 :     7088102 :   constructor_decl = decl;
    9933                 :     7088102 :   constructor_designated = 0;
    9934                 :             : 
    9935                 :     7088102 :   require_constant_value = init_require_constant;
    9936                 :     7088102 :   require_constexpr_value = init_require_constexpr;
    9937                 :     7088102 :   if (decl != NULL_TREE && decl != error_mark_node)
    9938                 :             :     {
    9939                 :     6188903 :       require_constant_elements
    9940                 :     6012466 :         = ((init_require_constant || (pedantic && !flag_isoc99))
    9941                 :             :            /* For a scalar, you can always use any value to initialize,
    9942                 :             :               even within braces.  */
    9943                 :     6200855 :            && AGGREGATE_TYPE_P (TREE_TYPE (decl)));
    9944                 :     6188903 :       locus = identifier_to_locale (IDENTIFIER_POINTER (DECL_NAME (decl)));
    9945                 :             :     }
    9946                 :             :   else
    9947                 :             :     {
    9948                 :      899199 :       require_constant_elements = false;
    9949                 :      899199 :       locus = _("(anonymous)");
    9950                 :             :     }
    9951                 :             : 
    9952                 :     7088102 :   constructor_stack = 0;
    9953                 :     7088102 :   constructor_range_stack = 0;
    9954                 :             : 
    9955                 :     7088102 :   found_missing_braces = 0;
    9956                 :             : 
    9957                 :     7088102 :   spelling_base = 0;
    9958                 :     7088102 :   spelling_size = 0;
    9959                 :     7088102 :   RESTORE_SPELLING_DEPTH (0);
    9960                 :             : 
    9961                 :     7088102 :   if (locus)
    9962                 :     7088102 :     push_string (locus);
    9963                 :     7088102 : }
    9964                 :             : 
    9965                 :             : void
    9966                 :     7088100 : finish_init (void)
    9967                 :             : {
    9968                 :     7088100 :   struct initializer_stack *p = initializer_stack;
    9969                 :             : 
    9970                 :             :   /* Free the whole constructor stack of this initializer.  */
    9971                 :     7088100 :   while (constructor_stack)
    9972                 :             :     {
    9973                 :           0 :       struct constructor_stack *q = constructor_stack;
    9974                 :           0 :       constructor_stack = q->next;
    9975                 :           0 :       XDELETE (q);
    9976                 :             :     }
    9977                 :             : 
    9978                 :     7088100 :   gcc_assert (!constructor_range_stack);
    9979                 :             : 
    9980                 :             :   /* Pop back to the data of the outer initializer (if any).  */
    9981                 :     7088100 :   XDELETE (spelling_base);
    9982                 :             : 
    9983                 :     7088100 :   constructor_decl = p->decl;
    9984                 :     7088100 :   require_constant_value = p->require_constant_value;
    9985                 :     7088100 :   require_constant_elements = p->require_constant_elements;
    9986                 :     7088100 :   require_constexpr_value = p->require_constexpr_value;
    9987                 :     7088100 :   constructor_stack = p->constructor_stack;
    9988                 :     7088100 :   constructor_designated = p->designated;
    9989                 :     7088100 :   constructor_range_stack = p->constructor_range_stack;
    9990                 :     7088100 :   constructor_elements = p->elements;
    9991                 :     7088100 :   spelling = p->spelling;
    9992                 :     7088100 :   spelling_base = p->spelling_base;
    9993                 :     7088100 :   spelling_size = p->spelling_size;
    9994                 :     7088100 :   initializer_stack = p->next;
    9995                 :     7088100 :   XDELETE (p);
    9996                 :     7088100 : }
    9997                 :             : 
    9998                 :             : /* Call here when we see the initializer is surrounded by braces.
    9999                 :             :    This is instead of a call to push_init_level;
   10000                 :             :    it is matched by a call to pop_init_level.
   10001                 :             : 
   10002                 :             :    TYPE is the type to initialize, for a constructor expression.
   10003                 :             :    For an initializer for a decl, TYPE is zero.  */
   10004                 :             : 
   10005                 :             : void
   10006                 :     1001356 : really_start_incremental_init (tree type)
   10007                 :             : {
   10008                 :     1001356 :   struct constructor_stack *p = XNEW (struct constructor_stack);
   10009                 :             : 
   10010                 :     1001356 :   if (type == NULL_TREE)
   10011                 :      104069 :     type = TREE_TYPE (constructor_decl);
   10012                 :             : 
   10013                 :     1001356 :   if (VECTOR_TYPE_P (type)
   10014                 :     1001356 :       && TYPE_VECTOR_OPAQUE (type))
   10015                 :           0 :     error ("opaque vector types cannot be initialized");
   10016                 :             : 
   10017                 :     1001356 :   p->type = constructor_type;
   10018                 :     1001356 :   p->fields = constructor_fields;
   10019                 :     1001356 :   p->index = constructor_index;
   10020                 :     1001356 :   p->max_index = constructor_max_index;
   10021                 :     1001356 :   p->unfilled_index = constructor_unfilled_index;
   10022                 :     1001356 :   p->unfilled_fields = constructor_unfilled_fields;
   10023                 :     1001356 :   p->bit_index = constructor_bit_index;
   10024                 :     1001356 :   p->elements = constructor_elements;
   10025                 :     1001356 :   p->constant = constructor_constant;
   10026                 :     1001356 :   p->simple = constructor_simple;
   10027                 :     1001356 :   p->nonconst = constructor_nonconst;
   10028                 :     1001356 :   p->erroneous = constructor_erroneous;
   10029                 :     1001356 :   p->pending_elts = constructor_pending_elts;
   10030                 :     1001356 :   p->depth = constructor_depth;
   10031                 :     1001356 :   p->replacement_value.value = 0;
   10032                 :     1001356 :   p->replacement_value.original_code = ERROR_MARK;
   10033                 :     1001356 :   p->replacement_value.original_type = NULL;
   10034                 :     1001356 :   p->implicit = 0;
   10035                 :     1001356 :   p->range_stack = 0;
   10036                 :     1001356 :   p->outer = 0;
   10037                 :     1001356 :   p->incremental = constructor_incremental;
   10038                 :     1001356 :   p->designated = constructor_designated;
   10039                 :     1001356 :   p->zero_padding_bits = constructor_zero_padding_bits;
   10040                 :     1001356 :   p->designator_depth = designator_depth;
   10041                 :     1001356 :   p->next = 0;
   10042                 :     1001356 :   constructor_stack = p;
   10043                 :             : 
   10044                 :     1001356 :   constructor_constant = 1;
   10045                 :     1001356 :   constructor_simple = 1;
   10046                 :     1001356 :   constructor_nonconst = 0;
   10047                 :     1001356 :   constructor_depth = SPELLING_DEPTH ();
   10048                 :     1001356 :   constructor_elements = NULL;
   10049                 :     1001356 :   constructor_pending_elts = 0;
   10050                 :     1001356 :   constructor_type = type;
   10051                 :     1001356 :   constructor_incremental = 1;
   10052                 :     1001356 :   constructor_designated = 0;
   10053                 :     1001356 :   constructor_zero_padding_bits = false;
   10054                 :     1001356 :   constructor_zeroinit = 1;
   10055                 :     1001356 :   designator_depth = 0;
   10056                 :     1001356 :   designator_erroneous = 0;
   10057                 :             : 
   10058                 :     1001356 :   if (RECORD_OR_UNION_TYPE_P (constructor_type))
   10059                 :             :     {
   10060                 :       80223 :       constructor_fields = TYPE_FIELDS (constructor_type);
   10061                 :             :       /* Skip any nameless bit fields at the beginning.  */
   10062                 :       80223 :       while (constructor_fields != NULL_TREE
   10063                 :       80251 :              && DECL_UNNAMED_BIT_FIELD (constructor_fields))
   10064                 :          28 :         constructor_fields = DECL_CHAIN (constructor_fields);
   10065                 :             : 
   10066                 :       80223 :       constructor_unfilled_fields = constructor_fields;
   10067                 :       80223 :       constructor_bit_index = bitsize_zero_node;
   10068                 :             :     }
   10069                 :      921133 :   else if (TREE_CODE (constructor_type) == ARRAY_TYPE)
   10070                 :             :     {
   10071                 :       17621 :       if (TYPE_DOMAIN (constructor_type))
   10072                 :             :         {
   10073                 :        9287 :           constructor_max_index
   10074                 :        9287 :             = TYPE_MAX_VALUE (TYPE_DOMAIN (constructor_type));
   10075                 :             : 
   10076                 :             :           /* Detect non-empty initializations of zero-length arrays.  */
   10077                 :        9287 :           if (constructor_max_index == NULL_TREE
   10078                 :        9287 :               && TYPE_SIZE (constructor_type))
   10079                 :         205 :             constructor_max_index = integer_minus_one_node;
   10080                 :             : 
   10081                 :             :           /* constructor_max_index needs to be an INTEGER_CST.  Attempts
   10082                 :             :              to initialize VLAs with a nonempty initializer will cause a
   10083                 :             :              proper error; avoid tree checking errors as well by setting a
   10084                 :             :              safe value.  */
   10085                 :        9287 :           if (constructor_max_index
   10086                 :        9287 :               && TREE_CODE (constructor_max_index) != INTEGER_CST)
   10087                 :          59 :             constructor_max_index = integer_minus_one_node;
   10088                 :             : 
   10089                 :        9287 :           constructor_index
   10090                 :        9287 :             = convert (bitsizetype,
   10091                 :        9287 :                        TYPE_MIN_VALUE (TYPE_DOMAIN (constructor_type)));
   10092                 :             :         }
   10093                 :             :       else
   10094                 :             :         {
   10095                 :        8334 :           constructor_index = bitsize_zero_node;
   10096                 :        8334 :           constructor_max_index = NULL_TREE;
   10097                 :             :         }
   10098                 :             : 
   10099                 :       17621 :       constructor_unfilled_index = constructor_index;
   10100                 :             :     }
   10101                 :      903512 :   else if (gnu_vector_type_p (constructor_type))
   10102                 :             :     {
   10103                 :             :       /* Vectors are like simple fixed-size arrays.  */
   10104                 :     1805952 :       constructor_max_index =
   10105                 :      902976 :         bitsize_int (TYPE_VECTOR_SUBPARTS (constructor_type) - 1);
   10106                 :      902976 :       constructor_index = bitsize_zero_node;
   10107                 :      902976 :       constructor_unfilled_index = constructor_index;
   10108                 :             :     }
   10109                 :             :   else
   10110                 :             :     {
   10111                 :             :       /* Handle the case of int x = {5}; */
   10112                 :         536 :       constructor_fields = constructor_type;
   10113                 :         536 :       constructor_unfilled_fields = constructor_type;
   10114                 :             :     }
   10115                 :     1001356 : }
   10116                 :             : 
   10117                 :             : extern location_t last_init_list_comma;
   10118                 :             : 
   10119                 :             : /* Called when we see an open brace for a nested initializer.  Finish
   10120                 :             :    off any pending levels with implicit braces.  */
   10121                 :             : void
   10122                 :      340282 : finish_implicit_inits (location_t loc, struct obstack *braced_init_obstack)
   10123                 :             : {
   10124                 :      340284 :   while (constructor_stack->implicit)
   10125                 :             :     {
   10126                 :         304 :       if (RECORD_OR_UNION_TYPE_P (constructor_type)
   10127                 :         140 :           && constructor_fields == NULL_TREE)
   10128                 :           0 :         process_init_element (input_location,
   10129                 :             :                               pop_init_level (loc, 1, braced_init_obstack,
   10130                 :             :                                               last_init_list_comma),
   10131                 :             :                               true, braced_init_obstack);
   10132                 :         304 :       else if (TREE_CODE (constructor_type) == ARRAY_TYPE
   10133                 :         164 :                && constructor_max_index
   10134                 :         468 :                && tree_int_cst_lt (constructor_max_index,
   10135                 :             :                                    constructor_index))
   10136                 :           2 :         process_init_element (input_location,
   10137                 :             :                               pop_init_level (loc, 1, braced_init_obstack,
   10138                 :             :                                               last_init_list_comma),
   10139                 :             :                               true, braced_init_obstack);
   10140                 :             :       else
   10141                 :             :         break;
   10142                 :             :     }
   10143                 :      340282 : }
   10144                 :             : 
   10145                 :             : /* Push down into a subobject, for initialization.
   10146                 :             :    If this is for an explicit set of braces, IMPLICIT is 0.
   10147                 :             :    If it is because the next element belongs at a lower level,
   10148                 :             :    IMPLICIT is 1 (or 2 if the push is because of designator list).  */
   10149                 :             : 
   10150                 :             : void
   10151                 :     1042892 : push_init_level (location_t loc, int implicit,
   10152                 :             :                  struct obstack *braced_init_obstack)
   10153                 :             : {
   10154                 :     1042892 :   struct constructor_stack *p;
   10155                 :     1042892 :   tree value = NULL_TREE;
   10156                 :             : 
   10157                 :             :   /* Unless this is an explicit brace, we need to preserve previous
   10158                 :             :      content if any.  */
   10159                 :     1042892 :   if (implicit)
   10160                 :             :     {
   10161                 :      703552 :       if (RECORD_OR_UNION_TYPE_P (constructor_type) && constructor_fields)
   10162                 :         778 :         value = find_init_member (constructor_fields, braced_init_obstack);
   10163                 :      702774 :       else if (TREE_CODE (constructor_type) == ARRAY_TYPE)
   10164                 :      702774 :         value = find_init_member (constructor_index, braced_init_obstack);
   10165                 :             :     }
   10166                 :             : 
   10167                 :     1042892 :   p = XNEW (struct constructor_stack);
   10168                 :     1042892 :   p->type = constructor_type;
   10169                 :     1042892 :   p->fields = constructor_fields;
   10170                 :     1042892 :   p->index = constructor_index;
   10171                 :     1042892 :   p->max_index = constructor_max_index;
   10172                 :     1042892 :   p->unfilled_index = constructor_unfilled_index;
   10173                 :     1042892 :   p->unfilled_fields = constructor_unfilled_fields;
   10174                 :     1042892 :   p->bit_index = constructor_bit_index;
   10175                 :     1042892 :   p->elements = constructor_elements;
   10176                 :     1042892 :   p->constant = constructor_constant;
   10177                 :     1042892 :   p->simple = constructor_simple;
   10178                 :     1042892 :   p->nonconst = constructor_nonconst;
   10179                 :     1042892 :   p->erroneous = constructor_erroneous;
   10180                 :     1042892 :   p->pending_elts = constructor_pending_elts;
   10181                 :     1042892 :   p->depth = constructor_depth;
   10182                 :     1042892 :   p->replacement_value.value = NULL_TREE;
   10183                 :     1042892 :   p->replacement_value.original_code = ERROR_MARK;
   10184                 :     1042892 :   p->replacement_value.original_type = NULL;
   10185                 :     1042892 :   p->implicit = implicit;
   10186                 :     1042892 :   p->outer = 0;
   10187                 :     1042892 :   p->incremental = constructor_incremental;
   10188                 :     1042892 :   p->designated = constructor_designated;
   10189                 :     1042892 :   p->zero_padding_bits = constructor_zero_padding_bits;
   10190                 :     1042892 :   p->designator_depth = designator_depth;
   10191                 :     1042892 :   p->next = constructor_stack;
   10192                 :     1042892 :   p->range_stack = 0;
   10193                 :     1042892 :   constructor_stack = p;
   10194                 :             : 
   10195                 :     1042892 :   constructor_constant = 1;
   10196                 :     1042892 :   constructor_simple = 1;
   10197                 :     1042892 :   constructor_nonconst = 0;
   10198                 :     1042892 :   constructor_depth = SPELLING_DEPTH ();
   10199                 :     1042892 :   constructor_elements = NULL;
   10200                 :     1042892 :   constructor_incremental = 1;
   10201                 :             :   /* If the upper initializer is designated, then mark this as
   10202                 :             :      designated too to prevent bogus warnings.  */
   10203                 :     1042892 :   constructor_designated = p->designated;
   10204                 :             :   /* If the upper initializer has padding bits zeroed, that includes
   10205                 :             :      all nested initializers as well.  */
   10206                 :     1042892 :   constructor_zero_padding_bits = p->zero_padding_bits;
   10207                 :     1042892 :   constructor_pending_elts = 0;
   10208                 :     1042892 :   if (!implicit)
   10209                 :             :     {
   10210                 :      339340 :       p->range_stack = constructor_range_stack;
   10211                 :      339340 :       constructor_range_stack = 0;
   10212                 :      339340 :       designator_depth = 0;
   10213                 :      339340 :       designator_erroneous = 0;
   10214                 :             :     }
   10215                 :             : 
   10216                 :             :   /* Don't die if an entire brace-pair level is superfluous
   10217                 :             :      in the containing level.  */
   10218                 :     1042892 :   if (constructor_type == NULL_TREE)
   10219                 :             :     ;
   10220                 :     1042892 :   else if (RECORD_OR_UNION_TYPE_P (constructor_type))
   10221                 :             :     {
   10222                 :             :       /* Don't die if there are extra init elts at the end.  */
   10223                 :      158738 :       if (constructor_fields == NULL_TREE)
   10224                 :          51 :         constructor_type = NULL_TREE;
   10225                 :             :       else
   10226                 :             :         {
   10227                 :      158687 :           constructor_type = TREE_TYPE (constructor_fields);
   10228                 :      158687 :           push_member_name (constructor_fields);
   10229                 :      158687 :           constructor_depth++;
   10230                 :             :         }
   10231                 :             :     }
   10232                 :      884154 :   else if (TREE_CODE (constructor_type) == ARRAY_TYPE)
   10233                 :             :     {
   10234                 :      884116 :       constructor_type = TREE_TYPE (constructor_type);
   10235                 :      884116 :       push_array_bounds (tree_to_uhwi (constructor_index));
   10236                 :      884116 :       constructor_depth++;
   10237                 :             :     }
   10238                 :             : 
   10239                 :     1042892 :   if (constructor_type == NULL_TREE)
   10240                 :             :     {
   10241                 :          51 :       error_init (loc, "extra brace group at end of initializer");
   10242                 :          51 :       constructor_fields = NULL_TREE;
   10243                 :          51 :       constructor_unfilled_fields = NULL_TREE;
   10244                 :          51 :       return;
   10245                 :             :     }
   10246                 :             : 
   10247                 :     1042841 :   if (value && TREE_CODE (value) == CONSTRUCTOR)
   10248                 :             :     {
   10249                 :         360 :       constructor_constant = TREE_CONSTANT (value);
   10250                 :         360 :       constructor_simple = TREE_STATIC (value);
   10251                 :         360 :       constructor_nonconst = CONSTRUCTOR_NON_CONST (value);
   10252                 :         360 :       constructor_elements = CONSTRUCTOR_ELTS (value);
   10253                 :         360 :       constructor_zero_padding_bits |= CONSTRUCTOR_ZERO_PADDING_BITS (value);
   10254                 :         360 :       if (!vec_safe_is_empty (constructor_elements)
   10255                 :         340 :           && (TREE_CODE (constructor_type) == RECORD_TYPE
   10256                 :         340 :               || TREE_CODE (constructor_type) == ARRAY_TYPE))
   10257                 :         294 :         set_nonincremental_init (braced_init_obstack);
   10258                 :             :     }
   10259                 :             : 
   10260                 :     1042841 :   if (implicit == 1)
   10261                 :             :     {
   10262                 :      702610 :       found_missing_braces = 1;
   10263                 :      702610 :       if (initializer_stack->missing_brace_richloc)
   10264                 :      702610 :         initializer_stack->missing_brace_richloc->add_fixit_insert_before
   10265                 :      702610 :           (loc, "{");
   10266                 :             :     }
   10267                 :             : 
   10268                 :     1042841 :   if (RECORD_OR_UNION_TYPE_P (constructor_type))
   10269                 :             :     {
   10270                 :      879612 :       constructor_fields = TYPE_FIELDS (constructor_type);
   10271                 :             :       /* Skip any nameless bit fields at the beginning.  */
   10272                 :      879612 :       while (constructor_fields != NULL_TREE
   10273                 :      879676 :              && DECL_UNNAMED_BIT_FIELD (constructor_fields))
   10274                 :          64 :         constructor_fields = DECL_CHAIN (constructor_fields);
   10275                 :             : 
   10276                 :      879612 :       constructor_unfilled_fields = constructor_fields;
   10277                 :      879612 :       constructor_bit_index = bitsize_zero_node;
   10278                 :             :     }
   10279                 :      163229 :   else if (gnu_vector_type_p (constructor_type))
   10280                 :             :     {
   10281                 :             :       /* Vectors are like simple fixed-size arrays.  */
   10282                 :        9600 :       constructor_max_index =
   10283                 :        4800 :         bitsize_int (TYPE_VECTOR_SUBPARTS (constructor_type) - 1);
   10284                 :        4800 :       constructor_index = bitsize_int (0);
   10285                 :        4800 :       constructor_unfilled_index = constructor_index;
   10286                 :             :     }
   10287                 :      158429 :   else if (TREE_CODE (constructor_type) == ARRAY_TYPE)
   10288                 :             :     {
   10289                 :      158371 :       if (TYPE_DOMAIN (constructor_type))
   10290                 :             :         {
   10291                 :      158371 :           constructor_max_index
   10292                 :      158371 :             = TYPE_MAX_VALUE (TYPE_DOMAIN (constructor_type));
   10293                 :             : 
   10294                 :             :           /* Detect non-empty initializations of zero-length arrays.  */
   10295                 :      158371 :           if (constructor_max_index == NULL_TREE
   10296                 :      158371 :               && TYPE_SIZE (constructor_type))
   10297                 :         135 :             constructor_max_index = integer_minus_one_node;
   10298                 :             : 
   10299                 :             :           /* constructor_max_index needs to be an INTEGER_CST.  Attempts
   10300                 :             :              to initialize VLAs will cause a proper error; avoid tree
   10301                 :             :              checking errors as well by setting a safe value.  */
   10302                 :      158371 :           if (constructor_max_index
   10303                 :      158102 :               && TREE_CODE (constructor_max_index) != INTEGER_CST)
   10304                 :           0 :             constructor_max_index = integer_minus_one_node;
   10305                 :             : 
   10306                 :      158371 :           constructor_index
   10307                 :      158371 :             = convert (bitsizetype,
   10308                 :      158371 :                        TYPE_MIN_VALUE (TYPE_DOMAIN (constructor_type)));
   10309                 :             :         }
   10310                 :             :       else
   10311                 :           0 :         constructor_index = bitsize_zero_node;
   10312                 :             : 
   10313                 :      158371 :       constructor_unfilled_index = constructor_index;
   10314                 :      158371 :       if (value && TREE_CODE (value) == STRING_CST)
   10315                 :             :         {
   10316                 :             :           /* We need to split the char/wchar array into individual
   10317                 :             :              characters, so that we don't have to special case it
   10318                 :             :              everywhere.  */
   10319                 :           7 :           set_nonincremental_init_from_string (value, braced_init_obstack);
   10320                 :             :         }
   10321                 :             :     }
   10322                 :             :   else
   10323                 :             :     {
   10324                 :          58 :       if (constructor_type != error_mark_node)
   10325                 :          29 :         warning_init (input_location, 0, "braces around scalar initializer");
   10326                 :          58 :       constructor_fields = constructor_type;
   10327                 :          58 :       constructor_unfilled_fields = constructor_type;
   10328                 :             :     }
   10329                 :             : }
   10330                 :             : 
   10331                 :             : /* At the end of an implicit or explicit brace level,
   10332                 :             :    finish up that level of constructor.  If a single expression
   10333                 :             :    with redundant braces initialized that level, return the
   10334                 :             :    c_expr structure for that expression.  Otherwise, the original_code
   10335                 :             :    element is set to ERROR_MARK.
   10336                 :             :    If we were outputting the elements as they are read, return 0 as the value
   10337                 :             :    from inner levels (process_init_element ignores that),
   10338                 :             :    but return error_mark_node as the value from the outermost level
   10339                 :             :    (that's what we want to put in DECL_INITIAL).
   10340                 :             :    Otherwise, return a CONSTRUCTOR expression as the value.  */
   10341                 :             : 
   10342                 :             : struct c_expr
   10343                 :     2044248 : pop_init_level (location_t loc, int implicit,
   10344                 :             :                 struct obstack *braced_init_obstack,
   10345                 :             :                 location_t insert_before)
   10346                 :             : {
   10347                 :     2044248 :   struct constructor_stack *p;
   10348                 :     2044248 :   struct c_expr ret;
   10349                 :     2044248 :   ret.value = NULL_TREE;
   10350                 :     2044248 :   ret.original_code = ERROR_MARK;
   10351                 :     2044248 :   ret.original_type = NULL;
   10352                 :     2044248 :   ret.m_decimal = 0;
   10353                 :             : 
   10354                 :     2044248 :   if (implicit == 0)
   10355                 :             :     {
   10356                 :             :       /* When we come to an explicit close brace,
   10357                 :             :          pop any inner levels that didn't have explicit braces.  */
   10358                 :     1341580 :       while (constructor_stack->implicit)
   10359                 :         884 :         process_init_element (input_location,
   10360                 :             :                               pop_init_level (loc, 1, braced_init_obstack,
   10361                 :             :                                               insert_before),
   10362                 :             :                               true, braced_init_obstack);
   10363                 :     1340696 :       gcc_assert (!constructor_range_stack);
   10364                 :             :     }
   10365                 :             :   else
   10366                 :      703552 :     if (initializer_stack->missing_brace_richloc)
   10367                 :      703552 :       initializer_stack->missing_brace_richloc->add_fixit_insert_before
   10368                 :      703552 :         (insert_before, "}");
   10369                 :             : 
   10370                 :             :   /* Now output all pending elements.  */
   10371                 :     2044248 :   constructor_incremental = 1;
   10372                 :     2044248 :   output_pending_init_elements (1, braced_init_obstack);
   10373                 :             : 
   10374                 :     2044248 :   p = constructor_stack;
   10375                 :             : 
   10376                 :             :   /* Error for initializing a flexible array member, or a zero-length
   10377                 :             :      array member in an inappropriate context.  */
   10378                 :     2044197 :   if (constructor_type && constructor_fields
   10379                 :      159199 :       && TREE_CODE (constructor_type) == ARRAY_TYPE
   10380                 :      152511 :       && TYPE_DOMAIN (constructor_type)
   10381                 :     2196751 :       && !TYPE_MAX_VALUE (TYPE_DOMAIN (constructor_type)))
   10382                 :             :     {
   10383                 :             :       /* Silently discard empty initializations.  The parser will
   10384                 :             :          already have pedwarned for empty brackets for C17 and earlier.  */
   10385                 :         299 :       if (integer_zerop (constructor_unfilled_index))
   10386                 :          84 :         constructor_type = NULL_TREE;
   10387                 :         299 :       if (constructor_type || flag_isoc23)
   10388                 :             :         {
   10389                 :         295 :           gcc_assert (!constructor_type || !TYPE_SIZE (constructor_type));
   10390                 :             : 
   10391                 :         295 :           if (constructor_depth <= 2)
   10392                 :         248 :             pedwarn_init (loc, OPT_Wpedantic,
   10393                 :             :                           "initialization of a flexible array member");
   10394                 :          47 :           else if (constructor_type)
   10395                 :          33 :             error_init (loc, "initialization of flexible array member "
   10396                 :             :                              "in a nested context");
   10397                 :             :           else
   10398                 :          14 :             pedwarn_init (loc, OPT_Wpedantic,
   10399                 :             :                           "initialization of flexible array member "
   10400                 :             :                           "in a nested context");
   10401                 :             : 
   10402                 :             :           /* We have already issued an error message for the existence
   10403                 :             :              of a flexible array member not at the end of the structure.
   10404                 :             :              Discard the initializer so that we do not die later.  */
   10405                 :         295 :           if (constructor_type
   10406                 :         215 :               && DECL_CHAIN (constructor_fields) != NULL_TREE
   10407                 :         301 :               && (!p->type || TREE_CODE (p->type) != UNION_TYPE))
   10408                 :           0 :             constructor_type = NULL_TREE;
   10409                 :             :         }
   10410                 :             :     }
   10411                 :             : 
   10412                 :     2044248 :   switch (vec_safe_length (constructor_elements))
   10413                 :             :     {
   10414                 :        4593 :     case 0:
   10415                 :             :       /* Initialization with { } counts as zeroinit.  */
   10416                 :        4593 :       constructor_zeroinit = 1;
   10417                 :        4593 :       break;
   10418                 :      913857 :     case 1:
   10419                 :             :       /* This might be zeroinit as well.  */
   10420                 :      913857 :       if (integer_zerop ((*constructor_elements)[0].value))
   10421                 :        1861 :         constructor_zeroinit = 1;
   10422                 :             :       break;
   10423                 :     1125798 :     default:
   10424                 :             :       /* If the constructor has more than one element, it can't be { 0 }.  */
   10425                 :     1125798 :       constructor_zeroinit = 0;
   10426                 :     1125798 :       break;
   10427                 :             :     }
   10428                 :             : 
   10429                 :             :   /* Warn when some structs are initialized with direct aggregation.  */
   10430                 :     2044248 :   if (!implicit && found_missing_braces && warn_missing_braces
   10431                 :          37 :       && !constructor_zeroinit)
   10432                 :             :     {
   10433                 :          18 :       gcc_assert (initializer_stack->missing_brace_richloc);
   10434                 :          18 :       warning_at (initializer_stack->missing_brace_richloc,
   10435                 :          18 :                   OPT_Wmissing_braces,
   10436                 :             :                   "missing braces around initializer");
   10437                 :             :     }
   10438                 :             : 
   10439                 :             :   /* Warn when some struct elements are implicitly initialized to zero.  */
   10440                 :     2044248 :   if (warn_missing_field_initializers
   10441                 :      425443 :       && constructor_type
   10442                 :      425415 :       && TREE_CODE (constructor_type) == RECORD_TYPE
   10443                 :      193395 :       && constructor_unfilled_fields)
   10444                 :             :     {
   10445                 :             :         /* Do not warn for flexible array members or zero-length arrays.  */
   10446                 :          43 :         while (constructor_unfilled_fields
   10447                 :          43 :                && (!DECL_SIZE (constructor_unfilled_fields)
   10448                 :          43 :                    || integer_zerop (DECL_SIZE (constructor_unfilled_fields))))
   10449                 :           0 :           constructor_unfilled_fields = DECL_CHAIN (constructor_unfilled_fields);
   10450                 :             : 
   10451                 :          43 :         if (constructor_unfilled_fields
   10452                 :             :             /* Do not warn if this level of the initializer uses member
   10453                 :             :                designators; it is likely to be deliberate.  */
   10454                 :          43 :             && !constructor_designated
   10455                 :             :             /* Do not warn about initializing with { 0 } or with { }.  */
   10456                 :          24 :             && !constructor_zeroinit)
   10457                 :             :           {
   10458                 :          10 :             if (warning_at (input_location, OPT_Wmissing_field_initializers,
   10459                 :             :                             "missing initializer for field %qD of %qT",
   10460                 :             :                             constructor_unfilled_fields,
   10461                 :             :                             constructor_type))
   10462                 :          10 :               inform (DECL_SOURCE_LOCATION (constructor_unfilled_fields),
   10463                 :             :                       "%qD declared here", constructor_unfilled_fields);
   10464                 :             :           }
   10465                 :             :     }
   10466                 :             : 
   10467                 :             :   /* Pad out the end of the structure.  */
   10468                 :     2044248 :   if (p->replacement_value.value)
   10469                 :             :     /* If this closes a superfluous brace pair,
   10470                 :             :        just pass out the element between them.  */
   10471                 :         102 :     ret = p->replacement_value;
   10472                 :     2044146 :   else if (constructor_type == NULL_TREE)
   10473                 :             :     ;
   10474                 :     2044019 :   else if (!RECORD_OR_UNION_TYPE_P (constructor_type)
   10475                 :     2044019 :            && TREE_CODE (constructor_type) != ARRAY_TYPE
   10476                 :     2044019 :            && !gnu_vector_type_p (constructor_type))
   10477                 :             :     {
   10478                 :             :       /* A nonincremental scalar initializer--just return
   10479                 :             :          the element, after verifying there is just one.
   10480                 :             :          Empty scalar initializers are supported in C23.  */
   10481                 :         594 :       if (vec_safe_is_empty (constructor_elements))
   10482                 :             :         {
   10483                 :         207 :           if (constructor_erroneous || constructor_type == error_mark_node)
   10484                 :          94 :             ret.value = error_mark_node;
   10485                 :         113 :           else if (TREE_CODE (constructor_type) == FUNCTION_TYPE)
   10486                 :             :             {
   10487                 :           2 :               error_init (loc, "invalid initializer");
   10488                 :           2 :               ret.value = error_mark_node;
   10489                 :             :             }
   10490                 :         111 :           else if (TREE_CODE (constructor_type) == POINTER_TYPE)
   10491                 :             :             /* Ensure this is a null pointer constant in the case of a
   10492                 :             :                'constexpr' object initialized with {}.  */
   10493                 :          33 :             ret.value = build_zero_cst (ptr_type_node);
   10494                 :             :           else
   10495                 :          78 :             ret.value = build_zero_cst (constructor_type);
   10496                 :             :         }
   10497                 :         387 :       else if (vec_safe_length (constructor_elements) != 1)
   10498                 :             :         {
   10499                 :           0 :           error_init (loc, "extra elements in scalar initializer");
   10500                 :           0 :           ret.value = (*constructor_elements)[0].value;
   10501                 :             :         }
   10502                 :             :       else
   10503                 :         387 :         ret.value = (*constructor_elements)[0].value;
   10504                 :             :     }
   10505                 :             :   else
   10506                 :             :     {
   10507                 :     2043425 :       if (constructor_erroneous)
   10508                 :         493 :         ret.value = error_mark_node;
   10509                 :             :       else
   10510                 :             :         {
   10511                 :     2042932 :           ret.value = build_constructor (constructor_type,
   10512                 :             :                                          constructor_elements);
   10513                 :     2042932 :           if (constructor_constant)
   10514                 :     1721800 :             TREE_CONSTANT (ret.value) = 1;
   10515                 :     2042932 :           if (constructor_constant && constructor_simple)
   10516                 :     1721761 :             TREE_STATIC (ret.value) = 1;
   10517                 :     2042932 :           if (constructor_nonconst)
   10518                 :         613 :             CONSTRUCTOR_NON_CONST (ret.value) = 1;
   10519                 :     2042932 :           if (constructor_zero_padding_bits)
   10520                 :          20 :             CONSTRUCTOR_ZERO_PADDING_BITS (ret.value) = 1;
   10521                 :             :         }
   10522                 :             :     }
   10523                 :             : 
   10524                 :     2044248 :   if (ret.value && TREE_CODE (ret.value) != CONSTRUCTOR)
   10525                 :             :     {
   10526                 :        1189 :       if (constructor_nonconst)
   10527                 :          15 :         ret.original_code = C_MAYBE_CONST_EXPR;
   10528                 :        1174 :       else if (ret.original_code == C_MAYBE_CONST_EXPR)
   10529                 :           0 :         ret.original_code = ERROR_MARK;
   10530                 :             :     }
   10531                 :             : 
   10532                 :     2044248 :   constructor_type = p->type;
   10533                 :     2044248 :   constructor_fields = p->fields;
   10534                 :     2044248 :   constructor_index = p->index;
   10535                 :     2044248 :   constructor_max_index = p->max_index;
   10536                 :     2044248 :   constructor_unfilled_index = p->unfilled_index;
   10537                 :     2044248 :   constructor_unfilled_fields = p->unfilled_fields;
   10538                 :     2044248 :   constructor_bit_index = p->bit_index;
   10539                 :     2044248 :   constructor_elements = p->elements;
   10540                 :     2044248 :   constructor_constant = p->constant;
   10541                 :     2044248 :   constructor_simple = p->simple;
   10542                 :     2044248 :   constructor_nonconst = p->nonconst;
   10543                 :     2044248 :   constructor_erroneous = p->erroneous;
   10544                 :     2044248 :   constructor_incremental = p->incremental;
   10545                 :     2044248 :   constructor_designated = p->designated;
   10546                 :     2044248 :   constructor_zero_padding_bits = p->zero_padding_bits;
   10547                 :     2044248 :   designator_depth = p->designator_depth;
   10548                 :     2044248 :   constructor_pending_elts = p->pending_elts;
   10549                 :     2044248 :   constructor_depth = p->depth;
   10550                 :     2044248 :   if (!p->implicit)
   10551                 :     1340696 :     constructor_range_stack = p->range_stack;
   10552                 :     2044248 :   RESTORE_SPELLING_DEPTH (constructor_depth);
   10553                 :             : 
   10554                 :     2044248 :   constructor_stack = p->next;
   10555                 :     2044248 :   XDELETE (p);
   10556                 :             : 
   10557                 :     2044248 :   if (ret.value == NULL_TREE && constructor_stack == 0)
   10558                 :           0 :     ret.value = error_mark_node;
   10559                 :     2044248 :   return ret;
   10560                 :             : }
   10561                 :             : 
   10562                 :             : /* Common handling for both array range and field name designators.
   10563                 :             :    ARRAY argument is nonzero for array ranges.  Returns false for success.  */
   10564                 :             : 
   10565                 :             : static bool
   10566                 :       33060 : set_designator (location_t loc, bool array,
   10567                 :             :                 struct obstack *braced_init_obstack)
   10568                 :             : {
   10569                 :       33060 :   tree subtype;
   10570                 :       33060 :   enum tree_code subcode;
   10571                 :             : 
   10572                 :             :   /* Don't die if an entire brace-pair level is superfluous
   10573                 :             :      in the containing level, or for an erroneous type.  */
   10574                 :       33060 :   if (constructor_type == NULL_TREE || constructor_type == error_mark_node)
   10575                 :             :     return true;
   10576                 :             : 
   10577                 :             :   /* If there were errors in this designator list already, bail out
   10578                 :             :      silently.  */
   10579                 :       33051 :   if (designator_erroneous)
   10580                 :             :     return true;
   10581                 :             : 
   10582                 :             :   /* Likewise for an initializer for a variable-size type.  Those are
   10583                 :             :      diagnosed in the parser, except for empty initializer braces.  */
   10584                 :       33051 :   if (COMPLETE_TYPE_P (constructor_type)
   10585                 :       33051 :       && TREE_CODE (TYPE_SIZE (constructor_type)) != INTEGER_CST)
   10586                 :             :     return true;
   10587                 :             : 
   10588                 :       33041 :   if (!designator_depth)
   10589                 :             :     {
   10590                 :       32423 :       gcc_assert (!constructor_range_stack);
   10591                 :             : 
   10592                 :             :       /* Designator list starts at the level of closest explicit
   10593                 :             :          braces.  */
   10594                 :       32806 :       while (constructor_stack->implicit)
   10595                 :         383 :         process_init_element (input_location,
   10596                 :             :                               pop_init_level (loc, 1, braced_init_obstack,
   10597                 :             :                                               last_init_list_comma),
   10598                 :             :                               true, braced_init_obstack);
   10599                 :       32423 :       constructor_designated = 1;
   10600                 :       32423 :       return false;
   10601                 :             :     }
   10602                 :             : 
   10603                 :         618 :   switch (TREE_CODE (constructor_type))
   10604                 :             :     {
   10605                 :         421 :     case  RECORD_TYPE:
   10606                 :         421 :     case  UNION_TYPE:
   10607                 :         421 :       subtype = TREE_TYPE (constructor_fields);
   10608                 :         421 :       if (subtype != error_mark_node)
   10609                 :         421 :         subtype = TYPE_MAIN_VARIANT (subtype);
   10610                 :             :       break;
   10611                 :         197 :     case ARRAY_TYPE:
   10612                 :         197 :       subtype = TYPE_MAIN_VARIANT (TREE_TYPE (constructor_type));
   10613                 :         197 :       break;
   10614                 :           0 :     default:
   10615                 :           0 :       gcc_unreachable ();
   10616                 :             :     }
   10617                 :             : 
   10618                 :         618 :   subcode = TREE_CODE (subtype);
   10619                 :         618 :   if (array && subcode != ARRAY_TYPE)
   10620                 :             :     {
   10621                 :           1 :       error_init (loc, "array index in non-array initializer");
   10622                 :           1 :       return true;
   10623                 :             :     }
   10624                 :         617 :   else if (!array && subcode != RECORD_TYPE && subcode != UNION_TYPE)
   10625                 :             :     {
   10626                 :           0 :       error_init (loc, "field name not in record or union initializer");
   10627                 :           0 :       return true;
   10628                 :             :     }
   10629                 :             : 
   10630                 :         617 :   constructor_designated = 1;
   10631                 :         617 :   finish_implicit_inits (loc, braced_init_obstack);
   10632                 :         617 :   push_init_level (loc, 2, braced_init_obstack);
   10633                 :         617 :   return false;
   10634                 :             : }
   10635                 :             : 
   10636                 :             : /* If there are range designators in designator list, push a new designator
   10637                 :             :    to constructor_range_stack.  RANGE_END is end of such stack range or
   10638                 :             :    NULL_TREE if there is no range designator at this level.  */
   10639                 :             : 
   10640                 :             : static void
   10641                 :         384 : push_range_stack (tree range_end, struct obstack * braced_init_obstack)
   10642                 :             : {
   10643                 :         384 :   struct constructor_range_stack *p;
   10644                 :             : 
   10645                 :         768 :   p = (struct constructor_range_stack *)
   10646                 :         384 :     obstack_alloc (braced_init_obstack,
   10647                 :             :                    sizeof (struct constructor_range_stack));
   10648                 :         384 :   p->prev = constructor_range_stack;
   10649                 :         384 :   p->next = 0;
   10650                 :         384 :   p->fields = constructor_fields;
   10651                 :         384 :   p->range_start = constructor_index;
   10652                 :         384 :   p->index = constructor_index;
   10653                 :         384 :   p->stack = constructor_stack;
   10654                 :         384 :   p->range_end = range_end;
   10655                 :         384 :   if (constructor_range_stack)
   10656                 :          19 :     constructor_range_stack->next = p;
   10657                 :         384 :   constructor_range_stack = p;
   10658                 :         384 : }
   10659                 :             : 
   10660                 :             : /* Within an array initializer, specify the next index to be initialized.
   10661                 :             :    FIRST is that index.  If LAST is nonzero, then initialize a range
   10662                 :             :    of indices, running from FIRST through LAST.  */
   10663                 :             : 
   10664                 :             : void
   10665                 :        1143 : set_init_index (location_t loc, tree first, tree last,
   10666                 :             :                 struct obstack *braced_init_obstack)
   10667                 :             : {
   10668                 :        1143 :   if (set_designator (loc, true, braced_init_obstack))
   10669                 :             :     return;
   10670                 :             : 
   10671                 :        1140 :   designator_erroneous = 1;
   10672                 :             : 
   10673                 :        2280 :   if (!INTEGRAL_TYPE_P (TREE_TYPE (first))
   10674                 :        2269 :       || (last && !INTEGRAL_TYPE_P (TREE_TYPE (last))))
   10675                 :             :     {
   10676                 :          12 :       error_init (loc, "array index in initializer not of integer type");
   10677                 :          12 :       return;
   10678                 :             :     }
   10679                 :             : 
   10680                 :        1128 :   if (TREE_CODE (first) != INTEGER_CST)
   10681                 :             :     {
   10682                 :           6 :       first = c_fully_fold (first, false, NULL);
   10683                 :           6 :       if (TREE_CODE (first) == INTEGER_CST)
   10684                 :           5 :         pedwarn_init (loc, OPT_Wpedantic,
   10685                 :             :                       "array index in initializer is not "
   10686                 :             :                       "an integer constant expression");
   10687                 :             :     }
   10688                 :             : 
   10689                 :        1128 :   if (last && TREE_CODE (last) != INTEGER_CST)
   10690                 :             :     {
   10691                 :           2 :       last = c_fully_fold (last, false, NULL);
   10692                 :           2 :       if (TREE_CODE (last) == INTEGER_CST)
   10693                 :           1 :         pedwarn_init (loc, OPT_Wpedantic,
   10694                 :             :                       "array index in initializer is not "
   10695                 :             :                       "an integer constant expression");
   10696                 :             :     }
   10697                 :             : 
   10698                 :        1128 :   if (TREE_CODE (first) != INTEGER_CST)
   10699                 :           1 :     error_init (loc, "nonconstant array index in initializer");
   10700                 :        1127 :   else if (last != NULL_TREE && TREE_CODE (last) != INTEGER_CST)
   10701                 :           1 :     error_init (loc, "nonconstant array index in initializer");
   10702                 :        1126 :   else if (TREE_CODE (constructor_type) != ARRAY_TYPE)
   10703                 :           9 :     error_init (loc, "array index in non-array initializer");
   10704                 :        1117 :   else if (tree_int_cst_sgn (first) == -1)
   10705                 :          15 :     error_init (loc, "array index in initializer exceeds array bounds");
   10706                 :        1102 :   else if (constructor_max_index
   10707                 :        1102 :            && tree_int_cst_lt (constructor_max_index, first))
   10708                 :           7 :     error_init (loc, "array index in initializer exceeds array bounds");
   10709                 :             :   else
   10710                 :             :     {
   10711                 :        1095 :       constant_expression_warning (first);
   10712                 :        1095 :       if (last)
   10713                 :         379 :         constant_expression_warning (last);
   10714                 :        1095 :       constructor_index = convert (bitsizetype, first);
   10715                 :        1095 :       if (tree_int_cst_lt (constructor_index, first))
   10716                 :             :         {
   10717                 :           0 :           constructor_index = copy_node (constructor_index);
   10718                 :           0 :           TREE_OVERFLOW (constructor_index) = 1;
   10719                 :             :         }
   10720                 :             : 
   10721                 :        1095 :       if (last)
   10722                 :             :         {
   10723                 :         379 :           if (tree_int_cst_equal (first, last))
   10724                 :             :             last = NULL_TREE;
   10725                 :         378 :           else if (tree_int_cst_lt (last, first))
   10726                 :             :             {
   10727                 :           2 :               error_init (loc, "empty index range in initializer");
   10728                 :           2 :               last = NULL_TREE;
   10729                 :             :             }
   10730                 :             :           else
   10731                 :             :             {
   10732                 :         376 :               last = convert (bitsizetype, last);
   10733                 :         376 :               if (constructor_max_index != NULL_TREE
   10734                 :         376 :                   && tree_int_cst_lt (constructor_max_index, last))
   10735                 :             :                 {
   10736                 :           3 :                   error_init (loc, "array index range in initializer exceeds "
   10737                 :             :                               "array bounds");
   10738                 :           3 :                   last = NULL_TREE;
   10739                 :             :                 }
   10740                 :             :             }
   10741                 :             :         }
   10742                 :             : 
   10743                 :        1095 :       designator_depth++;
   10744                 :        1095 :       designator_erroneous = 0;
   10745                 :        1095 :       if (constructor_range_stack || last)
   10746                 :         373 :         push_range_stack (last, braced_init_obstack);
   10747                 :             :     }
   10748                 :             : }
   10749                 :             : 
   10750                 :             : /* Within a struct initializer, specify the next field to be initialized.  */
   10751                 :             : 
   10752                 :             : void
   10753                 :       31872 : set_init_label (location_t loc, tree fieldname, location_t fieldname_loc,
   10754                 :             :                 struct obstack *braced_init_obstack)
   10755                 :             : {
   10756                 :       31872 :   tree field;
   10757                 :             : 
   10758                 :       31872 :   if (set_designator (loc, false, braced_init_obstack))
   10759                 :             :     return;
   10760                 :             : 
   10761                 :       31855 :   designator_erroneous = 1;
   10762                 :             : 
   10763                 :       31855 :   if (!RECORD_OR_UNION_TYPE_P (constructor_type))
   10764                 :             :     {
   10765                 :           3 :       error_init (loc, "field name not in record or union initializer");
   10766                 :           3 :       return;
   10767                 :             :     }
   10768                 :             : 
   10769                 :       31852 :   field = lookup_field (constructor_type, fieldname);
   10770                 :             : 
   10771                 :       31852 :   if (field == NULL_TREE)
   10772                 :             :     {
   10773                 :           8 :       tree guessed_id = lookup_field_fuzzy (constructor_type, fieldname);
   10774                 :           8 :       if (guessed_id)
   10775                 :             :         {
   10776                 :           4 :           gcc_rich_location rich_loc (fieldname_loc);
   10777                 :           4 :           rich_loc.add_fixit_misspelled_id (fieldname_loc, guessed_id);
   10778                 :           4 :           error_at (&rich_loc,
   10779                 :             :                     "%qT has no member named %qE; did you mean %qE?",
   10780                 :             :                     constructor_type, fieldname, guessed_id);
   10781                 :           4 :         }
   10782                 :             :       else
   10783                 :           4 :         error_at (fieldname_loc, "%qT has no member named %qE",
   10784                 :             :                   constructor_type, fieldname);
   10785                 :             :     }
   10786                 :             :   else
   10787                 :       31889 :     do
   10788                 :             :       {
   10789                 :       31889 :         constructor_fields = TREE_VALUE (field);
   10790                 :       31889 :         designator_depth++;
   10791                 :       31889 :         designator_erroneous = 0;
   10792                 :       31889 :         if (constructor_range_stack)
   10793                 :          11 :           push_range_stack (NULL_TREE, braced_init_obstack);
   10794                 :       31889 :         field = TREE_CHAIN (field);
   10795                 :       31889 :         if (field)
   10796                 :             :           {
   10797                 :          45 :             if (set_designator (loc, false, braced_init_obstack))
   10798                 :             :               return;
   10799                 :             :           }
   10800                 :             :       }
   10801                 :       31889 :     while (field != NULL_TREE);
   10802                 :             : }
   10803                 :             : 
   10804                 :             : /* Helper function for add_pending_init.  Find inorder successor of P
   10805                 :             :    in AVL tree.  */
   10806                 :             : static struct init_node *
   10807                 :         129 : init_node_successor (struct init_node *p)
   10808                 :             : {
   10809                 :         129 :   struct init_node *r;
   10810                 :         129 :   if (p->right)
   10811                 :             :     {
   10812                 :             :       r = p->right;
   10813                 :          58 :       while (r->left)
   10814                 :             :         r = r->left;
   10815                 :             :       return r;
   10816                 :             :     }
   10817                 :          75 :   r = p->parent;
   10818                 :         114 :   while (r && p == r->right)
   10819                 :             :     {
   10820                 :          39 :       p = r;
   10821                 :          39 :       r = r->parent;
   10822                 :             :     }
   10823                 :             :   return r;
   10824                 :             : }
   10825                 :             : 
   10826                 :             : /* Add a new initializer to the tree of pending initializers.  PURPOSE
   10827                 :             :    identifies the initializer, either array index or field in a structure.
   10828                 :             :    VALUE is the value of that index or field.  If ORIGTYPE is not
   10829                 :             :    NULL_TREE, it is the original type of VALUE.
   10830                 :             : 
   10831                 :             :    IMPLICIT is true if value comes from pop_init_level (1),
   10832                 :             :    the new initializer has been merged with the existing one
   10833                 :             :    and thus no warnings should be emitted about overriding an
   10834                 :             :    existing initializer.  */
   10835                 :             : 
   10836                 :             : static void
   10837                 :        3261 : add_pending_init (location_t loc, tree purpose, tree value, tree origtype,
   10838                 :             :                   bool implicit, struct obstack *braced_init_obstack)
   10839                 :             : {
   10840                 :        3261 :   struct init_node *p, **q, *r;
   10841                 :             : 
   10842                 :        3261 :   q = &constructor_pending_elts;
   10843                 :        3261 :   p = 0;
   10844                 :             : 
   10845                 :        3261 :   if (TREE_CODE (constructor_type) == ARRAY_TYPE)
   10846                 :             :     {
   10847                 :        3610 :       while (*q != 0)
   10848                 :             :         {
   10849                 :        2412 :           p = *q;
   10850                 :        2412 :           if (tree_int_cst_lt (purpose, p->purpose))
   10851                 :         283 :             q = &p->left;
   10852                 :        2129 :           else if (tree_int_cst_lt (p->purpose, purpose))
   10853                 :             :             {
   10854                 :        1960 :               if (TREE_CODE (p->value) != RAW_DATA_CST
   10855                 :        1960 :                   || (p->right
   10856                 :         112 :                       && tree_int_cst_le (p->right->purpose, purpose)))
   10857                 :        1830 :                 q = &p->right;
   10858                 :             :               else
   10859                 :             :                 {
   10860                 :         130 :                   widest_int pp = wi::to_widest (p->purpose);
   10861                 :         130 :                   widest_int pw = wi::to_widest (purpose);
   10862                 :         130 :                   if (pp + RAW_DATA_LENGTH (p->value) <= pw)
   10863                 :          98 :                     q = &p->right;
   10864                 :             :                   else
   10865                 :             :                     {
   10866                 :             :                       /* Override which should split the old RAW_DATA_CST
   10867                 :             :                          into 2 or 3 pieces.  */
   10868                 :          32 :                       if (!implicit && warn_override_init)
   10869                 :           9 :                         warning_init (loc, OPT_Woverride_init,
   10870                 :             :                                       "initialized field overwritten");
   10871                 :          32 :                       unsigned HOST_WIDE_INT start = (pw - pp).to_uhwi ();
   10872                 :          32 :                       unsigned HOST_WIDE_INT len = 1;
   10873                 :          32 :                       if (TREE_CODE (value) == RAW_DATA_CST)
   10874                 :           0 :                         len = RAW_DATA_LENGTH (value);
   10875                 :          32 :                       unsigned HOST_WIDE_INT end = 0;
   10876                 :          32 :                       unsigned plen = RAW_DATA_LENGTH (p->value);
   10877                 :          32 :                       gcc_checking_assert (start < plen && start);
   10878                 :          32 :                       if (plen - start > len)
   10879                 :          30 :                         end = plen - start - len;
   10880                 :          32 :                       tree v = p->value;
   10881                 :          32 :                       tree origtype = p->origtype;
   10882                 :          32 :                       if (start == 1)
   10883                 :           2 :                         p->value = build_int_cst (TREE_TYPE (v),
   10884                 :           2 :                                                   RAW_DATA_UCHAR_ELT (v, 0));
   10885                 :             :                       else
   10886                 :             :                         {
   10887                 :          30 :                           p->value = v;
   10888                 :          30 :                           if (end > 1)
   10889                 :          26 :                             v = copy_node (v);
   10890                 :          30 :                           RAW_DATA_LENGTH (p->value) = start;
   10891                 :             :                         }
   10892                 :          32 :                       if (end)
   10893                 :             :                         {
   10894                 :          30 :                           tree epurpose
   10895                 :          30 :                             = size_binop (PLUS_EXPR, purpose,
   10896                 :             :                                           bitsize_int (len));
   10897                 :          30 :                           if (end > 1)
   10898                 :             :                             {
   10899                 :          28 :                               RAW_DATA_LENGTH (v) -= plen - end;
   10900                 :          28 :                               RAW_DATA_POINTER (v) += plen - end;
   10901                 :             :                             }
   10902                 :             :                           else
   10903                 :           2 :                             v = build_int_cst (TREE_TYPE (v),
   10904                 :           2 :                                                RAW_DATA_UCHAR_ELT (v, plen
   10905                 :             :                                                                       - end));
   10906                 :          30 :                           add_pending_init (loc, epurpose, v, origtype,
   10907                 :             :                                             implicit, braced_init_obstack);
   10908                 :             :                         }
   10909                 :          32 :                       q = &constructor_pending_elts;
   10910                 :          32 :                       continue;
   10911                 :          32 :                     }
   10912                 :         130 :                 }
   10913                 :             :             }
   10914                 :             :           else
   10915                 :             :             {
   10916                 :         169 :               if (TREE_CODE (p->value) == RAW_DATA_CST
   10917                 :         179 :                   && (RAW_DATA_LENGTH (p->value)
   10918                 :          10 :                       > (TREE_CODE (value) == RAW_DATA_CST
   10919                 :          10 :                          ? RAW_DATA_LENGTH (value) : 1)))
   10920                 :             :                 {
   10921                 :             :                   /* Override which should split the old RAW_DATA_CST
   10922                 :             :                      into 2 pieces.  */
   10923                 :           6 :                   if (!implicit && warn_override_init)
   10924                 :           3 :                     warning_init (loc, OPT_Woverride_init,
   10925                 :             :                                   "initialized field overwritten");
   10926                 :           6 :                   unsigned HOST_WIDE_INT len = 1;
   10927                 :           6 :                   if (TREE_CODE (value) == RAW_DATA_CST)
   10928                 :           2 :                     len = RAW_DATA_LENGTH (value);
   10929                 :           6 :                   if ((unsigned) RAW_DATA_LENGTH (p->value) > len + 1)
   10930                 :             :                     {
   10931                 :           6 :                       RAW_DATA_LENGTH (p->value) -= len;
   10932                 :           6 :                       RAW_DATA_POINTER (p->value) += len;
   10933                 :             :                     }
   10934                 :             :                   else
   10935                 :             :                     {
   10936                 :           0 :                       unsigned int l = RAW_DATA_LENGTH (p->value) - 1;
   10937                 :           0 :                       p->value
   10938                 :           0 :                         = build_int_cst (TREE_TYPE (p->value),
   10939                 :           0 :                                          RAW_DATA_UCHAR_ELT (p->value, l));
   10940                 :             :                     }
   10941                 :           6 :                   p->purpose = size_binop (PLUS_EXPR, p->purpose,
   10942                 :             :                                            bitsize_int (len));
   10943                 :           6 :                   continue;
   10944                 :           6 :                 }
   10945                 :         163 :               if (TREE_CODE (value) == RAW_DATA_CST)
   10946                 :             :                 {
   10947                 :           8 :                 handle_raw_data:
   10948                 :             :                   /* RAW_DATA_CST value might overlap various further
   10949                 :             :                      prior initval entries.  Find out how many.  */
   10950                 :          13 :                   unsigned cnt = 0;
   10951                 :          13 :                   widest_int w
   10952                 :          26 :                     = wi::to_widest (purpose) + RAW_DATA_LENGTH (value);
   10953                 :          13 :                   struct init_node *r = p, *last = NULL;
   10954                 :          13 :                   bool override_init = warn_override_init;
   10955                 :          13 :                   while ((r = init_node_successor (r))
   10956                 :          53 :                          && wi::to_widest (r->purpose) < w)
   10957                 :             :                     {
   10958                 :          40 :                       ++cnt;
   10959                 :          40 :                       if (TREE_SIDE_EFFECTS (r->value))
   10960                 :           2 :                         warning_init (loc, OPT_Woverride_init_side_effects,
   10961                 :             :                                       "initialized field with side-effects "
   10962                 :             :                                       "overwritten");
   10963                 :          38 :                       else if (override_init)
   10964                 :             :                         {
   10965                 :           6 :                           warning_init (loc, OPT_Woverride_init,
   10966                 :             :                                         "initialized field overwritten");
   10967                 :           6 :                           override_init = false;
   10968                 :             :                         }
   10969                 :             :                       last = r;
   10970                 :             :                     }
   10971                 :          13 :                   if (cnt)
   10972                 :             :                     {
   10973                 :          26 :                       if (TREE_CODE (last->value) == RAW_DATA_CST
   10974                 :          13 :                           && (wi::to_widest (last->purpose)
   10975                 :          13 :                               + RAW_DATA_LENGTH (last->value) > w))
   10976                 :             :                         {
   10977                 :             :                           /* The last overlapping prior initval overlaps
   10978                 :             :                              only partially.  Shrink it and decrease cnt.  */
   10979                 :           0 :                           unsigned int l = (wi::to_widest (last->purpose)
   10980                 :           0 :                                             + RAW_DATA_LENGTH (last->value)
   10981                 :           0 :                                             - w).to_uhwi ();
   10982                 :           0 :                           --cnt;
   10983                 :           0 :                           RAW_DATA_LENGTH (last->value) -= l;
   10984                 :           0 :                           RAW_DATA_POINTER (last->value) += l;
   10985                 :           0 :                           if (RAW_DATA_LENGTH (last->value) == 1)
   10986                 :           0 :                             last->value
   10987                 :           0 :                               = build_int_cst (TREE_TYPE (last->value),
   10988                 :           0 :                                                RAW_DATA_UCHAR_ELT (last->value,
   10989                 :             :                                                                    0));
   10990                 :           0 :                           last->purpose
   10991                 :           0 :                             = size_binop (PLUS_EXPR, last->purpose,
   10992                 :             :                                           bitsize_int (l));
   10993                 :             :                         }
   10994                 :             :                       /* Instead of deleting cnt nodes from the AVL tree
   10995                 :             :                          and rebalancing, peel of last cnt bytes from the
   10996                 :             :                          RAW_DATA_CST.  Overriding thousands of previously
   10997                 :             :                          initialized array elements with #embed needs to work,
   10998                 :             :                          but doesn't need to be super efficient.  */
   10999                 :          13 :                       gcc_checking_assert ((unsigned) RAW_DATA_LENGTH (value)
   11000                 :             :                                            > cnt);
   11001                 :          13 :                       RAW_DATA_LENGTH (value) -= cnt;
   11002                 :          13 :                       const unsigned char *s
   11003                 :          13 :                         = &RAW_DATA_UCHAR_ELT (value, RAW_DATA_LENGTH (value));
   11004                 :          13 :                       unsigned int o = RAW_DATA_LENGTH (value);
   11005                 :          53 :                       for (r = p; cnt--; ++o, ++s)
   11006                 :             :                         {
   11007                 :          40 :                           r = init_node_successor (r);
   11008                 :          40 :                           r->purpose = size_binop (PLUS_EXPR, purpose,
   11009                 :             :                                                    bitsize_int (o));
   11010                 :          40 :                           r->value = build_int_cst (TREE_TYPE (value), *s);
   11011                 :          40 :                           r->origtype = origtype;
   11012                 :             :                         }
   11013                 :          13 :                       if (RAW_DATA_LENGTH (value) == 1)
   11014                 :           0 :                         value = build_int_cst (TREE_TYPE (value),
   11015                 :           0 :                                                RAW_DATA_UCHAR_ELT (value, 0));
   11016                 :             :                     }
   11017                 :             :                 }
   11018                 :         168 :               if (!implicit)
   11019                 :             :                 {
   11020                 :          54 :                   if (TREE_SIDE_EFFECTS (p->value))
   11021                 :           6 :                     warning_init (loc, OPT_Woverride_init_side_effects,
   11022                 :             :                                   "initialized field with side-effects "
   11023                 :             :                                   "overwritten");
   11024                 :          48 :                   else if (warn_override_init)
   11025                 :          13 :                     warning_init (loc, OPT_Woverride_init,
   11026                 :             :                                   "initialized field overwritten");
   11027                 :             :                 }
   11028                 :         168 :               p->value = value;
   11029                 :         168 :               p->origtype = origtype;
   11030                 :         168 :               return;
   11031                 :             :             }
   11032                 :             :         }
   11033                 :        1198 :       if (TREE_CODE (value) == RAW_DATA_CST && p)
   11034                 :             :         {
   11035                 :          61 :           struct init_node *r;
   11036                 :          61 :           if (q == &p->left)
   11037                 :             :             r = p;
   11038                 :             :           else
   11039                 :          36 :             r = init_node_successor (p);
   11040                 :         131 :           if (r && wi::to_widest (r->purpose) < (wi::to_widest (purpose)
   11041                 :         131 :                                                  + RAW_DATA_LENGTH (value)))
   11042                 :             :             {
   11043                 :             :               /* Overlap with at least one prior initval in the range but
   11044                 :             :                  not at the start.  */
   11045                 :           5 :               p = r;
   11046                 :           5 :               p->purpose = purpose;
   11047                 :           5 :               goto handle_raw_data;
   11048                 :             :             }
   11049                 :             :         }
   11050                 :             :     }
   11051                 :             :   else
   11052                 :             :     {
   11053                 :        1900 :       tree bitpos;
   11054                 :             : 
   11055                 :        1900 :       bitpos = bit_position (purpose);
   11056                 :        5386 :       while (*q != NULL)
   11057                 :             :         {
   11058                 :        1843 :           p = *q;
   11059                 :        1843 :           if (tree_int_cst_lt (bitpos, bit_position (p->purpose)))
   11060                 :          43 :             q = &p->left;
   11061                 :        1800 :           else if (p->purpose != purpose)
   11062                 :        1543 :             q = &p->right;
   11063                 :             :           else
   11064                 :             :             {
   11065                 :         257 :               if (!implicit)
   11066                 :             :                 {
   11067                 :          33 :                   if (TREE_SIDE_EFFECTS (p->value))
   11068                 :           4 :                     warning_init (loc, OPT_Woverride_init_side_effects,
   11069                 :             :                                   "initialized field with side-effects "
   11070                 :             :                                   "overwritten");
   11071                 :          29 :                   else if (warn_override_init)
   11072                 :           6 :                     warning_init (loc, OPT_Woverride_init,
   11073                 :             :                                   "initialized field overwritten");
   11074                 :             :                 }
   11075                 :         257 :               p->value = value;
   11076                 :         257 :               p->origtype = origtype;
   11077                 :         257 :               return;
   11078                 :             :             }
   11079                 :             :         }
   11080                 :             :     }
   11081                 :             : 
   11082                 :        2836 :   r = (struct init_node *) obstack_alloc (braced_init_obstack,
   11083                 :             :                                           sizeof (struct init_node));
   11084                 :        2836 :   r->purpose = purpose;
   11085                 :        2836 :   r->value = value;
   11086                 :        2836 :   r->origtype = origtype;
   11087                 :             : 
   11088                 :        2836 :   *q = r;
   11089                 :        2836 :   r->parent = p;
   11090                 :        2836 :   r->left = 0;
   11091                 :        2836 :   r->right = 0;
   11092                 :        2836 :   r->balance = 0;
   11093                 :             : 
   11094                 :        4854 :   while (p)
   11095                 :             :     {
   11096                 :        2806 :       struct init_node *s;
   11097                 :             : 
   11098                 :        2806 :       if (r == p->left)
   11099                 :             :         {
   11100                 :         237 :           if (p->balance == 0)
   11101                 :         174 :             p->balance = -1;
   11102                 :          63 :           else if (p->balance < 0)
   11103                 :             :             {
   11104                 :          45 :               if (r->balance < 0)
   11105                 :             :                 {
   11106                 :             :                   /* L rotation.  */
   11107                 :          40 :                   p->left = r->right;
   11108                 :          40 :                   if (p->left)
   11109                 :           2 :                     p->left->parent = p;
   11110                 :          40 :                   r->right = p;
   11111                 :             : 
   11112                 :          40 :                   p->balance = 0;
   11113                 :          40 :                   r->balance = 0;
   11114                 :             : 
   11115                 :          40 :                   s = p->parent;
   11116                 :          40 :                   p->parent = r;
   11117                 :          40 :                   r->parent = s;
   11118                 :          40 :                   if (s)
   11119                 :             :                     {
   11120                 :          31 :                       if (s->left == p)
   11121                 :          10 :                         s->left = r;
   11122                 :             :                       else
   11123                 :          21 :                         s->right = r;
   11124                 :             :                     }
   11125                 :             :                   else
   11126                 :           9 :                     constructor_pending_elts = r;
   11127                 :             :                 }
   11128                 :             :               else
   11129                 :             :                 {
   11130                 :             :                   /* LR rotation.  */
   11131                 :           5 :                   struct init_node *t = r->right;
   11132                 :             : 
   11133                 :           5 :                   r->right = t->left;
   11134                 :           5 :                   if (r->right)
   11135                 :           0 :                     r->right->parent = r;
   11136                 :           5 :                   t->left = r;
   11137                 :             : 
   11138                 :           5 :                   p->left = t->right;
   11139                 :           5 :                   if (p->left)
   11140                 :           0 :                     p->left->parent = p;
   11141                 :           5 :                   t->right = p;
   11142                 :             : 
   11143                 :           5 :                   p->balance = t->balance < 0;
   11144                 :           5 :                   r->balance = -(t->balance > 0);
   11145                 :           5 :                   t->balance = 0;
   11146                 :             : 
   11147                 :           5 :                   s = p->parent;
   11148                 :           5 :                   p->parent = t;
   11149                 :           5 :                   r->parent = t;
   11150                 :           5 :                   t->parent = s;
   11151                 :           5 :                   if (s)
   11152                 :             :                     {
   11153                 :           0 :                       if (s->left == p)
   11154                 :           0 :                         s->left = t;
   11155                 :             :                       else
   11156                 :           0 :                         s->right = t;
   11157                 :             :                     }
   11158                 :             :                   else
   11159                 :           5 :                     constructor_pending_elts = t;
   11160                 :             :                 }
   11161                 :             :               break;
   11162                 :             :             }
   11163                 :             :           else
   11164                 :             :             {
   11165                 :             :               /* p->balance == +1; growth of left side balances the node.  */
   11166                 :          18 :               p->balance = 0;
   11167                 :          18 :               break;
   11168                 :             :             }
   11169                 :             :         }
   11170                 :             :       else /* r == p->right */
   11171                 :             :         {
   11172                 :        2569 :           if (p->balance == 0)
   11173                 :             :             /* Growth propagation from right side.  */
   11174                 :        1844 :             p->balance++;
   11175                 :         725 :           else if (p->balance > 0)
   11176                 :             :             {
   11177                 :         696 :               if (r->balance > 0)
   11178                 :             :                 {
   11179                 :             :                   /* R rotation.  */
   11180                 :         694 :                   p->right = r->left;
   11181                 :         694 :                   if (p->right)
   11182                 :         173 :                     p->right->parent = p;
   11183                 :         694 :                   r->left = p;
   11184                 :             : 
   11185                 :         694 :                   p->balance = 0;
   11186                 :         694 :                   r->balance = 0;
   11187                 :             : 
   11188                 :         694 :                   s = p->parent;
   11189                 :         694 :                   p->parent = r;
   11190                 :         694 :                   r->parent = s;
   11191                 :         694 :                   if (s)
   11192                 :             :                     {
   11193                 :         374 :                       if (s->left == p)
   11194                 :           2 :                         s->left = r;
   11195                 :             :                       else
   11196                 :         372 :                         s->right = r;
   11197                 :             :                     }
   11198                 :             :                   else
   11199                 :         320 :                     constructor_pending_elts = r;
   11200                 :             :                 }
   11201                 :             :               else /* r->balance == -1 */
   11202                 :             :                 {
   11203                 :             :                   /* RL rotation */
   11204                 :           2 :                   struct init_node *t = r->left;
   11205                 :             : 
   11206                 :           2 :                   r->left = t->right;
   11207                 :           2 :                   if (r->left)
   11208                 :           2 :                     r->left->parent = r;
   11209                 :           2 :                   t->right = r;
   11210                 :             : 
   11211                 :           2 :                   p->right = t->left;
   11212                 :           2 :                   if (p->right)
   11213                 :           2 :                     p->right->parent = p;
   11214                 :           2 :                   t->left = p;
   11215                 :             : 
   11216                 :           2 :                   r->balance = (t->balance < 0);
   11217                 :           2 :                   p->balance = -(t->balance > 0);
   11218                 :           2 :                   t->balance = 0;
   11219                 :             : 
   11220                 :           2 :                   s = p->parent;
   11221                 :           2 :                   p->parent = t;
   11222                 :           2 :                   r->parent = t;
   11223                 :           2 :                   t->parent = s;
   11224                 :           2 :                   if (s)
   11225                 :             :                     {
   11226                 :           0 :                       if (s->left == p)
   11227                 :           0 :                         s->left = t;
   11228                 :             :                       else
   11229                 :           0 :                         s->right = t;
   11230                 :             :                     }
   11231                 :             :                   else
   11232                 :           2 :                     constructor_pending_elts = t;
   11233                 :             :                 }
   11234                 :             :               break;
   11235                 :             :             }
   11236                 :             :           else
   11237                 :             :             {
   11238                 :             :               /* p->balance == -1; growth of right side balances the node.  */
   11239                 :          29 :               p->balance = 0;
   11240                 :          29 :               break;
   11241                 :             :             }
   11242                 :             :         }
   11243                 :             : 
   11244                 :        2018 :       r = p;
   11245                 :        2018 :       p = p->parent;
   11246                 :             :     }
   11247                 :             : }
   11248                 :             : 
   11249                 :             : /* Build AVL tree from a sorted chain.  */
   11250                 :             : 
   11251                 :             : static void
   11252                 :         418 : set_nonincremental_init (struct obstack * braced_init_obstack)
   11253                 :             : {
   11254                 :         418 :   unsigned HOST_WIDE_INT ix;
   11255                 :         418 :   tree index, value;
   11256                 :             : 
   11257                 :         418 :   if (TREE_CODE (constructor_type) != RECORD_TYPE
   11258                 :         418 :       && TREE_CODE (constructor_type) != ARRAY_TYPE)
   11259                 :             :     return;
   11260                 :             : 
   11261                 :        1601 :   FOR_EACH_CONSTRUCTOR_ELT (constructor_elements, ix, index, value)
   11262                 :        1183 :     add_pending_init (input_location, index, value, NULL_TREE, true,
   11263                 :             :                       braced_init_obstack);
   11264                 :         418 :   constructor_elements = NULL;
   11265                 :         418 :   if (TREE_CODE (constructor_type) == RECORD_TYPE)
   11266                 :             :     {
   11267                 :         200 :       constructor_unfilled_fields = TYPE_FIELDS (constructor_type);
   11268                 :             :       /* Skip any nameless bit fields at the beginning.  */
   11269                 :         200 :       while (constructor_unfilled_fields != NULL_TREE
   11270                 :         200 :              && DECL_UNNAMED_BIT_FIELD (constructor_unfilled_fields))
   11271                 :           0 :         constructor_unfilled_fields = TREE_CHAIN (constructor_unfilled_fields);
   11272                 :             : 
   11273                 :             :     }
   11274                 :         218 :   else if (TREE_CODE (constructor_type) == ARRAY_TYPE)
   11275                 :             :     {
   11276                 :         218 :       if (TYPE_DOMAIN (constructor_type))
   11277                 :         160 :         constructor_unfilled_index
   11278                 :         160 :           = convert (bitsizetype,
   11279                 :         160 :                      TYPE_MIN_VALUE (TYPE_DOMAIN (constructor_type)));
   11280                 :             :       else
   11281                 :          58 :         constructor_unfilled_index = bitsize_zero_node;
   11282                 :             :     }
   11283                 :         418 :   constructor_incremental = 0;
   11284                 :             : }
   11285                 :             : 
   11286                 :             : /* Build AVL tree from a string constant.  */
   11287                 :             : 
   11288                 :             : static void
   11289                 :           7 : set_nonincremental_init_from_string (tree str,
   11290                 :             :                                      struct obstack * braced_init_obstack)
   11291                 :             : {
   11292                 :           7 :   tree value, purpose, type;
   11293                 :           7 :   HOST_WIDE_INT val[2];
   11294                 :           7 :   const char *p, *end;
   11295                 :           7 :   int byte, wchar_bytes, charwidth, bitpos;
   11296                 :             : 
   11297                 :           7 :   gcc_assert (TREE_CODE (constructor_type) == ARRAY_TYPE);
   11298                 :             : 
   11299                 :           7 :   wchar_bytes = TYPE_PRECISION (TREE_TYPE (TREE_TYPE (str))) / BITS_PER_UNIT;
   11300                 :           7 :   charwidth = TYPE_PRECISION (char_type_node);
   11301                 :           7 :   gcc_assert ((size_t) wchar_bytes * charwidth
   11302                 :             :               <= ARRAY_SIZE (val) * HOST_BITS_PER_WIDE_INT);
   11303                 :           7 :   type = TREE_TYPE (constructor_type);
   11304                 :           7 :   p = TREE_STRING_POINTER (str);
   11305                 :           7 :   end = p + TREE_STRING_LENGTH (str);
   11306                 :             : 
   11307                 :           7 :   for (purpose = bitsize_zero_node;
   11308                 :             :        p < end
   11309                 :          52 :        && !(constructor_max_index
   11310                 :          20 :             && tree_int_cst_lt (constructor_max_index, purpose));
   11311                 :          25 :        purpose = size_binop (PLUS_EXPR, purpose, bitsize_one_node))
   11312                 :             :     {
   11313                 :          25 :       if (wchar_bytes == 1)
   11314                 :             :         {
   11315                 :           9 :           val[0] = (unsigned char) *p++;
   11316                 :           9 :           val[1] = 0;
   11317                 :             :         }
   11318                 :             :       else
   11319                 :             :         {
   11320                 :          16 :           val[1] = 0;
   11321                 :          16 :           val[0] = 0;
   11322                 :          64 :           for (byte = 0; byte < wchar_bytes; byte++)
   11323                 :             :             {
   11324                 :          48 :               if (BYTES_BIG_ENDIAN)
   11325                 :             :                 bitpos = (wchar_bytes - byte - 1) * charwidth;
   11326                 :             :               else
   11327                 :          48 :                 bitpos = byte * charwidth;
   11328                 :          48 :               val[bitpos / HOST_BITS_PER_WIDE_INT]
   11329                 :          48 :                 |= ((unsigned HOST_WIDE_INT) ((unsigned char) *p++))
   11330                 :          48 :                    << (bitpos % HOST_BITS_PER_WIDE_INT);
   11331                 :             :             }
   11332                 :             :         }
   11333                 :             : 
   11334                 :          25 :       if (!TYPE_UNSIGNED (type))
   11335                 :             :         {
   11336                 :          13 :           bitpos = ((wchar_bytes - 1) * charwidth) + HOST_BITS_PER_CHAR;
   11337                 :          13 :           if (bitpos < HOST_BITS_PER_WIDE_INT)
   11338                 :             :             {
   11339                 :          13 :               if (val[0] & (HOST_WIDE_INT_1 << (bitpos - 1)))
   11340                 :             :                 {
   11341                 :           0 :                   val[0] |= HOST_WIDE_INT_M1U << bitpos;
   11342                 :           0 :                   val[1] = -1;
   11343                 :             :                 }
   11344                 :             :             }
   11345                 :           0 :           else if (bitpos == HOST_BITS_PER_WIDE_INT)
   11346                 :             :             {
   11347                 :           0 :               if (val[0] < 0)
   11348                 :           0 :                 val[1] = -1;
   11349                 :             :             }
   11350                 :           0 :           else if (val[1] & (HOST_WIDE_INT_1
   11351                 :           0 :                              << (bitpos - 1 - HOST_BITS_PER_WIDE_INT)))
   11352                 :           0 :             val[1] |= HOST_WIDE_INT_M1U << (bitpos - HOST_BITS_PER_WIDE_INT);
   11353                 :             :         }
   11354                 :             : 
   11355                 :          25 :       value = wide_int_to_tree (type,
   11356                 :          25 :                                 wide_int::from_array (val, 2,
   11357                 :             :                                                       HOST_BITS_PER_WIDE_INT * 2));
   11358                 :          25 :       add_pending_init (input_location, purpose, value, NULL_TREE, true,
   11359                 :             :                         braced_init_obstack);
   11360                 :             :     }
   11361                 :             : 
   11362                 :           7 :   constructor_incremental = 0;
   11363                 :           7 : }
   11364                 :             : 
   11365                 :             : /* Return value of FIELD in pending initializer or NULL_TREE if the field was
   11366                 :             :    not initialized yet.  */
   11367                 :             : 
   11368                 :             : static tree
   11369                 :      703552 : find_init_member (tree field, struct obstack * braced_init_obstack)
   11370                 :             : {
   11371                 :      703552 :   struct init_node *p;
   11372                 :             : 
   11373                 :      703552 :   if (TREE_CODE (constructor_type) == ARRAY_TYPE)
   11374                 :             :     {
   11375                 :      702774 :       if (constructor_incremental
   11376                 :      702774 :           && tree_int_cst_lt (field, constructor_unfilled_index))
   11377                 :          16 :         set_nonincremental_init (braced_init_obstack);
   11378                 :             : 
   11379                 :      702774 :       p = constructor_pending_elts;
   11380                 :      702897 :       while (p)
   11381                 :             :         {
   11382                 :         233 :           if (tree_int_cst_lt (field, p->purpose))
   11383                 :          25 :             p = p->left;
   11384                 :         208 :           else if (tree_int_cst_lt (p->purpose, field))
   11385                 :          98 :             p = p->right;
   11386                 :             :           else
   11387                 :         110 :             return p->value;
   11388                 :             :         }
   11389                 :             :     }
   11390                 :         778 :   else if (TREE_CODE (constructor_type) == RECORD_TYPE)
   11391                 :             :     {
   11392                 :         659 :       tree bitpos = bit_position (field);
   11393                 :             : 
   11394                 :         659 :       if (constructor_incremental
   11395                 :         659 :           && (!constructor_unfilled_fields
   11396                 :         456 :               || tree_int_cst_lt (bitpos,
   11397                 :         456 :                                   bit_position (constructor_unfilled_fields))))
   11398                 :          51 :         set_nonincremental_init (braced_init_obstack);
   11399                 :             : 
   11400                 :         659 :       p = constructor_pending_elts;
   11401                 :         799 :       while (p)
   11402                 :             :         {
   11403                 :         347 :           if (field == p->purpose)
   11404                 :         207 :             return p->value;
   11405                 :         140 :           else if (tree_int_cst_lt (bitpos, bit_position (p->purpose)))
   11406                 :           7 :             p = p->left;
   11407                 :             :           else
   11408                 :         133 :             p = p->right;
   11409                 :             :         }
   11410                 :             :     }
   11411                 :         119 :   else if (TREE_CODE (constructor_type) == UNION_TYPE)
   11412                 :             :     {
   11413                 :         119 :       if (!vec_safe_is_empty (constructor_elements)
   11414                 :          50 :           && (constructor_elements->last ().index == field))
   11415                 :          50 :         return constructor_elements->last ().value;
   11416                 :             :     }
   11417                 :             :   return NULL_TREE;
   11418                 :             : }
   11419                 :             : 
   11420                 :             : /* "Output" the next constructor element.
   11421                 :             :    At top level, really output it to assembler code now.
   11422                 :             :    Otherwise, collect it in a list from which we will make a CONSTRUCTOR.
   11423                 :             :    If ORIGTYPE is not NULL_TREE, it is the original type of VALUE.
   11424                 :             :    TYPE is the data type that the containing data type wants here.
   11425                 :             :    FIELD is the field (a FIELD_DECL) or the index that this element fills.
   11426                 :             :    If VALUE is a string constant, STRICT_STRING is true if it is
   11427                 :             :    unparenthesized or we should not warn here for it being parenthesized.
   11428                 :             :    For other types of VALUE, STRICT_STRING is not used.
   11429                 :             : 
   11430                 :             :    PENDING if true means output pending elements that belong
   11431                 :             :    right after this element.  (PENDING is normally true;
   11432                 :             :    it is false while outputting pending elements, to avoid recursion.)
   11433                 :             : 
   11434                 :             :    IMPLICIT is true if value comes from pop_init_level (1),
   11435                 :             :    the new initializer has been merged with the existing one
   11436                 :             :    and thus no warnings should be emitted about overriding an
   11437                 :             :    existing initializer.  */
   11438                 :             : 
   11439                 :             : static void
   11440                 :     9455461 : output_init_element (location_t loc, tree value, tree origtype,
   11441                 :             :                      bool strict_string, tree type, tree field, bool pending,
   11442                 :             :                      bool implicit, struct obstack * braced_init_obstack)
   11443                 :             : {
   11444                 :     9455461 :   tree semantic_type = NULL_TREE;
   11445                 :     9455461 :   bool maybe_const = true;
   11446                 :     9455461 :   bool npc, int_const_expr, arith_const_expr;
   11447                 :             : 
   11448                 :     9455461 :   if (type == error_mark_node || value == error_mark_node)
   11449                 :             :     {
   11450                 :         465 :       constructor_erroneous = 1;
   11451                 :        2582 :       return;
   11452                 :             :     }
   11453                 :     9454996 :   if (TREE_CODE (TREE_TYPE (value)) == ARRAY_TYPE
   11454                 :      199853 :       && (TREE_CODE (value) == STRING_CST
   11455                 :      158465 :           || TREE_CODE (value) == COMPOUND_LITERAL_EXPR)
   11456                 :       41396 :       && !(TREE_CODE (value) == STRING_CST
   11457                 :       41388 :            && TREE_CODE (type) == ARRAY_TYPE
   11458                 :        3896 :            && INTEGRAL_TYPE_P (TREE_TYPE (type)))
   11459                 :     9492496 :       && !comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (value)),
   11460                 :       37500 :                      TYPE_MAIN_VARIANT (type)))
   11461                 :       37500 :     value = array_to_pointer_conversion (input_location, value);
   11462                 :             : 
   11463                 :     9454996 :   if (TREE_CODE (value) == COMPOUND_LITERAL_EXPR
   11464                 :         178 :       && require_constant_value && pending)
   11465                 :             :     {
   11466                 :             :       /* As an extension, allow initializing objects with static storage
   11467                 :             :          duration with compound literals (which are then treated just as
   11468                 :             :          the brace enclosed list they contain).  */
   11469                 :         114 :       if (flag_isoc99)
   11470                 :          24 :         pedwarn_init (loc, OPT_Wpedantic, "initializer element is not "
   11471                 :             :                       "constant");
   11472                 :         114 :       tree decl = COMPOUND_LITERAL_EXPR_DECL (value);
   11473                 :         114 :       value = DECL_INITIAL (decl);
   11474                 :             :     }
   11475                 :             : 
   11476                 :     9454996 :   npc = null_pointer_constant_p (value);
   11477                 :    18909992 :   int_const_expr = (TREE_CODE (value) == INTEGER_CST
   11478                 :     4140452 :                     && !TREE_OVERFLOW (value)
   11479                 :    13595447 :                     && INTEGRAL_TYPE_P (TREE_TYPE (value)));
   11480                 :             :   /* Not fully determined before folding.  */
   11481                 :     9454996 :   arith_const_expr = true;
   11482                 :     9454996 :   if (TREE_CODE (value) == EXCESS_PRECISION_EXPR)
   11483                 :             :     {
   11484                 :          16 :       semantic_type = TREE_TYPE (value);
   11485                 :          16 :       value = TREE_OPERAND (value, 0);
   11486                 :             :     }
   11487                 :     9454996 :   value = c_fully_fold (value, require_constant_value, &maybe_const);
   11488                 :             :   /* TODO: this may not detect all cases of expressions folding to
   11489                 :             :      constants that are not arithmetic constant expressions.  */
   11490                 :     9454996 :   if (!maybe_const)
   11491                 :             :     arith_const_expr = false;
   11492                 :    18907651 :   else if (!INTEGRAL_TYPE_P (TREE_TYPE (value))
   11493                 :     3151916 :            && TREE_CODE (TREE_TYPE (value)) != REAL_TYPE
   11494                 :    11294489 :            && TREE_CODE (TREE_TYPE (value)) != COMPLEX_TYPE)
   11495                 :             :     arith_const_expr = false;
   11496                 :     7628111 :   else if (TREE_CODE (value) != INTEGER_CST
   11497                 :             :            && TREE_CODE (value) != REAL_CST
   11498                 :             :            && TREE_CODE (value) != COMPLEX_CST
   11499                 :             :            && TREE_CODE (value) != RAW_DATA_CST)
   11500                 :             :     arith_const_expr = false;
   11501                 :     4521284 :   else if (TREE_OVERFLOW (value))
   11502                 :     4933713 :     arith_const_expr = false;
   11503                 :             : 
   11504                 :     9454996 :   if (value == error_mark_node)
   11505                 :           0 :     constructor_erroneous = 1;
   11506                 :     9454996 :   else if (!TREE_CONSTANT (value))
   11507                 :     3126360 :     constructor_constant = 0;
   11508                 :     6328636 :   else if (!initializer_constant_valid_p (value,
   11509                 :     6328636 :                                           TREE_TYPE (value),
   11510                 :     6328636 :                                           AGGREGATE_TYPE_P (constructor_type)
   11511                 :     6328636 :                                           && TYPE_REVERSE_STORAGE_ORDER
   11512                 :             :                                              (constructor_type))
   11513                 :     6328636 :            || (RECORD_OR_UNION_TYPE_P (constructor_type)
   11514                 :     1037185 :                && DECL_C_BIT_FIELD (field)
   11515                 :        8035 :                && TREE_CODE (value) != INTEGER_CST))
   11516                 :          77 :     constructor_simple = 0;
   11517                 :     9454996 :   if (!maybe_const)
   11518                 :        1067 :     constructor_nonconst = 1;
   11519                 :             : 
   11520                 :             :   /* Digest the initializer and issue any errors about incompatible
   11521                 :             :      types before issuing errors about non-constant initializers.  */
   11522                 :     9454996 :   tree new_value = value;
   11523                 :     9454996 :   if (semantic_type)
   11524                 :          16 :     new_value = build1 (EXCESS_PRECISION_EXPR, semantic_type, value);
   11525                 :             :   /* In the case of braces around a scalar initializer, the result of
   11526                 :             :      this initializer processing goes through digest_init again at the
   11527                 :             :      outer level.  In the case of a constexpr initializer for a
   11528                 :             :      pointer, avoid converting a null pointer constant to something
   11529                 :             :      that is not a null pointer constant to avoid a spurious error
   11530                 :             :      from that second processing.  */
   11531                 :     9454996 :   if (!require_constexpr_value
   11532                 :         397 :       || !npc
   11533                 :          69 :       || TREE_CODE (constructor_type) != POINTER_TYPE)
   11534                 :     9454985 :     new_value = digest_init (loc,
   11535                 :     9454985 :                              RECORD_OR_UNION_TYPE_P (constructor_type)
   11536                 :     8386875 :                              ? field : constructor_fields
   11537                 :     8386875 :                              ? constructor_fields : constructor_decl,
   11538                 :             :                              type, new_value, origtype, npc,
   11539                 :             :                              int_const_expr, arith_const_expr, strict_string,
   11540                 :             :                              require_constant_value, require_constexpr_value);
   11541                 :     9454996 :   if (new_value == error_mark_node)
   11542                 :             :     {
   11543                 :          76 :       constructor_erroneous = 1;
   11544                 :          76 :       return;
   11545                 :             :     }
   11546                 :     9454920 :   if (require_constant_value || require_constant_elements)
   11547                 :     2710348 :     constant_expression_warning (new_value);
   11548                 :             : 
   11549                 :             :   /* Proceed to check the constness of the original initializer.  */
   11550                 :     9454920 :   if (!initializer_constant_valid_p (value, TREE_TYPE (value)))
   11551                 :             :     {
   11552                 :     3126386 :       if (require_constant_value)
   11553                 :             :         {
   11554                 :           0 :           error_init (loc, "initializer element is not constant");
   11555                 :           0 :           value = error_mark_node;
   11556                 :             :         }
   11557                 :     3126386 :       else if (require_constant_elements)
   11558                 :          15 :         pedwarn (loc, OPT_Wpedantic,
   11559                 :             :                  "initializer element is not computable at load time");
   11560                 :             :     }
   11561                 :     6328534 :   else if (!maybe_const
   11562                 :          54 :            && (require_constant_value || require_constant_elements))
   11563                 :          28 :     pedwarn_init (loc, OPT_Wpedantic,
   11564                 :             :                   "initializer element is not a constant expression");
   11565                 :             :   /* digest_init has already carried out the additional checks
   11566                 :             :      required for 'constexpr' initializers (using the information
   11567                 :             :      passed to it about whether the original initializer was certain
   11568                 :             :      kinds of constant expression), so that check does not need to be
   11569                 :             :      repeated here.  */
   11570                 :             : 
   11571                 :             :   /* Issue -Wc++-compat warnings about initializing a bitfield with
   11572                 :             :      enum type.  */
   11573                 :     9454920 :   if (warn_cxx_compat
   11574                 :        6859 :       && field != NULL_TREE
   11575                 :        6859 :       && TREE_CODE (field) == FIELD_DECL
   11576                 :         453 :       && DECL_BIT_FIELD_TYPE (field) != NULL_TREE
   11577                 :          21 :       && (TYPE_MAIN_VARIANT (DECL_BIT_FIELD_TYPE (field))
   11578                 :          21 :           != TYPE_MAIN_VARIANT (type))
   11579                 :     9454941 :       && TREE_CODE (DECL_BIT_FIELD_TYPE (field)) == ENUMERAL_TYPE)
   11580                 :             :     {
   11581                 :          21 :       tree checktype = origtype != NULL_TREE ? origtype : TREE_TYPE (value);
   11582                 :          21 :       if (checktype != error_mark_node
   11583                 :          21 :           && (TYPE_MAIN_VARIANT (checktype)
   11584                 :          21 :               != TYPE_MAIN_VARIANT (DECL_BIT_FIELD_TYPE (field))))
   11585                 :           9 :         warning_init (loc, OPT_Wc___compat,
   11586                 :             :                       "enum conversion in initialization is invalid in C++");
   11587                 :             :     }
   11588                 :             : 
   11589                 :             :   /* If this field is empty and does not have side effects (and is not at
   11590                 :             :      the end of structure), don't do anything other than checking the
   11591                 :             :      initializer.  */
   11592                 :     9454920 :   if (field
   11593                 :     9454920 :       && (TREE_TYPE (field) == error_mark_node
   11594                 :     9454533 :           || (COMPLETE_TYPE_P (TREE_TYPE (field))
   11595                 :     9454225 :               && integer_zerop (TYPE_SIZE (TREE_TYPE (field)))
   11596                 :          62 :               && !TREE_SIDE_EFFECTS (new_value)
   11597                 :          33 :               && (TREE_CODE (constructor_type) == ARRAY_TYPE
   11598                 :          33 :                   || DECL_CHAIN (field)))))
   11599                 :          18 :     return;
   11600                 :             : 
   11601                 :             :   /* Finally, set VALUE to the initializer value digested above.  */
   11602                 :     9454902 :   value = new_value;
   11603                 :             : 
   11604                 :             :   /* If this element doesn't come next in sequence,
   11605                 :             :      put it on constructor_pending_elts.  */
   11606                 :     9454902 :   if (TREE_CODE (constructor_type) == ARRAY_TYPE
   11607                 :     9454902 :       && (!constructor_incremental
   11608                 :     1713624 :           || !tree_int_cst_equal (field, constructor_unfilled_index)
   11609                 :     1713258 :           || (TREE_CODE (value) == RAW_DATA_CST
   11610                 :         233 :               && constructor_pending_elts
   11611                 :          66 :               && pending)))
   11612                 :             :     {
   11613                 :         627 :       if (constructor_incremental
   11614                 :         627 :           && (tree_int_cst_lt (field, constructor_unfilled_index)
   11615                 :         337 :               || (TREE_CODE (value) == RAW_DATA_CST
   11616                 :          14 :                   && constructor_pending_elts
   11617                 :          14 :                   && pending)))
   11618                 :          48 :         set_nonincremental_init (braced_init_obstack);
   11619                 :             : 
   11620                 :         627 :       add_pending_init (loc, field, value, origtype, implicit,
   11621                 :             :                         braced_init_obstack);
   11622                 :         627 :       return;
   11623                 :             :     }
   11624                 :     9454275 :   else if (TREE_CODE (constructor_type) == RECORD_TYPE
   11625                 :     1037901 :            && (!constructor_incremental
   11626                 :     1037561 :                || field != constructor_unfilled_fields))
   11627                 :             :     {
   11628                 :             :       /* We do this for records but not for unions.  In a union,
   11629                 :             :          no matter which field is specified, it can be initialized
   11630                 :             :          right away since it starts at the beginning of the union.  */
   11631                 :        1396 :       if (constructor_incremental)
   11632                 :             :         {
   11633                 :        1056 :           if (!constructor_unfilled_fields)
   11634                 :           5 :             set_nonincremental_init (braced_init_obstack);
   11635                 :             :           else
   11636                 :             :             {
   11637                 :        1051 :               tree bitpos, unfillpos;
   11638                 :             : 
   11639                 :        1051 :               bitpos = bit_position (field);
   11640                 :        1051 :               unfillpos = bit_position (constructor_unfilled_fields);
   11641                 :             : 
   11642                 :        1051 :               if (tree_int_cst_lt (bitpos, unfillpos))
   11643                 :           4 :                 set_nonincremental_init (braced_init_obstack);
   11644                 :             :             }
   11645                 :             :         }
   11646                 :             : 
   11647                 :        1396 :       add_pending_init (loc, field, value, origtype, implicit,
   11648                 :             :                         braced_init_obstack);
   11649                 :        1396 :       return;
   11650                 :             :     }
   11651                 :     9452879 :   else if (TREE_CODE (constructor_type) == UNION_TYPE
   11652                 :     9452879 :            && !vec_safe_is_empty (constructor_elements))
   11653                 :             :     {
   11654                 :          62 :       if (!implicit)
   11655                 :             :         {
   11656                 :          12 :           if (TREE_SIDE_EFFECTS (constructor_elements->last ().value))
   11657                 :           3 :             warning_init (loc, OPT_Woverride_init_side_effects,
   11658                 :             :                           "initialized field with side-effects overwritten");
   11659                 :           9 :           else if (warn_override_init)
   11660                 :           6 :             warning_init (loc, OPT_Woverride_init,
   11661                 :             :                           "initialized field overwritten");
   11662                 :             :         }
   11663                 :             : 
   11664                 :             :       /* We can have just one union field set.  */
   11665                 :          62 :       constructor_elements = NULL;
   11666                 :             :     }
   11667                 :             : 
   11668                 :             :   /* Otherwise, output this element either to
   11669                 :             :      constructor_elements or to the assembler file.  */
   11670                 :             : 
   11671                 :     9452879 :   constructor_elt celt = {field, value};
   11672                 :     9452879 :   vec_safe_push (constructor_elements, celt);
   11673                 :             : 
   11674                 :             :   /* Advance the variable that indicates sequential elements output.  */
   11675                 :     9452879 :   if (TREE_CODE (constructor_type) == ARRAY_TYPE)
   11676                 :             :     {
   11677                 :     1713253 :       tree inc = bitsize_one_node;
   11678                 :     1713253 :       if (value && TREE_CODE (value) == RAW_DATA_CST)
   11679                 :         228 :         inc = bitsize_int (RAW_DATA_LENGTH (value));
   11680                 :     1713253 :       constructor_unfilled_index
   11681                 :     1713253 :         = size_binop_loc (input_location, PLUS_EXPR,
   11682                 :             :                           constructor_unfilled_index, inc);
   11683                 :             :     }
   11684                 :     7739626 :   else if (TREE_CODE (constructor_type) == RECORD_TYPE)
   11685                 :             :     {
   11686                 :     1036505 :       constructor_unfilled_fields
   11687                 :     1036505 :         = DECL_CHAIN (constructor_unfilled_fields);
   11688                 :             : 
   11689                 :             :       /* Skip any nameless bit fields.  */
   11690                 :     1036505 :       while (constructor_unfilled_fields != NULL_TREE
   11691                 :     1036606 :              && DECL_UNNAMED_BIT_FIELD (constructor_unfilled_fields))
   11692                 :         101 :         constructor_unfilled_fields
   11693                 :         101 :           = DECL_CHAIN (constructor_unfilled_fields);
   11694                 :             :     }
   11695                 :     6703121 :   else if (TREE_CODE (constructor_type) == UNION_TYPE)
   11696                 :       30177 :     constructor_unfilled_fields = NULL_TREE;
   11697                 :             : 
   11698                 :             :   /* Now output any pending elements which have become next.  */
   11699                 :     9452879 :   if (pending)
   11700                 :     9450022 :     output_pending_init_elements (0, braced_init_obstack);
   11701                 :             : }
   11702                 :             : 
   11703                 :             : /* For two FIELD_DECLs in the same chain, return -1 if field1
   11704                 :             :    comes before field2, 1 if field1 comes after field2 and
   11705                 :             :    0 if field1 == field2.  */
   11706                 :             : 
   11707                 :             : static int
   11708                 :        4001 : init_field_decl_cmp (tree field1, tree field2)
   11709                 :             : {
   11710                 :        4001 :   if (field1 == field2)
   11711                 :             :     return 0;
   11712                 :             : 
   11713                 :        2138 :   tree bitpos1 = bit_position (field1);
   11714                 :        2138 :   tree bitpos2 = bit_position (field2);
   11715                 :        2138 :   if (tree_int_cst_equal (bitpos1, bitpos2))
   11716                 :             :     {
   11717                 :             :       /* If one of the fields has non-zero bitsize, then that
   11718                 :             :          field must be the last one in a sequence of zero
   11719                 :             :          sized fields, fields after it will have bigger
   11720                 :             :          bit_position.  */
   11721                 :          22 :       if (TREE_TYPE (field1) != error_mark_node
   11722                 :          22 :           && COMPLETE_TYPE_P (TREE_TYPE (field1))
   11723                 :          44 :           && integer_nonzerop (TREE_TYPE (field1)))
   11724                 :             :         return 1;
   11725                 :          22 :       if (TREE_TYPE (field2) != error_mark_node
   11726                 :          22 :           && COMPLETE_TYPE_P (TREE_TYPE (field2))
   11727                 :          37 :           && integer_nonzerop (TREE_TYPE (field2)))
   11728                 :             :         return -1;
   11729                 :             :       /* Otherwise, fallback to DECL_CHAIN walk to find out
   11730                 :             :          which field comes earlier.  Walk chains of both
   11731                 :             :          fields, so that if field1 and field2 are close to each
   11732                 :             :          other in either order, it is found soon even for large
   11733                 :             :          sequences of zero sized fields.  */
   11734                 :             :       tree f1 = field1, f2 = field2;
   11735                 :          22 :       while (1)
   11736                 :             :         {
   11737                 :          22 :           f1 = DECL_CHAIN (f1);
   11738                 :          22 :           f2 = DECL_CHAIN (f2);
   11739                 :          22 :           if (f1 == NULL_TREE)
   11740                 :             :             {
   11741                 :           7 :               gcc_assert (f2);
   11742                 :             :               return 1;
   11743                 :             :             }
   11744                 :          15 :           if (f2 == NULL_TREE)
   11745                 :             :             return -1;
   11746                 :           1 :           if (f1 == field2)
   11747                 :             :             return -1;
   11748                 :           0 :           if (f2 == field1)
   11749                 :             :             return 1;
   11750                 :           0 :           if (!tree_int_cst_equal (bit_position (f1), bitpos1))
   11751                 :             :             return 1;
   11752                 :           0 :           if (!tree_int_cst_equal (bit_position (f2), bitpos1))
   11753                 :             :             return -1;
   11754                 :             :         }
   11755                 :             :     }
   11756                 :        2116 :   else if (tree_int_cst_lt (bitpos1, bitpos2))
   11757                 :             :     return -1;
   11758                 :             :   else
   11759                 :             :     return 1;
   11760                 :             : }
   11761                 :             : 
   11762                 :             : /* Output any pending elements which have become next.
   11763                 :             :    As we output elements, constructor_unfilled_{fields,index}
   11764                 :             :    advances, which may cause other elements to become next;
   11765                 :             :    if so, they too are output.
   11766                 :             : 
   11767                 :             :    If ALL is 0, we return when there are
   11768                 :             :    no more pending elements to output now.
   11769                 :             : 
   11770                 :             :    If ALL is 1, we output space as necessary so that
   11771                 :             :    we can output all the pending elements.  */
   11772                 :             : static void
   11773                 :    11494270 : output_pending_init_elements (int all, struct obstack * braced_init_obstack)
   11774                 :             : {
   11775                 :    11494270 :   struct init_node *elt = constructor_pending_elts;
   11776                 :    11495266 :   tree next;
   11777                 :             : 
   11778                 :    11495266 :  retry:
   11779                 :             : 
   11780                 :             :   /* Look through the whole pending tree.
   11781                 :             :      If we find an element that should be output now,
   11782                 :             :      output it.  Otherwise, set NEXT to the element
   11783                 :             :      that comes first among those still pending.  */
   11784                 :             : 
   11785                 :    11495266 :   next = NULL_TREE;
   11786                 :    11500896 :   while (elt)
   11787                 :             :     {
   11788                 :        7574 :       if (TREE_CODE (constructor_type) == ARRAY_TYPE)
   11789                 :             :         {
   11790                 :        3004 :           if (tree_int_cst_equal (elt->purpose,
   11791                 :             :                                   constructor_unfilled_index))
   11792                 :        1197 :             output_init_element (input_location, elt->value, elt->origtype,
   11793                 :        1197 :                                  true, TREE_TYPE (constructor_type),
   11794                 :             :                                  constructor_unfilled_index, false, false,
   11795                 :             :                                  braced_init_obstack);
   11796                 :        1807 :           else if (tree_int_cst_lt (constructor_unfilled_index,
   11797                 :        1807 :                                     elt->purpose))
   11798                 :             :             {
   11799                 :             :               /* Advance to the next smaller node.  */
   11800                 :         589 :               if (elt->left)
   11801                 :             :                 elt = elt->left;
   11802                 :             :               else
   11803                 :             :                 {
   11804                 :             :                   /* We have reached the smallest node bigger than the
   11805                 :             :                      current unfilled index.  Fill the space first.  */
   11806                 :         209 :                   next = elt->purpose;
   11807                 :         209 :                   break;
   11808                 :             :                 }
   11809                 :             :             }
   11810                 :             :           else
   11811                 :             :             {
   11812                 :             :               /* Advance to the next bigger node.  */
   11813                 :        1218 :               if (elt->right)
   11814                 :             :                 elt = elt->right;
   11815                 :             :               else
   11816                 :             :                 {
   11817                 :             :                   /* We have reached the biggest node in a subtree.  Find
   11818                 :             :                      the parent of it, which is the next bigger node.  */
   11819                 :        1218 :                   while (elt->parent && elt->parent->right == elt)
   11820                 :             :                     elt = elt->parent;
   11821                 :         774 :                   elt = elt->parent;
   11822                 :        1149 :                   if (elt && tree_int_cst_lt (constructor_unfilled_index,
   11823                 :         375 :                                               elt->purpose))
   11824                 :             :                     {
   11825                 :          22 :                       next = elt->purpose;
   11826                 :          22 :                       break;
   11827                 :             :                     }
   11828                 :             :                 }
   11829                 :             :             }
   11830                 :             :         }
   11831                 :        4570 :       else if (RECORD_OR_UNION_TYPE_P (constructor_type))
   11832                 :             :         {
   11833                 :             :           /* If the current record is complete we are done.  */
   11834                 :        4570 :           if (constructor_unfilled_fields == NULL_TREE)
   11835                 :             :             break;
   11836                 :             : 
   11837                 :        3731 :           int cmp = init_field_decl_cmp (constructor_unfilled_fields,
   11838                 :             :                                          elt->purpose);
   11839                 :        3731 :           if (cmp == 0)
   11840                 :        1660 :             output_init_element (input_location, elt->value, elt->origtype,
   11841                 :        1660 :                                  true, TREE_TYPE (elt->purpose),
   11842                 :             :                                  elt->purpose, false, false,
   11843                 :             :                                  braced_init_obstack);
   11844                 :        2071 :           else if (cmp < 0)
   11845                 :             :             {
   11846                 :             :               /* Advance to the next smaller node.  */
   11847                 :        1084 :               if (elt->left)
   11848                 :             :                 elt = elt->left;
   11849                 :             :               else
   11850                 :             :                 {
   11851                 :             :                   /* We have reached the smallest node bigger than the
   11852                 :             :                      current unfilled field.  Fill the space first.  */
   11853                 :         807 :                   next = elt->purpose;
   11854                 :         807 :                   break;
   11855                 :             :                 }
   11856                 :             :             }
   11857                 :             :           else
   11858                 :             :             {
   11859                 :             :               /* Advance to the next bigger node.  */
   11860                 :         987 :               if (elt->right)
   11861                 :             :                 elt = elt->right;
   11862                 :             :               else
   11863                 :             :                 {
   11864                 :             :                   /* We have reached the biggest node in a subtree.  Find
   11865                 :             :                      the parent of it, which is the next bigger node.  */
   11866                 :         731 :                   while (elt->parent && elt->parent->right == elt)
   11867                 :             :                     elt = elt->parent;
   11868                 :         515 :                   elt = elt->parent;
   11869                 :         515 :                   if (elt
   11870                 :         515 :                       && init_field_decl_cmp (constructor_unfilled_fields,
   11871                 :             :                                               elt->purpose) < 0)
   11872                 :             :                     {
   11873                 :          67 :                       next = elt->purpose;
   11874                 :          67 :                       break;
   11875                 :             :                     }
   11876                 :             :                 }
   11877                 :             :             }
   11878                 :             :         }
   11879                 :             :     }
   11880                 :             : 
   11881                 :             :   /* Ordinarily return, but not if we want to output all
   11882                 :             :      and there are elements left.  */
   11883                 :    11495266 :   if (!(all && next != NULL_TREE))
   11884                 :    11494270 :     return;
   11885                 :             : 
   11886                 :             :   /* If it's not incremental, just skip over the gap, so that after
   11887                 :             :      jumping to retry we will output the next successive element.  */
   11888                 :         996 :   if (RECORD_OR_UNION_TYPE_P (constructor_type))
   11889                 :         804 :     constructor_unfilled_fields = next;
   11890                 :         192 :   else if (TREE_CODE (constructor_type) == ARRAY_TYPE)
   11891                 :         192 :     constructor_unfilled_index = next;
   11892                 :             : 
   11893                 :             :   /* ELT now points to the node in the pending tree with the next
   11894                 :             :      initializer to output.  */
   11895                 :         996 :   goto retry;
   11896                 :             : }
   11897                 :             : 
   11898                 :             : /* Expression VALUE coincides with the start of type TYPE in a braced
   11899                 :             :    initializer.  Return true if we should treat VALUE as initializing
   11900                 :             :    the first element of TYPE, false if we should treat it as initializing
   11901                 :             :    TYPE as a whole.
   11902                 :             : 
   11903                 :             :    If the initializer is clearly invalid, the question becomes:
   11904                 :             :    which choice gives the best error message?  */
   11905                 :             : 
   11906                 :             : static bool
   11907                 :     3478514 : initialize_elementwise_p (tree type, tree value)
   11908                 :             : {
   11909                 :     3478514 :   if (type == error_mark_node || value == error_mark_node)
   11910                 :             :     return false;
   11911                 :             : 
   11912                 :     3478070 :   gcc_checking_assert (TYPE_MAIN_VARIANT (type) == type);
   11913                 :             : 
   11914                 :     3478070 :   tree value_type = TREE_TYPE (value);
   11915                 :     3478070 :   if (value_type == error_mark_node)
   11916                 :             :     return false;
   11917                 :             : 
   11918                 :             :   /* GNU vectors can be initialized elementwise.  However, treat any
   11919                 :             :      kind of vector value as initializing the vector type as a whole,
   11920                 :             :      regardless of whether the value is a GNU vector.  Such initializers
   11921                 :             :      are valid if and only if they would have been valid in a non-braced
   11922                 :             :      initializer like:
   11923                 :             : 
   11924                 :             :         TYPE foo = VALUE;
   11925                 :             : 
   11926                 :             :      so recursing into the vector type would be at best confusing or at
   11927                 :             :      worst wrong.  For example, when -flax-vector-conversions is in effect,
   11928                 :             :      it's possible to initialize a V8HI from a V4SI, even though the vectors
   11929                 :             :      have different element types and different numbers of elements.  */
   11930                 :     3478070 :   if (gnu_vector_type_p (type))
   11931                 :       19160 :     return !VECTOR_TYPE_P (value_type);
   11932                 :             : 
   11933                 :     3458910 :   if (AGGREGATE_TYPE_P (type))
   11934                 :     1740931 :     return !comptypes (type, TYPE_MAIN_VARIANT (value_type));
   11935                 :             : 
   11936                 :             :   return false;
   11937                 :             : }
   11938                 :             : 
   11939                 :             : /* Helper function for process_init_element.  Split first element of
   11940                 :             :    RAW_DATA_CST and save the rest to *RAW_DATA.  */
   11941                 :             : 
   11942                 :             : static inline tree
   11943                 :     9452486 : maybe_split_raw_data (tree value, tree *raw_data)
   11944                 :             : {
   11945                 :     9452486 :   if (value == NULL_TREE || TREE_CODE (value) != RAW_DATA_CST)
   11946                 :             :     return value;
   11947                 :         211 :   *raw_data = value;
   11948                 :         211 :   value = build_int_cst (integer_type_node,
   11949                 :         211 :                          RAW_DATA_UCHAR_ELT (*raw_data, 0));
   11950                 :         211 :   ++RAW_DATA_POINTER (*raw_data);
   11951                 :         211 :   --RAW_DATA_LENGTH (*raw_data);
   11952                 :         211 :   return value;
   11953                 :             : }
   11954                 :             : 
   11955                 :             : /* Return non-zero if c_parser_initval should attempt to optimize
   11956                 :             :    large initializers into RAW_DATA_CST.  In that case return how
   11957                 :             :    many elements to optimize at most.  */
   11958                 :             : 
   11959                 :             : unsigned
   11960                 :     2928579 : c_maybe_optimize_large_byte_initializer (void)
   11961                 :             : {
   11962                 :     2928579 :   if (!constructor_type
   11963                 :     2928509 :       || TREE_CODE (constructor_type) != ARRAY_TYPE
   11964                 :      206258 :       || constructor_stack->implicit)
   11965                 :             :     return 0;
   11966                 :      203523 :   tree elttype = TYPE_MAIN_VARIANT (TREE_TYPE (constructor_type));
   11967                 :      203523 :   if (TREE_CODE (elttype) != INTEGER_TYPE
   11968                 :      203523 :       && TREE_CODE (elttype) != BITINT_TYPE)
   11969                 :             :     return 0;
   11970                 :      181142 :   if (TYPE_PRECISION (elttype) != CHAR_BIT
   11971                 :       27832 :       || constructor_stack->replacement_value.value
   11972                 :       27832 :       || (COMPLETE_TYPE_P (constructor_type)
   11973                 :       26195 :           && !poly_int_tree_p (TYPE_SIZE (constructor_type)))
   11974                 :      208974 :       || constructor_range_stack)
   11975                 :             :     return 0;
   11976                 :       27832 :   if (constructor_max_index == NULL_TREE)
   11977                 :             :     return INT_MAX;
   11978                 :       26195 :   if (tree_int_cst_le (constructor_max_index, constructor_index)
   11979                 :       26195 :       || integer_all_onesp (constructor_max_index))
   11980                 :        4756 :     return 0;
   11981                 :       21439 :   widest_int w = wi::to_widest (constructor_max_index);
   11982                 :       21439 :   w -= wi::to_widest (constructor_index);
   11983                 :       21439 :   w += 1;
   11984                 :       21439 :   if (w < 64)
   11985                 :             :     return 0;
   11986                 :        6888 :   if (w > INT_MAX)
   11987                 :             :     return INT_MAX;
   11988                 :        6888 :   return w.to_uhwi ();
   11989                 :       21439 : }
   11990                 :             : 
   11991                 :             : /* Add one non-braced element to the current constructor level.
   11992                 :             :    This adjusts the current position within the constructor's type.
   11993                 :             :    This may also start or terminate implicit levels
   11994                 :             :    to handle a partly-braced initializer.
   11995                 :             : 
   11996                 :             :    Once this has found the correct level for the new element,
   11997                 :             :    it calls output_init_element.
   11998                 :             : 
   11999                 :             :    IMPLICIT is true if value comes from pop_init_level (1),
   12000                 :             :    the new initializer has been merged with the existing one
   12001                 :             :    and thus no warnings should be emitted about overriding an
   12002                 :             :    existing initializer.  */
   12003                 :             : 
   12004                 :             : void
   12005                 :     9443504 : process_init_element (location_t loc, struct c_expr value, bool implicit,
   12006                 :             :                       struct obstack * braced_init_obstack)
   12007                 :             : {
   12008                 :     9443504 :   tree orig_value = value.value;
   12009                 :    18887008 :   int string_flag
   12010                 :     9443504 :     = (orig_value != NULL_TREE && TREE_CODE (orig_value) == STRING_CST);
   12011                 :     9443504 :   bool strict_string = value.original_code == STRING_CST;
   12012                 :     9443504 :   bool was_designated = designator_depth != 0;
   12013                 :     9443504 :   tree raw_data = NULL_TREE;
   12014                 :             : 
   12015                 :     9443716 : retry:
   12016                 :     9443716 :   designator_depth = 0;
   12017                 :     9443716 :   designator_erroneous = 0;
   12018                 :             : 
   12019                 :     9443716 :   if (!implicit && value.value && !integer_zerop (value.value))
   12020                 :     7445366 :     constructor_zeroinit = 0;
   12021                 :             : 
   12022                 :             :   /* Handle superfluous braces around string cst as in
   12023                 :             :      char x[] = {"foo"}; */
   12024                 :     9443716 :   if (constructor_type
   12025                 :     9443588 :       && !was_designated
   12026                 :     9410603 :       && TREE_CODE (constructor_type) == ARRAY_TYPE
   12027                 :     1701814 :       && INTEGRAL_TYPE_P (TREE_TYPE (constructor_type))
   12028                 :    10176940 :       && integer_zerop (constructor_unfilled_index))
   12029                 :             :     {
   12030                 :      162820 :       if (constructor_stack->replacement_value.value)
   12031                 :             :         {
   12032                 :           8 :           error_init (loc, "excess elements in %qT initializer", constructor_type);
   12033                 :         375 :           return;
   12034                 :             :         }
   12035                 :      162812 :       else if (string_flag)
   12036                 :             :         {
   12037                 :         102 :           constructor_stack->replacement_value = value;
   12038                 :         102 :           return;
   12039                 :             :         }
   12040                 :             :     }
   12041                 :             : 
   12042                 :     9443606 :   if (constructor_stack->replacement_value.value != NULL_TREE)
   12043                 :             :     {
   12044                 :           0 :       error_init (loc, "excess elements in struct initializer");
   12045                 :           0 :       return;
   12046                 :             :     }
   12047                 :             : 
   12048                 :             :   /* Ignore elements of a brace group if it is entirely superfluous
   12049                 :             :      and has already been diagnosed, or if the type is erroneous.  */
   12050                 :     9443606 :   if (constructor_type == NULL_TREE || constructor_type == error_mark_node)
   12051                 :             :     return;
   12052                 :             : 
   12053                 :             :   /* Ignore elements of an initializer for a variable-size type.
   12054                 :             :      Those are diagnosed in the parser (empty initializer braces are OK).  */
   12055                 :     9443401 :   if (COMPLETE_TYPE_P (constructor_type)
   12056                 :     9443401 :       && !poly_int_tree_p (TYPE_SIZE (constructor_type)))
   12057                 :             :     return;
   12058                 :             : 
   12059                 :     8739797 :   if (!implicit && warn_designated_init && !was_designated
   12060                 :     8707429 :       && TREE_CODE (constructor_type) == RECORD_TYPE
   12061                 :    10477311 :       && lookup_attribute ("designated_init",
   12062                 :     1033962 :                            TYPE_ATTRIBUTES (constructor_type)))
   12063                 :          50 :     warning_init (loc,
   12064                 :             :                   OPT_Wdesignated_init,
   12065                 :             :                   "positional initialization of field "
   12066                 :             :                   "in %<struct%> declared with %<designated_init%> attribute");
   12067                 :             : 
   12068                 :             :   /* If we've exhausted any levels that didn't have braces,
   12069                 :             :      pop them now.  */
   12070                 :    10145307 :   while (constructor_stack->implicit)
   12071                 :             :     {
   12072                 :      706771 :       if (RECORD_OR_UNION_TYPE_P (constructor_type)
   12073                 :      702768 :           && constructor_fields == NULL_TREE)
   12074                 :      701717 :         process_init_element (loc,
   12075                 :             :                               pop_init_level (loc, 1, braced_init_obstack,
   12076                 :             :                                               last_init_list_comma),
   12077                 :             :                               true, braced_init_obstack);
   12078                 :        5054 :       else if ((TREE_CODE (constructor_type) == ARRAY_TYPE
   12079                 :        1695 :                 || gnu_vector_type_p (constructor_type))
   12080                 :        4003 :                && constructor_max_index
   12081                 :        9030 :                && tree_int_cst_lt (constructor_max_index,
   12082                 :             :                                    constructor_index))
   12083                 :         241 :         process_init_element (loc,
   12084                 :             :                               pop_init_level (loc, 1, braced_init_obstack,
   12085                 :             :                                               last_init_list_comma),
   12086                 :             :                               true, braced_init_obstack);
   12087                 :             :       else
   12088                 :             :         break;
   12089                 :             :     }
   12090                 :             : 
   12091                 :             :   /* In the case of [LO ... HI] = VALUE, only evaluate VALUE once.  */
   12092                 :     9443349 :   if (constructor_range_stack)
   12093                 :             :     {
   12094                 :             :       /* If value is a compound literal and we'll be just using its
   12095                 :             :          content, don't put it into a SAVE_EXPR.  */
   12096                 :         365 :       if (TREE_CODE (value.value) != COMPOUND_LITERAL_EXPR
   12097                 :           3 :           || !require_constant_value)
   12098                 :             :         {
   12099                 :         362 :           tree semantic_type = NULL_TREE;
   12100                 :         362 :           if (TREE_CODE (value.value) == EXCESS_PRECISION_EXPR)
   12101                 :             :             {
   12102                 :           0 :               semantic_type = TREE_TYPE (value.value);
   12103                 :           0 :               value.value = TREE_OPERAND (value.value, 0);
   12104                 :             :             }
   12105                 :         362 :           value.value = save_expr (value.value);
   12106                 :         362 :           if (semantic_type)
   12107                 :           0 :             value.value = build1 (EXCESS_PRECISION_EXPR, semantic_type,
   12108                 :             :                                   value.value);
   12109                 :             :         }
   12110                 :             :     }
   12111                 :             : 
   12112                 :    10156761 :   while (1)
   12113                 :             :     {
   12114                 :    10156761 :       if (TREE_CODE (constructor_type) == RECORD_TYPE)
   12115                 :             :         {
   12116                 :     1037965 :           tree fieldtype;
   12117                 :     1037965 :           enum tree_code fieldcode;
   12118                 :             : 
   12119                 :     1037965 :           if (constructor_fields == NULL_TREE)
   12120                 :             :             {
   12121                 :        1280 :               pedwarn_init (loc, 0, "excess elements in struct initializer");
   12122                 :        1280 :               break;
   12123                 :             :             }
   12124                 :             : 
   12125                 :     1036685 :           fieldtype = TREE_TYPE (constructor_fields);
   12126                 :     1036685 :           if (fieldtype != error_mark_node)
   12127                 :     1036684 :             fieldtype = TYPE_MAIN_VARIANT (fieldtype);
   12128                 :     1036685 :           fieldcode = TREE_CODE (fieldtype);
   12129                 :             : 
   12130                 :             :           /* Error for non-static initialization of a flexible array member.  */
   12131                 :     1036685 :           if (fieldcode == ARRAY_TYPE
   12132                 :      155204 :               && !require_constant_value
   12133                 :        1078 :               && TYPE_SIZE (fieldtype) == NULL_TREE
   12134                 :     1036695 :               && DECL_CHAIN (constructor_fields) == NULL_TREE)
   12135                 :             :             {
   12136                 :          10 :               error_init (loc, "non-static initialization of a flexible "
   12137                 :             :                           "array member");
   12138                 :          10 :               break;
   12139                 :             :             }
   12140                 :             : 
   12141                 :             :           /* Error for initialization of a flexible array member with
   12142                 :             :              a string constant if the structure is in an array.  E.g.:
   12143                 :             :              struct S { int x; char y[]; };
   12144                 :             :              struct S s[] = { { 1, "foo" } };
   12145                 :             :              is invalid.  */
   12146                 :     1036675 :           if (string_flag
   12147                 :     1036675 :               && fieldcode == ARRAY_TYPE
   12148                 :        3352 :               && constructor_depth > 1
   12149                 :         489 :               && TYPE_SIZE (fieldtype) == NULL_TREE
   12150                 :     1036722 :               && DECL_CHAIN (constructor_fields) == NULL_TREE)
   12151                 :             :             {
   12152                 :          47 :               bool in_array_p = false;
   12153                 :          47 :               for (struct constructor_stack *p = constructor_stack;
   12154                 :          73 :                    p && p->type; p = p->next)
   12155                 :          59 :                 if (TREE_CODE (p->type) == ARRAY_TYPE)
   12156                 :             :                   {
   12157                 :             :                     in_array_p = true;
   12158                 :             :                     break;
   12159                 :             :                   }
   12160                 :          47 :               if (in_array_p)
   12161                 :             :                 {
   12162                 :          33 :                   error_init (loc, "initialization of flexible array "
   12163                 :             :                               "member in a nested context");
   12164                 :          33 :                   break;
   12165                 :             :                 }
   12166                 :             :             }
   12167                 :             : 
   12168                 :             :           /* Accept a string constant to initialize a subarray.  */
   12169                 :     1036642 :           if (value.value != NULL_TREE
   12170                 :     1036569 :               && fieldcode == ARRAY_TYPE
   12171                 :      155088 :               && INTEGRAL_TYPE_P (TREE_TYPE (fieldtype))
   12172                 :     1191253 :               && string_flag)
   12173                 :             :             value.value = orig_value;
   12174                 :             :           /* Otherwise, if we have come to a subaggregate,
   12175                 :             :              and we don't have an element of its type, push into it.  */
   12176                 :     1033611 :           else if (value.value != NULL_TREE
   12177                 :     1033323 :                    && initialize_elementwise_p (fieldtype, value.value))
   12178                 :             :             {
   12179                 :         288 :               push_init_level (loc, 1, braced_init_obstack);
   12180                 :         288 :               continue;
   12181                 :             :             }
   12182                 :             : 
   12183                 :     1036354 :           value.value = maybe_split_raw_data (value.value, &raw_data);
   12184                 :     1036354 :           if (value.value)
   12185                 :             :             {
   12186                 :     1036281 :               push_member_name (constructor_fields);
   12187                 :     1036281 :               output_init_element (loc, value.value, value.original_type,
   12188                 :             :                                    strict_string, fieldtype,
   12189                 :             :                                    constructor_fields, true, implicit,
   12190                 :             :                                    braced_init_obstack);
   12191                 :     1036281 :               RESTORE_SPELLING_DEPTH (constructor_depth);
   12192                 :             :             }
   12193                 :             :           else
   12194                 :             :             /* Do the bookkeeping for an element that was
   12195                 :             :                directly output as a constructor.  */
   12196                 :             :             {
   12197                 :             :               /* For a record, keep track of end position of last field.  */
   12198                 :          73 :               if (DECL_SIZE (constructor_fields))
   12199                 :          30 :                 constructor_bit_index
   12200                 :          30 :                   = size_binop_loc (input_location, PLUS_EXPR,
   12201                 :             :                                     bit_position (constructor_fields),
   12202                 :          30 :                                     DECL_SIZE (constructor_fields));
   12203                 :             : 
   12204                 :             :               /* If the current field was the first one not yet written out,
   12205                 :             :                  it isn't now, so update.  */
   12206                 :          73 :               if (constructor_unfilled_fields == constructor_fields)
   12207                 :             :                 {
   12208                 :          64 :                   constructor_unfilled_fields = DECL_CHAIN (constructor_fields);
   12209                 :             :                   /* Skip any nameless bit fields.  */
   12210                 :          64 :                   while (constructor_unfilled_fields != 0
   12211                 :          64 :                          && (DECL_UNNAMED_BIT_FIELD
   12212                 :             :                              (constructor_unfilled_fields)))
   12213                 :           0 :                     constructor_unfilled_fields =
   12214                 :           0 :                       DECL_CHAIN (constructor_unfilled_fields);
   12215                 :             :                 }
   12216                 :             :             }
   12217                 :             : 
   12218                 :     1036354 :           constructor_fields = DECL_CHAIN (constructor_fields);
   12219                 :             :           /* Skip any nameless bit fields at the beginning.  */
   12220                 :     1036354 :           while (constructor_fields != NULL_TREE
   12221                 :     1036455 :                  && DECL_UNNAMED_BIT_FIELD (constructor_fields))
   12222                 :         101 :             constructor_fields = DECL_CHAIN (constructor_fields);
   12223                 :             :         }
   12224                 :     9118796 :       else if (TREE_CODE (constructor_type) == UNION_TYPE)
   12225                 :             :         {
   12226                 :       30236 :           tree fieldtype;
   12227                 :       30236 :           enum tree_code fieldcode;
   12228                 :             : 
   12229                 :       30236 :           if (constructor_fields == NULL_TREE)
   12230                 :             :             {
   12231                 :           3 :               pedwarn_init (loc, 0,
   12232                 :             :                             "excess elements in union initializer");
   12233                 :           3 :               break;
   12234                 :             :             }
   12235                 :             : 
   12236                 :       30233 :           fieldtype = TREE_TYPE (constructor_fields);
   12237                 :       30233 :           if (fieldtype != error_mark_node)
   12238                 :       30233 :             fieldtype = TYPE_MAIN_VARIANT (fieldtype);
   12239                 :       30233 :           fieldcode = TREE_CODE (fieldtype);
   12240                 :             : 
   12241                 :             :           /* Warn that traditional C rejects initialization of unions.
   12242                 :             :              We skip the warning if the value is zero.  This is done
   12243                 :             :              under the assumption that the zero initializer in user
   12244                 :             :              code appears conditioned on e.g. __STDC__ to avoid
   12245                 :             :              "missing initializer" warnings and relies on default
   12246                 :             :              initialization to zero in the traditional C case.
   12247                 :             :              We also skip the warning if the initializer is designated,
   12248                 :             :              again on the assumption that this must be conditional on
   12249                 :             :              __STDC__ anyway (and we've already complained about the
   12250                 :             :              member-designator already).  */
   12251                 :       32280 :           if (!in_system_header_at (input_location) && !constructor_designated
   12252                 :       31664 :               && !(value.value && (integer_zerop (value.value)
   12253                 :        1333 :                                    || real_zerop (value.value))))
   12254                 :        1326 :             warning (OPT_Wtraditional, "traditional C rejects initialization "
   12255                 :             :                      "of unions");
   12256                 :             : 
   12257                 :             :           /* Error for non-static initialization of a flexible array member.  */
   12258                 :       30233 :           if (fieldcode == ARRAY_TYPE
   12259                 :         766 :               && !require_constant_value
   12260                 :       30290 :               && TYPE_SIZE (fieldtype) == NULL_TREE)
   12261                 :             :             {
   12262                 :           3 :               error_init (loc, "non-static initialization of a flexible "
   12263                 :             :                           "array member");
   12264                 :           3 :               break;
   12265                 :             :             }
   12266                 :             : 
   12267                 :             :           /* Error for initialization of a flexible array member with
   12268                 :             :              a string constant if the structure is in an array.  E.g.:
   12269                 :             :              union U { int x; char y[]; };
   12270                 :             :              union U s[] = { { 1, "foo" } };
   12271                 :             :              is invalid.  */
   12272                 :       30230 :           if (string_flag
   12273                 :       30230 :               && fieldcode == ARRAY_TYPE
   12274                 :           7 :               && constructor_depth > 1
   12275                 :       30234 :               && TYPE_SIZE (fieldtype) == NULL_TREE)
   12276                 :             :             {
   12277                 :           3 :               bool in_array_p = false;
   12278                 :           3 :               for (struct constructor_stack *p = constructor_stack;
   12279                 :           3 :                    p && p->type; p = p->next)
   12280                 :           3 :                 if (TREE_CODE (p->type) == ARRAY_TYPE)
   12281                 :             :                   {
   12282                 :             :                     in_array_p = true;
   12283                 :             :                     break;
   12284                 :             :                   }
   12285                 :           3 :               if (in_array_p)
   12286                 :             :                 {
   12287                 :           3 :                   error_init (loc, "initialization of flexible array "
   12288                 :             :                               "member in a nested context");
   12289                 :           3 :                   break;
   12290                 :             :                 }
   12291                 :             :             }
   12292                 :             : 
   12293                 :             :           /* Accept a string constant to initialize a subarray.  */
   12294                 :       30227 :           if (value.value != NULL_TREE
   12295                 :       30227 :               && fieldcode == ARRAY_TYPE
   12296                 :         760 :               && INTEGRAL_TYPE_P (TREE_TYPE (fieldtype))
   12297                 :       30982 :               && string_flag)
   12298                 :             :             value.value = orig_value;
   12299                 :             :           /* Otherwise, if we have come to a subaggregate,
   12300                 :             :              and we don't have an element of its type, push into it.  */
   12301                 :       30269 :           else if (value.value != NULL_TREE
   12302                 :       30223 :                    && initialize_elementwise_p (fieldtype, value.value))
   12303                 :             :             {
   12304                 :          46 :               push_init_level (loc, 1, braced_init_obstack);
   12305                 :          46 :               continue;
   12306                 :             :             }
   12307                 :             : 
   12308                 :       30181 :           value.value = maybe_split_raw_data (value.value, &raw_data);
   12309                 :       30181 :           if (value.value)
   12310                 :             :             {
   12311                 :       30181 :               push_member_name (constructor_fields);
   12312                 :       30181 :               output_init_element (loc, value.value, value.original_type,
   12313                 :             :                                    strict_string, fieldtype,
   12314                 :             :                                    constructor_fields, true, implicit,
   12315                 :             :                                    braced_init_obstack);
   12316                 :       30181 :               RESTORE_SPELLING_DEPTH (constructor_depth);
   12317                 :             :             }
   12318                 :             :           else
   12319                 :             :             /* Do the bookkeeping for an element that was
   12320                 :             :                directly output as a constructor.  */
   12321                 :             :             {
   12322                 :           0 :               constructor_bit_index = DECL_SIZE (constructor_fields);
   12323                 :           0 :               constructor_unfilled_fields = DECL_CHAIN (constructor_fields);
   12324                 :             :             }
   12325                 :             : 
   12326                 :       30181 :           constructor_fields = NULL_TREE;
   12327                 :             :         }
   12328                 :     9088560 :       else if (TREE_CODE (constructor_type) == ARRAY_TYPE)
   12329                 :             :         {
   12330                 :     2415536 :           tree elttype = TYPE_MAIN_VARIANT (TREE_TYPE (constructor_type));
   12331                 :     2415536 :           enum tree_code eltcode = TREE_CODE (elttype);
   12332                 :             : 
   12333                 :             :           /* Accept a string constant to initialize a subarray.  */
   12334                 :     2415536 :           if (value.value != NULL_TREE
   12335                 :     2415536 :               && eltcode == ARRAY_TYPE
   12336                 :        6867 :               && INTEGRAL_TYPE_P (TREE_TYPE (elttype))
   12337                 :     2420967 :               && string_flag)
   12338                 :             :             value.value = orig_value;
   12339                 :             :           /* Otherwise, if we have come to a subaggregate,
   12340                 :             :              and we don't have an element of its type, push into it.  */
   12341                 :     3117317 :           else if (value.value != NULL_TREE
   12342                 :     2415041 :                    && initialize_elementwise_p (elttype, value.value))
   12343                 :             :             {
   12344                 :      702276 :               push_init_level (loc, 1, braced_init_obstack);
   12345                 :      702276 :               continue;
   12346                 :             :             }
   12347                 :             : 
   12348                 :     1713260 :           if (constructor_max_index != NULL_TREE
   12349                 :     1713260 :               && (tree_int_cst_lt (constructor_max_index, constructor_index)
   12350                 :      670643 :                   || integer_all_onesp (constructor_max_index)))
   12351                 :             :             {
   12352                 :         113 :               pedwarn_init (loc, 0,
   12353                 :             :                             "excess elements in array initializer");
   12354                 :         113 :               break;
   12355                 :             :             }
   12356                 :             : 
   12357                 :     1713147 :           if (value.value
   12358                 :     1713147 :               && TREE_CODE (value.value) == RAW_DATA_CST
   12359                 :         191 :               && RAW_DATA_LENGTH (value.value) > 1
   12360                 :         191 :               && (TREE_CODE (elttype) == INTEGER_TYPE
   12361                 :         191 :                   || TREE_CODE (elttype) == BITINT_TYPE)
   12362                 :         191 :               && TYPE_PRECISION (elttype) == CHAR_BIT
   12363                 :     1713338 :               && (constructor_max_index == NULL_TREE
   12364                 :          53 :                   || tree_int_cst_lt (constructor_index,
   12365                 :             :                                       constructor_max_index)))
   12366                 :             :             {
   12367                 :         191 :               unsigned int len = RAW_DATA_LENGTH (value.value);
   12368                 :         191 :               if (constructor_max_index)
   12369                 :             :                 {
   12370                 :          53 :                   widest_int w = wi::to_widest (constructor_max_index);
   12371                 :          53 :                   w -= wi::to_widest (constructor_index);
   12372                 :          53 :                   w += 1;
   12373                 :          53 :                   if (w < len)
   12374                 :           3 :                     len = w.to_uhwi ();
   12375                 :          53 :                 }
   12376                 :         191 :               if (len < (unsigned) RAW_DATA_LENGTH (value.value))
   12377                 :             :                 {
   12378                 :           3 :                   raw_data = copy_node (value.value);
   12379                 :           3 :                   RAW_DATA_LENGTH (raw_data) -= len;
   12380                 :           3 :                   RAW_DATA_POINTER (raw_data) += len;
   12381                 :           3 :                   RAW_DATA_LENGTH (value.value) = len;
   12382                 :             :                 }
   12383                 :         191 :               TREE_TYPE (value.value) = elttype;
   12384                 :         191 :               push_array_bounds (tree_to_uhwi (constructor_index));
   12385                 :         191 :               output_init_element (loc, value.value, value.original_type,
   12386                 :             :                                    false, elttype, constructor_index, true,
   12387                 :             :                                    implicit, braced_init_obstack);
   12388                 :         191 :               RESTORE_SPELLING_DEPTH (constructor_depth);
   12389                 :         191 :               constructor_index
   12390                 :         191 :                 = size_binop_loc (input_location, PLUS_EXPR,
   12391                 :         191 :                                   constructor_index, bitsize_int (len));
   12392                 :             :             }
   12393                 :             :           else
   12394                 :             :             {
   12395                 :     1712956 :               value.value = maybe_split_raw_data (value.value, &raw_data);
   12396                 :             :               /* Now output the actual element.  */
   12397                 :     1712956 :               if (value.value)
   12398                 :             :                 {
   12399                 :     1712956 :                   push_array_bounds (tree_to_uhwi (constructor_index));
   12400                 :     1712956 :                   output_init_element (loc, value.value, value.original_type,
   12401                 :             :                                        strict_string, elttype,
   12402                 :             :                                        constructor_index, true, implicit,
   12403                 :             :                                        braced_init_obstack);
   12404                 :     1712956 :                   RESTORE_SPELLING_DEPTH (constructor_depth);
   12405                 :             :                 }
   12406                 :             : 
   12407                 :     1712956 :               constructor_index
   12408                 :     1712956 :                 = size_binop_loc (input_location, PLUS_EXPR,
   12409                 :             :                                   constructor_index, bitsize_one_node);
   12410                 :             : 
   12411                 :     1712956 :               if (!value.value)
   12412                 :             :                 /* If we are doing the bookkeeping for an element that was
   12413                 :             :                    directly output as a constructor, we must update
   12414                 :             :                    constructor_unfilled_index.  */
   12415                 :           0 :                 constructor_unfilled_index = constructor_index;
   12416                 :             :             }
   12417                 :             :         }
   12418                 :     6673024 :       else if (gnu_vector_type_p (constructor_type))
   12419                 :             :         {
   12420                 :     6672582 :           tree elttype = TYPE_MAIN_VARIANT (TREE_TYPE (constructor_type));
   12421                 :             : 
   12422                 :             :           /* Do a basic check of initializer size.  Note that vectors
   12423                 :             :              may not always have a fixed size derived from their type.  */
   12424                 :     6672582 :           if (maybe_lt (tree_to_poly_uint64 (constructor_max_index),
   12425                 :     6672582 :                         tree_to_poly_uint64 (constructor_index)))
   12426                 :             :             {
   12427                 :             :               /* Diagose VLA out-of-bounds as errors.  */
   12428                 :           2 :               if (tree_to_poly_uint64 (constructor_max_index).is_constant())
   12429                 :           2 :                 pedwarn_init (loc, 0,
   12430                 :             :                               "excess elements in vector initializer");
   12431                 :             :               else
   12432                 :             :                 error_init (loc, "excess elements in vector initializer");
   12433                 :             : 
   12434                 :             :               break;
   12435                 :             :             }
   12436                 :             : 
   12437                 :     6672580 :           value.value = maybe_split_raw_data (value.value, &raw_data);
   12438                 :             :           /* Now output the actual element.  */
   12439                 :     6672580 :           if (value.value)
   12440                 :             :             {
   12441                 :     6672580 :               if (TREE_CODE (value.value) == VECTOR_CST)
   12442                 :           0 :                 elttype = TYPE_MAIN_VARIANT (constructor_type);
   12443                 :     6672580 :               output_init_element (loc, value.value, value.original_type,
   12444                 :             :                                    strict_string, elttype,
   12445                 :             :                                    constructor_index, true, implicit,
   12446                 :             :                                    braced_init_obstack);
   12447                 :             :             }
   12448                 :             : 
   12449                 :     6672580 :           constructor_index
   12450                 :     6672580 :             = size_binop_loc (input_location,
   12451                 :             :                               PLUS_EXPR, constructor_index, bitsize_one_node);
   12452                 :             : 
   12453                 :     6672580 :           if (!value.value)
   12454                 :             :             /* If we are doing the bookkeeping for an element that was
   12455                 :             :                directly output as a constructor, we must update
   12456                 :             :                constructor_unfilled_index.  */
   12457                 :           0 :             constructor_unfilled_index = constructor_index;
   12458                 :             :         }
   12459                 :             : 
   12460                 :             :       /* Handle the sole element allowed in a braced initializer
   12461                 :             :          for a scalar variable.  */
   12462                 :         442 :       else if (constructor_type != error_mark_node
   12463                 :         442 :                && constructor_fields == NULL_TREE)
   12464                 :             :         {
   12465                 :          27 :           pedwarn_init (loc, 0,
   12466                 :             :                         "excess elements in scalar initializer");
   12467                 :          27 :           break;
   12468                 :             :         }
   12469                 :             :       else
   12470                 :             :         {
   12471                 :         415 :           value.value = maybe_split_raw_data (value.value, &raw_data);
   12472                 :         415 :           if (value.value)
   12473                 :         415 :             output_init_element (loc, value.value, value.original_type,
   12474                 :             :                                  strict_string, constructor_type,
   12475                 :             :                                  NULL_TREE, true, implicit,
   12476                 :             :                                  braced_init_obstack);
   12477                 :         415 :           constructor_fields = NULL_TREE;
   12478                 :             :         }
   12479                 :             : 
   12480                 :             :       /* Handle range initializers either at this level or anywhere higher
   12481                 :             :          in the designator stack.  */
   12482                 :     9452677 :       if (constructor_range_stack)
   12483                 :             :         {
   12484                 :       10802 :           struct constructor_range_stack *p, *range_stack;
   12485                 :       10802 :           int finish = 0;
   12486                 :             : 
   12487                 :       10802 :           range_stack = constructor_range_stack;
   12488                 :       10802 :           constructor_range_stack = 0;
   12489                 :       10802 :           while (constructor_stack != range_stack->stack)
   12490                 :             :             {
   12491                 :           0 :               gcc_assert (constructor_stack->implicit);
   12492                 :           0 :               process_init_element (loc,
   12493                 :             :                                     pop_init_level (loc, 1,
   12494                 :             :                                                     braced_init_obstack,
   12495                 :             :                                                     last_init_list_comma),
   12496                 :             :                                     true, braced_init_obstack);
   12497                 :             :             }
   12498                 :         325 :           for (p = range_stack;
   12499                 :       11127 :                !p->range_end || tree_int_cst_equal (p->index, p->range_end);
   12500                 :         325 :                p = p->prev)
   12501                 :             :             {
   12502                 :         325 :               gcc_assert (constructor_stack->implicit);
   12503                 :         325 :               process_init_element (loc,
   12504                 :             :                                     pop_init_level (loc, 1,
   12505                 :             :                                                     braced_init_obstack,
   12506                 :             :                                                     last_init_list_comma),
   12507                 :             :                                     true, braced_init_obstack);
   12508                 :             :             }
   12509                 :             : 
   12510                 :       10802 :           p->index = size_binop_loc (input_location,
   12511                 :             :                                      PLUS_EXPR, p->index, bitsize_one_node);
   12512                 :       10802 :           if (tree_int_cst_equal (p->index, p->range_end) && !p->prev)
   12513                 :         373 :             finish = 1;
   12514                 :             : 
   12515                 :       11127 :           while (1)
   12516                 :             :             {
   12517                 :       11127 :               constructor_index = p->index;
   12518                 :       11127 :               constructor_fields = p->fields;
   12519                 :       11127 :               if (finish && p->range_end && p->index == p->range_start)
   12520                 :             :                 {
   12521                 :           8 :                   finish = 0;
   12522                 :           8 :                   p->prev = 0;
   12523                 :             :                 }
   12524                 :       11127 :               p = p->next;
   12525                 :       11127 :               if (!p)
   12526                 :             :                 break;
   12527                 :         325 :               finish_implicit_inits (loc, braced_init_obstack);
   12528                 :         325 :               push_init_level (loc, 2, braced_init_obstack);
   12529                 :         325 :               p->stack = constructor_stack;
   12530                 :         325 :               if (p->range_end && tree_int_cst_equal (p->index, p->range_end))
   12531                 :          33 :                 p->index = p->range_start;
   12532                 :             :             }
   12533                 :             : 
   12534                 :       10802 :           if (!finish)
   12535                 :       10437 :             constructor_range_stack = range_stack;
   12536                 :       10802 :           continue;
   12537                 :       10802 :         }
   12538                 :             : 
   12539                 :             :       break;
   12540                 :             :     }
   12541                 :             : 
   12542                 :     9443349 :   constructor_range_stack = 0;
   12543                 :             : 
   12544                 :     9443349 :   if (raw_data && RAW_DATA_LENGTH (raw_data))
   12545                 :             :     {
   12546                 :         212 :       gcc_assert (!string_flag && !was_designated);
   12547                 :         212 :       value.value = raw_data;
   12548                 :         212 :       raw_data = NULL_TREE;
   12549                 :         212 :       goto retry;
   12550                 :             :     }
   12551                 :             : }
   12552                 :             : 
   12553                 :             : /* Build a complete asm-statement, whose components are a CV_QUALIFIER
   12554                 :             :    (guaranteed to be 'volatile' or null) and ARGS (represented using
   12555                 :             :    an ASM_EXPR node).  */
   12556                 :             : tree
   12557                 :      200448 : build_asm_stmt (bool is_volatile, tree args)
   12558                 :             : {
   12559                 :      200448 :   if (is_volatile)
   12560                 :      160900 :     ASM_VOLATILE_P (args) = 1;
   12561                 :      200448 :   return add_stmt (args);
   12562                 :             : }
   12563                 :             : 
   12564                 :             : /* Build an asm-expr, whose components are a STRING, some OUTPUTS,
   12565                 :             :    some INPUTS, and some CLOBBERS.  The latter three may be NULL.
   12566                 :             :    SIMPLE indicates whether there was anything at all after the
   12567                 :             :    string in the asm expression -- asm("blah") and asm("blah" : )
   12568                 :             :    are subtly different.  We use a ASM_EXPR node to represent this.
   12569                 :             :    LOC is the location of the asm, and IS_INLINE says whether this
   12570                 :             :    is asm inline.  */
   12571                 :             : tree
   12572                 :      200477 : build_asm_expr (location_t loc, tree string, tree outputs, tree inputs,
   12573                 :             :                 tree clobbers, tree labels, bool simple, bool is_inline)
   12574                 :             : {
   12575                 :      200477 :   tree tail;
   12576                 :      200477 :   tree args;
   12577                 :      200477 :   int i;
   12578                 :      200477 :   const char *constraint;
   12579                 :      200477 :   const char **oconstraints;
   12580                 :      200477 :   bool allows_mem, allows_reg, is_inout;
   12581                 :      200477 :   int ninputs, noutputs;
   12582                 :             : 
   12583                 :      200477 :   ninputs = list_length (inputs);
   12584                 :      200477 :   noutputs = list_length (outputs);
   12585                 :      200477 :   oconstraints = (const char **) alloca (noutputs * sizeof (const char *));
   12586                 :             : 
   12587                 :      200477 :   string = resolve_asm_operand_names (string, outputs, inputs, labels);
   12588                 :             : 
   12589                 :             :   /* Remove output conversions that change the type but not the mode.  */
   12590                 :      538789 :   for (i = 0, tail = outputs; tail; ++i, tail = TREE_CHAIN (tail))
   12591                 :             :     {
   12592                 :      338312 :       tree output = TREE_VALUE (tail);
   12593                 :             : 
   12594                 :      338312 :       output = c_fully_fold (output, false, NULL, true);
   12595                 :             : 
   12596                 :             :       /* ??? Really, this should not be here.  Users should be using a
   12597                 :             :          proper lvalue, dammit.  But there's a long history of using casts
   12598                 :             :          in the output operands.  In cases like longlong.h, this becomes a
   12599                 :             :          primitive form of typechecking -- if the cast can be removed, then
   12600                 :             :          the output operand had a type of the proper width; otherwise we'll
   12601                 :             :          get an error.  Gross, but ...  */
   12602                 :      338312 :       STRIP_NOPS (output);
   12603                 :             : 
   12604                 :      338312 :       if (!lvalue_or_else (loc, output, lv_asm))
   12605                 :           4 :         output = error_mark_node;
   12606                 :             : 
   12607                 :      338312 :       if (output != error_mark_node
   12608                 :      338312 :           && (TREE_READONLY (output)
   12609                 :      338306 :               || TYPE_READONLY (TREE_TYPE (output))
   12610                 :      338306 :               || (RECORD_OR_UNION_TYPE_P (TREE_TYPE (output))
   12611                 :         112 :                   && C_TYPE_FIELDS_READONLY (TREE_TYPE (output)))))
   12612                 :           2 :         readonly_error (loc, output, lv_asm);
   12613                 :             : 
   12614                 :      338312 :       constraint = TREE_STRING_POINTER (TREE_VALUE (TREE_PURPOSE (tail)));
   12615                 :      338312 :       oconstraints[i] = constraint;
   12616                 :             : 
   12617                 :      338312 :       if (parse_output_constraint (&constraint, i, ninputs, noutputs,
   12618                 :             :                                    &allows_mem, &allows_reg, &is_inout))
   12619                 :             :         {
   12620                 :             :           /* If the operand is going to end up in memory,
   12621                 :             :              mark it addressable.  */
   12622                 :      338304 :           if (!allows_reg && !c_mark_addressable (output))
   12623                 :           3 :             output = error_mark_node;
   12624                 :        1087 :           if (!(!allows_reg && allows_mem)
   12625                 :      337217 :               && output != error_mark_node
   12626                 :      675520 :               && VOID_TYPE_P (TREE_TYPE (output)))
   12627                 :             :             {
   12628                 :           4 :               error_at (loc, "invalid use of void expression");
   12629                 :           4 :               output = error_mark_node;
   12630                 :             :             }
   12631                 :      338304 :           if (allows_reg && current_function_decl == NULL_TREE)
   12632                 :             :             {
   12633                 :           1 :               error_at (loc, "constraint allows registers outside of "
   12634                 :             :                              "a function");
   12635                 :           1 :               output = error_mark_node;
   12636                 :             :             }
   12637                 :             :         }
   12638                 :             :       else
   12639                 :           8 :         output = error_mark_node;
   12640                 :             : 
   12641                 :      338312 :       if (current_function_decl == NULL_TREE && output != error_mark_node)
   12642                 :             :         {
   12643                 :           7 :           if (TREE_SIDE_EFFECTS (output))
   12644                 :             :             {
   12645                 :           0 :               error_at (loc, "side-effects in output operand outside "
   12646                 :             :                              "of a function");
   12647                 :           0 :               output = error_mark_node;
   12648                 :             :             }
   12649                 :             :           else
   12650                 :             :             {
   12651                 :           7 :               tree addr = build_unary_op (loc, ADDR_EXPR, output, false);
   12652                 :           7 :               if (addr == error_mark_node)
   12653                 :             :                 output = error_mark_node;
   12654                 :           7 :               else if (!initializer_constant_valid_p (addr, TREE_TYPE (addr)))
   12655                 :             :                 {
   12656                 :           1 :                   error_at (loc, "output operand outside of a function is not "
   12657                 :             :                                  "constant");
   12658                 :           1 :                   output = error_mark_node;
   12659                 :             :                 }
   12660                 :             :             }
   12661                 :             :         }
   12662                 :      338305 :       else if (output != error_mark_node && strstr (constraint, "-"))
   12663                 :             :         {
   12664                 :           1 :           error_at (loc, "%<-%> modifier used inside of a function");
   12665                 :           1 :           output = error_mark_node;
   12666                 :             :         }
   12667                 :             : 
   12668                 :      338312 :       TREE_VALUE (tail) = output;
   12669                 :             :     }
   12670                 :             : 
   12671                 :      554978 :   for (i = 0, tail = inputs; tail; ++i, tail = TREE_CHAIN (tail))
   12672                 :             :     {
   12673                 :      354501 :       tree input;
   12674                 :             : 
   12675                 :      354501 :       constraint = TREE_STRING_POINTER (TREE_VALUE (TREE_PURPOSE (tail)));
   12676                 :      354501 :       input = TREE_VALUE (tail);
   12677                 :             : 
   12678                 :      354501 :       if (parse_input_constraint (&constraint, i, ninputs, noutputs, 0,
   12679                 :             :                                   oconstraints, &allows_mem, &allows_reg))
   12680                 :             :         {
   12681                 :             :           /* If the operand is going to end up in memory,
   12682                 :             :              mark it addressable.  */
   12683                 :      354494 :           if (!allows_reg && allows_mem)
   12684                 :             :             {
   12685                 :        1078 :               input = c_fully_fold (input, false, NULL, true);
   12686                 :             : 
   12687                 :             :               /* Strip the nops as we allow this case.  FIXME, this really
   12688                 :             :                  should be rejected or made deprecated.  */
   12689                 :        1078 :               STRIP_NOPS (input);
   12690                 :        1078 :               if (!c_mark_addressable (input))
   12691                 :           2 :                 input = error_mark_node;
   12692                 :             :             }
   12693                 :             :           else
   12694                 :             :             {
   12695                 :      353416 :               struct c_expr expr;
   12696                 :      353416 :               memset (&expr, 0, sizeof (expr));
   12697                 :      353416 :               expr.value = input;
   12698                 :      353416 :               expr = convert_lvalue_to_rvalue (loc, expr, true, false);
   12699                 :      353416 :               input = c_fully_fold (expr.value, false, NULL);
   12700                 :             : 
   12701                 :      353416 :               if (input != error_mark_node && VOID_TYPE_P (TREE_TYPE (input)))
   12702                 :             :                 {
   12703                 :           4 :                   error_at (loc, "invalid use of void expression");
   12704                 :           4 :                   input = error_mark_node;
   12705                 :             :                 }
   12706                 :             :             }
   12707                 :      354494 :           if (allows_reg && current_function_decl == NULL_TREE)
   12708                 :             :             {
   12709                 :           1 :               error_at (loc, "constraint allows registers outside of "
   12710                 :             :                              "a function");
   12711                 :           1 :               input = error_mark_node;
   12712                 :             :             }
   12713                 :      354494 :           if (constraint[0] == ':' && input != error_mark_node)
   12714                 :             :             {
   12715                 :          12 :               tree t = input;
   12716                 :          12 :               STRIP_NOPS (t);
   12717                 :          12 :               if (TREE_CODE (t) != ADDR_EXPR
   12718                 :          12 :                   || !(TREE_CODE (TREE_OPERAND (t, 0)) == FUNCTION_DECL
   12719                 :           8 :                        || (VAR_P (TREE_OPERAND (t, 0))
   12720                 :           6 :                            && is_global_var (TREE_OPERAND (t, 0)))))
   12721                 :             :                 {
   12722                 :           5 :                   error_at (loc, "%<:%> constraint operand is not address "
   12723                 :             :                                  "of a function or non-automatic variable");
   12724                 :           5 :                   input = error_mark_node;
   12725                 :             :                 }
   12726                 :             :             }
   12727                 :             :         }
   12728                 :             :       else
   12729                 :           7 :         input = error_mark_node;
   12730                 :             : 
   12731                 :      354501 :       if (current_function_decl == NULL_TREE && input != error_mark_node)
   12732                 :             :         {
   12733                 :          30 :           if (TREE_SIDE_EFFECTS (input))
   12734                 :             :             {
   12735                 :           2 :               error_at (loc, "side-effects in input operand outside "
   12736                 :             :                              "of a function");
   12737                 :           2 :               input = error_mark_node;
   12738                 :             :             }
   12739                 :             :           else
   12740                 :             :             {
   12741                 :          28 :               tree tem = input;
   12742                 :          28 :               if (allows_mem && lvalue_p (input))
   12743                 :           7 :                 tem = build_unary_op (loc, ADDR_EXPR, input, false);
   12744                 :          28 :               if (!initializer_constant_valid_p (tem, TREE_TYPE (tem)))
   12745                 :             :                 {
   12746                 :           2 :                   error_at (loc, "input operand outside of a function is not "
   12747                 :             :                                  "constant");
   12748                 :           2 :                   input = error_mark_node;
   12749                 :             :                 }
   12750                 :             :             }
   12751                 :             :         }
   12752                 :      354471 :       else if (input != error_mark_node && strstr (constraint, "-"))
   12753                 :             :         {
   12754                 :           3 :           error_at (loc, "%<-%> modifier used inside of a function");
   12755                 :           3 :           input = error_mark_node;
   12756                 :             :         }
   12757                 :             : 
   12758                 :      354501 :       TREE_VALUE (tail) = input;
   12759                 :             :     }
   12760                 :             : 
   12761                 :      200477 :   args = build_stmt (loc, ASM_EXPR, string, outputs, inputs, clobbers, labels);
   12762                 :             : 
   12763                 :             :   /* asm statements without outputs, including simple ones, are treated
   12764                 :             :      as volatile.  */
   12765                 :      200477 :   ASM_BASIC_P (args) = simple;
   12766                 :      200477 :   ASM_VOLATILE_P (args) = (noutputs == 0);
   12767                 :      200477 :   ASM_INLINE_P (args) = is_inline;
   12768                 :             : 
   12769                 :      200477 :   return args;
   12770                 :             : }
   12771                 :             : 
   12772                 :             : /* Generate a goto statement to LABEL.  LOC is the location of the
   12773                 :             :    GOTO.  */
   12774                 :             : 
   12775                 :             : tree
   12776                 :       82127 : c_finish_goto_label (location_t loc, tree label)
   12777                 :             : {
   12778                 :       82127 :   tree decl = lookup_label_for_goto (loc, label);
   12779                 :       82127 :   if (!decl)
   12780                 :             :     return NULL_TREE;
   12781                 :       82127 :   TREE_USED (decl) = 1;
   12782                 :       82127 :   {
   12783                 :       82127 :     add_stmt (build_predict_expr (PRED_GOTO, NOT_TAKEN));
   12784                 :       82127 :     tree t = build1 (GOTO_EXPR, void_type_node, decl);
   12785                 :       82127 :     SET_EXPR_LOCATION (t, loc);
   12786                 :       82127 :     return add_stmt (t);
   12787                 :             :   }
   12788                 :             : }
   12789                 :             : 
   12790                 :             : /* Generate a computed goto statement to EXPR.  LOC is the location of
   12791                 :             :    the GOTO.  */
   12792                 :             : 
   12793                 :             : tree
   12794                 :         930 : c_finish_goto_ptr (location_t loc, c_expr val)
   12795                 :             : {
   12796                 :         930 :   tree expr = val.value;
   12797                 :         930 :   tree t;
   12798                 :         930 :   pedwarn (loc, OPT_Wpedantic, "ISO C forbids %<goto *expr;%>");
   12799                 :         930 :   if (expr != error_mark_node
   12800                 :         929 :       && !POINTER_TYPE_P (TREE_TYPE (expr))
   12801                 :         935 :       && !null_pointer_constant_p (expr))
   12802                 :             :     {
   12803                 :           2 :       error_at (val.get_location (),
   12804                 :             :                 "computed goto must be pointer type");
   12805                 :           2 :       expr = build_zero_cst (ptr_type_node);
   12806                 :             :     }
   12807                 :         930 :   expr = c_fully_fold (expr, false, NULL);
   12808                 :         930 :   expr = convert (ptr_type_node, expr);
   12809                 :         930 :   t = build1 (GOTO_EXPR, void_type_node, expr);
   12810                 :         930 :   SET_EXPR_LOCATION (t, loc);
   12811                 :         930 :   return add_stmt (t);
   12812                 :             : }
   12813                 :             : 
   12814                 :             : /* Generate a C `return' statement.  RETVAL is the expression for what
   12815                 :             :    to return, or a null pointer for `return;' with no value.  LOC is
   12816                 :             :    the location of the return statement, or the location of the expression,
   12817                 :             :    if the statement has any.  If ORIGTYPE is not NULL_TREE, it
   12818                 :             :    is the original type of RETVAL.  MUSTTAIL_P indicates a musttail
   12819                 :             :    attribute.  */
   12820                 :             : 
   12821                 :             : tree
   12822                 :    33722663 : c_finish_return (location_t loc, tree retval, tree origtype, bool musttail_p)
   12823                 :             : {
   12824                 :    33722663 :   tree valtype = TREE_TYPE (TREE_TYPE (current_function_decl)), ret_stmt;
   12825                 :    33722663 :   bool no_warning = false;
   12826                 :    33722663 :   bool npc = false;
   12827                 :             : 
   12828                 :             :   /* Use the expansion point to handle cases such as returning NULL
   12829                 :             :      in a function returning void.  */
   12830                 :    33722663 :   location_t xloc = expansion_point_location_if_in_system_header (loc);
   12831                 :             : 
   12832                 :    33722663 :   if (TREE_THIS_VOLATILE (current_function_decl))
   12833                 :          23 :     warning_at (xloc, 0,
   12834                 :             :                 "function declared %<noreturn%> has a %<return%> statement");
   12835                 :             : 
   12836                 :    33722663 :   set_musttail_on_return (retval, xloc, musttail_p);
   12837                 :             : 
   12838                 :    33722663 :   if (retval)
   12839                 :             :     {
   12840                 :    33701799 :       tree semantic_type = NULL_TREE;
   12841                 :    33701799 :       npc = null_pointer_constant_p (retval);
   12842                 :    33701799 :       if (TREE_CODE (retval) == EXCESS_PRECISION_EXPR)
   12843                 :             :         {
   12844                 :          92 :           semantic_type = TREE_TYPE (retval);
   12845                 :          92 :           retval = TREE_OPERAND (retval, 0);
   12846                 :             :         }
   12847                 :    33701799 :       retval = c_fully_fold (retval, false, NULL);
   12848                 :    33701799 :       if (semantic_type
   12849                 :    33701799 :           && valtype != NULL_TREE
   12850                 :          92 :           && TREE_CODE (valtype) != VOID_TYPE)
   12851                 :          92 :         retval = build1 (EXCESS_PRECISION_EXPR, semantic_type, retval);
   12852                 :             :     }
   12853                 :             : 
   12854                 :    33701799 :   if (!retval)
   12855                 :             :     {
   12856                 :       20864 :       current_function_returns_null = 1;
   12857                 :       20864 :       if ((warn_return_type >= 0 || flag_isoc99)
   12858                 :       20739 :           && valtype != NULL_TREE && TREE_CODE (valtype) != VOID_TYPE)
   12859                 :             :         {
   12860                 :          46 :           no_warning = true;
   12861                 :          47 :           if (emit_diagnostic (flag_isoc99 ? DK_PERMERROR : DK_WARNING,
   12862                 :          46 :                                loc, OPT_Wreturn_mismatch,
   12863                 :             :                                "%<return%> with no value,"
   12864                 :             :                                " in function returning non-void"))
   12865                 :          27 :             inform (DECL_SOURCE_LOCATION (current_function_decl),
   12866                 :             :                     "declared here");
   12867                 :             :         }
   12868                 :             :     }
   12869                 :    33701799 :   else if (valtype == NULL_TREE || VOID_TYPE_P (valtype))
   12870                 :             :     {
   12871                 :         289 :       current_function_returns_null = 1;
   12872                 :         289 :       bool warned_here;
   12873                 :         289 :       if (TREE_CODE (TREE_TYPE (retval)) != VOID_TYPE)
   12874                 :          64 :         warned_here = permerror_opt
   12875                 :          64 :           (xloc, OPT_Wreturn_mismatch,
   12876                 :             :            "%<return%> with a value, in function returning void");
   12877                 :             :       else
   12878                 :         225 :         warned_here = pedwarn
   12879                 :         225 :           (xloc, OPT_Wpedantic, "ISO C forbids "
   12880                 :             :            "%<return%> with expression, in function returning void");
   12881                 :         289 :       if (warned_here)
   12882                 :          43 :         inform (DECL_SOURCE_LOCATION (current_function_decl),
   12883                 :             :                 "declared here");
   12884                 :             :     }
   12885                 :             :   else
   12886                 :             :     {
   12887                 :    33701510 :       tree t = convert_for_assignment (loc, UNKNOWN_LOCATION, valtype,
   12888                 :             :                                        retval, origtype, ic_return,
   12889                 :             :                                        npc, NULL_TREE, NULL_TREE, 0);
   12890                 :    33701510 :       tree res = DECL_RESULT (current_function_decl);
   12891                 :    33701510 :       tree inner;
   12892                 :    33701510 :       bool save;
   12893                 :             : 
   12894                 :    33701510 :       current_function_returns_value = 1;
   12895                 :    33701510 :       if (t == error_mark_node)
   12896                 :             :         {
   12897                 :             :           /* Suppress -Wreturn-type for this function.  */
   12898                 :         299 :           if (warn_return_type)
   12899                 :         298 :             suppress_warning (current_function_decl, OPT_Wreturn_type);
   12900                 :         299 :           return NULL_TREE;
   12901                 :             :         }
   12902                 :             : 
   12903                 :    33701211 :       save = in_late_binary_op;
   12904                 :    67394922 :       if (C_BOOLEAN_TYPE_P (TREE_TYPE (res))
   12905                 :    33693690 :           || TREE_CODE (TREE_TYPE (res)) == COMPLEX_TYPE
   12906                 :    67393621 :           || (SCALAR_FLOAT_TYPE_P (TREE_TYPE (t))
   12907                 :      327521 :               && (TREE_CODE (TREE_TYPE (res)) == INTEGER_TYPE
   12908                 :      327521 :                   || TREE_CODE (TREE_TYPE (res)) == ENUMERAL_TYPE)
   12909                 :           0 :               && sanitize_flags_p (SANITIZE_FLOAT_CAST)))
   12910                 :        8801 :         in_late_binary_op = true;
   12911                 :    33701211 :       inner = t = convert (TREE_TYPE (res), t);
   12912                 :    33701211 :       in_late_binary_op = save;
   12913                 :             : 
   12914                 :             :       /* Strip any conversions, additions, and subtractions, and see if
   12915                 :             :          we are returning the address of a local variable.  Warn if so.  */
   12916                 :    36895970 :       while (1)
   12917                 :             :         {
   12918                 :    36895970 :           switch (TREE_CODE (inner))
   12919                 :             :             {
   12920                 :     3193360 :             CASE_CONVERT:
   12921                 :     3193360 :             case NON_LVALUE_EXPR:
   12922                 :     3193360 :             case PLUS_EXPR:
   12923                 :     3193360 :             case POINTER_PLUS_EXPR:
   12924                 :     3193360 :               inner = TREE_OPERAND (inner, 0);
   12925                 :     3193360 :               continue;
   12926                 :             : 
   12927                 :        1404 :             case MINUS_EXPR:
   12928                 :             :               /* If the second operand of the MINUS_EXPR has a pointer
   12929                 :             :                  type (or is converted from it), this may be valid, so
   12930                 :             :                  don't give a warning.  */
   12931                 :        1404 :               {
   12932                 :        1404 :                 tree op1 = TREE_OPERAND (inner, 1);
   12933                 :             : 
   12934                 :        3048 :                 while (!POINTER_TYPE_P (TREE_TYPE (op1))
   12935                 :        3293 :                        && (CONVERT_EXPR_P (op1)
   12936                 :        1399 :                            || TREE_CODE (op1) == NON_LVALUE_EXPR))
   12937                 :         245 :                   op1 = TREE_OPERAND (op1, 0);
   12938                 :             : 
   12939                 :        1404 :                 if (POINTER_TYPE_P (TREE_TYPE (op1)))
   12940                 :             :                   break;
   12941                 :             : 
   12942                 :        1399 :                 inner = TREE_OPERAND (inner, 0);
   12943                 :        1399 :                 continue;
   12944                 :        1399 :               }
   12945                 :             : 
   12946                 :        2707 :             case ADDR_EXPR:
   12947                 :        2707 :               inner = TREE_OPERAND (inner, 0);
   12948                 :             : 
   12949                 :        2707 :               while (REFERENCE_CLASS_P (inner)
   12950                 :        3580 :                      && !INDIRECT_REF_P (inner))
   12951                 :         873 :                 inner = TREE_OPERAND (inner, 0);
   12952                 :             : 
   12953                 :        2707 :               if (DECL_P (inner)
   12954                 :        1551 :                   && !DECL_EXTERNAL (inner)
   12955                 :         927 :                   && !TREE_STATIC (inner)
   12956                 :         132 :                   && DECL_CONTEXT (inner) == current_function_decl
   12957                 :        2760 :                   && POINTER_TYPE_P (TREE_TYPE (TREE_TYPE (current_function_decl))))
   12958                 :             :                 {
   12959                 :          13 :                   if (TREE_CODE (inner) == LABEL_DECL)
   12960                 :           4 :                     warning_at (loc, OPT_Wreturn_local_addr,
   12961                 :             :                                 "function returns address of label");
   12962                 :             :                   else
   12963                 :             :                     {
   12964                 :           9 :                       warning_at (loc, OPT_Wreturn_local_addr,
   12965                 :             :                                   "function returns address of local variable");
   12966                 :           9 :                       tree zero = build_zero_cst (TREE_TYPE (res));
   12967                 :           9 :                       t = build2 (COMPOUND_EXPR, TREE_TYPE (res), t, zero);
   12968                 :             :                     }
   12969                 :             :                 }
   12970                 :             :               break;
   12971                 :             : 
   12972                 :             :             default:
   12973                 :             :               break;
   12974                 :     3193360 :             }
   12975                 :             : 
   12976                 :    33701211 :           break;
   12977                 :             :         }
   12978                 :             : 
   12979                 :    33701211 :       retval = build2 (MODIFY_EXPR, TREE_TYPE (res), res, t);
   12980                 :    33701211 :       SET_EXPR_LOCATION (retval, loc);
   12981                 :             : 
   12982                 :    33701211 :       if (warn_sequence_point)
   12983                 :     2958107 :         verify_sequence_points (retval);
   12984                 :             :     }
   12985                 :             : 
   12986                 :    33722364 :   ret_stmt = build_stmt (loc, RETURN_EXPR, retval);
   12987                 :    33722364 :   if (no_warning)
   12988                 :          46 :     suppress_warning (ret_stmt, OPT_Wreturn_type);
   12989                 :    33722364 :   return add_stmt (ret_stmt);
   12990                 :             : }
   12991                 :             : 
   12992                 :             : struct c_switch {
   12993                 :             :   /* The SWITCH_STMT being built.  */
   12994                 :             :   tree switch_stmt;
   12995                 :             : 
   12996                 :             :   /* The original type of the testing expression, i.e. before the
   12997                 :             :      default conversion is applied.  */
   12998                 :             :   tree orig_type;
   12999                 :             : 
   13000                 :             :   /* A splay-tree mapping the low element of a case range to the high
   13001                 :             :      element, or NULL_TREE if there is no high element.  Used to
   13002                 :             :      determine whether or not a new case label duplicates an old case
   13003                 :             :      label.  We need a tree, rather than simply a hash table, because
   13004                 :             :      of the GNU case range extension.  */
   13005                 :             :   splay_tree cases;
   13006                 :             : 
   13007                 :             :   /* The bindings at the point of the switch.  This is used for
   13008                 :             :      warnings crossing decls when branching to a case label.  */
   13009                 :             :   struct c_spot_bindings *bindings;
   13010                 :             : 
   13011                 :             :   /* Whether the switch includes any break statements.  */
   13012                 :             :   bool break_stmt_seen_p;
   13013                 :             : 
   13014                 :             :   /* The next node on the stack.  */
   13015                 :             :   struct c_switch *next;
   13016                 :             : 
   13017                 :             :   /* Remember whether the controlling expression had boolean type
   13018                 :             :      before integer promotions for the sake of -Wswitch-bool.  */
   13019                 :             :   bool bool_cond_p;
   13020                 :             : };
   13021                 :             : 
   13022                 :             : /* A stack of the currently active switch statements.  The innermost
   13023                 :             :    switch statement is on the top of the stack.  There is no need to
   13024                 :             :    mark the stack for garbage collection because it is only active
   13025                 :             :    during the processing of the body of a function, and we never
   13026                 :             :    collect at that point.  */
   13027                 :             : 
   13028                 :             : struct c_switch *c_switch_stack;
   13029                 :             : 
   13030                 :             : /* Start a C switch statement, testing expression EXP.  Return the new
   13031                 :             :    SWITCH_STMT.  SWITCH_LOC is the location of the `switch'.
   13032                 :             :    SWITCH_COND_LOC is the location of the switch's condition.
   13033                 :             :    EXPLICIT_CAST_P is true if the expression EXP has an explicit cast.  */
   13034                 :             : 
   13035                 :             : tree
   13036                 :       36575 : c_start_switch (location_t switch_loc,
   13037                 :             :                 location_t switch_cond_loc,
   13038                 :             :                 tree exp, bool explicit_cast_p, tree switch_name)
   13039                 :             : {
   13040                 :       36575 :   tree orig_type = error_mark_node;
   13041                 :       36575 :   bool bool_cond_p = false;
   13042                 :       36575 :   struct c_switch *cs;
   13043                 :             : 
   13044                 :       36575 :   if (exp != error_mark_node)
   13045                 :             :     {
   13046                 :       36532 :       orig_type = TREE_TYPE (exp);
   13047                 :             : 
   13048                 :       36532 :       if (!INTEGRAL_TYPE_P (orig_type))
   13049                 :             :         {
   13050                 :          12 :           if (orig_type != error_mark_node)
   13051                 :             :             {
   13052                 :          12 :               error_at (switch_cond_loc, "switch quantity not an integer");
   13053                 :          12 :               orig_type = error_mark_node;
   13054                 :             :             }
   13055                 :          12 :           exp = integer_zero_node;
   13056                 :             :         }
   13057                 :             :       else
   13058                 :             :         {
   13059                 :       36520 :           tree type = TYPE_MAIN_VARIANT (orig_type);
   13060                 :       36520 :           tree e = exp;
   13061                 :             : 
   13062                 :             :           /* Warn if the condition has boolean value.  */
   13063                 :       36523 :           while (TREE_CODE (e) == COMPOUND_EXPR)
   13064                 :           3 :             e = TREE_OPERAND (e, 1);
   13065                 :             : 
   13066                 :       36495 :           if ((C_BOOLEAN_TYPE_P (type)
   13067                 :       36495 :                || truth_value_p (TREE_CODE (e)))
   13068                 :             :               /* Explicit cast to int suppresses this warning.  */
   13069                 :       36542 :               && !(TREE_CODE (type) == INTEGER_TYPE
   13070                 :             :                    && explicit_cast_p))
   13071                 :             :             bool_cond_p = true;
   13072                 :             : 
   13073                 :       36520 :           if (!in_system_header_at (input_location)
   13074                 :       36520 :               && (type == long_integer_type_node
   13075                 :       11829 :                   || type == long_unsigned_type_node))
   13076                 :         258 :             warning_at (switch_cond_loc,
   13077                 :         258 :                         OPT_Wtraditional, "%<long%> switch expression not "
   13078                 :             :                         "converted to %<int%> in ISO C");
   13079                 :             : 
   13080                 :       36520 :           exp = c_fully_fold (exp, false, NULL);
   13081                 :       36520 :           exp = default_conversion (exp);
   13082                 :             : 
   13083                 :       36520 :           if (warn_sequence_point)
   13084                 :        6001 :             verify_sequence_points (exp);
   13085                 :             :         }
   13086                 :             :     }
   13087                 :             : 
   13088                 :             :   /* Add this new SWITCH_STMT to the stack.  */
   13089                 :       36575 :   cs = XNEW (struct c_switch);
   13090                 :       36575 :   cs->switch_stmt = build_stmt (switch_loc, SWITCH_STMT, exp,
   13091                 :             :                                 NULL_TREE, orig_type, NULL_TREE, switch_name);
   13092                 :       36575 :   cs->orig_type = orig_type;
   13093                 :       36575 :   cs->cases = splay_tree_new (case_compare, NULL, NULL);
   13094                 :       36575 :   cs->bindings = c_get_switch_bindings ();
   13095                 :       36575 :   cs->break_stmt_seen_p = false;
   13096                 :       36575 :   cs->bool_cond_p = bool_cond_p;
   13097                 :       36575 :   cs->next = c_switch_stack;
   13098                 :       36575 :   c_switch_stack = cs;
   13099                 :             : 
   13100                 :       36575 :   return add_stmt (cs->switch_stmt);
   13101                 :             : }
   13102                 :             : 
   13103                 :             : /* Process a case label at location LOC, with attributes ATTRS.  */
   13104                 :             : 
   13105                 :             : tree
   13106                 :     1023929 : do_case (location_t loc, tree low_value, tree high_value, tree attrs)
   13107                 :             : {
   13108                 :     1023929 :   tree label = NULL_TREE;
   13109                 :             : 
   13110                 :     1023929 :   if (low_value && TREE_CODE (low_value) != INTEGER_CST)
   13111                 :             :     {
   13112                 :          87 :       low_value = c_fully_fold (low_value, false, NULL);
   13113                 :          87 :       if (TREE_CODE (low_value) == INTEGER_CST)
   13114                 :           9 :         pedwarn (loc, OPT_Wpedantic,
   13115                 :             :                  "case label is not an integer constant expression");
   13116                 :             :     }
   13117                 :             : 
   13118                 :     1023929 :   if (high_value && TREE_CODE (high_value) != INTEGER_CST)
   13119                 :             :     {
   13120                 :           0 :       high_value = c_fully_fold (high_value, false, NULL);
   13121                 :           0 :       if (TREE_CODE (high_value) == INTEGER_CST)
   13122                 :           0 :         pedwarn (input_location, OPT_Wpedantic,
   13123                 :             :                  "case label is not an integer constant expression");
   13124                 :             :     }
   13125                 :             : 
   13126                 :     1023929 :   if (c_switch_stack == NULL)
   13127                 :             :     {
   13128                 :           3 :       if (low_value)
   13129                 :           2 :         error_at (loc, "case label not within a switch statement");
   13130                 :             :       else
   13131                 :           1 :         error_at (loc, "%<default%> label not within a switch statement");
   13132                 :           3 :       return NULL_TREE;
   13133                 :             :     }
   13134                 :             : 
   13135                 :     1023926 :   if (c_check_switch_jump_warnings (c_switch_stack->bindings,
   13136                 :     1023926 :                                     EXPR_LOCATION (c_switch_stack->switch_stmt),
   13137                 :             :                                     loc))
   13138                 :             :     return NULL_TREE;
   13139                 :             : 
   13140                 :     1023914 :   label = c_add_case_label (loc, c_switch_stack->cases,
   13141                 :     1023914 :                             SWITCH_STMT_COND (c_switch_stack->switch_stmt),
   13142                 :             :                             low_value, high_value, attrs);
   13143                 :     1023914 :   if (label == error_mark_node)
   13144                 :         144 :     label = NULL_TREE;
   13145                 :             :   return label;
   13146                 :             : }
   13147                 :             : 
   13148                 :             : /* Finish the switch statement.  TYPE is the original type of the
   13149                 :             :    controlling expression of the switch, or NULL_TREE.  */
   13150                 :             : 
   13151                 :             : void
   13152                 :       36575 : c_finish_switch (tree body, tree type)
   13153                 :             : {
   13154                 :       36575 :   struct c_switch *cs = c_switch_stack;
   13155                 :       36575 :   location_t switch_location;
   13156                 :             : 
   13157                 :       36575 :   SWITCH_STMT_BODY (cs->switch_stmt) = body;
   13158                 :             : 
   13159                 :             :   /* Emit warnings as needed.  */
   13160                 :       36575 :   switch_location = EXPR_LOCATION (cs->switch_stmt);
   13161                 :       42660 :   c_do_switch_warnings (cs->cases, switch_location,
   13162                 :        6085 :                         type ? type : SWITCH_STMT_TYPE (cs->switch_stmt),
   13163                 :       36575 :                         SWITCH_STMT_COND (cs->switch_stmt), cs->bool_cond_p);
   13164                 :       36575 :   if (c_switch_covers_all_cases_p (cs->cases,
   13165                 :       36575 :                                    SWITCH_STMT_TYPE (cs->switch_stmt)))
   13166                 :       32704 :     SWITCH_STMT_ALL_CASES_P (cs->switch_stmt) = 1;
   13167                 :       36575 :   SWITCH_STMT_NO_BREAK_P (cs->switch_stmt) = !cs->break_stmt_seen_p;
   13168                 :             : 
   13169                 :             :   /* Pop the stack.  */
   13170                 :       36575 :   c_switch_stack = cs->next;
   13171                 :       36575 :   splay_tree_delete (cs->cases);
   13172                 :       36575 :   c_release_switch_bindings (cs->bindings);
   13173                 :       36575 :   XDELETE (cs);
   13174                 :       36575 : }
   13175                 :             : 
   13176                 :             : /* Emit an if statement.  IF_LOCUS is the location of the 'if'.  COND,
   13177                 :             :    THEN_BLOCK and ELSE_BLOCK are expressions to be used; ELSE_BLOCK
   13178                 :             :    may be null.  */
   13179                 :             : 
   13180                 :             : void
   13181                 :     1244539 : c_finish_if_stmt (location_t if_locus, tree cond, tree then_block,
   13182                 :             :                   tree else_block)
   13183                 :             : {
   13184                 :     1244539 :   tree stmt;
   13185                 :             : 
   13186                 :     1244539 :   stmt = build3 (COND_EXPR, void_type_node, cond, then_block, else_block);
   13187                 :     1244539 :   SET_EXPR_LOCATION (stmt, if_locus);
   13188                 :     1244539 :   add_stmt (stmt);
   13189                 :     1244539 : }
   13190                 :             : 
   13191                 :             : tree
   13192                 :      183276 : c_finish_bc_stmt (location_t loc, tree label, bool is_break, tree name)
   13193                 :             : {
   13194                 :             :   /* In switch statements break is sometimes stylistically used after
   13195                 :             :      a return statement.  This can lead to spurious warnings about
   13196                 :             :      control reaching the end of a non-void function when it is
   13197                 :             :      inlined.  Note that we are calling block_may_fallthru with
   13198                 :             :      language specific tree nodes; this works because
   13199                 :             :      block_may_fallthru returns true when given something it does not
   13200                 :             :      understand.  */
   13201                 :      183276 :   bool skip = !block_may_fallthru (cur_stmt_list);
   13202                 :             : 
   13203                 :      183276 :   if (is_break)
   13204                 :      171036 :     switch (in_statement & ~IN_NAMED_STMT)
   13205                 :             :       {
   13206                 :           9 :       case 0:
   13207                 :           9 :         error_at (loc, "break statement not within loop or switch");
   13208                 :           9 :         return NULL_TREE;
   13209                 :           4 :       case IN_OMP_BLOCK:
   13210                 :           4 :         error_at (loc, "invalid exit from OpenMP structured block");
   13211                 :           4 :         return NULL_TREE;
   13212                 :          12 :       case IN_OMP_FOR:
   13213                 :          12 :         error_at (loc, "break statement used with OpenMP for loop");
   13214                 :          12 :         return NULL_TREE;
   13215                 :             :       case IN_ITERATION_STMT:
   13216                 :             :       case IN_OBJC_FOREACH:
   13217                 :             :         break;
   13218                 :      155637 :       default:
   13219                 :      155637 :         gcc_assert (in_statement & IN_SWITCH_STMT);
   13220                 :      155637 :         c_switch_stack->break_stmt_seen_p = true;
   13221                 :      155637 :         break;
   13222                 :             :       }
   13223                 :             :   else
   13224                 :       12240 :     switch (in_statement & ~(IN_SWITCH_STMT | IN_NAMED_STMT))
   13225                 :             :       {
   13226                 :           7 :       case 0:
   13227                 :           7 :         error_at (loc, "continue statement not within a loop");
   13228                 :           7 :         return NULL_TREE;
   13229                 :           4 :       case IN_OMP_BLOCK:
   13230                 :           4 :         error_at (loc, "invalid exit from OpenMP structured block");
   13231                 :           4 :         return NULL_TREE;
   13232                 :             :       case IN_ITERATION_STMT:
   13233                 :             :       case IN_OMP_FOR:
   13234                 :             :       case IN_OBJC_FOREACH:
   13235                 :             :         break;
   13236                 :           0 :       default:
   13237                 :           0 :         gcc_unreachable ();
   13238                 :             :       }
   13239                 :             : 
   13240                 :      183240 :   if (skip)
   13241                 :             :     return NULL_TREE;
   13242                 :      182772 :   else if ((in_statement & IN_OBJC_FOREACH)
   13243                 :           0 :            && !(is_break && (in_statement & IN_SWITCH_STMT))
   13244                 :           0 :            && name == NULL_TREE)
   13245                 :             :     {
   13246                 :             :       /* The foreach expander produces low-level code using gotos instead
   13247                 :             :          of a structured loop construct.  */
   13248                 :           0 :       gcc_assert (label);
   13249                 :           0 :       return add_stmt (build_stmt (loc, GOTO_EXPR, label));
   13250                 :             :     }
   13251                 :      182869 :   else if (name && C_DECL_LOOP_NAME (name) && C_DECL_SWITCH_NAME (name))
   13252                 :             :     {
   13253                 :           0 :       label = DECL_CHAIN (name);
   13254                 :           0 :       if (!is_break)
   13255                 :           0 :         label = DECL_CHAIN (label);
   13256                 :             :       /* Foreach expander from some outer level.  */
   13257                 :           0 :       return add_stmt (build_stmt (loc, GOTO_EXPR, label));
   13258                 :             :     }
   13259                 :      195001 :   return add_stmt (build_stmt (loc, is_break ? BREAK_STMT : CONTINUE_STMT,
   13260                 :      182772 :                                name));
   13261                 :             : }
   13262                 :             : 
   13263                 :             : /* A helper routine for c_process_expr_stmt and c_finish_stmt_expr.  */
   13264                 :             : 
   13265                 :             : static void
   13266                 :     6227616 : emit_side_effect_warnings (location_t loc, tree expr)
   13267                 :             : {
   13268                 :     6227616 :   maybe_warn_nodiscard (loc, expr);
   13269                 :     6227616 :   if (!warn_unused_value)
   13270                 :             :     return;
   13271                 :     1290356 :   if (expr == error_mark_node)
   13272                 :             :     ;
   13273                 :     1290281 :   else if (!TREE_SIDE_EFFECTS (expr))
   13274                 :             :     {
   13275                 :        6400 :       if (!VOID_TYPE_P (TREE_TYPE (expr))
   13276                 :        6400 :           && !warning_suppressed_p (expr, OPT_Wunused_value))
   13277                 :          28 :         warning_at (loc, OPT_Wunused_value, "statement with no effect");
   13278                 :             :     }
   13279                 :     1283881 :   else if (TREE_CODE (expr) == COMPOUND_EXPR)
   13280                 :             :     {
   13281                 :             :       tree r = expr;
   13282                 :             :       location_t cloc = loc;
   13283                 :       11987 :       while (TREE_CODE (r) == COMPOUND_EXPR)
   13284                 :             :         {
   13285                 :        6009 :           if (EXPR_HAS_LOCATION (r))
   13286                 :        5479 :             cloc = EXPR_LOCATION (r);
   13287                 :        6009 :           r = TREE_OPERAND (r, 1);
   13288                 :             :         }
   13289                 :        5978 :       if (!TREE_SIDE_EFFECTS (r)
   13290                 :          33 :           && !VOID_TYPE_P (TREE_TYPE (r))
   13291                 :          24 :           && !CONVERT_EXPR_P (r)
   13292                 :          24 :           && !warning_suppressed_p (r, OPT_Wunused_value)
   13293                 :        5990 :           && !warning_suppressed_p (expr, OPT_Wunused_value))
   13294                 :           8 :         warning_at (cloc, OPT_Wunused_value,
   13295                 :             :                     "right-hand operand of comma expression has no effect");
   13296                 :             :     }
   13297                 :             :   else
   13298                 :     1277903 :     warn_if_unused_value (expr, loc);
   13299                 :             : }
   13300                 :             : 
   13301                 :             : /* Process an expression as if it were a complete statement.  Emit
   13302                 :             :    diagnostics, but do not call ADD_STMT.  LOC is the location of the
   13303                 :             :    statement.  */
   13304                 :             : 
   13305                 :             : tree
   13306                 :     6104455 : c_process_expr_stmt (location_t loc, tree expr)
   13307                 :             : {
   13308                 :     6104455 :   tree exprv;
   13309                 :             : 
   13310                 :     6104455 :   if (!expr)
   13311                 :             :     return NULL_TREE;
   13312                 :             : 
   13313                 :     6100283 :   expr = c_fully_fold (expr, false, NULL);
   13314                 :             : 
   13315                 :     6100283 :   if (warn_sequence_point)
   13316                 :     1286234 :     verify_sequence_points (expr);
   13317                 :             : 
   13318                 :     6100283 :   if (TREE_TYPE (expr) != error_mark_node
   13319                 :     6097778 :       && !COMPLETE_OR_VOID_TYPE_P (TREE_TYPE (expr))
   13320                 :     6100283 :       && TREE_CODE (TREE_TYPE (expr)) != ARRAY_TYPE)
   13321                 :           0 :     error_at (loc, "expression statement has incomplete type");
   13322                 :             : 
   13323                 :             :   /* If we're not processing a statement expression, warn about unused values.
   13324                 :             :      Warnings for statement expressions will be emitted later, once we figure
   13325                 :             :      out which is the result.  */
   13326                 :     6100283 :   if (!STATEMENT_LIST_STMT_EXPR (cur_stmt_list)
   13327                 :     6100283 :       && (warn_unused_value || warn_unused_result))
   13328                 :     6013876 :     emit_side_effect_warnings (EXPR_LOC_OR_LOC (expr, loc), expr);
   13329                 :             : 
   13330                 :             :   exprv = expr;
   13331                 :     6138578 :   while (TREE_CODE (exprv) == COMPOUND_EXPR)
   13332                 :       38296 :     exprv = TREE_OPERAND (exprv, 1);
   13333                 :     6110984 :   while (CONVERT_EXPR_P (exprv))
   13334                 :       10702 :     exprv = TREE_OPERAND (exprv, 0);
   13335                 :     6100282 :   if (DECL_P (exprv)
   13336                 :     6100829 :       || handled_component_p (exprv)
   13337                 :    12181444 :       || TREE_CODE (exprv) == ADDR_EXPR)
   13338                 :       19667 :     mark_exp_read (exprv);
   13339                 :             : 
   13340                 :             :   /* If the expression is not of a type to which we cannot assign a line
   13341                 :             :      number, wrap the thing in a no-op NOP_EXPR.  */
   13342                 :     6100282 :   if (DECL_P (expr) || CONSTANT_CLASS_P (expr))
   13343                 :             :     {
   13344                 :       14608 :       expr = build1 (NOP_EXPR, TREE_TYPE (expr), expr);
   13345                 :       14608 :       SET_EXPR_LOCATION (expr, loc);
   13346                 :             :     }
   13347                 :             : 
   13348                 :             :   return expr;
   13349                 :             : }
   13350                 :             : 
   13351                 :             : /* Emit an expression as a statement.  LOC is the location of the
   13352                 :             :    expression.  */
   13353                 :             : 
   13354                 :             : tree
   13355                 :     5815436 : c_finish_expr_stmt (location_t loc, tree expr)
   13356                 :             : {
   13357                 :     5815436 :   if (expr)
   13358                 :     5803278 :     return add_stmt (c_process_expr_stmt (loc, expr));
   13359                 :             :   else
   13360                 :             :     return NULL;
   13361                 :             : }
   13362                 :             : 
   13363                 :             : /* Do the opposite and emit a statement as an expression.  To begin,
   13364                 :             :    create a new binding level and return it.  */
   13365                 :             : 
   13366                 :             : tree
   13367                 :       33465 : c_begin_stmt_expr (void)
   13368                 :             : {
   13369                 :       33465 :   tree ret;
   13370                 :             : 
   13371                 :             :   /* We must force a BLOCK for this level so that, if it is not expanded
   13372                 :             :      later, there is a way to turn off the entire subtree of blocks that
   13373                 :             :      are contained in it.  */
   13374                 :       33465 :   keep_next_level ();
   13375                 :       33465 :   ret = c_begin_compound_stmt (true);
   13376                 :             : 
   13377                 :       33465 :   c_bindings_start_stmt_expr (c_switch_stack == NULL
   13378                 :             :                               ? NULL
   13379                 :             :                               : c_switch_stack->bindings);
   13380                 :             : 
   13381                 :             :   /* Mark the current statement list as belonging to a statement list.  */
   13382                 :       33465 :   STATEMENT_LIST_STMT_EXPR (ret) = 1;
   13383                 :             : 
   13384                 :       33465 :   return ret;
   13385                 :             : }
   13386                 :             : 
   13387                 :             : /* LOC is the location of the compound statement to which this body
   13388                 :             :    belongs.  */
   13389                 :             : 
   13390                 :             : tree
   13391                 :       33465 : c_finish_stmt_expr (location_t loc, tree body)
   13392                 :             : {
   13393                 :       33465 :   tree last, type, tmp, val;
   13394                 :       33465 :   tree *last_p;
   13395                 :             : 
   13396                 :       33465 :   body = c_end_compound_stmt (loc, body, true);
   13397                 :             : 
   13398                 :       33465 :   c_bindings_end_stmt_expr (c_switch_stack == NULL
   13399                 :             :                             ? NULL
   13400                 :             :                             : c_switch_stack->bindings);
   13401                 :             : 
   13402                 :             :   /* Locate the last statement in BODY.  See c_end_compound_stmt
   13403                 :             :      about always returning a BIND_EXPR.  */
   13404                 :       33465 :   last_p = &BIND_EXPR_BODY (body);
   13405                 :       33465 :   last = BIND_EXPR_BODY (body);
   13406                 :             : 
   13407                 :       33465 :  continue_searching:
   13408                 :       33465 :   if (TREE_CODE (last) == STATEMENT_LIST)
   13409                 :             :     {
   13410                 :       25753 :       tree_stmt_iterator l = tsi_last (last);
   13411                 :             : 
   13412                 :       25759 :       while (!tsi_end_p (l) && TREE_CODE (tsi_stmt (l)) == DEBUG_BEGIN_STMT)
   13413                 :           6 :         tsi_prev (&l);
   13414                 :             : 
   13415                 :             :       /* This can happen with degenerate cases like ({ }).  No value.  */
   13416                 :       25753 :       if (tsi_end_p (l))
   13417                 :         389 :         return body;
   13418                 :             : 
   13419                 :             :       /* If we're supposed to generate side effects warnings, process
   13420                 :             :          all of the statements except the last.  */
   13421                 :       25364 :       if (warn_unused_value || warn_unused_result)
   13422                 :             :         {
   13423                 :       25364 :           for (tree_stmt_iterator i = tsi_start (last);
   13424                 :      274934 :                tsi_stmt (i) != tsi_stmt (l); tsi_next (&i))
   13425                 :             :             {
   13426                 :      249570 :               location_t tloc;
   13427                 :      249570 :               tree t = tsi_stmt (i);
   13428                 :             : 
   13429                 :      249570 :               tloc = EXPR_HAS_LOCATION (t) ? EXPR_LOCATION (t) : loc;
   13430                 :      249570 :               emit_side_effect_warnings (tloc, t);
   13431                 :             :             }
   13432                 :             :         }
   13433                 :       25364 :       last_p = tsi_stmt_ptr (l);
   13434                 :       25364 :       last = *last_p;
   13435                 :             :     }
   13436                 :             : 
   13437                 :             :   /* If the end of the list is exception related, then the list was split
   13438                 :             :      by a call to push_cleanup.  Continue searching.  */
   13439                 :       33076 :   if (TREE_CODE (last) == TRY_FINALLY_EXPR
   13440                 :       33076 :       || TREE_CODE (last) == TRY_CATCH_EXPR)
   13441                 :             :     {
   13442                 :           0 :       last_p = &TREE_OPERAND (last, 0);
   13443                 :           0 :       last = *last_p;
   13444                 :           0 :       goto continue_searching;
   13445                 :             :     }
   13446                 :             : 
   13447                 :       33076 :   if (last == error_mark_node)
   13448                 :             :     return last;
   13449                 :             : 
   13450                 :             :   /* In the case that the BIND_EXPR is not necessary, return the
   13451                 :             :      expression out from inside it.  */
   13452                 :       33067 :   if ((last == BIND_EXPR_BODY (body)
   13453                 :             :        /* Skip nested debug stmts.  */
   13454                 :       25363 :        || last == expr_first (BIND_EXPR_BODY (body)))
   13455                 :       42736 :       && BIND_EXPR_VARS (body) == NULL)
   13456                 :             :     {
   13457                 :             :       /* Even if this looks constant, do not allow it in a constant
   13458                 :             :          expression.  */
   13459                 :        9657 :       last = c_wrap_maybe_const (last, true);
   13460                 :             :       /* Do not warn if the return value of a statement expression is
   13461                 :             :          unused.  */
   13462                 :        9657 :       suppress_warning (last, OPT_Wunused);
   13463                 :        9657 :       return last;
   13464                 :             :     }
   13465                 :             : 
   13466                 :             :   /* Extract the type of said expression.  */
   13467                 :       23410 :   type = TREE_TYPE (last);
   13468                 :             : 
   13469                 :             :   /* If we're not returning a value at all, then the BIND_EXPR that
   13470                 :             :      we already have is a fine expression to return.  */
   13471                 :       23410 :   if (!type || VOID_TYPE_P (type))
   13472                 :             :     return body;
   13473                 :             : 
   13474                 :             :   /* Now that we've located the expression containing the value, it seems
   13475                 :             :      silly to make voidify_wrapper_expr repeat the process.  Create a
   13476                 :             :      temporary of the appropriate type and stick it in a TARGET_EXPR.  */
   13477                 :       18102 :   tmp = create_tmp_var_raw (type);
   13478                 :             : 
   13479                 :             :   /* Unwrap a no-op NOP_EXPR as added by c_finish_expr_stmt.  This avoids
   13480                 :             :      tree_expr_nonnegative_p giving up immediately.  */
   13481                 :       18102 :   val = last;
   13482                 :       18102 :   if (TREE_CODE (val) == NOP_EXPR
   13483                 :       18102 :       && TREE_TYPE (val) == TREE_TYPE (TREE_OPERAND (val, 0)))
   13484                 :        3728 :     val = TREE_OPERAND (val, 0);
   13485                 :             : 
   13486                 :       18102 :   *last_p = build2 (MODIFY_EXPR, void_type_node, tmp, val);
   13487                 :       18102 :   SET_EXPR_LOCATION (*last_p, EXPR_LOCATION (last));
   13488                 :             : 
   13489                 :       18102 :   {
   13490                 :       18102 :     tree t = build4 (TARGET_EXPR, type, tmp, body, NULL_TREE, NULL_TREE);
   13491                 :       18102 :     SET_EXPR_LOCATION (t, loc);
   13492                 :       18102 :     return t;
   13493                 :             :   }
   13494                 :             : }
   13495                 :             : 
   13496                 :             : /* Begin and end compound statements.  This is as simple as pushing
   13497                 :             :    and popping new statement lists from the tree.  */
   13498                 :             : 
   13499                 :             : tree
   13500                 :    40085669 : c_begin_compound_stmt (bool do_scope)
   13501                 :             : {
   13502                 :    40085669 :   tree stmt = push_stmt_list ();
   13503                 :    40085669 :   if (do_scope)
   13504                 :    39989740 :     push_scope ();
   13505                 :    40085669 :   return stmt;
   13506                 :             : }
   13507                 :             : 
   13508                 :             : /* End a compound statement.  STMT is the statement.  LOC is the
   13509                 :             :    location of the compound statement-- this is usually the location
   13510                 :             :    of the opening brace.  */
   13511                 :             : 
   13512                 :             : tree
   13513                 :    40085668 : c_end_compound_stmt (location_t loc, tree stmt, bool do_scope)
   13514                 :             : {
   13515                 :    40085668 :   tree block = NULL;
   13516                 :             : 
   13517                 :    40085668 :   if (do_scope)
   13518                 :             :     {
   13519                 :    39989739 :       if (c_dialect_objc ())
   13520                 :           0 :         objc_clear_super_receiver ();
   13521                 :    39989739 :       block = pop_scope ();
   13522                 :             :     }
   13523                 :             : 
   13524                 :    40085668 :   stmt = pop_stmt_list (stmt);
   13525                 :    40085668 :   stmt = c_build_bind_expr (loc, block, stmt);
   13526                 :             : 
   13527                 :             :   /* If this compound statement is nested immediately inside a statement
   13528                 :             :      expression, then force a BIND_EXPR to be created.  Otherwise we'll
   13529                 :             :      do the wrong thing for ({ { 1; } }) or ({ 1; { } }).  In particular,
   13530                 :             :      STATEMENT_LISTs merge, and thus we can lose track of what statement
   13531                 :             :      was really last.  */
   13532                 :    80171336 :   if (building_stmt_list_p ()
   13533                 :    40085583 :       && STATEMENT_LIST_STMT_EXPR (cur_stmt_list)
   13534                 :    40206942 :       && TREE_CODE (stmt) != BIND_EXPR)
   13535                 :             :     {
   13536                 :      119534 :       stmt = build3 (BIND_EXPR, void_type_node, NULL, stmt, NULL);
   13537                 :      119534 :       TREE_SIDE_EFFECTS (stmt) = 1;
   13538                 :      119534 :       SET_EXPR_LOCATION (stmt, loc);
   13539                 :             :     }
   13540                 :             : 
   13541                 :    40085668 :   return stmt;
   13542                 :             : }
   13543                 :             : 
   13544                 :             : /* Queue a cleanup.  CLEANUP is an expression/statement to be executed
   13545                 :             :    when the current scope is exited.  EH_ONLY is true when this is not
   13546                 :             :    meant to apply to normal control flow transfer.  */
   13547                 :             : 
   13548                 :             : void
   13549                 :          95 : push_cleanup (tree decl, tree cleanup, bool eh_only)
   13550                 :             : {
   13551                 :          95 :   enum tree_code code;
   13552                 :          95 :   tree stmt, list;
   13553                 :          95 :   bool stmt_expr;
   13554                 :             : 
   13555                 :          95 :   code = eh_only ? TRY_CATCH_EXPR : TRY_FINALLY_EXPR;
   13556                 :          95 :   stmt = build_stmt (DECL_SOURCE_LOCATION (decl), code, NULL, cleanup);
   13557                 :          95 :   add_stmt (stmt);
   13558                 :          95 :   stmt_expr = STATEMENT_LIST_STMT_EXPR (cur_stmt_list);
   13559                 :          95 :   list = push_stmt_list ();
   13560                 :          95 :   TREE_OPERAND (stmt, 0) = list;
   13561                 :          95 :   STATEMENT_LIST_STMT_EXPR (list) = stmt_expr;
   13562                 :          95 : }
   13563                 :             : 
   13564                 :             : /* Build a vector comparison of ARG0 and ARG1 using CODE opcode
   13565                 :             :    into a value of TYPE type.  Comparison is done via VEC_COND_EXPR.  */
   13566                 :             : 
   13567                 :             : static tree
   13568                 :       98606 : build_vec_cmp (tree_code code, tree type,
   13569                 :             :                tree arg0, tree arg1)
   13570                 :             : {
   13571                 :       98606 :   tree zero_vec = build_zero_cst (type);
   13572                 :       98606 :   tree minus_one_vec = build_minus_one_cst (type);
   13573                 :       98606 :   tree cmp_type = truth_type_for (TREE_TYPE (arg0));
   13574                 :       98606 :   tree cmp = build2 (code, cmp_type, arg0, arg1);
   13575                 :       98606 :   return build3 (VEC_COND_EXPR, type, cmp, minus_one_vec, zero_vec);
   13576                 :             : }
   13577                 :             : 
   13578                 :             : /* Possibly warn about an address of OP never being NULL in a comparison
   13579                 :             :    operation CODE involving null.  */
   13580                 :             : 
   13581                 :             : static void
   13582                 :       50305 : maybe_warn_for_null_address (location_t loc, tree op, tree_code code)
   13583                 :             : {
   13584                 :             :   /* Prevent warnings issued for macro expansion.  */
   13585                 :       50305 :   if (!warn_address
   13586                 :       29769 :       || warning_suppressed_p (op, OPT_Waddress)
   13587                 :       79750 :       || from_macro_expansion_at (loc))
   13588                 :       23591 :     return;
   13589                 :             : 
   13590                 :       26714 :   if (TREE_CODE (op) == NOP_EXPR)
   13591                 :             :     {
   13592                 :             :       /* Allow casts to intptr_t to suppress the warning.  */
   13593                 :        1133 :       tree type = TREE_TYPE (op);
   13594                 :        1133 :       if (TREE_CODE (type) == INTEGER_TYPE)
   13595                 :             :         return;
   13596                 :        1133 :       op = TREE_OPERAND (op, 0);
   13597                 :             :     }
   13598                 :             : 
   13599                 :       26714 :   if (TREE_CODE (op) == POINTER_PLUS_EXPR)
   13600                 :             :     {
   13601                 :             :       /* Allow a cast to void* to suppress the warning.  */
   13602                 :          24 :       tree type = TREE_TYPE (TREE_TYPE (op));
   13603                 :          24 :       if (VOID_TYPE_P (type))
   13604                 :             :         return;
   13605                 :             : 
   13606                 :             :       /* Adding any value to a null pointer, including zero, is undefined
   13607                 :             :          in C.  This includes the expression &p[0] where p is the null
   13608                 :             :          pointer, although &p[0] will have been folded to p by this point
   13609                 :             :          and so not diagnosed.  */
   13610                 :          24 :       if (code == EQ_EXPR)
   13611                 :          22 :         warning_at (loc, OPT_Waddress,
   13612                 :             :                     "the comparison will always evaluate as %<false%> "
   13613                 :             :                     "for the pointer operand in %qE must not be NULL",
   13614                 :             :                     op);
   13615                 :             :       else
   13616                 :           2 :         warning_at (loc, OPT_Waddress,
   13617                 :             :                     "the comparison will always evaluate as %<true%> "
   13618                 :             :                     "for the pointer operand in %qE must not be NULL",
   13619                 :             :                     op);
   13620                 :             : 
   13621                 :          24 :       return;
   13622                 :             :     }
   13623                 :             : 
   13624                 :       26690 :   if (TREE_CODE (op) != ADDR_EXPR)
   13625                 :             :     return;
   13626                 :             : 
   13627                 :         254 :   op = TREE_OPERAND (op, 0);
   13628                 :             : 
   13629                 :         254 :   if (TREE_CODE (op) == IMAGPART_EXPR
   13630                 :         254 :       || TREE_CODE (op) == REALPART_EXPR)
   13631                 :             :     {
   13632                 :             :       /* The address of either complex part may not be null.  */
   13633                 :          14 :       if (code == EQ_EXPR)
   13634                 :           9 :         warning_at (loc, OPT_Waddress,
   13635                 :             :                     "the comparison will always evaluate as %<false%> "
   13636                 :             :                     "for the address of %qE will never be NULL",
   13637                 :             :                     op);
   13638                 :             :       else
   13639                 :           5 :         warning_at (loc, OPT_Waddress,
   13640                 :             :                     "the comparison will always evaluate as %<true%> "
   13641                 :             :                     "for the address of %qE will never be NULL",
   13642                 :             :                     op);
   13643                 :          14 :       return;
   13644                 :             :     }
   13645                 :             : 
   13646                 :             :   /* Set to true in the loop below if OP dereferences is operand.
   13647                 :             :      In such a case the ultimate target need not be a decl for
   13648                 :             :      the null [in]equality test to be constant.  */
   13649                 :             :   bool deref = false;
   13650                 :             : 
   13651                 :             :   /* Get the outermost array or object, or member.  */
   13652                 :         294 :   while (handled_component_p (op))
   13653                 :             :     {
   13654                 :          72 :       if (TREE_CODE (op) == COMPONENT_REF)
   13655                 :             :         {
   13656                 :             :           /* Get the member (its address is never null).  */
   13657                 :          18 :           op = TREE_OPERAND (op, 1);
   13658                 :          18 :           break;
   13659                 :             :         }
   13660                 :             : 
   13661                 :             :       /* Get the outer array/object to refer to in the warning.  */
   13662                 :          54 :       op = TREE_OPERAND (op, 0);
   13663                 :          54 :       deref = true;
   13664                 :             :     }
   13665                 :             : 
   13666                 :         192 :   if ((!deref && !decl_with_nonnull_addr_p (op))
   13667                 :         371 :       || from_macro_expansion_at (loc))
   13668                 :         109 :     return;
   13669                 :             : 
   13670                 :         131 :   bool w;
   13671                 :         131 :   if (code == EQ_EXPR)
   13672                 :          93 :     w = warning_at (loc, OPT_Waddress,
   13673                 :             :                     "the comparison will always evaluate as %<false%> "
   13674                 :             :                     "for the address of %qE will never be NULL",
   13675                 :             :                     op);
   13676                 :             :   else
   13677                 :          38 :     w = warning_at (loc, OPT_Waddress,
   13678                 :             :                     "the comparison will always evaluate as %<true%> "
   13679                 :             :                     "for the address of %qE will never be NULL",
   13680                 :             :                     op);
   13681                 :             : 
   13682                 :         131 :   if (w && DECL_P (op))
   13683                 :         120 :     inform (DECL_SOURCE_LOCATION (op), "%qD declared here", op);
   13684                 :             : }
   13685                 :             : 
   13686                 :             : /* Build a binary-operation expression without default conversions.
   13687                 :             :    CODE is the kind of expression to build.
   13688                 :             :    LOCATION is the operator's location.
   13689                 :             :    This function differs from `build' in several ways:
   13690                 :             :    the data type of the result is computed and recorded in it,
   13691                 :             :    warnings are generated if arg data types are invalid,
   13692                 :             :    special handling for addition and subtraction of pointers is known,
   13693                 :             :    and some optimization is done (operations on narrow ints
   13694                 :             :    are done in the narrower type when that gives the same result).
   13695                 :             :    Constant folding is also done before the result is returned.
   13696                 :             : 
   13697                 :             :    Note that the operands will never have enumeral types, or function
   13698                 :             :    or array types, because either they will have the default conversions
   13699                 :             :    performed or they have both just been converted to some other type in which
   13700                 :             :    the arithmetic is to be done.  */
   13701                 :             : 
   13702                 :             : tree
   13703                 :    16407107 : build_binary_op (location_t location, enum tree_code code,
   13704                 :             :                  tree orig_op0, tree orig_op1, bool convert_p)
   13705                 :             : {
   13706                 :    16407107 :   tree type0, type1, orig_type0, orig_type1;
   13707                 :    16407107 :   tree eptype;
   13708                 :    16407107 :   enum tree_code code0, code1;
   13709                 :    16407107 :   tree op0, op1;
   13710                 :    16407107 :   tree ret = error_mark_node;
   13711                 :    16407107 :   const char *invalid_op_diag;
   13712                 :    16407107 :   bool op0_int_operands, op1_int_operands;
   13713                 :    16407107 :   bool int_const, int_const_or_overflow, int_operands;
   13714                 :             : 
   13715                 :             :   /* Expression code to give to the expression when it is built.
   13716                 :             :      Normally this is CODE, which is what the caller asked for,
   13717                 :             :      but in some special cases we change it.  */
   13718                 :    16407107 :   enum tree_code resultcode = code;
   13719                 :             : 
   13720                 :             :   /* Data type in which the computation is to be performed.
   13721                 :             :      In the simplest cases this is the common type of the arguments.  */
   13722                 :    16407107 :   tree result_type = NULL;
   13723                 :             : 
   13724                 :             :   /* When the computation is in excess precision, the type of the
   13725                 :             :      final EXCESS_PRECISION_EXPR.  */
   13726                 :    16407107 :   tree semantic_result_type = NULL;
   13727                 :             : 
   13728                 :             :   /* Nonzero means operands have already been type-converted
   13729                 :             :      in whatever way is necessary.
   13730                 :             :      Zero means they need to be converted to RESULT_TYPE.  */
   13731                 :    16407107 :   int converted = 0;
   13732                 :             : 
   13733                 :             :   /* Nonzero means create the expression with this type, rather than
   13734                 :             :      RESULT_TYPE.  */
   13735                 :    16407107 :   tree build_type = NULL_TREE;
   13736                 :             : 
   13737                 :             :   /* Nonzero means after finally constructing the expression
   13738                 :             :      convert it to this type.  */
   13739                 :    16407107 :   tree final_type = NULL_TREE;
   13740                 :             : 
   13741                 :             :   /* Nonzero if this is an operation like MIN or MAX which can
   13742                 :             :      safely be computed in short if both args are promoted shorts.
   13743                 :             :      Also implies COMMON.
   13744                 :             :      -1 indicates a bitwise operation; this makes a difference
   13745                 :             :      in the exact conditions for when it is safe to do the operation
   13746                 :             :      in a narrower mode.  */
   13747                 :    16407107 :   int shorten = 0;
   13748                 :             : 
   13749                 :             :   /* Nonzero if this is a comparison operation;
   13750                 :             :      if both args are promoted shorts, compare the original shorts.
   13751                 :             :      Also implies COMMON.  */
   13752                 :    16407107 :   int short_compare = 0;
   13753                 :             : 
   13754                 :             :   /* Nonzero if this is a right-shift operation, which can be computed on the
   13755                 :             :      original short and then promoted if the operand is a promoted short.  */
   13756                 :    16407107 :   int short_shift = 0;
   13757                 :             : 
   13758                 :             :   /* Nonzero means set RESULT_TYPE to the common type of the args.  */
   13759                 :    16407107 :   int common = 0;
   13760                 :             : 
   13761                 :             :   /* True means types are compatible as far as ObjC is concerned.  */
   13762                 :    16407107 :   bool objc_ok;
   13763                 :             : 
   13764                 :             :   /* True means this is an arithmetic operation that may need excess
   13765                 :             :      precision.  */
   13766                 :    16407107 :   bool may_need_excess_precision;
   13767                 :             : 
   13768                 :             :   /* True means this is a boolean operation that converts both its
   13769                 :             :      operands to truth-values.  */
   13770                 :    16407107 :   bool boolean_op = false;
   13771                 :             : 
   13772                 :             :   /* Remember whether we're doing / or %.  */
   13773                 :    16407107 :   bool doing_div_or_mod = false;
   13774                 :             : 
   13775                 :             :   /* Remember whether we're doing << or >>.  */
   13776                 :    16407107 :   bool doing_shift = false;
   13777                 :             : 
   13778                 :             :   /* Tree holding instrumentation expression.  */
   13779                 :    16407107 :   tree instrument_expr = NULL;
   13780                 :             : 
   13781                 :    16407107 :   if (location == UNKNOWN_LOCATION)
   13782                 :       19356 :     location = input_location;
   13783                 :             : 
   13784                 :    16407107 :   op0 = orig_op0;
   13785                 :    16407107 :   op1 = orig_op1;
   13786                 :             : 
   13787                 :    16407107 :   op0_int_operands = EXPR_INT_CONST_OPERANDS (orig_op0);
   13788                 :     7920668 :   if (op0_int_operands)
   13789                 :     7920668 :     op0 = remove_c_maybe_const_expr (op0);
   13790                 :    16407107 :   op1_int_operands = EXPR_INT_CONST_OPERANDS (orig_op1);
   13791                 :    11112325 :   if (op1_int_operands)
   13792                 :    11112325 :     op1 = remove_c_maybe_const_expr (op1);
   13793                 :    27519432 :   int_operands = (op0_int_operands && op1_int_operands);
   13794                 :    11112325 :   if (int_operands)
   13795                 :             :     {
   13796                 :    15495503 :       int_const_or_overflow = (TREE_CODE (orig_op0) == INTEGER_CST
   13797                 :     7762918 :                                && TREE_CODE (orig_op1) == INTEGER_CST);
   13798                 :     7732585 :       int_const = (int_const_or_overflow
   13799                 :     7732585 :                    && !TREE_OVERFLOW (orig_op0)
   13800                 :     7732516 :                    && !TREE_OVERFLOW (orig_op1));
   13801                 :             :     }
   13802                 :             :   else
   13803                 :             :     int_const = int_const_or_overflow = false;
   13804                 :             : 
   13805                 :             :   /* Do not apply default conversion in mixed vector/scalar expression.  */
   13806                 :    16407107 :   if (convert_p
   13807                 :    16407107 :       && VECTOR_TYPE_P (TREE_TYPE (op0)) == VECTOR_TYPE_P (TREE_TYPE (op1)))
   13808                 :             :     {
   13809                 :     9913186 :       op0 = default_conversion (op0);
   13810                 :     9913186 :       op1 = default_conversion (op1);
   13811                 :             :     }
   13812                 :             : 
   13813                 :    16407107 :   orig_type0 = type0 = TREE_TYPE (op0);
   13814                 :             : 
   13815                 :    16407107 :   orig_type1 = type1 = TREE_TYPE (op1);
   13816                 :             : 
   13817                 :             :   /* The expression codes of the data types of the arguments tell us
   13818                 :             :      whether the arguments are integers, floating, pointers, etc.  */
   13819                 :    16407107 :   code0 = TREE_CODE (type0);
   13820                 :    16407107 :   code1 = TREE_CODE (type1);
   13821                 :             : 
   13822                 :             :   /* Strip NON_LVALUE_EXPRs, etc., since we aren't using as an lvalue.  */
   13823                 :    16407109 :   STRIP_TYPE_NOPS (op0);
   13824                 :    16407110 :   STRIP_TYPE_NOPS (op1);
   13825                 :             : 
   13826                 :             :   /* If an error was already reported for one of the arguments,
   13827                 :             :      avoid reporting another error.  */
   13828                 :             : 
   13829                 :    16407107 :   if (code0 == ERROR_MARK || code1 == ERROR_MARK)
   13830                 :         708 :     return error_mark_node;
   13831                 :             : 
   13832                 :    16406399 :   if (code0 == POINTER_TYPE
   13833                 :    16406399 :       && reject_gcc_builtin (op0, EXPR_LOCATION (orig_op0)))
   13834                 :          11 :     return error_mark_node;
   13835                 :             : 
   13836                 :    16406388 :   if (code1 == POINTER_TYPE
   13837                 :    16406388 :       && reject_gcc_builtin (op1, EXPR_LOCATION (orig_op1)))
   13838                 :          11 :     return error_mark_node;
   13839                 :             : 
   13840                 :    32812754 :   if ((invalid_op_diag
   13841                 :    16406377 :        = targetm.invalid_binary_op (code, type0, type1)))
   13842                 :             :     {
   13843                 :           0 :       error_at (location, invalid_op_diag);
   13844                 :           0 :       return error_mark_node;
   13845                 :             :     }
   13846                 :             : 
   13847                 :    16406377 :   switch (code)
   13848                 :             :     {
   13849                 :             :     case PLUS_EXPR:
   13850                 :             :     case MINUS_EXPR:
   13851                 :             :     case MULT_EXPR:
   13852                 :             :     case TRUNC_DIV_EXPR:
   13853                 :             :     case CEIL_DIV_EXPR:
   13854                 :             :     case FLOOR_DIV_EXPR:
   13855                 :             :     case ROUND_DIV_EXPR:
   13856                 :             :     case EXACT_DIV_EXPR:
   13857                 :             :       may_need_excess_precision = true;
   13858                 :             :       break;
   13859                 :             : 
   13860                 :     2670310 :     case EQ_EXPR:
   13861                 :     2670310 :     case NE_EXPR:
   13862                 :     2670310 :     case LE_EXPR:
   13863                 :     2670310 :     case GE_EXPR:
   13864                 :     2670310 :     case LT_EXPR:
   13865                 :     2670310 :     case GT_EXPR:
   13866                 :             :       /* Excess precision for implicit conversions of integers to
   13867                 :             :          floating point in C11 and later.  */
   13868                 :     2670310 :       may_need_excess_precision = (flag_isoc11
   13869                 :     2670310 :                                    && (ANY_INTEGRAL_TYPE_P (type0)
   13870                 :      470300 :                                        || ANY_INTEGRAL_TYPE_P (type1)));
   13871                 :             :       break;
   13872                 :             : 
   13873                 :             :     default:
   13874                 :    16406377 :       may_need_excess_precision = false;
   13875                 :             :       break;
   13876                 :             :     }
   13877                 :    16406377 :   if (TREE_CODE (op0) == EXCESS_PRECISION_EXPR)
   13878                 :             :     {
   13879                 :         184 :       op0 = TREE_OPERAND (op0, 0);
   13880                 :         184 :       type0 = TREE_TYPE (op0);
   13881                 :             :     }
   13882                 :    16406193 :   else if (may_need_excess_precision
   13883                 :    16406193 :            && (eptype = excess_precision_type (type0)) != NULL_TREE)
   13884                 :             :     {
   13885                 :         771 :       type0 = eptype;
   13886                 :         771 :       op0 = convert (eptype, op0);
   13887                 :             :     }
   13888                 :    16406377 :   if (TREE_CODE (op1) == EXCESS_PRECISION_EXPR)
   13889                 :             :     {
   13890                 :         887 :       op1 = TREE_OPERAND (op1, 0);
   13891                 :         887 :       type1 = TREE_TYPE (op1);
   13892                 :             :     }
   13893                 :    16405490 :   else if (may_need_excess_precision
   13894                 :    16405490 :            && (eptype = excess_precision_type (type1)) != NULL_TREE)
   13895                 :             :     {
   13896                 :         592 :       type1 = eptype;
   13897                 :         592 :       op1 = convert (eptype, op1);
   13898                 :             :     }
   13899                 :             : 
   13900                 :    16406377 :   objc_ok = objc_compare_types (type0, type1, -3, NULL_TREE);
   13901                 :             : 
   13902                 :             :   /* In case when one of the operands of the binary operation is
   13903                 :             :      a vector and another is a scalar -- convert scalar to vector.  */
   13904                 :    17946741 :   if ((gnu_vector_type_p (type0) && code1 != VECTOR_TYPE)
   13905                 :    17944924 :       || (gnu_vector_type_p (type1) && code0 != VECTOR_TYPE))
   13906                 :             :     {
   13907                 :        2413 :       enum stv_conv convert_flag = scalar_to_vector (location, code, orig_op0,
   13908                 :             :                                                      orig_op1, true);
   13909                 :             : 
   13910                 :        2413 :       switch (convert_flag)
   13911                 :             :         {
   13912                 :          12 :           case stv_error:
   13913                 :          12 :             return error_mark_node;
   13914                 :         583 :           case stv_firstarg:
   13915                 :         583 :             {
   13916                 :         583 :               bool maybe_const = true;
   13917                 :         583 :               tree sc;
   13918                 :         583 :               sc = c_fully_fold (op0, false, &maybe_const);
   13919                 :         583 :               sc = save_expr (sc);
   13920                 :         583 :               sc = convert (TREE_TYPE (type1), sc);
   13921                 :         583 :               op0 = build_vector_from_val (type1, sc);
   13922                 :         583 :               if (!maybe_const)
   13923                 :          93 :                 op0 = c_wrap_maybe_const (op0, true);
   13924                 :         583 :               orig_type0 = type0 = TREE_TYPE (op0);
   13925                 :         583 :               code0 = TREE_CODE (type0);
   13926                 :         583 :               converted = 1;
   13927                 :         583 :               break;
   13928                 :             :             }
   13929                 :         998 :           case stv_secondarg:
   13930                 :         998 :             {
   13931                 :         998 :               bool maybe_const = true;
   13932                 :         998 :               tree sc;
   13933                 :         998 :               sc = c_fully_fold (op1, false, &maybe_const);
   13934                 :         998 :               sc = save_expr (sc);
   13935                 :         998 :               sc = convert (TREE_TYPE (type0), sc);
   13936                 :         998 :               op1 = build_vector_from_val (type0, sc);
   13937                 :         998 :               if (!maybe_const)
   13938                 :          36 :                 op1 = c_wrap_maybe_const (op1, true);
   13939                 :         998 :               orig_type1 = type1 = TREE_TYPE (op1);
   13940                 :         998 :               code1 = TREE_CODE (type1);
   13941                 :         998 :               converted = 1;
   13942                 :         998 :               break;
   13943                 :             :             }
   13944                 :             :           default:
   13945                 :             :             break;
   13946                 :             :         }
   13947                 :             :     }
   13948                 :             : 
   13949                 :    16406365 :   switch (code)
   13950                 :             :     {
   13951                 :     8396588 :     case PLUS_EXPR:
   13952                 :             :       /* Handle the pointer + int case.  */
   13953                 :     8396588 :       if (code0 == POINTER_TYPE
   13954                 :     1223639 :           && (code1 == INTEGER_TYPE || code1 == BITINT_TYPE))
   13955                 :             :         {
   13956                 :     1223633 :           ret = pointer_int_sum (location, PLUS_EXPR, op0, op1);
   13957                 :     1223633 :           goto return_build_binary_op;
   13958                 :             :         }
   13959                 :     7172955 :       else if (code1 == POINTER_TYPE
   13960                 :        1529 :                && (code0 == INTEGER_TYPE || code0 == BITINT_TYPE))
   13961                 :             :         {
   13962                 :        1523 :           ret = pointer_int_sum (location, PLUS_EXPR, op1, op0);
   13963                 :        1523 :           goto return_build_binary_op;
   13964                 :             :         }
   13965                 :             :       else
   13966                 :             :         common = 1;
   13967                 :             :       break;
   13968                 :             : 
   13969                 :      780148 :     case MINUS_EXPR:
   13970                 :             :       /* Subtraction of two similar pointers.
   13971                 :             :          We must subtract them as integers, then divide by object size.  */
   13972                 :      780148 :       if (code0 == POINTER_TYPE && code1 == POINTER_TYPE
   13973                 :      780148 :           && comp_target_types (location, type0, type1))
   13974                 :             :         {
   13975                 :        3619 :           ret = pointer_diff (location, op0, op1, &instrument_expr);
   13976                 :        3619 :           goto return_build_binary_op;
   13977                 :             :         }
   13978                 :             :       /* Handle pointer minus int.  Just like pointer plus int.  */
   13979                 :      776529 :       else if (code0 == POINTER_TYPE
   13980                 :       28945 :                && (code1 == INTEGER_TYPE || code1 == BITINT_TYPE))
   13981                 :             :         {
   13982                 :       28933 :           ret = pointer_int_sum (location, MINUS_EXPR, op0, op1);
   13983                 :       28933 :           goto return_build_binary_op;
   13984                 :             :         }
   13985                 :             :       else
   13986                 :             :         common = 1;
   13987                 :             :       break;
   13988                 :             : 
   13989                 :             :     case MULT_EXPR:
   13990                 :             :       common = 1;
   13991                 :             :       break;
   13992                 :             : 
   13993                 :      262725 :     case TRUNC_DIV_EXPR:
   13994                 :      262725 :     case CEIL_DIV_EXPR:
   13995                 :      262725 :     case FLOOR_DIV_EXPR:
   13996                 :      262725 :     case ROUND_DIV_EXPR:
   13997                 :      262725 :     case EXACT_DIV_EXPR:
   13998                 :      262725 :       doing_div_or_mod = true;
   13999                 :      262725 :       warn_for_div_by_zero (location, op1);
   14000                 :             : 
   14001                 :      262724 :       if ((code0 == INTEGER_TYPE || code0 == REAL_TYPE
   14002                 :       48493 :            || code0 == FIXED_POINT_TYPE || code0 == BITINT_TYPE
   14003                 :       46515 :            || code0 == COMPLEX_TYPE
   14004                 :       44467 :            || gnu_vector_type_p (type0))
   14005                 :      311216 :           && (code1 == INTEGER_TYPE || code1 == REAL_TYPE
   14006                 :       46067 :               || code1 == FIXED_POINT_TYPE || code1 == BITINT_TYPE
   14007                 :       45928 :               || code1 == COMPLEX_TYPE
   14008                 :       44469 :               || gnu_vector_type_p (type1)))
   14009                 :             :         {
   14010                 :      262720 :           enum tree_code tcode0 = code0, tcode1 = code1;
   14011                 :             : 
   14012                 :      262720 :           if (code0 == COMPLEX_TYPE || code0 == VECTOR_TYPE)
   14013                 :       46514 :             tcode0 = TREE_CODE (TREE_TYPE (TREE_TYPE (op0)));
   14014                 :      262720 :           if (code1 == COMPLEX_TYPE || code1 == VECTOR_TYPE)
   14015                 :       45925 :             tcode1 = TREE_CODE (TREE_TYPE (TREE_TYPE (op1)));
   14016                 :             : 
   14017                 :      262720 :           if (!(((tcode0 == INTEGER_TYPE || tcode0 == BITINT_TYPE)
   14018                 :      195063 :                  && (tcode1 == INTEGER_TYPE || tcode1 == BITINT_TYPE))
   14019                 :       79686 :                 || (tcode0 == FIXED_POINT_TYPE && tcode1 == FIXED_POINT_TYPE)))
   14020                 :             :             resultcode = RDIV_EXPR;
   14021                 :             :           else
   14022                 :             :             /* Although it would be tempting to shorten always here, that
   14023                 :             :                loses on some targets, since the modulo instruction is
   14024                 :             :                undefined if the quotient can't be represented in the
   14025                 :             :                computation mode.  We shorten only if unsigned or if
   14026                 :             :                dividing by something we know != -1.  */
   14027                 :      183034 :             shorten = may_shorten_divmod (op0, op1);
   14028                 :             :           common = 1;
   14029                 :             :         }
   14030                 :             :       break;
   14031                 :             : 
   14032                 :     1537450 :     case BIT_AND_EXPR:
   14033                 :     1537450 :     case BIT_IOR_EXPR:
   14034                 :     1537450 :     case BIT_XOR_EXPR:
   14035                 :     1537450 :       if ((code0 == INTEGER_TYPE || code0 == BITINT_TYPE)
   14036                 :     1015470 :           && (code1 == INTEGER_TYPE || code1 == BITINT_TYPE))
   14037                 :             :         shorten = -1;
   14038                 :             :       /* Allow vector types which are not floating point types.   */
   14039                 :      522016 :       else if (gnu_vector_type_p (type0)
   14040                 :      521939 :                && gnu_vector_type_p (type1)
   14041                 :      521939 :                && !VECTOR_FLOAT_TYPE_P (type0)
   14042                 :     1043952 :                && !VECTOR_FLOAT_TYPE_P (type1))
   14043                 :             :         common = 1;
   14044                 :             :       break;
   14045                 :             : 
   14046                 :       56415 :     case TRUNC_MOD_EXPR:
   14047                 :       56415 :     case FLOOR_MOD_EXPR:
   14048                 :       56415 :       doing_div_or_mod = true;
   14049                 :       56415 :       warn_for_div_by_zero (location, op1);
   14050                 :             : 
   14051                 :       56415 :       if (gnu_vector_type_p (type0)
   14052                 :         297 :           && gnu_vector_type_p (type1)
   14053                 :         297 :           && TREE_CODE (TREE_TYPE (type0)) == INTEGER_TYPE
   14054                 :       56712 :           && TREE_CODE (TREE_TYPE (type1)) == INTEGER_TYPE)
   14055                 :             :         common = 1;
   14056                 :       56118 :       else if ((code0 == INTEGER_TYPE || code0 == BITINT_TYPE)
   14057                 :       56117 :                && (code1 == INTEGER_TYPE || code1 == BITINT_TYPE))
   14058                 :             :         {
   14059                 :             :           /* Although it would be tempting to shorten always here, that loses
   14060                 :             :              on some targets, since the modulo instruction is undefined if the
   14061                 :             :              quotient can't be represented in the computation mode.  We shorten
   14062                 :             :              only if unsigned or if dividing by something we know != -1.  */
   14063                 :       56117 :           shorten = may_shorten_divmod (op0, op1);
   14064                 :       56117 :           common = 1;
   14065                 :             :         }
   14066                 :             :       break;
   14067                 :             : 
   14068                 :      501977 :     case TRUTH_ANDIF_EXPR:
   14069                 :      501977 :     case TRUTH_ORIF_EXPR:
   14070                 :      501977 :     case TRUTH_AND_EXPR:
   14071                 :      501977 :     case TRUTH_OR_EXPR:
   14072                 :      501977 :     case TRUTH_XOR_EXPR:
   14073                 :      501977 :       if ((code0 == INTEGER_TYPE || code0 == POINTER_TYPE
   14074                 :           0 :            || code0 == REAL_TYPE || code0 == COMPLEX_TYPE
   14075                 :           0 :            || code0 == FIXED_POINT_TYPE || code0 == NULLPTR_TYPE
   14076                 :           0 :            || code0 == BITINT_TYPE)
   14077                 :      501977 :           && (code1 == INTEGER_TYPE || code1 == POINTER_TYPE
   14078                 :         159 :               || code1 == REAL_TYPE || code1 == COMPLEX_TYPE
   14079                 :          20 :               || code1 == FIXED_POINT_TYPE || code1 == NULLPTR_TYPE
   14080                 :          18 :               || code1 == BITINT_TYPE))
   14081                 :             :         {
   14082                 :             :           /* Result of these operations is always an int,
   14083                 :             :              but that does not mean the operands should be
   14084                 :             :              converted to ints!  */
   14085                 :      501977 :           result_type = integer_type_node;
   14086                 :      501977 :           if (op0_int_operands)
   14087                 :             :             {
   14088                 :      110634 :               op0 = c_objc_common_truthvalue_conversion (location, orig_op0);
   14089                 :      110634 :               op0 = remove_c_maybe_const_expr (op0);
   14090                 :             :             }
   14091                 :             :           else
   14092                 :      391343 :             op0 = c_objc_common_truthvalue_conversion (location, op0);
   14093                 :      501977 :           if (op1_int_operands)
   14094                 :             :             {
   14095                 :       72152 :               op1 = c_objc_common_truthvalue_conversion (location, orig_op1);
   14096                 :       72152 :               op1 = remove_c_maybe_const_expr (op1);
   14097                 :             :             }
   14098                 :             :           else
   14099                 :      429825 :             op1 = c_objc_common_truthvalue_conversion (location, op1);
   14100                 :             :           converted = 1;
   14101                 :             :           boolean_op = true;
   14102                 :             :         }
   14103                 :      501977 :       if (code == TRUTH_ANDIF_EXPR)
   14104                 :             :         {
   14105                 :      245150 :           int_const_or_overflow = (int_operands
   14106                 :       64077 :                                    && TREE_CODE (orig_op0) == INTEGER_CST
   14107                 :      245166 :                                    && (op0 == truthvalue_false_node
   14108                 :       13799 :                                        || TREE_CODE (orig_op1) == INTEGER_CST));
   14109                 :             :           int_const = (int_const_or_overflow
   14110                 :       64050 :                        && !TREE_OVERFLOW (orig_op0)
   14111                 :       64050 :                        && (op0 == truthvalue_false_node
   14112                 :       13783 :                            || !TREE_OVERFLOW (orig_op1)));
   14113                 :             :         }
   14114                 :      320877 :       else if (code == TRUTH_ORIF_EXPR)
   14115                 :             :         {
   14116                 :      327494 :           int_const_or_overflow = (int_operands
   14117                 :        6768 :                                    && TREE_CODE (orig_op0) == INTEGER_CST
   14118                 :      327517 :                                    && (op0 == truthvalue_true_node
   14119                 :        2085 :                                        || TREE_CODE (orig_op1) == INTEGER_CST));
   14120                 :             :           int_const = (int_const_or_overflow
   14121                 :        6738 :                        && !TREE_OVERFLOW (orig_op0)
   14122                 :        6738 :                        && (op0 == truthvalue_true_node
   14123                 :        2062 :                            || !TREE_OVERFLOW (orig_op1)));
   14124                 :             :         }
   14125                 :             :       break;
   14126                 :             : 
   14127                 :             :       /* Shift operations: result has same type as first operand;
   14128                 :             :          always convert second operand to int.
   14129                 :             :          Also set SHORT_SHIFT if shifting rightward.  */
   14130                 :             : 
   14131                 :      226156 :     case RSHIFT_EXPR:
   14132                 :      226156 :       if (gnu_vector_type_p (type0)
   14133                 :         793 :           && gnu_vector_type_p (type1)
   14134                 :         257 :           && TREE_CODE (TREE_TYPE (type0)) == INTEGER_TYPE
   14135                 :         255 :           && TREE_CODE (TREE_TYPE (type1)) == INTEGER_TYPE
   14136                 :      226411 :           && known_eq (TYPE_VECTOR_SUBPARTS (type0),
   14137                 :             :                        TYPE_VECTOR_SUBPARTS (type1)))
   14138                 :             :         {
   14139                 :             :           result_type = type0;
   14140                 :             :           converted = 1;
   14141                 :             :         }
   14142                 :      225903 :       else if ((code0 == INTEGER_TYPE || code0 == FIXED_POINT_TYPE
   14143                 :        1059 :                 || code0 == BITINT_TYPE
   14144                 :         544 :                 || (gnu_vector_type_p (type0)
   14145                 :         540 :                     && TREE_CODE (TREE_TYPE (type0)) == INTEGER_TYPE))
   14146                 :      226955 :                && (code1 == INTEGER_TYPE || code1 == BITINT_TYPE))
   14147                 :             :         {
   14148                 :      225894 :           doing_shift = true;
   14149                 :      225894 :           if (TREE_CODE (op1) == INTEGER_CST)
   14150                 :             :             {
   14151                 :      197071 :               if (tree_int_cst_sgn (op1) < 0)
   14152                 :             :                 {
   14153                 :         245 :                   int_const = false;
   14154                 :         245 :                   if (c_inhibit_evaluation_warnings == 0)
   14155                 :         105 :                     warning_at (location, OPT_Wshift_count_negative,
   14156                 :             :                                 "right shift count is negative");
   14157                 :             :                 }
   14158                 :      196826 :               else if (code0 == VECTOR_TYPE)
   14159                 :             :                 {
   14160                 :         452 :                   if (compare_tree_int (op1,
   14161                 :         452 :                                         TYPE_PRECISION (TREE_TYPE (type0)))
   14162                 :             :                       >= 0)
   14163                 :             :                     {
   14164                 :          16 :                       int_const = false;
   14165                 :          16 :                       if (c_inhibit_evaluation_warnings == 0)
   14166                 :          16 :                         warning_at (location, OPT_Wshift_count_overflow,
   14167                 :             :                                     "right shift count >= width of vector element");
   14168                 :             :                     }
   14169                 :             :                 }
   14170                 :             :               else
   14171                 :             :                 {
   14172                 :      196374 :                   if (!integer_zerop (op1))
   14173                 :      196016 :                     short_shift = 1;
   14174                 :             : 
   14175                 :      196374 :                   if (compare_tree_int (op1, TYPE_PRECISION (type0)) >= 0)
   14176                 :             :                     {
   14177                 :         584 :                       int_const = false;
   14178                 :         584 :                       if (c_inhibit_evaluation_warnings == 0)
   14179                 :          50 :                         warning_at (location, OPT_Wshift_count_overflow,
   14180                 :             :                                     "right shift count >= width of type");
   14181                 :             :                     }
   14182                 :             :                 }
   14183                 :             :             }
   14184                 :             : 
   14185                 :             :           /* Use the type of the value to be shifted.  */
   14186                 :             :           result_type = type0;
   14187                 :             :           /* Avoid converting op1 to result_type later.  */
   14188                 :             :           converted = 1;
   14189                 :             :         }
   14190                 :             :       break;
   14191                 :             : 
   14192                 :      782653 :     case LSHIFT_EXPR:
   14193                 :      782653 :       if (gnu_vector_type_p (type0)
   14194                 :         594 :           && gnu_vector_type_p (type1)
   14195                 :         316 :           && TREE_CODE (TREE_TYPE (type0)) == INTEGER_TYPE
   14196                 :         314 :           && TREE_CODE (TREE_TYPE (type1)) == INTEGER_TYPE
   14197                 :      782966 :           && known_eq (TYPE_VECTOR_SUBPARTS (type0),
   14198                 :             :                        TYPE_VECTOR_SUBPARTS (type1)))
   14199                 :             :         {
   14200                 :             :           result_type = type0;
   14201                 :             :           converted = 1;
   14202                 :             :         }
   14203                 :      782342 :       else if ((code0 == INTEGER_TYPE || code0 == FIXED_POINT_TYPE
   14204                 :         740 :                 || code0 == BITINT_TYPE
   14205                 :         289 :                 || (gnu_vector_type_p (type0)
   14206                 :         283 :                     && TREE_CODE (TREE_TYPE (type0)) == INTEGER_TYPE))
   14207                 :      783073 :                && (code1 == INTEGER_TYPE || code1 == BITINT_TYPE))
   14208                 :             :         {
   14209                 :      782328 :           doing_shift = true;
   14210                 :      782328 :           if (TREE_CODE (op0) == INTEGER_CST
   14211                 :      427157 :               && tree_int_cst_sgn (op0) < 0
   14212                 :      783077 :               && !TYPE_OVERFLOW_WRAPS (type0))
   14213                 :             :             {
   14214                 :             :               /* Don't reject a left shift of a negative value in a context
   14215                 :             :                  where a constant expression is needed in C90.  */
   14216                 :         712 :               if (flag_isoc99)
   14217                 :         666 :                 int_const = false;
   14218                 :         712 :               if (c_inhibit_evaluation_warnings == 0)
   14219                 :         712 :                 warning_at (location, OPT_Wshift_negative_value,
   14220                 :             :                             "left shift of negative value");
   14221                 :             :             }
   14222                 :      782328 :           if (TREE_CODE (op1) == INTEGER_CST)
   14223                 :             :             {
   14224                 :      712964 :               if (tree_int_cst_sgn (op1) < 0)
   14225                 :             :                 {
   14226                 :         281 :                   int_const = false;
   14227                 :         281 :                   if (c_inhibit_evaluation_warnings == 0)
   14228                 :         103 :                     warning_at (location, OPT_Wshift_count_negative,
   14229                 :             :                                 "left shift count is negative");
   14230                 :             :                 }
   14231                 :      712683 :               else if (code0 == VECTOR_TYPE)
   14232                 :             :                 {
   14233                 :         214 :                   if (compare_tree_int (op1,
   14234                 :         214 :                                         TYPE_PRECISION (TREE_TYPE (type0)))
   14235                 :             :                       >= 0)
   14236                 :             :                     {
   14237                 :           6 :                       int_const = false;
   14238                 :           6 :                       if (c_inhibit_evaluation_warnings == 0)
   14239                 :           6 :                         warning_at (location, OPT_Wshift_count_overflow,
   14240                 :             :                                     "left shift count >= width of vector element");
   14241                 :             :                     }
   14242                 :             :                 }
   14243                 :      712469 :               else if (compare_tree_int (op1, TYPE_PRECISION (type0)) >= 0)
   14244                 :             :                 {
   14245                 :       29731 :                   int_const = false;
   14246                 :       29731 :                   if (c_inhibit_evaluation_warnings == 0)
   14247                 :         111 :                     warning_at (location, OPT_Wshift_count_overflow,
   14248                 :             :                                 "left shift count >= width of type");
   14249                 :             :                 }
   14250                 :      682738 :               else if (TREE_CODE (op0) == INTEGER_CST
   14251                 :      355834 :                        && maybe_warn_shift_overflow (location, op0, op1)
   14252                 :      683370 :                        && flag_isoc99)
   14253                 :             :                 int_const = false;
   14254                 :             :             }
   14255                 :             : 
   14256                 :             :           /* Use the type of the value to be shifted.  */
   14257                 :             :           result_type = type0;
   14258                 :             :           /* Avoid converting op1 to result_type later.  */
   14259                 :             :           converted = 1;
   14260                 :             :         }
   14261                 :             :       break;
   14262                 :             : 
   14263                 :     1698652 :     case EQ_EXPR:
   14264                 :     1698652 :     case NE_EXPR:
   14265                 :     1698652 :       if (gnu_vector_type_p (type0) && gnu_vector_type_p (type1))
   14266                 :             :         {
   14267                 :       40861 :           tree intt;
   14268                 :       40861 :           if (!vector_types_compatible_elements_p (type0, type1))
   14269                 :             :             {
   14270                 :           4 :               error_at (location, "comparing vectors with different "
   14271                 :             :                                   "element types");
   14272                 :           4 :               return error_mark_node;
   14273                 :             :             }
   14274                 :             : 
   14275                 :       40857 :           if (maybe_ne (TYPE_VECTOR_SUBPARTS (type0),
   14276                 :       81714 :                         TYPE_VECTOR_SUBPARTS (type1)))
   14277                 :             :             {
   14278                 :           1 :               error_at (location, "comparing vectors with different "
   14279                 :             :                                   "number of elements");
   14280                 :           1 :               return error_mark_node;
   14281                 :             :             }
   14282                 :             : 
   14283                 :             :           /* It's not precisely specified how the usual arithmetic
   14284                 :             :              conversions apply to the vector types.  Here, we use
   14285                 :             :              the unsigned type if one of the operands is signed and
   14286                 :             :              the other one is unsigned.  */
   14287                 :       40856 :           if (TYPE_UNSIGNED (type0) != TYPE_UNSIGNED (type1))
   14288                 :             :             {
   14289                 :           4 :               if (!TYPE_UNSIGNED (type0))
   14290                 :           4 :                 op0 = build1 (VIEW_CONVERT_EXPR, type1, op0);
   14291                 :             :               else
   14292                 :           0 :                 op1 = build1 (VIEW_CONVERT_EXPR, type0, op1);
   14293                 :           4 :               warning_at (location, OPT_Wsign_compare, "comparison between "
   14294                 :             :                           "types %qT and %qT", type0, type1);
   14295                 :             :             }
   14296                 :             : 
   14297                 :             :           /* Always construct signed integer vector type.  */
   14298                 :      122568 :           intt = c_common_type_for_size (GET_MODE_BITSIZE
   14299                 :       81712 :                                          (SCALAR_TYPE_MODE
   14300                 :             :                                           (TREE_TYPE (type0))), 0);
   14301                 :       40856 :           if (!intt)
   14302                 :             :             {
   14303                 :           0 :               error_at (location, "could not find an integer type "
   14304                 :             :                                   "of the same size as %qT",
   14305                 :           0 :                         TREE_TYPE (type0));
   14306                 :           0 :               return error_mark_node;
   14307                 :             :             }
   14308                 :       40856 :           result_type = build_opaque_vector_type (intt,
   14309                 :       40856 :                                                   TYPE_VECTOR_SUBPARTS (type0));
   14310                 :       40856 :           converted = 1;
   14311                 :       40856 :           ret = build_vec_cmp (resultcode, result_type, op0, op1);
   14312                 :       40856 :           goto return_build_binary_op;
   14313                 :             :         }
   14314                 :     1657791 :       if (FLOAT_TYPE_P (type0) || FLOAT_TYPE_P (type1))
   14315                 :      245257 :         warning_at (location,
   14316                 :      245257 :                     OPT_Wfloat_equal,
   14317                 :             :                     "comparing floating-point with %<==%> or %<!=%> is unsafe");
   14318                 :             :       /* Result of comparison is always int,
   14319                 :             :          but don't convert the args to int!  */
   14320                 :     1657791 :       build_type = integer_type_node;
   14321                 :     1657791 :       if ((code0 == INTEGER_TYPE || code0 == REAL_TYPE || code0 == BITINT_TYPE
   14322                 :      154796 :            || code0 == FIXED_POINT_TYPE || code0 == COMPLEX_TYPE)
   14323                 :     1538288 :           && (code1 == INTEGER_TYPE || code1 == REAL_TYPE
   14324                 :             :               || code1 == BITINT_TYPE
   14325                 :             :               || code1 == FIXED_POINT_TYPE || code1 == COMPLEX_TYPE))
   14326                 :             :         short_compare = 1;
   14327                 :      119766 :       else if (code0 == POINTER_TYPE
   14328                 :      119766 :                && (code1 == NULLPTR_TYPE
   14329                 :      119429 :                    || null_pointer_constant_p (orig_op1)))
   14330                 :             :         {
   14331                 :       50021 :           maybe_warn_for_null_address (location, op0, code);
   14332                 :       50021 :           result_type = type0;
   14333                 :             :         }
   14334                 :       69745 :       else if (code1 == POINTER_TYPE
   14335                 :       69745 :                && (code0 == NULLPTR_TYPE
   14336                 :       69651 :                    || null_pointer_constant_p (orig_op0)))
   14337                 :             :         {
   14338                 :         284 :           maybe_warn_for_null_address (location, op1, code);
   14339                 :         284 :           result_type = type1;
   14340                 :             :         }
   14341                 :       69461 :       else if (code0 == POINTER_TYPE && code1 == POINTER_TYPE)
   14342                 :             :         {
   14343                 :       69379 :           tree tt0 = TREE_TYPE (type0);
   14344                 :       69379 :           tree tt1 = TREE_TYPE (type1);
   14345                 :       69379 :           addr_space_t as0 = TYPE_ADDR_SPACE (tt0);
   14346                 :       69379 :           addr_space_t as1 = TYPE_ADDR_SPACE (tt1);
   14347                 :       69379 :           addr_space_t as_common = ADDR_SPACE_GENERIC;
   14348                 :             : 
   14349                 :             :           /* Anything compares with void *.  void * compares with anything.
   14350                 :             :              Otherwise, the targets must be compatible
   14351                 :             :              and both must be object or both incomplete.  */
   14352                 :       69379 :           if (comp_target_types (location, type0, type1))
   14353                 :       48096 :             result_type = common_pointer_type (type0, type1);
   14354                 :       21283 :           else if (!addr_space_superset (as0, as1, &as_common))
   14355                 :             :             {
   14356                 :           0 :               error_at (location, "comparison of pointers to "
   14357                 :             :                         "disjoint address spaces");
   14358                 :           0 :               return error_mark_node;
   14359                 :             :             }
   14360                 :       21283 :           else if (VOID_TYPE_P (tt0) && !TYPE_ATOMIC (tt0))
   14361                 :             :             {
   14362                 :       21086 :               if (pedantic && TREE_CODE (tt1) == FUNCTION_TYPE)
   14363                 :           4 :                 pedwarn (location, OPT_Wpedantic, "ISO C forbids "
   14364                 :             :                          "comparison of %<void *%> with function pointer");
   14365                 :             :             }
   14366                 :         197 :           else if (VOID_TYPE_P (tt1) && !TYPE_ATOMIC (tt1))
   14367                 :             :             {
   14368                 :         149 :               if (pedantic && TREE_CODE (tt0) == FUNCTION_TYPE)
   14369                 :           4 :                 pedwarn (location, OPT_Wpedantic, "ISO C forbids "
   14370                 :             :                          "comparison of %<void *%> with function pointer");
   14371                 :             :             }
   14372                 :             :           else
   14373                 :             :             /* Avoid warning about the volatile ObjC EH puts on decls.  */
   14374                 :          48 :             if (!objc_ok)
   14375                 :          48 :               pedwarn (location, OPT_Wcompare_distinct_pointer_types,
   14376                 :             :                        "comparison of distinct pointer types lacks a cast");
   14377                 :             : 
   14378                 :       48152 :           if (result_type == NULL_TREE)
   14379                 :             :             {
   14380                 :       21283 :               int qual = ENCODE_QUAL_ADDR_SPACE (as_common);
   14381                 :       21283 :               result_type = c_build_pointer_type
   14382                 :       21283 :                               (c_build_qualified_type (void_type_node, qual));
   14383                 :             :             }
   14384                 :             :         }
   14385                 :          82 :       else if (code0 == POINTER_TYPE
   14386                 :          26 :                && (code1 == INTEGER_TYPE || code1 == BITINT_TYPE))
   14387                 :             :         {
   14388                 :          26 :           result_type = type0;
   14389                 :          26 :           pedwarn (location, 0, "comparison between pointer and integer");
   14390                 :             :         }
   14391                 :          56 :       else if ((code0 == INTEGER_TYPE || code0 == BITINT_TYPE)
   14392                 :          21 :                && code1 == POINTER_TYPE)
   14393                 :             :         {
   14394                 :           8 :           result_type = type1;
   14395                 :           8 :           pedwarn (location, 0, "comparison between pointer and integer");
   14396                 :             :         }
   14397                 :             :       /* 6.5.9: One of the following shall hold:
   14398                 :             :          -- both operands have type nullptr_t;  */
   14399                 :          48 :       else if (code0 == NULLPTR_TYPE && code1 == NULLPTR_TYPE)
   14400                 :             :         {
   14401                 :          14 :           result_type = nullptr_type_node;
   14402                 :             :           /* No need to convert the operands to result_type later.  */
   14403                 :          14 :           converted = 1;
   14404                 :             :         }
   14405                 :             :     /* -- one operand has type nullptr_t and the other is a null pointer
   14406                 :             :        constant.  We will have to convert the former to the type of the
   14407                 :             :        latter, because during gimplification we can't have mismatching
   14408                 :             :        comparison operand type.  We convert from nullptr_t to the other
   14409                 :             :        type, since only nullptr_t can be converted to nullptr_t.  Also,
   14410                 :             :        even a constant 0 is a null pointer constant, so we may have to
   14411                 :             :        create a pointer type from its type.  */
   14412                 :          34 :       else if (code0 == NULLPTR_TYPE && null_pointer_constant_p (orig_op1))
   14413                 :          19 :         result_type = (INTEGRAL_TYPE_P (type1)
   14414                 :          19 :                        ? c_build_pointer_type (type1) : type1);
   14415                 :          15 :       else if (code1 == NULLPTR_TYPE && null_pointer_constant_p (orig_op0))
   14416                 :          11 :         result_type = (INTEGRAL_TYPE_P (type0)
   14417                 :          11 :                        ? c_build_pointer_type (type0) : type0);
   14418                 :     4903749 :       if ((C_BOOLEAN_TYPE_P (TREE_TYPE (orig_op0))
   14419                 :     3245933 :            || truth_value_p (TREE_CODE (orig_op0)))
   14420                 :     3308332 :           ^ (C_BOOLEAN_TYPE_P (TREE_TYPE (orig_op1))
   14421                 :     3308328 :              || truth_value_p (TREE_CODE (orig_op1))))
   14422                 :       66672 :         maybe_warn_bool_compare (location, code, orig_op0, orig_op1);
   14423                 :             :       break;
   14424                 :             : 
   14425                 :      971654 :     case LE_EXPR:
   14426                 :      971654 :     case GE_EXPR:
   14427                 :      971654 :     case LT_EXPR:
   14428                 :      971654 :     case GT_EXPR:
   14429                 :      971654 :       if (gnu_vector_type_p (type0) && gnu_vector_type_p (type1))
   14430                 :             :         {
   14431                 :       57755 :           tree intt;
   14432                 :       57755 :           if (!vector_types_compatible_elements_p (type0, type1))
   14433                 :             :             {
   14434                 :           5 :               error_at (location, "comparing vectors with different "
   14435                 :             :                                   "element types");
   14436                 :           5 :               return error_mark_node;
   14437                 :             :             }
   14438                 :             : 
   14439                 :       57750 :           if (maybe_ne (TYPE_VECTOR_SUBPARTS (type0),
   14440                 :      115500 :                         TYPE_VECTOR_SUBPARTS (type1)))
   14441                 :             :             {
   14442                 :           0 :               error_at (location, "comparing vectors with different "
   14443                 :             :                                   "number of elements");
   14444                 :           0 :               return error_mark_node;
   14445                 :             :             }
   14446                 :             : 
   14447                 :             :           /* It's not precisely specified how the usual arithmetic
   14448                 :             :              conversions apply to the vector types.  Here, we use
   14449                 :             :              the unsigned type if one of the operands is signed and
   14450                 :             :              the other one is unsigned.  */
   14451                 :       57750 :           if (TYPE_UNSIGNED (type0) != TYPE_UNSIGNED (type1))
   14452                 :             :             {
   14453                 :          15 :               if (!TYPE_UNSIGNED (type0))
   14454                 :           8 :                 op0 = build1 (VIEW_CONVERT_EXPR, type1, op0);
   14455                 :             :               else
   14456                 :           7 :                 op1 = build1 (VIEW_CONVERT_EXPR, type0, op1);
   14457                 :          15 :               warning_at (location, OPT_Wsign_compare, "comparison between "
   14458                 :             :                           "types %qT and %qT", type0, type1);
   14459                 :             :             }
   14460                 :             : 
   14461                 :             :           /* Always construct signed integer vector type.  */
   14462                 :      173250 :           intt = c_common_type_for_size (GET_MODE_BITSIZE
   14463                 :      115500 :                                          (SCALAR_TYPE_MODE
   14464                 :             :                                           (TREE_TYPE (type0))), 0);
   14465                 :       57750 :           if (!intt)
   14466                 :             :             {
   14467                 :           0 :               error_at (location, "could not find an integer type "
   14468                 :             :                                   "of the same size as %qT",
   14469                 :           0 :                         TREE_TYPE (type0));
   14470                 :           0 :               return error_mark_node;
   14471                 :             :             }
   14472                 :       57750 :           result_type = build_opaque_vector_type (intt,
   14473                 :       57750 :                                                   TYPE_VECTOR_SUBPARTS (type0));
   14474                 :       57750 :           converted = 1;
   14475                 :       57750 :           ret = build_vec_cmp (resultcode, result_type, op0, op1);
   14476                 :       57750 :           goto return_build_binary_op;
   14477                 :             :         }
   14478                 :      913899 :       build_type = integer_type_node;
   14479                 :      913899 :       if ((code0 == INTEGER_TYPE || code0 == REAL_TYPE
   14480                 :       63656 :            || code0 == BITINT_TYPE || code0 == FIXED_POINT_TYPE)
   14481                 :      850772 :           && (code1 == INTEGER_TYPE || code1 == REAL_TYPE
   14482                 :             :               || code1 == BITINT_TYPE || code1 == FIXED_POINT_TYPE))
   14483                 :             :         short_compare = 1;
   14484                 :       63159 :       else if (code0 == POINTER_TYPE && code1 == POINTER_TYPE)
   14485                 :             :         {
   14486                 :       63092 :           addr_space_t as0 = TYPE_ADDR_SPACE (TREE_TYPE (type0));
   14487                 :       63092 :           addr_space_t as1 = TYPE_ADDR_SPACE (TREE_TYPE (type1));
   14488                 :       63092 :           addr_space_t as_common;
   14489                 :             : 
   14490                 :       63092 :           if (comp_target_types (location, type0, type1))
   14491                 :             :             {
   14492                 :       62979 :               result_type = common_pointer_type (type0, type1);
   14493                 :       62979 :               if (!COMPLETE_TYPE_P (TREE_TYPE (type0))
   14494                 :       62979 :                   != !COMPLETE_TYPE_P (TREE_TYPE (type1)))
   14495                 :          32 :                 pedwarn_c99 (location, OPT_Wpedantic,
   14496                 :             :                              "comparison of complete and incomplete pointers");
   14497                 :       62947 :               else if (TREE_CODE (TREE_TYPE (type0)) == FUNCTION_TYPE)
   14498                 :           0 :                 pedwarn (location, OPT_Wpedantic, "ISO C forbids "
   14499                 :             :                          "ordered comparisons of pointers to functions");
   14500                 :       62947 :               else if (null_pointer_constant_p (orig_op0)
   14501                 :       62947 :                        || null_pointer_constant_p (orig_op1))
   14502                 :           8 :                 warning_at (location, OPT_Wextra,
   14503                 :             :                             "ordered comparison of pointer with null pointer");
   14504                 :             : 
   14505                 :             :             }
   14506                 :         113 :           else if (!addr_space_superset (as0, as1, &as_common))
   14507                 :             :             {
   14508                 :           0 :               error_at (location, "comparison of pointers to "
   14509                 :             :                         "disjoint address spaces");
   14510                 :           0 :               return error_mark_node;
   14511                 :             :             }
   14512                 :             :           else
   14513                 :             :             {
   14514                 :         113 :               int qual = ENCODE_QUAL_ADDR_SPACE (as_common);
   14515                 :         113 :               result_type = c_build_pointer_type
   14516                 :         113 :                               (c_build_qualified_type (void_type_node, qual));
   14517                 :         113 :               pedwarn (location, OPT_Wcompare_distinct_pointer_types,
   14518                 :             :                        "comparison of distinct pointer types lacks a cast");
   14519                 :             :             }
   14520                 :             :         }
   14521                 :          67 :       else if (code0 == POINTER_TYPE && null_pointer_constant_p (orig_op1))
   14522                 :             :         {
   14523                 :          17 :           result_type = type0;
   14524                 :          17 :           if (pedantic)
   14525                 :          11 :             pedwarn (location, OPT_Wpedantic,
   14526                 :             :                      "ordered comparison of pointer with integer zero");
   14527                 :           6 :           else if (extra_warnings)
   14528                 :           1 :             warning_at (location, OPT_Wextra,
   14529                 :             :                         "ordered comparison of pointer with integer zero");
   14530                 :             :         }
   14531                 :          50 :       else if (code1 == POINTER_TYPE && null_pointer_constant_p (orig_op0))
   14532                 :             :         {
   14533                 :          12 :           result_type = type1;
   14534                 :          12 :           if (pedantic)
   14535                 :           2 :             pedwarn (location, OPT_Wpedantic,
   14536                 :             :                      "ordered comparison of pointer with integer zero");
   14537                 :          10 :           else if (extra_warnings)
   14538                 :           1 :             warning_at (location, OPT_Wextra,
   14539                 :             :                         "ordered comparison of pointer with integer zero");
   14540                 :             :         }
   14541                 :          38 :       else if (code0 == POINTER_TYPE
   14542                 :          18 :                && (code1 == INTEGER_TYPE || code1 == BITINT_TYPE))
   14543                 :             :         {
   14544                 :          18 :           result_type = type0;
   14545                 :          18 :           pedwarn (location, 0, "comparison between pointer and integer");
   14546                 :             :         }
   14547                 :          20 :       else if ((code0 == INTEGER_TYPE || code0 == BITINT_TYPE)
   14548                 :          20 :                && code1 == POINTER_TYPE)
   14549                 :             :         {
   14550                 :          18 :           result_type = type1;
   14551                 :          18 :           pedwarn (location, 0, "comparison between pointer and integer");
   14552                 :             :         }
   14553                 :             : 
   14554                 :      913899 :       if ((code0 == POINTER_TYPE || code1 == POINTER_TYPE)
   14555                 :       63157 :           && current_function_decl != NULL_TREE
   14556                 :      977045 :           && sanitize_flags_p (SANITIZE_POINTER_COMPARE))
   14557                 :             :         {
   14558                 :          35 :           op0 = save_expr (c_fully_fold (op0, false, NULL));
   14559                 :          35 :           op1 = save_expr (c_fully_fold (op1, false, NULL));
   14560                 :             : 
   14561                 :          35 :           tree tt = builtin_decl_explicit (BUILT_IN_ASAN_POINTER_COMPARE);
   14562                 :          35 :           instrument_expr = build_call_expr_loc (location, tt, 2, op0, op1);
   14563                 :             :         }
   14564                 :             : 
   14565                 :     2741607 :       if ((C_BOOLEAN_TYPE_P (TREE_TYPE (orig_op0))
   14566                 :     1827708 :            || truth_value_p (TREE_CODE (orig_op0)))
   14567                 :     1827723 :           ^ (C_BOOLEAN_TYPE_P (TREE_TYPE (orig_op1))
   14568                 :     1827723 :              || truth_value_p (TREE_CODE (orig_op1))))
   14569                 :         509 :         maybe_warn_bool_compare (location, code, orig_op0, orig_op1);
   14570                 :             :       break;
   14571                 :             : 
   14572                 :          43 :     case MIN_EXPR:
   14573                 :          43 :     case MAX_EXPR:
   14574                 :             :       /* Used for OpenMP atomics.  */
   14575                 :          43 :       gcc_assert (flag_openmp);
   14576                 :             :       common = 1;
   14577                 :             :       break;
   14578                 :             : 
   14579                 :           0 :     default:
   14580                 :           0 :       gcc_unreachable ();
   14581                 :             :     }
   14582                 :             : 
   14583                 :    15050040 :   if (code0 == ERROR_MARK || code1 == ERROR_MARK)
   14584                 :           0 :     return error_mark_node;
   14585                 :             : 
   14586                 :    15050040 :   if (gnu_vector_type_p (type0)
   14587                 :     1442327 :       && gnu_vector_type_p (type1)
   14588                 :    16491552 :       && (!tree_int_cst_equal (TYPE_SIZE (type0), TYPE_SIZE (type1))
   14589                 :     1441492 :           || !vector_types_compatible_elements_p (type0, type1)))
   14590                 :             :     {
   14591                 :          26 :       gcc_rich_location richloc (location);
   14592                 :          26 :       maybe_range_label_for_tree_type_mismatch
   14593                 :          26 :         label_for_op0 (orig_op0, orig_op1),
   14594                 :          26 :         label_for_op1 (orig_op1, orig_op0);
   14595                 :          26 :       richloc.maybe_add_expr (orig_op0, &label_for_op0, highlight_colors::lhs);
   14596                 :          26 :       richloc.maybe_add_expr (orig_op1, &label_for_op1, highlight_colors::rhs);
   14597                 :          26 :       binary_op_error (&richloc, code, type0, type1);
   14598                 :          26 :       return error_mark_node;
   14599                 :          26 :     }
   14600                 :             : 
   14601                 :    15050014 :   if ((code0 == INTEGER_TYPE || code0 == REAL_TYPE || code0 == COMPLEX_TYPE
   14602                 :     1693017 :        || code0 == FIXED_POINT_TYPE || code0 == BITINT_TYPE
   14603                 :     1625346 :        || gnu_vector_type_p (type0))
   14604                 :    16559986 :       && (code1 == INTEGER_TYPE || code1 == REAL_TYPE || code1 == COMPLEX_TYPE
   14605                 :     1534846 :           || code1 == FIXED_POINT_TYPE || code1 == BITINT_TYPE
   14606                 :     1443548 :           || gnu_vector_type_p (type1)))
   14607                 :             :     {
   14608                 :    14864912 :       bool first_complex = (code0 == COMPLEX_TYPE);
   14609                 :    14864912 :       bool second_complex = (code1 == COMPLEX_TYPE);
   14610                 :    14864912 :       int none_complex = (!first_complex && !second_complex);
   14611                 :             : 
   14612                 :    14864912 :       if (shorten || common || short_compare)
   14613                 :             :         {
   14614                 :    13355820 :           result_type = c_common_type (type0, type1);
   14615                 :    13355820 :           do_warn_double_promotion (result_type, type0, type1,
   14616                 :             :                                     "implicit conversion from %qT to %qT "
   14617                 :             :                                     "to match other operand of binary "
   14618                 :             :                                     "expression",
   14619                 :             :                                     location);
   14620                 :    13355820 :           if (result_type == error_mark_node)
   14621                 :             :             return error_mark_node;
   14622                 :             :         }
   14623                 :             : 
   14624                 :    14864890 :       if (first_complex != second_complex
   14625                 :       82043 :           && (code == PLUS_EXPR
   14626                 :             :               || code == MINUS_EXPR
   14627                 :       82043 :               || code == MULT_EXPR
   14628                 :       17525 :               || (code == TRUNC_DIV_EXPR && first_complex))
   14629                 :       65932 :           && TREE_CODE (TREE_TYPE (result_type)) == REAL_TYPE
   14630                 :    14927144 :           && flag_signed_zeros)
   14631                 :             :         {
   14632                 :             :           /* An operation on mixed real/complex operands must be
   14633                 :             :              handled specially, but the language-independent code can
   14634                 :             :              more easily optimize the plain complex arithmetic if
   14635                 :             :              -fno-signed-zeros.  */
   14636                 :       61942 :           tree real_type = TREE_TYPE (result_type);
   14637                 :       61942 :           tree real, imag;
   14638                 :       61942 :           if (type0 != orig_type0 || type1 != orig_type1)
   14639                 :             :             {
   14640                 :          94 :               gcc_assert (may_need_excess_precision && common);
   14641                 :          94 :               semantic_result_type = c_common_type (orig_type0, orig_type1);
   14642                 :             :             }
   14643                 :       61942 :           if (first_complex)
   14644                 :             :             {
   14645                 :        8253 :               if (TREE_TYPE (op0) != result_type)
   14646                 :        1787 :                 op0 = convert_and_check (location, result_type, op0);
   14647                 :        8253 :               if (TREE_TYPE (op1) != real_type)
   14648                 :        4601 :                 op1 = convert_and_check (location, real_type, op1);
   14649                 :             :             }
   14650                 :             :           else
   14651                 :             :             {
   14652                 :       53689 :               if (TREE_TYPE (op0) != real_type)
   14653                 :        2698 :                 op0 = convert_and_check (location, real_type, op0);
   14654                 :       53689 :               if (TREE_TYPE (op1) != result_type)
   14655                 :        1866 :                 op1 = convert_and_check (location, result_type, op1);
   14656                 :             :             }
   14657                 :       61942 :           if (TREE_CODE (op0) == ERROR_MARK || TREE_CODE (op1) == ERROR_MARK)
   14658                 :           0 :             return error_mark_node;
   14659                 :       61942 :           if (first_complex)
   14660                 :             :             {
   14661                 :        8253 :               op0 = save_expr (op0);
   14662                 :        8253 :               real = build_unary_op (EXPR_LOCATION (orig_op0), REALPART_EXPR,
   14663                 :             :                                      op0, true);
   14664                 :        8253 :               imag = build_unary_op (EXPR_LOCATION (orig_op0), IMAGPART_EXPR,
   14665                 :             :                                      op0, true);
   14666                 :        8253 :               switch (code)
   14667                 :             :                 {
   14668                 :        3488 :                 case MULT_EXPR:
   14669                 :        3488 :                 case TRUNC_DIV_EXPR:
   14670                 :        3488 :                   op1 = save_expr (op1);
   14671                 :        3488 :                   imag = build2 (resultcode, real_type, imag, op1);
   14672                 :             :                   /* Fall through.  */
   14673                 :        8253 :                 case PLUS_EXPR:
   14674                 :        8253 :                 case MINUS_EXPR:
   14675                 :        8253 :                   real = build2 (resultcode, real_type, real, op1);
   14676                 :        8253 :                   break;
   14677                 :           0 :                 default:
   14678                 :           0 :                   gcc_unreachable();
   14679                 :             :                 }
   14680                 :             :             }
   14681                 :             :           else
   14682                 :             :             {
   14683                 :       53689 :               op1 = save_expr (op1);
   14684                 :       53689 :               real = build_unary_op (EXPR_LOCATION (orig_op1), REALPART_EXPR,
   14685                 :             :                                      op1, true);
   14686                 :       53689 :               imag = build_unary_op (EXPR_LOCATION (orig_op1), IMAGPART_EXPR,
   14687                 :             :                                      op1, true);
   14688                 :       53689 :               switch (code)
   14689                 :             :                 {
   14690                 :        2008 :                 case MULT_EXPR:
   14691                 :        2008 :                   op0 = save_expr (op0);
   14692                 :        2008 :                   imag = build2 (resultcode, real_type, op0, imag);
   14693                 :             :                   /* Fall through.  */
   14694                 :       31957 :                 case PLUS_EXPR:
   14695                 :       31957 :                   real = build2 (resultcode, real_type, op0, real);
   14696                 :       31957 :                   break;
   14697                 :       21732 :                 case MINUS_EXPR:
   14698                 :       21732 :                   real = build2 (resultcode, real_type, op0, real);
   14699                 :       21732 :                   imag = build1 (NEGATE_EXPR, real_type, imag);
   14700                 :       21732 :                   break;
   14701                 :           0 :                 default:
   14702                 :           0 :                   gcc_unreachable();
   14703                 :             :                 }
   14704                 :             :             }
   14705                 :       61942 :           ret = build2 (COMPLEX_EXPR, result_type, real, imag);
   14706                 :       61942 :           goto return_build_binary_op;
   14707                 :             :         }
   14708                 :             : 
   14709                 :             :       /* For certain operations (which identify themselves by shorten != 0)
   14710                 :             :          if both args were extended from the same smaller type,
   14711                 :             :          do the arithmetic in that type and then extend.
   14712                 :             : 
   14713                 :             :          shorten !=0 and !=1 indicates a bitwise operation.
   14714                 :             :          For them, this optimization is safe only if
   14715                 :             :          both args are zero-extended or both are sign-extended.
   14716                 :             :          Otherwise, we might change the result.
   14717                 :             :          Eg, (short)-1 | (unsigned short)-1 is (int)-1
   14718                 :             :          but calculated in (unsigned short) it would be (unsigned short)-1.  */
   14719                 :             : 
   14720                 :    14802948 :       if (shorten && none_complex)
   14721                 :             :         {
   14722                 :     1248525 :           final_type = result_type;
   14723                 :     1248525 :           result_type = shorten_binary_op (result_type, op0, op1,
   14724                 :             :                                            shorten == -1);
   14725                 :             :         }
   14726                 :             : 
   14727                 :             :       /* Shifts can be shortened if shifting right.  */
   14728                 :             : 
   14729                 :    14802948 :       if (short_shift)
   14730                 :             :         {
   14731                 :      196016 :           int unsigned_arg;
   14732                 :      196016 :           tree arg0 = get_narrower (op0, &unsigned_arg);
   14733                 :             : 
   14734                 :      196016 :           final_type = result_type;
   14735                 :             : 
   14736                 :      196016 :           if (arg0 == op0 && final_type == TREE_TYPE (op0))
   14737                 :      138308 :             unsigned_arg = TYPE_UNSIGNED (TREE_TYPE (op0));
   14738                 :             : 
   14739                 :      196016 :           if (TYPE_PRECISION (TREE_TYPE (arg0)) < TYPE_PRECISION (result_type)
   14740                 :        2666 :               && tree_int_cst_sgn (op1) > 0
   14741                 :             :               /* We can shorten only if the shift count is less than the
   14742                 :             :                  number of bits in the smaller type size.  */
   14743                 :        2666 :               && compare_tree_int (op1, TYPE_PRECISION (TREE_TYPE (arg0))) < 0
   14744                 :             :               /* We cannot drop an unsigned shift after sign-extension.  */
   14745                 :      198550 :               && (!TYPE_UNSIGNED (final_type) || unsigned_arg))
   14746                 :             :             {
   14747                 :             :               /* Do an unsigned shift if the operand was zero-extended.  */
   14748                 :        2520 :               result_type
   14749                 :        2520 :                 = c_common_signed_or_unsigned_type (unsigned_arg,
   14750                 :        2520 :                                                     TREE_TYPE (arg0));
   14751                 :             :               /* Convert value-to-be-shifted to that type.  */
   14752                 :        2520 :               if (TREE_TYPE (op0) != result_type)
   14753                 :        2520 :                 op0 = convert (result_type, op0);
   14754                 :             :               converted = 1;
   14755                 :             :             }
   14756                 :             :         }
   14757                 :             : 
   14758                 :             :       /* Comparison operations are shortened too but differently.
   14759                 :             :          They identify themselves by setting short_compare = 1.  */
   14760                 :             : 
   14761                 :    14802948 :       if (short_compare)
   14762                 :             :         {
   14763                 :             :           /* Don't write &op0, etc., because that would prevent op0
   14764                 :             :              from being kept in a register.
   14765                 :             :              Instead, make copies of the our local variables and
   14766                 :             :              pass the copies by reference, then copy them back afterward.  */
   14767                 :     2388763 :           tree xop0 = op0, xop1 = op1, xresult_type = result_type;
   14768                 :     2388763 :           enum tree_code xresultcode = resultcode;
   14769                 :     2388763 :           tree val
   14770                 :     2388763 :             = shorten_compare (location, &xop0, &xop1, &xresult_type,
   14771                 :             :                                &xresultcode);
   14772                 :             : 
   14773                 :     2388763 :           if (val != NULL_TREE)
   14774                 :             :             {
   14775                 :       15785 :               ret = val;
   14776                 :       15785 :               goto return_build_binary_op;
   14777                 :             :             }
   14778                 :             : 
   14779                 :     2372978 :           op0 = xop0, op1 = xop1;
   14780                 :     2372978 :           converted = 1;
   14781                 :     2372978 :           resultcode = xresultcode;
   14782                 :             : 
   14783                 :     2372978 :           if (c_inhibit_evaluation_warnings == 0 && !c_in_omp_for)
   14784                 :             :             {
   14785                 :     2226526 :               bool op0_maybe_const = true;
   14786                 :     2226526 :               bool op1_maybe_const = true;
   14787                 :     2226526 :               tree orig_op0_folded, orig_op1_folded;
   14788                 :             : 
   14789                 :     2226526 :               if (in_late_binary_op)
   14790                 :             :                 {
   14791                 :             :                   orig_op0_folded = orig_op0;
   14792                 :             :                   orig_op1_folded = orig_op1;
   14793                 :             :                 }
   14794                 :             :               else
   14795                 :             :                 {
   14796                 :             :                   /* Fold for the sake of possible warnings, as in
   14797                 :             :                      build_conditional_expr.  This requires the
   14798                 :             :                      "original" values to be folded, not just op0 and
   14799                 :             :                      op1.  */
   14800                 :     2220868 :                   c_inhibit_evaluation_warnings++;
   14801                 :     2220868 :                   op0 = c_fully_fold (op0, require_constant_value,
   14802                 :             :                                       &op0_maybe_const);
   14803                 :     2220868 :                   op1 = c_fully_fold (op1, require_constant_value,
   14804                 :             :                                       &op1_maybe_const);
   14805                 :     2220868 :                   c_inhibit_evaluation_warnings--;
   14806                 :     2220868 :                   orig_op0_folded = c_fully_fold (orig_op0,
   14807                 :             :                                                   require_constant_value,
   14808                 :             :                                                   NULL);
   14809                 :     2220868 :                   orig_op1_folded = c_fully_fold (orig_op1,
   14810                 :             :                                                   require_constant_value,
   14811                 :             :                                                   NULL);
   14812                 :             :                 }
   14813                 :             : 
   14814                 :     2226526 :               if (warn_sign_compare)
   14815                 :      372578 :                 warn_for_sign_compare (location, orig_op0_folded,
   14816                 :             :                                        orig_op1_folded, op0, op1,
   14817                 :             :                                        result_type, resultcode);
   14818                 :     2226526 :               if (!in_late_binary_op && !int_operands)
   14819                 :             :                 {
   14820                 :     2044534 :                   if (!op0_maybe_const || TREE_CODE (op0) != INTEGER_CST)
   14821                 :     2041020 :                     op0 = c_wrap_maybe_const (op0, !op0_maybe_const);
   14822                 :     2044534 :                   if (!op1_maybe_const || TREE_CODE (op1) != INTEGER_CST)
   14823                 :      799627 :                     op1 = c_wrap_maybe_const (op1, !op1_maybe_const);
   14824                 :             :                 }
   14825                 :             :             }
   14826                 :             :         }
   14827                 :             :     }
   14828                 :             : 
   14829                 :             :   /* At this point, RESULT_TYPE must be nonzero to avoid an error message.
   14830                 :             :      If CONVERTED is zero, both args will be converted to type RESULT_TYPE.
   14831                 :             :      Then the expression will be built.
   14832                 :             :      It will be given type FINAL_TYPE if that is nonzero;
   14833                 :             :      otherwise, it will be given type RESULT_TYPE.  */
   14834                 :             : 
   14835                 :    14972265 :   if (!result_type)
   14836                 :             :     {
   14837                 :             :       /* Favor showing any expression locations that are available. */
   14838                 :         514 :       op_location_t oploc (location, UNKNOWN_LOCATION);
   14839                 :         514 :       binary_op_rich_location richloc (oploc, orig_op0, orig_op1, true);
   14840                 :         514 :       binary_op_error (&richloc, code, TREE_TYPE (op0), TREE_TYPE (op1));
   14841                 :         514 :       return error_mark_node;
   14842                 :         514 :     }
   14843                 :             : 
   14844                 :    14971751 :   if (build_type == NULL_TREE)
   14845                 :             :     {
   14846                 :    12415854 :       build_type = result_type;
   14847                 :    12415854 :       if ((type0 != orig_type0 || type1 != orig_type1)
   14848                 :         797 :           && !boolean_op)
   14849                 :             :         {
   14850                 :         797 :           gcc_assert (may_need_excess_precision && common);
   14851                 :         797 :           semantic_result_type = c_common_type (orig_type0, orig_type1);
   14852                 :             :         }
   14853                 :             :     }
   14854                 :             : 
   14855                 :    14971751 :   if (!converted)
   14856                 :             :     {
   14857                 :    11086797 :       op0 = ep_convert_and_check (location, result_type, op0,
   14858                 :             :                                   semantic_result_type);
   14859                 :    11086797 :       op1 = ep_convert_and_check (location, result_type, op1,
   14860                 :             :                                   semantic_result_type);
   14861                 :             : 
   14862                 :             :       /* This can happen if one operand has a vector type, and the other
   14863                 :             :          has a different type.  */
   14864                 :    11086797 :       if (TREE_CODE (op0) == ERROR_MARK || TREE_CODE (op1) == ERROR_MARK)
   14865                 :           3 :         return error_mark_node;
   14866                 :             :     }
   14867                 :             : 
   14868                 :    14971748 :   if (sanitize_flags_p ((SANITIZE_SHIFT
   14869                 :             :                          | SANITIZE_DIVIDE
   14870                 :             :                          | SANITIZE_FLOAT_DIVIDE
   14871                 :             :                          | SANITIZE_SI_OVERFLOW))
   14872                 :       23269 :       && current_function_decl != NULL_TREE
   14873                 :       19806 :       && (doing_div_or_mod || doing_shift)
   14874                 :    14974673 :       && !require_constant_value)
   14875                 :             :     {
   14876                 :             :       /* OP0 and/or OP1 might have side-effects.  */
   14877                 :        2869 :       op0 = save_expr (op0);
   14878                 :        2869 :       op1 = save_expr (op1);
   14879                 :        2869 :       op0 = c_fully_fold (op0, false, NULL);
   14880                 :        2869 :       op1 = c_fully_fold (op1, false, NULL);
   14881                 :        2869 :       if (doing_div_or_mod && (sanitize_flags_p ((SANITIZE_DIVIDE
   14882                 :             :                                                   | SANITIZE_FLOAT_DIVIDE
   14883                 :             :                                                   | SANITIZE_SI_OVERFLOW))))
   14884                 :         912 :         instrument_expr = ubsan_instrument_division (location, op0, op1);
   14885                 :        1957 :       else if (doing_shift && sanitize_flags_p (SANITIZE_SHIFT))
   14886                 :        1777 :         instrument_expr = ubsan_instrument_shift (location, code, op0, op1);
   14887                 :             :     }
   14888                 :             : 
   14889                 :             :   /* Treat expressions in initializers specially as they can't trap.  */
   14890                 :    14971748 :   if (int_const_or_overflow)
   14891                 :     7717156 :     ret = (require_constant_value
   14892                 :     7717156 :            ? fold_build2_initializer_loc (location, resultcode, build_type,
   14893                 :             :                                           op0, op1)
   14894                 :     7671035 :            : fold_build2_loc (location, resultcode, build_type, op0, op1));
   14895                 :             :   else
   14896                 :     7254592 :     ret = build2 (resultcode, build_type, op0, op1);
   14897                 :    14971748 :   if (final_type != NULL_TREE)
   14898                 :     1444541 :     ret = convert (final_type, ret);
   14899                 :             : 
   14900                 :    13527207 :  return_build_binary_op:
   14901                 :    16405789 :   gcc_assert (ret != error_mark_node);
   14902                 :    16405789 :   if (TREE_CODE (ret) == INTEGER_CST && !TREE_OVERFLOW (ret) && !int_const)
   14903                 :        1744 :     ret = (int_operands
   14904                 :        1744 :            ? note_integer_operands (ret)
   14905                 :         422 :            : build1 (NOP_EXPR, TREE_TYPE (ret), ret));
   14906                 :    16404045 :   else if (TREE_CODE (ret) != INTEGER_CST && int_operands
   14907                 :       60300 :            && !in_late_binary_op)
   14908                 :       60300 :     ret = note_integer_operands (ret);
   14909                 :    16405789 :   protected_set_expr_location (ret, location);
   14910                 :             : 
   14911                 :    16405789 :   if (instrument_expr != NULL)
   14912                 :        1420 :     ret = fold_build2 (COMPOUND_EXPR, TREE_TYPE (ret),
   14913                 :             :                        instrument_expr, ret);
   14914                 :             : 
   14915                 :    16405789 :   if (semantic_result_type)
   14916                 :         891 :     ret = build1_loc (location, EXCESS_PRECISION_EXPR,
   14917                 :             :                       semantic_result_type, ret);
   14918                 :             : 
   14919                 :             :   return ret;
   14920                 :             : }
   14921                 :             : 
   14922                 :             : 
   14923                 :             : /* Convert EXPR to be a truth-value (type TYPE), validating its type for this
   14924                 :             :    purpose.  LOCATION is the source location for the expression.  */
   14925                 :             : 
   14926                 :             : tree
   14927                 :     4042050 : c_objc_common_truthvalue_conversion (location_t location, tree expr, tree type)
   14928                 :             : {
   14929                 :     4042050 :   bool int_const, int_operands;
   14930                 :             : 
   14931                 :     4042050 :   switch (TREE_CODE (TREE_TYPE (expr)))
   14932                 :             :     {
   14933                 :          72 :     case ARRAY_TYPE:
   14934                 :          72 :       error_at (location, "used array that cannot be converted to pointer where scalar is required");
   14935                 :          72 :       return error_mark_node;
   14936                 :             : 
   14937                 :          86 :     case RECORD_TYPE:
   14938                 :          86 :       error_at (location, "used struct type value where scalar is required");
   14939                 :          86 :       return error_mark_node;
   14940                 :             : 
   14941                 :          83 :     case UNION_TYPE:
   14942                 :          83 :       error_at (location, "used union type value where scalar is required");
   14943                 :          83 :       return error_mark_node;
   14944                 :             : 
   14945                 :          22 :     case VOID_TYPE:
   14946                 :          22 :       error_at (location, "void value not ignored as it ought to be");
   14947                 :          22 :       return error_mark_node;
   14948                 :             : 
   14949                 :       29525 :     case POINTER_TYPE:
   14950                 :       29525 :       if (reject_gcc_builtin (expr))
   14951                 :           3 :         return error_mark_node;
   14952                 :             :       break;
   14953                 :             : 
   14954                 :           0 :     case FUNCTION_TYPE:
   14955                 :           0 :       gcc_unreachable ();
   14956                 :             : 
   14957                 :           8 :     case VECTOR_TYPE:
   14958                 :           8 :       error_at (location, "used vector type where scalar is required");
   14959                 :           8 :       return error_mark_node;
   14960                 :             : 
   14961                 :             :     default:
   14962                 :             :       break;
   14963                 :             :     }
   14964                 :             : 
   14965                 :             :   /* Conversion of a floating constant to boolean goes through here
   14966                 :             :      and yields an integer constant expression.  Otherwise, the result
   14967                 :             :      is only an integer constant expression if the argument is.  */
   14968                 :      892342 :   int_const = ((TREE_CODE (expr) == INTEGER_CST && !TREE_OVERFLOW (expr))
   14969                 :     4041852 :                || ((TREE_CODE (expr) == REAL_CST
   14970                 :     3149136 :                     || TREE_CODE (expr) == COMPLEX_CST)
   14971                 :         374 :                    && (TREE_CODE (type) == BOOLEAN_TYPE
   14972                 :          15 :                        || (TREE_CODE (type) == ENUMERAL_TYPE
   14973                 :           5 :                            && ENUM_UNDERLYING_TYPE (type) != NULL_TREE
   14974                 :           5 :                            && (TREE_CODE (ENUM_UNDERLYING_TYPE (type))
   14975                 :             :                                == BOOLEAN_TYPE)))));
   14976                 :     4041776 :   int_operands = EXPR_INT_CONST_OPERANDS (expr);
   14977                 :      892502 :   if (int_operands && TREE_CODE (expr) != INTEGER_CST)
   14978                 :             :     {
   14979                 :         319 :       expr = remove_c_maybe_const_expr (expr);
   14980                 :         319 :       expr = build2 (NE_EXPR, type, expr,
   14981                 :         319 :                      convert (TREE_TYPE (expr), integer_zero_node));
   14982                 :         319 :       expr = note_integer_operands (expr);
   14983                 :             :     }
   14984                 :             :   else
   14985                 :             :     {
   14986                 :             :       /* ??? Should we also give an error for vectors rather than leaving
   14987                 :             :          those to give errors later?  */
   14988                 :     4041457 :       expr = c_common_truthvalue_conversion (location, expr);
   14989                 :     4041457 :       expr = fold_convert_loc (location, type, expr);
   14990                 :             :     }
   14991                 :             : 
   14992                 :     4041776 :   if (TREE_CODE (expr) == INTEGER_CST && int_operands && !int_const)
   14993                 :             :     {
   14994                 :          76 :       if (TREE_OVERFLOW (expr))
   14995                 :             :         return expr;
   14996                 :             :       else
   14997                 :          76 :         return note_integer_operands (expr);
   14998                 :             :     }
   14999                 :     4041700 :   if (TREE_CODE (expr) == INTEGER_CST && !int_const)
   15000                 :         754 :     return build1 (NOP_EXPR, TREE_TYPE (expr), expr);
   15001                 :             :   return expr;
   15002                 :             : }
   15003                 :             : 
   15004                 :             : 
   15005                 :             : /* Convert EXPR to a contained DECL, updating *TC, *TI and *SE as
   15006                 :             :    required.  */
   15007                 :             : 
   15008                 :             : tree
   15009                 :   114220542 : c_expr_to_decl (tree expr, bool *tc ATTRIBUTE_UNUSED, bool *se)
   15010                 :             : {
   15011                 :   114220542 :   if (TREE_CODE (expr) == COMPOUND_LITERAL_EXPR)
   15012                 :             :     {
   15013                 :         655 :       tree decl = COMPOUND_LITERAL_EXPR_DECL (expr);
   15014                 :             :       /* Executing a compound literal inside a function reinitializes
   15015                 :             :          it.  */
   15016                 :         655 :       if (!TREE_STATIC (decl))
   15017                 :         399 :         *se = true;
   15018                 :         655 :       return decl;
   15019                 :             :     }
   15020                 :             :   else
   15021                 :             :     return expr;
   15022                 :             : }
   15023                 :             : 
   15024                 :             : /* Generate OMP construct CODE, with BODY and CLAUSES as its compound
   15025                 :             :    statement.  LOC is the location of the construct.  */
   15026                 :             : 
   15027                 :             : tree
   15028                 :        2154 : c_finish_omp_construct (location_t loc, enum tree_code code, tree body,
   15029                 :             :                         tree clauses)
   15030                 :             : {
   15031                 :        2154 :   body = c_end_compound_stmt (loc, body, true);
   15032                 :             : 
   15033                 :        2154 :   tree stmt = make_node (code);
   15034                 :        2154 :   TREE_TYPE (stmt) = void_type_node;
   15035                 :        2154 :   OMP_BODY (stmt) = body;
   15036                 :        2154 :   OMP_CLAUSES (stmt) = clauses;
   15037                 :        2154 :   SET_EXPR_LOCATION (stmt, loc);
   15038                 :             : 
   15039                 :        2154 :   return add_stmt (stmt);
   15040                 :             : }
   15041                 :             : 
   15042                 :             : /* Generate OACC_DATA, with CLAUSES and BLOCK as its compound
   15043                 :             :    statement.  LOC is the location of the OACC_DATA.  */
   15044                 :             : 
   15045                 :             : tree
   15046                 :         497 : c_finish_oacc_data (location_t loc, tree clauses, tree block)
   15047                 :             : {
   15048                 :         497 :   tree stmt;
   15049                 :             : 
   15050                 :         497 :   block = c_end_compound_stmt (loc, block, true);
   15051                 :             : 
   15052                 :         497 :   stmt = make_node (OACC_DATA);
   15053                 :         497 :   TREE_TYPE (stmt) = void_type_node;
   15054                 :         497 :   OACC_DATA_CLAUSES (stmt) = clauses;
   15055                 :         497 :   OACC_DATA_BODY (stmt) = block;
   15056                 :         497 :   SET_EXPR_LOCATION (stmt, loc);
   15057                 :             : 
   15058                 :         497 :   return add_stmt (stmt);
   15059                 :             : }
   15060                 :             : 
   15061                 :             : /* Generate OACC_HOST_DATA, with CLAUSES and BLOCK as its compound
   15062                 :             :    statement.  LOC is the location of the OACC_HOST_DATA.  */
   15063                 :             : 
   15064                 :             : tree
   15065                 :          21 : c_finish_oacc_host_data (location_t loc, tree clauses, tree block)
   15066                 :             : {
   15067                 :          21 :   tree stmt;
   15068                 :             : 
   15069                 :          21 :   block = c_end_compound_stmt (loc, block, true);
   15070                 :             : 
   15071                 :          21 :   stmt = make_node (OACC_HOST_DATA);
   15072                 :          21 :   TREE_TYPE (stmt) = void_type_node;
   15073                 :          21 :   OACC_HOST_DATA_CLAUSES (stmt) = clauses;
   15074                 :          21 :   OACC_HOST_DATA_BODY (stmt) = block;
   15075                 :          21 :   SET_EXPR_LOCATION (stmt, loc);
   15076                 :             : 
   15077                 :          21 :   return add_stmt (stmt);
   15078                 :             : }
   15079                 :             : 
   15080                 :             : /* Like c_begin_compound_stmt, except force the retention of the BLOCK.  */
   15081                 :             : 
   15082                 :             : tree
   15083                 :       11988 : c_begin_omp_parallel (void)
   15084                 :             : {
   15085                 :       11988 :   tree block;
   15086                 :             : 
   15087                 :       11988 :   keep_next_level ();
   15088                 :       11988 :   block = c_begin_compound_stmt (true);
   15089                 :             : 
   15090                 :       11988 :   return block;
   15091                 :             : }
   15092                 :             : 
   15093                 :             : /* Generate OMP_PARALLEL, with CLAUSES and BLOCK as its compound
   15094                 :             :    statement.  LOC is the location of the OMP_PARALLEL.  */
   15095                 :             : 
   15096                 :             : tree
   15097                 :        5663 : c_finish_omp_parallel (location_t loc, tree clauses, tree block)
   15098                 :             : {
   15099                 :        5663 :   tree stmt;
   15100                 :             : 
   15101                 :        5663 :   block = c_end_compound_stmt (loc, block, true);
   15102                 :             : 
   15103                 :        5663 :   stmt = make_node (OMP_PARALLEL);
   15104                 :        5663 :   TREE_TYPE (stmt) = void_type_node;
   15105                 :        5663 :   OMP_PARALLEL_CLAUSES (stmt) = clauses;
   15106                 :        5663 :   OMP_PARALLEL_BODY (stmt) = block;
   15107                 :        5663 :   SET_EXPR_LOCATION (stmt, loc);
   15108                 :             : 
   15109                 :        5663 :   return add_stmt (stmt);
   15110                 :             : }
   15111                 :             : 
   15112                 :             : /* Like c_begin_compound_stmt, except force the retention of the BLOCK.  */
   15113                 :             : 
   15114                 :             : tree
   15115                 :         894 : c_begin_omp_task (void)
   15116                 :             : {
   15117                 :         894 :   tree block;
   15118                 :             : 
   15119                 :         894 :   keep_next_level ();
   15120                 :         894 :   block = c_begin_compound_stmt (true);
   15121                 :             : 
   15122                 :         894 :   return block;
   15123                 :             : }
   15124                 :             : 
   15125                 :             : /* Generate OMP_TASK, with CLAUSES and BLOCK as its compound
   15126                 :             :    statement.  LOC is the location of the #pragma.  */
   15127                 :             : 
   15128                 :             : tree
   15129                 :         894 : c_finish_omp_task (location_t loc, tree clauses, tree block)
   15130                 :             : {
   15131                 :         894 :   tree stmt;
   15132                 :             : 
   15133                 :         894 :   block = c_end_compound_stmt (loc, block, true);
   15134                 :             : 
   15135                 :         894 :   stmt = make_node (OMP_TASK);
   15136                 :         894 :   TREE_TYPE (stmt) = void_type_node;
   15137                 :         894 :   OMP_TASK_CLAUSES (stmt) = clauses;
   15138                 :         894 :   OMP_TASK_BODY (stmt) = block;
   15139                 :         894 :   SET_EXPR_LOCATION (stmt, loc);
   15140                 :             : 
   15141                 :         894 :   return add_stmt (stmt);
   15142                 :             : }
   15143                 :             : 
   15144                 :             : /* Generate GOMP_cancel call for #pragma omp cancel.  */
   15145                 :             : 
   15146                 :             : void
   15147                 :         213 : c_finish_omp_cancel (location_t loc, tree clauses)
   15148                 :             : {
   15149                 :         213 :   tree fn = builtin_decl_explicit (BUILT_IN_GOMP_CANCEL);
   15150                 :         213 :   int mask = 0;
   15151                 :         213 :   if (omp_find_clause (clauses, OMP_CLAUSE_PARALLEL))
   15152                 :             :     mask = 1;
   15153                 :         150 :   else if (omp_find_clause (clauses, OMP_CLAUSE_FOR))
   15154                 :             :     mask = 2;
   15155                 :         101 :   else if (omp_find_clause (clauses, OMP_CLAUSE_SECTIONS))
   15156                 :             :     mask = 4;
   15157                 :          58 :   else if (omp_find_clause (clauses, OMP_CLAUSE_TASKGROUP))
   15158                 :             :     mask = 8;
   15159                 :             :   else
   15160                 :             :     {
   15161                 :           0 :       error_at (loc, "%<#pragma omp cancel%> must specify one of "
   15162                 :             :                      "%<parallel%>, %<for%>, %<sections%> or %<taskgroup%> "
   15163                 :             :                      "clauses");
   15164                 :           0 :       return;
   15165                 :             :     }
   15166                 :         213 :   tree ifc = omp_find_clause (clauses, OMP_CLAUSE_IF);
   15167                 :         213 :   if (ifc != NULL_TREE)
   15168                 :             :     {
   15169                 :          31 :       if (OMP_CLAUSE_IF_MODIFIER (ifc) != ERROR_MARK
   15170                 :          31 :           && OMP_CLAUSE_IF_MODIFIER (ifc) != VOID_CST)
   15171                 :           2 :         error_at (OMP_CLAUSE_LOCATION (ifc),
   15172                 :             :                   "expected %<cancel%> %<if%> clause modifier");
   15173                 :             :       else
   15174                 :             :         {
   15175                 :          29 :           tree ifc2 = omp_find_clause (OMP_CLAUSE_CHAIN (ifc), OMP_CLAUSE_IF);
   15176                 :          29 :           if (ifc2 != NULL_TREE)
   15177                 :             :             {
   15178                 :           1 :               gcc_assert (OMP_CLAUSE_IF_MODIFIER (ifc) == VOID_CST
   15179                 :             :                           && OMP_CLAUSE_IF_MODIFIER (ifc2) != ERROR_MARK
   15180                 :             :                           && OMP_CLAUSE_IF_MODIFIER (ifc2) != VOID_CST);
   15181                 :           1 :               error_at (OMP_CLAUSE_LOCATION (ifc2),
   15182                 :             :                         "expected %<cancel%> %<if%> clause modifier");
   15183                 :             :             }
   15184                 :             :         }
   15185                 :             : 
   15186                 :          31 :       tree type = TREE_TYPE (OMP_CLAUSE_IF_EXPR (ifc));
   15187                 :          62 :       ifc = fold_build2_loc (OMP_CLAUSE_LOCATION (ifc), NE_EXPR,
   15188                 :          31 :                              boolean_type_node, OMP_CLAUSE_IF_EXPR (ifc),
   15189                 :             :                              build_zero_cst (type));
   15190                 :             :     }
   15191                 :             :   else
   15192                 :         182 :     ifc = boolean_true_node;
   15193                 :         213 :   tree stmt = build_call_expr_loc (loc, fn, 2,
   15194                 :         213 :                                    build_int_cst (integer_type_node, mask),
   15195                 :             :                                    ifc);
   15196                 :         213 :   add_stmt (stmt);
   15197                 :             : }
   15198                 :             : 
   15199                 :             : /* Generate GOMP_cancellation_point call for
   15200                 :             :    #pragma omp cancellation point.  */
   15201                 :             : 
   15202                 :             : void
   15203                 :         167 : c_finish_omp_cancellation_point (location_t loc, tree clauses)
   15204                 :             : {
   15205                 :         167 :   tree fn = builtin_decl_explicit (BUILT_IN_GOMP_CANCELLATION_POINT);
   15206                 :         167 :   int mask = 0;
   15207                 :         167 :   if (omp_find_clause (clauses, OMP_CLAUSE_PARALLEL))
   15208                 :             :     mask = 1;
   15209                 :         123 :   else if (omp_find_clause (clauses, OMP_CLAUSE_FOR))
   15210                 :             :     mask = 2;
   15211                 :          88 :   else if (omp_find_clause (clauses, OMP_CLAUSE_SECTIONS))
   15212                 :             :     mask = 4;
   15213                 :          53 :   else if (omp_find_clause (clauses, OMP_CLAUSE_TASKGROUP))
   15214                 :             :     mask = 8;
   15215                 :             :   else
   15216                 :             :     {
   15217                 :           1 :       error_at (loc, "%<#pragma omp cancellation point%> must specify one of "
   15218                 :             :                      "%<parallel%>, %<for%>, %<sections%> or %<taskgroup%> "
   15219                 :             :                      "clauses");
   15220                 :           1 :       return;
   15221                 :             :     }
   15222                 :         166 :   tree stmt = build_call_expr_loc (loc, fn, 1,
   15223                 :         166 :                                    build_int_cst (integer_type_node, mask));
   15224                 :         166 :   add_stmt (stmt);
   15225                 :             : }
   15226                 :             : 
   15227                 :             : /* Helper function for handle_omp_array_sections.  Called recursively
   15228                 :             :    to handle multiple array-section-subscripts.  C is the clause,
   15229                 :             :    T current expression (initially OMP_CLAUSE_DECL), which is either
   15230                 :             :    a TREE_LIST for array-section-subscript (TREE_PURPOSE is low-bound
   15231                 :             :    expression if specified, TREE_VALUE length expression if specified,
   15232                 :             :    TREE_CHAIN is what it has been specified after, or some decl.
   15233                 :             :    TYPES vector is populated with array section types, MAYBE_ZERO_LEN
   15234                 :             :    set to true if any of the array-section-subscript could have length
   15235                 :             :    of zero (explicit or implicit), FIRST_NON_ONE is the index of the
   15236                 :             :    first array-section-subscript which is known not to have length
   15237                 :             :    of one.  Given say:
   15238                 :             :    map(a[:b][2:1][:c][:2][:d][e:f][2:5])
   15239                 :             :    FIRST_NON_ONE will be 3, array-section-subscript [:b], [2:1] and [:c]
   15240                 :             :    all are or may have length of 1, array-section-subscript [:2] is the
   15241                 :             :    first one known not to have length 1.  For array-section-subscript
   15242                 :             :    <= FIRST_NON_ONE we diagnose non-contiguous arrays if low bound isn't
   15243                 :             :    0 or length isn't the array domain max + 1, for > FIRST_NON_ONE we
   15244                 :             :    can if MAYBE_ZERO_LEN is false.  MAYBE_ZERO_LEN will be true in the above
   15245                 :             :    case though, as some lengths could be zero.  */
   15246                 :             : 
   15247                 :             : static tree
   15248                 :        6305 : handle_omp_array_sections_1 (tree c, tree t, vec<tree> &types,
   15249                 :             :                              bool &maybe_zero_len, unsigned int &first_non_one,
   15250                 :             :                              enum c_omp_region_type ort)
   15251                 :             : {
   15252                 :        6305 :   tree ret, low_bound, length, type;
   15253                 :        6305 :   bool openacc = (ort & C_ORT_ACC) != 0;
   15254                 :        6305 :   if (TREE_CODE (t) != OMP_ARRAY_SECTION)
   15255                 :             :     {
   15256                 :        2942 :       if (error_operand_p (t))
   15257                 :           2 :         return error_mark_node;
   15258                 :        2940 :       c_omp_address_inspector ai (OMP_CLAUSE_LOCATION (c), t);
   15259                 :        2940 :       ret = t;
   15260                 :        2940 :       if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_AFFINITY
   15261                 :        2841 :           && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_DEPEND
   15262                 :        5467 :           && TYPE_ATOMIC (strip_array_types (TREE_TYPE (t))))
   15263                 :             :         {
   15264                 :           6 :           error_at (OMP_CLAUSE_LOCATION (c), "%<_Atomic%> %qE in %qs clause",
   15265                 :           6 :                     t, omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   15266                 :           6 :           return error_mark_node;
   15267                 :             :         }
   15268                 :        2934 :       if (!ai.check_clause (c))
   15269                 :           0 :         return error_mark_node;
   15270                 :        2934 :       else if (ai.component_access_p ()
   15271                 :        3235 :                && (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP
   15272                 :          15 :                    || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_TO
   15273                 :          11 :                    || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_FROM))
   15274                 :         301 :         t = ai.get_root_term (true);
   15275                 :             :       else
   15276                 :        2633 :         t = ai.unconverted_ref_origin ();
   15277                 :        2934 :       if (t == error_mark_node)
   15278                 :             :         return error_mark_node;
   15279                 :        2934 :       if (!VAR_P (t)
   15280                 :         715 :           && (ort == C_ORT_ACC || !EXPR_P (t))
   15281                 :         714 :           && TREE_CODE (t) != PARM_DECL)
   15282                 :             :         {
   15283                 :           5 :           if (DECL_P (t))
   15284                 :           5 :             error_at (OMP_CLAUSE_LOCATION (c),
   15285                 :             :                       "%qD is not a variable in %qs clause", t,
   15286                 :           5 :                       omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   15287                 :             :           else
   15288                 :           0 :             error_at (OMP_CLAUSE_LOCATION (c),
   15289                 :             :                       "%qE is not a variable in %qs clause", t,
   15290                 :           0 :                       omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   15291                 :           5 :           return error_mark_node;
   15292                 :             :         }
   15293                 :        2929 :       else if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_AFFINITY
   15294                 :        2831 :                && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_DEPEND
   15295                 :        5447 :                && TYPE_ATOMIC (TREE_TYPE (t)))
   15296                 :             :         {
   15297                 :           0 :           error_at (OMP_CLAUSE_LOCATION (c), "%<_Atomic%> %qD in %qs clause",
   15298                 :           0 :                     t, omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   15299                 :           0 :           return error_mark_node;
   15300                 :             :         }
   15301                 :        2929 :       else if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_AFFINITY
   15302                 :        2831 :                && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_DEPEND
   15303                 :        2518 :                && VAR_P (t)
   15304                 :        4925 :                && DECL_THREAD_LOCAL_P (t))
   15305                 :             :         {
   15306                 :           3 :           error_at (OMP_CLAUSE_LOCATION (c),
   15307                 :             :                     "%qD is threadprivate variable in %qs clause", t,
   15308                 :           3 :                     omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   15309                 :           3 :           return error_mark_node;
   15310                 :             :         }
   15311                 :        2926 :       if ((OMP_CLAUSE_CODE (c) == OMP_CLAUSE_AFFINITY
   15312                 :        2828 :            || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND)
   15313                 :         411 :           && TYPE_ATOMIC (TREE_TYPE (t))
   15314                 :        2928 :           && POINTER_TYPE_P (TREE_TYPE (t)))
   15315                 :             :         {
   15316                 :             :           /* If the array section is pointer based and the pointer
   15317                 :             :              itself is _Atomic qualified, we need to atomically load
   15318                 :             :              the pointer.  */
   15319                 :           2 :           c_expr expr;
   15320                 :           2 :           memset (&expr, 0, sizeof (expr));
   15321                 :           2 :           expr.value = ret;
   15322                 :           2 :           expr = convert_lvalue_to_rvalue (OMP_CLAUSE_LOCATION (c),
   15323                 :             :                                            expr, false, false);
   15324                 :           2 :           ret = expr.value;
   15325                 :             :         }
   15326                 :        2926 :       return ret;
   15327                 :        2940 :     }
   15328                 :             : 
   15329                 :        3363 :   ret = handle_omp_array_sections_1 (c, TREE_OPERAND (t, 0), types,
   15330                 :             :                                      maybe_zero_len, first_non_one, ort);
   15331                 :        3363 :   if (ret == error_mark_node || ret == NULL_TREE)
   15332                 :             :     return ret;
   15333                 :             : 
   15334                 :        3298 :   type = TREE_TYPE (ret);
   15335                 :        3298 :   low_bound = TREE_OPERAND (t, 1);
   15336                 :        3298 :   length = TREE_OPERAND (t, 2);
   15337                 :             : 
   15338                 :        3298 :   if (low_bound == error_mark_node || length == error_mark_node)
   15339                 :             :     return error_mark_node;
   15340                 :             : 
   15341                 :        3298 :   if (low_bound && !INTEGRAL_TYPE_P (TREE_TYPE (low_bound)))
   15342                 :             :     {
   15343                 :          13 :       error_at (OMP_CLAUSE_LOCATION (c),
   15344                 :             :                 "low bound %qE of array section does not have integral type",
   15345                 :             :                 low_bound);
   15346                 :          13 :       return error_mark_node;
   15347                 :             :     }
   15348                 :        3285 :   if (length && !INTEGRAL_TYPE_P (TREE_TYPE (length)))
   15349                 :             :     {
   15350                 :          12 :       error_at (OMP_CLAUSE_LOCATION (c),
   15351                 :             :                 "length %qE of array section does not have integral type",
   15352                 :             :                 length);
   15353                 :          12 :       return error_mark_node;
   15354                 :             :     }
   15355                 :        3273 :   if (low_bound
   15356                 :        2706 :       && TREE_CODE (low_bound) == INTEGER_CST
   15357                 :        5705 :       && TYPE_PRECISION (TREE_TYPE (low_bound))
   15358                 :        2432 :          > TYPE_PRECISION (sizetype))
   15359                 :           0 :     low_bound = fold_convert (sizetype, low_bound);
   15360                 :        3273 :   if (length
   15361                 :        3085 :       && TREE_CODE (length) == INTEGER_CST
   15362                 :        5414 :       && TYPE_PRECISION (TREE_TYPE (length))
   15363                 :        2141 :          > TYPE_PRECISION (sizetype))
   15364                 :           0 :     length = fold_convert (sizetype, length);
   15365                 :        3273 :   if (low_bound == NULL_TREE)
   15366                 :         567 :     low_bound = integer_zero_node;
   15367                 :        3273 :   if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP
   15368                 :        3273 :       && (OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_ATTACH
   15369                 :        1905 :           || OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_DETACH))
   15370                 :             :     {
   15371                 :          10 :       if (length != integer_one_node)
   15372                 :             :         {
   15373                 :           6 :           error_at (OMP_CLAUSE_LOCATION (c),
   15374                 :             :                     "expected single pointer in %qs clause",
   15375                 :             :                     user_omp_clause_code_name (c, openacc));
   15376                 :           6 :           return error_mark_node;
   15377                 :             :         }
   15378                 :             :     }
   15379                 :        3267 :   if (length != NULL_TREE)
   15380                 :             :     {
   15381                 :        3083 :       if (!integer_nonzerop (length))
   15382                 :             :         {
   15383                 :         972 :           if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_AFFINITY
   15384                 :             :               || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND
   15385                 :             :               || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION
   15386                 :             :               || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_IN_REDUCTION
   15387                 :             :               || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_TASK_REDUCTION)
   15388                 :             :             {
   15389                 :         180 :               if (integer_zerop (length))
   15390                 :             :                 {
   15391                 :          12 :                   error_at (OMP_CLAUSE_LOCATION (c),
   15392                 :             :                             "zero length array section in %qs clause",
   15393                 :          12 :                             omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   15394                 :          12 :                   return error_mark_node;
   15395                 :             :                 }
   15396                 :             :             }
   15397                 :             :           else
   15398                 :         792 :             maybe_zero_len = true;
   15399                 :             :         }
   15400                 :        3071 :       if (first_non_one == types.length ()
   15401                 :        3071 :           && (TREE_CODE (length) != INTEGER_CST || integer_onep (length)))
   15402                 :        1567 :         first_non_one++;
   15403                 :             :     }
   15404                 :        3255 :   if (TREE_CODE (type) == ARRAY_TYPE)
   15405                 :             :     {
   15406                 :        1487 :       if (length == NULL_TREE
   15407                 :        1487 :           && (TYPE_DOMAIN (type) == NULL_TREE
   15408                 :         168 :               || TYPE_MAX_VALUE (TYPE_DOMAIN (type)) == NULL_TREE))
   15409                 :             :         {
   15410                 :           8 :           error_at (OMP_CLAUSE_LOCATION (c),
   15411                 :             :                     "for unknown bound array type length expression must "
   15412                 :             :                     "be specified");
   15413                 :           8 :           return error_mark_node;
   15414                 :             :         }
   15415                 :        1479 :       if (TREE_CODE (low_bound) == INTEGER_CST
   15416                 :        1479 :           && tree_int_cst_sgn (low_bound) == -1)
   15417                 :             :         {
   15418                 :          35 :           error_at (OMP_CLAUSE_LOCATION (c),
   15419                 :             :                     "negative low bound in array section in %qs clause",
   15420                 :          35 :                     omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   15421                 :          35 :           return error_mark_node;
   15422                 :             :         }
   15423                 :        1444 :       if (length != NULL_TREE
   15424                 :        1288 :           && TREE_CODE (length) == INTEGER_CST
   15425                 :        2292 :           && tree_int_cst_sgn (length) == -1)
   15426                 :             :         {
   15427                 :          35 :           error_at (OMP_CLAUSE_LOCATION (c),
   15428                 :             :                     "negative length in array section in %qs clause",
   15429                 :          35 :                     omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   15430                 :          35 :           return error_mark_node;
   15431                 :             :         }
   15432                 :        1409 :       if (TYPE_DOMAIN (type)
   15433                 :        1398 :           && TYPE_MAX_VALUE (TYPE_DOMAIN (type))
   15434                 :        2807 :           && TREE_CODE (TYPE_MAX_VALUE (TYPE_DOMAIN (type)))
   15435                 :             :                         == INTEGER_CST)
   15436                 :             :         {
   15437                 :        1052 :           tree size
   15438                 :        1052 :             = fold_convert (sizetype, TYPE_MAX_VALUE (TYPE_DOMAIN (type)));
   15439                 :        1052 :           size = size_binop (PLUS_EXPR, size, size_one_node);
   15440                 :        1052 :           if (TREE_CODE (low_bound) == INTEGER_CST)
   15441                 :             :             {
   15442                 :         867 :               if (tree_int_cst_lt (size, low_bound))
   15443                 :             :                 {
   15444                 :          10 :                   error_at (OMP_CLAUSE_LOCATION (c),
   15445                 :             :                             "low bound %qE above array section size "
   15446                 :             :                             "in %qs clause", low_bound,
   15447                 :          10 :                             omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   15448                 :          10 :                   return error_mark_node;
   15449                 :             :                 }
   15450                 :         857 :               if (tree_int_cst_equal (size, low_bound))
   15451                 :             :                 {
   15452                 :           5 :                   if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_AFFINITY
   15453                 :             :                       || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND
   15454                 :             :                       || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION
   15455                 :             :                       || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_IN_REDUCTION
   15456                 :             :                       || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_TASK_REDUCTION)
   15457                 :             :                     {
   15458                 :           5 :                       error_at (OMP_CLAUSE_LOCATION (c),
   15459                 :             :                                 "zero length array section in %qs clause",
   15460                 :           5 :                                 omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   15461                 :           5 :                       return error_mark_node;
   15462                 :             :                     }
   15463                 :           0 :                   maybe_zero_len = true;
   15464                 :             :                 }
   15465                 :         852 :               else if (length == NULL_TREE
   15466                 :         256 :                        && first_non_one == types.length ()
   15467                 :         907 :                        && tree_int_cst_equal
   15468                 :          55 :                             (TYPE_MAX_VALUE (TYPE_DOMAIN (type)),
   15469                 :             :                              low_bound))
   15470                 :          30 :                 first_non_one++;
   15471                 :             :             }
   15472                 :         185 :           else if (length == NULL_TREE)
   15473                 :             :             {
   15474                 :           3 :               if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_AFFINITY
   15475                 :             :                   && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_DEPEND
   15476                 :             :                   && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_REDUCTION
   15477                 :             :                   && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_IN_REDUCTION
   15478                 :             :                   && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_TASK_REDUCTION)
   15479                 :           0 :                 maybe_zero_len = true;
   15480                 :           6 :               if (first_non_one == types.length ())
   15481                 :           1 :                 first_non_one++;
   15482                 :             :             }
   15483                 :        1037 :           if (length && TREE_CODE (length) == INTEGER_CST)
   15484                 :             :             {
   15485                 :         790 :               if (tree_int_cst_lt (size, length))
   15486                 :             :                 {
   15487                 :          11 :                   error_at (OMP_CLAUSE_LOCATION (c),
   15488                 :             :                             "length %qE above array section size "
   15489                 :             :                             "in %qs clause", length,
   15490                 :          11 :                             omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   15491                 :          11 :                   return error_mark_node;
   15492                 :             :                 }
   15493                 :         779 :               if (TREE_CODE (low_bound) == INTEGER_CST)
   15494                 :             :                 {
   15495                 :         681 :                   tree lbpluslen
   15496                 :         681 :                     = size_binop (PLUS_EXPR,
   15497                 :             :                                   fold_convert (sizetype, low_bound),
   15498                 :             :                                   fold_convert (sizetype, length));
   15499                 :         681 :                   if (TREE_CODE (lbpluslen) == INTEGER_CST
   15500                 :         681 :                       && tree_int_cst_lt (size, lbpluslen))
   15501                 :             :                     {
   15502                 :          10 :                       error_at (OMP_CLAUSE_LOCATION (c),
   15503                 :             :                                 "high bound %qE above array section size "
   15504                 :             :                                 "in %qs clause", lbpluslen,
   15505                 :          10 :                                 omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   15506                 :          10 :                       return error_mark_node;
   15507                 :             :                     }
   15508                 :             :                 }
   15509                 :             :             }
   15510                 :             :         }
   15511                 :         357 :       else if (length == NULL_TREE)
   15512                 :             :         {
   15513                 :          10 :           if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_AFFINITY
   15514                 :             :               && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_DEPEND
   15515                 :             :               && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_REDUCTION
   15516                 :             :               && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_IN_REDUCTION
   15517                 :             :               && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_TASK_REDUCTION)
   15518                 :           0 :             maybe_zero_len = true;
   15519                 :          20 :           if (first_non_one == types.length ())
   15520                 :          10 :             first_non_one++;
   15521                 :             :         }
   15522                 :             : 
   15523                 :             :       /* For [lb:] we will need to evaluate lb more than once.  */
   15524                 :         920 :       if (length == NULL_TREE && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_DEPEND)
   15525                 :             :         {
   15526                 :         127 :           tree lb = save_expr (low_bound);
   15527                 :         127 :           if (lb != low_bound)
   15528                 :             :             {
   15529                 :           2 :               TREE_OPERAND (t, 1) = lb;
   15530                 :           2 :               low_bound = lb;
   15531                 :             :             }
   15532                 :             :         }
   15533                 :             :     }
   15534                 :        1768 :   else if (TREE_CODE (type) == POINTER_TYPE)
   15535                 :             :     {
   15536                 :        1757 :       if (length == NULL_TREE)
   15537                 :             :         {
   15538                 :          10 :           if (TREE_CODE (ret) == PARM_DECL && C_ARRAY_PARAMETER (ret))
   15539                 :           8 :             error_at (OMP_CLAUSE_LOCATION (c),
   15540                 :             :                       "for array function parameter length expression "
   15541                 :             :                       "must be specified");
   15542                 :             :           else
   15543                 :           2 :             error_at (OMP_CLAUSE_LOCATION (c),
   15544                 :             :                       "for pointer type length expression must be specified");
   15545                 :          10 :           return error_mark_node;
   15546                 :             :         }
   15547                 :        1747 :       if (length != NULL_TREE
   15548                 :        1747 :           && TREE_CODE (length) == INTEGER_CST
   15549                 :        1243 :           && tree_int_cst_sgn (length) == -1)
   15550                 :             :         {
   15551                 :          20 :           error_at (OMP_CLAUSE_LOCATION (c),
   15552                 :             :                     "negative length in array section in %qs clause",
   15553                 :          20 :                     omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   15554                 :          20 :           return error_mark_node;
   15555                 :             :         }
   15556                 :             :       /* If there is a pointer type anywhere but in the very first
   15557                 :             :          array-section-subscript, the array section could be non-contiguous.  */
   15558                 :        1727 :       if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_DEPEND
   15559                 :        1566 :           && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_AFFINITY
   15560                 :        3264 :           && TREE_CODE (TREE_OPERAND (t, 0)) == OMP_ARRAY_SECTION)
   15561                 :             :         {
   15562                 :             :           /* If any prior dimension has a non-one length, then deem this
   15563                 :             :              array section as non-contiguous.  */
   15564                 :          25 :           for (tree d = TREE_OPERAND (t, 0);
   15565                 :          46 :                TREE_CODE (d) == OMP_ARRAY_SECTION;
   15566                 :          21 :                d = TREE_OPERAND (d, 0))
   15567                 :             :             {
   15568                 :          25 :               tree d_length = TREE_OPERAND (d, 2);
   15569                 :          25 :               if (d_length == NULL_TREE || !integer_onep (d_length))
   15570                 :             :                 {
   15571                 :           4 :                   error_at (OMP_CLAUSE_LOCATION (c),
   15572                 :             :                             "array section is not contiguous in %qs clause",
   15573                 :           4 :                             omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   15574                 :           4 :                   return error_mark_node;
   15575                 :             :                 }
   15576                 :             :             }
   15577                 :             :         }
   15578                 :             :     }
   15579                 :             :   else
   15580                 :             :     {
   15581                 :          11 :       error_at (OMP_CLAUSE_LOCATION (c),
   15582                 :             :                 "%qE does not have pointer or array type", ret);
   15583                 :          11 :       return error_mark_node;
   15584                 :             :     }
   15585                 :        3096 :   if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_DEPEND)
   15586                 :        2780 :     types.safe_push (TREE_TYPE (ret));
   15587                 :             :   /* We will need to evaluate lb more than once.  */
   15588                 :        3096 :   tree lb = save_expr (low_bound);
   15589                 :        3096 :   if (lb != low_bound)
   15590                 :             :     {
   15591                 :         258 :       TREE_OPERAND (t, 1) = lb;
   15592                 :         258 :       low_bound = lb;
   15593                 :             :     }
   15594                 :        3096 :   ret = build_array_ref (OMP_CLAUSE_LOCATION (c), ret, low_bound);
   15595                 :        3096 :   return ret;
   15596                 :             : }
   15597                 :             : 
   15598                 :             : /* Handle array sections for clause C.  */
   15599                 :             : 
   15600                 :             : static bool
   15601                 :        2942 : handle_omp_array_sections (tree &c, enum c_omp_region_type ort)
   15602                 :             : {
   15603                 :        2942 :   bool maybe_zero_len = false;
   15604                 :        2942 :   unsigned int first_non_one = 0;
   15605                 :        2942 :   auto_vec<tree, 10> types;
   15606                 :        2942 :   tree *tp = &OMP_CLAUSE_DECL (c);
   15607                 :        2942 :   if ((OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND
   15608                 :        2628 :        || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_AFFINITY)
   15609                 :         413 :       && TREE_CODE (*tp) == TREE_LIST
   15610                 :          66 :       && TREE_PURPOSE (*tp)
   15611                 :        3008 :       && TREE_CODE (TREE_PURPOSE (*tp)) == TREE_VEC)
   15612                 :          66 :     tp = &TREE_VALUE (*tp);
   15613                 :        2942 :   tree first = handle_omp_array_sections_1 (c, *tp, types,
   15614                 :             :                                             maybe_zero_len, first_non_one,
   15615                 :             :                                             ort);
   15616                 :        2942 :   if (first == error_mark_node)
   15617                 :             :     return true;
   15618                 :        2724 :   if (first == NULL_TREE)
   15619                 :             :     return false;
   15620                 :        2724 :   if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND
   15621                 :        2724 :       || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_AFFINITY)
   15622                 :             :     {
   15623                 :         336 :       tree t = *tp;
   15624                 :         336 :       tree tem = NULL_TREE;
   15625                 :             :       /* Need to evaluate side effects in the length expressions
   15626                 :             :          if any.  */
   15627                 :         336 :       while (TREE_CODE (t) == TREE_LIST)
   15628                 :             :         {
   15629                 :           0 :           if (TREE_VALUE (t) && TREE_SIDE_EFFECTS (TREE_VALUE (t)))
   15630                 :             :             {
   15631                 :           0 :               if (tem == NULL_TREE)
   15632                 :             :                 tem = TREE_VALUE (t);
   15633                 :             :               else
   15634                 :           0 :                 tem = build2 (COMPOUND_EXPR, TREE_TYPE (tem),
   15635                 :           0 :                               TREE_VALUE (t), tem);
   15636                 :             :             }
   15637                 :           0 :           t = TREE_CHAIN (t);
   15638                 :             :         }
   15639                 :         336 :       if (tem)
   15640                 :           0 :         first = build2 (COMPOUND_EXPR, TREE_TYPE (first), tem, first);
   15641                 :         336 :       first = c_fully_fold (first, false, NULL, true);
   15642                 :         336 :       *tp = first;
   15643                 :             :     }
   15644                 :             :   else
   15645                 :             :     {
   15646                 :        2388 :       unsigned int num = types.length (), i;
   15647                 :        2388 :       tree t, side_effects = NULL_TREE, size = NULL_TREE;
   15648                 :        2388 :       tree condition = NULL_TREE;
   15649                 :             : 
   15650                 :        2388 :       if (int_size_in_bytes (TREE_TYPE (first)) <= 0)
   15651                 :           3 :         maybe_zero_len = true;
   15652                 :             : 
   15653                 :        4959 :       for (i = num, t = OMP_CLAUSE_DECL (c); i > 0;
   15654                 :        2571 :            t = TREE_OPERAND (t, 0))
   15655                 :             :         {
   15656                 :        2586 :           tree low_bound = TREE_OPERAND (t, 1);
   15657                 :        2586 :           tree length = TREE_OPERAND (t, 2);
   15658                 :             : 
   15659                 :        2586 :           i--;
   15660                 :        2586 :           if (low_bound
   15661                 :        2139 :               && TREE_CODE (low_bound) == INTEGER_CST
   15662                 :        4554 :               && TYPE_PRECISION (TREE_TYPE (low_bound))
   15663                 :        1968 :                  > TYPE_PRECISION (sizetype))
   15664                 :           0 :             low_bound = fold_convert (sizetype, low_bound);
   15665                 :        2586 :           if (length
   15666                 :        2494 :               && TREE_CODE (length) == INTEGER_CST
   15667                 :        4154 :               && TYPE_PRECISION (TREE_TYPE (length))
   15668                 :        1568 :                  > TYPE_PRECISION (sizetype))
   15669                 :           0 :             length = fold_convert (sizetype, length);
   15670                 :        2586 :           if (low_bound == NULL_TREE)
   15671                 :         447 :             low_bound = integer_zero_node;
   15672                 :        2586 :           if (!maybe_zero_len && i > first_non_one)
   15673                 :             :             {
   15674                 :         109 :               if (integer_nonzerop (low_bound))
   15675                 :           6 :                 goto do_warn_noncontiguous;
   15676                 :         103 :               if (length != NULL_TREE
   15677                 :          50 :                   && TREE_CODE (length) == INTEGER_CST
   15678                 :          50 :                   && TYPE_DOMAIN (types[i])
   15679                 :          50 :                   && TYPE_MAX_VALUE (TYPE_DOMAIN (types[i]))
   15680                 :         153 :                   && TREE_CODE (TYPE_MAX_VALUE (TYPE_DOMAIN (types[i])))
   15681                 :             :                      == INTEGER_CST)
   15682                 :             :                 {
   15683                 :          50 :                   tree size;
   15684                 :          50 :                   size = size_binop (PLUS_EXPR,
   15685                 :             :                                      TYPE_MAX_VALUE (TYPE_DOMAIN (types[i])),
   15686                 :             :                                      size_one_node);
   15687                 :          50 :                   if (!tree_int_cst_equal (length, size))
   15688                 :             :                     {
   15689                 :           7 :                      do_warn_noncontiguous:
   15690                 :          26 :                       error_at (OMP_CLAUSE_LOCATION (c),
   15691                 :             :                                 "array section is not contiguous in %qs "
   15692                 :             :                                 "clause",
   15693                 :          13 :                                 omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   15694                 :        2388 :                       return true;
   15695                 :             :                     }
   15696                 :             :                 }
   15697                 :          96 :               if (length != NULL_TREE
   15698                 :          96 :                   && TREE_SIDE_EFFECTS (length))
   15699                 :             :                 {
   15700                 :           0 :                   if (side_effects == NULL_TREE)
   15701                 :             :                     side_effects = length;
   15702                 :             :                   else
   15703                 :           0 :                     side_effects = build2 (COMPOUND_EXPR,
   15704                 :           0 :                                            TREE_TYPE (side_effects),
   15705                 :             :                                            length, side_effects);
   15706                 :             :                 }
   15707                 :             :             }
   15708                 :             :           else
   15709                 :             :             {
   15710                 :        2477 :               tree l;
   15711                 :             : 
   15712                 :        2477 :               if (i > first_non_one
   15713                 :        2477 :                   && ((length && integer_nonzerop (length))
   15714                 :           0 :                       || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION
   15715                 :             :                       || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_IN_REDUCTION
   15716                 :             :                       || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_TASK_REDUCTION))
   15717                 :           0 :                 continue;
   15718                 :        2477 :               if (length)
   15719                 :        2444 :                 l = fold_convert (sizetype, length);
   15720                 :             :               else
   15721                 :             :                 {
   15722                 :          33 :                   l = size_binop (PLUS_EXPR,
   15723                 :             :                                   TYPE_MAX_VALUE (TYPE_DOMAIN (types[i])),
   15724                 :             :                                   size_one_node);
   15725                 :          33 :                   l = size_binop (MINUS_EXPR, l,
   15726                 :             :                                   fold_convert (sizetype, low_bound));
   15727                 :             :                 }
   15728                 :        2477 :               if (i > first_non_one)
   15729                 :             :                 {
   15730                 :           0 :                   l = fold_build2 (NE_EXPR, boolean_type_node, l,
   15731                 :             :                                    size_zero_node);
   15732                 :           0 :                   if (condition == NULL_TREE)
   15733                 :             :                     condition = l;
   15734                 :             :                   else
   15735                 :           0 :                     condition = fold_build2 (BIT_AND_EXPR, boolean_type_node,
   15736                 :             :                                              l, condition);
   15737                 :             :                 }
   15738                 :        2477 :               else if (size == NULL_TREE)
   15739                 :             :                 {
   15740                 :        2375 :                   size = size_in_bytes (TREE_TYPE (types[i]));
   15741                 :        2375 :                   tree eltype = TREE_TYPE (types[num - 1]);
   15742                 :        2395 :                   while (TREE_CODE (eltype) == ARRAY_TYPE)
   15743                 :          20 :                     eltype = TREE_TYPE (eltype);
   15744                 :        2375 :                   if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION
   15745                 :        2140 :                       || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_IN_REDUCTION
   15746                 :        4255 :                       || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_TASK_REDUCTION)
   15747                 :             :                     {
   15748                 :         539 :                       if (integer_zerop (size)
   15749                 :        1076 :                           || integer_zerop (size_in_bytes (eltype)))
   15750                 :             :                         {
   15751                 :           4 :                           error_at (OMP_CLAUSE_LOCATION (c),
   15752                 :             :                                     "zero length array section in %qs clause",
   15753                 :           2 :                                     omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   15754                 :           2 :                           return error_mark_node;
   15755                 :             :                         }
   15756                 :         537 :                       size = size_binop (EXACT_DIV_EXPR, size,
   15757                 :             :                                          size_in_bytes (eltype));
   15758                 :             :                     }
   15759                 :        2373 :                   size = size_binop (MULT_EXPR, size, l);
   15760                 :        2373 :                   if (condition)
   15761                 :           0 :                     size = fold_build3 (COND_EXPR, sizetype, condition,
   15762                 :             :                                         size, size_zero_node);
   15763                 :             :                 }
   15764                 :             :               else
   15765                 :         102 :                 size = size_binop (MULT_EXPR, size, l);
   15766                 :             :             }
   15767                 :             :         }
   15768                 :        2373 :       if (side_effects)
   15769                 :           0 :         size = build2 (COMPOUND_EXPR, sizetype, side_effects, size);
   15770                 :        2373 :       if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION
   15771                 :        2140 :           || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_IN_REDUCTION
   15772                 :        4253 :           || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_TASK_REDUCTION)
   15773                 :             :         {
   15774                 :         537 :           size = size_binop (MINUS_EXPR, size, size_one_node);
   15775                 :         537 :           size = c_fully_fold (size, false, NULL);
   15776                 :         537 :           size = save_expr (size);
   15777                 :         537 :           tree index_type = build_index_type (size);
   15778                 :         537 :           tree eltype = TREE_TYPE (first);
   15779                 :         549 :           while (TREE_CODE (eltype) == ARRAY_TYPE)
   15780                 :          12 :             eltype = TREE_TYPE (eltype);
   15781                 :         537 :           tree type = c_build_array_type (eltype, index_type);
   15782                 :         537 :           tree ptype = c_build_pointer_type (eltype);
   15783                 :         537 :           if (TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE)
   15784                 :         296 :             t = build_fold_addr_expr (t);
   15785                 :         537 :           tree t2 = build_fold_addr_expr (first);
   15786                 :         537 :           t2 = fold_convert_loc (OMP_CLAUSE_LOCATION (c),
   15787                 :             :                                  ptrdiff_type_node, t2);
   15788                 :         537 :           t2 = fold_build2_loc (OMP_CLAUSE_LOCATION (c), MINUS_EXPR,
   15789                 :             :                                 ptrdiff_type_node, t2,
   15790                 :         537 :                                 fold_convert_loc (OMP_CLAUSE_LOCATION (c),
   15791                 :             :                                                   ptrdiff_type_node, t));
   15792                 :         537 :           t2 = c_fully_fold (t2, false, NULL);
   15793                 :         537 :           if (tree_fits_shwi_p (t2))
   15794                 :         398 :             t = build2 (MEM_REF, type, t,
   15795                 :         398 :                         build_int_cst (ptype, tree_to_shwi (t2)));
   15796                 :             :           else
   15797                 :             :             {
   15798                 :         139 :               t2 = fold_convert_loc (OMP_CLAUSE_LOCATION (c), sizetype, t2);
   15799                 :         139 :               t = build2_loc (OMP_CLAUSE_LOCATION (c), POINTER_PLUS_EXPR,
   15800                 :         139 :                               TREE_TYPE (t), t, t2);
   15801                 :         139 :               t = build2 (MEM_REF, type, t, build_int_cst (ptype, 0));
   15802                 :             :             }
   15803                 :         537 :           OMP_CLAUSE_DECL (c) = t;
   15804                 :         537 :           return false;
   15805                 :             :         }
   15806                 :        1836 :       first = c_fully_fold (first, false, NULL);
   15807                 :        1836 :       OMP_CLAUSE_DECL (c) = first;
   15808                 :        1836 :       if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_HAS_DEVICE_ADDR)
   15809                 :             :         return false;
   15810                 :             :       /* Don't set OMP_CLAUSE_SIZE for bare attach/detach clauses.  */
   15811                 :        1825 :       if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_MAP
   15812                 :        1825 :           || (OMP_CLAUSE_MAP_KIND (c) != GOMP_MAP_ATTACH
   15813                 :        1697 :               && OMP_CLAUSE_MAP_KIND (c) != GOMP_MAP_DETACH
   15814                 :        1695 :               && OMP_CLAUSE_MAP_KIND (c) != GOMP_MAP_FORCE_DETACH))
   15815                 :             :         {
   15816                 :        1821 :           if (size)
   15817                 :        1821 :             size = c_fully_fold (size, false, NULL);
   15818                 :        1821 :           OMP_CLAUSE_SIZE (c) = size;
   15819                 :             :         }
   15820                 :             : 
   15821                 :        1825 :       if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_MAP)
   15822                 :             :         return false;
   15823                 :             : 
   15824                 :        1699 :       auto_vec<omp_addr_token *, 10> addr_tokens;
   15825                 :             : 
   15826                 :        1699 :       if (!omp_parse_expr (addr_tokens, first))
   15827                 :        1699 :         return true;
   15828                 :             : 
   15829                 :        1699 :       c_omp_address_inspector ai (OMP_CLAUSE_LOCATION (c), t);
   15830                 :             : 
   15831                 :        1699 :       tree nc = ai.expand_map_clause (c, first, addr_tokens, ort);
   15832                 :        1699 :       if (nc != error_mark_node)
   15833                 :             :         {
   15834                 :        1699 :           using namespace omp_addr_tokenizer;
   15835                 :             : 
   15836                 :        1699 :           if (ai.maybe_zero_length_array_section (c))
   15837                 :        1695 :             OMP_CLAUSE_MAP_MAYBE_ZERO_LENGTH_ARRAY_SECTION (c) = 1;
   15838                 :             : 
   15839                 :             :           /* !!! If we're accessing a base decl via chained access
   15840                 :             :              methods (e.g. multiple indirections), duplicate clause
   15841                 :             :              detection won't work properly.  Skip it in that case.  */
   15842                 :        1699 :           if ((addr_tokens[0]->type == STRUCTURE_BASE
   15843                 :        1412 :                || addr_tokens[0]->type == ARRAY_BASE)
   15844                 :        1699 :               && addr_tokens[0]->u.structure_base_kind == BASE_DECL
   15845                 :        1699 :               && addr_tokens[1]->type == ACCESS_METHOD
   15846                 :        3398 :               && omp_access_chain_p (addr_tokens, 1))
   15847                 :          27 :             c = nc;
   15848                 :             : 
   15849                 :        1699 :           return false;
   15850                 :             :         }
   15851                 :             :     }
   15852                 :             :   return false;
   15853                 :        2942 : }
   15854                 :             : 
   15855                 :             : /* Helper function of finish_omp_clauses.  Clone STMT as if we were making
   15856                 :             :    an inline call.  But, remap
   15857                 :             :    the OMP_DECL1 VAR_DECL (omp_out resp. omp_orig) to PLACEHOLDER
   15858                 :             :    and OMP_DECL2 VAR_DECL (omp_in resp. omp_priv) to DECL.  */
   15859                 :             : 
   15860                 :             : static tree
   15861                 :         510 : c_clone_omp_udr (tree stmt, tree omp_decl1, tree omp_decl2,
   15862                 :             :                  tree decl, tree placeholder)
   15863                 :             : {
   15864                 :         510 :   copy_body_data id;
   15865                 :         510 :   hash_map<tree, tree> decl_map;
   15866                 :             : 
   15867                 :         510 :   decl_map.put (omp_decl1, placeholder);
   15868                 :         510 :   decl_map.put (omp_decl2, decl);
   15869                 :         510 :   memset (&id, 0, sizeof (id));
   15870                 :         510 :   id.src_fn = DECL_CONTEXT (omp_decl1);
   15871                 :         510 :   id.dst_fn = current_function_decl;
   15872                 :         510 :   id.src_cfun = DECL_STRUCT_FUNCTION (id.src_fn);
   15873                 :         510 :   id.decl_map = &decl_map;
   15874                 :             : 
   15875                 :         510 :   id.copy_decl = copy_decl_no_change;
   15876                 :         510 :   id.transform_call_graph_edges = CB_CGE_DUPLICATE;
   15877                 :         510 :   id.transform_new_cfg = true;
   15878                 :         510 :   id.transform_return_to_modify = false;
   15879                 :         510 :   id.eh_lp_nr = 0;
   15880                 :         510 :   walk_tree (&stmt, copy_tree_body_r, &id, NULL);
   15881                 :         510 :   return stmt;
   15882                 :         510 : }
   15883                 :             : 
   15884                 :             : /* Helper function of c_finish_omp_clauses, called via walk_tree.
   15885                 :             :    Find OMP_CLAUSE_PLACEHOLDER (passed in DATA) in *TP.  */
   15886                 :             : 
   15887                 :             : static tree
   15888                 :        1123 : c_find_omp_placeholder_r (tree *tp, int *, void *data)
   15889                 :             : {
   15890                 :        1123 :   if (*tp == (tree) data)
   15891                 :          28 :     return *tp;
   15892                 :             :   return NULL_TREE;
   15893                 :             : }
   15894                 :             : 
   15895                 :             : /* Similarly, but also walk aggregate fields.  */
   15896                 :             : 
   15897                 :             : struct c_find_omp_var_s { tree var; hash_set<tree> *pset; };
   15898                 :             : 
   15899                 :             : static tree
   15900                 :         192 : c_find_omp_var_r (tree *tp, int *, void *data)
   15901                 :             : {
   15902                 :         192 :   if (*tp == ((struct c_find_omp_var_s *) data)->var)
   15903                 :             :     return *tp;
   15904                 :         184 :   if (RECORD_OR_UNION_TYPE_P (*tp))
   15905                 :             :     {
   15906                 :           2 :       tree field;
   15907                 :           2 :       hash_set<tree> *pset = ((struct c_find_omp_var_s *) data)->pset;
   15908                 :             : 
   15909                 :           2 :       for (field = TYPE_FIELDS (*tp); field;
   15910                 :           0 :            field = DECL_CHAIN (field))
   15911                 :           2 :         if (TREE_CODE (field) == FIELD_DECL)
   15912                 :             :           {
   15913                 :           2 :             tree ret = walk_tree (&DECL_FIELD_OFFSET (field),
   15914                 :             :                                   c_find_omp_var_r, data, pset);
   15915                 :           2 :             if (ret)
   15916                 :             :               return ret;
   15917                 :           2 :             ret = walk_tree (&DECL_SIZE (field), c_find_omp_var_r, data, pset);
   15918                 :           2 :             if (ret)
   15919                 :             :               return ret;
   15920                 :           2 :             ret = walk_tree (&DECL_SIZE_UNIT (field), c_find_omp_var_r, data,
   15921                 :             :                              pset);
   15922                 :           2 :             if (ret)
   15923                 :             :               return ret;
   15924                 :           2 :             ret = walk_tree (&TREE_TYPE (field), c_find_omp_var_r, data, pset);
   15925                 :           2 :             if (ret)
   15926                 :             :               return ret;
   15927                 :             :           }
   15928                 :             :     }
   15929                 :         182 :   else if (INTEGRAL_TYPE_P (*tp))
   15930                 :          27 :     return walk_tree (&TYPE_MAX_VALUE (*tp), c_find_omp_var_r, data,
   15931                 :             :                       ((struct c_find_omp_var_s *) data)->pset);
   15932                 :             :   return NULL_TREE;
   15933                 :             : }
   15934                 :             : 
   15935                 :             : /* Finish OpenMP iterators ITER.  Return true if they are errorneous
   15936                 :             :    and clauses containing them should be removed.  */
   15937                 :             : 
   15938                 :             : static bool
   15939                 :         111 : c_omp_finish_iterators (tree iter)
   15940                 :             : {
   15941                 :         111 :   bool ret = false;
   15942                 :         243 :   for (tree it = iter; it; it = TREE_CHAIN (it))
   15943                 :             :     {
   15944                 :         132 :       tree var = TREE_VEC_ELT (it, 0);
   15945                 :         132 :       tree begin = TREE_VEC_ELT (it, 1);
   15946                 :         132 :       tree end = TREE_VEC_ELT (it, 2);
   15947                 :         132 :       tree step = TREE_VEC_ELT (it, 3);
   15948                 :         132 :       tree orig_step;
   15949                 :         132 :       tree type = TREE_TYPE (var);
   15950                 :         132 :       location_t loc = DECL_SOURCE_LOCATION (var);
   15951                 :         132 :       if (type == error_mark_node)
   15952                 :             :         {
   15953                 :           0 :           ret = true;
   15954                 :          34 :           continue;
   15955                 :             :         }
   15956                 :         132 :       if (!INTEGRAL_TYPE_P (type) && !POINTER_TYPE_P (type))
   15957                 :             :         {
   15958                 :           6 :           error_at (loc, "iterator %qD has neither integral nor pointer type",
   15959                 :             :                     var);
   15960                 :           6 :           ret = true;
   15961                 :           6 :           continue;
   15962                 :             :         }
   15963                 :         126 :       else if (TYPE_ATOMIC (type))
   15964                 :             :         {
   15965                 :           2 :           error_at (loc, "iterator %qD has %<_Atomic%> qualified type", var);
   15966                 :           2 :           ret = true;
   15967                 :           2 :           continue;
   15968                 :             :         }
   15969                 :         124 :       else if (TYPE_READONLY (type))
   15970                 :             :         {
   15971                 :           4 :           error_at (loc, "iterator %qD has const qualified type", var);
   15972                 :           4 :           ret = true;
   15973                 :           4 :           continue;
   15974                 :             :         }
   15975                 :         120 :       else if (step == error_mark_node
   15976                 :         120 :                || TREE_TYPE (step) == error_mark_node)
   15977                 :             :         {
   15978                 :           0 :           ret = true;
   15979                 :           0 :           continue;
   15980                 :             :         }
   15981                 :         120 :       else if (!INTEGRAL_TYPE_P (TREE_TYPE (step)))
   15982                 :             :         {
   15983                 :           6 :           error_at (EXPR_LOC_OR_LOC (step, loc),
   15984                 :             :                     "iterator step with non-integral type");
   15985                 :           4 :           ret = true;
   15986                 :           4 :           continue;
   15987                 :             :         }
   15988                 :         116 :       begin = c_fully_fold (build_c_cast (loc, type, begin), false, NULL);
   15989                 :         116 :       end = c_fully_fold (build_c_cast (loc, type, end), false, NULL);
   15990                 :         116 :       orig_step = save_expr (c_fully_fold (step, false, NULL));
   15991                 :         116 :       tree stype = POINTER_TYPE_P (type) ? sizetype : type;
   15992                 :         116 :       step = c_fully_fold (build_c_cast (loc, stype, orig_step), false, NULL);
   15993                 :         116 :       if (POINTER_TYPE_P (type))
   15994                 :             :         {
   15995                 :          14 :           begin = save_expr (begin);
   15996                 :          14 :           step = pointer_int_sum (loc, PLUS_EXPR, begin, step);
   15997                 :          14 :           step = fold_build2_loc (loc, MINUS_EXPR, sizetype,
   15998                 :             :                                   fold_convert (sizetype, step),
   15999                 :             :                                   fold_convert (sizetype, begin));
   16000                 :          14 :           step = fold_convert (ssizetype, step);
   16001                 :             :         }
   16002                 :         116 :       if (integer_zerop (step))
   16003                 :             :         {
   16004                 :           6 :           error_at (loc, "iterator %qD has zero step", var);
   16005                 :           6 :           ret = true;
   16006                 :           6 :           continue;
   16007                 :             :         }
   16008                 :             : 
   16009                 :         110 :       if (begin == error_mark_node
   16010                 :         108 :           || end == error_mark_node
   16011                 :         106 :           || step == error_mark_node
   16012                 :         106 :           || orig_step == error_mark_node)
   16013                 :             :         {
   16014                 :           4 :           ret = true;
   16015                 :           4 :           continue;
   16016                 :             :         }
   16017                 :         106 :       hash_set<tree> pset;
   16018                 :         106 :       tree it2;
   16019                 :         123 :       for (it2 = TREE_CHAIN (it); it2; it2 = TREE_CHAIN (it2))
   16020                 :             :         {
   16021                 :          25 :           tree var2 = TREE_VEC_ELT (it2, 0);
   16022                 :          25 :           tree begin2 = TREE_VEC_ELT (it2, 1);
   16023                 :          25 :           tree end2 = TREE_VEC_ELT (it2, 2);
   16024                 :          25 :           tree step2 = TREE_VEC_ELT (it2, 3);
   16025                 :          25 :           tree type2 = TREE_TYPE (var2);
   16026                 :          25 :           location_t loc2 = DECL_SOURCE_LOCATION (var2);
   16027                 :          25 :           struct c_find_omp_var_s data = { var, &pset };
   16028                 :          25 :           if (walk_tree (&type2, c_find_omp_var_r, &data, &pset))
   16029                 :             :             {
   16030                 :           2 :               error_at (loc2,
   16031                 :             :                         "type of iterator %qD refers to outer iterator %qD",
   16032                 :             :                         var2, var);
   16033                 :          10 :               break;
   16034                 :             :             }
   16035                 :          23 :           else if (walk_tree (&begin2, c_find_omp_var_r, &data, &pset))
   16036                 :             :             {
   16037                 :           2 :               error_at (EXPR_LOC_OR_LOC (begin2, loc2),
   16038                 :             :                         "begin expression refers to outer iterator %qD", var);
   16039                 :           2 :               break;
   16040                 :             :             }
   16041                 :          21 :           else if (walk_tree (&end2, c_find_omp_var_r, &data, &pset))
   16042                 :             :             {
   16043                 :           2 :               error_at (EXPR_LOC_OR_LOC (end2, loc2),
   16044                 :             :                         "end expression refers to outer iterator %qD", var);
   16045                 :           2 :               break;
   16046                 :             :             }
   16047                 :          19 :           else if (walk_tree (&step2, c_find_omp_var_r, &data, &pset))
   16048                 :             :             {
   16049                 :           2 :               error_at (EXPR_LOC_OR_LOC (step2, loc2),
   16050                 :             :                         "step expression refers to outer iterator %qD", var);
   16051                 :           2 :               break;
   16052                 :             :             }
   16053                 :             :         }
   16054                 :         106 :       if (it2)
   16055                 :             :         {
   16056                 :           8 :           ret = true;
   16057                 :           8 :           continue;
   16058                 :             :         }
   16059                 :          98 :       TREE_VEC_ELT (it, 1) = begin;
   16060                 :          98 :       TREE_VEC_ELT (it, 2) = end;
   16061                 :          98 :       TREE_VEC_ELT (it, 3) = step;
   16062                 :          98 :       TREE_VEC_ELT (it, 4) = orig_step;
   16063                 :         106 :     }
   16064                 :         111 :   return ret;
   16065                 :             : }
   16066                 :             : 
   16067                 :             : /* Ensure that pointers are used in OpenACC attach and detach clauses.
   16068                 :             :    Return true if an error has been detected.  */
   16069                 :             : 
   16070                 :             : static bool
   16071                 :        9332 : c_oacc_check_attachments (tree c)
   16072                 :             : {
   16073                 :        9332 :   if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_MAP)
   16074                 :             :     return false;
   16075                 :             : 
   16076                 :             :   /* OpenACC attach / detach clauses must be pointers.  */
   16077                 :        6350 :   if (OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_ATTACH
   16078                 :        6350 :       || OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_DETACH)
   16079                 :             :     {
   16080                 :          64 :       tree t = OMP_CLAUSE_DECL (c);
   16081                 :             : 
   16082                 :          70 :       while (TREE_CODE (t) == OMP_ARRAY_SECTION)
   16083                 :           6 :         t = TREE_OPERAND (t, 0);
   16084                 :             : 
   16085                 :          64 :       if (TREE_CODE (TREE_TYPE (t)) != POINTER_TYPE)
   16086                 :             :         {
   16087                 :           6 :           error_at (OMP_CLAUSE_LOCATION (c), "expected pointer in %qs clause",
   16088                 :             :                     user_omp_clause_code_name (c, true));
   16089                 :           6 :           return true;
   16090                 :             :         }
   16091                 :             :     }
   16092                 :             : 
   16093                 :             :   return false;
   16094                 :             : }
   16095                 :             : 
   16096                 :             : /* For all elements of CLAUSES, validate them against their constraints.
   16097                 :             :    Remove any elements from the list that are invalid.  */
   16098                 :             : 
   16099                 :             : tree
   16100                 :       29166 : c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
   16101                 :             : {
   16102                 :       29166 :   bitmap_head generic_head, firstprivate_head, lastprivate_head;
   16103                 :       29166 :   bitmap_head aligned_head, map_head, map_field_head, map_firstprivate_head;
   16104                 :       29166 :   bitmap_head oacc_reduction_head, is_on_device_head;
   16105                 :       29166 :   tree c, t, type, *pc;
   16106                 :       29166 :   tree simdlen = NULL_TREE, safelen = NULL_TREE;
   16107                 :       29166 :   bool branch_seen = false;
   16108                 :       29166 :   bool copyprivate_seen = false;
   16109                 :       29166 :   bool mergeable_seen = false;
   16110                 :       29166 :   tree *detach_seen = NULL;
   16111                 :       29166 :   bool linear_variable_step_check = false;
   16112                 :       29166 :   tree *nowait_clause = NULL;
   16113                 :       29166 :   tree *grainsize_seen = NULL;
   16114                 :       29166 :   bool num_tasks_seen = false;
   16115                 :       29166 :   tree ordered_clause = NULL_TREE;
   16116                 :       29166 :   tree schedule_clause = NULL_TREE;
   16117                 :       29166 :   bool oacc_async = false;
   16118                 :       29166 :   tree last_iterators = NULL_TREE;
   16119                 :       29166 :   bool last_iterators_remove = false;
   16120                 :       29166 :   tree *nogroup_seen = NULL;
   16121                 :       29166 :   tree *order_clause = NULL;
   16122                 :             :   /* 1 if normal/task reduction has been seen, -1 if inscan reduction
   16123                 :             :      has been seen, -2 if mixed inscan/normal reduction diagnosed.  */
   16124                 :       29166 :   int reduction_seen = 0;
   16125                 :       29166 :   bool allocate_seen = false;
   16126                 :       29166 :   bool implicit_moved = false;
   16127                 :       29166 :   bool target_in_reduction_seen = false;
   16128                 :       29166 :   tree *full_seen = NULL;
   16129                 :       29166 :   bool partial_seen = false;
   16130                 :       29166 :   bool openacc = (ort & C_ORT_ACC) != 0;
   16131                 :       29166 :   bool init_seen = false;
   16132                 :       29166 :   bool init_use_destroy_seen = false;
   16133                 :       29166 :   tree init_no_targetsync_clause = NULL_TREE;
   16134                 :       29166 :   tree depend_clause = NULL_TREE;
   16135                 :             : 
   16136                 :       29166 :   bitmap_obstack_initialize (NULL);
   16137                 :       29166 :   bitmap_initialize (&generic_head, &bitmap_default_obstack);
   16138                 :       29166 :   bitmap_initialize (&firstprivate_head, &bitmap_default_obstack);
   16139                 :       29166 :   bitmap_initialize (&lastprivate_head, &bitmap_default_obstack);
   16140                 :       29166 :   bitmap_initialize (&aligned_head, &bitmap_default_obstack);
   16141                 :             :   /* If ort == C_ORT_OMP_DECLARE_SIMD used as uniform_head instead.  */
   16142                 :       29166 :   bitmap_initialize (&map_head, &bitmap_default_obstack);
   16143                 :       29166 :   bitmap_initialize (&map_field_head, &bitmap_default_obstack);
   16144                 :       29166 :   bitmap_initialize (&map_firstprivate_head, &bitmap_default_obstack);
   16145                 :             :   /* If ort == C_ORT_OMP used as nontemporal_head or use_device_xxx_head
   16146                 :             :      instead and for ort == C_ORT_OMP_TARGET used as in_reduction_head.  */
   16147                 :       29166 :   bitmap_initialize (&oacc_reduction_head, &bitmap_default_obstack);
   16148                 :       29166 :   bitmap_initialize (&is_on_device_head, &bitmap_default_obstack);
   16149                 :             : 
   16150                 :       29166 :   if (openacc)
   16151                 :       12252 :     for (c = clauses; c; c = OMP_CLAUSE_CHAIN (c))
   16152                 :        7244 :       if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_ASYNC)
   16153                 :             :         {
   16154                 :             :           oacc_async = true;
   16155                 :             :           break;
   16156                 :             :         }
   16157                 :             : 
   16158                 :       29166 :   tree *grp_start_p = NULL, grp_sentinel = NULL_TREE;
   16159                 :             : 
   16160                 :       76745 :   for (pc = &clauses, c = clauses; c ; c = *pc)
   16161                 :             :     {
   16162                 :       47579 :       bool remove = false;
   16163                 :       47579 :       bool need_complete = false;
   16164                 :       47579 :       bool need_implicitly_determined = false;
   16165                 :             : 
   16166                 :             :       /* We've reached the end of a list of expanded nodes.  Reset the group
   16167                 :             :          start pointer.  */
   16168                 :       47579 :       if (c == grp_sentinel)
   16169                 :        2455 :         grp_start_p = NULL;
   16170                 :             : 
   16171                 :       47579 :       switch (OMP_CLAUSE_CODE (c))
   16172                 :             :         {
   16173                 :        1137 :         case OMP_CLAUSE_SHARED:
   16174                 :        1137 :           need_implicitly_determined = true;
   16175                 :        1137 :           goto check_dup_generic;
   16176                 :             : 
   16177                 :         837 :         case OMP_CLAUSE_PRIVATE:
   16178                 :         837 :           need_complete = true;
   16179                 :         837 :           need_implicitly_determined = true;
   16180                 :         837 :           goto check_dup_generic;
   16181                 :             : 
   16182                 :        3516 :         case OMP_CLAUSE_REDUCTION:
   16183                 :        3516 :           if (reduction_seen == 0)
   16184                 :        2917 :             reduction_seen = OMP_CLAUSE_REDUCTION_INSCAN (c) ? -1 : 1;
   16185                 :         599 :           else if (reduction_seen != -2
   16186                 :        1198 :                    && reduction_seen != (OMP_CLAUSE_REDUCTION_INSCAN (c)
   16187                 :         599 :                                          ? -1 : 1))
   16188                 :             :             {
   16189                 :           2 :               error_at (OMP_CLAUSE_LOCATION (c),
   16190                 :             :                         "%<inscan%> and non-%<inscan%> %<reduction%> clauses "
   16191                 :             :                         "on the same construct");
   16192                 :           2 :               reduction_seen = -2;
   16193                 :             :             }
   16194                 :             :           /* FALLTHRU */
   16195                 :        4179 :         case OMP_CLAUSE_IN_REDUCTION:
   16196                 :        4179 :         case OMP_CLAUSE_TASK_REDUCTION:
   16197                 :        4179 :           need_implicitly_determined = true;
   16198                 :        4179 :           t = OMP_CLAUSE_DECL (c);
   16199                 :        4179 :           if (TREE_CODE (t) == OMP_ARRAY_SECTION)
   16200                 :             :             {
   16201                 :         553 :               if (handle_omp_array_sections (c, ort))
   16202                 :             :                 {
   16203                 :             :                   remove = true;
   16204                 :             :                   break;
   16205                 :             :                 }
   16206                 :             : 
   16207                 :         537 :               t = OMP_CLAUSE_DECL (c);
   16208                 :         537 :               if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION
   16209                 :         537 :                   && OMP_CLAUSE_REDUCTION_INSCAN (c))
   16210                 :             :                 {
   16211                 :           1 :                   error_at (OMP_CLAUSE_LOCATION (c),
   16212                 :             :                             "%<inscan%> %<reduction%> clause with array "
   16213                 :             :                             "section");
   16214                 :           1 :                   remove = true;
   16215                 :           1 :                   break;
   16216                 :             :                 }
   16217                 :             :             }
   16218                 :        4162 :           t = require_complete_type (OMP_CLAUSE_LOCATION (c), t);
   16219                 :        4162 :           if (t == error_mark_node)
   16220                 :             :             {
   16221                 :             :               remove = true;
   16222                 :             :               break;
   16223                 :             :             }
   16224                 :        4160 :           if (oacc_async)
   16225                 :           3 :             c_mark_addressable (t);
   16226                 :        4160 :           type = TREE_TYPE (t);
   16227                 :        4160 :           if (TREE_CODE (t) == MEM_REF)
   16228                 :         536 :             type = TREE_TYPE (type);
   16229                 :        4160 :           if (TREE_CODE (type) == ARRAY_TYPE)
   16230                 :             :             {
   16231                 :          74 :               tree oatype = type;
   16232                 :          74 :               gcc_assert (TREE_CODE (t) != MEM_REF);
   16233                 :         148 :               while (TREE_CODE (type) == ARRAY_TYPE)
   16234                 :          74 :                 type = TREE_TYPE (type);
   16235                 :          74 :               if (integer_zerop (TYPE_SIZE_UNIT (type)))
   16236                 :             :                 {
   16237                 :           1 :                   error_at (OMP_CLAUSE_LOCATION (c),
   16238                 :             :                             "%qD in %<reduction%> clause is a zero size array",
   16239                 :             :                             t);
   16240                 :           1 :                   remove = true;
   16241                 :           1 :                   break;
   16242                 :             :                 }
   16243                 :          73 :               tree size = size_binop (EXACT_DIV_EXPR, TYPE_SIZE_UNIT (oatype),
   16244                 :             :                                       TYPE_SIZE_UNIT (type));
   16245                 :          73 :               if (integer_zerop (size))
   16246                 :             :                 {
   16247                 :           1 :                   error_at (OMP_CLAUSE_LOCATION (c),
   16248                 :             :                             "%qD in %<reduction%> clause is a zero size array",
   16249                 :             :                             t);
   16250                 :           1 :                   remove = true;
   16251                 :           1 :                   break;
   16252                 :             :                 }
   16253                 :          72 :               size = size_binop (MINUS_EXPR, size, size_one_node);
   16254                 :          72 :               size = save_expr (size);
   16255                 :          72 :               tree index_type = build_index_type (size);
   16256                 :          72 :               tree atype = c_build_array_type (TYPE_MAIN_VARIANT (type),
   16257                 :             :                                                index_type);
   16258                 :          72 :               atype = c_build_qualified_type (atype, TYPE_QUALS (type));
   16259                 :          72 :               tree ptype = c_build_pointer_type (type);
   16260                 :          72 :               if (TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE)
   16261                 :          72 :                 t = build_fold_addr_expr (t);
   16262                 :          72 :               t = build2 (MEM_REF, atype, t, build_int_cst (ptype, 0));
   16263                 :          72 :               OMP_CLAUSE_DECL (c) = t;
   16264                 :             :             }
   16265                 :        4158 :           if (TYPE_ATOMIC (type))
   16266                 :             :             {
   16267                 :           3 :               error_at (OMP_CLAUSE_LOCATION (c),
   16268                 :             :                         "%<_Atomic%> %qE in %<reduction%> clause", t);
   16269                 :           3 :               remove = true;
   16270                 :           3 :               break;
   16271                 :             :             }
   16272                 :        4155 :           if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_REDUCTION
   16273                 :        4155 :               || OMP_CLAUSE_REDUCTION_TASK (c))
   16274                 :             :             {
   16275                 :             :               /* Disallow zero sized or potentially zero sized task
   16276                 :             :                  reductions.  */
   16277                 :         870 :               if (integer_zerop (TYPE_SIZE_UNIT (type)))
   16278                 :             :                 {
   16279                 :           6 :                   error_at (OMP_CLAUSE_LOCATION (c),
   16280                 :             :                             "zero sized type %qT in %qs clause", type,
   16281                 :           3 :                             omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   16282                 :           3 :                   remove = true;
   16283                 :           3 :                   break;
   16284                 :             :                 }
   16285                 :         867 :               else if (TREE_CODE (TYPE_SIZE_UNIT (type)) != INTEGER_CST)
   16286                 :             :                 {
   16287                 :           0 :                   error_at (OMP_CLAUSE_LOCATION (c),
   16288                 :             :                             "variable sized type %qT in %qs clause", type,
   16289                 :           0 :                             omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   16290                 :           0 :                   remove = true;
   16291                 :           0 :                   break;
   16292                 :             :                 }
   16293                 :             :             }
   16294                 :        4152 :           if (OMP_CLAUSE_REDUCTION_PLACEHOLDER (c) == NULL_TREE
   16295                 :        4152 :               && (FLOAT_TYPE_P (type)
   16296                 :        3600 :                   || TREE_CODE (type) == COMPLEX_TYPE))
   16297                 :             :             {
   16298                 :         340 :               enum tree_code r_code = OMP_CLAUSE_REDUCTION_CODE (c);
   16299                 :         340 :               const char *r_name = NULL;
   16300                 :             : 
   16301                 :         340 :               switch (r_code)
   16302                 :             :                 {
   16303                 :             :                 case PLUS_EXPR:
   16304                 :             :                 case MULT_EXPR:
   16305                 :             :                 case MINUS_EXPR:
   16306                 :             :                 case TRUTH_ANDIF_EXPR:
   16307                 :             :                 case TRUTH_ORIF_EXPR:
   16308                 :             :                   break;
   16309                 :          13 :                 case MIN_EXPR:
   16310                 :          13 :                   if (TREE_CODE (type) == COMPLEX_TYPE)
   16311                 :             :                     r_name = "min";
   16312                 :             :                   break;
   16313                 :          38 :                 case MAX_EXPR:
   16314                 :          38 :                   if (TREE_CODE (type) == COMPLEX_TYPE)
   16315                 :             :                     r_name = "max";
   16316                 :             :                   break;
   16317                 :           3 :                 case BIT_AND_EXPR:
   16318                 :           3 :                   r_name = "&";
   16319                 :           3 :                   break;
   16320                 :           2 :                 case BIT_XOR_EXPR:
   16321                 :           2 :                   r_name = "^";
   16322                 :           2 :                   break;
   16323                 :             :                 case BIT_IOR_EXPR:
   16324                 :             :                   r_name = "|";
   16325                 :             :                   break;
   16326                 :           0 :                 default:
   16327                 :           0 :                   gcc_unreachable ();
   16328                 :             :                 }
   16329                 :           5 :               if (r_name)
   16330                 :             :                 {
   16331                 :          12 :                   error_at (OMP_CLAUSE_LOCATION (c),
   16332                 :             :                             "%qE has invalid type for %<reduction(%s)%>",
   16333                 :             :                             t, r_name);
   16334                 :          12 :                   remove = true;
   16335                 :          12 :                   break;
   16336                 :             :                 }
   16337                 :             :             }
   16338                 :        3812 :           else if (OMP_CLAUSE_REDUCTION_PLACEHOLDER (c) == error_mark_node)
   16339                 :             :             {
   16340                 :           2 :               error_at (OMP_CLAUSE_LOCATION (c),
   16341                 :             :                         "user defined reduction not found for %qE", t);
   16342                 :           2 :               remove = true;
   16343                 :           2 :               break;
   16344                 :             :             }
   16345                 :        3810 :           else if (OMP_CLAUSE_REDUCTION_PLACEHOLDER (c))
   16346                 :             :             {
   16347                 :         277 :               tree list = OMP_CLAUSE_REDUCTION_PLACEHOLDER (c);
   16348                 :         277 :               type = TYPE_MAIN_VARIANT (type);
   16349                 :         277 :               tree placeholder = build_decl (OMP_CLAUSE_LOCATION (c),
   16350                 :             :                                              VAR_DECL, NULL_TREE, type);
   16351                 :         277 :               tree decl_placeholder = NULL_TREE;
   16352                 :         277 :               OMP_CLAUSE_REDUCTION_PLACEHOLDER (c) = placeholder;
   16353                 :         277 :               DECL_ARTIFICIAL (placeholder) = 1;
   16354                 :         277 :               DECL_IGNORED_P (placeholder) = 1;
   16355                 :         277 :               if (TREE_CODE (t) == MEM_REF)
   16356                 :             :                 {
   16357                 :          56 :                   decl_placeholder = build_decl (OMP_CLAUSE_LOCATION (c),
   16358                 :             :                                                  VAR_DECL, NULL_TREE, type);
   16359                 :          56 :                   OMP_CLAUSE_REDUCTION_DECL_PLACEHOLDER (c) = decl_placeholder;
   16360                 :          56 :                   DECL_ARTIFICIAL (decl_placeholder) = 1;
   16361                 :          56 :                   DECL_IGNORED_P (decl_placeholder) = 1;
   16362                 :             :                 }
   16363                 :         277 :               if (TREE_ADDRESSABLE (TREE_VEC_ELT (list, 0)))
   16364                 :          42 :                 c_mark_addressable (placeholder);
   16365                 :         277 :               if (TREE_ADDRESSABLE (TREE_VEC_ELT (list, 1)))
   16366                 :          76 :                 c_mark_addressable (decl_placeholder ? decl_placeholder
   16367                 :          34 :                                     : OMP_CLAUSE_DECL (c));
   16368                 :         277 :               OMP_CLAUSE_REDUCTION_MERGE (c)
   16369                 :         775 :                 = c_clone_omp_udr (TREE_VEC_ELT (list, 2),
   16370                 :         277 :                                    TREE_VEC_ELT (list, 0),
   16371                 :         277 :                                    TREE_VEC_ELT (list, 1),
   16372                 :             :                                    decl_placeholder ? decl_placeholder
   16373                 :         221 :                                    : OMP_CLAUSE_DECL (c), placeholder);
   16374                 :         277 :               OMP_CLAUSE_REDUCTION_MERGE (c)
   16375                 :         277 :                 = build3_loc (OMP_CLAUSE_LOCATION (c), BIND_EXPR,
   16376                 :             :                               void_type_node, NULL_TREE,
   16377                 :         277 :                               OMP_CLAUSE_REDUCTION_MERGE (c), NULL_TREE);
   16378                 :         277 :               TREE_SIDE_EFFECTS (OMP_CLAUSE_REDUCTION_MERGE (c)) = 1;
   16379                 :         277 :               if (TREE_VEC_LENGTH (list) == 6)
   16380                 :             :                 {
   16381                 :         233 :                   if (TREE_ADDRESSABLE (TREE_VEC_ELT (list, 3)))
   16382                 :          70 :                     c_mark_addressable (decl_placeholder ? decl_placeholder
   16383                 :          33 :                                         : OMP_CLAUSE_DECL (c));
   16384                 :         233 :                   if (TREE_ADDRESSABLE (TREE_VEC_ELT (list, 4)))
   16385                 :          27 :                     c_mark_addressable (placeholder);
   16386                 :         233 :                   tree init = TREE_VEC_ELT (list, 5);
   16387                 :         233 :                   if (init == error_mark_node)
   16388                 :         197 :                     init = DECL_INITIAL (TREE_VEC_ELT (list, 3));
   16389                 :         233 :                   OMP_CLAUSE_REDUCTION_INIT (c)
   16390                 :         651 :                     = c_clone_omp_udr (init, TREE_VEC_ELT (list, 4),
   16391                 :         233 :                                        TREE_VEC_ELT (list, 3),
   16392                 :             :                                        decl_placeholder ? decl_placeholder
   16393                 :         185 :                                        : OMP_CLAUSE_DECL (c), placeholder);
   16394                 :         233 :                   if (TREE_VEC_ELT (list, 5) == error_mark_node)
   16395                 :             :                     {
   16396                 :         197 :                       tree v = decl_placeholder ? decl_placeholder : t;
   16397                 :         197 :                       OMP_CLAUSE_REDUCTION_INIT (c)
   16398                 :         394 :                         = build2 (INIT_EXPR, TREE_TYPE (v), v,
   16399                 :         197 :                                   OMP_CLAUSE_REDUCTION_INIT (c));
   16400                 :             :                     }
   16401                 :         233 :                   if (walk_tree (&OMP_CLAUSE_REDUCTION_INIT (c),
   16402                 :             :                                  c_find_omp_placeholder_r,
   16403                 :             :                                  placeholder, NULL))
   16404                 :          28 :                     OMP_CLAUSE_REDUCTION_OMP_ORIG_REF (c) = 1;
   16405                 :             :                 }
   16406                 :             :               else
   16407                 :             :                 {
   16408                 :          44 :                   tree init;
   16409                 :          44 :                   tree v = decl_placeholder ? decl_placeholder : t;
   16410                 :          44 :                   if (AGGREGATE_TYPE_P (TREE_TYPE (v)))
   16411                 :          34 :                     init = build_constructor (TREE_TYPE (v), NULL);
   16412                 :             :                   else
   16413                 :          10 :                     init = fold_convert (TREE_TYPE (v), integer_zero_node);
   16414                 :          44 :                   OMP_CLAUSE_REDUCTION_INIT (c)
   16415                 :          88 :                     = build2 (INIT_EXPR, TREE_TYPE (v), v, init);
   16416                 :             :                 }
   16417                 :         277 :               OMP_CLAUSE_REDUCTION_INIT (c)
   16418                 :         277 :                 = build3_loc (OMP_CLAUSE_LOCATION (c), BIND_EXPR,
   16419                 :             :                               void_type_node, NULL_TREE,
   16420                 :         277 :                                OMP_CLAUSE_REDUCTION_INIT (c), NULL_TREE);
   16421                 :         277 :               TREE_SIDE_EFFECTS (OMP_CLAUSE_REDUCTION_INIT (c)) = 1;
   16422                 :             :             }
   16423                 :        4138 :           if (TREE_CODE (t) == MEM_REF)
   16424                 :             :             {
   16425                 :         607 :               if (TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (t))) == NULL_TREE
   16426                 :         607 :                   || TREE_CODE (TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (t))))
   16427                 :             :                      != INTEGER_CST)
   16428                 :             :                 {
   16429                 :           0 :                   sorry ("variable length element type in array "
   16430                 :             :                          "%<reduction%> clause");
   16431                 :           0 :                   remove = true;
   16432                 :           0 :                   break;
   16433                 :             :                 }
   16434                 :         607 :               t = TREE_OPERAND (t, 0);
   16435                 :         607 :               if (TREE_CODE (t) == POINTER_PLUS_EXPR)
   16436                 :         139 :                 t = TREE_OPERAND (t, 0);
   16437                 :         607 :               if (TREE_CODE (t) == ADDR_EXPR)
   16438                 :         367 :                 t = TREE_OPERAND (t, 0);
   16439                 :             :             }
   16440                 :        4138 :           goto check_dup_generic_t;
   16441                 :             : 
   16442                 :          24 :         case OMP_CLAUSE_COPYPRIVATE:
   16443                 :          24 :           copyprivate_seen = true;
   16444                 :          24 :           if (nowait_clause)
   16445                 :             :             {
   16446                 :           1 :               error_at (OMP_CLAUSE_LOCATION (*nowait_clause),
   16447                 :             :                         "%<nowait%> clause must not be used together "
   16448                 :             :                         "with %<copyprivate%> clause");
   16449                 :           1 :               *nowait_clause = OMP_CLAUSE_CHAIN (*nowait_clause);
   16450                 :           1 :               nowait_clause = NULL;
   16451                 :             :             }
   16452                 :          24 :           goto check_dup_generic;
   16453                 :             : 
   16454                 :          99 :         case OMP_CLAUSE_COPYIN:
   16455                 :          99 :           t = OMP_CLAUSE_DECL (c);
   16456                 :          99 :           if (!VAR_P (t) || !DECL_THREAD_LOCAL_P (t))
   16457                 :             :             {
   16458                 :           5 :               error_at (OMP_CLAUSE_LOCATION (c),
   16459                 :             :                         "%qE must be %<threadprivate%> for %<copyin%>", t);
   16460                 :           5 :               remove = true;
   16461                 :           5 :               break;
   16462                 :             :             }
   16463                 :          94 :           goto check_dup_generic;
   16464                 :             : 
   16465                 :         478 :         case OMP_CLAUSE_LINEAR:
   16466                 :         478 :           if (ort != C_ORT_OMP_DECLARE_SIMD)
   16467                 :         327 :             need_implicitly_determined = true;
   16468                 :         478 :           t = OMP_CLAUSE_DECL (c);
   16469                 :         478 :           if (ort != C_ORT_OMP_DECLARE_SIMD
   16470                 :         327 :               && OMP_CLAUSE_LINEAR_KIND (c) != OMP_CLAUSE_LINEAR_DEFAULT
   16471                 :         483 :               && OMP_CLAUSE_LINEAR_OLD_LINEAR_MODIFIER (c))
   16472                 :             :             {
   16473                 :           5 :               error_at (OMP_CLAUSE_LOCATION (c),
   16474                 :             :                         "modifier should not be specified in %<linear%> "
   16475                 :             :                         "clause on %<simd%> or %<for%> constructs when not "
   16476                 :             :                         "using OpenMP 5.2 modifiers");
   16477                 :           5 :               OMP_CLAUSE_LINEAR_KIND (c) = OMP_CLAUSE_LINEAR_DEFAULT;
   16478                 :             :             }
   16479                 :         956 :           if (!INTEGRAL_TYPE_P (TREE_TYPE (t))
   16480                 :         501 :               && TREE_CODE (TREE_TYPE (t)) != POINTER_TYPE)
   16481                 :             :             {
   16482                 :           1 :               error_at (OMP_CLAUSE_LOCATION (c),
   16483                 :             :                         "linear clause applied to non-integral non-pointer "
   16484                 :           1 :                         "variable with type %qT", TREE_TYPE (t));
   16485                 :           1 :               remove = true;
   16486                 :           1 :               break;
   16487                 :             :             }
   16488                 :         477 :           if (TYPE_ATOMIC (TREE_TYPE (t)))
   16489                 :             :             {
   16490                 :           3 :               error_at (OMP_CLAUSE_LOCATION (c),
   16491                 :             :                         "%<_Atomic%> %qD in %<linear%> clause", t);
   16492                 :           3 :               remove = true;
   16493                 :           3 :               break;
   16494                 :             :             }
   16495                 :         474 :           if (ort == C_ORT_OMP_DECLARE_SIMD)
   16496                 :             :             {
   16497                 :         150 :               tree s = OMP_CLAUSE_LINEAR_STEP (c);
   16498                 :         150 :               if (TREE_CODE (s) == PARM_DECL)
   16499                 :             :                 {
   16500                 :           9 :                   OMP_CLAUSE_LINEAR_VARIABLE_STRIDE (c) = 1;
   16501                 :             :                   /* map_head bitmap is used as uniform_head if
   16502                 :             :                      declare_simd.  */
   16503                 :           9 :                   if (!bitmap_bit_p (&map_head, DECL_UID (s)))
   16504                 :           5 :                     linear_variable_step_check = true;
   16505                 :           9 :                   goto check_dup_generic;
   16506                 :             :                 }
   16507                 :         141 :               if (TREE_CODE (s) != INTEGER_CST)
   16508                 :             :                 {
   16509                 :           7 :                   error_at (OMP_CLAUSE_LOCATION (c),
   16510                 :             :                             "%<linear%> clause step %qE is neither constant "
   16511                 :             :                             "nor a parameter", s);
   16512                 :           7 :                   remove = true;
   16513                 :           7 :                   break;
   16514                 :             :                 }
   16515                 :             :             }
   16516                 :         458 :           if (TREE_CODE (TREE_TYPE (OMP_CLAUSE_DECL (c))) == POINTER_TYPE)
   16517                 :             :             {
   16518                 :          20 :               tree s = OMP_CLAUSE_LINEAR_STEP (c);
   16519                 :          20 :               s = pointer_int_sum (OMP_CLAUSE_LOCATION (c), PLUS_EXPR,
   16520                 :          20 :                                    OMP_CLAUSE_DECL (c), s);
   16521                 :          20 :               s = fold_build2_loc (OMP_CLAUSE_LOCATION (c), MINUS_EXPR,
   16522                 :             :                                    sizetype, fold_convert (sizetype, s),
   16523                 :          20 :                                    fold_convert
   16524                 :             :                                      (sizetype, OMP_CLAUSE_DECL (c)));
   16525                 :          20 :               if (s == error_mark_node)
   16526                 :           0 :                 s = size_one_node;
   16527                 :          20 :               OMP_CLAUSE_LINEAR_STEP (c) = s;
   16528                 :             :             }
   16529                 :             :           else
   16530                 :         438 :             OMP_CLAUSE_LINEAR_STEP (c)
   16531                 :         876 :               = fold_convert (TREE_TYPE (t), OMP_CLAUSE_LINEAR_STEP (c));
   16532                 :         458 :           goto check_dup_generic;
   16533                 :             : 
   16534                 :        2872 :         check_dup_generic:
   16535                 :        2872 :           t = OMP_CLAUSE_DECL (c);
   16536                 :        7098 :         check_dup_generic_t:
   16537                 :        7098 :           if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL)
   16538                 :             :             {
   16539                 :           4 :               error_at (OMP_CLAUSE_LOCATION (c),
   16540                 :             :                         "%qE is not a variable in clause %qs", t,
   16541                 :           2 :                         omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   16542                 :           2 :               remove = true;
   16543                 :             :             }
   16544                 :        1149 :           else if ((openacc && OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION)
   16545                 :        6057 :                    || (ort == C_ORT_OMP
   16546                 :        5349 :                        && (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_USE_DEVICE_PTR
   16547                 :        5338 :                            || (OMP_CLAUSE_CODE (c)
   16548                 :             :                                == OMP_CLAUSE_USE_DEVICE_ADDR)))
   16549                 :       13106 :                    || (ort == C_ORT_OMP_TARGET
   16550                 :         338 :                        && OMP_CLAUSE_CODE (c) == OMP_CLAUSE_IN_REDUCTION))
   16551                 :             :             {
   16552                 :        1196 :               if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_IN_REDUCTION
   16553                 :        1196 :                   && (bitmap_bit_p (&generic_head, DECL_UID (t))
   16554                 :         109 :                       || bitmap_bit_p (&firstprivate_head, DECL_UID (t))))
   16555                 :             :                 {
   16556                 :           2 :                   error_at (OMP_CLAUSE_LOCATION (c),
   16557                 :             :                             "%qD appears more than once in data-sharing "
   16558                 :             :                             "clauses", t);
   16559                 :           2 :                   remove = true;
   16560                 :           2 :                   break;
   16561                 :             :                 }
   16562                 :        1194 :               if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_IN_REDUCTION)
   16563                 :         108 :                 target_in_reduction_seen = true;
   16564                 :        1194 :               if (bitmap_bit_p (&oacc_reduction_head, DECL_UID (t)))
   16565                 :             :                 {
   16566                 :           4 :                   error_at (OMP_CLAUSE_LOCATION (c),
   16567                 :             :                             openacc
   16568                 :             :                             ? "%qD appears more than once in reduction clauses"
   16569                 :             :                             : "%qD appears more than once in data clauses",
   16570                 :             :                             t);
   16571                 :           2 :                   remove = true;
   16572                 :             :                 }
   16573                 :             :               else
   16574                 :        1192 :                 bitmap_set_bit (&oacc_reduction_head, DECL_UID (t));
   16575                 :             :             }
   16576                 :        5900 :           else if (bitmap_bit_p (&generic_head, DECL_UID (t))
   16577                 :        5878 :                    || bitmap_bit_p (&firstprivate_head, DECL_UID (t))
   16578                 :        5877 :                    || bitmap_bit_p (&lastprivate_head, DECL_UID (t))
   16579                 :       11777 :                    || bitmap_bit_p (&map_firstprivate_head, DECL_UID (t)))
   16580                 :             :             {
   16581                 :          23 :               error_at (OMP_CLAUSE_LOCATION (c),
   16582                 :             :                         "%qE appears more than once in data clauses", t);
   16583                 :          23 :               remove = true;
   16584                 :             :             }
   16585                 :        5877 :           else if ((OMP_CLAUSE_CODE (c) == OMP_CLAUSE_PRIVATE
   16586                 :             :                     || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_HAS_DEVICE_ADDR
   16587                 :             :                     || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_IS_DEVICE_PTR)
   16588                 :        1036 :                    && bitmap_bit_p (&map_head, DECL_UID (t)))
   16589                 :             :             {
   16590                 :           3 :               if (openacc)
   16591                 :           0 :                 error_at (OMP_CLAUSE_LOCATION (c),
   16592                 :             :                           "%qD appears more than once in data clauses", t);
   16593                 :             :               else
   16594                 :           3 :                 error_at (OMP_CLAUSE_LOCATION (c),
   16595                 :             :                           "%qD appears both in data and map clauses", t);
   16596                 :             :               remove = true;
   16597                 :             :             }
   16598                 :             :           else
   16599                 :        5874 :             bitmap_set_bit (&generic_head, DECL_UID (t));
   16600                 :             :           break;
   16601                 :             : 
   16602                 :        1320 :         case OMP_CLAUSE_FIRSTPRIVATE:
   16603                 :        1320 :           if (OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT (c) && !implicit_moved)
   16604                 :             :             {
   16605                 :         186 :             move_implicit:
   16606                 :         186 :               implicit_moved = true;
   16607                 :             :               /* Move firstprivate and map clauses with
   16608                 :             :                  OMP_CLAUSE_{FIRSTPRIVATE,MAP}_IMPLICIT set to the end of
   16609                 :             :                  clauses chain.  */
   16610                 :         186 :               tree cl1 = NULL_TREE, cl2 = NULL_TREE;
   16611                 :         186 :               tree *pc1 = pc, *pc2 = &cl1, *pc3 = &cl2;
   16612                 :        1072 :               while (*pc1)
   16613                 :         886 :                 if (OMP_CLAUSE_CODE (*pc1) == OMP_CLAUSE_FIRSTPRIVATE
   16614                 :         886 :                     && OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT (*pc1))
   16615                 :             :                   {
   16616                 :         113 :                     *pc3 = *pc1;
   16617                 :         113 :                     pc3 = &OMP_CLAUSE_CHAIN (*pc3);
   16618                 :         113 :                     *pc1 = OMP_CLAUSE_CHAIN (*pc1);
   16619                 :             :                   }
   16620                 :         773 :                 else if (OMP_CLAUSE_CODE (*pc1) == OMP_CLAUSE_MAP
   16621                 :         773 :                          && OMP_CLAUSE_MAP_IMPLICIT (*pc1))
   16622                 :             :                   {
   16623                 :         164 :                     *pc2 = *pc1;
   16624                 :         164 :                     pc2 = &OMP_CLAUSE_CHAIN (*pc2);
   16625                 :         164 :                     *pc1 = OMP_CLAUSE_CHAIN (*pc1);
   16626                 :             :                   }
   16627                 :             :                 else
   16628                 :         609 :                   pc1 = &OMP_CLAUSE_CHAIN (*pc1);
   16629                 :         186 :               *pc3 = NULL;
   16630                 :         186 :               *pc2 = cl2;
   16631                 :         186 :               *pc1 = cl1;
   16632                 :         186 :               continue;
   16633                 :         186 :             }
   16634                 :        1225 :           t = OMP_CLAUSE_DECL (c);
   16635                 :        1225 :           need_complete = true;
   16636                 :        1225 :           need_implicitly_determined = true;
   16637                 :        1225 :           if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL)
   16638                 :             :             {
   16639                 :           1 :               error_at (OMP_CLAUSE_LOCATION (c),
   16640                 :             :                         "%qE is not a variable in clause %<firstprivate%>", t);
   16641                 :           1 :               remove = true;
   16642                 :             :             }
   16643                 :        1224 :           else if (OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT (c)
   16644                 :         113 :                    && !OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT_TARGET (c)
   16645                 :        1330 :                    && bitmap_bit_p (&map_firstprivate_head, DECL_UID (t)))
   16646                 :             :             remove = true;
   16647                 :        1224 :           else if (bitmap_bit_p (&generic_head, DECL_UID (t))
   16648                 :        1222 :                    || bitmap_bit_p (&firstprivate_head, DECL_UID (t))
   16649                 :        2445 :                    || bitmap_bit_p (&map_firstprivate_head, DECL_UID (t)))
   16650                 :             :             {
   16651                 :           4 :               error_at (OMP_CLAUSE_LOCATION (c),
   16652                 :             :                         "%qE appears more than once in data clauses", t);
   16653                 :           4 :               remove = true;
   16654                 :             :             }
   16655                 :        1220 :           else if (bitmap_bit_p (&map_head, DECL_UID (t))
   16656                 :        1220 :                    || bitmap_bit_p (&map_field_head, DECL_UID (t)))
   16657                 :             :             {
   16658                 :           7 :               if (openacc)
   16659                 :           0 :                 error_at (OMP_CLAUSE_LOCATION (c),
   16660                 :             :                           "%qD appears more than once in data clauses", t);
   16661                 :           7 :               else if (OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT (c)
   16662                 :           7 :                        && !OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT_TARGET (c))
   16663                 :             :                 /* Silently drop the clause.  */;
   16664                 :             :               else
   16665                 :           6 :                 error_at (OMP_CLAUSE_LOCATION (c),
   16666                 :             :                           "%qD appears both in data and map clauses", t);
   16667                 :             :               remove = true;
   16668                 :             :             }
   16669                 :             :           else
   16670                 :        1213 :             bitmap_set_bit (&firstprivate_head, DECL_UID (t));
   16671                 :             :           break;
   16672                 :             : 
   16673                 :        1522 :         case OMP_CLAUSE_LASTPRIVATE:
   16674                 :        1522 :           t = OMP_CLAUSE_DECL (c);
   16675                 :        1522 :           need_complete = true;
   16676                 :        1522 :           need_implicitly_determined = true;
   16677                 :        1522 :           if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL)
   16678                 :             :             {
   16679                 :           0 :               error_at (OMP_CLAUSE_LOCATION (c),
   16680                 :             :                         "%qE is not a variable in clause %<lastprivate%>", t);
   16681                 :           0 :               remove = true;
   16682                 :             :             }
   16683                 :        1522 :           else if (bitmap_bit_p (&generic_head, DECL_UID (t))
   16684                 :        1522 :                    || bitmap_bit_p (&lastprivate_head, DECL_UID (t)))
   16685                 :             :             {
   16686                 :           3 :               error_at (OMP_CLAUSE_LOCATION (c),
   16687                 :             :                      "%qE appears more than once in data clauses", t);
   16688                 :           3 :               remove = true;
   16689                 :             :             }
   16690                 :             :           else
   16691                 :        1519 :             bitmap_set_bit (&lastprivate_head, DECL_UID (t));
   16692                 :             :           break;
   16693                 :             : 
   16694                 :         253 :         case OMP_CLAUSE_ALIGNED:
   16695                 :         253 :           t = OMP_CLAUSE_DECL (c);
   16696                 :         253 :           if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL)
   16697                 :             :             {
   16698                 :           0 :               error_at (OMP_CLAUSE_LOCATION (c),
   16699                 :             :                         "%qE is not a variable in %<aligned%> clause", t);
   16700                 :           0 :               remove = true;
   16701                 :             :             }
   16702                 :         289 :           else if (!POINTER_TYPE_P (TREE_TYPE (t))
   16703                 :         289 :                    && TREE_CODE (TREE_TYPE (t)) != ARRAY_TYPE)
   16704                 :             :             {
   16705                 :           7 :               error_at (OMP_CLAUSE_LOCATION (c),
   16706                 :             :                         "%qE in %<aligned%> clause is neither a pointer nor "
   16707                 :             :                         "an array", t);
   16708                 :           7 :               remove = true;
   16709                 :             :             }
   16710                 :         246 :           else if (TYPE_ATOMIC (TREE_TYPE (t)))
   16711                 :             :             {
   16712                 :           1 :               error_at (OMP_CLAUSE_LOCATION (c),
   16713                 :             :                         "%<_Atomic%> %qD in %<aligned%> clause", t);
   16714                 :           1 :               remove = true;
   16715                 :           1 :               break;
   16716                 :             :             }
   16717                 :         245 :           else if (bitmap_bit_p (&aligned_head, DECL_UID (t)))
   16718                 :             :             {
   16719                 :           0 :               error_at (OMP_CLAUSE_LOCATION (c),
   16720                 :             :                         "%qE appears more than once in %<aligned%> clauses",
   16721                 :             :                         t);
   16722                 :           0 :               remove = true;
   16723                 :             :             }
   16724                 :             :           else
   16725                 :         245 :             bitmap_set_bit (&aligned_head, DECL_UID (t));
   16726                 :             :           break;
   16727                 :             : 
   16728                 :         125 :         case OMP_CLAUSE_NONTEMPORAL:
   16729                 :         125 :           t = OMP_CLAUSE_DECL (c);
   16730                 :         125 :           if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL)
   16731                 :             :             {
   16732                 :           0 :               error_at (OMP_CLAUSE_LOCATION (c),
   16733                 :             :                         "%qE is not a variable in %<nontemporal%> clause", t);
   16734                 :           0 :               remove = true;
   16735                 :             :             }
   16736                 :         125 :           else if (bitmap_bit_p (&oacc_reduction_head, DECL_UID (t)))
   16737                 :             :             {
   16738                 :           2 :               error_at (OMP_CLAUSE_LOCATION (c),
   16739                 :             :                         "%qE appears more than once in %<nontemporal%> "
   16740                 :             :                         "clauses", t);
   16741                 :           2 :               remove = true;
   16742                 :             :             }
   16743                 :             :           else
   16744                 :         123 :             bitmap_set_bit (&oacc_reduction_head, DECL_UID (t));
   16745                 :             :           break;
   16746                 :             : 
   16747                 :         786 :         case OMP_CLAUSE_ALLOCATE:
   16748                 :         786 :           t = OMP_CLAUSE_DECL (c);
   16749                 :         786 :           if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL)
   16750                 :             :             {
   16751                 :           1 :               error_at (OMP_CLAUSE_LOCATION (c),
   16752                 :             :                         "%qE is not a variable in %<allocate%> clause", t);
   16753                 :           1 :               remove = true;
   16754                 :             :             }
   16755                 :         785 :           else if (bitmap_bit_p (&aligned_head, DECL_UID (t)))
   16756                 :             :             {
   16757                 :           2 :               warning_at (OMP_CLAUSE_LOCATION (c), OPT_Wopenmp,
   16758                 :             :                           "%qE appears more than once in %<allocate%> clauses",
   16759                 :             :                           t);
   16760                 :           2 :               remove = true;
   16761                 :             :             }
   16762                 :             :           else
   16763                 :             :             {
   16764                 :         783 :               bitmap_set_bit (&aligned_head, DECL_UID (t));
   16765                 :         783 :               if (!OMP_CLAUSE_ALLOCATE_COMBINED (c))
   16766                 :         684 :                 allocate_seen = true;
   16767                 :             :             }
   16768                 :             :           break;
   16769                 :             : 
   16770                 :         355 :         case OMP_CLAUSE_DOACROSS:
   16771                 :         355 :           t = OMP_CLAUSE_DECL (c);
   16772                 :         355 :           if (t == NULL_TREE)
   16773                 :             :             break;
   16774                 :         168 :           if (OMP_CLAUSE_DOACROSS_KIND (c) == OMP_CLAUSE_DOACROSS_SINK)
   16775                 :             :             {
   16776                 :         168 :               gcc_assert (TREE_CODE (t) == TREE_LIST);
   16777                 :        1313 :               for (; t; t = TREE_CHAIN (t))
   16778                 :             :                 {
   16779                 :        1145 :                   tree decl = TREE_VALUE (t);
   16780                 :        1145 :                   if (TREE_CODE (TREE_TYPE (decl)) == POINTER_TYPE)
   16781                 :             :                     {
   16782                 :           3 :                       tree offset = TREE_PURPOSE (t);
   16783                 :           3 :                       bool neg = wi::neg_p (wi::to_wide (offset));
   16784                 :           3 :                       offset = fold_unary (ABS_EXPR, TREE_TYPE (offset), offset);
   16785                 :           6 :                       tree t2 = pointer_int_sum (OMP_CLAUSE_LOCATION (c),
   16786                 :             :                                                  neg ? MINUS_EXPR : PLUS_EXPR,
   16787                 :             :                                                  decl, offset);
   16788                 :           3 :                       t2 = fold_build2_loc (OMP_CLAUSE_LOCATION (c), MINUS_EXPR,
   16789                 :             :                                             sizetype,
   16790                 :             :                                             fold_convert (sizetype, t2),
   16791                 :             :                                             fold_convert (sizetype, decl));
   16792                 :           3 :                       if (t2 == error_mark_node)
   16793                 :             :                         {
   16794                 :             :                           remove = true;
   16795                 :             :                           break;
   16796                 :             :                         }
   16797                 :           3 :                       TREE_PURPOSE (t) = t2;
   16798                 :             :                     }
   16799                 :             :                 }
   16800                 :             :               break;
   16801                 :             :             }
   16802                 :           0 :           gcc_unreachable ();
   16803                 :         713 :         case OMP_CLAUSE_DEPEND:
   16804                 :         713 :           depend_clause = c;
   16805                 :             :           /* FALLTHRU */
   16806                 :         870 :         case OMP_CLAUSE_AFFINITY:
   16807                 :         870 :           t = OMP_CLAUSE_DECL (c);
   16808                 :         870 :           if (TREE_CODE (t) == TREE_LIST
   16809                 :         131 :               && TREE_PURPOSE (t)
   16810                 :        1001 :               && TREE_CODE (TREE_PURPOSE (t)) == TREE_VEC)
   16811                 :             :             {
   16812                 :         131 :               if (TREE_PURPOSE (t) != last_iterators)
   16813                 :         111 :                 last_iterators_remove
   16814                 :         111 :                   = c_omp_finish_iterators (TREE_PURPOSE (t));
   16815                 :         131 :               last_iterators = TREE_PURPOSE (t);
   16816                 :         131 :               t = TREE_VALUE (t);
   16817                 :         131 :               if (last_iterators_remove)
   16818                 :          34 :                 t = error_mark_node;
   16819                 :             :             }
   16820                 :             :           else
   16821                 :             :             last_iterators = NULL_TREE;
   16822                 :         870 :           if (TREE_CODE (t) == OMP_ARRAY_SECTION)
   16823                 :             :             {
   16824                 :         413 :               if (handle_omp_array_sections (c, ort))
   16825                 :             :                 remove = true;
   16826                 :         336 :               else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND
   16827                 :         336 :                        && OMP_CLAUSE_DEPEND_KIND (c) == OMP_CLAUSE_DEPEND_DEPOBJ)
   16828                 :             :                 {
   16829                 :           1 :                   error_at (OMP_CLAUSE_LOCATION (c),
   16830                 :             :                             "%<depend%> clause with %<depobj%> dependence "
   16831                 :             :                             "type on array section");
   16832                 :           1 :                   remove = true;
   16833                 :             :                 }
   16834                 :             :               break;
   16835                 :             :             }
   16836                 :         457 :           if (t == error_mark_node)
   16837                 :             :             remove = true;
   16838                 :         423 :           else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND
   16839                 :         423 :                    && t == ridpointers[RID_OMP_ALL_MEMORY])
   16840                 :             :             {
   16841                 :          15 :               if (OMP_CLAUSE_DEPEND_KIND (c) != OMP_CLAUSE_DEPEND_OUT
   16842                 :          15 :                   && OMP_CLAUSE_DEPEND_KIND (c) != OMP_CLAUSE_DEPEND_INOUT)
   16843                 :             :                 {
   16844                 :           3 :                   error_at (OMP_CLAUSE_LOCATION (c),
   16845                 :             :                             "%<omp_all_memory%> used with %<depend%> kind "
   16846                 :             :                             "other than %<out%> or %<inout%>");
   16847                 :           3 :                   remove = true;
   16848                 :             :                 }
   16849                 :             :             }
   16850                 :         408 :           else if (!lvalue_p (t))
   16851                 :             :             {
   16852                 :           6 :               error_at (OMP_CLAUSE_LOCATION (c),
   16853                 :             :                         "%qE is not lvalue expression nor array section in "
   16854                 :             :                         "%qs clause", t,
   16855                 :           3 :                         omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   16856                 :           3 :               remove = true;
   16857                 :             :             }
   16858                 :         405 :           else if (TREE_CODE (t) == COMPONENT_REF
   16859                 :         405 :                    && DECL_C_BIT_FIELD (TREE_OPERAND (t, 1)))
   16860                 :             :             {
   16861                 :           2 :               gcc_assert (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND
   16862                 :             :                           || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_AFFINITY);
   16863                 :           2 :               error_at (OMP_CLAUSE_LOCATION (c),
   16864                 :             :                         "bit-field %qE in %qs clause", t,
   16865                 :           2 :                         omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   16866                 :           2 :               remove = true;
   16867                 :             :             }
   16868                 :         403 :           else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND
   16869                 :         403 :                    && OMP_CLAUSE_DEPEND_KIND (c) == OMP_CLAUSE_DEPEND_DEPOBJ)
   16870                 :             :             {
   16871                 :          20 :               if (!c_omp_depend_t_p (TREE_TYPE (t)))
   16872                 :             :                 {
   16873                 :           2 :                   error_at (OMP_CLAUSE_LOCATION (c),
   16874                 :             :                             "%qE does not have %<omp_depend_t%> type in "
   16875                 :             :                             "%<depend%> clause with %<depobj%> dependence "
   16876                 :             :                             "type", t);
   16877                 :           2 :                   remove = true;
   16878                 :             :                 }
   16879                 :             :             }
   16880                 :         383 :           else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND
   16881                 :         383 :                    && c_omp_depend_t_p (TREE_TYPE (t)))
   16882                 :             :             {
   16883                 :           2 :               error_at (OMP_CLAUSE_LOCATION (c),
   16884                 :             :                         "%qE should not have %<omp_depend_t%> type in "
   16885                 :             :                         "%<depend%> clause with dependence type other than "
   16886                 :             :                         "%<depobj%>", t);
   16887                 :           2 :               remove = true;
   16888                 :             :             }
   16889                 :          12 :           if (!remove)
   16890                 :             :             {
   16891                 :         411 :               if (t == ridpointers[RID_OMP_ALL_MEMORY])
   16892                 :          12 :                 t = null_pointer_node;
   16893                 :             :               else
   16894                 :             :                 {
   16895                 :         399 :                   tree addr = build_unary_op (OMP_CLAUSE_LOCATION (c),
   16896                 :             :                                               ADDR_EXPR, t, false);
   16897                 :         399 :                   if (addr == error_mark_node)
   16898                 :             :                     {
   16899                 :             :                       remove = true;
   16900                 :             :                       break;
   16901                 :             :                     }
   16902                 :         399 :                   t = build_indirect_ref (OMP_CLAUSE_LOCATION (c), addr,
   16903                 :             :                                           RO_UNARY_STAR);
   16904                 :         399 :                   if (t == error_mark_node)
   16905                 :             :                     {
   16906                 :             :                       remove = true;
   16907                 :             :                       break;
   16908                 :             :                     }
   16909                 :             :                 }
   16910                 :         411 :               if (TREE_CODE (OMP_CLAUSE_DECL (c)) == TREE_LIST
   16911                 :          31 :                   && TREE_PURPOSE (OMP_CLAUSE_DECL (c))
   16912                 :         442 :                   && (TREE_CODE (TREE_PURPOSE (OMP_CLAUSE_DECL (c)))
   16913                 :             :                       == TREE_VEC))
   16914                 :          31 :                 TREE_VALUE (OMP_CLAUSE_DECL (c)) = t;
   16915                 :             :               else
   16916                 :         380 :                 OMP_CLAUSE_DECL (c) = t;
   16917                 :             :             }
   16918                 :             :           break;
   16919                 :             : 
   16920                 :        6471 :         case OMP_CLAUSE_MAP:
   16921                 :        6471 :           if (OMP_CLAUSE_MAP_IMPLICIT (c) && !implicit_moved)
   16922                 :          91 :             goto move_implicit;
   16923                 :        6380 :           if (OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_PUSH_MAPPER_NAME
   16924                 :        6380 :               || OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_POP_MAPPER_NAME)
   16925                 :             :             {
   16926                 :             :               remove = true;
   16927                 :             :               break;
   16928                 :             :             }
   16929                 :             :           /* FALLTHRU */
   16930                 :        9356 :         case OMP_CLAUSE_TO:
   16931                 :        9356 :         case OMP_CLAUSE_FROM:
   16932                 :        9356 :         case OMP_CLAUSE__CACHE_:
   16933                 :        9356 :           {
   16934                 :        9356 :             using namespace omp_addr_tokenizer;
   16935                 :        9356 :             auto_vec<omp_addr_token *, 10> addr_tokens;
   16936                 :             : 
   16937                 :        9356 :             t = OMP_CLAUSE_DECL (c);
   16938                 :        9356 :             if (TREE_CODE (t) == OMP_ARRAY_SECTION)
   16939                 :             :               {
   16940                 :        1965 :                 grp_start_p = pc;
   16941                 :        1965 :                 grp_sentinel = OMP_CLAUSE_CHAIN (c);
   16942                 :             : 
   16943                 :        1965 :                 if (handle_omp_array_sections (c, ort))
   16944                 :             :                   remove = true;
   16945                 :             :                 else
   16946                 :             :                   {
   16947                 :        1825 :                     t = OMP_CLAUSE_DECL (c);
   16948                 :        1825 :                     if (!omp_mappable_type (TREE_TYPE (t)))
   16949                 :             :                       {
   16950                 :           2 :                         error_at (OMP_CLAUSE_LOCATION (c),
   16951                 :             :                                   "array section does not have mappable type "
   16952                 :             :                                   "in %qs clause",
   16953                 :           1 :                                   omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   16954                 :           1 :                         remove = true;
   16955                 :             :                       }
   16956                 :        1824 :                     else if (TYPE_ATOMIC (TREE_TYPE (t)))
   16957                 :             :                       {
   16958                 :           2 :                         error_at (OMP_CLAUSE_LOCATION (c),
   16959                 :             :                                   "%<_Atomic%> %qE in %qs clause", t,
   16960                 :           1 :                                   omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   16961                 :           1 :                         remove = true;
   16962                 :             :                       }
   16963                 :        2466 :                     while (TREE_CODE (t) == ARRAY_REF)
   16964                 :         641 :                       t = TREE_OPERAND (t, 0);
   16965                 :             : 
   16966                 :        1825 :                     c_omp_address_inspector ai (OMP_CLAUSE_LOCATION (c), t);
   16967                 :             : 
   16968                 :        1825 :                     if (!omp_parse_expr (addr_tokens, t))
   16969                 :             :                       {
   16970                 :           0 :                         sorry_at (OMP_CLAUSE_LOCATION (c),
   16971                 :             :                                   "unsupported map expression %qE",
   16972                 :           0 :                                   OMP_CLAUSE_DECL (c));
   16973                 :           0 :                         remove = true;
   16974                 :           0 :                         break;
   16975                 :             :                       }
   16976                 :             : 
   16977                 :             :                     /* This check is to determine if this will be the only map
   16978                 :             :                        node created for this clause.  Otherwise, we'll check
   16979                 :             :                        the following FIRSTPRIVATE_POINTER or ATTACH_DETACH
   16980                 :             :                        node on the next iteration(s) of the loop.   */
   16981                 :        3632 :                     if (addr_tokens.length () >= 4
   16982                 :         302 :                         && addr_tokens[0]->type == STRUCTURE_BASE
   16983                 :         302 :                         && addr_tokens[0]->u.structure_base_kind == BASE_DECL
   16984                 :         302 :                         && addr_tokens[1]->type == ACCESS_METHOD
   16985                 :         302 :                         && addr_tokens[2]->type == COMPONENT_SELECTOR
   16986                 :         302 :                         && addr_tokens[3]->type == ACCESS_METHOD
   16987                 :        2066 :                         && (addr_tokens[3]->u.access_kind == ACCESS_DIRECT
   16988                 :         188 :                             || (addr_tokens[3]->u.access_kind
   16989                 :             :                                 == ACCESS_INDEXED_ARRAY)))
   16990                 :             :                       {
   16991                 :          55 :                         tree rt = addr_tokens[1]->expr;
   16992                 :             : 
   16993                 :          55 :                         gcc_assert (DECL_P (rt));
   16994                 :             : 
   16995                 :          55 :                         if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP
   16996                 :          50 :                             && OMP_CLAUSE_MAP_IMPLICIT (c)
   16997                 :          55 :                             && (bitmap_bit_p (&map_head, DECL_UID (rt))
   16998                 :           0 :                                 || bitmap_bit_p (&map_field_head, DECL_UID (rt))
   16999                 :           0 :                                 || bitmap_bit_p (&map_firstprivate_head,
   17000                 :           0 :                                                  DECL_UID (rt))))
   17001                 :             :                           {
   17002                 :             :                             remove = true;
   17003                 :             :                             break;
   17004                 :             :                           }
   17005                 :          55 :                         if (bitmap_bit_p (&map_field_head, DECL_UID (rt)))
   17006                 :             :                           break;
   17007                 :          37 :                         if (bitmap_bit_p (&map_head, DECL_UID (rt)))
   17008                 :             :                           {
   17009                 :           0 :                             if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_MAP)
   17010                 :           0 :                               error_at (OMP_CLAUSE_LOCATION (c),
   17011                 :             :                                         "%qD appears more than once in motion "
   17012                 :             :                                         "clauses", rt);
   17013                 :           0 :                             else if (openacc)
   17014                 :           0 :                               error_at (OMP_CLAUSE_LOCATION (c),
   17015                 :             :                                         "%qD appears more than once in data "
   17016                 :             :                                         "clauses", rt);
   17017                 :             :                             else
   17018                 :           0 :                               error_at (OMP_CLAUSE_LOCATION (c),
   17019                 :             :                                         "%qD appears more than once in map "
   17020                 :             :                                         "clauses", rt);
   17021                 :             :                             remove = true;
   17022                 :             :                           }
   17023                 :             :                         else
   17024                 :             :                           {
   17025                 :          37 :                             bitmap_set_bit (&map_head, DECL_UID (rt));
   17026                 :          37 :                             bitmap_set_bit (&map_field_head, DECL_UID (rt));
   17027                 :             :                           }
   17028                 :             :                       }
   17029                 :        1825 :                   }
   17030                 :        1947 :                 if (c_oacc_check_attachments (c))
   17031                 :           2 :                   remove = true;
   17032                 :        1947 :                 if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP
   17033                 :        1783 :                     && (OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_ATTACH
   17034                 :        1772 :                         || OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_DETACH)
   17035                 :        1965 :                     && !OMP_CLAUSE_SIZE (c))
   17036                 :             :                   /* In this case, we have a single array element which is a
   17037                 :             :                      pointer, and we already set OMP_CLAUSE_SIZE in
   17038                 :             :                      handle_omp_array_sections above.  For attach/detach
   17039                 :             :                      clauses, reset the OMP_CLAUSE_SIZE (representing a bias)
   17040                 :             :                      to zero here.  */
   17041                 :          10 :                   OMP_CLAUSE_SIZE (c) = size_zero_node;
   17042                 :             :                 break;
   17043                 :             :               }
   17044                 :        7391 :             else if (!omp_parse_expr (addr_tokens, t))
   17045                 :             :               {
   17046                 :           0 :                 sorry_at (OMP_CLAUSE_LOCATION (c),
   17047                 :             :                           "unsupported map expression %qE",
   17048                 :           0 :                           OMP_CLAUSE_DECL (c));
   17049                 :           0 :                 remove = true;
   17050                 :           0 :                 break;
   17051                 :             :               }
   17052                 :        7391 :             if (t == error_mark_node)
   17053                 :             :               {
   17054                 :             :                 remove = true;
   17055                 :             :                 break;
   17056                 :             :               }
   17057                 :             :             /* OpenACC attach / detach clauses must be pointers.  */
   17058                 :        7385 :             if (c_oacc_check_attachments (c))
   17059                 :             :               {
   17060                 :             :                 remove = true;
   17061                 :             :                 break;
   17062                 :             :               }
   17063                 :        7381 :             if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP
   17064                 :        4563 :                 && (OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_ATTACH
   17065                 :        4536 :                     || OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_DETACH)
   17066                 :        7423 :                 && !OMP_CLAUSE_SIZE (c))
   17067                 :             :               /* For attach/detach clauses, set OMP_CLAUSE_SIZE (representing a
   17068                 :             :                  bias) to zero here, so it is not set erroneously to the pointer
   17069                 :             :                  size later on in gimplify.cc.  */
   17070                 :          28 :               OMP_CLAUSE_SIZE (c) = size_zero_node;
   17071                 :             : 
   17072                 :        7381 :             c_omp_address_inspector ai (OMP_CLAUSE_LOCATION (c), t);
   17073                 :             : 
   17074                 :        7381 :             if (!ai.check_clause (c))
   17075                 :             :               {
   17076                 :             :                 remove = true;
   17077                 :             :                 break;
   17078                 :             :               }
   17079                 :             : 
   17080                 :        7373 :             if (!ai.map_supported_p ())
   17081                 :             :               {
   17082                 :          10 :                 sorry_at (OMP_CLAUSE_LOCATION (c),
   17083                 :             :                           "unsupported map expression %qE",
   17084                 :           5 :                           OMP_CLAUSE_DECL (c));
   17085                 :           5 :                 remove = true;
   17086                 :           5 :                 break;
   17087                 :             :               }
   17088                 :             : 
   17089                 :       14736 :             gcc_assert ((addr_tokens[0]->type == ARRAY_BASE
   17090                 :             :                          || addr_tokens[0]->type == STRUCTURE_BASE)
   17091                 :             :                         && addr_tokens[1]->type == ACCESS_METHOD);
   17092                 :             : 
   17093                 :        7368 :             t = addr_tokens[1]->expr;
   17094                 :             : 
   17095                 :        7368 :             if (addr_tokens[0]->u.structure_base_kind != BASE_DECL)
   17096                 :           0 :               goto skip_decl_checks;
   17097                 :             : 
   17098                 :             :             /* For OpenMP, we can access a struct "t" and "t.d" on the same
   17099                 :             :                mapping.  OpenACC allows multiple fields of the same structure
   17100                 :             :                to be written.  */
   17101                 :        7368 :             if (addr_tokens[0]->type == STRUCTURE_BASE
   17102                 :        7368 :                 && (bitmap_bit_p (&map_field_head, DECL_UID (t))
   17103                 :         238 :                     || (!openacc && bitmap_bit_p (&map_head, DECL_UID (t)))))
   17104                 :         246 :               goto skip_decl_checks;
   17105                 :             : 
   17106                 :        7122 :             if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL)
   17107                 :             :               {
   17108                 :           3 :                 if (ort != C_ORT_ACC && EXPR_P (t))
   17109                 :             :                   break;
   17110                 :             : 
   17111                 :           6 :                 error_at (OMP_CLAUSE_LOCATION (c),
   17112                 :             :                           "%qE is not a variable in %qs clause", t,
   17113                 :           3 :                           omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   17114                 :           3 :                 remove = true;
   17115                 :             :               }
   17116                 :        7119 :             else if (VAR_P (t) && DECL_THREAD_LOCAL_P (t))
   17117                 :             :               {
   17118                 :           0 :                 error_at (OMP_CLAUSE_LOCATION (c),
   17119                 :             :                           "%qD is threadprivate variable in %qs clause", t,
   17120                 :           0 :                           omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   17121                 :           0 :                 remove = true;
   17122                 :             :               }
   17123                 :        7119 :             else if ((OMP_CLAUSE_CODE (c) != OMP_CLAUSE_MAP
   17124                 :        4308 :                       || (OMP_CLAUSE_MAP_KIND (c)
   17125                 :             :                           != GOMP_MAP_FIRSTPRIVATE_POINTER))
   17126                 :       10399 :                      && !c_mark_addressable (t))
   17127                 :             :               remove = true;
   17128                 :        7119 :             else if (!(OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP
   17129                 :        4308 :                        && (OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_POINTER
   17130                 :        4308 :                            || (OMP_CLAUSE_MAP_KIND (c)
   17131                 :             :                                == GOMP_MAP_FIRSTPRIVATE_POINTER)
   17132                 :        3280 :                            || (OMP_CLAUSE_MAP_KIND (c)
   17133                 :             :                                == GOMP_MAP_FORCE_DEVICEPTR)))
   17134                 :        6033 :                      && t == OMP_CLAUSE_DECL (c)
   17135                 :       12916 :                      && !omp_mappable_type (TREE_TYPE (t)))
   17136                 :             :               {
   17137                 :          16 :                 error_at (OMP_CLAUSE_LOCATION (c),
   17138                 :             :                           "%qD does not have a mappable type in %qs clause", t,
   17139                 :           8 :                           omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   17140                 :           8 :                 remove = true;
   17141                 :             :               }
   17142                 :        7111 :             else if (TREE_TYPE (t) == error_mark_node)
   17143                 :             :               remove = true;
   17144                 :        7110 :             else if (TYPE_ATOMIC (strip_array_types (TREE_TYPE (t))))
   17145                 :             :               {
   17146                 :           8 :                 error_at (OMP_CLAUSE_LOCATION (c),
   17147                 :             :                           "%<_Atomic%> %qE in %qs clause", t,
   17148                 :           4 :                           omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   17149                 :           4 :                 remove = true;
   17150                 :             :               }
   17151                 :        7106 :             else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP
   17152                 :        4298 :                      && OMP_CLAUSE_MAP_IMPLICIT (c)
   17153                 :        7270 :                      && (bitmap_bit_p (&map_head, DECL_UID (t))
   17154                 :         128 :                          || bitmap_bit_p (&map_field_head, DECL_UID (t))
   17155                 :         128 :                          || bitmap_bit_p (&map_firstprivate_head,
   17156                 :         128 :                                           DECL_UID (t))))
   17157                 :             :               remove = true;
   17158                 :        7069 :             else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP
   17159                 :        7069 :                      && (OMP_CLAUSE_MAP_KIND (c)
   17160                 :             :                          == GOMP_MAP_FIRSTPRIVATE_POINTER))
   17161                 :             :               {
   17162                 :        1026 :                 if (bitmap_bit_p (&generic_head, DECL_UID (t))
   17163                 :        1026 :                     || bitmap_bit_p (&firstprivate_head, DECL_UID (t))
   17164                 :        2051 :                     || bitmap_bit_p (&map_firstprivate_head, DECL_UID (t)))
   17165                 :             :                   {
   17166                 :           5 :                     error_at (OMP_CLAUSE_LOCATION (c),
   17167                 :             :                               "%qD appears more than once in data clauses", t);
   17168                 :           5 :                     remove = true;
   17169                 :             :                   }
   17170                 :        1021 :                 else if (bitmap_bit_p (&map_head, DECL_UID (t))
   17171                 :           4 :                          && !bitmap_bit_p (&map_field_head, DECL_UID (t))
   17172                 :        1023 :                          && openacc)
   17173                 :             :                   {
   17174                 :           1 :                     error_at (OMP_CLAUSE_LOCATION (c),
   17175                 :             :                               "%qD appears more than once in data clauses", t);
   17176                 :           1 :                     remove = true;
   17177                 :             :                   }
   17178                 :             :                 else
   17179                 :        1020 :                   bitmap_set_bit (&map_firstprivate_head, DECL_UID (t));
   17180                 :             :               }
   17181                 :        6043 :             else if (bitmap_bit_p (&map_head, DECL_UID (t))
   17182                 :          59 :                      && !bitmap_bit_p (&map_field_head, DECL_UID (t))
   17183                 :          13 :                      && ort != C_ORT_OMP
   17184                 :        6056 :                      && ort != C_ORT_OMP_EXIT_DATA)
   17185                 :             :               {
   17186                 :          10 :                 if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_MAP)
   17187                 :           0 :                   error_at (OMP_CLAUSE_LOCATION (c),
   17188                 :             :                             "%qD appears more than once in motion clauses", t);
   17189                 :          10 :                 else if (openacc)
   17190                 :           7 :                   error_at (OMP_CLAUSE_LOCATION (c),
   17191                 :             :                             "%qD appears more than once in data clauses", t);
   17192                 :             :                 else
   17193                 :           3 :                   error_at (OMP_CLAUSE_LOCATION (c),
   17194                 :             :                             "%qD appears more than once in map clauses", t);
   17195                 :             :                 remove = true;
   17196                 :             :               }
   17197                 :        6033 :             else if (openacc && bitmap_bit_p (&generic_head, DECL_UID (t)))
   17198                 :             :               {
   17199                 :           0 :                 error_at (OMP_CLAUSE_LOCATION (c),
   17200                 :             :                           "%qD appears more than once in data clauses", t);
   17201                 :           0 :                 remove = true;
   17202                 :             :               }
   17203                 :        6033 :             else if (bitmap_bit_p (&firstprivate_head, DECL_UID (t))
   17204                 :        6033 :                      || bitmap_bit_p (&is_on_device_head, DECL_UID (t)))
   17205                 :             :               {
   17206                 :           9 :                 if (openacc)
   17207                 :           0 :                   error_at (OMP_CLAUSE_LOCATION (c),
   17208                 :             :                             "%qD appears more than once in data clauses", t);
   17209                 :             :                 else
   17210                 :           9 :                   error_at (OMP_CLAUSE_LOCATION (c),
   17211                 :             :                             "%qD appears both in data and map clauses", t);
   17212                 :             :                 remove = true;
   17213                 :             :               }
   17214                 :        6024 :             else if (!omp_access_chain_p (addr_tokens, 1))
   17215                 :             :               {
   17216                 :        6024 :                 bitmap_set_bit (&map_head, DECL_UID (t));
   17217                 :        6024 :                 if (t != OMP_CLAUSE_DECL (c)
   17218                 :        6024 :                     && TREE_CODE (OMP_CLAUSE_DECL (c)) == COMPONENT_REF)
   17219                 :         232 :                   bitmap_set_bit (&map_field_head, DECL_UID (t));
   17220                 :             :               }
   17221                 :             : 
   17222                 :           0 :           skip_decl_checks:
   17223                 :             :             /* If we call omp_expand_map_clause in handle_omp_array_sections,
   17224                 :             :                the containing loop (here) iterates through the new nodes
   17225                 :             :                created by that expansion.  Avoid expanding those again (just
   17226                 :             :                by checking the node type).  */
   17227                 :        7368 :             if (!remove
   17228                 :        7368 :                 && ort != C_ORT_DECLARE_SIMD
   17229                 :        7368 :                 && (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_MAP
   17230                 :        4476 :                     || (OMP_CLAUSE_MAP_KIND (c) != GOMP_MAP_FIRSTPRIVATE_POINTER
   17231                 :        3456 :                         && (OMP_CLAUSE_MAP_KIND (c)
   17232                 :             :                             != GOMP_MAP_FIRSTPRIVATE_REFERENCE)
   17233                 :        3456 :                         && OMP_CLAUSE_MAP_KIND (c) != GOMP_MAP_ALWAYS_POINTER
   17234                 :        3456 :                         && OMP_CLAUSE_MAP_KIND (c) != GOMP_MAP_ATTACH_DETACH
   17235                 :        3157 :                         && OMP_CLAUSE_MAP_KIND (c) != GOMP_MAP_ATTACH
   17236                 :        3130 :                         && OMP_CLAUSE_MAP_KIND (c) != GOMP_MAP_DETACH)))
   17237                 :             :               {
   17238                 :        5929 :                 grp_start_p = pc;
   17239                 :        5929 :                 grp_sentinel = OMP_CLAUSE_CHAIN (c);
   17240                 :        5929 :                 tree nc = ai.expand_map_clause (c, OMP_CLAUSE_DECL (c),
   17241                 :             :                                                 addr_tokens, ort);
   17242                 :        5929 :                 if (nc != error_mark_node)
   17243                 :        5929 :                   c = nc;
   17244                 :             :               }
   17245                 :        9369 :           }
   17246                 :        7368 :           break;
   17247                 :             : 
   17248                 :         222 :         case OMP_CLAUSE_ENTER:
   17249                 :         222 :         case OMP_CLAUSE_LINK:
   17250                 :         222 :           t = OMP_CLAUSE_DECL (c);
   17251                 :         222 :           const char *cname;
   17252                 :         222 :           cname = omp_clause_code_name[OMP_CLAUSE_CODE (c)];
   17253                 :         222 :           if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_ENTER
   17254                 :         222 :               && OMP_CLAUSE_ENTER_TO (c))
   17255                 :             :             cname = "to";
   17256                 :         222 :           if (TREE_CODE (t) == FUNCTION_DECL
   17257                 :         222 :               && OMP_CLAUSE_CODE (c) == OMP_CLAUSE_ENTER)
   17258                 :             :             ;
   17259                 :         145 :           else if (!VAR_P (t))
   17260                 :             :             {
   17261                 :           1 :               if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_ENTER)
   17262                 :           0 :                 error_at (OMP_CLAUSE_LOCATION (c),
   17263                 :             :                           "%qE is neither a variable nor a function name in "
   17264                 :             :                           "clause %qs", t, cname);
   17265                 :             :               else
   17266                 :           1 :                 error_at (OMP_CLAUSE_LOCATION (c),
   17267                 :             :                           "%qE is not a variable in clause %qs", t, cname);
   17268                 :             :               remove = true;
   17269                 :             :             }
   17270                 :         144 :           else if (DECL_THREAD_LOCAL_P (t))
   17271                 :             :             {
   17272                 :           2 :               error_at (OMP_CLAUSE_LOCATION (c),
   17273                 :             :                         "%qD is threadprivate variable in %qs clause", t,
   17274                 :             :                         cname);
   17275                 :           2 :               remove = true;
   17276                 :             :             }
   17277                 :         142 :           else if (!omp_mappable_type (TREE_TYPE (t)))
   17278                 :             :             {
   17279                 :           6 :               error_at (OMP_CLAUSE_LOCATION (c),
   17280                 :             :                         "%qD does not have a mappable type in %qs clause", t,
   17281                 :             :                         cname);
   17282                 :           6 :               remove = true;
   17283                 :             :             }
   17284                 :           8 :           if (remove)
   17285                 :             :             break;
   17286                 :         213 :           if (bitmap_bit_p (&generic_head, DECL_UID (t)))
   17287                 :             :             {
   17288                 :           8 :               error_at (OMP_CLAUSE_LOCATION (c),
   17289                 :             :                         "%qE appears more than once on the same "
   17290                 :             :                         "%<declare target%> directive", t);
   17291                 :           8 :               remove = true;
   17292                 :             :             }
   17293                 :             :           else
   17294                 :         205 :             bitmap_set_bit (&generic_head, DECL_UID (t));
   17295                 :             :           break;
   17296                 :             : 
   17297                 :         117 :         case OMP_CLAUSE_UNIFORM:
   17298                 :         117 :           t = OMP_CLAUSE_DECL (c);
   17299                 :         117 :           if (TREE_CODE (t) != PARM_DECL)
   17300                 :             :             {
   17301                 :           0 :               if (DECL_P (t))
   17302                 :           0 :                 error_at (OMP_CLAUSE_LOCATION (c),
   17303                 :             :                           "%qD is not an argument in %<uniform%> clause", t);
   17304                 :             :               else
   17305                 :           0 :                 error_at (OMP_CLAUSE_LOCATION (c),
   17306                 :             :                           "%qE is not an argument in %<uniform%> clause", t);
   17307                 :             :               remove = true;
   17308                 :             :               break;
   17309                 :             :             }
   17310                 :             :           /* map_head bitmap is used as uniform_head if declare_simd.  */
   17311                 :         117 :           bitmap_set_bit (&map_head, DECL_UID (t));
   17312                 :         117 :           goto check_dup_generic;
   17313                 :             : 
   17314                 :         160 :         case OMP_CLAUSE_IS_DEVICE_PTR:
   17315                 :         160 :         case OMP_CLAUSE_USE_DEVICE_PTR:
   17316                 :         160 :           t = OMP_CLAUSE_DECL (c);
   17317                 :         160 :           if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_IS_DEVICE_PTR)
   17318                 :         122 :             bitmap_set_bit (&is_on_device_head, DECL_UID (t));
   17319                 :         160 :           if (TREE_CODE (TREE_TYPE (t)) != POINTER_TYPE)
   17320                 :             :             {
   17321                 :          21 :               if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_USE_DEVICE_PTR
   17322                 :          21 :                   && !openacc)
   17323                 :             :                 {
   17324                 :           1 :                   error_at (OMP_CLAUSE_LOCATION (c),
   17325                 :             :                             "%qs variable is not a pointer",
   17326                 :           1 :                             omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   17327                 :           1 :                   remove = true;
   17328                 :             :                 }
   17329                 :          20 :               else if (TREE_CODE (TREE_TYPE (t)) != ARRAY_TYPE)
   17330                 :             :                 {
   17331                 :           4 :                   error_at (OMP_CLAUSE_LOCATION (c),
   17332                 :             :                             "%qs variable is neither a pointer nor an array",
   17333                 :           4 :                             omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   17334                 :           4 :                   remove = true;
   17335                 :             :                 }
   17336                 :             :             }
   17337                 :         160 :           goto check_dup_generic;
   17338                 :             : 
   17339                 :          88 :         case OMP_CLAUSE_HAS_DEVICE_ADDR:
   17340                 :          88 :           t = OMP_CLAUSE_DECL (c);
   17341                 :          88 :           if (TREE_CODE (t) == OMP_ARRAY_SECTION)
   17342                 :             :             {
   17343                 :          11 :               if (handle_omp_array_sections (c, ort))
   17344                 :             :                 remove = true;
   17345                 :             :               else
   17346                 :             :                 {
   17347                 :          11 :                   t = OMP_CLAUSE_DECL (c);
   17348                 :          24 :                   while (TREE_CODE (t) == ARRAY_REF)
   17349                 :          13 :                     t = TREE_OPERAND (t, 0);
   17350                 :             :                 }
   17351                 :             :             }
   17352                 :          88 :           bitmap_set_bit (&is_on_device_head, DECL_UID (t));
   17353                 :          88 :           if (VAR_P (t) || TREE_CODE (t) == PARM_DECL)
   17354                 :          88 :             c_mark_addressable (t);
   17355                 :          88 :           goto check_dup_generic_t;
   17356                 :             : 
   17357                 :          36 :         case OMP_CLAUSE_USE_DEVICE_ADDR:
   17358                 :          36 :           t = OMP_CLAUSE_DECL (c);
   17359                 :          36 :           if (VAR_P (t) || TREE_CODE (t) == PARM_DECL)
   17360                 :          36 :             c_mark_addressable (t);
   17361                 :          36 :           goto check_dup_generic;
   17362                 :             : 
   17363                 :        4788 :         case OMP_CLAUSE_NOWAIT:
   17364                 :        4788 :           if (copyprivate_seen)
   17365                 :             :             {
   17366                 :           1 :               error_at (OMP_CLAUSE_LOCATION (c),
   17367                 :             :                         "%<nowait%> clause must not be used together "
   17368                 :             :                         "with %<copyprivate%> clause");
   17369                 :           1 :               remove = true;
   17370                 :           1 :               break;
   17371                 :             :             }
   17372                 :        4787 :           nowait_clause = pc;
   17373                 :        4787 :           pc = &OMP_CLAUSE_CHAIN (c);
   17374                 :        4787 :           continue;
   17375                 :             : 
   17376                 :         522 :         case OMP_CLAUSE_ORDER:
   17377                 :         522 :           if (ordered_clause)
   17378                 :             :             {
   17379                 :           2 :               error_at (OMP_CLAUSE_LOCATION (c),
   17380                 :             :                         "%<order%> clause must not be used together "
   17381                 :             :                         "with %<ordered%> clause");
   17382                 :           2 :               remove = true;
   17383                 :           2 :               break;
   17384                 :             :             }
   17385                 :         520 :           else if (order_clause)
   17386                 :             :             {
   17387                 :             :               /* Silently remove duplicates.  */
   17388                 :             :               remove = true;
   17389                 :             :               break;
   17390                 :             :             }
   17391                 :         512 :           order_clause = pc;
   17392                 :         512 :           pc = &OMP_CLAUSE_CHAIN (c);
   17393                 :         512 :           continue;
   17394                 :             : 
   17395                 :          32 :         case OMP_CLAUSE_DETACH:
   17396                 :          32 :           t = OMP_CLAUSE_DECL (c);
   17397                 :          32 :           if (detach_seen)
   17398                 :             :             {
   17399                 :           1 :               error_at (OMP_CLAUSE_LOCATION (c),
   17400                 :             :                         "too many %qs clauses on a task construct",
   17401                 :             :                         "detach");
   17402                 :           1 :               remove = true;
   17403                 :           1 :               break;
   17404                 :             :             }
   17405                 :          31 :           detach_seen = pc;
   17406                 :          31 :           pc = &OMP_CLAUSE_CHAIN (c);
   17407                 :          31 :           c_mark_addressable (t);
   17408                 :          31 :           continue;
   17409                 :             : 
   17410                 :       14507 :         case OMP_CLAUSE_IF:
   17411                 :       14507 :         case OMP_CLAUSE_SELF:
   17412                 :       14507 :         case OMP_CLAUSE_NUM_THREADS:
   17413                 :       14507 :         case OMP_CLAUSE_NUM_TEAMS:
   17414                 :       14507 :         case OMP_CLAUSE_THREAD_LIMIT:
   17415                 :       14507 :         case OMP_CLAUSE_DEFAULT:
   17416                 :       14507 :         case OMP_CLAUSE_UNTIED:
   17417                 :       14507 :         case OMP_CLAUSE_COLLAPSE:
   17418                 :       14507 :         case OMP_CLAUSE_FINAL:
   17419                 :       14507 :         case OMP_CLAUSE_DEVICE:
   17420                 :       14507 :         case OMP_CLAUSE_DIST_SCHEDULE:
   17421                 :       14507 :         case OMP_CLAUSE_PARALLEL:
   17422                 :       14507 :         case OMP_CLAUSE_FOR:
   17423                 :       14507 :         case OMP_CLAUSE_SECTIONS:
   17424                 :       14507 :         case OMP_CLAUSE_TASKGROUP:
   17425                 :       14507 :         case OMP_CLAUSE_PROC_BIND:
   17426                 :       14507 :         case OMP_CLAUSE_DEVICE_TYPE:
   17427                 :       14507 :         case OMP_CLAUSE_PRIORITY:
   17428                 :       14507 :         case OMP_CLAUSE_THREADS:
   17429                 :       14507 :         case OMP_CLAUSE_SIMD:
   17430                 :       14507 :         case OMP_CLAUSE_HINT:
   17431                 :       14507 :         case OMP_CLAUSE_FILTER:
   17432                 :       14507 :         case OMP_CLAUSE_DEFAULTMAP:
   17433                 :       14507 :         case OMP_CLAUSE_BIND:
   17434                 :       14507 :         case OMP_CLAUSE_NUM_GANGS:
   17435                 :       14507 :         case OMP_CLAUSE_NUM_WORKERS:
   17436                 :       14507 :         case OMP_CLAUSE_VECTOR_LENGTH:
   17437                 :       14507 :         case OMP_CLAUSE_ASYNC:
   17438                 :       14507 :         case OMP_CLAUSE_WAIT:
   17439                 :       14507 :         case OMP_CLAUSE_AUTO:
   17440                 :       14507 :         case OMP_CLAUSE_INDEPENDENT:
   17441                 :       14507 :         case OMP_CLAUSE_SEQ:
   17442                 :       14507 :         case OMP_CLAUSE_GANG:
   17443                 :       14507 :         case OMP_CLAUSE_WORKER:
   17444                 :       14507 :         case OMP_CLAUSE_VECTOR:
   17445                 :       14507 :         case OMP_CLAUSE_TILE:
   17446                 :       14507 :         case OMP_CLAUSE_IF_PRESENT:
   17447                 :       14507 :         case OMP_CLAUSE_FINALIZE:
   17448                 :       14507 :         case OMP_CLAUSE_NOHOST:
   17449                 :       14507 :         case OMP_CLAUSE_INDIRECT:
   17450                 :       14507 :         case OMP_CLAUSE_NOVARIANTS:
   17451                 :       14507 :         case OMP_CLAUSE_NOCONTEXT:
   17452                 :       14507 :           pc = &OMP_CLAUSE_CHAIN (c);
   17453                 :       14507 :           continue;
   17454                 :             : 
   17455                 :          62 :         case OMP_CLAUSE_GRAINSIZE:
   17456                 :          62 :           grainsize_seen = pc;
   17457                 :          62 :           pc = &OMP_CLAUSE_CHAIN (c);
   17458                 :          62 :           continue;
   17459                 :             : 
   17460                 :          49 :         case OMP_CLAUSE_NUM_TASKS:
   17461                 :          49 :           num_tasks_seen = true;
   17462                 :          49 :           pc = &OMP_CLAUSE_CHAIN (c);
   17463                 :          49 :           continue;
   17464                 :             : 
   17465                 :          78 :         case OMP_CLAUSE_MERGEABLE:
   17466                 :          78 :           mergeable_seen = true;
   17467                 :          78 :           pc = &OMP_CLAUSE_CHAIN (c);
   17468                 :          78 :           continue;
   17469                 :             : 
   17470                 :          18 :         case OMP_CLAUSE_NOGROUP:
   17471                 :          18 :           nogroup_seen = pc;
   17472                 :          18 :           pc = &OMP_CLAUSE_CHAIN (c);
   17473                 :          18 :           continue;
   17474                 :             : 
   17475                 :        3463 :         case OMP_CLAUSE_SCHEDULE:
   17476                 :        3463 :           schedule_clause = c;
   17477                 :        3463 :           pc = &OMP_CLAUSE_CHAIN (c);
   17478                 :        3463 :           continue;
   17479                 :             : 
   17480                 :         303 :         case OMP_CLAUSE_ORDERED:
   17481                 :         303 :           ordered_clause = c;
   17482                 :         303 :           if (order_clause)
   17483                 :             :             {
   17484                 :           2 :               error_at (OMP_CLAUSE_LOCATION (*order_clause),
   17485                 :             :                         "%<order%> clause must not be used together "
   17486                 :             :                         "with %<ordered%> clause");
   17487                 :           2 :               *order_clause = OMP_CLAUSE_CHAIN (*order_clause);
   17488                 :           2 :               order_clause = NULL;
   17489                 :             :             }
   17490                 :         303 :           pc = &OMP_CLAUSE_CHAIN (c);
   17491                 :         303 :           continue;
   17492                 :             : 
   17493                 :         223 :         case OMP_CLAUSE_SAFELEN:
   17494                 :         223 :           safelen = c;
   17495                 :         223 :           pc = &OMP_CLAUSE_CHAIN (c);
   17496                 :         223 :           continue;
   17497                 :         313 :         case OMP_CLAUSE_SIMDLEN:
   17498                 :         313 :           simdlen = c;
   17499                 :         313 :           pc = &OMP_CLAUSE_CHAIN (c);
   17500                 :         313 :           continue;
   17501                 :             : 
   17502                 :          69 :         case OMP_CLAUSE_FULL:
   17503                 :          69 :           full_seen = pc;
   17504                 :          69 :           pc = &OMP_CLAUSE_CHAIN (c);
   17505                 :          69 :           continue;
   17506                 :             : 
   17507                 :         223 :         case OMP_CLAUSE_PARTIAL:
   17508                 :         223 :           partial_seen = true;
   17509                 :         223 :           pc = &OMP_CLAUSE_CHAIN (c);
   17510                 :         223 :           continue;
   17511                 :             : 
   17512                 :           0 :         case OMP_CLAUSE_SIZES:
   17513                 :           0 :           pc = &OMP_CLAUSE_CHAIN (c);
   17514                 :           0 :           continue;
   17515                 :             : 
   17516                 :         199 :         case OMP_CLAUSE_INBRANCH:
   17517                 :         199 :         case OMP_CLAUSE_NOTINBRANCH:
   17518                 :         199 :           if (branch_seen)
   17519                 :             :             {
   17520                 :           1 :               error_at (OMP_CLAUSE_LOCATION (c),
   17521                 :             :                         "%<inbranch%> clause is incompatible with "
   17522                 :             :                         "%<notinbranch%>");
   17523                 :           1 :               remove = true;
   17524                 :           1 :               break;
   17525                 :             :             }
   17526                 :         198 :           branch_seen = true;
   17527                 :         198 :           pc = &OMP_CLAUSE_CHAIN (c);
   17528                 :         198 :           continue;
   17529                 :             : 
   17530                 :         367 :         case OMP_CLAUSE_INCLUSIVE:
   17531                 :         367 :         case OMP_CLAUSE_EXCLUSIVE:
   17532                 :         367 :           need_complete = true;
   17533                 :         367 :           need_implicitly_determined = true;
   17534                 :         367 :           t = OMP_CLAUSE_DECL (c);
   17535                 :         367 :           if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL)
   17536                 :             :             {
   17537                 :           0 :               error_at (OMP_CLAUSE_LOCATION (c),
   17538                 :             :                         "%qE is not a variable in clause %qs", t,
   17539                 :           0 :                         omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   17540                 :           0 :               remove = true;
   17541                 :             :             }
   17542                 :             :           break;
   17543                 :             : 
   17544                 :         152 :         case OMP_CLAUSE_INIT:
   17545                 :         152 :           init_seen = true;
   17546                 :         152 :           if (!OMP_CLAUSE_INIT_TARGETSYNC (c))
   17547                 :          71 :             init_no_targetsync_clause = c;
   17548                 :             :           /* FALLTHRU */
   17549                 :         242 :         case OMP_CLAUSE_DESTROY:
   17550                 :         242 :         case OMP_CLAUSE_USE:
   17551                 :         242 :           init_use_destroy_seen = true;
   17552                 :         242 :           t = OMP_CLAUSE_DECL (c);
   17553                 :         242 :           if (bitmap_bit_p (&generic_head, DECL_UID (t)))
   17554                 :             :             {
   17555                 :           3 :               error_at (OMP_CLAUSE_LOCATION (c),
   17556                 :             :                         "%qD appears more than once in action clauses", t);
   17557                 :           3 :               remove = true;
   17558                 :           3 :               break;
   17559                 :             :             }
   17560                 :         239 :           bitmap_set_bit (&generic_head, DECL_UID (t));
   17561                 :             :           /* FALLTHRU */
   17562                 :         297 :         case OMP_CLAUSE_INTEROP:
   17563                 :         297 :           if (/* ort == C_ORT_OMP_INTEROP [uncomment for depobj init]  */
   17564                 :         297 :                    !c_omp_interop_t_p (TREE_TYPE (OMP_CLAUSE_DECL (c))))
   17565                 :             :             {
   17566                 :          40 :               error_at (OMP_CLAUSE_LOCATION (c),
   17567                 :             :                         "%qD must be of %<omp_interop_t%>",
   17568                 :          20 :                         OMP_CLAUSE_DECL (c));
   17569                 :          20 :               remove = true;
   17570                 :             :             }
   17571                 :         277 :           else if ((OMP_CLAUSE_CODE (c) == OMP_CLAUSE_INIT
   17572                 :         132 :                     || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DESTROY)
   17573                 :         317 :                    && TREE_READONLY (OMP_CLAUSE_DECL (c)))
   17574                 :             :             {
   17575                 :          12 :               error_at (OMP_CLAUSE_LOCATION (c),
   17576                 :           6 :                       "%qD shall not be const", OMP_CLAUSE_DECL (c));
   17577                 :           6 :               remove = true;
   17578                 :             :             }
   17579                 :         297 :           pc = &OMP_CLAUSE_CHAIN (c);
   17580                 :         297 :           break;
   17581                 :           0 :         default:
   17582                 :           0 :           gcc_unreachable ();
   17583                 :       24836 :         }
   17584                 :             : 
   17585                 :       22557 :       if (!remove)
   17586                 :             :         {
   17587                 :       21999 :           t = OMP_CLAUSE_DECL (c);
   17588                 :             : 
   17589                 :       21999 :           if (need_complete)
   17590                 :             :             {
   17591                 :        3930 :               t = require_complete_type (OMP_CLAUSE_LOCATION (c), t);
   17592                 :        3930 :               if (t == error_mark_node)
   17593                 :           7 :                 remove = true;
   17594                 :             :             }
   17595                 :             : 
   17596                 :       21999 :           if (need_implicitly_determined)
   17597                 :             :             {
   17598                 :        9523 :               const char *share_name = NULL;
   17599                 :             : 
   17600                 :        9523 :               if (VAR_P (t) && DECL_THREAD_LOCAL_P (t))
   17601                 :             :                 share_name = "threadprivate";
   17602                 :        9517 :               else switch (c_omp_predetermined_sharing (t))
   17603                 :             :                 {
   17604                 :             :                 case OMP_CLAUSE_DEFAULT_UNSPECIFIED:
   17605                 :             :                   break;
   17606                 :          20 :                 case OMP_CLAUSE_DEFAULT_SHARED:
   17607                 :          20 :                   if ((OMP_CLAUSE_CODE (c) == OMP_CLAUSE_SHARED
   17608                 :          12 :                        || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_FIRSTPRIVATE)
   17609                 :          28 :                       && c_omp_predefined_variable (t))
   17610                 :             :                     /* The __func__ variable and similar function-local
   17611                 :             :                        predefined variables may be listed in a shared or
   17612                 :             :                        firstprivate clause.  */
   17613                 :             :                     break;
   17614                 :             :                   share_name = "shared";
   17615                 :             :                   break;
   17616                 :             :                 case OMP_CLAUSE_DEFAULT_PRIVATE:
   17617                 :             :                   share_name = "private";
   17618                 :             :                   break;
   17619                 :           0 :                 default:
   17620                 :           0 :                   gcc_unreachable ();
   17621                 :             :                 }
   17622                 :             :               if (share_name)
   17623                 :             :                 {
   17624                 :          20 :                   error_at (OMP_CLAUSE_LOCATION (c),
   17625                 :             :                             "%qE is predetermined %qs for %qs",
   17626                 :             :                             t, share_name,
   17627                 :          10 :                             omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   17628                 :          10 :                   remove = true;
   17629                 :             :                 }
   17630                 :        9513 :               else if (TREE_READONLY (t)
   17631                 :          23 :                        && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_SHARED
   17632                 :        9526 :                        && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_FIRSTPRIVATE)
   17633                 :             :                 {
   17634                 :           4 :                   error_at (OMP_CLAUSE_LOCATION (c),
   17635                 :             :                             "%<const%> qualified %qE may appear only in "
   17636                 :             :                             "%<shared%> or %<firstprivate%> clauses", t);
   17637                 :           4 :                   remove = true;
   17638                 :             :                 }
   17639                 :             :             }
   17640                 :             :         }
   17641                 :             : 
   17642                 :       21999 :       if (remove)
   17643                 :             :         {
   17644                 :         579 :           if (grp_start_p)
   17645                 :             :             {
   17646                 :             :               /* If we found a clause to remove, we want to remove the whole
   17647                 :             :                  expanded group, otherwise gimplify
   17648                 :             :                  (omp_resolve_clause_dependencies) can get confused.  */
   17649                 :         154 :               *grp_start_p = grp_sentinel;
   17650                 :         154 :               pc = grp_start_p;
   17651                 :         154 :               grp_start_p = NULL;
   17652                 :             :             }
   17653                 :             :           else
   17654                 :         425 :             *pc = OMP_CLAUSE_CHAIN (c);
   17655                 :             :         }
   17656                 :             :       else
   17657                 :       21978 :         pc = &OMP_CLAUSE_CHAIN (c);
   17658                 :             :     }
   17659                 :             : 
   17660                 :       29166 :   if (simdlen
   17661                 :       29166 :       && safelen
   17662                 :       29283 :       && tree_int_cst_lt (OMP_CLAUSE_SAFELEN_EXPR (safelen),
   17663                 :         117 :                           OMP_CLAUSE_SIMDLEN_EXPR (simdlen)))
   17664                 :             :     {
   17665                 :           0 :       error_at (OMP_CLAUSE_LOCATION (simdlen),
   17666                 :             :                 "%<simdlen%> clause value is bigger than "
   17667                 :             :                 "%<safelen%> clause value");
   17668                 :           0 :       OMP_CLAUSE_SIMDLEN_EXPR (simdlen)
   17669                 :           0 :         = OMP_CLAUSE_SAFELEN_EXPR (safelen);
   17670                 :             :     }
   17671                 :             : 
   17672                 :       29166 :   if (ordered_clause
   17673                 :       29166 :       && schedule_clause
   17674                 :       29166 :       && (OMP_CLAUSE_SCHEDULE_KIND (schedule_clause)
   17675                 :             :           & OMP_CLAUSE_SCHEDULE_NONMONOTONIC))
   17676                 :             :     {
   17677                 :           7 :       error_at (OMP_CLAUSE_LOCATION (schedule_clause),
   17678                 :             :                 "%<nonmonotonic%> schedule modifier specified together "
   17679                 :             :                 "with %<ordered%> clause");
   17680                 :          14 :       OMP_CLAUSE_SCHEDULE_KIND (schedule_clause)
   17681                 :           7 :         = (enum omp_clause_schedule_kind)
   17682                 :           7 :           (OMP_CLAUSE_SCHEDULE_KIND (schedule_clause)
   17683                 :             :            & ~OMP_CLAUSE_SCHEDULE_NONMONOTONIC);
   17684                 :             :     }
   17685                 :             : 
   17686                 :       29166 :   if (reduction_seen < 0 && ordered_clause)
   17687                 :             :     {
   17688                 :           2 :       error_at (OMP_CLAUSE_LOCATION (ordered_clause),
   17689                 :             :                 "%qs clause specified together with %<inscan%> "
   17690                 :             :                 "%<reduction%> clause", "ordered");
   17691                 :           2 :       reduction_seen = -2;
   17692                 :             :     }
   17693                 :             : 
   17694                 :       29166 :   if (reduction_seen < 0 && schedule_clause)
   17695                 :             :     {
   17696                 :           3 :       error_at (OMP_CLAUSE_LOCATION (schedule_clause),
   17697                 :             :                 "%qs clause specified together with %<inscan%> "
   17698                 :             :                 "%<reduction%> clause", "schedule");
   17699                 :           3 :       reduction_seen = -2;
   17700                 :             :     }
   17701                 :             : 
   17702                 :       29166 :   if (linear_variable_step_check
   17703                 :       29166 :       || reduction_seen == -2
   17704                 :             :       || allocate_seen
   17705                 :       29154 :       || target_in_reduction_seen)
   17706                 :        5145 :     for (pc = &clauses, c = clauses; c ; c = *pc)
   17707                 :             :       {
   17708                 :        4556 :         bool remove = false;
   17709                 :        4556 :         if (allocate_seen)
   17710                 :        4398 :           switch (OMP_CLAUSE_CODE (c))
   17711                 :             :             {
   17712                 :         430 :             case OMP_CLAUSE_REDUCTION:
   17713                 :         430 :             case OMP_CLAUSE_IN_REDUCTION:
   17714                 :         430 :             case OMP_CLAUSE_TASK_REDUCTION:
   17715                 :         430 :               if (TREE_CODE (OMP_CLAUSE_DECL (c)) == MEM_REF)
   17716                 :             :                 {
   17717                 :          23 :                   t = TREE_OPERAND (OMP_CLAUSE_DECL (c), 0);
   17718                 :          23 :                   if (TREE_CODE (t) == POINTER_PLUS_EXPR)
   17719                 :           0 :                     t = TREE_OPERAND (t, 0);
   17720                 :          23 :                   if (TREE_CODE (t) == ADDR_EXPR
   17721                 :          10 :                       || INDIRECT_REF_P (t))
   17722                 :          13 :                     t = TREE_OPERAND (t, 0);
   17723                 :          23 :                   if (DECL_P (t))
   17724                 :          23 :                     bitmap_clear_bit (&aligned_head, DECL_UID (t));
   17725                 :             :                   break;
   17726                 :             :                 }
   17727                 :             :               /* FALLTHRU */
   17728                 :        1302 :             case OMP_CLAUSE_PRIVATE:
   17729                 :        1302 :             case OMP_CLAUSE_FIRSTPRIVATE:
   17730                 :        1302 :             case OMP_CLAUSE_LASTPRIVATE:
   17731                 :        1302 :             case OMP_CLAUSE_LINEAR:
   17732                 :        1302 :               if (DECL_P (OMP_CLAUSE_DECL (c)))
   17733                 :        2604 :                 bitmap_clear_bit (&aligned_head,
   17734                 :        1302 :                                   DECL_UID (OMP_CLAUSE_DECL (c)));
   17735                 :             :               break;
   17736                 :             :             default:
   17737                 :             :               break;
   17738                 :             :             }
   17739                 :        4556 :         if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_LINEAR
   17740                 :          29 :             && OMP_CLAUSE_LINEAR_VARIABLE_STRIDE (c)
   17741                 :        4563 :             && !bitmap_bit_p (&map_head,
   17742                 :           7 :                               DECL_UID (OMP_CLAUSE_LINEAR_STEP (c))))
   17743                 :             :           {
   17744                 :           2 :             error_at (OMP_CLAUSE_LOCATION (c),
   17745                 :             :                       "%<linear%> clause step is a parameter %qD not "
   17746                 :             :                       "specified in %<uniform%> clause",
   17747                 :           2 :                       OMP_CLAUSE_LINEAR_STEP (c));
   17748                 :           2 :             remove = true;
   17749                 :             :           }
   17750                 :        4554 :         else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION
   17751                 :        4554 :                  && reduction_seen == -2)
   17752                 :           9 :           OMP_CLAUSE_REDUCTION_INSCAN (c) = 0;
   17753                 :        4556 :         if (target_in_reduction_seen
   17754                 :        4556 :             && OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP)
   17755                 :             :           {
   17756                 :         256 :             tree t = OMP_CLAUSE_DECL (c);
   17757                 :         256 :             while (handled_component_p (t)
   17758                 :             :                    || INDIRECT_REF_P (t)
   17759                 :             :                    || TREE_CODE (t) == ADDR_EXPR
   17760                 :             :                    || TREE_CODE (t) == MEM_REF
   17761                 :         288 :                    || TREE_CODE (t) == NON_LVALUE_EXPR)
   17762                 :          32 :               t = TREE_OPERAND (t, 0);
   17763                 :         256 :             if (DECL_P (t)
   17764                 :         256 :                 && bitmap_bit_p (&oacc_reduction_head, DECL_UID (t)))
   17765                 :         138 :               OMP_CLAUSE_MAP_IN_REDUCTION (c) = 1;
   17766                 :             :           }
   17767                 :             : 
   17768                 :        4556 :         if (remove)
   17769                 :           2 :           *pc = OMP_CLAUSE_CHAIN (c);
   17770                 :             :         else
   17771                 :        4554 :           pc = &OMP_CLAUSE_CHAIN (c);
   17772                 :             :       }
   17773                 :             : 
   17774                 :         589 :   if (allocate_seen)
   17775                 :        4961 :     for (pc = &clauses, c = clauses; c ; c = *pc)
   17776                 :             :       {
   17777                 :        4398 :         bool remove = false;
   17778                 :        4398 :         if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_ALLOCATE
   17779                 :         704 :             && !OMP_CLAUSE_ALLOCATE_COMBINED (c)
   17780                 :        5082 :             && bitmap_bit_p (&aligned_head, DECL_UID (OMP_CLAUSE_DECL (c))))
   17781                 :             :           {
   17782                 :           3 :             error_at (OMP_CLAUSE_LOCATION (c),
   17783                 :             :                       "%qD specified in %<allocate%> clause but not in "
   17784                 :           3 :                       "an explicit privatization clause", OMP_CLAUSE_DECL (c));
   17785                 :           3 :             remove = true;
   17786                 :             :           }
   17787                 :        4398 :         if (remove)
   17788                 :           3 :           *pc = OMP_CLAUSE_CHAIN (c);
   17789                 :             :         else
   17790                 :        4395 :           pc = &OMP_CLAUSE_CHAIN (c);
   17791                 :             :       }
   17792                 :             : 
   17793                 :       29166 :   if (nogroup_seen && reduction_seen)
   17794                 :             :     {
   17795                 :           1 :       error_at (OMP_CLAUSE_LOCATION (*nogroup_seen),
   17796                 :             :                 "%<nogroup%> clause must not be used together with "
   17797                 :             :                 "%<reduction%> clause");
   17798                 :           1 :       *nogroup_seen = OMP_CLAUSE_CHAIN (*nogroup_seen);
   17799                 :             :     }
   17800                 :             : 
   17801                 :       29166 :   if (grainsize_seen && num_tasks_seen)
   17802                 :             :     {
   17803                 :           2 :       error_at (OMP_CLAUSE_LOCATION (*grainsize_seen),
   17804                 :             :                 "%<grainsize%> clause must not be used together with "
   17805                 :             :                 "%<num_tasks%> clause");
   17806                 :           2 :       *grainsize_seen = OMP_CLAUSE_CHAIN (*grainsize_seen);
   17807                 :             :     }
   17808                 :             : 
   17809                 :       29166 :   if (full_seen && partial_seen)
   17810                 :             :     {
   17811                 :           4 :       error_at (OMP_CLAUSE_LOCATION (*full_seen),
   17812                 :             :                 "%<full%> clause must not be used together with "
   17813                 :             :                 "%<partial%> clause");
   17814                 :           4 :       *full_seen = OMP_CLAUSE_CHAIN (*full_seen);
   17815                 :             :     }
   17816                 :             : 
   17817                 :       29166 :   if (detach_seen)
   17818                 :             :     {
   17819                 :          31 :       if (mergeable_seen)
   17820                 :             :         {
   17821                 :           2 :           error_at (OMP_CLAUSE_LOCATION (*detach_seen),
   17822                 :             :                     "%<detach%> clause must not be used together with "
   17823                 :             :                     "%<mergeable%> clause");
   17824                 :           2 :           *detach_seen = OMP_CLAUSE_CHAIN (*detach_seen);
   17825                 :             :         }
   17826                 :             :       else
   17827                 :             :         {
   17828                 :          29 :           tree detach_decl = OMP_CLAUSE_DECL (*detach_seen);
   17829                 :             : 
   17830                 :          79 :           for (pc = &clauses, c = clauses; c ; c = *pc)
   17831                 :             :             {
   17832                 :          50 :               bool remove = false;
   17833                 :          50 :               if ((OMP_CLAUSE_CODE (c) == OMP_CLAUSE_SHARED
   17834                 :          48 :                    || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_PRIVATE
   17835                 :          48 :                    || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_FIRSTPRIVATE
   17836                 :          44 :                    || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_LASTPRIVATE)
   17837                 :          54 :                   && OMP_CLAUSE_DECL (c) == detach_decl)
   17838                 :             :                 {
   17839                 :           2 :                   error_at (OMP_CLAUSE_LOCATION (c),
   17840                 :             :                             "the event handle of a %<detach%> clause "
   17841                 :             :                             "should not be in a data-sharing clause");
   17842                 :           2 :                   remove = true;
   17843                 :             :                 }
   17844                 :          50 :               if (remove)
   17845                 :           2 :                 *pc = OMP_CLAUSE_CHAIN (c);
   17846                 :             :               else
   17847                 :          48 :                 pc = &OMP_CLAUSE_CHAIN (c);
   17848                 :             :             }
   17849                 :             :         }
   17850                 :             :     }
   17851                 :             : 
   17852                 :       29166 :   if (ort == C_ORT_OMP_INTEROP
   17853                 :       29166 :       && depend_clause
   17854                 :          21 :       && (!init_use_destroy_seen
   17855                 :          20 :           || (init_seen && init_no_targetsync_clause)))
   17856                 :             :     {
   17857                 :           3 :       error_at (OMP_CLAUSE_LOCATION (depend_clause),
   17858                 :             :                 "%<depend%> clause requires action clauses with "
   17859                 :             :                 "%<targetsync%> interop-type");
   17860                 :           3 :       if (init_no_targetsync_clause)
   17861                 :           2 :         inform (OMP_CLAUSE_LOCATION (init_no_targetsync_clause),
   17862                 :             :                 "%<init%> clause lacks the %<targetsync%> modifier");
   17863                 :             :     }
   17864                 :             : 
   17865                 :       29166 :   bitmap_obstack_release (NULL);
   17866                 :       29166 :   return clauses;
   17867                 :             : }
   17868                 :             : 
   17869                 :             : /* Do processing necessary to make CLAUSES well-formed, where CLAUSES result
   17870                 :             :    from implicit instantiation of user-defined mappers (in gimplify.cc).  */
   17871                 :             : 
   17872                 :             : tree
   17873                 :          13 : c_omp_finish_mapper_clauses (tree clauses)
   17874                 :             : {
   17875                 :          13 :   return c_finish_omp_clauses (clauses, C_ORT_OMP);
   17876                 :             : }
   17877                 :             : 
   17878                 :             : /* Return code to initialize DST with a copy constructor from SRC.
   17879                 :             :    C doesn't have copy constructors nor assignment operators, only for
   17880                 :             :    _Atomic vars we need to perform __atomic_load from src into a temporary
   17881                 :             :    followed by __atomic_store of the temporary to dst.  */
   17882                 :             : 
   17883                 :             : tree
   17884                 :       18709 : c_omp_clause_copy_ctor (tree clause, tree dst, tree src)
   17885                 :             : {
   17886                 :       18709 :   if (!really_atomic_lvalue (dst) && !really_atomic_lvalue (src))
   17887                 :       18705 :     return build2 (MODIFY_EXPR, TREE_TYPE (dst), dst, src);
   17888                 :             : 
   17889                 :           4 :   location_t loc = OMP_CLAUSE_LOCATION (clause);
   17890                 :           4 :   tree type = TREE_TYPE (dst);
   17891                 :           4 :   tree nonatomic_type = build_qualified_type (type, TYPE_UNQUALIFIED);
   17892                 :           4 :   tree tmp = create_tmp_var (nonatomic_type);
   17893                 :           4 :   tree tmp_addr = build_fold_addr_expr (tmp);
   17894                 :           4 :   TREE_ADDRESSABLE (tmp) = 1;
   17895                 :           4 :   suppress_warning (tmp);
   17896                 :           4 :   tree src_addr = build_fold_addr_expr (src);
   17897                 :           4 :   tree dst_addr = build_fold_addr_expr (dst);
   17898                 :           4 :   tree seq_cst = build_int_cst (integer_type_node, MEMMODEL_SEQ_CST);
   17899                 :           4 :   vec<tree, va_gc> *params;
   17900                 :             :   /* Expansion of a generic atomic load may require an addition
   17901                 :             :      element, so allocate enough to prevent a resize.  */
   17902                 :           4 :   vec_alloc (params, 4);
   17903                 :             : 
   17904                 :             :   /* Build __atomic_load (&src, &tmp, SEQ_CST);  */
   17905                 :           4 :   tree fndecl = builtin_decl_explicit (BUILT_IN_ATOMIC_LOAD);
   17906                 :           4 :   params->quick_push (src_addr);
   17907                 :           4 :   params->quick_push (tmp_addr);
   17908                 :           4 :   params->quick_push (seq_cst);
   17909                 :           4 :   tree load = c_build_function_call_vec (loc, vNULL, fndecl, params, NULL);
   17910                 :             : 
   17911                 :           4 :   vec_alloc (params, 4);
   17912                 :             : 
   17913                 :             :   /* Build __atomic_store (&dst, &tmp, SEQ_CST);  */
   17914                 :           4 :   fndecl = builtin_decl_explicit (BUILT_IN_ATOMIC_STORE);
   17915                 :           4 :   params->quick_push (dst_addr);
   17916                 :           4 :   params->quick_push (tmp_addr);
   17917                 :           4 :   params->quick_push (seq_cst);
   17918                 :           4 :   tree store = c_build_function_call_vec (loc, vNULL, fndecl, params, NULL);
   17919                 :           4 :   return build2 (COMPOUND_EXPR, void_type_node, load, store);
   17920                 :             : }
   17921                 :             : 
   17922                 :             : /* Create a transaction node.  */
   17923                 :             : 
   17924                 :             : tree
   17925                 :         135 : c_finish_transaction (location_t loc, tree block, int flags)
   17926                 :             : {
   17927                 :         135 :   tree stmt = build_stmt (loc, TRANSACTION_EXPR, block);
   17928                 :         135 :   if (flags & TM_STMT_ATTR_OUTER)
   17929                 :          10 :     TRANSACTION_EXPR_OUTER (stmt) = 1;
   17930                 :         135 :   if (flags & TM_STMT_ATTR_RELAXED)
   17931                 :          31 :     TRANSACTION_EXPR_RELAXED (stmt) = 1;
   17932                 :         135 :   return add_stmt (stmt);
   17933                 :             : }
   17934                 :             : 
   17935                 :             : /* Make a variant type in the proper way for C/C++, propagating qualifiers
   17936                 :             :    down to the element type of an array.  If ORIG_QUAL_TYPE is not
   17937                 :             :    NULL, then it should be used as the qualified type
   17938                 :             :    ORIG_QUAL_INDIRECT levels down in array type derivation (to
   17939                 :             :    preserve information about the typedef name from which an array
   17940                 :             :    type was derived).  */
   17941                 :             : 
   17942                 :             : tree
   17943                 :    72634368 : c_build_qualified_type (tree type, int type_quals, tree orig_qual_type,
   17944                 :             :                         size_t orig_qual_indirect)
   17945                 :             : {
   17946                 :    72634368 :   if (type == error_mark_node)
   17947                 :             :     return type;
   17948                 :             : 
   17949                 :    72634222 :   if (TREE_CODE (type) == ARRAY_TYPE)
   17950                 :             :     {
   17951                 :     3112681 :       tree t;
   17952                 :     3112681 :       tree element_type = c_build_qualified_type (TREE_TYPE (type),
   17953                 :             :                                                   type_quals, orig_qual_type,
   17954                 :             :                                                   orig_qual_indirect - 1);
   17955                 :             : 
   17956                 :             :       /* See if we already have an identically qualified type.  */
   17957                 :     3112681 :       if (orig_qual_type && orig_qual_indirect == 0)
   17958                 :             :         t = orig_qual_type;
   17959                 :             :       else
   17960                 :     4547567 :         for (t = TYPE_MAIN_VARIANT (type); t; t = TYPE_NEXT_VARIANT (t))
   17961                 :             :           {
   17962                 :     4409708 :             if (TYPE_QUALS (strip_array_types (t)) == type_quals
   17963                 :     2995373 :                 && TYPE_NAME (t) == TYPE_NAME (type)
   17964                 :     2974781 :                 && TYPE_CONTEXT (t) == TYPE_CONTEXT (type)
   17965                 :     7384489 :                 && attribute_list_equal (TYPE_ATTRIBUTES (t),
   17966                 :     2974781 :                                          TYPE_ATTRIBUTES (type)))
   17967                 :             :               break;
   17968                 :             :           }
   17969                 :     3112640 :       if (!t)
   17970                 :             :         {
   17971                 :      137859 :           tree domain = TYPE_DOMAIN (type);
   17972                 :             : 
   17973                 :      137859 :           t = build_variant_type_copy (type);
   17974                 :      137859 :           TREE_TYPE (t) = element_type;
   17975                 :      137859 :           TYPE_ADDR_SPACE (t) = TYPE_ADDR_SPACE (element_type);
   17976                 :             : 
   17977                 :      137859 :           if (TYPE_STRUCTURAL_EQUALITY_P (element_type)
   17978                 :      137859 :               || (domain && TYPE_STRUCTURAL_EQUALITY_P (domain)))
   17979                 :         179 :             SET_TYPE_STRUCTURAL_EQUALITY (t);
   17980                 :      137680 :           else if (TYPE_CANONICAL (element_type) != element_type
   17981                 :      137680 :                    || (domain && TYPE_CANONICAL (domain) != domain))
   17982                 :             :             {
   17983                 :        2686 :               tree unqualified_canon
   17984                 :        5164 :                 = c_build_array_type (TYPE_CANONICAL (element_type),
   17985                 :        2478 :                                       domain ? TYPE_CANONICAL (domain)
   17986                 :             :                                              : NULL_TREE);
   17987                 :        2686 :               if (TYPE_REVERSE_STORAGE_ORDER (type))
   17988                 :             :                 {
   17989                 :           0 :                   unqualified_canon
   17990                 :           0 :                     = build_distinct_type_copy (unqualified_canon);
   17991                 :           0 :                   TYPE_REVERSE_STORAGE_ORDER (unqualified_canon) = 1;
   17992                 :             :                 }
   17993                 :        2686 :               TYPE_CANONICAL (t)
   17994                 :        5372 :                 = c_build_qualified_type (unqualified_canon, type_quals);
   17995                 :             :             }
   17996                 :             :           else
   17997                 :      134994 :             TYPE_CANONICAL (t) = t;
   17998                 :             :         }
   17999                 :     3112681 :       return t;
   18000                 :             :     }
   18001                 :             : 
   18002                 :             :   /* A restrict-qualified pointer type must be a pointer to object or
   18003                 :             :      incomplete type.  Note that the use of POINTER_TYPE_P also allows
   18004                 :             :      REFERENCE_TYPEs, which is appropriate for C++.  */
   18005                 :    69521541 :   if ((type_quals & TYPE_QUAL_RESTRICT)
   18006                 :    69521541 :       && (!POINTER_TYPE_P (type)
   18007                 :     3327727 :           || !C_TYPE_OBJECT_OR_INCOMPLETE_P (TREE_TYPE (type))))
   18008                 :             :     {
   18009                 :           3 :       error ("invalid use of %<restrict%>");
   18010                 :           3 :       type_quals &= ~TYPE_QUAL_RESTRICT;
   18011                 :             :     }
   18012                 :             : 
   18013                 :    69521541 :   tree var_type = (orig_qual_type && orig_qual_indirect == 0
   18014                 :    69521541 :                    ? orig_qual_type
   18015                 :    69521524 :                    : build_qualified_type (type, type_quals));
   18016                 :             : 
   18017                 :    69521541 :   gcc_checking_assert (C_TYPE_VARIABLE_SIZE (var_type)
   18018                 :             :                        == C_TYPE_VARIABLE_SIZE (type));
   18019                 :    69521541 :   gcc_checking_assert (C_TYPE_VARIABLY_MODIFIED (var_type)
   18020                 :             :                        == C_TYPE_VARIABLY_MODIFIED (type));
   18021                 :             : 
   18022                 :             :   /* A variant type does not inherit the list of incomplete vars from the
   18023                 :             :      type main variant.  */
   18024                 :    69521541 :   if ((RECORD_OR_UNION_TYPE_P (var_type)
   18025                 :    67637010 :        || TREE_CODE (var_type) == ENUMERAL_TYPE)
   18026                 :    69621920 :       && TYPE_MAIN_VARIANT (var_type) != var_type)
   18027                 :     1382239 :     C_TYPE_INCOMPLETE_VARS (var_type) = 0;
   18028                 :             :   return var_type;
   18029                 :             : }
   18030                 :             : 
   18031                 :             : /* Build a VA_ARG_EXPR for the C parser.  */
   18032                 :             : 
   18033                 :             : tree
   18034                 :       19882 : c_build_va_arg (location_t loc1, tree expr, location_t loc2, tree type)
   18035                 :             : {
   18036                 :       19882 :   if (error_operand_p (type))
   18037                 :           2 :     return error_mark_node;
   18038                 :             :   /* VA_ARG_EXPR cannot be used for a scalar va_list with reverse storage
   18039                 :             :      order because it takes the address of the expression.  */
   18040                 :       19880 :   else if (handled_component_p (expr)
   18041                 :          31 :            && reverse_storage_order_for_component_p (expr))
   18042                 :             :     {
   18043                 :           0 :       error_at (loc1, "cannot use %<va_arg%> with reverse storage order");
   18044                 :           0 :       return error_mark_node;
   18045                 :             :     }
   18046                 :       19880 :   else if (!COMPLETE_TYPE_P (type))
   18047                 :             :     {
   18048                 :          11 :       error_at (loc2, "second argument to %<va_arg%> is of incomplete "
   18049                 :             :                 "type %qT", type);
   18050                 :          11 :       return error_mark_node;
   18051                 :             :     }
   18052                 :       19869 :   else if (TREE_CODE (type) == FUNCTION_TYPE)
   18053                 :             :     {
   18054                 :           1 :       error_at (loc2, "second argument to %<va_arg%> is a function type %qT",
   18055                 :             :                 type);
   18056                 :           1 :       return error_mark_node;
   18057                 :             :     }
   18058                 :       19868 :   else if (warn_cxx_compat && TREE_CODE (type) == ENUMERAL_TYPE)
   18059                 :           1 :     warning_at (loc2, OPT_Wc___compat,
   18060                 :             :                 "C++ requires promoted type, not enum type, in %<va_arg%>");
   18061                 :       19868 :   return build_va_arg (loc2, expr, type);
   18062                 :             : }
   18063                 :             : 
   18064                 :             : /* Return truthvalue of whether T1 is the same tree structure as T2.
   18065                 :             :    Return 1 if they are the same. Return false if they are different.  */
   18066                 :             : 
   18067                 :             : bool
   18068                 :        1854 : c_tree_equal (tree t1, tree t2)
   18069                 :             : {
   18070                 :        1883 :   enum tree_code code1, code2;
   18071                 :             : 
   18072                 :        1883 :   if (t1 == t2)
   18073                 :             :     return true;
   18074                 :         661 :   if (!t1 || !t2)
   18075                 :             :     return false;
   18076                 :             : 
   18077                 :         681 :   for (code1 = TREE_CODE (t1); code1 == NON_LVALUE_EXPR;
   18078                 :          20 :        code1 = TREE_CODE (t1))
   18079                 :          20 :     t1 = TREE_OPERAND (t1, 0);
   18080                 :         682 :   for (code2 = TREE_CODE (t2); code2 == NON_LVALUE_EXPR;
   18081                 :          21 :        code2 = TREE_CODE (t2))
   18082                 :          21 :     t2 = TREE_OPERAND (t2, 0);
   18083                 :             : 
   18084                 :             :   /* They might have become equal now.  */
   18085                 :         661 :   if (t1 == t2)
   18086                 :             :     return true;
   18087                 :             : 
   18088                 :         640 :   if (code1 != code2)
   18089                 :             :     return false;
   18090                 :             : 
   18091                 :         379 :   if (CONSTANT_CLASS_P (t1) && !comptypes (TREE_TYPE (t1), TREE_TYPE (t2)))
   18092                 :             :     return false;
   18093                 :             : 
   18094                 :         379 :   switch (code1)
   18095                 :             :     {
   18096                 :           2 :     case INTEGER_CST:
   18097                 :           2 :       return wi::to_wide (t1) == wi::to_wide (t2);
   18098                 :             : 
   18099                 :          10 :     case REAL_CST:
   18100                 :          10 :       return real_equal (&TREE_REAL_CST (t1), &TREE_REAL_CST (t2));
   18101                 :             : 
   18102                 :           0 :     case STRING_CST:
   18103                 :           0 :       return TREE_STRING_LENGTH (t1) == TREE_STRING_LENGTH (t2)
   18104                 :           0 :         && !memcmp (TREE_STRING_POINTER (t1), TREE_STRING_POINTER (t2),
   18105                 :           0 :                     TREE_STRING_LENGTH (t1));
   18106                 :             : 
   18107                 :           0 :     case FIXED_CST:
   18108                 :           0 :       return FIXED_VALUES_IDENTICAL (TREE_FIXED_CST (t1),
   18109                 :             :                                      TREE_FIXED_CST (t2));
   18110                 :             : 
   18111                 :           0 :     case COMPLEX_CST:
   18112                 :           0 :       return c_tree_equal (TREE_REALPART (t1), TREE_REALPART (t2))
   18113                 :           0 :              && c_tree_equal (TREE_IMAGPART (t1), TREE_IMAGPART (t2));
   18114                 :             : 
   18115                 :           0 :     case VECTOR_CST:
   18116                 :           0 :       return operand_equal_p (t1, t2, OEP_ONLY_CONST);
   18117                 :             : 
   18118                 :           0 :     case CONSTRUCTOR:
   18119                 :             :       /* We need to do this when determining whether or not two
   18120                 :             :          non-type pointer to member function template arguments
   18121                 :             :          are the same.  */
   18122                 :           0 :       if (!comptypes (TREE_TYPE (t1), TREE_TYPE (t2))
   18123                 :           0 :           || CONSTRUCTOR_NELTS (t1) != CONSTRUCTOR_NELTS (t2))
   18124                 :             :         return false;
   18125                 :             :       {
   18126                 :             :         tree field, value;
   18127                 :             :         unsigned int i;
   18128                 :           0 :         FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (t1), i, field, value)
   18129                 :             :           {
   18130                 :           0 :             constructor_elt *elt2 = CONSTRUCTOR_ELT (t2, i);
   18131                 :           0 :             if (!c_tree_equal (field, elt2->index)
   18132                 :           0 :                 || !c_tree_equal (value, elt2->value))
   18133                 :           0 :               return false;
   18134                 :             :           }
   18135                 :             :       }
   18136                 :             :       return true;
   18137                 :             : 
   18138                 :           0 :     case TREE_LIST:
   18139                 :           0 :       if (!c_tree_equal (TREE_PURPOSE (t1), TREE_PURPOSE (t2)))
   18140                 :             :         return false;
   18141                 :           0 :       if (!c_tree_equal (TREE_VALUE (t1), TREE_VALUE (t2)))
   18142                 :             :         return false;
   18143                 :           0 :       return c_tree_equal (TREE_CHAIN (t1), TREE_CHAIN (t2));
   18144                 :             : 
   18145                 :           0 :     case SAVE_EXPR:
   18146                 :           0 :       return c_tree_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0));
   18147                 :             : 
   18148                 :          25 :     case CALL_EXPR:
   18149                 :          25 :       {
   18150                 :          25 :         tree arg1, arg2;
   18151                 :          25 :         call_expr_arg_iterator iter1, iter2;
   18152                 :          25 :         if (!c_tree_equal (CALL_EXPR_FN (t1), CALL_EXPR_FN (t2)))
   18153                 :             :           return false;
   18154                 :          50 :         for (arg1 = first_call_expr_arg (t1, &iter1),
   18155                 :          25 :                arg2 = first_call_expr_arg (t2, &iter2);
   18156                 :          25 :              arg1 && arg2;
   18157                 :           0 :              arg1 = next_call_expr_arg (&iter1),
   18158                 :           0 :                arg2 = next_call_expr_arg (&iter2))
   18159                 :           0 :           if (!c_tree_equal (arg1, arg2))
   18160                 :             :             return false;
   18161                 :          25 :         if (arg1 || arg2)
   18162                 :             :           return false;
   18163                 :             :         return true;
   18164                 :             :       }
   18165                 :             : 
   18166                 :           0 :     case TARGET_EXPR:
   18167                 :           0 :       {
   18168                 :           0 :         tree o1 = TREE_OPERAND (t1, 0);
   18169                 :           0 :         tree o2 = TREE_OPERAND (t2, 0);
   18170                 :             : 
   18171                 :             :         /* Special case: if either target is an unallocated VAR_DECL,
   18172                 :             :            it means that it's going to be unified with whatever the
   18173                 :             :            TARGET_EXPR is really supposed to initialize, so treat it
   18174                 :             :            as being equivalent to anything.  */
   18175                 :           0 :         if (VAR_P (o1) && DECL_NAME (o1) == NULL_TREE
   18176                 :           0 :             && !DECL_RTL_SET_P (o1))
   18177                 :             :           /*Nop*/;
   18178                 :           0 :         else if (VAR_P (o2) && DECL_NAME (o2) == NULL_TREE
   18179                 :           0 :                  && !DECL_RTL_SET_P (o2))
   18180                 :             :           /*Nop*/;
   18181                 :           0 :         else if (!c_tree_equal (o1, o2))
   18182                 :             :           return false;
   18183                 :             : 
   18184                 :           0 :         return c_tree_equal (TREE_OPERAND (t1, 1), TREE_OPERAND (t2, 1));
   18185                 :             :       }
   18186                 :             : 
   18187                 :          29 :     case COMPONENT_REF:
   18188                 :          29 :       if (TREE_OPERAND (t1, 1) != TREE_OPERAND (t2, 1))
   18189                 :             :         return false;
   18190                 :          29 :       return c_tree_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0));
   18191                 :             : 
   18192                 :             :     case PARM_DECL:
   18193                 :             :     case VAR_DECL:
   18194                 :             :     case CONST_DECL:
   18195                 :             :     case FIELD_DECL:
   18196                 :             :     case FUNCTION_DECL:
   18197                 :             :     case IDENTIFIER_NODE:
   18198                 :             :     case SSA_NAME:
   18199                 :             :       return false;
   18200                 :             : 
   18201                 :           0 :     case TREE_VEC:
   18202                 :           0 :       {
   18203                 :           0 :         unsigned ix;
   18204                 :           0 :         if (TREE_VEC_LENGTH (t1) != TREE_VEC_LENGTH (t2))
   18205                 :             :           return false;
   18206                 :           0 :         for (ix = TREE_VEC_LENGTH (t1); ix--;)
   18207                 :           0 :           if (!c_tree_equal (TREE_VEC_ELT (t1, ix),
   18208                 :           0 :                              TREE_VEC_ELT (t2, ix)))
   18209                 :             :             return false;
   18210                 :             :         return true;
   18211                 :             :       }
   18212                 :             : 
   18213                 :          22 :     CASE_CONVERT:
   18214                 :          22 :       if (!comptypes (TREE_TYPE (t1), TREE_TYPE (t2)))
   18215                 :             :         return false;
   18216                 :             :       break;
   18217                 :             : 
   18218                 :             :     default:
   18219                 :             :       break;
   18220                 :             :     }
   18221                 :             : 
   18222                 :         131 :   switch (TREE_CODE_CLASS (code1))
   18223                 :             :     {
   18224                 :         131 :     case tcc_unary:
   18225                 :         131 :     case tcc_binary:
   18226                 :         131 :     case tcc_comparison:
   18227                 :         131 :     case tcc_expression:
   18228                 :         131 :     case tcc_vl_exp:
   18229                 :         131 :     case tcc_reference:
   18230                 :         131 :     case tcc_statement:
   18231                 :         131 :       {
   18232                 :         131 :         int i, n = TREE_OPERAND_LENGTH (t1);
   18233                 :             : 
   18234                 :         131 :         switch (code1)
   18235                 :             :           {
   18236                 :           0 :           case PREINCREMENT_EXPR:
   18237                 :           0 :           case PREDECREMENT_EXPR:
   18238                 :           0 :           case POSTINCREMENT_EXPR:
   18239                 :           0 :           case POSTDECREMENT_EXPR:
   18240                 :           0 :             n = 1;
   18241                 :           0 :             break;
   18242                 :          16 :           case ARRAY_REF:
   18243                 :          16 :             n = 2;
   18244                 :          16 :             break;
   18245                 :             :           default:
   18246                 :             :             break;
   18247                 :             :           }
   18248                 :             : 
   18249                 :         131 :         if (TREE_CODE_CLASS (code1) == tcc_vl_exp
   18250                 :         131 :             && n != TREE_OPERAND_LENGTH (t2))
   18251                 :             :           return false;
   18252                 :             : 
   18253                 :         305 :         for (i = 0; i < n; ++i)
   18254                 :         186 :           if (!c_tree_equal (TREE_OPERAND (t1, i), TREE_OPERAND (t2, i)))
   18255                 :             :             return false;
   18256                 :             : 
   18257                 :             :         return true;
   18258                 :             :       }
   18259                 :             : 
   18260                 :           0 :     case tcc_type:
   18261                 :           0 :       return comptypes (t1, t2);
   18262                 :           0 :     default:
   18263                 :           0 :       gcc_unreachable ();
   18264                 :             :     }
   18265                 :             : }
   18266                 :             : 
   18267                 :             : /* Returns true when the function declaration FNDECL is implicit,
   18268                 :             :    introduced as a result of a call to an otherwise undeclared
   18269                 :             :    function, and false otherwise.  */
   18270                 :             : 
   18271                 :             : bool
   18272                 :        2013 : c_decl_implicit (const_tree fndecl)
   18273                 :             : {
   18274                 :        2013 :   return C_DECL_IMPLICIT (fndecl);
   18275                 :             : }
        

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.