LCOV - code coverage report
Current view: top level - gcc/c - c-typeck.cc (source / functions) Coverage Total Hit
Test: gcc.info Lines: 93.8 % 9227 8651
Test Date: 2026-05-30 15:37:04 Functions: 99.5 % 207 206
Legend: Lines:     hit not hit

            Line data    Source code
       1              : /* Build expressions with type checking for C compiler.
       2              :    Copyright (C) 1987-2026 Free Software Foundation, Inc.
       3              : 
       4              : This file is part of GCC.
       5              : 
       6              : GCC is free software; you can redistribute it and/or modify it under
       7              : the terms of the GNU General Public License as published by the Free
       8              : Software Foundation; either version 3, or (at your option) any later
       9              : version.
      10              : 
      11              : GCC is distributed in the hope that it will be useful, but WITHOUT ANY
      12              : WARRANTY; without even the implied warranty of MERCHANTABILITY or
      13              : FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
      14              : for more details.
      15              : 
      16              : You should have received a copy of the GNU General Public License
      17              : along with GCC; see the file COPYING3.  If not see
      18              : <http://www.gnu.org/licenses/>.  */
      19              : 
      20              : 
      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              : /* The level of nesting inside "_Generic".  */
      82              : int in_generic;
      83              : 
      84              : /* True when parsing OpenMP loop expressions.  */
      85              : bool c_in_omp_for;
      86              : 
      87              : /* True when parsing OpenMP map clause.  */
      88              : bool c_omp_array_section_p;
      89              : 
      90              : /* The argument of last parsed sizeof expression, only to be tested
      91              :    if expr.original_code == SIZEOF_EXPR.  */
      92              : tree c_last_sizeof_arg;
      93              : location_t c_last_sizeof_loc;
      94              : 
      95              : /* Nonzero if we might need to print a "missing braces around
      96              :    initializer" message within this initializer.  */
      97              : static int found_missing_braces;
      98              : 
      99              : static bool require_constant_value;
     100              : static bool require_constant_elements;
     101              : static bool require_constexpr_value;
     102              : 
     103              : static tree qualify_type (tree, tree);
     104              : struct comptypes_data;
     105              : static bool tagged_types_tu_compatible_p (const_tree, const_tree,
     106              :                                           struct comptypes_data *);
     107              : static bool comp_target_types (location_t, tree, tree);
     108              : static bool function_types_compatible_p (const_tree, const_tree,
     109              :                                          struct comptypes_data *);
     110              : static bool type_lists_compatible_p (const_tree, const_tree,
     111              :                                      struct comptypes_data *);
     112              : static int convert_arguments (location_t, vec<location_t>, tree,
     113              :                               vec<tree, va_gc> *, vec<tree, va_gc> *, tree,
     114              :                               tree);
     115              : static tree pointer_diff (location_t, tree, tree, tree *);
     116              : static tree convert_for_assignment (location_t, location_t, tree, tree, tree,
     117              :                                     enum impl_conv, bool, tree, tree, int,
     118              :                                     int = 0);
     119              : static tree valid_compound_expr_initializer (tree, tree);
     120              : static void push_string (const char *);
     121              : static void push_member_name (tree);
     122              : static int spelling_length (void);
     123              : static char *print_spelling (char *);
     124              : static void warning_init (location_t, int, const char *);
     125              : static tree digest_init (location_t, tree, tree, tree, tree, bool, bool, bool,
     126              :                          bool, bool, bool);
     127              : static void output_init_element (location_t, tree, tree, bool, tree, tree, bool,
     128              :                                  bool, struct obstack *);
     129              : static void output_pending_init_elements (int, struct obstack *);
     130              : static bool set_designator (location_t, bool, struct obstack *);
     131              : static void push_range_stack (tree, struct obstack *);
     132              : static void add_pending_init (location_t, tree, tree, tree, bool,
     133              :                               struct obstack *);
     134              : static void set_nonincremental_init (struct obstack *);
     135              : static void set_nonincremental_init_from_string (tree, struct obstack *);
     136              : static tree find_init_member (tree, struct obstack *);
     137              : static void readonly_warning (tree, enum lvalue_use);
     138              : static int lvalue_or_else (location_t, const_tree, enum lvalue_use);
     139              : static void record_maybe_used_decl (tree, bool address);
     140              : static bool comptypes_internal (const_tree, const_tree,
     141              :                                 struct comptypes_data *data);
     142              : static bool comptypes_check_for_composite (tree t1, tree t2);
     143              : static bool handle_counted_by_p (tree);
     144              : 
     145              : /* Return true if EXP is a null pointer constant, false otherwise.  */
     146              : 
     147              : bool
     148    188661489 : null_pointer_constant_p (const_tree expr)
     149              : {
     150              :   /* This should really operate on c_expr structures, but they aren't
     151              :      yet available everywhere required.  */
     152    188661489 :   tree type = TREE_TYPE (expr);
     153              : 
     154              :   /* An integer constant expression with the value 0, such an expression
     155              :      cast to type void*, or the predefined constant nullptr, are a null
     156              :      pointer constant.  */
     157    188661489 :   if (expr == nullptr_node)
     158              :     return true;
     159              : 
     160    188660805 :   return (TREE_CODE (expr) == INTEGER_CST
     161     19109564 :           && !TREE_OVERFLOW (expr)
     162     19109467 :           && integer_zerop (expr)
     163    192596691 :           && (INTEGRAL_TYPE_P (type)
     164       336456 :               || (TREE_CODE (type) == POINTER_TYPE
     165       336454 :                   && VOID_TYPE_P (TREE_TYPE (type))
     166       261169 :                   && TYPE_QUALS (TREE_TYPE (type)) == TYPE_UNQUALIFIED)));
     167              : }
     168              : 
     169              : /* EXPR may appear in an unevaluated part of an integer constant
     170              :    expression, but not in an evaluated part.  Wrap it in a
     171              :    C_MAYBE_CONST_EXPR, or mark it with TREE_OVERFLOW if it is just an
     172              :    INTEGER_CST and we cannot create a C_MAYBE_CONST_EXPR.  */
     173              : 
     174              : static tree
     175        62357 : note_integer_operands (tree expr)
     176              : {
     177        62357 :   tree ret;
     178        62357 :   if (TREE_CODE (expr) == INTEGER_CST && in_late_binary_op)
     179              :     {
     180           22 :       ret = copy_node (expr);
     181           22 :       TREE_OVERFLOW (ret) = 1;
     182              :     }
     183              :   else
     184              :     {
     185        62335 :       ret = build2 (C_MAYBE_CONST_EXPR, TREE_TYPE (expr), NULL_TREE, expr);
     186        62335 :       C_MAYBE_CONST_EXPR_INT_OPERANDS (ret) = 1;
     187              :     }
     188        62357 :   return ret;
     189              : }
     190              : 
     191              : /* Having checked whether EXPR may appear in an unevaluated part of an
     192              :    integer constant expression and found that it may, remove any
     193              :    C_MAYBE_CONST_EXPR noting this fact and return the resulting
     194              :    expression.  */
     195              : 
     196              : static inline tree
     197     33778093 : remove_c_maybe_const_expr (tree expr)
     198              : {
     199     33778093 :   if (TREE_CODE (expr) == C_MAYBE_CONST_EXPR)
     200        61507 :     return C_MAYBE_CONST_EXPR_EXPR (expr);
     201              :   else
     202              :     return expr;
     203              : }
     204              : 
     205              : /* This is a cache to hold if two types are seen.  */
     206              : 
     207              : struct tagged_tu_seen_cache {
     208              :   const struct tagged_tu_seen_cache * next;
     209              :   const_tree t1;
     210              :   const_tree t2;
     211              : };
     212              : 
     213              : /* Do `exp = require_complete_type (loc, exp);' to make sure exp
     214              :    does not have an incomplete type.  (That includes void types.)
     215              :    LOC is the location of the use.  */
     216              : 
     217              : tree
     218    773703859 : require_complete_type (location_t loc, tree value)
     219              : {
     220    773703859 :   tree type = TREE_TYPE (value);
     221              : 
     222    773703859 :   if (error_operand_p (value))
     223         8908 :     return error_mark_node;
     224              : 
     225              :   /* First, detect a valid value with a complete type.  */
     226    773694951 :   if (COMPLETE_TYPE_P (type))
     227              :     return value;
     228              : 
     229          164 :   c_incomplete_type_error (loc, value, type);
     230          164 :   return error_mark_node;
     231              : }
     232              : 
     233              : /* Print an error message for invalid use of an incomplete type.
     234              :    VALUE is the expression that was used (or 0 if that isn't known)
     235              :    and TYPE is the type that was invalid.  LOC is the location for
     236              :    the error.  */
     237              : 
     238              : void
     239          232 : c_incomplete_type_error (location_t loc, const_tree value, const_tree type)
     240              : {
     241              :   /* Avoid duplicate error message.  */
     242          232 :   if (TREE_CODE (type) == ERROR_MARK)
     243              :     return;
     244              : 
     245          232 :   if (value != NULL_TREE && (VAR_P (value) || TREE_CODE (value) == PARM_DECL))
     246           98 :     error_at (loc, "%qD has an incomplete type %qT", value, type);
     247              :   else
     248              :     {
     249          134 :     retry:
     250              :       /* We must print an error message.  Be clever about what it says.  */
     251              : 
     252          134 :       switch (TREE_CODE (type))
     253              :         {
     254           90 :         case RECORD_TYPE:
     255           90 :         case UNION_TYPE:
     256           90 :         case ENUMERAL_TYPE:
     257           90 :           break;
     258              : 
     259           38 :         case VOID_TYPE:
     260           38 :           error_at (loc, "invalid use of void expression");
     261           38 :           return;
     262              : 
     263            6 :         case ARRAY_TYPE:
     264            6 :           if (TYPE_DOMAIN (type))
     265              :             {
     266            3 :               if (TYPE_MAX_VALUE (TYPE_DOMAIN (type)) == NULL)
     267              :                 {
     268            3 :                   error_at (loc, "invalid use of flexible array member");
     269            3 :                   return;
     270              :                 }
     271            0 :               type = TREE_TYPE (type);
     272            0 :               goto retry;
     273              :             }
     274            3 :           error_at (loc, "invalid use of array with unspecified bounds");
     275            3 :           return;
     276              : 
     277            0 :         default:
     278            0 :           gcc_unreachable ();
     279              :         }
     280              : 
     281           90 :       if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
     282           88 :         error_at (loc, "invalid use of undefined type %qT", type);
     283              :       else
     284              :         /* If this type has a typedef-name, the TYPE_NAME is a TYPE_DECL.  */
     285            2 :         error_at (loc, "invalid use of incomplete typedef %qT", type);
     286              :     }
     287              : }
     288              : 
     289              : /* Given a type, apply default promotions wrt unnamed function
     290              :    arguments and return the new type.  */
     291              : 
     292              : tree
     293    125107769 : c_type_promotes_to (tree type)
     294              : {
     295    125107769 :   tree ret = NULL_TREE;
     296              : 
     297    125107769 :   if (TYPE_MAIN_VARIANT (type) == float_type_node)
     298      1616886 :     ret = double_type_node;
     299    123490883 :   else if (c_promoting_integer_type_p (type))
     300              :     {
     301              :       /* Preserve unsignedness if not really getting any wider.  */
     302     18660450 :       if (TYPE_UNSIGNED (type)
     303     18660450 :           && (TYPE_PRECISION (type) == TYPE_PRECISION (integer_type_node)))
     304            0 :         ret = unsigned_type_node;
     305              :       else
     306     18660450 :         ret = integer_type_node;
     307              :     }
     308              : 
     309     20277336 :   if (ret != NULL_TREE)
     310     20277336 :     return (TYPE_ATOMIC (type)
     311     20277336 :             ? c_build_qualified_type (ret, TYPE_QUAL_ATOMIC)
     312              :             : ret);
     313              : 
     314              :   return type;
     315              : }
     316              : 
     317              : /* Return true if between two named address spaces, whether there is a superset
     318              :    named address space that encompasses both address spaces.  If there is a
     319              :    superset, return which address space is the superset.  */
     320              : 
     321              : static bool
     322      7446168 : addr_space_superset (addr_space_t as1, addr_space_t as2, addr_space_t *common)
     323              : {
     324      7446168 :   if (as1 == as2)
     325              :     {
     326      7446168 :       *common = as1;
     327      7446168 :       return true;
     328              :     }
     329            0 :   else if (targetm.addr_space.subset_p (as1, as2))
     330              :     {
     331            0 :       *common = as2;
     332            0 :       return true;
     333              :     }
     334            0 :   else if (targetm.addr_space.subset_p (as2, as1))
     335              :     {
     336            0 :       *common = as1;
     337            0 :       return true;
     338              :     }
     339              :   else
     340              :     return false;
     341              : }
     342              : 
     343              : /* Return a variant of TYPE which has all the type qualifiers of LIKE
     344              :    as well as those of TYPE.  */
     345              : 
     346              : static tree
     347      2682441 : qualify_type (tree type, tree like)
     348              : {
     349      2682441 :   addr_space_t as_type = TYPE_ADDR_SPACE (type);
     350      2682441 :   addr_space_t as_like = TYPE_ADDR_SPACE (like);
     351      2682441 :   addr_space_t as_common;
     352              : 
     353              :   /* If the two named address spaces are different, determine the common
     354              :      superset address space.  If there isn't one, raise an error.  */
     355      2682441 :   if (!addr_space_superset (as_type, as_like, &as_common))
     356              :     {
     357            0 :       as_common = as_type;
     358            0 :       error ("%qT and %qT are in disjoint named address spaces",
     359              :              type, like);
     360              :     }
     361              : 
     362      5364882 :   return c_build_qualified_type (type,
     363      2682441 :                                  TYPE_QUALS_NO_ADDR_SPACE (type)
     364      2682441 :                                  | TYPE_QUALS_NO_ADDR_SPACE_NO_ATOMIC (like)
     365      2682441 :                                  | ENCODE_QUAL_ADDR_SPACE (as_common));
     366              : }
     367              : 
     368              : 
     369              : /* Check consistency of type TYPE.  For derived types, we test that
     370              :    C_TYPE_VARIABLE_SIZE and C_TYPE_VARIABLY_MODIFIED are consistent with
     371              :    the requirements of the base type.  We also check that arrays with a
     372              :    non-constant length are marked with C_TYPE_VARIABLE_SIZE. If any
     373              :    inconsistency is detected false is returned and true otherwise.  */
     374              : 
     375              : static bool
     376    141253855 : c_verify_type (tree type)
     377              : {
     378    141253855 :   switch (TREE_CODE (type))
     379              :     {
     380     67446806 :     case POINTER_TYPE:
     381     67446806 :     case FUNCTION_TYPE:
     382     67446806 :     case ARRAY_TYPE:
     383              :       /* Pointer, array, functions are variably modified if and only if the
     384              :          target, element, return type is variably modified.  */
     385     67446806 :       if (!TYPE_STRUCTURAL_EQUALITY_P (type)
     386     67446806 :           && (C_TYPE_VARIABLY_MODIFIED (type)
     387     67265827 :               != C_TYPE_VARIABLY_MODIFIED (TREE_TYPE (type))))
     388              :         return false;
     389              :       /* If the target type is structural equality, the type should also. */
     390     67446806 :       if (!TYPE_STRUCTURAL_EQUALITY_P (type)
     391     67446806 :           && TYPE_STRUCTURAL_EQUALITY_P (TREE_TYPE (type)))
     392              :         return false;
     393              : 
     394    141253855 :      default:
     395    141253855 :        break;
     396              :     }
     397              : 
     398    141253855 :   switch (TREE_CODE (type))
     399              :     {
     400     66530732 :     case POINTER_TYPE:
     401     66530732 :     case FUNCTION_TYPE:
     402              :       /* Pointer and functions can not have variable size.  */
     403     66530732 :       if (C_TYPE_VARIABLE_SIZE (type))
     404            0 :         return false;
     405              :       break;
     406       916074 :     case ARRAY_TYPE:
     407              :       /* An array has variable size if and only if it has a non-constant
     408              :          dimensions or its element type has variable size.  */
     409       916074 :       if ((C_TYPE_VARIABLE_SIZE (TREE_TYPE (type))
     410       916074 :            || (TYPE_DOMAIN (type) && TYPE_MAX_VALUE (TYPE_DOMAIN (type))
     411       890655 :                && TREE_CODE (TYPE_MAX_VALUE (TYPE_DOMAIN (type)))
     412              :                   != INTEGER_CST))
     413       916074 :           != C_TYPE_VARIABLE_SIZE (type))
     414              :         return false;
     415              :       /* If the element type or the array has variable size, then the
     416              :          array has variable size and is variably modified.  */
     417       916074 :       if (C_TYPE_VARIABLE_SIZE (TREE_TYPE (type))
     418       916074 :           || C_TYPE_VARIABLE_SIZE (type))
     419              :         {
     420        27686 :           if (!C_TYPE_VARIABLE_SIZE (type))
     421              :             return false;
     422        27686 :           if (!C_TYPE_VARIABLY_MODIFIED (type))
     423            0 :             return false;
     424              :         }
     425              :     default:
     426              :       break;
     427              :     }
     428              :   return true;
     429              : }
     430              : 
     431              : /* Propagate C_TYPE_VARIABLY_MODIFIED and C_TYPE_VARIABLE_SIZE
     432              :    from a base type to a newly built derived or qualified type.  */
     433              : 
     434              : static tree
     435    134234203 : c_set_type_bits (tree new_type, tree old_type)
     436              : {
     437    134234203 :   gcc_checking_assert (c_verify_type (old_type));
     438              : 
     439    134234203 :   if (c_type_variably_modified_p (old_type))
     440        28333 :     C_TYPE_VARIABLY_MODIFIED (new_type) = true;
     441              : 
     442    134234203 :   if (TREE_CODE (new_type) == ARRAY_TYPE && C_TYPE_VARIABLE_SIZE (old_type))
     443              :     {
     444        16804 :       C_TYPE_VARIABLY_MODIFIED (new_type) = true;
     445        16804 :       C_TYPE_VARIABLE_SIZE (new_type) = true;
     446              :     }
     447    134234203 :   return new_type;
     448              : }
     449              : 
     450              : /* Build a pointer type using the default pointer mode.  */
     451              : 
     452              : tree
     453     71643389 : c_build_pointer_type (tree to_type)
     454              : {
     455     71643389 :   addr_space_t as = to_type == error_mark_node ? ADDR_SPACE_GENERIC
     456     71643389 :                                                : TYPE_ADDR_SPACE (to_type);
     457     71643389 :   machine_mode pointer_mode;
     458              : 
     459     71643389 :   if (as != ADDR_SPACE_GENERIC || c_default_pointer_mode == VOIDmode)
     460     71643389 :     pointer_mode = targetm.addr_space.pointer_mode (as);
     461              :   else
     462              :     pointer_mode = c_default_pointer_mode;
     463              : 
     464     71643389 :   return c_build_pointer_type_for_mode (to_type, pointer_mode, false);
     465              : }
     466              : 
     467              : /* Build a pointer type using the given mode.  */
     468              : 
     469              : tree
     470     71890366 : c_build_pointer_type_for_mode (tree type, machine_mode mode, bool m)
     471              : {
     472     71890366 :   tree ret = build_pointer_type_for_mode (type, mode, m);
     473     71890366 :   return c_set_type_bits (ret, type);
     474              : }
     475              : 
     476              : /* Build a function type.  */
     477              : 
     478              : tree
     479     53767363 : c_build_function_type (tree type, tree args, bool no)
     480              : {
     481     53767363 :   tree ret = build_function_type (type, args, no);
     482     53767363 :   return c_set_type_bits (ret, type);
     483              : }
     484              : 
     485              : /* Build an array type.  This sets typeless storage as required
     486              :    by C2Y and C_TYPE_VARIABLY_MODIFIED and C_TYPE_VARIABLE_SIZE
     487              :    based on the element type and domain.  */
     488              : 
     489              : tree
     490      1157050 : c_build_array_type (tree type, tree domain)
     491              : {
     492      1157050 :   int type_quals = TYPE_QUALS (type);
     493              : 
     494              :   /* Identify typeless storage as introduced in C2Y
     495              :      and supported also in earlier language modes.  */
     496      1718988 :   bool typeless = (char_type_p (type) && !(type_quals & TYPE_QUAL_ATOMIC))
     497      1157050 :                   || (AGGREGATE_TYPE_P (type) && TYPE_TYPELESS_STORAGE (type));
     498              : 
     499      1157050 :   tree ret = build_array_type (type, domain, typeless);
     500              : 
     501      1071185 :   if (domain && TYPE_MAX_VALUE (domain)
     502      2138942 :       && TREE_CODE (TYPE_MAX_VALUE (domain)) != INTEGER_CST)
     503              :     {
     504        24267 :       C_TYPE_VARIABLE_SIZE (ret) = 1;
     505        24267 :       C_TYPE_VARIABLY_MODIFIED (ret) = 1;
     506              :     }
     507              : 
     508      1157050 :   return c_set_type_bits (ret, type);
     509              : }
     510              : 
     511              : 
     512              : /* Build an array type of unspecified size.  */
     513              : tree
     514          150 : c_build_array_type_unspecified (tree type)
     515              : {
     516          150 :   tree upper = build2 (COMPOUND_EXPR, TREE_TYPE (size_zero_node),
     517              :                        integer_zero_node, size_zero_node);
     518          150 :   return c_build_array_type (type, build_index_type (upper));
     519              : }
     520              : 
     521              : 
     522              : tree
     523      7419424 : c_build_type_attribute_qual_variant (tree type, tree attrs, int quals)
     524              : {
     525      7419424 :   tree ret = build_type_attribute_qual_variant (type, attrs, quals);
     526      7419424 :   return c_set_type_bits (ret, type);
     527              : }
     528              : 
     529              : tree
     530      7231129 : c_build_type_attribute_variant (tree type, tree attrs)
     531              : {
     532      7231129 :   return c_build_type_attribute_qual_variant (type, attrs, TYPE_QUALS (type));
     533              : }
     534              : 
     535              : /* Reconstruct a complex derived type.  This is used to re-construct types
     536              :    with the vector attribute.  It is called via a langhook.  */
     537              : 
     538              : tree
     539       838860 : c_reconstruct_complex_type (tree type, tree bottom)
     540              : {
     541       838860 :   tree inner, outer;
     542              : 
     543       838860 :   if (TREE_CODE (type) == POINTER_TYPE)
     544              :     {
     545       173982 :       inner = c_reconstruct_complex_type (TREE_TYPE (type), bottom);
     546       173982 :       outer = c_build_pointer_type_for_mode (inner, TYPE_MODE (type),
     547       173982 :                                              TYPE_REF_CAN_ALIAS_ALL (type));
     548              :     }
     549              :   else if (TREE_CODE (type) == ARRAY_TYPE)
     550              :     {
     551         7354 :       bool rso = TYPE_REVERSE_STORAGE_ORDER (type);
     552         7354 :       inner = c_reconstruct_complex_type (TREE_TYPE (type), bottom);
     553         7354 :       outer = c_build_array_type (inner, TYPE_DOMAIN (type));
     554         7354 :       if (rso)
     555              :         {
     556            1 :           outer = build_distinct_type_copy (outer);
     557            1 :           TYPE_REVERSE_STORAGE_ORDER (outer) = 1;
     558              :         }
     559              : 
     560         7354 :       gcc_checking_assert (C_TYPE_VARIABLE_SIZE (type)
     561              :                            == C_TYPE_VARIABLE_SIZE (outer));
     562              :     }
     563              :   else if (TREE_CODE (type) == FUNCTION_TYPE)
     564              :     {
     565          585 :       inner = c_reconstruct_complex_type (TREE_TYPE (type), bottom);
     566          585 :       outer = c_build_function_type (inner, TYPE_ARG_TYPES (type),
     567          585 :                                      TYPE_NO_NAMED_ARGS_STDARG_P (type));
     568              :     }
     569              :   else if (TREE_CODE (type) == REFERENCE_TYPE
     570              :            || TREE_CODE (type) == OFFSET_TYPE)
     571            0 :     gcc_unreachable ();
     572              :   else
     573              :     return bottom;
     574              : 
     575       181921 :   return c_build_type_attribute_qual_variant (outer, TYPE_ATTRIBUTES (type),
     576       363842 :                                               TYPE_QUALS (type));
     577              : }
     578              : 
     579              : 
     580              : /* Helper function for c_canonical_type.  Check whether FIELD
     581              :    contains a pointer to a structure or union with tag,
     582              :    possibly nested in other type derivations.  */
     583              : static bool
     584      3428229 : ptr_to_tagged_member (tree field)
     585              : {
     586      3428229 :   gcc_assert (FIELD_DECL == TREE_CODE (field));
     587      3428229 :   tree type = TREE_TYPE (field);
     588      3428229 :   bool ptr_seen = false;
     589      3428229 :   while (TREE_CODE (type) == ARRAY_TYPE
     590              :          || TREE_CODE (type) == FUNCTION_TYPE
     591      4696570 :          || TREE_CODE (type) == POINTER_TYPE)
     592              :     {
     593      1268341 :       if (TREE_CODE (type) == POINTER_TYPE)
     594       695105 :         ptr_seen = true;
     595      1268341 :       type = TREE_TYPE (type);
     596              :     }
     597              : 
     598      3428229 :   if (ptr_seen
     599       675376 :       && RECORD_OR_UNION_TYPE_P (type)
     600      3675352 :       && NULL_TREE != c_type_tag (type))
     601              :     return true;
     602              : 
     603              :   return false;
     604              : }
     605              : 
     606              : /* For a record or union type, make necessary adaptations so that the
     607              :    type can be used as TYPE_CANONICAL.
     608              : 
     609              :    If the TYPE contains a pointer (possibly nested in other type
     610              :    derivations) to a structure or union as a member, create a copy
     611              :    and change such pointers to void pointers.  Otherwise, the middle-end
     612              :    gets confused when recording component aliases in the case where we
     613              :    have formed equivalency classes that include types for which these
     614              :    member pointers end up pointing to other structure or unions types
     615              :    which have the same tag but are not compatible.  */
     616              : tree
     617       884725 : c_type_canonical (tree type)
     618              : {
     619       884725 :   gcc_assert (RECORD_OR_UNION_TYPE_P (type));
     620              : 
     621       884725 :   bool needs_mod = false;
     622      3621247 :   for (tree x = TYPE_FIELDS (type); x; x = DECL_CHAIN (x))
     623              :     {
     624      2817812 :       if (!ptr_to_tagged_member (x))
     625      2736522 :         continue;
     626              :       needs_mod = true;
     627              :       break;
     628              :     }
     629       884725 :   if (!needs_mod)
     630              :     return type;
     631              : 
     632              :   /* Construct new version with such members replaced.  */
     633        81290 :   tree n = build_distinct_type_copy (type);
     634        81290 :   tree *fields = &TYPE_FIELDS (n);
     635       691707 :   for (tree x = TYPE_FIELDS (type); x; x = DECL_CHAIN (x))
     636              :     {
     637       610417 :       tree f = copy_node (x);
     638       610417 :       if (ptr_to_tagged_member (x))
     639       161678 :         TREE_TYPE (f) = c_reconstruct_complex_type (TREE_TYPE (x),
     640              :                                                     ptr_type_node);
     641       610417 :       *fields = f;
     642       610417 :       fields = &DECL_CHAIN (f);
     643              :     }
     644        81290 :   TYPE_CANONICAL (n) = n;
     645        81290 :   return n;
     646              : }
     647              : 
     648              : 
     649              : /* If NTYPE is a type of a non-variadic function with a prototype
     650              :    and OTYPE is a type of a function without a prototype and ATTRS
     651              :    contains attribute format, diagnosess and removes it from ATTRS.
     652              :    Returns the result of build_type_attribute_variant of NTYPE and
     653              :    the (possibly) modified ATTRS.  */
     654              : 
     655              : static tree
     656        10753 : c_build_functype_attribute_variant (tree ntype, tree otype, tree attrs)
     657              : {
     658        10753 :   if (!prototype_p (otype)
     659        10741 :       && prototype_p (ntype)
     660        21464 :       && lookup_attribute ("format", attrs))
     661              :     {
     662           14 :       warning_at (input_location, OPT_Wattributes,
     663              :                   "%qs attribute can only be applied to variadic functions",
     664              :                   "format");
     665           14 :       attrs = remove_attribute ("format", attrs);
     666              :     }
     667        10753 :   return c_build_type_attribute_variant (ntype, attrs);
     668              : 
     669              : }
     670              : 
     671              : /* Given a type which could be a typedef name, make sure to return the
     672              :    original type.  See set_underlying_type. */
     673              : static const_tree
     674     62454961 : c_type_original (const_tree t)
     675              : {
     676              :   /* It may even be a typedef of a typedef...
     677              :      In the case of compiler-created builtin structs the TYPE_DECL
     678              :      may be a dummy, with no DECL_ORIGINAL_TYPE.  Don't fault.  */
     679     62454961 :   while (TYPE_NAME (t)
     680     32189290 :          && TREE_CODE (TYPE_NAME (t)) == TYPE_DECL
     681     62499061 :          && DECL_ORIGINAL_TYPE (TYPE_NAME (t)))
     682        22048 :     t = DECL_ORIGINAL_TYPE (TYPE_NAME (t));
     683     62454961 :   return t;
     684              : }
     685              : 
     686              : /* Return the tag for a tagged type.  */
     687              : tree
     688     62454961 : c_type_tag (const_tree t)
     689              : {
     690     62454961 :   gcc_assert (RECORD_OR_UNION_TYPE_P (t) || TREE_CODE (t) == ENUMERAL_TYPE);
     691     62454961 :   const_tree orig = c_type_original (t);
     692     62454961 :   tree name = TYPE_NAME (orig);
     693     62454961 :   if (!name)
     694              :     return NULL_TREE;
     695     32167242 :   if (TREE_CODE (name) == TYPE_DECL)
     696              :     {
     697            4 :       if (!DECL_NAME (name))
     698              :         return NULL_TREE;
     699            2 :       name = DECL_NAME (name);
     700              :     }
     701     32167240 :   gcc_checking_assert (TREE_CODE (name) == IDENTIFIER_NODE);
     702              :   return name;
     703              : }
     704              : 
     705              : /* Remove qualifiers but not atomic.  For arrays remove qualifiers
     706              :    on the element type but also do not remove atomic.  */
     707              : static tree
     708     63795285 : remove_qualifiers (tree t)
     709              : {
     710     63795285 :   if (!t || t == error_mark_node)
     711              :     return t;
     712     63795260 :   return TYPE_ATOMIC (strip_array_types (t))
     713     63795260 :          ? c_build_qualified_type (TYPE_MAIN_VARIANT (t), TYPE_QUAL_ATOMIC)
     714     63779685 :          : TYPE_MAIN_VARIANT (t);
     715              : }
     716              : 
     717              : 
     718              : /* Helper function for composite_type_internal.  Find a compatible type
     719              :    in a (transparent) union U compatible to T.  If found, return the
     720              :    type of the corresponding member.  Otherwise, return the union type U.  */
     721              : static tree
     722      8432334 : transparent_union_replacement (tree u, tree t)
     723              : {
     724      8432329 :   if (u == error_mark_node || t == error_mark_node
     725      8432324 :       || TREE_CODE (u) != UNION_TYPE
     726           64 :       || !(TYPE_TRANSPARENT_AGGR (u) || TYPE_NAME (u) == NULL_TREE)
     727      8432398 :       || comptypes (u, t))
     728      8432270 :     return u;
     729              : 
     730           80 :   for (tree memb = TYPE_FIELDS (u); memb; memb = DECL_CHAIN (memb))
     731              :     {
     732           80 :       tree m = remove_qualifiers (TREE_TYPE (memb));
     733           80 :       if (comptypes (m, t))
     734              :         {
     735           64 :           pedwarn (input_location, OPT_Wpedantic,
     736              :                     "function types not truly compatible in ISO C");
     737           64 :           return m;
     738              :         }
     739              :     }
     740              : 
     741              :   return u;
     742              : }
     743              : 
     744              : 
     745              : 
     746              : /* Return the composite type of two compatible types.
     747              : 
     748              :    We assume that comptypes has already been done and returned
     749              :    nonzero; if that isn't so, this may crash.  In particular, we
     750              :    assume that qualifiers match.  */
     751              : 
     752              : struct composite_cache {
     753              :   tree t1;
     754              :   tree t2;
     755              :   tree composite;
     756              :   struct composite_cache* next;
     757              : };
     758              : 
     759              : tree
     760     13352916 : composite_type_internal (tree t1, tree t2, tree cond,
     761              :                          struct composite_cache* cache)
     762              : {
     763     13352916 :   enum tree_code code1;
     764     13352916 :   enum tree_code code2;
     765     13352916 :   tree attributes;
     766              : 
     767              :   /* Save time if the two types are the same.  */
     768              : 
     769     13352916 :   if (t1 == t2) return t1;
     770              : 
     771              :   /* If one type is nonsense, use the other.  */
     772      2717234 :   if (t1 == error_mark_node)
     773              :     return t2;
     774      2717230 :   if (t2 == error_mark_node)
     775              :     return t1;
     776              : 
     777      2717228 :   code1 = TREE_CODE (t1);
     778      2717228 :   code2 = TREE_CODE (t2);
     779              : 
     780              :   /* Merge the attributes.  */
     781      2717228 :   attributes = targetm.merge_type_attributes (t1, t2);
     782              : 
     783              :   /* If one is an enumerated type and the other is the compatible
     784              :      integer type, the composite type might be either of the two
     785              :      (DR#013 question 3).  For consistency, use the enumerated type as
     786              :      the composite type.  */
     787              : 
     788      2717228 :   if (code1 == ENUMERAL_TYPE
     789          194 :       && (code2 == INTEGER_TYPE
     790          194 :           || code2 == BOOLEAN_TYPE))
     791              :     return t1;
     792      2717034 :   if (code2 == ENUMERAL_TYPE
     793           69 :       && (code1 == INTEGER_TYPE
     794           69 :           || code1 == BOOLEAN_TYPE))
     795              :     return t2;
     796              : 
     797      2716965 :   gcc_assert (code1 == code2);
     798              : 
     799      2716965 :   switch (code1)
     800              :     {
     801         6374 :     case POINTER_TYPE:
     802              :       /* For two pointers, do this recursively on the target type.  */
     803         6374 :       {
     804         6374 :         gcc_checking_assert (TYPE_QUALS (t1) == TYPE_QUALS (t2));
     805         6374 :         tree target = composite_type_internal (TREE_TYPE (t1), TREE_TYPE (t2),
     806              :                                                cond, cache);
     807         6374 :         tree n = c_build_pointer_type_for_mode (target, TYPE_MODE (t1), false);
     808        12748 :         return c_build_type_attribute_qual_variant (n, attributes,
     809         6374 :                                                     TYPE_QUALS (t2));
     810              :       }
     811              : 
     812        10994 :     case ARRAY_TYPE:
     813        10994 :       {
     814        10994 :         tree d1 = TYPE_DOMAIN (t1);
     815        10994 :         tree d2 = TYPE_DOMAIN (t2);
     816              : 
     817              :         /* We should not have any type quals on arrays at all.  */
     818        10994 :         gcc_assert (!TYPE_QUALS_NO_ADDR_SPACE (t1)
     819              :                     && !TYPE_QUALS_NO_ADDR_SPACE (t2));
     820              : 
     821        10994 :         bool t1_complete = COMPLETE_TYPE_P (t1);
     822        10994 :         bool t2_complete = COMPLETE_TYPE_P (t2);
     823              : 
     824        10994 :         bool d1_zero = d1 == NULL_TREE || !TYPE_MAX_VALUE (d1);
     825        10994 :         bool d2_zero = d2 == NULL_TREE || !TYPE_MAX_VALUE (d2);
     826              : 
     827        10994 :         bool d1_variable, d2_variable;
     828              : 
     829        21988 :         d1_variable = (!d1_zero
     830        10994 :                        && (TREE_CODE (TYPE_MIN_VALUE (d1)) != INTEGER_CST
     831        10399 :                            || TREE_CODE (TYPE_MAX_VALUE (d1)) != INTEGER_CST));
     832        21988 :         d2_variable = (!d2_zero
     833        10994 :                        && (TREE_CODE (TYPE_MIN_VALUE (d2)) != INTEGER_CST
     834        10652 :                            || TREE_CODE (TYPE_MAX_VALUE (d2)) != INTEGER_CST));
     835              : 
     836        10994 :         bool use1 = d1 && (d2_variable || d2_zero || !d1_variable);
     837        10994 :         bool use2 = d2 && (d1_variable || d1_zero || !d2_variable);
     838              : 
     839              :         /* If the first is an unspecified size pick the other one.  */
     840         9012 :         if (d2_variable && c_type_unspecified_p (t1))
     841              :           {
     842           28 :             gcc_assert (use1 && use2);
     843              :             use1 = false;
     844              :           }
     845              : 
     846              :         /* If both are VLAs but not unspecified and we are in the
     847              :            conditional operator, we create a conditional to select
     848              :            the size of the active branch.  */
     849          232 :         bool use0 = cond && d1_variable && !c_type_unspecified_p (t1)
     850        11223 :                          && d2_variable && !c_type_unspecified_p (t2);
     851              : 
     852        10994 :         tree td;
     853        10994 :         tree elt = composite_type_internal (TREE_TYPE (t1), TREE_TYPE (t2),
     854              :                                             cond, cache);
     855              : 
     856        10994 :         if (!use0)
     857              :           {
     858              :             /* Save space: see if the result is identical to one of the args.  */
     859        10877 :             if (elt == TREE_TYPE (t1) && use1)
     860        10087 :               return c_build_type_attribute_variant (t1, attributes);
     861          790 :             if (elt == TREE_TYPE (t2) && use2)
     862          672 :               return c_build_type_attribute_variant (t2, attributes);
     863              : 
     864          161 :             if (elt == TREE_TYPE (t1) && !TYPE_DOMAIN (t2) && !TYPE_DOMAIN (t1))
     865           10 :               return c_build_type_attribute_variant (t1, attributes);
     866          116 :             if (elt == TREE_TYPE (t2) && !TYPE_DOMAIN (t2) && !TYPE_DOMAIN (t1))
     867            2 :               return c_build_type_attribute_variant (t2, attributes);
     868              : 
     869          212 :             td = TYPE_DOMAIN (use1 ? t1 : t2);
     870              :           }
     871              :         else
     872              :           {
     873              :             /* Not used in C.  */
     874          117 :             gcc_assert (size_zero_node == TYPE_MIN_VALUE (d1));
     875          117 :             gcc_assert (size_zero_node == TYPE_MIN_VALUE (d2));
     876              : 
     877          117 :             tree d = fold_build3_loc (UNKNOWN_LOCATION, COND_EXPR, sizetype,
     878          117 :                                       cond, TYPE_MAX_VALUE (d1),
     879          117 :                                       TYPE_MAX_VALUE (d2));
     880              : 
     881          117 :             td = build_index_type (d);
     882              :           }
     883              : 
     884              :         /* Merge the element types, and have a size if either arg has
     885              :            one.  We may have qualifiers on the element types.  To set
     886              :            up TYPE_MAIN_VARIANT correctly, we need to form the
     887              :            composite of the unqualified types and add the qualifiers
     888              :            back at the end.  */
     889          223 :         int quals = TYPE_QUALS (strip_array_types (elt));
     890          223 :         tree unqual_elt = c_build_qualified_type (elt, TYPE_UNQUALIFIED);
     891              : 
     892          223 :         t1 = c_build_array_type (unqual_elt, td);
     893              : 
     894              :         /* Check that a type which has a varying outermost dimension
     895              :            got marked has having a variable size.  */
     896          223 :         bool varsize = (d1_variable && d2_variable)
     897           97 :                        || (d1_variable && !t2_complete)
     898          309 :                        || (d2_variable && !t1_complete);
     899          157 :         gcc_checking_assert (!varsize || C_TYPE_VARIABLE_SIZE (t1));
     900              : 
     901              :         /* Ensure a composite type involving a zero-length array type
     902              :            is a zero-length type not an incomplete type.  */
     903          223 :         if (d1_zero && d2_zero
     904           16 :             && (t1_complete || t2_complete)
     905          224 :             && !COMPLETE_TYPE_P (t1))
     906              :           {
     907            1 :             TYPE_SIZE (t1) = bitsize_zero_node;
     908            1 :             TYPE_SIZE_UNIT (t1) = size_zero_node;
     909              :           }
     910          223 :         t1 = c_build_qualified_type (t1, quals);
     911          223 :         return c_build_type_attribute_variant (t1, attributes);
     912              :       }
     913              : 
     914          253 :     case RECORD_TYPE:
     915          253 :     case UNION_TYPE:
     916          253 :       if (flag_isoc23 && !comptypes_same_p (t1, t2))
     917              :         {
     918              :           /* Go to the original type to get the right tag.  */
     919          150 :           tree tag = c_type_tag (t1);
     920              : 
     921          150 :           gcc_checking_assert (COMPLETE_TYPE_P (t1) && COMPLETE_TYPE_P (t2));
     922          150 :           gcc_checking_assert (!tag || comptypes (t1, t2));
     923              : 
     924              :           /* If a composite type for these two types is already under
     925              :              construction, return it.  */
     926              : 
     927          376 :           for (struct composite_cache *c = cache; c != NULL; c = c->next)
     928          246 :             if ((c->t1 == t1 && c->t2 == t2) || (c->t1 == t2 && c->t2 == t1))
     929           20 :                return c->composite;
     930              : 
     931              :           /* Otherwise, create a new type node and link it into the cache.  */
     932              : 
     933          130 :           tree n = make_node (code1);
     934          130 :           SET_TYPE_STRUCTURAL_EQUALITY (n);
     935          130 :           TYPE_NAME (n) = tag;
     936              : 
     937          130 :           struct composite_cache cache2 = { t1, t2, n, cache };
     938          130 :           cache = &cache2;
     939              : 
     940          130 :           tree f1 = TYPE_FIELDS (t1);
     941          130 :           tree f2 = TYPE_FIELDS (t2);
     942          130 :           tree fields = NULL_TREE;
     943              : 
     944          321 :           for (tree a = f1, b = f2; a && b;
     945          191 :                a = DECL_CHAIN (a), b = DECL_CHAIN (b))
     946              :             {
     947          191 :               tree ta = TREE_TYPE (a);
     948          191 :               tree tb = TREE_TYPE (b);
     949              : 
     950          191 :               if (DECL_C_BIT_FIELD (a))
     951              :                 {
     952           19 :                   ta = DECL_BIT_FIELD_TYPE (a);
     953           19 :                   tb = DECL_BIT_FIELD_TYPE (b);
     954              :                 }
     955              : 
     956          191 :               gcc_assert (DECL_NAME (a) == DECL_NAME (b));
     957          191 :               gcc_checking_assert (!DECL_NAME (a) || comptypes (ta, tb));
     958              : 
     959          191 :               tree t = composite_type_internal (ta, tb, cond, cache);
     960          191 :               tree f = build_decl (input_location, FIELD_DECL, DECL_NAME (a), t);
     961              : 
     962          191 :               DECL_PACKED (f) = DECL_PACKED (a);
     963          191 :               SET_DECL_ALIGN (f, DECL_ALIGN (a));
     964          191 :               DECL_ATTRIBUTES (f) = DECL_ATTRIBUTES (a);
     965          191 :               C_DECL_VARIABLE_SIZE (f) = C_TYPE_VARIABLE_SIZE (t);
     966              : 
     967          191 :               decl_attributes (&f, DECL_ATTRIBUTES (f), 0);
     968              : 
     969          191 :               finish_decl (f, input_location, NULL, NULL, NULL);
     970              : 
     971          191 :               if (DECL_C_BIT_FIELD (a))
     972              :                 {
     973              :                   /* This will be processed by finish_struct.  */
     974           19 :                   SET_DECL_C_BIT_FIELD (f);
     975           19 :                   DECL_INITIAL (f) = build_int_cst (integer_type_node,
     976           19 :                                                     tree_to_uhwi (DECL_SIZE (a)));
     977           19 :                   DECL_NONADDRESSABLE_P (f) = true;
     978           19 :                   DECL_PADDING_P (f) = !DECL_NAME (a);
     979              :                 }
     980              : 
     981          191 :               DECL_CHAIN (f) = fields;
     982          191 :               fields = f;
     983              :             }
     984              : 
     985          130 :           fields = nreverse (fields);
     986              : 
     987              :           /* Setup the struct/union type.  Because we inherit all variably
     988              :              modified components, we can ignore the size expression.  */
     989          130 :           tree expr = NULL_TREE;
     990              : 
     991              :           /* Set TYPE_STUB_DECL for debugging symbols.  */
     992          130 :           TYPE_STUB_DECL (n) = pushdecl (build_decl (input_location, TYPE_DECL,
     993              :                                                      NULL_TREE, n));
     994              : 
     995          130 :           n = finish_struct (input_location, n, fields, attributes, NULL,
     996              :                              &expr);
     997              : 
     998          130 :           return qualify_type (n, t1);
     999              :         }
    1000              :       /* FALLTHRU */
    1001          103 :     case ENUMERAL_TYPE:
    1002          103 :       if (attributes != NULL)
    1003              :         {
    1004              :           /* Try harder not to create a new aggregate type.  */
    1005            4 :           if (attribute_list_equal (TYPE_ATTRIBUTES (t1), attributes))
    1006              :             return t1;
    1007            0 :           if (attribute_list_equal (TYPE_ATTRIBUTES (t2), attributes))
    1008              :             return t2;
    1009              :         }
    1010           99 :       return c_build_type_attribute_variant (t1, attributes);
    1011              : 
    1012      2657826 :     case FUNCTION_TYPE:
    1013              :       /* Function types: prefer the one that specified arg types.
    1014              :          If both do, merge the arg types.  Also merge the return types.  */
    1015      2657826 :       {
    1016      2657826 :         tree valtype = composite_type_internal (TREE_TYPE (t1), TREE_TYPE (t2),
    1017              :                                                 cond, cache);
    1018      2657826 :         tree p1 = TYPE_ARG_TYPES (t1);
    1019      2657826 :         tree p2 = TYPE_ARG_TYPES (t2);
    1020              : 
    1021              :         /* Save space: see if the result is identical to one of the args.  */
    1022      2657826 :         if (valtype == TREE_TYPE (t1) && !TYPE_ARG_TYPES (t2))
    1023        10763 :           return c_build_functype_attribute_variant (t1, t2, attributes);
    1024      2647590 :         if (valtype == TREE_TYPE (t2) && !TYPE_ARG_TYPES (t1))
    1025          517 :           return c_build_functype_attribute_variant (t2, t1, attributes);
    1026              : 
    1027              :         /* Simple way if one arg fails to specify argument types.  */
    1028      2647073 :         if (TYPE_ARG_TYPES (t1) == NULL_TREE)
    1029              :           {
    1030            9 :             t1 = c_build_function_type (valtype, TYPE_ARG_TYPES (t2),
    1031            9 :                                         TYPE_NO_NAMED_ARGS_STDARG_P (t2));
    1032            9 :             t1 = c_build_type_attribute_variant (t1, attributes);
    1033            9 :             return qualify_type (t1, t2);
    1034              :          }
    1035      2647064 :         if (TYPE_ARG_TYPES (t2) == NULL_TREE)
    1036              :           {
    1037            1 :             t1 = c_build_function_type (valtype, TYPE_ARG_TYPES (t1),
    1038            1 :                                         TYPE_NO_NAMED_ARGS_STDARG_P (t1));
    1039            1 :             t1 = c_build_type_attribute_variant (t1, attributes);
    1040            1 :             return qualify_type (t1, t2);
    1041              :           }
    1042              : 
    1043              :         /* If both args specify argument types, we must merge the two
    1044              :            lists, argument by argument.  */
    1045      2647063 :         tree newargs = NULL_TREE;
    1046      2647063 :         tree *endp = &newargs;
    1047              : 
    1048      6863230 :         for (; p1; p1 = TREE_CHAIN (p1), p2 = TREE_CHAIN (p2))
    1049              :           {
    1050      6694908 :             if (p1 == void_list_node)
    1051              :               {
    1052      2478741 :                 *endp = void_list_node;
    1053      2478741 :                 break;
    1054              :               }
    1055      4216167 :             tree mv1 = remove_qualifiers (TREE_VALUE (p1));
    1056      4216167 :             tree mv2 = remove_qualifiers (TREE_VALUE (p2));
    1057              : 
    1058      4216167 :             gcc_assert (mv1);
    1059      4216167 :             gcc_assert (mv2);
    1060              : 
    1061      4216167 :             mv1 = transparent_union_replacement (mv1, mv2);
    1062      4216167 :             mv2 = transparent_union_replacement (mv2, mv1);
    1063              : 
    1064      4216167 :             *endp = tree_cons (NULL_TREE,
    1065              :                                composite_type_internal (mv1, mv2, cond, cache),
    1066              :                                NULL_TREE);
    1067              : 
    1068      4216167 :             endp = &TREE_CHAIN (*endp);
    1069              :           }
    1070              : 
    1071      2647063 :         t1 = c_build_function_type (valtype, newargs);
    1072      2647063 :         t1 = qualify_type (t1, t2);
    1073              :       }
    1074              :       /* FALLTHRU */
    1075              : 
    1076      2688581 :     default:
    1077      2688581 :       return c_build_type_attribute_variant (t1, attributes);
    1078              :     }
    1079              : }
    1080              : 
    1081              : tree
    1082      6461364 : composite_type_cond (tree t1, tree t2, tree cond)
    1083              : {
    1084      6461364 :   gcc_checking_assert (comptypes_check_for_composite (t1, t2));
    1085              : 
    1086      6461364 :   struct composite_cache cache = { };
    1087      6461364 :   tree n = composite_type_internal (t1, t2, cond, &cache);
    1088              : 
    1089      6461364 :   gcc_checking_assert (comptypes_check_for_composite (n, t1));
    1090      6461364 :   gcc_checking_assert (comptypes_check_for_composite (n, t2));
    1091      6461364 :   return n;
    1092              : }
    1093              : 
    1094              : 
    1095              : tree
    1096      6456893 : composite_type (tree t1, tree t2)
    1097              : {
    1098      6456893 :   return composite_type_cond (t1, t2, NULL_TREE);
    1099              : }
    1100              : 
    1101              : /* Return the type of a conditional expression between pointers to
    1102              :    possibly differently qualified versions of compatible types.
    1103              : 
    1104              :    We assume that comp_target_types has already been done and returned
    1105              :    true; if that isn't so, this may crash.  */
    1106              : 
    1107              : static tree
    1108       115095 : common_pointer_type (tree t1, tree t2, tree cond)
    1109              : {
    1110       115095 :   tree attributes;
    1111       115095 :   unsigned target_quals;
    1112       115095 :   addr_space_t as1, as2, as_common;
    1113       115095 :   int quals1, quals2;
    1114              : 
    1115              :   /* Save time if the two types are the same.  */
    1116              : 
    1117       115095 :   if (t1 == t2) return t1;
    1118              : 
    1119              :   /* If one type is nonsense, use the other.  */
    1120         4471 :   if (t1 == error_mark_node)
    1121              :     return t2;
    1122         4471 :   if (t2 == error_mark_node)
    1123              :     return t1;
    1124              : 
    1125         4471 :   gcc_assert (TREE_CODE (t1) == POINTER_TYPE
    1126              :               && TREE_CODE (t2) == POINTER_TYPE);
    1127              : 
    1128              :   /* Merge the attributes.  */
    1129         4471 :   attributes = targetm.merge_type_attributes (t1, t2);
    1130              : 
    1131              :   /* Find the composite type of the target types, and combine the
    1132              :      qualifiers of the two types' targets.  */
    1133         4471 :   tree pointed_to_1 = TREE_TYPE (t1);
    1134         4471 :   tree pointed_to_2 = TREE_TYPE (t2);
    1135         4471 :   tree target = composite_type_cond (TYPE_MAIN_VARIANT (pointed_to_1),
    1136         4471 :                                      TYPE_MAIN_VARIANT (pointed_to_2), cond);
    1137              : 
    1138              :   /* Strip array types to get correct qualifier for pointers to arrays */
    1139         4471 :   quals1 = TYPE_QUALS_NO_ADDR_SPACE (strip_array_types (pointed_to_1));
    1140         4471 :   quals2 = TYPE_QUALS_NO_ADDR_SPACE (strip_array_types (pointed_to_2));
    1141              : 
    1142              :   /* For function types do not merge const qualifiers, but drop them
    1143              :      if used inconsistently.  The middle-end uses these to mark const
    1144              :      and noreturn functions.  */
    1145         4471 :   if (TREE_CODE (pointed_to_1) == FUNCTION_TYPE)
    1146         2129 :     target_quals = (quals1 & quals2);
    1147              :   else
    1148         2342 :     target_quals = (quals1 | quals2);
    1149              : 
    1150              :   /* If the two named address spaces are different, determine the common
    1151              :      superset address space.  This is guaranteed to exist due to the
    1152              :      assumption that comp_target_type returned true.  */
    1153         4471 :   as1 = TYPE_ADDR_SPACE (pointed_to_1);
    1154         4471 :   as2 = TYPE_ADDR_SPACE (pointed_to_2);
    1155         4471 :   if (!addr_space_superset (as1, as2, &as_common))
    1156            0 :     gcc_unreachable ();
    1157              : 
    1158         4471 :   target_quals |= ENCODE_QUAL_ADDR_SPACE (as_common);
    1159              : 
    1160         4471 :   t1 = c_build_pointer_type (c_build_qualified_type (target, target_quals));
    1161         4471 :   return c_build_type_attribute_variant (t1, attributes);
    1162              : }
    1163              : 
    1164              : /* Return the common type for two arithmetic types under the usual
    1165              :    arithmetic conversions.  The default conversions have already been
    1166              :    applied, and enumerated types converted to their compatible integer
    1167              :    types.  The resulting type is unqualified and has no attributes.
    1168              : 
    1169              :    This is the type for the result of most arithmetic operations
    1170              :    if the operands have the given two types.  */
    1171              : 
    1172              : static tree
    1173     13971446 : c_common_type (tree t1, tree t2)
    1174              : {
    1175     13971446 :   enum tree_code code1;
    1176     13971446 :   enum tree_code code2;
    1177              : 
    1178              :   /* If one type is nonsense, use the other.  */
    1179     13971446 :   if (t1 == error_mark_node)
    1180              :     return t2;
    1181     13971446 :   if (t2 == error_mark_node)
    1182              :     return t1;
    1183              : 
    1184     13971446 :   if (TYPE_QUALS (t1) != TYPE_UNQUALIFIED)
    1185        37971 :     t1 = TYPE_MAIN_VARIANT (t1);
    1186              : 
    1187     13971446 :   if (TYPE_QUALS (t2) != TYPE_UNQUALIFIED)
    1188        49382 :     t2 = TYPE_MAIN_VARIANT (t2);
    1189              : 
    1190     13971446 :   if (TYPE_ATTRIBUTES (t1) != NULL_TREE)
    1191              :     {
    1192       188346 :       tree attrs = affects_type_identity_attributes (TYPE_ATTRIBUTES (t1));
    1193       188346 :       t1 = c_build_type_attribute_variant (t1, attrs);
    1194              :     }
    1195              : 
    1196     13971446 :   if (TYPE_ATTRIBUTES (t2) != NULL_TREE)
    1197              :     {
    1198       187824 :       tree attrs = affects_type_identity_attributes (TYPE_ATTRIBUTES (t2));
    1199       187824 :       t2 = c_build_type_attribute_variant (t2, attrs);
    1200              :     }
    1201              : 
    1202              :   /* Save time if the two types are the same.  */
    1203              : 
    1204     13971446 :   if (t1 == t2) return t1;
    1205              : 
    1206      2328013 :   code1 = TREE_CODE (t1);
    1207      2328013 :   code2 = TREE_CODE (t2);
    1208              : 
    1209      2328013 :   gcc_assert (code1 == VECTOR_TYPE || code1 == COMPLEX_TYPE
    1210              :               || code1 == FIXED_POINT_TYPE || code1 == REAL_TYPE
    1211              :               || code1 == INTEGER_TYPE || code1 == BITINT_TYPE);
    1212      2328013 :   gcc_assert (code2 == VECTOR_TYPE || code2 == COMPLEX_TYPE
    1213              :               || code2 == FIXED_POINT_TYPE || code2 == REAL_TYPE
    1214              :               || code2 == INTEGER_TYPE || code2 == BITINT_TYPE);
    1215              : 
    1216              :   /* When one operand is a decimal float type, the other operand cannot be
    1217              :      a generic float type or a complex type.  We also disallow vector types
    1218              :      here.  */
    1219      2328013 :   if ((DECIMAL_FLOAT_TYPE_P (t1) || DECIMAL_FLOAT_TYPE_P (t2))
    1220      2330436 :       && !(DECIMAL_FLOAT_TYPE_P (t1) && DECIMAL_FLOAT_TYPE_P (t2)))
    1221              :     {
    1222         1080 :       if (code1 == VECTOR_TYPE || code2 == VECTOR_TYPE)
    1223              :         {
    1224            3 :           error ("cannot mix operands of decimal floating and vector types");
    1225            3 :           return error_mark_node;
    1226              :         }
    1227         1077 :       if (code1 == COMPLEX_TYPE || code2 == COMPLEX_TYPE)
    1228              :         {
    1229            5 :           error ("cannot mix operands of decimal floating and complex types");
    1230            5 :           return error_mark_node;
    1231              :         }
    1232         1072 :       if (code1 == REAL_TYPE && code2 == REAL_TYPE)
    1233              :         {
    1234           16 :           error ("cannot mix operands of decimal floating "
    1235              :                  "and other floating types");
    1236           16 :           return error_mark_node;
    1237              :         }
    1238              :     }
    1239              : 
    1240              :   /* If one type is a vector type, return that type.  (How the usual
    1241              :      arithmetic conversions apply to the vector types extension is not
    1242              :      precisely specified.)  */
    1243      2327989 :   if (code1 == VECTOR_TYPE)
    1244              :     return t1;
    1245              : 
    1246      2327700 :   if (code2 == VECTOR_TYPE)
    1247              :     return t2;
    1248              : 
    1249              :   /* If one type is complex, form the common type of the non-complex
    1250              :      components, then make that complex.  Use T1 or T2 if it is the
    1251              :      required type.  */
    1252      2327697 :   if (code1 == COMPLEX_TYPE || code2 == COMPLEX_TYPE)
    1253              :     {
    1254        89325 :       tree subtype1 = code1 == COMPLEX_TYPE ? TREE_TYPE (t1) : t1;
    1255        89325 :       tree subtype2 = code2 == COMPLEX_TYPE ? TREE_TYPE (t2) : t2;
    1256        89325 :       tree subtype = c_common_type (subtype1, subtype2);
    1257              : 
    1258        89325 :       if (code1 == COMPLEX_TYPE && TREE_TYPE (t1) == subtype)
    1259              :         return t1;
    1260        59210 :       else if (code2 == COMPLEX_TYPE && TREE_TYPE (t2) == subtype)
    1261              :         return t2;
    1262         3242 :       else if (TREE_CODE (subtype) == BITINT_TYPE)
    1263              :         {
    1264            8 :           sorry ("%<_Complex _BitInt(%d)%> unsupported",
    1265            4 :                  TYPE_PRECISION (subtype));
    1266            6 :           return code1 == COMPLEX_TYPE ? t1 : t2;
    1267              :         }
    1268              :       else
    1269         3238 :         return build_complex_type (subtype);
    1270              :     }
    1271              : 
    1272              :   /* If only one is real, use it as the result.  */
    1273              : 
    1274      2238372 :   if (code1 == REAL_TYPE && code2 != REAL_TYPE)
    1275              :     return t1;
    1276              : 
    1277      2109410 :   if (code2 == REAL_TYPE && code1 != REAL_TYPE)
    1278              :     return t2;
    1279              : 
    1280              :   /* If both are real and either are decimal floating point types, use
    1281              :      the decimal floating point type with the greater precision. */
    1282              : 
    1283      2078077 :   if (code1 == REAL_TYPE && code2 == REAL_TYPE)
    1284              :     {
    1285       107467 :       if (TYPE_MAIN_VARIANT (t1) == dfloat128_type_node
    1286       107467 :           || TYPE_MAIN_VARIANT (t2) == dfloat128_type_node)
    1287              :         return dfloat128_type_node;
    1288              :       /* And prefer _Decimal128 over _Decimal64x which has in GCC's
    1289              :          implementation the same mode.  */
    1290       106918 :       else if (TYPE_MAIN_VARIANT (t1) == dfloat64x_type_node
    1291       106918 :                || TYPE_MAIN_VARIANT (t2) == dfloat64x_type_node)
    1292              :         return dfloat64x_type_node;
    1293       106914 :       else if (TYPE_MAIN_VARIANT (t1) == dfloat64_type_node
    1294       106914 :                || TYPE_MAIN_VARIANT (t2) == dfloat64_type_node)
    1295              :         return dfloat64_type_node;
    1296       106469 :       else if (TYPE_MAIN_VARIANT (t1) == dfloat32_type_node
    1297       106469 :                || TYPE_MAIN_VARIANT (t2) == dfloat32_type_node)
    1298              :         return dfloat32_type_node;
    1299              :     }
    1300              : 
    1301              :   /* Deal with fixed-point types.  */
    1302      2076734 :   if (code1 == FIXED_POINT_TYPE || code2 == FIXED_POINT_TYPE)
    1303              :     {
    1304            0 :       unsigned int unsignedp = 0, satp = 0;
    1305            0 :       scalar_mode m1, m2;
    1306            0 :       unsigned int fbit1, ibit1, fbit2, ibit2, max_fbit, max_ibit;
    1307              : 
    1308            0 :       m1 = SCALAR_TYPE_MODE (t1);
    1309            0 :       m2 = SCALAR_TYPE_MODE (t2);
    1310              : 
    1311              :       /* If one input type is saturating, the result type is saturating.  */
    1312            0 :       if (TYPE_SATURATING (t1) || TYPE_SATURATING (t2))
    1313              :         satp = 1;
    1314              : 
    1315              :       /* If both fixed-point types are unsigned, the result type is unsigned.
    1316              :          When mixing fixed-point and integer types, follow the sign of the
    1317              :          fixed-point type.
    1318              :          Otherwise, the result type is signed.  */
    1319            0 :       if ((TYPE_UNSIGNED (t1) && TYPE_UNSIGNED (t2)
    1320            0 :            && code1 == FIXED_POINT_TYPE && code2 == FIXED_POINT_TYPE)
    1321            0 :           || (code1 == FIXED_POINT_TYPE && code2 != FIXED_POINT_TYPE
    1322            0 :               && TYPE_UNSIGNED (t1))
    1323            0 :           || (code1 != FIXED_POINT_TYPE && code2 == FIXED_POINT_TYPE
    1324            0 :               && TYPE_UNSIGNED (t2)))
    1325              :         unsignedp = 1;
    1326              : 
    1327              :       /* The result type is signed.  */
    1328            0 :       if (unsignedp == 0)
    1329              :         {
    1330              :           /* If the input type is unsigned, we need to convert to the
    1331              :              signed type.  */
    1332            0 :           if (code1 == FIXED_POINT_TYPE && TYPE_UNSIGNED (t1))
    1333              :             {
    1334            0 :               enum mode_class mclass = (enum mode_class) 0;
    1335            0 :               if (GET_MODE_CLASS (m1) == MODE_UFRACT)
    1336              :                 mclass = MODE_FRACT;
    1337            0 :               else if (GET_MODE_CLASS (m1) == MODE_UACCUM)
    1338              :                 mclass = MODE_ACCUM;
    1339              :               else
    1340            0 :                 gcc_unreachable ();
    1341            0 :               m1 = as_a <scalar_mode>
    1342            0 :                 (mode_for_size (GET_MODE_PRECISION (m1), mclass, 0));
    1343              :             }
    1344            0 :           if (code2 == FIXED_POINT_TYPE && TYPE_UNSIGNED (t2))
    1345              :             {
    1346            0 :               enum mode_class mclass = (enum mode_class) 0;
    1347            0 :               if (GET_MODE_CLASS (m2) == MODE_UFRACT)
    1348              :                 mclass = MODE_FRACT;
    1349            0 :               else if (GET_MODE_CLASS (m2) == MODE_UACCUM)
    1350              :                 mclass = MODE_ACCUM;
    1351              :               else
    1352            0 :                 gcc_unreachable ();
    1353            0 :               m2 = as_a <scalar_mode>
    1354            0 :                 (mode_for_size (GET_MODE_PRECISION (m2), mclass, 0));
    1355              :             }
    1356              :         }
    1357              : 
    1358            0 :       if (code1 == FIXED_POINT_TYPE)
    1359              :         {
    1360            0 :           fbit1 = GET_MODE_FBIT (m1);
    1361            0 :           ibit1 = GET_MODE_IBIT (m1);
    1362              :         }
    1363              :       else
    1364              :         {
    1365            0 :           fbit1 = 0;
    1366              :           /* Signed integers need to subtract one sign bit.  */
    1367            0 :           ibit1 = TYPE_PRECISION (t1) - (!TYPE_UNSIGNED (t1));
    1368              :         }
    1369              : 
    1370            0 :       if (code2 == FIXED_POINT_TYPE)
    1371              :         {
    1372            0 :           fbit2 = GET_MODE_FBIT (m2);
    1373            0 :           ibit2 = GET_MODE_IBIT (m2);
    1374              :         }
    1375              :       else
    1376              :         {
    1377            0 :           fbit2 = 0;
    1378              :           /* Signed integers need to subtract one sign bit.  */
    1379            0 :           ibit2 = TYPE_PRECISION (t2) - (!TYPE_UNSIGNED (t2));
    1380              :         }
    1381              : 
    1382            0 :       max_ibit = ibit1 >= ibit2 ?  ibit1 : ibit2;
    1383            0 :       max_fbit = fbit1 >= fbit2 ?  fbit1 : fbit2;
    1384            0 :       return c_common_fixed_point_type_for_size (max_ibit, max_fbit, unsignedp,
    1385              :                                                  satp);
    1386              :     }
    1387              : 
    1388              :   /* Both real or both integers; use the one with greater precision.  */
    1389              : 
    1390      2076734 :   if (TYPE_PRECISION (t1) > TYPE_PRECISION (t2))
    1391              :     return t1;
    1392      1103845 :   else if (TYPE_PRECISION (t2) > TYPE_PRECISION (t1))
    1393              :     return t2;
    1394              : 
    1395              :   /* Same precision.  Prefer long longs to longs to ints when the
    1396              :      same precision, following the C99 rules on integer type rank
    1397              :      (which are equivalent to the C90 rules for C90 types).  */
    1398              : 
    1399       739003 :   if (TYPE_MAIN_VARIANT (t1) == long_long_unsigned_type_node
    1400       739003 :       || TYPE_MAIN_VARIANT (t2) == long_long_unsigned_type_node)
    1401              :     return long_long_unsigned_type_node;
    1402              : 
    1403       649758 :   if (TYPE_MAIN_VARIANT (t1) == long_long_integer_type_node
    1404       649758 :       || TYPE_MAIN_VARIANT (t2) == long_long_integer_type_node)
    1405              :     {
    1406        15318 :       if (TYPE_UNSIGNED (t1) || TYPE_UNSIGNED (t2))
    1407          361 :         return long_long_unsigned_type_node;
    1408              :       else
    1409              :         return long_long_integer_type_node;
    1410              :     }
    1411              : 
    1412       634440 :   if (TYPE_MAIN_VARIANT (t1) == long_unsigned_type_node
    1413       634440 :       || TYPE_MAIN_VARIANT (t2) == long_unsigned_type_node)
    1414              :     return long_unsigned_type_node;
    1415              : 
    1416       535260 :   if (TYPE_MAIN_VARIANT (t1) == long_integer_type_node
    1417       535260 :       || TYPE_MAIN_VARIANT (t2) == long_integer_type_node)
    1418              :     {
    1419              :       /* But preserve unsignedness from the other type,
    1420              :          since long cannot hold all the values of an unsigned int.  */
    1421        26403 :       if (TYPE_UNSIGNED (t1) || TYPE_UNSIGNED (t2))
    1422          129 :         return long_unsigned_type_node;
    1423              :       else
    1424              :         return long_integer_type_node;
    1425              :     }
    1426              : 
    1427              :   /* For floating types of the same TYPE_PRECISION (which we here
    1428              :      assume means either the same set of values, or sets of values
    1429              :      neither a subset of the other, with behavior being undefined in
    1430              :      the latter case), follow the rules from TS 18661-3: prefer
    1431              :      interchange types _FloatN, then standard types long double,
    1432              :      double, float, then extended types _FloatNx.  For extended types,
    1433              :      check them starting with _Float128x as that seems most consistent
    1434              :      in spirit with preferring long double to double; for interchange
    1435              :      types, also check in that order for consistency although it's not
    1436              :      possible for more than one of them to have the same
    1437              :      precision.  */
    1438       508857 :   tree mv1 = TYPE_MAIN_VARIANT (t1);
    1439       508857 :   tree mv2 = TYPE_MAIN_VARIANT (t2);
    1440              : 
    1441      2543639 :   for (int i = NUM_FLOATN_TYPES - 1; i >= 0; i--)
    1442      2034965 :     if (mv1 == FLOATN_TYPE_NODE (i) || mv2 == FLOATN_TYPE_NODE (i))
    1443              :       return FLOATN_TYPE_NODE (i);
    1444              : 
    1445              :   /* Likewise, prefer long double to double even if same size.  */
    1446       508674 :   if (mv1 == long_double_type_node || mv2 == long_double_type_node)
    1447              :     return long_double_type_node;
    1448              : 
    1449              :   /* Likewise, prefer double to float even if same size.
    1450              :      We got a couple of embedded targets with 32 bit doubles, and the
    1451              :      pdp11 might have 64 bit floats.  */
    1452       508416 :   if (mv1 == double_type_node || mv2 == double_type_node)
    1453              :     return double_type_node;
    1454              : 
    1455       507844 :   if (mv1 == float_type_node || mv2 == float_type_node)
    1456              :     return float_type_node;
    1457              : 
    1458      2022636 :   for (int i = NUM_FLOATNX_TYPES - 1; i >= 0; i--)
    1459      1516977 :     if (mv1 == FLOATNX_TYPE_NODE (i) || mv2 == FLOATNX_TYPE_NODE (i))
    1460              :       return FLOATNX_TYPE_NODE (i);
    1461              : 
    1462       505659 :   if ((code1 == BITINT_TYPE || code2 == BITINT_TYPE) && code1 != code2)
    1463              :     {
    1464              :       /* Prefer any other integral types over bit-precise integer types.  */
    1465           10 :       if (TYPE_UNSIGNED (t1) == TYPE_UNSIGNED (t2))
    1466            6 :         return code1 == BITINT_TYPE ? t2 : t1;
    1467              :       /* If BITINT_TYPE is unsigned and the other type is signed
    1468              :          non-BITINT_TYPE with the same precision, the latter has higher rank.
    1469              :          In that case:
    1470              :          Otherwise, both operands are converted to the unsigned integer type
    1471              :          corresponding to the type of the operand with signed integer type.  */
    1472            8 :       if (TYPE_UNSIGNED (code1 == BITINT_TYPE ? t1 : t2))
    1473            5 :         return c_common_unsigned_type (code1 == BITINT_TYPE ? t2 : t1);
    1474              :     }
    1475              : 
    1476              :   /* Otherwise prefer the unsigned one.  */
    1477              : 
    1478       505651 :   if (TYPE_UNSIGNED (t1))
    1479              :     return t1;
    1480              :   else
    1481              :     return t2;
    1482              : }
    1483              : 
    1484              : /* Wrapper around c_common_type that is used by c-common.cc and other
    1485              :    front end optimizations that remove promotions.  ENUMERAL_TYPEs
    1486              :    are allowed here and are converted to their compatible integer types.
    1487              :    BOOLEAN_TYPEs are allowed here and return either boolean_type_node or
    1488              :    preferably a non-Boolean type as the common type.  */
    1489              : tree
    1490       102982 : common_type (tree t1, tree t2)
    1491              : {
    1492       102982 :   if (TREE_CODE (t1) == ENUMERAL_TYPE)
    1493            0 :     t1 = ENUM_UNDERLYING_TYPE (t1);
    1494       102982 :   if (TREE_CODE (t2) == ENUMERAL_TYPE)
    1495            1 :     t2 = ENUM_UNDERLYING_TYPE (t2);
    1496              : 
    1497              :   /* If both types are BOOLEAN_TYPE, then return boolean_type_node.  */
    1498       102982 :   if (TREE_CODE (t1) == BOOLEAN_TYPE
    1499          584 :       && TREE_CODE (t2) == BOOLEAN_TYPE)
    1500          584 :     return boolean_type_node;
    1501              : 
    1502              :   /* If either type is BOOLEAN_TYPE, then return the other.  */
    1503       102398 :   if (TREE_CODE (t1) == BOOLEAN_TYPE)
    1504              :     return t2;
    1505       102398 :   if (TREE_CODE (t2) == BOOLEAN_TYPE)
    1506              :     return t1;
    1507              : 
    1508       102398 :   return c_common_type (t1, t2);
    1509              : }
    1510              : 
    1511              : 
    1512              : 
    1513              : /* Helper function for comptypes.  For two compatible types, return 1
    1514              :    if they pass consistency checks.  In particular we test that
    1515              :    TYPE_CANONICAL is set correctly, i.e. the two types can alias.  */
    1516              : 
    1517              : static bool
    1518     43028959 : comptypes_verify (tree type1, tree type2)
    1519              : {
    1520     43028959 :   if (type1 == type2 || !type1 || !type2
    1521      3509827 :       || TREE_CODE (type1) == ERROR_MARK || TREE_CODE (type2) == ERROR_MARK)
    1522              :     return true;
    1523              : 
    1524      3509826 :   gcc_checking_assert (c_verify_type (type1));
    1525      3509826 :   gcc_checking_assert (c_verify_type (type2));
    1526              : 
    1527      3509826 :   if (TYPE_CANONICAL (type1) != TYPE_CANONICAL (type2)
    1528       387227 :       && !TYPE_STRUCTURAL_EQUALITY_P (type1)
    1529      3895594 :       && !TYPE_STRUCTURAL_EQUALITY_P (type2))
    1530              :     {
    1531              :       /* FIXME: check other types. */
    1532       385457 :       if (RECORD_OR_UNION_TYPE_P (type1)
    1533       385457 :           || TREE_CODE (type1) == ENUMERAL_TYPE
    1534       385457 :           || TREE_CODE (type2) == ENUMERAL_TYPE)
    1535            0 :         return false;
    1536              :     }
    1537              :   return true;
    1538              : }
    1539              : 
    1540              : struct comptypes_data {
    1541              : 
    1542              :   /* output */
    1543              :   bool enum_and_int_p;
    1544              :   bool different_types_p;
    1545              :   bool warning_needed;
    1546              : 
    1547              :   /* context */
    1548              :   bool anon_field;
    1549              :   bool pointedto;
    1550              : 
    1551              :   /* configuration */
    1552              :   bool equiv;
    1553              :   bool ignore_promoting_args;
    1554              : 
    1555              :   const struct tagged_tu_seen_cache* cache;
    1556              : };
    1557              : 
    1558              : 
    1559              : /* Helper function for composite_type.  This function ignores when the
    1560              :    function type of an old-style declaration is incompatible with a type
    1561              :    of a declaration with prototype because some are arguments are not
    1562              :    self-promoting.  This is ignored only for function types but not
    1563              :    ignored in a nested context.  */
    1564              : 
    1565              : static bool
    1566     19384092 : comptypes_check_for_composite (tree t1, tree t2)
    1567              : {
    1568     19384092 :   struct comptypes_data data = { };
    1569     19384092 :   data.ignore_promoting_args = FUNCTION_TYPE == TREE_CODE (t1);
    1570     19384092 :   return comptypes_internal (t1, t2, &data);
    1571              : }
    1572              : 
    1573              : 
    1574              : /* C implementation of compatible_types_for_indirection_note_p.  */
    1575              : 
    1576              : bool
    1577          762 : compatible_types_for_indirection_note_p (tree type1, tree type2)
    1578              : {
    1579          762 :   return comptypes (type1, type2);
    1580              : }
    1581              : 
    1582              : /* Return true if TYPE1 and TYPE2 are compatible types for assignment
    1583              :    or various other operations.  */
    1584              : 
    1585              : bool
    1586     56539498 : comptypes (tree type1, tree type2)
    1587              : {
    1588     56539498 :   struct comptypes_data data = { };
    1589     56539498 :   bool ret = comptypes_internal (type1, type2, &data);
    1590              : 
    1591     56539498 :   gcc_checking_assert (!ret || comptypes_verify (type1, type2));
    1592              : 
    1593     56539498 :   return ret;
    1594              : }
    1595              : 
    1596              : 
    1597              : /* Like comptypes, but it returns non-zero only for identical
    1598              :    types.  */
    1599              : 
    1600              : bool
    1601        46244 : comptypes_same_p (tree type1, tree type2)
    1602              : {
    1603        46244 :   struct comptypes_data data = { };
    1604        46244 :   bool ret = comptypes_internal (type1, type2, &data);
    1605              : 
    1606        46244 :   gcc_checking_assert (!ret || comptypes_verify (type1, type2));
    1607              : 
    1608        46244 :   if (data.different_types_p)
    1609          163 :     return false;
    1610              : 
    1611              :   return ret;
    1612              : }
    1613              : 
    1614              : 
    1615              : /* Like comptypes, but if it returns true because enum and int are
    1616              :    compatible, it sets *ENUM_AND_INT_P to true.  */
    1617              : 
    1618              : bool
    1619      5108879 : comptypes_check_enum_int (tree type1, tree type2, bool *enum_and_int_p)
    1620              : {
    1621      5108879 :   struct comptypes_data data = { };
    1622      5108879 :   bool ret = comptypes_internal (type1, type2, &data);
    1623      5108879 :   *enum_and_int_p = data.enum_and_int_p;
    1624              : 
    1625      5108879 :   gcc_checking_assert (!ret || comptypes_verify (type1, type2));
    1626              : 
    1627      5108879 :   return ret;
    1628              : }
    1629              : 
    1630              : 
    1631              : 
    1632              : /* Like comptypes, but if it returns true for struct and union types
    1633              :    considered equivalent for aliasing purposes, i.e. for setting
    1634              :    TYPE_CANONICAL after completing a struct or union.
    1635              : 
    1636              :    This function must return false only for types which are not
    1637              :    compatible according to C language semantics (cf. comptypes),
    1638              :    otherwise the middle-end would make incorrect aliasing decisions.
    1639              :    It may return true for some similar types that are not compatible
    1640              :    according to those stricter rules.
    1641              : 
    1642              :    In particular, we ignore size expression in arrays so that the
    1643              :    following structs are in the same equivalence class:
    1644              : 
    1645              :    struct foo { char (*buf)[]; };
    1646              :    struct foo { char (*buf)[3]; };
    1647              :    struct foo { char (*buf)[4]; };
    1648              : 
    1649              :    We also treat unions / structs with members which are pointers to
    1650              :    structures or unions with the same tag as equivalent (if they are not
    1651              :    incompatible for other reasons).  Although incomplete structure
    1652              :    or union types are not compatible to any other type, they may become
    1653              :    compatible to different types when completed.  To avoid having to update
    1654              :    TYPE_CANONICAL at this point, we only consider the tag when forming
    1655              :    the equivalence classes.  For example, the following types with tag
    1656              :    'foo' are all considered equivalent:
    1657              : 
    1658              :    struct bar;
    1659              :    struct foo { struct bar *x };
    1660              :    struct foo { struct bar { int a; } *x };
    1661              :    struct foo { struct bar { char b; } *x };  */
    1662              : 
    1663              : bool
    1664     14650762 : comptypes_equiv_p (tree type1, tree type2)
    1665              : {
    1666     14650762 :   struct comptypes_data data = { };
    1667     14650762 :   data.equiv = true;
    1668     14650762 :   bool ret = comptypes_internal (type1, type2, &data);
    1669              : 
    1670              :   /* check that different equivance classes are assigned only
    1671              :      to types that are not compatible.  */
    1672     14650762 :   gcc_checking_assert (ret || !comptypes (type1, type2));
    1673              : 
    1674     14650762 :   return ret;
    1675              : }
    1676              : 
    1677              : 
    1678              : /* Return true if TYPE1 and TYPE2 are compatible types for assignment
    1679              :    or various other operations.  If they are compatible but a warning may
    1680              :    be needed if you use them together, 'warning_needed' in DATA is set.
    1681              :    If one type is an enum and the other a compatible integer type, then
    1682              :    this sets 'enum_and_int_p' in DATA to true (it is never set to
    1683              :    false).  If the types are compatible but different enough not to be
    1684              :    permitted in C11 typedef redeclarations, then this sets
    1685              :    'different_types_p' in DATA to true; it is never set to
    1686              :    false, but may or may not be set if the types are incompatible.
    1687              :    If two functions types are not compatible only because one is
    1688              :    an old-style definition that does not have self-promoting arguments,
    1689              :    then this can be ignored by setting 'ignore_promoting_args_p'.
    1690              :    For 'equiv' we can compute equivalency classes (see above).  */
    1691              : 
    1692              : static bool
    1693    134274806 : comptypes_internal (const_tree type1, const_tree type2,
    1694              :                     struct comptypes_data *data)
    1695              : {
    1696    134558812 :   const_tree t1 = type1;
    1697    134558812 :   const_tree t2 = type2;
    1698              : 
    1699              :   /* Suppress errors caused by previously reported errors.  */
    1700              : 
    1701    134558812 :   if (t1 == t2 || !t1 || !t2
    1702     45360945 :       || TREE_CODE (t1) == ERROR_MARK || TREE_CODE (t2) == ERROR_MARK)
    1703              :     return true;
    1704              : 
    1705              :   /* Qualifiers must match. C99 6.7.3p9 */
    1706              : 
    1707     45360942 :   if (TYPE_QUALS (t1) != TYPE_QUALS (t2))
    1708              :     return false;
    1709              : 
    1710              :   /* Enumerated types are compatible with integer types, but this is
    1711              :      not transitive: two enumerated types in the same translation unit
    1712              :      are compatible with each other only if they are the same type.  */
    1713              : 
    1714     45320725 :   if (TREE_CODE (t1) == ENUMERAL_TYPE
    1715         1018 :       && COMPLETE_TYPE_P (t1)
    1716     45321699 :       && TREE_CODE (t2) != ENUMERAL_TYPE)
    1717              :     {
    1718          858 :       t1 = ENUM_UNDERLYING_TYPE (t1);
    1719          858 :       if (TREE_CODE (t2) != VOID_TYPE)
    1720              :         {
    1721          854 :           data->enum_and_int_p = true;
    1722          854 :           data->different_types_p = true;
    1723              :         }
    1724              :     }
    1725     45319867 :   else if (TREE_CODE (t2) == ENUMERAL_TYPE
    1726         4722 :            && COMPLETE_TYPE_P (t2)
    1727     45324583 :            && TREE_CODE (t1) != ENUMERAL_TYPE)
    1728              :     {
    1729         4600 :       t2 = ENUM_UNDERLYING_TYPE (t2);
    1730         4600 :       if (TREE_CODE (t1) != VOID_TYPE)
    1731              :         {
    1732         3701 :           data->enum_and_int_p = true;
    1733         3701 :           data->different_types_p = true;
    1734              :         }
    1735              :     }
    1736              : 
    1737     45320725 :   if (t1 == t2)
    1738              :     return true;
    1739              : 
    1740              :   /* Different classes of types can't be compatible.  */
    1741              : 
    1742     45319353 :   if (TREE_CODE (t1) != TREE_CODE (t2))
    1743              :     return false;
    1744              : 
    1745              :   /* Allow for two different type nodes which have essentially the same
    1746              :      definition.  Note that we already checked for equality of the type
    1747              :      qualifiers (just above).  */
    1748              : 
    1749     37353628 :   if (TREE_CODE (t1) != ARRAY_TYPE
    1750     37353628 :       && TYPE_MAIN_VARIANT (t1) == TYPE_MAIN_VARIANT (t2))
    1751              :     return true;
    1752              : 
    1753     37016121 :   int attrval;
    1754              : 
    1755              :   /* 1 if no need for warning yet, 2 if warning cause has been seen.  */
    1756     37016121 :   if (!(attrval = comp_type_attributes (t1, t2)))
    1757              :     return false;
    1758              : 
    1759     37015744 :   if (2 == attrval)
    1760          336 :     data->warning_needed = true;
    1761              : 
    1762     37015744 :   switch (TREE_CODE (t1))
    1763              :     {
    1764      3360744 :     case INTEGER_TYPE:
    1765      3360744 :     case FIXED_POINT_TYPE:
    1766      3360744 :     case REAL_TYPE:
    1767      3360744 :     case BITINT_TYPE:
    1768              :       /* With these nodes, we can't determine type equivalence by
    1769              :          looking at what is stored in the nodes themselves, because
    1770              :          two nodes might have different TYPE_MAIN_VARIANTs but still
    1771              :          represent the same type.  For example, wchar_t and int could
    1772              :          have the same properties (TYPE_PRECISION, TYPE_MIN_VALUE,
    1773              :          TYPE_MAX_VALUE, etc.), but have different TYPE_MAIN_VARIANTs
    1774              :          and are distinct types.  On the other hand, int and the
    1775              :          following typedef
    1776              : 
    1777              :            typedef int INT __attribute((may_alias));
    1778              : 
    1779              :          have identical properties, different TYPE_MAIN_VARIANTs, but
    1780              :          represent the same type.  The canonical type system keeps
    1781              :          track of equivalence in this case, so we fall back on it.  */
    1782      3360744 :       return TYPE_CANONICAL (t1) == TYPE_CANONICAL (t2);
    1783              : 
    1784       284006 :     case POINTER_TYPE:
    1785              :       /* Do not remove mode information.  */
    1786       284006 :       if (TYPE_MODE (t1) != TYPE_MODE (t2))
    1787              :         return false;
    1788       284006 :       data->pointedto = true;
    1789       284006 :       return comptypes_internal (TREE_TYPE (t1), TREE_TYPE (t2), data);
    1790              : 
    1791      9158063 :     case FUNCTION_TYPE:
    1792      9158063 :       return function_types_compatible_p (t1, t2, data);
    1793              : 
    1794       154612 :     case ARRAY_TYPE:
    1795       154612 :       {
    1796       154612 :         tree d1 = TYPE_DOMAIN (t1);
    1797       154612 :         tree d2 = TYPE_DOMAIN (t2);
    1798       154612 :         bool d1_variable, d2_variable;
    1799       154612 :         bool d1_zero, d2_zero;
    1800              : 
    1801              :         /* Target types must match incl. qualifiers.  */
    1802       154612 :         if (!comptypes_internal (TREE_TYPE (t1), TREE_TYPE (t2), data))
    1803              :           return false;
    1804              : 
    1805       119688 :         if ((d1 == NULL_TREE) != (d2 == NULL_TREE))
    1806         6350 :           data->different_types_p = true;
    1807              :         /* Ignore size mismatches when forming equivalence classes.  */
    1808       119688 :         if (data->equiv)
    1809              :           return true;
    1810              :         /* Sizes must match unless one is missing or variable.  */
    1811        50394 :         if (d1 == NULL_TREE || d2 == NULL_TREE || d1 == d2)
    1812              :           return true;
    1813              : 
    1814        34120 :         d1_zero = !TYPE_MAX_VALUE (d1);
    1815        34120 :         d2_zero = !TYPE_MAX_VALUE (d2);
    1816              : 
    1817        68240 :         d1_variable = (!d1_zero
    1818        34120 :                        && (TREE_CODE (TYPE_MIN_VALUE (d1)) != INTEGER_CST
    1819        34088 :                            || TREE_CODE (TYPE_MAX_VALUE (d1)) != INTEGER_CST));
    1820        68240 :         d2_variable = (!d2_zero
    1821        34120 :                        && (TREE_CODE (TYPE_MIN_VALUE (d2)) != INTEGER_CST
    1822        33992 :                            || TREE_CODE (TYPE_MAX_VALUE (d2)) != INTEGER_CST));
    1823              : 
    1824        34120 :         if (d1_variable != d2_variable)
    1825          943 :           data->different_types_p = true;
    1826        34120 :         if (d1_variable || d2_variable)
    1827              :           return true;
    1828         4027 :         if (d1_zero && d2_zero)
    1829              :           return true;
    1830         4027 :         if (d1_zero || d2_zero
    1831         3931 :             || !tree_int_cst_equal (TYPE_MIN_VALUE (d1), TYPE_MIN_VALUE (d2))
    1832         7958 :             || !tree_int_cst_equal (TYPE_MAX_VALUE (d1), TYPE_MAX_VALUE (d2)))
    1833         4027 :           return false;
    1834              : 
    1835              :         return true;
    1836              :       }
    1837              : 
    1838     23520564 :     case ENUMERAL_TYPE:
    1839     23520564 :     case RECORD_TYPE:
    1840     23520564 :     case UNION_TYPE:
    1841              : 
    1842     23520564 :       if (!flag_isoc23)
    1843              :         return false;
    1844              : 
    1845     23520517 :       return tagged_types_tu_compatible_p (t1, t2, data);
    1846              : 
    1847       536950 :     case VECTOR_TYPE:
    1848      1073900 :       return known_eq (TYPE_VECTOR_SUBPARTS (t1), TYPE_VECTOR_SUBPARTS (t2))
    1849       536950 :              && comptypes_internal (TREE_TYPE (t1), TREE_TYPE (t2), data);
    1850              : 
    1851              :     default:
    1852              :       return false;
    1853              :     }
    1854              :   gcc_unreachable ();
    1855              : }
    1856              : 
    1857              : /* Return true if TTL and TTR are pointers to types that are equivalent, ignoring
    1858              :    their qualifiers, except for named address spaces.  If the pointers point to
    1859              :    different named addresses, then we must determine if one address space is a
    1860              :    subset of the other.  */
    1861              : 
    1862              : static bool
    1863      1767976 : comp_target_types (location_t location, tree ttl, tree ttr)
    1864              : {
    1865      1767976 :   tree mvl = TREE_TYPE (ttl);
    1866      1767976 :   tree mvr = TREE_TYPE (ttr);
    1867      1767976 :   addr_space_t asl = TYPE_ADDR_SPACE (mvl);
    1868      1767976 :   addr_space_t asr = TYPE_ADDR_SPACE (mvr);
    1869      1767976 :   addr_space_t as_common;
    1870              : 
    1871              :   /* Fail if pointers point to incompatible address spaces.  */
    1872      1767976 :   if (!addr_space_superset (asl, asr, &as_common))
    1873              :     return 0;
    1874              : 
    1875              :   /* Qualifiers on element types of array types that are
    1876              :      pointer targets are also removed.  */
    1877      1767976 :   struct comptypes_data data = { };
    1878      1767976 :   if (!comptypes_internal (remove_qualifiers (mvl),
    1879      1767976 :                            remove_qualifiers (mvr), &data))
    1880              :     return false;
    1881              : 
    1882              :   /* For pedantic use comptypes on arrays before removing
    1883              :      qualifiers on the element type. */
    1884      1666635 :   if (TREE_CODE (mvl) == ARRAY_TYPE
    1885         1891 :       && TREE_CODE (mvr) == ARRAY_TYPE
    1886      1668526 :       && !comptypes (mvl, mvr))
    1887          190 :     pedwarn_c11 (location, OPT_Wpedantic, "invalid use of pointers to arrays "
    1888              :                                           "with different qualifiers in ISO C "
    1889              :                                           "before C23");
    1890              : 
    1891      1666635 :   if (data.warning_needed)
    1892          126 :     pedwarn (location, OPT_Wpedantic, "types are not quite compatible");
    1893              : 
    1894      1666635 :   if (data.enum_and_int_p && warn_cxx_compat)
    1895            2 :     warning_at (location, OPT_Wc___compat,
    1896              :                 "pointer target types incompatible in C++");
    1897              : 
    1898              :   return true;
    1899              : }
    1900              : 
    1901              : /* Subroutines of `comptypes'.  */
    1902              : 
    1903              : /* Return true if two 'struct', 'union', or 'enum' types T1 and T2 are
    1904              :    compatible.  The two types are not the same (which has been
    1905              :    checked earlier in comptypes_internal).  */
    1906              : 
    1907              : static bool
    1908     23520517 : tagged_types_tu_compatible_p (const_tree t1, const_tree t2,
    1909              :                               struct comptypes_data *data)
    1910              : {
    1911     23520517 :   tree s1, s2;
    1912              : 
    1913     23520517 :   if (c_type_tag (t1) != c_type_tag (t2))
    1914              :     return false;
    1915              : 
    1916              :   /* When forming equivalence classes for TYPE_CANONICAL in C23, we treat
    1917              :      structs with the same tag as equivalent, but only when they are targets
    1918              :      of pointers inside other structs.  */
    1919     19405624 :   if (data->equiv && data->pointedto && NULL_TREE != c_type_tag (t1))
    1920              :     return true;
    1921              : 
    1922              :   /* Different types without tag are incompatible except as an anonymous
    1923              :      field or when forming equivalence classes for TYPE_CANONICAL.  */
    1924     19405562 :   if (!data->anon_field && !data->equiv && NULL_TREE == c_type_tag (t1))
    1925              :     return false;
    1926              : 
    1927     14264526 :   if (!data->anon_field && TYPE_STUB_DECL (t1) != TYPE_STUB_DECL (t2))
    1928     14263481 :     data->different_types_p = true;
    1929              : 
    1930              :   /* Incomplete types are incompatible inside a TU.  */
    1931     14264526 :   if (TYPE_SIZE (t1) == NULL || TYPE_SIZE (t2) == NULL)
    1932              :     return false;
    1933              : 
    1934     14264516 :   if (ENUMERAL_TYPE != TREE_CODE (t1)
    1935     14264516 :       && (TYPE_REVERSE_STORAGE_ORDER (t1)
    1936     14264461 :           != TYPE_REVERSE_STORAGE_ORDER (t2)))
    1937              :     return false;
    1938              : 
    1939     14264506 :   if (TYPE_USER_ALIGN (t1) != TYPE_USER_ALIGN (t2))
    1940       143921 :     data->different_types_p = true;
    1941              : 
    1942              :   /* For types already being looked at in some active
    1943              :      invocation of this function, assume compatibility.
    1944              :      The cache is built as a linked list on the stack
    1945              :      with the head of the list passed downwards.  */
    1946     14264506 :   for (const struct tagged_tu_seen_cache *t = data->cache;
    1947     14274183 :        t != NULL; t = t->next)
    1948         9972 :     if (t->t1 == t1 && t->t2 == t2)
    1949              :       return true;
    1950              : 
    1951     14264211 :   const struct tagged_tu_seen_cache entry = { data->cache, t1, t2 };
    1952              : 
    1953     14264211 :   switch (TREE_CODE (t1))
    1954              :     {
    1955           55 :     case ENUMERAL_TYPE:
    1956           55 :       {
    1957           55 :         if (!comptypes (ENUM_UNDERLYING_TYPE (t1), ENUM_UNDERLYING_TYPE (t2)))
    1958              :           return false;
    1959              : 
    1960              :         /* Speed up the case where the type values are in the same order.  */
    1961           51 :         tree tv1 = TYPE_VALUES (t1);
    1962           51 :         tree tv2 = TYPE_VALUES (t2);
    1963              : 
    1964           51 :         if (tv1 == tv2)
    1965              :           return true;
    1966              : 
    1967           97 :         for (;tv1 && tv2; tv1 = TREE_CHAIN (tv1), tv2 = TREE_CHAIN (tv2))
    1968              :           {
    1969           58 :             if (TREE_PURPOSE (tv1) != TREE_PURPOSE (tv2))
    1970              :               break;
    1971              : 
    1972           51 :             if (simple_cst_equal (DECL_INITIAL (TREE_VALUE (tv1)),
    1973           51 :                                   DECL_INITIAL (TREE_VALUE (tv2))) != 1)
    1974              :               break;
    1975              :           }
    1976              : 
    1977           51 :         if (tv1 == NULL_TREE && tv2 == NULL_TREE)
    1978              :           return true;
    1979              : 
    1980           12 :         if (tv1 == NULL_TREE || tv2 == NULL_TREE)
    1981              :           return false;
    1982              : 
    1983           12 :         if (list_length (TYPE_VALUES (t1)) != list_length (TYPE_VALUES (t2)))
    1984              :           return false;
    1985              : 
    1986           20 :         for (s1 = TYPE_VALUES (t1); s1; s1 = TREE_CHAIN (s1))
    1987              :           {
    1988           16 :             s2 = purpose_member (TREE_PURPOSE (s1), TYPE_VALUES (t2));
    1989              : 
    1990           16 :             if (s2 == NULL
    1991           29 :                 || simple_cst_equal (DECL_INITIAL (TREE_VALUE (s1)),
    1992           13 :                                      DECL_INITIAL (TREE_VALUE (s2))) != 1)
    1993            8 :               return false;
    1994              :           }
    1995              : 
    1996              :         return true;
    1997              :       }
    1998              : 
    1999     14264156 :     case UNION_TYPE:
    2000     14264156 :     case RECORD_TYPE:
    2001              : 
    2002     14264156 :         if (list_length (TYPE_FIELDS (t1)) != list_length (TYPE_FIELDS (t2)))
    2003              :           return false;
    2004              : 
    2005     12325774 :         for (s1 = TYPE_FIELDS (t1), s2 = TYPE_FIELDS (t2);
    2006     13847790 :              s1 && s2;
    2007      1522016 :              s1 = DECL_CHAIN (s1), s2 = DECL_CHAIN (s2))
    2008              :           {
    2009     13782454 :             gcc_assert (TREE_CODE (s1) == FIELD_DECL);
    2010     13782454 :             gcc_assert (TREE_CODE (s2) == FIELD_DECL);
    2011              : 
    2012     13782454 :             tree ft1 = TREE_TYPE (s1);
    2013     13782454 :             tree ft2 = TREE_TYPE (s2);
    2014              : 
    2015     13782454 :             if (DECL_NAME (s1) != DECL_NAME (s2))
    2016              :               return false;
    2017              : 
    2018     12134254 :             if (DECL_ALIGN (s1) != DECL_ALIGN (s2))
    2019              :               return false;
    2020              : 
    2021      3232611 :             if (DECL_C_BIT_FIELD (s1) != DECL_C_BIT_FIELD (s2))
    2022              :                return false;
    2023              : 
    2024      3232591 :             if (DECL_C_BIT_FIELD (s1))
    2025              :               {
    2026          496 :                 if (!tree_int_cst_equal (DECL_SIZE (s1), DECL_SIZE (s2)))
    2027              :                   return false;
    2028              : 
    2029          342 :                 ft1 = DECL_BIT_FIELD_TYPE (s1);
    2030          342 :                 ft2 = DECL_BIT_FIELD_TYPE (s2);
    2031              :               }
    2032              : 
    2033      3232437 :             if (!ft1 || !ft2)
    2034              :               return false;
    2035              : 
    2036      3232437 :             if (TREE_CODE (ft1) == ERROR_MARK || TREE_CODE (ft2) == ERROR_MARK)
    2037              :               return false;
    2038              : 
    2039      3232436 :             data->anon_field = !DECL_NAME (s1);
    2040      3232436 :             data->pointedto = false;
    2041              : 
    2042      3232436 :             const struct tagged_tu_seen_cache *cache = data->cache;
    2043      3232436 :             data->cache = &entry;
    2044      3232436 :             bool ret = comptypes_internal (ft1, ft2, data);
    2045      3232436 :             data->cache = cache;
    2046      3232436 :             if (!ret)
    2047              :               return false;
    2048              : 
    2049      1591198 :             tree st1 = TYPE_SIZE (TREE_TYPE (s1));
    2050      1591198 :             tree st2 = TYPE_SIZE (TREE_TYPE (s2));
    2051              : 
    2052      1591198 :             if (data->equiv
    2053       996914 :                 && st1 && TREE_CODE (st1) == INTEGER_CST
    2054       996432 :                 && st2 && TREE_CODE (st2) == INTEGER_CST
    2055      2587624 :                 && !tree_int_cst_equal (st1, st2))
    2056              :              return false;
    2057              : 
    2058      1522050 :             tree counted_by1 = lookup_attribute ("counted_by",
    2059      1522050 :                                                  DECL_ATTRIBUTES (s1));
    2060      1522050 :             tree counted_by2 = lookup_attribute ("counted_by",
    2061      1522050 :                                                  DECL_ATTRIBUTES (s2));
    2062              :             /* If there is no counted_by attribute for both fields.  */
    2063      1522050 :             if (!counted_by1 && !counted_by2)
    2064      1521986 :               continue;
    2065              : 
    2066              :             /* If only one field has counted_by attribute.  */
    2067           64 :             if ((counted_by1 && !counted_by2)
    2068           64 :                 || (!counted_by1 && counted_by2))
    2069              :               return false;
    2070              : 
    2071              :             /* Now both s1 and s2 have counted_by attributes, check
    2072              :                whether they are the same.  */
    2073              : 
    2074           52 :             tree counted_by_field1
    2075           52 :               = lookup_field (t1, TREE_VALUE (TREE_VALUE (counted_by1)));
    2076           52 :             tree counted_by_field2
    2077           52 :               = lookup_field (t2, TREE_VALUE (TREE_VALUE (counted_by2)));
    2078              : 
    2079           52 :             gcc_assert (counted_by_field1 && counted_by_field2);
    2080              : 
    2081           94 :             while (TREE_CHAIN (counted_by_field1))
    2082           42 :               counted_by_field1 = TREE_CHAIN (counted_by_field1);
    2083           86 :             while (TREE_CHAIN (counted_by_field2))
    2084           34 :               counted_by_field2 = TREE_CHAIN (counted_by_field2);
    2085              : 
    2086           52 :             if (DECL_NAME (TREE_VALUE (counted_by_field1))
    2087           52 :                 != DECL_NAME (TREE_VALUE (counted_by_field2)))
    2088              :               return false;
    2089              :           }
    2090              :         return true;
    2091              : 
    2092            0 :     default:
    2093            0 :       gcc_unreachable ();
    2094              :     }
    2095              : }
    2096              : 
    2097              : /* Return true if two function types F1 and F2 are compatible.
    2098              :    If either type specifies no argument types,
    2099              :    the other must specify a fixed number of self-promoting arg types.
    2100              :    Otherwise, if one type specifies only the number of arguments,
    2101              :    the other must specify that number of self-promoting arg types.
    2102              :    Otherwise, the argument types must match.  */
    2103              : 
    2104              : static bool
    2105      9158063 : function_types_compatible_p (const_tree f1, const_tree f2,
    2106              :                              struct comptypes_data *data)
    2107              : {
    2108      9158063 :   tree ret1 = TREE_TYPE (f1);
    2109      9158063 :   tree ret2 = TREE_TYPE (f2);
    2110              : 
    2111              :   /* 'volatile' qualifiers on a function's return type used to mean
    2112              :      the function is noreturn.  */
    2113      9158063 :   if (TYPE_VOLATILE (ret1) != TYPE_VOLATILE (ret2))
    2114           29 :     pedwarn (input_location, 0, "function return types not compatible due to %<volatile%>");
    2115      9158063 :   if (TYPE_VOLATILE (ret1))
    2116           15 :     ret1 = build_qualified_type (TYPE_MAIN_VARIANT (ret1),
    2117           15 :                                  TYPE_QUALS (ret1) & ~TYPE_QUAL_VOLATILE);
    2118      9158063 :   if (TYPE_VOLATILE (ret2))
    2119           18 :     ret2 = build_qualified_type (TYPE_MAIN_VARIANT (ret2),
    2120           18 :                                  TYPE_QUALS (ret2) & ~TYPE_QUAL_VOLATILE);
    2121              : 
    2122      9158063 :   bool ignore_pargs = data->ignore_promoting_args;
    2123      9158063 :   data->ignore_promoting_args = false;
    2124              : 
    2125      9158063 :   if (!comptypes_internal (ret1, ret2, data))
    2126              :     return false;
    2127              : 
    2128      9155468 :   data->ignore_promoting_args = ignore_pargs;
    2129              : 
    2130      9155468 :   tree args1 = TYPE_ARG_TYPES (f1);
    2131      9155468 :   tree args2 = TYPE_ARG_TYPES (f2);
    2132              : 
    2133      9155468 :   if ((args1 == NULL_TREE) != (args2 == NULL_TREE))
    2134        45201 :     data->different_types_p = true;
    2135              : 
    2136              :   /* An unspecified parmlist matches any specified parmlist
    2137              :      whose argument types don't need default promotions.  */
    2138              : 
    2139      9155468 :   if (args1 == NULL_TREE)
    2140              :     {
    2141        23745 :       if (TYPE_NO_NAMED_ARGS_STDARG_P (f1) != TYPE_NO_NAMED_ARGS_STDARG_P (f2))
    2142              :         return false;
    2143        23742 :       if (!(data->ignore_promoting_args || self_promoting_args_p (args2)))
    2144              :         return false;
    2145        23270 :       data->ignore_promoting_args = false;
    2146              :       /* If one of these types comes from a non-prototype fn definition,
    2147              :          compare that with the other type's arglist.
    2148              :          If they don't match, ask for a warning (but no error).  */
    2149        23270 :       if (TYPE_ACTUAL_ARG_TYPES (f1)
    2150        23270 :           && !type_lists_compatible_p (args2, TYPE_ACTUAL_ARG_TYPES (f1), data))
    2151           12 :          data->warning_needed = true;
    2152        23270 :       return true;
    2153              :     }
    2154      9131723 :   if (args2 == NULL_TREE)
    2155              :     {
    2156        21538 :       if (TYPE_NO_NAMED_ARGS_STDARG_P (f1) != TYPE_NO_NAMED_ARGS_STDARG_P (f2))
    2157              :         return false;
    2158        21536 :       if (!(data->ignore_promoting_args || self_promoting_args_p (args1)))
    2159              :         return false;
    2160        21475 :       data->ignore_promoting_args = false;
    2161        21475 :       if (TYPE_ACTUAL_ARG_TYPES (f2)
    2162        21475 :           && !type_lists_compatible_p (args1, TYPE_ACTUAL_ARG_TYPES (f2), data))
    2163            1 :         data->warning_needed = true;
    2164        21475 :       return true;
    2165              :     }
    2166              : 
    2167              :   /* Both types have argument lists: compare them and propagate results.  */
    2168      9110185 :   return type_lists_compatible_p (args1, args2, data);
    2169              : }
    2170              : 
    2171              : /* Check two lists of types for compatibility, returning false for
    2172              :    incompatible, true for compatible.  */
    2173              : 
    2174              : static bool
    2175      9110261 : type_lists_compatible_p (const_tree args1, const_tree args2,
    2176              :                          struct comptypes_data *data)
    2177              : {
    2178     56601273 :   while (1)
    2179              :     {
    2180     32855767 :       if (args1 == NULL_TREE && args2 == NULL_TREE)
    2181              :         return true;
    2182              :       /* If one list is shorter than the other,
    2183              :          they fail to match.  */
    2184     23890751 :       if (args1 == NULL_TREE || args2 == NULL_TREE)
    2185              :         return false;
    2186     23890744 :       tree a1 = TREE_VALUE (args1);
    2187     23890744 :       tree a2 = TREE_VALUE (args2);
    2188     23890744 :       tree mv1 = remove_qualifiers (a1);
    2189     23890744 :       tree mv2 = remove_qualifiers (a2);
    2190              : 
    2191     23890744 :       gcc_assert (mv2);
    2192     23890744 :       gcc_assert (mv2);
    2193              : 
    2194              :       /* If one of the lists has an error marker, ignore this arg.  */
    2195     23890744 :       if (TREE_CODE (a1) == ERROR_MARK
    2196     23890740 :                || TREE_CODE (a2) == ERROR_MARK)
    2197              :         ;
    2198     23890724 :       else if (!comptypes_internal (mv1, mv2, data))
    2199              :         {
    2200       145469 :           data->different_types_p = true;
    2201              :           /* Allow  wait (union {union wait *u; int *i} *)
    2202              :              and  wait (union wait *)  to be compatible.  */
    2203       145469 :           if (TREE_CODE (a1) == UNION_TYPE
    2204          130 :               && (TYPE_NAME (a1) == NULL_TREE
    2205           98 :                   || TYPE_TRANSPARENT_AGGR (a1))
    2206          130 :               && TREE_CODE (TYPE_SIZE (a1)) == INTEGER_CST
    2207       145599 :               && tree_int_cst_equal (TYPE_SIZE (a1),
    2208          130 :                                      TYPE_SIZE (a2)))
    2209              :             {
    2210          130 :               tree memb;
    2211          130 :               for (memb = TYPE_FIELDS (a1);
    2212          166 :                    memb; memb = DECL_CHAIN (memb))
    2213              :                 {
    2214          164 :                   tree mv3 = remove_qualifiers (TREE_TYPE (memb));
    2215          164 :                   if (comptypes_internal (mv3, mv2, data))
    2216              :                     break;
    2217              :                 }
    2218              :               if (memb == NULL_TREE)
    2219              :                 return false;
    2220              :             }
    2221       145339 :           else if (TREE_CODE (a2) == UNION_TYPE
    2222          105 :                    && (TYPE_NAME (a2) == NULL_TREE
    2223           74 :                        || TYPE_TRANSPARENT_AGGR (a2))
    2224          105 :                    && TREE_CODE (TYPE_SIZE (a2)) == INTEGER_CST
    2225       145444 :                    && tree_int_cst_equal (TYPE_SIZE (a2),
    2226          105 :                                           TYPE_SIZE (a1)))
    2227              :             {
    2228          105 :               tree memb;
    2229          105 :               for (memb = TYPE_FIELDS (a2);
    2230          133 :                    memb; memb = DECL_CHAIN (memb))
    2231              :                 {
    2232          131 :                   tree mv3 = remove_qualifiers (TREE_TYPE (memb));
    2233          131 :                   if (comptypes_internal (mv3, mv1, data))
    2234              :                     break;
    2235              :                 }
    2236              :               if (memb == NULL_TREE)
    2237              :                 return false;
    2238              :             }
    2239              :           else
    2240       145234 :             return false;
    2241              :         }
    2242              : 
    2243     23745506 :       args1 = TREE_CHAIN (args1);
    2244     23745506 :       args2 = TREE_CHAIN (args2);
    2245     23745506 :     }
    2246              : }
    2247              : 
    2248              : /* Compute the size to increment a pointer by.  When a function type or void
    2249              :    type or incomplete type is passed, size_one_node is returned.
    2250              :    This function does not emit any diagnostics; the caller is responsible
    2251              :    for that.  */
    2252              : 
    2253              : static tree
    2254       234011 : c_size_in_bytes (const_tree type)
    2255              : {
    2256       234011 :   enum tree_code code = TREE_CODE (type);
    2257              : 
    2258       234011 :   if (code == FUNCTION_TYPE || code == VOID_TYPE || code == ERROR_MARK
    2259       234011 :       || !COMPLETE_TYPE_P (type))
    2260          191 :     return size_one_node;
    2261              : 
    2262              :   /* Convert in case a char is more than one unit.  */
    2263       233820 :   return size_binop_loc (input_location, CEIL_DIV_EXPR, TYPE_SIZE_UNIT (type),
    2264       233820 :                          size_int (TYPE_PRECISION (char_type_node)
    2265              :                                    / BITS_PER_UNIT));
    2266              : }
    2267              : 
    2268              : /* Return either DECL or its known constant value (if it has one).  */
    2269              : 
    2270              : tree
    2271     14342677 : decl_constant_value_1 (tree decl, bool in_init)
    2272              : {
    2273     14342677 :   if (/* Note that DECL_INITIAL isn't valid for a PARM_DECL.  */
    2274     14342677 :       TREE_CODE (decl) != PARM_DECL
    2275     14342677 :       && !TREE_THIS_VOLATILE (decl)
    2276     13998338 :       && TREE_READONLY (decl)
    2277        36755 :       && DECL_INITIAL (decl) != NULL_TREE
    2278        35759 :       && !error_operand_p (DECL_INITIAL (decl))
    2279              :       /* This is invalid if initial value is not constant.
    2280              :          If it has either a function call, a memory reference,
    2281              :          or a variable, then re-evaluating it could give different results.  */
    2282        35750 :       && TREE_CONSTANT (DECL_INITIAL (decl))
    2283              :       /* Check for cases where this is sub-optimal, even though valid.  */
    2284     14365365 :       && (in_init || TREE_CODE (DECL_INITIAL (decl)) != CONSTRUCTOR))
    2285        17572 :     return DECL_INITIAL (decl);
    2286              :   return decl;
    2287              : }
    2288              : 
    2289              : /* Return either DECL or its known constant value (if it has one).
    2290              :    Like the above, but always return decl outside of functions.  */
    2291              : 
    2292              : tree
    2293     14342429 : decl_constant_value (tree decl)
    2294              : {
    2295              :   /* Don't change a variable array bound or initial value to a constant
    2296              :      in a place where a variable is invalid.  */
    2297     14342429 :   return current_function_decl ? decl_constant_value_1 (decl, false) : decl;
    2298              : }
    2299              : 
    2300              : /* Convert the array expression EXP to a pointer.  */
    2301              : static tree
    2302       826586 : array_to_pointer_conversion (location_t loc, tree exp)
    2303              : {
    2304       826586 :   tree orig_exp = exp;
    2305       826586 :   tree type = TREE_TYPE (exp);
    2306       826586 :   tree adr;
    2307       826586 :   tree restype = TREE_TYPE (type);
    2308       826586 :   tree ptrtype;
    2309              : 
    2310       826586 :   gcc_assert (TREE_CODE (type) == ARRAY_TYPE);
    2311              : 
    2312       826586 :   STRIP_TYPE_NOPS (exp);
    2313              : 
    2314       826586 :   copy_warning (exp, orig_exp);
    2315              : 
    2316       826586 :   ptrtype = c_build_pointer_type (restype);
    2317              : 
    2318       826586 :   if (INDIRECT_REF_P (exp))
    2319         2906 :     return convert (ptrtype, TREE_OPERAND (exp, 0));
    2320              : 
    2321              :   /* In C++ array compound literals are temporary objects unless they are
    2322              :      const or appear in namespace scope, so they are destroyed too soon
    2323              :      to use them for much of anything  (c++/53220).  */
    2324       823680 :   if (warn_cxx_compat && TREE_CODE (exp) == COMPOUND_LITERAL_EXPR)
    2325              :     {
    2326           48 :       tree decl = TREE_OPERAND (TREE_OPERAND (exp, 0), 0);
    2327           48 :       if (!TREE_READONLY (decl) && !TREE_STATIC (decl))
    2328           46 :         warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wc___compat,
    2329              :                     "converting an array compound literal to a pointer "
    2330              :                     "leads to a dangling pointer in C++");
    2331              :     }
    2332              : 
    2333       823680 :   adr = build_unary_op (loc, ADDR_EXPR, exp, true);
    2334       823680 :   return convert (ptrtype, adr);
    2335              : }
    2336              : 
    2337              : /* Convert the function expression EXP to a pointer.  */
    2338              : static tree
    2339     50607819 : function_to_pointer_conversion (location_t loc, tree exp)
    2340              : {
    2341     50607819 :   tree orig_exp = exp;
    2342              : 
    2343     50607819 :   gcc_assert (TREE_CODE (TREE_TYPE (exp)) == FUNCTION_TYPE);
    2344              : 
    2345     50607819 :   STRIP_TYPE_NOPS (exp);
    2346              : 
    2347     50607819 :   copy_warning (exp, orig_exp);
    2348              : 
    2349     50607819 :   tree exp2 = build_unary_op (loc, ADDR_EXPR, exp, false);
    2350              : 
    2351              :   /* If the function is defined and known to not require a non-local
    2352              :      context, make sure no trampoline is generated.  */
    2353     50607819 :   if (TREE_CODE (exp) == FUNCTION_DECL
    2354     50607819 :       && DECL_INITIAL (exp) && !C_FUNC_NONLOCAL_CONTEXT (exp))
    2355     16067508 :    TREE_NO_TRAMPOLINE (exp2) = 1;
    2356              : 
    2357     50607819 :   return exp2;
    2358              : }
    2359              : 
    2360              : /* Mark EXP as read, not just set, for set but not used -Wunused
    2361              :    warning purposes.  */
    2362              : 
    2363              : void
    2364    490160684 : mark_exp_read (tree exp)
    2365              : {
    2366    616550148 :   switch (TREE_CODE (exp))
    2367              :     {
    2368    203596356 :     case VAR_DECL:
    2369    203596356 :     case PARM_DECL:
    2370    203596356 :       DECL_READ_P (exp) = 1;
    2371    203596356 :       break;
    2372     19719604 :     CASE_CONVERT:
    2373     19719604 :       if (VOID_TYPE_P (TREE_TYPE (exp)))
    2374         3805 :         switch (TREE_CODE (TREE_OPERAND (exp, 0)))
    2375              :           {
    2376              :           case PREINCREMENT_EXPR:
    2377              :           case PREDECREMENT_EXPR:
    2378              :           case POSTINCREMENT_EXPR:
    2379              :           case POSTDECREMENT_EXPR:
    2380              :             return;
    2381              :           default:
    2382              :             break;
    2383              :           }
    2384              :       /* FALLTHRU */
    2385    123644549 :     case ARRAY_REF:
    2386    123644549 :     case COMPONENT_REF:
    2387    123644549 :     case MODIFY_EXPR:
    2388    123644549 :     case REALPART_EXPR:
    2389    123644549 :     case IMAGPART_EXPR:
    2390    123644549 :     case ADDR_EXPR:
    2391    123644549 :     case VIEW_CONVERT_EXPR:
    2392    123644549 :     case PREINCREMENT_EXPR:
    2393    123644549 :     case PREDECREMENT_EXPR:
    2394    123644549 :     case POSTINCREMENT_EXPR:
    2395    123644549 :     case POSTDECREMENT_EXPR:
    2396    123644549 :       mark_exp_read (TREE_OPERAND (exp, 0));
    2397    123644549 :       break;
    2398       235964 :     case COMPOUND_EXPR:
    2399              :       /* Pattern match what build_atomic_assign produces with modifycode
    2400              :          NOP_EXPR.  */
    2401       235964 :       if (VAR_P (TREE_OPERAND (exp, 1))
    2402        27227 :           && DECL_ARTIFICIAL (TREE_OPERAND (exp, 1))
    2403       263107 :           && TREE_CODE (TREE_OPERAND (exp, 0)) == COMPOUND_EXPR)
    2404              :         {
    2405         2210 :           tree t1 = TREE_OPERAND (TREE_OPERAND (exp, 0), 0);
    2406         2210 :           tree t2 = TREE_OPERAND (TREE_OPERAND (exp, 0), 1);
    2407         2210 :           if (TREE_CODE (t1) == TARGET_EXPR
    2408         2202 :               && TARGET_EXPR_SLOT (t1) == TREE_OPERAND (exp, 1)
    2409         4410 :               && TREE_CODE (t2) == CALL_EXPR)
    2410              :             {
    2411         2200 :               tree fndecl = get_callee_fndecl (t2);
    2412         2200 :               tree arg = NULL_TREE;
    2413         2200 :               if (fndecl
    2414         2200 :                   && TREE_CODE (fndecl) == FUNCTION_DECL
    2415         2200 :                   && fndecl_built_in_p (fndecl, BUILT_IN_NORMAL)
    2416         4400 :                   && call_expr_nargs (t2) >= 2)
    2417         2200 :                 switch (DECL_FUNCTION_CODE (fndecl))
    2418              :                   {
    2419          130 :                   case BUILT_IN_ATOMIC_STORE:
    2420          130 :                     arg = CALL_EXPR_ARG (t2, 1);
    2421          130 :                     break;
    2422         2070 :                   case BUILT_IN_ATOMIC_STORE_1:
    2423         2070 :                   case BUILT_IN_ATOMIC_STORE_2:
    2424         2070 :                   case BUILT_IN_ATOMIC_STORE_4:
    2425         2070 :                   case BUILT_IN_ATOMIC_STORE_8:
    2426         2070 :                   case BUILT_IN_ATOMIC_STORE_16:
    2427         2070 :                     arg = CALL_EXPR_ARG (t2, 0);
    2428         2070 :                     break;
    2429              :                   default:
    2430              :                     break;
    2431              :                   }
    2432         2200 :               if (arg)
    2433              :                 {
    2434         2200 :                   STRIP_NOPS (arg);
    2435         2200 :                   if (TREE_CODE (arg) == ADDR_EXPR
    2436         2200 :                       && DECL_P (TREE_OPERAND (arg, 0))
    2437         4400 :                       && TYPE_ATOMIC (TREE_TYPE (TREE_OPERAND (arg, 0))))
    2438         2200 :                     mark_exp_read (TREE_OPERAND (arg, 0));
    2439              :                 }
    2440              :             }
    2441              :         }
    2442              :       /* FALLTHRU */
    2443      2744372 :     case C_MAYBE_CONST_EXPR:
    2444      2744372 :       mark_exp_read (TREE_OPERAND (exp, 1));
    2445      2744372 :       break;
    2446          578 :     case OMP_ARRAY_SECTION:
    2447          578 :       mark_exp_read (TREE_OPERAND (exp, 0));
    2448          578 :       if (TREE_OPERAND (exp, 1))
    2449          384 :         mark_exp_read (TREE_OPERAND (exp, 1));
    2450          578 :       if (TREE_OPERAND (exp, 2))
    2451          543 :         mark_exp_read (TREE_OPERAND (exp, 2));
    2452              :       break;
    2453              :     default:
    2454              :       break;
    2455              :     }
    2456              : }
    2457              : 
    2458              : /* Perform the default conversion of arrays and functions to pointers.
    2459              :    Return the result of converting EXP.  For any other expression, just
    2460              :    return EXP.
    2461              : 
    2462              :    LOC is the location of the expression.  */
    2463              : 
    2464              : struct c_expr
    2465    362207354 : default_function_array_conversion (location_t loc, struct c_expr exp)
    2466              : {
    2467    362207354 :   tree orig_exp = exp.value;
    2468    362207354 :   tree type = TREE_TYPE (exp.value);
    2469    362207354 :   enum tree_code code = TREE_CODE (type);
    2470              : 
    2471    362207354 :   switch (code)
    2472              :     {
    2473              :     case ARRAY_TYPE:
    2474              :       {
    2475              :         bool not_lvalue = false;
    2476              :         bool lvalue_array_p;
    2477              : 
    2478       779681 :         while ((TREE_CODE (exp.value) == NON_LVALUE_EXPR
    2479       779681 :                 || CONVERT_EXPR_P (exp.value))
    2480       779681 :                && TREE_TYPE (TREE_OPERAND (exp.value, 0)) == type)
    2481              :           {
    2482            0 :             if (TREE_CODE (exp.value) == NON_LVALUE_EXPR)
    2483            0 :               not_lvalue = true;
    2484            0 :             exp.value = TREE_OPERAND (exp.value, 0);
    2485              :           }
    2486              : 
    2487       779681 :         copy_warning (exp.value, orig_exp);
    2488              : 
    2489       779681 :         lvalue_array_p = !not_lvalue && lvalue_p (exp.value);
    2490       779681 :         if (!flag_isoc99 && !lvalue_array_p)
    2491              :           {
    2492              :             /* Before C99, non-lvalue arrays do not decay to pointers.
    2493              :                Normally, using such an array would be invalid; but it can
    2494              :                be used correctly inside sizeof or as a statement expression.
    2495              :                Thus, do not give an error here; an error will result later.  */
    2496          109 :             return exp;
    2497              :           }
    2498              : 
    2499       779572 :         exp.value = array_to_pointer_conversion (loc, exp.value);
    2500              :       }
    2501       779572 :       break;
    2502       762295 :     case FUNCTION_TYPE:
    2503       762295 :       exp.value = function_to_pointer_conversion (loc, exp.value);
    2504       762295 :       break;
    2505              :     default:
    2506              :       break;
    2507              :     }
    2508              : 
    2509    362207245 :   return exp;
    2510              : }
    2511              : 
    2512              : struct c_expr
    2513       948222 : default_function_array_read_conversion (location_t loc, struct c_expr exp)
    2514              : {
    2515       948222 :   mark_exp_read (exp.value);
    2516              :   /* We only generate a call to .ACCESS_WITH_SIZE when it is a read.  */
    2517       948222 :   if (TREE_CODE (exp.value) == COMPONENT_REF
    2518       948222 :       && handle_counted_by_p (exp.value))
    2519        66872 :     exp.value = handle_counted_by_for_component_ref (loc, exp.value);
    2520       948222 :   return default_function_array_conversion (loc, exp);
    2521              : }
    2522              : 
    2523              : /* Return whether EXPR should be treated as an atomic lvalue for the
    2524              :    purposes of load and store handling.  */
    2525              : 
    2526              : static bool
    2527    363301588 : really_atomic_lvalue (tree expr)
    2528              : {
    2529    363301588 :   if (error_operand_p (expr))
    2530              :     return false;
    2531    363294070 :   if (!TYPE_ATOMIC (TREE_TYPE (expr)))
    2532              :     return false;
    2533        57393 :   if (!COMPLETE_TYPE_P (TREE_TYPE (expr)))
    2534              :     return false;
    2535        57390 :   if (!lvalue_p (expr))
    2536              :     return false;
    2537              : 
    2538              :   /* Ignore _Atomic on register variables, since their addresses can't
    2539              :      be taken so (a) atomicity is irrelevant and (b) the normal atomic
    2540              :      sequences wouldn't work.  Ignore _Atomic on structures containing
    2541              :      bit-fields, since accessing elements of atomic structures or
    2542              :      unions is undefined behavior (C11 6.5.2.3#5), but it's unclear if
    2543              :      it's undefined at translation time or execution time, and the
    2544              :      normal atomic sequences again wouldn't work.  */
    2545        57532 :   while (handled_component_p (expr))
    2546              :     {
    2547          144 :       if (TREE_CODE (expr) == COMPONENT_REF
    2548          144 :           && DECL_C_BIT_FIELD (TREE_OPERAND (expr, 1)))
    2549              :         return false;
    2550          144 :       expr = TREE_OPERAND (expr, 0);
    2551              :     }
    2552        57388 :   if (TREE_CODE (expr) == COMPOUND_LITERAL_EXPR)
    2553            1 :     expr = COMPOUND_LITERAL_EXPR_DECL (expr);
    2554       112572 :   if (DECL_P (expr) && C_DECL_REGISTER (expr))
    2555              :     return false;
    2556              :   return true;
    2557              : }
    2558              : 
    2559              : /* If EXPR is a named constant (C23) derived from a constexpr variable
    2560              :    - that is, a reference to such a variable, or a member extracted by
    2561              :    a sequence of structure and union (but not array) member accesses
    2562              :    (where union member accesses must access the same member as
    2563              :    initialized) - then return the corresponding initializer;
    2564              :    otherwise, return NULL_TREE.  */
    2565              : 
    2566              : static tree
    2567    360112091 : maybe_get_constexpr_init (tree expr)
    2568              : {
    2569    360112091 :   tree decl = NULL_TREE;
    2570    360112091 :   if (TREE_CODE (expr) == VAR_DECL)
    2571              :     decl = expr;
    2572    348394023 :   else if (TREE_CODE (expr) == COMPOUND_LITERAL_EXPR)
    2573       822117 :     decl = COMPOUND_LITERAL_EXPR_DECL (expr);
    2574       822117 :   if (decl
    2575     12540185 :       && C_DECL_DECLARED_CONSTEXPR (decl)
    2576          370 :       && DECL_INITIAL (decl) != NULL_TREE
    2577       822487 :       && !error_operand_p (DECL_INITIAL (decl)))
    2578          370 :     return DECL_INITIAL (decl);
    2579    360111721 :   if (TREE_CODE (expr) != COMPONENT_REF)
    2580              :     return NULL_TREE;
    2581       875331 :   tree inner = maybe_get_constexpr_init (TREE_OPERAND (expr, 0));
    2582       875331 :   if (inner == NULL_TREE)
    2583              :     return NULL_TREE;
    2584          126 :   while ((CONVERT_EXPR_P (inner) || TREE_CODE (inner) == NON_LVALUE_EXPR)
    2585           47 :          && !error_operand_p (inner)
    2586          220 :          && (TYPE_MAIN_VARIANT (TREE_TYPE (inner))
    2587           47 :              == TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (inner, 0)))))
    2588           47 :     inner = TREE_OPERAND (inner, 0);
    2589          126 :   if (TREE_CODE (inner) != CONSTRUCTOR)
    2590              :     return NULL_TREE;
    2591          126 :   tree field = TREE_OPERAND (expr, 1);
    2592          126 :   unsigned HOST_WIDE_INT cidx;
    2593          126 :   tree cfield, cvalue;
    2594          126 :   bool have_other_init = false;
    2595          266 :   FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (inner), cidx, cfield, cvalue)
    2596              :     {
    2597          250 :       if (cfield == field)
    2598              :         return cvalue;
    2599          140 :       have_other_init = true;
    2600              :     }
    2601           16 :   if (TREE_CODE (TREE_TYPE (inner)) == UNION_TYPE
    2602           16 :       && (have_other_init || field != TYPE_FIELDS (TREE_TYPE (inner))))
    2603              :     return NULL_TREE;
    2604              :   /* Return a default initializer.  */
    2605           13 :   if (RECORD_OR_UNION_TYPE_P (TREE_TYPE (expr)))
    2606            5 :     return build_constructor (TREE_TYPE (expr), NULL);
    2607            8 :   return build_zero_cst (TREE_TYPE (expr));
    2608              : }
    2609              : 
    2610              : /* Helper function for convert_lvalue_to_rvalue called via
    2611              :    walk_tree_without_duplicates.  Find DATA inside of the expression.  */
    2612              : 
    2613              : static tree
    2614       230295 : c_find_var_r (tree *tp, int *walk_subtrees, void *data)
    2615              : {
    2616       230295 :   if (TYPE_P (*tp))
    2617            0 :     *walk_subtrees = 0;
    2618       230295 :   else if (*tp == (tree) data)
    2619              :     return *tp;
    2620              :   return NULL_TREE;
    2621              : }
    2622              : 
    2623              : /* Convert expression EXP (location LOC) from lvalue to rvalue,
    2624              :    including converting functions and arrays to pointers if CONVERT_P.
    2625              :    If READ_P, also mark the expression as having been read.  If
    2626              :    FOR_INIT, constexpr expressions of structure and union type should
    2627              :    be replaced by the corresponding CONSTRUCTOR; otherwise, only
    2628              :    constexpr scalars (including elements of structures and unions) are
    2629              :    replaced by their initializers.  */
    2630              : 
    2631              : struct c_expr
    2632    359424519 : convert_lvalue_to_rvalue (location_t loc, struct c_expr exp,
    2633              :                           bool convert_p, bool read_p, bool for_init)
    2634              : {
    2635    359424519 :   bool force_non_npc = false;
    2636    359424519 :   if (read_p)
    2637    315378103 :     mark_exp_read (exp.value);
    2638              :   /* We only generate a call to .ACCESS_WITH_SIZE when it is a read.  */
    2639    315378103 :   if (read_p && TREE_CODE (exp.value) == COMPONENT_REF
    2640       783755 :       && handle_counted_by_p (exp.value))
    2641       783726 :     exp.value = handle_counted_by_for_component_ref (loc, exp.value);
    2642              : 
    2643    359424519 :   if (convert_p)
    2644    359411267 :     exp = default_function_array_conversion (loc, exp);
    2645    359424519 :   if (!VOID_TYPE_P (TREE_TYPE (exp.value))
    2646    359424519 :       || (flag_isoc2y
    2647         1574 :           && TYPE_QUALS (TREE_TYPE (exp.value)) != TYPE_UNQUALIFIED))
    2648    356940771 :     exp.value = require_complete_type (loc, exp.value);
    2649    359424519 :   if (for_init || !RECORD_OR_UNION_TYPE_P (TREE_TYPE (exp.value)))
    2650              :     {
    2651    359236760 :       tree init = maybe_get_constexpr_init (exp.value);
    2652    359236760 :       if (init != NULL_TREE)
    2653              :         {
    2654              :           /* A named constant of pointer type or type nullptr_t is not
    2655              :              a null pointer constant even if the initializer is
    2656              :              one.  */
    2657          367 :           if (TREE_CODE (init) == INTEGER_CST
    2658          232 :               && !INTEGRAL_TYPE_P (TREE_TYPE (init))
    2659          393 :               && integer_zerop (init))
    2660              :             force_non_npc = true;
    2661              :           exp.value = init;
    2662              :         }
    2663              :     }
    2664    359424519 :   if (really_atomic_lvalue (exp.value))
    2665              :     {
    2666        26938 :       vec<tree, va_gc> *params;
    2667        26938 :       tree nonatomic_type, tmp, tmp_addr, fndecl, func_call;
    2668        26938 :       tree expr_type = TREE_TYPE (exp.value);
    2669        26938 :       tree expr_addr = build_unary_op (loc, ADDR_EXPR, exp.value, false);
    2670        26938 :       tree seq_cst = build_int_cst (integer_type_node, MEMMODEL_SEQ_CST);
    2671              : 
    2672        26938 :       gcc_assert (TYPE_ATOMIC (expr_type));
    2673              : 
    2674              :       /* Expansion of a generic atomic load may require an addition
    2675              :          element, so allocate enough to prevent a resize.  */
    2676        26938 :       vec_alloc (params, 4);
    2677              : 
    2678              :       /* Remove the qualifiers for the rest of the expressions and
    2679              :          create the VAL temp variable to hold the RHS.  */
    2680        26938 :       nonatomic_type = build_qualified_type (expr_type, TYPE_UNQUALIFIED);
    2681        26938 :       tmp = create_tmp_var_raw (nonatomic_type);
    2682        26938 :       tmp_addr = build_unary_op (loc, ADDR_EXPR, tmp, false);
    2683        26938 :       TREE_ADDRESSABLE (tmp) = 1;
    2684              :       /* Do not disable warnings for TMP even though it's artificial.
    2685              :          -Winvalid-memory-model depends on it.  */
    2686              : 
    2687              :       /* Issue __atomic_load (&expr, &tmp, SEQ_CST);  */
    2688        26938 :       fndecl = builtin_decl_explicit (BUILT_IN_ATOMIC_LOAD);
    2689        26938 :       params->quick_push (expr_addr);
    2690        26938 :       params->quick_push (tmp_addr);
    2691        26938 :       params->quick_push (seq_cst);
    2692        26938 :       func_call = c_build_function_call_vec (loc, vNULL, fndecl, params, NULL);
    2693              : 
    2694              :       /* EXPR is always read.  */
    2695        26938 :       mark_exp_read (exp.value);
    2696              : 
    2697              :       /* Optimize the common case where c_build_function_call_vec
    2698              :          immediately folds __atomic_load (&expr, &tmp, SEQ_CST); into
    2699              :          tmp = __atomic_load_<N> (&expr, SEQ_CST);
    2700              :          In that case tmp is not addressable and can be initialized
    2701              :          fully by the rhs of the MODIFY_EXPR.  */
    2702        26938 :       tree tem = func_call;
    2703        26938 :       if (CONVERT_EXPR_P (tem) && VOID_TYPE_P (TREE_TYPE (tem)))
    2704              :         {
    2705        25683 :           tem = TREE_OPERAND (tem, 0);
    2706        25683 :           if (TREE_CODE (tem) == MODIFY_EXPR
    2707        25683 :               && TREE_OPERAND (tem, 0) == tmp
    2708        51366 :               && !walk_tree_without_duplicates (&TREE_OPERAND (tem, 1),
    2709              :                                                 c_find_var_r, tmp))
    2710              :             {
    2711        25683 :               TREE_ADDRESSABLE (tmp) = 0;
    2712        25683 :               func_call = TREE_OPERAND (tem, 1);
    2713              :             }
    2714              :         }
    2715              : 
    2716              :       /* Return tmp which contains the value loaded.  */
    2717        26938 :       exp.value = build4 (TARGET_EXPR, nonatomic_type, tmp, func_call,
    2718              :                           NULL_TREE, NULL_TREE);
    2719              :     }
    2720    359411267 :   if (convert_p && !error_operand_p (exp.value)
    2721    718828312 :       && (TREE_CODE (TREE_TYPE (exp.value)) != ARRAY_TYPE))
    2722    359403684 :     exp.value = convert (build_qualified_type (TREE_TYPE (exp.value), TYPE_UNQUALIFIED), exp.value);
    2723    359424519 :   if (force_non_npc)
    2724           24 :     exp.value = build1 (NOP_EXPR, TREE_TYPE (exp.value), exp.value);
    2725              : 
    2726    359424519 :   {
    2727    359424519 :     tree false_value, true_value;
    2728    359411267 :     if (convert_p && !error_operand_p (exp.value)
    2729    718828312 :         && c_hardbool_type_attr (TREE_TYPE (exp.value),
    2730              :                                  &false_value, &true_value))
    2731              :       {
    2732         9721 :         tree t = save_expr (exp.value);
    2733              : 
    2734         9721 :         mark_exp_read (exp.value);
    2735              : 
    2736         9721 :         tree trapfn = builtin_decl_explicit (BUILT_IN_TRAP);
    2737         9721 :         tree expr = build_call_expr_loc (loc, trapfn, 0);
    2738         9721 :         expr = build_compound_expr (loc, expr, boolean_true_node);
    2739         9721 :         expr = fold_build3_loc (loc, COND_EXPR, boolean_type_node,
    2740              :                                 fold_build2_loc (loc, NE_EXPR,
    2741              :                                                  boolean_type_node,
    2742              :                                                  t, true_value),
    2743              :                                 expr, boolean_true_node);
    2744         9721 :         expr = fold_build3_loc (loc, COND_EXPR, boolean_type_node,
    2745              :                                 fold_build2_loc (loc, NE_EXPR,
    2746              :                                                  boolean_type_node,
    2747              :                                                  t, false_value),
    2748              :                                 expr, boolean_false_node);
    2749              : 
    2750         9721 :         exp.value = expr;
    2751              :       }
    2752              :   }
    2753              : 
    2754    359424519 :   return exp;
    2755              : }
    2756              : 
    2757              : /* Wrapper for the overload above, same arguments but for tree rather than
    2758              :    c_expr.  This is important for hardbools to decay to bools.  */
    2759              : 
    2760              : static inline tree
    2761       575790 : convert_lvalue_to_rvalue (location_t loc, tree val,
    2762              :                           bool convert_p, bool read_p, bool for_init = false)
    2763              : {
    2764       575790 :   struct c_expr expr;
    2765       575790 :   memset (&expr, 0, sizeof (expr));
    2766       575790 :   expr.value = val;
    2767       575790 :   expr = convert_lvalue_to_rvalue (loc, expr, convert_p, read_p, for_init);
    2768       575790 :   return expr.value;
    2769              : }
    2770              : 
    2771              : /* EXP is an expression of integer type.  Apply the integer promotions
    2772              :    to it and return the promoted value.  */
    2773              : 
    2774              : tree
    2775     76981184 : perform_integral_promotions (tree exp)
    2776              : {
    2777     76981184 :   tree type = TREE_TYPE (exp);
    2778     76981184 :   enum tree_code code = TREE_CODE (type);
    2779              : 
    2780     76981184 :   gcc_assert (INTEGRAL_TYPE_P (type));
    2781              : 
    2782              :   /* Convert enums to the result of applying the integer promotions to
    2783              :      their underlying type.  */
    2784     76981184 :   if (code == ENUMERAL_TYPE)
    2785              :     {
    2786       650510 :       type = ENUM_UNDERLYING_TYPE (type);
    2787       650510 :       if (c_promoting_integer_type_p (type))
    2788              :         {
    2789           94 :           if (TYPE_UNSIGNED (type)
    2790           94 :               && TYPE_PRECISION (type) == TYPE_PRECISION (integer_type_node))
    2791            0 :             type = unsigned_type_node;
    2792              :           else
    2793           94 :             type = integer_type_node;
    2794              :         }
    2795              : 
    2796       650510 :       return convert (type, exp);
    2797              :     }
    2798              : 
    2799              :   /* ??? This should no longer be needed now bit-fields have their
    2800              :      proper types.  */
    2801     76330674 :   if (TREE_CODE (exp) == COMPONENT_REF
    2802     76330674 :       && DECL_C_BIT_FIELD (TREE_OPERAND (exp, 1)))
    2803              :     {
    2804        62213 :       if (BITINT_TYPE_P (DECL_BIT_FIELD_TYPE (TREE_OPERAND (exp, 1))))
    2805              :         {
    2806          484 :           tree btype = DECL_BIT_FIELD_TYPE (TREE_OPERAND (exp, 1));
    2807          484 :           if (TREE_CODE (btype) == BITINT_TYPE)
    2808          454 :             return convert (btype, exp);
    2809              :           else
    2810           30 :             return convert (ENUM_UNDERLYING_TYPE (btype), exp);
    2811              :         }
    2812              :       /* If it's thinner than an int, promote it like a
    2813              :          c_promoting_integer_type_p, otherwise leave it alone.  */
    2814        61729 :       if (compare_tree_int (DECL_SIZE (TREE_OPERAND (exp, 1)),
    2815        61729 :                             TYPE_PRECISION (integer_type_node)) < 0)
    2816        53467 :         return convert (integer_type_node, exp);
    2817              :     }
    2818              : 
    2819     76276723 :   if (c_promoting_integer_type_p (type))
    2820              :     {
    2821              :       /* Preserve unsignedness if not really getting any wider.  */
    2822       644992 :       if (TYPE_UNSIGNED (type)
    2823       644992 :           && TYPE_PRECISION (type) == TYPE_PRECISION (integer_type_node))
    2824            0 :         return convert (unsigned_type_node, exp);
    2825              : 
    2826       644992 :       return convert (integer_type_node, exp);
    2827              :     }
    2828              : 
    2829              :   return exp;
    2830              : }
    2831              : 
    2832              : 
    2833              : /* Perform default promotions for C data used in expressions.
    2834              :    Enumeral types or short or char are converted to int.
    2835              :    In addition, manifest constants symbols are replaced by their values.  */
    2836              : 
    2837              : tree
    2838     86516840 : default_conversion (tree exp)
    2839              : {
    2840     86516840 :   tree orig_exp;
    2841     86516840 :   tree type = TREE_TYPE (exp);
    2842     86516840 :   enum tree_code code = TREE_CODE (type);
    2843     86516840 :   tree promoted_type;
    2844              : 
    2845     86516840 :   mark_exp_read (exp);
    2846              :   /* We only generate a call to .ACCESS_WITH_SIZE when it is a read.  */
    2847     86516840 :   if (TREE_CODE (exp) == COMPONENT_REF
    2848     86516840 :       && handle_counted_by_p (exp))
    2849       600836 :     exp = handle_counted_by_for_component_ref (EXPR_LOCATION (exp), exp);
    2850              : 
    2851              :   /* Functions and arrays have been converted during parsing.  */
    2852     86516840 :   gcc_assert (code != FUNCTION_TYPE);
    2853     86516840 :   if (code == ARRAY_TYPE)
    2854              :     return exp;
    2855              : 
    2856              :   /* Constants can be used directly unless they're not loadable.  */
    2857     86516681 :   if (TREE_CODE (exp) == CONST_DECL)
    2858            0 :     exp = DECL_INITIAL (exp);
    2859              : 
    2860              :   /* Strip no-op conversions.  */
    2861     86516681 :   orig_exp = exp;
    2862     86888428 :   STRIP_TYPE_NOPS (exp);
    2863              : 
    2864     86516681 :   copy_warning (exp, orig_exp);
    2865              : 
    2866     86516681 :   if (code == VOID_TYPE)
    2867              :     {
    2868            2 :       error_at (EXPR_LOC_OR_LOC (exp, input_location),
    2869              :                 "void value not ignored as it ought to be");
    2870            2 :       return error_mark_node;
    2871              :     }
    2872              : 
    2873     86516679 :   exp = require_complete_type (EXPR_LOC_OR_LOC (exp, input_location), exp);
    2874     86516679 :   if (exp == error_mark_node)
    2875              :     return error_mark_node;
    2876              : 
    2877     86515775 :   promoted_type = targetm.promoted_type (type);
    2878     86515775 :   if (promoted_type)
    2879            0 :     return convert (promoted_type, exp);
    2880              : 
    2881     86515775 :   if (INTEGRAL_TYPE_P (type))
    2882     75983835 :     return perform_integral_promotions (exp);
    2883              : 
    2884              :   return exp;
    2885              : }
    2886              : 
    2887              : /* Look up COMPONENT in a structure or union TYPE.
    2888              : 
    2889              :    If the component name is not found, returns NULL_TREE.  Otherwise,
    2890              :    the return value is a TREE_LIST, with each TREE_VALUE a FIELD_DECL
    2891              :    stepping down the chain to the component, which is in the last
    2892              :    TREE_VALUE of the list.  Normally the list is of length one, but if
    2893              :    the component is embedded within (nested) anonymous structures or
    2894              :    unions, the list steps down the chain to the component.  */
    2895              : 
    2896              : tree
    2897      2321068 : lookup_field (const_tree type, tree component)
    2898              : {
    2899      2321068 :   tree field;
    2900              : 
    2901              :   /* If TYPE_LANG_SPECIFIC is set, then it is a sorted array of pointers
    2902              :      to the field elements.  Use a binary search on this array to quickly
    2903              :      find the element.  Otherwise, do a linear search.  TYPE_LANG_SPECIFIC
    2904              :      will always be set for structures which have many elements.
    2905              : 
    2906              :      Duplicate field checking replaces duplicates with NULL_TREE so
    2907              :      TYPE_LANG_SPECIFIC arrays are potentially no longer sorted.  In that
    2908              :      case just iterate using DECL_CHAIN.  */
    2909              : 
    2910      2621888 :   if (TYPE_LANG_SPECIFIC (type) && TYPE_LANG_SPECIFIC (type)->s
    2911      2621888 :       && !seen_error ())
    2912              :     {
    2913       300799 :       int bot, top, half;
    2914       300799 :       tree *field_array = &TYPE_LANG_SPECIFIC (type)->s->elts[0];
    2915              : 
    2916       300799 :       field = TYPE_FIELDS (type);
    2917       300799 :       bot = 0;
    2918       300799 :       top = TYPE_LANG_SPECIFIC (type)->s->len;
    2919      1383038 :       while (top - bot > 1)
    2920              :         {
    2921      1353627 :           half = (top - bot + 1) >> 1;
    2922      1353627 :           field = field_array[bot+half];
    2923              : 
    2924      1353627 :           if (DECL_NAME (field) == NULL_TREE)
    2925              :             {
    2926              :               /* Step through all anon unions in linear fashion.  */
    2927            0 :               while (DECL_NAME (field_array[bot]) == NULL_TREE)
    2928              :                 {
    2929            0 :                   field = field_array[bot++];
    2930            0 :                   if (RECORD_OR_UNION_TYPE_P (TREE_TYPE (field)))
    2931              :                     {
    2932            0 :                       tree anon = lookup_field (TREE_TYPE (field), component);
    2933              : 
    2934            0 :                       if (anon)
    2935            0 :                         return tree_cons (NULL_TREE, field, anon);
    2936              : 
    2937              :                       /* The Plan 9 compiler permits referring
    2938              :                          directly to an anonymous struct/union field
    2939              :                          using a typedef name.  */
    2940            0 :                       if (flag_plan9_extensions
    2941            0 :                           && TYPE_NAME (TREE_TYPE (field)) != NULL_TREE
    2942            0 :                           && (TREE_CODE (TYPE_NAME (TREE_TYPE (field)))
    2943              :                               == TYPE_DECL)
    2944            0 :                           && (DECL_NAME (TYPE_NAME (TREE_TYPE (field)))
    2945              :                               == component))
    2946              :                         break;
    2947              :                     }
    2948              :                 }
    2949              : 
    2950              :               /* Entire record is only anon unions.  */
    2951            0 :               if (bot > top)
    2952              :                 return NULL_TREE;
    2953              : 
    2954              :               /* Restart the binary search, with new lower bound.  */
    2955            0 :               continue;
    2956            0 :             }
    2957              : 
    2958      1353627 :           if (DECL_NAME (field) == component)
    2959              :             break;
    2960      1082239 :           if (DECL_NAME (field) < component)
    2961              :             bot += half;
    2962              :           else
    2963       897859 :             top = bot + half;
    2964              :         }
    2965              : 
    2966       300799 :       if (DECL_NAME (field_array[bot]) == component)
    2967              :         field = field_array[bot];
    2968       271388 :       else if (DECL_NAME (field) != component)
    2969              :         return NULL_TREE;
    2970              :     }
    2971              :   else
    2972              :     {
    2973      5258913 :       for (field = TYPE_FIELDS (type); field; field = DECL_CHAIN (field))
    2974              :         {
    2975      5249620 :           if (DECL_NAME (field) == NULL_TREE
    2976      5249620 :               && RECORD_OR_UNION_TYPE_P (TREE_TYPE (field)))
    2977              :             {
    2978        12197 :               tree anon = lookup_field (TREE_TYPE (field), component);
    2979              : 
    2980        12197 :               if (anon)
    2981         2999 :                 return tree_cons (NULL_TREE, field, anon);
    2982              : 
    2983              :               /* The Plan 9 compiler permits referring directly to an
    2984              :                  anonymous struct/union field using a typedef
    2985              :                  name.  */
    2986         9198 :               if (flag_plan9_extensions
    2987          174 :                   && TYPE_NAME (TREE_TYPE (field)) != NULL_TREE
    2988          172 :                   && TREE_CODE (TYPE_NAME (TREE_TYPE (field))) == TYPE_DECL
    2989         9260 :                   && (DECL_NAME (TYPE_NAME (TREE_TYPE (field)))
    2990              :                       == component))
    2991              :                 break;
    2992              :             }
    2993              : 
    2994      5246617 :           if (DECL_NAME (field) == component)
    2995              :             break;
    2996              :         }
    2997              : 
    2998      2017270 :       if (field == NULL_TREE)
    2999              :         return NULL_TREE;
    3000              :     }
    3001              : 
    3002      2308776 :   return tree_cons (NULL_TREE, field, NULL_TREE);
    3003              : }
    3004              : 
    3005              : /* Recursively append candidate IDENTIFIER_NODEs to CANDIDATES.  */
    3006              : 
    3007              : static void
    3008          101 : lookup_field_fuzzy_find_candidates (tree type, tree component,
    3009              :                                     vec<tree> *candidates)
    3010              : {
    3011          101 :   tree field;
    3012          258 :   for (field = TYPE_FIELDS (type); field; field = DECL_CHAIN (field))
    3013              :     {
    3014          157 :       if (DECL_NAME (field) == NULL_TREE
    3015          157 :           && RECORD_OR_UNION_TYPE_P (TREE_TYPE (field)))
    3016           30 :         lookup_field_fuzzy_find_candidates (TREE_TYPE (field), component,
    3017              :                                             candidates);
    3018              : 
    3019          157 :       if (DECL_NAME (field))
    3020          111 :         candidates->safe_push (DECL_NAME (field));
    3021              :     }
    3022          101 : }
    3023              : 
    3024              : /* Like "lookup_field", but find the closest matching IDENTIFIER_NODE,
    3025              :    rather than returning a TREE_LIST for an exact match.  */
    3026              : 
    3027              : static tree
    3028           71 : lookup_field_fuzzy (tree type, tree component)
    3029              : {
    3030           71 :   gcc_assert (TREE_CODE (component) == IDENTIFIER_NODE);
    3031              : 
    3032              :   /* First, gather a list of candidates.  */
    3033           71 :   auto_vec <tree> candidates;
    3034              : 
    3035           71 :   lookup_field_fuzzy_find_candidates (type, component,
    3036              :                                       &candidates);
    3037              : 
    3038           71 :   return find_closest_identifier (component, &candidates);
    3039           71 : }
    3040              : 
    3041              : /* Support function for build_component_ref's error-handling.
    3042              : 
    3043              :    Given DATUM_TYPE, and "DATUM.COMPONENT", where DATUM is *not* a
    3044              :    struct or union, should we suggest "DATUM->COMPONENT" as a hint?  */
    3045              : 
    3046              : static bool
    3047           72 : should_suggest_deref_p (tree datum_type)
    3048              : {
    3049              :   /* We don't do it for Objective-C, since Objective-C 2.0 dot-syntax
    3050              :      allows "." for ptrs; we could be handling a failed attempt
    3051              :      to access a property.  */
    3052           72 :   if (c_dialect_objc ())
    3053              :     return false;
    3054              : 
    3055              :   /* Only suggest it for pointers...  */
    3056           72 :   if (TREE_CODE (datum_type) != POINTER_TYPE)
    3057              :     return false;
    3058              : 
    3059              :   /* ...to structs/unions.  */
    3060            8 :   tree underlying_type = TREE_TYPE (datum_type);
    3061            8 :   enum tree_code code = TREE_CODE (underlying_type);
    3062            8 :   if (code == RECORD_TYPE || code == UNION_TYPE)
    3063              :     return true;
    3064              :   else
    3065            1 :     return false;
    3066              : }
    3067              : 
    3068              : /* Give a component ref REF, decide whether we should handle its counted_by
    3069              :    attribute based on its context:
    3070              :    Do not handle counted_by when in offsetof, typeof and alignof operator.  */
    3071              : 
    3072              : static bool
    3073      2276622 : handle_counted_by_p (tree ref)
    3074              : {
    3075      2276622 :   gcc_assert (TREE_CODE (ref) == COMPONENT_REF);
    3076      2276622 :   tree datum = TREE_OPERAND (ref, 0);
    3077              :   /* If the component_ref is build for a offsetof, i.e., the datum
    3078              :      of the component_ref is a indirect_ref of null_pointer_node,
    3079              :      we should not generate call to .ACCESS_WITH_SIZE.  */
    3080      2276622 :   if (TREE_CODE (datum) == INDIRECT_REF
    3081      2276622 :       && TREE_OPERAND (datum, 0) == null_pointer_node)
    3082              :     return false;
    3083      2276292 :   if (in_typeof || in_alignof)
    3084         8786 :     return false;
    3085              :   return true;
    3086              : }
    3087              : 
    3088              : /* Given a component ref REF, if there is a counted_by attribute attached,
    3089              :    issue error when the element_type is a structure or union including a
    3090              :    flexible array member.  */
    3091              : 
    3092              : static void
    3093      2274996 : check_counted_by_attribute (location_t loc, tree ref)
    3094              : {
    3095      2274996 :   tree subdatum = TREE_OPERAND (ref, 1);
    3096      2274996 :   tree sub_type = TREE_TYPE (subdatum);
    3097              : 
    3098      2274996 :   if (!c_flexible_array_member_type_p (sub_type)
    3099      2274996 :       && TREE_CODE (sub_type) != POINTER_TYPE)
    3100              :     return;
    3101              : 
    3102       387881 :   tree element_type = TREE_TYPE (sub_type);
    3103              : 
    3104       387881 :   tree attr_counted_by = lookup_attribute ("counted_by",
    3105       387881 :                                            DECL_ATTRIBUTES (subdatum));
    3106       387881 :   if (attr_counted_by)
    3107              :     {
    3108              :       /* Issue error when the element_type is a structure or
    3109              :         union including a flexible array member.  */
    3110          873 :       if (RECORD_OR_UNION_TYPE_P (element_type)
    3111          873 :           && TYPE_INCLUDES_FLEXARRAY (element_type))
    3112              :         {
    3113            2 :           error_at (loc,
    3114              :                     "%<counted_by%> attribute is not allowed for a pointer to"
    3115              :                     " structure or union with flexible array member");
    3116            2 :           return;
    3117              :         }
    3118              :     }
    3119              : }
    3120              : 
    3121              : /* For a SUBDATUM field of a structure or union DATUM, generate a REF
    3122              :    to the object that represents its counted_by per the attribute
    3123              :    counted_by attached to this field if it's a flexible array member
    3124              :    or a pointer field, otherwise return NULL_TREE.
    3125              :    Set COUNTED_BY_TYPE to the TYPE of the counted_by field.
    3126              :    For example, if:
    3127              : 
    3128              :     struct P {
    3129              :       int k;
    3130              :       int x[] __attribute__ ((counted_by (k)));
    3131              :     } *p;
    3132              : 
    3133              :     for:
    3134              :     p->x
    3135              : 
    3136              :     the ref to the object that represents its element count will be:
    3137              : 
    3138              :     &(p->k)
    3139              : */
    3140              : 
    3141              : static tree
    3142       501273 : build_counted_by_ref (tree datum, tree subdatum,
    3143              :                       tree *counted_by_type)
    3144              : {
    3145       501273 :   tree sub_type = TREE_TYPE (subdatum);
    3146       501273 :   if (!c_flexible_array_member_type_p (sub_type)
    3147       501273 :       && TREE_CODE (sub_type) != POINTER_TYPE)
    3148              :     return NULL_TREE;
    3149              : 
    3150       501273 :   tree attr_counted_by = lookup_attribute ("counted_by",
    3151       501273 :                                            DECL_ATTRIBUTES (subdatum));
    3152       501273 :   if (!attr_counted_by)
    3153              :     return NULL_TREE;
    3154              : 
    3155          653 :   tree counted_by_ref = NULL_TREE;
    3156          653 :   *counted_by_type = NULL_TREE;
    3157              : 
    3158          653 :   tree type = TREE_TYPE (datum);
    3159              : 
    3160              :   /* If the type of the containing structure is an anonymous struct/union,
    3161              :      and this anonymous struct/union is not a root type, get the first
    3162              :      outer named structure/union type.  */
    3163          653 :   while (TREE_CODE (datum) == COMPONENT_REF
    3164           35 :          && c_type_tag (type) == NULL_TREE
    3165          723 :          && DECL_NAME (TREE_OPERAND (datum, 1)) == NULL_TREE)
    3166              :     {
    3167           35 :       datum = TREE_OPERAND (datum, 0);
    3168           35 :       type = TREE_TYPE (datum);
    3169              :     }
    3170              : 
    3171          653 :   tree field_id = TREE_VALUE (TREE_VALUE (attr_counted_by));
    3172          653 :   tree counted_by_field = lookup_field (type, field_id);
    3173          653 :   gcc_assert (counted_by_field);
    3174              : 
    3175         1065 :   tree counted_by_subdatum;
    3176         1065 :   do
    3177              :     {
    3178         1065 :       counted_by_subdatum = TREE_VALUE (counted_by_field);
    3179              :       /* Get the TYPE of the counted_by field.  */
    3180         1065 :       *counted_by_type = TREE_TYPE (counted_by_subdatum);
    3181              : 
    3182         1065 :       counted_by_ref
    3183         1065 :         = build3 (COMPONENT_REF, TREE_TYPE (counted_by_subdatum),
    3184              :                   datum, counted_by_subdatum, NULL_TREE);
    3185              : 
    3186         1065 :       datum = counted_by_ref;
    3187         1065 :       counted_by_field = TREE_CHAIN (counted_by_field);
    3188              :     }
    3189         1065 :   while (counted_by_field);
    3190              : 
    3191          653 :   counted_by_ref = build_fold_addr_expr (counted_by_ref);
    3192          653 :   return counted_by_ref;
    3193              : }
    3194              : 
    3195              : /* Given a COMPONENT_REF REF with the location LOC, the corresponding
    3196              :    COUNTED_BY_REF, and the COUNTED_BY_TYPE, generate the corresponding
    3197              :    call to the internal function .ACCESS_WITH_SIZE.
    3198              : 
    3199              :    A: For the Flexible Array Member, Generate an INDIRECT_REF to a call to
    3200              :    the internal function .ACCESS_WITH_SIZE.
    3201              : 
    3202              :    REF
    3203              : 
    3204              :    to:
    3205              : 
    3206              :    (*.ACCESS_WITH_SIZE (REF, COUNTED_BY_REF, (* TYPE_OF_SIZE)0,
    3207              :                         TYPE_SIZE_UNIT for element)
    3208              : 
    3209              :    NOTE: The return type of this function is the POINTER type pointing
    3210              :    to the original flexible array type.  Then the type of the INDIRECT_REF
    3211              :    is the original flexible array type.
    3212              :    The type of the first argument of this function is a POINTER type
    3213              :    to the original flexible array type.
    3214              : 
    3215              :    B: For pointers with counted_by, generate a call to the internal function
    3216              :    .ACCESS_WITH_SIZE.
    3217              : 
    3218              :     REF
    3219              : 
    3220              :     to:
    3221              : 
    3222              :     .ACCESS_WITH_SIZE (REF, COUNTED_BY_REF, (* TYPE_OF_SIZE)0,
    3223              :                        TYPE_SIZE_UNIT for element)
    3224              : 
    3225              :    NOTE: The return type of this function is the original pointer type.
    3226              :    The type of the first argument of this function is the original
    3227              :    pointer type.
    3228              : 
    3229              :    The 3rd argument of the call is a constant 0 with the pointer TYPE whose
    3230              :    pointee type is the TYPE of the object pointed by COUNTED_BY_REF.
    3231              : 
    3232              :    The 4th argument of the call is the TYPE_SIZE_UNIT of the element TYPE
    3233              :    of the array.
    3234              : 
    3235              :   */
    3236              : static tree
    3237          653 : build_access_with_size_for_counted_by (location_t loc, tree ref,
    3238              :                                        tree counted_by_ref,
    3239              :                                        tree counted_by_type)
    3240              : {
    3241          653 :   gcc_assert (c_flexible_array_member_type_p (TREE_TYPE (ref))
    3242              :               || TREE_CODE (TREE_TYPE (ref)) == POINTER_TYPE);
    3243              : 
    3244          653 :   bool is_fam = c_flexible_array_member_type_p (TREE_TYPE (ref));
    3245              : 
    3246              :   /* The result type of the call is a pointer to the flexible array type;
    3247              :      or is the original ponter type to the pointer field with counted_by.  */
    3248          653 :   tree result_type = is_fam ? c_build_pointer_type (TREE_TYPE (ref))
    3249          452 :                      : TREE_TYPE (ref);
    3250              : 
    3251          653 :   tree element_type = TREE_TYPE (TREE_TYPE (ref));
    3252          653 :   tree element_size = VOID_TYPE_P (element_type)
    3253          653 :                       ? size_one_node
    3254          653 :                       : TYPE_SIZE_UNIT (element_type);
    3255          653 :   if (element_size == NULL_TREE)
    3256              :     return ref;
    3257              : 
    3258          639 :   tree first_param = is_fam
    3259          639 :                      ? c_fully_fold (array_to_pointer_conversion (loc, ref),
    3260              :                                      false, NULL)
    3261          438 :                      : c_fully_fold (ref, false, NULL);
    3262          639 :   tree second_param
    3263          639 :     = c_fully_fold (counted_by_ref, false, NULL);
    3264          639 :   tree third_param = build_int_cst (c_build_pointer_type (counted_by_type), 0);
    3265              : 
    3266          639 :   tree call
    3267          639 :     = build_call_expr_internal_loc (loc, IFN_ACCESS_WITH_SIZE,
    3268              :                                     result_type, 4,
    3269              :                                     first_param,
    3270              :                                     second_param,
    3271              :                                     third_param,
    3272              :                                     element_size);
    3273              : 
    3274              :   /* Wrap the call with an INDIRECT_REF with the flexible array type.  */
    3275          639 :   if (is_fam)
    3276          201 :     call = build1 (INDIRECT_REF, TREE_TYPE (ref), call);
    3277          639 :   SET_EXPR_LOCATION (call, loc);
    3278          639 :   return call;
    3279              : }
    3280              : 
    3281              : /* For the COMPONENT_REF ref, check whether it has a counted_by attribute,
    3282              :    if so, wrap this COMPONENT_REF with the corresponding CALL to the
    3283              :    function .ACCESS_WITH_SIZE.
    3284              :    Otherwise, return the ref itself.  */
    3285              : 
    3286              : tree
    3287      2267586 : handle_counted_by_for_component_ref (location_t loc, tree ref)
    3288              : {
    3289      2267586 :   gcc_assert (TREE_CODE (ref) == COMPONENT_REF);
    3290      2267586 :   tree datum = TREE_OPERAND (ref, 0);
    3291      2267586 :   tree subdatum = TREE_OPERAND (ref, 1);
    3292      2267586 :   tree counted_by_type = NULL_TREE;
    3293              : 
    3294      2267586 :   if (!(c_flexible_array_member_type_p (TREE_TYPE (ref))
    3295      2197128 :         || TREE_CODE (TREE_TYPE (ref)) == POINTER_TYPE))
    3296              :     return ref;
    3297              : 
    3298       501273 :   tree counted_by_ref = build_counted_by_ref (datum, subdatum,
    3299              :                                               &counted_by_type);
    3300       501273 :   if (counted_by_ref)
    3301          653 :     ref = build_access_with_size_for_counted_by (loc, ref,
    3302              :                                                  counted_by_ref,
    3303              :                                                  counted_by_type);
    3304              :   return ref;
    3305              : }
    3306              : 
    3307              : /* Make an expression to refer to the COMPONENT field of structure or
    3308              :    union value DATUM.  COMPONENT is an IDENTIFIER_NODE.  LOC is the
    3309              :    location of the COMPONENT_REF.  COMPONENT_LOC is the location
    3310              :    of COMPONENT.  ARROW_LOC is the location of the first -> operand if
    3311              :    it is from -> operator.
    3312              :    If HANDLE_COUNTED_BY is true, check the counted_by attribute and generate
    3313              :    a call to .ACCESS_WITH_SIZE.  Otherwise, ignore the attribute.  */
    3314              : 
    3315              : tree
    3316      2272886 : build_component_ref (location_t loc, tree datum, tree component,
    3317              :                      location_t component_loc, location_t arrow_loc)
    3318              : {
    3319      2272886 :   tree type = TREE_TYPE (datum);
    3320      2272886 :   enum tree_code code = TREE_CODE (type);
    3321      2272886 :   tree field = NULL;
    3322      2272886 :   tree ref;
    3323      2272886 :   bool datum_lvalue = lvalue_p (datum);
    3324              : 
    3325      2272886 :   if (!objc_is_public (datum, component))
    3326            0 :     return error_mark_node;
    3327              : 
    3328              :   /* Detect Objective-C property syntax object.property.  */
    3329      2272886 :   if (c_dialect_objc ()
    3330      2272886 :       && (ref = objc_maybe_build_component_ref (datum, component)))
    3331              :     return ref;
    3332              : 
    3333              :   /* See if there is a field or component with name COMPONENT.  */
    3334              : 
    3335      2272886 :   if (code == RECORD_TYPE || code == UNION_TYPE)
    3336              :     {
    3337      2272814 :       if (!COMPLETE_TYPE_P (type))
    3338              :         {
    3339           19 :           c_incomplete_type_error (loc, NULL_TREE, type);
    3340           19 :           return error_mark_node;
    3341              :         }
    3342              : 
    3343      2272795 :       field = lookup_field (type, component);
    3344              : 
    3345      2272795 :       if (!field)
    3346              :         {
    3347           63 :           tree guessed_id = lookup_field_fuzzy (type, component);
    3348           63 :           if (guessed_id)
    3349              :             {
    3350              :               /* Attempt to provide a fixit replacement hint, if
    3351              :                  we have a valid range for the component.  */
    3352            0 :               location_t reported_loc
    3353           26 :                 = (component_loc != UNKNOWN_LOCATION) ? component_loc : loc;
    3354           26 :               gcc_rich_location rich_loc (reported_loc);
    3355           26 :               if (component_loc != UNKNOWN_LOCATION)
    3356           26 :                 rich_loc.add_fixit_misspelled_id (component_loc, guessed_id);
    3357           26 :               error_at (&rich_loc,
    3358              :                         "%qT has no member named %qE; did you mean %qE?",
    3359              :                         type, component, guessed_id);
    3360           26 :             }
    3361              :           else
    3362           37 :             error_at (loc, "%qT has no member named %qE", type, component);
    3363           63 :           return error_mark_node;
    3364              :         }
    3365              : 
    3366              :       /* Accessing elements of atomic structures or unions is undefined
    3367              :          behavior (C11 6.5.2.3#5).  */
    3368      2272732 :       if (TYPE_ATOMIC (type) && c_inhibit_evaluation_warnings == 0)
    3369              :         {
    3370           18 :           if (code == RECORD_TYPE)
    3371           12 :             warning_at (loc, 0, "accessing a member %qE of an atomic "
    3372              :                         "structure %qE", component, datum);
    3373              :           else
    3374            6 :             warning_at (loc, 0, "accessing a member %qE of an atomic "
    3375              :                         "union %qE", component, datum);
    3376              :         }
    3377              : 
    3378              :       /* Chain the COMPONENT_REFs if necessary down to the FIELD.
    3379              :          This might be better solved in future the way the C++ front
    3380              :          end does it - by giving the anonymous entities each a
    3381              :          separate name and type, and then have build_component_ref
    3382              :          recursively call itself.  We can't do that here.  */
    3383      2274996 :       do
    3384              :         {
    3385      2274996 :           tree subdatum = TREE_VALUE (field);
    3386      2274996 :           int quals;
    3387      2274996 :           tree subtype;
    3388      2274996 :           bool use_datum_quals;
    3389              : 
    3390      2274996 :           if (TREE_TYPE (subdatum) == error_mark_node)
    3391              :             return error_mark_node;
    3392              : 
    3393              :           /* If this is an rvalue, it does not have qualifiers in C
    3394              :              standard terms and we must avoid propagating such
    3395              :              qualifiers down to a non-lvalue array that is then
    3396              :              converted to a pointer.  */
    3397      4549992 :           use_datum_quals = (datum_lvalue
    3398      2274996 :                              || TREE_CODE (TREE_TYPE (subdatum)) != ARRAY_TYPE);
    3399              : 
    3400      2274996 :           quals = TYPE_QUALS (strip_array_types (TREE_TYPE (subdatum)));
    3401      2274996 :           if (use_datum_quals)
    3402      2274734 :             quals |= TYPE_QUALS (TREE_TYPE (datum));
    3403      2274996 :           subtype = c_build_qualified_type (TREE_TYPE (subdatum), quals);
    3404              : 
    3405      2274996 :           ref = build3 (COMPONENT_REF, subtype, datum, subdatum,
    3406              :                         NULL_TREE);
    3407      2274996 :           SET_EXPR_LOCATION (ref, loc);
    3408              : 
    3409      2274996 :           check_counted_by_attribute (loc, ref);
    3410              : 
    3411      2274996 :           if (TREE_READONLY (subdatum)
    3412      2274996 :               || (use_datum_quals && TREE_READONLY (datum)))
    3413        30563 :             TREE_READONLY (ref) = 1;
    3414      2274996 :           if (TREE_THIS_VOLATILE (subdatum)
    3415      2274002 :               || (use_datum_quals && TREE_THIS_VOLATILE (datum)))
    3416         2428 :             TREE_THIS_VOLATILE (ref) = 1;
    3417              : 
    3418      2274996 :           if (TREE_UNAVAILABLE (subdatum))
    3419           10 :             error_unavailable_use (subdatum, NULL_TREE);
    3420      2274986 :           else if (TREE_DEPRECATED (subdatum))
    3421           16 :             warn_deprecated_use (subdatum, NULL_TREE);
    3422              : 
    3423      2274996 :           datum = ref;
    3424              : 
    3425      2274996 :           field = TREE_CHAIN (field);
    3426              :         }
    3427      2274996 :       while (field);
    3428              : 
    3429              :       return ref;
    3430              :     }
    3431           72 :   else if (should_suggest_deref_p (type))
    3432              :     {
    3433              :       /* Special-case the error message for "ptr.field" for the case
    3434              :          where the user has confused "." vs "->".  */
    3435            7 :       rich_location richloc (line_table, loc);
    3436            7 :       if (INDIRECT_REF_P (datum) && arrow_loc != UNKNOWN_LOCATION)
    3437              :         {
    3438            2 :           richloc.add_fixit_insert_before (arrow_loc, "(*");
    3439            2 :           richloc.add_fixit_insert_after (arrow_loc, ")");
    3440            2 :           error_at (&richloc,
    3441              :                     "%qE is a pointer to pointer; did you mean to dereference "
    3442              :                     "it before applying %<->%> to it?",
    3443            2 :                     TREE_OPERAND (datum, 0));
    3444              :         }
    3445              :       else
    3446              :         {
    3447              :           /* "loc" should be the "." token.  */
    3448            5 :           richloc.add_fixit_replace ("->");
    3449            5 :           error_at (&richloc,
    3450              :                     "%qE is a pointer; did you mean to use %<->%>?",
    3451              :                     datum);
    3452              :         }
    3453            7 :       return error_mark_node;
    3454            7 :     }
    3455           65 :   else if (code != ERROR_MARK)
    3456            1 :     error_at (loc,
    3457              :               "request for member %qE in something not a structure or union",
    3458              :               component);
    3459              : 
    3460           65 :   return error_mark_node;
    3461              : }
    3462              : 
    3463              : /* Given an expression PTR for a pointer, return an expression
    3464              :    for the value pointed to.
    3465              :    ERRORSTRING is the name of the operator to appear in error messages.
    3466              : 
    3467              :    LOC is the location to use for the generated tree.  */
    3468              : 
    3469              : tree
    3470      2750675 : build_indirect_ref (location_t loc, tree ptr, ref_operator errstring)
    3471              : {
    3472      2750675 :   tree pointer = default_conversion (ptr);
    3473      2750675 :   tree type = TREE_TYPE (pointer);
    3474      2750675 :   tree ref;
    3475              : 
    3476      2750675 :   if (TREE_CODE (type) == POINTER_TYPE)
    3477              :     {
    3478      2750321 :       if (CONVERT_EXPR_P (pointer)
    3479      1969643 :           || TREE_CODE (pointer) == VIEW_CONVERT_EXPR)
    3480              :         {
    3481              :           /* If a warning is issued, mark it to avoid duplicates from
    3482              :              the backend.  This only needs to be done at
    3483              :              warn_strict_aliasing > 2.  */
    3484       780678 :           if (warn_strict_aliasing > 2)
    3485       335117 :             if (strict_aliasing_warning (EXPR_LOCATION (pointer),
    3486       335117 :                                          type, TREE_OPERAND (pointer, 0)))
    3487            7 :               suppress_warning (pointer, OPT_Wstrict_aliasing_);
    3488              :         }
    3489              : 
    3490      2750321 :       if (TREE_CODE (pointer) == ADDR_EXPR
    3491      2750321 :           && (TREE_TYPE (TREE_OPERAND (pointer, 0))
    3492        67439 :               == TREE_TYPE (type)))
    3493              :         {
    3494        67430 :           ref = TREE_OPERAND (pointer, 0);
    3495        67430 :           protected_set_expr_location (ref, loc);
    3496        67430 :           return ref;
    3497              :         }
    3498              :       else
    3499              :         {
    3500      2682891 :           tree t = TREE_TYPE (type);
    3501              : 
    3502      2682891 :           ref = build1 (INDIRECT_REF, t, pointer);
    3503              : 
    3504      2682891 :           if (VOID_TYPE_P (t) && c_inhibit_evaluation_warnings == 0)
    3505          151 :             warning_at (loc, 0, "dereferencing %<void *%> pointer");
    3506              : 
    3507              :           /* We *must* set TREE_READONLY when dereferencing a pointer to const,
    3508              :              so that we get the proper error message if the result is used
    3509              :              to assign to.  Also, &* is supposed to be a no-op.
    3510              :              And ANSI C seems to specify that the type of the result
    3511              :              should be the const type.  */
    3512              :           /* A de-reference of a pointer to const is not a const.  It is valid
    3513              :              to change it via some other pointer.  */
    3514      2682891 :           TREE_READONLY (ref) = TYPE_READONLY (t);
    3515      2682891 :           TREE_SIDE_EFFECTS (ref)
    3516      2682891 :             = TYPE_VOLATILE (t) || TREE_SIDE_EFFECTS (pointer);
    3517      2682891 :           TREE_THIS_VOLATILE (ref) = TYPE_VOLATILE (t);
    3518      2682891 :           protected_set_expr_location (ref, loc);
    3519      2682891 :           return ref;
    3520              :         }
    3521              :     }
    3522          354 :   else if (TREE_CODE (pointer) != ERROR_MARK)
    3523          278 :     invalid_indirection_error (loc, type, errstring);
    3524              : 
    3525          354 :   return error_mark_node;
    3526              : }
    3527              : 
    3528              : /* This handles expressions of the form "a[i]", which denotes
    3529              :    an array reference.
    3530              : 
    3531              :    This is logically equivalent in C to *(a+i), but we may do it differently.
    3532              :    If A is a variable or a member, we generate a primitive ARRAY_REF.
    3533              :    This avoids forcing the array out of registers, and can work on
    3534              :    arrays that are not lvalues (for example, members of structures returned
    3535              :    by functions).
    3536              : 
    3537              :    For vector types, allow vector[i] but not i[vector], and create
    3538              :    *(((type*)&vectortype) + i) for the expression.
    3539              : 
    3540              :    LOC is the location to use for the returned expression.  */
    3541              : 
    3542              : tree
    3543      3471157 : build_array_ref (location_t loc, tree array, tree index)
    3544              : {
    3545      3471157 :   tree ret;
    3546      3471157 :   bool swapped = false;
    3547      3471157 :   if (TREE_TYPE (array) == error_mark_node
    3548      3471157 :       || TREE_TYPE (index) == error_mark_node)
    3549              :     return error_mark_node;
    3550              : 
    3551      3471049 :   if (TREE_CODE (TREE_TYPE (array)) != ARRAY_TYPE
    3552      1995771 :       && TREE_CODE (TREE_TYPE (array)) != POINTER_TYPE
    3553              :       /* Allow vector[index] but not index[vector].  */
    3554      4493753 :       && !gnu_vector_type_p (TREE_TYPE (array)))
    3555              :     {
    3556          194 :       if (TREE_CODE (TREE_TYPE (index)) != ARRAY_TYPE
    3557          194 :           && TREE_CODE (TREE_TYPE (index)) != POINTER_TYPE)
    3558              :         {
    3559            2 :           error_at (loc,
    3560              :             "subscripted value is neither array nor pointer nor vector");
    3561              : 
    3562            2 :           return error_mark_node;
    3563              :         }
    3564          192 :       std::swap (array, index);
    3565          192 :       swapped = true;
    3566              :     }
    3567              : 
    3568      3471047 :   if (!INTEGRAL_TYPE_P (TREE_TYPE (index)))
    3569              :     {
    3570            2 :       error_at (loc, "array subscript is not an integer");
    3571            2 :       return error_mark_node;
    3572              :     }
    3573              : 
    3574      3471045 :   if (TREE_CODE (TREE_TYPE (TREE_TYPE (array))) == FUNCTION_TYPE)
    3575              :     {
    3576           10 :       error_at (loc, "subscripted value is pointer to function");
    3577           10 :       return error_mark_node;
    3578              :     }
    3579              : 
    3580              :   /* ??? Existing practice has been to warn only when the char
    3581              :      index is syntactically the index, not for char[array].  */
    3582      3471035 :   if (!swapped)
    3583      3470849 :      warn_array_subscript_with_type_char (loc, index);
    3584              : 
    3585              :   /* Apply default promotions *after* noticing character types.  */
    3586      3471035 :   index = default_conversion (index);
    3587      3471035 :   if (index == error_mark_node)
    3588              :     return error_mark_node;
    3589              : 
    3590      3471034 :   gcc_assert (TREE_CODE (TREE_TYPE (index)) == INTEGER_TYPE
    3591              :               || TREE_CODE (TREE_TYPE (index)) == BITINT_TYPE);
    3592              : 
    3593      3471034 :   bool was_vector = VECTOR_TYPE_P (TREE_TYPE (array));
    3594      3471034 :   bool non_lvalue = convert_vector_to_array_for_subscript (loc, &array, index);
    3595              : 
    3596              :   /* We only generate a call to .ACCESS_WITH_SIZE when it is a read.  */
    3597      3471034 :   if (TREE_CODE (array) == COMPONENT_REF
    3598      3471034 :       && handle_counted_by_p (array))
    3599       816072 :     array = handle_counted_by_for_component_ref (loc, array);
    3600              : 
    3601      3471034 :   if (TREE_CODE (TREE_TYPE (array)) == ARRAY_TYPE)
    3602              :     {
    3603      2497795 :       tree rval, type;
    3604              : 
    3605              :       /* An array that is indexed by a non-constant
    3606              :          cannot be stored in a register; we must be able to do
    3607              :          address arithmetic on its address.
    3608              :          Likewise an array of elements of variable size.  */
    3609      2497795 :       if (TREE_CODE (index) != INTEGER_CST
    3610      2497795 :           || (COMPLETE_TYPE_P (TREE_TYPE (TREE_TYPE (array)))
    3611      2024122 :               && TREE_CODE (TYPE_SIZE (TREE_TYPE (TREE_TYPE (array)))) != INTEGER_CST))
    3612              :         {
    3613       474413 :           if (!c_mark_addressable (array, true, true))
    3614            1 :             return error_mark_node;
    3615              :         }
    3616              :       /* An array that is indexed by a constant value which is not within
    3617              :          the array bounds cannot be stored in a register either; because we
    3618              :          would get a crash in store_bit_field/extract_bit_field when trying
    3619              :          to access a non-existent part of the register.  */
    3620      2497794 :       if (TREE_CODE (index) == INTEGER_CST
    3621      2024122 :           && TYPE_DOMAIN (TREE_TYPE (array))
    3622      4518557 :           && !int_fits_type_p (index, TYPE_DOMAIN (TREE_TYPE (array))))
    3623              :         {
    3624        60654 :           if (!c_mark_addressable (array, false, true))
    3625            0 :             return error_mark_node;
    3626              :           /* ISO C2Y disallows a negative integer constant expression index
    3627              :              when array subscripting has an operand of array type.  */
    3628        60654 :           if (flag_isoc2y
    3629           26 :               && !TREE_OVERFLOW (index)
    3630        60677 :               && tree_int_cst_sgn (index) < 0)
    3631           10 :             error_at (loc, "array subscript is negative");
    3632              :         }
    3633              : 
    3634      2497794 :       if ((pedantic || warn_c90_c99_compat || warn_c23_c2y_compat)
    3635      2474445 :           && ! was_vector)
    3636              :         {
    3637      1474564 :           tree foo = array;
    3638      2309793 :           while (TREE_CODE (foo) == COMPONENT_REF)
    3639       835229 :             foo = TREE_OPERAND (foo, 0);
    3640       975274 :           if ((VAR_P (foo) && C_DECL_REGISTER (foo))
    3641      2449772 :               || (TREE_CODE (foo) == COMPOUND_LITERAL_EXPR
    3642           72 :                   && C_DECL_REGISTER (COMPOUND_LITERAL_EXPR_DECL (foo))))
    3643           78 :             pedwarn_c23 (loc, OPT_Wpedantic,
    3644              :                          "ISO C forbids subscripting %<register%> array "
    3645              :                          "before C2Y");
    3646      1474486 :           else if (!lvalue_p (foo))
    3647          118 :             pedwarn_c90 (loc, OPT_Wpedantic,
    3648              :                          "ISO C90 forbids subscripting non-lvalue "
    3649              :                          "array");
    3650              :         }
    3651              : 
    3652      2497794 :       if (TREE_CODE (TREE_TYPE (index)) == BITINT_TYPE
    3653      2497794 :           && TYPE_PRECISION (TREE_TYPE (index)) > TYPE_PRECISION (sizetype))
    3654            3 :         index = fold_convert (sizetype, index);
    3655              : 
    3656      2497794 :       type = TREE_TYPE (TREE_TYPE (array));
    3657      2497794 :       rval = build4 (ARRAY_REF, type, array, index, NULL_TREE, NULL_TREE);
    3658              :       /* Array ref is const/volatile if the array elements are
    3659              :          or if the array is.  */
    3660      7493382 :       TREE_READONLY (rval)
    3661      2497794 :         |= (TYPE_READONLY (TREE_TYPE (TREE_TYPE (array)))
    3662      2497794 :             | TREE_READONLY (array));
    3663      7493382 :       TREE_SIDE_EFFECTS (rval)
    3664      2497794 :         |= (TYPE_VOLATILE (TREE_TYPE (TREE_TYPE (array)))
    3665      2497794 :             | TREE_SIDE_EFFECTS (array));
    3666      4995588 :       TREE_THIS_VOLATILE (rval)
    3667      2497794 :         |= (TYPE_VOLATILE (TREE_TYPE (TREE_TYPE (array)))
    3668              :             /* This was added by rms on 16 Nov 91.
    3669              :                It fixes  vol struct foo *a;  a->elts[1]
    3670              :                in an inline function.
    3671              :                Hope it doesn't break something else.  */
    3672      2497794 :             | TREE_THIS_VOLATILE (array));
    3673      2497794 :       ret = require_complete_type (loc, rval);
    3674      2497794 :       protected_set_expr_location (ret, loc);
    3675      2497794 :       if (non_lvalue)
    3676       105143 :         ret = non_lvalue_loc (loc, ret);
    3677      2497794 :       return ret;
    3678              :     }
    3679              :   else
    3680              :     {
    3681       973239 :       tree ar = default_conversion (array);
    3682              : 
    3683       973239 :       if (ar == error_mark_node)
    3684              :         return ar;
    3685              : 
    3686       973239 :       gcc_assert (TREE_CODE (TREE_TYPE (ar)) == POINTER_TYPE);
    3687       973239 :       gcc_assert (TREE_CODE (TREE_TYPE (TREE_TYPE (ar))) != FUNCTION_TYPE);
    3688              : 
    3689       973239 :       ret = build_indirect_ref (loc, build_binary_op (loc, PLUS_EXPR, ar,
    3690              :                                                       index, false),
    3691              :                                 RO_ARRAY_INDEXING);
    3692       973239 :       if (non_lvalue)
    3693            0 :         ret = non_lvalue_loc (loc, ret);
    3694       973239 :       return ret;
    3695              :     }
    3696              : }
    3697              : 
    3698              : /* Build an OpenMP array section reference, creating an exact type for the
    3699              :    resulting expression based on the element type and bounds if possible.  If
    3700              :    we have variable bounds, create an incomplete array type for the result
    3701              :    instead.  */
    3702              : 
    3703              : tree
    3704         3951 : build_omp_array_section (location_t loc, tree array, tree index, tree length)
    3705              : {
    3706         3951 :   tree type = TREE_TYPE (array);
    3707         3951 :   gcc_assert (type);
    3708              : 
    3709         3951 :   tree sectype, eltype = TREE_TYPE (type);
    3710              : 
    3711              :   /* It's not an array or pointer type.  Just reuse the type of the original
    3712              :      expression as the type of the array section (an error will be raised
    3713              :      anyway, later).  */
    3714         3951 :   if (eltype == NULL_TREE || error_operand_p (eltype))
    3715           12 :     sectype = TREE_TYPE (array);
    3716              :   else
    3717              :     {
    3718         3939 :       tree idxtype = NULL_TREE;
    3719              : 
    3720         3939 :       if (index != NULL_TREE
    3721         3939 :           && length != NULL_TREE
    3722         3012 :           && INTEGRAL_TYPE_P (TREE_TYPE (index))
    3723         6946 :           && INTEGRAL_TYPE_P (TREE_TYPE (length)))
    3724              :         {
    3725         3000 :           tree low = fold_convert (sizetype, index);
    3726         3000 :           tree high = fold_convert (sizetype, length);
    3727         3000 :           high = size_binop (PLUS_EXPR, low, high);
    3728         3000 :           high = size_binop (MINUS_EXPR, high, size_one_node);
    3729         3000 :           idxtype = build_range_type (sizetype, low, high);
    3730              :         }
    3731          135 :       else if ((index == NULL_TREE || integer_zerop (index))
    3732          829 :                && length != NULL_TREE
    3733         1616 :                && INTEGRAL_TYPE_P (TREE_TYPE (length)))
    3734          660 :         idxtype = build_index_type (length);
    3735              : 
    3736         3939 :       gcc_assert (!error_operand_p (idxtype));
    3737              : 
    3738         3939 :       sectype = c_build_array_type (eltype, idxtype);
    3739              :     }
    3740              : 
    3741         3951 :   return build3_loc (loc, OMP_ARRAY_SECTION, sectype, array, index, length);
    3742              : }
    3743              : 
    3744              : 
    3745              : /* Record that REF is used.  This is relevant for undeclared static
    3746              :    function and declarations referenced from a non-local context.
    3747              :    ADDRESS indicates whether the address is taken.  */
    3748              : 
    3749              : void
    3750    475313235 : mark_decl_used (tree ref, bool address)
    3751              : {
    3752    475313235 :   if (!ref || !DECL_P (ref) || in_alignof)
    3753              :     return;
    3754              : 
    3755              :   /* Non-file-scope and non-local reference in nested function.  */
    3756    348366979 :   bool nonloc_p = current_function_decl && DECL_CONTEXT (ref)
    3757    122184127 :                   && DECL_CONTEXT (current_function_decl)
    3758    475279181 :                   && DECL_CONTEXT (ref) != current_function_decl;
    3759              : 
    3760              :   /* An undeclared static function.  */
    3761    475269097 :   bool static_p = TREE_CODE (ref) == FUNCTION_DECL
    3762    101936068 :                   && DECL_INITIAL (ref) == NULL_TREE
    3763     69737490 :                   && DECL_EXTERNAL (ref)
    3764    545003989 :                   && !TREE_PUBLIC (ref);
    3765              : 
    3766    475135481 :   if (!static_p && !nonloc_p)
    3767              :     return;
    3768              : 
    3769              :   /* If we may be in an unevaluated context, delay the decision.  */
    3770       136245 :   if (in_sizeof || in_typeof || in_countof || in_generic)
    3771          273 :     return record_maybe_used_decl (ref, address);
    3772              : 
    3773       135972 :   if (static_p)
    3774       133360 :     C_DECL_USED (ref) = 1;
    3775              : 
    3776       135972 :   if (nonloc_p && (VAR_OR_FUNCTION_DECL_P (ref)
    3777              :                    || TREE_CODE (ref) == PARM_DECL))
    3778         2049 :     DECL_NONLOCAL (ref) = 1;
    3779              : 
    3780              :   /* Nothing to do anymore.  */
    3781         2612 :   if (!nonloc_p || C_FUNC_NONLOCAL_CONTEXT (current_function_decl))
    3782       134765 :     return;
    3783              : 
    3784              :   /* Filter out the cases where referencing a non-local variable does not
    3785              :      require a non-local context passed via the static chain.  */
    3786         1207 :   if (!c_type_variably_modified_p (TREE_TYPE (ref)))
    3787         1135 :     switch (TREE_CODE (ref))
    3788              :       {
    3789          215 :       case FUNCTION_DECL:
    3790              :         /* Use of another local function that requires no context is ok.  */
    3791          215 :         if (!C_FUNC_NONLOCAL_CONTEXT (ref) && DECL_INITIAL (ref))
    3792              :           return;
    3793              :         break;
    3794          438 :       case VAR_DECL:
    3795              :         /* Static variables and constexpr are ok, but for the later only
    3796              :            when the address is not taken.  */
    3797          438 :         if (TREE_STATIC (ref) || (C_DECL_DECLARED_CONSTEXPR (ref) && !address))
    3798              :           return;
    3799              :         break;
    3800              :       case TYPE_DECL:
    3801              :         /* A typedef is ok when not for a variably-modified type. */
    3802              :         return;
    3803              :       case CONST_DECL:
    3804              :         /* An enumeration constant is ok. */
    3805              :         return;
    3806              :       case PARM_DECL:
    3807              :         break;
    3808              :       case LABEL_DECL:
    3809              :         break;
    3810            0 :       default:
    3811            0 :         gcc_unreachable ();
    3812              :     }
    3813              : 
    3814              :   /* Mark all parent functions up to the nesting level of the variable as
    3815              :      as needing the non-local context.  */
    3816         2019 :   for (tree cont = current_function_decl; cont; cont = DECL_CONTEXT (cont))
    3817              :     {
    3818         2019 :       if (cont == DECL_CONTEXT (ref))
    3819              :         break;
    3820              : 
    3821              :       /* There should not be any other type of context used for function
    3822              :          except TRANSLATION_UNIT_DECL which we should be able to reach.  */
    3823         1015 :       gcc_checking_assert (TREE_CODE (cont) == FUNCTION_DECL);
    3824              : 
    3825         1015 :       if (TREE_CODE (cont) == FUNCTION_DECL)
    3826         1015 :         C_FUNC_NONLOCAL_CONTEXT (cont) = 1;
    3827              :     }
    3828              : }
    3829              : 
    3830              : 
    3831              : /* Build an external reference to identifier ID.  FUN indicates
    3832              :    whether this will be used for a function call.  LOC is the source
    3833              :    location of the identifier.  This sets *TYPE to the type of the
    3834              :    identifier, which is not the same as the type of the returned value
    3835              :    for CONST_DECLs defined as enum constants.  If the type of the
    3836              :    identifier is not available, *TYPE is set to NULL.  */
    3837              : tree
    3838    174960803 : build_external_ref (location_t loc, tree id, bool fun, tree *type)
    3839              : {
    3840    174960803 :   tree ref;
    3841    174960803 :   tree decl = lookup_name (id);
    3842              : 
    3843              :   /* In Objective-C, an instance variable (ivar) may be preferred to
    3844              :      whatever lookup_name() found.  */
    3845    174960803 :   decl = objc_lookup_ivar (decl, id);
    3846              : 
    3847    174960803 :   *type = NULL;
    3848    174960803 :   if (decl && decl != error_mark_node)
    3849              :     {
    3850    174954610 :       ref = decl;
    3851    174954610 :       *type = TREE_TYPE (ref);
    3852    174954610 :       if (DECL_P (decl) && C_DECL_UNDERSPECIFIED (decl))
    3853            4 :         error_at (loc, "underspecified %qD referenced in its initializer",
    3854              :                   decl);
    3855              :     }
    3856         6193 :   else if (fun)
    3857              :     /* Implicit function declaration.  */
    3858         4729 :     ref = implicitly_declare (loc, id);
    3859         1464 :   else if (decl == error_mark_node)
    3860              :     /* Don't complain about something that's already been
    3861              :        complained about.  */
    3862              :     return error_mark_node;
    3863              :   else
    3864              :     {
    3865         1230 :       undeclared_variable (loc, id);
    3866         1230 :       return error_mark_node;
    3867              :     }
    3868              : 
    3869              :   /* For an OpenMP map clause, we can get better diagnostics for decls with
    3870              :      unmappable types if we return the decl with an error_mark_node type,
    3871              :      rather than returning error_mark_node for the decl itself.  */
    3872    174959339 :   if (TREE_TYPE (ref) == error_mark_node
    3873    174959339 :       && !c_omp_array_section_p)
    3874              :     return error_mark_node;
    3875              : 
    3876    174959321 :   if (TREE_UNAVAILABLE (ref))
    3877           14 :     error_unavailable_use (ref, NULL_TREE);
    3878    174959307 :   else if (TREE_DEPRECATED (ref))
    3879          100 :     warn_deprecated_use (ref, NULL_TREE);
    3880              : 
    3881              :   /* Recursive call does not count as usage.  */
    3882    174959321 :   if (ref != current_function_decl)
    3883              :     {
    3884    174956667 :       TREE_USED (ref) = 1;
    3885              :     }
    3886              : 
    3887    174959321 :   mark_decl_used (ref, false);
    3888              : 
    3889    174959321 :   if (TREE_CODE (ref) == CONST_DECL)
    3890              :     {
    3891       417520 :       used_types_insert (TREE_TYPE (ref));
    3892              : 
    3893       417520 :       if (warn_cxx_compat
    3894          417 :           && TREE_CODE (TREE_TYPE (ref)) == ENUMERAL_TYPE
    3895       417935 :           && C_TYPE_DEFINED_IN_STRUCT (TREE_TYPE (ref)))
    3896              :         {
    3897            1 :           warning_at (loc, OPT_Wc___compat,
    3898              :                       "enum constant defined in struct or union "
    3899              :                       "is not visible in C++");
    3900            1 :           inform (DECL_SOURCE_LOCATION (ref), "enum constant defined here");
    3901              :         }
    3902              : 
    3903       417520 :       ref = DECL_INITIAL (ref);
    3904       417520 :       TREE_CONSTANT (ref) = 1;
    3905              :     }
    3906              :   /* C99 6.7.4p3: An inline definition of a function with external
    3907              :      linkage ... shall not contain a reference to an identifier with
    3908              :      internal linkage.  */
    3909    174541801 :   else if (current_function_decl != NULL_TREE
    3910    173029725 :            && DECL_DECLARED_INLINE_P (current_function_decl)
    3911    159365691 :            && DECL_EXTERNAL (current_function_decl)
    3912    158591209 :            && VAR_OR_FUNCTION_DECL_P (ref)
    3913     56516149 :            && (!VAR_P (ref) || TREE_STATIC (ref))
    3914     47367565 :            && ! TREE_PUBLIC (ref)
    3915    174541835 :            && DECL_CONTEXT (ref) != current_function_decl)
    3916           25 :     record_inline_static (loc, current_function_decl, ref,
    3917              :                           csi_internal);
    3918              : 
    3919              :   return ref;
    3920              : }
    3921              : 
    3922              : static struct maybe_used_decl *maybe_used_decls;
    3923              : 
    3924              : /* Record that DECL, a reference seen inside sizeof or typeof or _Countof or
    3925              :    _Generic, might be used if the operand of sizeof is a VLA type or the
    3926              :    operand of typeof is a variably modified type or the operand of _Countof has
    3927              :    a variable number of elements or the operand of _Generic is the one selected
    3928              :    as the result.  */
    3929              : 
    3930              : static void
    3931          273 : record_maybe_used_decl (tree decl, bool address)
    3932              : {
    3933          273 :   struct maybe_used_decl *t = XOBNEW (&parser_obstack, struct maybe_used_decl);
    3934          273 :   t->decl = decl;
    3935          273 :   t->level = in_sizeof + in_typeof + in_countof + in_generic;
    3936          273 :   t->address = address;
    3937          273 :   t->next = maybe_used_decls;
    3938          273 :   maybe_used_decls = t;
    3939          273 : }
    3940              : 
    3941              : /* Pop the stack of decls possibly used inside sizeof or typeof or _Countof or
    3942              :    _Generic.  If USED is false, just discard them.  If it is true, mark them
    3943              :    used (if no longer inside sizeof or typeof or _Countof or _Generic) or move
    3944              :    them to the next level up (if still inside sizeof or typeof or _Countof or
    3945              :    _Generic).  */
    3946              : 
    3947              : void
    3948      1468547 : pop_maybe_used (bool used)
    3949              : {
    3950      1468547 :   struct maybe_used_decl *p = maybe_used_decls;
    3951      1468547 :   int cur_level = in_sizeof + in_typeof + in_countof + in_generic;
    3952      1468844 :   while (p && p->level > cur_level)
    3953              :     {
    3954          297 :       if (used)
    3955              :         {
    3956           77 :           if (cur_level == 0)
    3957           53 :             mark_decl_used (p->decl, p->address);
    3958              :           else
    3959           24 :             p->level = cur_level;
    3960              :         }
    3961          297 :       p = p->next;
    3962              :     }
    3963      1468547 :   if (!used || cur_level == 0)
    3964      1468466 :     maybe_used_decls = p;
    3965      1468547 : }
    3966              : 
    3967              : /* Pop the stack of decls possibly used inside sizeof or typeof or _Countof or
    3968              :    _Generic, without acting on them, and return the pointer to the previous top
    3969              :    of the stack.  This for use at the end of a default generic association when
    3970              :    it is not yet known whether the expression is used.  If it later turns out
    3971              :    the expression is used (or treated as used before C23), restore_maybe_used
    3972              :    should be called on the return value followed by pop_maybe_used (true);
    3973              :    otherwise, the return value can be discarded.  */
    3974              : 
    3975              : struct maybe_used_decl *
    3976         1135 : save_maybe_used ()
    3977              : {
    3978         1135 :   struct maybe_used_decl *p = maybe_used_decls, *orig = p;
    3979         1135 :   int cur_level = in_sizeof + in_typeof + in_countof + in_generic;
    3980         1167 :   while (p && p->level > cur_level)
    3981           32 :     p = p->next;
    3982         1135 :   maybe_used_decls = p;
    3983         1135 :   return orig;
    3984              : }
    3985              : 
    3986              : /* Restore the stack of decls possibly used inside sizeof or typeof or _Countof
    3987              :    or _Generic returned by save_maybe_used.  It is required that the stack is
    3988              :    at exactly the point where it was left by save_maybe_used.  */
    3989              : 
    3990              : void
    3991          278 : restore_maybe_used (struct maybe_used_decl *stack)
    3992              : {
    3993          278 :   maybe_used_decls = stack;
    3994          278 : }
    3995              : 
    3996              : /* Return the result of sizeof applied to EXPR.  */
    3997              : 
    3998              : struct c_expr
    3999       313074 : c_expr_sizeof_expr (location_t loc, struct c_expr expr)
    4000              : {
    4001       313074 :   struct c_expr ret;
    4002       313074 :   if (expr.value == error_mark_node)
    4003              :     {
    4004          111 :       ret.value = error_mark_node;
    4005          111 :       ret.original_code = ERROR_MARK;
    4006          111 :       ret.original_type = NULL;
    4007          111 :       ret.m_decimal = 0;
    4008          111 :       pop_maybe_used (false);
    4009              :     }
    4010              :   else
    4011              :     {
    4012       312963 :       bool expr_const_operands = true;
    4013              : 
    4014       312963 :       if (TREE_CODE (expr.value) == PARM_DECL
    4015       312963 :           && C_ARRAY_PARAMETER (expr.value))
    4016              :         {
    4017           55 :           auto_diagnostic_group d;
    4018           55 :           if (warning_at (loc, OPT_Wsizeof_array_argument,
    4019              :                           "%<sizeof%> on array function parameter %qE will "
    4020              :                           "return size of %qT", expr.value,
    4021           55 :                           TREE_TYPE (expr.value)))
    4022           19 :             inform (DECL_SOURCE_LOCATION (expr.value), "declared here");
    4023           55 :         }
    4024       312963 :       tree folded_expr = c_fully_fold (expr.value, require_constant_value,
    4025              :                                        &expr_const_operands);
    4026       312963 :       ret.value = c_sizeof (loc, TREE_TYPE (folded_expr));
    4027       312963 :       c_last_sizeof_arg = expr.value;
    4028       312963 :       c_last_sizeof_loc = loc;
    4029       312963 :       ret.original_code = SIZEOF_EXPR;
    4030       312963 :       ret.original_type = NULL;
    4031       312963 :       ret.m_decimal = 0;
    4032       312963 :       if (C_TYPE_VARIABLE_SIZE (TREE_TYPE (folded_expr)))
    4033              :         {
    4034              :           /* sizeof is evaluated when given a vla (C99 6.5.3.4p2).  */
    4035          288 :           ret.value = build2 (C_MAYBE_CONST_EXPR, TREE_TYPE (ret.value),
    4036              :                               folded_expr, ret.value);
    4037          288 :           C_MAYBE_CONST_EXPR_NON_CONST (ret.value) = !expr_const_operands;
    4038          288 :           SET_EXPR_LOCATION (ret.value, loc);
    4039              :         }
    4040       312963 :       pop_maybe_used (C_TYPE_VARIABLE_SIZE (TREE_TYPE (folded_expr)));
    4041              :     }
    4042       313074 :   return ret;
    4043              : }
    4044              : 
    4045              : /* Return the result of sizeof applied to T, a structure for the type
    4046              :    name passed to sizeof (rather than the type itself).  LOC is the
    4047              :    location of the original expression.  */
    4048              : 
    4049              : struct c_expr
    4050       331949 : c_expr_sizeof_type (location_t loc, struct c_type_name *t)
    4051              : {
    4052       331949 :   tree type;
    4053       331949 :   struct c_expr ret;
    4054       331949 :   tree type_expr = NULL_TREE;
    4055       331949 :   bool type_expr_const = true;
    4056       331949 :   type = groktypename (t, &type_expr, &type_expr_const);
    4057       331949 :   ret.value = c_sizeof (loc, type);
    4058       331949 :   c_last_sizeof_arg = type;
    4059       331949 :   c_last_sizeof_loc = loc;
    4060       331949 :   ret.original_code = SIZEOF_EXPR;
    4061       331949 :   ret.original_type = NULL;
    4062       331949 :   ret.m_decimal = 0;
    4063       331949 :   if (type == error_mark_node)
    4064              :     {
    4065            5 :       ret.value = error_mark_node;
    4066            5 :       ret.original_code = ERROR_MARK;
    4067              :     }
    4068              :   else
    4069       331902 :   if ((type_expr || TREE_CODE (ret.value) == INTEGER_CST)
    4070       663761 :       && C_TYPE_VARIABLE_SIZE (type))
    4071              :     {
    4072              :       /* If the type is a [*] array, it is a VLA but is represented as
    4073              :          having a size of zero.  In such a case we must ensure that
    4074              :          the result of sizeof does not get folded to a constant by
    4075              :          c_fully_fold, because if the size is evaluated the result is
    4076              :          not constant and so constraints on zero or negative size
    4077              :          arrays must not be applied when this sizeof call is inside
    4078              :          another array declarator.  */
    4079           41 :       if (!type_expr)
    4080           16 :         type_expr = integer_zero_node;
    4081           41 :       ret.value = build2 (C_MAYBE_CONST_EXPR, TREE_TYPE (ret.value),
    4082              :                           type_expr, ret.value);
    4083           41 :       C_MAYBE_CONST_EXPR_NON_CONST (ret.value) = !type_expr_const;
    4084              :     }
    4085       331949 :   pop_maybe_used (type != error_mark_node
    4086       331949 :                   ? C_TYPE_VARIABLE_SIZE (type) : false);
    4087       331949 :   return ret;
    4088              : }
    4089              : 
    4090              : static bool
    4091          138 : is_top_array_vla (tree type)
    4092              : {
    4093          138 :   bool zero, var;
    4094          138 :   tree d;
    4095              : 
    4096          138 :   if (TREE_CODE (type) != ARRAY_TYPE)
    4097              :     return false;
    4098          120 :   if (!COMPLETE_TYPE_P (type))
    4099              :     return false;
    4100              : 
    4101          116 :   d = TYPE_DOMAIN (type);
    4102          116 :   zero = !TYPE_MAX_VALUE (d);
    4103          116 :   if (zero)
    4104              :     return false;
    4105              : 
    4106          100 :   var = (TREE_CODE (TYPE_MIN_VALUE (d)) != INTEGER_CST
    4107          100 :          || TREE_CODE (TYPE_MAX_VALUE (d)) != INTEGER_CST);
    4108              :   return var;
    4109              : }
    4110              : 
    4111              : /* Return the result of countof applied to EXPR.  */
    4112              : 
    4113              : struct c_expr
    4114           54 : c_expr_countof_expr (location_t loc, struct c_expr expr)
    4115              : {
    4116           54 :   struct c_expr ret;
    4117           54 :   if (expr.value == error_mark_node)
    4118              :     {
    4119            1 :       ret.value = error_mark_node;
    4120            1 :       ret.original_code = ERROR_MARK;
    4121            1 :       ret.original_type = NULL;
    4122            1 :       ret.m_decimal = 0;
    4123            1 :       pop_maybe_used (false);
    4124              :     }
    4125              :   else
    4126              :     {
    4127           53 :       bool expr_const_operands = true;
    4128              : 
    4129           53 :       tree folded_expr = c_fully_fold (expr.value, require_constant_value,
    4130              :                                        &expr_const_operands);
    4131           53 :       ret.value = c_countof_type (loc, TREE_TYPE (folded_expr));
    4132           53 :       c_last_sizeof_arg = expr.value;
    4133           53 :       c_last_sizeof_loc = loc;
    4134           53 :       ret.original_code = COUNTOF_EXPR;
    4135           53 :       ret.original_type = NULL;
    4136           53 :       ret.m_decimal = 0;
    4137           53 :       if (is_top_array_vla (TREE_TYPE (folded_expr)))
    4138              :         {
    4139              :           /* countof is evaluated when given a vla.  */
    4140           11 :           ret.value = build2 (C_MAYBE_CONST_EXPR, TREE_TYPE (ret.value),
    4141              :                               folded_expr, ret.value);
    4142           11 :           C_MAYBE_CONST_EXPR_NON_CONST (ret.value) = !expr_const_operands;
    4143           11 :           SET_EXPR_LOCATION (ret.value, loc);
    4144              :         }
    4145           53 :       pop_maybe_used (is_top_array_vla (TREE_TYPE (folded_expr)));
    4146              :     }
    4147           54 :   return ret;
    4148              : }
    4149              : 
    4150              : /* Return the result of countof applied to T, a structure for the type
    4151              :    name passed to countof (rather than the type itself).  LOC is the
    4152              :    location of the original expression.  */
    4153              : 
    4154              : struct c_expr
    4155           18 : c_expr_countof_type (location_t loc, struct c_type_name *t)
    4156              : {
    4157           18 :   tree type;
    4158           18 :   struct c_expr ret;
    4159           18 :   tree type_expr = NULL_TREE;
    4160           18 :   bool type_expr_const = true;
    4161           18 :   type = groktypename (t, &type_expr, &type_expr_const);
    4162           18 :   ret.value = c_countof_type (loc, type);
    4163           18 :   c_last_sizeof_arg = type;
    4164           18 :   c_last_sizeof_loc = loc;
    4165           18 :   ret.original_code = COUNTOF_EXPR;
    4166           18 :   ret.original_type = NULL;
    4167           18 :   ret.m_decimal = 0;
    4168           18 :   if (type == error_mark_node)
    4169              :     {
    4170            0 :       ret.value = error_mark_node;
    4171            0 :       ret.original_code = ERROR_MARK;
    4172              :     }
    4173              :   else
    4174            8 :   if ((type_expr || TREE_CODE (ret.value) == INTEGER_CST)
    4175           22 :       && is_top_array_vla (type))
    4176              :     {
    4177              :       /* If the type is a [*] array, it is a VLA but is represented as
    4178              :          having a size of zero.  In such a case we must ensure that
    4179              :          the result of countof does not get folded to a constant by
    4180              :          c_fully_fold, because if the number of elements is evaluated
    4181              :          the result is not constant and so
    4182              :          constraints on zero or negative size arrays must not be applied
    4183              :          when this countof call is inside another array declarator.  */
    4184            6 :       if (!type_expr)
    4185            0 :         type_expr = integer_zero_node;
    4186            6 :       ret.value = build2 (C_MAYBE_CONST_EXPR, TREE_TYPE (ret.value),
    4187              :                           type_expr, ret.value);
    4188            6 :       C_MAYBE_CONST_EXPR_NON_CONST (ret.value) = !type_expr_const;
    4189              :     }
    4190           18 :   pop_maybe_used (type != error_mark_node ? is_top_array_vla (type) : false);
    4191           18 :   return ret;
    4192              : }
    4193              : 
    4194              : /* Return the result of maxof applied to T, a structure for the type
    4195              :    name passed to maxof (rather than the type itself).  LOC is the
    4196              :    location of the original expression.  */
    4197              : 
    4198              : struct c_expr
    4199           46 : c_expr_maxof_type (location_t loc, struct c_type_name *t)
    4200              : {
    4201           46 :   tree type;
    4202           46 :   struct c_expr ret;
    4203           46 :   tree type_expr = NULL_TREE;
    4204           46 :   bool type_expr_const = true;
    4205           46 :   type = groktypename (t, &type_expr, &type_expr_const);
    4206           46 :   ret.value = c_maxof_type (loc, type);
    4207           46 :   c_last_sizeof_arg = type;
    4208           46 :   c_last_sizeof_loc = loc;
    4209           46 :   ret.original_code = MAXOF_EXPR;
    4210           46 :   ret.original_type = NULL;
    4211           46 :   ret.m_decimal = 0;
    4212           46 :   if (type == error_mark_node)
    4213              :     {
    4214            0 :       ret.value = error_mark_node;
    4215            0 :       ret.original_code = ERROR_MARK;
    4216              :     }
    4217           46 :   pop_maybe_used (type != error_mark_node);
    4218           46 :   return ret;
    4219              : }
    4220              : 
    4221              : /* Return the result of minof applied to T, a structure for the type
    4222              :    name passed to minof (rather than the type itself).  LOC is the
    4223              :    location of the original expression.  */
    4224              : 
    4225              : struct c_expr
    4226           46 : c_expr_minof_type (location_t loc, struct c_type_name *t)
    4227              : {
    4228           46 :   tree type;
    4229           46 :   struct c_expr ret;
    4230           46 :   tree type_expr = NULL_TREE;
    4231           46 :   bool type_expr_const = true;
    4232           46 :   type = groktypename (t, &type_expr, &type_expr_const);
    4233           46 :   ret.value = c_minof_type (loc, type);
    4234           46 :   c_last_sizeof_arg = type;
    4235           46 :   c_last_sizeof_loc = loc;
    4236           46 :   ret.original_code = MINOF_EXPR;
    4237           46 :   ret.original_type = NULL;
    4238           46 :   ret.m_decimal = 0;
    4239           46 :   if (type == error_mark_node)
    4240              :     {
    4241            0 :       ret.value = error_mark_node;
    4242            0 :       ret.original_code = ERROR_MARK;
    4243              :     }
    4244           46 :   pop_maybe_used (type != error_mark_node);
    4245           46 :   return ret;
    4246              : }
    4247              : 
    4248              : /* Build a function call to function FUNCTION with parameters PARAMS.
    4249              :    The function call is at LOC.
    4250              :    PARAMS is a list--a chain of TREE_LIST nodes--in which the
    4251              :    TREE_VALUE of each node is a parameter-expression.
    4252              :    FUNCTION's data type may be a function type or a pointer-to-function.  */
    4253              : 
    4254              : tree
    4255            0 : build_function_call (location_t loc, tree function, tree params)
    4256              : {
    4257            0 :   vec<tree, va_gc> *v;
    4258            0 :   tree ret;
    4259              : 
    4260            0 :   vec_alloc (v, list_length (params));
    4261            0 :   for (; params; params = TREE_CHAIN (params))
    4262            0 :     v->quick_push (TREE_VALUE (params));
    4263            0 :   ret = c_build_function_call_vec (loc, vNULL, function, v, NULL);
    4264            0 :   vec_free (v);
    4265            0 :   return ret;
    4266              : }
    4267              : 
    4268              : /* Give a note about the location of the declaration of DECL,
    4269              :    or, failing that, a pertinent declaration for FUNCTION_EXPR.  */
    4270              : 
    4271              : static void
    4272          299 : inform_declaration (tree decl, tree function_expr)
    4273              : {
    4274          299 :   if (decl && (TREE_CODE (decl) != FUNCTION_DECL
    4275          278 :                || !DECL_IS_UNDECLARED_BUILTIN (decl)))
    4276          207 :     inform (DECL_SOURCE_LOCATION (decl), "declared here");
    4277           92 :   else if (function_expr)
    4278           92 :     switch (TREE_CODE (function_expr))
    4279              :       {
    4280              :       default:
    4281              :         break;
    4282           13 :       case COMPONENT_REF:
    4283              :         /* Show the decl of the pertinent field (e.g. for callback
    4284              :            fields in a struct.  */
    4285           13 :         {
    4286           13 :           tree field_decl = TREE_OPERAND (function_expr, 1);
    4287           13 :           if (location_t loc = DECL_SOURCE_LOCATION (field_decl))
    4288           13 :             inform (loc, "declared here");
    4289              :         }
    4290              :         break;
    4291              :       }
    4292          299 : }
    4293              : 
    4294              : 
    4295              : /* Build a function call to function FUNCTION with parameters PARAMS.
    4296              :    If FUNCTION is the result of resolving an overloaded target built-in,
    4297              :    ORIG_FUNDECL is the original function decl, otherwise it is null.
    4298              :    ORIGTYPES, if not NULL, is a vector of types; each element is
    4299              :    either NULL or the original type of the corresponding element in
    4300              :    PARAMS.  The original type may differ from TREE_TYPE of the
    4301              :    parameter for enums.  FUNCTION's data type may be a function type
    4302              :    or pointer-to-function.  This function changes the elements of
    4303              :    PARAMS.  */
    4304              : 
    4305              : tree
    4306     49908490 : build_function_call_vec (location_t loc, vec<location_t> arg_loc,
    4307              :                          tree function, vec<tree, va_gc> *params,
    4308              :                          vec<tree, va_gc> *origtypes, tree orig_fundecl)
    4309              : {
    4310     49908490 :   tree fntype, fundecl = NULL_TREE;
    4311     49908490 :   tree name = NULL_TREE, result;
    4312     49908490 :   tree tem;
    4313     49908490 :   int nargs;
    4314     49908490 :   tree *argarray;
    4315              : 
    4316              : 
    4317              :   /* Strip NON_LVALUE_EXPRs, etc., since we aren't using as an lvalue.  */
    4318     49908490 :   STRIP_TYPE_NOPS (function);
    4319              : 
    4320              :   /* Convert anything with function type to a pointer-to-function.  */
    4321     49908490 :   if (TREE_CODE (function) == FUNCTION_DECL)
    4322              :     {
    4323     49831010 :       name = DECL_NAME (function);
    4324              : 
    4325     49831010 :       if (flag_tm)
    4326          421 :         tm_malloc_replacement (function);
    4327     49831010 :       fundecl = function;
    4328     49831010 :       if (!orig_fundecl)
    4329     49831010 :         orig_fundecl = fundecl;
    4330              :       /* Atomic functions have type checking/casting already done.  They are
    4331              :          often rewritten and don't match the original parameter list.  */
    4332     99662020 :       if (name && startswith (IDENTIFIER_POINTER (name), "__atomic_"))
    4333              :         origtypes = NULL;
    4334              :     }
    4335     49908490 :   if (TREE_CODE (TREE_TYPE (function)) == FUNCTION_TYPE)
    4336     49845524 :     function = function_to_pointer_conversion (loc, function);
    4337              : 
    4338              :   /* For Objective-C, convert any calls via a cast to OBJC_TYPE_REF
    4339              :      expressions, like those used for ObjC messenger dispatches.  */
    4340     49908490 :   if (params && !params->is_empty ())
    4341     38191403 :     function = objc_rewrite_function_call (function, (*params)[0]);
    4342              : 
    4343     49908490 :   function = c_fully_fold (function, false, NULL);
    4344              : 
    4345     49908490 :   fntype = TREE_TYPE (function);
    4346              : 
    4347     49908490 :   if (TREE_CODE (fntype) == ERROR_MARK)
    4348            5 :     return error_mark_node;
    4349              : 
    4350     49908485 :   if (!(TREE_CODE (fntype) == POINTER_TYPE
    4351     49908451 :         && TREE_CODE (TREE_TYPE (fntype)) == FUNCTION_TYPE))
    4352              :     {
    4353           37 :       if (!flag_diagnostics_show_caret && !STATEMENT_CLASS_P (function))
    4354           33 :         error_at (loc,
    4355              :                   "called object %qE is not a function or function pointer",
    4356              :                   function);
    4357            4 :       else if (DECL_P (function))
    4358              :         {
    4359            1 :           auto_diagnostic_group d;
    4360            1 :           error_at (loc,
    4361              :                     "called object %qD is not a function or function pointer",
    4362              :                     function);
    4363            1 :           inform_declaration (function, NULL_TREE);
    4364            1 :         }
    4365              :       else
    4366            3 :         error_at (loc,
    4367              :                   "called object is not a function or function pointer");
    4368           37 :       return error_mark_node;
    4369              :     }
    4370              : 
    4371     49908448 :   if (fundecl && TREE_THIS_VOLATILE (fundecl))
    4372       376867 :     current_function_returns_abnormally = 1;
    4373              : 
    4374              :   /* fntype now gets the type of function pointed to.  */
    4375     49908448 :   fntype = TREE_TYPE (fntype);
    4376     49908448 :   tree return_type = TREE_TYPE (fntype);
    4377              : 
    4378              :   /* Convert the parameters to the types declared in the
    4379              :      function prototype, or apply default promotions.  */
    4380              : 
    4381     49908448 :   nargs = convert_arguments (loc, arg_loc, fntype, params,
    4382              :                              origtypes, function, fundecl);
    4383     49908448 :   if (nargs < 0)
    4384          178 :     return error_mark_node;
    4385              : 
    4386              :   /* Check that the function is called through a compatible prototype.
    4387              :      If it is not, warn.  */
    4388     49907363 :   if (CONVERT_EXPR_P (function)
    4389          923 :       && TREE_CODE (tem = TREE_OPERAND (function, 0)) == ADDR_EXPR
    4390          215 :       && TREE_CODE (tem = TREE_OPERAND (tem, 0)) == FUNCTION_DECL
    4391     49908455 :       && !comptypes (fntype, TREE_TYPE (tem)))
    4392              :     {
    4393              :       /* This situation leads to run-time undefined behavior.  We can't,
    4394              :          therefore, simply error unless we can prove that all possible
    4395              :          executions of the program must execute the code.  */
    4396           20 :       warning_at (loc, 0, "function called through a non-compatible type");
    4397              : 
    4398           20 :       if (VOID_TYPE_P (return_type)
    4399           20 :           && TYPE_QUALS (return_type) != TYPE_UNQUALIFIED)
    4400            1 :         pedwarn (loc, 0,
    4401              :                  "function with qualified void return type called");
    4402              :      }
    4403              : 
    4404     49908270 :   argarray = vec_safe_address (params);
    4405              : 
    4406              :   /* Check that arguments to builtin functions match the expectations.  */
    4407     49908270 :   if (fundecl
    4408     49830847 :       && fndecl_built_in_p (fundecl)
    4409     83161946 :       && !check_builtin_function_arguments (loc, arg_loc, fundecl,
    4410              :                                             orig_fundecl, nargs, argarray))
    4411          298 :     return error_mark_node;
    4412              : 
    4413              :   /* Check that the arguments to the function are valid.  */
    4414     49907972 :   bool warned_p = check_function_arguments (loc, fundecl, fntype,
    4415              :                                             nargs, argarray, &arg_loc,
    4416              :                                             comptypes);
    4417              : 
    4418     49907972 :   if (TYPE_QUALS (return_type) != TYPE_UNQUALIFIED
    4419     49907972 :       && !VOID_TYPE_P (return_type))
    4420           11 :     return_type = c_build_qualified_type (return_type, TYPE_UNQUALIFIED);
    4421     49907972 :   if (name != NULL_TREE
    4422     99738521 :       && startswith (IDENTIFIER_POINTER (name), "__builtin_"))
    4423              :     {
    4424     32527603 :       if (require_constant_value)
    4425         3460 :         result
    4426         3460 :           = fold_build_call_array_initializer_loc (loc, return_type,
    4427              :                                                    function, nargs, argarray);
    4428              :       else
    4429     32524143 :         result = fold_build_call_array_loc (loc, return_type,
    4430              :                                             function, nargs, argarray);
    4431     32527603 :       if (TREE_CODE (result) == NOP_EXPR
    4432     32527603 :           && TREE_CODE (TREE_OPERAND (result, 0)) == INTEGER_CST)
    4433        26464 :         STRIP_TYPE_NOPS (result);
    4434              :     }
    4435              :   else
    4436     17380369 :     result = build_call_array_loc (loc, return_type,
    4437              :                                    function, nargs, argarray);
    4438              :   /* If -Wnonnull warning has been diagnosed, avoid diagnosing it again
    4439              :      later.  */
    4440     49907972 :   if (warned_p && TREE_CODE (result) == CALL_EXPR)
    4441          215 :     suppress_warning (result, OPT_Wnonnull);
    4442              : 
    4443              :   /* In this improbable scenario, a nested function returns a VM type.
    4444              :      Create a TARGET_EXPR so that the call always has a LHS, much as
    4445              :      what the C++ FE does for functions returning non-PODs.  */
    4446     49907972 :   if (c_type_variably_modified_p (TREE_TYPE (fntype)))
    4447              :     {
    4448           83 :       tree tmp = create_tmp_var_raw (TREE_TYPE (fntype));
    4449           83 :       result = build4 (TARGET_EXPR, TREE_TYPE (fntype), tmp, result,
    4450              :                        NULL_TREE, NULL_TREE);
    4451              :     }
    4452              : 
    4453     49907972 :   if (VOID_TYPE_P (TREE_TYPE (result)))
    4454              :     {
    4455      2393629 :       if (TYPE_QUALS (TREE_TYPE (result)) != TYPE_UNQUALIFIED)
    4456            2 :         pedwarn (loc, 0,
    4457              :                  "function with qualified void return type called");
    4458      2393629 :       return result;
    4459              :     }
    4460     47514343 :   return require_complete_type (loc, result);
    4461              : }
    4462              : 
    4463              : /* Like build_function_call_vec, but call also resolve_overloaded_builtin.  */
    4464              : 
    4465              : tree
    4466     49908047 : c_build_function_call_vec (location_t loc, const vec<location_t> &arg_loc,
    4467              :                            tree function, vec<tree, va_gc> *params,
    4468              :                            vec<tree, va_gc> *origtypes)
    4469              : {
    4470              :   /* Strip NON_LVALUE_EXPRs, etc., since we aren't using as an lvalue.  */
    4471     49908058 :   STRIP_TYPE_NOPS (function);
    4472              : 
    4473              :   /* Convert anything with function type to a pointer-to-function.  */
    4474     49908047 :   if (TREE_CODE (function) == FUNCTION_DECL)
    4475              :     {
    4476              :       /* Implement type-directed function overloading for builtins.
    4477              :          resolve_overloaded_builtin and targetm.resolve_overloaded_builtin
    4478              :          handle all the type checking.  The result is a complete expression
    4479              :          that implements this function call.  */
    4480     49830567 :       tree tem = resolve_overloaded_builtin (loc, function, params);
    4481     49830567 :       if (tem)
    4482              :         return tem;
    4483              :     }
    4484     49822096 :   return build_function_call_vec (loc, arg_loc, function, params, origtypes);
    4485              : }
    4486              : 
    4487              : /* Helper for convert_arguments called to convert the VALue of argument
    4488              :    number ARGNUM from ORIGTYPE to the corresponding parameter number
    4489              :    PARMNUM and TYPE.
    4490              :    PLOC is the location where the conversion is being performed.
    4491              :    FUNCTION and FUNDECL are the same as in convert_arguments.
    4492              :    VALTYPE is the original type of VAL before the conversion and,
    4493              :    for EXCESS_PRECISION_EXPR, the operand of the expression.
    4494              :    NPC is true if VAL represents the null pointer constant (VAL itself
    4495              :    will have been folded to an integer constant).
    4496              :    RNAME is the same as FUNCTION except in Objective C when it's
    4497              :    the function selector.
    4498              :    EXCESS_PRECISION is true when VAL was originally represented
    4499              :    as EXCESS_PRECISION_EXPR.
    4500              :    WARNOPT is the same as in convert_for_assignment.  */
    4501              : 
    4502              : static tree
    4503    125620230 : convert_argument (location_t ploc, tree function, tree fundecl,
    4504              :                   tree type, tree origtype, tree val, tree valtype,
    4505              :                   bool npc, tree rname, int parmnum, int argnum,
    4506              :                   bool excess_precision, int warnopt)
    4507              : {
    4508              :   /* Formal parm type is specified by a function prototype.  */
    4509              : 
    4510    125620230 :   if (type == error_mark_node || !COMPLETE_TYPE_P (type))
    4511              :     {
    4512            3 :       error_at (ploc, "type of formal parameter %d is incomplete",
    4513              :                 parmnum + 1);
    4514            3 :       return error_mark_node;
    4515              :     }
    4516              : 
    4517              :   /* Optionally warn about conversions that differ from the default
    4518              :      conversions.  */
    4519    125620227 :   if (warn_traditional_conversion || warn_traditional)
    4520              :     {
    4521          193 :       if (INTEGRAL_TYPE_P (type)
    4522          107 :           && SCALAR_FLOAT_TYPE_P (valtype))
    4523           19 :         warning_at (ploc, OPT_Wtraditional_conversion,
    4524              :                     "passing argument %d of %qE as integer rather "
    4525              :                     "than floating due to prototype",
    4526              :                     argnum, rname);
    4527          193 :       if (INTEGRAL_TYPE_P (type)
    4528          107 :           && TREE_CODE (valtype) == COMPLEX_TYPE)
    4529            5 :         warning_at (ploc, OPT_Wtraditional_conversion,
    4530              :                     "passing argument %d of %qE as integer rather "
    4531              :                     "than complex due to prototype",
    4532              :                     argnum, rname);
    4533          188 :       else if (TREE_CODE (type) == COMPLEX_TYPE
    4534           14 :                && SCALAR_FLOAT_TYPE_P (valtype))
    4535            7 :         warning_at (ploc, OPT_Wtraditional_conversion,
    4536              :                     "passing argument %d of %qE as complex rather "
    4537              :                     "than floating due to prototype",
    4538              :                     argnum, rname);
    4539          181 :       else if (SCALAR_FLOAT_TYPE_P (type)
    4540           71 :                && INTEGRAL_TYPE_P (valtype))
    4541           19 :         warning_at (ploc, OPT_Wtraditional_conversion,
    4542              :                     "passing argument %d of %qE as floating rather "
    4543              :                     "than integer due to prototype",
    4544              :                     argnum, rname);
    4545          162 :       else if (TREE_CODE (type) == COMPLEX_TYPE
    4546            7 :                && INTEGRAL_TYPE_P (valtype))
    4547            5 :         warning_at (ploc, OPT_Wtraditional_conversion,
    4548              :                     "passing argument %d of %qE as complex rather "
    4549              :                     "than integer due to prototype",
    4550              :                     argnum, rname);
    4551          157 :       else if (SCALAR_FLOAT_TYPE_P (type)
    4552           52 :                && TREE_CODE (valtype) == COMPLEX_TYPE)
    4553            7 :         warning_at (ploc, OPT_Wtraditional_conversion,
    4554              :                     "passing argument %d of %qE as floating rather "
    4555              :                     "than complex due to prototype",
    4556              :                     argnum, rname);
    4557              :       /* ??? At some point, messages should be written about
    4558              :          conversions between complex types, but that's too messy
    4559              :          to do now.  */
    4560          150 :       else if (SCALAR_FLOAT_TYPE_P (type)
    4561           45 :                && SCALAR_FLOAT_TYPE_P (valtype))
    4562              :         {
    4563           45 :           unsigned int formal_prec = TYPE_PRECISION (type);
    4564              : 
    4565              :           /* Warn if any argument is passed as `float',
    4566              :              since without a prototype it would be `double'.  */
    4567           45 :           if (formal_prec == TYPE_PRECISION (float_type_node)
    4568           45 :               && type != dfloat32_type_node)
    4569            7 :             warning_at (ploc, 0,
    4570              :                         "passing argument %d of %qE as %<float%> "
    4571              :                         "rather than %<double%> due to prototype",
    4572              :                         argnum, rname);
    4573              : 
    4574              :           /* Warn if mismatch between argument and prototype
    4575              :              for decimal float types.  Warn of conversions with
    4576              :              binary float types and of precision narrowing due to
    4577              :              prototype.  */
    4578           38 :           else if (type != valtype
    4579           32 :                    && (type == dfloat32_type_node
    4580           22 :                        || type == dfloat64_type_node
    4581           12 :                        || type == dfloat128_type_node
    4582            2 :                        || valtype == dfloat32_type_node
    4583            2 :                        || valtype == dfloat64_type_node
    4584            2 :                        || valtype == dfloat128_type_node)
    4585           38 :                    && (formal_prec
    4586           30 :                        <= TYPE_PRECISION (valtype)
    4587           14 :                        || (type == dfloat128_type_node
    4588           10 :                            && (valtype
    4589           10 :                                != dfloat64_type_node
    4590            8 :                                && (valtype
    4591              :                                    != dfloat32_type_node)))
    4592            8 :                        || (type == dfloat64_type_node
    4593            4 :                            && (valtype
    4594              :                                != dfloat32_type_node))))
    4595           24 :             warning_at (ploc, 0,
    4596              :                         "passing argument %d of %qE as %qT "
    4597              :                         "rather than %qT due to prototype",
    4598              :                         argnum, rname, type, valtype);
    4599              : 
    4600              :         }
    4601              :       /* Detect integer changing in width or signedness.
    4602              :          These warnings are only activated with
    4603              :          -Wtraditional-conversion, not with -Wtraditional.  */
    4604          105 :       else if (warn_traditional_conversion
    4605          105 :                && INTEGRAL_TYPE_P (type)
    4606          102 :                && INTEGRAL_TYPE_P (valtype))
    4607              :         {
    4608           83 :           unsigned int formal_prec = TYPE_PRECISION (type);
    4609           83 :           tree would_have_been = default_conversion (val);
    4610           83 :           tree type1 = TREE_TYPE (would_have_been);
    4611              : 
    4612           83 :           if (val == error_mark_node)
    4613              :             /* VAL could have been of incomplete type.  */;
    4614           83 :           else if (TREE_CODE (type) == ENUMERAL_TYPE
    4615           83 :                    && (TYPE_MAIN_VARIANT (type)
    4616            2 :                        == TYPE_MAIN_VARIANT (valtype)))
    4617              :             /* No warning if function asks for enum
    4618              :                and the actual arg is that enum type.  */
    4619              :             ;
    4620           81 :           else if (formal_prec != TYPE_PRECISION (type1))
    4621           14 :             warning_at (ploc, OPT_Wtraditional_conversion,
    4622              :                         "passing argument %d of %qE "
    4623              :                         "with different width due to prototype",
    4624              :                         argnum, rname);
    4625           67 :           else if (TYPE_UNSIGNED (type) == TYPE_UNSIGNED (type1))
    4626              :             ;
    4627              :           /* Don't complain if the formal parameter type
    4628              :              is an enum, because we can't tell now whether
    4629              :              the value was an enum--even the same enum.  */
    4630           32 :           else if (TREE_CODE (type) == ENUMERAL_TYPE)
    4631              :             ;
    4632           32 :           else if (TREE_CODE (val) == INTEGER_CST
    4633            5 :                    && int_fits_type_p (val, type))
    4634              :             /* Change in signedness doesn't matter
    4635              :                if a constant value is unaffected.  */
    4636              :             ;
    4637              :           /* If the value is extended from a narrower
    4638              :              unsigned type, it doesn't matter whether we
    4639              :              pass it as signed or unsigned; the value
    4640              :              certainly is the same either way.  */
    4641           32 :           else if (TYPE_PRECISION (valtype) < TYPE_PRECISION (type)
    4642           32 :                    && TYPE_UNSIGNED (valtype))
    4643              :             ;
    4644           32 :           else if (TYPE_UNSIGNED (type))
    4645           17 :             warning_at (ploc, OPT_Wtraditional_conversion,
    4646              :                         "passing argument %d of %qE "
    4647              :                         "as unsigned due to prototype",
    4648              :                         argnum, rname);
    4649              :           else
    4650           15 :             warning_at (ploc, OPT_Wtraditional_conversion,
    4651              :                         "passing argument %d of %qE "
    4652              :                         "as signed due to prototype",
    4653              :                         argnum, rname);
    4654              :         }
    4655              :     }
    4656              : 
    4657              :   /* Possibly restore an EXCESS_PRECISION_EXPR for the
    4658              :      sake of better warnings from convert_and_check.  */
    4659    125620227 :   if (excess_precision)
    4660          380 :     val = build1 (EXCESS_PRECISION_EXPR, valtype, val);
    4661              : 
    4662    125620227 :   tree parmval = convert_for_assignment (ploc, ploc, type,
    4663              :                                          val, origtype, ic_argpass,
    4664              :                                          npc, fundecl, function,
    4665              :                                          parmnum + 1, warnopt);
    4666    125620227 :   return parmval;
    4667              : }
    4668              : 
    4669              : /* Convert the argument expressions in the vector VALUES
    4670              :    to the types in the list TYPE_ARG_TYPES (FNTYPE).
    4671              : 
    4672              :    If the list is exhausted, or when an element has NULL as its type,
    4673              :    perform the default conversions.
    4674              : 
    4675              :    ORIGTYPES is the original types of the expressions in VALUES.  This
    4676              :    holds the type of enum values which have been converted to integral
    4677              :    types.  It may be NULL.
    4678              : 
    4679              :    FUNCTION is a tree for the called function.  It is used only for
    4680              :    error messages, where it is formatted with %qE.
    4681              : 
    4682              :    This is also where warnings about wrong number of args are generated.
    4683              : 
    4684              :    ARG_LOC are locations of function arguments (if any).
    4685              : 
    4686              :    Returns the actual number of arguments processed (which may be less
    4687              :    than the length of VALUES in some error situations), or -1 on
    4688              :    failure.  */
    4689              : 
    4690              : static int
    4691     49908448 : convert_arguments (location_t loc, vec<location_t> arg_loc, tree fntype,
    4692              :                    vec<tree, va_gc> *values, vec<tree, va_gc> *origtypes,
    4693              :                    tree function, tree fundecl)
    4694              : {
    4695     49908448 :   tree typelist = TYPE_ARG_TYPES (fntype);
    4696     49908448 :   unsigned int parmnum;
    4697     49908448 :   bool error_args = false;
    4698     49908448 :   const bool type_generic = fundecl
    4699     49908448 :     && lookup_attribute ("type generic", TYPE_ATTRIBUTES (TREE_TYPE (fundecl)));
    4700     49908448 :   bool type_generic_remove_excess_precision = false;
    4701     49908448 :   bool type_generic_overflow_p = false;
    4702     49908448 :   bool type_generic_bit_query = false;
    4703     49908448 :   tree selector;
    4704              : 
    4705              :   /* Change pointer to function to the function itself for
    4706              :      diagnostics.  */
    4707     49908448 :   if (TREE_CODE (function) == ADDR_EXPR
    4708     49908448 :       && TREE_CODE (TREE_OPERAND (function, 0)) == FUNCTION_DECL)
    4709     49833108 :     function = TREE_OPERAND (function, 0);
    4710              : 
    4711              :   /* Handle an ObjC selector specially for diagnostics.  */
    4712     49908448 :   selector = objc_message_selector ();
    4713              : 
    4714              :   /* For a call to a built-in function declared without a prototype,
    4715              :      set to the built-in function's argument list.  */
    4716     49908448 :   tree builtin_typelist = NULL_TREE;
    4717              : 
    4718              :   /* For type-generic built-in functions, determine whether excess
    4719              :      precision should be removed (classification) or not
    4720              :      (comparison).  */
    4721     49908448 :   if (fundecl
    4722     49908448 :       && fndecl_built_in_p (fundecl, BUILT_IN_NORMAL))
    4723              :     {
    4724      1404632 :       built_in_function code = DECL_FUNCTION_CODE (fundecl);
    4725      1404632 :       if (C_DECL_BUILTIN_PROTOTYPE (fundecl))
    4726              :         {
    4727              :           /* For a call to a built-in function declared without a prototype
    4728              :              use the types of the parameters of the internal built-in to
    4729              :              match those of the arguments to.  */
    4730       691773 :           if (tree bdecl = builtin_decl_explicit (code))
    4731       691773 :             builtin_typelist = TYPE_ARG_TYPES (TREE_TYPE (bdecl));
    4732              :         }
    4733              : 
    4734              :       /* For type-generic built-in functions, determine whether excess
    4735              :          precision should be removed (classification) or not
    4736              :          (comparison).  */
    4737      1404632 :       if (type_generic)
    4738        60924 :         switch (code)
    4739              :           {
    4740         5399 :           case BUILT_IN_ISFINITE:
    4741         5399 :           case BUILT_IN_ISINF:
    4742         5399 :           case BUILT_IN_ISINF_SIGN:
    4743         5399 :           case BUILT_IN_ISNAN:
    4744         5399 :           case BUILT_IN_ISNORMAL:
    4745         5399 :           case BUILT_IN_ISSIGNALING:
    4746         5399 :           case BUILT_IN_FPCLASSIFY:
    4747         5399 :             type_generic_remove_excess_precision = true;
    4748         5399 :             break;
    4749              : 
    4750        21026 :           case BUILT_IN_ADD_OVERFLOW_P:
    4751        21026 :           case BUILT_IN_SUB_OVERFLOW_P:
    4752        21026 :           case BUILT_IN_MUL_OVERFLOW_P:
    4753              :             /* The last argument of these type-generic builtins
    4754              :                should not be promoted.  */
    4755        21026 :             type_generic_overflow_p = true;
    4756        21026 :             break;
    4757              : 
    4758         1302 :           case BUILT_IN_CLZG:
    4759         1302 :           case BUILT_IN_CTZG:
    4760         1302 :           case BUILT_IN_CLRSBG:
    4761         1302 :           case BUILT_IN_FFSG:
    4762         1302 :           case BUILT_IN_PARITYG:
    4763         1302 :           case BUILT_IN_POPCOUNTG:
    4764              :             /* The first argument of these type-generic builtins
    4765              :                should not be promoted.  */
    4766         1302 :             type_generic_bit_query = true;
    4767         1302 :             break;
    4768              : 
    4769              :           default:
    4770              :             break;
    4771              :           }
    4772              :     }
    4773              : 
    4774              :   /* Scan the given expressions (VALUES) and types (TYPELIST), producing
    4775              :      individual converted arguments.  */
    4776              : 
    4777     49908448 :   tree typetail, builtin_typetail, val;
    4778     49908448 :   for (typetail = typelist,
    4779     49908448 :          builtin_typetail = builtin_typelist,
    4780     49908448 :          parmnum = 0;
    4781    176466255 :        values && values->iterate (parmnum, &val);
    4782              :        ++parmnum)
    4783              :     {
    4784              :       /* The type of the function parameter (if it was declared with one).  */
    4785    252176187 :       tree type = typetail ? TREE_VALUE (typetail) : NULL_TREE;
    4786              :       /* The type of the built-in function parameter (if the function
    4787              :          is a built-in).  Used to detect type incompatibilities in
    4788              :          calls to built-ins declared without a prototype.  */
    4789    126557843 :       tree builtin_type = (builtin_typetail
    4790    127596528 :                            ? TREE_VALUE (builtin_typetail) : NULL_TREE);
    4791              :       /* The original type of the argument being passed to the function.  */
    4792    126557843 :       tree valtype = TREE_TYPE (val);
    4793              :       /* The called function (or function selector in Objective C).  */
    4794    126557843 :       tree rname = function;
    4795    126557843 :       int argnum = parmnum + 1;
    4796    126557843 :       const char *invalid_func_diag;
    4797              :       /* Set for EXCESS_PRECISION_EXPR arguments.  */
    4798    126557843 :       bool excess_precision = false;
    4799              :       /* The value of the argument after conversion to the type
    4800              :          of the function parameter it is passed to.  */
    4801    126557843 :       tree parmval;
    4802              :       /* Some __atomic_* builtins have additional hidden argument at
    4803              :          position 0.  */
    4804    126557843 :       location_t ploc
    4805    126288995 :         = !arg_loc.is_empty () && values->length () == arg_loc.length ()
    4806    126288395 :           ? expansion_point_location_if_in_system_header (arg_loc[parmnum])
    4807    126557843 :           : input_location;
    4808              : 
    4809    126557843 :       if (type == void_type_node)
    4810              :         {
    4811           33 :           auto_diagnostic_group d;
    4812           33 :           int num_expected = parmnum;
    4813           33 :           int num_actual = values->length ();
    4814           33 :           gcc_rich_location rich_loc (loc);
    4815           33 :           if (ploc != input_location)
    4816           32 :             rich_loc.add_range (ploc);
    4817           33 :           if (selector)
    4818            0 :             error_at (&rich_loc,
    4819              :                       "too many arguments to method %qE; expected %i, have %i",
    4820              :                       selector, num_expected, num_actual);
    4821              :           else
    4822           33 :             error_at (&rich_loc,
    4823              :                       "too many arguments to function %qE; expected %i, have %i",
    4824              :                       function, num_expected, num_actual);
    4825           33 :           inform_declaration (fundecl, function);
    4826           65 :           return error_args ? -1 : (int) parmnum;
    4827           33 :         }
    4828              : 
    4829    126557810 :       if (builtin_type == void_type_node)
    4830              :         {
    4831           12 :           auto_diagnostic_group d;
    4832           12 :           if (warning_at (loc, OPT_Wbuiltin_declaration_mismatch,
    4833              :                           "too many arguments to built-in function %qE "
    4834              :                           "expecting %d", function, parmnum))
    4835           12 :             inform_declaration (fundecl, function);
    4836           12 :           builtin_typetail = NULL_TREE;
    4837           12 :         }
    4838              : 
    4839        90447 :       if (!typetail && parmnum == 0 && !TYPE_NO_NAMED_ARGS_STDARG_P (fntype)
    4840    126648138 :           && !(fundecl && fndecl_built_in_p (fundecl)))
    4841              :         {
    4842         6962 :           auto_diagnostic_group d;
    4843         6962 :           bool warned;
    4844         6962 :           if (selector)
    4845            0 :             warned = warning_at (loc, OPT_Wdeprecated_non_prototype,
    4846              :                                  "ISO C23 does not allow arguments"
    4847              :                                  " for method %qE declared without parameters",
    4848              :                                  function);
    4849              :           else
    4850         6962 :             warned = warning_at (loc, OPT_Wdeprecated_non_prototype,
    4851              :                                  "ISO C23 does not allow arguments"
    4852              :                                  " for function %qE declared without parameters",
    4853              :                                  function);
    4854         6962 :           if (warned)
    4855            4 :             inform_declaration (fundecl, function);
    4856         6962 :         }
    4857              : 
    4858    126557810 :       if (selector && argnum > 2)
    4859              :         {
    4860            0 :           rname = selector;
    4861            0 :           argnum -= 2;
    4862              :         }
    4863              : 
    4864              :       /* Determine if VAL is a null pointer constant before folding it.  */
    4865    126557810 :       bool npc = null_pointer_constant_p (val);
    4866              : 
    4867              :       /* If there is excess precision and a prototype, convert once to
    4868              :          the required type rather than converting via the semantic
    4869              :          type.  Likewise without a prototype a float value represented
    4870              :          as long double should be converted once to double.  But for
    4871              :          type-generic classification functions excess precision must
    4872              :          be removed here.  */
    4873    126557810 :       if (TREE_CODE (val) == EXCESS_PRECISION_EXPR
    4874          433 :           && (type || !type_generic || !type_generic_remove_excess_precision))
    4875              :         {
    4876          413 :           val = TREE_OPERAND (val, 0);
    4877          413 :           excess_precision = true;
    4878              :         }
    4879    126557810 :       val = c_fully_fold (val, false, NULL);
    4880    253115621 :       STRIP_TYPE_NOPS (val);
    4881              : 
    4882    126557810 :       val = require_complete_type (ploc, val);
    4883              : 
    4884              :       /* Some floating-point arguments must be promoted to double when
    4885              :          no type is specified by a prototype.  This applies to
    4886              :          arguments of type float, and to architecture-specific types
    4887              :          (ARM __fp16), but not to _FloatN or _FloatNx types.  */
    4888    126557810 :       bool promote_float_arg = false;
    4889    126557810 :       if (type == NULL_TREE
    4890       939499 :           && TREE_CODE (valtype) == REAL_TYPE
    4891       269595 :           && (TYPE_PRECISION (valtype)
    4892       269595 :               <= TYPE_PRECISION (double_type_node))
    4893       262349 :           && TYPE_MAIN_VARIANT (valtype) != double_type_node
    4894       131373 :           && TYPE_MAIN_VARIANT (valtype) != long_double_type_node
    4895    126689183 :           && !DECIMAL_FLOAT_MODE_P (TYPE_MODE (valtype)))
    4896              :         {
    4897              :           /* Promote this argument, unless it has a _FloatN or
    4898              :              _FloatNx type.  */
    4899      1027486 :           promote_float_arg = true;
    4900      1027486 :           for (int i = 0; i < NUM_FLOATN_NX_TYPES; i++)
    4901       900123 :             if (TYPE_MAIN_VARIANT (valtype) == FLOATN_NX_TYPE_NODE (i))
    4902              :               {
    4903              :                 promote_float_arg = false;
    4904              :                 break;
    4905              :               }
    4906              :           /* Don't promote __bf16 either.  */
    4907       130640 :           if (TYPE_MAIN_VARIANT (valtype) == bfloat16_type_node)
    4908    126427240 :             promote_float_arg = false;
    4909              :         }
    4910              : 
    4911    126557810 :       if (type != NULL_TREE)
    4912              :         {
    4913    125618311 :           tree origtype = (!origtypes) ? NULL_TREE : (*origtypes)[parmnum];
    4914    125618311 :           parmval = convert_argument (ploc, function, fundecl, type, origtype,
    4915              :                                       val, valtype, npc, rname, parmnum, argnum,
    4916              :                                       excess_precision, 0);
    4917              :         }
    4918              :       /* A NULLPTR type is just a nullptr always.  */
    4919       939499 :       else if (TREE_CODE (TREE_TYPE (val)) == NULLPTR_TYPE)
    4920            9 :         parmval = omit_one_operand_loc (ploc, TREE_TYPE (val), nullptr_node, val);
    4921       939490 :       else if (promote_float_arg)
    4922              :         {
    4923       127293 :           if (type_generic)
    4924              :             parmval = val;
    4925              :           else
    4926              :             {
    4927              :               /* Convert `float' to `double'.  */
    4928       124522 :               if (warn_double_promotion && !c_inhibit_evaluation_warnings)
    4929            6 :                 warning_at (ploc, OPT_Wdouble_promotion,
    4930              :                             "implicit conversion from %qT to %qT when passing "
    4931              :                             "argument to function",
    4932              :                             valtype, double_type_node);
    4933       124522 :               parmval = convert (double_type_node, val);
    4934              :             }
    4935              :         }
    4936       812197 :       else if ((excess_precision && !type_generic)
    4937       812195 :                || (type_generic_overflow_p && parmnum == 2)
    4938       791173 :                || (type_generic_bit_query && parmnum == 0))
    4939              :         /* A "double" argument with excess precision being passed
    4940              :            without a prototype or in variable arguments.
    4941              :            The last argument of __builtin_*_overflow_p should not be
    4942              :            promoted, similarly the first argument of
    4943              :            __builtin_{clz,ctz,clrsb,ffs,parity,popcount}g.  */
    4944        22320 :         parmval = convert (valtype, val);
    4945      1579754 :       else if ((invalid_func_diag =
    4946       789877 :                 targetm.calls.invalid_arg_for_unprototyped_fn (typelist, fundecl, val)))
    4947              :         {
    4948            0 :           error (invalid_func_diag);
    4949            0 :           return -1;
    4950              :         }
    4951       789877 :       else if (TREE_CODE (val) == ADDR_EXPR && reject_gcc_builtin (val))
    4952              :         {
    4953              :           return -1;
    4954              :         }
    4955              :       else
    4956              :         /* Convert `short' and `char' to full-size `int'.  */
    4957       789874 :         parmval = default_conversion (val);
    4958              : 
    4959    126557807 :       (*values)[parmnum] = parmval;
    4960    126557807 :       if (parmval == error_mark_node)
    4961          105 :         error_args = true;
    4962              : 
    4963    126557807 :       if (!type && builtin_type && TREE_CODE (builtin_type) != VOID_TYPE)
    4964              :         {
    4965              :           /* For a call to a built-in function declared without a prototype,
    4966              :              perform the conversions from the argument to the expected type
    4967              :              but issue warnings rather than errors for any mismatches.
    4968              :              Ignore the converted argument and use the PARMVAL obtained
    4969              :              above by applying default conversions instead.  */
    4970         1919 :           tree origtype = (!origtypes) ? NULL_TREE : (*origtypes)[parmnum];
    4971         1919 :           convert_argument (ploc, function, fundecl, builtin_type, origtype,
    4972              :                             val, valtype, npc, rname, parmnum, argnum,
    4973              :                             excess_precision,
    4974              :                             OPT_Wbuiltin_declaration_mismatch);
    4975              :         }
    4976              : 
    4977    126557807 :       if (typetail)
    4978    125618311 :         typetail = TREE_CHAIN (typetail);
    4979              : 
    4980    126557807 :       if (builtin_typetail)
    4981      1038668 :         builtin_typetail = TREE_CHAIN (builtin_typetail);
    4982              :     }
    4983              : 
    4984     88099768 :   gcc_assert (parmnum == vec_safe_length (values));
    4985              : 
    4986     99484195 :   if (typetail != NULL_TREE && TREE_VALUE (typetail) != void_type_node)
    4987              :     {
    4988              :       /* Not enough args.
    4989              :          Determine minimum number of arguments required.  */
    4990              :       int min_expected_num = 0;
    4991          231 :       bool at_least_p = false;
    4992              :       tree iter = typelist;
    4993          386 :       while (true)
    4994              :         {
    4995          231 :           if (!iter)
    4996              :             {
    4997              :               /* Variadic arguments; stop iterating.  */
    4998              :               at_least_p = true;
    4999              :               break;
    5000              :             }
    5001          222 :           if (iter == void_list_node)
    5002              :             /* End of arguments; stop iterating.  */
    5003              :             break;
    5004          155 :           ++min_expected_num;
    5005          155 :           iter = TREE_CHAIN (iter);
    5006              :         }
    5007           76 :       auto_diagnostic_group d;
    5008           76 :       int actual_num = vec_safe_length (values);
    5009          143 :       error_at (loc,
    5010              :                 at_least_p
    5011              :                 ? G_("too few arguments to function %qE; expected at least %i, have %i")
    5012              :                 : G_("too few arguments to function %qE; expected %i, have %i"),
    5013              :                 function, min_expected_num, actual_num);
    5014           76 :       inform_declaration (fundecl, function);
    5015           76 :       return -1;
    5016           76 :     }
    5017              : 
    5018     50563892 :   if (builtin_typetail && TREE_VALUE (builtin_typetail) != void_type_node)
    5019              :     {
    5020              :       unsigned nargs = parmnum;
    5021          616 :       for (tree t = builtin_typetail; t; t = TREE_CHAIN (t))
    5022          428 :         ++nargs;
    5023              : 
    5024          188 :       auto_diagnostic_group d;
    5025          188 :       if (warning_at (loc, OPT_Wbuiltin_declaration_mismatch,
    5026              :                       "too few arguments to built-in function %qE "
    5027              :                       "expecting %u", function, nargs - 1))
    5028          173 :         inform_declaration (fundecl, function);
    5029          188 :     }
    5030              : 
    5031     49908336 :   return error_args ? -1 : (int) parmnum;
    5032              : }
    5033              : 
    5034              : /* This is the entry point used by the parser to build unary operators
    5035              :    in the input.  CODE, a tree_code, specifies the unary operator, and
    5036              :    ARG is the operand.  For unary plus, the C parser currently uses
    5037              :    CONVERT_EXPR for code.
    5038              : 
    5039              :    LOC is the location to use for the tree generated.
    5040              : */
    5041              : 
    5042              : struct c_expr
    5043      8168317 : parser_build_unary_op (location_t loc, enum tree_code code, struct c_expr arg)
    5044              : {
    5045      8168317 :   struct c_expr result;
    5046              : 
    5047      8168317 :   result.original_code = code;
    5048      8168317 :   result.original_type = NULL;
    5049      8168317 :   result.m_decimal = 0;
    5050              : 
    5051      8168317 :   if (reject_gcc_builtin (arg.value))
    5052              :     {
    5053            2 :       result.value = error_mark_node;
    5054              :     }
    5055              :   else
    5056              :     {
    5057      8168315 :       result.value = build_unary_op (loc, code, arg.value, false);
    5058              : 
    5059      8168315 :       if (TREE_OVERFLOW_P (result.value) && !TREE_OVERFLOW_P (arg.value))
    5060            5 :         overflow_warning (loc, result.value, arg.value);
    5061              :     }
    5062              : 
    5063              :   /* We are typically called when parsing a prefix token at LOC acting on
    5064              :      ARG.  Reflect this by updating the source range of the result to
    5065              :      start at LOC and end at the end of ARG.  */
    5066      8168317 :   set_c_expr_source_range (&result,
    5067              :                            loc, arg.get_finish ());
    5068              : 
    5069      8168317 :   return result;
    5070              : }
    5071              : 
    5072              : /* Returns true if TYPE is a character type, *not* including wchar_t.  */
    5073              : 
    5074              : bool
    5075      1267629 : char_type_p (tree type)
    5076              : {
    5077      1267629 :   return (type == char_type_node
    5078       977253 :           || type == unsigned_char_type_node
    5079       958198 :           || type == signed_char_type_node
    5080       957350 :           || type == char16_type_node
    5081      2004693 :           || type == char32_type_node);
    5082              : }
    5083              : 
    5084              : /* This is the entry point used by the parser to build binary operators
    5085              :    in the input.  CODE, a tree_code, specifies the binary operator, and
    5086              :    ARG1 and ARG2 are the operands.  In addition to constructing the
    5087              :    expression, we check for operands that were written with other binary
    5088              :    operators in a way that is likely to confuse the user.  ORIG_ARG1 is
    5089              :    the original first operand for TRUTH_{AND,OR}IF_EXPR before it is
    5090              :    converted to truth value, otherwise NULL_TREE.
    5091              : 
    5092              :    LOCATION is the location of the binary operator.  */
    5093              : 
    5094              : struct c_expr
    5095      9333801 : parser_build_binary_op (location_t location, enum tree_code code,
    5096              :                         struct c_expr arg1, struct c_expr arg2, tree orig_arg1)
    5097              : {
    5098      9333801 :   struct c_expr result;
    5099      9333801 :   result.m_decimal = 0;
    5100              : 
    5101      9333801 :   enum tree_code code1 = arg1.original_code;
    5102      9333801 :   enum tree_code code2 = arg2.original_code;
    5103      9333801 :   tree type1 = (arg1.original_type
    5104      9333801 :                 ? arg1.original_type
    5105      5991454 :                 : TREE_TYPE (arg1.value));
    5106      9333801 :   tree type2 = (arg2.original_type
    5107      9333801 :                 ? arg2.original_type
    5108      6887832 :                 : TREE_TYPE (arg2.value));
    5109              : 
    5110      9333801 :   result.value = build_binary_op (location, code,
    5111              :                                   arg1.value, arg2.value, true);
    5112      9333800 :   result.original_code = code;
    5113      9333800 :   result.original_type = NULL;
    5114      9333800 :   result.m_decimal = 0;
    5115              : 
    5116      9333800 :   if (TREE_CODE (result.value) == ERROR_MARK)
    5117              :     {
    5118         1297 :       set_c_expr_source_range (&result,
    5119              :                                arg1.get_start (),
    5120              :                                arg2.get_finish ());
    5121         1297 :       return result;
    5122              :     }
    5123              : 
    5124      9332503 :   if (location != UNKNOWN_LOCATION)
    5125      9332503 :     protected_set_expr_location (result.value, location);
    5126              : 
    5127      9332503 :   set_c_expr_source_range (&result,
    5128              :                            arg1.get_start (),
    5129              :                            arg2.get_finish ());
    5130              : 
    5131              :   /* Check for cases such as x+y<<z which users are likely
    5132              :      to misinterpret.  */
    5133      9332503 :   if (warn_parentheses)
    5134      2009039 :     warn_about_parentheses (location, code, code1, arg1.value, code2,
    5135              :                             arg2.value);
    5136              : 
    5137      9332503 :   if (warn_logical_op)
    5138          340 :     warn_logical_operator (location, code, TREE_TYPE (result.value),
    5139              :                            code1, arg1.value, code2, arg2.value);
    5140              : 
    5141      9332503 :   if (warn_constant_logical_operand
    5142      2007454 :       && (code == TRUTH_ANDIF_EXPR || code == TRUTH_ORIF_EXPR)
    5143        74202 :       && INTEGRAL_NB_TYPE_P (type1)
    5144        72440 :       && INTEGRAL_NB_TYPE_P (type2))
    5145              :     {
    5146        70887 :       const char *name = code == TRUTH_ANDIF_EXPR ? "&&" : "||";
    5147        70887 :       if (orig_arg1 == NULL_TREE)
    5148            0 :         orig_arg1 = arg1.value;
    5149        76284 :       auto enum_other_than_0_1 = [] (tree type) {
    5150         5397 :         if (TREE_CODE (type) != ENUMERAL_TYPE)
    5151              :           return false;
    5152           48 :         for (tree l = TYPE_VALUES (type); l; l = TREE_CHAIN (l))
    5153              :           {
    5154           40 :             tree v = DECL_INITIAL (TREE_VALUE (l));
    5155           40 :             if (!integer_zerop (v) && !integer_onep (v))
    5156              :               return true;
    5157              :           }
    5158              :         return false;
    5159              :       };
    5160       212645 :       auto diagnose_constant_logical_operand = [=] (tree val, tree type) {
    5161       141758 :         if (TREE_CODE (val) != INTEGER_CST || integer_zerop (val))
    5162       136337 :           return false;
    5163         5421 :         if (integer_onep (val) && !enum_other_than_0_1 (type))
    5164              :           return false;
    5165           32 :         gcc_rich_location richloc (location);
    5166           32 :         richloc.add_fixit_replace (name + 1);
    5167           32 :         auto_diagnostic_group d;
    5168           32 :         if (warning_at (location, OPT_Wconstant_logical_operand,
    5169              :                         "use of logical %qs with constant operand %qE",
    5170              :                         name, val))
    5171           32 :           inform (&richloc, "use %qs for bitwise operation", name + 1);
    5172           32 :         return true;
    5173           32 :       };
    5174        70887 :       if (!diagnose_constant_logical_operand (arg2.value, type2))
    5175        70871 :         diagnose_constant_logical_operand (orig_arg1, type1);
    5176              :     }
    5177              : 
    5178      9332503 :   if (warn_tautological_compare)
    5179              :     {
    5180      2007552 :       tree lhs = arg1.value;
    5181      2007552 :       tree rhs = arg2.value;
    5182      2007552 :       if (TREE_CODE (lhs) == C_MAYBE_CONST_EXPR)
    5183              :         {
    5184            2 :           if (C_MAYBE_CONST_EXPR_PRE (lhs) != NULL_TREE
    5185            2 :               && TREE_SIDE_EFFECTS (C_MAYBE_CONST_EXPR_PRE (lhs)))
    5186              :             lhs = NULL_TREE;
    5187              :           else
    5188            2 :             lhs = C_MAYBE_CONST_EXPR_EXPR (lhs);
    5189              :         }
    5190      2007552 :       if (TREE_CODE (rhs) == C_MAYBE_CONST_EXPR)
    5191              :         {
    5192           12 :           if (C_MAYBE_CONST_EXPR_PRE (rhs) != NULL_TREE
    5193           12 :               && TREE_SIDE_EFFECTS (C_MAYBE_CONST_EXPR_PRE (rhs)))
    5194              :             rhs = NULL_TREE;
    5195              :           else
    5196           12 :             rhs = C_MAYBE_CONST_EXPR_EXPR (rhs);
    5197              :         }
    5198      2007552 :       if (lhs != NULL_TREE && rhs != NULL_TREE)
    5199      2007552 :         warn_tautological_cmp (location, code, lhs, rhs);
    5200              :     }
    5201              : 
    5202      9332503 :   if (warn_logical_not_paren
    5203      2007635 :       && TREE_CODE_CLASS (code) == tcc_comparison
    5204       409100 :       && code1 == TRUTH_NOT_EXPR
    5205       409100 :       && code2 != TRUTH_NOT_EXPR
    5206              :       /* Avoid warning for !!x == y.  */
    5207      9332629 :       && (TREE_CODE (arg1.value) != NE_EXPR
    5208           19 :           || !integer_zerop (TREE_OPERAND (arg1.value, 1))))
    5209              :     {
    5210              :       /* Avoid warning for !b == y where b has _Bool type.  */
    5211          107 :       tree t = integer_zero_node;
    5212          107 :       if (TREE_CODE (arg1.value) == EQ_EXPR
    5213           98 :           && integer_zerop (TREE_OPERAND (arg1.value, 1))
    5214          205 :           && TREE_TYPE (TREE_OPERAND (arg1.value, 0)) == integer_type_node)
    5215              :         {
    5216           90 :           t = TREE_OPERAND (arg1.value, 0);
    5217          199 :           do
    5218              :             {
    5219          199 :               if (TREE_TYPE (t) != integer_type_node)
    5220              :                 break;
    5221          180 :               if (TREE_CODE (t) == C_MAYBE_CONST_EXPR)
    5222           90 :                 t = C_MAYBE_CONST_EXPR_EXPR (t);
    5223           90 :               else if (CONVERT_EXPR_P (t))
    5224           19 :                 t = TREE_OPERAND (t, 0);
    5225              :               else
    5226              :                 break;
    5227              :             }
    5228              :           while (1);
    5229              :         }
    5230          107 :       if (!C_BOOLEAN_TYPE_P (TREE_TYPE (t)))
    5231           88 :         warn_logical_not_parentheses (location, code, arg1.value, arg2.value);
    5232              :     }
    5233              : 
    5234              :   /* Warn about comparisons against string literals, with the exception
    5235              :      of testing for equality or inequality of a string literal with NULL.  */
    5236      9332503 :   if (code == EQ_EXPR || code == NE_EXPR)
    5237              :     {
    5238      1170314 :       if ((code1 == STRING_CST
    5239           16 :            && !integer_zerop (tree_strip_nop_conversions (arg2.value)))
    5240      1170325 :           || (code2 == STRING_CST
    5241           39 :               && !integer_zerop (tree_strip_nop_conversions (arg1.value))))
    5242           36 :         warning_at (location, OPT_Waddress,
    5243              :                     "comparison with string literal results in unspecified behavior");
    5244              :       /* Warn for ptr == '\0', it's likely that it should've been ptr[0].  */
    5245      1170314 :       if (POINTER_TYPE_P (type1)
    5246        90672 :           && null_pointer_constant_p (arg2.value)
    5247      1191414 :           && char_type_p (type2))
    5248              :         {
    5249           18 :           auto_diagnostic_group d;
    5250           18 :           if (warning_at (location, OPT_Wpointer_compare,
    5251              :                             "comparison between pointer and zero character "
    5252              :                             "constant"))
    5253           10 :             inform (arg1.get_start (),
    5254              :                       "did you mean to dereference the pointer?");
    5255           18 :         }
    5256      1170296 :       else if (POINTER_TYPE_P (type2)
    5257        87986 :                && null_pointer_constant_p (arg1.value)
    5258      1170566 :                && char_type_p (type1))
    5259              :         {
    5260           10 :           auto_diagnostic_group d;
    5261           10 :           if (warning_at (location, OPT_Wpointer_compare,
    5262              :                             "comparison between pointer and zero character "
    5263              :                             "constant"))
    5264           10 :             inform (arg2.get_start (),
    5265              :                       "did you mean to dereference the pointer?");
    5266           10 :         }
    5267              :     }
    5268      8162189 :   else if (TREE_CODE_CLASS (code) == tcc_comparison
    5269       997530 :            && (code1 == STRING_CST || code2 == STRING_CST))
    5270            0 :     warning_at (location, OPT_Waddress,
    5271              :                 "comparison with string literal results in unspecified "
    5272              :                 "behavior");
    5273              : 
    5274      9332503 :   if (warn_zero_as_null_pointer_constant
    5275           24 :       && c_inhibit_evaluation_warnings == 0
    5276           24 :       && TREE_CODE_CLASS (code) == tcc_comparison)
    5277              :     {
    5278           24 :       if ((TREE_CODE (type1) == POINTER_TYPE
    5279           17 :            || TREE_CODE (type1) == NULLPTR_TYPE)
    5280            9 :           && INTEGRAL_TYPE_P (type2)
    5281           33 :           && null_pointer_constant_p (arg2.value))
    5282            9 :         warning_at (arg2.get_location(), OPT_Wzero_as_null_pointer_constant,
    5283              :                     "zero as null pointer constant");
    5284              : 
    5285           24 :       if ((TREE_CODE (type2) == POINTER_TYPE
    5286           15 :            || TREE_CODE (type2) == NULLPTR_TYPE)
    5287           11 :           && INTEGRAL_TYPE_P (type1)
    5288           35 :           && null_pointer_constant_p (arg1.value))
    5289           11 :         warning_at (arg1.get_location(), OPT_Wzero_as_null_pointer_constant,
    5290              :                     "zero as null pointer constant");
    5291              :     }
    5292              : 
    5293      9332503 :   if (warn_array_compare
    5294      2007390 :       && TREE_CODE_CLASS (code) == tcc_comparison
    5295       408885 :       && TREE_CODE (type1) == ARRAY_TYPE
    5296           38 :       && TREE_CODE (type2) == ARRAY_TYPE)
    5297           15 :     do_warn_array_compare (location, code, arg1.value, arg2.value);
    5298              : 
    5299      2181684 :   if (TREE_OVERFLOW_P (result.value)
    5300          299 :       && !TREE_OVERFLOW_P (arg1.value)
    5301      9332795 :       && !TREE_OVERFLOW_P (arg2.value))
    5302          249 :     overflow_warning (location, result.value);
    5303              : 
    5304              :   /* Warn about comparisons of different enum types.  */
    5305      9332502 :   if (warn_enum_compare
    5306      2027380 :       && TREE_CODE_CLASS (code) == tcc_comparison
    5307       413310 :       && TREE_CODE (type1) == ENUMERAL_TYPE
    5308         7133 :       && TREE_CODE (type2) == ENUMERAL_TYPE
    5309      9339571 :       && TYPE_MAIN_VARIANT (type1) != TYPE_MAIN_VARIANT (type2))
    5310            2 :     warning_at (location, OPT_Wenum_compare,
    5311              :                 "comparison between %qT and %qT",
    5312              :                 type1, type2);
    5313              : 
    5314      9332502 :   if (warn_xor_used_as_pow
    5315      9332502 :       && code == BIT_XOR_EXPR
    5316        77164 :       && arg1.m_decimal
    5317          730 :       && arg2.m_decimal)
    5318          427 :     check_for_xor_used_as_pow (arg1.get_location (), arg1.value,
    5319              :                                location,
    5320              :                                arg2.get_location (), arg2.value);
    5321              : 
    5322              :   return result;
    5323              : }
    5324              : 
    5325              : /* Return a tree for the difference of pointers OP0 and OP1.
    5326              :    The resulting tree has type ptrdiff_t.  If POINTER_SUBTRACT sanitization is
    5327              :    enabled, assign to INSTRUMENT_EXPR call to libsanitizer.  */
    5328              : 
    5329              : static tree
    5330         3700 : pointer_diff (location_t loc, tree op0, tree op1, tree *instrument_expr)
    5331              : {
    5332         3700 :   tree restype = ptrdiff_type_node;
    5333         3700 :   tree result, inttype;
    5334              : 
    5335         3700 :   addr_space_t as0 = TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (op0)));
    5336         3700 :   addr_space_t as1 = TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (op1)));
    5337         3700 :   tree target_type = TREE_TYPE (TREE_TYPE (op0));
    5338         3700 :   tree orig_op0 = op0;
    5339         3700 :   tree orig_op1 = op1;
    5340              : 
    5341              :   /* If the operands point into different address spaces, we need to
    5342              :      explicitly convert them to pointers into the common address space
    5343              :      before we can subtract the numerical address values.  */
    5344         3700 :   if (as0 != as1)
    5345              :     {
    5346            0 :       addr_space_t as_common;
    5347            0 :       tree common_type;
    5348              : 
    5349              :       /* Determine the common superset address space.  This is guaranteed
    5350              :          to exist because the caller verified that comp_target_types
    5351              :          returned non-zero.  */
    5352            0 :       if (!addr_space_superset (as0, as1, &as_common))
    5353            0 :         gcc_unreachable ();
    5354              : 
    5355            0 :       common_type = common_pointer_type (TREE_TYPE (op0), TREE_TYPE (op1), NULL_TREE);
    5356            0 :       op0 = convert (common_type, op0);
    5357            0 :       op1 = convert (common_type, op1);
    5358              :     }
    5359              : 
    5360              :   /* Determine integer type result of the subtraction.  This will usually
    5361              :      be the same as the result type (ptrdiff_t), but may need to be a wider
    5362              :      type if pointers for the address space are wider than ptrdiff_t.  */
    5363         3700 :   if (TYPE_PRECISION (restype) < TYPE_PRECISION (TREE_TYPE (op0)))
    5364            0 :     inttype = c_common_type_for_size (TYPE_PRECISION (TREE_TYPE (op0)), 0);
    5365              :   else
    5366              :     inttype = restype;
    5367              : 
    5368         3700 :   if (VOID_TYPE_P (target_type))
    5369          146 :     pedwarn (loc, OPT_Wpointer_arith,
    5370              :              "pointer of type %<void *%> used in subtraction");
    5371         3700 :   if (TREE_CODE (target_type) == FUNCTION_TYPE)
    5372            4 :     pedwarn (loc, OPT_Wpointer_arith,
    5373              :              "pointer to a function used in subtraction");
    5374              : 
    5375         3700 :   if (current_function_decl != NULL_TREE
    5376         3700 :       && sanitize_flags_p (SANITIZE_POINTER_SUBTRACT))
    5377              :     {
    5378           70 :       op0 = save_expr (c_fully_fold (op0, false, NULL));
    5379           70 :       op1 = save_expr (c_fully_fold (op1, false, NULL));
    5380              : 
    5381           70 :       tree tt = builtin_decl_explicit (BUILT_IN_ASAN_POINTER_SUBTRACT);
    5382           70 :       *instrument_expr = build_call_expr_loc (loc, tt, 2, op0, op1);
    5383              :     }
    5384              : 
    5385              :   /* First do the subtraction, then build the divide operator
    5386              :      and only convert at the very end.
    5387              :      Do not do default conversions in case restype is a short type.  */
    5388              : 
    5389              :   /* POINTER_DIFF_EXPR requires a signed integer type of the same size as
    5390              :      pointers.  If some platform cannot provide that, or has a larger
    5391              :      ptrdiff_type to support differences larger than half the address
    5392              :      space, cast the pointers to some larger integer type and do the
    5393              :      computations in that type.  */
    5394         3700 :   if (TYPE_PRECISION (inttype) > TYPE_PRECISION (TREE_TYPE (op0)))
    5395            0 :     op0 = build_binary_op (loc, MINUS_EXPR, convert (inttype, op0),
    5396              :                            convert (inttype, op1), false);
    5397              :   else
    5398              :     {
    5399              :       /* Cast away qualifiers.  */
    5400         3700 :       op0 = convert (c_common_type (TREE_TYPE (op0), TREE_TYPE (op0)), op0);
    5401         3700 :       op1 = convert (c_common_type (TREE_TYPE (op1), TREE_TYPE (op1)), op1);
    5402         3700 :       op0 = build2_loc (loc, POINTER_DIFF_EXPR, inttype, op0, op1);
    5403              :     }
    5404              : 
    5405              :   /* This generates an error if op1 is pointer to incomplete type.  */
    5406         3700 :   if (!COMPLETE_OR_VOID_TYPE_P (TREE_TYPE (TREE_TYPE (orig_op1))))
    5407            4 :     error_at (loc, "arithmetic on pointer to an incomplete type");
    5408         3696 :   else if (verify_type_context (loc, TCTX_POINTER_ARITH,
    5409         3696 :                                 TREE_TYPE (TREE_TYPE (orig_op0))))
    5410         7392 :     verify_type_context (loc, TCTX_POINTER_ARITH,
    5411         3696 :                          TREE_TYPE (TREE_TYPE (orig_op1)));
    5412              : 
    5413         3700 :   op1 = c_size_in_bytes (target_type);
    5414              : 
    5415         3700 :   if (pointer_to_zero_sized_aggr_p (TREE_TYPE (orig_op1)))
    5416            4 :     error_at (loc, "arithmetic on pointer to an empty aggregate");
    5417              : 
    5418              :   /* Divide by the size, in easiest possible way.  */
    5419         3700 :   result = fold_build2_loc (loc, EXACT_DIV_EXPR, inttype,
    5420              :                             op0, convert (inttype, op1));
    5421              : 
    5422              :   /* Convert to final result type if necessary.  */
    5423         3700 :   return convert (restype, result);
    5424              : }
    5425              : 
    5426              : /* Expand atomic compound assignments into an appropriate sequence as
    5427              :    specified by the C11 standard section 6.5.16.2.
    5428              : 
    5429              :        _Atomic T1 E1
    5430              :        T2 E2
    5431              :        E1 op= E2
    5432              : 
    5433              :   This sequence is used for all types for which these operations are
    5434              :   supported.
    5435              : 
    5436              :   In addition, built-in versions of the 'fe' prefixed routines may
    5437              :   need to be invoked for floating point (real, complex or vector) when
    5438              :   floating-point exceptions are supported.  See 6.5.16.2 footnote 113.
    5439              : 
    5440              :   T1 newval;
    5441              :   T1 old;
    5442              :   T1 *addr
    5443              :   T2 val
    5444              :   fenv_t fenv
    5445              : 
    5446              :   addr = &E1;
    5447              :   val = (E2);
    5448              :   __atomic_load (addr, &old, SEQ_CST);
    5449              :   feholdexcept (&fenv);
    5450              : loop:
    5451              :     newval = old op val;
    5452              :     if (__atomic_compare_exchange_strong (addr, &old, &newval, SEQ_CST,
    5453              :                                           SEQ_CST))
    5454              :       goto done;
    5455              :     feclearexcept (FE_ALL_EXCEPT);
    5456              :     goto loop:
    5457              : done:
    5458              :   feupdateenv (&fenv);
    5459              : 
    5460              :   The compiler will issue the __atomic_fetch_* built-in when possible,
    5461              :   otherwise it will generate the generic form of the atomic operations.
    5462              :   This requires temp(s) and has their address taken.  The atomic processing
    5463              :   is smart enough to figure out when the size of an object can utilize
    5464              :   a lock-free version, and convert the built-in call to the appropriate
    5465              :   lock-free routine.  The optimizers will then dispose of any temps that
    5466              :   are no longer required, and lock-free implementations are utilized as
    5467              :   long as there is target support for the required size.
    5468              : 
    5469              :   If the operator is NOP_EXPR, then this is a simple assignment, and
    5470              :   an __atomic_store is issued to perform the assignment rather than
    5471              :   the above loop.  */
    5472              : 
    5473              : /* Build an atomic assignment at LOC, expanding into the proper
    5474              :    sequence to store LHS MODIFYCODE= RHS.  Return a value representing
    5475              :    the result of the operation, unless RETURN_OLD_P, in which case
    5476              :    return the old value of LHS (this is only for postincrement and
    5477              :    postdecrement).  */
    5478              : 
    5479              : static tree
    5480        30433 : build_atomic_assign (location_t loc, tree lhs, enum tree_code modifycode,
    5481              :                      tree rhs, bool return_old_p)
    5482              : {
    5483        30433 :   tree fndecl, func_call;
    5484        30433 :   vec<tree, va_gc> *params;
    5485        30433 :   tree val, nonatomic_lhs_type, nonatomic_rhs_type, newval, newval_addr;
    5486        30433 :   tree old, old_addr;
    5487        30433 :   tree compound_stmt = NULL_TREE;
    5488        30433 :   tree stmt, goto_stmt;
    5489        30433 :   tree loop_label, loop_decl, done_label, done_decl;
    5490              : 
    5491        30433 :   tree lhs_type = TREE_TYPE (lhs);
    5492        30433 :   tree lhs_addr = build_unary_op (loc, ADDR_EXPR, lhs, false);
    5493        30433 :   tree seq_cst = build_int_cst (integer_type_node, MEMMODEL_SEQ_CST);
    5494        30433 :   tree rhs_semantic_type = TREE_TYPE (rhs);
    5495        30433 :   tree nonatomic_rhs_semantic_type;
    5496        30433 :   tree rhs_type;
    5497              : 
    5498        30433 :   gcc_assert (TYPE_ATOMIC (lhs_type));
    5499              : 
    5500        30433 :   if (return_old_p)
    5501         2313 :     gcc_assert (modifycode == PLUS_EXPR || modifycode == MINUS_EXPR);
    5502              : 
    5503              :   /* Allocate enough vector items for a compare_exchange.  */
    5504        30433 :   vec_alloc (params, 6);
    5505              : 
    5506              :   /* Create a compound statement to hold the sequence of statements
    5507              :      with a loop.  */
    5508        30433 :   if (modifycode != NOP_EXPR)
    5509              :     {
    5510        19954 :       compound_stmt = c_begin_compound_stmt (false);
    5511              : 
    5512              :       /* For consistency with build_modify_expr on non-_Atomic,
    5513              :          mark the lhs as read.  Also, it would be very hard to match
    5514              :          such expressions in mark_exp_read.  */
    5515        19954 :       mark_exp_read (lhs);
    5516              :     }
    5517              : 
    5518              :   /* Remove any excess precision (which is only present here in the
    5519              :      case of compound assignments).  */
    5520        30433 :   if (TREE_CODE (rhs) == EXCESS_PRECISION_EXPR)
    5521              :     {
    5522            0 :       gcc_assert (modifycode != NOP_EXPR);
    5523            0 :       rhs = TREE_OPERAND (rhs, 0);
    5524              :     }
    5525        30433 :   rhs_type = TREE_TYPE (rhs);
    5526              : 
    5527              :   /* Fold the RHS if it hasn't already been folded.  */
    5528        30433 :   if (modifycode != NOP_EXPR)
    5529        19954 :     rhs = c_fully_fold (rhs, false, NULL);
    5530              : 
    5531              :   /* Remove the qualifiers for the rest of the expressions and create
    5532              :      the VAL temp variable to hold the RHS.  */
    5533        30433 :   nonatomic_lhs_type = build_qualified_type (lhs_type, TYPE_UNQUALIFIED);
    5534        30433 :   nonatomic_rhs_type = build_qualified_type (rhs_type, TYPE_UNQUALIFIED);
    5535        30433 :   nonatomic_rhs_semantic_type = build_qualified_type (rhs_semantic_type,
    5536              :                                                       TYPE_UNQUALIFIED);
    5537        30433 :   val = create_tmp_var_raw (nonatomic_rhs_type);
    5538        30433 :   TREE_ADDRESSABLE (val) = 1;
    5539        30433 :   suppress_warning (val);
    5540        30433 :   rhs = build4 (TARGET_EXPR, nonatomic_rhs_type, val, rhs, NULL_TREE,
    5541              :                 NULL_TREE);
    5542        30433 :   TREE_SIDE_EFFECTS (rhs) = 1;
    5543        30433 :   SET_EXPR_LOCATION (rhs, loc);
    5544        30433 :   if (modifycode != NOP_EXPR)
    5545        19954 :     add_stmt (rhs);
    5546              : 
    5547              :   /* NOP_EXPR indicates it's a straight store of the RHS. Simply issue
    5548              :      an atomic_store.  */
    5549        30433 :   if (modifycode == NOP_EXPR)
    5550              :     {
    5551        10479 :       compound_stmt = rhs;
    5552              :       /* Build __atomic_store (&lhs, &val, SEQ_CST)  */
    5553        10479 :       rhs = build_unary_op (loc, ADDR_EXPR, val, false);
    5554        10479 :       fndecl = builtin_decl_explicit (BUILT_IN_ATOMIC_STORE);
    5555        10479 :       params->quick_push (lhs_addr);
    5556        10479 :       params->quick_push (rhs);
    5557        10479 :       params->quick_push (seq_cst);
    5558        10479 :       func_call = c_build_function_call_vec (loc, vNULL, fndecl, params, NULL);
    5559              : 
    5560        10479 :       compound_stmt = build2 (COMPOUND_EXPR, void_type_node,
    5561              :                               compound_stmt, func_call);
    5562              : 
    5563              :       /* VAL is the value which was stored, return a COMPOUND_STMT of
    5564              :          the statement and that value.  */
    5565        10479 :       return build2 (COMPOUND_EXPR, nonatomic_lhs_type, compound_stmt, val);
    5566              :     }
    5567              : 
    5568              :   /* Attempt to implement the atomic operation as an __atomic_fetch_* or
    5569              :      __atomic_*_fetch built-in rather than a CAS loop.  atomic_bool type
    5570              :      isn't applicable for such builtins.  ??? Do we want to handle enums?  */
    5571        19954 :   if ((TREE_CODE (lhs_type) == INTEGER_TYPE || POINTER_TYPE_P (lhs_type))
    5572        13941 :       && TREE_CODE (rhs_type) == INTEGER_TYPE)
    5573              :     {
    5574        11713 :       built_in_function fncode;
    5575        11713 :       switch (modifycode)
    5576              :         {
    5577         3075 :         case PLUS_EXPR:
    5578         3075 :         case POINTER_PLUS_EXPR:
    5579         2124 :           fncode = (return_old_p
    5580         3075 :                     ? BUILT_IN_ATOMIC_FETCH_ADD_N
    5581              :                     : BUILT_IN_ATOMIC_ADD_FETCH_N);
    5582              :           break;
    5583         2889 :         case MINUS_EXPR:
    5584         2094 :           fncode = (return_old_p
    5585         2889 :                     ? BUILT_IN_ATOMIC_FETCH_SUB_N
    5586              :                     : BUILT_IN_ATOMIC_SUB_FETCH_N);
    5587              :           break;
    5588          609 :         case BIT_AND_EXPR:
    5589          609 :           fncode = (return_old_p
    5590          609 :                     ? BUILT_IN_ATOMIC_FETCH_AND_N
    5591              :                     : BUILT_IN_ATOMIC_AND_FETCH_N);
    5592              :           break;
    5593          609 :         case BIT_IOR_EXPR:
    5594          609 :           fncode = (return_old_p
    5595          609 :                     ? BUILT_IN_ATOMIC_FETCH_OR_N
    5596              :                     : BUILT_IN_ATOMIC_OR_FETCH_N);
    5597              :           break;
    5598          609 :         case BIT_XOR_EXPR:
    5599          609 :           fncode = (return_old_p
    5600          609 :                     ? BUILT_IN_ATOMIC_FETCH_XOR_N
    5601              :                     : BUILT_IN_ATOMIC_XOR_FETCH_N);
    5602              :           break;
    5603         3922 :         default:
    5604         3922 :           goto cas_loop;
    5605              :         }
    5606              : 
    5607              :       /* We can only use "_1" through "_16" variants of the atomic fetch
    5608              :          built-ins.  */
    5609         7791 :       unsigned HOST_WIDE_INT size = tree_to_uhwi (TYPE_SIZE_UNIT (lhs_type));
    5610         7791 :       if (size != 1 && size != 2 && size != 4 && size != 8 && size != 16)
    5611            0 :         goto cas_loop;
    5612              : 
    5613              :       /* If this is a pointer type, we need to multiply by the size of
    5614              :          the pointer target type.  */
    5615         7791 :       if (POINTER_TYPE_P (lhs_type))
    5616              :         {
    5617         1018 :           if (!COMPLETE_TYPE_P (TREE_TYPE (lhs_type))
    5618              :               /* ??? This would introduce -Wdiscarded-qualifiers
    5619              :                  warning: __atomic_fetch_* expect volatile void *
    5620              :                  type as the first argument.  (Assignments between
    5621              :                  atomic and non-atomic objects are OK.) */
    5622         1018 :               || TYPE_RESTRICT (lhs_type))
    5623           17 :             goto cas_loop;
    5624         1001 :           tree sz = TYPE_SIZE_UNIT (TREE_TYPE (lhs_type));
    5625         1001 :           rhs = fold_build2_loc (loc, MULT_EXPR, ptrdiff_type_node,
    5626              :                                  convert (ptrdiff_type_node, rhs),
    5627              :                                  convert (ptrdiff_type_node, sz));
    5628              :         }
    5629              : 
    5630              :       /* Build __atomic_fetch_* (&lhs, &val, SEQ_CST), or
    5631              :          __atomic_*_fetch (&lhs, &val, SEQ_CST).  */
    5632         7774 :       fndecl = builtin_decl_explicit (fncode);
    5633         7774 :       params->quick_push (lhs_addr);
    5634         7774 :       params->quick_push (rhs);
    5635         7774 :       params->quick_push (seq_cst);
    5636         7774 :       func_call = c_build_function_call_vec (loc, vNULL, fndecl, params, NULL);
    5637              : 
    5638         7774 :       newval = create_tmp_var_raw (nonatomic_lhs_type);
    5639         7774 :       TREE_ADDRESSABLE (newval) = 1;
    5640         7774 :       suppress_warning (newval);
    5641         7774 :       rhs = build4 (TARGET_EXPR, nonatomic_lhs_type, newval, func_call,
    5642              :                     NULL_TREE, NULL_TREE);
    5643         7774 :       SET_EXPR_LOCATION (rhs, loc);
    5644         7774 :       add_stmt (rhs);
    5645              : 
    5646              :       /* Finish the compound statement.  */
    5647         7774 :       compound_stmt = c_end_compound_stmt (loc, compound_stmt, false);
    5648              : 
    5649              :       /* NEWVAL is the value which was stored, return a COMPOUND_STMT of
    5650              :          the statement and that value.  */
    5651         7774 :       return build2 (COMPOUND_EXPR, nonatomic_lhs_type, compound_stmt, newval);
    5652              :     }
    5653              : 
    5654         8241 : cas_loop:
    5655              :   /* Create the variables and labels required for the op= form.  */
    5656        12180 :   old = create_tmp_var_raw (nonatomic_lhs_type);
    5657        12180 :   old_addr = build_unary_op (loc, ADDR_EXPR, old, false);
    5658        12180 :   TREE_ADDRESSABLE (old) = 1;
    5659        12180 :   suppress_warning (old);
    5660              : 
    5661        12180 :   newval = create_tmp_var_raw (nonatomic_lhs_type);
    5662        12180 :   newval_addr = build_unary_op (loc, ADDR_EXPR, newval, false);
    5663        12180 :   TREE_ADDRESSABLE (newval) = 1;
    5664        12180 :   suppress_warning (newval);
    5665              : 
    5666        12180 :   loop_decl = create_artificial_label (loc);
    5667        12180 :   loop_label = build1 (LABEL_EXPR, void_type_node, loop_decl);
    5668              : 
    5669        12180 :   done_decl = create_artificial_label (loc);
    5670        12180 :   done_label = build1 (LABEL_EXPR, void_type_node, done_decl);
    5671              : 
    5672              :   /* __atomic_load (addr, &old, SEQ_CST).  */
    5673        12180 :   fndecl = builtin_decl_explicit (BUILT_IN_ATOMIC_LOAD);
    5674        12180 :   params->quick_push (lhs_addr);
    5675        12180 :   params->quick_push (old_addr);
    5676        12180 :   params->quick_push (seq_cst);
    5677        12180 :   func_call = c_build_function_call_vec (loc, vNULL, fndecl, params, NULL);
    5678        12180 :   old = build4 (TARGET_EXPR, nonatomic_lhs_type, old, func_call, NULL_TREE,
    5679              :                 NULL_TREE);
    5680        12180 :   add_stmt (old);
    5681        12180 :   params->truncate (0);
    5682              : 
    5683              :   /* Create the expressions for floating-point environment
    5684              :      manipulation, if required.  */
    5685        12180 :   bool need_fenv = (flag_trapping_math
    5686        12180 :                     && (FLOAT_TYPE_P (lhs_type) || FLOAT_TYPE_P (rhs_type)));
    5687        12180 :   tree hold_call = NULL_TREE, clear_call = NULL_TREE, update_call = NULL_TREE;
    5688        12180 :   if (need_fenv)
    5689         7054 :     targetm.atomic_assign_expand_fenv (&hold_call, &clear_call, &update_call);
    5690              : 
    5691        12180 :   if (hold_call)
    5692         7054 :     add_stmt (hold_call);
    5693              : 
    5694              :   /* loop:  */
    5695        12180 :   add_stmt (loop_label);
    5696              : 
    5697              :   /* newval = old + val;  */
    5698        12180 :   if (rhs_type != rhs_semantic_type)
    5699            0 :     val = build1 (EXCESS_PRECISION_EXPR, nonatomic_rhs_semantic_type, val);
    5700        12180 :   rhs = build_binary_op (loc, modifycode,
    5701              :                          convert_lvalue_to_rvalue (loc, old, true, true),
    5702              :                          val, true);
    5703        12180 :   if (TREE_CODE (rhs) == EXCESS_PRECISION_EXPR)
    5704              :     {
    5705            0 :       tree eptype = TREE_TYPE (rhs);
    5706            0 :       rhs = c_fully_fold (TREE_OPERAND (rhs, 0), false, NULL);
    5707            0 :       rhs = build1 (EXCESS_PRECISION_EXPR, eptype, rhs);
    5708              :     }
    5709              :   else
    5710        12180 :     rhs = c_fully_fold (rhs, false, NULL);
    5711        12180 :   rhs = convert_for_assignment (loc, UNKNOWN_LOCATION, nonatomic_lhs_type,
    5712              :                                 rhs, NULL_TREE, ic_assign, false, NULL_TREE,
    5713              :                                 NULL_TREE, 0);
    5714              :   /* The temporary variable for NEWVAL is only gimplified correctly (in
    5715              :      particular, given a DECL_CONTEXT) if used in a TARGET_EXPR.  To avoid
    5716              :      subsequent ICEs in nested function processing after an error, ensure such
    5717              :      a TARGET_EXPR is built even after an error.  */
    5718        12180 :   if (rhs == error_mark_node)
    5719           10 :     rhs = old;
    5720        12180 :   rhs = build4 (TARGET_EXPR, nonatomic_lhs_type, newval, rhs, NULL_TREE,
    5721              :                 NULL_TREE);
    5722        12180 :   SET_EXPR_LOCATION (rhs, loc);
    5723        12180 :   add_stmt (rhs);
    5724              : 
    5725              :   /* if (__atomic_compare_exchange (addr, &old, &new, false, SEQ_CST, SEQ_CST))
    5726              :        goto done;  */
    5727        12180 :   fndecl = builtin_decl_explicit (BUILT_IN_ATOMIC_COMPARE_EXCHANGE);
    5728        12180 :   params->quick_push (lhs_addr);
    5729        12180 :   params->quick_push (old_addr);
    5730        12180 :   params->quick_push (newval_addr);
    5731        12180 :   params->quick_push (integer_zero_node);
    5732        12180 :   params->quick_push (seq_cst);
    5733        12180 :   params->quick_push (seq_cst);
    5734        12180 :   func_call = c_build_function_call_vec (loc, vNULL, fndecl, params, NULL);
    5735              : 
    5736        12180 :   goto_stmt = build1 (GOTO_EXPR, void_type_node, done_decl);
    5737        12180 :   SET_EXPR_LOCATION (goto_stmt, loc);
    5738              : 
    5739        12180 :   stmt = build3 (COND_EXPR, void_type_node, func_call, goto_stmt, NULL_TREE);
    5740        12180 :   SET_EXPR_LOCATION (stmt, loc);
    5741        12180 :   add_stmt (stmt);
    5742              : 
    5743        12180 :   if (clear_call)
    5744         7054 :     add_stmt (clear_call);
    5745              : 
    5746              :   /* goto loop;  */
    5747        12180 :   goto_stmt  = build1 (GOTO_EXPR, void_type_node, loop_decl);
    5748        12180 :   SET_EXPR_LOCATION (goto_stmt, loc);
    5749        12180 :   add_stmt (goto_stmt);
    5750              : 
    5751              :   /* done:  */
    5752        12180 :   add_stmt (done_label);
    5753              : 
    5754        12180 :   if (update_call)
    5755         7054 :     add_stmt (update_call);
    5756              : 
    5757              :   /* Finish the compound statement.  */
    5758        12180 :   compound_stmt = c_end_compound_stmt (loc, compound_stmt, false);
    5759              : 
    5760              :   /* NEWVAL is the value that was successfully stored, return a
    5761              :      COMPOUND_EXPR of the statement and the appropriate value.  */
    5762        23787 :   return build2 (COMPOUND_EXPR, nonatomic_lhs_type, compound_stmt,
    5763        12180 :                  return_old_p ? old : newval);
    5764              : }
    5765              : 
    5766              : /* Construct and perhaps optimize a tree representation
    5767              :    for a unary operation.  CODE, a tree_code, specifies the operation
    5768              :    and XARG is the operand.
    5769              :    For any CODE other than ADDR_EXPR, NOCONVERT suppresses the default
    5770              :    promotions (such as from short to int).
    5771              :    For ADDR_EXPR, the default promotions are not applied; NOCONVERT allows
    5772              :    non-lvalues; this is only used to handle conversion of non-lvalue arrays
    5773              :    to pointers in C99.
    5774              : 
    5775              :    LOCATION is the location of the operator.  */
    5776              : 
    5777              : tree
    5778     60541743 : build_unary_op (location_t location, enum tree_code code, tree xarg,
    5779              :                 bool noconvert)
    5780              : {
    5781              :   /* No default_conversion here.  It causes trouble for ADDR_EXPR.  */
    5782     60541743 :   tree arg = xarg;
    5783     60541743 :   tree argtype = NULL_TREE;
    5784     60541743 :   enum tree_code typecode;
    5785     60541743 :   tree val;
    5786     60541743 :   tree ret = error_mark_node;
    5787     60541743 :   tree eptype = NULL_TREE;
    5788     60541743 :   const char *invalid_op_diag;
    5789     60541743 :   bool int_operands;
    5790              : 
    5791     60541743 :   int_operands = EXPR_INT_CONST_OPERANDS (xarg);
    5792      6463262 :   if (int_operands)
    5793      6463262 :     arg = remove_c_maybe_const_expr (arg);
    5794              : 
    5795     60541743 :   if (code != ADDR_EXPR)
    5796      8540433 :     arg = require_complete_type (location, arg);
    5797              : 
    5798     60541743 :   typecode = TREE_CODE (TREE_TYPE (arg));
    5799     60541743 :   if (typecode == ERROR_MARK)
    5800           74 :     return error_mark_node;
    5801     60541669 :   if (typecode == ENUMERAL_TYPE || typecode == BOOLEAN_TYPE)
    5802        32251 :     typecode = INTEGER_TYPE;
    5803              : 
    5804    121083338 :   if ((invalid_op_diag
    5805     60541669 :        = targetm.invalid_unary_op (code, TREE_TYPE (xarg))))
    5806              :     {
    5807            0 :       error_at (location, invalid_op_diag);
    5808            0 :       return error_mark_node;
    5809              :     }
    5810              : 
    5811     60541669 :   if (TREE_CODE (arg) == EXCESS_PRECISION_EXPR)
    5812              :     {
    5813          245 :       eptype = TREE_TYPE (arg);
    5814          245 :       arg = TREE_OPERAND (arg, 0);
    5815              :     }
    5816              : 
    5817     60541669 :   switch (code)
    5818              :     {
    5819        28759 :     case CONVERT_EXPR:
    5820              :       /* This is used for unary plus, because a CONVERT_EXPR
    5821              :          is enough to prevent anybody from looking inside for
    5822              :          associativity, but won't generate any code.  */
    5823        28764 :       if (!(typecode == INTEGER_TYPE || typecode == REAL_TYPE
    5824           13 :             || typecode == FIXED_POINT_TYPE || typecode == COMPLEX_TYPE
    5825           10 :             || typecode == BITINT_TYPE
    5826            5 :             || gnu_vector_type_p (TREE_TYPE (arg))))
    5827              :         {
    5828            1 :           error_at (location, "wrong type argument to unary plus");
    5829            1 :           return error_mark_node;
    5830              :         }
    5831        28758 :       else if (!noconvert)
    5832        28758 :         arg = default_conversion (arg);
    5833        28758 :       arg = non_lvalue_loc (location, arg);
    5834        28758 :       break;
    5835              : 
    5836      6699460 :     case NEGATE_EXPR:
    5837      7146864 :       if (!(typecode == INTEGER_TYPE || typecode == REAL_TYPE
    5838       484076 :             || typecode == FIXED_POINT_TYPE || typecode == COMPLEX_TYPE
    5839       452809 :             || typecode == BITINT_TYPE
    5840       447404 :             || gnu_vector_type_p (TREE_TYPE (arg))))
    5841              :         {
    5842            1 :           error_at (location, "wrong type argument to unary minus");
    5843            1 :           return error_mark_node;
    5844              :         }
    5845      6699459 :       else if (!noconvert)
    5846      6699453 :         arg = default_conversion (arg);
    5847              :       break;
    5848              : 
    5849       295348 :     case BIT_NOT_EXPR:
    5850              :       /* ~ works on integer types and non float vectors. */
    5851       295348 :       if (typecode == INTEGER_TYPE
    5852       295348 :           || typecode == BITINT_TYPE
    5853       295348 :           || (gnu_vector_type_p (TREE_TYPE (arg))
    5854         2059 :               && !VECTOR_FLOAT_TYPE_P (TREE_TYPE (arg))))
    5855              :         {
    5856              :           tree e = arg;
    5857              : 
    5858              :           /* Warn if the expression has boolean value.  */
    5859       294749 :           while (TREE_CODE (e) == COMPOUND_EXPR)
    5860           11 :             e = TREE_OPERAND (e, 1);
    5861              : 
    5862       589460 :           if ((C_BOOLEAN_TYPE_P (TREE_TYPE (arg))
    5863       589460 :                || truth_value_p (TREE_CODE (e))))
    5864              :             {
    5865          148 :               auto_diagnostic_group d;
    5866          148 :               if (warning_at (location, OPT_Wbool_operation,
    5867              :                                 "%<~%> on a boolean expression"))
    5868              :                 {
    5869           12 :                   gcc_rich_location richloc (location);
    5870           12 :                   richloc.add_fixit_insert_before (location, "!");
    5871           12 :                   inform (&richloc, "did you mean to use logical not?");
    5872           12 :                 }
    5873          148 :             }
    5874       294738 :           if (!noconvert)
    5875       294735 :             arg = default_conversion (arg);
    5876              :         }
    5877          610 :       else if (typecode == COMPLEX_TYPE)
    5878              :         {
    5879          605 :           code = CONJ_EXPR;
    5880          605 :           pedwarn (location, OPT_Wpedantic,
    5881              :                    "ISO C does not support %<~%> for complex conjugation");
    5882          605 :           if (!noconvert)
    5883          605 :             arg = default_conversion (arg);
    5884              :         }
    5885              :       else
    5886              :         {
    5887            5 :           error_at (location, "wrong type argument to bit-complement");
    5888            5 :           return error_mark_node;
    5889              :         }
    5890              :       break;
    5891              : 
    5892            3 :     case ABS_EXPR:
    5893            3 :       if (!(typecode == INTEGER_TYPE || typecode == REAL_TYPE))
    5894              :         {
    5895            0 :           error_at (location, "wrong type argument to abs");
    5896            0 :           return error_mark_node;
    5897              :         }
    5898            3 :       else if (!noconvert)
    5899            0 :         arg = default_conversion (arg);
    5900              :       break;
    5901              : 
    5902            7 :     case ABSU_EXPR:
    5903            7 :       if (!(typecode == INTEGER_TYPE))
    5904              :         {
    5905            0 :           error_at (location, "wrong type argument to absu");
    5906            0 :           return error_mark_node;
    5907              :         }
    5908            7 :       else if (!noconvert)
    5909            0 :         arg = default_conversion (arg);
    5910              :       break;
    5911              : 
    5912            0 :     case CONJ_EXPR:
    5913              :       /* Conjugating a real value is a no-op, but allow it anyway.  */
    5914            0 :       if (!(typecode == INTEGER_TYPE || typecode == REAL_TYPE
    5915              :             || typecode == COMPLEX_TYPE))
    5916              :         {
    5917            0 :           error_at (location, "wrong type argument to conjugation");
    5918            0 :           return error_mark_node;
    5919              :         }
    5920            0 :       else if (!noconvert)
    5921            0 :         arg = default_conversion (arg);
    5922              :       break;
    5923              : 
    5924       378118 :     case TRUTH_NOT_EXPR:
    5925       378118 :       if (typecode != INTEGER_TYPE && typecode != FIXED_POINT_TYPE
    5926         7080 :           && typecode != REAL_TYPE && typecode != POINTER_TYPE
    5927           21 :           && typecode != COMPLEX_TYPE && typecode != NULLPTR_TYPE
    5928           18 :           && typecode != BITINT_TYPE)
    5929              :         {
    5930           10 :           error_at (location,
    5931              :                     "wrong type argument to unary exclamation mark");
    5932           10 :           return error_mark_node;
    5933              :         }
    5934       378108 :       if (int_operands)
    5935              :         {
    5936       139865 :           arg = c_objc_common_truthvalue_conversion (location, xarg);
    5937       139865 :           arg = remove_c_maybe_const_expr (arg);
    5938              :         }
    5939              :       else
    5940       238243 :         arg = c_objc_common_truthvalue_conversion (location, arg);
    5941       378108 :       ret = invert_truthvalue_loc (location, arg);
    5942              :       /* If the TRUTH_NOT_EXPR has been folded, reset the location.  */
    5943       378108 :       if (EXPR_P (ret) && EXPR_HAS_LOCATION (ret))
    5944       237850 :         location = EXPR_LOCATION (ret);
    5945       378108 :       goto return_build_unary_op;
    5946              : 
    5947       203100 :     case REALPART_EXPR:
    5948       203100 :     case IMAGPART_EXPR:
    5949       203100 :       ret = build_real_imag_expr (location, code, arg);
    5950       203100 :       if (ret == error_mark_node)
    5951              :         return error_mark_node;
    5952       203092 :       if (eptype && TREE_CODE (eptype) == COMPLEX_TYPE)
    5953            2 :         eptype = TREE_TYPE (eptype);
    5954       203092 :       goto return_build_unary_op;
    5955              : 
    5956       935595 :     case PREINCREMENT_EXPR:
    5957       935595 :     case POSTINCREMENT_EXPR:
    5958       935595 :     case PREDECREMENT_EXPR:
    5959       935595 :     case POSTDECREMENT_EXPR:
    5960              : 
    5961       935595 :       if (TREE_CODE (arg) == C_MAYBE_CONST_EXPR)
    5962              :         {
    5963            2 :           tree inner = build_unary_op (location, code,
    5964            2 :                                        C_MAYBE_CONST_EXPR_EXPR (arg),
    5965              :                                        noconvert);
    5966            2 :           if (inner == error_mark_node)
    5967              :             return error_mark_node;
    5968            4 :           ret = build2 (C_MAYBE_CONST_EXPR, TREE_TYPE (inner),
    5969            2 :                         C_MAYBE_CONST_EXPR_PRE (arg), inner);
    5970            2 :           gcc_assert (!C_MAYBE_CONST_EXPR_INT_OPERANDS (arg));
    5971            2 :           C_MAYBE_CONST_EXPR_NON_CONST (ret) = 1;
    5972            2 :           goto return_build_unary_op;
    5973              :         }
    5974              : 
    5975              :       /* Complain about anything that is not a true lvalue.  In
    5976              :          Objective-C, skip this check for property_refs.  */
    5977       935593 :       if (!objc_is_property_ref (arg)
    5978      1871186 :           && !lvalue_or_else (location,
    5979       935593 :                               arg, ((code == PREINCREMENT_EXPR
    5980       935593 :                                      || code == POSTINCREMENT_EXPR)
    5981              :                                     ? lv_increment
    5982              :                                     : lv_decrement)))
    5983           22 :         return error_mark_node;
    5984              : 
    5985       935571 :       if (warn_cxx_compat && TREE_CODE (TREE_TYPE (arg)) == ENUMERAL_TYPE)
    5986              :         {
    5987            4 :           if (code == PREINCREMENT_EXPR || code == POSTINCREMENT_EXPR)
    5988            2 :             warning_at (location, OPT_Wc___compat,
    5989              :                         "increment of enumeration value is invalid in C++");
    5990              :           else
    5991            2 :             warning_at (location, OPT_Wc___compat,
    5992              :                         "decrement of enumeration value is invalid in C++");
    5993              :         }
    5994              : 
    5995       935571 :       if (C_BOOLEAN_TYPE_P (TREE_TYPE (arg)))
    5996              :         {
    5997          664 :           if (code == PREINCREMENT_EXPR || code == POSTINCREMENT_EXPR)
    5998          328 :             warning_at (location, OPT_Wbool_operation,
    5999              :                         "increment of a boolean expression");
    6000              :           else
    6001          336 :             warning_at (location, OPT_Wbool_operation,
    6002              :                         "decrement of a boolean expression");
    6003              :         }
    6004              : 
    6005              :       /* Ensure the argument is fully folded inside any SAVE_EXPR.  */
    6006       935571 :       arg = c_fully_fold (arg, false, NULL, true);
    6007              : 
    6008       935571 :       bool atomic_op;
    6009       935571 :       atomic_op = really_atomic_lvalue (arg);
    6010              : 
    6011              :       /* Increment or decrement the real part of the value,
    6012              :          and don't change the imaginary part.  */
    6013       935571 :       if (typecode == COMPLEX_TYPE)
    6014              :         {
    6015           57 :           tree real, imag;
    6016              : 
    6017           57 :           pedwarn_c23 (location, OPT_Wpedantic,
    6018              :                        "ISO C does not support %<++%> and %<--%> on complex "
    6019              :                        "types before C2Y");
    6020              : 
    6021           57 :           if (!atomic_op)
    6022              :             {
    6023           53 :               arg = stabilize_reference (arg);
    6024           53 :               real = build_unary_op (EXPR_LOCATION (arg), REALPART_EXPR, arg,
    6025              :                                      true);
    6026           53 :               imag = build_unary_op (EXPR_LOCATION (arg), IMAGPART_EXPR, arg,
    6027              :                                      true);
    6028           53 :               real = build_unary_op (EXPR_LOCATION (arg), code, real, true);
    6029           53 :               if (real == error_mark_node || imag == error_mark_node)
    6030              :                 return error_mark_node;
    6031           53 :               ret = build2 (COMPLEX_EXPR, TREE_TYPE (arg),
    6032              :                             real, imag);
    6033           53 :               goto return_build_unary_op;
    6034              :             }
    6035              :         }
    6036              : 
    6037              :       /* Report invalid types.  */
    6038              : 
    6039       935518 :       if (typecode != POINTER_TYPE && typecode != FIXED_POINT_TYPE
    6040       705207 :           && typecode != INTEGER_TYPE && typecode != REAL_TYPE
    6041          208 :           && typecode != COMPLEX_TYPE && typecode != BITINT_TYPE
    6042       935574 :           && !gnu_vector_type_p (TREE_TYPE (arg)))
    6043              :         {
    6044            5 :           if (code == PREINCREMENT_EXPR || code == POSTINCREMENT_EXPR)
    6045            3 :             error_at (location, "wrong type argument to increment");
    6046              :           else
    6047            2 :             error_at (location, "wrong type argument to decrement");
    6048              : 
    6049            5 :           return error_mark_node;
    6050              :         }
    6051              : 
    6052       935513 :       {
    6053       935513 :         tree inc;
    6054              : 
    6055       935513 :         argtype = TREE_TYPE (arg);
    6056              : 
    6057              :         /* Compute the increment.  */
    6058              : 
    6059       935513 :         if (typecode == POINTER_TYPE)
    6060              :           {
    6061              :             /* If pointer target is an incomplete type,
    6062              :                we just cannot know how to do the arithmetic.  */
    6063       230311 :             if (!COMPLETE_OR_VOID_TYPE_P (TREE_TYPE (argtype)))
    6064              :               {
    6065           27 :                 if (code == PREINCREMENT_EXPR || code == POSTINCREMENT_EXPR)
    6066           17 :                   error_at (location,
    6067              :                             "increment of pointer to an incomplete type %qT",
    6068           17 :                             TREE_TYPE (argtype));
    6069              :                 else
    6070           10 :                   error_at (location,
    6071              :                             "decrement of pointer to an incomplete type %qT",
    6072           10 :                             TREE_TYPE (argtype));
    6073              :               }
    6074       230284 :             else if (TREE_CODE (TREE_TYPE (argtype)) == FUNCTION_TYPE
    6075       230284 :                      || VOID_TYPE_P (TREE_TYPE (argtype)))
    6076              :               {
    6077           10 :                 if (code == PREINCREMENT_EXPR || code == POSTINCREMENT_EXPR)
    6078            6 :                   pedwarn (location, OPT_Wpointer_arith,
    6079              :                            "wrong type argument to increment");
    6080              :                 else
    6081            4 :                   pedwarn (location, OPT_Wpointer_arith,
    6082              :                            "wrong type argument to decrement");
    6083              :               }
    6084              :             else
    6085       460548 :               verify_type_context (location, TCTX_POINTER_ARITH,
    6086       230274 :                                    TREE_TYPE (argtype));
    6087              : 
    6088       230311 :             inc = c_size_in_bytes (TREE_TYPE (argtype));
    6089       230311 :             inc = convert_to_ptrofftype_loc (location, inc);
    6090              :           }
    6091       705202 :         else if (FRACT_MODE_P (TYPE_MODE (argtype)))
    6092              :           {
    6093              :             /* For signed fract types, we invert ++ to -- or
    6094              :                -- to ++, and change inc from 1 to -1, because
    6095              :                it is not possible to represent 1 in signed fract constants.
    6096              :                For unsigned fract types, the result always overflows and
    6097              :                we get an undefined (original) or the maximum value.  */
    6098            0 :             if (code == PREINCREMENT_EXPR)
    6099              :               code = PREDECREMENT_EXPR;
    6100              :             else if (code == PREDECREMENT_EXPR)
    6101              :               code = PREINCREMENT_EXPR;
    6102              :             else if (code == POSTINCREMENT_EXPR)
    6103              :               code = POSTDECREMENT_EXPR;
    6104              :             else /* code == POSTDECREMENT_EXPR  */
    6105            0 :               code = POSTINCREMENT_EXPR;
    6106              : 
    6107            0 :             inc = integer_minus_one_node;
    6108            0 :             inc = convert (argtype, inc);
    6109              :           }
    6110              :         else
    6111              :           {
    6112       705151 :             inc = VECTOR_TYPE_P (argtype)
    6113       705202 :               ? build_one_cst (argtype)
    6114              :               : integer_one_node;
    6115       705202 :             inc = convert (argtype, inc);
    6116              :           }
    6117              : 
    6118              :         /* If 'arg' is an Objective-C PROPERTY_REF expression, then we
    6119              :            need to ask Objective-C to build the increment or decrement
    6120              :            expression for it.  */
    6121       935513 :         if (objc_is_property_ref (arg))
    6122            0 :           return objc_build_incr_expr_for_property_ref (location, code,
    6123           20 :                                                         arg, inc);
    6124              : 
    6125              :         /* Report a read-only lvalue.  */
    6126       935513 :         if (TYPE_READONLY (argtype))
    6127              :           {
    6128           20 :             readonly_error (location, arg,
    6129           20 :                             ((code == PREINCREMENT_EXPR
    6130           20 :                               || code == POSTINCREMENT_EXPR)
    6131              :                              ? lv_increment : lv_decrement));
    6132           20 :             return error_mark_node;
    6133              :           }
    6134       935493 :         else if (TREE_READONLY (arg))
    6135            4 :           readonly_warning (arg,
    6136            4 :                             ((code == PREINCREMENT_EXPR
    6137            4 :                               || code == POSTINCREMENT_EXPR)
    6138              :                              ? lv_increment : lv_decrement));
    6139              : 
    6140              :         /* If the argument is atomic, use the special code sequences for
    6141              :            atomic compound assignment.  */
    6142       935493 :         if (atomic_op)
    6143              :           {
    6144         4469 :             arg = stabilize_reference (arg);
    6145         8938 :             ret = build_atomic_assign (location, arg,
    6146         4469 :                                        ((code == PREINCREMENT_EXPR
    6147         4469 :                                          || code == POSTINCREMENT_EXPR)
    6148              :                                         ? PLUS_EXPR
    6149              :                                         : MINUS_EXPR),
    6150         4469 :                                        (FRACT_MODE_P (TYPE_MODE (argtype))
    6151              :                                         ? inc
    6152              :                                         : integer_one_node),
    6153              :                                        (code == POSTINCREMENT_EXPR
    6154         4469 :                                         || code == POSTDECREMENT_EXPR));
    6155       935493 :             goto return_build_unary_op;
    6156              :           }
    6157              : 
    6158       931024 :         tree true_res;
    6159       931024 :         if (c_hardbool_type_attr (TREE_TYPE (arg), NULL, &true_res))
    6160              :           {
    6161          364 :             tree larg = stabilize_reference (arg);
    6162          364 :             tree sarg = save_expr (larg);
    6163          364 :             switch (code)
    6164              :               {
    6165           91 :               case PREINCREMENT_EXPR:
    6166           91 :                 val = build2 (MODIFY_EXPR, TREE_TYPE (larg), larg, true_res);
    6167           91 :                 val = build2 (COMPOUND_EXPR, TREE_TYPE (larg), sarg, val);
    6168           91 :                 break;
    6169           91 :               case POSTINCREMENT_EXPR:
    6170           91 :                 val = build2 (MODIFY_EXPR, TREE_TYPE (larg), larg, true_res);
    6171           91 :                 val = build2 (COMPOUND_EXPR, TREE_TYPE (larg), val, sarg);
    6172           91 :                 val = build2 (COMPOUND_EXPR, TREE_TYPE (larg), sarg, val);
    6173           91 :                 break;
    6174           91 :               case PREDECREMENT_EXPR:
    6175           91 :                 {
    6176           91 :                   tree rarg = convert_lvalue_to_rvalue (location, sarg,
    6177              :                                                         true, true);
    6178           91 :                   rarg = invert_truthvalue_loc (location, rarg);
    6179           91 :                   rarg = convert (TREE_TYPE (sarg), rarg);
    6180           91 :                   val = build2 (MODIFY_EXPR, TREE_TYPE (larg), larg, rarg);
    6181              :                 }
    6182           91 :                 break;
    6183           91 :               case POSTDECREMENT_EXPR:
    6184           91 :                 {
    6185           91 :                   tree rarg = convert_lvalue_to_rvalue (location, sarg,
    6186              :                                                         true, true);
    6187           91 :                   rarg = invert_truthvalue_loc (location, rarg);
    6188           91 :                   tree iarg = convert (TREE_TYPE (larg), rarg);
    6189           91 :                   val = build2 (MODIFY_EXPR, TREE_TYPE (larg), larg, iarg);
    6190           91 :                   val = build2 (COMPOUND_EXPR, TREE_TYPE (larg), val, sarg);
    6191           91 :                   val = build2 (COMPOUND_EXPR, TREE_TYPE (larg), sarg, val);
    6192              :                 }
    6193           91 :                 break;
    6194              :               default:
    6195              :                 gcc_unreachable ();
    6196              :               }
    6197          364 :             TREE_SIDE_EFFECTS (val) = 1;
    6198              :           }
    6199       930660 :         else if (C_BOOLEAN_TYPE_P (TREE_TYPE (arg)))
    6200           64 :           val = boolean_increment (code, arg);
    6201              :         else
    6202       930596 :           val = build2 (code, TREE_TYPE (arg), arg, inc);
    6203       931024 :         TREE_SIDE_EFFECTS (val) = 1;
    6204       931024 :         if (TYPE_QUALS (TREE_TYPE (val)) != TYPE_UNQUALIFIED)
    6205         3939 :           TREE_TYPE (val) = c_build_qualified_type (TREE_TYPE (val),
    6206              :                                                     TYPE_UNQUALIFIED);
    6207       931024 :         ret = val;
    6208       931024 :         goto return_build_unary_op;
    6209              :       }
    6210              : 
    6211     52001269 :     case ADDR_EXPR:
    6212              :       /* Note that this operation never does default_conversion.  */
    6213              : 
    6214              :       /* The operand of unary '&' must be an lvalue (which excludes
    6215              :          expressions of type void), or, in C99, the result of a [] or
    6216              :          unary '*' operator.  */
    6217     52001269 :       if (VOID_TYPE_P (TREE_TYPE (arg))
    6218           25 :           && TYPE_QUALS (TREE_TYPE (arg)) == TYPE_UNQUALIFIED
    6219     52001288 :           && (!INDIRECT_REF_P (arg) || !flag_isoc99))
    6220           18 :         pedwarn (location, 0, "taking address of expression of type %<void%>");
    6221              : 
    6222              :       /* Let &* cancel out to simplify resulting code.  */
    6223     52001269 :       if (INDIRECT_REF_P (arg))
    6224              :         {
    6225              :           /* Don't let this be an lvalue.  */
    6226        22303 :           if (lvalue_p (TREE_OPERAND (arg, 0)))
    6227        16818 :             return non_lvalue_loc (location, TREE_OPERAND (arg, 0));
    6228         5485 :           ret = TREE_OPERAND (arg, 0);
    6229         5485 :           goto return_build_unary_op;
    6230              :         }
    6231              : 
    6232              :       /* Anything not already handled and not a true memory reference
    6233              :          or a non-lvalue array is an error.  */
    6234     51978966 :       if (typecode != FUNCTION_TYPE && !noconvert
    6235     51978966 :           && !lvalue_or_else (location, arg, lv_addressof))
    6236           17 :         return error_mark_node;
    6237              : 
    6238              :       /* Move address operations inside C_MAYBE_CONST_EXPR to simplify
    6239              :          folding later.  */
    6240     51978949 :       if (TREE_CODE (arg) == C_MAYBE_CONST_EXPR)
    6241              :         {
    6242           14 :           tree inner = build_unary_op (location, code,
    6243           14 :                                        C_MAYBE_CONST_EXPR_EXPR (arg),
    6244              :                                        noconvert);
    6245           28 :           ret = build2 (C_MAYBE_CONST_EXPR, TREE_TYPE (inner),
    6246           14 :                         C_MAYBE_CONST_EXPR_PRE (arg), inner);
    6247           14 :           gcc_assert (!C_MAYBE_CONST_EXPR_INT_OPERANDS (arg));
    6248           14 :           C_MAYBE_CONST_EXPR_NON_CONST (ret)
    6249           14 :             = C_MAYBE_CONST_EXPR_NON_CONST (arg);
    6250           14 :           goto return_build_unary_op;
    6251              :         }
    6252              : 
    6253              :       /* Ordinary case; arg is a COMPONENT_REF or a decl, or a call to
    6254              :          .ACCESS_WITH_SIZE.  */
    6255     51978935 :       if (is_access_with_size_p (arg))
    6256            0 :         arg = TREE_OPERAND (TREE_OPERAND (CALL_EXPR_ARG (arg, 0), 0), 0);
    6257              : 
    6258     51978935 :       argtype = TREE_TYPE (arg);
    6259              : 
    6260              :       /* If the lvalue is const or volatile, merge that into the type
    6261              :          to which the address will point.  This is only needed
    6262              :          for function types.  */
    6263     51978935 :       if ((DECL_P (arg) || REFERENCE_CLASS_P (arg))
    6264     51486775 :           && (TREE_READONLY (arg) || TREE_THIS_VOLATILE (arg))
    6265     82073607 :           && TREE_CODE (argtype) == FUNCTION_TYPE)
    6266              :         {
    6267     30014685 :           int orig_quals = TYPE_QUALS (strip_array_types (argtype));
    6268     30014685 :           int quals = orig_quals;
    6269              : 
    6270     30014685 :           if (TREE_READONLY (arg))
    6271     29638539 :             quals |= TYPE_QUAL_CONST;
    6272     30014685 :           if (TREE_THIS_VOLATILE (arg))
    6273       377054 :             quals |= TYPE_QUAL_VOLATILE;
    6274              : 
    6275     30014685 :           argtype = c_build_qualified_type (argtype, quals);
    6276              :         }
    6277              : 
    6278     51978935 :       switch (TREE_CODE (arg))
    6279              :         {
    6280        65587 :         case COMPONENT_REF:
    6281        65587 :           if (DECL_C_BIT_FIELD (TREE_OPERAND (arg, 1)))
    6282              :             {
    6283            8 :               error_at (location, "cannot take address of bit-field %qD",
    6284            8 :                         TREE_OPERAND (arg, 1));
    6285            8 :               return error_mark_node;
    6286              :             }
    6287              : 
    6288              :           /* fall through */
    6289              : 
    6290       139832 :         case ARRAY_REF:
    6291       139832 :           if (TYPE_REVERSE_STORAGE_ORDER (TREE_TYPE (TREE_OPERAND (arg, 0))))
    6292              :             {
    6293           78 :               if (!AGGREGATE_TYPE_P (TREE_TYPE (arg))
    6294            7 :                   && !POINTER_TYPE_P (TREE_TYPE (arg))
    6295           75 :                   && !VECTOR_TYPE_P (TREE_TYPE (arg)))
    6296              :                 {
    6297            6 :                   error_at (location, "cannot take address of scalar with "
    6298              :                             "reverse storage order");
    6299            6 :                   return error_mark_node;
    6300              :                 }
    6301              : 
    6302           63 :               if (TREE_CODE (TREE_TYPE (arg)) == ARRAY_TYPE
    6303           63 :                   && TYPE_REVERSE_STORAGE_ORDER (TREE_TYPE (arg)))
    6304           58 :                 warning_at (location, OPT_Wscalar_storage_order,
    6305              :                             "address of array with reverse scalar storage "
    6306              :                             "order requested");
    6307              :             }
    6308              : 
    6309     51978921 :         default:
    6310     51978921 :           break;
    6311              :         }
    6312              : 
    6313     51978921 :       if (!c_mark_addressable (arg))
    6314           20 :         return error_mark_node;
    6315              : 
    6316     51978901 :       gcc_assert (TREE_CODE (arg) != COMPONENT_REF
    6317              :                   || !DECL_C_BIT_FIELD (TREE_OPERAND (arg, 1)));
    6318              : 
    6319     51978901 :       argtype = c_build_pointer_type (argtype);
    6320              : 
    6321              :       /* ??? Cope with user tricks that amount to offsetof.  Delete this
    6322              :          when we have proper support for integer constant expressions.  */
    6323     51978901 :       val = get_base_address (arg);
    6324     51978901 :       if (val && INDIRECT_REF_P (val)
    6325     52002918 :           && TREE_CONSTANT (TREE_OPERAND (val, 0)))
    6326              :         {
    6327          540 :           ret = fold_offsetof (arg, argtype);
    6328          540 :           goto return_build_unary_op;
    6329              :         }
    6330              : 
    6331     51978361 :       val = build1 (ADDR_EXPR, argtype, arg);
    6332              : 
    6333     51978361 :       ret = val;
    6334     51978361 :       goto return_build_unary_op;
    6335              : 
    6336           10 :     case PAREN_EXPR:
    6337           10 :       ret = build1 (code, TREE_TYPE (arg), arg);
    6338           10 :       goto return_build_unary_op;
    6339              : 
    6340            0 :     default:
    6341            0 :       gcc_unreachable ();
    6342              :     }
    6343              : 
    6344      7023570 :   if (argtype == NULL_TREE)
    6345      7023570 :     argtype = TREE_TYPE (arg);
    6346      7023570 :   if (TREE_CODE (arg) == INTEGER_CST)
    6347      6319054 :     ret = (require_constant_value
    6348      6319054 :            ? fold_build1_initializer_loc (location, code, argtype, arg)
    6349      6300463 :            : fold_build1_loc (location, code, argtype, arg));
    6350              :   else
    6351       704516 :     ret = build1 (code, argtype, arg);
    6352     60524728 :  return_build_unary_op:
    6353     60524728 :   gcc_assert (ret != error_mark_node);
    6354      6463738 :   if (TREE_CODE (ret) == INTEGER_CST && !TREE_OVERFLOW (ret)
    6355     66988457 :       && !(TREE_CODE (xarg) == INTEGER_CST && !TREE_OVERFLOW (xarg)))
    6356          562 :     ret = build1 (NOP_EXPR, TREE_TYPE (ret), ret);
    6357     60524166 :   else if (TREE_CODE (ret) != INTEGER_CST && int_operands)
    6358           74 :     ret = note_integer_operands (ret);
    6359     60524728 :   if (eptype)
    6360          245 :     ret = build1 (EXCESS_PRECISION_EXPR, eptype, ret);
    6361     60524728 :   protected_set_expr_location (ret, location);
    6362     60524728 :   return ret;
    6363              : }
    6364              : 
    6365              : /* Return nonzero if REF is an lvalue valid for this language.
    6366              :    Lvalues can be assigned, unless their type has TYPE_READONLY.
    6367              :    Lvalues can have their address taken, unless they have C_DECL_REGISTER.  */
    6368              : 
    6369              : bool
    6370    178302354 : lvalue_p (const_tree ref)
    6371              : {
    6372    179802435 :   const enum tree_code code = TREE_CODE (ref);
    6373              : 
    6374    179802435 :   switch (code)
    6375              :     {
    6376      1475272 :     case REALPART_EXPR:
    6377      1475272 :     case IMAGPART_EXPR:
    6378      1475272 :     case COMPONENT_REF:
    6379      1475272 :       return lvalue_p (TREE_OPERAND (ref, 0));
    6380              : 
    6381        24809 :     case C_MAYBE_CONST_EXPR:
    6382        24809 :       return lvalue_p (TREE_OPERAND (ref, 1));
    6383              : 
    6384              :     case COMPOUND_LITERAL_EXPR:
    6385              :     case STRING_CST:
    6386              :       return true;
    6387              : 
    6388     25496243 :     case MEM_REF:
    6389     25496243 :     case TARGET_MEM_REF:
    6390              :       /* MEM_REFs can appear from -fgimple parsing or folding, so allow them
    6391              :          here as well.  */
    6392     25496243 :     case INDIRECT_REF:
    6393     25496243 :     case ARRAY_REF:
    6394     25496243 :     case VAR_DECL:
    6395     25496243 :     case PARM_DECL:
    6396     25496243 :     case RESULT_DECL:
    6397     25496243 :     case ERROR_MARK:
    6398     25496243 :       return (TREE_CODE (TREE_TYPE (ref)) != FUNCTION_TYPE
    6399     25496243 :               && TREE_CODE (TREE_TYPE (ref)) != METHOD_TYPE);
    6400              : 
    6401            6 :     case BIND_EXPR:
    6402            6 :       return TREE_CODE (TREE_TYPE (ref)) == ARRAY_TYPE;
    6403              : 
    6404      7079664 :     case CALL_EXPR:
    6405      7079664 :       return is_access_with_size_p (ref);
    6406              : 
    6407              :     default:
    6408              :       return false;
    6409              :     }
    6410              : }
    6411              : 
    6412              : /* Give a warning for storing in something that is read-only in GCC
    6413              :    terms but not const in ISO C terms.  */
    6414              : 
    6415              : static void
    6416            5 : readonly_warning (tree arg, enum lvalue_use use)
    6417              : {
    6418            5 :   switch (use)
    6419              :     {
    6420            1 :     case lv_assign:
    6421            1 :       warning (0, "assignment of read-only location %qE", arg);
    6422            1 :       break;
    6423            2 :     case lv_increment:
    6424            2 :       warning (0, "increment of read-only location %qE", arg);
    6425            2 :       break;
    6426            2 :     case lv_decrement:
    6427            2 :       warning (0, "decrement of read-only location %qE", arg);
    6428            2 :       break;
    6429            0 :     default:
    6430            0 :       gcc_unreachable ();
    6431              :     }
    6432            5 :   return;
    6433              : }
    6434              : 
    6435              : 
    6436              : /* Return nonzero if REF is an lvalue valid for this language;
    6437              :    otherwise, print an error message and return zero.  USE says
    6438              :    how the lvalue is being used and so selects the error message.
    6439              :    LOCATION is the location at which any error should be reported.  */
    6440              : 
    6441              : static int
    6442      4721843 : lvalue_or_else (location_t loc, const_tree ref, enum lvalue_use use)
    6443              : {
    6444      4721843 :   int win = lvalue_p (ref);
    6445              : 
    6446      4721843 :   if (!win)
    6447           75 :     lvalue_error (loc, use);
    6448              : 
    6449      4721843 :   return win;
    6450              : }
    6451              : 
    6452              : /* Mark EXP saying that we need to be able to take the
    6453              :    address of it; it should not be allocated in a register.
    6454              :    Returns true if successful.  ARRAY_REF_P is true if this
    6455              :    is for ARRAY_REF construction - in that case we don't want
    6456              :    to look through VIEW_CONVERT_EXPR from VECTOR_TYPE to ARRAY_TYPE,
    6457              :    it is fine to use ARRAY_REFs for vector subscripts on vector
    6458              :    register variables.  If OVERRIDE_REGISTER, clear DECL_REGISTER rather
    6459              :    than producing an error for taking the address of a register.  */
    6460              : 
    6461              : bool
    6462     52523795 : c_mark_addressable (tree exp, bool array_ref_p, bool override_register)
    6463              : {
    6464     52523795 :   tree x = exp;
    6465              : 
    6466     53104484 :   while (1)
    6467     53104484 :     switch (TREE_CODE (x))
    6468              :       {
    6469        10029 :       case VIEW_CONVERT_EXPR:
    6470        10029 :         if (array_ref_p
    6471         9919 :             && TREE_CODE (TREE_TYPE (x)) == ARRAY_TYPE
    6472        19948 :             && VECTOR_TYPE_P (TREE_TYPE (TREE_OPERAND (x, 0))))
    6473              :           return true;
    6474          110 :         x = TREE_OPERAND (x, 0);
    6475          110 :         break;
    6476              : 
    6477       396372 :       case COMPONENT_REF:
    6478       396372 :         if (DECL_C_BIT_FIELD (TREE_OPERAND (x, 1)))
    6479              :           {
    6480            6 :             error ("cannot take address of bit-field %qD",
    6481            3 :                    TREE_OPERAND (x, 1));
    6482            3 :             return false;
    6483              :           }
    6484              :         /* FALLTHRU */
    6485       580579 :       case ADDR_EXPR:
    6486       580579 :       case ARRAY_REF:
    6487       580579 :       case REALPART_EXPR:
    6488       580579 :       case IMAGPART_EXPR:
    6489       580579 :         x = TREE_OPERAND (x, 0);
    6490       580579 :         break;
    6491              : 
    6492          587 :       case COMPOUND_LITERAL_EXPR:
    6493          587 :         if (C_DECL_REGISTER (COMPOUND_LITERAL_EXPR_DECL (x)))
    6494              :           {
    6495           16 :             if (override_register)
    6496           12 :               DECL_REGISTER (COMPOUND_LITERAL_EXPR_DECL (x)) = 0;
    6497              :             else
    6498              :               {
    6499            4 :                 error ("address of register compound literal requested");
    6500            4 :                 return false;
    6501              :               }
    6502              :           }
    6503          583 :         TREE_ADDRESSABLE (x) = 1;
    6504          583 :         TREE_ADDRESSABLE (COMPOUND_LITERAL_EXPR_DECL (x)) = 1;
    6505          583 :         return true;
    6506              : 
    6507            0 :       case CONSTRUCTOR:
    6508            0 :         TREE_ADDRESSABLE (x) = 1;
    6509            0 :         return true;
    6510              : 
    6511      1323480 :       case VAR_DECL:
    6512      1323480 :       case CONST_DECL:
    6513      1323480 :       case PARM_DECL:
    6514      1323480 :       case RESULT_DECL:
    6515      1323480 :         if (C_DECL_REGISTER (x)
    6516      1323480 :             && DECL_NONLOCAL (x))
    6517              :           {
    6518            0 :             if (TREE_PUBLIC (x) || is_global_var (x))
    6519              :               {
    6520            0 :                 error
    6521            0 :                   ("global register variable %qD used in nested function", x);
    6522            0 :                 return false;
    6523              :               }
    6524            0 :             pedwarn (input_location, 0, "register variable %qD used in nested function", x);
    6525              :           }
    6526      1323480 :         else if (C_DECL_REGISTER (x))
    6527              :           {
    6528           73 :             if (TREE_PUBLIC (x) || is_global_var (x))
    6529            4 :               error ("address of global register variable %qD requested", x);
    6530          123 :             else if (override_register && !DECL_HARD_REGISTER (x))
    6531              :               {
    6532           54 :                 DECL_REGISTER (x) = 0;
    6533           54 :                 TREE_ADDRESSABLE (x) = 1;
    6534           54 :                 mark_decl_used (x, true);
    6535           54 :                 return true;
    6536              :               }
    6537              :             else
    6538           15 :               error ("address of register variable %qD requested", x);
    6539           19 :             return false;
    6540              :           }
    6541              : 
    6542              :         /* FALLTHRU */
    6543     51945888 :       case FUNCTION_DECL:
    6544     51945888 :         TREE_ADDRESSABLE (x) = 1;
    6545     51945888 :         mark_decl_used (x, true);
    6546              :         /* FALLTHRU */
    6547              :       default:
    6548              :         return true;
    6549              :     }
    6550              : }
    6551              : 
    6552              : /* Convert EXPR to TYPE, warning about conversion problems with
    6553              :    constants.  SEMANTIC_TYPE is the type this conversion would use
    6554              :    without excess precision. If SEMANTIC_TYPE is NULL, this function
    6555              :    is equivalent to convert_and_check. This function is a wrapper that
    6556              :    handles conversions that may be different than
    6557              :    the usual ones because of excess precision.  */
    6558              : 
    6559              : static tree
    6560     23629084 : ep_convert_and_check (location_t loc, tree type, tree expr,
    6561              :                       tree semantic_type)
    6562              : {
    6563     23629084 :   if (TREE_TYPE (expr) == type)
    6564              :     return expr;
    6565              : 
    6566              :   /* For C11, integer conversions may have results with excess
    6567              :      precision.  */
    6568      2062149 :   if (flag_isoc11 || !semantic_type)
    6569      2062145 :     return convert_and_check (loc, type, expr);
    6570              : 
    6571            4 :   if (TREE_CODE (TREE_TYPE (expr)) == INTEGER_TYPE
    6572            4 :       && TREE_TYPE (expr) != semantic_type)
    6573              :     {
    6574              :       /* For integers, we need to check the real conversion, not
    6575              :          the conversion to the excess precision type.  */
    6576            4 :       expr = convert_and_check (loc, semantic_type, expr);
    6577              :     }
    6578              :   /* Result type is the excess precision type, which should be
    6579              :      large enough, so do not check.  */
    6580            4 :   return convert (type, expr);
    6581              : }
    6582              : 
    6583              : /* If EXPR refers to a built-in declared without a prototype returns
    6584              :    the actual type of the built-in and, if non-null, set *BLTIN to
    6585              :    a pointer to the built-in.  Otherwise return the type of EXPR
    6586              :    and clear *BLTIN if non-null.  */
    6587              : 
    6588              : static tree
    6589      2829769 : type_or_builtin_type (tree expr, tree *bltin = NULL)
    6590              : {
    6591      2829769 :   tree dummy;
    6592      2829769 :   if (!bltin)
    6593            0 :     bltin = &dummy;
    6594              : 
    6595      2829769 :   *bltin = NULL_TREE;
    6596              : 
    6597      2829769 :   tree type = TREE_TYPE (expr);
    6598      2829769 :   if (TREE_CODE (expr) != ADDR_EXPR)
    6599              :     return type;
    6600              : 
    6601       209261 :   tree oper = TREE_OPERAND (expr, 0);
    6602       209261 :   if (!DECL_P (oper)
    6603       170703 :       || TREE_CODE (oper) != FUNCTION_DECL
    6604       245685 :       || !fndecl_built_in_p (oper, BUILT_IN_NORMAL))
    6605              :     return type;
    6606              : 
    6607         2085 :   built_in_function code = DECL_FUNCTION_CODE (oper);
    6608         2085 :   if (!C_DECL_BUILTIN_PROTOTYPE (oper))
    6609              :     return type;
    6610              : 
    6611         1977 :   if ((*bltin = builtin_decl_implicit (code)))
    6612          991 :     type = c_build_pointer_type (TREE_TYPE (*bltin));
    6613              : 
    6614              :   return type;
    6615              : }
    6616              : 
    6617              : /* Build and return a conditional expression IFEXP ? OP1 : OP2.  If
    6618              :    IFEXP_BCP then the condition is a call to __builtin_constant_p, and
    6619              :    if folded to an integer constant then the unselected half may
    6620              :    contain arbitrary operations not normally permitted in constant
    6621              :    expressions.  Set the location of the expression to LOC.  */
    6622              : 
    6623              : tree
    6624       403714 : build_conditional_expr (location_t colon_loc, tree ifexp, bool ifexp_bcp,
    6625              :                         tree op1, tree op1_original_type, location_t op1_loc,
    6626              :                         tree op2, tree op2_original_type, location_t op2_loc)
    6627              : {
    6628       403714 :   tree type1;
    6629       403714 :   tree type2;
    6630       403714 :   tree result_type = NULL;
    6631       403714 :   tree semantic_result_type = NULL;
    6632       403714 :   tree orig_op1 = op1, orig_op2 = op2;
    6633       403714 :   bool int_const, op1_int_operands, op2_int_operands, int_operands;
    6634       403714 :   bool ifexp_int_operands;
    6635       403714 :   tree ret;
    6636              : 
    6637       403714 :   op1_int_operands = EXPR_INT_CONST_OPERANDS (orig_op1);
    6638       110244 :   if (op1_int_operands)
    6639       110244 :     op1 = remove_c_maybe_const_expr (op1);
    6640       403714 :   op2_int_operands = EXPR_INT_CONST_OPERANDS (orig_op2);
    6641       145437 :   if (op2_int_operands)
    6642       145437 :     op2 = remove_c_maybe_const_expr (op2);
    6643       403714 :   ifexp_int_operands = EXPR_INT_CONST_OPERANDS (ifexp);
    6644       242646 :   if (ifexp_int_operands)
    6645       242646 :     ifexp = remove_c_maybe_const_expr (ifexp);
    6646              : 
    6647              :   /* Promote both alternatives.  */
    6648              : 
    6649       403714 :   if (TREE_CODE (TREE_TYPE (op1)) != VOID_TYPE)
    6650       399792 :     op1 = default_conversion (op1);
    6651       403714 :   if (TREE_CODE (TREE_TYPE (op2)) != VOID_TYPE)
    6652       373869 :     op2 = default_conversion (op2);
    6653              : 
    6654       403714 :   if (TREE_CODE (ifexp) == ERROR_MARK
    6655       403645 :       || TREE_CODE (TREE_TYPE (op1)) == ERROR_MARK
    6656       807345 :       || TREE_CODE (TREE_TYPE (op2)) == ERROR_MARK)
    6657           83 :     return error_mark_node;
    6658              : 
    6659       403631 :   tree bltin1 = NULL_TREE;
    6660       403631 :   tree bltin2 = NULL_TREE;
    6661       403631 :   type1 = type_or_builtin_type (op1, &bltin1);
    6662       403631 :   const enum tree_code code1 = TREE_CODE (type1);
    6663       403631 :   type2 = type_or_builtin_type (op2, &bltin2);
    6664       403631 :   const enum tree_code code2 = TREE_CODE (type2);
    6665              : 
    6666       403631 :   if (code1 == POINTER_TYPE && reject_gcc_builtin (op1))
    6667            1 :     return error_mark_node;
    6668              : 
    6669       403630 :   if (code2 == POINTER_TYPE && reject_gcc_builtin (op2))
    6670            1 :     return error_mark_node;
    6671              : 
    6672              :   /* C90 does not permit non-lvalue arrays in conditional expressions.
    6673              :      In C99 they will be pointers by now.  */
    6674       403629 :   if (code1 == ARRAY_TYPE || code2 == ARRAY_TYPE)
    6675              :     {
    6676            1 :       error_at (colon_loc, "non-lvalue array in conditional expression");
    6677            1 :       return error_mark_node;
    6678              :     }
    6679              : 
    6680       403628 :   if ((TREE_CODE (op1) == EXCESS_PRECISION_EXPR
    6681       403622 :        || TREE_CODE (op2) == EXCESS_PRECISION_EXPR)
    6682            7 :       && (code1 == INTEGER_TYPE || code1 == REAL_TYPE
    6683            0 :           || code1 == COMPLEX_TYPE || code1 == BITINT_TYPE)
    6684            7 :       && (code2 == INTEGER_TYPE || code2 == REAL_TYPE
    6685            0 :           || code2 == COMPLEX_TYPE || code2 == BITINT_TYPE))
    6686              :     {
    6687            7 :       semantic_result_type = c_common_type (type1, type2);
    6688            7 :       if (TREE_CODE (op1) == EXCESS_PRECISION_EXPR)
    6689              :         {
    6690            6 :           op1 = TREE_OPERAND (op1, 0);
    6691            6 :           type1 = TREE_TYPE (op1);
    6692            6 :           gcc_assert (TREE_CODE (type1) == code1);
    6693              :         }
    6694            7 :       if (TREE_CODE (op2) == EXCESS_PRECISION_EXPR)
    6695              :         {
    6696            1 :           op2 = TREE_OPERAND (op2, 0);
    6697            1 :           type2 = TREE_TYPE (op2);
    6698            1 :           gcc_assert (TREE_CODE (type2) == code2);
    6699              :         }
    6700              :     }
    6701              : 
    6702       403628 :   if (warn_cxx_compat)
    6703              :     {
    6704          418 :       tree t1 = op1_original_type ? op1_original_type : TREE_TYPE (orig_op1);
    6705          418 :       tree t2 = op2_original_type ? op2_original_type : TREE_TYPE (orig_op2);
    6706              : 
    6707          418 :       if (TREE_CODE (t1) == ENUMERAL_TYPE
    6708            6 :           && TREE_CODE (t2) == ENUMERAL_TYPE
    6709          424 :           && TYPE_MAIN_VARIANT (t1) != TYPE_MAIN_VARIANT (t2))
    6710            2 :         warning_at (colon_loc, OPT_Wc___compat,
    6711              :                     "different enum types in conditional is "
    6712              :                     "invalid in C++: %qT vs %qT", t1, t2);
    6713              :     }
    6714              : 
    6715       403628 :   if (warn_zero_as_null_pointer_constant
    6716           20 :       && c_inhibit_evaluation_warnings == 0)
    6717              :     {
    6718           20 :       if ((code1 == POINTER_TYPE || code1 == NULLPTR_TYPE)
    6719           20 :           && INTEGRAL_TYPE_P (type2) && null_pointer_constant_p (orig_op2))
    6720            5 :         warning_at (op2_loc, OPT_Wzero_as_null_pointer_constant,
    6721              :                     "zero as null pointer constant");
    6722              : 
    6723           20 :       if ((code2 == POINTER_TYPE || code2 == NULLPTR_TYPE)
    6724           20 :           && INTEGRAL_TYPE_P (type1) && null_pointer_constant_p (orig_op1))
    6725            5 :         warning_at (op1_loc, OPT_Wzero_as_null_pointer_constant,
    6726              :                     "zero as null pointer constant");
    6727              :     }
    6728              : 
    6729              :   /* Quickly detect the usual case where op1 and op2 have the same type
    6730              :      after promotion.  */
    6731       403628 :   if (TYPE_MAIN_VARIANT (type1) == TYPE_MAIN_VARIANT (type2))
    6732              :     {
    6733       268589 :       if (type1 == type2)
    6734              :         result_type = type1;
    6735              :       else
    6736         6394 :         result_type = TYPE_MAIN_VARIANT (type1);
    6737              :     }
    6738       135039 :   else if ((code1 == INTEGER_TYPE || code1 == REAL_TYPE
    6739        80384 :             || code1 == COMPLEX_TYPE || code1 == BITINT_TYPE)
    6740        54703 :            && (code2 == INTEGER_TYPE || code2 == REAL_TYPE
    6741        26152 :                || code2 == COMPLEX_TYPE || code2 == BITINT_TYPE))
    6742              :     {
    6743              :       /* In C11, a conditional expression between a floating-point
    6744              :          type and an integer type should convert the integer type to
    6745              :          the evaluation format of the floating-point type, with
    6746              :          possible excess precision.  */
    6747        28651 :       tree eptype1 = type1;
    6748        28651 :       tree eptype2 = type2;
    6749        28651 :       if (flag_isoc11)
    6750              :         {
    6751        28338 :           tree eptype;
    6752        11641 :           if (ANY_INTEGRAL_TYPE_P (type1)
    6753        28338 :               && (eptype = excess_precision_type (type2)) != NULL_TREE)
    6754              :             {
    6755            2 :               eptype2 = eptype;
    6756            2 :               if (!semantic_result_type)
    6757            2 :                 semantic_result_type = c_common_type (type1, type2);
    6758              :             }
    6759          501 :           else if (ANY_INTEGRAL_TYPE_P (type2)
    6760        28336 :                    && (eptype = excess_precision_type (type1)) != NULL_TREE)
    6761              :             {
    6762         4626 :               eptype1 = eptype;
    6763         4626 :               if (!semantic_result_type)
    6764         4626 :                 semantic_result_type = c_common_type (type1, type2);
    6765              :             }
    6766              :         }
    6767        28651 :       result_type = c_common_type (eptype1, eptype2);
    6768        28651 :       if (result_type == error_mark_node)
    6769              :         return error_mark_node;
    6770        28649 :       do_warn_double_promotion (result_type, type1, type2,
    6771              :                                 "implicit conversion from %qT to %qT to "
    6772              :                                 "match other result of conditional",
    6773              :                                 colon_loc);
    6774              : 
    6775              :       /* If -Wsign-compare, warn here if type1 and type2 have
    6776              :          different signedness.  We'll promote the signed to unsigned
    6777              :          and later code won't know it used to be different.
    6778              :          Do this check on the original types, so that explicit casts
    6779              :          will be considered, but default promotions won't.  */
    6780        28649 :       if (c_inhibit_evaluation_warnings == 0)
    6781              :         {
    6782        28458 :           int unsigned_op1 = TYPE_UNSIGNED (TREE_TYPE (orig_op1));
    6783        28458 :           int unsigned_op2 = TYPE_UNSIGNED (TREE_TYPE (orig_op2));
    6784              : 
    6785        28458 :           if (unsigned_op1 ^ unsigned_op2)
    6786              :             {
    6787              :               /* Do not warn if the result type is signed, since the
    6788              :                  signed type will only be chosen if it can represent
    6789              :                  all the values of the unsigned type.  */
    6790        13019 :               if (!TYPE_UNSIGNED (result_type))
    6791              :                 /* OK */;
    6792              :               else
    6793              :                 {
    6794        12915 :                   bool op1_maybe_const = true;
    6795        12915 :                   bool op2_maybe_const = true;
    6796              : 
    6797              :                   /* Do not warn if the signed quantity is an
    6798              :                      unsuffixed integer literal (or some static
    6799              :                      constant expression involving such literals) and
    6800              :                      it is non-negative.  This warning requires the
    6801              :                      operands to be folded for best results, so do
    6802              :                      that folding in this case even without
    6803              :                      warn_sign_compare to avoid warning options
    6804              :                      possibly affecting code generation.  */
    6805        12915 :                   c_inhibit_evaluation_warnings
    6806        12915 :                     += (ifexp == truthvalue_false_node);
    6807        12915 :                   op1 = c_fully_fold (op1, require_constant_value,
    6808              :                                       &op1_maybe_const);
    6809        12915 :                   c_inhibit_evaluation_warnings
    6810        12915 :                     -= (ifexp == truthvalue_false_node);
    6811              : 
    6812        12915 :                   c_inhibit_evaluation_warnings
    6813        12915 :                     += (ifexp == truthvalue_true_node);
    6814        12915 :                   op2 = c_fully_fold (op2, require_constant_value,
    6815              :                                       &op2_maybe_const);
    6816        12915 :                   c_inhibit_evaluation_warnings
    6817        12915 :                     -= (ifexp == truthvalue_true_node);
    6818              : 
    6819        12915 :                   if (warn_sign_compare)
    6820              :                     {
    6821         1245 :                       if ((unsigned_op2
    6822          685 :                            && tree_expr_nonnegative_p (op1))
    6823         1248 :                           || (unsigned_op1
    6824          560 :                               && tree_expr_nonnegative_p (op2)))
    6825              :                         /* OK */;
    6826           10 :                       else if (unsigned_op2)
    6827            3 :                         warning_at (op1_loc, OPT_Wsign_compare,
    6828              :                                     "operand of %<?:%> changes signedness from "
    6829              :                                     "%qT to %qT due to unsignedness of other "
    6830            3 :                                     "operand", TREE_TYPE (orig_op1),
    6831            3 :                                     TREE_TYPE (orig_op2));
    6832              :                       else
    6833            7 :                         warning_at (op2_loc, OPT_Wsign_compare,
    6834              :                                     "operand of %<?:%> changes signedness from "
    6835              :                                     "%qT to %qT due to unsignedness of other "
    6836            7 :                                     "operand", TREE_TYPE (orig_op2),
    6837            7 :                                     TREE_TYPE (orig_op1));
    6838              :                     }
    6839        12915 :                   if (!op1_maybe_const || TREE_CODE (op1) != INTEGER_CST)
    6840         7565 :                     op1 = c_wrap_maybe_const (op1, !op1_maybe_const);
    6841        12915 :                   if (!op2_maybe_const || TREE_CODE (op2) != INTEGER_CST)
    6842         4394 :                     op2 = c_wrap_maybe_const (op2, !op2_maybe_const);
    6843              :                 }
    6844              :             }
    6845              :         }
    6846              :     }
    6847       106388 :   else if (code1 == VOID_TYPE || code2 == VOID_TYPE)
    6848              :     {
    6849        25995 :       if (code1 != VOID_TYPE || code2 != VOID_TYPE)
    6850        25995 :         pedwarn (colon_loc, OPT_Wpedantic,
    6851              :                  "ISO C forbids conditional expr with only one void side");
    6852        25995 :       result_type = void_type_node;
    6853              :     }
    6854        80393 :   else if (code1 == POINTER_TYPE && code2 == POINTER_TYPE)
    6855              :     {
    6856        79996 :       addr_space_t as1 = TYPE_ADDR_SPACE (TREE_TYPE (type1));
    6857        79996 :       addr_space_t as2 = TYPE_ADDR_SPACE (TREE_TYPE (type2));
    6858        79996 :       addr_space_t as_common;
    6859              : 
    6860        79996 :       if (comp_target_types (colon_loc, type1, type2))
    6861              :         {
    6862         2620 :           ifexp = save_expr (ifexp);
    6863         2620 :           result_type = common_pointer_type (type1, type2, ifexp);
    6864              :         }
    6865        77376 :       else if (null_pointer_constant_p (orig_op1))
    6866              :         result_type = type2;
    6867        73214 :       else if (null_pointer_constant_p (orig_op2))
    6868              :         result_type = type1;
    6869        35286 :       else if (!addr_space_superset (as1, as2, &as_common))
    6870              :         {
    6871            0 :           error_at (colon_loc, "pointers to disjoint address spaces "
    6872              :                     "used in conditional expression");
    6873            0 :           return error_mark_node;
    6874              :         }
    6875        35286 :       else if ((VOID_TYPE_P (TREE_TYPE (type1))
    6876          330 :                 && !TYPE_ATOMIC (TREE_TYPE (type1)))
    6877        35288 :                || (VOID_TYPE_P (TREE_TYPE (type2))
    6878        34911 :                    && !TYPE_ATOMIC (TREE_TYPE (type2))))
    6879              :         {
    6880        35238 :           tree t1 = TREE_TYPE (type1);
    6881        35238 :           tree t2 = TREE_TYPE (type2);
    6882        35238 :           if (!(VOID_TYPE_P (t1)
    6883          329 :                 && !TYPE_ATOMIC (t1)))
    6884              :            {
    6885              :              /* roles are swapped */
    6886        34910 :              t1 = t2;
    6887        34910 :              t2 = TREE_TYPE (type1);
    6888              :            }
    6889        35238 :           tree t2_stripped = strip_array_types (t2);
    6890        35238 :           if ((TREE_CODE (t2) == ARRAY_TYPE)
    6891        35238 :               && (TYPE_QUALS (t2_stripped) & ~TYPE_QUALS (t1)))
    6892              :             {
    6893           18 :               if (!flag_isoc23)
    6894            6 :                 warning_at (colon_loc, OPT_Wdiscarded_array_qualifiers,
    6895              :                             "pointer to array loses qualifier "
    6896              :                             "in conditional expression");
    6897           12 :               else if (warn_c11_c23_compat > 0)
    6898            6 :                 warning_at (colon_loc, OPT_Wc11_c23_compat,
    6899              :                             "pointer to array loses qualifier "
    6900              :                             "in conditional expression in ISO C before C23");
    6901              :             }
    6902        35238 :           if (TREE_CODE (t2) == FUNCTION_TYPE)
    6903            4 :             pedwarn (colon_loc, OPT_Wpedantic,
    6904              :                      "ISO C forbids conditional expr between "
    6905              :                      "%<void *%> and function pointer");
    6906              :           /* for array, use qualifiers of element type */
    6907        35238 :           if (flag_isoc23)
    6908        11457 :             t2 = t2_stripped;
    6909        35238 :           result_type = c_build_pointer_type (qualify_type (t1, t2));
    6910              :         }
    6911              :       /* Objective-C pointer comparisons are a bit more lenient.  */
    6912           48 :       else if (objc_have_common_type (type1, type2, -3, NULL_TREE))
    6913            0 :         result_type = objc_common_type (type1, type2);
    6914              :       else
    6915              :         {
    6916           48 :           int qual = ENCODE_QUAL_ADDR_SPACE (as_common);
    6917           48 :           enum diagnostics::kind kind = diagnostics::kind::permerror;
    6918           48 :           if (!flag_isoc99)
    6919              :             /* This downgrade to a warning ensures that -std=gnu89
    6920              :                -pedantic-errors does not flag these mismatches between
    6921              :                builtins as errors (as diagnostics::kind::permerror would)
    6922              :                ISO C99 and later do not have implicit function declarations,
    6923              :                so the mismatch cannot occur naturally there.  */
    6924            5 :             kind = (bltin1 && bltin2
    6925            5 :                     ? diagnostics::kind::warning
    6926              :                     : diagnostics::kind::pedwarn);
    6927           48 :           if (emit_diagnostic (kind, colon_loc, OPT_Wincompatible_pointer_types,
    6928              :                                "pointer type mismatch "
    6929              :                                "in conditional expression"))
    6930              :             {
    6931           46 :               inform (op1_loc, "first expression has type %qT", type1);
    6932           46 :               inform (op2_loc, "second expression has type %qT", type2);
    6933              :             }
    6934           48 :           result_type = c_build_pointer_type
    6935           48 :                           (c_build_qualified_type (void_type_node, qual));
    6936              :         }
    6937              :     }
    6938          397 :   else if (code1 == POINTER_TYPE
    6939          277 :            && (code2 == INTEGER_TYPE || code2 == BITINT_TYPE))
    6940              :     {
    6941          273 :       if (!null_pointer_constant_p (orig_op2))
    6942           14 :         permerror_opt (colon_loc, OPT_Wint_conversion,
    6943              :                        "pointer/integer type mismatch "
    6944              :                        "in conditional expression");
    6945              :       else
    6946              :         {
    6947          259 :           op2 = null_pointer_node;
    6948              :         }
    6949              :       result_type = type1;
    6950              :     }
    6951          124 :   else if (code2 == POINTER_TYPE
    6952           90 :            && (code1 == INTEGER_TYPE || code1 == BITINT_TYPE))
    6953              :     {
    6954           86 :       if (!null_pointer_constant_p (orig_op1))
    6955           14 :         permerror_opt (colon_loc, OPT_Wint_conversion,
    6956              :                        "pointer/integer type mismatch "
    6957              :                        "in conditional expression");
    6958              :       else
    6959              :         {
    6960           72 :           op1 = null_pointer_node;
    6961              :         }
    6962              :       result_type = type2;
    6963              :     }
    6964              :   /* 6.5.15: "if one is a null pointer constant (other than a pointer) or has
    6965              :      type nullptr_t and the other is a pointer, the result type is the pointer
    6966              :      type."  */
    6967           38 :   else if (code1 == NULLPTR_TYPE && code2 == POINTER_TYPE)
    6968              :     result_type = type2;
    6969           34 :   else if (code1 == POINTER_TYPE && code2 == NULLPTR_TYPE)
    6970              :     result_type = type1;
    6971            8 :   else if (RECORD_OR_UNION_TYPE_P (type1) && RECORD_OR_UNION_TYPE_P (type2)
    6972           38 :            && comptypes (TYPE_MAIN_VARIANT (type1),
    6973            8 :                          TYPE_MAIN_VARIANT (type2)))
    6974            8 :     result_type = composite_type (TYPE_MAIN_VARIANT (type1),
    6975            8 :                                   TYPE_MAIN_VARIANT (type2));
    6976              : 
    6977       403604 :   if (!result_type)
    6978              :     {
    6979           22 :       if (flag_cond_mismatch)
    6980            0 :         result_type = void_type_node;
    6981              :       else
    6982              :         {
    6983           22 :           error_at (colon_loc, "type mismatch in conditional expression");
    6984           22 :           return error_mark_node;
    6985              :         }
    6986              :     }
    6987              : 
    6988              :   /* Merge const and volatile flags of the incoming types.  */
    6989       403604 :   result_type
    6990       403604 :     = build_type_variant (result_type,
    6991              :                           TYPE_READONLY (type1) || TYPE_READONLY (type2),
    6992              :                           TYPE_VOLATILE (type1) || TYPE_VOLATILE (type2));
    6993              : 
    6994       403604 :   op1 = ep_convert_and_check (colon_loc, result_type, op1,
    6995              :                               semantic_result_type);
    6996       403604 :   op2 = ep_convert_and_check (colon_loc, result_type, op2,
    6997              :                               semantic_result_type);
    6998              : 
    6999       403604 :   if (ifexp_bcp && ifexp == truthvalue_true_node)
    7000              :     {
    7001           10 :       op2_int_operands = true;
    7002           10 :       op1 = c_fully_fold (op1, require_constant_value, NULL);
    7003              :     }
    7004           59 :   if (ifexp_bcp && ifexp == truthvalue_false_node)
    7005              :     {
    7006           49 :       op1_int_operands = true;
    7007           49 :       op2 = c_fully_fold (op2, require_constant_value, NULL);
    7008              :     }
    7009       904221 :   int_const = int_operands = (ifexp_int_operands
    7010       403604 :                               && op1_int_operands
    7011       403604 :                               && op2_int_operands);
    7012        97013 :   if (int_operands)
    7013              :     {
    7014        97013 :       int_const = ((ifexp == truthvalue_true_node
    7015        58730 :                     && TREE_CODE (orig_op1) == INTEGER_CST
    7016        58716 :                     && !TREE_OVERFLOW (orig_op1))
    7017        97027 :                    || (ifexp == truthvalue_false_node
    7018        38237 :                        && TREE_CODE (orig_op2) == INTEGER_CST
    7019        38221 :                        && !TREE_OVERFLOW (orig_op2)));
    7020              :     }
    7021              : 
    7022              :   /* Need to convert condition operand into a vector mask.  */
    7023       403604 :   if (VECTOR_TYPE_P (TREE_TYPE (ifexp)))
    7024              :     {
    7025            0 :       tree vectype = TREE_TYPE (ifexp);
    7026            0 :       tree elem_type = TREE_TYPE (vectype);
    7027            0 :       tree zero = build_int_cst (elem_type, 0);
    7028            0 :       tree zero_vec = build_vector_from_val (vectype, zero);
    7029            0 :       tree cmp_type = truth_type_for (vectype);
    7030            0 :       ifexp = build2 (NE_EXPR, cmp_type, ifexp, zero_vec);
    7031              :     }
    7032              : 
    7033       403604 :   if (int_const || (ifexp_bcp && TREE_CODE (ifexp) == INTEGER_CST))
    7034        96969 :     ret = fold_build3_loc (colon_loc, COND_EXPR, result_type, ifexp, op1, op2);
    7035              :   else
    7036              :     {
    7037       306635 :       if (int_operands)
    7038              :         {
    7039              :           /* Use c_fully_fold here, since C_MAYBE_CONST_EXPR might be
    7040              :              nested inside of the expression.  */
    7041           76 :           op1 = c_fully_fold (op1, false, NULL);
    7042           76 :           op2 = c_fully_fold (op2, false, NULL);
    7043              :         }
    7044       306635 :       ret = build3 (COND_EXPR, result_type, ifexp, op1, op2);
    7045       306635 :       if (int_operands)
    7046           76 :         ret = note_integer_operands (ret);
    7047              :     }
    7048       403604 :   if (semantic_result_type)
    7049         4635 :     ret = build1 (EXCESS_PRECISION_EXPR, semantic_result_type, ret);
    7050              : 
    7051       403604 :   protected_set_expr_location (ret, colon_loc);
    7052              : 
    7053              :   /* If the OP1 and OP2 are the same and don't have side-effects,
    7054              :      warn here, because the COND_EXPR will be turned into OP1.  */
    7055       403604 :   if (warn_duplicated_branches
    7056           34 :       && TREE_CODE (ret) == COND_EXPR
    7057       403638 :       && (op1 == op2 || operand_equal_p (op1, op2, OEP_ADDRESS_OF_SAME_FIELD)))
    7058           13 :     warning_at (EXPR_LOCATION (ret), OPT_Wduplicated_branches,
    7059              :                 "this condition has identical branches");
    7060              : 
    7061              :   return ret;
    7062              : }
    7063              : 
    7064              : /* EXPR is an expression, location LOC, whose result is discarded.
    7065              :    Warn if it is a call to a nodiscard function (or a COMPOUND_EXPR
    7066              :    whose right-hand operand is such a call, possibly recursively).  */
    7067              : 
    7068              : static void
    7069      6483625 : maybe_warn_nodiscard (location_t loc, tree expr)
    7070              : {
    7071      6483625 :   if (VOID_TYPE_P (TREE_TYPE (expr)))
    7072              :     return;
    7073      3965022 :   while (TREE_CODE (expr) == COMPOUND_EXPR)
    7074              :     {
    7075        49452 :       expr = TREE_OPERAND (expr, 1);
    7076        49452 :       if (EXPR_HAS_LOCATION (expr))
    7077        32351 :         loc = EXPR_LOCATION (expr);
    7078              :     }
    7079      3915570 :   if (TREE_CODE (expr) != CALL_EXPR)
    7080              :     return;
    7081       347072 :   tree fn = CALL_EXPR_FN (expr);
    7082       347072 :   if (!fn)
    7083              :     return;
    7084       347056 :   tree attr;
    7085       347056 :   if (TREE_CODE (fn) == ADDR_EXPR
    7086       346389 :       && TREE_CODE (TREE_OPERAND (fn, 0)) == FUNCTION_DECL
    7087       693445 :       && (attr = lookup_attribute ("nodiscard",
    7088       346389 :                                    DECL_ATTRIBUTES (TREE_OPERAND (fn, 0)))))
    7089              :     {
    7090            3 :       fn = TREE_OPERAND (fn, 0);
    7091            3 :       tree args = TREE_VALUE (attr);
    7092            3 :       if (args)
    7093            1 :         args = TREE_VALUE (args);
    7094            3 :       auto_diagnostic_group d;
    7095            3 :       auto_urlify_attributes sentinel;
    7096            3 :       int warned;
    7097            3 :       if (args)
    7098            1 :         warned = warning_at (loc, OPT_Wunused_result,
    7099              :                              "ignoring return value of %qD, declared with "
    7100              :                              "attribute %<nodiscard%>: %E", fn, args);
    7101              :       else
    7102            2 :         warned = warning_at (loc, OPT_Wunused_result,
    7103              :                              "ignoring return value of %qD, declared with "
    7104              :                              "attribute %<nodiscard%>", fn);
    7105            3 :       if (warned)
    7106            3 :         inform (DECL_SOURCE_LOCATION (fn), "declared here");
    7107            3 :     }
    7108              :   else
    7109              :     {
    7110       347053 :       tree rettype = TREE_TYPE (TREE_TYPE (TREE_TYPE (fn)));
    7111       347053 :       attr = lookup_attribute ("nodiscard", TYPE_ATTRIBUTES (rettype));
    7112       347053 :       if (!attr)
    7113       347041 :         return;
    7114           12 :       tree args = TREE_VALUE (attr);
    7115           12 :       if (args)
    7116            5 :         args = TREE_VALUE (args);
    7117           12 :       auto_diagnostic_group d;
    7118           12 :       auto_urlify_attributes sentinel;
    7119           12 :       int warned;
    7120           12 :       if (args)
    7121            5 :         warned = warning_at (loc, OPT_Wunused_result,
    7122              :                              "ignoring return value of type %qT, declared "
    7123              :                              "with attribute %<nodiscard%>: %E",
    7124              :                              rettype, args);
    7125              :       else
    7126            7 :         warned = warning_at (loc, OPT_Wunused_result,
    7127              :                              "ignoring return value of type %qT, declared "
    7128              :                              "with attribute %<nodiscard%>", rettype);
    7129           12 :       if (warned)
    7130              :         {
    7131           12 :           if (TREE_CODE (fn) == ADDR_EXPR)
    7132              :             {
    7133           11 :               fn = TREE_OPERAND (fn, 0);
    7134           11 :               if (TREE_CODE (fn) == FUNCTION_DECL)
    7135           11 :                 inform (DECL_SOURCE_LOCATION (fn),
    7136              :                         "in call to %qD, declared here", fn);
    7137              :             }
    7138              :         }
    7139           12 :     }
    7140              : }
    7141              : 
    7142              : /* Return a compound expression that performs two expressions and
    7143              :    returns the value of the second of them.
    7144              : 
    7145              :    LOC is the location of the COMPOUND_EXPR.  */
    7146              : 
    7147              : tree
    7148       111792 : build_compound_expr (location_t loc, tree expr1, tree expr2)
    7149              : {
    7150       111792 :   bool expr1_int_operands, expr2_int_operands;
    7151       111792 :   tree eptype = NULL_TREE;
    7152       111792 :   tree ret;
    7153              : 
    7154       111792 :   expr1_int_operands = EXPR_INT_CONST_OPERANDS (expr1);
    7155          326 :   if (expr1_int_operands)
    7156          326 :     expr1 = remove_c_maybe_const_expr (expr1);
    7157       111792 :   expr2_int_operands = EXPR_INT_CONST_OPERANDS (expr2);
    7158        66105 :   if (expr2_int_operands)
    7159        66105 :     expr2 = remove_c_maybe_const_expr (expr2);
    7160              : 
    7161       111792 :   if (TREE_CODE (expr1) == EXCESS_PRECISION_EXPR)
    7162            0 :     expr1 = TREE_OPERAND (expr1, 0);
    7163       111792 :   if (TREE_CODE (expr2) == EXCESS_PRECISION_EXPR)
    7164              :     {
    7165            1 :       eptype = TREE_TYPE (expr2);
    7166            1 :       expr2 = TREE_OPERAND (expr2, 0);
    7167              :     }
    7168              : 
    7169       111792 :   if (!TREE_SIDE_EFFECTS (expr1))
    7170              :     {
    7171              :       /* The left-hand operand of a comma expression is like an expression
    7172              :          statement: with -Wunused, we should warn if it doesn't have
    7173              :          any side-effects, unless it was explicitly cast to (void).  */
    7174         8406 :       if (warn_unused_value)
    7175              :         {
    7176         1257 :           if (VOID_TYPE_P (TREE_TYPE (expr1))
    7177         1257 :               && CONVERT_EXPR_P (expr1))
    7178              :             ; /* (void) a, b */
    7179           14 :           else if (VOID_TYPE_P (TREE_TYPE (expr1))
    7180            4 :                    && TREE_CODE (expr1) == COMPOUND_EXPR
    7181           17 :                    && CONVERT_EXPR_P (TREE_OPERAND (expr1, 1)))
    7182              :             ; /* (void) a, (void) b, c */
    7183              :           else
    7184           11 :             warning_at (loc, OPT_Wunused_value,
    7185              :                         "left-hand operand of comma expression has no effect");
    7186              :         }
    7187              :     }
    7188       103386 :   else if (TREE_CODE (expr1) == COMPOUND_EXPR
    7189        13111 :            && warn_unused_value)
    7190              :     {
    7191              :       tree r = expr1;
    7192              :       location_t cloc = loc;
    7193         4833 :       while (TREE_CODE (r) == COMPOUND_EXPR)
    7194              :         {
    7195         2417 :           if (EXPR_HAS_LOCATION (r))
    7196         2417 :             cloc = EXPR_LOCATION (r);
    7197         2417 :           r = TREE_OPERAND (r, 1);
    7198              :         }
    7199         2416 :       if (!TREE_SIDE_EFFECTS (r)
    7200            4 :           && !VOID_TYPE_P (TREE_TYPE (r))
    7201         2420 :           && !CONVERT_EXPR_P (r))
    7202            4 :         warning_at (cloc, OPT_Wunused_value,
    7203              :                     "right-hand operand of comma expression has no effect");
    7204              :     }
    7205              : 
    7206              :   /* With -Wunused, we should also warn if the left-hand operand does have
    7207              :      side-effects, but computes a value which is not used.  For example, in
    7208              :      `foo() + bar(), baz()' the result of the `+' operator is not used,
    7209              :      so we should issue a warning.  */
    7210       100970 :   else if (warn_unused_value)
    7211        35400 :     warn_if_unused_value (expr1, loc);
    7212              : 
    7213       111792 :   maybe_warn_nodiscard (loc, expr1);
    7214              : 
    7215       111792 :   if (expr2 == error_mark_node)
    7216              :     return error_mark_node;
    7217              : 
    7218       111779 :   ret = build2 (COMPOUND_EXPR, TREE_TYPE (expr2), expr1, expr2);
    7219              : 
    7220       111779 :   if (flag_isoc99
    7221              :       && expr1_int_operands
    7222       111323 :       && expr2_int_operands)
    7223          153 :     ret = note_integer_operands (ret);
    7224              : 
    7225       111779 :   if (eptype)
    7226            1 :     ret = build1 (EXCESS_PRECISION_EXPR, eptype, ret);
    7227              : 
    7228       111779 :   protected_set_expr_location (ret, loc);
    7229       111779 :   return ret;
    7230              : }
    7231              : 
    7232              : /* Issue -Wcast-qual warnings when appropriate.  TYPE is the type to
    7233              :    which we are casting.  OTYPE is the type of the expression being
    7234              :    cast.  Both TYPE and OTYPE are pointer types.  LOC is the location
    7235              :    of the cast.  -Wcast-qual appeared on the command line.  Named
    7236              :    address space qualifiers are not handled here, because they result
    7237              :    in different warnings.  */
    7238              : 
    7239              : static void
    7240        13581 : handle_warn_cast_qual (location_t loc, tree type, tree otype)
    7241              : {
    7242        13581 :   tree in_type = type;
    7243        13581 :   tree in_otype = otype;
    7244        13581 :   int added = 0;
    7245        13581 :   int discarded = 0;
    7246        13751 :   bool is_const;
    7247              : 
    7248              :   /* Check that the qualifiers on IN_TYPE are a superset of the
    7249              :      qualifiers of IN_OTYPE.  The outermost level of POINTER_TYPE
    7250              :      nodes is uninteresting and we stop as soon as we hit a
    7251              :      non-POINTER_TYPE node on either type.  */
    7252        13751 :   do
    7253              :     {
    7254        13751 :       in_otype = TREE_TYPE (in_otype);
    7255        13751 :       in_type = TREE_TYPE (in_type);
    7256              : 
    7257              :       /* GNU C allows cv-qualified function types.  'const' means the
    7258              :          function is very pure, 'volatile' means it can't return.  We
    7259              :          need to warn when such qualifiers are added, not when they're
    7260              :          taken away.  */
    7261        13751 :       if (TREE_CODE (in_otype) == FUNCTION_TYPE
    7262           26 :           && TREE_CODE (in_type) == FUNCTION_TYPE)
    7263           18 :         added |= (TYPE_QUALS_NO_ADDR_SPACE (in_type)
    7264           18 :                   & ~TYPE_QUALS_NO_ADDR_SPACE (in_otype));
    7265              :       else
    7266        13733 :         discarded |= (TYPE_QUALS_NO_ADDR_SPACE (in_otype)
    7267        13733 :                       & ~TYPE_QUALS_NO_ADDR_SPACE (in_type));
    7268              :     }
    7269        13751 :   while (TREE_CODE (in_type) == POINTER_TYPE
    7270        13751 :          && TREE_CODE (in_otype) == POINTER_TYPE);
    7271              : 
    7272        13581 :   if (added)
    7273            2 :     warning_at (loc, OPT_Wcast_qual,
    7274              :                 "cast adds %q#v qualifier to function type", added);
    7275              : 
    7276        13581 :   if (discarded)
    7277              :     /* There are qualifiers present in IN_OTYPE that are not present
    7278              :        in IN_TYPE.  */
    7279         1117 :     warning_at (loc, OPT_Wcast_qual,
    7280              :                 "cast discards %qv qualifier from pointer target type",
    7281              :                 discarded);
    7282              : 
    7283        13581 :   if (added || discarded)
    7284              :     return;
    7285              : 
    7286              :   /* A cast from **T to const **T is unsafe, because it can cause a
    7287              :      const value to be changed with no additional warning.  We only
    7288              :      issue this warning if T is the same on both sides, and we only
    7289              :      issue the warning if there are the same number of pointers on
    7290              :      both sides, as otherwise the cast is clearly unsafe anyhow.  A
    7291              :      cast is unsafe when a qualifier is added at one level and const
    7292              :      is not present at all outer levels.
    7293              : 
    7294              :      To issue this warning, we check at each level whether the cast
    7295              :      adds new qualifiers not already seen.  We don't need to special
    7296              :      case function types, as they won't have the same
    7297              :      TYPE_MAIN_VARIANT.  */
    7298              : 
    7299        12462 :   if (TYPE_MAIN_VARIANT (in_type) != TYPE_MAIN_VARIANT (in_otype))
    7300              :     return;
    7301          227 :   if (TREE_CODE (TREE_TYPE (type)) != POINTER_TYPE)
    7302              :     return;
    7303              : 
    7304           48 :   in_type = type;
    7305           48 :   in_otype = otype;
    7306           48 :   is_const = TYPE_READONLY (TREE_TYPE (in_type));
    7307          130 :   do
    7308              :     {
    7309          130 :       in_type = TREE_TYPE (in_type);
    7310          130 :       in_otype = TREE_TYPE (in_otype);
    7311          130 :       if ((TYPE_QUALS (in_type) &~ TYPE_QUALS (in_otype)) != 0
    7312          130 :           && !is_const)
    7313              :         {
    7314           27 :           warning_at (loc, OPT_Wcast_qual,
    7315              :                       "to be safe all intermediate pointers in cast from "
    7316              :                       "%qT to %qT must be %<const%> qualified",
    7317              :                       otype, type);
    7318           27 :           break;
    7319              :         }
    7320          103 :       if (is_const)
    7321           72 :         is_const = TYPE_READONLY (in_type);
    7322              :     }
    7323          103 :   while (TREE_CODE (in_type) == POINTER_TYPE);
    7324              : }
    7325              : 
    7326              : /* Heuristic check if two parameter types can be considered ABI-equivalent.  */
    7327              : 
    7328              : static bool
    7329         1312 : c_safe_arg_type_equiv_p (tree t1, tree t2)
    7330              : {
    7331         1312 :   if (error_operand_p (t1) || error_operand_p (t2))
    7332              :     return true;
    7333              : 
    7334         1311 :   t1 = TYPE_MAIN_VARIANT (t1);
    7335         1311 :   t2 = TYPE_MAIN_VARIANT (t2);
    7336              : 
    7337         1311 :   if (TREE_CODE (t1) == POINTER_TYPE
    7338          229 :       && TREE_CODE (t2) == POINTER_TYPE)
    7339              :     return true;
    7340              : 
    7341              :   /* Only the precision of the parameter matters.  This check should
    7342              :      make sure that the callee does not see undefined values in argument
    7343              :      registers.  */
    7344         1103 :   if (INTEGRAL_TYPE_P (t1)
    7345          913 :       && INTEGRAL_TYPE_P (t2)
    7346         1448 :       && TYPE_PRECISION (t1) == TYPE_PRECISION (t2))
    7347              :     return true;
    7348              : 
    7349          938 :   return comptypes (t1, t2);
    7350              : }
    7351              : 
    7352              : /* Check if a type cast between two function types can be considered safe.  */
    7353              : 
    7354              : static bool
    7355         7559 : c_safe_function_type_cast_p (tree t1, tree t2)
    7356              : {
    7357         7559 :   if (TREE_TYPE (t1) == void_type_node &&
    7358         5561 :       TYPE_ARG_TYPES (t1) == void_list_node)
    7359              :     return true;
    7360              : 
    7361         3722 :   if (TREE_TYPE (t2) == void_type_node &&
    7362         2889 :       TYPE_ARG_TYPES (t2) == void_list_node)
    7363              :     return true;
    7364              : 
    7365          892 :   if (!c_safe_arg_type_equiv_p (TREE_TYPE (t1), TREE_TYPE (t2)))
    7366              :     return false;
    7367              : 
    7368          197 :   for (t1 = TYPE_ARG_TYPES (t1), t2 = TYPE_ARG_TYPES (t2);
    7369          513 :        t1 && t2;
    7370          316 :        t1 = TREE_CHAIN (t1), t2 = TREE_CHAIN (t2))
    7371          420 :     if (!c_safe_arg_type_equiv_p (TREE_VALUE (t1), TREE_VALUE (t2)))
    7372              :       return false;
    7373              : 
    7374              :   return true;
    7375              : }
    7376              : 
    7377              : /* Build an expression representing a cast to type TYPE of expression EXPR.
    7378              :    LOC is the location of the cast-- typically the open paren of the cast.  */
    7379              : 
    7380              : tree
    7381    120253424 : build_c_cast (location_t loc, tree type, tree expr)
    7382              : {
    7383    120253424 :   tree value;
    7384              : 
    7385    120253424 :   bool int_operands = EXPR_INT_CONST_OPERANDS (expr);
    7386              : 
    7387    120253424 :   if (TREE_CODE (expr) == EXCESS_PRECISION_EXPR)
    7388           66 :     expr = TREE_OPERAND (expr, 0);
    7389              : 
    7390    120253424 :   value = expr;
    7391    120253424 :   if (int_operands)
    7392      6873025 :     value = remove_c_maybe_const_expr (value);
    7393              : 
    7394    120253424 :   if (type == error_mark_node || expr == error_mark_node)
    7395              :     return error_mark_node;
    7396              : 
    7397              :   /* The ObjC front-end uses TYPE_MAIN_VARIANT to tie together types differing
    7398              :      only in <protocol> qualifications.  But when constructing cast expressions,
    7399              :      the protocols do matter and must be kept around.  */
    7400    120252404 :   if (objc_is_object_ptr (type) && objc_is_object_ptr (TREE_TYPE (expr)))
    7401            0 :     return build1 (NOP_EXPR, type, expr);
    7402              : 
    7403    120252404 :   type = TYPE_MAIN_VARIANT (type);
    7404              : 
    7405    120252404 :   if (TREE_CODE (type) == ARRAY_TYPE)
    7406              :     {
    7407           13 :       error_at (loc, "cast specifies array type");
    7408           13 :       return error_mark_node;
    7409              :     }
    7410              : 
    7411    120252391 :   if (TREE_CODE (type) == FUNCTION_TYPE)
    7412              :     {
    7413            6 :       error_at (loc, "cast specifies function type");
    7414            6 :       return error_mark_node;
    7415              :     }
    7416              : 
    7417    120252385 :   if (!VOID_TYPE_P (type))
    7418              :     {
    7419    120207880 :       value = require_complete_type (loc, value);
    7420    120207880 :       if (value == error_mark_node)
    7421              :         return error_mark_node;
    7422              :     }
    7423              : 
    7424    120252384 :   if (type == TYPE_MAIN_VARIANT (TREE_TYPE (value)))
    7425              :     {
    7426     18121171 :       if (RECORD_OR_UNION_TYPE_P (type)
    7427     18121171 :           && pedwarn (loc, OPT_Wpedantic,
    7428              :                       "ISO C forbids casting nonscalar to the same type"))
    7429              :               ;
    7430     18121167 :       else if (warn_useless_cast && c_inhibit_evaluation_warnings == 0)
    7431            8 :         warning_at (loc, OPT_Wuseless_cast,
    7432              :                     "useless cast to type %qT", type);
    7433              : 
    7434              :       /* Convert to remove any qualifiers from VALUE's type.  */
    7435     18121171 :       value = convert (type, value);
    7436              :     }
    7437    102131213 :   else if (TREE_CODE (type) == UNION_TYPE)
    7438              :     {
    7439          137 :       tree field;
    7440              : 
    7441          192 :       for (field = TYPE_FIELDS (type); field; field = DECL_CHAIN (field))
    7442          185 :         if (TREE_TYPE (field) != error_mark_node
    7443          369 :             && comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (field)),
    7444          184 :                           TYPE_MAIN_VARIANT (TREE_TYPE (value))))
    7445              :           break;
    7446              : 
    7447          137 :       if (field)
    7448              :         {
    7449          130 :           tree t;
    7450          130 :           bool maybe_const = true;
    7451              : 
    7452          130 :           pedwarn (loc, OPT_Wpedantic, "ISO C forbids casts to union type");
    7453          130 :           t = c_fully_fold (value, false, &maybe_const);
    7454          130 :           t = build_constructor_single (type, field, t);
    7455          130 :           if (!maybe_const)
    7456           15 :             t = c_wrap_maybe_const (t, true);
    7457          130 :           t = digest_init (loc, field, type, t,
    7458              :                            NULL_TREE, false, false, false, true, false, false);
    7459          130 :           TREE_CONSTANT (t) = TREE_CONSTANT (value);
    7460          130 :           return t;
    7461              :         }
    7462            7 :       error_at (loc, "cast to union type from type not present in union");
    7463            7 :       return error_mark_node;
    7464              :     }
    7465              :   else
    7466              :     {
    7467    102131076 :       tree otype, ovalue;
    7468              : 
    7469    102131076 :       if (type == void_type_node)
    7470              :         {
    7471        18535 :           tree t = build1 (CONVERT_EXPR, type, value);
    7472        18535 :           SET_EXPR_LOCATION (t, loc);
    7473        18535 :           return t;
    7474              :         }
    7475              : 
    7476    102112541 :       otype = TREE_TYPE (value);
    7477              : 
    7478              :       /* Optionally warn about potentially worrisome casts.  */
    7479    102112541 :       if (warn_cast_qual
    7480       179855 :           && TREE_CODE (type) == POINTER_TYPE
    7481        26821 :           && TREE_CODE (otype) == POINTER_TYPE)
    7482        13581 :         handle_warn_cast_qual (loc, type, otype);
    7483              : 
    7484              :       /* Warn about conversions between pointers to disjoint
    7485              :          address spaces.  */
    7486    102112541 :       if (TREE_CODE (type) == POINTER_TYPE
    7487      3334471 :           && TREE_CODE (otype) == POINTER_TYPE
    7488    105100883 :           && !null_pointer_constant_p (value))
    7489              :         {
    7490      2934497 :           addr_space_t as_to = TYPE_ADDR_SPACE (TREE_TYPE (type));
    7491      2934497 :           addr_space_t as_from = TYPE_ADDR_SPACE (TREE_TYPE (otype));
    7492      2934497 :           addr_space_t as_common;
    7493              : 
    7494      2934497 :           if (!addr_space_superset (as_to, as_from, &as_common))
    7495              :             {
    7496            0 :               if (ADDR_SPACE_GENERIC_P (as_from))
    7497            0 :                 warning_at (loc, 0, "cast to %qs address space pointer "
    7498              :                             "from disjoint generic address space pointer",
    7499              :                             c_addr_space_name (as_to));
    7500              : 
    7501            0 :               else if (ADDR_SPACE_GENERIC_P (as_to))
    7502            0 :                 warning_at (loc, 0, "cast to generic address space pointer "
    7503              :                             "from disjoint %qs address space pointer",
    7504              :                             c_addr_space_name (as_from));
    7505              : 
    7506              :               else
    7507            0 :                 warning_at (loc, 0, "cast to %qs address space pointer "
    7508              :                             "from disjoint %qs address space pointer",
    7509              :                             c_addr_space_name (as_to),
    7510              :                             c_addr_space_name (as_from));
    7511              :             }
    7512              : 
    7513              :           /* Warn of new allocations that are not big enough for the target
    7514              :              type.  */
    7515      2934497 :           if (warn_alloc_size && TREE_CODE (value) == CALL_EXPR)
    7516         1069 :             if (tree fndecl = get_callee_fndecl (value))
    7517         1065 :               if (DECL_IS_MALLOC (fndecl))
    7518              :                 {
    7519          573 :                   tree attrs = TYPE_ATTRIBUTES (TREE_TYPE (fndecl));
    7520          573 :                   tree alloc_size = lookup_attribute ("alloc_size", attrs);
    7521          573 :                   if (alloc_size)
    7522          215 :                     warn_for_alloc_size (loc, TREE_TYPE (type), value,
    7523              :                                          alloc_size);
    7524              :                 }
    7525              :         }
    7526              : 
    7527              :       /* Warn about possible alignment problems.  */
    7528    102112541 :       if ((STRICT_ALIGNMENT || warn_cast_align == 2)
    7529            7 :           && TREE_CODE (type) == POINTER_TYPE
    7530            7 :           && TREE_CODE (otype) == POINTER_TYPE
    7531            7 :           && TREE_CODE (TREE_TYPE (otype)) != VOID_TYPE
    7532            7 :           && TREE_CODE (TREE_TYPE (otype)) != FUNCTION_TYPE
    7533              :           /* Don't warn about opaque types, where the actual alignment
    7534              :              restriction is unknown.  */
    7535           12 :           && !(RECORD_OR_UNION_TYPE_P (TREE_TYPE (otype))
    7536            5 :                && TYPE_MODE (TREE_TYPE (otype)) == VOIDmode)
    7537    102112555 :           && min_align_of_type (TREE_TYPE (type))
    7538            7 :              > min_align_of_type (TREE_TYPE (otype)))
    7539            5 :         warning_at (loc, OPT_Wcast_align,
    7540              :                     "cast increases required alignment of target type");
    7541              : 
    7542    102112541 :       if ((TREE_CODE (type) == INTEGER_TYPE
    7543    102112541 :            || TREE_CODE (type) == BITINT_TYPE)
    7544      7088265 :           && TREE_CODE (otype) == POINTER_TYPE
    7545    102137807 :           && TYPE_PRECISION (type) != TYPE_PRECISION (otype))
    7546              :       /* Unlike conversion of integers to pointers, where the
    7547              :          warning is disabled for converting constants because
    7548              :          of cases such as SIG_*, warn about converting constant
    7549              :          pointers to integers. In some cases it may cause unwanted
    7550              :          sign extension, and a warning is appropriate.  */
    7551         1450 :         warning_at (loc, OPT_Wpointer_to_int_cast,
    7552              :                     "cast from pointer to integer of different size");
    7553              : 
    7554    102112541 :       if ((TREE_CODE (value) == CALL_EXPR
    7555     34668032 :            && !is_access_with_size_p (value))
    7556    136780571 :           && TREE_CODE (type) != TREE_CODE (otype))
    7557         2306 :         warning_at (loc, OPT_Wbad_function_cast,
    7558              :                     "cast from function call of type %qT "
    7559              :                     "to non-matching type %qT", otype, type);
    7560              : 
    7561    102112541 :       if (TREE_CODE (type) == POINTER_TYPE
    7562      3334471 :           && (TREE_CODE (otype) == INTEGER_TYPE
    7563      3334471 :               || TREE_CODE (otype) == BITINT_TYPE)
    7564       346043 :           && TYPE_PRECISION (type) != TYPE_PRECISION (otype)
    7565              :           /* Don't warn about converting any constant.  */
    7566    102420909 :           && !TREE_CONSTANT (value))
    7567          407 :         warning_at (loc,
    7568          407 :                     OPT_Wint_to_pointer_cast, "cast to pointer from integer "
    7569              :                     "of different size");
    7570              : 
    7571    102112541 :       if (warn_strict_aliasing <= 2)
    7572     93577190 :         strict_aliasing_warning (EXPR_LOCATION (value), type, expr);
    7573              : 
    7574              :       /* If pedantic, warn for conversions between function and object
    7575              :          pointer types, except for converting a null pointer constant
    7576              :          to function pointer type.  */
    7577    102112541 :       if (pedantic
    7578       238453 :           && TREE_CODE (type) == POINTER_TYPE
    7579       143951 :           && TREE_CODE (otype) == POINTER_TYPE
    7580         2620 :           && TREE_CODE (TREE_TYPE (otype)) == FUNCTION_TYPE
    7581    102112562 :           && TREE_CODE (TREE_TYPE (type)) != FUNCTION_TYPE)
    7582           18 :         pedwarn (loc, OPT_Wpedantic, "ISO C forbids "
    7583              :                  "conversion of function pointer to object pointer type");
    7584              : 
    7585    102112541 :       if (pedantic
    7586       238453 :           && TREE_CODE (type) == POINTER_TYPE
    7587       143951 :           && TREE_CODE (otype) == POINTER_TYPE
    7588         2620 :           && TREE_CODE (TREE_TYPE (type)) == FUNCTION_TYPE
    7589           13 :           && TREE_CODE (TREE_TYPE (otype)) != FUNCTION_TYPE
    7590    102112551 :           && !null_pointer_constant_p (value))
    7591            4 :         pedwarn (loc, OPT_Wpedantic, "ISO C forbids "
    7592              :                  "conversion of object pointer to function pointer type");
    7593              : 
    7594    102112541 :       if (TREE_CODE (type) == POINTER_TYPE
    7595      3334471 :           && TREE_CODE (otype) == POINTER_TYPE
    7596      2988342 :           && TREE_CODE (TREE_TYPE (type)) == FUNCTION_TYPE
    7597         8677 :           && TREE_CODE (TREE_TYPE (otype)) == FUNCTION_TYPE
    7598    102120100 :           && !c_safe_function_type_cast_p (TREE_TYPE (type),
    7599         7559 :                                            TREE_TYPE (otype)))
    7600          799 :         warning_at (loc, OPT_Wcast_function_type,
    7601              :                     "cast between incompatible function types"
    7602              :                     " from %qT to %qT", otype, type);
    7603              : 
    7604    102112541 :       ovalue = value;
    7605              :       /* If converting to boolean a value with integer operands that
    7606              :          is not itself represented as an INTEGER_CST, the call below
    7607              :          to note_integer_operands may insert a C_MAYBE_CONST_EXPR, but
    7608              :          build_binary_op as called by c_common_truthvalue_conversion
    7609              :          may also insert a C_MAYBE_CONST_EXPR to indicate that a
    7610              :          subexpression has been fully folded.  To avoid nested
    7611              :          C_MAYBE_CONST_EXPR, ensure that
    7612              :          c_objc_common_truthvalue_conversion receives an argument
    7613              :          properly marked as having integer operands in that case.  */
    7614    102112541 :       if (int_operands
    7615      6682735 :           && TREE_CODE (value) != INTEGER_CST
    7616    102112583 :           && (TREE_CODE (type) == BOOLEAN_TYPE
    7617           28 :               || (TREE_CODE (type) == ENUMERAL_TYPE
    7618           14 :                   && ENUM_UNDERLYING_TYPE (type) != NULL_TREE
    7619           14 :                   && TREE_CODE (ENUM_UNDERLYING_TYPE (type)) == BOOLEAN_TYPE)))
    7620           28 :         value = note_integer_operands (value);
    7621    102112541 :       value = convert (type, value);
    7622              : 
    7623              :       /* Ignore any integer overflow caused by the cast.  */
    7624    102112541 :       if (TREE_CODE (value) == INTEGER_CST && !FLOAT_TYPE_P (otype))
    7625              :         {
    7626      6629384 :           if (TREE_OVERFLOW_P (ovalue))
    7627              :             {
    7628            9 :               if (!TREE_OVERFLOW (value))
    7629              :                 {
    7630              :                   /* Avoid clobbering a shared constant.  */
    7631            0 :                   value = copy_node (value);
    7632            0 :                   TREE_OVERFLOW (value) = TREE_OVERFLOW (ovalue);
    7633              :                 }
    7634              :             }
    7635      6629375 :           else if (TREE_OVERFLOW (value))
    7636              :             /* Reset VALUE's overflow flags, ensuring constant sharing.  */
    7637         3085 :             value = wide_int_to_tree (TREE_TYPE (value), wi::to_wide (value));
    7638              :         }
    7639              :     }
    7640              : 
    7641              :   /* Don't let a cast be an lvalue.  */
    7642    120233712 :   if (lvalue_p (value))
    7643        90676 :     value = non_lvalue_loc (loc, value);
    7644              : 
    7645              :   /* Don't allow the results of casting to floating-point or complex
    7646              :      types be confused with actual constants, or casts involving
    7647              :      integer and pointer types other than direct integer-to-integer
    7648              :      and integer-to-pointer be confused with integer constant
    7649              :      expressions and null pointer constants.  */
    7650    120233712 :   if (TREE_CODE (value) == REAL_CST
    7651    120183769 :       || TREE_CODE (value) == COMPLEX_CST
    7652    240394858 :       || (TREE_CODE (value) == INTEGER_CST
    7653      6878396 :           && !((TREE_CODE (expr) == INTEGER_CST
    7654      6804811 :                 && INTEGRAL_TYPE_P (TREE_TYPE (expr)))
    7655        66182 :                || TREE_CODE (expr) == REAL_CST
    7656              :                || TREE_CODE (expr) == COMPLEX_CST)))
    7657       134381 :       value = build1 (NOP_EXPR, type, value);
    7658              : 
    7659              :   /* If the expression has integer operands and so can occur in an
    7660              :      unevaluated part of an integer constant expression, ensure the
    7661              :      return value reflects this.  */
    7662    120233712 :   if (int_operands
    7663      6859101 :       && INTEGRAL_TYPE_P (type)
    7664      6413387 :       && value != error_mark_node
    7665    126647098 :       && !EXPR_INT_CONST_OPERANDS (value))
    7666           11 :     value = note_integer_operands (value);
    7667              : 
    7668    120233712 :   protected_set_expr_location (value, loc);
    7669    120233712 :   return value;
    7670              : }
    7671              : 
    7672              : /* Interpret a cast of expression EXPR to type TYPE.  LOC is the
    7673              :    location of the open paren of the cast, or the position of the cast
    7674              :    expr.  */
    7675              : tree
    7676    120252928 : c_cast_expr (location_t loc, struct c_type_name *type_name, tree expr)
    7677              : {
    7678    120252928 :   tree type;
    7679    120252928 :   tree type_expr = NULL_TREE;
    7680    120252928 :   bool type_expr_const = true;
    7681    120252928 :   tree ret;
    7682    120252928 :   int saved_wsp = warn_strict_prototypes;
    7683              : 
    7684              :   /* This avoids warnings about unprototyped casts on
    7685              :      integers.  E.g. "#define SIG_DFL (void(*)())0".  */
    7686    120252928 :   if (TREE_CODE (expr) == INTEGER_CST)
    7687      6926981 :     warn_strict_prototypes = 0;
    7688    120252928 :   type = groktypename (type_name, &type_expr, &type_expr_const);
    7689    120252928 :   warn_strict_prototypes = saved_wsp;
    7690              : 
    7691       765017 :   if (TREE_CODE (expr) == ADDR_EXPR && !VOID_TYPE_P (type)
    7692    121017691 :       && reject_gcc_builtin (expr))
    7693            2 :     return error_mark_node;
    7694              : 
    7695    120252926 :   ret = build_c_cast (loc, type, expr);
    7696    120252926 :   if (ret == error_mark_node)
    7697              :     return error_mark_node;
    7698              : 
    7699    120251766 :   if (type_expr)
    7700              :     {
    7701          250 :       bool inner_expr_const = true;
    7702          250 :       ret = c_fully_fold (ret, require_constant_value, &inner_expr_const);
    7703          250 :       ret = build2 (C_MAYBE_CONST_EXPR, TREE_TYPE (ret), type_expr, ret);
    7704          500 :       C_MAYBE_CONST_EXPR_NON_CONST (ret) = !(type_expr_const
    7705          145 :                                              && inner_expr_const);
    7706          250 :       SET_EXPR_LOCATION (ret, loc);
    7707              :     }
    7708              : 
    7709    120251766 :   if (!EXPR_HAS_LOCATION (ret))
    7710      6805351 :     protected_set_expr_location (ret, loc);
    7711              : 
    7712              :   /* C++ does not permits types to be defined in a cast, but it
    7713              :      allows references to incomplete types.  */
    7714    120251766 :   if (warn_cxx_compat && type_name->specs->typespec_kind == ctsk_tagdef)
    7715            1 :     warning_at (loc, OPT_Wc___compat,
    7716              :                 "defining a type in a cast is invalid in C++");
    7717              : 
    7718              :   return ret;
    7719              : }
    7720              : 
    7721              : /* Build an assignment expression of lvalue LHS from value RHS.
    7722              :    If LHS_ORIGTYPE is not NULL, it is the original type of LHS, which
    7723              :    may differ from TREE_TYPE (LHS) for an enum bitfield.
    7724              :    MODIFYCODE is the code for a binary operator that we use
    7725              :    to combine the old value of LHS with RHS to get the new value.
    7726              :    Or else MODIFYCODE is NOP_EXPR meaning do a simple assignment.
    7727              :    If RHS_ORIGTYPE is not NULL_TREE, it is the original type of RHS,
    7728              :    which may differ from TREE_TYPE (RHS) for an enum value.
    7729              : 
    7730              :    LOCATION is the location of the MODIFYCODE operator.
    7731              :    RHS_LOC is the location of the RHS.  */
    7732              : 
    7733              : tree
    7734      2904538 : build_modify_expr (location_t location, tree lhs, tree lhs_origtype,
    7735              :                    enum tree_code modifycode,
    7736              :                    location_t rhs_loc, tree rhs, tree rhs_origtype)
    7737              : {
    7738      2904538 :   tree result;
    7739      2904538 :   tree newrhs;
    7740      2904538 :   tree rhseval = NULL_TREE;
    7741      2904538 :   tree lhstype = TREE_TYPE (lhs);
    7742      2904538 :   tree olhstype = lhstype;
    7743      2904538 :   bool npc;
    7744      2904538 :   bool is_atomic_op;
    7745              : 
    7746              :   /* Types that aren't fully specified cannot be used in assignments.  */
    7747      2904538 :   lhs = require_complete_type (location, lhs);
    7748      2904538 :   rhs = require_complete_type (location, rhs);
    7749              : 
    7750              :   /* Avoid duplicate error messages from operands that had errors.  */
    7751      2904538 :   if (TREE_CODE (lhs) == ERROR_MARK || TREE_CODE (rhs) == ERROR_MARK)
    7752          473 :     return error_mark_node;
    7753              : 
    7754              :   /* Ensure an error for assigning a non-lvalue array to an array in
    7755              :      C90.  */
    7756      2904065 :   if (TREE_CODE (lhstype) == ARRAY_TYPE)
    7757              :     {
    7758            1 :       error_at (location, "assignment to expression with array type");
    7759            1 :       return error_mark_node;
    7760              :     }
    7761              : 
    7762              :   /* For ObjC properties, defer this check.  */
    7763      2904064 :   if (!objc_is_property_ref (lhs) && !lvalue_or_else (location, lhs, lv_assign))
    7764           32 :     return error_mark_node;
    7765              : 
    7766      2904032 :   is_atomic_op = really_atomic_lvalue (lhs);
    7767              : 
    7768      2904032 :   newrhs = rhs;
    7769              : 
    7770      2904032 :   if (TREE_CODE (lhs) == C_MAYBE_CONST_EXPR)
    7771              :     {
    7772            2 :       tree inner = build_modify_expr (location, C_MAYBE_CONST_EXPR_EXPR (lhs),
    7773              :                                       lhs_origtype, modifycode, rhs_loc, rhs,
    7774              :                                       rhs_origtype);
    7775            2 :       if (inner == error_mark_node)
    7776              :         return error_mark_node;
    7777            4 :       result = build2 (C_MAYBE_CONST_EXPR, TREE_TYPE (inner),
    7778            2 :                        C_MAYBE_CONST_EXPR_PRE (lhs), inner);
    7779            2 :       gcc_assert (!C_MAYBE_CONST_EXPR_INT_OPERANDS (lhs));
    7780            2 :       C_MAYBE_CONST_EXPR_NON_CONST (result) = 1;
    7781            2 :       protected_set_expr_location (result, location);
    7782            2 :       return result;
    7783              :     }
    7784              : 
    7785              :   /* If a binary op has been requested, combine the old LHS value with the RHS
    7786              :      producing the value we should actually store into the LHS.  */
    7787              : 
    7788      2904030 :   if (modifycode != NOP_EXPR)
    7789              :     {
    7790       215513 :       lhs = c_fully_fold (lhs, false, NULL, true);
    7791       215513 :       lhs = stabilize_reference (lhs);
    7792              : 
    7793              :       /* Construct the RHS for any non-atomic compound assignemnt. */
    7794       215513 :       if (!is_atomic_op)
    7795              :         {
    7796              :           /* If in LHS op= RHS the RHS has side-effects, ensure they
    7797              :              are preevaluated before the rest of the assignment expression's
    7798              :              side-effects, because RHS could contain e.g. function calls
    7799              :              that modify LHS.  */
    7800       200028 :           if (TREE_SIDE_EFFECTS (rhs))
    7801              :             {
    7802         8816 :               if (TREE_CODE (rhs) == EXCESS_PRECISION_EXPR)
    7803           28 :                 newrhs = save_expr (TREE_OPERAND (rhs, 0));
    7804              :               else
    7805         8788 :                 newrhs = save_expr (rhs);
    7806         8816 :               rhseval = newrhs;
    7807         8816 :               if (TREE_CODE (rhs) == EXCESS_PRECISION_EXPR)
    7808           28 :                 newrhs = build1 (EXCESS_PRECISION_EXPR, TREE_TYPE (rhs),
    7809              :                                  newrhs);
    7810              :             }
    7811       200028 :           bool clear_decl_read = false;
    7812        88485 :           if ((VAR_P (lhs) || TREE_CODE (lhs) == PARM_DECL)
    7813       153691 :               && !DECL_READ_P (lhs)
    7814       252346 :               && (VAR_P (lhs) ? warn_unused_but_set_variable
    7815              :                               : warn_unused_but_set_parameter) > 2)
    7816              :             {
    7817        21554 :               mark_exp_read (newrhs);
    7818        21554 :               if (!DECL_READ_P (lhs))
    7819       200028 :                 clear_decl_read = true;
    7820              :             }
    7821              : 
    7822       200028 :           newrhs = build_binary_op (location, modifycode,
    7823              :                                     convert_lvalue_to_rvalue (location, lhs,
    7824              :                                                               true, true),
    7825              :                                     newrhs, true);
    7826       200028 :           if (clear_decl_read)
    7827        21554 :             DECL_READ_P (lhs) = 0;
    7828              : 
    7829              :           /* The original type of the right hand side is no longer
    7830              :              meaningful.  */
    7831              :           rhs_origtype = NULL_TREE;
    7832              :         }
    7833              :     }
    7834              : 
    7835      2904030 :   if (c_dialect_objc ())
    7836              :     {
    7837              :       /* Check if we are modifying an Objective-C property reference;
    7838              :          if so, we need to generate setter calls.  */
    7839            0 :       if (TREE_CODE (newrhs) == EXCESS_PRECISION_EXPR)
    7840            0 :         result = objc_maybe_build_modify_expr (lhs, TREE_OPERAND (newrhs, 0));
    7841              :       else
    7842            0 :         result = objc_maybe_build_modify_expr (lhs, newrhs);
    7843            0 :       if (result)
    7844            0 :         goto return_result;
    7845              : 
    7846              :       /* Else, do the check that we postponed for Objective-C.  */
    7847            0 :       if (!lvalue_or_else (location, lhs, lv_assign))
    7848            0 :         return error_mark_node;
    7849              :     }
    7850              : 
    7851              :   /* Give an error for storing in something that is 'const'.  */
    7852              : 
    7853      2904030 :   if (TYPE_READONLY (lhstype)
    7854      2904030 :       || (RECORD_OR_UNION_TYPE_P (lhstype)
    7855        25779 :           && C_TYPE_FIELDS_READONLY (lhstype)))
    7856              :     {
    7857           88 :       readonly_error (location, lhs, lv_assign);
    7858           88 :       return error_mark_node;
    7859              :     }
    7860      2903942 :   else if (TREE_READONLY (lhs))
    7861            1 :     readonly_warning (lhs, lv_assign);
    7862              : 
    7863              :   /* If storing into a structure or union member,
    7864              :      it has probably been given type `int'.
    7865              :      Compute the type that would go with
    7866              :      the actual amount of storage the member occupies.  */
    7867              : 
    7868      2903942 :   if (TREE_CODE (lhs) == COMPONENT_REF
    7869       249555 :       && (TREE_CODE (lhstype) == INTEGER_TYPE
    7870       249555 :           || TREE_CODE (lhstype) == BOOLEAN_TYPE
    7871       109971 :           || SCALAR_FLOAT_TYPE_P (lhstype)
    7872        86578 :           || TREE_CODE (lhstype) == ENUMERAL_TYPE))
    7873       169973 :     lhstype = TREE_TYPE (get_unwidened (lhs, 0));
    7874              : 
    7875              :   /* If storing in a field that is in actuality a short or narrower than one,
    7876              :      we must store in the field in its actual type.  */
    7877              : 
    7878      2903942 :   if (lhstype != TREE_TYPE (lhs))
    7879              :     {
    7880            0 :       lhs = copy_node (lhs);
    7881            0 :       TREE_TYPE (lhs) = lhstype;
    7882              :     }
    7883              : 
    7884              :   /* Issue -Wc++-compat warnings about an assignment to an enum type
    7885              :      when LHS does not have its original type.  This happens for,
    7886              :      e.g., an enum bitfield in a struct.  */
    7887      2903942 :   if (warn_cxx_compat
    7888         3196 :       && lhs_origtype != NULL_TREE
    7889         3196 :       && lhs_origtype != lhstype
    7890            7 :       && TREE_CODE (lhs_origtype) == ENUMERAL_TYPE)
    7891              :     {
    7892            4 :       tree checktype = (rhs_origtype != NULL_TREE
    7893            4 :                         ? rhs_origtype
    7894            0 :                         : TREE_TYPE (rhs));
    7895            4 :       if (checktype != error_mark_node
    7896            4 :           && (TYPE_MAIN_VARIANT (checktype) != TYPE_MAIN_VARIANT (lhs_origtype)
    7897            2 :               || (is_atomic_op && modifycode != NOP_EXPR)))
    7898            2 :         warning_at (location, OPT_Wc___compat,
    7899              :                     "enum conversion in assignment is invalid in C++");
    7900              :     }
    7901              : 
    7902              :   /* Remove qualifiers.  */
    7903      2903942 :   lhstype = c_build_qualified_type (lhstype, TYPE_UNQUALIFIED);
    7904      2903942 :   olhstype = c_build_qualified_type (olhstype, TYPE_UNQUALIFIED);
    7905              : 
    7906              :   /* Convert new value to destination type.  Fold it first, then
    7907              :      restore any excess precision information, for the sake of
    7908              :      conversion warnings.  */
    7909              : 
    7910      2903942 :   if (!(is_atomic_op && modifycode != NOP_EXPR))
    7911              :     {
    7912      2888457 :       tree rhs_semantic_type = NULL_TREE;
    7913      2888457 :       if (!c_in_omp_for)
    7914              :         {
    7915      2872136 :           if (TREE_CODE (newrhs) == EXCESS_PRECISION_EXPR)
    7916              :             {
    7917         5077 :               rhs_semantic_type = TREE_TYPE (newrhs);
    7918         5077 :               newrhs = TREE_OPERAND (newrhs, 0);
    7919              :             }
    7920      2872136 :           npc = null_pointer_constant_p (newrhs);
    7921      2872136 :           newrhs = c_fully_fold (newrhs, false, NULL);
    7922      2872136 :           if (rhs_semantic_type)
    7923         5077 :             newrhs = build1 (EXCESS_PRECISION_EXPR, rhs_semantic_type, newrhs);
    7924              :         }
    7925              :       else
    7926        16321 :         npc = null_pointer_constant_p (newrhs);
    7927      2888457 :       newrhs = convert_for_assignment (location, rhs_loc, lhstype, newrhs,
    7928              :                                        rhs_origtype, ic_assign, npc,
    7929              :                                        NULL_TREE, NULL_TREE, 0);
    7930      2888457 :       if (TREE_CODE (newrhs) == ERROR_MARK)
    7931          127 :         return error_mark_node;
    7932              :     }
    7933              : 
    7934              :   /* Emit ObjC write barrier, if necessary.  */
    7935      2903815 :   if (c_dialect_objc () && flag_objc_gc)
    7936              :     {
    7937            0 :       result = objc_generate_write_barrier (lhs, modifycode, newrhs);
    7938            0 :       if (result)
    7939              :         {
    7940            0 :           protected_set_expr_location (result, location);
    7941            0 :           goto return_result;
    7942              :         }
    7943              :     }
    7944              : 
    7945              :   /* Scan operands.  */
    7946              : 
    7947      2903815 :   if (is_atomic_op)
    7948        25964 :     result = build_atomic_assign (location, lhs, modifycode, newrhs, false);
    7949              :   else
    7950              :     {
    7951      2877851 :       result = build2 (MODIFY_EXPR, lhstype, lhs, newrhs);
    7952      2877851 :       TREE_SIDE_EFFECTS (result) = 1;
    7953      2877851 :       protected_set_expr_location (result, location);
    7954              :     }
    7955              : 
    7956              :   /* If we got the LHS in a different type for storing in,
    7957              :      convert the result back to the nominal type of LHS
    7958              :      so that the value we return always has the same type
    7959              :      as the LHS argument.  */
    7960              : 
    7961      2903815 :   if (olhstype == TREE_TYPE (result))
    7962      2903815 :     goto return_result;
    7963              : 
    7964            0 :   result = convert_for_assignment (location, rhs_loc, olhstype, result,
    7965              :                                    rhs_origtype, ic_assign, false, NULL_TREE,
    7966              :                                    NULL_TREE, 0);
    7967            0 :   protected_set_expr_location (result, location);
    7968              : 
    7969      2903815 : return_result:
    7970      2903815 :   if (rhseval)
    7971         8816 :     result = build2 (COMPOUND_EXPR, TREE_TYPE (result), rhseval, result);
    7972              :   return result;
    7973              : }
    7974              : 
    7975              : /* Return whether STRUCT_TYPE has an anonymous field with type TYPE.
    7976              :    This is used to implement -fplan9-extensions.  */
    7977              : 
    7978              : static bool
    7979           26 : find_anonymous_field_with_type (tree struct_type, tree type)
    7980              : {
    7981           26 :   tree field;
    7982           26 :   bool found;
    7983              : 
    7984           26 :   gcc_assert (RECORD_OR_UNION_TYPE_P (struct_type));
    7985           26 :   found = false;
    7986           26 :   for (field = TYPE_FIELDS (struct_type);
    7987           68 :        field != NULL_TREE;
    7988           42 :        field = TREE_CHAIN (field))
    7989              :     {
    7990           42 :       tree fieldtype = remove_qualifiers (TREE_TYPE (field));
    7991           42 :       if (DECL_NAME (field) == NULL
    7992           42 :           && comptypes (type, fieldtype))
    7993              :         {
    7994            4 :           if (found)
    7995              :             return false;
    7996              :           found = true;
    7997              :         }
    7998           38 :       else if (DECL_NAME (field) == NULL
    7999            2 :                && RECORD_OR_UNION_TYPE_P (TREE_TYPE (field))
    8000           40 :                && find_anonymous_field_with_type (TREE_TYPE (field), type))
    8001              :         {
    8002            0 :           if (found)
    8003              :             return false;
    8004              :           found = true;
    8005              :         }
    8006              :     }
    8007              :   return found;
    8008              : }
    8009              : 
    8010              : /* RHS is an expression whose type is pointer to struct.  If there is
    8011              :    an anonymous field in RHS with type TYPE, then return a pointer to
    8012              :    that field in RHS.  This is used with -fplan9-extensions.  This
    8013              :    returns NULL if no conversion could be found.  */
    8014              : 
    8015              : static tree
    8016           28 : convert_to_anonymous_field (location_t location, tree type, tree rhs)
    8017              : {
    8018           28 :   tree rhs_struct_type, lhs_main_type;
    8019           28 :   tree field, found_field;
    8020           28 :   bool found_sub_field;
    8021           28 :   tree ret;
    8022              : 
    8023           28 :   gcc_assert (POINTER_TYPE_P (TREE_TYPE (rhs)));
    8024           28 :   rhs_struct_type = TREE_TYPE (TREE_TYPE (rhs));
    8025           28 :   gcc_assert (RECORD_OR_UNION_TYPE_P (rhs_struct_type));
    8026              : 
    8027           28 :   gcc_assert (POINTER_TYPE_P (type));
    8028           28 :   lhs_main_type = remove_qualifiers (TREE_TYPE (type));
    8029              : 
    8030           28 :   found_field = NULL_TREE;
    8031           28 :   found_sub_field = false;
    8032           28 :   for (field = TYPE_FIELDS (rhs_struct_type);
    8033          172 :        field != NULL_TREE;
    8034          144 :        field = TREE_CHAIN (field))
    8035              :     {
    8036          148 :       if (DECL_NAME (field) != NULL_TREE
    8037          148 :           || !RECORD_OR_UNION_TYPE_P (TREE_TYPE (field)))
    8038           96 :         continue;
    8039           52 :       tree fieldtype = remove_qualifiers (TREE_TYPE (field));
    8040           52 :       if (comptypes (lhs_main_type, fieldtype))
    8041              :         {
    8042           28 :           if (found_field != NULL_TREE)
    8043              :             return NULL_TREE;
    8044              :           found_field = field;
    8045              :         }
    8046           24 :       else if (find_anonymous_field_with_type (TREE_TYPE (field),
    8047              :                                                lhs_main_type))
    8048              :         {
    8049            4 :           if (found_field != NULL_TREE)
    8050              :             return NULL_TREE;
    8051              :           found_field = field;
    8052              :           found_sub_field = true;
    8053              :         }
    8054              :     }
    8055              : 
    8056           24 :   if (found_field == NULL_TREE)
    8057              :     return NULL_TREE;
    8058              : 
    8059           24 :   ret = fold_build3_loc (location, COMPONENT_REF, TREE_TYPE (found_field),
    8060              :                          build_fold_indirect_ref (rhs), found_field,
    8061              :                          NULL_TREE);
    8062           24 :   ret = build_fold_addr_expr_loc (location, ret);
    8063              : 
    8064           24 :   if (found_sub_field)
    8065              :     {
    8066            2 :       ret = convert_to_anonymous_field (location, type, ret);
    8067            2 :       gcc_assert (ret != NULL_TREE);
    8068              :     }
    8069              : 
    8070              :   return ret;
    8071              : }
    8072              : 
    8073              : /* Issue an error message for a bad initializer component.
    8074              :    GMSGID identifies the message.
    8075              :    The component name is taken from the spelling stack.  */
    8076              : 
    8077              : static void ATTRIBUTE_GCC_DIAG (2,0)
    8078          944 : error_init (location_t loc, const char *gmsgid, ...)
    8079              : {
    8080          944 :   char *ofwhat;
    8081              : 
    8082          944 :   auto_diagnostic_group d;
    8083              : 
    8084              :   /* The gmsgid may be a format string with %< and %>. */
    8085          944 :   va_list ap;
    8086          944 :   va_start (ap, gmsgid);
    8087          944 :   bool warned = emit_diagnostic_valist (diagnostics::kind::error,
    8088          944 :                                         loc, -1, gmsgid, &ap);
    8089          944 :   va_end (ap);
    8090              : 
    8091          944 :   ofwhat = print_spelling ((char *) alloca (spelling_length () + 1));
    8092          944 :   if (*ofwhat && warned)
    8093          220 :     inform (loc, "(near initialization for %qs)", ofwhat);
    8094          944 : }
    8095              : 
    8096              : /* Used to implement pedwarn_init and permerror_init.  */
    8097              : 
    8098              : static bool ATTRIBUTE_GCC_DIAG (3,0)
    8099         2538 : pedwarn_permerror_init (location_t loc, int opt, const char *gmsgid,
    8100              :                         va_list *ap, enum diagnostics::kind kind)
    8101              : {
    8102              :   /* Use the location where a macro was expanded rather than where
    8103              :      it was defined to make sure macros defined in system headers
    8104              :      but used incorrectly elsewhere are diagnosed.  */
    8105         2538 :   location_t exploc = expansion_point_location_if_in_system_header (loc);
    8106         2538 :   auto_diagnostic_group d;
    8107         2538 :   bool warned = emit_diagnostic_valist (kind, exploc, opt, gmsgid, ap);
    8108         2538 :   if (warned)
    8109              :     {
    8110         1815 :       char *ofwhat = print_spelling ((char *) alloca (spelling_length () + 1));
    8111         1815 :       if (*ofwhat)
    8112         1494 :         inform (exploc, "(near initialization for %qs)", ofwhat);
    8113              :     }
    8114         5076 :   return warned;
    8115         2538 : }
    8116              : 
    8117              : /* Issue a pedantic warning for a bad initializer component.  OPT is
    8118              :    the option OPT_* (from options.h) controlling this warning or 0 if
    8119              :    it is unconditionally given.  GMSGID identifies the message.  The
    8120              :    component name is taken from the spelling stack.  */
    8121              : 
    8122              : static bool ATTRIBUTE_GCC_DIAG (3,0)
    8123         2187 : pedwarn_init (location_t loc, int opt, const char *gmsgid, ...)
    8124              : {
    8125         2187 :   va_list ap;
    8126         2187 :   va_start (ap, gmsgid);
    8127         2187 :   bool warned = pedwarn_permerror_init (loc, opt, gmsgid, &ap,
    8128              :                                         diagnostics::kind::pedwarn);
    8129         2187 :   va_end (ap);
    8130         2187 :   return warned;
    8131              : }
    8132              : 
    8133              : /* Like pedwarn_init, but issue a permerror.  */
    8134              : 
    8135              : static bool ATTRIBUTE_GCC_DIAG (3,0)
    8136          351 : permerror_init (location_t loc, int opt, const char *gmsgid, ...)
    8137              : {
    8138          351 :   va_list ap;
    8139          351 :   va_start (ap, gmsgid);
    8140          351 :   bool warned = pedwarn_permerror_init (loc, opt, gmsgid, &ap,
    8141              :                                         diagnostics::kind::permerror);
    8142          351 :   va_end (ap);
    8143          351 :   return warned;
    8144              : }
    8145              : 
    8146              : /* Issue a warning for a bad initializer component.
    8147              : 
    8148              :    OPT is the OPT_W* value corresponding to the warning option that
    8149              :    controls this warning.  GMSGID identifies the message.  The
    8150              :    component name is taken from the spelling stack.  */
    8151              : 
    8152              : static void
    8153          146 : warning_init (location_t loc, int opt, const char *gmsgid)
    8154              : {
    8155          146 :   char *ofwhat;
    8156          146 :   bool warned;
    8157              : 
    8158          146 :   auto_diagnostic_group d;
    8159              : 
    8160              :   /* Use the location where a macro was expanded rather than where
    8161              :      it was defined to make sure macros defined in system headers
    8162              :      but used incorrectly elsewhere are diagnosed.  */
    8163          146 :   location_t exploc = expansion_point_location_if_in_system_header (loc);
    8164              : 
    8165              :   /* The gmsgid may be a format string with %< and %>. */
    8166          146 :   warned = warning_at (exploc, opt, gmsgid);
    8167          146 :   if (warned)
    8168              :     {
    8169          133 :       ofwhat = print_spelling ((char *) alloca (spelling_length () + 1));
    8170          133 :       if (*ofwhat)
    8171          133 :         inform (exploc, "(near initialization for %qs)", ofwhat);
    8172              :     }
    8173          146 : }
    8174              : 
    8175              : /* If TYPE is an array type and EXPR is a parenthesized string
    8176              :    constant, warn if pedantic that EXPR is being used to initialize an
    8177              :    object of type TYPE.  */
    8178              : 
    8179              : void
    8180      7282669 : maybe_warn_string_init (location_t loc, tree type, struct c_expr expr)
    8181              : {
    8182      7282669 :   if (pedantic
    8183        80536 :       && TREE_CODE (type) == ARRAY_TYPE
    8184         1193 :       && TREE_CODE (expr.value) == STRING_CST
    8185          472 :       && expr.original_code != STRING_CST)
    8186           13 :     pedwarn_init (loc, OPT_Wpedantic,
    8187              :                   "array initialized from parenthesized string constant");
    8188      7282669 : }
    8189              : 
    8190              : /* Attempt to locate the parameter with the given index within FNDECL,
    8191              :    returning DECL_SOURCE_LOCATION (FNDECL) if it can't be found.  */
    8192              : 
    8193              : static location_t
    8194          937 : get_fndecl_argument_location (tree fndecl, int argnum)
    8195              : {
    8196          937 :   int i;
    8197          937 :   tree param;
    8198              : 
    8199              :   /* Locate param by index within DECL_ARGUMENTS (fndecl).  */
    8200          937 :   for (i = 0, param = DECL_ARGUMENTS (fndecl);
    8201         1016 :        i < argnum && param;
    8202           79 :        i++, param = TREE_CHAIN (param))
    8203              :     ;
    8204              : 
    8205              :   /* If something went wrong (e.g. if we have a builtin and thus no arguments),
    8206              :      return DECL_SOURCE_LOCATION (FNDECL).  */
    8207          937 :   if (param == NULL)
    8208          653 :     return DECL_SOURCE_LOCATION (fndecl);
    8209              : 
    8210          284 :   return DECL_SOURCE_LOCATION (param);
    8211              : }
    8212              : 
    8213              : /* Issue a note about a mismatching argument for parameter PARMNUM
    8214              :    to FUNDECL, for types EXPECTED_TYPE and ACTUAL_TYPE.
    8215              :    Attempt to issue the note at the pertinent parameter of the decl;
    8216              :    failing that issue it at the location of FUNDECL; failing that
    8217              :    issue it at PLOC.
    8218              :    Use highlight_colors::actual for the ACTUAL_TYPE
    8219              :    and highlight_colors::expected for EXPECTED_TYPE and the
    8220              :    parameter of FUNDECL*/
    8221              : 
    8222              : static void
    8223         1061 : inform_for_arg (tree fundecl, location_t ploc, int parmnum,
    8224              :                 tree expected_type, tree actual_type)
    8225              : {
    8226         1061 :   location_t loc;
    8227         1061 :   if (fundecl && !DECL_IS_UNDECLARED_BUILTIN (fundecl))
    8228          937 :     loc = get_fndecl_argument_location (fundecl, parmnum - 1);
    8229              :   else
    8230              :     loc = ploc;
    8231              : 
    8232         1061 :   gcc_rich_location richloc (loc, nullptr, highlight_colors::expected);
    8233              : 
    8234         1061 :   pp_markup::element_expected_type elem_expected_type (expected_type);
    8235         1061 :   pp_markup::element_actual_type elem_actual_type (actual_type);
    8236         1061 :   inform (&richloc,
    8237              :           "expected %e but argument is of type %e",
    8238              :           &elem_expected_type, &elem_actual_type);
    8239         1061 : }
    8240              : 
    8241              : /* Issue a warning when an argument of ARGTYPE is passed to a built-in
    8242              :    function FUNDECL declared without prototype to parameter PARMNUM of
    8243              :    PARMTYPE when ARGTYPE does not promote to PARMTYPE.  */
    8244              : 
    8245              : static void
    8246          418 : maybe_warn_builtin_no_proto_arg (location_t loc, tree fundecl, int parmnum,
    8247              :                                  tree parmtype, tree argtype)
    8248              : {
    8249          418 :   tree_code parmcode = TREE_CODE (parmtype);
    8250          418 :   tree_code argcode = TREE_CODE (argtype);
    8251          418 :   tree promoted = c_type_promotes_to (argtype);
    8252              : 
    8253              :   /* Avoid warning for enum arguments that promote to an integer type
    8254              :      of the same size/mode.  */
    8255          418 :   if (parmcode == INTEGER_TYPE
    8256          418 :       && argcode == ENUMERAL_TYPE
    8257          418 :       && TYPE_MODE (parmtype) == TYPE_MODE (argtype))
    8258              :     return;
    8259              : 
    8260          417 :   if ((parmcode == argcode
    8261          222 :        || (parmcode == INTEGER_TYPE
    8262              :            && argcode == ENUMERAL_TYPE))
    8263          418 :       && TYPE_MAIN_VARIANT (parmtype) == TYPE_MAIN_VARIANT (promoted))
    8264              :     return;
    8265              : 
    8266              :   /* This diagnoses even signed/unsigned mismatches.  Those might be
    8267              :      safe in many cases but GCC may emit suboptimal code for them so
    8268              :      warning on those cases drives efficiency improvements.  */
    8269          398 :   if (warning_at (loc, OPT_Wbuiltin_declaration_mismatch,
    8270          398 :                   TYPE_MAIN_VARIANT (promoted) == argtype
    8271              :                   ? G_("%qD argument %d type is %qT where %qT is expected "
    8272              :                        "in a call to built-in function declared without "
    8273              :                        "prototype")
    8274              :                   : G_("%qD argument %d promotes to %qT where %qT is expected "
    8275              :                        "in a call to built-in function declared without "
    8276              :                        "prototype"),
    8277              :                   fundecl, parmnum, promoted, parmtype))
    8278          150 :     inform (DECL_SOURCE_LOCATION (fundecl),
    8279              :             "built-in %qD declared here",
    8280              :             fundecl);
    8281              : }
    8282              : 
    8283              : /* Print a declaration in quotes, with the given highlight_color.
    8284              :    Analogous to handler for %qD, but with a specific highlight color.  */
    8285              : 
    8286          199 : class pp_element_quoted_decl : public pp_element
    8287              : {
    8288              : public:
    8289          199 :   pp_element_quoted_decl (tree decl, const char *highlight_color)
    8290          199 :   : m_decl (decl),
    8291          199 :     m_highlight_color (highlight_color)
    8292              :   {
    8293              :   }
    8294              : 
    8295          199 :   void add_to_phase_2 (pp_markup::context &ctxt) override
    8296              :   {
    8297          199 :     ctxt.begin_quote ();
    8298          199 :     ctxt.begin_highlight_color (m_highlight_color);
    8299              : 
    8300          199 :     print_decl (ctxt);
    8301              : 
    8302          199 :     ctxt.end_highlight_color ();
    8303          199 :     ctxt.end_quote ();
    8304          199 :   }
    8305              : 
    8306          199 :   void print_decl (pp_markup::context &ctxt)
    8307              :   {
    8308          199 :     pretty_printer *const pp = &ctxt.m_pp;
    8309          199 :     pp->set_padding (pp_none);
    8310          199 :     if (DECL_NAME (m_decl))
    8311          199 :       pp_identifier (pp, lang_hooks.decl_printable_name (m_decl, 2));
    8312              :     else
    8313            0 :       pp_string (pp, _("({anonymous})"));
    8314          199 :   }
    8315              : 
    8316              : private:
    8317              :   tree m_decl;
    8318              :   const char *m_highlight_color;
    8319              : };
    8320              : 
    8321              : /* If TYPE is from a typedef, issue a note showing the location
    8322              :    to the user.
    8323              :    Use HIGHLIGHT_COLOR as the highlight color.  */
    8324              : 
    8325              : static void
    8326         1178 : maybe_inform_typedef_location (tree type, const char *highlight_color)
    8327              : {
    8328         1178 :   if (!typedef_variant_p (type))
    8329         1144 :     return;
    8330              : 
    8331           34 :   tree typedef_decl = TYPE_NAME (type);
    8332           34 :   gcc_assert (TREE_CODE (typedef_decl) == TYPE_DECL);
    8333           34 :   gcc_rich_location richloc (DECL_SOURCE_LOCATION (typedef_decl),
    8334           34 :                              nullptr, highlight_color);
    8335           34 :   pp_element_quoted_decl e_typedef_decl (typedef_decl, highlight_color);
    8336           34 :   inform (&richloc, "%e declared here", &e_typedef_decl);
    8337           34 : }
    8338              : 
    8339              : /* Convert value RHS to type TYPE as preparation for an assignment to
    8340              :    an lvalue of type TYPE.  If ORIGTYPE is not NULL_TREE, it is the
    8341              :    original type of RHS; this differs from TREE_TYPE (RHS) for enum
    8342              :    types.  NULL_POINTER_CONSTANT says whether RHS was a null pointer
    8343              :    constant before any folding.
    8344              :    The real work of conversion is done by `convert'.
    8345              :    The purpose of this function is to generate error messages
    8346              :    for assignments that are not allowed in C.
    8347              :    ERRTYPE says whether it is argument passing, assignment,
    8348              :    initialization or return.
    8349              : 
    8350              :    In the following example, '~' denotes where EXPR_LOC and '^' where
    8351              :    LOCATION point to:
    8352              : 
    8353              :      f (var);      [ic_argpass]
    8354              :      ^  ~~~
    8355              :      x = var;      [ic_assign]
    8356              :        ^ ~~~;
    8357              :      int x = var;  [ic_init]
    8358              :              ^^^
    8359              :      return x;     [ic_return]
    8360              :             ^
    8361              : 
    8362              :    FUNCTION is a tree for the function being called.
    8363              :    PARMNUM is the number of the argument, for printing in error messages.
    8364              :    WARNOPT may be set to a warning option to issue the corresponding warning
    8365              :    rather than an error for invalid conversions.  Used for calls to built-in
    8366              :    functions declared without a prototype.  */
    8367              : 
    8368              : static tree
    8369    167068376 : convert_for_assignment (location_t location, location_t expr_loc, tree type,
    8370              :                         tree rhs, tree origtype, enum impl_conv errtype,
    8371              :                         bool null_pointer_constant, tree fundecl,
    8372              :                         tree function, int parmnum, int warnopt /* = 0 */)
    8373              : {
    8374    167068376 :   enum tree_code codel = TREE_CODE (type);
    8375    167068376 :   tree orig_rhs = rhs;
    8376    167068376 :   tree rhstype;
    8377    167068376 :   enum tree_code coder;
    8378    167068376 :   tree rname = NULL_TREE;
    8379    167068376 :   bool objc_ok = false;
    8380              : 
    8381              :   /* Use the expansion point location to handle cases such as user's
    8382              :      function returning a wrong-type macro defined in a system header.  */
    8383    167068376 :   location = expansion_point_location_if_in_system_header (location);
    8384              : 
    8385    167068376 :   if (errtype == ic_argpass)
    8386              :     {
    8387    125620513 :       tree selector;
    8388              :       /* Change pointer to function to the function itself for
    8389              :          diagnostics.  */
    8390    125620513 :       if (TREE_CODE (function) == ADDR_EXPR
    8391    125620513 :           && TREE_CODE (TREE_OPERAND (function, 0)) == FUNCTION_DECL)
    8392            0 :         function = TREE_OPERAND (function, 0);
    8393              : 
    8394              :       /* Handle an ObjC selector specially for diagnostics.  */
    8395    125620513 :       selector = objc_message_selector ();
    8396    125620513 :       rname = function;
    8397    125620513 :       if (selector && parmnum > 2)
    8398              :         {
    8399            0 :           rname = selector;
    8400            0 :           parmnum -= 2;
    8401              :         }
    8402              :     }
    8403              : 
    8404              :   /* This macro is used to emit diagnostics to ensure that all format
    8405              :      strings are complete sentences, visible to gettext and checked at
    8406              :      compile time.  */
    8407              : #define PEDWARN_FOR_ASSIGNMENT(LOCATION, PLOC, OPT, AR, AS, IN, RE)      \
    8408              :   do {                                                                   \
    8409              :     switch (errtype)                                                     \
    8410              :       {                                                                  \
    8411              :       case ic_argpass:                                                   \
    8412              :         {                                                               \
    8413              :           auto_diagnostic_group d;                                              \
    8414              :           if (pedwarn (PLOC, OPT, AR, parmnum, rname))          \
    8415              :             inform_for_arg (fundecl, (PLOC), parmnum, type, rhstype); \
    8416              :         }                                                               \
    8417              :         break;                                                           \
    8418              :       case ic_assign:                                                    \
    8419              :         pedwarn (LOCATION, OPT, AS);                                     \
    8420              :         break;                                                           \
    8421              :       case ic_init:                                                      \
    8422              :       case ic_init_const:                                                \
    8423              :         pedwarn_init (LOCATION, OPT, IN);                                \
    8424              :         break;                                                           \
    8425              :       case ic_return:                                                    \
    8426              :         pedwarn (LOCATION, OPT, RE);                                     \
    8427              :         break;                                                           \
    8428              :       default:                                                           \
    8429              :         gcc_unreachable ();                                              \
    8430              :       }                                                                  \
    8431              :   } while (0)
    8432              : 
    8433              :   /* This macro is used to emit diagnostics to ensure that all format
    8434              :      strings are complete sentences, visible to gettext and checked at
    8435              :      compile time.  It can be called with 'pedwarn' or 'warning_at'.  */
    8436              : #define WARNING_FOR_QUALIFIERS(PEDWARN, LOCATION, PLOC, OPT, AR, AS, IN, RE, QUALS) \
    8437              :   do {                                                                   \
    8438              :     switch (errtype)                                                     \
    8439              :       {                                                                  \
    8440              :       case ic_argpass:                                                   \
    8441              :         {                                                                \
    8442              :           auto_diagnostic_group d;                                       \
    8443              :           if (PEDWARN) {                                                 \
    8444              :             if (pedwarn (PLOC, OPT, AR, parmnum, rname, QUALS))          \
    8445              :               inform_for_arg (fundecl, (PLOC), parmnum, type, rhstype);  \
    8446              :           } else {                                                       \
    8447              :             if (warning_at (PLOC, OPT, AR, parmnum, rname, QUALS))       \
    8448              :               inform_for_arg (fundecl, (PLOC), parmnum, type, rhstype);  \
    8449              :           }                                                              \
    8450              :         }                                                                \
    8451              :         break;                                                           \
    8452              :       case ic_assign:                                                    \
    8453              :         if (PEDWARN)                                                     \
    8454              :           pedwarn (LOCATION, OPT, AS, QUALS);                            \
    8455              :         else                                                             \
    8456              :           warning_at (LOCATION, OPT, AS, QUALS);                         \
    8457              :         break;                                                           \
    8458              :       case ic_init:                                                      \
    8459              :       case ic_init_const:                                                \
    8460              :         if (PEDWARN)                                                     \
    8461              :           pedwarn (LOCATION, OPT, IN, QUALS);                            \
    8462              :         else                                                             \
    8463              :           warning_at (LOCATION, OPT, IN, QUALS);                         \
    8464              :         break;                                                           \
    8465              :       case ic_return:                                                    \
    8466              :         if (PEDWARN)                                                     \
    8467              :           pedwarn (LOCATION, OPT, RE, QUALS);                            \
    8468              :         else                                                             \
    8469              :           warning_at (LOCATION, OPT, RE, QUALS);                         \
    8470              :         break;                                                           \
    8471              :       default:                                                           \
    8472              :         gcc_unreachable ();                                              \
    8473              :       }                                                                  \
    8474              :   } while (0)
    8475              : 
    8476              :   /* This macro is used to emit diagnostics to ensure that all format
    8477              :      strings are complete sentences, visible to gettext and checked at
    8478              :      compile time.  It is the same as PEDWARN_FOR_ASSIGNMENT but with an
    8479              :      extra parameter to enumerate qualifiers.  */
    8480              : #define PEDWARN_FOR_QUALIFIERS(LOCATION, PLOC, OPT, AR, AS, IN, RE, QUALS) \
    8481              :    WARNING_FOR_QUALIFIERS (true, LOCATION, PLOC, OPT, AR, AS, IN, RE, QUALS)
    8482              : 
    8483              : 
    8484    167068376 :   if (TREE_CODE (rhs) == EXCESS_PRECISION_EXPR)
    8485         5985 :     rhs = TREE_OPERAND (rhs, 0);
    8486              : 
    8487    167068376 :   rhstype = TREE_TYPE (rhs);
    8488    167068376 :   coder = TREE_CODE (rhstype);
    8489              : 
    8490    167068376 :   if (coder == ERROR_MARK)
    8491          347 :     return error_mark_node;
    8492              : 
    8493    167068029 :   if (c_dialect_objc ())
    8494              :     {
    8495            0 :       int parmno;
    8496              : 
    8497            0 :       switch (errtype)
    8498              :         {
    8499              :         case ic_return:
    8500              :           parmno = 0;
    8501              :           break;
    8502              : 
    8503              :         case ic_assign:
    8504              :           parmno = -1;
    8505              :           break;
    8506              : 
    8507              :         case ic_init:
    8508              :         case ic_init_const:
    8509              :           parmno = -2;
    8510              :           break;
    8511              : 
    8512              :         default:
    8513            0 :           parmno = parmnum;
    8514              :           break;
    8515              :         }
    8516              : 
    8517            0 :       objc_ok = objc_compare_types (type, rhstype, parmno, rname);
    8518              :     }
    8519              : 
    8520    167068029 :   if (warn_cxx_compat)
    8521              :     {
    8522        28958 :       tree checktype = origtype != NULL_TREE ? origtype : rhstype;
    8523        28958 :       if (checktype != error_mark_node
    8524        28958 :           && TREE_CODE (type) == ENUMERAL_TYPE
    8525        29064 :           && TYPE_MAIN_VARIANT (checktype) != TYPE_MAIN_VARIANT (type))
    8526           45 :         switch (errtype)
    8527              :           {
    8528            8 :           case ic_argpass:
    8529            8 :             if (pedwarn (expr_loc, OPT_Wc___compat, "enum conversion when "
    8530              :                          "passing argument %d of %qE is invalid in C++",
    8531              :                          parmnum, rname))
    8532           16 :               inform ((fundecl && !DECL_IS_UNDECLARED_BUILTIN (fundecl))
    8533            8 :                       ? DECL_SOURCE_LOCATION (fundecl) : expr_loc,
    8534              :                       "expected %qT but argument is of type %qT",
    8535              :                       type, rhstype);
    8536              :             break;
    8537           10 :           case ic_assign:
    8538           10 :             pedwarn (location, OPT_Wc___compat, "enum conversion from %qT to "
    8539              :                      "%qT in assignment is invalid in C++", rhstype, type);
    8540           10 :             break;
    8541           18 :           case ic_init:
    8542           18 :           case ic_init_const:
    8543           18 :             pedwarn_init (location, OPT_Wc___compat, "enum conversion from "
    8544              :                           "%qT to %qT in initialization is invalid in C++",
    8545              :                           rhstype, type);
    8546           18 :             break;
    8547            9 :           case ic_return:
    8548            9 :             pedwarn (location, OPT_Wc___compat, "enum conversion from %qT to "
    8549              :                      "%qT in return is invalid in C++", rhstype, type);
    8550            9 :             break;
    8551            0 :           default:
    8552            0 :             gcc_unreachable ();
    8553              :           }
    8554              :     }
    8555              : 
    8556    167068029 :   if (warn_enum_conversion)
    8557              :     {
    8558     14600121 :       tree checktype = origtype != NULL_TREE ? origtype : rhstype;
    8559     14600121 :       if (checktype != error_mark_node
    8560     14600121 :           && TREE_CODE (checktype) == ENUMERAL_TYPE
    8561        12823 :           && TREE_CODE (type) == ENUMERAL_TYPE
    8562     14608409 :           && !comptypes (TYPE_MAIN_VARIANT (checktype), TYPE_MAIN_VARIANT (type)))
    8563              :        {
    8564            7 :           gcc_rich_location loc (location);
    8565            7 :           warning_at (&loc, OPT_Wenum_conversion,
    8566              :                       "implicit conversion from %qT to %qT",
    8567              :                       checktype, type);
    8568            7 :        }
    8569              :     }
    8570              : 
    8571    167068029 :   if (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (rhstype))
    8572              :     {
    8573    147957067 :       warn_for_address_of_packed_member (type, orig_rhs);
    8574    147957067 :       if (type != rhstype)
    8575              :         /* Convert RHS to TYPE in order to not lose TYPE in diagnostics.  */
    8576     36863176 :         rhs = convert (type, rhs);
    8577    147957067 :       return rhs;
    8578              :     }
    8579              : 
    8580     19110962 :   if (coder == VOID_TYPE)
    8581              :     {
    8582              :       /* Except for passing an argument to an unprototyped function,
    8583              :          this is a constraint violation.  When passing an argument to
    8584              :          an unprototyped function, it is compile-time undefined;
    8585              :          making it a constraint in that case was rejected in
    8586              :          DR#252.  */
    8587            8 :       const char msg[] = "void value not ignored as it ought to be";
    8588            8 :       if (warnopt)
    8589            0 :         warning_at (location, warnopt, msg);
    8590              :       else
    8591            8 :         error_at (location, msg);
    8592            8 :       return error_mark_node;
    8593              :     }
    8594     19110954 :   rhs = require_complete_type (location, rhs);
    8595     19110954 :   if (rhs == error_mark_node)
    8596              :     return error_mark_node;
    8597              : 
    8598     19110954 :   if (coder == POINTER_TYPE && reject_gcc_builtin (rhs))
    8599            6 :     return error_mark_node;
    8600              : 
    8601              :   /* A non-reference type can convert to a reference.  This handles
    8602              :      va_start, va_copy and possibly port built-ins.  */
    8603     19110948 :   if (codel == REFERENCE_TYPE && coder != REFERENCE_TYPE)
    8604              :     {
    8605          286 :       if (!lvalue_p (rhs))
    8606              :         {
    8607            0 :           const char msg[] = "cannot pass rvalue to reference parameter";
    8608            0 :           if (warnopt)
    8609            0 :             warning_at (location, warnopt, msg);
    8610              :           else
    8611            0 :             error_at (location, msg);
    8612            0 :           return error_mark_node;
    8613              :         }
    8614          286 :       if (!c_mark_addressable (rhs))
    8615            0 :         return error_mark_node;
    8616          286 :       rhs = build1 (ADDR_EXPR, c_build_pointer_type (TREE_TYPE (rhs)), rhs);
    8617          286 :       SET_EXPR_LOCATION (rhs, location);
    8618              : 
    8619          286 :       rhs = convert_for_assignment (location, expr_loc,
    8620          286 :                                     c_build_pointer_type (TREE_TYPE (type)),
    8621              :                                     rhs, origtype, errtype,
    8622              :                                     null_pointer_constant, fundecl, function,
    8623              :                                     parmnum, warnopt);
    8624          286 :       if (rhs == error_mark_node)
    8625              :         return error_mark_node;
    8626              : 
    8627          286 :       rhs = build1 (NOP_EXPR, type, rhs);
    8628          286 :       SET_EXPR_LOCATION (rhs, location);
    8629          286 :       return rhs;
    8630              :     }
    8631              :   /* Some types can interconvert without explicit casts.  */
    8632     19110662 :   else if (codel == VECTOR_TYPE && coder == VECTOR_TYPE
    8633     19110662 :            && vector_types_convertible_p (type, TREE_TYPE (rhs), true))
    8634      9287057 :     return convert (type, rhs);
    8635              :   /* Arithmetic types all interconvert, and enum is treated like int.  */
    8636      9823605 :   else if ((codel == INTEGER_TYPE || codel == REAL_TYPE
    8637      2286413 :             || codel == FIXED_POINT_TYPE
    8638      2286413 :             || codel == ENUMERAL_TYPE || codel == COMPLEX_TYPE
    8639      2200052 :             || codel == BOOLEAN_TYPE || codel == BITINT_TYPE)
    8640      7722570 :            && (coder == INTEGER_TYPE || coder == REAL_TYPE
    8641        83511 :                || coder == FIXED_POINT_TYPE
    8642        83511 :                || coder == ENUMERAL_TYPE || coder == COMPLEX_TYPE
    8643        40441 :                || coder == BOOLEAN_TYPE || coder == BITINT_TYPE))
    8644              :     {
    8645      7721203 :       if (warnopt && errtype == ic_argpass)
    8646          418 :         maybe_warn_builtin_no_proto_arg (expr_loc, fundecl, parmnum, type,
    8647              :                                          rhstype);
    8648              : 
    8649      7721203 :       bool save = in_late_binary_op;
    8650      7685292 :       if (C_BOOLEAN_TYPE_P (type) || codel == COMPLEX_TYPE
    8651     15349346 :           || (coder == REAL_TYPE
    8652       276126 :               && (codel == INTEGER_TYPE || codel == ENUMERAL_TYPE)
    8653        24196 :               && sanitize_flags_p (SANITIZE_FLOAT_CAST)))
    8654        99804 :         in_late_binary_op = true;
    8655     11100876 :       tree ret = convert_and_check (expr_loc != UNKNOWN_LOCATION
    8656              :                                     ? expr_loc : location, type, orig_rhs,
    8657              :                                     errtype == ic_init_const);
    8658      7721203 :       in_late_binary_op = save;
    8659      7721203 :       return ret;
    8660              :     }
    8661              : 
    8662              :   /* Aggregates in different TUs might need conversion.  */
    8663      2102402 :   if ((codel == RECORD_TYPE || codel == UNION_TYPE)
    8664          105 :       && codel == coder
    8665      2102424 :       && comptypes (TYPE_MAIN_VARIANT (type), TYPE_MAIN_VARIANT (rhstype)))
    8666            9 :     return convert_and_check (expr_loc != UNKNOWN_LOCATION
    8667            9 :                               ? expr_loc : location, type, rhs);
    8668              : 
    8669              :   /* Conversion to a transparent union or record from its member types.
    8670              :      This applies only to function arguments.  */
    8671      2102393 :   if (((codel == UNION_TYPE || codel == RECORD_TYPE)
    8672           96 :       && TYPE_TRANSPARENT_AGGR (type))
    8673      2102432 :       && errtype == ic_argpass)
    8674              :     {
    8675           39 :       tree memb, marginal_memb = NULL_TREE;
    8676              : 
    8677           50 :       for (memb = TYPE_FIELDS (type); memb ; memb = DECL_CHAIN (memb))
    8678              :         {
    8679           50 :           tree memb_type = TREE_TYPE (memb);
    8680              : 
    8681           50 :           if (comptypes (TYPE_MAIN_VARIANT (memb_type),
    8682           50 :                          TYPE_MAIN_VARIANT (rhstype)))
    8683              :             break;
    8684              : 
    8685           27 :           if (TREE_CODE (memb_type) != POINTER_TYPE)
    8686            1 :             continue;
    8687              : 
    8688           26 :           if (coder == POINTER_TYPE)
    8689              :             {
    8690           26 :               tree ttl = TREE_TYPE (memb_type);
    8691           26 :               tree ttr = TREE_TYPE (rhstype);
    8692              : 
    8693              :               /* Any non-function converts to a [const][volatile] void *
    8694              :                  and vice versa; otherwise, targets must be the same.
    8695              :                  Meanwhile, the lhs target must have all the qualifiers of
    8696              :                  the rhs.  */
    8697            0 :               if ((VOID_TYPE_P (ttl) && !TYPE_ATOMIC (ttl))
    8698           26 :                   || (VOID_TYPE_P (ttr) && !TYPE_ATOMIC (ttr))
    8699           45 :                   || comp_target_types (location, memb_type, rhstype))
    8700              :                 {
    8701           16 :                   int lquals = TYPE_QUALS (ttl) & ~TYPE_QUAL_ATOMIC;
    8702           16 :                   int rquals = TYPE_QUALS (ttr) & ~TYPE_QUAL_ATOMIC;
    8703              :                   /* If this type won't generate any warnings, use it.  */
    8704           16 :                   if (lquals == rquals
    8705           16 :                       || ((TREE_CODE (ttr) == FUNCTION_TYPE
    8706            0 :                            && TREE_CODE (ttl) == FUNCTION_TYPE)
    8707            0 :                           ? ((lquals | rquals) == rquals)
    8708           16 :                           : ((lquals | rquals) == lquals)))
    8709              :                     break;
    8710              : 
    8711              :                   /* Keep looking for a better type, but remember this one.  */
    8712            0 :                   if (!marginal_memb)
    8713           10 :                     marginal_memb = memb;
    8714              :                 }
    8715              :             }
    8716              : 
    8717              :           /* Can convert integer zero to any pointer type.  */
    8718           10 :           if (null_pointer_constant)
    8719              :             {
    8720            0 :               rhs = null_pointer_node;
    8721            0 :               break;
    8722              :             }
    8723              :         }
    8724              : 
    8725           39 :       if (memb || marginal_memb)
    8726              :         {
    8727           39 :           if (!memb)
    8728              :             {
    8729              :               /* We have only a marginally acceptable member type;
    8730              :                  it needs a warning.  */
    8731            0 :               tree ttl = TREE_TYPE (TREE_TYPE (marginal_memb));
    8732            0 :               tree ttr = TREE_TYPE (rhstype);
    8733              : 
    8734              :               /* Const and volatile mean something different for function
    8735              :                  types, so the usual warnings are not appropriate.  */
    8736            0 :               if (TREE_CODE (ttr) == FUNCTION_TYPE
    8737            0 :                   && TREE_CODE (ttl) == FUNCTION_TYPE)
    8738              :                 {
    8739              :                   /* Because const and volatile on functions are
    8740              :                      restrictions that say the function will not do
    8741              :                      certain things, it is okay to use a const or volatile
    8742              :                      function where an ordinary one is wanted, but not
    8743              :                      vice-versa.  */
    8744            0 :                   if (TYPE_QUALS_NO_ADDR_SPACE (ttl)
    8745            0 :                       & ~TYPE_QUALS_NO_ADDR_SPACE (ttr))
    8746            0 :                     PEDWARN_FOR_QUALIFIERS (location, expr_loc,
    8747              :                                             OPT_Wdiscarded_qualifiers,
    8748              :                                             G_("passing argument %d of %qE "
    8749              :                                                "makes %q#v qualified function "
    8750              :                                                "pointer from unqualified"),
    8751              :                                             G_("assignment makes %q#v qualified "
    8752              :                                                "function pointer from "
    8753              :                                                "unqualified"),
    8754              :                                             G_("initialization makes %q#v qualified "
    8755              :                                                "function pointer from "
    8756              :                                                "unqualified"),
    8757              :                                             G_("return makes %q#v qualified function "
    8758              :                                                "pointer from unqualified"),
    8759              :                                             TYPE_QUALS (ttl) & ~TYPE_QUALS (ttr));
    8760              :                 }
    8761            0 :               else if (TYPE_QUALS_NO_ADDR_SPACE (ttr)
    8762            0 :                        & ~TYPE_QUALS_NO_ADDR_SPACE (ttl))
    8763            0 :                 PEDWARN_FOR_QUALIFIERS (location, expr_loc,
    8764              :                                         OPT_Wdiscarded_qualifiers,
    8765              :                                         G_("passing argument %d of %qE discards "
    8766              :                                            "%qv qualifier from pointer target type"),
    8767              :                                         G_("assignment discards %qv qualifier "
    8768              :                                            "from pointer target type"),
    8769              :                                         G_("initialization discards %qv qualifier "
    8770              :                                            "from pointer target type"),
    8771              :                                         G_("return discards %qv qualifier from "
    8772              :                                            "pointer target type"),
    8773              :                                         TYPE_QUALS (ttr) & ~TYPE_QUALS (ttl));
    8774              : 
    8775              :               memb = marginal_memb;
    8776              :             }
    8777              : 
    8778           39 :           if (!fundecl || !DECL_IN_SYSTEM_HEADER (fundecl))
    8779           31 :             pedwarn (location, OPT_Wpedantic,
    8780              :                      "ISO C prohibits argument conversion to union type");
    8781              : 
    8782           39 :           rhs = fold_convert_loc (location, TREE_TYPE (memb), rhs);
    8783           39 :           return build_constructor_single (type, memb, rhs);
    8784              :         }
    8785              :     }
    8786              : 
    8787              :   /* Conversions among pointers */
    8788      2102354 :   else if ((codel == POINTER_TYPE || codel == REFERENCE_TYPE)
    8789      2100831 :            && (coder == codel))
    8790              :     {
    8791              :       /* If RHS refers to a built-in declared without a prototype
    8792              :          BLTIN is the declaration of the built-in with a prototype
    8793              :          and RHSTYPE is set to the actual type of the built-in.  */
    8794      2022507 :       tree bltin;
    8795      2022507 :       rhstype = type_or_builtin_type (rhs, &bltin);
    8796              : 
    8797      2022507 :       tree ttl = TREE_TYPE (type);
    8798      2022507 :       tree ttr = TREE_TYPE (rhstype);
    8799      2022507 :       bool is_opaque_pointer;
    8800      2022507 :       bool target_cmp = false;   /* Cache comp_target_types () result.  */
    8801      2022507 :       addr_space_t asl;
    8802      2022507 :       addr_space_t asr;
    8803              : 
    8804      2022507 :       tree mvl = remove_qualifiers (ttl);
    8805      2022507 :       tree mvr = remove_qualifiers (ttr);
    8806              : 
    8807              :       /* Opaque pointers are treated like void pointers.  */
    8808      2022507 :       is_opaque_pointer = vector_targets_convertible_p (ttl, ttr);
    8809              : 
    8810              :       /* The Plan 9 compiler permits a pointer to a struct to be
    8811              :          automatically converted into a pointer to an anonymous field
    8812              :          within the struct.  */
    8813      2022507 :       if (flag_plan9_extensions
    8814           50 :           && RECORD_OR_UNION_TYPE_P (mvl)
    8815           26 :           && RECORD_OR_UNION_TYPE_P (mvr)
    8816           26 :           && mvl != mvr)
    8817              :         {
    8818           26 :           tree new_rhs = convert_to_anonymous_field (location, type, rhs);
    8819           26 :           if (new_rhs != NULL_TREE)
    8820              :             {
    8821           22 :               rhs = new_rhs;
    8822           22 :               rhstype = TREE_TYPE (rhs);
    8823           22 :               coder = TREE_CODE (rhstype);
    8824           22 :               ttr = TREE_TYPE (rhstype);
    8825           22 :               mvr = TYPE_MAIN_VARIANT (ttr);
    8826              :             }
    8827              :         }
    8828              : 
    8829              :       /* C++ does not allow the implicit conversion void* -> T*.  However,
    8830              :          for the purpose of reducing the number of false positives, we
    8831              :          tolerate the special case of
    8832              : 
    8833              :                 int *p = NULL;
    8834              : 
    8835              :          where NULL is typically defined in C to be '(void *) 0'.  */
    8836      2022507 :       if (VOID_TYPE_P (ttr) && rhs != null_pointer_node && !VOID_TYPE_P (ttl))
    8837        26896 :         warning_at (errtype == ic_argpass ? expr_loc : location,
    8838        14260 :                     OPT_Wc___compat,
    8839              :                     "request for implicit conversion "
    8840              :                     "from %qT to %qT not permitted in C++", rhstype, type);
    8841              : 
    8842              :       /* Warn of new allocations that are not big enough for the target
    8843              :          type.  */
    8844      2022507 :       if (warn_alloc_size && TREE_CODE (rhs) == CALL_EXPR)
    8845         5437 :         if (tree fndecl = get_callee_fndecl (rhs))
    8846         5437 :           if (DECL_IS_MALLOC (fndecl))
    8847              :             {
    8848         4605 :               tree attrs = TYPE_ATTRIBUTES (TREE_TYPE (fndecl));
    8849         4605 :               tree alloc_size = lookup_attribute ("alloc_size", attrs);
    8850         4605 :               if (alloc_size)
    8851          451 :                 warn_for_alloc_size (location, ttl, rhs, alloc_size);
    8852              :             }
    8853              : 
    8854              :       /* See if the pointers point to incompatible address spaces.  */
    8855      2022507 :       asl = TYPE_ADDR_SPACE (ttl);
    8856      2022507 :       asr = TYPE_ADDR_SPACE (ttr);
    8857      2022507 :       if (!null_pointer_constant_p (rhs)
    8858      2022507 :           && asr != asl && !targetm.addr_space.subset_p (asr, asl))
    8859              :         {
    8860            3 :           auto_diagnostic_group d;
    8861            3 :           bool diagnosed = true;
    8862            3 :           switch (errtype)
    8863              :             {
    8864            1 :             case ic_argpass:
    8865            1 :               {
    8866            1 :                 const char msg[] = G_("passing argument %d of %qE from "
    8867              :                                       "pointer to non-enclosed address space");
    8868            1 :                 if (warnopt)
    8869            0 :                   diagnosed
    8870            0 :                     = warning_at (expr_loc, warnopt, msg, parmnum, rname);
    8871              :                 else
    8872            1 :                   error_at (expr_loc, msg, parmnum, rname);
    8873            0 :               break;
    8874              :               }
    8875            0 :             case ic_assign:
    8876            0 :               {
    8877            0 :                 const char msg[] = G_("assignment from pointer to "
    8878              :                                       "non-enclosed address space");
    8879            0 :                 if (warnopt)
    8880            0 :                   diagnosed = warning_at (location, warnopt, msg);
    8881              :                 else
    8882            0 :                   error_at (location, msg);
    8883            0 :                 break;
    8884              :               }
    8885            0 :             case ic_init:
    8886            0 :             case ic_init_const:
    8887            0 :               {
    8888            0 :                 const char msg[] = G_("initialization from pointer to "
    8889              :                                       "non-enclosed address space");
    8890            0 :                 if (warnopt)
    8891            0 :                   diagnosed = warning_at (location, warnopt, msg);
    8892              :                 else
    8893            0 :                   error_at (location, msg);
    8894            0 :                 break;
    8895              :               }
    8896            2 :             case ic_return:
    8897            2 :               {
    8898            2 :                 const char msg[] = G_("return from pointer to "
    8899              :                                       "non-enclosed address space");
    8900            2 :                 if (warnopt)
    8901            0 :                   diagnosed = warning_at (location, warnopt, msg);
    8902              :                 else
    8903            2 :                   error_at (location, msg);
    8904            0 :                 break;
    8905              :               }
    8906            0 :             default:
    8907            0 :               gcc_unreachable ();
    8908              :             }
    8909            3 :           if (diagnosed)
    8910              :             {
    8911            3 :               if (errtype == ic_argpass)
    8912            1 :                 inform_for_arg (fundecl, expr_loc, parmnum, type, rhstype);
    8913              :               else
    8914            2 :                 inform (location, "expected %qT but pointer is of type %qT",
    8915              :                         type, rhstype);
    8916              :             }
    8917            3 :           return error_mark_node;
    8918            3 :         }
    8919              : 
    8920              :       /* Check if the right-hand side has a format attribute but the
    8921              :          left-hand side doesn't.  */
    8922      2022504 :       if (warn_suggest_attribute_format
    8923      2022504 :           && check_missing_format_attribute (type, rhstype))
    8924              :         {
    8925           16 :           switch (errtype)
    8926              :           {
    8927            4 :           case ic_argpass:
    8928            4 :             warning_at (expr_loc, OPT_Wsuggest_attribute_format,
    8929              :                         "argument %d of %qE might be "
    8930              :                         "a candidate for a format attribute",
    8931              :                         parmnum, rname);
    8932            4 :             break;
    8933            4 :           case ic_assign:
    8934            4 :             warning_at (location, OPT_Wsuggest_attribute_format,
    8935              :                         "assignment left-hand side might be "
    8936              :                         "a candidate for a format attribute");
    8937            4 :             break;
    8938            4 :           case ic_init:
    8939            4 :           case ic_init_const:
    8940            4 :             warning_at (location, OPT_Wsuggest_attribute_format,
    8941              :                         "initialization left-hand side might be "
    8942              :                         "a candidate for a format attribute");
    8943            4 :             break;
    8944            4 :           case ic_return:
    8945            4 :             warning_at (location, OPT_Wsuggest_attribute_format,
    8946              :                         "return type might be "
    8947              :                         "a candidate for a format attribute");
    8948            4 :             break;
    8949            0 :           default:
    8950            0 :             gcc_unreachable ();
    8951              :           }
    8952              :         }
    8953              : 
    8954              :       /* See if the pointers point to incompatible scalar storage orders.  */
    8955      2022504 :       if (warn_scalar_storage_order
    8956      2019588 :           && !null_pointer_constant_p (rhs)
    8957      5993768 :           && (AGGREGATE_TYPE_P (ttl) && TYPE_REVERSE_STORAGE_ORDER (ttl))
    8958      1985632 :              != (AGGREGATE_TYPE_P (ttr) && TYPE_REVERSE_STORAGE_ORDER (ttr)))
    8959              :         {
    8960           18 :           tree t;
    8961              : 
    8962           18 :           switch (errtype)
    8963              :           {
    8964           11 :           case ic_argpass:
    8965              :             /* Do not warn for built-in functions, for example memcpy, since we
    8966              :                control how they behave and they can be useful in this area.  */
    8967           11 :             if (TREE_CODE (rname) != FUNCTION_DECL
    8968           11 :                 || !fndecl_built_in_p (rname))
    8969            1 :               warning_at (location, OPT_Wscalar_storage_order,
    8970              :                           "passing argument %d of %qE from incompatible "
    8971              :                           "scalar storage order", parmnum, rname);
    8972              :             break;
    8973            3 :           case ic_assign:
    8974              :             /* Do not warn if the RHS is a call to a function that returns a
    8975              :                pointer that is not an alias.  */
    8976            3 :             if (TREE_CODE (rhs) != CALL_EXPR
    8977            2 :                 || (t = get_callee_fndecl (rhs)) == NULL_TREE
    8978            5 :                 || !DECL_IS_MALLOC (t))
    8979            1 :               warning_at (location, OPT_Wscalar_storage_order,
    8980              :                           "assignment to %qT from pointer type %qT with "
    8981              :                           "incompatible scalar storage order", type, rhstype);
    8982              :             break;
    8983            3 :           case ic_init:
    8984            3 :           case ic_init_const:
    8985              :             /* Likewise.  */
    8986            3 :             if (TREE_CODE (rhs) != CALL_EXPR
    8987            2 :                 || (t = get_callee_fndecl (rhs)) == NULL_TREE
    8988            5 :                 || !DECL_IS_MALLOC (t))
    8989            1 :               warning_at (location, OPT_Wscalar_storage_order,
    8990              :                           "initialization of %qT from pointer type %qT with "
    8991              :                           "incompatible scalar storage order", type, rhstype);
    8992              :             break;
    8993            1 :           case ic_return:
    8994            1 :             warning_at (location, OPT_Wscalar_storage_order,
    8995              :                         "returning %qT from pointer type with incompatible "
    8996              :                         "scalar storage order %qT", rhstype, type);
    8997            1 :             break;
    8998            0 :           default:
    8999            0 :             gcc_unreachable ();
    9000              :           }
    9001              :         }
    9002              : 
    9003              :       /* Any non-function converts to a [const][volatile] void *
    9004              :          and vice versa; otherwise, targets must be the same.
    9005              :          Meanwhile, the lhs target must have all the qualifiers of the rhs.  */
    9006       424151 :       if ((VOID_TYPE_P (ttl) && !TYPE_ATOMIC (ttl))
    9007      1598354 :           || (VOID_TYPE_P (ttr) && !TYPE_ATOMIC (ttr))
    9008      1550277 :           || (target_cmp = comp_target_types (location, type, rhstype))
    9009         2446 :           || is_opaque_pointer
    9010      2027396 :           || ((c_common_unsigned_type (mvl)
    9011         2446 :                == c_common_unsigned_type (mvr))
    9012         3340 :               && (c_common_signed_type (mvl)
    9013         1670 :                   == c_common_signed_type (mvr))
    9014         1655 :               && TYPE_ATOMIC (mvl) == TYPE_ATOMIC (mvr)))
    9015              :         {
    9016              :           /* Warn about loss of qualifers from pointers to arrays with
    9017              :              qualifiers on the element type. */
    9018      2021705 :           if (TREE_CODE (ttr) == ARRAY_TYPE)
    9019              :             {
    9020         2131 :               ttr = strip_array_types (ttr);
    9021         2131 :               ttl = strip_array_types (ttl);
    9022              : 
    9023         2131 :               if (TYPE_QUALS_NO_ADDR_SPACE_NO_ATOMIC (ttr)
    9024         2131 :                   & ~TYPE_QUALS_NO_ADDR_SPACE_NO_ATOMIC (ttl))
    9025          115 :                 WARNING_FOR_QUALIFIERS (flag_isoc23,
    9026              :                                         location, expr_loc,
    9027              :                                         OPT_Wdiscarded_array_qualifiers,
    9028              :                                         G_("passing argument %d of %qE discards "
    9029              :                                            "%qv qualifier from pointer target type"),
    9030              :                                         G_("assignment discards %qv qualifier "
    9031              :                                            "from pointer target type"),
    9032              :                                         G_("initialization discards %qv qualifier "
    9033              :                                            "from pointer target type"),
    9034              :                                         G_("return discards %qv qualifier from "
    9035              :                                            "pointer target type"),
    9036              :                                         TYPE_QUALS (ttr) & ~TYPE_QUALS (ttl));
    9037              :             }
    9038      2019574 :           else if (pedantic
    9039       146269 :               && ((VOID_TYPE_P (ttl) && TREE_CODE (ttr) == FUNCTION_TYPE)
    9040       146249 :                   ||
    9041              :                   (VOID_TYPE_P (ttr)
    9042         2917 :                    && !null_pointer_constant
    9043          178 :                    && TREE_CODE (ttl) == FUNCTION_TYPE)))
    9044           34 :             PEDWARN_FOR_ASSIGNMENT (location, expr_loc, OPT_Wpedantic,
    9045              :                                     G_("ISO C forbids passing argument %d of "
    9046              :                                        "%qE between function pointer "
    9047              :                                        "and %<void *%>"),
    9048              :                                     G_("ISO C forbids assignment between "
    9049              :                                        "function pointer and %<void *%>"),
    9050              :                                     G_("ISO C forbids initialization between "
    9051              :                                        "function pointer and %<void *%>"),
    9052              :                                     G_("ISO C forbids return between function "
    9053              :                                        "pointer and %<void *%>"));
    9054              :           /* Const and volatile mean something different for function types,
    9055              :              so the usual warnings are not appropriate.  */
    9056      2019540 :           else if (TREE_CODE (ttr) != FUNCTION_TYPE
    9057      1987117 :                    && TREE_CODE (ttl) != FUNCTION_TYPE)
    9058              :             {
    9059              :                /* Assignments between atomic and non-atomic objects are OK.  */
    9060      1986420 :                bool warn_quals_ped = TYPE_QUALS_NO_ADDR_SPACE_NO_ATOMIC (ttr)
    9061      1986420 :                                      & ~TYPE_QUALS_NO_ADDR_SPACE_NO_ATOMIC (ttl);
    9062      1986420 :                bool warn_quals = TYPE_QUALS_NO_ADDR_SPACE_NO_ATOMIC (ttr)
    9063      1986420 :                                  & ~TYPE_QUALS_NO_ADDR_SPACE_NO_ATOMIC (strip_array_types (ttl));
    9064              : 
    9065              :               /* Don't warn about loss of qualifier for conversions from
    9066              :                  qualified void* to pointers to arrays with corresponding
    9067              :                  qualifier on the element type (except for pedantic before C23). */
    9068      1986420 :               if (warn_quals || (warn_quals_ped && pedantic && !flag_isoc23))
    9069          697 :                 PEDWARN_FOR_QUALIFIERS (location, expr_loc,
    9070              :                                         OPT_Wdiscarded_qualifiers,
    9071              :                                         G_("passing argument %d of %qE discards "
    9072              :                                            "%qv qualifier from pointer target type"),
    9073              :                                         G_("assignment discards %qv qualifier "
    9074              :                                            "from pointer target type"),
    9075              :                                         G_("initialization discards %qv qualifier "
    9076              :                                            "from pointer target type"),
    9077              :                                         G_("return discards %qv qualifier from "
    9078              :                                            "pointer target type"),
    9079              :                                         TYPE_QUALS (ttr) & ~TYPE_QUALS (ttl));
    9080           11 :               else if (warn_quals_ped)
    9081           11 :                 pedwarn_c11 (location, OPT_Wc11_c23_compat,
    9082              :                              "array with qualifier on the element is not qualified before C23");
    9083              : 
    9084              :               /* If this is not a case of ignoring a mismatch in signedness,
    9085              :                  no warning.  */
    9086      1985712 :               else if (VOID_TYPE_P (ttl) || VOID_TYPE_P (ttr)
    9087      1545354 :                        || target_cmp)
    9088              :                 ;
    9089              :               /* If there is a mismatch, do warn.  */
    9090         1647 :               else if (warn_pointer_sign)
    9091           82 :                 switch (errtype)
    9092              :                   {
    9093           33 :                   case ic_argpass:
    9094           33 :                     {
    9095           33 :                       auto_diagnostic_group d;
    9096           33 :                       range_label_for_type_mismatch rhs_label (rhstype, type);
    9097           33 :                       gcc_rich_location richloc (expr_loc, &rhs_label,
    9098           33 :                                                  highlight_colors::actual);
    9099           33 :                       if (pedwarn (&richloc, OPT_Wpointer_sign,
    9100              :                                    "pointer targets in passing argument %d of "
    9101              :                                    "%qE differ in signedness", parmnum, rname))
    9102           33 :                         inform_for_arg (fundecl, expr_loc, parmnum, type,
    9103              :                                         rhstype);
    9104           33 :                     }
    9105           33 :                     break;
    9106           21 :                   case ic_assign:
    9107           21 :                     pedwarn (location, OPT_Wpointer_sign,
    9108              :                              "pointer targets in assignment from %qT to %qT "
    9109              :                              "differ in signedness", rhstype, type);
    9110           21 :                     break;
    9111           14 :                   case ic_init:
    9112           14 :                   case ic_init_const:
    9113           14 :                     pedwarn_init (location, OPT_Wpointer_sign,
    9114              :                                   "pointer targets in initialization of %qT "
    9115              :                                   "from %qT differ in signedness", type,
    9116              :                                   rhstype);
    9117           14 :                     break;
    9118           14 :                   case ic_return:
    9119           14 :                     pedwarn (location, OPT_Wpointer_sign, "pointer targets in "
    9120              :                              "returning %qT from a function with return type "
    9121              :                              "%qT differ in signedness", rhstype, type);
    9122           14 :                     break;
    9123            0 :                   default:
    9124            0 :                     gcc_unreachable ();
    9125              :                   }
    9126              :             }
    9127        33120 :           else if (TREE_CODE (ttl) == FUNCTION_TYPE
    9128         4150 :                    && TREE_CODE (ttr) == FUNCTION_TYPE)
    9129              :             {
    9130              :               /* Because const and volatile on functions are restrictions
    9131              :                  that say the function will not do certain things,
    9132              :                  it is okay to use a const or volatile function
    9133              :                  where an ordinary one is wanted, but not vice-versa.  */
    9134         3453 :               if (TYPE_QUALS_NO_ADDR_SPACE (ttl)
    9135         3453 :                   & ~TYPE_QUALS_NO_ADDR_SPACE (ttr))
    9136           18 :                 PEDWARN_FOR_QUALIFIERS (location, expr_loc,
    9137              :                                         OPT_Wdiscarded_qualifiers,
    9138              :                                         G_("passing argument %d of %qE makes "
    9139              :                                            "%q#v qualified function pointer "
    9140              :                                            "from unqualified"),
    9141              :                                         G_("assignment makes %q#v qualified function "
    9142              :                                            "pointer from unqualified"),
    9143              :                                         G_("initialization makes %q#v qualified "
    9144              :                                            "function pointer from unqualified"),
    9145              :                                         G_("return makes %q#v qualified function "
    9146              :                                            "pointer from unqualified"),
    9147              :                                         TYPE_QUALS (ttl) & ~TYPE_QUALS (ttr));
    9148              :             }
    9149              :         }
    9150              :       /* Avoid warning about the volatile ObjC EH puts on decls.  */
    9151          799 :       else if (!objc_ok)
    9152              :         {
    9153          799 :           auto_diagnostic_group d;
    9154          799 :           bool warned = false;
    9155          799 :           pp_markup::element_expected_type e_type (type);
    9156          799 :           pp_markup::element_actual_type e_rhstype (rhstype);
    9157          799 :           switch (errtype)
    9158              :             {
    9159          306 :             case ic_argpass:
    9160          306 :               {
    9161          306 :                 range_label_for_type_mismatch rhs_label (rhstype, type);
    9162          306 :                 gcc_rich_location richloc (expr_loc, &rhs_label,
    9163          306 :                                            highlight_colors::actual);
    9164          306 :                 warned
    9165          306 :                   = permerror_opt (&richloc, OPT_Wincompatible_pointer_types,
    9166              :                                    "passing argument %d of %qE from "
    9167              :                                    "incompatible pointer type",
    9168              :                                    parmnum, rname);
    9169          306 :                 if (warned)
    9170          174 :                   inform_for_arg (fundecl, expr_loc, parmnum, type, rhstype);
    9171          306 :               }
    9172          306 :               break;
    9173          267 :             case ic_assign:
    9174          267 :               if (bltin)
    9175           11 :                 warned
    9176           11 :                   = permerror_opt (location, OPT_Wincompatible_pointer_types,
    9177              :                                    "assignment to %e from pointer to "
    9178              :                                    "%qD with incompatible type %e",
    9179              :                                    &e_type, bltin, &e_rhstype);
    9180              :               else
    9181          256 :                 warned
    9182          256 :                   = permerror_opt (location, OPT_Wincompatible_pointer_types,
    9183              :                                    "assignment to %e from incompatible "
    9184              :                                    "pointer type %e",
    9185              :                                    &e_type, &e_rhstype);
    9186              :               break;
    9187          167 :             case ic_init:
    9188          167 :             case ic_init_const:
    9189          167 :               if (bltin)
    9190           13 :                 warned
    9191           13 :                   = permerror_init (location, OPT_Wincompatible_pointer_types,
    9192              :                                     "initialization of %e from pointer to "
    9193              :                                     "%qD with incompatible type %e",
    9194              :                                     &e_type, bltin, &e_rhstype);
    9195              :               else
    9196          154 :                 warned
    9197          154 :                   = permerror_init (location, OPT_Wincompatible_pointer_types,
    9198              :                                     "initialization of %e from incompatible "
    9199              :                                     "pointer type %e",
    9200              :                                     &e_type, &e_rhstype);
    9201              :               break;
    9202           59 :             case ic_return:
    9203           59 :               if (bltin)
    9204           11 :                 warned
    9205           11 :                   = permerror_opt (location, OPT_Wincompatible_pointer_types,
    9206              :                                    "returning pointer to %qD of type %e from "
    9207              :                                    "a function with incompatible type %e",
    9208              :                                    bltin, &e_rhstype, &e_type);
    9209              :               else
    9210           48 :                 warned
    9211           48 :                   = permerror_opt (location, OPT_Wincompatible_pointer_types,
    9212              :                                    "returning %e from a function with "
    9213              :                                    "incompatible return type %e",
    9214              :                                    &e_rhstype, &e_type);
    9215              :               break;
    9216            0 :             default:
    9217            0 :               gcc_unreachable ();
    9218              :             }
    9219          799 :           if (warned)
    9220              :             {
    9221              :               /* If the mismatching function type is a pointer to a function,
    9222              :                  try to show the decl of the function.  */
    9223          589 :               if (TREE_CODE (rhs) == ADDR_EXPR
    9224          589 :                   && TREE_CODE (TREE_OPERAND (rhs, 0)) == FUNCTION_DECL)
    9225              :                 {
    9226          191 :                   tree rhs_fndecl = TREE_OPERAND (rhs, 0);
    9227          191 :                   if (!DECL_IS_UNDECLARED_BUILTIN (rhs_fndecl))
    9228              :                     {
    9229          165 :                       gcc_rich_location richloc
    9230          165 :                         (DECL_SOURCE_LOCATION (rhs_fndecl), nullptr,
    9231          165 :                          highlight_colors::actual);
    9232          165 :                       pp_element_quoted_decl e_rhs_fndecl
    9233          165 :                         (rhs_fndecl, highlight_colors::actual);
    9234          165 :                       inform (&richloc,
    9235              :                               "%e declared here", &e_rhs_fndecl);
    9236          165 :                     }
    9237              :                 }
    9238              :               /* If either/both of the types are typedefs, show the decl.  */
    9239          589 :               maybe_inform_typedef_location (type,
    9240              :                                              highlight_colors::expected);
    9241          589 :               maybe_inform_typedef_location (rhstype,
    9242              :                                              highlight_colors::actual);
    9243              :             }
    9244          799 :         }
    9245              : 
    9246              :       /* If RHS isn't an address, check pointer or array of packed
    9247              :          struct or union.  */
    9248      2022504 :       warn_for_address_of_packed_member (type, orig_rhs);
    9249              : 
    9250      2022504 :       return convert (type, rhs);
    9251              :     }
    9252        79847 :   else if (codel == POINTER_TYPE && coder == ARRAY_TYPE)
    9253              :     {
    9254              :       /* ??? This should not be an error when inlining calls to
    9255              :          unprototyped functions.  */
    9256            4 :       const char msg[] = "invalid use of non-lvalue array";
    9257            4 :       if (warnopt)
    9258            0 :         warning_at (location, warnopt, msg);
    9259              :       else
    9260            4 :         error_at (location, msg);
    9261            4 :       return error_mark_node;
    9262              :     }
    9263        79843 :   else if (codel == POINTER_TYPE
    9264        78320 :            && (coder == INTEGER_TYPE
    9265        78320 :                || coder == ENUMERAL_TYPE
    9266          616 :                || coder == BOOLEAN_TYPE
    9267          616 :                || coder == NULLPTR_TYPE
    9268           27 :                || coder == BITINT_TYPE))
    9269              :     {
    9270        78307 :       if (null_pointer_constant && c_inhibit_evaluation_warnings == 0
    9271        77309 :           && coder != NULLPTR_TYPE)
    9272        76749 :         warning_at (location, OPT_Wzero_as_null_pointer_constant,
    9273              :                     "zero as null pointer constant");
    9274              :       /* A NULLPTR type is just a nullptr always.  */
    9275        77747 :       if (coder == NULLPTR_TYPE)
    9276          575 :         return omit_one_operand_loc (expr_loc, type, nullptr_node, rhs);
    9277              :       /* An explicit constant 0 or type nullptr_t can convert to a pointer,
    9278              :          or one that results from arithmetic, even including a cast to
    9279              :          integer type.  */
    9280        77732 :       else if (!null_pointer_constant)
    9281          972 :         switch (errtype)
    9282              :           {
    9283          800 :           case ic_argpass:
    9284          800 :             {
    9285          800 :               auto_diagnostic_group d;
    9286          800 :               range_label_for_type_mismatch rhs_label (rhstype, type);
    9287          800 :               gcc_rich_location richloc (expr_loc, &rhs_label,
    9288          800 :                                          highlight_colors::actual);
    9289          800 :               if (permerror_opt (&richloc, OPT_Wint_conversion,
    9290              :                                  "passing argument %d of %qE makes pointer "
    9291              :                                  "from integer without a cast", parmnum, rname))
    9292              :                 {
    9293          439 :                   maybe_emit_indirection_note (expr_loc, rhs, type);
    9294          439 :                   inform_for_arg (fundecl, expr_loc, parmnum, type, rhstype);
    9295              :                 }
    9296          800 :             }
    9297          800 :             break;
    9298           93 :           case ic_assign:
    9299           93 :             permerror_opt (location, OPT_Wint_conversion,
    9300              :                            "assignment to %qT from %qT makes pointer from "
    9301              :                            "integer without a cast", type, rhstype);
    9302           93 :             break;
    9303           56 :           case ic_init:
    9304           56 :           case ic_init_const:
    9305           56 :             permerror_init (location, OPT_Wint_conversion,
    9306              :                             "initialization of %qT from %qT makes pointer "
    9307              :                             "from integer without a cast", type, rhstype);
    9308           56 :             break;
    9309           23 :           case ic_return:
    9310           23 :             permerror_init (location, OPT_Wint_conversion,
    9311              :                             "returning %qT from a function with return type "
    9312              :                             "%qT makes pointer from integer without a cast",
    9313              :                             rhstype, type);
    9314           23 :             break;
    9315            0 :           default:
    9316            0 :             gcc_unreachable ();
    9317              :           }
    9318              : 
    9319        77732 :       return convert (type, rhs);
    9320              :     }
    9321         1536 :   else if ((codel == INTEGER_TYPE || codel == BITINT_TYPE)
    9322          540 :            && coder == POINTER_TYPE)
    9323              :     {
    9324          514 :       switch (errtype)
    9325              :         {
    9326          344 :         case ic_argpass:
    9327          344 :           {
    9328          344 :             auto_diagnostic_group d;
    9329          344 :             range_label_for_type_mismatch rhs_label (rhstype, type);
    9330          344 :             gcc_rich_location richloc (expr_loc, &rhs_label,
    9331          344 :                                        highlight_colors::actual);
    9332          344 :             if (permerror_opt (&richloc, OPT_Wint_conversion,
    9333              :                                "passing argument %d of %qE makes integer from "
    9334              :                                "pointer without a cast", parmnum, rname))
    9335              :               {
    9336          323 :                 maybe_emit_indirection_note (expr_loc, rhs, type);
    9337          323 :                 inform_for_arg (fundecl, expr_loc, parmnum, type, rhstype);
    9338              :               }
    9339          344 :           }
    9340          344 :           break;
    9341           52 :         case ic_assign:
    9342           52 :           permerror_opt (location, OPT_Wint_conversion,
    9343              :                          "assignment to %qT from %qT makes integer from "
    9344              :                          "pointer without a cast", type, rhstype);
    9345           52 :           break;
    9346           83 :         case ic_init:
    9347           83 :         case ic_init_const:
    9348           83 :           permerror_init (location, OPT_Wint_conversion,
    9349              :                           "initialization of %qT from %qT makes integer "
    9350              :                           "from pointer without a cast", type, rhstype);
    9351           83 :           break;
    9352           35 :         case ic_return:
    9353           35 :           permerror_opt (location, OPT_Wint_conversion, "returning %qT from a "
    9354              :                          "function with return type %qT makes integer from "
    9355              :                          "pointer without a cast", rhstype, type);
    9356           35 :           break;
    9357            0 :         default:
    9358            0 :           gcc_unreachable ();
    9359              :         }
    9360              : 
    9361          514 :       return convert (type, rhs);
    9362              :     }
    9363          626 :   else if (C_BOOLEAN_TYPE_P (type)
    9364              :            /* The type nullptr_t may be converted to bool.  The
    9365              :               result is false.  */
    9366         1024 :            && (coder == POINTER_TYPE || coder == NULLPTR_TYPE))
    9367              :     {
    9368          398 :       tree ret;
    9369          398 :       bool save = in_late_binary_op;
    9370          398 :       in_late_binary_op = true;
    9371          398 :       ret = convert (type, rhs);
    9372          398 :       in_late_binary_op = save;
    9373          398 :       return ret;
    9374              :     }
    9375          624 :   else if (codel == NULLPTR_TYPE && null_pointer_constant)
    9376            6 :     return convert (type, rhs);
    9377              : 
    9378          618 :   switch (errtype)
    9379              :     {
    9380           35 :     case ic_argpass:
    9381           35 :       {
    9382           35 :         auto_diagnostic_group d;
    9383           35 :         range_label_for_type_mismatch rhs_label (rhstype, type);
    9384           35 :         gcc_rich_location richloc (expr_loc, &rhs_label,
    9385           35 :                                    highlight_colors::actual);
    9386           35 :         const char msg[] = G_("incompatible type for argument %d of %qE");
    9387           35 :         if (warnopt)
    9388            8 :           warning_at (expr_loc, warnopt, msg, parmnum, rname);
    9389              :         else
    9390           27 :           error_at (&richloc, msg, parmnum, rname);
    9391           35 :         inform_for_arg (fundecl, expr_loc, parmnum, type, rhstype);
    9392           35 :       }
    9393           35 :       break;
    9394          108 :     case ic_assign:
    9395          108 :       {
    9396          108 :         const char msg[]
    9397              :           = G_("incompatible types when assigning to type %qT from type %qT");
    9398          108 :         if (warnopt)
    9399            0 :           warning_at (expr_loc, 0, msg, type, rhstype);
    9400              :         else
    9401          108 :           error_at (expr_loc, msg, type, rhstype);
    9402          108 :         break;
    9403              :       }
    9404          460 :     case ic_init:
    9405          460 :     case ic_init_const:
    9406          460 :       {
    9407          460 :         const char msg[]
    9408              :           = G_("incompatible types when initializing type %qT using type %qT");
    9409          460 :         if (warnopt)
    9410            0 :           warning_at (location, 0, msg, type, rhstype);
    9411              :         else
    9412          460 :           error_at (location, msg, type, rhstype);
    9413          460 :         break;
    9414              :       }
    9415           15 :     case ic_return:
    9416           15 :       {
    9417           15 :         const char msg[]
    9418              :           = G_("incompatible types when returning type %qT but %qT was expected");
    9419           15 :         if (warnopt)
    9420            0 :           warning_at (location, 0, msg, rhstype, type);
    9421              :         else
    9422           15 :           error_at (location, msg, rhstype, type);
    9423           15 :         break;
    9424              :       }
    9425            0 :     default:
    9426            0 :       gcc_unreachable ();
    9427              :     }
    9428              : 
    9429          618 :   return error_mark_node;
    9430              : }
    9431              : 
    9432              : /* If VALUE is a compound expr all of whose expressions are constant, then
    9433              :    return its value.  Otherwise, return error_mark_node.
    9434              : 
    9435              :    This is for handling COMPOUND_EXPRs as initializer elements
    9436              :    which is allowed with a warning when -pedantic is specified.  */
    9437              : 
    9438              : static tree
    9439            2 : valid_compound_expr_initializer (tree value, tree endtype)
    9440              : {
    9441            2 :   if (TREE_CODE (value) == COMPOUND_EXPR)
    9442              :     {
    9443            1 :       if (valid_compound_expr_initializer (TREE_OPERAND (value, 0), endtype)
    9444            1 :           == error_mark_node)
    9445              :         return error_mark_node;
    9446            0 :       return valid_compound_expr_initializer (TREE_OPERAND (value, 1),
    9447            0 :                                               endtype);
    9448              :     }
    9449            1 :   else if (!initializer_constant_valid_p (value, endtype))
    9450            1 :     return error_mark_node;
    9451              :   else
    9452              :     return value;
    9453              : }
    9454              : 
    9455              : /* Perform appropriate conversions on the initial value of a variable,
    9456              :    store it in the declaration DECL,
    9457              :    and print any error messages that are appropriate.
    9458              :    If ORIGTYPE is not NULL_TREE, it is the original type of INIT.
    9459              :    If the init is invalid, store an ERROR_MARK.
    9460              : 
    9461              :    INIT_LOC is the location of the initial value.  */
    9462              : 
    9463              : void
    9464      7273771 : store_init_value (location_t init_loc, tree decl, tree init, tree origtype)
    9465              : {
    9466      7273771 :   tree value, type;
    9467      7273771 :   bool npc = false;
    9468      7273771 :   bool int_const_expr = false;
    9469      7273771 :   bool arith_const_expr = false;
    9470              : 
    9471              :   /* If variable's type was invalidly declared, just ignore it.  */
    9472              : 
    9473      7273771 :   type = TREE_TYPE (decl);
    9474      7273771 :   if (TREE_CODE (type) == ERROR_MARK)
    9475              :     return;
    9476              : 
    9477              :   /* Digest the specified initializer into an expression.  */
    9478              : 
    9479      7273763 :   if (init)
    9480              :     {
    9481      7273760 :       npc = null_pointer_constant_p (init);
    9482      7273760 :       int_const_expr = (TREE_CODE (init) == INTEGER_CST
    9483       420563 :                         && !TREE_OVERFLOW (init)
    9484      7694287 :                         && INTEGRAL_TYPE_P (TREE_TYPE (init)));
    9485              :       /* Not fully determined before folding.  */
    9486              :       arith_const_expr = true;
    9487              :     }
    9488      7273763 :   bool constexpr_p = (VAR_P (decl)
    9489      7273763 :                       && C_DECL_DECLARED_CONSTEXPR (decl));
    9490      7273763 :   value = digest_init (init_loc, decl, type, init, origtype, npc,
    9491              :                        int_const_expr, arith_const_expr, true,
    9492      7273763 :                        TREE_STATIC (decl) || constexpr_p, constexpr_p);
    9493              : 
    9494              :   /* Store the expression if valid; else report error.  */
    9495              : 
    9496      7273763 :   if (!in_system_header_at (input_location)
    9497      7273763 :       && AGGREGATE_TYPE_P (TREE_TYPE (decl)) && !TREE_STATIC (decl))
    9498        28952 :     warning (OPT_Wtraditional, "traditional C rejects automatic "
    9499              :              "aggregate initialization");
    9500              : 
    9501      7273763 :   if (value != error_mark_node || TREE_CODE (decl) != FUNCTION_DECL)
    9502      7273762 :     DECL_INITIAL (decl) = value;
    9503              : 
    9504              :   /* ANSI wants warnings about out-of-range constant initializers.  */
    9505      7273774 :   STRIP_TYPE_NOPS (value);
    9506      7273763 :   if (TREE_STATIC (decl))
    9507       180595 :     constant_expression_warning (value);
    9508              : 
    9509              :   /* Check if we need to set array size from compound literal size.  */
    9510      7273763 :   if (TREE_CODE (type) == ARRAY_TYPE
    9511        26527 :       && TYPE_DOMAIN (type) == NULL_TREE
    9512      7286324 :       && value != error_mark_node)
    9513              :     {
    9514              :       tree inside_init = init;
    9515              : 
    9516        11689 :       STRIP_TYPE_NOPS (inside_init);
    9517        11689 :       inside_init = fold (inside_init);
    9518              : 
    9519        11689 :       if (TREE_CODE (inside_init) == COMPOUND_LITERAL_EXPR)
    9520              :         {
    9521           13 :           tree cldecl = COMPOUND_LITERAL_EXPR_DECL (inside_init);
    9522              : 
    9523           13 :           if (TYPE_DOMAIN (TREE_TYPE (cldecl)))
    9524              :             {
    9525              :               /* For int foo[] = (int [3]){1}; we need to set array size
    9526              :                  now since later on array initializer will be just the
    9527              :                  brace enclosed list of the compound literal.  */
    9528           13 :               tree etype = strip_array_types (TREE_TYPE (decl));
    9529           13 :               type = build_distinct_type_copy (TYPE_MAIN_VARIANT (type));
    9530           13 :               TYPE_DOMAIN (type) = TYPE_DOMAIN (TREE_TYPE (cldecl));
    9531           13 :               layout_type (type);
    9532           13 :               layout_decl (cldecl, 0);
    9533           13 :               TREE_TYPE (decl)
    9534           26 :                 = c_build_qualified_type (type, TYPE_QUALS (etype));
    9535              :             }
    9536              :         }
    9537              :     }
    9538              : }
    9539              : 
    9540              : /* Methods for storing and printing names for error messages.  */
    9541              : 
    9542              : /* Implement a spelling stack that allows components of a name to be pushed
    9543              :    and popped.  Each element on the stack is this structure.  */
    9544              : 
    9545              : struct spelling
    9546              : {
    9547              :   int kind;
    9548              :   union
    9549              :     {
    9550              :       unsigned HOST_WIDE_INT i;
    9551              :       const char *s;
    9552              :     } u;
    9553              : };
    9554              : 
    9555              : #define SPELLING_STRING 1
    9556              : #define SPELLING_MEMBER 2
    9557              : #define SPELLING_BOUNDS 3
    9558              : 
    9559              : static struct spelling *spelling;       /* Next stack element (unused).  */
    9560              : static struct spelling *spelling_base;  /* Spelling stack base.  */
    9561              : static int spelling_size;               /* Size of the spelling stack.  */
    9562              : 
    9563              : /* Macros to save and restore the spelling stack around push_... functions.
    9564              :    Alternative to SAVE_SPELLING_STACK.  */
    9565              : 
    9566              : #define SPELLING_DEPTH() (spelling - spelling_base)
    9567              : #define RESTORE_SPELLING_DEPTH(DEPTH) (spelling = spelling_base + (DEPTH))
    9568              : 
    9569              : /* Push an element on the spelling stack with type KIND and assign VALUE
    9570              :    to MEMBER.  */
    9571              : 
    9572              : #define PUSH_SPELLING(KIND, VALUE, MEMBER)                              \
    9573              : {                                                                       \
    9574              :   int depth = SPELLING_DEPTH ();                                        \
    9575              :                                                                         \
    9576              :   if (depth >= spelling_size)                                                \
    9577              :     {                                                                   \
    9578              :       spelling_size += 10;                                              \
    9579              :       spelling_base = XRESIZEVEC (struct spelling, spelling_base,       \
    9580              :                                   spelling_size);                       \
    9581              :       RESTORE_SPELLING_DEPTH (depth);                                   \
    9582              :     }                                                                   \
    9583              :                                                                         \
    9584              :   spelling->kind = (KIND);                                           \
    9585              :   spelling->MEMBER = (VALUE);                                                \
    9586              :   spelling++;                                                           \
    9587              : }
    9588              : 
    9589              : /* Push STRING on the stack.  Printed literally.  */
    9590              : 
    9591              : static void
    9592      7270998 : push_string (const char *string)
    9593              : {
    9594      7270998 :   PUSH_SPELLING (SPELLING_STRING, string, u.s);
    9595      7270998 : }
    9596              : 
    9597              : /* Push a member name on the stack.  Printed as '.' STRING.  */
    9598              : 
    9599              : static void
    9600      1230892 : push_member_name (tree decl)
    9601              : {
    9602      1230892 :   const char *const string
    9603      1230892 :     = (DECL_NAME (decl)
    9604      1230892 :        ? identifier_to_locale (IDENTIFIER_POINTER (DECL_NAME (decl)))
    9605          210 :        : _("<anonymous>"));
    9606      1230892 :   PUSH_SPELLING (SPELLING_MEMBER, string, u.s);
    9607      1230892 : }
    9608              : 
    9609              : /* Push an array bounds on the stack.  Printed as [BOUNDS].  */
    9610              : 
    9611              : static void
    9612      2603298 : push_array_bounds (unsigned HOST_WIDE_INT bounds)
    9613              : {
    9614      2603298 :   PUSH_SPELLING (SPELLING_BOUNDS, bounds, u.i);
    9615      2603298 : }
    9616              : 
    9617              : /* Compute the maximum size in bytes of the printed spelling.  */
    9618              : 
    9619              : static int
    9620         2892 : spelling_length (void)
    9621              : {
    9622         2892 :   int size = 0;
    9623         2892 :   struct spelling *p;
    9624              : 
    9625         6416 :   for (p = spelling_base; p < spelling; p++)
    9626              :     {
    9627         3524 :       if (p->kind == SPELLING_BOUNDS)
    9628         1479 :         size += 25;
    9629              :       else
    9630         2045 :         size += strlen (p->u.s) + 1;
    9631              :     }
    9632              : 
    9633         2892 :   return size;
    9634              : }
    9635              : 
    9636              : /* Print the spelling to BUFFER and return it.  */
    9637              : 
    9638              : static char *
    9639         2892 : print_spelling (char *buffer)
    9640              : {
    9641         2892 :   char *d = buffer;
    9642         2892 :   struct spelling *p;
    9643              : 
    9644         6416 :   for (p = spelling_base; p < spelling; p++)
    9645         3524 :     if (p->kind == SPELLING_BOUNDS)
    9646              :       {
    9647         1479 :         sprintf (d, "[" HOST_WIDE_INT_PRINT_UNSIGNED "]", p->u.i);
    9648         1479 :         d += strlen (d);
    9649              :       }
    9650              :     else
    9651              :       {
    9652         2045 :         const char *s;
    9653         2045 :         if (p->kind == SPELLING_MEMBER)
    9654          198 :           *d++ = '.';
    9655        16715 :         for (s = p->u.s; (*d = *s++); d++)
    9656              :           ;
    9657              :       }
    9658         2892 :   *d++ = '\0';
    9659         2892 :   return buffer;
    9660              : }
    9661              : 
    9662              : /* Check whether INIT, a floating or integer constant, is
    9663              :    representable in TYPE, a real floating type with the same radix or
    9664              :    a decimal floating type initialized with a binary floating
    9665              :    constant.  Return true if OK, false if not.  */
    9666              : static bool
    9667          362 : constexpr_init_fits_real_type (tree type, tree init)
    9668              : {
    9669          362 :   gcc_assert (SCALAR_FLOAT_TYPE_P (type));
    9670          362 :   gcc_assert (TREE_CODE (init) == INTEGER_CST || TREE_CODE (init) == REAL_CST);
    9671          362 :   if (TREE_CODE (init) == REAL_CST
    9672          362 :       && TYPE_MODE (TREE_TYPE (init)) == TYPE_MODE (type))
    9673              :     {
    9674              :       /* Same mode, no conversion required except for the case of
    9675              :          signaling NaNs if the types are incompatible (e.g. double and
    9676              :          long double with the same mode).  */
    9677          177 :       if (REAL_VALUE_ISSIGNALING_NAN (TREE_REAL_CST (init))
    9678          195 :           && !comptypes (TYPE_MAIN_VARIANT (type),
    9679           18 :                          TYPE_MAIN_VARIANT (TREE_TYPE (init))))
    9680              :         return false;
    9681          177 :       return true;
    9682              :     }
    9683          185 :   if (TREE_CODE (init) == INTEGER_CST)
    9684              :     {
    9685           54 :       tree converted = build_real_from_int_cst (type, init);
    9686           54 :       bool fail = false;
    9687          108 :       wide_int w = real_to_integer (&TREE_REAL_CST (converted), &fail,
    9688           54 :                                     TYPE_PRECISION (TREE_TYPE (init)));
    9689           68 :       return !fail && wi::eq_p (w, wi::to_wide (init));
    9690           54 :     }
    9691          131 :   if (REAL_VALUE_ISSIGNALING_NAN (TREE_REAL_CST (init)))
    9692              :     return false;
    9693          114 :   if ((REAL_VALUE_ISINF (TREE_REAL_CST (init))
    9694           34 :        && MODE_HAS_INFINITIES (TYPE_MODE (type)))
    9695          218 :       || (REAL_VALUE_ISNAN (TREE_REAL_CST (init))
    9696           34 :           && MODE_HAS_NANS (TYPE_MODE (type))))
    9697           20 :     return true;
    9698           94 :   if (DECIMAL_FLOAT_TYPE_P (type)
    9699          134 :       && !DECIMAL_FLOAT_TYPE_P (TREE_TYPE (init)))
    9700              :     {
    9701              :       /* This is valid if the real number represented by the
    9702              :          initializer can be exactly represented in the decimal
    9703              :          type.  Compare the values using MPFR.  */
    9704            8 :       REAL_VALUE_TYPE t;
    9705            8 :       real_convert (&t, TYPE_MODE (type), &TREE_REAL_CST (init));
    9706            8 :       mpfr_t bin_val, dec_val;
    9707            8 :       mpfr_init2 (bin_val, REAL_MODE_FORMAT (TYPE_MODE (TREE_TYPE (init)))->p);
    9708            8 :       mpfr_init2 (dec_val, REAL_MODE_FORMAT (TYPE_MODE (TREE_TYPE (init)))->p);
    9709            8 :       mpfr_from_real (bin_val, &TREE_REAL_CST (init), MPFR_RNDN);
    9710            8 :       char string[256];
    9711            8 :       real_to_decimal (string, &t, sizeof string, 0, 1);
    9712            8 :       bool res = (mpfr_strtofr (dec_val, string, NULL, 10, MPFR_RNDN) == 0
    9713            8 :                   && mpfr_equal_p (bin_val, dec_val));
    9714            8 :       mpfr_clear (bin_val);
    9715            8 :       mpfr_clear (dec_val);
    9716            8 :       return res;
    9717              :     }
    9718              :   /* exact_real_truncate is not quite right here, since it doesn't
    9719              :      allow even an exact conversion to subnormal values.  */
    9720           86 :   REAL_VALUE_TYPE t;
    9721           86 :   real_convert (&t, TYPE_MODE (type), &TREE_REAL_CST (init));
    9722           86 :   return real_identical (&t, &TREE_REAL_CST (init));
    9723              : }
    9724              : 
    9725              : /* Check whether INIT (location LOC) is valid as a 'constexpr'
    9726              :    initializer for type TYPE, and give an error if not.  INIT has
    9727              :    already been folded and verified to be constant.  INT_CONST_EXPR
    9728              :    and ARITH_CONST_EXPR say whether it is an integer constant
    9729              :    expression or arithmetic constant expression, respectively.  If
    9730              :    TYPE is not a scalar type, this function does nothing.  */
    9731              : 
    9732              : static void
    9733          912 : check_constexpr_init (location_t loc, tree type, tree init,
    9734              :                       bool int_const_expr, bool arith_const_expr)
    9735              : {
    9736          912 :   if (POINTER_TYPE_P (type))
    9737              :     {
    9738              :       /* The initializer must be null.  */
    9739           86 :       if (TREE_CODE (init) != INTEGER_CST || !integer_zerop (init))
    9740            8 :         error_at (loc, "%<constexpr%> pointer initializer is not null");
    9741           86 :       return;
    9742              :     }
    9743          826 :   if (INTEGRAL_TYPE_P (type))
    9744              :     {
    9745              :       /* The initializer must be an integer constant expression,
    9746              :          representable in the target type.  */
    9747          316 :       if (!int_const_expr)
    9748              :         {
    9749           13 :           if (TREE_CODE (init) == RAW_DATA_CST
    9750           13 :               && TYPE_PRECISION (type) == CHAR_BIT)
    9751              :             {
    9752            4 :               if (!TYPE_UNSIGNED (type))
    9753          137 :                 for (unsigned int i = 0;
    9754          140 :                      i < (unsigned) RAW_DATA_LENGTH (init); ++i)
    9755          138 :                   if (RAW_DATA_SCHAR_ELT (init, i) < 0)
    9756              :                     {
    9757            1 :                       error_at (loc, "%<constexpr%> initializer not "
    9758              :                                 "representable in type of object");
    9759            1 :                       break;
    9760              :                     }
    9761              :             }
    9762              :           else
    9763            9 :             error_at (loc, "%<constexpr%> integer initializer is not an "
    9764              :                       "integer constant expression");
    9765              :         }
    9766          303 :       else if (!int_fits_type_p (init, type))
    9767            6 :         error_at (loc, "%<constexpr%> initializer not representable in "
    9768              :                   "type of object");
    9769          316 :       return;
    9770              :     }
    9771              :   /* We don't apply any extra checks to extension types such as vector
    9772              :      or fixed-point types.  */
    9773          510 :   if (TREE_CODE (type) != REAL_TYPE && TREE_CODE (type) != COMPLEX_TYPE)
    9774              :     return;
    9775          353 :   if (!arith_const_expr)
    9776              :     {
    9777            5 :       error_at (loc, "%<constexpr%> initializer is not an arithmetic "
    9778              :                 "constant expression");
    9779            5 :       return;
    9780              :     }
    9781              :   /* We don't apply any extra checks to complex integers.  */
    9782          348 :   if (TREE_CODE (type) == COMPLEX_TYPE
    9783          348 :       && TREE_CODE (TREE_TYPE (type)) != REAL_TYPE)
    9784              :     return;
    9785              :   /* Following N3082, a real type cannot be initialized from a complex
    9786              :      type and a binary type cannot be initialized from a decimal type
    9787              :      (but initializing a decimal type from a binary type is OK).
    9788              :      Signaling NaN initializers are OK only if the types are
    9789              :      compatible (not just the same mode); all quiet NaN and infinity
    9790              :      initializations are considered to preserve the value.  */
    9791          348 :   if (TREE_CODE (TREE_TYPE (init)) == COMPLEX_TYPE
    9792          348 :       && SCALAR_FLOAT_TYPE_P (type))
    9793              :     {
    9794            6 :       error_at (loc, "%<constexpr%> initializer for a real type is of "
    9795              :                 "complex type");
    9796            6 :       return;
    9797              :     }
    9798          342 :   if (SCALAR_FLOAT_TYPE_P (type)
    9799          300 :       && SCALAR_FLOAT_TYPE_P (TREE_TYPE (init))
    9800          250 :       && DECIMAL_FLOAT_TYPE_P (TREE_TYPE (init))
    9801          481 :       && !DECIMAL_FLOAT_TYPE_P (type))
    9802              :     {
    9803            6 :       error_at (loc, "%<constexpr%> initializer for a binary "
    9804              :                 "floating-point type is of decimal type");
    9805            6 :       return;
    9806              :     }
    9807          336 :   bool fits;
    9808          336 :   if (TREE_CODE (type) == COMPLEX_TYPE)
    9809              :     {
    9810           42 :       switch (TREE_CODE (init))
    9811              :         {
    9812           10 :         case INTEGER_CST:
    9813           10 :         case REAL_CST:
    9814           10 :           fits = constexpr_init_fits_real_type (TREE_TYPE (type), init);
    9815           10 :           break;
    9816           32 :         case COMPLEX_CST:
    9817           32 :           fits = (constexpr_init_fits_real_type (TREE_TYPE (type),
    9818           32 :                                                  TREE_REALPART (init))
    9819           58 :                   && constexpr_init_fits_real_type (TREE_TYPE (type),
    9820           26 :                                                     TREE_IMAGPART (init)));
    9821              :           break;
    9822            0 :         default:
    9823            0 :           gcc_unreachable ();
    9824              :         }
    9825              :     }
    9826              :   else
    9827          294 :     fits = constexpr_init_fits_real_type (type, init);
    9828          304 :   if (!fits)
    9829           65 :     error_at (loc, "%<constexpr%> initializer not representable in "
    9830              :               "type of object");
    9831              : }
    9832              : 
    9833              : /* Digest the parser output INIT as an initializer for type TYPE
    9834              :    initializing DECL.
    9835              :    Return a C expression of type TYPE to represent the initial value.
    9836              : 
    9837              :    If ORIGTYPE is not NULL_TREE, it is the original type of INIT.
    9838              : 
    9839              :    NULL_POINTER_CONSTANT is true if INIT is a null pointer constant,
    9840              :    INT_CONST_EXPR is true if INIT is an integer constant expression,
    9841              :    and ARITH_CONST_EXPR is true if INIT is, or might be, an arithmetic
    9842              :    constant expression, false if it has already been determined in the
    9843              :    caller that it is not (but folding may have made the value passed here
    9844              :    indistinguishable from an arithmetic constant expression).
    9845              : 
    9846              :    If INIT is a string constant, STRICT_STRING is true if it is
    9847              :    unparenthesized or we should not warn here for it being parenthesized.
    9848              :    For other types of INIT, STRICT_STRING is not used.
    9849              : 
    9850              :    INIT_LOC is the location of the INIT.
    9851              : 
    9852              :    REQUIRE_CONSTANT requests an error if non-constant initializers or
    9853              :    elements are seen.  REQUIRE_CONSTEXPR means the stricter requirements
    9854              :    on initializers for 'constexpr' objects apply.  */
    9855              : 
    9856              : static tree
    9857     16904230 : digest_init (location_t init_loc, tree decl, tree type, tree init,
    9858              :              tree origtype, bool null_pointer_constant, bool int_const_expr,
    9859              :              bool arith_const_expr, bool strict_string,
    9860              :              bool require_constant, bool require_constexpr)
    9861              : {
    9862     16904230 :   enum tree_code code = TREE_CODE (type);
    9863     16904230 :   tree inside_init = init;
    9864     16904230 :   tree semantic_type = NULL_TREE;
    9865     16904230 :   bool maybe_const = true;
    9866              : 
    9867     16904230 :   if (type == error_mark_node
    9868     16904230 :       || !init
    9869     33808457 :       || error_operand_p (init))
    9870              :     return error_mark_node;
    9871              : 
    9872     16911647 :   STRIP_TYPE_NOPS (inside_init);
    9873              : 
    9874              :   /* If require_constant is TRUE,  when the initializer is a call to
    9875              :      .ACCESS_WITH_SIZE, use the first argument as the initializer.
    9876              :      For example:
    9877              :      y = (char *) .ACCESS_WITH_SIZE ((char *) &static_annotated.c,...)
    9878              :      will be converted to
    9879              :      y = &static_annotated.c.  */
    9880              : 
    9881     16903095 :   if (require_constant
    9882      2892548 :       && TREE_CODE (inside_init) == NOP_EXPR
    9883       736243 :       && TREE_CODE (TREE_OPERAND (inside_init, 0)) == CALL_EXPR
    9884     16903097 :       && is_access_with_size_p (TREE_OPERAND (inside_init, 0)))
    9885            2 :     inside_init
    9886            2 :       = get_ref_from_access_with_size (TREE_OPERAND (inside_init, 0));
    9887              : 
    9888     16903095 :   if (!c_in_omp_for)
    9889              :     {
    9890     16898343 :       if (TREE_CODE (inside_init) == EXCESS_PRECISION_EXPR)
    9891              :         {
    9892          441 :           semantic_type = TREE_TYPE (inside_init);
    9893          441 :           inside_init = TREE_OPERAND (inside_init, 0);
    9894              :         }
    9895     16898343 :       inside_init = c_fully_fold (inside_init, require_constant, &maybe_const);
    9896              :     }
    9897              :   /* TODO: this may not detect all cases of expressions folding to
    9898              :      constants that are not arithmetic constant expressions.  */
    9899     16903095 :   if (!maybe_const)
    9900              :     arith_const_expr = false;
    9901     25226381 :   else if (!INTEGRAL_TYPE_P (TREE_TYPE (inside_init))
    9902      5659469 :            && TREE_CODE (TREE_TYPE (inside_init)) != REAL_TYPE
    9903     16838592 :            && TREE_CODE (TREE_TYPE (inside_init)) != COMPLEX_TYPE)
    9904              :     arith_const_expr = false;
    9905      8416354 :   else if (TREE_CODE (inside_init) != INTEGER_CST
    9906              :            && TREE_CODE (inside_init) != REAL_CST
    9907              :            && TREE_CODE (inside_init) != COMPLEX_CST
    9908              :            && TREE_CODE (inside_init) != RAW_DATA_CST)
    9909              :     arith_const_expr = false;
    9910      5076897 :   else if (TREE_OVERFLOW (inside_init))
    9911     11826242 :     arith_const_expr = false;
    9912              : 
    9913              :   /* Initialization of an array of chars from a string constant
    9914              :      optionally enclosed in braces.  */
    9915              : 
    9916     16903095 :   if (code == ARRAY_TYPE && inside_init
    9917       189442 :       && TREE_CODE (inside_init) == STRING_CST)
    9918              :     {
    9919        11773 :       tree typ1
    9920        11773 :         = (TYPE_ATOMIC (TREE_TYPE (type))
    9921        11773 :            ? c_build_qualified_type (TYPE_MAIN_VARIANT (TREE_TYPE (type)),
    9922              :                                      TYPE_QUAL_ATOMIC)
    9923        11759 :            : TYPE_MAIN_VARIANT (TREE_TYPE (type)));
    9924              :       /* Note that an array could be both an array of character type
    9925              :          and an array of wchar_t if wchar_t is signed char or unsigned
    9926              :          char.  */
    9927        23546 :       bool char_array = (typ1 == char_type_node
    9928          516 :                          || typ1 == signed_char_type_node
    9929        12254 :                          || typ1 == unsigned_char_type_node);
    9930        11773 :       bool wchar_array = comptypes (typ1, wchar_type_node);
    9931        11773 :       bool char16_array = comptypes (typ1, char16_type_node);
    9932        11773 :       bool char32_array = comptypes (typ1, char32_type_node);
    9933              : 
    9934        11773 :       if (char_array || wchar_array || char16_array || char32_array)
    9935              :         {
    9936        11744 :           struct c_expr expr;
    9937        11744 :           tree typ2 = TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (inside_init)));
    9938        11744 :           bool incompat_string_cst = false;
    9939        11744 :           expr.value = inside_init;
    9940        11744 :           expr.original_code = (strict_string ? STRING_CST : ERROR_MARK);
    9941        11744 :           expr.original_type = NULL;
    9942        11744 :           expr.m_decimal = 0;
    9943        11744 :           maybe_warn_string_init (init_loc, type, expr);
    9944              : 
    9945        11744 :           if (TYPE_DOMAIN (type) && !TYPE_MAX_VALUE (TYPE_DOMAIN (type)))
    9946           91 :             pedwarn_init (init_loc, OPT_Wpedantic,
    9947              :                           "initialization of a flexible array member");
    9948              : 
    9949        11744 :           if (comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (inside_init)),
    9950        11744 :                          TYPE_MAIN_VARIANT (type)))
    9951              :             return inside_init;
    9952              : 
    9953         4186 :           if (char_array)
    9954              :             {
    9955         4075 :               if (typ2 != char_type_node && typ2 != char8_type_node)
    9956              :                 incompat_string_cst = true;
    9957              :             }
    9958          111 :           else if (!comptypes (typ1, typ2))
    9959              :             incompat_string_cst = true;
    9960              : 
    9961              :           if (incompat_string_cst)
    9962              :             {
    9963           72 :               error_init (init_loc, "cannot initialize array of %qT from "
    9964              :                           "a string literal with type array of %qT",
    9965              :                           typ1, typ2);
    9966           72 :               return error_mark_node;
    9967              :             }
    9968              : 
    9969         4114 :           if (require_constexpr
    9970         4114 :               && TYPE_UNSIGNED (typ1) != TYPE_UNSIGNED (typ2))
    9971              :             {
    9972              :               /* Check if all characters of the string can be
    9973              :                  represented in the type of the constexpr object being
    9974              :                  initialized.  */
    9975           24 :               unsigned HOST_WIDE_INT len = TREE_STRING_LENGTH (inside_init);
    9976           24 :               const unsigned char *p =
    9977           24 :                 (const unsigned char *) TREE_STRING_POINTER (inside_init);
    9978           24 :               gcc_assert (CHAR_TYPE_SIZE == 8 && CHAR_BIT == 8);
    9979           70 :               for (unsigned i = 0; i < len; i++)
    9980           58 :                 if (p[i] > 127)
    9981              :                   {
    9982           12 :                     error_init (init_loc, "%<constexpr%> initializer not "
    9983              :                                 "representable in type of object");
    9984           12 :                     break;
    9985              :                   }
    9986              :             }
    9987              : 
    9988         4114 :           if (TYPE_DOMAIN (type) != NULL_TREE
    9989         4020 :               && TYPE_SIZE (type) != NULL_TREE
    9990         8075 :               && TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST)
    9991              :             {
    9992         3961 :               unsigned HOST_WIDE_INT len = TREE_STRING_LENGTH (inside_init);
    9993              : 
    9994         3961 :               if (compare_tree_int (TYPE_SIZE_UNIT (type), len) < 0)
    9995              :                 {
    9996          397 :                   unsigned HOST_WIDE_INT avail
    9997          397 :                     = tree_to_uhwi (TYPE_SIZE_UNIT (type));
    9998          397 :                   unsigned unit = TYPE_PRECISION (typ1) / BITS_PER_UNIT;
    9999          397 :                   const char *p = TREE_STRING_POINTER (inside_init);
   10000              : 
   10001              :                   /* Construct truncated string.  */
   10002          397 :                   inside_init = build_string (avail, p);
   10003              : 
   10004              :                   /* Subtract the size of a single (possibly wide) character
   10005              :                      because it may be ok to ignore the terminating NUL char
   10006              :                      that is counted in the length of the constant.  */
   10007          397 :                   if (len - unit > avail)
   10008           63 :                     pedwarn_init (init_loc, 0,
   10009              :                                   "initializer-string for array of %qT "
   10010              :                                   "is too long (%wu chars into %wu "
   10011              :                                   "available)", typ1, len, avail);
   10012          334 :                   else if (warn_cxx_compat)
   10013            9 :                     warning_at (init_loc, OPT_Wc___compat,
   10014              :                                 "initializer-string for array of %qT "
   10015              :                                 "is too long for C++ (%wu chars into %wu "
   10016              :                                 "available)", typ1, len, avail);
   10017          325 :                   else if (warn_unterminated_string_initialization
   10018          325 :                            && get_attr_nonstring_decl (decl) == NULL_TREE)
   10019           22 :                     warning_at (init_loc,
   10020           22 :                                 OPT_Wunterminated_string_initialization,
   10021              :                                 "initializer-string for array of %qT "
   10022              :                                 "truncates NUL terminator but destination "
   10023              :                                 "lacks %qs attribute (%wu chars into %wu "
   10024              :                                 "available)", typ1, "nonstring", len, avail);
   10025              :                 }
   10026              :             }
   10027              : 
   10028         4114 :           TREE_TYPE (inside_init) = type;
   10029         4114 :           return inside_init;
   10030              :         }
   10031           29 :       else if (INTEGRAL_TYPE_P (typ1))
   10032              :         {
   10033           29 :           error_init (init_loc, "array of inappropriate type initialized "
   10034              :                       "from string constant");
   10035           29 :           return error_mark_node;
   10036              :         }
   10037              :     }
   10038              : 
   10039              :   /* Build a VECTOR_CST from a *constant* vector constructor.  If the
   10040              :      vector constructor is not constant (e.g. {1,2,3,foo()}) then punt
   10041              :      below and handle as a constructor.  */
   10042     16891322 :   if (code == VECTOR_TYPE
   10043      6311095 :       && VECTOR_TYPE_P (TREE_TYPE (inside_init))
   10044      6311093 :       && vector_types_convertible_p (TREE_TYPE (inside_init), type, true)
   10045     23202377 :       && TREE_CONSTANT (inside_init))
   10046              :     {
   10047       633268 :       if (TREE_CODE (inside_init) == VECTOR_CST
   10048       633365 :           && comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (inside_init)),
   10049           97 :                         TYPE_MAIN_VARIANT (type)))
   10050              :         return inside_init;
   10051              : 
   10052       633171 :       if (TREE_CODE (inside_init) == CONSTRUCTOR)
   10053              :         {
   10054              :           unsigned HOST_WIDE_INT ix;
   10055              :           tree value;
   10056      4173687 :           bool constant_p = true;
   10057              : 
   10058              :           /* Iterate through elements and check if all constructor
   10059              :              elements are *_CSTs.  */
   10060      4173687 :           FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (inside_init), ix, value)
   10061      3540572 :             if (!CONSTANT_CLASS_P (value))
   10062              :               {
   10063              :                 constant_p = false;
   10064              :                 break;
   10065              :               }
   10066              : 
   10067       633171 :           if (constant_p)
   10068       633115 :             return build_vector_from_ctor (type,
   10069       633115 :                                            CONSTRUCTOR_ELTS (inside_init));
   10070              :         }
   10071              :     }
   10072              : 
   10073     16258110 :   if (warn_sequence_point)
   10074      2448782 :     verify_sequence_points (inside_init);
   10075              : 
   10076              :   /* Any type can be initialized
   10077              :      from an expression of the same type, optionally with braces.  */
   10078              : 
   10079     16258110 :   if (inside_init && TREE_TYPE (inside_init) != NULL_TREE
   10080     32516220 :       && (comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (inside_init)),
   10081     16258110 :                      TYPE_MAIN_VARIANT (type))
   10082      3133523 :           || (code == ARRAY_TYPE
   10083          477 :               && comptypes (TREE_TYPE (inside_init), type))
   10084      3133523 :           || (gnu_vector_type_p (type)
   10085          189 :               && comptypes (TREE_TYPE (inside_init), type))
   10086      3133523 :           || (code == POINTER_TYPE
   10087       112616 :               && TREE_CODE (TREE_TYPE (inside_init)) == ARRAY_TYPE
   10088         9295 :               && comptypes (TREE_TYPE (TREE_TYPE (inside_init)),
   10089         9295 :                             TREE_TYPE (type)))))
   10090              :     {
   10091     13126565 :       if (code == POINTER_TYPE)
   10092              :         {
   10093       784738 :           if (TREE_CODE (TREE_TYPE (inside_init)) == ARRAY_TYPE)
   10094              :             {
   10095         1978 :               if (TREE_CODE (inside_init) == STRING_CST
   10096           68 :                   || TREE_CODE (inside_init) == COMPOUND_LITERAL_EXPR)
   10097         1975 :                 inside_init = array_to_pointer_conversion
   10098         1975 :                   (init_loc, inside_init);
   10099              :               else
   10100              :                 {
   10101            3 :                   error_init (init_loc, "invalid use of non-lvalue array");
   10102            3 :                   return error_mark_node;
   10103              :                 }
   10104              :             }
   10105              :         }
   10106              : 
   10107     13126562 :       if (code == VECTOR_TYPE || c_hardbool_type_attr (type))
   10108              :         /* Although the types are compatible, we may require a
   10109              :            conversion.  */
   10110      5677827 :         inside_init = convert (type, inside_init);
   10111              : 
   10112     13126562 :       if ((code == RECORD_TYPE || code == UNION_TYPE)
   10113     13126562 :           && !comptypes (TYPE_MAIN_VARIANT (type), TYPE_MAIN_VARIANT (TREE_TYPE (inside_init))))
   10114              :         {
   10115            0 :           error_init (init_loc, "invalid initializer");
   10116            0 :           return error_mark_node;
   10117              :         }
   10118              : 
   10119     13126562 :       if (require_constant
   10120      2297939 :           && TREE_CODE (inside_init) == COMPOUND_LITERAL_EXPR)
   10121              :         {
   10122              :           /* As an extension, allow initializing objects with static storage
   10123              :              duration with compound literals (which are then treated just as
   10124              :              the brace enclosed list they contain).  Also allow this for
   10125              :              vectors, as we can only assign them with compound literals.  */
   10126           31 :           if (flag_isoc99 && code != VECTOR_TYPE)
   10127            8 :             pedwarn_init (init_loc, OPT_Wpedantic, "initializer element "
   10128              :                           "is not constant");
   10129           31 :           tree decl = COMPOUND_LITERAL_EXPR_DECL (inside_init);
   10130           31 :           inside_init = DECL_INITIAL (decl);
   10131              :         }
   10132              : 
   10133     13126562 :       if (code == ARRAY_TYPE && TREE_CODE (inside_init) != STRING_CST
   10134       177192 :           && TREE_CODE (inside_init) != CONSTRUCTOR)
   10135              :         {
   10136            2 :           error_init (init_loc, "array initialized from non-constant array "
   10137              :                       "expression");
   10138            2 :           return error_mark_node;
   10139              :         }
   10140              : 
   10141              :       /* Compound expressions can only occur here if -Wpedantic or
   10142              :          -pedantic-errors is specified.  In the later case, we always want
   10143              :          an error.  In the former case, we simply want a warning.  */
   10144     13126560 :       if (require_constant && pedantic
   10145        20308 :           && TREE_CODE (inside_init) == COMPOUND_EXPR)
   10146              :         {
   10147            1 :           inside_init
   10148            1 :             = valid_compound_expr_initializer (inside_init,
   10149            1 :                                                TREE_TYPE (inside_init));
   10150            1 :           if (inside_init == error_mark_node)
   10151            1 :             error_init (init_loc, "initializer element is not constant");
   10152              :           else
   10153            0 :             pedwarn_init (init_loc, OPT_Wpedantic,
   10154              :                           "initializer element is not constant");
   10155            1 :           if (flag_pedantic_errors)
   10156            0 :             inside_init = error_mark_node;
   10157              :         }
   10158      2297938 :       else if (require_constant
   10159      2297938 :                && !initializer_constant_valid_p (inside_init,
   10160      2297938 :                                                  TREE_TYPE (inside_init)))
   10161              :         {
   10162           94 :           error_init (init_loc, "initializer element is not constant");
   10163           94 :           inside_init = error_mark_node;
   10164              :         }
   10165     13126465 :       else if (require_constant && !maybe_const)
   10166          219 :         pedwarn_init (init_loc, OPT_Wpedantic,
   10167              :                       "initializer element is not a constant expression");
   10168     13126246 :       else if (require_constexpr)
   10169          584 :         check_constexpr_init (init_loc, type, inside_init,
   10170              :                               int_const_expr, arith_const_expr);
   10171              : 
   10172              :       /* Added to enable additional -Wsuggest-attribute=format warnings.  */
   10173     13126560 :       if (TREE_CODE (TREE_TYPE (inside_init)) == POINTER_TYPE)
   10174       853813 :         inside_init = convert_for_assignment (init_loc, UNKNOWN_LOCATION,
   10175              :                                               type, inside_init, origtype,
   10176              :                                               (require_constant
   10177              :                                                ? ic_init_const
   10178              :                                                : ic_init), null_pointer_constant,
   10179              :                                               NULL_TREE, NULL_TREE, 0);
   10180     13126560 :       if (TREE_CODE (inside_init) == RAW_DATA_CST
   10181          254 :           && c_inhibit_evaluation_warnings == 0
   10182          254 :           && warn_conversion
   10183            1 :           && !TYPE_UNSIGNED (type)
   10184     13126561 :           && TYPE_PRECISION (type) == CHAR_BIT)
   10185          303 :         for (unsigned int i = 0;
   10186          304 :              i < (unsigned) RAW_DATA_LENGTH (inside_init); ++i)
   10187          303 :           if (RAW_DATA_SCHAR_ELT (inside_init, i) < 0)
   10188           10 :             warning_at (init_loc, OPT_Wconversion,
   10189              :                         "conversion from %qT to %qT changes value from "
   10190              :                         "%qd to %qd",
   10191              :                         integer_type_node, type,
   10192           10 :                         RAW_DATA_UCHAR_ELT (inside_init, i),
   10193           10 :                         RAW_DATA_SCHAR_ELT (inside_init, i));
   10194     13126560 :       return inside_init;
   10195              :     }
   10196              : 
   10197              :   /* Handle scalar types, including conversions.  */
   10198              : 
   10199      3131545 :   if (code == INTEGER_TYPE || code == REAL_TYPE || code == FIXED_POINT_TYPE
   10200       129441 :       || code == POINTER_TYPE || code == ENUMERAL_TYPE || code == BOOLEAN_TYPE
   10201        11787 :       || code == COMPLEX_TYPE || code == VECTOR_TYPE || code == NULLPTR_TYPE
   10202         9724 :       || code == BITINT_TYPE)
   10203              :     {
   10204      3131057 :       tree unconverted_init = inside_init;
   10205      3131057 :       if (TREE_CODE (TREE_TYPE (init)) == ARRAY_TYPE
   10206      3131057 :           && (TREE_CODE (init) == STRING_CST
   10207            2 :               || TREE_CODE (init) == COMPOUND_LITERAL_EXPR))
   10208         7318 :         inside_init = init = array_to_pointer_conversion (init_loc, init);
   10209      3131057 :       if (semantic_type)
   10210          436 :         inside_init = build1 (EXCESS_PRECISION_EXPR, semantic_type,
   10211              :                               inside_init);
   10212      3131057 :       inside_init
   10213      5682287 :         = convert_for_assignment (init_loc, UNKNOWN_LOCATION, type,
   10214              :                                   inside_init, origtype,
   10215              :                                   require_constant ? ic_init_const : ic_init,
   10216              :                                   null_pointer_constant, NULL_TREE, NULL_TREE,
   10217              :                                   0);
   10218              : 
   10219              :       /* Check to see if we have already given an error message.  */
   10220      3131057 :       if (inside_init == error_mark_node)
   10221              :         ;
   10222      3130597 :       else if (require_constant && !TREE_CONSTANT (inside_init))
   10223              :         {
   10224           36 :           error_init (init_loc, "initializer element is not constant");
   10225           36 :           inside_init = error_mark_node;
   10226              :         }
   10227      3130561 :       else if (require_constant
   10228      3709960 :                && !initializer_constant_valid_p (inside_init,
   10229       579399 :                                                  TREE_TYPE (inside_init)))
   10230              :         {
   10231           10 :           error_init (init_loc, "initializer element is not computable at "
   10232              :                       "load time");
   10233           10 :           inside_init = error_mark_node;
   10234              :         }
   10235      3130551 :       else if (require_constant && !maybe_const)
   10236            5 :         pedwarn_init (init_loc, OPT_Wpedantic,
   10237              :                       "initializer element is not a constant expression");
   10238      3130546 :       else if (require_constexpr)
   10239          328 :         check_constexpr_init (init_loc, type, unconverted_init,
   10240              :                               int_const_expr, arith_const_expr);
   10241              : 
   10242      3131057 :       return inside_init;
   10243              :     }
   10244              : 
   10245              :   /* Come here only for records and arrays.  */
   10246              : 
   10247          488 :   if (COMPLETE_TYPE_P (type) && TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST)
   10248              :     {
   10249            0 :       error_init (init_loc,
   10250              :                   "variable-sized object may not be initialized except "
   10251              :                   "with an empty initializer");
   10252            0 :       return error_mark_node;
   10253              :     }
   10254              : 
   10255          488 :   error_init (init_loc, "invalid initializer");
   10256          488 :   return error_mark_node;
   10257              : }
   10258              : 
   10259              : /* Handle initializers that use braces.  */
   10260              : 
   10261              : /* Type of object we are accumulating a constructor for.
   10262              :    This type is always a RECORD_TYPE, UNION_TYPE or ARRAY_TYPE.  */
   10263              : static tree constructor_type;
   10264              : 
   10265              : /* For a RECORD_TYPE or UNION_TYPE, this is the chain of fields
   10266              :    left to fill.  */
   10267              : static tree constructor_fields;
   10268              : 
   10269              : /* For an ARRAY_TYPE, this is the specified index
   10270              :    at which to store the next element we get.  */
   10271              : static tree constructor_index;
   10272              : 
   10273              : /* For an ARRAY_TYPE, this is the maximum index.  */
   10274              : static tree constructor_max_index;
   10275              : 
   10276              : /* For a RECORD_TYPE, this is the first field not yet written out.  */
   10277              : static tree constructor_unfilled_fields;
   10278              : 
   10279              : /* For an ARRAY_TYPE, this is the index of the first element
   10280              :    not yet written out.  */
   10281              : static tree constructor_unfilled_index;
   10282              : 
   10283              : /* In a RECORD_TYPE, the byte index of the next consecutive field.
   10284              :    This is so we can generate gaps between fields, when appropriate.  */
   10285              : static tree constructor_bit_index;
   10286              : 
   10287              : /* If we are saving up the elements rather than allocating them,
   10288              :    this is the list of elements so far (in reverse order,
   10289              :    most recent first).  */
   10290              : static vec<constructor_elt, va_gc> *constructor_elements;
   10291              : 
   10292              : /* 1 if constructor should be incrementally stored into a constructor chain,
   10293              :    0 if all the elements should be kept in AVL tree.  */
   10294              : static int constructor_incremental;
   10295              : 
   10296              : /* 1 if so far this constructor's elements are all compile-time constants.  */
   10297              : static int constructor_constant;
   10298              : 
   10299              : /* 1 if so far this constructor's elements are all valid address constants.  */
   10300              : static int constructor_simple;
   10301              : 
   10302              : /* 1 if this constructor has an element that cannot be part of a
   10303              :    constant expression.  */
   10304              : static int constructor_nonconst;
   10305              : 
   10306              : /* 1 if this constructor is erroneous so far.  */
   10307              : static int constructor_erroneous;
   10308              : 
   10309              : /* 1 if this constructor is the universal zero initializer { 0 }.  */
   10310              : static int constructor_zeroinit;
   10311              : 
   10312              : /* 1 if this constructor should have padding bits zeroed (C23 {}.  */
   10313              : static bool constructor_zero_padding_bits;
   10314              : 
   10315              : /* 1 if this constructor is a braced scalar initializer (further nested levels
   10316              :    of braces are an error).  */
   10317              : static bool constructor_braced_scalar;
   10318              : 
   10319              : /* Structure for managing pending initializer elements, organized as an
   10320              :    AVL tree.  */
   10321              : 
   10322              : struct init_node
   10323              : {
   10324              :   struct init_node *left, *right;
   10325              :   struct init_node *parent;
   10326              :   int balance;
   10327              :   tree purpose;
   10328              :   tree value;
   10329              :   tree origtype;
   10330              : };
   10331              : 
   10332              : /* Tree of pending elements at this constructor level.
   10333              :    These are elements encountered out of order
   10334              :    which belong at places we haven't reached yet in actually
   10335              :    writing the output.
   10336              :    Will never hold tree nodes across GC runs.  */
   10337              : static struct init_node *constructor_pending_elts;
   10338              : 
   10339              : /* The SPELLING_DEPTH of this constructor.  */
   10340              : static int constructor_depth;
   10341              : 
   10342              : /* DECL node for which an initializer is being read.
   10343              :    0 means we are reading a constructor expression
   10344              :    such as (struct foo) {...}.  */
   10345              : static tree constructor_decl;
   10346              : 
   10347              : /* Nonzero if there were any member designators in this initializer.  */
   10348              : static int constructor_designated;
   10349              : 
   10350              : /* Nesting depth of designator list.  */
   10351              : static int designator_depth;
   10352              : 
   10353              : /* Nonzero if there were diagnosed errors in this designator list.  */
   10354              : static int designator_erroneous;
   10355              : 
   10356              : 
   10357              : /* This stack has a level for each implicit or explicit level of
   10358              :    structuring in the initializer, including the outermost one.  It
   10359              :    saves the values of most of the variables above.  */
   10360              : 
   10361              : struct constructor_range_stack;
   10362              : 
   10363              : struct constructor_stack
   10364              : {
   10365              :   struct constructor_stack *next;
   10366              :   tree type;
   10367              :   tree fields;
   10368              :   tree index;
   10369              :   tree max_index;
   10370              :   tree unfilled_index;
   10371              :   tree unfilled_fields;
   10372              :   tree bit_index;
   10373              :   vec<constructor_elt, va_gc> *elements;
   10374              :   struct init_node *pending_elts;
   10375              :   int offset;
   10376              :   int depth;
   10377              :   /* If value nonzero, this value should replace the entire
   10378              :      constructor at this level.  */
   10379              :   struct c_expr replacement_value;
   10380              :   struct constructor_range_stack *range_stack;
   10381              :   char constant;
   10382              :   char simple;
   10383              :   char nonconst;
   10384              :   char implicit;
   10385              :   char erroneous;
   10386              :   char outer;
   10387              :   char incremental;
   10388              :   char designated;
   10389              :   bool zero_padding_bits;
   10390              :   bool braced_scalar;
   10391              :   int designator_depth;
   10392              : };
   10393              : 
   10394              : static struct constructor_stack *constructor_stack;
   10395              : 
   10396              : /* This stack represents designators from some range designator up to
   10397              :    the last designator in the list.  */
   10398              : 
   10399              : struct constructor_range_stack
   10400              : {
   10401              :   struct constructor_range_stack *next, *prev;
   10402              :   struct constructor_stack *stack;
   10403              :   tree range_start;
   10404              :   tree index;
   10405              :   tree range_end;
   10406              :   tree fields;
   10407              : };
   10408              : 
   10409              : static struct constructor_range_stack *constructor_range_stack;
   10410              : 
   10411              : /* This stack records separate initializers that are nested.
   10412              :    Nested initializers can't happen in ANSI C, but GNU C allows them
   10413              :    in cases like { ... (struct foo) { ... } ... }.  */
   10414              : 
   10415              : struct initializer_stack
   10416              : {
   10417              :   struct initializer_stack *next;
   10418              :   tree decl;
   10419              :   struct constructor_stack *constructor_stack;
   10420              :   struct constructor_range_stack *constructor_range_stack;
   10421              :   vec<constructor_elt, va_gc> *elements;
   10422              :   struct spelling *spelling;
   10423              :   struct spelling *spelling_base;
   10424              :   int spelling_size;
   10425              :   char require_constant_value;
   10426              :   char require_constant_elements;
   10427              :   char require_constexpr_value;
   10428              :   char designated;
   10429              :   rich_location *missing_brace_richloc;
   10430              : };
   10431              : 
   10432              : static struct initializer_stack *initializer_stack;
   10433              : 
   10434              : /* Prepare to parse and output the initializer for variable DECL.  */
   10435              : 
   10436              : void
   10437      7270998 : start_init (tree decl, tree asmspec_tree ATTRIBUTE_UNUSED,
   10438              :             bool init_require_constant, bool init_require_constexpr,
   10439              :             rich_location *richloc)
   10440              : {
   10441      7270998 :   const char *locus;
   10442      7270998 :   struct initializer_stack *p = XNEW (struct initializer_stack);
   10443              : 
   10444      7270998 :   p->decl = constructor_decl;
   10445      7270998 :   p->require_constant_value = require_constant_value;
   10446      7270998 :   p->require_constant_elements = require_constant_elements;
   10447      7270998 :   p->require_constexpr_value = require_constexpr_value;
   10448      7270998 :   p->constructor_stack = constructor_stack;
   10449      7270998 :   p->constructor_range_stack = constructor_range_stack;
   10450      7270998 :   p->elements = constructor_elements;
   10451      7270998 :   p->spelling = spelling;
   10452      7270998 :   p->spelling_base = spelling_base;
   10453      7270998 :   p->spelling_size = spelling_size;
   10454      7270998 :   p->next = initializer_stack;
   10455      7270998 :   p->missing_brace_richloc = richloc;
   10456      7270998 :   p->designated = constructor_designated;
   10457      7270998 :   initializer_stack = p;
   10458              : 
   10459      7270998 :   constructor_decl = decl;
   10460      7270998 :   constructor_designated = 0;
   10461              : 
   10462      7270998 :   require_constant_value = init_require_constant;
   10463      7270998 :   require_constexpr_value = init_require_constexpr;
   10464      7270998 :   if (decl != NULL_TREE && decl != error_mark_node)
   10465              :     {
   10466      6349292 :       require_constant_elements
   10467      6171894 :         = ((init_require_constant || (pedantic && !flag_isoc99))
   10468              :            /* For a scalar, you can always use any value to initialize,
   10469              :               even within braces.  */
   10470      6361253 :            && AGGREGATE_TYPE_P (TREE_TYPE (decl)));
   10471      6349292 :       locus = identifier_to_locale (IDENTIFIER_POINTER (DECL_NAME (decl)));
   10472              :     }
   10473              :   else
   10474              :     {
   10475       921706 :       require_constant_elements = false;
   10476       921706 :       locus = _("(anonymous)");
   10477              :     }
   10478              : 
   10479      7270998 :   constructor_stack = 0;
   10480      7270998 :   constructor_range_stack = 0;
   10481              : 
   10482      7270998 :   found_missing_braces = 0;
   10483              : 
   10484      7270998 :   spelling_base = 0;
   10485      7270998 :   spelling_size = 0;
   10486      7270998 :   RESTORE_SPELLING_DEPTH (0);
   10487              : 
   10488      7270998 :   if (locus)
   10489      7270998 :     push_string (locus);
   10490      7270998 : }
   10491              : 
   10492              : void
   10493      7270996 : finish_init (void)
   10494              : {
   10495      7270996 :   struct initializer_stack *p = initializer_stack;
   10496              : 
   10497              :   /* Free the whole constructor stack of this initializer.  */
   10498      7270996 :   while (constructor_stack)
   10499              :     {
   10500            0 :       struct constructor_stack *q = constructor_stack;
   10501            0 :       constructor_stack = q->next;
   10502            0 :       XDELETE (q);
   10503              :     }
   10504              : 
   10505      7270996 :   gcc_assert (!constructor_range_stack);
   10506              : 
   10507              :   /* Pop back to the data of the outer initializer (if any).  */
   10508      7270996 :   XDELETE (spelling_base);
   10509              : 
   10510      7270996 :   constructor_decl = p->decl;
   10511      7270996 :   require_constant_value = p->require_constant_value;
   10512      7270996 :   require_constant_elements = p->require_constant_elements;
   10513      7270996 :   require_constexpr_value = p->require_constexpr_value;
   10514      7270996 :   constructor_stack = p->constructor_stack;
   10515      7270996 :   constructor_designated = p->designated;
   10516      7270996 :   constructor_range_stack = p->constructor_range_stack;
   10517      7270996 :   constructor_elements = p->elements;
   10518      7270996 :   spelling = p->spelling;
   10519      7270996 :   spelling_base = p->spelling_base;
   10520      7270996 :   spelling_size = p->spelling_size;
   10521      7270996 :   initializer_stack = p->next;
   10522      7270996 :   XDELETE (p);
   10523      7270996 : }
   10524              : 
   10525              : /* Call here when we see the initializer is surrounded by braces.
   10526              :    This is instead of a call to push_init_level;
   10527              :    it is matched by a call to pop_init_level.
   10528              : 
   10529              :    TYPE is the type to initialize, for a constructor expression.
   10530              :    For an initializer for a decl, TYPE is zero.  */
   10531              : 
   10532              : void
   10533      1026049 : really_start_incremental_init (tree type)
   10534              : {
   10535      1026049 :   struct constructor_stack *p = XNEW (struct constructor_stack);
   10536              : 
   10537      1026049 :   if (type == NULL_TREE)
   10538       106307 :     type = TREE_TYPE (constructor_decl);
   10539              : 
   10540      1026049 :   if (VECTOR_TYPE_P (type)
   10541      1026049 :       && TYPE_VECTOR_OPAQUE (type))
   10542            0 :     error ("opaque vector types cannot be initialized");
   10543              : 
   10544      1026049 :   p->type = constructor_type;
   10545      1026049 :   p->fields = constructor_fields;
   10546      1026049 :   p->index = constructor_index;
   10547      1026049 :   p->max_index = constructor_max_index;
   10548      1026049 :   p->unfilled_index = constructor_unfilled_index;
   10549      1026049 :   p->unfilled_fields = constructor_unfilled_fields;
   10550      1026049 :   p->bit_index = constructor_bit_index;
   10551      1026049 :   p->elements = constructor_elements;
   10552      1026049 :   p->constant = constructor_constant;
   10553      1026049 :   p->simple = constructor_simple;
   10554      1026049 :   p->nonconst = constructor_nonconst;
   10555      1026049 :   p->erroneous = constructor_erroneous;
   10556      1026049 :   p->pending_elts = constructor_pending_elts;
   10557      1026049 :   p->depth = constructor_depth;
   10558      1026049 :   p->replacement_value.value = 0;
   10559      1026049 :   p->replacement_value.original_code = ERROR_MARK;
   10560      1026049 :   p->replacement_value.original_type = NULL;
   10561      1026049 :   p->implicit = 0;
   10562      1026049 :   p->range_stack = 0;
   10563      1026049 :   p->outer = 0;
   10564      1026049 :   p->incremental = constructor_incremental;
   10565      1026049 :   p->designated = constructor_designated;
   10566      1026049 :   p->zero_padding_bits = constructor_zero_padding_bits;
   10567      1026049 :   p->braced_scalar = constructor_braced_scalar;
   10568      1026049 :   p->designator_depth = designator_depth;
   10569      1026049 :   p->next = 0;
   10570      1026049 :   constructor_stack = p;
   10571              : 
   10572      1026049 :   constructor_constant = 1;
   10573      1026049 :   constructor_simple = 1;
   10574      1026049 :   constructor_nonconst = 0;
   10575      1026049 :   constructor_depth = SPELLING_DEPTH ();
   10576      1026049 :   constructor_elements = NULL;
   10577      1026049 :   constructor_pending_elts = 0;
   10578      1026049 :   constructor_type = type;
   10579      1026049 :   constructor_incremental = 1;
   10580      1026049 :   constructor_designated = 0;
   10581      1026049 :   constructor_zero_padding_bits = false;
   10582      1026049 :   constructor_zeroinit = 1;
   10583      1026049 :   constructor_braced_scalar = false;
   10584      1026049 :   designator_depth = 0;
   10585      1026049 :   designator_erroneous = 0;
   10586              : 
   10587      1026049 :   if (RECORD_OR_UNION_TYPE_P (constructor_type))
   10588              :     {
   10589        82145 :       constructor_fields = TYPE_FIELDS (constructor_type);
   10590              :       /* Skip any nameless bit fields at the beginning.  */
   10591        82145 :       while (constructor_fields != NULL_TREE
   10592        82173 :              && DECL_UNNAMED_BIT_FIELD (constructor_fields))
   10593           28 :         constructor_fields = DECL_CHAIN (constructor_fields);
   10594              : 
   10595        82145 :       constructor_unfilled_fields = constructor_fields;
   10596        82145 :       constructor_bit_index = bitsize_zero_node;
   10597              :     }
   10598       943904 :   else if (TREE_CODE (constructor_type) == ARRAY_TYPE)
   10599              :     {
   10600        17999 :       if (TYPE_DOMAIN (constructor_type))
   10601              :         {
   10602         9525 :           constructor_max_index
   10603         9525 :             = TYPE_MAX_VALUE (TYPE_DOMAIN (constructor_type));
   10604              : 
   10605              :           /* Detect non-empty initializations of zero-length arrays.  */
   10606         9525 :           if (constructor_max_index == NULL_TREE
   10607         9525 :               && TYPE_SIZE (constructor_type))
   10608          205 :             constructor_max_index = integer_minus_one_node;
   10609              : 
   10610              :           /* constructor_max_index needs to be an INTEGER_CST.  Attempts
   10611              :              to initialize VLAs with a nonempty initializer will cause a
   10612              :              proper error; avoid tree checking errors as well by setting a
   10613              :              safe value.  */
   10614         9525 :           if (constructor_max_index
   10615         9525 :               && TREE_CODE (constructor_max_index) != INTEGER_CST)
   10616           73 :             constructor_max_index = integer_minus_one_node;
   10617              : 
   10618         9525 :           constructor_index
   10619         9525 :             = convert (bitsizetype,
   10620         9525 :                        TYPE_MIN_VALUE (TYPE_DOMAIN (constructor_type)));
   10621              :         }
   10622              :       else
   10623              :         {
   10624         8474 :           constructor_index = bitsize_zero_node;
   10625         8474 :           constructor_max_index = NULL_TREE;
   10626              :         }
   10627              : 
   10628        17999 :       constructor_unfilled_index = constructor_index;
   10629              :     }
   10630       925905 :   else if (gnu_vector_type_p (constructor_type))
   10631              :     {
   10632              :       /* Vectors are like simple fixed-size arrays.  */
   10633      1850698 :       constructor_max_index =
   10634       925349 :         bitsize_int (TYPE_VECTOR_SUBPARTS (constructor_type) - 1);
   10635       925349 :       constructor_index = bitsize_zero_node;
   10636       925349 :       constructor_unfilled_index = constructor_index;
   10637              :     }
   10638              :   else
   10639              :     {
   10640              :       /* Handle the case of int x = {5}; */
   10641          556 :       constructor_fields = constructor_type;
   10642          556 :       constructor_unfilled_fields = constructor_type;
   10643          556 :       constructor_braced_scalar = true;
   10644              :     }
   10645      1026049 : }
   10646              : 
   10647              : extern location_t last_init_list_comma;
   10648              : 
   10649              : /* Called when we see an open brace for a nested initializer.  Finish
   10650              :    off any pending levels with implicit braces.  */
   10651              : void
   10652       342403 : finish_implicit_inits (location_t loc, struct obstack *braced_init_obstack)
   10653              : {
   10654       342405 :   while (constructor_stack->implicit)
   10655              :     {
   10656         1154 :       if (RECORD_OR_UNION_TYPE_P (constructor_type)
   10657          208 :           && constructor_fields == NULL_TREE)
   10658            0 :         process_init_element (input_location,
   10659              :                               pop_init_level (loc, 1, braced_init_obstack,
   10660              :                                               last_init_list_comma),
   10661              :                               true, braced_init_obstack);
   10662         1154 :       else if (TREE_CODE (constructor_type) == ARRAY_TYPE
   10663          946 :                && constructor_max_index
   10664         2100 :                && tree_int_cst_lt (constructor_max_index,
   10665              :                                    constructor_index))
   10666            2 :         process_init_element (input_location,
   10667              :                               pop_init_level (loc, 1, braced_init_obstack,
   10668              :                                               last_init_list_comma),
   10669              :                               true, braced_init_obstack);
   10670              :       else
   10671              :         break;
   10672              :     }
   10673       342403 : }
   10674              : 
   10675              : /* Push down into a subobject, for initialization.
   10676              :    If this is for an explicit set of braces, IMPLICIT is 0.
   10677              :    If it is because the next element belongs at a lower level,
   10678              :    IMPLICIT is 1 (or 2 if the push is because of designator list).  */
   10679              : 
   10680              : void
   10681      1045083 : push_init_level (location_t loc, int implicit,
   10682              :                  struct obstack *braced_init_obstack)
   10683              : {
   10684      1045083 :   struct constructor_stack *p;
   10685      1045083 :   tree value = NULL_TREE;
   10686              : 
   10687              :   /* Unless this is an explicit brace, we need to preserve previous
   10688              :      content if any.  */
   10689      1045083 :   if (implicit)
   10690              :     {
   10691       705323 :       if (RECORD_OR_UNION_TYPE_P (constructor_type) && constructor_fields)
   10692         1819 :         value = find_init_member (constructor_fields, braced_init_obstack);
   10693       703504 :       else if (TREE_CODE (constructor_type) == ARRAY_TYPE)
   10694       703504 :         value = find_init_member (constructor_index, braced_init_obstack);
   10695              :     }
   10696              : 
   10697      1045083 :   p = XNEW (struct constructor_stack);
   10698      1045083 :   p->type = constructor_type;
   10699      1045083 :   p->fields = constructor_fields;
   10700      1045083 :   p->index = constructor_index;
   10701      1045083 :   p->max_index = constructor_max_index;
   10702      1045083 :   p->unfilled_index = constructor_unfilled_index;
   10703      1045083 :   p->unfilled_fields = constructor_unfilled_fields;
   10704      1045083 :   p->bit_index = constructor_bit_index;
   10705      1045083 :   p->elements = constructor_elements;
   10706      1045083 :   p->constant = constructor_constant;
   10707      1045083 :   p->simple = constructor_simple;
   10708      1045083 :   p->nonconst = constructor_nonconst;
   10709      1045083 :   p->erroneous = constructor_erroneous;
   10710      1045083 :   p->pending_elts = constructor_pending_elts;
   10711      1045083 :   p->depth = constructor_depth;
   10712      1045083 :   p->replacement_value.value = NULL_TREE;
   10713      1045083 :   p->replacement_value.original_code = ERROR_MARK;
   10714      1045083 :   p->replacement_value.original_type = NULL;
   10715      1045083 :   p->implicit = implicit;
   10716      1045083 :   p->outer = 0;
   10717      1045083 :   p->incremental = constructor_incremental;
   10718      1045083 :   p->designated = constructor_designated;
   10719      1045083 :   p->zero_padding_bits = constructor_zero_padding_bits;
   10720      1045083 :   p->braced_scalar = constructor_braced_scalar;
   10721      1045083 :   p->designator_depth = designator_depth;
   10722      1045083 :   p->next = constructor_stack;
   10723      1045083 :   p->range_stack = 0;
   10724      1045083 :   constructor_stack = p;
   10725              : 
   10726      1045083 :   constructor_constant = 1;
   10727      1045083 :   constructor_simple = 1;
   10728      1045083 :   constructor_nonconst = 0;
   10729      1045083 :   constructor_depth = SPELLING_DEPTH ();
   10730      1045083 :   constructor_elements = NULL;
   10731      1045083 :   constructor_incremental = 1;
   10732              :   /* If the upper initializer is designated, then mark this as
   10733              :      designated too to prevent bogus warnings.  */
   10734      1045083 :   constructor_designated = p->designated;
   10735              :   /* If the upper initializer has padding bits zeroed, that includes
   10736              :      all nested initializers as well.  */
   10737      1045083 :   constructor_zero_padding_bits = p->zero_padding_bits;
   10738      1045083 :   constructor_braced_scalar = false;
   10739      1045083 :   constructor_pending_elts = 0;
   10740      1045083 :   if (!implicit)
   10741              :     {
   10742       339760 :       p->range_stack = constructor_range_stack;
   10743       339760 :       constructor_range_stack = 0;
   10744       339760 :       designator_depth = 0;
   10745       339760 :       designator_erroneous = 0;
   10746              :     }
   10747              : 
   10748              :   /* Don't die if an entire brace-pair level is superfluous
   10749              :      in the containing level.  */
   10750      1045083 :   if (constructor_type == NULL_TREE)
   10751              :     ;
   10752      1045083 :   else if (RECORD_OR_UNION_TYPE_P (constructor_type))
   10753              :     {
   10754              :       /* Don't die if there are extra init elts at the end.  */
   10755       160052 :       if (constructor_fields == NULL_TREE)
   10756           51 :         constructor_type = NULL_TREE;
   10757              :       else
   10758              :         {
   10759       160001 :           constructor_type = TREE_TYPE (constructor_fields);
   10760       160001 :           push_member_name (constructor_fields);
   10761       160001 :           constructor_depth++;
   10762              :         }
   10763              :     }
   10764       885031 :   else if (TREE_CODE (constructor_type) == ARRAY_TYPE)
   10765              :     {
   10766       884980 :       constructor_type = TREE_TYPE (constructor_type);
   10767       884980 :       push_array_bounds (tree_to_uhwi (constructor_index));
   10768       884980 :       constructor_depth++;
   10769              :     }
   10770              : 
   10771      1045083 :   if (constructor_type == NULL_TREE)
   10772              :     {
   10773           51 :       error_init (loc, "extra brace group at end of initializer");
   10774           51 :       constructor_fields = NULL_TREE;
   10775           51 :       constructor_unfilled_fields = NULL_TREE;
   10776           51 :       return;
   10777              :     }
   10778              : 
   10779      1045032 :   if (value && TREE_CODE (value) == CONSTRUCTOR)
   10780              :     {
   10781         1686 :       constructor_constant = TREE_CONSTANT (value);
   10782         1686 :       constructor_simple = TREE_STATIC (value);
   10783         1686 :       constructor_nonconst = CONSTRUCTOR_NON_CONST (value);
   10784         1686 :       constructor_elements = CONSTRUCTOR_ELTS (value);
   10785         1686 :       constructor_zero_padding_bits |= CONSTRUCTOR_ZERO_PADDING_BITS (value);
   10786         1686 :       if (!vec_safe_is_empty (constructor_elements)
   10787         1462 :           && (TREE_CODE (constructor_type) == RECORD_TYPE
   10788         1462 :               || TREE_CODE (constructor_type) == ARRAY_TYPE))
   10789         1416 :         set_nonincremental_init (braced_init_obstack);
   10790              :     }
   10791              : 
   10792      1045032 :   if (implicit == 1)
   10793              :     {
   10794       702680 :       found_missing_braces = 1;
   10795       702680 :       if (initializer_stack->missing_brace_richloc)
   10796       702680 :         initializer_stack->missing_brace_richloc->add_fixit_insert_before
   10797       702680 :           (loc, "{");
   10798              :     }
   10799              : 
   10800      1045032 :   if (RECORD_OR_UNION_TYPE_P (constructor_type))
   10801              :     {
   10802       880825 :       constructor_fields = TYPE_FIELDS (constructor_type);
   10803              :       /* Skip any nameless bit fields at the beginning.  */
   10804       880825 :       while (constructor_fields != NULL_TREE
   10805       880889 :              && DECL_UNNAMED_BIT_FIELD (constructor_fields))
   10806           64 :         constructor_fields = DECL_CHAIN (constructor_fields);
   10807              : 
   10808       880825 :       constructor_unfilled_fields = constructor_fields;
   10809       880825 :       constructor_bit_index = bitsize_zero_node;
   10810              :     }
   10811       164207 :   else if (gnu_vector_type_p (constructor_type))
   10812              :     {
   10813              :       /* Vectors are like simple fixed-size arrays.  */
   10814         9602 :       constructor_max_index =
   10815         4801 :         bitsize_int (TYPE_VECTOR_SUBPARTS (constructor_type) - 1);
   10816         4801 :       constructor_index = bitsize_int (0);
   10817         4801 :       constructor_unfilled_index = constructor_index;
   10818              :     }
   10819       159406 :   else if (TREE_CODE (constructor_type) == ARRAY_TYPE)
   10820              :     {
   10821       159326 :       if (TYPE_DOMAIN (constructor_type))
   10822              :         {
   10823       159326 :           constructor_max_index
   10824       159326 :             = TYPE_MAX_VALUE (TYPE_DOMAIN (constructor_type));
   10825              : 
   10826              :           /* Detect non-empty initializations of zero-length arrays.  */
   10827       159326 :           if (constructor_max_index == NULL_TREE
   10828       159326 :               && TYPE_SIZE (constructor_type))
   10829          135 :             constructor_max_index = integer_minus_one_node;
   10830              : 
   10831              :           /* constructor_max_index needs to be an INTEGER_CST.  Attempts
   10832              :              to initialize VLAs will cause a proper error; avoid tree
   10833              :              checking errors as well by setting a safe value.  */
   10834       159326 :           if (constructor_max_index
   10835       159056 :               && TREE_CODE (constructor_max_index) != INTEGER_CST)
   10836            2 :             constructor_max_index = integer_minus_one_node;
   10837              : 
   10838       159326 :           constructor_index
   10839       159326 :             = convert (bitsizetype,
   10840       159326 :                        TYPE_MIN_VALUE (TYPE_DOMAIN (constructor_type)));
   10841              :         }
   10842              :       else
   10843            0 :         constructor_index = bitsize_zero_node;
   10844              : 
   10845       159326 :       constructor_unfilled_index = constructor_index;
   10846       159326 :       if (value && TREE_CODE (value) == STRING_CST)
   10847              :         {
   10848              :           /* We need to split the char/wchar array into individual
   10849              :              characters, so that we don't have to special case it
   10850              :              everywhere.  */
   10851            7 :           set_nonincremental_init_from_string (value, braced_init_obstack);
   10852              :         }
   10853              :     }
   10854              :   else
   10855              :     {
   10856           80 :       if (constructor_type != error_mark_node)
   10857              :         {
   10858           51 :           if (p->braced_scalar)
   10859           22 :             permerror_init (input_location, 0,
   10860              :                             "braces around scalar initializer");
   10861              :           else
   10862           29 :             warning_init (input_location, 0,
   10863              :                           "braces around scalar initializer");
   10864           51 :           constructor_braced_scalar = true;
   10865              :         }
   10866           80 :       constructor_fields = constructor_type;
   10867           80 :       constructor_unfilled_fields = constructor_type;
   10868              :     }
   10869              : }
   10870              : 
   10871              : /* At the end of an implicit or explicit brace level,
   10872              :    finish up that level of constructor.  If a single expression
   10873              :    with redundant braces initialized that level, return the
   10874              :    c_expr structure for that expression.  Otherwise, the original_code
   10875              :    element is set to ERROR_MARK.
   10876              :    If we were outputting the elements as they are read, return 0 as the value
   10877              :    from inner levels (process_init_element ignores that),
   10878              :    but return error_mark_node as the value from the outermost level
   10879              :    (that's what we want to put in DECL_INITIAL).
   10880              :    Otherwise, return a CONSTRUCTOR expression as the value.  */
   10881              : 
   10882              : struct c_expr
   10883      2071132 : pop_init_level (location_t loc, int implicit,
   10884              :                 struct obstack *braced_init_obstack,
   10885              :                 location_t insert_before)
   10886              : {
   10887      2071132 :   struct constructor_stack *p;
   10888      2071132 :   struct c_expr ret;
   10889      2071132 :   ret.value = NULL_TREE;
   10890      2071132 :   ret.original_code = ERROR_MARK;
   10891      2071132 :   ret.original_type = NULL;
   10892      2071132 :   ret.m_decimal = 0;
   10893              : 
   10894      2071132 :   if (implicit == 0)
   10895              :     {
   10896              :       /* When we come to an explicit close brace,
   10897              :          pop any inner levels that didn't have explicit braces.  */
   10898      1367151 :       while (constructor_stack->implicit)
   10899         1342 :         process_init_element (input_location,
   10900              :                               pop_init_level (loc, 1, braced_init_obstack,
   10901              :                                               insert_before),
   10902              :                               true, braced_init_obstack);
   10903      1365809 :       gcc_assert (!constructor_range_stack);
   10904              :     }
   10905              :   else
   10906       705323 :     if (initializer_stack->missing_brace_richloc)
   10907       705323 :       initializer_stack->missing_brace_richloc->add_fixit_insert_before
   10908       705323 :         (insert_before, "}");
   10909              : 
   10910              :   /* Now output all pending elements.  */
   10911      2071132 :   constructor_incremental = 1;
   10912      2071132 :   output_pending_init_elements (1, braced_init_obstack);
   10913              : 
   10914      2071132 :   p = constructor_stack;
   10915              : 
   10916              :   /* Error for initializing a flexible array member, or a zero-length
   10917              :      array member in an inappropriate context.  */
   10918      2071081 :   if (constructor_type && constructor_fields
   10919       161019 :       && TREE_CODE (constructor_type) == ARRAY_TYPE
   10920       153372 :       && TYPE_DOMAIN (constructor_type)
   10921      2224496 :       && !TYPE_MAX_VALUE (TYPE_DOMAIN (constructor_type)))
   10922              :     {
   10923              :       /* Silently discard empty initializations.  The parser will
   10924              :          already have pedwarned for empty brackets for C17 and earlier.  */
   10925          300 :       if (integer_zerop (constructor_unfilled_index))
   10926           84 :         constructor_type = NULL_TREE;
   10927          300 :       if (constructor_type || flag_isoc23)
   10928              :         {
   10929          296 :           gcc_assert (!constructor_type || !TYPE_SIZE (constructor_type));
   10930              : 
   10931          296 :           if (constructor_depth <= 2)
   10932          249 :             pedwarn_init (loc, OPT_Wpedantic,
   10933              :                           "initialization of a flexible array member");
   10934           47 :           else if (constructor_type)
   10935           33 :             error_init (loc, "initialization of flexible array member "
   10936              :                              "in a nested context");
   10937              :           else
   10938           14 :             pedwarn_init (loc, OPT_Wpedantic,
   10939              :                           "initialization of flexible array member "
   10940              :                           "in a nested context");
   10941              : 
   10942              :           /* We have already issued an error message for the existence
   10943              :              of a flexible array member not at the end of the structure.
   10944              :              Discard the initializer so that we do not die later.  */
   10945          296 :           if (constructor_type
   10946          216 :               && DECL_CHAIN (constructor_fields) != NULL_TREE
   10947          302 :               && (!p->type || TREE_CODE (p->type) != UNION_TYPE))
   10948            0 :             constructor_type = NULL_TREE;
   10949              :         }
   10950              :     }
   10951              : 
   10952      2071132 :   switch (vec_safe_length (constructor_elements))
   10953              :     {
   10954         5092 :     case 0:
   10955              :       /* Initialization with { } counts as zeroinit.  */
   10956         5092 :       constructor_zeroinit = 1;
   10957         5092 :       break;
   10958       916265 :     case 1:
   10959              :       /* This might be zeroinit as well.  */
   10960       916265 :       if (integer_zerop ((*constructor_elements)[0].value))
   10961         2080 :         constructor_zeroinit = 1;
   10962              :       break;
   10963      1149775 :     default:
   10964              :       /* If the constructor has more than one element, it can't be { 0 }.  */
   10965      1149775 :       constructor_zeroinit = 0;
   10966      1149775 :       break;
   10967              :     }
   10968              : 
   10969              :   /* Warn when some structs are initialized with direct aggregation.  */
   10970      2071132 :   if (!implicit && found_missing_braces && warn_missing_braces
   10971           37 :       && !constructor_zeroinit)
   10972              :     {
   10973           18 :       gcc_assert (initializer_stack->missing_brace_richloc);
   10974           18 :       warning_at (initializer_stack->missing_brace_richloc,
   10975           18 :                   OPT_Wmissing_braces,
   10976              :                   "missing braces around initializer");
   10977              :     }
   10978              : 
   10979              :   /* Warn when some struct elements are implicitly initialized to zero.  */
   10980      2071132 :   if (warn_missing_field_initializers
   10981       425471 :       && constructor_type
   10982       425443 :       && TREE_CODE (constructor_type) == RECORD_TYPE
   10983       193403 :       && constructor_unfilled_fields)
   10984              :     {
   10985              :         /* Do not warn for flexible array members or zero-length arrays.  */
   10986           43 :         while (constructor_unfilled_fields
   10987           43 :                && (!DECL_SIZE (constructor_unfilled_fields)
   10988           43 :                    || integer_zerop (DECL_SIZE (constructor_unfilled_fields))))
   10989            0 :           constructor_unfilled_fields = DECL_CHAIN (constructor_unfilled_fields);
   10990              : 
   10991           43 :         if (constructor_unfilled_fields
   10992              :             /* Do not warn if this level of the initializer uses member
   10993              :                designators; it is likely to be deliberate.  */
   10994           43 :             && !constructor_designated
   10995              :             /* Do not warn about initializing with { 0 } or with { }.  */
   10996           24 :             && !constructor_zeroinit)
   10997              :           {
   10998           10 :             if (warning_at (input_location, OPT_Wmissing_field_initializers,
   10999              :                             "missing initializer for field %qD of %qT",
   11000              :                             constructor_unfilled_fields,
   11001              :                             constructor_type))
   11002           10 :               inform (DECL_SOURCE_LOCATION (constructor_unfilled_fields),
   11003              :                       "%qD declared here", constructor_unfilled_fields);
   11004              :           }
   11005              :     }
   11006              : 
   11007              :   /* Pad out the end of the structure.  */
   11008      2071132 :   if (p->replacement_value.value)
   11009              :     /* If this closes a superfluous brace pair,
   11010              :        just pass out the element between them.  */
   11011          138 :     ret = p->replacement_value;
   11012      2070994 :   else if (constructor_type == NULL_TREE)
   11013              :     ;
   11014      2070867 :   else if (!RECORD_OR_UNION_TYPE_P (constructor_type)
   11015      2070867 :            && TREE_CODE (constructor_type) != ARRAY_TYPE
   11016      2070867 :            && !gnu_vector_type_p (constructor_type))
   11017              :     {
   11018              :       /* A nonincremental scalar initializer--just return
   11019              :          the element, after verifying there is just one.
   11020              :          Empty scalar initializers are supported in C23.  */
   11021          636 :       if (vec_safe_is_empty (constructor_elements))
   11022              :         {
   11023          201 :           if (constructor_erroneous || constructor_type == error_mark_node)
   11024           85 :             ret.value = error_mark_node;
   11025          116 :           else if (TREE_CODE (constructor_type) == FUNCTION_TYPE)
   11026              :             {
   11027            2 :               error_init (loc, "invalid initializer");
   11028            2 :               ret.value = error_mark_node;
   11029              :             }
   11030          114 :           else if (TREE_CODE (constructor_type) == POINTER_TYPE)
   11031              :             /* Ensure this is a null pointer constant in the case of a
   11032              :                'constexpr' object initialized with {}.  */
   11033           33 :             ret.value = build_zero_cst (ptr_type_node);
   11034              :           else
   11035           81 :             ret.value = build_zero_cst (constructor_type);
   11036              :         }
   11037          435 :       else if (vec_safe_length (constructor_elements) != 1)
   11038              :         {
   11039            0 :           error_init (loc, "extra elements in scalar initializer");
   11040            0 :           ret.value = (*constructor_elements)[0].value;
   11041              :         }
   11042              :       else
   11043          435 :         ret.value = (*constructor_elements)[0].value;
   11044              :     }
   11045              :   else
   11046              :     {
   11047      2070231 :       if (constructor_erroneous)
   11048          314 :         ret.value = error_mark_node;
   11049              :       else
   11050              :         {
   11051      2069917 :           ret.value = build_constructor (constructor_type,
   11052              :                                          constructor_elements);
   11053      2069917 :           if (constructor_constant)
   11054      1739910 :             TREE_CONSTANT (ret.value) = 1;
   11055      2069917 :           if (constructor_constant && constructor_simple)
   11056      1739871 :             TREE_STATIC (ret.value) = 1;
   11057      2069917 :           if (constructor_nonconst)
   11058          672 :             CONSTRUCTOR_NON_CONST (ret.value) = 1;
   11059      2069917 :           if (constructor_zero_padding_bits)
   11060          687 :             CONSTRUCTOR_ZERO_PADDING_BITS (ret.value) = 1;
   11061              :         }
   11062              :     }
   11063              : 
   11064      2071132 :   if (ret.value && TREE_CODE (ret.value) != CONSTRUCTOR)
   11065              :     {
   11066         1088 :       if (constructor_nonconst)
   11067           15 :         ret.original_code = C_MAYBE_CONST_EXPR;
   11068         1073 :       else if (ret.original_code == C_MAYBE_CONST_EXPR)
   11069            0 :         ret.original_code = ERROR_MARK;
   11070              :     }
   11071              : 
   11072      2071132 :   constructor_type = p->type;
   11073      2071132 :   constructor_fields = p->fields;
   11074      2071132 :   constructor_index = p->index;
   11075      2071132 :   constructor_max_index = p->max_index;
   11076      2071132 :   constructor_unfilled_index = p->unfilled_index;
   11077      2071132 :   constructor_unfilled_fields = p->unfilled_fields;
   11078      2071132 :   constructor_bit_index = p->bit_index;
   11079      2071132 :   constructor_elements = p->elements;
   11080      2071132 :   constructor_constant = p->constant;
   11081      2071132 :   constructor_simple = p->simple;
   11082      2071132 :   constructor_nonconst = p->nonconst;
   11083      2071132 :   constructor_erroneous = p->erroneous;
   11084      2071132 :   constructor_incremental = p->incremental;
   11085      2071132 :   constructor_designated = p->designated;
   11086      2071132 :   constructor_zero_padding_bits = p->zero_padding_bits;
   11087      2071132 :   constructor_braced_scalar = p->braced_scalar;
   11088      2071132 :   designator_depth = p->designator_depth;
   11089      2071132 :   constructor_pending_elts = p->pending_elts;
   11090      2071132 :   constructor_depth = p->depth;
   11091      2071132 :   if (!p->implicit)
   11092      1365809 :     constructor_range_stack = p->range_stack;
   11093      2071132 :   RESTORE_SPELLING_DEPTH (constructor_depth);
   11094              : 
   11095      2071132 :   constructor_stack = p->next;
   11096      2071132 :   XDELETE (p);
   11097              : 
   11098      2071132 :   if (ret.value == NULL_TREE && constructor_stack == 0)
   11099            0 :     ret.value = error_mark_node;
   11100      2071132 :   return ret;
   11101              : }
   11102              : 
   11103              : /* Common handling for both array range and field name designators.
   11104              :    ARRAY argument is nonzero for array ranges.  Returns false for success.  */
   11105              : 
   11106              : static bool
   11107        36919 : set_designator (location_t loc, bool array,
   11108              :                 struct obstack *braced_init_obstack)
   11109              : {
   11110        36919 :   tree subtype;
   11111        36919 :   enum tree_code subcode;
   11112              : 
   11113              :   /* Don't die if an entire brace-pair level is superfluous
   11114              :      in the containing level, or for an erroneous type.  */
   11115        36919 :   if (constructor_type == NULL_TREE || constructor_type == error_mark_node)
   11116              :     return true;
   11117              : 
   11118              :   /* If there were errors in this designator list already, bail out
   11119              :      silently.  */
   11120        36910 :   if (designator_erroneous)
   11121              :     return true;
   11122              : 
   11123              :   /* Likewise for an initializer for a variable-size type.  Those are
   11124              :      diagnosed in the parser, except for empty initializer braces.  */
   11125        36910 :   if (COMPLETE_TYPE_P (constructor_type)
   11126        36910 :       && TREE_CODE (TYPE_SIZE (constructor_type)) != INTEGER_CST)
   11127              :     return true;
   11128              : 
   11129        36900 :   if (!designator_depth)
   11130              :     {
   11131        34581 :       gcc_assert (!constructor_range_stack);
   11132              : 
   11133              :       /* Designator list starts at the level of closest explicit
   11134              :          braces.  */
   11135        36256 :       while (constructor_stack->implicit)
   11136         1675 :         process_init_element (input_location,
   11137              :                               pop_init_level (loc, 1, braced_init_obstack,
   11138              :                                               last_init_list_comma),
   11139              :                               true, braced_init_obstack);
   11140        34581 :       constructor_designated = 1;
   11141        34581 :       return false;
   11142              :     }
   11143              : 
   11144         2319 :   switch (TREE_CODE (constructor_type))
   11145              :     {
   11146         1442 :     case  RECORD_TYPE:
   11147         1442 :     case  UNION_TYPE:
   11148         1442 :       subtype = TREE_TYPE (constructor_fields);
   11149         1442 :       if (subtype != error_mark_node)
   11150         1442 :         subtype = TYPE_MAIN_VARIANT (subtype);
   11151              :       break;
   11152          877 :     case ARRAY_TYPE:
   11153          877 :       subtype = TYPE_MAIN_VARIANT (TREE_TYPE (constructor_type));
   11154          877 :       break;
   11155            0 :     default:
   11156            0 :       gcc_unreachable ();
   11157              :     }
   11158              : 
   11159         2319 :   subcode = TREE_CODE (subtype);
   11160         2319 :   if (array && subcode != ARRAY_TYPE)
   11161              :     {
   11162            1 :       error_init (loc, "array index in non-array initializer");
   11163            1 :       return true;
   11164              :     }
   11165         2318 :   else if (!array && subcode != RECORD_TYPE && subcode != UNION_TYPE)
   11166              :     {
   11167            0 :       error_init (loc, "field name not in record or union initializer");
   11168            0 :       return true;
   11169              :     }
   11170              : 
   11171         2318 :   constructor_designated = 1;
   11172         2318 :   finish_implicit_inits (loc, braced_init_obstack);
   11173         2318 :   push_init_level (loc, 2, braced_init_obstack);
   11174         2318 :   return false;
   11175              : }
   11176              : 
   11177              : /* If there are range designators in designator list, push a new designator
   11178              :    to constructor_range_stack.  RANGE_END is end of such stack range or
   11179              :    NULL_TREE if there is no range designator at this level.  */
   11180              : 
   11181              : static void
   11182          390 : push_range_stack (tree range_end, struct obstack * braced_init_obstack)
   11183              : {
   11184          390 :   struct constructor_range_stack *p;
   11185              : 
   11186          780 :   p = (struct constructor_range_stack *)
   11187          390 :     obstack_alloc (braced_init_obstack,
   11188              :                    sizeof (struct constructor_range_stack));
   11189          390 :   p->prev = constructor_range_stack;
   11190          390 :   p->next = 0;
   11191          390 :   p->fields = constructor_fields;
   11192          390 :   p->range_start = constructor_index;
   11193          390 :   p->index = constructor_index;
   11194          390 :   p->stack = constructor_stack;
   11195          390 :   p->range_end = range_end;
   11196          390 :   if (constructor_range_stack)
   11197           19 :     constructor_range_stack->next = p;
   11198          390 :   constructor_range_stack = p;
   11199          390 : }
   11200              : 
   11201              : /* Within an array initializer, specify the next index to be initialized.
   11202              :    FIRST is that index.  If LAST is nonzero, then initialize a range
   11203              :    of indices, running from FIRST through LAST.  */
   11204              : 
   11205              : void
   11206         1931 : set_init_index (location_t loc, tree first, tree last,
   11207              :                 struct obstack *braced_init_obstack)
   11208              : {
   11209         1931 :   if (set_designator (loc, true, braced_init_obstack))
   11210              :     return;
   11211              : 
   11212         1928 :   designator_erroneous = 1;
   11213              : 
   11214         3856 :   if (!INTEGRAL_TYPE_P (TREE_TYPE (first))
   11215         3845 :       || (last && !INTEGRAL_TYPE_P (TREE_TYPE (last))))
   11216              :     {
   11217           12 :       error_init (loc, "array index in initializer not of integer type");
   11218           12 :       return;
   11219              :     }
   11220              : 
   11221         1916 :   if (TREE_CODE (first) != INTEGER_CST)
   11222              :     {
   11223            6 :       first = c_fully_fold (first, false, NULL);
   11224            6 :       if (TREE_CODE (first) == INTEGER_CST)
   11225            5 :         pedwarn_init (loc, OPT_Wpedantic,
   11226              :                       "array index in initializer is not "
   11227              :                       "an integer constant expression");
   11228              :     }
   11229              : 
   11230         1916 :   if (last && TREE_CODE (last) != INTEGER_CST)
   11231              :     {
   11232            2 :       last = c_fully_fold (last, false, NULL);
   11233            2 :       if (TREE_CODE (last) == INTEGER_CST)
   11234            1 :         pedwarn_init (loc, OPT_Wpedantic,
   11235              :                       "array index in initializer is not "
   11236              :                       "an integer constant expression");
   11237              :     }
   11238              : 
   11239         1916 :   if (TREE_CODE (first) != INTEGER_CST)
   11240            1 :     error_init (loc, "nonconstant array index in initializer");
   11241         1915 :   else if (last != NULL_TREE && TREE_CODE (last) != INTEGER_CST)
   11242            1 :     error_init (loc, "nonconstant array index in initializer");
   11243         1914 :   else if (TREE_CODE (constructor_type) != ARRAY_TYPE)
   11244            9 :     error_init (loc, "array index in non-array initializer");
   11245         1905 :   else if (tree_int_cst_sgn (first) == -1)
   11246           15 :     error_init (loc, "array index in initializer exceeds array bounds");
   11247         1890 :   else if (constructor_max_index
   11248         1890 :            && tree_int_cst_lt (constructor_max_index, first))
   11249            7 :     error_init (loc, "array index in initializer exceeds array bounds");
   11250              :   else
   11251              :     {
   11252         1883 :       constant_expression_warning (first);
   11253         1883 :       if (last)
   11254          385 :         constant_expression_warning (last);
   11255         1883 :       constructor_index = convert (bitsizetype, first);
   11256         1883 :       if (tree_int_cst_lt (constructor_index, first))
   11257              :         {
   11258            0 :           constructor_index = copy_node (constructor_index);
   11259            0 :           TREE_OVERFLOW (constructor_index) = 1;
   11260              :         }
   11261              : 
   11262         1883 :       if (last)
   11263              :         {
   11264          385 :           if (tree_int_cst_equal (first, last))
   11265              :             last = NULL_TREE;
   11266          384 :           else if (tree_int_cst_lt (last, first))
   11267              :             {
   11268            2 :               error_init (loc, "empty index range in initializer");
   11269            2 :               last = NULL_TREE;
   11270              :             }
   11271              :           else
   11272              :             {
   11273          382 :               last = convert (bitsizetype, last);
   11274          382 :               if (constructor_max_index != NULL_TREE
   11275          382 :                   && tree_int_cst_lt (constructor_max_index, last))
   11276              :                 {
   11277            3 :                   error_init (loc, "array index range in initializer exceeds "
   11278              :                               "array bounds");
   11279            3 :                   last = NULL_TREE;
   11280              :                 }
   11281              :             }
   11282              :         }
   11283              : 
   11284         1883 :       designator_depth++;
   11285         1883 :       designator_erroneous = 0;
   11286         1883 :       if (constructor_range_stack || last)
   11287          379 :         push_range_stack (last, braced_init_obstack);
   11288              :     }
   11289              : }
   11290              : 
   11291              : /* Within a struct initializer, specify the next field to be initialized.  */
   11292              : 
   11293              : void
   11294        34942 : set_init_label (location_t loc, tree fieldname, location_t fieldname_loc,
   11295              :                 struct obstack *braced_init_obstack)
   11296              : {
   11297        34942 :   tree field;
   11298              : 
   11299        34942 :   if (set_designator (loc, false, braced_init_obstack))
   11300              :     return;
   11301              : 
   11302        34925 :   designator_erroneous = 1;
   11303              : 
   11304        34925 :   if (!RECORD_OR_UNION_TYPE_P (constructor_type))
   11305              :     {
   11306            3 :       error_init (loc, "field name not in record or union initializer");
   11307            3 :       return;
   11308              :     }
   11309              : 
   11310        34922 :   field = lookup_field (constructor_type, fieldname);
   11311              : 
   11312        34922 :   if (field == NULL_TREE)
   11313              :     {
   11314            8 :       tree guessed_id = lookup_field_fuzzy (constructor_type, fieldname);
   11315            8 :       if (guessed_id)
   11316              :         {
   11317            4 :           gcc_rich_location rich_loc (fieldname_loc);
   11318            4 :           rich_loc.add_fixit_misspelled_id (fieldname_loc, guessed_id);
   11319            4 :           error_at (&rich_loc,
   11320              :                     "%qT has no member named %qE; did you mean %qE?",
   11321              :                     constructor_type, fieldname, guessed_id);
   11322            4 :         }
   11323              :       else
   11324            4 :         error_at (fieldname_loc, "%qT has no member named %qE",
   11325              :                   constructor_type, fieldname);
   11326              :     }
   11327              :   else
   11328        34960 :     do
   11329              :       {
   11330        34960 :         constructor_fields = TREE_VALUE (field);
   11331        34960 :         designator_depth++;
   11332        34960 :         designator_erroneous = 0;
   11333        34960 :         if (constructor_range_stack)
   11334           11 :           push_range_stack (NULL_TREE, braced_init_obstack);
   11335        34960 :         field = TREE_CHAIN (field);
   11336        34960 :         if (field)
   11337              :           {
   11338           46 :             if (set_designator (loc, false, braced_init_obstack))
   11339              :               return;
   11340              :           }
   11341              :       }
   11342        34960 :     while (field != NULL_TREE);
   11343              : }
   11344              : 
   11345              : /* Helper function for add_pending_init.  Find inorder successor of P
   11346              :    in AVL tree.  */
   11347              : static struct init_node *
   11348          129 : init_node_successor (struct init_node *p)
   11349              : {
   11350          129 :   struct init_node *r;
   11351          129 :   if (p->right)
   11352              :     {
   11353              :       r = p->right;
   11354           58 :       while (r->left)
   11355              :         r = r->left;
   11356              :       return r;
   11357              :     }
   11358           75 :   r = p->parent;
   11359          114 :   while (r && p == r->right)
   11360              :     {
   11361           39 :       p = r;
   11362           39 :       r = r->parent;
   11363              :     }
   11364              :   return r;
   11365              : }
   11366              : 
   11367              : /* Add a new initializer to the tree of pending initializers.  PURPOSE
   11368              :    identifies the initializer, either array index or field in a structure.
   11369              :    VALUE is the value of that index or field.  If ORIGTYPE is not
   11370              :    NULL_TREE, it is the original type of VALUE.
   11371              : 
   11372              :    IMPLICIT is true if value comes from pop_init_level (1),
   11373              :    the new initializer has been merged with the existing one
   11374              :    and thus no warnings should be emitted about overriding an
   11375              :    existing initializer.  */
   11376              : 
   11377              : static void
   11378         7893 : add_pending_init (location_t loc, tree purpose, tree value, tree origtype,
   11379              :                   bool implicit, struct obstack *braced_init_obstack)
   11380              : {
   11381         7893 :   struct init_node *p, **q, *r;
   11382              : 
   11383         7893 :   q = &constructor_pending_elts;
   11384         7893 :   p = 0;
   11385              : 
   11386         7893 :   if (TREE_CODE (constructor_type) == ARRAY_TYPE)
   11387              :     {
   11388         7214 :       while (*q != 0)
   11389              :         {
   11390         4384 :           p = *q;
   11391         4384 :           if (tree_int_cst_lt (purpose, p->purpose))
   11392          419 :             q = &p->left;
   11393         3965 :           else if (tree_int_cst_lt (p->purpose, purpose))
   11394              :             {
   11395         3354 :               if (TREE_CODE (p->value) != RAW_DATA_CST
   11396         3354 :                   || (p->right
   11397          112 :                       && tree_int_cst_le (p->right->purpose, purpose)))
   11398         3224 :                 q = &p->right;
   11399              :               else
   11400              :                 {
   11401          130 :                   widest_int pp = wi::to_widest (p->purpose);
   11402          130 :                   widest_int pw = wi::to_widest (purpose);
   11403          130 :                   if (pp + RAW_DATA_LENGTH (p->value) <= pw)
   11404           98 :                     q = &p->right;
   11405              :                   else
   11406              :                     {
   11407              :                       /* Override which should split the old RAW_DATA_CST
   11408              :                          into 2 or 3 pieces.  */
   11409           32 :                       if (!implicit && warn_override_init)
   11410            9 :                         warning_init (loc, OPT_Woverride_init,
   11411              :                                       "initialized field overwritten");
   11412           32 :                       unsigned HOST_WIDE_INT start = (pw - pp).to_uhwi ();
   11413           32 :                       unsigned HOST_WIDE_INT len = 1;
   11414           32 :                       if (TREE_CODE (value) == RAW_DATA_CST)
   11415            0 :                         len = RAW_DATA_LENGTH (value);
   11416           32 :                       unsigned HOST_WIDE_INT end = 0;
   11417           32 :                       unsigned plen = RAW_DATA_LENGTH (p->value);
   11418           32 :                       gcc_checking_assert (start < plen && start);
   11419           32 :                       if (plen - start > len)
   11420           30 :                         end = plen - start - len;
   11421           32 :                       tree v = p->value;
   11422           32 :                       tree origtype = p->origtype;
   11423           32 :                       if (start == 1)
   11424            2 :                         p->value = build_int_cst (TREE_TYPE (v),
   11425            2 :                                                   RAW_DATA_UCHAR_ELT (v, 0));
   11426              :                       else
   11427              :                         {
   11428           30 :                           p->value = v;
   11429           30 :                           if (end > 1)
   11430           26 :                             v = copy_node (v);
   11431           30 :                           RAW_DATA_LENGTH (p->value) = start;
   11432              :                         }
   11433           32 :                       if (end)
   11434              :                         {
   11435           30 :                           tree epurpose
   11436           30 :                             = size_binop (PLUS_EXPR, purpose,
   11437              :                                           bitsize_int (len));
   11438           30 :                           if (end > 1)
   11439              :                             {
   11440           28 :                               RAW_DATA_LENGTH (v) -= plen - end;
   11441           28 :                               RAW_DATA_POINTER (v) += plen - end;
   11442              :                             }
   11443              :                           else
   11444            2 :                             v = build_int_cst (TREE_TYPE (v),
   11445            2 :                                                RAW_DATA_UCHAR_ELT (v, plen
   11446              :                                                                       - end));
   11447           30 :                           add_pending_init (loc, epurpose, v, origtype,
   11448              :                                             implicit, braced_init_obstack);
   11449              :                         }
   11450           32 :                       q = &constructor_pending_elts;
   11451           32 :                       continue;
   11452           32 :                     }
   11453          130 :                 }
   11454              :             }
   11455              :           else
   11456              :             {
   11457          611 :               if (TREE_CODE (p->value) == RAW_DATA_CST
   11458          621 :                   && (RAW_DATA_LENGTH (p->value)
   11459           10 :                       > (TREE_CODE (value) == RAW_DATA_CST
   11460           10 :                          ? RAW_DATA_LENGTH (value) : 1)))
   11461              :                 {
   11462              :                   /* Override which should split the old RAW_DATA_CST
   11463              :                      into 2 pieces.  */
   11464            6 :                   if (!implicit && warn_override_init)
   11465            3 :                     warning_init (loc, OPT_Woverride_init,
   11466              :                                   "initialized field overwritten");
   11467            6 :                   unsigned HOST_WIDE_INT len = 1;
   11468            6 :                   if (TREE_CODE (value) == RAW_DATA_CST)
   11469            2 :                     len = RAW_DATA_LENGTH (value);
   11470            6 :                   if ((unsigned) RAW_DATA_LENGTH (p->value) > len + 1)
   11471              :                     {
   11472            6 :                       RAW_DATA_LENGTH (p->value) -= len;
   11473            6 :                       RAW_DATA_POINTER (p->value) += len;
   11474              :                     }
   11475              :                   else
   11476              :                     {
   11477            0 :                       unsigned int l = RAW_DATA_LENGTH (p->value) - 1;
   11478            0 :                       p->value
   11479            0 :                         = build_int_cst (TREE_TYPE (p->value),
   11480            0 :                                          RAW_DATA_UCHAR_ELT (p->value, l));
   11481              :                     }
   11482            6 :                   p->purpose = size_binop (PLUS_EXPR, p->purpose,
   11483              :                                            bitsize_int (len));
   11484            6 :                   continue;
   11485            6 :                 }
   11486          605 :               if (TREE_CODE (value) == RAW_DATA_CST)
   11487              :                 {
   11488            8 :                 handle_raw_data:
   11489              :                   /* RAW_DATA_CST value might overlap various further
   11490              :                      prior initval entries.  Find out how many.  */
   11491           13 :                   unsigned cnt = 0;
   11492           13 :                   widest_int w
   11493           26 :                     = wi::to_widest (purpose) + RAW_DATA_LENGTH (value);
   11494           13 :                   struct init_node *r = p, *last = NULL;
   11495           13 :                   bool override_init = warn_override_init;
   11496           13 :                   while ((r = init_node_successor (r))
   11497           53 :                          && wi::to_widest (r->purpose) < w)
   11498              :                     {
   11499           40 :                       ++cnt;
   11500           40 :                       if (TREE_SIDE_EFFECTS (r->value))
   11501            2 :                         warning_init (loc, OPT_Woverride_init_side_effects,
   11502              :                                       "initialized field with side-effects "
   11503              :                                       "overwritten");
   11504           38 :                       else if (override_init)
   11505              :                         {
   11506            6 :                           warning_init (loc, OPT_Woverride_init,
   11507              :                                         "initialized field overwritten");
   11508            6 :                           override_init = false;
   11509              :                         }
   11510              :                       last = r;
   11511              :                     }
   11512           13 :                   if (cnt)
   11513              :                     {
   11514           26 :                       if (TREE_CODE (last->value) == RAW_DATA_CST
   11515           13 :                           && (wi::to_widest (last->purpose)
   11516           13 :                               + RAW_DATA_LENGTH (last->value) > w))
   11517              :                         {
   11518              :                           /* The last overlapping prior initval overlaps
   11519              :                              only partially.  Shrink it and decrease cnt.  */
   11520            0 :                           unsigned int l = (wi::to_widest (last->purpose)
   11521            0 :                                             + RAW_DATA_LENGTH (last->value)
   11522            0 :                                             - w).to_uhwi ();
   11523            0 :                           --cnt;
   11524            0 :                           RAW_DATA_LENGTH (last->value) -= l;
   11525            0 :                           RAW_DATA_POINTER (last->value) += l;
   11526            0 :                           if (RAW_DATA_LENGTH (last->value) == 1)
   11527            0 :                             last->value
   11528            0 :                               = build_int_cst (TREE_TYPE (last->value),
   11529            0 :                                                RAW_DATA_UCHAR_ELT (last->value,
   11530              :                                                                    0));
   11531            0 :                           last->purpose
   11532            0 :                             = size_binop (PLUS_EXPR, last->purpose,
   11533              :                                           bitsize_int (l));
   11534              :                         }
   11535              :                       /* Instead of deleting cnt nodes from the AVL tree
   11536              :                          and rebalancing, peel of last cnt bytes from the
   11537              :                          RAW_DATA_CST.  Overriding thousands of previously
   11538              :                          initialized array elements with #embed needs to work,
   11539              :                          but doesn't need to be super efficient.  */
   11540           13 :                       gcc_checking_assert ((unsigned) RAW_DATA_LENGTH (value)
   11541              :                                            > cnt);
   11542           13 :                       RAW_DATA_LENGTH (value) -= cnt;
   11543           13 :                       const unsigned char *s
   11544           13 :                         = &RAW_DATA_UCHAR_ELT (value, RAW_DATA_LENGTH (value));
   11545           13 :                       unsigned int o = RAW_DATA_LENGTH (value);
   11546           53 :                       for (r = p; cnt--; ++o, ++s)
   11547              :                         {
   11548           40 :                           r = init_node_successor (r);
   11549           40 :                           r->purpose = size_binop (PLUS_EXPR, purpose,
   11550              :                                                    bitsize_int (o));
   11551           40 :                           r->value = build_int_cst (TREE_TYPE (value), *s);
   11552           40 :                           r->origtype = origtype;
   11553              :                         }
   11554           13 :                       if (RAW_DATA_LENGTH (value) == 1)
   11555            0 :                         value = build_int_cst (TREE_TYPE (value),
   11556            0 :                                                RAW_DATA_UCHAR_ELT (value, 0));
   11557              :                     }
   11558              :                 }
   11559          610 :               if (!implicit)
   11560              :                 {
   11561           54 :                   if (TREE_SIDE_EFFECTS (p->value))
   11562            6 :                     warning_init (loc, OPT_Woverride_init_side_effects,
   11563              :                                   "initialized field with side-effects "
   11564              :                                   "overwritten");
   11565           48 :                   else if (warn_override_init)
   11566           13 :                     warning_init (loc, OPT_Woverride_init,
   11567              :                                   "initialized field overwritten");
   11568              :                 }
   11569          610 :               p->value = value;
   11570          610 :               p->origtype = origtype;
   11571          610 :               return;
   11572              :             }
   11573              :         }
   11574         2830 :       if (TREE_CODE (value) == RAW_DATA_CST && p)
   11575              :         {
   11576           61 :           struct init_node *r;
   11577           61 :           if (q == &p->left)
   11578              :             r = p;
   11579              :           else
   11580           36 :             r = init_node_successor (p);
   11581          131 :           if (r && wi::to_widest (r->purpose) < (wi::to_widest (purpose)
   11582          131 :                                                  + RAW_DATA_LENGTH (value)))
   11583              :             {
   11584              :               /* Overlap with at least one prior initval in the range but
   11585              :                  not at the start.  */
   11586            5 :               p = r;
   11587            5 :               p->purpose = purpose;
   11588            5 :               goto handle_raw_data;
   11589              :             }
   11590              :         }
   11591              :     }
   11592              :   else
   11593              :     {
   11594         4458 :       tree bitpos;
   11595              : 
   11596         4458 :       bitpos = bit_position (purpose);
   11597        12298 :       while (*q != NULL)
   11598              :         {
   11599         4625 :           p = *q;
   11600         4625 :           if (tree_int_cst_lt (bitpos, bit_position (p->purpose)))
   11601           77 :             q = &p->left;
   11602         4548 :           else if (p->purpose != purpose)
   11603         3305 :             q = &p->right;
   11604              :           else
   11605              :             {
   11606         1243 :               if (!implicit)
   11607              :                 {
   11608          101 :                   if (TREE_SIDE_EFFECTS (p->value))
   11609            4 :                     warning_init (loc, OPT_Woverride_init_side_effects,
   11610              :                                   "initialized field with side-effects "
   11611              :                                   "overwritten");
   11612           97 :                   else if (warn_override_init)
   11613            6 :                     warning_init (loc, OPT_Woverride_init,
   11614              :                                   "initialized field overwritten");
   11615              :                 }
   11616         1243 :               p->value = value;
   11617         1243 :               p->origtype = origtype;
   11618         1243 :               return;
   11619              :             }
   11620              :         }
   11621              :     }
   11622              : 
   11623         6040 :   r = (struct init_node *) obstack_alloc (braced_init_obstack,
   11624              :                                           sizeof (struct init_node));
   11625         6040 :   r->purpose = purpose;
   11626         6040 :   r->value = value;
   11627         6040 :   r->origtype = origtype;
   11628              : 
   11629         6040 :   *q = r;
   11630         6040 :   r->parent = p;
   11631         6040 :   r->left = 0;
   11632         6040 :   r->right = 0;
   11633         6040 :   r->balance = 0;
   11634              : 
   11635         9740 :   while (p)
   11636              :     {
   11637         5036 :       struct init_node *s;
   11638              : 
   11639         5036 :       if (r == p->left)
   11640              :         {
   11641          339 :           if (p->balance == 0)
   11642          242 :             p->balance = -1;
   11643           97 :           else if (p->balance < 0)
   11644              :             {
   11645           45 :               if (r->balance < 0)
   11646              :                 {
   11647              :                   /* L rotation.  */
   11648           40 :                   p->left = r->right;
   11649           40 :                   if (p->left)
   11650            2 :                     p->left->parent = p;
   11651           40 :                   r->right = p;
   11652              : 
   11653           40 :                   p->balance = 0;
   11654           40 :                   r->balance = 0;
   11655              : 
   11656           40 :                   s = p->parent;
   11657           40 :                   p->parent = r;
   11658           40 :                   r->parent = s;
   11659           40 :                   if (s)
   11660              :                     {
   11661           31 :                       if (s->left == p)
   11662           10 :                         s->left = r;
   11663              :                       else
   11664           21 :                         s->right = r;
   11665              :                     }
   11666              :                   else
   11667            9 :                     constructor_pending_elts = r;
   11668              :                 }
   11669              :               else
   11670              :                 {
   11671              :                   /* LR rotation.  */
   11672            5 :                   struct init_node *t = r->right;
   11673              : 
   11674            5 :                   r->right = t->left;
   11675            5 :                   if (r->right)
   11676            0 :                     r->right->parent = r;
   11677            5 :                   t->left = r;
   11678              : 
   11679            5 :                   p->left = t->right;
   11680            5 :                   if (p->left)
   11681            0 :                     p->left->parent = p;
   11682            5 :                   t->right = p;
   11683              : 
   11684            5 :                   p->balance = t->balance < 0;
   11685            5 :                   r->balance = -(t->balance > 0);
   11686            5 :                   t->balance = 0;
   11687              : 
   11688            5 :                   s = p->parent;
   11689            5 :                   p->parent = t;
   11690            5 :                   r->parent = t;
   11691            5 :                   t->parent = s;
   11692            5 :                   if (s)
   11693              :                     {
   11694            0 :                       if (s->left == p)
   11695            0 :                         s->left = t;
   11696              :                       else
   11697            0 :                         s->right = t;
   11698              :                     }
   11699              :                   else
   11700            5 :                     constructor_pending_elts = t;
   11701              :                 }
   11702              :               break;
   11703              :             }
   11704              :           else
   11705              :             {
   11706              :               /* p->balance == +1; growth of left side balances the node.  */
   11707           52 :               p->balance = 0;
   11708           52 :               break;
   11709              :             }
   11710              :         }
   11711              :       else /* r == p->right */
   11712              :         {
   11713         4697 :           if (p->balance == 0)
   11714              :             /* Growth propagation from right side.  */
   11715         3458 :             p->balance++;
   11716         1239 :           else if (p->balance > 0)
   11717              :             {
   11718         1176 :               if (r->balance > 0)
   11719              :                 {
   11720              :                   /* R rotation.  */
   11721         1174 :                   p->right = r->left;
   11722         1174 :                   if (p->right)
   11723          173 :                     p->right->parent = p;
   11724         1174 :                   r->left = p;
   11725              : 
   11726         1174 :                   p->balance = 0;
   11727         1174 :                   r->balance = 0;
   11728              : 
   11729         1174 :                   s = p->parent;
   11730         1174 :                   p->parent = r;
   11731         1174 :                   r->parent = s;
   11732         1174 :                   if (s)
   11733              :                     {
   11734          378 :                       if (s->left == p)
   11735            2 :                         s->left = r;
   11736              :                       else
   11737          376 :                         s->right = r;
   11738              :                     }
   11739              :                   else
   11740          796 :                     constructor_pending_elts = r;
   11741              :                 }
   11742              :               else /* r->balance == -1 */
   11743              :                 {
   11744              :                   /* RL rotation */
   11745            2 :                   struct init_node *t = r->left;
   11746              : 
   11747            2 :                   r->left = t->right;
   11748            2 :                   if (r->left)
   11749            2 :                     r->left->parent = r;
   11750            2 :                   t->right = r;
   11751              : 
   11752            2 :                   p->right = t->left;
   11753            2 :                   if (p->right)
   11754            2 :                     p->right->parent = p;
   11755            2 :                   t->left = p;
   11756              : 
   11757            2 :                   r->balance = (t->balance < 0);
   11758            2 :                   p->balance = -(t->balance > 0);
   11759            2 :                   t->balance = 0;
   11760              : 
   11761            2 :                   s = p->parent;
   11762            2 :                   p->parent = t;
   11763            2 :                   r->parent = t;
   11764            2 :                   t->parent = s;
   11765            2 :                   if (s)
   11766              :                     {
   11767            0 :                       if (s->left == p)
   11768            0 :                         s->left = t;
   11769              :                       else
   11770            0 :                         s->right = t;
   11771              :                     }
   11772              :                   else
   11773            2 :                     constructor_pending_elts = t;
   11774              :                 }
   11775              :               break;
   11776              :             }
   11777              :           else
   11778              :             {
   11779              :               /* p->balance == -1; growth of right side balances the node.  */
   11780           63 :               p->balance = 0;
   11781           63 :               break;
   11782              :             }
   11783              :         }
   11784              : 
   11785         3700 :       r = p;
   11786         3700 :       p = p->parent;
   11787              :     }
   11788              : }
   11789              : 
   11790              : /* Build AVL tree from a sorted chain.  */
   11791              : 
   11792              : static void
   11793         1812 : set_nonincremental_init (struct obstack * braced_init_obstack)
   11794              : {
   11795         1812 :   unsigned HOST_WIDE_INT ix;
   11796         1812 :   tree index, value;
   11797              : 
   11798         1812 :   if (TREE_CODE (constructor_type) != RECORD_TYPE
   11799         1812 :       && TREE_CODE (constructor_type) != ARRAY_TYPE)
   11800              :     return;
   11801              : 
   11802         5511 :   FOR_EACH_CONSTRUCTOR_ELT (constructor_elements, ix, index, value)
   11803         3699 :     add_pending_init (input_location, index, value, NULL_TREE, true,
   11804              :                       braced_init_obstack);
   11805         1812 :   constructor_elements = NULL;
   11806         1812 :   if (TREE_CODE (constructor_type) == RECORD_TYPE)
   11807              :     {
   11808          948 :       constructor_unfilled_fields = TYPE_FIELDS (constructor_type);
   11809              :       /* Skip any nameless bit fields at the beginning.  */
   11810          948 :       while (constructor_unfilled_fields != NULL_TREE
   11811          948 :              && DECL_UNNAMED_BIT_FIELD (constructor_unfilled_fields))
   11812            0 :         constructor_unfilled_fields = TREE_CHAIN (constructor_unfilled_fields);
   11813              : 
   11814              :     }
   11815          864 :   else if (TREE_CODE (constructor_type) == ARRAY_TYPE)
   11816              :     {
   11817          864 :       if (TYPE_DOMAIN (constructor_type))
   11818          806 :         constructor_unfilled_index
   11819          806 :           = convert (bitsizetype,
   11820          806 :                      TYPE_MIN_VALUE (TYPE_DOMAIN (constructor_type)));
   11821              :       else
   11822           58 :         constructor_unfilled_index = bitsize_zero_node;
   11823              :     }
   11824         1812 :   constructor_incremental = 0;
   11825              : }
   11826              : 
   11827              : /* Build AVL tree from a string constant.  */
   11828              : 
   11829              : static void
   11830            7 : set_nonincremental_init_from_string (tree str,
   11831              :                                      struct obstack * braced_init_obstack)
   11832              : {
   11833            7 :   tree value, purpose, type;
   11834            7 :   HOST_WIDE_INT val[2];
   11835            7 :   const char *p, *end;
   11836            7 :   int byte, wchar_bytes, charwidth, bitpos;
   11837              : 
   11838            7 :   gcc_assert (TREE_CODE (constructor_type) == ARRAY_TYPE);
   11839              : 
   11840            7 :   wchar_bytes = TYPE_PRECISION (TREE_TYPE (TREE_TYPE (str))) / BITS_PER_UNIT;
   11841            7 :   charwidth = TYPE_PRECISION (char_type_node);
   11842            7 :   gcc_assert ((size_t) wchar_bytes * charwidth
   11843              :               <= ARRAY_SIZE (val) * HOST_BITS_PER_WIDE_INT);
   11844            7 :   type = TREE_TYPE (constructor_type);
   11845            7 :   p = TREE_STRING_POINTER (str);
   11846            7 :   end = p + TREE_STRING_LENGTH (str);
   11847              : 
   11848            7 :   for (purpose = bitsize_zero_node;
   11849              :        p < end
   11850           52 :        && !(constructor_max_index
   11851           20 :             && tree_int_cst_lt (constructor_max_index, purpose));
   11852           25 :        purpose = size_binop (PLUS_EXPR, purpose, bitsize_one_node))
   11853              :     {
   11854           25 :       if (wchar_bytes == 1)
   11855              :         {
   11856            9 :           val[0] = (unsigned char) *p++;
   11857            9 :           val[1] = 0;
   11858              :         }
   11859              :       else
   11860              :         {
   11861           16 :           val[1] = 0;
   11862           16 :           val[0] = 0;
   11863           64 :           for (byte = 0; byte < wchar_bytes; byte++)
   11864              :             {
   11865           48 :               if (BYTES_BIG_ENDIAN)
   11866              :                 bitpos = (wchar_bytes - byte - 1) * charwidth;
   11867              :               else
   11868           48 :                 bitpos = byte * charwidth;
   11869           48 :               val[bitpos / HOST_BITS_PER_WIDE_INT]
   11870           48 :                 |= ((unsigned HOST_WIDE_INT) ((unsigned char) *p++))
   11871           48 :                    << (bitpos % HOST_BITS_PER_WIDE_INT);
   11872              :             }
   11873              :         }
   11874              : 
   11875           25 :       if (!TYPE_UNSIGNED (type))
   11876              :         {
   11877           13 :           bitpos = ((wchar_bytes - 1) * charwidth) + HOST_BITS_PER_CHAR;
   11878           13 :           if (bitpos < HOST_BITS_PER_WIDE_INT)
   11879              :             {
   11880           13 :               if (val[0] & (HOST_WIDE_INT_1 << (bitpos - 1)))
   11881              :                 {
   11882            0 :                   val[0] |= HOST_WIDE_INT_M1U << bitpos;
   11883            0 :                   val[1] = -1;
   11884              :                 }
   11885              :             }
   11886            0 :           else if (bitpos == HOST_BITS_PER_WIDE_INT)
   11887              :             {
   11888            0 :               if (val[0] < 0)
   11889            0 :                 val[1] = -1;
   11890              :             }
   11891            0 :           else if (val[1] & (HOST_WIDE_INT_1
   11892            0 :                              << (bitpos - 1 - HOST_BITS_PER_WIDE_INT)))
   11893            0 :             val[1] |= HOST_WIDE_INT_M1U << (bitpos - HOST_BITS_PER_WIDE_INT);
   11894              :         }
   11895              : 
   11896           25 :       value = wide_int_to_tree (type,
   11897           25 :                                 wide_int::from_array (val, 2,
   11898              :                                                       HOST_BITS_PER_WIDE_INT * 2));
   11899           25 :       add_pending_init (input_location, purpose, value, NULL_TREE, true,
   11900              :                         braced_init_obstack);
   11901              :     }
   11902              : 
   11903            7 :   constructor_incremental = 0;
   11904            7 : }
   11905              : 
   11906              : /* Return value of FIELD in pending initializer or NULL_TREE if the field was
   11907              :    not initialized yet.  */
   11908              : 
   11909              : static tree
   11910       705323 : find_init_member (tree field, struct obstack * braced_init_obstack)
   11911              : {
   11912       705323 :   struct init_node *p;
   11913              : 
   11914       705323 :   if (TREE_CODE (constructor_type) == ARRAY_TYPE)
   11915              :     {
   11916       703504 :       if (constructor_incremental
   11917       703504 :           && tree_int_cst_lt (field, constructor_unfilled_index))
   11918           16 :         set_nonincremental_init (braced_init_obstack);
   11919              : 
   11920       703504 :       p = constructor_pending_elts;
   11921       704103 :       while (p)
   11922              :         {
   11923         1151 :           if (tree_int_cst_lt (field, p->purpose))
   11924           93 :             p = p->left;
   11925         1058 :           else if (tree_int_cst_lt (p->purpose, field))
   11926          506 :             p = p->right;
   11927              :           else
   11928          552 :             return p->value;
   11929              :         }
   11930              :     }
   11931         1819 :   else if (TREE_CODE (constructor_type) == RECORD_TYPE)
   11932              :     {
   11933         1696 :       tree bitpos = bit_position (field);
   11934              : 
   11935         1696 :       if (constructor_incremental
   11936         1696 :           && (!constructor_unfilled_fields
   11937          609 :               || tree_int_cst_lt (bitpos,
   11938          609 :                                   bit_position (constructor_unfilled_fields))))
   11939          289 :         set_nonincremental_init (braced_init_obstack);
   11940              : 
   11941         1696 :       p = constructor_pending_elts;
   11942         2652 :       while (p)
   11943              :         {
   11944         2047 :           if (field == p->purpose)
   11945         1091 :             return p->value;
   11946          956 :           else if (tree_int_cst_lt (bitpos, bit_position (p->purpose)))
   11947            7 :             p = p->left;
   11948              :           else
   11949          949 :             p = p->right;
   11950              :         }
   11951              :     }
   11952          123 :   else if (TREE_CODE (constructor_type) == UNION_TYPE)
   11953              :     {
   11954          123 :       if (!vec_safe_is_empty (constructor_elements)
   11955           50 :           && (constructor_elements->last ().index == field))
   11956           50 :         return constructor_elements->last ().value;
   11957              :     }
   11958              :   return NULL_TREE;
   11959              : }
   11960              : 
   11961              : /* "Output" the next constructor element.
   11962              :    At top level, really output it to assembler code now.
   11963              :    Otherwise, collect it in a list from which we will make a CONSTRUCTOR.
   11964              :    If ORIGTYPE is not NULL_TREE, it is the original type of VALUE.
   11965              :    TYPE is the data type that the containing data type wants here.
   11966              :    FIELD is the field (a FIELD_DECL) or the index that this element fills.
   11967              :    If VALUE is a string constant, STRICT_STRING is true if it is
   11968              :    unparenthesized or we should not warn here for it being parenthesized.
   11969              :    For other types of VALUE, STRICT_STRING is not used.
   11970              : 
   11971              :    PENDING if true means output pending elements that belong
   11972              :    right after this element.  (PENDING is normally true;
   11973              :    it is false while outputting pending elements, to avoid recursion.)
   11974              : 
   11975              :    IMPLICIT is true if value comes from pop_init_level (1),
   11976              :    the new initializer has been merged with the existing one
   11977              :    and thus no warnings should be emitted about overriding an
   11978              :    existing initializer.  */
   11979              : 
   11980              : static void
   11981      9630634 : output_init_element (location_t loc, tree value, tree origtype,
   11982              :                      bool strict_string, tree type, tree field, bool pending,
   11983              :                      bool implicit, struct obstack * braced_init_obstack)
   11984              : {
   11985      9630634 :   tree semantic_type = NULL_TREE;
   11986      9630634 :   bool maybe_const = true;
   11987      9630634 :   bool npc, int_const_expr, arith_const_expr;
   11988              : 
   11989      9630634 :   if (type == error_mark_node || value == error_mark_node)
   11990              :     {
   11991          286 :       constructor_erroneous = 1;
   11992         4519 :       return;
   11993              :     }
   11994      9630348 :   if (TREE_CODE (TREE_TYPE (value)) == ARRAY_TYPE
   11995       200966 :       && (TREE_CODE (value) == STRING_CST
   11996       159556 :           || TREE_CODE (value) == COMPOUND_LITERAL_EXPR)
   11997        41418 :       && !(TREE_CODE (value) == STRING_CST
   11998        41410 :            && TREE_CODE (type) == ARRAY_TYPE
   11999         3898 :            && INTEGRAL_TYPE_P (TREE_TYPE (type)))
   12000      9667868 :       && !comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (value)),
   12001        37520 :                      TYPE_MAIN_VARIANT (type)))
   12002        37520 :     value = array_to_pointer_conversion (input_location, value);
   12003              : 
   12004      9630348 :   if (TREE_CODE (value) == COMPOUND_LITERAL_EXPR
   12005          182 :       && require_constant_value && pending)
   12006              :     {
   12007              :       /* As an extension, allow initializing objects with static storage
   12008              :          duration with compound literals (which are then treated just as
   12009              :          the brace enclosed list they contain).  */
   12010          114 :       if (flag_isoc99)
   12011           24 :         pedwarn_init (loc, OPT_Wpedantic, "initializer element is not "
   12012              :                       "constant");
   12013          114 :       tree decl = COMPOUND_LITERAL_EXPR_DECL (value);
   12014          114 :       value = DECL_INITIAL (decl);
   12015              :     }
   12016              : 
   12017      9630348 :   npc = null_pointer_constant_p (value);
   12018     19260696 :   int_const_expr = (TREE_CODE (value) == INTEGER_CST
   12019      4221614 :                     && !TREE_OVERFLOW (value)
   12020     13851961 :                     && INTEGRAL_TYPE_P (TREE_TYPE (value)));
   12021              :   /* Not fully determined before folding.  */
   12022      9630348 :   arith_const_expr = true;
   12023      9630348 :   if (TREE_CODE (value) == EXCESS_PRECISION_EXPR)
   12024              :     {
   12025           16 :       semantic_type = TREE_TYPE (value);
   12026           16 :       value = TREE_OPERAND (value, 0);
   12027              :     }
   12028      9630348 :   value = c_fully_fold (value, require_constant_value, &maybe_const);
   12029              :   /* TODO: this may not detect all cases of expressions folding to
   12030              :      constants that are not arithmetic constant expressions.  */
   12031      9630348 :   if (!maybe_const)
   12032              :     arith_const_expr = false;
   12033     19258139 :   else if (!INTEGRAL_TYPE_P (TREE_TYPE (value))
   12034      3189065 :            && TREE_CODE (TREE_TYPE (value)) != REAL_TYPE
   12035     11474963 :            && TREE_CODE (TREE_TYPE (value)) != COMPLEX_TYPE)
   12036              :     arith_const_expr = false;
   12037      7798500 :   else if (TREE_CODE (value) != INTEGER_CST
   12038              :            && TREE_CODE (value) != REAL_CST
   12039              :            && TREE_CODE (value) != COMPLEX_CST
   12040              :            && TREE_CODE (value) != RAW_DATA_CST)
   12041              :     arith_const_expr = false;
   12042      4610552 :   else if (TREE_OVERFLOW (value))
   12043      5019797 :     arith_const_expr = false;
   12044              : 
   12045      9630348 :   if (value == error_mark_node)
   12046            0 :     constructor_erroneous = 1;
   12047      9630348 :   else if (!TREE_CONSTANT (value))
   12048      3208356 :     constructor_constant = 0;
   12049      6421992 :   else if (!initializer_constant_valid_p (value,
   12050      6421992 :                                           TREE_TYPE (value),
   12051      6421992 :                                           AGGREGATE_TYPE_P (constructor_type)
   12052      6421992 :                                           && TYPE_REVERSE_STORAGE_ORDER
   12053              :                                              (constructor_type))
   12054      6421992 :            || (RECORD_OR_UNION_TYPE_P (constructor_type)
   12055      1041090 :                && DECL_C_BIT_FIELD (field)
   12056         7995 :                && TREE_CODE (value) != INTEGER_CST))
   12057           77 :     constructor_simple = 0;
   12058      9630348 :   if (!maybe_const)
   12059         1172 :     constructor_nonconst = 1;
   12060              : 
   12061              :   /* Digest the initializer and issue any errors about incompatible
   12062              :      types before issuing errors about non-constant initializers.  */
   12063      9630348 :   tree new_value = value;
   12064      9630348 :   if (semantic_type)
   12065           16 :     new_value = build1 (EXCESS_PRECISION_EXPR, semantic_type, value);
   12066              :   /* In the case of braces around a scalar initializer, the result of
   12067              :      this initializer processing goes through digest_init again at the
   12068              :      outer level.  In the case of a constexpr initializer for a
   12069              :      pointer, avoid converting a null pointer constant to something
   12070              :      that is not a null pointer constant to avoid a spurious error
   12071              :      from that second processing.  */
   12072      9630348 :   if (!require_constexpr_value
   12073          398 :       || !npc
   12074           69 :       || TREE_CODE (constructor_type) != POINTER_TYPE)
   12075      9630337 :     new_value = digest_init (loc,
   12076      9630337 :                              RECORD_OR_UNION_TYPE_P (constructor_type)
   12077      8556192 :                              ? field : constructor_fields
   12078      8556192 :                              ? constructor_fields : constructor_decl,
   12079              :                              type, new_value, origtype, npc,
   12080              :                              int_const_expr, arith_const_expr, strict_string,
   12081              :                              require_constant_value, require_constexpr_value);
   12082      9630348 :   if (new_value == error_mark_node)
   12083              :     {
   12084           76 :       constructor_erroneous = 1;
   12085           76 :       return;
   12086              :     }
   12087      9630272 :   if (require_constant_value || require_constant_elements)
   12088      2712778 :     constant_expression_warning (new_value);
   12089              : 
   12090              :   /* Proceed to check the constness of the original initializer.  */
   12091      9630272 :   if (!initializer_constant_valid_p (value, TREE_TYPE (value)))
   12092              :     {
   12093      3208382 :       if (require_constant_value)
   12094              :         {
   12095            0 :           error_init (loc, "initializer element is not constant");
   12096            0 :           value = error_mark_node;
   12097              :         }
   12098      3208382 :       else if (require_constant_elements)
   12099           15 :         pedwarn (loc, OPT_Wpedantic,
   12100              :                  "initializer element is not computable at load time");
   12101              :     }
   12102      6421890 :   else if (!maybe_const
   12103           54 :            && (require_constant_value || require_constant_elements))
   12104           28 :     pedwarn_init (loc, OPT_Wpedantic,
   12105              :                   "initializer element is not a constant expression");
   12106              :   /* digest_init has already carried out the additional checks
   12107              :      required for 'constexpr' initializers (using the information
   12108              :      passed to it about whether the original initializer was certain
   12109              :      kinds of constant expression), so that check does not need to be
   12110              :      repeated here.  */
   12111              : 
   12112              :   /* Issue -Wc++-compat warnings about initializing a bitfield with
   12113              :      enum type.  */
   12114      9630272 :   if (warn_cxx_compat
   12115         6895 :       && field != NULL_TREE
   12116         6895 :       && TREE_CODE (field) == FIELD_DECL
   12117          459 :       && DECL_BIT_FIELD_TYPE (field) != NULL_TREE
   12118           21 :       && (TYPE_MAIN_VARIANT (DECL_BIT_FIELD_TYPE (field))
   12119           21 :           != TYPE_MAIN_VARIANT (type))
   12120      9630293 :       && TREE_CODE (DECL_BIT_FIELD_TYPE (field)) == ENUMERAL_TYPE)
   12121              :     {
   12122           21 :       tree checktype = origtype != NULL_TREE ? origtype : TREE_TYPE (value);
   12123           21 :       if (checktype != error_mark_node
   12124           21 :           && (TYPE_MAIN_VARIANT (checktype)
   12125           21 :               != TYPE_MAIN_VARIANT (DECL_BIT_FIELD_TYPE (field))))
   12126            9 :         warning_init (loc, OPT_Wc___compat,
   12127              :                       "enum conversion in initialization is invalid in C++");
   12128              :     }
   12129              : 
   12130              :   /* If this field is empty and does not have side effects (and is not at
   12131              :      the end of structure), don't do anything other than checking the
   12132              :      initializer.  */
   12133      9630272 :   if (field
   12134      9630272 :       && (TREE_TYPE (field) == error_mark_node
   12135      9629837 :           || (COMPLETE_TYPE_P (TREE_TYPE (field))
   12136      9629528 :               && integer_zerop (TYPE_SIZE (TREE_TYPE (field)))
   12137           62 :               && !TREE_SIDE_EFFECTS (new_value)
   12138           33 :               && (TREE_CODE (constructor_type) == ARRAY_TYPE
   12139           33 :                   || DECL_CHAIN (field)))))
   12140           18 :     return;
   12141              : 
   12142              :   /* Finally, set VALUE to the initializer value digested above.  */
   12143      9630254 :   value = new_value;
   12144              : 
   12145              :   /* If this element doesn't come next in sequence,
   12146              :      put it on constructor_pending_elts.  */
   12147      9630254 :   if (TREE_CODE (constructor_type) == ARRAY_TYPE
   12148      9630254 :       && (!constructor_incremental
   12149      1719960 :           || !tree_int_cst_equal (field, constructor_unfilled_index)
   12150      1719526 :           || (TREE_CODE (value) == RAW_DATA_CST
   12151          235 :               && constructor_pending_elts
   12152           66 :               && pending)))
   12153              :     {
   12154         1341 :       if (constructor_incremental
   12155         1341 :           && (tree_int_cst_lt (field, constructor_unfilled_index)
   12156          405 :               || (TREE_CODE (value) == RAW_DATA_CST
   12157           14 :                   && constructor_pending_elts
   12158           14 :                   && pending)))
   12159           48 :         set_nonincremental_init (braced_init_obstack);
   12160              : 
   12161         1341 :       add_pending_init (loc, field, value, origtype, implicit,
   12162              :                         braced_init_obstack);
   12163         1341 :       return;
   12164              :     }
   12165      9628913 :   else if (TREE_CODE (constructor_type) == RECORD_TYPE
   12166      1042799 :            && (!constructor_incremental
   12167      1041133 :                || field != constructor_unfilled_fields))
   12168              :     {
   12169              :       /* We do this for records but not for unions.  In a union,
   12170              :          no matter which field is specified, it can be initialized
   12171              :          right away since it starts at the beginning of the union.  */
   12172         2798 :       if (constructor_incremental)
   12173              :         {
   12174         1132 :           if (!constructor_unfilled_fields)
   12175           39 :             set_nonincremental_init (braced_init_obstack);
   12176              :           else
   12177              :             {
   12178         1093 :               tree bitpos, unfillpos;
   12179              : 
   12180         1093 :               bitpos = bit_position (field);
   12181         1093 :               unfillpos = bit_position (constructor_unfilled_fields);
   12182              : 
   12183         1093 :               if (tree_int_cst_lt (bitpos, unfillpos))
   12184            4 :                 set_nonincremental_init (braced_init_obstack);
   12185              :             }
   12186              :         }
   12187              : 
   12188         2798 :       add_pending_init (loc, field, value, origtype, implicit,
   12189              :                         braced_init_obstack);
   12190         2798 :       return;
   12191              :     }
   12192      9626115 :   else if (TREE_CODE (constructor_type) == UNION_TYPE
   12193      9626115 :            && !vec_safe_is_empty (constructor_elements))
   12194              :     {
   12195           62 :       if (!implicit)
   12196              :         {
   12197           12 :           if (TREE_SIDE_EFFECTS (constructor_elements->last ().value))
   12198            3 :             warning_init (loc, OPT_Woverride_init_side_effects,
   12199              :                           "initialized field with side-effects overwritten");
   12200            9 :           else if (warn_override_init)
   12201            6 :             warning_init (loc, OPT_Woverride_init,
   12202              :                           "initialized field overwritten");
   12203              :         }
   12204              : 
   12205              :       /* We can have just one union field set.  */
   12206           62 :       constructor_elements = NULL;
   12207              :     }
   12208              : 
   12209              :   /* Otherwise, output this element either to
   12210              :      constructor_elements or to the assembler file.  */
   12211              : 
   12212      9626115 :   constructor_elt celt = {field, value};
   12213      9626115 :   vec_safe_push (constructor_elements, celt);
   12214              : 
   12215              :   /* Advance the variable that indicates sequential elements output.  */
   12216      9626115 :   if (TREE_CODE (constructor_type) == ARRAY_TYPE)
   12217              :     {
   12218      1719521 :       tree inc = bitsize_one_node;
   12219      1719521 :       if (value && TREE_CODE (value) == RAW_DATA_CST)
   12220          230 :         inc = bitsize_int (RAW_DATA_LENGTH (value));
   12221      1719521 :       constructor_unfilled_index
   12222      1719521 :         = size_binop_loc (input_location, PLUS_EXPR,
   12223              :                           constructor_unfilled_index, inc);
   12224              :     }
   12225      7906594 :   else if (TREE_CODE (constructor_type) == RECORD_TYPE)
   12226              :     {
   12227      1040001 :       constructor_unfilled_fields
   12228      1040001 :         = DECL_CHAIN (constructor_unfilled_fields);
   12229              : 
   12230              :       /* Skip any nameless bit fields.  */
   12231      1040001 :       while (constructor_unfilled_fields != NULL_TREE
   12232      1040102 :              && DECL_UNNAMED_BIT_FIELD (constructor_unfilled_fields))
   12233          101 :         constructor_unfilled_fields
   12234          101 :           = DECL_CHAIN (constructor_unfilled_fields);
   12235              :     }
   12236      6866593 :   else if (TREE_CODE (constructor_type) == UNION_TYPE)
   12237        31314 :     constructor_unfilled_fields = NULL_TREE;
   12238              : 
   12239              :   /* Now output any pending elements which have become next.  */
   12240      9626115 :   if (pending)
   12241      9620020 :     output_pending_init_elements (0, braced_init_obstack);
   12242              : }
   12243              : 
   12244              : /* For two FIELD_DECLs in the same chain, return -1 if field1
   12245              :    comes before field2, 1 if field1 comes after field2 and
   12246              :    0 if field1 == field2.  */
   12247              : 
   12248              : static int
   12249         6851 : init_field_decl_cmp (tree field1, tree field2)
   12250              : {
   12251         6851 :   if (field1 == field2)
   12252              :     return 0;
   12253              : 
   12254         3208 :   tree bitpos1 = bit_position (field1);
   12255         3208 :   tree bitpos2 = bit_position (field2);
   12256         3208 :   if (tree_int_cst_equal (bitpos1, bitpos2))
   12257              :     {
   12258              :       /* If one of the fields has non-zero bitsize, then that
   12259              :          field must be the last one in a sequence of zero
   12260              :          sized fields, fields after it will have bigger
   12261              :          bit_position.  */
   12262           22 :       if (TREE_TYPE (field1) != error_mark_node
   12263           22 :           && COMPLETE_TYPE_P (TREE_TYPE (field1))
   12264           44 :           && integer_nonzerop (TREE_TYPE (field1)))
   12265              :         return 1;
   12266           22 :       if (TREE_TYPE (field2) != error_mark_node
   12267           22 :           && COMPLETE_TYPE_P (TREE_TYPE (field2))
   12268           37 :           && integer_nonzerop (TREE_TYPE (field2)))
   12269              :         return -1;
   12270              :       /* Otherwise, fallback to DECL_CHAIN walk to find out
   12271              :          which field comes earlier.  Walk chains of both
   12272              :          fields, so that if field1 and field2 are close to each
   12273              :          other in either order, it is found soon even for large
   12274              :          sequences of zero sized fields.  */
   12275              :       tree f1 = field1, f2 = field2;
   12276           22 :       while (1)
   12277              :         {
   12278           22 :           f1 = DECL_CHAIN (f1);
   12279           22 :           f2 = DECL_CHAIN (f2);
   12280           22 :           if (f1 == NULL_TREE)
   12281              :             {
   12282            7 :               gcc_assert (f2);
   12283              :               return 1;
   12284              :             }
   12285           15 :           if (f2 == NULL_TREE)
   12286              :             return -1;
   12287            1 :           if (f1 == field2)
   12288              :             return -1;
   12289            0 :           if (f2 == field1)
   12290              :             return 1;
   12291            0 :           if (!tree_int_cst_equal (bit_position (f1), bitpos1))
   12292              :             return 1;
   12293            0 :           if (!tree_int_cst_equal (bit_position (f2), bitpos1))
   12294              :             return -1;
   12295              :         }
   12296              :     }
   12297         3186 :   else if (tree_int_cst_lt (bitpos1, bitpos2))
   12298              :     return -1;
   12299              :   else
   12300              :     return 1;
   12301              : }
   12302              : 
   12303              : /* Output any pending elements which have become next.
   12304              :    As we output elements, constructor_unfilled_{fields,index}
   12305              :    advances, which may cause other elements to become next;
   12306              :    if so, they too are output.
   12307              : 
   12308              :    If ALL is 0, we return when there are
   12309              :    no more pending elements to output now.
   12310              : 
   12311              :    If ALL is 1, we output space as necessary so that
   12312              :    we can output all the pending elements.  */
   12313              : static void
   12314     11691152 : output_pending_init_elements (int all, struct obstack * braced_init_obstack)
   12315              : {
   12316     11691152 :   struct init_node *elt = constructor_pending_elts;
   12317     11692288 :   tree next;
   12318              : 
   12319     11692288 :  retry:
   12320              : 
   12321              :   /* Look through the whole pending tree.
   12322              :      If we find an element that should be output now,
   12323              :      output it.  Otherwise, set NEXT to the element
   12324              :      that comes first among those still pending.  */
   12325              : 
   12326     11692288 :   next = NULL_TREE;
   12327     11704262 :   while (elt)
   12328              :     {
   12329        14806 :       if (TREE_CODE (constructor_type) == ARRAY_TYPE)
   12330              :         {
   12331         6812 :           if (tree_int_cst_equal (elt->purpose,
   12332              :                                   constructor_unfilled_index))
   12333         2829 :             output_init_element (input_location, elt->value, elt->origtype,
   12334         2829 :                                  true, TREE_TYPE (constructor_type),
   12335              :                                  constructor_unfilled_index, false, false,
   12336              :                                  braced_init_obstack);
   12337         3983 :           else if (tree_int_cst_lt (constructor_unfilled_index,
   12338         3983 :                                     elt->purpose))
   12339              :             {
   12340              :               /* Advance to the next smaller node.  */
   12341         1133 :               if (elt->left)
   12342              :                 elt = elt->left;
   12343              :               else
   12344              :                 {
   12345              :                   /* We have reached the smallest node bigger than the
   12346              :                      current unfilled index.  Fill the space first.  */
   12347          345 :                   next = elt->purpose;
   12348          345 :                   break;
   12349              :                 }
   12350              :             }
   12351              :           else
   12352              :             {
   12353              :               /* Advance to the next bigger node.  */
   12354         2850 :               if (elt->right)
   12355              :                 elt = elt->right;
   12356              :               else
   12357              :                 {
   12358              :                   /* We have reached the biggest node in a subtree.  Find
   12359              :                      the parent of it, which is the next bigger node.  */
   12360         2850 :                   while (elt->parent && elt->parent->right == elt)
   12361              :                     elt = elt->parent;
   12362         1896 :                   elt = elt->parent;
   12363         2679 :                   if (elt && tree_int_cst_lt (constructor_unfilled_index,
   12364          783 :                                               elt->purpose))
   12365              :                     {
   12366           22 :                       next = elt->purpose;
   12367           22 :                       break;
   12368              :                     }
   12369              :                 }
   12370              :             }
   12371              :         }
   12372         7994 :       else if (RECORD_OR_UNION_TYPE_P (constructor_type))
   12373              :         {
   12374              :           /* If the current record is complete we are done.  */
   12375         7994 :           if (constructor_unfilled_fields == NULL_TREE)
   12376              :             break;
   12377              : 
   12378         6407 :           int cmp = init_field_decl_cmp (constructor_unfilled_fields,
   12379              :                                          elt->purpose);
   12380         6407 :           if (cmp == 0)
   12381         3266 :             output_init_element (input_location, elt->value, elt->origtype,
   12382         3266 :                                  true, TREE_TYPE (elt->purpose),
   12383              :                                  elt->purpose, false, false,
   12384              :                                  braced_init_obstack);
   12385         3141 :           else if (cmp < 0)
   12386              :             {
   12387              :               /* Advance to the next smaller node.  */
   12388         1262 :               if (elt->left)
   12389              :                 elt = elt->left;
   12390              :               else
   12391              :                 {
   12392              :                   /* We have reached the smallest node bigger than the
   12393              :                      current unfilled field.  Fill the space first.  */
   12394          811 :                   next = elt->purpose;
   12395          811 :                   break;
   12396              :                 }
   12397              :             }
   12398              :           else
   12399              :             {
   12400              :               /* Advance to the next bigger node.  */
   12401         1879 :               if (elt->right)
   12402              :                 elt = elt->right;
   12403              :               else
   12404              :                 {
   12405              :                   /* We have reached the biggest node in a subtree.  Find
   12406              :                      the parent of it, which is the next bigger node.  */
   12407          973 :                   while (elt->parent && elt->parent->right == elt)
   12408              :                     elt = elt->parent;
   12409          757 :                   elt = elt->parent;
   12410          757 :                   if (elt
   12411          757 :                       && init_field_decl_cmp (constructor_unfilled_fields,
   12412              :                                               elt->purpose) < 0)
   12413              :                     {
   12414           67 :                       next = elt->purpose;
   12415           67 :                       break;
   12416              :                     }
   12417              :                 }
   12418              :             }
   12419              :         }
   12420              :     }
   12421              : 
   12422              :   /* Ordinarily return, but not if we want to output all
   12423              :      and there are elements left.  */
   12424     11692288 :   if (!(all && next != NULL_TREE))
   12425     11691152 :     return;
   12426              : 
   12427              :   /* If it's not incremental, just skip over the gap, so that after
   12428              :      jumping to retry we will output the next successive element.  */
   12429         1136 :   if (RECORD_OR_UNION_TYPE_P (constructor_type))
   12430          808 :     constructor_unfilled_fields = next;
   12431          328 :   else if (TREE_CODE (constructor_type) == ARRAY_TYPE)
   12432          328 :     constructor_unfilled_index = next;
   12433              : 
   12434              :   /* ELT now points to the node in the pending tree with the next
   12435              :      initializer to output.  */
   12436         1136 :   goto retry;
   12437              : }
   12438              : 
   12439              : /* Expression VALUE coincides with the start of type TYPE in a braced
   12440              :    initializer.  Return true if we should treat VALUE as initializing
   12441              :    the first element of TYPE, false if we should treat it as initializing
   12442              :    TYPE as a whole.
   12443              : 
   12444              :    If the initializer is clearly invalid, the question becomes:
   12445              :    which choice gives the best error message?  */
   12446              : 
   12447              : static bool
   12448      3488182 : initialize_elementwise_p (tree type, tree value)
   12449              : {
   12450      3488182 :   if (type == error_mark_node || value == error_mark_node)
   12451              :     return false;
   12452              : 
   12453      3487917 :   gcc_checking_assert (TYPE_MAIN_VARIANT (type) == type);
   12454              : 
   12455      3487917 :   tree value_type = TREE_TYPE (value);
   12456      3487917 :   if (value_type == error_mark_node)
   12457              :     return false;
   12458              : 
   12459              :   /* GNU vectors can be initialized elementwise.  However, treat any
   12460              :      kind of vector value as initializing the vector type as a whole,
   12461              :      regardless of whether the value is a GNU vector.  Such initializers
   12462              :      are valid if and only if they would have been valid in a non-braced
   12463              :      initializer like:
   12464              : 
   12465              :         TYPE foo = VALUE;
   12466              : 
   12467              :      so recursing into the vector type would be at best confusing or at
   12468              :      worst wrong.  For example, when -flax-vector-conversions is in effect,
   12469              :      it's possible to initialize a V8HI from a V4SI, even though the vectors
   12470              :      have different element types and different numbers of elements.  */
   12471      3487917 :   if (gnu_vector_type_p (type))
   12472        19532 :     return !VECTOR_TYPE_P (value_type);
   12473              : 
   12474      3468385 :   if (AGGREGATE_TYPE_P (type))
   12475      1743195 :     return !comptypes (type, TYPE_MAIN_VARIANT (value_type));
   12476              : 
   12477              :   return false;
   12478              : }
   12479              : 
   12480              : /* Helper function for process_init_element.  Split first element of
   12481              :    RAW_DATA_CST and save the rest to *RAW_DATA.  */
   12482              : 
   12483              : static inline tree
   12484      9624419 : maybe_split_raw_data (tree value, tree *raw_data)
   12485              : {
   12486      9624419 :   if (value == NULL_TREE || TREE_CODE (value) != RAW_DATA_CST)
   12487              :     return value;
   12488          211 :   *raw_data = value;
   12489          211 :   value = build_int_cst (integer_type_node,
   12490          211 :                          RAW_DATA_UCHAR_ELT (*raw_data, 0));
   12491          211 :   ++RAW_DATA_POINTER (*raw_data);
   12492          211 :   --RAW_DATA_LENGTH (*raw_data);
   12493          211 :   return value;
   12494              : }
   12495              : 
   12496              : /* Return non-zero if c_parser_initval should attempt to optimize
   12497              :    large initializers into RAW_DATA_CST.  In that case return how
   12498              :    many elements to optimize at most.  */
   12499              : 
   12500              : unsigned
   12501      2992269 : c_maybe_optimize_large_byte_initializer (void)
   12502              : {
   12503      2992269 :   if (!constructor_type
   12504      2992199 :       || TREE_CODE (constructor_type) != ARRAY_TYPE
   12505       209307 :       || constructor_stack->implicit)
   12506              :     return 0;
   12507       206542 :   tree elttype = TYPE_MAIN_VARIANT (TREE_TYPE (constructor_type));
   12508       206542 :   if (TREE_CODE (elttype) != INTEGER_TYPE
   12509       206542 :       && TREE_CODE (elttype) != BITINT_TYPE)
   12510              :     return 0;
   12511       183897 :   if (TYPE_PRECISION (elttype) != CHAR_BIT
   12512        27862 :       || constructor_stack->replacement_value.value
   12513        27862 :       || (COMPLETE_TYPE_P (constructor_type)
   12514        26217 :           && !poly_int_tree_p (TYPE_SIZE (constructor_type)))
   12515       211759 :       || constructor_range_stack)
   12516              :     return 0;
   12517        27862 :   if (constructor_max_index == NULL_TREE)
   12518              :     return INT_MAX;
   12519        26217 :   if (tree_int_cst_le (constructor_max_index, constructor_index)
   12520        26217 :       || integer_all_onesp (constructor_max_index))
   12521         4765 :     return 0;
   12522        21452 :   widest_int w = wi::to_widest (constructor_max_index);
   12523        21452 :   w -= wi::to_widest (constructor_index);
   12524        21452 :   w += 1;
   12525        21452 :   if (w < 64)
   12526              :     return 0;
   12527         6890 :   if (w > INT_MAX)
   12528              :     return INT_MAX;
   12529         6890 :   return w.to_uhwi ();
   12530        21452 : }
   12531              : 
   12532              : /* Add one non-braced element to the current constructor level.
   12533              :    This adjusts the current position within the constructor's type.
   12534              :    This may also start or terminate implicit levels
   12535              :    to handle a partly-braced initializer.
   12536              : 
   12537              :    Once this has found the correct level for the new element,
   12538              :    it calls output_init_element.
   12539              : 
   12540              :    IMPLICIT is true if value comes from pop_init_level (1),
   12541              :    the new initializer has been merged with the existing one
   12542              :    and thus no warnings should be emitted about overriding an
   12543              :    existing initializer.  */
   12544              : 
   12545              : void
   12546      9614713 : process_init_element (location_t loc, struct c_expr value, bool implicit,
   12547              :                       struct obstack * braced_init_obstack)
   12548              : {
   12549      9614713 :   tree orig_value = value.value;
   12550     19229426 :   int string_flag
   12551      9614713 :     = (orig_value != NULL_TREE && TREE_CODE (orig_value) == STRING_CST);
   12552      9614713 :   bool strict_string = value.original_code == STRING_CST;
   12553      9614713 :   bool was_designated = designator_depth != 0;
   12554      9614713 :   tree raw_data = NULL_TREE;
   12555              : 
   12556      9614925 : retry:
   12557      9614925 :   designator_depth = 0;
   12558      9614925 :   designator_erroneous = 0;
   12559              : 
   12560      9614925 :   if (!implicit && value.value && !integer_zerop (value.value))
   12561      7590360 :     constructor_zeroinit = 0;
   12562              : 
   12563              :   /* Handle superfluous braces around string cst as in
   12564              :      char x[] = {"foo"}; */
   12565      9614925 :   if (constructor_type
   12566      9614797 :       && !was_designated
   12567      9577953 :       && TREE_CODE (constructor_type) == ARRAY_TYPE
   12568      1705480 :       && INTEGRAL_TYPE_P (TREE_TYPE (constructor_type))
   12569     10351313 :       && integer_zerop (constructor_unfilled_index))
   12570              :     {
   12571       163121 :       if (constructor_stack->replacement_value.value)
   12572              :         {
   12573            8 :           error_init (loc, "excess elements in %qT initializer", constructor_type);
   12574          409 :           return;
   12575              :         }
   12576       163113 :       else if (string_flag)
   12577              :         {
   12578          138 :           constructor_stack->replacement_value = value;
   12579          138 :           return;
   12580              :         }
   12581              :     }
   12582              : 
   12583      9614779 :   if (constructor_stack->replacement_value.value != NULL_TREE)
   12584              :     {
   12585            0 :       error_init (loc, "excess elements in struct initializer");
   12586            0 :       return;
   12587              :     }
   12588              : 
   12589              :   /* Ignore elements of a brace group if it is entirely superfluous
   12590              :      and has already been diagnosed, or if the type is erroneous.  */
   12591      9614779 :   if (constructor_type == NULL_TREE || constructor_type == error_mark_node)
   12592              :     return;
   12593              : 
   12594              :   /* Ignore elements of an initializer for a variable-size type.
   12595              :      Those are diagnosed in the parser (empty initializer braces are OK).  */
   12596      9614582 :   if (COMPLETE_TYPE_P (constructor_type)
   12597      9614582 :       && !poly_int_tree_p (TYPE_SIZE (constructor_type)))
   12598              :     return;
   12599              : 
   12600      8909201 :   if (!implicit && warn_designated_init && !was_designated
   12601      8874675 :       && TREE_CODE (constructor_type) == RECORD_TYPE
   12602     10649709 :       && lookup_attribute ("designated_init",
   12603      1035185 :                            TYPE_ATTRIBUTES (constructor_type)))
   12604           50 :     warning_init (loc,
   12605              :                   OPT_Wdesignated_init,
   12606              :                   "positional initialization of field "
   12607              :                   "in %<struct%> declared with %<designated_init%> attribute");
   12608              : 
   12609              :   /* If we've exhausted any levels that didn't have braces,
   12610              :      pop them now.  */
   12611     10316503 :   while (constructor_stack->implicit)
   12612              :     {
   12613       708550 :       if (RECORD_OR_UNION_TYPE_P (constructor_type)
   12614       703711 :           && constructor_fields == NULL_TREE)
   12615       701738 :         process_init_element (loc,
   12616              :                               pop_init_level (loc, 1, braced_init_obstack,
   12617              :                                               last_init_list_comma),
   12618              :                               true, braced_init_obstack);
   12619         6812 :       else if ((TREE_CODE (constructor_type) == ARRAY_TYPE
   12620         2617 :                 || gnu_vector_type_p (constructor_type))
   12621         4839 :                && constructor_max_index
   12622        11624 :                && tree_int_cst_lt (constructor_max_index,
   12623              :                                    constructor_index))
   12624          241 :         process_init_element (loc,
   12625              :                               pop_init_level (loc, 1, braced_init_obstack,
   12626              :                                               last_init_list_comma),
   12627              :                               true, braced_init_obstack);
   12628              :       else
   12629              :         break;
   12630              :     }
   12631              : 
   12632              :   /* In the case of [LO ... HI] = VALUE, only evaluate VALUE once.  */
   12633      9614524 :   if (constructor_range_stack)
   12634              :     {
   12635              :       /* If value is a compound literal and we'll be just using its
   12636              :          content, don't put it into a SAVE_EXPR.  */
   12637          371 :       if (TREE_CODE (value.value) != COMPOUND_LITERAL_EXPR
   12638            3 :           || !require_constant_value)
   12639              :         {
   12640          368 :           tree semantic_type = NULL_TREE;
   12641          368 :           if (TREE_CODE (value.value) == EXCESS_PRECISION_EXPR)
   12642              :             {
   12643            0 :               semantic_type = TREE_TYPE (value.value);
   12644            0 :               value.value = TREE_OPERAND (value.value, 0);
   12645              :             }
   12646          368 :           value.value = save_expr (value.value);
   12647          368 :           if (semantic_type)
   12648            0 :             value.value = build1 (EXCESS_PRECISION_EXPR, semantic_type,
   12649              :                                   value.value);
   12650              :         }
   12651              :     }
   12652              : 
   12653     10328768 :   while (1)
   12654              :     {
   12655     10328768 :       if (TREE_CODE (constructor_type) == RECORD_TYPE)
   12656              :         {
   12657      1041273 :           tree fieldtype;
   12658      1041273 :           enum tree_code fieldcode;
   12659              : 
   12660      1041273 :           if (constructor_fields == NULL_TREE)
   12661              :             {
   12662         1280 :               pedwarn_init (loc, 0, "excess elements in struct initializer");
   12663         1280 :               break;
   12664              :             }
   12665              : 
   12666      1039993 :           fieldtype = TREE_TYPE (constructor_fields);
   12667      1039993 :           if (fieldtype != error_mark_node)
   12668      1039992 :             fieldtype = TYPE_MAIN_VARIANT (fieldtype);
   12669      1039993 :           fieldcode = TREE_CODE (fieldtype);
   12670              : 
   12671              :           /* Error for non-static initialization of a flexible array member.  */
   12672      1039993 :           if (fieldcode == ARRAY_TYPE
   12673       156025 :               && !require_constant_value
   12674         1891 :               && TYPE_SIZE (fieldtype) == NULL_TREE
   12675      1040003 :               && DECL_CHAIN (constructor_fields) == NULL_TREE)
   12676              :             {
   12677           10 :               error_init (loc, "non-static initialization of a flexible "
   12678              :                           "array member");
   12679           10 :               break;
   12680              :             }
   12681              : 
   12682              :           /* Error for initialization of a flexible array member with
   12683              :              a string constant if the structure is in an array.  E.g.:
   12684              :              struct S { int x; char y[]; };
   12685              :              struct S s[] = { { 1, "foo" } };
   12686              :              is invalid.  */
   12687      1039983 :           if (string_flag
   12688      1039983 :               && fieldcode == ARRAY_TYPE
   12689         3353 :               && constructor_depth > 1
   12690          489 :               && TYPE_SIZE (fieldtype) == NULL_TREE
   12691      1040030 :               && DECL_CHAIN (constructor_fields) == NULL_TREE)
   12692              :             {
   12693           47 :               bool in_array_p = false;
   12694           47 :               for (struct constructor_stack *p = constructor_stack;
   12695           73 :                    p && p->type; p = p->next)
   12696           59 :                 if (TREE_CODE (p->type) == ARRAY_TYPE)
   12697              :                   {
   12698              :                     in_array_p = true;
   12699              :                     break;
   12700              :                   }
   12701           47 :               if (in_array_p)
   12702              :                 {
   12703           33 :                   error_init (loc, "initialization of flexible array "
   12704              :                               "member in a nested context");
   12705           33 :                   break;
   12706              :                 }
   12707              :             }
   12708              : 
   12709              :           /* Accept a string constant to initialize a subarray.  */
   12710      1039950 :           if (value.value != NULL_TREE
   12711      1039877 :               && fieldcode == ARRAY_TYPE
   12712       155909 :               && INTEGRAL_TYPE_P (TREE_TYPE (fieldtype))
   12713      1194556 :               && string_flag)
   12714              :             value.value = orig_value;
   12715              :           /* Otherwise, if we have come to a subaggregate,
   12716              :              and we don't have an element of its type, push into it.  */
   12717      1036934 :           else if (value.value != NULL_TREE
   12718      1036630 :                    && initialize_elementwise_p (fieldtype, value.value))
   12719              :             {
   12720          304 :               push_init_level (loc, 1, braced_init_obstack);
   12721          304 :               continue;
   12722              :             }
   12723              : 
   12724      1039646 :           value.value = maybe_split_raw_data (value.value, &raw_data);
   12725      1039646 :           if (value.value)
   12726              :             {
   12727      1039573 :               push_member_name (constructor_fields);
   12728      1039573 :               output_init_element (loc, value.value, value.original_type,
   12729              :                                    strict_string, fieldtype,
   12730              :                                    constructor_fields, true, implicit,
   12731              :                                    braced_init_obstack);
   12732      1039573 :               RESTORE_SPELLING_DEPTH (constructor_depth);
   12733              :             }
   12734              :           else
   12735              :             /* Do the bookkeeping for an element that was
   12736              :                directly output as a constructor.  */
   12737              :             {
   12738              :               /* For a record, keep track of end position of last field.  */
   12739           73 :               if (DECL_SIZE (constructor_fields))
   12740           30 :                 constructor_bit_index
   12741           30 :                   = size_binop_loc (input_location, PLUS_EXPR,
   12742              :                                     bit_position (constructor_fields),
   12743           30 :                                     DECL_SIZE (constructor_fields));
   12744              : 
   12745              :               /* If the current field was the first one not yet written out,
   12746              :                  it isn't now, so update.  */
   12747           73 :               if (constructor_unfilled_fields == constructor_fields)
   12748              :                 {
   12749           64 :                   constructor_unfilled_fields = DECL_CHAIN (constructor_fields);
   12750              :                   /* Skip any nameless bit fields.  */
   12751           64 :                   while (constructor_unfilled_fields != 0
   12752           64 :                          && (DECL_UNNAMED_BIT_FIELD
   12753              :                              (constructor_unfilled_fields)))
   12754            0 :                     constructor_unfilled_fields =
   12755            0 :                       DECL_CHAIN (constructor_unfilled_fields);
   12756              :                 }
   12757              :             }
   12758              : 
   12759      1039646 :           constructor_fields = DECL_CHAIN (constructor_fields);
   12760              :           /* Skip any nameless bit fields at the beginning.  */
   12761      1039646 :           while (constructor_fields != NULL_TREE
   12762      1039747 :                  && DECL_UNNAMED_BIT_FIELD (constructor_fields))
   12763          101 :             constructor_fields = DECL_CHAIN (constructor_fields);
   12764              :         }
   12765      9287495 :       else if (TREE_CODE (constructor_type) == UNION_TYPE)
   12766              :         {
   12767        31377 :           tree fieldtype;
   12768        31377 :           enum tree_code fieldcode;
   12769              : 
   12770        31377 :           if (constructor_fields == NULL_TREE)
   12771              :             {
   12772            3 :               pedwarn_init (loc, 0,
   12773              :                             "excess elements in union initializer");
   12774            3 :               break;
   12775              :             }
   12776              : 
   12777        31374 :           fieldtype = TREE_TYPE (constructor_fields);
   12778        31374 :           if (fieldtype != error_mark_node)
   12779        31374 :             fieldtype = TYPE_MAIN_VARIANT (fieldtype);
   12780        31374 :           fieldcode = TREE_CODE (fieldtype);
   12781              : 
   12782              :           /* Warn that traditional C rejects initialization of unions.
   12783              :              We skip the warning if the value is zero.  This is done
   12784              :              under the assumption that the zero initializer in user
   12785              :              code appears conditioned on e.g. __STDC__ to avoid
   12786              :              "missing initializer" warnings and relies on default
   12787              :              initialization to zero in the traditional C case.
   12788              :              We also skip the warning if the initializer is designated,
   12789              :              again on the assumption that this must be conditional on
   12790              :              __STDC__ anyway (and we've already complained about the
   12791              :              member-designator already).  */
   12792        33824 :           if (!in_system_header_at (input_location) && !constructor_designated
   12793        32925 :               && !(value.value && (integer_zerop (value.value)
   12794         1444 :                                    || real_zerop (value.value))))
   12795         1437 :             warning (OPT_Wtraditional, "traditional C rejects initialization "
   12796              :                      "of unions");
   12797              : 
   12798              :           /* Error for non-static initialization of a flexible array member.  */
   12799        31374 :           if (fieldcode == ARRAY_TYPE
   12800          766 :               && !require_constant_value
   12801        31431 :               && TYPE_SIZE (fieldtype) == NULL_TREE)
   12802              :             {
   12803            3 :               error_init (loc, "non-static initialization of a flexible "
   12804              :                           "array member");
   12805            3 :               break;
   12806              :             }
   12807              : 
   12808              :           /* Error for initialization of a flexible array member with
   12809              :              a string constant if the structure is in an array.  E.g.:
   12810              :              union U { int x; char y[]; };
   12811              :              union U s[] = { { 1, "foo" } };
   12812              :              is invalid.  */
   12813        31371 :           if (string_flag
   12814        31371 :               && fieldcode == ARRAY_TYPE
   12815            7 :               && constructor_depth > 1
   12816        31375 :               && TYPE_SIZE (fieldtype) == NULL_TREE)
   12817              :             {
   12818            3 :               bool in_array_p = false;
   12819            3 :               for (struct constructor_stack *p = constructor_stack;
   12820            3 :                    p && p->type; p = p->next)
   12821            3 :                 if (TREE_CODE (p->type) == ARRAY_TYPE)
   12822              :                   {
   12823              :                     in_array_p = true;
   12824              :                     break;
   12825              :                   }
   12826            3 :               if (in_array_p)
   12827              :                 {
   12828            3 :                   error_init (loc, "initialization of flexible array "
   12829              :                               "member in a nested context");
   12830            3 :                   break;
   12831              :                 }
   12832              :             }
   12833              : 
   12834              :           /* Accept a string constant to initialize a subarray.  */
   12835        31368 :           if (value.value != NULL_TREE
   12836        31368 :               && fieldcode == ARRAY_TYPE
   12837          760 :               && INTEGRAL_TYPE_P (TREE_TYPE (fieldtype))
   12838        32123 :               && string_flag)
   12839              :             value.value = orig_value;
   12840              :           /* Otherwise, if we have come to a subaggregate,
   12841              :              and we don't have an element of its type, push into it.  */
   12842        31414 :           else if (value.value != NULL_TREE
   12843        31364 :                    && initialize_elementwise_p (fieldtype, value.value))
   12844              :             {
   12845           50 :               push_init_level (loc, 1, braced_init_obstack);
   12846           50 :               continue;
   12847              :             }
   12848              : 
   12849        31318 :           value.value = maybe_split_raw_data (value.value, &raw_data);
   12850        31318 :           if (value.value)
   12851              :             {
   12852        31318 :               push_member_name (constructor_fields);
   12853        31318 :               output_init_element (loc, value.value, value.original_type,
   12854              :                                    strict_string, fieldtype,
   12855              :                                    constructor_fields, true, implicit,
   12856              :                                    braced_init_obstack);
   12857        31318 :               RESTORE_SPELLING_DEPTH (constructor_depth);
   12858              :             }
   12859              :           else
   12860              :             /* Do the bookkeeping for an element that was
   12861              :                directly output as a constructor.  */
   12862              :             {
   12863            0 :               constructor_bit_index = DECL_SIZE (constructor_fields);
   12864            0 :               constructor_unfilled_fields = DECL_CHAIN (constructor_fields);
   12865              :             }
   12866              : 
   12867        31318 :           constructor_fields = NULL_TREE;
   12868              :         }
   12869      9256118 :       else if (TREE_CODE (constructor_type) == ARRAY_TYPE)
   12870              :         {
   12871      2420757 :           tree elttype = TYPE_MAIN_VARIANT (TREE_TYPE (constructor_type));
   12872      2420757 :           enum tree_code eltcode = TREE_CODE (elttype);
   12873              : 
   12874              :           /* Accept a string constant to initialize a subarray.  */
   12875      2420757 :           if (value.value != NULL_TREE
   12876      2420757 :               && eltcode == ARRAY_TYPE
   12877         7031 :               && INTEGRAL_TYPE_P (TREE_TYPE (elttype))
   12878      2426305 :               && string_flag)
   12879              :             value.value = orig_value;
   12880              :           /* Otherwise, if we have come to a subaggregate,
   12881              :              and we don't have an element of its type, push into it.  */
   12882      3122587 :           else if (value.value != NULL_TREE
   12883      2420261 :                    && initialize_elementwise_p (elttype, value.value))
   12884              :             {
   12885       702326 :               push_init_level (loc, 1, braced_init_obstack);
   12886       702326 :               continue;
   12887              :             }
   12888              : 
   12889      1718431 :           if (constructor_max_index != NULL_TREE
   12890       675592 :               && (tree_int_cst_lt (constructor_max_index, constructor_index)
   12891       675477 :                   || integer_all_onesp (constructor_max_index))
   12892              :               /* For VLA we got an error already.  */
   12893      1718546 :               && !C_TYPE_VARIABLE_SIZE (constructor_type))
   12894              :             {
   12895          113 :               pedwarn_init (loc, 0,
   12896              :                             "excess elements in array initializer");
   12897          113 :               break;
   12898              :             }
   12899              : 
   12900      1718318 :           if (value.value
   12901      1718318 :               && TREE_CODE (value.value) == RAW_DATA_CST
   12902          193 :               && RAW_DATA_LENGTH (value.value) > 1
   12903          193 :               && (TREE_CODE (elttype) == INTEGER_TYPE
   12904          193 :                   || TREE_CODE (elttype) == BITINT_TYPE)
   12905          193 :               && TYPE_PRECISION (elttype) == CHAR_BIT
   12906      1718511 :               && (constructor_max_index == NULL_TREE
   12907           55 :                   || tree_int_cst_lt (constructor_index,
   12908              :                                       constructor_max_index)))
   12909              :             {
   12910          193 :               unsigned int len = RAW_DATA_LENGTH (value.value);
   12911          193 :               if (constructor_max_index)
   12912              :                 {
   12913           55 :                   widest_int w = wi::to_widest (constructor_max_index);
   12914           55 :                   w -= wi::to_widest (constructor_index);
   12915           55 :                   w += 1;
   12916           55 :                   if (w < len)
   12917            3 :                     len = w.to_uhwi ();
   12918           55 :                 }
   12919          193 :               if (len < (unsigned) RAW_DATA_LENGTH (value.value))
   12920              :                 {
   12921            3 :                   raw_data = copy_node (value.value);
   12922            3 :                   RAW_DATA_LENGTH (raw_data) -= len;
   12923            3 :                   RAW_DATA_POINTER (raw_data) += len;
   12924            3 :                   RAW_DATA_LENGTH (value.value) = len;
   12925              :                 }
   12926          193 :               TREE_TYPE (value.value) = elttype;
   12927          193 :               push_array_bounds (tree_to_uhwi (constructor_index));
   12928          193 :               output_init_element (loc, value.value, value.original_type,
   12929              :                                    false, elttype, constructor_index, true,
   12930              :                                    implicit, braced_init_obstack);
   12931          193 :               RESTORE_SPELLING_DEPTH (constructor_depth);
   12932          193 :               constructor_index
   12933          193 :                 = size_binop_loc (input_location, PLUS_EXPR,
   12934          193 :                                   constructor_index, bitsize_int (len));
   12935              :             }
   12936              :           else
   12937              :             {
   12938      1718125 :               value.value = maybe_split_raw_data (value.value, &raw_data);
   12939              :               /* Now output the actual element.  */
   12940      1718125 :               if (value.value)
   12941              :                 {
   12942      1718125 :                   push_array_bounds (tree_to_uhwi (constructor_index));
   12943      1718125 :                   output_init_element (loc, value.value, value.original_type,
   12944              :                                        strict_string, elttype,
   12945              :                                        constructor_index, true, implicit,
   12946              :                                        braced_init_obstack);
   12947      1718125 :                   RESTORE_SPELLING_DEPTH (constructor_depth);
   12948              :                 }
   12949              : 
   12950      1718125 :               constructor_index
   12951      1718125 :                 = size_binop_loc (input_location, PLUS_EXPR,
   12952              :                                   constructor_index, bitsize_one_node);
   12953              : 
   12954      1718125 :               if (!value.value)
   12955              :                 /* If we are doing the bookkeeping for an element that was
   12956              :                    directly output as a constructor, we must update
   12957              :                    constructor_unfilled_index.  */
   12958            0 :                 constructor_unfilled_index = constructor_index;
   12959              :             }
   12960              :         }
   12961      6835361 :       else if (gnu_vector_type_p (constructor_type))
   12962              :         {
   12963      6834869 :           tree elttype = TYPE_MAIN_VARIANT (TREE_TYPE (constructor_type));
   12964              : 
   12965              :           /* Do a basic check of initializer size.  Note that vectors
   12966              :              may not always have a fixed size derived from their type.  */
   12967      6834869 :           if (maybe_lt (tree_to_poly_uint64 (constructor_max_index),
   12968      6834869 :                         tree_to_poly_uint64 (constructor_index)))
   12969              :             {
   12970              :               /* Diagose VLA out-of-bounds as errors.  */
   12971            2 :               if (tree_to_poly_uint64 (constructor_max_index).is_constant())
   12972            2 :                 pedwarn_init (loc, 0,
   12973              :                               "excess elements in vector initializer");
   12974              :               else
   12975              :                 error_init (loc, "excess elements in vector initializer");
   12976              : 
   12977              :               break;
   12978              :             }
   12979              : 
   12980      6834867 :           value.value = maybe_split_raw_data (value.value, &raw_data);
   12981              :           /* Now output the actual element.  */
   12982      6834867 :           if (value.value)
   12983              :             {
   12984      6834867 :               if (TREE_CODE (value.value) == VECTOR_CST)
   12985            0 :                 elttype = TYPE_MAIN_VARIANT (constructor_type);
   12986      6834867 :               output_init_element (loc, value.value, value.original_type,
   12987              :                                    strict_string, elttype,
   12988              :                                    constructor_index, true, implicit,
   12989              :                                    braced_init_obstack);
   12990              :             }
   12991              : 
   12992      6834867 :           constructor_index
   12993      6834867 :             = size_binop_loc (input_location,
   12994              :                               PLUS_EXPR, constructor_index, bitsize_one_node);
   12995              : 
   12996      6834867 :           if (!value.value)
   12997              :             /* If we are doing the bookkeeping for an element that was
   12998              :                directly output as a constructor, we must update
   12999              :                constructor_unfilled_index.  */
   13000            0 :             constructor_unfilled_index = constructor_index;
   13001              :         }
   13002              : 
   13003              :       /* Handle the sole element allowed in a braced initializer
   13004              :          for a scalar variable.  */
   13005          492 :       else if (constructor_type != error_mark_node
   13006          492 :                && constructor_fields == NULL_TREE)
   13007              :         {
   13008           29 :           pedwarn_init (loc, 0,
   13009              :                         "excess elements in scalar initializer");
   13010           29 :           break;
   13011              :         }
   13012              :       else
   13013              :         {
   13014          463 :           value.value = maybe_split_raw_data (value.value, &raw_data);
   13015          463 :           if (value.value)
   13016          463 :             output_init_element (loc, value.value, value.original_type,
   13017              :                                  strict_string, constructor_type,
   13018              :                                  NULL_TREE, true, implicit,
   13019              :                                  braced_init_obstack);
   13020          463 :           constructor_fields = NULL_TREE;
   13021              :         }
   13022              : 
   13023              :       /* Handle range initializers either at this level or anywhere higher
   13024              :          in the designator stack.  */
   13025      9624612 :       if (constructor_range_stack)
   13026              :         {
   13027        11564 :           struct constructor_range_stack *p, *range_stack;
   13028        11564 :           int finish = 0;
   13029              : 
   13030        11564 :           range_stack = constructor_range_stack;
   13031        11564 :           constructor_range_stack = 0;
   13032        11564 :           while (constructor_stack != range_stack->stack)
   13033              :             {
   13034            0 :               gcc_assert (constructor_stack->implicit);
   13035            0 :               process_init_element (loc,
   13036              :                                     pop_init_level (loc, 1,
   13037              :                                                     braced_init_obstack,
   13038              :                                                     last_init_list_comma),
   13039              :                                     true, braced_init_obstack);
   13040              :             }
   13041          325 :           for (p = range_stack;
   13042        11889 :                !p->range_end || tree_int_cst_equal (p->index, p->range_end);
   13043          325 :                p = p->prev)
   13044              :             {
   13045          325 :               gcc_assert (constructor_stack->implicit);
   13046          325 :               process_init_element (loc,
   13047              :                                     pop_init_level (loc, 1,
   13048              :                                                     braced_init_obstack,
   13049              :                                                     last_init_list_comma),
   13050              :                                     true, braced_init_obstack);
   13051              :             }
   13052              : 
   13053        11564 :           p->index = size_binop_loc (input_location,
   13054              :                                      PLUS_EXPR, p->index, bitsize_one_node);
   13055        11564 :           if (tree_int_cst_equal (p->index, p->range_end) && !p->prev)
   13056          379 :             finish = 1;
   13057              : 
   13058        11889 :           while (1)
   13059              :             {
   13060        11889 :               constructor_index = p->index;
   13061        11889 :               constructor_fields = p->fields;
   13062        11889 :               if (finish && p->range_end && p->index == p->range_start)
   13063              :                 {
   13064            8 :                   finish = 0;
   13065            8 :                   p->prev = 0;
   13066              :                 }
   13067        11889 :               p = p->next;
   13068        11889 :               if (!p)
   13069              :                 break;
   13070          325 :               finish_implicit_inits (loc, braced_init_obstack);
   13071          325 :               push_init_level (loc, 2, braced_init_obstack);
   13072          325 :               p->stack = constructor_stack;
   13073          325 :               if (p->range_end && tree_int_cst_equal (p->index, p->range_end))
   13074           33 :                 p->index = p->range_start;
   13075              :             }
   13076              : 
   13077        11564 :           if (!finish)
   13078        11193 :             constructor_range_stack = range_stack;
   13079        11564 :           continue;
   13080        11564 :         }
   13081              : 
   13082              :       break;
   13083              :     }
   13084              : 
   13085      9614524 :   constructor_range_stack = 0;
   13086              : 
   13087      9614524 :   if (raw_data && RAW_DATA_LENGTH (raw_data))
   13088              :     {
   13089          212 :       gcc_assert (!string_flag && !was_designated);
   13090          212 :       value.value = raw_data;
   13091          212 :       raw_data = NULL_TREE;
   13092          212 :       goto retry;
   13093              :     }
   13094              : }
   13095              : 
   13096              : /* Build a complete asm-statement, whose components are a CV_QUALIFIER
   13097              :    (guaranteed to be 'volatile' or null) and ARGS (represented using
   13098              :    an ASM_EXPR node).  */
   13099              : tree
   13100       205058 : build_asm_stmt (bool is_volatile, tree args)
   13101              : {
   13102       205058 :   if (is_volatile)
   13103       165266 :     ASM_VOLATILE_P (args) = 1;
   13104       205058 :   return add_stmt (args);
   13105              : }
   13106              : 
   13107              : /* Build an asm-expr, whose components are a STRING, some OUTPUTS,
   13108              :    some INPUTS, and some CLOBBERS.  The latter three may be NULL.
   13109              :    SIMPLE indicates whether there was anything at all after the
   13110              :    string in the asm expression -- asm("blah") and asm("blah" : )
   13111              :    are subtly different.  We use a ASM_EXPR node to represent this.
   13112              :    LOC is the location of the asm, and IS_INLINE says whether this
   13113              :    is asm inline.  */
   13114              : tree
   13115       205110 : build_asm_expr (location_t loc, tree string, tree outputs, tree inputs,
   13116              :                 tree clobbers, tree labels, bool simple, bool is_inline)
   13117              : {
   13118       205110 :   tree tail;
   13119       205110 :   tree args;
   13120       205110 :   int i;
   13121       205110 :   const char *constraint;
   13122       205110 :   const char **oconstraints;
   13123       205110 :   bool allows_mem, allows_reg, is_inout;
   13124       205110 :   int ninputs, noutputs;
   13125              : 
   13126       205110 :   ninputs = list_length (inputs);
   13127       205110 :   noutputs = list_length (outputs);
   13128       205110 :   oconstraints = (const char **) alloca (noutputs * sizeof (const char *));
   13129              : 
   13130       205110 :   string = resolve_asm_operand_names (string, outputs, inputs, labels);
   13131              : 
   13132              :   /* Remove output conversions that change the type but not the mode.  */
   13133       554536 :   for (i = 0, tail = outputs; tail; ++i, tail = TREE_CHAIN (tail))
   13134              :     {
   13135       349426 :       tree output = TREE_VALUE (tail);
   13136              : 
   13137       349426 :       output = c_fully_fold (output, false, NULL, true);
   13138              : 
   13139              :       /* ??? Really, this should not be here.  Users should be using a
   13140              :          proper lvalue, dammit.  But there's a long history of using casts
   13141              :          in the output operands.  In cases like longlong.h, this becomes a
   13142              :          primitive form of typechecking -- if the cast can be removed, then
   13143              :          the output operand had a type of the proper width; otherwise we'll
   13144              :          get an error.  Gross, but ...  */
   13145       349426 :       STRIP_NOPS (output);
   13146              : 
   13147       349426 :       if (!lvalue_or_else (loc, output, lv_asm))
   13148            4 :         output = error_mark_node;
   13149              : 
   13150       349426 :       if (output != error_mark_node
   13151       349426 :           && (TREE_READONLY (output)
   13152       349419 :               || TYPE_READONLY (TREE_TYPE (output))
   13153       349419 :               || (RECORD_OR_UNION_TYPE_P (TREE_TYPE (output))
   13154          112 :                   && C_TYPE_FIELDS_READONLY (TREE_TYPE (output)))))
   13155            2 :         readonly_error (loc, output, lv_asm);
   13156              : 
   13157       349426 :       constraint = TREE_STRING_POINTER (TREE_VALUE (TREE_PURPOSE (tail)));
   13158       349426 :       oconstraints[i] = constraint;
   13159              : 
   13160       349426 :       if (parse_output_constraint (&constraint, i, ninputs, noutputs,
   13161              :                                    &allows_mem, &allows_reg, &is_inout,
   13162              :                                    nullptr))
   13163              :         {
   13164              :           /* If the operand is going to end up in memory,
   13165              :              mark it addressable.  */
   13166       349418 :           if (!allows_reg && !c_mark_addressable (output))
   13167            3 :             output = error_mark_node;
   13168         1419 :           if (!(!allows_reg && allows_mem)
   13169       347999 :               && output != error_mark_node
   13170       697415 :               && VOID_TYPE_P (TREE_TYPE (output)))
   13171              :             {
   13172            4 :               error_at (loc, "invalid use of void expression");
   13173            4 :               output = error_mark_node;
   13174              :             }
   13175       349418 :           if (allows_reg && current_function_decl == NULL_TREE)
   13176              :             {
   13177            1 :               error_at (loc, "constraint allows registers outside of "
   13178              :                              "a function");
   13179            1 :               output = error_mark_node;
   13180              :             }
   13181              :         }
   13182              :       else
   13183            8 :         output = error_mark_node;
   13184              : 
   13185       349426 :       if (current_function_decl == NULL_TREE && output != error_mark_node)
   13186              :         {
   13187            7 :           if (TREE_SIDE_EFFECTS (output))
   13188              :             {
   13189            0 :               error_at (loc, "side-effects in output operand outside "
   13190              :                              "of a function");
   13191            0 :               output = error_mark_node;
   13192              :             }
   13193              :           else
   13194              :             {
   13195            7 :               tree addr = build_unary_op (loc, ADDR_EXPR, output, false);
   13196            7 :               if (addr == error_mark_node)
   13197              :                 output = error_mark_node;
   13198            7 :               else if (!initializer_constant_valid_p (addr, TREE_TYPE (addr)))
   13199              :                 {
   13200            1 :                   error_at (loc, "output operand outside of a function is not "
   13201              :                                  "constant");
   13202            1 :                   output = error_mark_node;
   13203              :                 }
   13204              :             }
   13205              :         }
   13206       349419 :       else if (output != error_mark_node && strstr (constraint, "-"))
   13207              :         {
   13208            1 :           error_at (loc, "%<-%> modifier used inside of a function");
   13209            1 :           output = error_mark_node;
   13210              :         }
   13211              : 
   13212       349426 :       TREE_VALUE (tail) = output;
   13213              :     }
   13214              : 
   13215       569881 :   for (i = 0, tail = inputs; tail; ++i, tail = TREE_CHAIN (tail))
   13216              :     {
   13217       364771 :       tree input;
   13218              : 
   13219       364771 :       constraint = TREE_STRING_POINTER (TREE_VALUE (TREE_PURPOSE (tail)));
   13220       364771 :       input = TREE_VALUE (tail);
   13221              : 
   13222       364771 :       if (parse_input_constraint (&constraint, i, ninputs, noutputs, 0,
   13223              :                                   oconstraints, &allows_mem, &allows_reg,
   13224              :                                   nullptr))
   13225              :         {
   13226              :           /* If the operand is going to end up in memory,
   13227              :              mark it addressable.  */
   13228       364763 :           if (!allows_reg && allows_mem)
   13229              :             {
   13230         1365 :               input = c_fully_fold (input, false, NULL, true);
   13231              : 
   13232              :               /* Strip the nops as we allow this case.  FIXME, this really
   13233              :                  should be rejected or made deprecated.  */
   13234         1365 :               STRIP_NOPS (input);
   13235         1365 :               if (!c_mark_addressable (input))
   13236            2 :                 input = error_mark_node;
   13237              :             }
   13238              :           else
   13239              :             {
   13240       363398 :               input = c_fully_fold (convert_lvalue_to_rvalue (loc, input,
   13241              :                                                               true, false),
   13242              :                                     false, NULL);
   13243              : 
   13244       363398 :               if (input != error_mark_node && VOID_TYPE_P (TREE_TYPE (input)))
   13245              :                 {
   13246            4 :                   error_at (loc, "invalid use of void expression");
   13247            4 :                   input = error_mark_node;
   13248              :                 }
   13249              :             }
   13250       364763 :           if (allows_reg && current_function_decl == NULL_TREE)
   13251              :             {
   13252            1 :               error_at (loc, "constraint allows registers outside of "
   13253              :                              "a function");
   13254            1 :               input = error_mark_node;
   13255              :             }
   13256       364763 :           if (constraint[0] == ':' && input != error_mark_node)
   13257              :             {
   13258           35 :               tree t = input;
   13259           35 :               STRIP_NOPS (t);
   13260           35 :               if (TREE_CODE (t) != ADDR_EXPR
   13261           35 :                   || !(TREE_CODE (TREE_OPERAND (t, 0)) == FUNCTION_DECL
   13262           23 :                        || (VAR_P (TREE_OPERAND (t, 0))
   13263           21 :                            && is_global_var (TREE_OPERAND (t, 0)))))
   13264              :                 {
   13265            5 :                   error_at (loc, "%<:%> constraint operand is not address "
   13266              :                                  "of a function or non-automatic variable");
   13267            5 :                   input = error_mark_node;
   13268              :                 }
   13269           30 :               else if (TREE_CODE (TREE_OPERAND (t, 0)) == FUNCTION_DECL)
   13270           10 :                 suppress_warning (TREE_OPERAND (t, 0), OPT_Wunused);
   13271              :             }
   13272              :         }
   13273              :       else
   13274            8 :         input = error_mark_node;
   13275              : 
   13276       364771 :       if (current_function_decl == NULL_TREE && input != error_mark_node)
   13277              :         {
   13278           58 :           if (TREE_SIDE_EFFECTS (input))
   13279              :             {
   13280            2 :               error_at (loc, "side-effects in input operand outside "
   13281              :                              "of a function");
   13282            2 :               input = error_mark_node;
   13283              :             }
   13284              :           else
   13285              :             {
   13286           56 :               tree tem = input;
   13287           56 :               if (allows_mem && lvalue_p (input))
   13288            7 :                 tem = build_unary_op (loc, ADDR_EXPR, input, false);
   13289           56 :               if (!initializer_constant_valid_p (tem, TREE_TYPE (tem)))
   13290              :                 {
   13291            2 :                   error_at (loc, "input operand outside of a function is not "
   13292              :                                  "constant");
   13293            2 :                   input = error_mark_node;
   13294              :                 }
   13295              :             }
   13296              :         }
   13297       364713 :       else if (input != error_mark_node && strstr (constraint, "-"))
   13298              :         {
   13299            3 :           error_at (loc, "%<-%> modifier used inside of a function");
   13300            3 :           input = error_mark_node;
   13301              :         }
   13302              : 
   13303       364771 :       TREE_VALUE (tail) = input;
   13304              :     }
   13305              : 
   13306       205110 :   args = build_stmt (loc, ASM_EXPR, string, outputs, inputs, clobbers, labels);
   13307              : 
   13308              :   /* asm statements without outputs, including simple ones, are treated
   13309              :      as volatile.  */
   13310       205110 :   ASM_BASIC_P (args) = simple;
   13311       205110 :   ASM_VOLATILE_P (args) = (noutputs == 0);
   13312       205110 :   ASM_INLINE_P (args) = is_inline;
   13313              : 
   13314       205110 :   return args;
   13315              : }
   13316              : 
   13317              : /* Generate a goto statement to LABEL.  LOC is the location of the
   13318              :    GOTO.  */
   13319              : 
   13320              : tree
   13321        82874 : c_finish_goto_label (location_t loc, tree label)
   13322              : {
   13323        82874 :   tree decl = lookup_label_for_goto (loc, label);
   13324        82874 :   if (!decl)
   13325              :     return NULL_TREE;
   13326        82874 :   TREE_USED (decl) = 1;
   13327        82874 :   mark_decl_used (decl, false);
   13328        82874 :   {
   13329        82874 :     add_stmt (build_predict_expr (PRED_GOTO, NOT_TAKEN));
   13330        82874 :     tree t = build1 (GOTO_EXPR, void_type_node, decl);
   13331        82874 :     SET_EXPR_LOCATION (t, loc);
   13332        82874 :     return add_stmt (t);
   13333              :   }
   13334              : }
   13335              : 
   13336              : /* Generate a computed goto statement to EXPR.  LOC is the location of
   13337              :    the GOTO.  */
   13338              : 
   13339              : tree
   13340          942 : c_finish_goto_ptr (location_t loc, c_expr val)
   13341              : {
   13342          942 :   tree expr = val.value;
   13343          942 :   tree t;
   13344          942 :   pedwarn (loc, OPT_Wpedantic, "ISO C forbids %<goto *expr;%>");
   13345          942 :   if (expr != error_mark_node
   13346          941 :       && !POINTER_TYPE_P (TREE_TYPE (expr))
   13347          947 :       && !null_pointer_constant_p (expr))
   13348              :     {
   13349            2 :       error_at (val.get_location (),
   13350              :                 "computed goto must be pointer type");
   13351            2 :       expr = build_zero_cst (ptr_type_node);
   13352              :     }
   13353          942 :   expr = c_fully_fold (expr, false, NULL);
   13354          942 :   expr = convert (ptr_type_node, expr);
   13355          942 :   t = build1 (GOTO_EXPR, void_type_node, expr);
   13356          942 :   SET_EXPR_LOCATION (t, loc);
   13357          942 :   return add_stmt (t);
   13358              : }
   13359              : 
   13360              : /* Generate a C `return' statement.  RETVAL is the expression for what
   13361              :    to return, or a null pointer for `return;' with no value.  LOC is
   13362              :    the location of the return statement, or the location of the expression,
   13363              :    if the statement has any.  If ORIGTYPE is not NULL_TREE, it
   13364              :    is the original type of RETVAL.  MUSTTAIL_P indicates a musttail
   13365              :    attribute.  */
   13366              : 
   13367              : tree
   13368     34653120 : c_finish_return (location_t loc, tree retval, tree origtype, bool musttail_p)
   13369              : {
   13370     34653120 :   tree valtype = TREE_TYPE (TREE_TYPE (current_function_decl)), ret_stmt;
   13371     34653120 :   bool no_warning = false;
   13372     34653120 :   bool npc = false;
   13373              : 
   13374              :   /* Use the expansion point to handle cases such as returning NULL
   13375              :      in a function returning void.  */
   13376     34653120 :   location_t xloc = expansion_point_location_if_in_system_header (loc);
   13377              : 
   13378     34653120 :   if (TREE_THIS_VOLATILE (current_function_decl))
   13379           23 :     warning_at (xloc, 0,
   13380              :                 "function declared %<noreturn%> has a %<return%> statement");
   13381              : 
   13382     34653120 :   set_musttail_on_return (retval, xloc, musttail_p);
   13383              : 
   13384     34653120 :   if (retval)
   13385              :     {
   13386     34631761 :       tree semantic_type = NULL_TREE;
   13387     34631761 :       npc = null_pointer_constant_p (retval);
   13388     34631761 :       if (TREE_CODE (retval) == EXCESS_PRECISION_EXPR)
   13389              :         {
   13390           92 :           semantic_type = TREE_TYPE (retval);
   13391           92 :           retval = TREE_OPERAND (retval, 0);
   13392              :         }
   13393     34631761 :       retval = c_fully_fold (retval, false, NULL);
   13394     34631761 :       if (semantic_type
   13395     34631761 :           && valtype != NULL_TREE
   13396           92 :           && TREE_CODE (valtype) != VOID_TYPE)
   13397           92 :         retval = build1 (EXCESS_PRECISION_EXPR, semantic_type, retval);
   13398              :     }
   13399              : 
   13400     34631761 :   if (!retval)
   13401              :     {
   13402        21359 :       current_function_returns_null = 1;
   13403        21359 :       if ((warn_return_type >= 0 || flag_isoc99)
   13404        21234 :           && valtype != NULL_TREE && TREE_CODE (valtype) != VOID_TYPE)
   13405              :         {
   13406           46 :           no_warning = true;
   13407           47 :           if (emit_diagnostic (flag_isoc99
   13408              :                                ? diagnostics::kind::permerror
   13409              :                                : diagnostics::kind::warning,
   13410           46 :                                loc, OPT_Wreturn_mismatch,
   13411              :                                "%<return%> with no value,"
   13412              :                                " in function returning non-void"))
   13413           27 :             inform (DECL_SOURCE_LOCATION (current_function_decl),
   13414              :                     "declared here");
   13415              :         }
   13416              :     }
   13417     34631761 :   else if (valtype == NULL_TREE || VOID_TYPE_P (valtype))
   13418              :     {
   13419          325 :       current_function_returns_null = 1;
   13420          325 :       bool warned_here;
   13421          325 :       if (TREE_CODE (TREE_TYPE (retval)) != VOID_TYPE)
   13422           64 :         warned_here = permerror_opt
   13423           64 :           (xloc, OPT_Wreturn_mismatch,
   13424              :            "%<return%> with a value, in function returning void");
   13425              :       else
   13426          261 :         warned_here = pedwarn
   13427          261 :           (xloc, OPT_Wpedantic, "ISO C forbids "
   13428              :            "%<return%> with expression, in function returning void");
   13429          325 :       if (warned_here)
   13430           43 :         inform (DECL_SOURCE_LOCATION (current_function_decl),
   13431              :                 "declared here");
   13432              :     }
   13433              :   else
   13434              :     {
   13435     34631436 :       tree t = convert_for_assignment (loc, UNKNOWN_LOCATION, valtype,
   13436              :                                        retval, origtype, ic_return,
   13437              :                                        npc, NULL_TREE, NULL_TREE, 0);
   13438     34631436 :       tree res = DECL_RESULT (current_function_decl);
   13439     34631436 :       tree inner;
   13440     34631436 :       bool save;
   13441              : 
   13442     34631436 :       current_function_returns_value = 1;
   13443     34631436 :       if (t == error_mark_node)
   13444              :         {
   13445              :           /* Suppress -Wreturn-type for this function.  */
   13446          299 :           if (warn_return_type)
   13447          298 :             suppress_warning (current_function_decl, OPT_Wreturn_type);
   13448          299 :           return NULL_TREE;
   13449              :         }
   13450              : 
   13451     34631137 :       save = in_late_binary_op;
   13452     69254113 :       if (C_BOOLEAN_TYPE_P (TREE_TYPE (res))
   13453     34622171 :           || TREE_CODE (TREE_TYPE (res)) == COMPLEX_TYPE
   13454     69252028 :           || (SCALAR_FLOAT_TYPE_P (TREE_TYPE (t))
   13455       333423 :               && (TREE_CODE (TREE_TYPE (res)) == INTEGER_TYPE
   13456       333423 :                   || TREE_CODE (TREE_TYPE (res)) == ENUMERAL_TYPE)
   13457            0 :               && sanitize_flags_p (SANITIZE_FLOAT_CAST)))
   13458        10246 :         in_late_binary_op = true;
   13459     34631137 :       inner = t = convert (TREE_TYPE (res), t);
   13460     34631137 :       in_late_binary_op = save;
   13461              : 
   13462              :       /* Strip any conversions, additions, and subtractions, and see if
   13463              :          we are returning the address of a local variable.  Warn if so.  */
   13464     37909299 :       while (1)
   13465              :         {
   13466     37909299 :           switch (TREE_CODE (inner))
   13467              :             {
   13468      3276736 :             CASE_CONVERT:
   13469      3276736 :             case NON_LVALUE_EXPR:
   13470      3276736 :             case PLUS_EXPR:
   13471      3276736 :             case POINTER_PLUS_EXPR:
   13472      3276736 :               inner = TREE_OPERAND (inner, 0);
   13473      3276736 :               continue;
   13474              : 
   13475         1431 :             case MINUS_EXPR:
   13476              :               /* If the second operand of the MINUS_EXPR has a pointer
   13477              :                  type (or is converted from it), this may be valid, so
   13478              :                  don't give a warning.  */
   13479         1431 :               {
   13480         1431 :                 tree op1 = TREE_OPERAND (inner, 1);
   13481              : 
   13482         3111 :                 while (!POINTER_TYPE_P (TREE_TYPE (op1))
   13483         3365 :                        && (CONVERT_EXPR_P (op1)
   13484         1426 :                            || TREE_CODE (op1) == NON_LVALUE_EXPR))
   13485          254 :                   op1 = TREE_OPERAND (op1, 0);
   13486              : 
   13487         1431 :                 if (POINTER_TYPE_P (TREE_TYPE (op1)))
   13488              :                   break;
   13489              : 
   13490         1426 :                 inner = TREE_OPERAND (inner, 0);
   13491         1426 :                 continue;
   13492         1426 :               }
   13493              : 
   13494         2937 :             case ADDR_EXPR:
   13495         2937 :               inner = TREE_OPERAND (inner, 0);
   13496              : 
   13497         2937 :               while (REFERENCE_CLASS_P (inner)
   13498         3823 :                      && !INDIRECT_REF_P (inner))
   13499          886 :                 inner = TREE_OPERAND (inner, 0);
   13500              : 
   13501         2937 :               if (DECL_P (inner)
   13502         1614 :                   && !DECL_EXTERNAL (inner)
   13503          978 :                   && DECL_CONTEXT (inner) == current_function_decl
   13504         3159 :                   && POINTER_TYPE_P (TREE_TYPE (TREE_TYPE (current_function_decl))))
   13505              :                 {
   13506          182 :                   if (TREE_CODE (inner) == LABEL_DECL)
   13507            4 :                     warning_at (loc, OPT_Wreturn_local_addr,
   13508              :                                 "function returns address of label");
   13509          178 :                   else if (TREE_CODE (inner) == FUNCTION_DECL
   13510          178 :                            && (C_FUNC_NONLOCAL_CONTEXT (inner)
   13511            9 :                                || !DECL_INITIAL (inner)))
   13512           14 :                     warning_at (loc, OPT_Wreturn_local_addr,
   13513              :                                 "function returns address of nested function "
   13514              :                                 "referencing local context");
   13515          164 :                   else if (TREE_CODE (inner) != FUNCTION_DECL
   13516          156 :                            && !TREE_STATIC (inner))
   13517              :                     {
   13518            9 :                       warning_at (loc, OPT_Wreturn_local_addr,
   13519              :                                   "function returns address of local variable");
   13520            9 :                       tree zero = build_zero_cst (TREE_TYPE (res));
   13521            9 :                       t = build2 (COMPOUND_EXPR, TREE_TYPE (res), t, zero);
   13522              :                     }
   13523              :                 }
   13524              :               break;
   13525              : 
   13526              :             default:
   13527              :               break;
   13528      3276736 :             }
   13529              : 
   13530     34631137 :           break;
   13531              :         }
   13532              : 
   13533     34631137 :       retval = build2 (MODIFY_EXPR, TREE_TYPE (res), res, t);
   13534     34631137 :       SET_EXPR_LOCATION (retval, loc);
   13535              : 
   13536     34631137 :       if (warn_sequence_point)
   13537      2965930 :         verify_sequence_points (retval);
   13538              :     }
   13539              : 
   13540     34652821 :   ret_stmt = build_stmt (loc, RETURN_EXPR, retval);
   13541     34652821 :   if (no_warning)
   13542           46 :     suppress_warning (ret_stmt, OPT_Wreturn_type);
   13543     34652821 :   return add_stmt (ret_stmt);
   13544              : }
   13545              : 
   13546              : struct c_switch {
   13547              :   /* The SWITCH_STMT being built.  */
   13548              :   tree switch_stmt;
   13549              : 
   13550              :   /* The original type of the testing expression, i.e. before the
   13551              :      default conversion is applied.  */
   13552              :   tree orig_type;
   13553              : 
   13554              :   /* A splay-tree mapping the low element of a case range to the high
   13555              :      element, or NULL_TREE if there is no high element.  Used to
   13556              :      determine whether or not a new case label duplicates an old case
   13557              :      label.  We need a tree, rather than simply a hash table, because
   13558              :      of the GNU case range extension.  */
   13559              :   splay_tree cases;
   13560              : 
   13561              :   /* The bindings at the point of the switch.  This is used for
   13562              :      warnings crossing decls when branching to a case label.  */
   13563              :   struct c_spot_bindings *bindings;
   13564              : 
   13565              :   /* Whether the switch includes any break statements.  */
   13566              :   bool break_stmt_seen_p;
   13567              : 
   13568              :   /* The next node on the stack.  */
   13569              :   struct c_switch *next;
   13570              : 
   13571              :   /* Remember whether the controlling expression had boolean type
   13572              :      before integer promotions for the sake of -Wswitch-bool.  */
   13573              :   bool bool_cond_p;
   13574              : };
   13575              : 
   13576              : /* A stack of the currently active switch statements.  The innermost
   13577              :    switch statement is on the top of the stack.  There is no need to
   13578              :    mark the stack for garbage collection because it is only active
   13579              :    during the processing of the body of a function, and we never
   13580              :    collect at that point.  */
   13581              : 
   13582              : struct c_switch *c_switch_stack;
   13583              : 
   13584              : /* Start a C switch statement, testing expression EXP.  Return the new
   13585              :    SWITCH_STMT.  SWITCH_LOC is the location of the `switch'.
   13586              :    SWITCH_COND_LOC is the location of the switch's condition.
   13587              :    EXPLICIT_CAST_P is true if the expression EXP has an explicit cast.  */
   13588              : 
   13589              : tree
   13590        37365 : c_start_switch (location_t switch_loc,
   13591              :                 location_t switch_cond_loc,
   13592              :                 tree exp, bool explicit_cast_p, tree switch_name)
   13593              : {
   13594        37365 :   tree orig_type = error_mark_node;
   13595        37365 :   bool bool_cond_p = false;
   13596        37365 :   struct c_switch *cs;
   13597              : 
   13598        37365 :   if (exp != error_mark_node)
   13599              :     {
   13600        37322 :       orig_type = TREE_TYPE (exp);
   13601              : 
   13602        37322 :       if (!INTEGRAL_TYPE_P (orig_type))
   13603              :         {
   13604           12 :           if (orig_type != error_mark_node)
   13605              :             {
   13606           12 :               error_at (switch_cond_loc, "switch quantity not an integer");
   13607           12 :               orig_type = error_mark_node;
   13608              :             }
   13609           12 :           exp = integer_zero_node;
   13610              :         }
   13611              :       else
   13612              :         {
   13613        37310 :           tree type = TYPE_MAIN_VARIANT (orig_type);
   13614        37310 :           tree e = exp;
   13615              : 
   13616              :           /* Warn if the condition has boolean value.  */
   13617        37313 :           while (TREE_CODE (e) == COMPOUND_EXPR)
   13618            3 :             e = TREE_OPERAND (e, 1);
   13619              : 
   13620        37285 :           if ((C_BOOLEAN_TYPE_P (type)
   13621        37285 :                || truth_value_p (TREE_CODE (e)))
   13622              :               /* Explicit cast to int suppresses this warning.  */
   13623        37332 :               && !(TREE_CODE (type) == INTEGER_TYPE
   13624              :                    && explicit_cast_p))
   13625              :             bool_cond_p = true;
   13626              : 
   13627        37310 :           if (!in_system_header_at (input_location)
   13628        37310 :               && (type == long_integer_type_node
   13629        11991 :                   || type == long_unsigned_type_node))
   13630          289 :             warning_at (switch_cond_loc,
   13631          289 :                         OPT_Wtraditional, "%<long%> switch expression not "
   13632              :                         "converted to %<int%> in ISO C");
   13633              : 
   13634        37310 :           exp = c_fully_fold (exp, false, NULL);
   13635        37310 :           exp = default_conversion (exp);
   13636              : 
   13637        37310 :           if (warn_sequence_point)
   13638         6026 :             verify_sequence_points (exp);
   13639              :         }
   13640              :     }
   13641              : 
   13642              :   /* Add this new SWITCH_STMT to the stack.  */
   13643        37365 :   cs = XNEW (struct c_switch);
   13644        37365 :   cs->switch_stmt = build_stmt (switch_loc, SWITCH_STMT, exp,
   13645              :                                 NULL_TREE, orig_type, NULL_TREE, switch_name);
   13646        37365 :   cs->orig_type = orig_type;
   13647        37365 :   cs->cases = splay_tree_new (case_compare, NULL, NULL);
   13648        37365 :   cs->bindings = c_get_switch_bindings ();
   13649        37365 :   cs->break_stmt_seen_p = false;
   13650        37365 :   cs->bool_cond_p = bool_cond_p;
   13651        37365 :   cs->next = c_switch_stack;
   13652        37365 :   c_switch_stack = cs;
   13653              : 
   13654        37365 :   return add_stmt (cs->switch_stmt);
   13655              : }
   13656              : 
   13657              : /* Process a case label at location LOC, with attributes ATTRS.  */
   13658              : 
   13659              : tree
   13660      1030566 : do_case (location_t loc, tree low_value, tree high_value, tree attrs)
   13661              : {
   13662      1030566 :   tree label = NULL_TREE;
   13663              : 
   13664      1030566 :   if (low_value && TREE_CODE (low_value) != INTEGER_CST)
   13665              :     {
   13666           87 :       low_value = c_fully_fold (low_value, false, NULL);
   13667           87 :       if (TREE_CODE (low_value) == INTEGER_CST)
   13668            9 :         pedwarn (loc, OPT_Wpedantic,
   13669              :                  "case label is not an integer constant expression");
   13670              :     }
   13671              : 
   13672      1030566 :   if (high_value && TREE_CODE (high_value) != INTEGER_CST)
   13673              :     {
   13674            0 :       high_value = c_fully_fold (high_value, false, NULL);
   13675            0 :       if (TREE_CODE (high_value) == INTEGER_CST)
   13676            0 :         pedwarn (input_location, OPT_Wpedantic,
   13677              :                  "case label is not an integer constant expression");
   13678              :     }
   13679              : 
   13680      1030566 :   if (c_switch_stack == NULL)
   13681              :     {
   13682            3 :       if (low_value)
   13683            2 :         error_at (loc, "case label not within a switch statement");
   13684              :       else
   13685            1 :         error_at (loc, "%<default%> label not within a switch statement");
   13686            3 :       return NULL_TREE;
   13687              :     }
   13688              : 
   13689      1030563 :   if (c_check_switch_jump_warnings (c_switch_stack->bindings,
   13690      1030563 :                                     EXPR_LOCATION (c_switch_stack->switch_stmt),
   13691              :                                     loc))
   13692              :     return NULL_TREE;
   13693              : 
   13694      1030551 :   label = c_add_case_label (loc, c_switch_stack->cases,
   13695      1030551 :                             SWITCH_STMT_COND (c_switch_stack->switch_stmt),
   13696              :                             low_value, high_value, attrs);
   13697      1030551 :   if (label == error_mark_node)
   13698          144 :     label = NULL_TREE;
   13699              :   return label;
   13700              : }
   13701              : 
   13702              : /* Finish the switch statement.  TYPE is the original type of the
   13703              :    controlling expression of the switch, or NULL_TREE.  */
   13704              : 
   13705              : void
   13706        37365 : c_finish_switch (tree body, tree type)
   13707              : {
   13708        37365 :   struct c_switch *cs = c_switch_stack;
   13709        37365 :   location_t switch_location;
   13710              : 
   13711        37365 :   SWITCH_STMT_BODY (cs->switch_stmt) = body;
   13712              : 
   13713              :   /* Emit warnings as needed.  */
   13714        37365 :   switch_location = EXPR_LOCATION (cs->switch_stmt);
   13715        43561 :   c_do_switch_warnings (cs->cases, switch_location,
   13716         6196 :                         type ? type : SWITCH_STMT_TYPE (cs->switch_stmt),
   13717        37365 :                         SWITCH_STMT_COND (cs->switch_stmt), cs->bool_cond_p);
   13718        37365 :   if (c_switch_covers_all_cases_p (cs->cases,
   13719        37365 :                                    SWITCH_STMT_TYPE (cs->switch_stmt)))
   13720        33443 :     SWITCH_STMT_ALL_CASES_P (cs->switch_stmt) = 1;
   13721        37365 :   SWITCH_STMT_NO_BREAK_P (cs->switch_stmt) = !cs->break_stmt_seen_p;
   13722              : 
   13723              :   /* Pop the stack.  */
   13724        37365 :   c_switch_stack = cs->next;
   13725        37365 :   splay_tree_delete (cs->cases);
   13726        37365 :   c_release_switch_bindings (cs->bindings);
   13727        37365 :   XDELETE (cs);
   13728        37365 : }
   13729              : 
   13730              : /* Emit an if statement.  IF_LOCUS is the location of the 'if'.  COND,
   13731              :    THEN_BLOCK and ELSE_BLOCK are expressions to be used; ELSE_BLOCK
   13732              :    may be null.  */
   13733              : 
   13734              : void
   13735      1272658 : c_finish_if_stmt (location_t if_locus, tree cond, tree then_block,
   13736              :                   tree else_block)
   13737              : {
   13738      1272658 :   tree stmt;
   13739              : 
   13740      1272658 :   stmt = build3 (COND_EXPR, void_type_node, cond, then_block, else_block);
   13741      1272658 :   SET_EXPR_LOCATION (stmt, if_locus);
   13742      1272658 :   add_stmt (stmt);
   13743      1272658 : }
   13744              : 
   13745              : tree
   13746       187520 : c_finish_bc_stmt (location_t loc, tree label, bool is_break, tree name)
   13747              : {
   13748              :   /* In switch statements break is sometimes stylistically used after
   13749              :      a return statement.  This can lead to spurious warnings about
   13750              :      control reaching the end of a non-void function when it is
   13751              :      inlined.  Note that we are calling block_may_fallthru with
   13752              :      language specific tree nodes; this works because
   13753              :      block_may_fallthru returns true when given something it does not
   13754              :      understand.  */
   13755       187520 :   bool skip = !block_may_fallthru (cur_stmt_list);
   13756              : 
   13757       187520 :   if (is_break)
   13758       174342 :     switch (in_statement & ~IN_NAMED_STMT)
   13759              :       {
   13760            9 :       case 0:
   13761            9 :         error_at (loc, "break statement not within loop or switch");
   13762            9 :         return NULL_TREE;
   13763            4 :       case IN_OMP_BLOCK:
   13764            4 :         error_at (loc, "invalid exit from OpenMP structured block");
   13765            4 :         return NULL_TREE;
   13766           12 :       case IN_OMP_FOR:
   13767           12 :         error_at (loc, "break statement used with OpenMP for loop");
   13768           12 :         return NULL_TREE;
   13769              :       case IN_ITERATION_STMT:
   13770              :       case IN_OBJC_FOREACH:
   13771              :         break;
   13772       158497 :       default:
   13773       158497 :         gcc_assert (in_statement & IN_SWITCH_STMT);
   13774       158497 :         c_switch_stack->break_stmt_seen_p = true;
   13775       158497 :         break;
   13776              :       }
   13777              :   else
   13778        13178 :     switch (in_statement & ~(IN_SWITCH_STMT | IN_NAMED_STMT))
   13779              :       {
   13780            7 :       case 0:
   13781            7 :         error_at (loc, "continue statement not within a loop");
   13782            7 :         return NULL_TREE;
   13783            4 :       case IN_OMP_BLOCK:
   13784            4 :         error_at (loc, "invalid exit from OpenMP structured block");
   13785            4 :         return NULL_TREE;
   13786              :       case IN_ITERATION_STMT:
   13787              :       case IN_OMP_FOR:
   13788              :       case IN_OBJC_FOREACH:
   13789              :         break;
   13790            0 :       default:
   13791            0 :         gcc_unreachable ();
   13792              :       }
   13793              : 
   13794       187484 :   if (skip)
   13795              :     return NULL_TREE;
   13796       187020 :   else if ((in_statement & IN_OBJC_FOREACH)
   13797            0 :            && !(is_break && (in_statement & IN_SWITCH_STMT))
   13798            0 :            && name == NULL_TREE)
   13799              :     {
   13800              :       /* The foreach expander produces low-level code using gotos instead
   13801              :          of a structured loop construct.  */
   13802            0 :       gcc_assert (label);
   13803            0 :       return add_stmt (build_stmt (loc, GOTO_EXPR, label));
   13804              :     }
   13805       187117 :   else if (name && C_DECL_LOOP_NAME (name) && C_DECL_SWITCH_NAME (name))
   13806              :     {
   13807            0 :       label = DECL_CHAIN (name);
   13808            0 :       if (!is_break)
   13809            0 :         label = DECL_CHAIN (label);
   13810              :       /* Foreach expander from some outer level.  */
   13811            0 :       return add_stmt (build_stmt (loc, GOTO_EXPR, label));
   13812              :     }
   13813       200187 :   return add_stmt (build_stmt (loc, is_break ? BREAK_STMT : CONTINUE_STMT,
   13814       187020 :                                name));
   13815              : }
   13816              : 
   13817              : /* A helper routine for c_process_expr_stmt and c_finish_stmt_expr.  */
   13818              : 
   13819              : static void
   13820      6371833 : emit_side_effect_warnings (location_t loc, tree expr)
   13821              : {
   13822      6371833 :   maybe_warn_nodiscard (loc, expr);
   13823      6371833 :   if (!warn_unused_value)
   13824              :     return;
   13825      1302264 :   if (expr == error_mark_node)
   13826              :     ;
   13827      1302189 :   else if (!TREE_SIDE_EFFECTS (expr))
   13828              :     {
   13829         6460 :       if (!VOID_TYPE_P (TREE_TYPE (expr))
   13830         6460 :           && !warning_suppressed_p (expr, OPT_Wunused_value))
   13831           28 :         warning_at (loc, OPT_Wunused_value, "statement with no effect");
   13832              :     }
   13833      1295729 :   else if (TREE_CODE (expr) == COMPOUND_EXPR)
   13834              :     {
   13835              :       tree r = expr;
   13836              :       location_t cloc = loc;
   13837        11989 :       while (TREE_CODE (r) == COMPOUND_EXPR)
   13838              :         {
   13839         6010 :           if (EXPR_HAS_LOCATION (r))
   13840         5480 :             cloc = EXPR_LOCATION (r);
   13841         6010 :           r = TREE_OPERAND (r, 1);
   13842              :         }
   13843         5979 :       if (!TREE_SIDE_EFFECTS (r)
   13844           33 :           && !VOID_TYPE_P (TREE_TYPE (r))
   13845           24 :           && !CONVERT_EXPR_P (r)
   13846           24 :           && !warning_suppressed_p (r, OPT_Wunused_value)
   13847         5991 :           && !warning_suppressed_p (expr, OPT_Wunused_value))
   13848            8 :         warning_at (cloc, OPT_Wunused_value,
   13849              :                     "right-hand operand of comma expression has no effect");
   13850              :     }
   13851              :   else
   13852      1289750 :     warn_if_unused_value (expr, loc);
   13853              : }
   13854              : 
   13855              : /* Process an expression as if it were a complete statement.  Emit
   13856              :    diagnostics, but do not call ADD_STMT.  LOC is the location of the
   13857              :    statement.  */
   13858              : 
   13859              : tree
   13860      6248429 : c_process_expr_stmt (location_t loc, tree expr)
   13861              : {
   13862      6248429 :   tree exprv;
   13863              : 
   13864      6248429 :   if (!expr)
   13865              :     return NULL_TREE;
   13866              : 
   13867      6244097 :   expr = c_fully_fold (expr, false, NULL);
   13868              : 
   13869      6244097 :   if (warn_sequence_point)
   13870      1298056 :     verify_sequence_points (expr);
   13871              : 
   13872      6244097 :   if (TREE_TYPE (expr) != error_mark_node
   13873      6241520 :       && !COMPLETE_OR_VOID_TYPE_P (TREE_TYPE (expr))
   13874      6244097 :       && TREE_CODE (TREE_TYPE (expr)) != ARRAY_TYPE)
   13875            0 :     error_at (loc, "expression statement has incomplete type");
   13876              : 
   13877              :   /* If we're not processing a statement expression, warn about unused values.
   13878              :      Warnings for statement expressions will be emitted later, once we figure
   13879              :      out which is the result.  */
   13880      6244097 :   if (!STATEMENT_LIST_STMT_EXPR (cur_stmt_list)
   13881      6244097 :       && (warn_unused_value || warn_unused_result))
   13882      6158144 :     emit_side_effect_warnings (EXPR_LOC_OR_LOC (expr, loc), expr);
   13883              : 
   13884              :   exprv = expr;
   13885      6282964 :   while (TREE_CODE (exprv) == COMPOUND_EXPR)
   13886        38868 :     exprv = TREE_OPERAND (exprv, 1);
   13887      6255560 :   while (CONVERT_EXPR_P (exprv))
   13888        11464 :     exprv = TREE_OPERAND (exprv, 0);
   13889      6244096 :   if (DECL_P (exprv)
   13890      6244681 :       || handled_component_p (exprv)
   13891     12468377 :       || TREE_CODE (exprv) == ADDR_EXPR)
   13892        20400 :     mark_exp_read (exprv);
   13893              : 
   13894              :   /* If the expression is not of a type to which we cannot assign a line
   13895              :      number, wrap the thing in a no-op NOP_EXPR.  */
   13896      6244096 :   if (DECL_P (expr) || CONSTANT_CLASS_P (expr))
   13897              :     {
   13898        14871 :       expr = build1 (NOP_EXPR, TREE_TYPE (expr), expr);
   13899        14871 :       SET_EXPR_LOCATION (expr, loc);
   13900              :     }
   13901              : 
   13902              :   return expr;
   13903              : }
   13904              : 
   13905              : /* Emit an expression as a statement.  LOC is the location of the
   13906              :    expression.  */
   13907              : 
   13908              : tree
   13909      5947825 : c_finish_expr_stmt (location_t loc, tree expr)
   13910              : {
   13911      5947825 :   if (expr)
   13912      5935263 :     return add_stmt (c_process_expr_stmt (loc, expr));
   13913              :   else
   13914              :     return NULL;
   13915              : }
   13916              : 
   13917              : /* Do the opposite and emit a statement as an expression.  To begin,
   13918              :    create a new binding level and return it.  */
   13919              : 
   13920              : tree
   13921        34875 : c_begin_stmt_expr (void)
   13922              : {
   13923        34875 :   tree ret;
   13924              : 
   13925              :   /* We must force a BLOCK for this level so that, if it is not expanded
   13926              :      later, there is a way to turn off the entire subtree of blocks that
   13927              :      are contained in it.  */
   13928        34875 :   keep_next_level ();
   13929        34875 :   ret = c_begin_compound_stmt (true);
   13930              : 
   13931        34875 :   c_bindings_start_stmt_expr (c_switch_stack == NULL
   13932              :                               ? NULL
   13933              :                               : c_switch_stack->bindings);
   13934              : 
   13935              :   /* Mark the current statement list as belonging to a statement list.  */
   13936        34875 :   STATEMENT_LIST_STMT_EXPR (ret) = 1;
   13937              : 
   13938        34875 :   return ret;
   13939              : }
   13940              : 
   13941              : /* LOC is the location of the compound statement to which this body
   13942              :    belongs.  */
   13943              : 
   13944              : tree
   13945        34875 : c_finish_stmt_expr (location_t loc, tree body)
   13946              : {
   13947        34875 :   tree last, type, tmp, val;
   13948        34875 :   tree *last_p;
   13949              : 
   13950        34875 :   body = c_end_compound_stmt (loc, body, true);
   13951              : 
   13952        34875 :   c_bindings_end_stmt_expr (c_switch_stack == NULL
   13953              :                             ? NULL
   13954              :                             : c_switch_stack->bindings);
   13955              : 
   13956              :   /* Locate the last statement in BODY.  See c_end_compound_stmt
   13957              :      about always returning a BIND_EXPR.  */
   13958        34875 :   last_p = &BIND_EXPR_BODY (body);
   13959        34875 :   last = BIND_EXPR_BODY (body);
   13960              : 
   13961        34875 :  continue_searching:
   13962        34875 :   if (TREE_CODE (last) == STATEMENT_LIST)
   13963              :     {
   13964        26061 :       tree_stmt_iterator l = tsi_last (last);
   13965              : 
   13966        26067 :       while (!tsi_end_p (l) && TREE_CODE (tsi_stmt (l)) == DEBUG_BEGIN_STMT)
   13967            6 :         tsi_prev (&l);
   13968              : 
   13969              :       /* This can happen with degenerate cases like ({ }).  No value.  */
   13970        26061 :       if (tsi_end_p (l))
   13971          389 :         return body;
   13972              : 
   13973              :       /* If we're supposed to generate side effects warnings, process
   13974              :          all of the statements except the last.  */
   13975        25672 :       if (warn_unused_value || warn_unused_result)
   13976              :         {
   13977        25672 :           for (tree_stmt_iterator i = tsi_start (last);
   13978       275711 :                tsi_stmt (i) != tsi_stmt (l); tsi_next (&i))
   13979              :             {
   13980       250039 :               location_t tloc;
   13981       250039 :               tree t = tsi_stmt (i);
   13982              : 
   13983       250039 :               tloc = EXPR_HAS_LOCATION (t) ? EXPR_LOCATION (t) : loc;
   13984       250039 :               emit_side_effect_warnings (tloc, t);
   13985              :             }
   13986              :         }
   13987        25672 :       last_p = tsi_stmt_ptr (l);
   13988        25672 :       last = *last_p;
   13989              :     }
   13990              : 
   13991              :   /* If the end of the list is exception related, then the list was split
   13992              :      by a call to push_cleanup.  Continue searching.  */
   13993        34486 :   if (TREE_CODE (last) == TRY_FINALLY_EXPR
   13994        34486 :       || TREE_CODE (last) == TRY_CATCH_EXPR)
   13995              :     {
   13996            0 :       last_p = &TREE_OPERAND (last, 0);
   13997            0 :       last = *last_p;
   13998            0 :       goto continue_searching;
   13999              :     }
   14000              : 
   14001        34486 :   if (last == error_mark_node)
   14002              :     return last;
   14003              : 
   14004              :   /* In the case that the BIND_EXPR is not necessary, return the
   14005              :      expression out from inside it.  */
   14006        34477 :   if ((last == BIND_EXPR_BODY (body)
   14007              :        /* Skip nested debug stmts.  */
   14008        25671 :        || last == expr_first (BIND_EXPR_BODY (body)))
   14009        45484 :       && BIND_EXPR_VARS (body) == NULL)
   14010              :     {
   14011              :       /* Even if this looks constant, do not allow it in a constant
   14012              :          expression.  */
   14013        10995 :       last = c_wrap_maybe_const (last, true);
   14014              :       /* Do not warn if the return value of a statement expression is
   14015              :          unused.  */
   14016        10995 :       suppress_warning (last, OPT_Wunused);
   14017        10995 :       return last;
   14018              :     }
   14019              : 
   14020              :   /* Extract the type of said expression.  */
   14021        23482 :   type = TREE_TYPE (last);
   14022              : 
   14023              :   /* If we're not returning a value at all, then the BIND_EXPR that
   14024              :      we already have is a fine expression to return.  */
   14025        23482 :   if (!type || VOID_TYPE_P (type))
   14026              :     return body;
   14027              : 
   14028              :   /* Now that we've located the expression containing the value, it seems
   14029              :      silly to make voidify_wrapper_expr repeat the process.  Create a
   14030              :      temporary of the appropriate type and stick it in a TARGET_EXPR.  */
   14031        18158 :   tmp = create_tmp_var_raw (type);
   14032              : 
   14033              :   /* Unwrap a no-op NOP_EXPR as added by c_finish_expr_stmt.  This avoids
   14034              :      tree_expr_nonnegative_p giving up immediately.  */
   14035        18158 :   val = last;
   14036        18158 :   if (TREE_CODE (val) == NOP_EXPR
   14037        18158 :       && TREE_TYPE (val) == TREE_TYPE (TREE_OPERAND (val, 0)))
   14038         3773 :     val = TREE_OPERAND (val, 0);
   14039              : 
   14040        18158 :   *last_p = build2 (MODIFY_EXPR, void_type_node, tmp, val);
   14041        18158 :   SET_EXPR_LOCATION (*last_p, EXPR_LOCATION (last));
   14042              : 
   14043        18158 :   {
   14044        18158 :     tree t = build4 (TARGET_EXPR, type, tmp, body, NULL_TREE, NULL_TREE);
   14045        18158 :     SET_EXPR_LOCATION (t, loc);
   14046        18158 :     return t;
   14047              :   }
   14048              : }
   14049              : 
   14050              : /* Begin and end compound statements.  This is as simple as pushing
   14051              :    and popping new statement lists from the tree.  */
   14052              : 
   14053              : tree
   14054     41187461 : c_begin_compound_stmt (bool do_scope)
   14055              : {
   14056     41187461 :   tree stmt = push_stmt_list ();
   14057     41187461 :   if (do_scope)
   14058     41091407 :     push_scope ();
   14059     41187461 :   return stmt;
   14060              : }
   14061              : 
   14062              : /* End a compound statement.  STMT is the statement.  LOC is the
   14063              :    location of the compound statement-- this is usually the location
   14064              :    of the opening brace.  */
   14065              : 
   14066              : tree
   14067     41187460 : c_end_compound_stmt (location_t loc, tree stmt, bool do_scope)
   14068              : {
   14069     41187460 :   tree block = NULL;
   14070              : 
   14071     41187460 :   if (do_scope)
   14072              :     {
   14073     41091406 :       if (c_dialect_objc ())
   14074            0 :         objc_clear_super_receiver ();
   14075     41091406 :       block = pop_scope ();
   14076              :     }
   14077              : 
   14078     41187460 :   stmt = pop_stmt_list (stmt);
   14079     41187460 :   stmt = c_build_bind_expr (loc, block, stmt);
   14080              : 
   14081              :   /* If this compound statement is nested immediately inside a statement
   14082              :      expression, then force a BIND_EXPR to be created.  Otherwise we'll
   14083              :      do the wrong thing for ({ { 1; } }) or ({ 1; { } }).  In particular,
   14084              :      STATEMENT_LISTs merge, and thus we can lose track of what statement
   14085              :      was really last.  */
   14086     82374920 :   if (building_stmt_list_p ()
   14087     41187375 :       && STATEMENT_LIST_STMT_EXPR (cur_stmt_list)
   14088     41310121 :       && TREE_CODE (stmt) != BIND_EXPR)
   14089              :     {
   14090       120918 :       stmt = build3 (BIND_EXPR, void_type_node, NULL, stmt, NULL);
   14091       120918 :       TREE_SIDE_EFFECTS (stmt) = 1;
   14092       120918 :       SET_EXPR_LOCATION (stmt, loc);
   14093              :     }
   14094              : 
   14095     41187460 :   return stmt;
   14096              : }
   14097              : 
   14098              : /* Queue a cleanup.  CLEANUP is an expression/statement to be executed
   14099              :    when the current scope is exited.  EH_ONLY is true when this is not
   14100              :    meant to apply to normal control flow transfer.  */
   14101              : 
   14102              : void
   14103          131 : push_cleanup (tree decl, tree cleanup, bool eh_only)
   14104              : {
   14105          131 :   enum tree_code code;
   14106          131 :   tree stmt, list;
   14107          131 :   bool stmt_expr;
   14108              : 
   14109          131 :   code = eh_only ? TRY_CATCH_EXPR : TRY_FINALLY_EXPR;
   14110          131 :   stmt = build_stmt (DECL_SOURCE_LOCATION (decl), code, NULL, cleanup);
   14111          131 :   add_stmt (stmt);
   14112          131 :   stmt_expr = STATEMENT_LIST_STMT_EXPR (cur_stmt_list);
   14113          131 :   list = push_stmt_list ();
   14114          131 :   TREE_OPERAND (stmt, 0) = list;
   14115          131 :   STATEMENT_LIST_STMT_EXPR (list) = stmt_expr;
   14116          131 : }
   14117              : 
   14118              : /* Build a vector comparison of ARG0 and ARG1 using CODE opcode
   14119              :    into a value of TYPE type.  Comparison is done via VEC_COND_EXPR.  */
   14120              : 
   14121              : static tree
   14122       101011 : build_vec_cmp (tree_code code, tree type,
   14123              :                tree arg0, tree arg1)
   14124              : {
   14125       101011 :   tree zero_vec = build_zero_cst (type);
   14126       101011 :   tree minus_one_vec = build_minus_one_cst (type);
   14127       101011 :   tree cmp_type = truth_type_for (TREE_TYPE (arg0));
   14128       101011 :   tree cmp = build2 (code, cmp_type, arg0, arg1);
   14129       101011 :   return build3 (VEC_COND_EXPR, type, cmp, minus_one_vec, zero_vec);
   14130              : }
   14131              : 
   14132              : /* Possibly warn about an address of OP never being NULL in a comparison
   14133              :    operation CODE involving null.  */
   14134              : 
   14135              : static void
   14136        51616 : maybe_warn_for_null_address (location_t loc, tree op, tree_code code)
   14137              : {
   14138              :   /* Prevent warnings issued for macro expansion.  */
   14139        51616 :   if (!warn_address
   14140        30255 :       || warning_suppressed_p (op, OPT_Waddress)
   14141        81527 :       || from_macro_expansion_at (loc))
   14142        24415 :     return;
   14143              : 
   14144        27201 :   if (TREE_CODE (op) == NOP_EXPR)
   14145              :     {
   14146              :       /* Allow casts to intptr_t to suppress the warning.  */
   14147         1133 :       tree type = TREE_TYPE (op);
   14148         1133 :       if (TREE_CODE (type) == INTEGER_TYPE)
   14149              :         return;
   14150         1133 :       op = TREE_OPERAND (op, 0);
   14151              :     }
   14152              : 
   14153        27201 :   if (TREE_CODE (op) == POINTER_PLUS_EXPR)
   14154              :     {
   14155              :       /* Allow a cast to void* to suppress the warning.  */
   14156           24 :       tree type = TREE_TYPE (TREE_TYPE (op));
   14157           24 :       if (VOID_TYPE_P (type))
   14158              :         return;
   14159              : 
   14160              :       /* Adding any value to a null pointer, including zero, is undefined
   14161              :          in C.  This includes the expression &p[0] where p is the null
   14162              :          pointer, although &p[0] will have been folded to p by this point
   14163              :          and so not diagnosed.  */
   14164           24 :       if (code == EQ_EXPR)
   14165           22 :         warning_at (loc, OPT_Waddress,
   14166              :                     "the comparison will always evaluate as %<false%> "
   14167              :                     "for the pointer operand in %qE must not be NULL",
   14168              :                     op);
   14169              :       else
   14170            2 :         warning_at (loc, OPT_Waddress,
   14171              :                     "the comparison will always evaluate as %<true%> "
   14172              :                     "for the pointer operand in %qE must not be NULL",
   14173              :                     op);
   14174              : 
   14175           24 :       return;
   14176              :     }
   14177              : 
   14178        27177 :   if (TREE_CODE (op) != ADDR_EXPR)
   14179              :     return;
   14180              : 
   14181          254 :   op = TREE_OPERAND (op, 0);
   14182              : 
   14183          254 :   if (TREE_CODE (op) == IMAGPART_EXPR
   14184          254 :       || TREE_CODE (op) == REALPART_EXPR)
   14185              :     {
   14186              :       /* The address of either complex part may not be null.  */
   14187           14 :       if (code == EQ_EXPR)
   14188            9 :         warning_at (loc, OPT_Waddress,
   14189              :                     "the comparison will always evaluate as %<false%> "
   14190              :                     "for the address of %qE will never be NULL",
   14191              :                     op);
   14192              :       else
   14193            5 :         warning_at (loc, OPT_Waddress,
   14194              :                     "the comparison will always evaluate as %<true%> "
   14195              :                     "for the address of %qE will never be NULL",
   14196              :                     op);
   14197           14 :       return;
   14198              :     }
   14199              : 
   14200              :   /* Set to true in the loop below if OP dereferences is operand.
   14201              :      In such a case the ultimate target need not be a decl for
   14202              :      the null [in]equality test to be constant.  */
   14203              :   bool deref = false;
   14204              : 
   14205              :   /* Get the outermost array or object, or member.  */
   14206          294 :   while (handled_component_p (op))
   14207              :     {
   14208           72 :       if (TREE_CODE (op) == COMPONENT_REF)
   14209              :         {
   14210              :           /* Get the member (its address is never null).  */
   14211           18 :           op = TREE_OPERAND (op, 1);
   14212           18 :           break;
   14213              :         }
   14214              : 
   14215              :       /* Get the outer array/object to refer to in the warning.  */
   14216           54 :       op = TREE_OPERAND (op, 0);
   14217           54 :       deref = true;
   14218              :     }
   14219              : 
   14220          192 :   if ((!deref && !decl_with_nonnull_addr_p (op))
   14221          371 :       || from_macro_expansion_at (loc))
   14222          109 :     return;
   14223              : 
   14224          131 :   bool w;
   14225          131 :   if (code == EQ_EXPR)
   14226           93 :     w = warning_at (loc, OPT_Waddress,
   14227              :                     "the comparison will always evaluate as %<false%> "
   14228              :                     "for the address of %qE will never be NULL",
   14229              :                     op);
   14230              :   else
   14231           38 :     w = warning_at (loc, OPT_Waddress,
   14232              :                     "the comparison will always evaluate as %<true%> "
   14233              :                     "for the address of %qE will never be NULL",
   14234              :                     op);
   14235              : 
   14236          131 :   if (w && DECL_P (op))
   14237          120 :     inform (DECL_SOURCE_LOCATION (op), "%qD declared here", op);
   14238              : }
   14239              : 
   14240              : /* Build a binary-operation expression without default conversions.
   14241              :    CODE is the kind of expression to build.
   14242              :    LOCATION is the operator's location.
   14243              :    This function differs from `build' in several ways:
   14244              :    the data type of the result is computed and recorded in it,
   14245              :    warnings are generated if arg data types are invalid,
   14246              :    special handling for addition and subtraction of pointers is known,
   14247              :    and some optimization is done (operations on narrow ints
   14248              :    are done in the narrower type when that gives the same result).
   14249              :    Constant folding is also done before the result is returned.
   14250              : 
   14251              :    Note that the operands will never have enumeral types, or function
   14252              :    or array types, because either they will have the default conversions
   14253              :    performed or they have both just been converted to some other type in which
   14254              :    the arithmetic is to be done.  */
   14255              : 
   14256              : tree
   14257     16844886 : build_binary_op (location_t location, enum tree_code code,
   14258              :                  tree orig_op0, tree orig_op1, bool convert_p)
   14259              : {
   14260     16844886 :   tree type0, type1, orig_type0, orig_type1;
   14261     16844886 :   tree eptype;
   14262     16844886 :   enum tree_code code0, code1;
   14263     16844886 :   tree op0, op1;
   14264     16844886 :   tree ret = error_mark_node;
   14265     16844886 :   const char *invalid_op_diag;
   14266     16844886 :   bool op0_int_operands, op1_int_operands;
   14267     16844886 :   bool int_const, int_const_or_overflow, int_operands;
   14268              : 
   14269              :   /* Expression code to give to the expression when it is built.
   14270              :      Normally this is CODE, which is what the caller asked for,
   14271              :      but in some special cases we change it.  */
   14272     16844886 :   enum tree_code resultcode = code;
   14273              : 
   14274              :   /* Data type in which the computation is to be performed.
   14275              :      In the simplest cases this is the common type of the arguments.  */
   14276     16844886 :   tree result_type = NULL;
   14277              : 
   14278              :   /* When the computation is in excess precision, the type of the
   14279              :      final EXCESS_PRECISION_EXPR.  */
   14280     16844886 :   tree semantic_result_type = NULL;
   14281              : 
   14282              :   /* Nonzero means operands have already been type-converted
   14283              :      in whatever way is necessary.
   14284              :      Zero means they need to be converted to RESULT_TYPE.  */
   14285     16844886 :   int converted = 0;
   14286              : 
   14287              :   /* Nonzero means create the expression with this type, rather than
   14288              :      RESULT_TYPE.  */
   14289     16844886 :   tree build_type = NULL_TREE;
   14290              : 
   14291              :   /* Nonzero means after finally constructing the expression
   14292              :      convert it to this type.  */
   14293     16844886 :   tree final_type = NULL_TREE;
   14294              : 
   14295              :   /* Nonzero if this is an operation like MIN or MAX which can
   14296              :      safely be computed in short if both args are promoted shorts.
   14297              :      Also implies COMMON.
   14298              :      -1 indicates a bitwise operation; this makes a difference
   14299              :      in the exact conditions for when it is safe to do the operation
   14300              :      in a narrower mode.  */
   14301     16844886 :   int shorten = 0;
   14302              : 
   14303              :   /* Nonzero if this is a comparison operation;
   14304              :      if both args are promoted shorts, compare the original shorts.
   14305              :      Also implies COMMON.  */
   14306     16844886 :   int short_compare = 0;
   14307              : 
   14308              :   /* Nonzero if this is a right-shift operation, which can be computed on the
   14309              :      original short and then promoted if the operand is a promoted short.  */
   14310     16844886 :   int short_shift = 0;
   14311              : 
   14312              :   /* Nonzero means set RESULT_TYPE to the common type of the args.  */
   14313     16844886 :   int common = 0;
   14314              : 
   14315              :   /* True means types are compatible as far as ObjC is concerned.  */
   14316     16844886 :   bool objc_ok;
   14317              : 
   14318              :   /* True means this is an arithmetic operation that may need excess
   14319              :      precision.  */
   14320     16844886 :   bool may_need_excess_precision;
   14321              : 
   14322              :   /* True means this is a boolean operation that converts both its
   14323              :      operands to truth-values.  */
   14324     16844886 :   bool boolean_op = false;
   14325              : 
   14326              :   /* Remember whether we're doing / or %.  */
   14327     16844886 :   bool doing_div_or_mod = false;
   14328              : 
   14329              :   /* Remember whether we're doing << or >>.  */
   14330     16844886 :   bool doing_shift = false;
   14331              : 
   14332              :   /* Tree holding instrumentation expression.  */
   14333     16844886 :   tree instrument_expr = NULL;
   14334              : 
   14335     16844886 :   if (location == UNKNOWN_LOCATION)
   14336           79 :     location = input_location;
   14337              : 
   14338     16844886 :   op0 = orig_op0;
   14339     16844886 :   op1 = orig_op1;
   14340              : 
   14341     16844886 :   op0_int_operands = EXPR_INT_CONST_OPERANDS (orig_op0);
   14342      8143090 :   if (op0_int_operands)
   14343      8143090 :     op0 = remove_c_maybe_const_expr (op0);
   14344     16844886 :   op1_int_operands = EXPR_INT_CONST_OPERANDS (orig_op1);
   14345     11411812 :   if (op1_int_operands)
   14346     11411812 :     op1 = remove_c_maybe_const_expr (op1);
   14347     28256698 :   int_operands = (op0_int_operands && op1_int_operands);
   14348     11411812 :   if (int_operands)
   14349              :     {
   14350     15929681 :       int_const_or_overflow = (TREE_CODE (orig_op0) == INTEGER_CST
   14351      7980007 :                                && TREE_CODE (orig_op1) == INTEGER_CST);
   14352      7949674 :       int_const = (int_const_or_overflow
   14353      7949674 :                    && !TREE_OVERFLOW (orig_op0)
   14354      7949605 :                    && !TREE_OVERFLOW (orig_op1));
   14355              :     }
   14356              :   else
   14357              :     int_const = int_const_or_overflow = false;
   14358              : 
   14359              :   /* Do not apply default conversion in mixed vector/scalar expression.  */
   14360     16844886 :   if (convert_p
   14361     16844886 :       && VECTOR_TYPE_P (TREE_TYPE (op0)) == VECTOR_TYPE_P (TREE_TYPE (op1)))
   14362              :     {
   14363     10132021 :       op0 = default_conversion (op0);
   14364     10132021 :       op1 = default_conversion (op1);
   14365              :     }
   14366              : 
   14367     16844886 :   orig_type0 = type0 = TREE_TYPE (op0);
   14368              : 
   14369     16844886 :   orig_type1 = type1 = TREE_TYPE (op1);
   14370              : 
   14371              :   /* The expression codes of the data types of the arguments tell us
   14372              :      whether the arguments are integers, floating, pointers, etc.  */
   14373     16844886 :   code0 = TREE_CODE (type0);
   14374     16844886 :   code1 = TREE_CODE (type1);
   14375              : 
   14376              :   /* Strip NON_LVALUE_EXPRs, etc., since we aren't using as an lvalue.  */
   14377     16844888 :   STRIP_TYPE_NOPS (op0);
   14378     16844889 :   STRIP_TYPE_NOPS (op1);
   14379              : 
   14380              :   /* If an error was already reported for one of the arguments,
   14381              :      avoid reporting another error.  */
   14382              : 
   14383     16844886 :   if (code0 == ERROR_MARK || code1 == ERROR_MARK)
   14384          710 :     return error_mark_node;
   14385              : 
   14386     16844176 :   if (code0 == POINTER_TYPE
   14387     16844176 :       && reject_gcc_builtin (op0, EXPR_LOCATION (orig_op0)))
   14388           11 :     return error_mark_node;
   14389              : 
   14390     16844165 :   if (code1 == POINTER_TYPE
   14391     16844165 :       && reject_gcc_builtin (op1, EXPR_LOCATION (orig_op1)))
   14392           11 :     return error_mark_node;
   14393              : 
   14394     33688308 :   if ((invalid_op_diag
   14395     16844154 :        = targetm.invalid_binary_op (code, type0, type1)))
   14396              :     {
   14397            0 :       error_at (location, invalid_op_diag);
   14398            0 :       return error_mark_node;
   14399              :     }
   14400              : 
   14401     16844154 :   switch (code)
   14402              :     {
   14403              :     case PLUS_EXPR:
   14404              :     case MINUS_EXPR:
   14405              :     case MULT_EXPR:
   14406              :     case TRUNC_DIV_EXPR:
   14407              :     case CEIL_DIV_EXPR:
   14408              :     case FLOOR_DIV_EXPR:
   14409              :     case ROUND_DIV_EXPR:
   14410              :     case EXACT_DIV_EXPR:
   14411              :       may_need_excess_precision = true;
   14412              :       break;
   14413              : 
   14414      2736493 :     case EQ_EXPR:
   14415      2736493 :     case NE_EXPR:
   14416      2736493 :     case LE_EXPR:
   14417      2736493 :     case GE_EXPR:
   14418      2736493 :     case LT_EXPR:
   14419      2736493 :     case GT_EXPR:
   14420              :       /* Excess precision for implicit conversions of integers to
   14421              :          floating point in C11 and later.  */
   14422      2736493 :       may_need_excess_precision = (flag_isoc11
   14423      2736493 :                                    && (ANY_INTEGRAL_TYPE_P (type0)
   14424       487853 :                                        || ANY_INTEGRAL_TYPE_P (type1)));
   14425              :       break;
   14426              : 
   14427              :     default:
   14428     16844154 :       may_need_excess_precision = false;
   14429              :       break;
   14430              :     }
   14431     16844154 :   if (TREE_CODE (op0) == EXCESS_PRECISION_EXPR)
   14432              :     {
   14433          184 :       op0 = TREE_OPERAND (op0, 0);
   14434          184 :       type0 = TREE_TYPE (op0);
   14435              :     }
   14436     16843970 :   else if (may_need_excess_precision
   14437     16843970 :            && (eptype = excess_precision_type (type0)) != NULL_TREE)
   14438              :     {
   14439          771 :       type0 = eptype;
   14440          771 :       op0 = convert (eptype, op0);
   14441              :     }
   14442     16844154 :   if (TREE_CODE (op1) == EXCESS_PRECISION_EXPR)
   14443              :     {
   14444          889 :       op1 = TREE_OPERAND (op1, 0);
   14445          889 :       type1 = TREE_TYPE (op1);
   14446              :     }
   14447     16843265 :   else if (may_need_excess_precision
   14448     16843265 :            && (eptype = excess_precision_type (type1)) != NULL_TREE)
   14449              :     {
   14450          592 :       type1 = eptype;
   14451          592 :       op1 = convert (eptype, op1);
   14452              :     }
   14453              : 
   14454     16844154 :   objc_ok = objc_compare_types (type0, type1, -3, NULL_TREE);
   14455              : 
   14456              :   /* In case when one of the operands of the binary operation is
   14457              :      a vector and another is a scalar -- convert scalar to vector.  */
   14458     18424071 :   if ((gnu_vector_type_p (type0) && code1 != VECTOR_TYPE)
   14459     18422158 :       || (gnu_vector_type_p (type1) && code0 != VECTOR_TYPE))
   14460              :     {
   14461         2520 :       enum stv_conv convert_flag = scalar_to_vector (location, code, orig_op0,
   14462              :                                                      orig_op1, true);
   14463              : 
   14464         2520 :       switch (convert_flag)
   14465              :         {
   14466           12 :           case stv_error:
   14467           12 :             return error_mark_node;
   14468          594 :           case stv_firstarg:
   14469          594 :             {
   14470          594 :               bool maybe_const = true;
   14471          594 :               tree sc;
   14472          594 :               sc = c_fully_fold (op0, false, &maybe_const);
   14473          594 :               sc = save_expr (sc);
   14474          594 :               sc = convert (TREE_TYPE (type1), sc);
   14475          594 :               op0 = build_vector_from_val (type1, sc);
   14476          594 :               if (!maybe_const)
   14477           93 :                 op0 = c_wrap_maybe_const (op0, true);
   14478          594 :               orig_type0 = type0 = TREE_TYPE (op0);
   14479          594 :               code0 = TREE_CODE (type0);
   14480          594 :               converted = 1;
   14481          594 :               break;
   14482              :             }
   14483         1072 :           case stv_secondarg:
   14484         1072 :             {
   14485         1072 :               bool maybe_const = true;
   14486         1072 :               tree sc;
   14487         1072 :               sc = c_fully_fold (op1, false, &maybe_const);
   14488         1072 :               sc = save_expr (sc);
   14489         1072 :               sc = convert (TREE_TYPE (type0), sc);
   14490         1072 :               op1 = build_vector_from_val (type0, sc);
   14491         1072 :               if (!maybe_const)
   14492           37 :                 op1 = c_wrap_maybe_const (op1, true);
   14493         1072 :               orig_type1 = type1 = TREE_TYPE (op1);
   14494         1072 :               code1 = TREE_CODE (type1);
   14495         1072 :               converted = 1;
   14496         1072 :               break;
   14497              :             }
   14498              :           default:
   14499              :             break;
   14500              :         }
   14501              :     }
   14502              : 
   14503     16844142 :   switch (code)
   14504              :     {
   14505      8636933 :     case PLUS_EXPR:
   14506              :       /* Handle the pointer + int case.  */
   14507      8636933 :       if (code0 == POINTER_TYPE
   14508      1250818 :           && (code1 == INTEGER_TYPE || code1 == BITINT_TYPE))
   14509              :         {
   14510      1250812 :           ret = pointer_int_sum (location, PLUS_EXPR, op0, op1);
   14511      1250812 :           goto return_build_binary_op;
   14512              :         }
   14513      7386121 :       else if (code1 == POINTER_TYPE
   14514         1538 :                && (code0 == INTEGER_TYPE || code0 == BITINT_TYPE))
   14515              :         {
   14516         1532 :           ret = pointer_int_sum (location, PLUS_EXPR, op1, op0);
   14517         1532 :           goto return_build_binary_op;
   14518              :         }
   14519              :       else
   14520              :         common = 1;
   14521              :       break;
   14522              : 
   14523       791536 :     case MINUS_EXPR:
   14524              :       /* Subtraction of two similar pointers.
   14525              :          We must subtract them as integers, then divide by object size.  */
   14526       791536 :       if (code0 == POINTER_TYPE && code1 == POINTER_TYPE
   14527       791536 :           && comp_target_types (location, type0, type1))
   14528              :         {
   14529         3700 :           ret = pointer_diff (location, op0, op1, &instrument_expr);
   14530         3700 :           goto return_build_binary_op;
   14531              :         }
   14532              :       /* Handle pointer minus int.  Just like pointer plus int.  */
   14533       787836 :       else if (code0 == POINTER_TYPE
   14534        16854 :                && (code1 == INTEGER_TYPE || code1 == BITINT_TYPE))
   14535              :         {
   14536        16842 :           ret = pointer_int_sum (location, MINUS_EXPR, op0, op1);
   14537        16842 :           goto return_build_binary_op;
   14538              :         }
   14539              :       else
   14540              :         common = 1;
   14541              :       break;
   14542              : 
   14543              :     case MULT_EXPR:
   14544              :       common = 1;
   14545              :       break;
   14546              : 
   14547       274686 :     case TRUNC_DIV_EXPR:
   14548       274686 :     case CEIL_DIV_EXPR:
   14549       274686 :     case FLOOR_DIV_EXPR:
   14550       274686 :     case ROUND_DIV_EXPR:
   14551       274686 :     case EXACT_DIV_EXPR:
   14552       274686 :       doing_div_or_mod = true;
   14553       274686 :       warn_for_div_by_zero (location, op1);
   14554              : 
   14555       274685 :       if ((code0 == INTEGER_TYPE || code0 == REAL_TYPE
   14556        49647 :            || code0 == FIXED_POINT_TYPE || code0 == BITINT_TYPE
   14557        47633 :            || code0 == COMPLEX_TYPE
   14558        45585 :            || gnu_vector_type_p (type0))
   14559       324331 :           && (code1 == INTEGER_TYPE || code1 == REAL_TYPE
   14560        47214 :               || code1 == FIXED_POINT_TYPE || code1 == BITINT_TYPE
   14561        47047 :               || code1 == COMPLEX_TYPE
   14562        45587 :               || gnu_vector_type_p (type1)))
   14563              :         {
   14564       274681 :           enum tree_code tcode0 = code0, tcode1 = code1;
   14565              : 
   14566       274681 :           if (code0 == COMPLEX_TYPE || code0 == VECTOR_TYPE)
   14567        47632 :             tcode0 = TREE_CODE (TREE_TYPE (TREE_TYPE (op0)));
   14568       274681 :           if (code1 == COMPLEX_TYPE || code1 == VECTOR_TYPE)
   14569        47044 :             tcode1 = TREE_CODE (TREE_TYPE (TREE_TYPE (op1)));
   14570              : 
   14571       274681 :           if (!(((tcode0 == INTEGER_TYPE || tcode0 == BITINT_TYPE
   14572        69631 :                   || (tcode0 == ENUMERAL_TYPE && code0 == VECTOR_TYPE))
   14573       205051 :                  && (tcode1 == INTEGER_TYPE || tcode1 == BITINT_TYPE
   14574        12988 :                      || (tcode1 == ENUMERAL_TYPE && code1 == VECTOR_TYPE)))
   14575        82617 :                 || (tcode0 == FIXED_POINT_TYPE && tcode1 == FIXED_POINT_TYPE)))
   14576              :             resultcode = RDIV_EXPR;
   14577              :           else
   14578              :             /* Although it would be tempting to shorten always here, that
   14579              :                loses on some targets, since the modulo instruction is
   14580              :                undefined if the quotient can't be represented in the
   14581              :                computation mode.  We shorten only if unsigned or if
   14582              :                dividing by something we know != -1.  */
   14583       192064 :             shorten = may_shorten_divmod (op0, op1);
   14584              :           common = 1;
   14585              :         }
   14586              :       break;
   14587              : 
   14588      1586153 :     case BIT_AND_EXPR:
   14589      1586153 :     case BIT_IOR_EXPR:
   14590      1586153 :     case BIT_XOR_EXPR:
   14591      1586153 :       if ((code0 == INTEGER_TYPE || code0 == BITINT_TYPE)
   14592      1050719 :           && (code1 == INTEGER_TYPE || code1 == BITINT_TYPE))
   14593              :         shorten = -1;
   14594              :       /* Allow vector types which are not floating point types.   */
   14595       535470 :       else if (gnu_vector_type_p (type0)
   14596       535393 :                && gnu_vector_type_p (type1)
   14597       535393 :                && !VECTOR_FLOAT_TYPE_P (type0)
   14598      1070860 :                && !VECTOR_FLOAT_TYPE_P (type1))
   14599              :         common = 1;
   14600              :       break;
   14601              : 
   14602        58537 :     case TRUNC_MOD_EXPR:
   14603        58537 :     case FLOOR_MOD_EXPR:
   14604        58537 :       doing_div_or_mod = true;
   14605        58537 :       warn_for_div_by_zero (location, op1);
   14606              : 
   14607        58537 :       if (gnu_vector_type_p (type0)
   14608          297 :           && gnu_vector_type_p (type1)
   14609          297 :           && TREE_CODE (TREE_TYPE (type0)) == INTEGER_TYPE
   14610        58834 :           && TREE_CODE (TREE_TYPE (type1)) == INTEGER_TYPE)
   14611              :         common = 1;
   14612        58240 :       else if ((code0 == INTEGER_TYPE || code0 == BITINT_TYPE)
   14613        58239 :                && (code1 == INTEGER_TYPE || code1 == BITINT_TYPE))
   14614              :         {
   14615              :           /* Although it would be tempting to shorten always here, that loses
   14616              :              on some targets, since the modulo instruction is undefined if the
   14617              :              quotient can't be represented in the computation mode.  We shorten
   14618              :              only if unsigned or if dividing by something we know != -1.  */
   14619        58239 :           shorten = may_shorten_divmod (op0, op1);
   14620        58239 :           common = 1;
   14621              :         }
   14622              :       break;
   14623              : 
   14624       511309 :     case TRUTH_ANDIF_EXPR:
   14625       511309 :     case TRUTH_ORIF_EXPR:
   14626       511309 :     case TRUTH_AND_EXPR:
   14627       511309 :     case TRUTH_OR_EXPR:
   14628       511309 :     case TRUTH_XOR_EXPR:
   14629       511309 :       if ((code0 == INTEGER_TYPE || code0 == POINTER_TYPE
   14630            0 :            || code0 == REAL_TYPE || code0 == COMPLEX_TYPE
   14631            0 :            || code0 == FIXED_POINT_TYPE || code0 == NULLPTR_TYPE
   14632            0 :            || code0 == BITINT_TYPE)
   14633       511309 :           && (code1 == INTEGER_TYPE || code1 == POINTER_TYPE
   14634          163 :               || code1 == REAL_TYPE || code1 == COMPLEX_TYPE
   14635           24 :               || code1 == FIXED_POINT_TYPE || code1 == NULLPTR_TYPE
   14636           22 :               || code1 == BITINT_TYPE))
   14637              :         {
   14638              :           /* Result of these operations is always an int,
   14639              :              but that does not mean the operands should be
   14640              :              converted to ints!  */
   14641       511309 :           result_type = integer_type_node;
   14642       511309 :           if (op0_int_operands)
   14643              :             {
   14644       110481 :               op0 = c_objc_common_truthvalue_conversion (location, orig_op0);
   14645       110481 :               op0 = remove_c_maybe_const_expr (op0);
   14646              :             }
   14647              :           else
   14648       400828 :             op0 = c_objc_common_truthvalue_conversion (location, op0);
   14649       511309 :           if (op1_int_operands)
   14650              :             {
   14651        71481 :               op1 = c_objc_common_truthvalue_conversion (location, orig_op1);
   14652        71481 :               op1 = remove_c_maybe_const_expr (op1);
   14653              :             }
   14654              :           else
   14655       439828 :             op1 = c_objc_common_truthvalue_conversion (location, op1);
   14656              :           converted = 1;
   14657              :           boolean_op = true;
   14658              :         }
   14659       511309 :       if (code == TRUTH_ANDIF_EXPR)
   14660              :         {
   14661       250132 :           int_const_or_overflow = (int_operands
   14662        63296 :                                    && TREE_CODE (orig_op0) == INTEGER_CST
   14663       250148 :                                    && (op0 == truthvalue_false_node
   14664        13222 :                                        || TREE_CODE (orig_op1) == INTEGER_CST));
   14665              :           int_const = (int_const_or_overflow
   14666        63269 :                        && !TREE_OVERFLOW (orig_op0)
   14667        63269 :                        && (op0 == truthvalue_false_node
   14668        13206 :                            || !TREE_OVERFLOW (orig_op1)));
   14669              :         }
   14670       324446 :       else if (code == TRUTH_ORIF_EXPR)
   14671              :         {
   14672       331126 :           int_const_or_overflow = (int_operands
   14673         6831 :                                    && TREE_CODE (orig_op0) == INTEGER_CST
   14674       331149 :                                    && (op0 == truthvalue_true_node
   14675         2146 :                                        || TREE_CODE (orig_op1) == INTEGER_CST));
   14676              :           int_const = (int_const_or_overflow
   14677         6801 :                        && !TREE_OVERFLOW (orig_op0)
   14678         6801 :                        && (op0 == truthvalue_true_node
   14679         2123 :                            || !TREE_OVERFLOW (orig_op1)));
   14680              :         }
   14681              :       break;
   14682              : 
   14683              :       /* Shift operations: result has same type as first operand;
   14684              :          always convert second operand to int.
   14685              :          Also set SHORT_SHIFT if shifting rightward.  */
   14686              : 
   14687       231371 :     case RSHIFT_EXPR:
   14688       231371 :       if (gnu_vector_type_p (type0)
   14689          814 :           && gnu_vector_type_p (type1)
   14690          258 :           && TREE_CODE (TREE_TYPE (type0)) == INTEGER_TYPE
   14691          256 :           && TREE_CODE (TREE_TYPE (type1)) == INTEGER_TYPE
   14692       231627 :           && known_eq (TYPE_VECTOR_SUBPARTS (type0),
   14693              :                        TYPE_VECTOR_SUBPARTS (type1)))
   14694              :         {
   14695              :           result_type = type0;
   14696              :           converted = 1;
   14697              :         }
   14698       231117 :       else if ((code0 == INTEGER_TYPE || code0 == FIXED_POINT_TYPE
   14699         1119 :                 || code0 == BITINT_TYPE
   14700          564 :                 || (gnu_vector_type_p (type0)
   14701          560 :                     && TREE_CODE (TREE_TYPE (type0)) == INTEGER_TYPE))
   14702       232229 :                && (code1 == INTEGER_TYPE || code1 == BITINT_TYPE))
   14703              :         {
   14704       231108 :           doing_shift = true;
   14705       231108 :           if (TREE_CODE (op1) == INTEGER_CST)
   14706              :             {
   14707       201676 :               if (tree_int_cst_sgn (op1) < 0)
   14708              :                 {
   14709          269 :                   int_const = false;
   14710          269 :                   if (c_inhibit_evaluation_warnings == 0)
   14711          129 :                     warning_at (location, OPT_Wshift_count_negative,
   14712              :                                 "right shift count is negative");
   14713              :                 }
   14714       201407 :               else if (code0 == VECTOR_TYPE)
   14715              :                 {
   14716          458 :                   if (compare_tree_int (op1,
   14717          458 :                                         TYPE_PRECISION (TREE_TYPE (type0)))
   14718              :                       >= 0)
   14719              :                     {
   14720           16 :                       int_const = false;
   14721           16 :                       if (c_inhibit_evaluation_warnings == 0)
   14722           16 :                         warning_at (location, OPT_Wshift_count_overflow,
   14723              :                                     "right shift count >= width of vector element");
   14724              :                     }
   14725              :                 }
   14726              :               else
   14727              :                 {
   14728       200949 :                   if (!integer_zerop (op1))
   14729       200591 :                     short_shift = 1;
   14730              : 
   14731       200949 :                   if (compare_tree_int (op1, TYPE_PRECISION (type0)) >= 0)
   14732              :                     {
   14733          584 :                       int_const = false;
   14734          584 :                       if (c_inhibit_evaluation_warnings == 0)
   14735           50 :                         warning_at (location, OPT_Wshift_count_overflow,
   14736              :                                     "right shift count >= width of type");
   14737              :                     }
   14738              :                 }
   14739              :             }
   14740              : 
   14741              :           /* Use the type of the value to be shifted.  */
   14742              :           result_type = type0;
   14743              :           /* Avoid converting op1 to result_type later.  */
   14744              :           converted = 1;
   14745              :         }
   14746              :       break;
   14747              : 
   14748       803154 :     case LSHIFT_EXPR:
   14749       803154 :       if (gnu_vector_type_p (type0)
   14750          596 :           && gnu_vector_type_p (type1)
   14751          316 :           && TREE_CODE (TREE_TYPE (type0)) == INTEGER_TYPE
   14752          314 :           && TREE_CODE (TREE_TYPE (type1)) == INTEGER_TYPE
   14753       803467 :           && known_eq (TYPE_VECTOR_SUBPARTS (type0),
   14754              :                        TYPE_VECTOR_SUBPARTS (type1)))
   14755              :         {
   14756              :           result_type = type0;
   14757              :           converted = 1;
   14758              :         }
   14759       802843 :       else if ((code0 == INTEGER_TYPE || code0 == FIXED_POINT_TYPE
   14760          781 :                 || code0 == BITINT_TYPE
   14761          291 :                 || (gnu_vector_type_p (type0)
   14762          285 :                     && TREE_CODE (TREE_TYPE (type0)) == INTEGER_TYPE))
   14763       803615 :                && (code1 == INTEGER_TYPE || code1 == BITINT_TYPE))
   14764              :         {
   14765       802829 :           doing_shift = true;
   14766       802829 :           if (TREE_CODE (op0) == INTEGER_CST
   14767       438593 :               && tree_int_cst_sgn (op0) < 0
   14768       803578 :               && !TYPE_OVERFLOW_WRAPS (type0))
   14769              :             {
   14770              :               /* Don't reject a left shift of a negative value in a context
   14771              :                  where a constant expression is needed in C90.  */
   14772          712 :               if (flag_isoc99)
   14773          666 :                 int_const = false;
   14774          712 :               if (c_inhibit_evaluation_warnings == 0)
   14775          712 :                 warning_at (location, OPT_Wshift_negative_value,
   14776              :                             "left shift of negative value");
   14777              :             }
   14778       802829 :           if (TREE_CODE (op1) == INTEGER_CST)
   14779              :             {
   14780       730370 :               if (tree_int_cst_sgn (op1) < 0)
   14781              :                 {
   14782          313 :                   int_const = false;
   14783          313 :                   if (c_inhibit_evaluation_warnings == 0)
   14784          135 :                     warning_at (location, OPT_Wshift_count_negative,
   14785              :                                 "left shift count is negative");
   14786              :                 }
   14787       730057 :               else if (code0 == VECTOR_TYPE)
   14788              :                 {
   14789          216 :                   if (compare_tree_int (op1,
   14790          216 :                                         TYPE_PRECISION (TREE_TYPE (type0)))
   14791              :                       >= 0)
   14792              :                     {
   14793            6 :                       int_const = false;
   14794            6 :                       if (c_inhibit_evaluation_warnings == 0)
   14795            6 :                         warning_at (location, OPT_Wshift_count_overflow,
   14796              :                                     "left shift count >= width of vector element");
   14797              :                     }
   14798              :                 }
   14799       729841 :               else if (compare_tree_int (op1, TYPE_PRECISION (type0)) >= 0)
   14800              :                 {
   14801        29733 :                   int_const = false;
   14802        29733 :                   if (c_inhibit_evaluation_warnings == 0)
   14803          113 :                     warning_at (location, OPT_Wshift_count_overflow,
   14804              :                                 "left shift count >= width of type");
   14805              :                 }
   14806       700108 :               else if (TREE_CODE (op0) == INTEGER_CST
   14807       364805 :                        && maybe_warn_shift_overflow (location, op0, op1)
   14808       700736 :                        && flag_isoc99)
   14809              :                 int_const = false;
   14810              :             }
   14811              : 
   14812              :           /* Use the type of the value to be shifted.  */
   14813              :           result_type = type0;
   14814              :           /* Avoid converting op1 to result_type later.  */
   14815              :           converted = 1;
   14816              :         }
   14817              :       break;
   14818              : 
   14819      1738907 :     case EQ_EXPR:
   14820      1738907 :     case NE_EXPR:
   14821      1738907 :       if (gnu_vector_type_p (type0) && gnu_vector_type_p (type1))
   14822              :         {
   14823        41891 :           tree intt;
   14824        41891 :           if (!vector_types_compatible_elements_p (type0, type1))
   14825              :             {
   14826            4 :               error_at (location, "comparing vectors with different "
   14827              :                                   "element types");
   14828            4 :               return error_mark_node;
   14829              :             }
   14830              : 
   14831        41887 :           if (maybe_ne (TYPE_VECTOR_SUBPARTS (type0),
   14832        83774 :                         TYPE_VECTOR_SUBPARTS (type1)))
   14833              :             {
   14834            1 :               error_at (location, "comparing vectors with different "
   14835              :                                   "number of elements");
   14836            1 :               return error_mark_node;
   14837              :             }
   14838              : 
   14839              :           /* It's not precisely specified how the usual arithmetic
   14840              :              conversions apply to the vector types.  Here, we use
   14841              :              the unsigned type if one of the operands is signed and
   14842              :              the other one is unsigned.  */
   14843        41886 :           if (TYPE_UNSIGNED (type0) != TYPE_UNSIGNED (type1))
   14844              :             {
   14845            4 :               if (!TYPE_UNSIGNED (type0))
   14846            4 :                 op0 = build1 (VIEW_CONVERT_EXPR, type1, op0);
   14847              :               else
   14848            0 :                 op1 = build1 (VIEW_CONVERT_EXPR, type0, op1);
   14849            4 :               warning_at (location, OPT_Wsign_compare, "comparison between "
   14850              :                           "types %qT and %qT", type0, type1);
   14851              :             }
   14852              : 
   14853              :           /* Always construct signed integer vector type.  */
   14854        41886 :           if (VECTOR_BOOLEAN_TYPE_P (type0) && VECTOR_BOOLEAN_TYPE_P (type1))
   14855              :             result_type = type0;
   14856              :           else
   14857              :             {
   14858        41886 :               auto nelts = TYPE_VECTOR_SUBPARTS (type0);
   14859              : 
   14860       125658 :               intt = c_common_type_for_size (GET_MODE_BITSIZE
   14861        83772 :                                              (SCALAR_TYPE_MODE
   14862              :                                                 (TREE_TYPE (type0))), 0);
   14863        41886 :               if (!intt)
   14864              :                 {
   14865            0 :                   error_at (location, "could not find an integer type "
   14866              :                                       "of the same size as %qT",
   14867            0 :                             TREE_TYPE (type0));
   14868            0 :                   return error_mark_node;
   14869              :                 }
   14870        41886 :               result_type = build_opaque_vector_type (intt, nelts);
   14871              :             }
   14872        41886 :           converted = 1;
   14873        41886 :           ret = build_vec_cmp (resultcode, result_type, op0, op1);
   14874        41886 :           goto return_build_binary_op;
   14875              :         }
   14876      1697016 :       if (FLOAT_TYPE_P (type0) || FLOAT_TYPE_P (type1))
   14877       254605 :         warning_at (location,
   14878       254605 :                     OPT_Wfloat_equal,
   14879              :                     "comparing floating-point with %<==%> or %<!=%> is unsafe");
   14880              :       /* Result of comparison is always int,
   14881              :          but don't convert the args to int!  */
   14882      1697016 :       build_type = integer_type_node;
   14883      1697016 :       if ((code0 == INTEGER_TYPE || code0 == REAL_TYPE || code0 == BITINT_TYPE
   14884       156567 :            || code0 == FIXED_POINT_TYPE || code0 == COMPLEX_TYPE)
   14885      1575984 :           && (code1 == INTEGER_TYPE || code1 == REAL_TYPE
   14886              :               || code1 == BITINT_TYPE
   14887              :               || code1 == FIXED_POINT_TYPE || code1 == COMPLEX_TYPE))
   14888              :         short_compare = 1;
   14889       121298 :       else if (code0 == POINTER_TYPE
   14890       121298 :                && (code1 == NULLPTR_TYPE
   14891       120921 :                    || null_pointer_constant_p (orig_op1)))
   14892              :         {
   14893        51324 :           maybe_warn_for_null_address (location, op0, code);
   14894        51324 :           result_type = type0;
   14895              :         }
   14896        69974 :       else if (code1 == POINTER_TYPE
   14897        69974 :                && (code0 == NULLPTR_TYPE
   14898        69872 :                    || null_pointer_constant_p (orig_op0)))
   14899              :         {
   14900          292 :           maybe_warn_for_null_address (location, op1, code);
   14901          292 :           result_type = type1;
   14902              :         }
   14903        69682 :       else if (code0 == POINTER_TYPE && code1 == POINTER_TYPE)
   14904              :         {
   14905        69592 :           tree tt0 = TREE_TYPE (type0);
   14906        69592 :           tree tt1 = TREE_TYPE (type1);
   14907        69592 :           addr_space_t as0 = TYPE_ADDR_SPACE (tt0);
   14908        69592 :           addr_space_t as1 = TYPE_ADDR_SPACE (tt1);
   14909        69592 :           addr_space_t as_common = ADDR_SPACE_GENERIC;
   14910              : 
   14911              :           /* Anything compares with void *.  void * compares with anything.
   14912              :              Otherwise, the targets must be compatible
   14913              :              and both must be object or both incomplete.  */
   14914        69592 :           if (comp_target_types (location, type0, type1))
   14915        48260 :             result_type = common_pointer_type (type0, type1, NULL_TREE);
   14916        21332 :           else if (!addr_space_superset (as0, as1, &as_common))
   14917              :             {
   14918            0 :               error_at (location, "comparison of pointers to "
   14919              :                         "disjoint address spaces");
   14920            0 :               return error_mark_node;
   14921              :             }
   14922        21332 :           else if (VOID_TYPE_P (tt0) && !TYPE_ATOMIC (tt0))
   14923              :             {
   14924        21105 :               if (pedantic && TREE_CODE (tt1) == FUNCTION_TYPE)
   14925            4 :                 pedwarn (location, OPT_Wpedantic, "ISO C forbids "
   14926              :                          "comparison of %<void *%> with function pointer");
   14927              :             }
   14928          227 :           else if (VOID_TYPE_P (tt1) && !TYPE_ATOMIC (tt1))
   14929              :             {
   14930          179 :               if (pedantic && TREE_CODE (tt0) == FUNCTION_TYPE)
   14931            4 :                 pedwarn (location, OPT_Wpedantic, "ISO C forbids "
   14932              :                          "comparison of %<void *%> with function pointer");
   14933              :             }
   14934              :           else
   14935              :             /* Avoid warning about the volatile ObjC EH puts on decls.  */
   14936           48 :             if (!objc_ok)
   14937           48 :               pedwarn (location, OPT_Wcompare_distinct_pointer_types,
   14938              :                        "comparison of distinct pointer types lacks a cast");
   14939              : 
   14940        48316 :           if (result_type == NULL_TREE)
   14941              :             {
   14942        21332 :               int qual = ENCODE_QUAL_ADDR_SPACE (as_common);
   14943        21332 :               result_type = c_build_pointer_type
   14944        21332 :                               (c_build_qualified_type (void_type_node, qual));
   14945              :             }
   14946              :         }
   14947           90 :       else if (code0 == POINTER_TYPE
   14948           26 :                && (code1 == INTEGER_TYPE || code1 == BITINT_TYPE))
   14949              :         {
   14950           26 :           result_type = type0;
   14951           26 :           pedwarn (location, 0, "comparison between pointer and integer");
   14952              :         }
   14953           64 :       else if ((code0 == INTEGER_TYPE || code0 == BITINT_TYPE)
   14954           21 :                && code1 == POINTER_TYPE)
   14955              :         {
   14956            8 :           result_type = type1;
   14957            8 :           pedwarn (location, 0, "comparison between pointer and integer");
   14958              :         }
   14959              :       /* 6.5.9: One of the following shall hold:
   14960              :          -- both operands have type nullptr_t;  */
   14961           56 :       else if (code0 == NULLPTR_TYPE && code1 == NULLPTR_TYPE)
   14962              :         {
   14963           22 :           result_type = nullptr_type_node;
   14964              :           /* No need to convert the operands to result_type later.  */
   14965           22 :           converted = 1;
   14966              :         }
   14967              :     /* -- one operand has type nullptr_t and the other is a null pointer
   14968              :        constant.  We will have to convert the former to the type of the
   14969              :        latter, because during gimplification we can't have mismatching
   14970              :        comparison operand type.  We convert from nullptr_t to the other
   14971              :        type, since only nullptr_t can be converted to nullptr_t.  Also,
   14972              :        even a constant 0 is a null pointer constant, so we may have to
   14973              :        create a pointer type from its type.  */
   14974           34 :       else if (code0 == NULLPTR_TYPE && null_pointer_constant_p (orig_op1))
   14975           19 :         result_type = (INTEGRAL_TYPE_P (type1)
   14976           19 :                        ? c_build_pointer_type (type1) : type1);
   14977           15 :       else if (code1 == NULLPTR_TYPE && null_pointer_constant_p (orig_op0))
   14978           11 :         result_type = (INTEGRAL_TYPE_P (type0)
   14979           11 :                        ? c_build_pointer_type (type0) : type0);
   14980      5016430 :       if ((C_BOOLEAN_TYPE_P (TREE_TYPE (orig_op0))
   14981      3319389 :            || truth_value_p (TREE_CODE (orig_op0)))
   14982      3386758 :           ^ (C_BOOLEAN_TYPE_P (TREE_TYPE (orig_op1))
   14983      3386754 :              || truth_value_p (TREE_CODE (orig_op1))))
   14984        71584 :         maybe_warn_bool_compare (location, code, orig_op0, orig_op1);
   14985              :       break;
   14986              : 
   14987       997582 :     case LE_EXPR:
   14988       997582 :     case GE_EXPR:
   14989       997582 :     case LT_EXPR:
   14990       997582 :     case GT_EXPR:
   14991       997582 :       if (gnu_vector_type_p (type0) && gnu_vector_type_p (type1))
   14992              :         {
   14993        59130 :           tree intt;
   14994        59130 :           if (!vector_types_compatible_elements_p (type0, type1))
   14995              :             {
   14996            5 :               error_at (location, "comparing vectors with different "
   14997              :                                   "element types");
   14998            5 :               return error_mark_node;
   14999              :             }
   15000              : 
   15001        59125 :           if (maybe_ne (TYPE_VECTOR_SUBPARTS (type0),
   15002       118250 :                         TYPE_VECTOR_SUBPARTS (type1)))
   15003              :             {
   15004            0 :               error_at (location, "comparing vectors with different "
   15005              :                                   "number of elements");
   15006            0 :               return error_mark_node;
   15007              :             }
   15008              : 
   15009              :           /* It's not precisely specified how the usual arithmetic
   15010              :              conversions apply to the vector types.  Here, we use
   15011              :              the unsigned type if one of the operands is signed and
   15012              :              the other one is unsigned.  */
   15013        59125 :           if (TYPE_UNSIGNED (type0) != TYPE_UNSIGNED (type1))
   15014              :             {
   15015           15 :               if (!TYPE_UNSIGNED (type0))
   15016            8 :                 op0 = build1 (VIEW_CONVERT_EXPR, type1, op0);
   15017              :               else
   15018            7 :                 op1 = build1 (VIEW_CONVERT_EXPR, type0, op1);
   15019           15 :               warning_at (location, OPT_Wsign_compare, "comparison between "
   15020              :                           "types %qT and %qT", type0, type1);
   15021              :             }
   15022              : 
   15023              :           /* Always construct signed integer vector type.  */
   15024       177375 :           intt = c_common_type_for_size (GET_MODE_BITSIZE
   15025       118250 :                                          (SCALAR_TYPE_MODE
   15026              :                                           (TREE_TYPE (type0))), 0);
   15027        59125 :           if (!intt)
   15028              :             {
   15029            0 :               error_at (location, "could not find an integer type "
   15030              :                                   "of the same size as %qT",
   15031            0 :                         TREE_TYPE (type0));
   15032            0 :               return error_mark_node;
   15033              :             }
   15034        59125 :           result_type = build_opaque_vector_type (intt,
   15035        59125 :                                                   TYPE_VECTOR_SUBPARTS (type0));
   15036        59125 :           converted = 1;
   15037        59125 :           ret = build_vec_cmp (resultcode, result_type, op0, op1);
   15038        59125 :           goto return_build_binary_op;
   15039              :         }
   15040       938452 :       build_type = integer_type_node;
   15041       938452 :       if ((code0 == INTEGER_TYPE || code0 == REAL_TYPE
   15042        64962 :            || code0 == BITINT_TYPE || code0 == FIXED_POINT_TYPE)
   15043       874037 :           && (code1 == INTEGER_TYPE || code1 == REAL_TYPE
   15044              :               || code1 == BITINT_TYPE || code1 == FIXED_POINT_TYPE))
   15045              :         short_compare = 1;
   15046        64447 :       else if (code0 == POINTER_TYPE && code1 == POINTER_TYPE)
   15047              :         {
   15048        64380 :           addr_space_t as0 = TYPE_ADDR_SPACE (TREE_TYPE (type0));
   15049        64380 :           addr_space_t as1 = TYPE_ADDR_SPACE (TREE_TYPE (type1));
   15050        64380 :           addr_space_t as_common;
   15051              : 
   15052        64380 :           if (comp_target_types (location, type0, type1))
   15053              :             {
   15054        64215 :               result_type = common_pointer_type (type0, type1, NULL_TREE);
   15055        64215 :               if (!COMPLETE_TYPE_P (TREE_TYPE (type0))
   15056        64215 :                   != !COMPLETE_TYPE_P (TREE_TYPE (type1)))
   15057           32 :                 pedwarn_c99 (location, OPT_Wpedantic,
   15058              :                              "comparison of complete and incomplete pointers");
   15059        64183 :               else if (TREE_CODE (TREE_TYPE (type0)) == FUNCTION_TYPE)
   15060            0 :                 pedwarn (location, OPT_Wpedantic, "ISO C forbids "
   15061              :                          "ordered comparisons of pointers to functions");
   15062        64183 :               else if (null_pointer_constant_p (orig_op0)
   15063        64183 :                        || null_pointer_constant_p (orig_op1))
   15064            8 :                 warning_at (location, OPT_Wextra,
   15065              :                             "ordered comparison of pointer with null pointer");
   15066              : 
   15067              :             }
   15068          165 :           else if (!addr_space_superset (as0, as1, &as_common))
   15069              :             {
   15070            0 :               error_at (location, "comparison of pointers to "
   15071              :                         "disjoint address spaces");
   15072            0 :               return error_mark_node;
   15073              :             }
   15074              :           else
   15075              :             {
   15076          165 :               int qual = ENCODE_QUAL_ADDR_SPACE (as_common);
   15077          165 :               result_type = c_build_pointer_type
   15078          165 :                               (c_build_qualified_type (void_type_node, qual));
   15079          165 :               pedwarn (location, OPT_Wcompare_distinct_pointer_types,
   15080              :                        "comparison of distinct pointer types lacks a cast");
   15081              :             }
   15082              :         }
   15083           67 :       else if (code0 == POINTER_TYPE && null_pointer_constant_p (orig_op1))
   15084              :         {
   15085           17 :           result_type = type0;
   15086           17 :           if (pedantic)
   15087           11 :             pedwarn (location, OPT_Wpedantic,
   15088              :                      "ordered comparison of pointer with integer zero");
   15089            6 :           else if (extra_warnings)
   15090            1 :             warning_at (location, OPT_Wextra,
   15091              :                         "ordered comparison of pointer with integer zero");
   15092              :         }
   15093           50 :       else if (code1 == POINTER_TYPE && null_pointer_constant_p (orig_op0))
   15094              :         {
   15095           12 :           result_type = type1;
   15096           12 :           if (pedantic)
   15097            2 :             pedwarn (location, OPT_Wpedantic,
   15098              :                      "ordered comparison of pointer with integer zero");
   15099           10 :           else if (extra_warnings)
   15100            1 :             warning_at (location, OPT_Wextra,
   15101              :                         "ordered comparison of pointer with integer zero");
   15102              :         }
   15103           38 :       else if (code0 == POINTER_TYPE
   15104           18 :                && (code1 == INTEGER_TYPE || code1 == BITINT_TYPE))
   15105              :         {
   15106           18 :           result_type = type0;
   15107           18 :           pedwarn (location, 0, "comparison between pointer and integer");
   15108              :         }
   15109           20 :       else if ((code0 == INTEGER_TYPE || code0 == BITINT_TYPE)
   15110           20 :                && code1 == POINTER_TYPE)
   15111              :         {
   15112           18 :           result_type = type1;
   15113           18 :           pedwarn (location, 0, "comparison between pointer and integer");
   15114              :         }
   15115              : 
   15116       938452 :       if ((code0 == POINTER_TYPE || code1 == POINTER_TYPE)
   15117        64445 :           && current_function_decl != NULL_TREE
   15118      1002886 :           && sanitize_flags_p (SANITIZE_POINTER_COMPARE))
   15119              :         {
   15120           35 :           op0 = save_expr (c_fully_fold (op0, false, NULL));
   15121           35 :           op1 = save_expr (c_fully_fold (op1, false, NULL));
   15122              : 
   15123           35 :           tree tt = builtin_decl_explicit (BUILT_IN_ASAN_POINTER_COMPARE);
   15124           35 :           instrument_expr = build_call_expr_loc (location, tt, 2, op0, op1);
   15125              :         }
   15126              : 
   15127      2815264 :       if ((C_BOOLEAN_TYPE_P (TREE_TYPE (orig_op0))
   15128      1876812 :            || truth_value_p (TREE_CODE (orig_op0)))
   15129      1876829 :           ^ (C_BOOLEAN_TYPE_P (TREE_TYPE (orig_op1))
   15130      1876829 :              || truth_value_p (TREE_CODE (orig_op1))))
   15131          517 :         maybe_warn_bool_compare (location, code, orig_op0, orig_op1);
   15132              :       break;
   15133              : 
   15134           43 :     case MIN_EXPR:
   15135           43 :     case MAX_EXPR:
   15136              :       /* Used for OpenMP atomics.  */
   15137           43 :       gcc_assert (flag_openmp);
   15138              :       common = 1;
   15139              :       break;
   15140              : 
   15141            0 :     default:
   15142            0 :       gcc_unreachable ();
   15143              :     }
   15144              : 
   15145     15470234 :   if (code0 == ERROR_MARK || code1 == ERROR_MARK)
   15146            0 :     return error_mark_node;
   15147              : 
   15148     15470234 :   if (gnu_vector_type_p (type0)
   15149      1479486 :       && gnu_vector_type_p (type1)
   15150     16948883 :       && (!tree_int_cst_equal (TYPE_SIZE (type0), TYPE_SIZE (type1))
   15151      1478629 :           || !vector_types_compatible_elements_p (type0, type1)))
   15152              :     {
   15153           26 :       gcc_rich_location richloc (location);
   15154           26 :       maybe_range_label_for_tree_type_mismatch
   15155           26 :         label_for_op0 (orig_op0, orig_op1),
   15156           26 :         label_for_op1 (orig_op1, orig_op0);
   15157           26 :       richloc.maybe_add_expr (orig_op0, &label_for_op0, highlight_colors::lhs);
   15158           26 :       richloc.maybe_add_expr (orig_op1, &label_for_op1, highlight_colors::rhs);
   15159           26 :       binary_op_error (&richloc, code, type0, type1);
   15160           26 :       return error_mark_node;
   15161           26 :     }
   15162              : 
   15163     15470208 :   if ((code0 == INTEGER_TYPE || code0 == REAL_TYPE || code0 == COMPLEX_TYPE
   15164      1733830 :        || code0 == FIXED_POINT_TYPE || code0 == BITINT_TYPE
   15165      1665322 :        || gnu_vector_type_p (type0))
   15166     17018176 :       && (code1 == INTEGER_TYPE || code1 == REAL_TYPE || code1 == COMPLEX_TYPE
   15167      1572639 :           || code1 == FIXED_POINT_TYPE || code1 == BITINT_TYPE
   15168      1480732 :           || gnu_vector_type_p (type1)))
   15169              :     {
   15170     15282242 :       bool first_complex = (code0 == COMPLEX_TYPE);
   15171     15282242 :       bool second_complex = (code1 == COMPLEX_TYPE);
   15172     15282242 :       int none_complex = (!first_complex && !second_complex);
   15173              : 
   15174     15282242 :       if (shorten || common || short_compare)
   15175              :         {
   15176     13738146 :           result_type = c_common_type (type0, type1);
   15177     13738146 :           do_warn_double_promotion (result_type, type0, type1,
   15178              :                                     "implicit conversion from %qT to %qT "
   15179              :                                     "to match other operand of binary "
   15180              :                                     "expression",
   15181              :                                     location);
   15182     13738146 :           if (result_type == error_mark_node)
   15183              :             return error_mark_node;
   15184              :         }
   15185              : 
   15186     15282220 :       if (first_complex != second_complex
   15187        82045 :           && (code == PLUS_EXPR
   15188              :               || code == MINUS_EXPR
   15189        82045 :               || code == MULT_EXPR
   15190        17526 :               || (code == TRUNC_DIV_EXPR && first_complex))
   15191        65933 :           && TREE_CODE (TREE_TYPE (result_type)) == REAL_TYPE
   15192     15344474 :           && flag_signed_zeros)
   15193              :         {
   15194              :           /* An operation on mixed real/complex operands must be
   15195              :              handled specially, but the language-independent code can
   15196              :              more easily optimize the plain complex arithmetic if
   15197              :              -fno-signed-zeros.  */
   15198        61942 :           tree real_type = TREE_TYPE (result_type);
   15199        61942 :           tree real, imag;
   15200        61942 :           if (type0 != orig_type0 || type1 != orig_type1)
   15201              :             {
   15202           94 :               gcc_assert (may_need_excess_precision && common);
   15203           94 :               semantic_result_type = c_common_type (orig_type0, orig_type1);
   15204              :             }
   15205        61942 :           if (first_complex)
   15206              :             {
   15207         8253 :               if (TREE_TYPE (op0) != result_type)
   15208         1787 :                 op0 = convert_and_check (location, result_type, op0);
   15209         8253 :               if (TREE_TYPE (op1) != real_type)
   15210         4601 :                 op1 = convert_and_check (location, real_type, op1);
   15211              :             }
   15212              :           else
   15213              :             {
   15214        53689 :               if (TREE_TYPE (op0) != real_type)
   15215         2698 :                 op0 = convert_and_check (location, real_type, op0);
   15216        53689 :               if (TREE_TYPE (op1) != result_type)
   15217         1866 :                 op1 = convert_and_check (location, result_type, op1);
   15218              :             }
   15219        61942 :           if (TREE_CODE (op0) == ERROR_MARK || TREE_CODE (op1) == ERROR_MARK)
   15220            0 :             return error_mark_node;
   15221        61942 :           if (first_complex)
   15222              :             {
   15223         8253 :               op0 = save_expr (op0);
   15224         8253 :               real = build_unary_op (EXPR_LOCATION (orig_op0), REALPART_EXPR,
   15225              :                                      op0, true);
   15226         8253 :               imag = build_unary_op (EXPR_LOCATION (orig_op0), IMAGPART_EXPR,
   15227              :                                      op0, true);
   15228         8253 :               switch (code)
   15229              :                 {
   15230         3488 :                 case MULT_EXPR:
   15231         3488 :                 case TRUNC_DIV_EXPR:
   15232         3488 :                   op1 = save_expr (op1);
   15233         3488 :                   imag = build2 (resultcode, real_type, imag, op1);
   15234              :                   /* Fall through.  */
   15235         8253 :                 case PLUS_EXPR:
   15236         8253 :                 case MINUS_EXPR:
   15237         8253 :                   real = build2 (resultcode, real_type, real, op1);
   15238         8253 :                   break;
   15239            0 :                 default:
   15240            0 :                   gcc_unreachable();
   15241              :                 }
   15242              :             }
   15243              :           else
   15244              :             {
   15245        53689 :               op1 = save_expr (op1);
   15246        53689 :               real = build_unary_op (EXPR_LOCATION (orig_op1), REALPART_EXPR,
   15247              :                                      op1, true);
   15248        53689 :               imag = build_unary_op (EXPR_LOCATION (orig_op1), IMAGPART_EXPR,
   15249              :                                      op1, true);
   15250        53689 :               switch (code)
   15251              :                 {
   15252         2008 :                 case MULT_EXPR:
   15253         2008 :                   op0 = save_expr (op0);
   15254         2008 :                   imag = build2 (resultcode, real_type, op0, imag);
   15255              :                   /* Fall through.  */
   15256        31957 :                 case PLUS_EXPR:
   15257        31957 :                   real = build2 (resultcode, real_type, op0, real);
   15258        31957 :                   break;
   15259        21732 :                 case MINUS_EXPR:
   15260        21732 :                   real = build2 (resultcode, real_type, op0, real);
   15261        21732 :                   imag = build1 (NEGATE_EXPR, real_type, imag);
   15262        21732 :                   break;
   15263            0 :                 default:
   15264            0 :                   gcc_unreachable();
   15265              :                 }
   15266              :             }
   15267        61942 :           ret = build2 (COMPLEX_EXPR, result_type, real, imag);
   15268        61942 :           goto return_build_binary_op;
   15269              :         }
   15270              : 
   15271              :       /* For certain operations (which identify themselves by shorten != 0)
   15272              :          if both args were extended from the same smaller type,
   15273              :          do the arithmetic in that type and then extend.
   15274              : 
   15275              :          shorten !=0 and !=1 indicates a bitwise operation.
   15276              :          For them, this optimization is safe only if
   15277              :          both args are zero-extended or both are sign-extended.
   15278              :          Otherwise, we might change the result.
   15279              :          Eg, (short)-1 | (unsigned short)-1 is (int)-1
   15280              :          but calculated in (unsigned short) it would be (unsigned short)-1.  */
   15281              : 
   15282     15220278 :       if (shorten && none_complex)
   15283              :         {
   15284      1294280 :           final_type = result_type;
   15285      1294280 :           result_type = shorten_binary_op (result_type, op0, op1,
   15286              :                                            shorten == -1);
   15287              :         }
   15288              : 
   15289              :       /* Shifts can be shortened if shifting right.  */
   15290              : 
   15291     15220278 :       if (short_shift)
   15292              :         {
   15293       200591 :           int unsigned_arg;
   15294       200591 :           tree arg0 = get_narrower (op0, &unsigned_arg);
   15295              : 
   15296       200591 :           final_type = result_type;
   15297              : 
   15298       200591 :           if (arg0 == op0 && final_type == TREE_TYPE (op0))
   15299       141108 :             unsigned_arg = TYPE_UNSIGNED (TREE_TYPE (op0));
   15300              : 
   15301       200591 :           if (TYPE_PRECISION (TREE_TYPE (arg0)) < TYPE_PRECISION (result_type)
   15302         2990 :               && tree_int_cst_sgn (op1) > 0
   15303              :               /* We can shorten only if the shift count is less than the
   15304              :                  number of bits in the smaller type size.  */
   15305         2990 :               && compare_tree_int (op1, TYPE_PRECISION (TREE_TYPE (arg0))) < 0
   15306              :               /* We cannot drop an unsigned shift after sign-extension.  */
   15307       203441 :               && (!TYPE_UNSIGNED (final_type) || unsigned_arg))
   15308              :             {
   15309              :               /* Do an unsigned shift if the operand was zero-extended.  */
   15310         2835 :               result_type
   15311         2835 :                 = c_common_signed_or_unsigned_type (unsigned_arg,
   15312         2835 :                                                     TREE_TYPE (arg0));
   15313              :               /* Convert value-to-be-shifted to that type.  */
   15314         2835 :               if (TREE_TYPE (op0) != result_type)
   15315         2835 :                 op0 = convert (result_type, op0);
   15316              :               converted = 1;
   15317              :             }
   15318              :         }
   15319              : 
   15320              :       /* Comparison operations are shortened too but differently.
   15321              :          They identify themselves by setting short_compare = 1.  */
   15322              : 
   15323     15220278 :       if (short_compare)
   15324              :         {
   15325              :           /* Don't write &op0, etc., because that would prevent op0
   15326              :              from being kept in a register.
   15327              :              Instead, make copies of the our local variables and
   15328              :              pass the copies by reference, then copy them back afterward.  */
   15329      2449721 :           tree xop0 = op0, xop1 = op1, xresult_type = result_type;
   15330      2449721 :           enum tree_code xresultcode = resultcode;
   15331      2449721 :           tree val
   15332      2449721 :             = shorten_compare (location, &xop0, &xop1, &xresult_type,
   15333              :                                &xresultcode);
   15334              : 
   15335      2449721 :           if (val != NULL_TREE)
   15336              :             {
   15337        15793 :               ret = val;
   15338        15793 :               goto return_build_binary_op;
   15339              :             }
   15340              : 
   15341      2433928 :           op0 = xop0, op1 = xop1;
   15342      2433928 :           converted = 1;
   15343      2433928 :           resultcode = xresultcode;
   15344              : 
   15345      2433928 :           if (c_inhibit_evaluation_warnings == 0 && !c_in_omp_for)
   15346              :             {
   15347      2286410 :               bool op0_maybe_const = true;
   15348      2286410 :               bool op1_maybe_const = true;
   15349      2286410 :               tree orig_op0_folded, orig_op1_folded;
   15350              : 
   15351      2286410 :               if (in_late_binary_op)
   15352              :                 {
   15353              :                   orig_op0_folded = orig_op0;
   15354              :                   orig_op1_folded = orig_op1;
   15355              :                 }
   15356              :               else
   15357              :                 {
   15358              :                   /* Fold for the sake of possible warnings, as in
   15359              :                      build_conditional_expr.  This requires the
   15360              :                      "original" values to be folded, not just op0 and
   15361              :                      op1.  */
   15362      2277869 :                   c_inhibit_evaluation_warnings++;
   15363      2277869 :                   op0 = c_fully_fold (op0, require_constant_value,
   15364              :                                       &op0_maybe_const);
   15365      2277869 :                   op1 = c_fully_fold (op1, require_constant_value,
   15366              :                                       &op1_maybe_const);
   15367      2277869 :                   c_inhibit_evaluation_warnings--;
   15368      2277869 :                   orig_op0_folded = c_fully_fold (orig_op0,
   15369              :                                                   require_constant_value,
   15370              :                                                   NULL);
   15371      2277869 :                   orig_op1_folded = c_fully_fold (orig_op1,
   15372              :                                                   require_constant_value,
   15373              :                                                   NULL);
   15374              :                 }
   15375              : 
   15376      2286410 :               if (warn_sign_compare)
   15377       376799 :                 warn_for_sign_compare (location, orig_op0_folded,
   15378              :                                        orig_op1_folded, op0, op1,
   15379              :                                        result_type, resultcode);
   15380      2286410 :               if (!in_late_binary_op && !int_operands)
   15381              :                 {
   15382      2101344 :                   if (!op0_maybe_const || TREE_CODE (op0) != INTEGER_CST)
   15383      2097820 :                     op0 = c_wrap_maybe_const (op0, !op0_maybe_const);
   15384      2101344 :                   if (!op1_maybe_const || TREE_CODE (op1) != INTEGER_CST)
   15385       827090 :                     op1 = c_wrap_maybe_const (op1, !op1_maybe_const);
   15386              :                 }
   15387              :             }
   15388              :         }
   15389              :     }
   15390              : 
   15391              :   /* At this point, RESULT_TYPE must be nonzero to avoid an error message.
   15392              :      If CONVERTED is zero, both args will be converted to type RESULT_TYPE.
   15393              :      Then the expression will be built.
   15394              :      It will be given type FINAL_TYPE if that is nonzero;
   15395              :      otherwise, it will be given type RESULT_TYPE.  */
   15396              : 
   15397     15392451 :   if (!result_type)
   15398              :     {
   15399              :       /* Favor showing any expression locations that are available. */
   15400          514 :       op_location_t oploc (location, UNKNOWN_LOCATION);
   15401          514 :       binary_op_rich_location richloc (oploc, orig_op0, orig_op1, true);
   15402          514 :       binary_op_error (&richloc, code, TREE_TYPE (op0), TREE_TYPE (op1));
   15403          514 :       return error_mark_node;
   15404          514 :     }
   15405              : 
   15406     15391937 :   if (build_type == NULL_TREE)
   15407              :     {
   15408     12772270 :       build_type = result_type;
   15409     12772270 :       if ((type0 != orig_type0 || type1 != orig_type1)
   15410          797 :           && !boolean_op)
   15411              :         {
   15412          797 :           gcc_assert (may_need_excess_precision && common);
   15413          797 :           semantic_result_type = c_common_type (orig_type0, orig_type1);
   15414              :         }
   15415              :     }
   15416              : 
   15417     15391937 :   if (!converted)
   15418              :     {
   15419     11410938 :       op0 = ep_convert_and_check (location, result_type, op0,
   15420              :                                   semantic_result_type);
   15421     11410938 :       op1 = ep_convert_and_check (location, result_type, op1,
   15422              :                                   semantic_result_type);
   15423              : 
   15424              :       /* This can happen if one operand has a vector type, and the other
   15425              :          has a different type.  */
   15426     11410938 :       if (TREE_CODE (op0) == ERROR_MARK || TREE_CODE (op1) == ERROR_MARK)
   15427            3 :         return error_mark_node;
   15428              :     }
   15429              : 
   15430     15391934 :   if (sanitize_flags_p ((SANITIZE_SHIFT
   15431              :                          | SANITIZE_DIVIDE
   15432              :                          | SANITIZE_FLOAT_DIVIDE
   15433              :                          | SANITIZE_SI_OVERFLOW))
   15434        23365 :       && current_function_decl != NULL_TREE
   15435        19902 :       && (doing_div_or_mod || doing_shift)
   15436     15394859 :       && !require_constant_value)
   15437              :     {
   15438              :       /* OP0 and/or OP1 might have side-effects.  */
   15439         2869 :       op0 = save_expr (op0);
   15440         2869 :       op1 = save_expr (op1);
   15441         2869 :       op0 = c_fully_fold (op0, false, NULL);
   15442         2869 :       op1 = c_fully_fold (op1, false, NULL);
   15443         2869 :       if (doing_div_or_mod && (sanitize_flags_p ((SANITIZE_DIVIDE
   15444              :                                                   | SANITIZE_FLOAT_DIVIDE
   15445              :                                                   | SANITIZE_SI_OVERFLOW))))
   15446          912 :         instrument_expr = ubsan_instrument_division (location, op0, op1);
   15447         1957 :       else if (doing_shift && sanitize_flags_p (SANITIZE_SHIFT))
   15448         1777 :         instrument_expr = ubsan_instrument_shift (location, code, op0, op1);
   15449              :     }
   15450              : 
   15451              :   /* Treat expressions in initializers specially as they can't trap.  */
   15452     15391934 :   if (int_const_or_overflow)
   15453      7934245 :     ret = (require_constant_value
   15454      7934245 :            ? fold_build2_initializer_loc (location, resultcode, build_type,
   15455              :                                           op0, op1)
   15456      7888126 :            : fold_build2_loc (location, resultcode, build_type, op0, op1));
   15457              :   else
   15458      7457689 :     ret = build2 (resultcode, build_type, op0, op1);
   15459     15391934 :   if (final_type != NULL_TREE)
   15460      1494871 :     ret = convert (final_type, ret);
   15461              : 
   15462     13897063 :  return_build_binary_op:
   15463     16843566 :   gcc_assert (ret != error_mark_node);
   15464     16843566 :   if (TREE_CODE (ret) == INTEGER_CST && !TREE_OVERFLOW (ret) && !int_const)
   15465         1756 :     ret = (int_operands
   15466         1756 :            ? note_integer_operands (ret)
   15467          436 :            : build1 (NOP_EXPR, TREE_TYPE (ret), ret));
   15468     16841810 :   else if (TREE_CODE (ret) != INTEGER_CST && int_operands
   15469        60300 :            && !in_late_binary_op)
   15470        60300 :     ret = note_integer_operands (ret);
   15471     16843566 :   protected_set_expr_location (ret, location);
   15472              : 
   15473     16843566 :   if (instrument_expr != NULL)
   15474         1420 :     ret = fold_build2 (COMPOUND_EXPR, TREE_TYPE (ret),
   15475              :                        instrument_expr, ret);
   15476              : 
   15477     16843566 :   if (semantic_result_type)
   15478          891 :     ret = build1_loc (location, EXCESS_PRECISION_EXPR,
   15479              :                       semantic_result_type, ret);
   15480              : 
   15481              :   return ret;
   15482              : }
   15483              : 
   15484              : 
   15485              : /* Convert EXPR to be a truth-value (type TYPE), validating its type for this
   15486              :    purpose.  LOCATION is the source location for the expression.  */
   15487              : 
   15488              : tree
   15489      4131580 : c_objc_common_truthvalue_conversion (location_t location, tree expr, tree type)
   15490              : {
   15491      4131580 :   bool int_const, int_operands;
   15492              : 
   15493      4131580 :   switch (TREE_CODE (TREE_TYPE (expr)))
   15494              :     {
   15495           72 :     case ARRAY_TYPE:
   15496           72 :       error_at (location, "used array that cannot be converted to pointer where scalar is required");
   15497           72 :       return error_mark_node;
   15498              : 
   15499           86 :     case RECORD_TYPE:
   15500           86 :       error_at (location, "used struct type value where scalar is required");
   15501           86 :       return error_mark_node;
   15502              : 
   15503           83 :     case UNION_TYPE:
   15504           83 :       error_at (location, "used union type value where scalar is required");
   15505           83 :       return error_mark_node;
   15506              : 
   15507           22 :     case VOID_TYPE:
   15508           22 :       error_at (location, "void value not ignored as it ought to be");
   15509           22 :       return error_mark_node;
   15510              : 
   15511        30515 :     case POINTER_TYPE:
   15512        30515 :       if (reject_gcc_builtin (expr))
   15513            3 :         return error_mark_node;
   15514              :       break;
   15515              : 
   15516            0 :     case FUNCTION_TYPE:
   15517            0 :       gcc_unreachable ();
   15518              : 
   15519            8 :     case VECTOR_TYPE:
   15520            8 :       error_at (location, "used vector type where scalar is required");
   15521            8 :       return error_mark_node;
   15522              : 
   15523              :     default:
   15524              :       break;
   15525              :     }
   15526              : 
   15527              :   /* Conversion of a floating constant to boolean goes through here
   15528              :      and yields an integer constant expression.  Otherwise, the result
   15529              :      is only an integer constant expression if the argument is.  */
   15530       898555 :   int_const = ((TREE_CODE (expr) == INTEGER_CST && !TREE_OVERFLOW (expr))
   15531      4131382 :                || ((TREE_CODE (expr) == REAL_CST
   15532      3232453 :                     || TREE_CODE (expr) == COMPLEX_CST)
   15533          374 :                    && (TREE_CODE (type) == BOOLEAN_TYPE
   15534           15 :                        || (TREE_CODE (type) == ENUMERAL_TYPE
   15535            5 :                            && ENUM_UNDERLYING_TYPE (type) != NULL_TREE
   15536            5 :                            && (TREE_CODE (ENUM_UNDERLYING_TYPE (type))
   15537              :                                == BOOLEAN_TYPE)))));
   15538      4131306 :   int_operands = EXPR_INT_CONST_OPERANDS (expr);
   15539       898715 :   if (int_operands && TREE_CODE (expr) != INTEGER_CST)
   15540              :     {
   15541          319 :       expr = remove_c_maybe_const_expr (expr);
   15542          319 :       expr = build2 (NE_EXPR, type, expr,
   15543          319 :                      convert (TREE_TYPE (expr), integer_zero_node));
   15544          319 :       expr = note_integer_operands (expr);
   15545              :     }
   15546              :   else
   15547              :     {
   15548              :       /* ??? Should we also give an error for vectors rather than leaving
   15549              :          those to give errors later?  */
   15550      4130987 :       expr = c_common_truthvalue_conversion (location, expr);
   15551      4130987 :       expr = fold_convert_loc (location, type, expr);
   15552              :     }
   15553              : 
   15554      4131306 :   if (TREE_CODE (expr) == INTEGER_CST && int_operands && !int_const)
   15555              :     {
   15556           76 :       if (TREE_OVERFLOW (expr))
   15557              :         return expr;
   15558              :       else
   15559           76 :         return note_integer_operands (expr);
   15560              :     }
   15561      4131230 :   if (TREE_CODE (expr) == INTEGER_CST && !int_const)
   15562          754 :     return build1 (NOP_EXPR, TREE_TYPE (expr), expr);
   15563              :   return expr;
   15564              : }
   15565              : 
   15566              : 
   15567              : /* Convert EXPR to a contained DECL, updating *TC, *TI and *SE as
   15568              :    required.  */
   15569              : 
   15570              : tree
   15571    119500623 : c_expr_to_decl (tree expr, bool *tc ATTRIBUTE_UNUSED, bool *se)
   15572              : {
   15573    119500623 :   if (TREE_CODE (expr) == COMPOUND_LITERAL_EXPR)
   15574              :     {
   15575          699 :       tree decl = COMPOUND_LITERAL_EXPR_DECL (expr);
   15576              :       /* Executing a compound literal inside a function reinitializes
   15577              :          it.  */
   15578          699 :       if (!TREE_STATIC (decl))
   15579          433 :         *se = true;
   15580          699 :       return decl;
   15581              :     }
   15582              :   else
   15583              :     return expr;
   15584              : }
   15585              : 
   15586              : /* Generate OMP construct CODE, with BODY and CLAUSES as its compound
   15587              :    statement.  LOC is the location of the construct.  */
   15588              : 
   15589              : tree
   15590         2154 : c_finish_omp_construct (location_t loc, enum tree_code code, tree body,
   15591              :                         tree clauses)
   15592              : {
   15593         2154 :   body = c_end_compound_stmt (loc, body, true);
   15594              : 
   15595         2154 :   tree stmt = make_node (code);
   15596         2154 :   TREE_TYPE (stmt) = void_type_node;
   15597         2154 :   OMP_BODY (stmt) = body;
   15598         2154 :   OMP_CLAUSES (stmt) = clauses;
   15599         2154 :   SET_EXPR_LOCATION (stmt, loc);
   15600              : 
   15601         2154 :   return add_stmt (stmt);
   15602              : }
   15603              : 
   15604              : /* Generate OACC_DATA, with CLAUSES and BLOCK as its compound
   15605              :    statement.  LOC is the location of the OACC_DATA.  */
   15606              : 
   15607              : tree
   15608          497 : c_finish_oacc_data (location_t loc, tree clauses, tree block)
   15609              : {
   15610          497 :   tree stmt;
   15611              : 
   15612          497 :   block = c_end_compound_stmt (loc, block, true);
   15613              : 
   15614          497 :   stmt = make_node (OACC_DATA);
   15615          497 :   TREE_TYPE (stmt) = void_type_node;
   15616          497 :   OACC_DATA_CLAUSES (stmt) = clauses;
   15617          497 :   OACC_DATA_BODY (stmt) = block;
   15618          497 :   SET_EXPR_LOCATION (stmt, loc);
   15619              : 
   15620          497 :   return add_stmt (stmt);
   15621              : }
   15622              : 
   15623              : /* Generate OACC_HOST_DATA, with CLAUSES and BLOCK as its compound
   15624              :    statement.  LOC is the location of the OACC_HOST_DATA.  */
   15625              : 
   15626              : tree
   15627           21 : c_finish_oacc_host_data (location_t loc, tree clauses, tree block)
   15628              : {
   15629           21 :   tree stmt;
   15630              : 
   15631           21 :   block = c_end_compound_stmt (loc, block, true);
   15632              : 
   15633           21 :   stmt = make_node (OACC_HOST_DATA);
   15634           21 :   TREE_TYPE (stmt) = void_type_node;
   15635           21 :   OACC_HOST_DATA_CLAUSES (stmt) = clauses;
   15636           21 :   OACC_HOST_DATA_BODY (stmt) = block;
   15637           21 :   SET_EXPR_LOCATION (stmt, loc);
   15638              : 
   15639           21 :   return add_stmt (stmt);
   15640              : }
   15641              : 
   15642              : /* Like c_begin_compound_stmt, except force the retention of the BLOCK.  */
   15643              : 
   15644              : tree
   15645        12003 : c_begin_omp_parallel (void)
   15646              : {
   15647        12003 :   tree block;
   15648              : 
   15649        12003 :   keep_next_level ();
   15650        12003 :   block = c_begin_compound_stmt (true);
   15651              : 
   15652        12003 :   return block;
   15653              : }
   15654              : 
   15655              : /* Generate OMP_PARALLEL, with CLAUSES and BLOCK as its compound
   15656              :    statement.  LOC is the location of the OMP_PARALLEL.  */
   15657              : 
   15658              : tree
   15659         5677 : c_finish_omp_parallel (location_t loc, tree clauses, tree block)
   15660              : {
   15661         5677 :   tree stmt;
   15662              : 
   15663         5677 :   block = c_end_compound_stmt (loc, block, true);
   15664              : 
   15665         5677 :   stmt = make_node (OMP_PARALLEL);
   15666         5677 :   TREE_TYPE (stmt) = void_type_node;
   15667         5677 :   OMP_PARALLEL_CLAUSES (stmt) = clauses;
   15668         5677 :   OMP_PARALLEL_BODY (stmt) = block;
   15669         5677 :   SET_EXPR_LOCATION (stmt, loc);
   15670              : 
   15671         5677 :   return add_stmt (stmt);
   15672              : }
   15673              : 
   15674              : /* Like c_begin_compound_stmt, except force the retention of the BLOCK.  */
   15675              : 
   15676              : tree
   15677          898 : c_begin_omp_task (void)
   15678              : {
   15679          898 :   tree block;
   15680              : 
   15681          898 :   keep_next_level ();
   15682          898 :   block = c_begin_compound_stmt (true);
   15683              : 
   15684          898 :   return block;
   15685              : }
   15686              : 
   15687              : /* Generate OMP_TASK, with CLAUSES and BLOCK as its compound
   15688              :    statement.  LOC is the location of the #pragma.  */
   15689              : 
   15690              : tree
   15691          898 : c_finish_omp_task (location_t loc, tree clauses, tree block)
   15692              : {
   15693          898 :   tree stmt;
   15694              : 
   15695          898 :   block = c_end_compound_stmt (loc, block, true);
   15696              : 
   15697          898 :   stmt = make_node (OMP_TASK);
   15698          898 :   TREE_TYPE (stmt) = void_type_node;
   15699          898 :   OMP_TASK_CLAUSES (stmt) = clauses;
   15700          898 :   OMP_TASK_BODY (stmt) = block;
   15701          898 :   SET_EXPR_LOCATION (stmt, loc);
   15702              : 
   15703          898 :   return add_stmt (stmt);
   15704              : }
   15705              : 
   15706              : /* Generate GOMP_cancel call for #pragma omp cancel.  */
   15707              : 
   15708              : void
   15709          213 : c_finish_omp_cancel (location_t loc, tree clauses)
   15710              : {
   15711          213 :   tree fn = builtin_decl_explicit (BUILT_IN_GOMP_CANCEL);
   15712          213 :   int mask = 0;
   15713          213 :   if (omp_find_clause (clauses, OMP_CLAUSE_PARALLEL))
   15714              :     mask = 1;
   15715          150 :   else if (omp_find_clause (clauses, OMP_CLAUSE_FOR))
   15716              :     mask = 2;
   15717          101 :   else if (omp_find_clause (clauses, OMP_CLAUSE_SECTIONS))
   15718              :     mask = 4;
   15719           58 :   else if (omp_find_clause (clauses, OMP_CLAUSE_TASKGROUP))
   15720              :     mask = 8;
   15721              :   else
   15722              :     {
   15723            0 :       error_at (loc, "%<#pragma omp cancel%> must specify one of "
   15724              :                      "%<parallel%>, %<for%>, %<sections%> or %<taskgroup%> "
   15725              :                      "clauses");
   15726            0 :       return;
   15727              :     }
   15728          213 :   tree ifc = omp_find_clause (clauses, OMP_CLAUSE_IF);
   15729          213 :   if (ifc != NULL_TREE)
   15730              :     {
   15731           31 :       if (OMP_CLAUSE_IF_MODIFIER (ifc) != ERROR_MARK
   15732           31 :           && OMP_CLAUSE_IF_MODIFIER (ifc) != VOID_CST)
   15733            2 :         error_at (OMP_CLAUSE_LOCATION (ifc),
   15734              :                   "expected %<cancel%> %<if%> clause modifier");
   15735              :       else
   15736              :         {
   15737           29 :           tree ifc2 = omp_find_clause (OMP_CLAUSE_CHAIN (ifc), OMP_CLAUSE_IF);
   15738           29 :           if (ifc2 != NULL_TREE)
   15739              :             {
   15740            1 :               gcc_assert (OMP_CLAUSE_IF_MODIFIER (ifc) == VOID_CST
   15741              :                           && OMP_CLAUSE_IF_MODIFIER (ifc2) != ERROR_MARK
   15742              :                           && OMP_CLAUSE_IF_MODIFIER (ifc2) != VOID_CST);
   15743            1 :               error_at (OMP_CLAUSE_LOCATION (ifc2),
   15744              :                         "expected %<cancel%> %<if%> clause modifier");
   15745              :             }
   15746              :         }
   15747              : 
   15748           31 :       tree type = TREE_TYPE (OMP_CLAUSE_IF_EXPR (ifc));
   15749           62 :       ifc = fold_build2_loc (OMP_CLAUSE_LOCATION (ifc), NE_EXPR,
   15750           31 :                              boolean_type_node, OMP_CLAUSE_IF_EXPR (ifc),
   15751              :                              build_zero_cst (type));
   15752              :     }
   15753              :   else
   15754          182 :     ifc = boolean_true_node;
   15755          213 :   tree stmt = build_call_expr_loc (loc, fn, 2,
   15756          213 :                                    build_int_cst (integer_type_node, mask),
   15757              :                                    ifc);
   15758          213 :   add_stmt (stmt);
   15759              : }
   15760              : 
   15761              : /* Generate GOMP_cancellation_point call for
   15762              :    #pragma omp cancellation point.  */
   15763              : 
   15764              : void
   15765          167 : c_finish_omp_cancellation_point (location_t loc, tree clauses)
   15766              : {
   15767          167 :   tree fn = builtin_decl_explicit (BUILT_IN_GOMP_CANCELLATION_POINT);
   15768          167 :   int mask = 0;
   15769          167 :   if (omp_find_clause (clauses, OMP_CLAUSE_PARALLEL))
   15770              :     mask = 1;
   15771          123 :   else if (omp_find_clause (clauses, OMP_CLAUSE_FOR))
   15772              :     mask = 2;
   15773           88 :   else if (omp_find_clause (clauses, OMP_CLAUSE_SECTIONS))
   15774              :     mask = 4;
   15775           53 :   else if (omp_find_clause (clauses, OMP_CLAUSE_TASKGROUP))
   15776              :     mask = 8;
   15777              :   else
   15778              :     {
   15779            1 :       error_at (loc, "%<#pragma omp cancellation point%> must specify one of "
   15780              :                      "%<parallel%>, %<for%>, %<sections%> or %<taskgroup%> "
   15781              :                      "clauses");
   15782            1 :       return;
   15783              :     }
   15784          166 :   tree stmt = build_call_expr_loc (loc, fn, 1,
   15785          166 :                                    build_int_cst (integer_type_node, mask));
   15786          166 :   add_stmt (stmt);
   15787              : }
   15788              : 
   15789              : /* Helper function for handle_omp_array_sections.  Called recursively
   15790              :    to handle multiple array-section-subscripts.  C is the clause,
   15791              :    T current expression (initially OMP_CLAUSE_DECL), which is either
   15792              :    a TREE_LIST for array-section-subscript (TREE_PURPOSE is low-bound
   15793              :    expression if specified, TREE_VALUE length expression if specified,
   15794              :    TREE_CHAIN is what it has been specified after, or some decl.
   15795              :    TYPES vector is populated with array section types, MAYBE_ZERO_LEN
   15796              :    set to true if any of the array-section-subscript could have length
   15797              :    of zero (explicit or implicit), FIRST_NON_ONE is the index of the
   15798              :    first array-section-subscript which is known not to have length
   15799              :    of one.  Given say:
   15800              :    map(a[:b][2:1][:c][:2][:d][e:f][2:5])
   15801              :    FIRST_NON_ONE will be 3, array-section-subscript [:b], [2:1] and [:c]
   15802              :    all are or may have length of 1, array-section-subscript [:2] is the
   15803              :    first one known not to have length 1.  For array-section-subscript
   15804              :    <= FIRST_NON_ONE we diagnose non-contiguous arrays if low bound isn't
   15805              :    0 or length isn't the array domain max + 1, for > FIRST_NON_ONE we
   15806              :    can if MAYBE_ZERO_LEN is false.  MAYBE_ZERO_LEN will be true in the above
   15807              :    case though, as some lengths could be zero.  */
   15808              : 
   15809              : static tree
   15810         6394 : handle_omp_array_sections_1 (tree c, tree t, vec<tree> &types,
   15811              :                              bool &maybe_zero_len, unsigned int &first_non_one,
   15812              :                              enum c_omp_region_type ort)
   15813              : {
   15814         6394 :   tree ret, low_bound, length, type;
   15815         6394 :   bool openacc = (ort & C_ORT_ACC) != 0;
   15816         6394 :   if (TREE_CODE (t) != OMP_ARRAY_SECTION)
   15817              :     {
   15818         2978 :       if (error_operand_p (t))
   15819            2 :         return error_mark_node;
   15820         2976 :       c_omp_address_inspector ai (OMP_CLAUSE_LOCATION (c), t);
   15821         2976 :       ret = t;
   15822         2976 :       if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_AFFINITY
   15823         2877 :           && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_DEPEND
   15824         5539 :           && TYPE_ATOMIC (strip_array_types (TREE_TYPE (t))))
   15825              :         {
   15826            6 :           error_at (OMP_CLAUSE_LOCATION (c), "%<_Atomic%> %qE in %qs clause",
   15827            6 :                     t, omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   15828            6 :           return error_mark_node;
   15829              :         }
   15830         2970 :       if (!ai.check_clause (c))
   15831            0 :         return error_mark_node;
   15832         2970 :       else if (ai.component_access_p ()
   15833         3271 :                && (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP
   15834           15 :                    || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_TO
   15835           11 :                    || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_FROM))
   15836          301 :         t = ai.get_root_term (true);
   15837              :       else
   15838         2669 :         t = ai.unconverted_ref_origin ();
   15839         2970 :       if (t == error_mark_node)
   15840              :         return error_mark_node;
   15841         2970 :       if (!VAR_P (t)
   15842          741 :           && (ort == C_ORT_ACC || !EXPR_P (t))
   15843          738 :           && TREE_CODE (t) != PARM_DECL)
   15844              :         {
   15845            5 :           if (DECL_P (t))
   15846            5 :             error_at (OMP_CLAUSE_LOCATION (c),
   15847              :                       "%qD is not a variable in %qs clause", t,
   15848            5 :                       omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   15849              :           else
   15850            0 :             error_at (OMP_CLAUSE_LOCATION (c),
   15851              :                       "%qE is not a variable in %qs clause", t,
   15852            0 :                       omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   15853            5 :           return error_mark_node;
   15854              :         }
   15855         2965 :       else if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_AFFINITY
   15856         2867 :                && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_DEPEND
   15857         5519 :                && TYPE_ATOMIC (TREE_TYPE (t)))
   15858              :         {
   15859            0 :           error_at (OMP_CLAUSE_LOCATION (c), "%<_Atomic%> %qD in %qs clause",
   15860            0 :                     t, omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   15861            0 :           return error_mark_node;
   15862              :         }
   15863         2965 :       else if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_AFFINITY
   15864         2867 :                && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_DEPEND
   15865         2554 :                && VAR_P (t)
   15866         4971 :                && DECL_THREAD_LOCAL_P (t))
   15867              :         {
   15868            3 :           error_at (OMP_CLAUSE_LOCATION (c),
   15869              :                     "%qD is threadprivate variable in %qs clause", t,
   15870            3 :                     omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   15871            3 :           return error_mark_node;
   15872              :         }
   15873         2962 :       if ((OMP_CLAUSE_CODE (c) == OMP_CLAUSE_AFFINITY
   15874         2864 :            || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND)
   15875          411 :           && TYPE_ATOMIC (TREE_TYPE (t))
   15876         2964 :           && POINTER_TYPE_P (TREE_TYPE (t)))
   15877              :         {
   15878              :           /* If the array section is pointer based and the pointer
   15879              :              itself is _Atomic qualified, we need to atomically load
   15880              :              the pointer.  */
   15881            2 :           ret = convert_lvalue_to_rvalue (OMP_CLAUSE_LOCATION (c),
   15882              :                                           ret, false, false);
   15883              :         }
   15884         2962 :       return ret;
   15885         2976 :     }
   15886              : 
   15887         3416 :   ret = handle_omp_array_sections_1 (c, TREE_OPERAND (t, 0), types,
   15888              :                                      maybe_zero_len, first_non_one, ort);
   15889         3416 :   if (ret == error_mark_node || ret == NULL_TREE)
   15890              :     return ret;
   15891              : 
   15892         3351 :   type = TREE_TYPE (ret);
   15893         3351 :   low_bound = TREE_OPERAND (t, 1);
   15894         3351 :   length = TREE_OPERAND (t, 2);
   15895              : 
   15896         3351 :   if (low_bound == error_mark_node || length == error_mark_node)
   15897              :     return error_mark_node;
   15898              : 
   15899         3351 :   if (low_bound && !INTEGRAL_TYPE_P (TREE_TYPE (low_bound)))
   15900              :     {
   15901           13 :       error_at (OMP_CLAUSE_LOCATION (c),
   15902              :                 "low bound %qE of array section does not have integral type",
   15903              :                 low_bound);
   15904           13 :       return error_mark_node;
   15905              :     }
   15906         3338 :   if (length && !INTEGRAL_TYPE_P (TREE_TYPE (length)))
   15907              :     {
   15908           12 :       error_at (OMP_CLAUSE_LOCATION (c),
   15909              :                 "length %qE of array section does not have integral type",
   15910              :                 length);
   15911           12 :       return error_mark_node;
   15912              :     }
   15913         3326 :   if (low_bound
   15914         2742 :       && TREE_CODE (low_bound) == INTEGER_CST
   15915         5779 :       && TYPE_PRECISION (TREE_TYPE (low_bound))
   15916         2453 :          > TYPE_PRECISION (sizetype))
   15917            0 :     low_bound = fold_convert (sizetype, low_bound);
   15918         3326 :   if (length
   15919         3138 :       && TREE_CODE (length) == INTEGER_CST
   15920         5519 :       && TYPE_PRECISION (TREE_TYPE (length))
   15921         2193 :          > TYPE_PRECISION (sizetype))
   15922            0 :     length = fold_convert (sizetype, length);
   15923         3326 :   if (low_bound == NULL_TREE)
   15924          584 :     low_bound = integer_zero_node;
   15925         3326 :   if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP
   15926         3326 :       && (OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_ATTACH
   15927         1936 :           || OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_DETACH))
   15928              :     {
   15929           10 :       if (length != integer_one_node)
   15930              :         {
   15931            6 :           error_at (OMP_CLAUSE_LOCATION (c),
   15932              :                     "expected single pointer in %qs clause",
   15933              :                     user_omp_clause_code_name (c, openacc));
   15934            6 :           return error_mark_node;
   15935              :         }
   15936              :     }
   15937         3320 :   if (length != NULL_TREE)
   15938              :     {
   15939         3136 :       if (!integer_nonzerop (length))
   15940              :         {
   15941          974 :           if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_AFFINITY
   15942              :               || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND
   15943              :               || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION
   15944              :               || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_IN_REDUCTION
   15945              :               || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_TASK_REDUCTION)
   15946              :             {
   15947          180 :               if (integer_zerop (length))
   15948              :                 {
   15949           12 :                   error_at (OMP_CLAUSE_LOCATION (c),
   15950              :                             "zero length array section in %qs clause",
   15951           12 :                             omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   15952           12 :                   return error_mark_node;
   15953              :                 }
   15954              :             }
   15955              :           else
   15956          794 :             maybe_zero_len = true;
   15957              :         }
   15958         3124 :       if (first_non_one == types.length ()
   15959         3124 :           && (TREE_CODE (length) != INTEGER_CST || integer_onep (length)))
   15960         1597 :         first_non_one++;
   15961              :     }
   15962         3308 :   if (TREE_CODE (type) == ARRAY_TYPE)
   15963              :     {
   15964         1496 :       if (length == NULL_TREE
   15965         1496 :           && (TYPE_DOMAIN (type) == NULL_TREE
   15966          168 :               || TYPE_MAX_VALUE (TYPE_DOMAIN (type)) == NULL_TREE))
   15967              :         {
   15968            8 :           error_at (OMP_CLAUSE_LOCATION (c),
   15969              :                     "for unknown bound array type length expression must "
   15970              :                     "be specified");
   15971            8 :           return error_mark_node;
   15972              :         }
   15973         1488 :       if (TREE_CODE (low_bound) == INTEGER_CST
   15974         1488 :           && tree_int_cst_sgn (low_bound) == -1)
   15975              :         {
   15976           35 :           error_at (OMP_CLAUSE_LOCATION (c),
   15977              :                     "negative low bound in array section in %qs clause",
   15978           35 :                     omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   15979           35 :           return error_mark_node;
   15980              :         }
   15981         1453 :       if (length != NULL_TREE
   15982         1297 :           && TREE_CODE (length) == INTEGER_CST
   15983         2310 :           && tree_int_cst_sgn (length) == -1)
   15984              :         {
   15985           35 :           error_at (OMP_CLAUSE_LOCATION (c),
   15986              :                     "negative length in array section in %qs clause",
   15987           35 :                     omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   15988           35 :           return error_mark_node;
   15989              :         }
   15990         1418 :       if (TYPE_DOMAIN (type)
   15991         1407 :           && TYPE_MAX_VALUE (TYPE_DOMAIN (type))
   15992         2825 :           && TREE_CODE (TYPE_MAX_VALUE (TYPE_DOMAIN (type)))
   15993              :                         == INTEGER_CST)
   15994              :         {
   15995         1061 :           tree size
   15996         1061 :             = fold_convert (sizetype, TYPE_MAX_VALUE (TYPE_DOMAIN (type)));
   15997         1061 :           size = size_binop (PLUS_EXPR, size, size_one_node);
   15998         1061 :           if (TREE_CODE (low_bound) == INTEGER_CST)
   15999              :             {
   16000          874 :               if (tree_int_cst_lt (size, low_bound))
   16001              :                 {
   16002           10 :                   error_at (OMP_CLAUSE_LOCATION (c),
   16003              :                             "low bound %qE above array section size "
   16004              :                             "in %qs clause", low_bound,
   16005           10 :                             omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   16006           10 :                   return error_mark_node;
   16007              :                 }
   16008          864 :               if (tree_int_cst_equal (size, low_bound))
   16009              :                 {
   16010            5 :                   if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_AFFINITY
   16011              :                       || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND
   16012              :                       || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION
   16013              :                       || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_IN_REDUCTION
   16014              :                       || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_TASK_REDUCTION)
   16015              :                     {
   16016            5 :                       error_at (OMP_CLAUSE_LOCATION (c),
   16017              :                                 "zero length array section in %qs clause",
   16018            5 :                                 omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   16019            5 :                       return error_mark_node;
   16020              :                     }
   16021            0 :                   maybe_zero_len = true;
   16022              :                 }
   16023          859 :               else if (length == NULL_TREE
   16024          256 :                        && first_non_one == types.length ()
   16025          914 :                        && tree_int_cst_equal
   16026           55 :                             (TYPE_MAX_VALUE (TYPE_DOMAIN (type)),
   16027              :                              low_bound))
   16028           30 :                 first_non_one++;
   16029              :             }
   16030          187 :           else if (length == NULL_TREE)
   16031              :             {
   16032            3 :               if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_AFFINITY
   16033              :                   && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_DEPEND
   16034              :                   && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_REDUCTION
   16035              :                   && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_IN_REDUCTION
   16036              :                   && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_TASK_REDUCTION)
   16037            0 :                 maybe_zero_len = true;
   16038            6 :               if (first_non_one == types.length ())
   16039            1 :                 first_non_one++;
   16040              :             }
   16041         1046 :           if (length && TREE_CODE (length) == INTEGER_CST)
   16042              :             {
   16043          799 :               if (tree_int_cst_lt (size, length))
   16044              :                 {
   16045           11 :                   error_at (OMP_CLAUSE_LOCATION (c),
   16046              :                             "length %qE above array section size "
   16047              :                             "in %qs clause", length,
   16048           11 :                             omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   16049           11 :                   return error_mark_node;
   16050              :                 }
   16051          788 :               if (TREE_CODE (low_bound) == INTEGER_CST)
   16052              :                 {
   16053          688 :                   tree lbpluslen
   16054          688 :                     = size_binop (PLUS_EXPR,
   16055              :                                   fold_convert (sizetype, low_bound),
   16056              :                                   fold_convert (sizetype, length));
   16057          688 :                   if (TREE_CODE (lbpluslen) == INTEGER_CST
   16058          688 :                       && tree_int_cst_lt (size, lbpluslen))
   16059              :                     {
   16060           10 :                       error_at (OMP_CLAUSE_LOCATION (c),
   16061              :                                 "high bound %qE above array section size "
   16062              :                                 "in %qs clause", lbpluslen,
   16063           10 :                                 omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   16064           10 :                       return error_mark_node;
   16065              :                     }
   16066              :                 }
   16067              :             }
   16068              :         }
   16069          357 :       else if (length == NULL_TREE)
   16070              :         {
   16071           10 :           if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_AFFINITY
   16072              :               && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_DEPEND
   16073              :               && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_REDUCTION
   16074              :               && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_IN_REDUCTION
   16075              :               && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_TASK_REDUCTION)
   16076            0 :             maybe_zero_len = true;
   16077           20 :           if (first_non_one == types.length ())
   16078           10 :             first_non_one++;
   16079              :         }
   16080              : 
   16081              :       /* For [lb:] we will need to evaluate lb more than once.  */
   16082          929 :       if (length == NULL_TREE && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_DEPEND)
   16083              :         {
   16084          127 :           tree lb = save_expr (low_bound);
   16085          127 :           if (lb != low_bound)
   16086              :             {
   16087            2 :               TREE_OPERAND (t, 1) = lb;
   16088            2 :               low_bound = lb;
   16089              :             }
   16090              :         }
   16091              :     }
   16092         1812 :   else if (TREE_CODE (type) == POINTER_TYPE)
   16093              :     {
   16094         1801 :       if (length == NULL_TREE)
   16095              :         {
   16096           10 :           if (TREE_CODE (ret) == PARM_DECL && C_ARRAY_PARAMETER (ret))
   16097            8 :             error_at (OMP_CLAUSE_LOCATION (c),
   16098              :                       "for array function parameter length expression "
   16099              :                       "must be specified");
   16100              :           else
   16101            2 :             error_at (OMP_CLAUSE_LOCATION (c),
   16102              :                       "for pointer type length expression must be specified");
   16103           10 :           return error_mark_node;
   16104              :         }
   16105         1791 :       if (length != NULL_TREE
   16106         1791 :           && TREE_CODE (length) == INTEGER_CST
   16107         1286 :           && tree_int_cst_sgn (length) == -1)
   16108              :         {
   16109           20 :           error_at (OMP_CLAUSE_LOCATION (c),
   16110              :                     "negative length in array section in %qs clause",
   16111           20 :                     omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   16112           20 :           return error_mark_node;
   16113              :         }
   16114              :       /* If there is a pointer type anywhere but in the very first
   16115              :          array-section-subscript, the array section could be non-contiguous.  */
   16116         1771 :       if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_DEPEND
   16117         1610 :           && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_AFFINITY
   16118         3352 :           && TREE_CODE (TREE_OPERAND (t, 0)) == OMP_ARRAY_SECTION)
   16119              :         {
   16120              :           /* If any prior dimension has a non-one length, then deem this
   16121              :              array section as non-contiguous.  */
   16122           42 :           for (tree d = TREE_OPERAND (t, 0);
   16123           82 :                TREE_CODE (d) == OMP_ARRAY_SECTION;
   16124           40 :                d = TREE_OPERAND (d, 0))
   16125              :             {
   16126           44 :               tree d_length = TREE_OPERAND (d, 2);
   16127           44 :               if (d_length == NULL_TREE || !integer_onep (d_length))
   16128              :                 {
   16129            4 :                   error_at (OMP_CLAUSE_LOCATION (c),
   16130              :                             "array section is not contiguous in %qs clause",
   16131            4 :                             omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   16132            4 :                   return error_mark_node;
   16133              :                 }
   16134              :             }
   16135              :         }
   16136              :     }
   16137              :   else
   16138              :     {
   16139           11 :       error_at (OMP_CLAUSE_LOCATION (c),
   16140              :                 "%qE does not have pointer or array type", ret);
   16141           11 :       return error_mark_node;
   16142              :     }
   16143         3149 :   if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_DEPEND)
   16144         2833 :     types.safe_push (TREE_TYPE (ret));
   16145              :   /* We will need to evaluate lb more than once.  */
   16146         3149 :   tree lb = save_expr (low_bound);
   16147         3149 :   if (lb != low_bound)
   16148              :     {
   16149          273 :       TREE_OPERAND (t, 1) = lb;
   16150          273 :       low_bound = lb;
   16151              :     }
   16152         3149 :   ret = build_array_ref (OMP_CLAUSE_LOCATION (c), ret, low_bound);
   16153         3149 :   return ret;
   16154              : }
   16155              : 
   16156              : /* Handle array sections for clause C.  */
   16157              : 
   16158              : static bool
   16159         2978 : handle_omp_array_sections (tree &c, enum c_omp_region_type ort)
   16160              : {
   16161         2978 :   bool maybe_zero_len = false;
   16162         2978 :   unsigned int first_non_one = 0;
   16163         2978 :   auto_vec<tree, 10> types;
   16164         2978 :   tree *tp = &OMP_CLAUSE_DECL (c);
   16165         2978 :   if ((OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND
   16166         2664 :        || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_AFFINITY)
   16167         3077 :       && OMP_ITERATOR_DECL_P (*tp))
   16168           66 :     tp = &TREE_VALUE (*tp);
   16169         2978 :   tree first = handle_omp_array_sections_1 (c, *tp, types,
   16170              :                                             maybe_zero_len, first_non_one,
   16171              :                                             ort);
   16172         2978 :   if (first == error_mark_node)
   16173              :     return true;
   16174         2760 :   if (first == NULL_TREE)
   16175              :     return false;
   16176         2760 :   if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND
   16177         2760 :       || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_AFFINITY)
   16178              :     {
   16179          336 :       tree t = *tp;
   16180          336 :       tree tem = NULL_TREE;
   16181              :       /* Need to evaluate side effects in the length expressions
   16182              :          if any.  */
   16183          336 :       while (TREE_CODE (t) == TREE_LIST)
   16184              :         {
   16185            0 :           if (TREE_VALUE (t) && TREE_SIDE_EFFECTS (TREE_VALUE (t)))
   16186              :             {
   16187            0 :               if (tem == NULL_TREE)
   16188              :                 tem = TREE_VALUE (t);
   16189              :               else
   16190            0 :                 tem = build2 (COMPOUND_EXPR, TREE_TYPE (tem),
   16191            0 :                               TREE_VALUE (t), tem);
   16192              :             }
   16193            0 :           t = TREE_CHAIN (t);
   16194              :         }
   16195          336 :       if (tem)
   16196            0 :         first = build2 (COMPOUND_EXPR, TREE_TYPE (first), tem, first);
   16197          336 :       first = c_fully_fold (first, false, NULL, true);
   16198          336 :       *tp = first;
   16199              :     }
   16200              :   else
   16201              :     {
   16202         2424 :       unsigned int num = types.length (), i;
   16203         2424 :       tree t, side_effects = NULL_TREE, size = NULL_TREE;
   16204         2424 :       tree condition = NULL_TREE;
   16205              : 
   16206         2424 :       if (int_size_in_bytes (TREE_TYPE (first)) <= 0)
   16207            3 :         maybe_zero_len = true;
   16208              : 
   16209         5048 :       for (i = num, t = OMP_CLAUSE_DECL (c); i > 0;
   16210         2624 :            t = TREE_OPERAND (t, 0))
   16211              :         {
   16212         2639 :           tree low_bound = TREE_OPERAND (t, 1);
   16213         2639 :           tree length = TREE_OPERAND (t, 2);
   16214              : 
   16215         2639 :           i--;
   16216         2639 :           if (low_bound
   16217         2175 :               && TREE_CODE (low_bound) == INTEGER_CST
   16218         4628 :               && TYPE_PRECISION (TREE_TYPE (low_bound))
   16219         1989 :                  > TYPE_PRECISION (sizetype))
   16220            0 :             low_bound = fold_convert (sizetype, low_bound);
   16221         2639 :           if (length
   16222         2547 :               && TREE_CODE (length) == INTEGER_CST
   16223         4259 :               && TYPE_PRECISION (TREE_TYPE (length))
   16224         1620 :                  > TYPE_PRECISION (sizetype))
   16225            0 :             length = fold_convert (sizetype, length);
   16226         2639 :           if (low_bound == NULL_TREE)
   16227          464 :             low_bound = integer_zero_node;
   16228         2639 :           if (!maybe_zero_len && i > first_non_one)
   16229              :             {
   16230          109 :               if (integer_nonzerop (low_bound))
   16231            6 :                 goto do_warn_noncontiguous;
   16232          103 :               if (length != NULL_TREE
   16233           50 :                   && TREE_CODE (length) == INTEGER_CST
   16234           50 :                   && TYPE_DOMAIN (types[i])
   16235           50 :                   && TYPE_MAX_VALUE (TYPE_DOMAIN (types[i]))
   16236          153 :                   && TREE_CODE (TYPE_MAX_VALUE (TYPE_DOMAIN (types[i])))
   16237              :                      == INTEGER_CST)
   16238              :                 {
   16239           50 :                   tree size;
   16240           50 :                   size = size_binop (PLUS_EXPR,
   16241              :                                      TYPE_MAX_VALUE (TYPE_DOMAIN (types[i])),
   16242              :                                      size_one_node);
   16243           50 :                   if (!tree_int_cst_equal (length, size))
   16244              :                     {
   16245            7 :                      do_warn_noncontiguous:
   16246           26 :                       error_at (OMP_CLAUSE_LOCATION (c),
   16247              :                                 "array section is not contiguous in %qs "
   16248              :                                 "clause",
   16249           13 :                                 omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   16250         2424 :                       return true;
   16251              :                     }
   16252              :                 }
   16253           96 :               if (length != NULL_TREE
   16254           96 :                   && TREE_SIDE_EFFECTS (length))
   16255              :                 {
   16256            0 :                   if (side_effects == NULL_TREE)
   16257              :                     side_effects = length;
   16258              :                   else
   16259            0 :                     side_effects = build2 (COMPOUND_EXPR,
   16260            0 :                                            TREE_TYPE (side_effects),
   16261              :                                            length, side_effects);
   16262              :                 }
   16263              :             }
   16264              :           else
   16265              :             {
   16266         2530 :               tree l;
   16267              : 
   16268         2530 :               if (i > first_non_one
   16269         2530 :                   && ((length && integer_nonzerop (length))
   16270            0 :                       || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION
   16271              :                       || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_IN_REDUCTION
   16272              :                       || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_TASK_REDUCTION))
   16273            0 :                 continue;
   16274         2530 :               if (length)
   16275         2497 :                 l = fold_convert (sizetype, length);
   16276              :               else
   16277              :                 {
   16278           33 :                   l = size_binop (PLUS_EXPR,
   16279              :                                   TYPE_MAX_VALUE (TYPE_DOMAIN (types[i])),
   16280              :                                   size_one_node);
   16281           33 :                   l = size_binop (MINUS_EXPR, l,
   16282              :                                   fold_convert (sizetype, low_bound));
   16283              :                 }
   16284         2530 :               if (i > first_non_one)
   16285              :                 {
   16286            0 :                   l = fold_build2 (NE_EXPR, boolean_type_node, l,
   16287              :                                    size_zero_node);
   16288            0 :                   if (condition == NULL_TREE)
   16289              :                     condition = l;
   16290              :                   else
   16291            0 :                     condition = fold_build2 (BIT_AND_EXPR, boolean_type_node,
   16292              :                                              l, condition);
   16293              :                 }
   16294         2530 :               else if (size == NULL_TREE)
   16295              :                 {
   16296         2411 :                   size = size_in_bytes (TREE_TYPE (types[i]));
   16297         2411 :                   tree eltype = TREE_TYPE (types[num - 1]);
   16298         2431 :                   while (TREE_CODE (eltype) == ARRAY_TYPE)
   16299           20 :                     eltype = TREE_TYPE (eltype);
   16300         2411 :                   if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION
   16301         2176 :                       || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_IN_REDUCTION
   16302         4327 :                       || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_TASK_REDUCTION)
   16303              :                     {
   16304          539 :                       if (integer_zerop (size)
   16305         1076 :                           || integer_zerop (size_in_bytes (eltype)))
   16306              :                         {
   16307            4 :                           error_at (OMP_CLAUSE_LOCATION (c),
   16308              :                                     "zero length array section in %qs clause",
   16309            2 :                                     omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   16310            2 :                           return error_mark_node;
   16311              :                         }
   16312          537 :                       size = size_binop (EXACT_DIV_EXPR, size,
   16313              :                                          size_in_bytes (eltype));
   16314              :                     }
   16315         2409 :                   size = size_binop (MULT_EXPR, size, l);
   16316         2409 :                   if (condition)
   16317            0 :                     size = fold_build3 (COND_EXPR, sizetype, condition,
   16318              :                                         size, size_zero_node);
   16319              :                 }
   16320              :               else
   16321          119 :                 size = size_binop (MULT_EXPR, size, l);
   16322              :             }
   16323              :         }
   16324         2409 :       if (side_effects)
   16325            0 :         size = build2 (COMPOUND_EXPR, sizetype, side_effects, size);
   16326         2409 :       if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION
   16327         2176 :           || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_IN_REDUCTION
   16328         4325 :           || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_TASK_REDUCTION)
   16329              :         {
   16330          537 :           size = size_binop (MINUS_EXPR, size, size_one_node);
   16331          537 :           size = c_fully_fold (size, false, NULL);
   16332          537 :           size = save_expr (size);
   16333          537 :           tree index_type = build_index_type (size);
   16334          537 :           tree eltype = TREE_TYPE (first);
   16335          549 :           while (TREE_CODE (eltype) == ARRAY_TYPE)
   16336           12 :             eltype = TREE_TYPE (eltype);
   16337          537 :           tree type = c_build_array_type (eltype, index_type);
   16338          537 :           tree ptype = c_build_pointer_type (eltype);
   16339          537 :           if (TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE)
   16340          296 :             t = build_fold_addr_expr (t);
   16341          537 :           tree t2 = build_fold_addr_expr (first);
   16342          537 :           t2 = fold_convert_loc (OMP_CLAUSE_LOCATION (c),
   16343              :                                  ptrdiff_type_node, t2);
   16344          537 :           t2 = fold_build2_loc (OMP_CLAUSE_LOCATION (c), MINUS_EXPR,
   16345              :                                 ptrdiff_type_node, t2,
   16346          537 :                                 fold_convert_loc (OMP_CLAUSE_LOCATION (c),
   16347              :                                                   ptrdiff_type_node, t));
   16348          537 :           t2 = c_fully_fold (t2, false, NULL);
   16349          537 :           if (tree_fits_shwi_p (t2))
   16350          398 :             t = build2 (MEM_REF, type, t,
   16351          398 :                         build_int_cst (ptype, tree_to_shwi (t2)));
   16352              :           else
   16353              :             {
   16354          139 :               t2 = fold_convert_loc (OMP_CLAUSE_LOCATION (c), sizetype, t2);
   16355          139 :               t = build2_loc (OMP_CLAUSE_LOCATION (c), POINTER_PLUS_EXPR,
   16356          139 :                               TREE_TYPE (t), t, t2);
   16357          139 :               t = build2 (MEM_REF, type, t, build_int_cst (ptype, 0));
   16358              :             }
   16359          537 :           OMP_CLAUSE_DECL (c) = t;
   16360          537 :           return false;
   16361              :         }
   16362         1872 :       first = c_fully_fold (first, false, NULL);
   16363         1872 :       OMP_CLAUSE_DECL (c) = first;
   16364         1872 :       if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_HAS_DEVICE_ADDR)
   16365              :         return false;
   16366              :       /* Don't set OMP_CLAUSE_SIZE for bare attach/detach clauses.  */
   16367         1861 :       if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_MAP
   16368         1861 :           || (OMP_CLAUSE_MAP_KIND (c) != GOMP_MAP_ATTACH
   16369         1721 :               && OMP_CLAUSE_MAP_KIND (c) != GOMP_MAP_DETACH
   16370         1719 :               && OMP_CLAUSE_MAP_KIND (c) != GOMP_MAP_FORCE_DETACH))
   16371              :         {
   16372         1857 :           if (size)
   16373         1857 :             size = c_fully_fold (size, false, NULL);
   16374         1857 :           OMP_CLAUSE_SIZE (c) = size;
   16375              :         }
   16376              : 
   16377         1861 :       if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_MAP)
   16378              :         return false;
   16379              : 
   16380         1723 :       auto_vec<omp_addr_token *, 10> addr_tokens;
   16381              : 
   16382         1723 :       if (!omp_parse_expr (addr_tokens, first))
   16383         1723 :         return true;
   16384              : 
   16385         1723 :       c_omp_address_inspector ai (OMP_CLAUSE_LOCATION (c), t);
   16386              : 
   16387         1723 :       tree nc = ai.expand_map_clause (c, first, addr_tokens, ort);
   16388         1723 :       if (nc != error_mark_node)
   16389              :         {
   16390         1723 :           using namespace omp_addr_tokenizer;
   16391              : 
   16392         1723 :           if (ai.maybe_zero_length_array_section (c))
   16393         1719 :             OMP_CLAUSE_MAP_MAYBE_ZERO_LENGTH_ARRAY_SECTION (c) = 1;
   16394              : 
   16395              :           /* !!! If we're accessing a base decl via chained access
   16396              :              methods (e.g. multiple indirections), duplicate clause
   16397              :              detection won't work properly.  Skip it in that case.  */
   16398         1723 :           if ((addr_tokens[0]->type == STRUCTURE_BASE
   16399         1436 :                || addr_tokens[0]->type == ARRAY_BASE)
   16400         1723 :               && addr_tokens[0]->u.structure_base_kind == BASE_DECL
   16401         1723 :               && addr_tokens[1]->type == ACCESS_METHOD
   16402         3446 :               && omp_access_chain_p (addr_tokens, 1))
   16403           34 :             c = nc;
   16404              : 
   16405         1723 :           return false;
   16406              :         }
   16407              :     }
   16408              :   return false;
   16409         2978 : }
   16410              : 
   16411              : /* Helper function of finish_omp_clauses.  Clone STMT as if we were making
   16412              :    an inline call.  But, remap
   16413              :    the OMP_DECL1 VAR_DECL (omp_out resp. omp_orig) to PLACEHOLDER
   16414              :    and OMP_DECL2 VAR_DECL (omp_in resp. omp_priv) to DECL.  */
   16415              : 
   16416              : static tree
   16417          510 : c_clone_omp_udr (tree stmt, tree omp_decl1, tree omp_decl2,
   16418              :                  tree decl, tree placeholder)
   16419              : {
   16420          510 :   copy_body_data id;
   16421          510 :   hash_map<tree, tree> decl_map;
   16422              : 
   16423          510 :   decl_map.put (omp_decl1, placeholder);
   16424          510 :   decl_map.put (omp_decl2, decl);
   16425          510 :   memset (&id, 0, sizeof (id));
   16426          510 :   id.src_fn = DECL_CONTEXT (omp_decl1);
   16427          510 :   id.dst_fn = current_function_decl;
   16428          510 :   id.src_cfun = DECL_STRUCT_FUNCTION (id.src_fn);
   16429          510 :   id.decl_map = &decl_map;
   16430              : 
   16431          510 :   id.copy_decl = copy_decl_no_change;
   16432          510 :   id.transform_call_graph_edges = CB_CGE_DUPLICATE;
   16433          510 :   id.transform_new_cfg = true;
   16434          510 :   id.transform_return_to_modify = false;
   16435          510 :   id.eh_lp_nr = 0;
   16436          510 :   walk_tree (&stmt, copy_tree_body_r, &id, NULL);
   16437          510 :   return stmt;
   16438          510 : }
   16439              : 
   16440              : /* Helper function of c_finish_omp_clauses, called via walk_tree.
   16441              :    Find OMP_CLAUSE_PLACEHOLDER (passed in DATA) in *TP.  */
   16442              : 
   16443              : static tree
   16444         1123 : c_find_omp_placeholder_r (tree *tp, int *, void *data)
   16445              : {
   16446         1123 :   if (*tp == (tree) data)
   16447           28 :     return *tp;
   16448              :   return NULL_TREE;
   16449              : }
   16450              : 
   16451              : /* Similarly, but also walk aggregate fields.  */
   16452              : 
   16453              : struct c_find_omp_var_s { tree var; hash_set<tree> *pset; };
   16454              : 
   16455              : static tree
   16456          288 : c_find_omp_var_r (tree *tp, int *, void *data)
   16457              : {
   16458          288 :   if (*tp == ((struct c_find_omp_var_s *) data)->var)
   16459              :     return *tp;
   16460          280 :   if (RECORD_OR_UNION_TYPE_P (*tp))
   16461              :     {
   16462            2 :       tree field;
   16463            2 :       hash_set<tree> *pset = ((struct c_find_omp_var_s *) data)->pset;
   16464              : 
   16465            2 :       for (field = TYPE_FIELDS (*tp); field;
   16466            0 :            field = DECL_CHAIN (field))
   16467            2 :         if (TREE_CODE (field) == FIELD_DECL)
   16468              :           {
   16469            2 :             tree ret = walk_tree (&DECL_FIELD_OFFSET (field),
   16470              :                                   c_find_omp_var_r, data, pset);
   16471            2 :             if (ret)
   16472              :               return ret;
   16473            2 :             ret = walk_tree (&DECL_SIZE (field), c_find_omp_var_r, data, pset);
   16474            2 :             if (ret)
   16475              :               return ret;
   16476            2 :             ret = walk_tree (&DECL_SIZE_UNIT (field), c_find_omp_var_r, data,
   16477              :                              pset);
   16478            2 :             if (ret)
   16479              :               return ret;
   16480            2 :             ret = walk_tree (&TREE_TYPE (field), c_find_omp_var_r, data, pset);
   16481            2 :             if (ret)
   16482              :               return ret;
   16483              :           }
   16484              :     }
   16485          278 :   else if (INTEGRAL_TYPE_P (*tp))
   16486           45 :     return walk_tree (&TYPE_MAX_VALUE (*tp), c_find_omp_var_r, data,
   16487              :                       ((struct c_find_omp_var_s *) data)->pset);
   16488              :   return NULL_TREE;
   16489              : }
   16490              : 
   16491              : /* Finish OpenMP iterators ITER.  Return true if they are errorneous
   16492              :    and clauses containing them should be removed.  */
   16493              : 
   16494              : static bool
   16495          143 : c_omp_finish_iterators (tree iter)
   16496              : {
   16497          143 :   bool ret = false;
   16498          325 :   for (tree it = iter; it; it = TREE_CHAIN (it))
   16499              :     {
   16500          182 :       tree var = TREE_VEC_ELT (it, 0);
   16501          182 :       tree begin = TREE_VEC_ELT (it, 1);
   16502          182 :       tree end = TREE_VEC_ELT (it, 2);
   16503          182 :       tree step = TREE_VEC_ELT (it, 3);
   16504          182 :       tree orig_step;
   16505          182 :       tree type = TREE_TYPE (var);
   16506          182 :       location_t loc = DECL_SOURCE_LOCATION (var);
   16507          182 :       if (type == error_mark_node)
   16508              :         {
   16509            0 :           ret = true;
   16510           34 :           continue;
   16511              :         }
   16512          182 :       if (!INTEGRAL_TYPE_P (type) && !POINTER_TYPE_P (type))
   16513              :         {
   16514            6 :           error_at (loc, "iterator %qD has neither integral nor pointer type",
   16515              :                     var);
   16516            6 :           ret = true;
   16517            6 :           continue;
   16518              :         }
   16519          176 :       else if (TYPE_ATOMIC (type))
   16520              :         {
   16521            2 :           error_at (loc, "iterator %qD has %<_Atomic%> qualified type", var);
   16522            2 :           ret = true;
   16523            2 :           continue;
   16524              :         }
   16525          174 :       else if (TYPE_READONLY (type))
   16526              :         {
   16527            4 :           error_at (loc, "iterator %qD has const qualified type", var);
   16528            4 :           ret = true;
   16529            4 :           continue;
   16530              :         }
   16531          170 :       else if (step == error_mark_node
   16532          170 :                || TREE_TYPE (step) == error_mark_node)
   16533              :         {
   16534            0 :           ret = true;
   16535            0 :           continue;
   16536              :         }
   16537          170 :       else if (!INTEGRAL_TYPE_P (TREE_TYPE (step)))
   16538              :         {
   16539            6 :           error_at (EXPR_LOC_OR_LOC (step, loc),
   16540              :                     "iterator step with non-integral type");
   16541            4 :           ret = true;
   16542            4 :           continue;
   16543              :         }
   16544          166 :       begin = c_fully_fold (build_c_cast (loc, type, begin), false, NULL);
   16545          166 :       end = c_fully_fold (build_c_cast (loc, type, end), false, NULL);
   16546          166 :       orig_step = save_expr (c_fully_fold (step, false, NULL));
   16547          166 :       tree stype = POINTER_TYPE_P (type) ? sizetype : type;
   16548          166 :       step = c_fully_fold (build_c_cast (loc, stype, orig_step), false, NULL);
   16549          166 :       if (POINTER_TYPE_P (type))
   16550              :         {
   16551           14 :           begin = save_expr (begin);
   16552           14 :           step = pointer_int_sum (loc, PLUS_EXPR, begin, step);
   16553           14 :           step = fold_build2_loc (loc, MINUS_EXPR, sizetype,
   16554              :                                   fold_convert (sizetype, step),
   16555              :                                   fold_convert (sizetype, begin));
   16556           14 :           step = fold_convert (ssizetype, step);
   16557              :         }
   16558          166 :       if (integer_zerop (step))
   16559              :         {
   16560            6 :           error_at (loc, "iterator %qD has zero step", var);
   16561            6 :           ret = true;
   16562            6 :           continue;
   16563              :         }
   16564              : 
   16565          160 :       if (begin == error_mark_node
   16566          158 :           || end == error_mark_node
   16567          156 :           || step == error_mark_node
   16568          156 :           || orig_step == error_mark_node)
   16569              :         {
   16570            4 :           ret = true;
   16571            4 :           continue;
   16572              :         }
   16573          156 :       hash_set<tree> pset;
   16574          156 :       tree it2;
   16575          197 :       for (it2 = TREE_CHAIN (it); it2; it2 = TREE_CHAIN (it2))
   16576              :         {
   16577           49 :           tree var2 = TREE_VEC_ELT (it2, 0);
   16578           49 :           tree begin2 = TREE_VEC_ELT (it2, 1);
   16579           49 :           tree end2 = TREE_VEC_ELT (it2, 2);
   16580           49 :           tree step2 = TREE_VEC_ELT (it2, 3);
   16581           49 :           tree type2 = TREE_TYPE (var2);
   16582           49 :           location_t loc2 = DECL_SOURCE_LOCATION (var2);
   16583           49 :           struct c_find_omp_var_s data = { var, &pset };
   16584           49 :           if (walk_tree (&type2, c_find_omp_var_r, &data, &pset))
   16585              :             {
   16586            2 :               error_at (loc2,
   16587              :                         "type of iterator %qD refers to outer iterator %qD",
   16588              :                         var2, var);
   16589           10 :               break;
   16590              :             }
   16591           47 :           else if (walk_tree (&begin2, c_find_omp_var_r, &data, &pset))
   16592              :             {
   16593            2 :               error_at (EXPR_LOC_OR_LOC (begin2, loc2),
   16594              :                         "begin expression refers to outer iterator %qD", var);
   16595            2 :               break;
   16596              :             }
   16597           45 :           else if (walk_tree (&end2, c_find_omp_var_r, &data, &pset))
   16598              :             {
   16599            2 :               error_at (EXPR_LOC_OR_LOC (end2, loc2),
   16600              :                         "end expression refers to outer iterator %qD", var);
   16601            2 :               break;
   16602              :             }
   16603           43 :           else if (walk_tree (&step2, c_find_omp_var_r, &data, &pset))
   16604              :             {
   16605            2 :               error_at (EXPR_LOC_OR_LOC (step2, loc2),
   16606              :                         "step expression refers to outer iterator %qD", var);
   16607            2 :               break;
   16608              :             }
   16609              :         }
   16610          156 :       if (it2)
   16611              :         {
   16612            8 :           ret = true;
   16613            8 :           continue;
   16614              :         }
   16615          148 :       TREE_VEC_ELT (it, 1) = begin;
   16616          148 :       TREE_VEC_ELT (it, 2) = end;
   16617          148 :       TREE_VEC_ELT (it, 3) = step;
   16618          148 :       TREE_VEC_ELT (it, 4) = orig_step;
   16619          156 :     }
   16620          143 :   return ret;
   16621              : }
   16622              : 
   16623              : /* Ensure that pointers are used in OpenACC attach and detach clauses.
   16624              :    Return true if an error has been detected.  */
   16625              : 
   16626              : static bool
   16627         9601 : c_oacc_check_attachments (tree c)
   16628              : {
   16629         9601 :   if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_MAP)
   16630              :     return false;
   16631              : 
   16632              :   /* OpenACC attach / detach clauses must be pointers.  */
   16633         6578 :   if (OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_ATTACH
   16634         6578 :       || OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_DETACH)
   16635              :     {
   16636           71 :       tree t = OMP_CLAUSE_DECL (c);
   16637              : 
   16638           77 :       while (TREE_CODE (t) == OMP_ARRAY_SECTION)
   16639            6 :         t = TREE_OPERAND (t, 0);
   16640              : 
   16641           71 :       if (TREE_CODE (TREE_TYPE (t)) != POINTER_TYPE)
   16642              :         {
   16643            6 :           error_at (OMP_CLAUSE_LOCATION (c), "expected pointer in %qs clause",
   16644              :                     user_omp_clause_code_name (c, true));
   16645            6 :           return true;
   16646              :         }
   16647              :     }
   16648              : 
   16649              :   return false;
   16650              : }
   16651              : 
   16652              : /* For all elements of CLAUSES, validate them against their constraints.
   16653              :    Remove any elements from the list that are invalid.  */
   16654              : 
   16655              : tree
   16656        29545 : c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
   16657              : {
   16658        29545 :   bitmap_head generic_head, firstprivate_head, lastprivate_head;
   16659        29545 :   bitmap_head aligned_head, map_head, map_field_head, map_firstprivate_head;
   16660        29545 :   bitmap_head oacc_reduction_head, is_on_device_head;
   16661        29545 :   tree c, t, type, *pc;
   16662        29545 :   tree simdlen = NULL_TREE, safelen = NULL_TREE;
   16663        29545 :   bool branch_seen = false;
   16664        29545 :   bool copyprivate_seen = false;
   16665        29545 :   bool mergeable_seen = false;
   16666        29545 :   tree *detach_seen = NULL;
   16667        29545 :   bool linear_variable_step_check = false;
   16668        29545 :   tree *nowait_clause = NULL;
   16669        29545 :   tree *grainsize_seen = NULL;
   16670        29545 :   bool num_tasks_seen = false;
   16671        29545 :   tree ordered_clause = NULL_TREE;
   16672        29545 :   tree schedule_clause = NULL_TREE;
   16673        29545 :   bool oacc_async = false;
   16674        29545 :   tree last_iterators = NULL_TREE;
   16675        29545 :   bool last_iterators_remove = false;
   16676        29545 :   tree *nogroup_seen = NULL;
   16677        29545 :   tree *order_clause = NULL;
   16678              :   /* 1 if normal/task reduction has been seen, -1 if inscan reduction
   16679              :      has been seen, -2 if mixed inscan/normal reduction diagnosed.  */
   16680        29545 :   int reduction_seen = 0;
   16681        29545 :   bool allocate_seen = false;
   16682        29545 :   bool implicit_moved = false;
   16683        29545 :   bool target_in_reduction_seen = false;
   16684        29545 :   tree *full_seen = NULL;
   16685        29545 :   bool partial_seen = false;
   16686        29545 :   bool openacc = (ort & C_ORT_ACC) != 0;
   16687        29545 :   bool init_seen = false;
   16688        29545 :   bool init_use_destroy_seen = false;
   16689        29545 :   tree init_no_targetsync_clause = NULL_TREE;
   16690        29545 :   tree depend_clause = NULL_TREE;
   16691              : 
   16692        29545 :   if (!openacc)
   16693        24308 :     clauses = omp_remove_duplicate_maps (clauses, true);
   16694              : 
   16695        29545 :   bitmap_obstack_initialize (NULL);
   16696        29545 :   bitmap_initialize (&generic_head, &bitmap_default_obstack);
   16697        29545 :   bitmap_initialize (&firstprivate_head, &bitmap_default_obstack);
   16698        29545 :   bitmap_initialize (&lastprivate_head, &bitmap_default_obstack);
   16699        29545 :   bitmap_initialize (&aligned_head, &bitmap_default_obstack);
   16700              :   /* If ort == C_ORT_OMP_DECLARE_SIMD used as uniform_head instead.  */
   16701        29545 :   bitmap_initialize (&map_head, &bitmap_default_obstack);
   16702        29545 :   bitmap_initialize (&map_field_head, &bitmap_default_obstack);
   16703        29545 :   bitmap_initialize (&map_firstprivate_head, &bitmap_default_obstack);
   16704              :   /* If ort == C_ORT_OMP used as nontemporal_head or use_device_xxx_head
   16705              :      instead and for ort == C_ORT_OMP_TARGET used as in_reduction_head.  */
   16706        29545 :   bitmap_initialize (&oacc_reduction_head, &bitmap_default_obstack);
   16707        29545 :   bitmap_initialize (&is_on_device_head, &bitmap_default_obstack);
   16708              : 
   16709        29545 :   if (openacc)
   16710        12269 :     for (c = clauses; c; c = OMP_CLAUSE_CHAIN (c))
   16711         7258 :       if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_ASYNC)
   16712              :         {
   16713              :           oacc_async = true;
   16714              :           break;
   16715              :         }
   16716              : 
   16717        29545 :   tree *grp_start_p = NULL, grp_sentinel = NULL_TREE;
   16718              : 
   16719        77571 :   for (pc = &clauses, c = clauses; c ; c = *pc)
   16720              :     {
   16721        48026 :       bool remove = false;
   16722        48026 :       bool need_complete = false;
   16723        48026 :       bool need_implicitly_determined = false;
   16724              : 
   16725              :       /* We've reached the end of a list of expanded nodes.  Reset the group
   16726              :          start pointer.  */
   16727        48026 :       if (c == grp_sentinel)
   16728              :         {
   16729         2507 :           if (grp_start_p
   16730         2507 :               && OMP_CLAUSE_HAS_ITERATORS (*grp_start_p))
   16731           32 :             for (tree gc = *grp_start_p; gc != grp_sentinel;
   16732           22 :                  gc = OMP_CLAUSE_CHAIN (gc))
   16733           22 :               OMP_CLAUSE_ITERATORS (gc) = OMP_CLAUSE_ITERATORS (*grp_start_p);
   16734              :           grp_start_p = NULL;
   16735              :         }
   16736              : 
   16737        48026 :       switch (OMP_CLAUSE_CODE (c))
   16738              :         {
   16739         1139 :         case OMP_CLAUSE_SHARED:
   16740         1139 :           need_implicitly_determined = true;
   16741         1139 :           goto check_dup_generic;
   16742              : 
   16743          847 :         case OMP_CLAUSE_PRIVATE:
   16744          847 :           need_complete = true;
   16745          847 :           need_implicitly_determined = true;
   16746          847 :           goto check_dup_generic;
   16747              : 
   16748         3519 :         case OMP_CLAUSE_REDUCTION:
   16749         3519 :           if (reduction_seen == 0)
   16750         2920 :             reduction_seen = OMP_CLAUSE_REDUCTION_INSCAN (c) ? -1 : 1;
   16751          599 :           else if (reduction_seen != -2
   16752         1198 :                    && reduction_seen != (OMP_CLAUSE_REDUCTION_INSCAN (c)
   16753          599 :                                          ? -1 : 1))
   16754              :             {
   16755            2 :               error_at (OMP_CLAUSE_LOCATION (c),
   16756              :                         "%<inscan%> and non-%<inscan%> %<reduction%> clauses "
   16757              :                         "on the same construct");
   16758            2 :               reduction_seen = -2;
   16759              :             }
   16760              :           /* FALLTHRU */
   16761         4183 :         case OMP_CLAUSE_IN_REDUCTION:
   16762         4183 :         case OMP_CLAUSE_TASK_REDUCTION:
   16763         4183 :           need_implicitly_determined = true;
   16764         4183 :           t = OMP_CLAUSE_DECL (c);
   16765         4183 :           if (TREE_CODE (t) == OMP_ARRAY_SECTION)
   16766              :             {
   16767          553 :               if (handle_omp_array_sections (c, ort))
   16768              :                 {
   16769              :                   remove = true;
   16770              :                   break;
   16771              :                 }
   16772              : 
   16773          537 :               t = OMP_CLAUSE_DECL (c);
   16774          537 :               if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION
   16775          537 :                   && OMP_CLAUSE_REDUCTION_INSCAN (c))
   16776              :                 {
   16777            1 :                   error_at (OMP_CLAUSE_LOCATION (c),
   16778              :                             "%<inscan%> %<reduction%> clause with array "
   16779              :                             "section");
   16780            1 :                   remove = true;
   16781            1 :                   break;
   16782              :                 }
   16783              :             }
   16784         4166 :           t = require_complete_type (OMP_CLAUSE_LOCATION (c), t);
   16785         4166 :           if (t == error_mark_node)
   16786              :             {
   16787              :               remove = true;
   16788              :               break;
   16789              :             }
   16790         4164 :           if (oacc_async)
   16791            3 :             c_mark_addressable (t);
   16792         4164 :           type = TREE_TYPE (t);
   16793         4164 :           if (TREE_CODE (t) == MEM_REF)
   16794          536 :             type = TREE_TYPE (type);
   16795         4164 :           if (TREE_CODE (type) == ARRAY_TYPE)
   16796              :             {
   16797           74 :               tree oatype = type;
   16798           74 :               gcc_assert (TREE_CODE (t) != MEM_REF);
   16799          148 :               while (TREE_CODE (type) == ARRAY_TYPE)
   16800           74 :                 type = TREE_TYPE (type);
   16801           74 :               if (integer_zerop (TYPE_SIZE_UNIT (type)))
   16802              :                 {
   16803            1 :                   error_at (OMP_CLAUSE_LOCATION (c),
   16804              :                             "%qD in %<reduction%> clause is a zero size array",
   16805              :                             t);
   16806            1 :                   remove = true;
   16807            1 :                   break;
   16808              :                 }
   16809           73 :               tree size = size_binop (EXACT_DIV_EXPR, TYPE_SIZE_UNIT (oatype),
   16810              :                                       TYPE_SIZE_UNIT (type));
   16811           73 :               if (integer_zerop (size))
   16812              :                 {
   16813            1 :                   error_at (OMP_CLAUSE_LOCATION (c),
   16814              :                             "%qD in %<reduction%> clause is a zero size array",
   16815              :                             t);
   16816            1 :                   remove = true;
   16817            1 :                   break;
   16818              :                 }
   16819           72 :               size = size_binop (MINUS_EXPR, size, size_one_node);
   16820           72 :               size = save_expr (size);
   16821           72 :               tree index_type = build_index_type (size);
   16822           72 :               tree atype = c_build_array_type (TYPE_MAIN_VARIANT (type),
   16823              :                                                index_type);
   16824           72 :               atype = c_build_qualified_type (atype, TYPE_QUALS (type));
   16825           72 :               tree ptype = c_build_pointer_type (type);
   16826           72 :               if (TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE)
   16827           72 :                 t = build_fold_addr_expr (t);
   16828           72 :               t = build2 (MEM_REF, atype, t, build_int_cst (ptype, 0));
   16829           72 :               OMP_CLAUSE_DECL (c) = t;
   16830              :             }
   16831         4162 :           if (TYPE_ATOMIC (type))
   16832              :             {
   16833            3 :               error_at (OMP_CLAUSE_LOCATION (c),
   16834              :                         "%<_Atomic%> %qE in %<reduction%> clause", t);
   16835            3 :               remove = true;
   16836            3 :               break;
   16837              :             }
   16838         4159 :           if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_REDUCTION
   16839         4159 :               || OMP_CLAUSE_REDUCTION_TASK (c))
   16840              :             {
   16841              :               /* Disallow zero sized or potentially zero sized task
   16842              :                  reductions.  */
   16843          871 :               if (integer_zerop (TYPE_SIZE_UNIT (type)))
   16844              :                 {
   16845            6 :                   error_at (OMP_CLAUSE_LOCATION (c),
   16846              :                             "zero sized type %qT in %qs clause", type,
   16847            3 :                             omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   16848            3 :                   remove = true;
   16849            3 :                   break;
   16850              :                 }
   16851          868 :               else if (TREE_CODE (TYPE_SIZE_UNIT (type)) != INTEGER_CST)
   16852              :                 {
   16853            0 :                   error_at (OMP_CLAUSE_LOCATION (c),
   16854              :                             "variable sized type %qT in %qs clause", type,
   16855            0 :                             omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   16856            0 :                   remove = true;
   16857            0 :                   break;
   16858              :                 }
   16859              :             }
   16860         4156 :           if (OMP_CLAUSE_REDUCTION_PLACEHOLDER (c) == NULL_TREE
   16861         4156 :               && (FLOAT_TYPE_P (type)
   16862         3604 :                   || TREE_CODE (type) == COMPLEX_TYPE))
   16863              :             {
   16864          340 :               enum tree_code r_code = OMP_CLAUSE_REDUCTION_CODE (c);
   16865          340 :               const char *r_name = NULL;
   16866              : 
   16867          340 :               switch (r_code)
   16868              :                 {
   16869              :                 case PLUS_EXPR:
   16870              :                 case MULT_EXPR:
   16871              :                 case MINUS_EXPR:
   16872              :                 case TRUTH_ANDIF_EXPR:
   16873              :                 case TRUTH_ORIF_EXPR:
   16874              :                   break;
   16875           13 :                 case MIN_EXPR:
   16876           13 :                   if (TREE_CODE (type) == COMPLEX_TYPE)
   16877              :                     r_name = "min";
   16878              :                   break;
   16879           38 :                 case MAX_EXPR:
   16880           38 :                   if (TREE_CODE (type) == COMPLEX_TYPE)
   16881              :                     r_name = "max";
   16882              :                   break;
   16883            3 :                 case BIT_AND_EXPR:
   16884            3 :                   r_name = "&";
   16885            3 :                   break;
   16886            2 :                 case BIT_XOR_EXPR:
   16887            2 :                   r_name = "^";
   16888            2 :                   break;
   16889              :                 case BIT_IOR_EXPR:
   16890              :                   r_name = "|";
   16891              :                   break;
   16892            0 :                 default:
   16893            0 :                   gcc_unreachable ();
   16894              :                 }
   16895            5 :               if (r_name)
   16896              :                 {
   16897           12 :                   error_at (OMP_CLAUSE_LOCATION (c),
   16898              :                             "%qE has invalid type for %<reduction(%s)%>",
   16899              :                             t, r_name);
   16900           12 :                   remove = true;
   16901           12 :                   break;
   16902              :                 }
   16903              :             }
   16904         3816 :           else if (OMP_CLAUSE_REDUCTION_PLACEHOLDER (c) == error_mark_node)
   16905              :             {
   16906            2 :               error_at (OMP_CLAUSE_LOCATION (c),
   16907              :                         "user defined reduction not found for %qE", t);
   16908            2 :               remove = true;
   16909            2 :               break;
   16910              :             }
   16911         3814 :           else if (OMP_CLAUSE_REDUCTION_PLACEHOLDER (c))
   16912              :             {
   16913          277 :               tree list = OMP_CLAUSE_REDUCTION_PLACEHOLDER (c);
   16914          277 :               type = TYPE_MAIN_VARIANT (type);
   16915          277 :               tree placeholder = build_decl (OMP_CLAUSE_LOCATION (c),
   16916              :                                              VAR_DECL, NULL_TREE, type);
   16917          277 :               tree decl_placeholder = NULL_TREE;
   16918          277 :               OMP_CLAUSE_REDUCTION_PLACEHOLDER (c) = placeholder;
   16919          277 :               DECL_ARTIFICIAL (placeholder) = 1;
   16920          277 :               DECL_IGNORED_P (placeholder) = 1;
   16921          277 :               if (TREE_CODE (t) == MEM_REF)
   16922              :                 {
   16923           56 :                   decl_placeholder = build_decl (OMP_CLAUSE_LOCATION (c),
   16924              :                                                  VAR_DECL, NULL_TREE, type);
   16925           56 :                   OMP_CLAUSE_REDUCTION_DECL_PLACEHOLDER (c) = decl_placeholder;
   16926           56 :                   DECL_ARTIFICIAL (decl_placeholder) = 1;
   16927           56 :                   DECL_IGNORED_P (decl_placeholder) = 1;
   16928              :                 }
   16929          277 :               if (TREE_ADDRESSABLE (TREE_VEC_ELT (list, 0)))
   16930           42 :                 c_mark_addressable (placeholder);
   16931          277 :               if (TREE_ADDRESSABLE (TREE_VEC_ELT (list, 1)))
   16932           76 :                 c_mark_addressable (decl_placeholder ? decl_placeholder
   16933           34 :                                     : OMP_CLAUSE_DECL (c));
   16934          277 :               OMP_CLAUSE_REDUCTION_MERGE (c)
   16935          775 :                 = c_clone_omp_udr (TREE_VEC_ELT (list, 2),
   16936          277 :                                    TREE_VEC_ELT (list, 0),
   16937          277 :                                    TREE_VEC_ELT (list, 1),
   16938              :                                    decl_placeholder ? decl_placeholder
   16939          221 :                                    : OMP_CLAUSE_DECL (c), placeholder);
   16940          277 :               OMP_CLAUSE_REDUCTION_MERGE (c)
   16941          277 :                 = build3_loc (OMP_CLAUSE_LOCATION (c), BIND_EXPR,
   16942              :                               void_type_node, NULL_TREE,
   16943          277 :                               OMP_CLAUSE_REDUCTION_MERGE (c), NULL_TREE);
   16944          277 :               TREE_SIDE_EFFECTS (OMP_CLAUSE_REDUCTION_MERGE (c)) = 1;
   16945          277 :               if (TREE_VEC_LENGTH (list) == 6)
   16946              :                 {
   16947          233 :                   if (TREE_ADDRESSABLE (TREE_VEC_ELT (list, 3)))
   16948           70 :                     c_mark_addressable (decl_placeholder ? decl_placeholder
   16949           33 :                                         : OMP_CLAUSE_DECL (c));
   16950          233 :                   if (TREE_ADDRESSABLE (TREE_VEC_ELT (list, 4)))
   16951           27 :                     c_mark_addressable (placeholder);
   16952          233 :                   tree init = TREE_VEC_ELT (list, 5);
   16953          233 :                   if (init == error_mark_node)
   16954          197 :                     init = DECL_INITIAL (TREE_VEC_ELT (list, 3));
   16955          233 :                   OMP_CLAUSE_REDUCTION_INIT (c)
   16956          651 :                     = c_clone_omp_udr (init, TREE_VEC_ELT (list, 4),
   16957          233 :                                        TREE_VEC_ELT (list, 3),
   16958              :                                        decl_placeholder ? decl_placeholder
   16959          185 :                                        : OMP_CLAUSE_DECL (c), placeholder);
   16960          233 :                   if (TREE_VEC_ELT (list, 5) == error_mark_node)
   16961              :                     {
   16962          197 :                       tree v = decl_placeholder ? decl_placeholder : t;
   16963          197 :                       OMP_CLAUSE_REDUCTION_INIT (c)
   16964          394 :                         = build2 (INIT_EXPR, TREE_TYPE (v), v,
   16965          197 :                                   OMP_CLAUSE_REDUCTION_INIT (c));
   16966              :                     }
   16967          233 :                   if (walk_tree (&OMP_CLAUSE_REDUCTION_INIT (c),
   16968              :                                  c_find_omp_placeholder_r,
   16969              :                                  placeholder, NULL))
   16970           28 :                     OMP_CLAUSE_REDUCTION_OMP_ORIG_REF (c) = 1;
   16971              :                 }
   16972              :               else
   16973              :                 {
   16974           44 :                   tree init;
   16975           44 :                   tree v = decl_placeholder ? decl_placeholder : t;
   16976           44 :                   if (AGGREGATE_TYPE_P (TREE_TYPE (v)))
   16977           34 :                     init = build_constructor (TREE_TYPE (v), NULL);
   16978              :                   else
   16979           10 :                     init = fold_convert (TREE_TYPE (v), integer_zero_node);
   16980           44 :                   OMP_CLAUSE_REDUCTION_INIT (c)
   16981           88 :                     = build2 (INIT_EXPR, TREE_TYPE (v), v, init);
   16982              :                 }
   16983          277 :               OMP_CLAUSE_REDUCTION_INIT (c)
   16984          277 :                 = build3_loc (OMP_CLAUSE_LOCATION (c), BIND_EXPR,
   16985              :                               void_type_node, NULL_TREE,
   16986          277 :                                OMP_CLAUSE_REDUCTION_INIT (c), NULL_TREE);
   16987          277 :               TREE_SIDE_EFFECTS (OMP_CLAUSE_REDUCTION_INIT (c)) = 1;
   16988              :             }
   16989         4142 :           if (TREE_CODE (t) == MEM_REF)
   16990              :             {
   16991          607 :               if (TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (t))) == NULL_TREE
   16992          607 :                   || TREE_CODE (TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (t))))
   16993              :                      != INTEGER_CST)
   16994              :                 {
   16995            0 :                   sorry ("variable length element type in array "
   16996              :                          "%<reduction%> clause");
   16997            0 :                   remove = true;
   16998            0 :                   break;
   16999              :                 }
   17000          607 :               t = TREE_OPERAND (t, 0);
   17001          607 :               if (TREE_CODE (t) == POINTER_PLUS_EXPR)
   17002          139 :                 t = TREE_OPERAND (t, 0);
   17003          607 :               if (TREE_CODE (t) == ADDR_EXPR)
   17004          367 :                 t = TREE_OPERAND (t, 0);
   17005              :             }
   17006         4142 :           goto check_dup_generic_t;
   17007              : 
   17008           24 :         case OMP_CLAUSE_COPYPRIVATE:
   17009           24 :           copyprivate_seen = true;
   17010           24 :           if (nowait_clause)
   17011              :             {
   17012            1 :               error_at (OMP_CLAUSE_LOCATION (*nowait_clause),
   17013              :                         "%<nowait%> clause must not be used together "
   17014              :                         "with %<copyprivate%> clause");
   17015            1 :               *nowait_clause = OMP_CLAUSE_CHAIN (*nowait_clause);
   17016            1 :               nowait_clause = NULL;
   17017              :             }
   17018           24 :           goto check_dup_generic;
   17019              : 
   17020           99 :         case OMP_CLAUSE_COPYIN:
   17021           99 :           t = OMP_CLAUSE_DECL (c);
   17022           99 :           if (!VAR_P (t) || !DECL_THREAD_LOCAL_P (t))
   17023              :             {
   17024            5 :               error_at (OMP_CLAUSE_LOCATION (c),
   17025              :                         "%qE must be %<threadprivate%> for %<copyin%>", t);
   17026            5 :               remove = true;
   17027            5 :               break;
   17028              :             }
   17029           94 :           goto check_dup_generic;
   17030              : 
   17031          480 :         case OMP_CLAUSE_LINEAR:
   17032          480 :           if (ort != C_ORT_OMP_DECLARE_SIMD)
   17033          327 :             need_implicitly_determined = true;
   17034          480 :           t = OMP_CLAUSE_DECL (c);
   17035          480 :           if (ort != C_ORT_OMP_DECLARE_SIMD
   17036          327 :               && OMP_CLAUSE_LINEAR_KIND (c) != OMP_CLAUSE_LINEAR_DEFAULT
   17037          485 :               && OMP_CLAUSE_LINEAR_OLD_LINEAR_MODIFIER (c))
   17038              :             {
   17039            5 :               error_at (OMP_CLAUSE_LOCATION (c),
   17040              :                         "modifier should not be specified in %<linear%> "
   17041              :                         "clause on %<simd%> or %<for%> constructs when not "
   17042              :                         "using OpenMP 5.2 modifiers");
   17043            5 :               OMP_CLAUSE_LINEAR_KIND (c) = OMP_CLAUSE_LINEAR_DEFAULT;
   17044              :             }
   17045          960 :           if (!INTEGRAL_TYPE_P (TREE_TYPE (t))
   17046          503 :               && TREE_CODE (TREE_TYPE (t)) != POINTER_TYPE)
   17047              :             {
   17048            1 :               error_at (OMP_CLAUSE_LOCATION (c),
   17049              :                         "linear clause applied to non-integral non-pointer "
   17050            1 :                         "variable with type %qT", TREE_TYPE (t));
   17051            1 :               remove = true;
   17052            1 :               break;
   17053              :             }
   17054          479 :           if (TYPE_ATOMIC (TREE_TYPE (t)))
   17055              :             {
   17056            3 :               error_at (OMP_CLAUSE_LOCATION (c),
   17057              :                         "%<_Atomic%> %qD in %<linear%> clause", t);
   17058            3 :               remove = true;
   17059            3 :               break;
   17060              :             }
   17061          476 :           if (ort == C_ORT_OMP_DECLARE_SIMD)
   17062              :             {
   17063          152 :               tree s = OMP_CLAUSE_LINEAR_STEP (c);
   17064          152 :               if (TREE_CODE (s) == PARM_DECL)
   17065              :                 {
   17066            9 :                   OMP_CLAUSE_LINEAR_VARIABLE_STRIDE (c) = 1;
   17067              :                   /* map_head bitmap is used as uniform_head if
   17068              :                      declare_simd.  */
   17069            9 :                   if (!bitmap_bit_p (&map_head, DECL_UID (s)))
   17070            5 :                     linear_variable_step_check = true;
   17071            9 :                   goto check_dup_generic;
   17072              :                 }
   17073          143 :               if (TREE_CODE (s) != INTEGER_CST)
   17074              :                 {
   17075            7 :                   error_at (OMP_CLAUSE_LOCATION (c),
   17076              :                             "%<linear%> clause step %qE is neither constant "
   17077              :                             "nor a parameter", s);
   17078            7 :                   remove = true;
   17079            7 :                   break;
   17080              :                 }
   17081              :             }
   17082          460 :           if (TREE_CODE (TREE_TYPE (OMP_CLAUSE_DECL (c))) == POINTER_TYPE)
   17083              :             {
   17084           20 :               tree s = OMP_CLAUSE_LINEAR_STEP (c);
   17085           20 :               s = pointer_int_sum (OMP_CLAUSE_LOCATION (c), PLUS_EXPR,
   17086           20 :                                    OMP_CLAUSE_DECL (c), s);
   17087           20 :               s = fold_build2_loc (OMP_CLAUSE_LOCATION (c), MINUS_EXPR,
   17088              :                                    sizetype, fold_convert (sizetype, s),
   17089           20 :                                    fold_convert
   17090              :                                      (sizetype, OMP_CLAUSE_DECL (c)));
   17091           20 :               if (s == error_mark_node)
   17092            0 :                 s = size_one_node;
   17093           20 :               OMP_CLAUSE_LINEAR_STEP (c) = s;
   17094              :             }
   17095              :           else
   17096          440 :             OMP_CLAUSE_LINEAR_STEP (c)
   17097          880 :               = fold_convert (TREE_TYPE (t), OMP_CLAUSE_LINEAR_STEP (c));
   17098          460 :           goto check_dup_generic;
   17099              : 
   17100         2887 :         check_dup_generic:
   17101         2887 :           t = OMP_CLAUSE_DECL (c);
   17102         7118 :         check_dup_generic_t:
   17103         7118 :           if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL)
   17104              :             {
   17105            4 :               error_at (OMP_CLAUSE_LOCATION (c),
   17106              :                         "%qE is not a variable in clause %qs", t,
   17107            2 :                         omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   17108            2 :               remove = true;
   17109              :             }
   17110         1149 :           else if ((openacc && OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION)
   17111         6077 :                    || (ort == C_ORT_OMP
   17112         5358 :                        && (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_USE_DEVICE_PTR
   17113         5347 :                            || (OMP_CLAUSE_CODE (c)
   17114              :                                == OMP_CLAUSE_USE_DEVICE_ADDR)))
   17115        13146 :                    || (ort == C_ORT_OMP_TARGET
   17116          347 :                        && OMP_CLAUSE_CODE (c) == OMP_CLAUSE_IN_REDUCTION))
   17117              :             {
   17118         1196 :               if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_IN_REDUCTION
   17119         1196 :                   && (bitmap_bit_p (&generic_head, DECL_UID (t))
   17120          109 :                       || bitmap_bit_p (&firstprivate_head, DECL_UID (t))))
   17121              :                 {
   17122            2 :                   error_at (OMP_CLAUSE_LOCATION (c),
   17123              :                             "%qD appears more than once in data-sharing "
   17124              :                             "clauses", t);
   17125            2 :                   remove = true;
   17126            2 :                   break;
   17127              :                 }
   17128         1194 :               if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_IN_REDUCTION)
   17129          108 :                 target_in_reduction_seen = true;
   17130         1194 :               if (bitmap_bit_p (&oacc_reduction_head, DECL_UID (t)))
   17131              :                 {
   17132            4 :                   error_at (OMP_CLAUSE_LOCATION (c),
   17133              :                             openacc
   17134              :                             ? "%qD appears more than once in reduction clauses"
   17135              :                             : "%qD appears more than once in data clauses",
   17136              :                             t);
   17137            2 :                   remove = true;
   17138              :                 }
   17139              :               else
   17140         1192 :                 bitmap_set_bit (&oacc_reduction_head, DECL_UID (t));
   17141              :             }
   17142         5920 :           else if (bitmap_bit_p (&generic_head, DECL_UID (t))
   17143         5897 :                    || bitmap_bit_p (&firstprivate_head, DECL_UID (t))
   17144         5896 :                    || bitmap_bit_p (&lastprivate_head, DECL_UID (t))
   17145        11816 :                    || bitmap_bit_p (&map_firstprivate_head, DECL_UID (t)))
   17146              :             {
   17147           24 :               error_at (OMP_CLAUSE_LOCATION (c),
   17148              :                         "%qE appears more than once in data clauses", t);
   17149           24 :               remove = true;
   17150              :             }
   17151         5896 :           else if ((OMP_CLAUSE_CODE (c) == OMP_CLAUSE_PRIVATE
   17152              :                     || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_HAS_DEVICE_ADDR
   17153              :                     || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_IS_DEVICE_PTR)
   17154         1047 :                    && bitmap_bit_p (&map_head, DECL_UID (t)))
   17155              :             {
   17156            3 :               if (openacc)
   17157            0 :                 error_at (OMP_CLAUSE_LOCATION (c),
   17158              :                           "%qD appears more than once in data clauses", t);
   17159              :               else
   17160            3 :                 error_at (OMP_CLAUSE_LOCATION (c),
   17161              :                           "%qD appears both in data and map clauses", t);
   17162              :               remove = true;
   17163              :             }
   17164              :           else
   17165         5893 :             bitmap_set_bit (&generic_head, DECL_UID (t));
   17166              :           break;
   17167              : 
   17168         1333 :         case OMP_CLAUSE_FIRSTPRIVATE:
   17169         1333 :           if (OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT (c) && !implicit_moved)
   17170              :             {
   17171          153 :             move_implicit:
   17172          153 :               implicit_moved = true;
   17173              :               /* Move firstprivate and map clauses with
   17174              :                  OMP_CLAUSE_{FIRSTPRIVATE,MAP}_IMPLICIT set to the end of
   17175              :                  clauses chain.  */
   17176          153 :               tree cl1 = NULL_TREE, cl2 = NULL_TREE;
   17177          153 :               tree *pc1 = pc, *pc2 = &cl1, *pc3 = &cl2;
   17178          972 :               while (*pc1)
   17179          819 :                 if (OMP_CLAUSE_CODE (*pc1) == OMP_CLAUSE_FIRSTPRIVATE
   17180          819 :                     && OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT (*pc1))
   17181              :                   {
   17182          113 :                     *pc3 = *pc1;
   17183          113 :                     pc3 = &OMP_CLAUSE_CHAIN (*pc3);
   17184          113 :                     *pc1 = OMP_CLAUSE_CHAIN (*pc1);
   17185              :                   }
   17186          706 :                 else if (OMP_CLAUSE_CODE (*pc1) == OMP_CLAUSE_MAP
   17187          706 :                          && OMP_CLAUSE_MAP_IMPLICIT (*pc1))
   17188              :                   {
   17189          131 :                     *pc2 = *pc1;
   17190          131 :                     pc2 = &OMP_CLAUSE_CHAIN (*pc2);
   17191          131 :                     *pc1 = OMP_CLAUSE_CHAIN (*pc1);
   17192              :                   }
   17193              :                 else
   17194          575 :                   pc1 = &OMP_CLAUSE_CHAIN (*pc1);
   17195          153 :               *pc3 = NULL;
   17196          153 :               *pc2 = cl2;
   17197          153 :               *pc1 = cl1;
   17198          153 :               continue;
   17199          153 :             }
   17200         1238 :           t = OMP_CLAUSE_DECL (c);
   17201         1238 :           need_complete = true;
   17202         1238 :           need_implicitly_determined = true;
   17203         1238 :           if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL)
   17204              :             {
   17205            1 :               error_at (OMP_CLAUSE_LOCATION (c),
   17206              :                         "%qE is not a variable in clause %<firstprivate%>", t);
   17207            1 :               remove = true;
   17208              :             }
   17209         1237 :           else if (OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT (c)
   17210          113 :                    && !OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT_TARGET (c)
   17211         1343 :                    && bitmap_bit_p (&map_firstprivate_head, DECL_UID (t)))
   17212              :             remove = true;
   17213         1237 :           else if (bitmap_bit_p (&generic_head, DECL_UID (t))
   17214         1235 :                    || bitmap_bit_p (&firstprivate_head, DECL_UID (t))
   17215         2471 :                    || bitmap_bit_p (&map_firstprivate_head, DECL_UID (t)))
   17216              :             {
   17217            4 :               error_at (OMP_CLAUSE_LOCATION (c),
   17218              :                         "%qE appears more than once in data clauses", t);
   17219            4 :               remove = true;
   17220              :             }
   17221         1233 :           else if (bitmap_bit_p (&map_head, DECL_UID (t))
   17222         1233 :                    || bitmap_bit_p (&map_field_head, DECL_UID (t)))
   17223              :             {
   17224            7 :               if (openacc)
   17225            0 :                 error_at (OMP_CLAUSE_LOCATION (c),
   17226              :                           "%qD appears more than once in data clauses", t);
   17227            7 :               else if (OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT (c)
   17228            7 :                        && !OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT_TARGET (c))
   17229              :                 /* Silently drop the clause.  */;
   17230              :               else
   17231            6 :                 error_at (OMP_CLAUSE_LOCATION (c),
   17232              :                           "%qD appears both in data and map clauses", t);
   17233              :               remove = true;
   17234              :             }
   17235              :           else
   17236         1226 :             bitmap_set_bit (&firstprivate_head, DECL_UID (t));
   17237              :           break;
   17238              : 
   17239         1523 :         case OMP_CLAUSE_LASTPRIVATE:
   17240         1523 :           t = OMP_CLAUSE_DECL (c);
   17241         1523 :           need_complete = true;
   17242         1523 :           need_implicitly_determined = true;
   17243         1523 :           if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL)
   17244              :             {
   17245            0 :               error_at (OMP_CLAUSE_LOCATION (c),
   17246              :                         "%qE is not a variable in clause %<lastprivate%>", t);
   17247            0 :               remove = true;
   17248              :             }
   17249         1523 :           else if (bitmap_bit_p (&generic_head, DECL_UID (t))
   17250         1523 :                    || bitmap_bit_p (&lastprivate_head, DECL_UID (t)))
   17251              :             {
   17252            3 :               error_at (OMP_CLAUSE_LOCATION (c),
   17253              :                      "%qE appears more than once in data clauses", t);
   17254            3 :               remove = true;
   17255              :             }
   17256              :           else
   17257         1520 :             bitmap_set_bit (&lastprivate_head, DECL_UID (t));
   17258              :           break;
   17259              : 
   17260          253 :         case OMP_CLAUSE_ALIGNED:
   17261          253 :           t = OMP_CLAUSE_DECL (c);
   17262          253 :           if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL)
   17263              :             {
   17264            0 :               error_at (OMP_CLAUSE_LOCATION (c),
   17265              :                         "%qE is not a variable in %<aligned%> clause", t);
   17266            0 :               remove = true;
   17267              :             }
   17268          289 :           else if (!POINTER_TYPE_P (TREE_TYPE (t))
   17269          289 :                    && TREE_CODE (TREE_TYPE (t)) != ARRAY_TYPE)
   17270              :             {
   17271            7 :               error_at (OMP_CLAUSE_LOCATION (c),
   17272              :                         "%qE in %<aligned%> clause is neither a pointer nor "
   17273              :                         "an array", t);
   17274            7 :               remove = true;
   17275              :             }
   17276          246 :           else if (TYPE_ATOMIC (TREE_TYPE (t)))
   17277              :             {
   17278            1 :               error_at (OMP_CLAUSE_LOCATION (c),
   17279              :                         "%<_Atomic%> %qD in %<aligned%> clause", t);
   17280            1 :               remove = true;
   17281            1 :               break;
   17282              :             }
   17283          245 :           else if (bitmap_bit_p (&aligned_head, DECL_UID (t)))
   17284              :             {
   17285            0 :               error_at (OMP_CLAUSE_LOCATION (c),
   17286              :                         "%qE appears more than once in %<aligned%> clauses",
   17287              :                         t);
   17288            0 :               remove = true;
   17289              :             }
   17290              :           else
   17291          245 :             bitmap_set_bit (&aligned_head, DECL_UID (t));
   17292              :           break;
   17293              : 
   17294          125 :         case OMP_CLAUSE_NONTEMPORAL:
   17295          125 :           t = OMP_CLAUSE_DECL (c);
   17296          125 :           if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL)
   17297              :             {
   17298            0 :               error_at (OMP_CLAUSE_LOCATION (c),
   17299              :                         "%qE is not a variable in %<nontemporal%> clause", t);
   17300            0 :               remove = true;
   17301              :             }
   17302          125 :           else if (bitmap_bit_p (&oacc_reduction_head, DECL_UID (t)))
   17303              :             {
   17304            2 :               error_at (OMP_CLAUSE_LOCATION (c),
   17305              :                         "%qE appears more than once in %<nontemporal%> "
   17306              :                         "clauses", t);
   17307            2 :               remove = true;
   17308              :             }
   17309              :           else
   17310          123 :             bitmap_set_bit (&oacc_reduction_head, DECL_UID (t));
   17311              :           break;
   17312              : 
   17313          802 :         case OMP_CLAUSE_ALLOCATE:
   17314          802 :           t = OMP_CLAUSE_DECL (c);
   17315          802 :           if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL)
   17316              :             {
   17317            1 :               error_at (OMP_CLAUSE_LOCATION (c),
   17318              :                         "%qE is not a variable in %<allocate%> clause", t);
   17319            1 :               remove = true;
   17320              :             }
   17321          801 :           else if (bitmap_bit_p (&aligned_head, DECL_UID (t)))
   17322              :             {
   17323            2 :               warning_at (OMP_CLAUSE_LOCATION (c), OPT_Wopenmp,
   17324              :                           "%qE appears more than once in %<allocate%> clauses",
   17325              :                           t);
   17326            2 :               remove = true;
   17327              :             }
   17328              :           else
   17329              :             {
   17330          799 :               bitmap_set_bit (&aligned_head, DECL_UID (t));
   17331          799 :               if (!OMP_CLAUSE_ALLOCATE_COMBINED (c))
   17332          700 :                 allocate_seen = true;
   17333              :             }
   17334              :           break;
   17335              : 
   17336          357 :         case OMP_CLAUSE_DOACROSS:
   17337          357 :           t = OMP_CLAUSE_DECL (c);
   17338          357 :           if (t == NULL_TREE)
   17339              :             break;
   17340          169 :           if (OMP_CLAUSE_DOACROSS_KIND (c) == OMP_CLAUSE_DOACROSS_SINK)
   17341              :             {
   17342          169 :               gcc_assert (TREE_CODE (t) == TREE_LIST);
   17343         1315 :               for (; t; t = TREE_CHAIN (t))
   17344              :                 {
   17345         1146 :                   tree decl = TREE_VALUE (t);
   17346         1146 :                   if (TREE_CODE (TREE_TYPE (decl)) == POINTER_TYPE)
   17347              :                     {
   17348            3 :                       tree offset = TREE_PURPOSE (t);
   17349            3 :                       bool neg = wi::neg_p (wi::to_wide (offset));
   17350            3 :                       offset = fold_unary (ABS_EXPR, TREE_TYPE (offset), offset);
   17351            6 :                       tree t2 = pointer_int_sum (OMP_CLAUSE_LOCATION (c),
   17352              :                                                  neg ? MINUS_EXPR : PLUS_EXPR,
   17353              :                                                  decl, offset);
   17354            3 :                       t2 = fold_build2_loc (OMP_CLAUSE_LOCATION (c), MINUS_EXPR,
   17355              :                                             sizetype,
   17356              :                                             fold_convert (sizetype, t2),
   17357              :                                             fold_convert (sizetype, decl));
   17358            3 :                       if (t2 == error_mark_node)
   17359              :                         {
   17360              :                           remove = true;
   17361              :                           break;
   17362              :                         }
   17363            3 :                       TREE_PURPOSE (t) = t2;
   17364              :                     }
   17365              :                 }
   17366              :               break;
   17367              :             }
   17368            0 :           gcc_unreachable ();
   17369              : 
   17370           36 :         case OMP_CLAUSE_USES_ALLOCATORS:
   17371           36 :           t = OMP_CLAUSE_USES_ALLOCATORS_ALLOCATOR (c);
   17372           36 :           if (t == error_mark_node)
   17373              :             {
   17374              :               remove = true;
   17375              :               break;
   17376              :             }
   17377            6 :           if ((VAR_P (t) || TREE_CODE (t) == PARM_DECL)
   17378           33 :               && (bitmap_bit_p (&generic_head, DECL_UID (t))
   17379           27 :                   || bitmap_bit_p (&map_head, DECL_UID (t))
   17380           27 :                   || bitmap_bit_p (&firstprivate_head, DECL_UID (t))
   17381           26 :                   || bitmap_bit_p (&lastprivate_head, DECL_UID (t))))
   17382              :             {
   17383            1 :               error_at (OMP_CLAUSE_LOCATION (c),
   17384              :                         "%qE appears more than once in data clauses", t);
   17385            1 :               remove = true;
   17386            1 :               break;
   17387              :             }
   17388              :           else
   17389           31 :             bitmap_set_bit (&generic_head, DECL_UID (t));
   17390           31 :           if (TREE_CODE (TREE_TYPE (t)) != ENUMERAL_TYPE
   17391           59 :               || strcmp (IDENTIFIER_POINTER (TYPE_IDENTIFIER (TREE_TYPE (t))),
   17392              :                          "omp_allocator_handle_t") != 0)
   17393              :             {
   17394            3 :               error_at (OMP_CLAUSE_LOCATION (c),
   17395              :                         "allocator %qE must be of %<omp_allocator_handle_t%> "
   17396              :                         "type", t);
   17397            3 :               remove = true;
   17398            3 :               break;
   17399              :             }
   17400           28 :           tree init;
   17401           28 :           if (!DECL_P (t)
   17402           28 :               || (TREE_CODE (t) == CONST_DECL
   17403            5 :                   && ((init = DECL_INITIAL(t)) == nullptr
   17404            5 :                       || TREE_CODE (init) != INTEGER_CST
   17405            5 :                       || ((wi::to_widest (init) < 0
   17406            5 :                            || wi::to_widest (init) > GOMP_OMP_PREDEF_ALLOC_MAX)
   17407            0 :                           && (wi::to_widest (init) < GOMP_OMPX_PREDEF_ALLOC_MIN
   17408            0 :                               || (wi::to_widest (init)
   17409            0 :                                   > GOMP_OMPX_PREDEF_ALLOC_MAX))))))
   17410              :             {
   17411            0 :               remove = true;
   17412            0 :               error_at (OMP_CLAUSE_LOCATION (c),
   17413              :                         "allocator %qE must be either a variable or a "
   17414              :                         "predefined allocator", t);
   17415            0 :               break;
   17416              :             }
   17417           28 :           else if (TREE_CODE (t) == CONST_DECL)
   17418              :             {
   17419              :               /* omp_null_allocator is ignored and for predefined allocators,
   17420              :                  not special handling is required; thus, remove them removed. */
   17421            5 :               remove = true;
   17422              : 
   17423            5 :               if (OMP_CLAUSE_USES_ALLOCATORS_MEMSPACE (c)
   17424            5 :                   || OMP_CLAUSE_USES_ALLOCATORS_TRAITS (c))
   17425              :                 {
   17426            0 :                   error_at (OMP_CLAUSE_LOCATION (c),
   17427              :                             "modifiers cannot be used with predefined "
   17428              :                             "allocator %qE", t);
   17429            0 :                   break;
   17430              :                 }
   17431              :             }
   17432           28 :           t = OMP_CLAUSE_USES_ALLOCATORS_MEMSPACE (c);
   17433           28 :           if (t == error_mark_node)
   17434              :             {
   17435              :               remove = true;
   17436              :               break;
   17437              :             }
   17438           28 :           if (t != NULL_TREE
   17439           28 :               && ((TREE_CODE (t) != CONST_DECL && TREE_CODE (t) != INTEGER_CST)
   17440            5 :                   || TREE_CODE (TREE_TYPE (t)) != ENUMERAL_TYPE
   17441            8 :                   || strcmp (IDENTIFIER_POINTER (TYPE_IDENTIFIER (TREE_TYPE (t))),
   17442              :                              "omp_memspace_handle_t") != 0))
   17443              :             {
   17444            1 :               error_at (OMP_CLAUSE_LOCATION (c), "memspace modifier %qE must be"
   17445              :                         " constant enum of %<omp_memspace_handle_t%> type", t);
   17446            1 :               remove = true;
   17447            1 :               break;
   17448              :             }
   17449           27 :           t = OMP_CLAUSE_USES_ALLOCATORS_TRAITS (c);
   17450           27 :           if (t == error_mark_node)
   17451              :             {
   17452              :               remove = true;
   17453              :               break;
   17454              :             }
   17455           27 :           if (t != NULL_TREE
   17456              :               && t != error_mark_node
   17457           27 :               && (DECL_EXTERNAL (t)
   17458            9 :                   || TREE_CODE (t) == PARM_DECL))
   17459              :             {
   17460            3 :               error_at (OMP_CLAUSE_LOCATION (c), "traits array %qE must be "
   17461              :                         "defined in same scope as the construct on which the "
   17462              :                         "clause appears", t);
   17463            3 :               remove = true;
   17464              :             }
   17465           27 :           if (t != NULL_TREE)
   17466              :             {
   17467           11 :               bool type_err = false;
   17468              : 
   17469           11 :               if (TREE_CODE (TREE_TYPE (t)) != ARRAY_TYPE
   17470           10 :                   || DECL_SIZE (t) == NULL_TREE
   17471           20 :                   || !COMPLETE_TYPE_P (TREE_TYPE (t)))
   17472              :                 type_err = true;
   17473              :               else
   17474              :                 {
   17475            9 :                   tree elem_t = TREE_TYPE (TREE_TYPE (t));
   17476            9 :                   if (TREE_CODE (elem_t) != RECORD_TYPE
   17477           18 :                       || strcmp (IDENTIFIER_POINTER (TYPE_IDENTIFIER (elem_t)),
   17478              :                                  "omp_alloctrait_t") != 0
   17479           18 :                       || !TYPE_READONLY (elem_t))
   17480              :                     type_err = true;
   17481              :                 }
   17482            8 :               if (type_err)
   17483              :                 {
   17484            3 :                   if (t != error_mark_node)
   17485            3 :                     error_at (OMP_CLAUSE_LOCATION (c), "traits array %qE must "
   17486              :                               "be of %<const omp_alloctrait_t []%> type", t);
   17487              :                   else
   17488            0 :                     error_at (OMP_CLAUSE_LOCATION (c), "traits array must "
   17489              :                               "be of %<const omp_alloctrait_t []%> type");
   17490              :                   remove = true;
   17491              :                 }
   17492              :               else
   17493              :                 {
   17494            8 :                   tree cst_val = decl_constant_value_1 (t, true);
   17495            8 :                   if (cst_val == t)
   17496              :                     {
   17497            1 :                       error_at (OMP_CLAUSE_LOCATION (c), "traits array must be "
   17498              :                                 "initialized with constants");
   17499              : 
   17500            1 :                       remove = true;
   17501              :                     }
   17502              :                 }
   17503              :             }
   17504           24 :           if (remove)
   17505              :             break;
   17506           18 :           pc = &OMP_CLAUSE_CHAIN (c);
   17507           18 :           continue;
   17508          713 :         case OMP_CLAUSE_DEPEND:
   17509          713 :           depend_clause = c;
   17510              :           /* FALLTHRU */
   17511          870 :         case OMP_CLAUSE_AFFINITY:
   17512          870 :           t = OMP_CLAUSE_DECL (c);
   17513          870 :           if (OMP_ITERATOR_DECL_P (t))
   17514              :             {
   17515          131 :               if (TREE_PURPOSE (t) != last_iterators)
   17516          111 :                 last_iterators_remove
   17517          111 :                   = c_omp_finish_iterators (TREE_PURPOSE (t));
   17518          131 :               last_iterators = TREE_PURPOSE (t);
   17519          131 :               t = TREE_VALUE (t);
   17520          131 :               if (last_iterators_remove)
   17521           34 :                 t = error_mark_node;
   17522              :             }
   17523              :           else
   17524              :             last_iterators = NULL_TREE;
   17525          870 :           if (TREE_CODE (t) == OMP_ARRAY_SECTION)
   17526              :             {
   17527          413 :               if (handle_omp_array_sections (c, ort))
   17528              :                 remove = true;
   17529          336 :               else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND
   17530          336 :                        && OMP_CLAUSE_DEPEND_KIND (c) == OMP_CLAUSE_DEPEND_DEPOBJ)
   17531              :                 {
   17532            1 :                   error_at (OMP_CLAUSE_LOCATION (c),
   17533              :                             "%<depend%> clause with %<depobj%> dependence "
   17534              :                             "type on array section");
   17535            1 :                   remove = true;
   17536              :                 }
   17537              :               break;
   17538              :             }
   17539          457 :           if (t == error_mark_node)
   17540              :             remove = true;
   17541          423 :           else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND
   17542          423 :                    && t == ridpointers[RID_OMP_ALL_MEMORY])
   17543              :             {
   17544           15 :               if (OMP_CLAUSE_DEPEND_KIND (c) != OMP_CLAUSE_DEPEND_OUT
   17545           15 :                   && OMP_CLAUSE_DEPEND_KIND (c) != OMP_CLAUSE_DEPEND_INOUT)
   17546              :                 {
   17547            3 :                   error_at (OMP_CLAUSE_LOCATION (c),
   17548              :                             "%<omp_all_memory%> used with %<depend%> kind "
   17549              :                             "other than %<out%> or %<inout%>");
   17550            3 :                   remove = true;
   17551              :                 }
   17552              :             }
   17553          408 :           else if (!lvalue_p (t))
   17554              :             {
   17555            6 :               error_at (OMP_CLAUSE_LOCATION (c),
   17556              :                         "%qE is not lvalue expression nor array section in "
   17557              :                         "%qs clause", t,
   17558            3 :                         omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   17559            3 :               remove = true;
   17560              :             }
   17561          405 :           else if (TREE_CODE (t) == COMPONENT_REF
   17562          405 :                    && DECL_C_BIT_FIELD (TREE_OPERAND (t, 1)))
   17563              :             {
   17564            2 :               gcc_assert (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND
   17565              :                           || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_AFFINITY);
   17566            2 :               error_at (OMP_CLAUSE_LOCATION (c),
   17567              :                         "bit-field %qE in %qs clause", t,
   17568            2 :                         omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   17569            2 :               remove = true;
   17570              :             }
   17571          403 :           else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND
   17572          403 :                    && OMP_CLAUSE_DEPEND_KIND (c) == OMP_CLAUSE_DEPEND_DEPOBJ)
   17573              :             {
   17574           20 :               if (!c_omp_depend_t_p (TREE_TYPE (t)))
   17575              :                 {
   17576            2 :                   error_at (OMP_CLAUSE_LOCATION (c),
   17577              :                             "%qE does not have %<omp_depend_t%> type in "
   17578              :                             "%<depend%> clause with %<depobj%> dependence "
   17579              :                             "type", t);
   17580            2 :                   remove = true;
   17581              :                 }
   17582              :             }
   17583          383 :           else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND
   17584          383 :                    && c_omp_depend_t_p (TREE_TYPE (t)))
   17585              :             {
   17586            2 :               error_at (OMP_CLAUSE_LOCATION (c),
   17587              :                         "%qE should not have %<omp_depend_t%> type in "
   17588              :                         "%<depend%> clause with dependence type other than "
   17589              :                         "%<depobj%>", t);
   17590            2 :               remove = true;
   17591              :             }
   17592           12 :           if (!remove)
   17593              :             {
   17594          411 :               if (t == ridpointers[RID_OMP_ALL_MEMORY])
   17595           12 :                 t = null_pointer_node;
   17596              :               else
   17597              :                 {
   17598          399 :                   tree addr = build_unary_op (OMP_CLAUSE_LOCATION (c),
   17599              :                                               ADDR_EXPR, t, false);
   17600          399 :                   if (addr == error_mark_node)
   17601              :                     {
   17602              :                       remove = true;
   17603              :                       break;
   17604              :                     }
   17605          399 :                   t = build_indirect_ref (OMP_CLAUSE_LOCATION (c), addr,
   17606              :                                           RO_UNARY_STAR);
   17607          399 :                   if (t == error_mark_node)
   17608              :                     {
   17609              :                       remove = true;
   17610              :                       break;
   17611              :                     }
   17612              :                 }
   17613          411 :               if (OMP_ITERATOR_DECL_P (OMP_CLAUSE_DECL (c)))
   17614           31 :                 TREE_VALUE (OMP_CLAUSE_DECL (c)) = t;
   17615              :               else
   17616          380 :                 OMP_CLAUSE_DECL (c) = t;
   17617              :             }
   17618              :           break;
   17619              : 
   17620         6680 :         case OMP_CLAUSE_MAP:
   17621         6680 :           if (OMP_CLAUSE_MAP_IMPLICIT (c) && !implicit_moved)
   17622           58 :             goto move_implicit;
   17623         6622 :           if (OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_PUSH_MAPPER_NAME
   17624         6622 :               || OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_POP_MAPPER_NAME)
   17625              :             {
   17626              :               remove = true;
   17627              :               break;
   17628              :             }
   17629              :           /* FALLTHRU */
   17630         9495 :         case OMP_CLAUSE_TO:
   17631         9495 :         case OMP_CLAUSE_FROM:
   17632         9495 :           if (OMP_CLAUSE_ITERATORS (c)
   17633         9495 :               && c_omp_finish_iterators (OMP_CLAUSE_ITERATORS (c)))
   17634              :             {
   17635        22921 :               t = error_mark_node;
   17636              :               break;
   17637              :             }
   17638              :           /* FALLTHRU */
   17639         9631 :         case OMP_CLAUSE__CACHE_:
   17640         9631 :           {
   17641         9631 :             using namespace omp_addr_tokenizer;
   17642         9631 :             auto_vec<omp_addr_token *, 10> addr_tokens;
   17643              : 
   17644         9631 :             t = OMP_CLAUSE_DECL (c);
   17645         9631 :             if (TREE_CODE (t) == OMP_ARRAY_SECTION)
   17646              :               {
   17647         2001 :                 grp_start_p = pc;
   17648         2001 :                 grp_sentinel = OMP_CLAUSE_CHAIN (c);
   17649              : 
   17650         2001 :                 if (handle_omp_array_sections (c, ort))
   17651              :                   remove = true;
   17652              :                 else
   17653              :                   {
   17654         1861 :                     t = OMP_CLAUSE_DECL (c);
   17655         1861 :                     if (!omp_mappable_type (TREE_TYPE (t)))
   17656              :                       {
   17657            2 :                         error_at (OMP_CLAUSE_LOCATION (c),
   17658              :                                   "array section does not have mappable type "
   17659              :                                   "in %qs clause",
   17660            1 :                                   omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   17661            1 :                         remove = true;
   17662              :                       }
   17663         1860 :                     else if (TYPE_ATOMIC (TREE_TYPE (t)))
   17664              :                       {
   17665            2 :                         error_at (OMP_CLAUSE_LOCATION (c),
   17666              :                                   "%<_Atomic%> %qE in %qs clause", t,
   17667            1 :                                   omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   17668            1 :                         remove = true;
   17669              :                       }
   17670         2510 :                     while (TREE_CODE (t) == ARRAY_REF)
   17671          649 :                       t = TREE_OPERAND (t, 0);
   17672              : 
   17673         1861 :                     c_omp_address_inspector ai (OMP_CLAUSE_LOCATION (c), t);
   17674              : 
   17675         1861 :                     if (!omp_parse_expr (addr_tokens, t))
   17676              :                       {
   17677            0 :                         sorry_at (OMP_CLAUSE_LOCATION (c),
   17678              :                                   "unsupported map expression %qE",
   17679            0 :                                   OMP_CLAUSE_DECL (c));
   17680            0 :                         remove = true;
   17681            0 :                         break;
   17682              :                       }
   17683              : 
   17684              :                     /* This check is to determine if this will be the only map
   17685              :                        node created for this clause.  Otherwise, we'll check
   17686              :                        the following FIRSTPRIVATE_POINTER or ATTACH_DETACH
   17687              :                        node on the next iteration(s) of the loop.   */
   17688         3704 :                     if (addr_tokens.length () >= 4
   17689          304 :                         && addr_tokens[0]->type == STRUCTURE_BASE
   17690          302 :                         && addr_tokens[0]->u.structure_base_kind == BASE_DECL
   17691          302 :                         && addr_tokens[1]->type == ACCESS_METHOD
   17692          302 :                         && addr_tokens[2]->type == COMPONENT_SELECTOR
   17693          302 :                         && addr_tokens[3]->type == ACCESS_METHOD
   17694         2102 :                         && (addr_tokens[3]->u.access_kind == ACCESS_DIRECT
   17695          188 :                             || (addr_tokens[3]->u.access_kind
   17696              :                                 == ACCESS_INDEXED_ARRAY)))
   17697              :                       {
   17698           55 :                         tree rt = addr_tokens[1]->expr;
   17699              : 
   17700           55 :                         gcc_assert (DECL_P (rt));
   17701              : 
   17702           55 :                         if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP
   17703           50 :                             && OMP_CLAUSE_MAP_IMPLICIT (c)
   17704           55 :                             && (bitmap_bit_p (&map_head, DECL_UID (rt))
   17705            0 :                                 || bitmap_bit_p (&map_field_head, DECL_UID (rt))
   17706            0 :                                 || bitmap_bit_p (&map_firstprivate_head,
   17707            0 :                                                  DECL_UID (rt))))
   17708              :                           {
   17709              :                             remove = true;
   17710              :                             break;
   17711              :                           }
   17712           55 :                         if (bitmap_bit_p (&map_field_head, DECL_UID (rt)))
   17713              :                           break;
   17714           37 :                         if (bitmap_bit_p (&map_head, DECL_UID (rt)))
   17715              :                           {
   17716            0 :                             if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_MAP)
   17717            0 :                               error_at (OMP_CLAUSE_LOCATION (c),
   17718              :                                         "%qD appears more than once in motion "
   17719              :                                         "clauses", rt);
   17720            0 :                             else if (openacc)
   17721            0 :                               error_at (OMP_CLAUSE_LOCATION (c),
   17722              :                                         "%qD appears more than once in data "
   17723              :                                         "clauses", rt);
   17724              :                             else
   17725            0 :                               error_at (OMP_CLAUSE_LOCATION (c),
   17726              :                                         "%qD appears more than once in map "
   17727              :                                         "clauses", rt);
   17728              :                             remove = true;
   17729              :                           }
   17730              :                         else
   17731              :                           {
   17732           37 :                             bitmap_set_bit (&map_head, DECL_UID (rt));
   17733           37 :                             bitmap_set_bit (&map_field_head, DECL_UID (rt));
   17734              :                           }
   17735              :                       }
   17736         1861 :                   }
   17737         1983 :                 if (c_oacc_check_attachments (c))
   17738            2 :                   remove = true;
   17739         1983 :                 if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP
   17740         1807 :                     && (OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_ATTACH
   17741         1789 :                         || OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_DETACH)
   17742         2008 :                     && !OMP_CLAUSE_SIZE (c))
   17743              :                   /* In this case, we have a single array element which is a
   17744              :                      pointer, and we already set OMP_CLAUSE_SIZE in
   17745              :                      handle_omp_array_sections above.  For attach/detach
   17746              :                      clauses, reset the OMP_CLAUSE_SIZE (representing a bias)
   17747              :                      to zero here.  */
   17748           10 :                   OMP_CLAUSE_SIZE (c) = size_zero_node;
   17749              :                 break;
   17750              :               }
   17751         7630 :             else if (!omp_parse_expr (addr_tokens, t))
   17752              :               {
   17753            0 :                 sorry_at (OMP_CLAUSE_LOCATION (c),
   17754              :                           "unsupported map expression %qE",
   17755            0 :                           OMP_CLAUSE_DECL (c));
   17756            0 :                 remove = true;
   17757            0 :                 break;
   17758              :               }
   17759         7630 :             if (t == error_mark_node)
   17760              :               {
   17761              :                 remove = true;
   17762              :                 break;
   17763              :               }
   17764              :             /* OpenACC attach / detach clauses must be pointers.  */
   17765         7618 :             if (c_oacc_check_attachments (c))
   17766              :               {
   17767              :                 remove = true;
   17768              :                 break;
   17769              :               }
   17770         7614 :             if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP
   17771         4767 :                 && (OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_ATTACH
   17772         4740 :                     || OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_DETACH)
   17773         7656 :                 && !OMP_CLAUSE_SIZE (c))
   17774              :               /* For attach/detach clauses, set OMP_CLAUSE_SIZE (representing a
   17775              :                  bias) to zero here, so it is not set erroneously to the pointer
   17776              :                  size later on in gimplify.cc.  */
   17777           28 :               OMP_CLAUSE_SIZE (c) = size_zero_node;
   17778              : 
   17779         7614 :             c_omp_address_inspector ai (OMP_CLAUSE_LOCATION (c), t);
   17780              : 
   17781         7614 :             if (!ai.check_clause (c))
   17782              :               {
   17783              :                 remove = true;
   17784              :                 break;
   17785              :               }
   17786              : 
   17787         7606 :             if (!ai.map_supported_p ())
   17788              :               {
   17789           14 :                 sorry_at (OMP_CLAUSE_LOCATION (c),
   17790              :                           "unsupported map expression %qE",
   17791            7 :                           OMP_CLAUSE_DECL (c));
   17792            7 :                 remove = true;
   17793            7 :                 break;
   17794              :               }
   17795              : 
   17796        15198 :             gcc_assert ((addr_tokens[0]->type == ARRAY_BASE
   17797              :                          || addr_tokens[0]->type == STRUCTURE_BASE)
   17798              :                         && addr_tokens[1]->type == ACCESS_METHOD);
   17799              : 
   17800         7599 :             t = addr_tokens[1]->expr;
   17801              : 
   17802         7599 :             if (addr_tokens[0]->u.structure_base_kind != BASE_DECL)
   17803            0 :               goto skip_decl_checks;
   17804              : 
   17805              :             /* For OpenMP, we can access a struct "t" and "t.d" on the same
   17806              :                mapping.  OpenACC allows multiple fields of the same structure
   17807              :                to be written.  */
   17808         7599 :             if (addr_tokens[0]->type == STRUCTURE_BASE
   17809         7599 :                 && (bitmap_bit_p (&map_field_head, DECL_UID (t))
   17810          260 :                     || (!openacc && bitmap_bit_p (&map_head, DECL_UID (t)))))
   17811          307 :               goto skip_decl_checks;
   17812              : 
   17813         7292 :             if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL)
   17814              :               {
   17815            3 :                 if (ort != C_ORT_ACC && EXPR_P (t))
   17816              :                   break;
   17817              : 
   17818            6 :                 error_at (OMP_CLAUSE_LOCATION (c),
   17819              :                           "%qE is not a variable in %qs clause", t,
   17820            3 :                           omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   17821            3 :                 remove = true;
   17822              :               }
   17823         7289 :             else if (VAR_P (t) && DECL_THREAD_LOCAL_P (t))
   17824              :               {
   17825            0 :                 error_at (OMP_CLAUSE_LOCATION (c),
   17826              :                           "%qD is threadprivate variable in %qs clause", t,
   17827            0 :                           omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   17828            0 :                 remove = true;
   17829              :               }
   17830         7289 :             else if ((OMP_CLAUSE_CODE (c) != OMP_CLAUSE_MAP
   17831         4469 :                       || (OMP_CLAUSE_MAP_KIND (c)
   17832              :                           != GOMP_MAP_FIRSTPRIVATE_POINTER))
   17833        10715 :                      && !c_mark_addressable (t))
   17834              :               remove = true;
   17835         7289 :             else if (!(OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP
   17836         4469 :                        && (OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_POINTER
   17837         4469 :                            || (OMP_CLAUSE_MAP_KIND (c)
   17838              :                                == GOMP_MAP_FIRSTPRIVATE_POINTER)
   17839         3426 :                            || (OMP_CLAUSE_MAP_KIND (c)
   17840              :                                == GOMP_MAP_FORCE_DEVICEPTR)))
   17841         6188 :                      && t == OMP_CLAUSE_DECL (c)
   17842        13219 :                      && !omp_mappable_type (TREE_TYPE (t)))
   17843              :               {
   17844           16 :                 error_at (OMP_CLAUSE_LOCATION (c),
   17845              :                           "%qD does not have a mappable type in %qs clause", t,
   17846            8 :                           omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   17847            8 :                 remove = true;
   17848              :               }
   17849         7281 :             else if (TREE_TYPE (t) == error_mark_node)
   17850              :               remove = true;
   17851         7280 :             else if (TYPE_ATOMIC (strip_array_types (TREE_TYPE (t))))
   17852              :               {
   17853            8 :                 error_at (OMP_CLAUSE_LOCATION (c),
   17854              :                           "%<_Atomic%> %qE in %qs clause", t,
   17855            4 :                           omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   17856            4 :                 remove = true;
   17857              :               }
   17858         7276 :             else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP
   17859         4459 :                      && OMP_CLAUSE_MAP_IMPLICIT (c)
   17860         7407 :                      && (bitmap_bit_p (&map_head, DECL_UID (t))
   17861          130 :                          || bitmap_bit_p (&map_field_head, DECL_UID (t))
   17862          130 :                          || bitmap_bit_p (&map_firstprivate_head,
   17863          130 :                                           DECL_UID (t))))
   17864              :               remove = true;
   17865         7274 :             else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP
   17866         7274 :                      && (OMP_CLAUSE_MAP_KIND (c)
   17867              :                          == GOMP_MAP_FIRSTPRIVATE_POINTER))
   17868              :               {
   17869         1041 :                 if (bitmap_bit_p (&generic_head, DECL_UID (t))
   17870         1041 :                     || bitmap_bit_p (&firstprivate_head, DECL_UID (t))
   17871         2081 :                     || bitmap_bit_p (&map_firstprivate_head, DECL_UID (t)))
   17872              :                   {
   17873            4 :                     error_at (OMP_CLAUSE_LOCATION (c),
   17874              :                               "%qD appears more than once in data clauses", t);
   17875            4 :                     remove = true;
   17876              :                   }
   17877         1037 :                 else if (bitmap_bit_p (&map_head, DECL_UID (t))
   17878            4 :                          && !bitmap_bit_p (&map_field_head, DECL_UID (t))
   17879         1039 :                          && openacc)
   17880              :                   {
   17881            1 :                     error_at (OMP_CLAUSE_LOCATION (c),
   17882              :                               "%qD appears more than once in data clauses", t);
   17883            1 :                     remove = true;
   17884              :                   }
   17885              :                 else
   17886         1036 :                   bitmap_set_bit (&map_firstprivate_head, DECL_UID (t));
   17887              :               }
   17888         6233 :             else if (bitmap_bit_p (&map_head, DECL_UID (t))
   17889           64 :                      && !bitmap_bit_p (&map_field_head, DECL_UID (t))
   17890           18 :                      && ort != C_ORT_OMP
   17891           18 :                      && ort != C_ORT_OMP_TARGET
   17892         6243 :                      && ort != C_ORT_OMP_EXIT_DATA)
   17893              :               {
   17894            7 :                 if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_MAP)
   17895            0 :                   error_at (OMP_CLAUSE_LOCATION (c),
   17896              :                             "%qD appears more than once in motion clauses", t);
   17897            7 :                 else if (openacc)
   17898            7 :                   error_at (OMP_CLAUSE_LOCATION (c),
   17899              :                             "%qD appears more than once in data clauses", t);
   17900              :                 else
   17901            0 :                   error_at (OMP_CLAUSE_LOCATION (c),
   17902              :                             "%qD appears more than once in map clauses", t);
   17903              :                 remove = true;
   17904              :               }
   17905         6226 :             else if (openacc && bitmap_bit_p (&generic_head, DECL_UID (t)))
   17906              :               {
   17907            0 :                 error_at (OMP_CLAUSE_LOCATION (c),
   17908              :                           "%qD appears more than once in data clauses", t);
   17909            0 :                 remove = true;
   17910              :               }
   17911         6226 :             else if (bitmap_bit_p (&firstprivate_head, DECL_UID (t))
   17912         6226 :                      || bitmap_bit_p (&is_on_device_head, DECL_UID (t)))
   17913              :               {
   17914            9 :                 if (openacc)
   17915            0 :                   error_at (OMP_CLAUSE_LOCATION (c),
   17916              :                             "%qD appears more than once in data clauses", t);
   17917              :                 else
   17918            9 :                   error_at (OMP_CLAUSE_LOCATION (c),
   17919              :                             "%qD appears both in data and map clauses", t);
   17920              :                 remove = true;
   17921              :               }
   17922         6217 :             else if (!omp_access_chain_p (addr_tokens, 1))
   17923              :               {
   17924         6217 :                 bitmap_set_bit (&map_head, DECL_UID (t));
   17925         6217 :                 if (t != OMP_CLAUSE_DECL (c)
   17926         6217 :                     && TREE_CODE (OMP_CLAUSE_DECL (c)) == COMPONENT_REF)
   17927          254 :                   bitmap_set_bit (&map_field_head, DECL_UID (t));
   17928              :               }
   17929              : 
   17930            0 :           skip_decl_checks:
   17931              :             /* If we call omp_expand_map_clause in handle_omp_array_sections,
   17932              :                the containing loop (here) iterates through the new nodes
   17933              :                created by that expansion.  Avoid expanding those again (just
   17934              :                by checking the node type).  */
   17935         7599 :             if (!remove
   17936         7599 :                 && ort != C_ORT_DECLARE_SIMD
   17937         7599 :                 && (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_MAP
   17938         4717 :                     || (OMP_CLAUSE_MAP_KIND (c) != GOMP_MAP_FIRSTPRIVATE_POINTER
   17939         3681 :                         && (OMP_CLAUSE_MAP_KIND (c)
   17940              :                             != GOMP_MAP_FIRSTPRIVATE_REFERENCE)
   17941         3681 :                         && OMP_CLAUSE_MAP_KIND (c) != GOMP_MAP_ALWAYS_POINTER
   17942         3681 :                         && OMP_CLAUSE_MAP_KIND (c) != GOMP_MAP_ATTACH_DETACH
   17943         3381 :                         && OMP_CLAUSE_MAP_KIND (c) != GOMP_MAP_ATTACH
   17944         3354 :                         && OMP_CLAUSE_MAP_KIND (c) != GOMP_MAP_DETACH)))
   17945              :               {
   17946         6182 :                 grp_start_p = pc;
   17947         6182 :                 grp_sentinel = OMP_CLAUSE_CHAIN (c);
   17948         6182 :                 tree nc = ai.expand_map_clause (c, OMP_CLAUSE_DECL (c),
   17949              :                                                 addr_tokens, ort);
   17950         6182 :                 if (nc != error_mark_node)
   17951         6182 :                   c = nc;
   17952              :               }
   17953         9646 :           }
   17954         7599 :           break;
   17955              : 
   17956          232 :         case OMP_CLAUSE_ENTER:
   17957          232 :         case OMP_CLAUSE_LINK:
   17958          232 :           t = OMP_CLAUSE_DECL (c);
   17959          232 :           const char *cname;
   17960          232 :           cname = omp_clause_code_name[OMP_CLAUSE_CODE (c)];
   17961          232 :           if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_ENTER
   17962          232 :               && OMP_CLAUSE_ENTER_TO (c))
   17963              :             cname = "to";
   17964          232 :           if (TREE_CODE (t) == FUNCTION_DECL
   17965          232 :               && OMP_CLAUSE_CODE (c) == OMP_CLAUSE_ENTER)
   17966              :             ;
   17967          151 :           else if (!VAR_P (t))
   17968              :             {
   17969            1 :               if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_ENTER)
   17970            0 :                 error_at (OMP_CLAUSE_LOCATION (c),
   17971              :                           "%qE is neither a variable nor a function name in "
   17972              :                           "clause %qs", t, cname);
   17973              :               else
   17974            1 :                 error_at (OMP_CLAUSE_LOCATION (c),
   17975              :                           "%qE is not a variable in clause %qs", t, cname);
   17976              :               remove = true;
   17977              :             }
   17978          150 :           else if (DECL_THREAD_LOCAL_P (t))
   17979              :             {
   17980            2 :               error_at (OMP_CLAUSE_LOCATION (c),
   17981              :                         "%qD is threadprivate variable in %qs clause", t,
   17982              :                         cname);
   17983            2 :               remove = true;
   17984              :             }
   17985          148 :           else if (!omp_mappable_type (TREE_TYPE (t)))
   17986              :             {
   17987            6 :               error_at (OMP_CLAUSE_LOCATION (c),
   17988              :                         "%qD does not have a mappable type in %qs clause", t,
   17989              :                         cname);
   17990            6 :               remove = true;
   17991              :             }
   17992            8 :           if (remove)
   17993              :             break;
   17994          223 :           if (bitmap_bit_p (&generic_head, DECL_UID (t)))
   17995              :             {
   17996            8 :               error_at (OMP_CLAUSE_LOCATION (c),
   17997              :                         "%qE appears more than once on the same "
   17998              :                         "%<declare target%> directive", t);
   17999            8 :               remove = true;
   18000              :             }
   18001              :           else
   18002          215 :             bitmap_set_bit (&generic_head, DECL_UID (t));
   18003              :           break;
   18004              : 
   18005          117 :         case OMP_CLAUSE_UNIFORM:
   18006          117 :           t = OMP_CLAUSE_DECL (c);
   18007          117 :           if (TREE_CODE (t) != PARM_DECL)
   18008              :             {
   18009            0 :               if (DECL_P (t))
   18010            0 :                 error_at (OMP_CLAUSE_LOCATION (c),
   18011              :                           "%qD is not an argument in %<uniform%> clause", t);
   18012              :               else
   18013            0 :                 error_at (OMP_CLAUSE_LOCATION (c),
   18014              :                           "%qE is not an argument in %<uniform%> clause", t);
   18015              :               remove = true;
   18016              :               break;
   18017              :             }
   18018              :           /* map_head bitmap is used as uniform_head if declare_simd.  */
   18019          117 :           bitmap_set_bit (&map_head, DECL_UID (t));
   18020          117 :           goto check_dup_generic;
   18021              : 
   18022          161 :         case OMP_CLAUSE_IS_DEVICE_PTR:
   18023          161 :         case OMP_CLAUSE_USE_DEVICE_PTR:
   18024          161 :           t = OMP_CLAUSE_DECL (c);
   18025          161 :           if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_IS_DEVICE_PTR)
   18026          123 :             bitmap_set_bit (&is_on_device_head, DECL_UID (t));
   18027          161 :           if (TREE_CODE (TREE_TYPE (t)) != POINTER_TYPE)
   18028              :             {
   18029           21 :               if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_USE_DEVICE_PTR
   18030           21 :                   && !openacc)
   18031              :                 {
   18032            1 :                   error_at (OMP_CLAUSE_LOCATION (c),
   18033              :                             "%qs variable is not a pointer",
   18034            1 :                             omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   18035            1 :                   remove = true;
   18036              :                 }
   18037           20 :               else if (TREE_CODE (TREE_TYPE (t)) != ARRAY_TYPE)
   18038              :                 {
   18039            4 :                   error_at (OMP_CLAUSE_LOCATION (c),
   18040              :                             "%qs variable is neither a pointer nor an array",
   18041            4 :                             omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   18042            4 :                   remove = true;
   18043              :                 }
   18044              :             }
   18045          161 :           goto check_dup_generic;
   18046              : 
   18047           89 :         case OMP_CLAUSE_HAS_DEVICE_ADDR:
   18048           89 :           t = OMP_CLAUSE_DECL (c);
   18049           89 :           if (TREE_CODE (t) == OMP_ARRAY_SECTION)
   18050              :             {
   18051           11 :               if (handle_omp_array_sections (c, ort))
   18052              :                 remove = true;
   18053              :               else
   18054              :                 {
   18055           11 :                   t = OMP_CLAUSE_DECL (c);
   18056           24 :                   while (TREE_CODE (t) == ARRAY_REF)
   18057           13 :                     t = TREE_OPERAND (t, 0);
   18058              :                 }
   18059              :             }
   18060           89 :           bitmap_set_bit (&is_on_device_head, DECL_UID (t));
   18061           89 :           if (VAR_P (t) || TREE_CODE (t) == PARM_DECL)
   18062           89 :             c_mark_addressable (t);
   18063           89 :           goto check_dup_generic_t;
   18064              : 
   18065           36 :         case OMP_CLAUSE_USE_DEVICE_ADDR:
   18066           36 :           t = OMP_CLAUSE_DECL (c);
   18067           36 :           if (VAR_P (t) || TREE_CODE (t) == PARM_DECL)
   18068           36 :             c_mark_addressable (t);
   18069           36 :           goto check_dup_generic;
   18070              : 
   18071         4791 :         case OMP_CLAUSE_NOWAIT:
   18072         4791 :           if (copyprivate_seen)
   18073              :             {
   18074            1 :               error_at (OMP_CLAUSE_LOCATION (c),
   18075              :                         "%<nowait%> clause must not be used together "
   18076              :                         "with %<copyprivate%> clause");
   18077            1 :               remove = true;
   18078            1 :               break;
   18079              :             }
   18080         4790 :           nowait_clause = pc;
   18081         4790 :           pc = &OMP_CLAUSE_CHAIN (c);
   18082         4790 :           continue;
   18083              : 
   18084          523 :         case OMP_CLAUSE_ORDER:
   18085          523 :           if (ordered_clause)
   18086              :             {
   18087            2 :               error_at (OMP_CLAUSE_LOCATION (c),
   18088              :                         "%<order%> clause must not be used together "
   18089              :                         "with %<ordered%> clause");
   18090            2 :               remove = true;
   18091            2 :               break;
   18092              :             }
   18093          521 :           else if (order_clause)
   18094              :             {
   18095              :               /* Silently remove duplicates.  */
   18096              :               remove = true;
   18097              :               break;
   18098              :             }
   18099          513 :           order_clause = pc;
   18100          513 :           pc = &OMP_CLAUSE_CHAIN (c);
   18101          513 :           continue;
   18102              : 
   18103           32 :         case OMP_CLAUSE_DETACH:
   18104           32 :           t = OMP_CLAUSE_DECL (c);
   18105           32 :           if (detach_seen)
   18106              :             {
   18107            1 :               error_at (OMP_CLAUSE_LOCATION (c),
   18108              :                         "too many %qs clauses on a task construct",
   18109              :                         "detach");
   18110            1 :               remove = true;
   18111            1 :               break;
   18112              :             }
   18113           31 :           detach_seen = pc;
   18114           31 :           pc = &OMP_CLAUSE_CHAIN (c);
   18115           31 :           c_mark_addressable (t);
   18116           31 :           continue;
   18117              : 
   18118        14583 :         case OMP_CLAUSE_IF:
   18119        14583 :         case OMP_CLAUSE_SELF:
   18120        14583 :         case OMP_CLAUSE_NUM_THREADS:
   18121        14583 :         case OMP_CLAUSE_NUM_TEAMS:
   18122        14583 :         case OMP_CLAUSE_THREAD_LIMIT:
   18123        14583 :         case OMP_CLAUSE_DEFAULT:
   18124        14583 :         case OMP_CLAUSE_UNTIED:
   18125        14583 :         case OMP_CLAUSE_COLLAPSE:
   18126        14583 :         case OMP_CLAUSE_FINAL:
   18127        14583 :         case OMP_CLAUSE_DEVICE:
   18128        14583 :         case OMP_CLAUSE_DIST_SCHEDULE:
   18129        14583 :         case OMP_CLAUSE_DYN_GROUPPRIVATE:
   18130        14583 :         case OMP_CLAUSE_PARALLEL:
   18131        14583 :         case OMP_CLAUSE_FOR:
   18132        14583 :         case OMP_CLAUSE_SECTIONS:
   18133        14583 :         case OMP_CLAUSE_TASKGROUP:
   18134        14583 :         case OMP_CLAUSE_PROC_BIND:
   18135        14583 :         case OMP_CLAUSE_DEVICE_TYPE:
   18136        14583 :         case OMP_CLAUSE_PRIORITY:
   18137        14583 :         case OMP_CLAUSE_THREADS:
   18138        14583 :         case OMP_CLAUSE_SIMD:
   18139        14583 :         case OMP_CLAUSE_HINT:
   18140        14583 :         case OMP_CLAUSE_FILTER:
   18141        14583 :         case OMP_CLAUSE_DEFAULTMAP:
   18142        14583 :         case OMP_CLAUSE_BIND:
   18143        14583 :         case OMP_CLAUSE_NUM_GANGS:
   18144        14583 :         case OMP_CLAUSE_NUM_WORKERS:
   18145        14583 :         case OMP_CLAUSE_VECTOR_LENGTH:
   18146        14583 :         case OMP_CLAUSE_ASYNC:
   18147        14583 :         case OMP_CLAUSE_WAIT:
   18148        14583 :         case OMP_CLAUSE_AUTO:
   18149        14583 :         case OMP_CLAUSE_INDEPENDENT:
   18150        14583 :         case OMP_CLAUSE_SEQ:
   18151        14583 :         case OMP_CLAUSE_GANG:
   18152        14583 :         case OMP_CLAUSE_WORKER:
   18153        14583 :         case OMP_CLAUSE_VECTOR:
   18154        14583 :         case OMP_CLAUSE_TILE:
   18155        14583 :         case OMP_CLAUSE_IF_PRESENT:
   18156        14583 :         case OMP_CLAUSE_FINALIZE:
   18157        14583 :         case OMP_CLAUSE_NOHOST:
   18158        14583 :         case OMP_CLAUSE_INDIRECT:
   18159        14583 :         case OMP_CLAUSE_NOVARIANTS:
   18160        14583 :         case OMP_CLAUSE_NOCONTEXT:
   18161        14583 :           pc = &OMP_CLAUSE_CHAIN (c);
   18162        14583 :           continue;
   18163              : 
   18164           62 :         case OMP_CLAUSE_GRAINSIZE:
   18165           62 :           grainsize_seen = pc;
   18166           62 :           pc = &OMP_CLAUSE_CHAIN (c);
   18167           62 :           continue;
   18168              : 
   18169           50 :         case OMP_CLAUSE_NUM_TASKS:
   18170           50 :           num_tasks_seen = true;
   18171           50 :           pc = &OMP_CLAUSE_CHAIN (c);
   18172           50 :           continue;
   18173              : 
   18174           79 :         case OMP_CLAUSE_MERGEABLE:
   18175           79 :           mergeable_seen = true;
   18176           79 :           pc = &OMP_CLAUSE_CHAIN (c);
   18177           79 :           continue;
   18178              : 
   18179           18 :         case OMP_CLAUSE_NOGROUP:
   18180           18 :           nogroup_seen = pc;
   18181           18 :           pc = &OMP_CLAUSE_CHAIN (c);
   18182           18 :           continue;
   18183              : 
   18184         3465 :         case OMP_CLAUSE_SCHEDULE:
   18185         3465 :           schedule_clause = c;
   18186         3465 :           pc = &OMP_CLAUSE_CHAIN (c);
   18187         3465 :           continue;
   18188              : 
   18189          304 :         case OMP_CLAUSE_ORDERED:
   18190          304 :           ordered_clause = c;
   18191          304 :           if (order_clause)
   18192              :             {
   18193            2 :               error_at (OMP_CLAUSE_LOCATION (*order_clause),
   18194              :                         "%<order%> clause must not be used together "
   18195              :                         "with %<ordered%> clause");
   18196            2 :               *order_clause = OMP_CLAUSE_CHAIN (*order_clause);
   18197            2 :               order_clause = NULL;
   18198              :             }
   18199          304 :           pc = &OMP_CLAUSE_CHAIN (c);
   18200          304 :           continue;
   18201              : 
   18202          223 :         case OMP_CLAUSE_SAFELEN:
   18203          223 :           safelen = c;
   18204          223 :           pc = &OMP_CLAUSE_CHAIN (c);
   18205          223 :           continue;
   18206          320 :         case OMP_CLAUSE_SIMDLEN:
   18207          320 :           simdlen = c;
   18208          320 :           pc = &OMP_CLAUSE_CHAIN (c);
   18209          320 :           continue;
   18210              : 
   18211           69 :         case OMP_CLAUSE_FULL:
   18212           69 :           full_seen = pc;
   18213           69 :           pc = &OMP_CLAUSE_CHAIN (c);
   18214           69 :           continue;
   18215              : 
   18216          223 :         case OMP_CLAUSE_PARTIAL:
   18217          223 :           partial_seen = true;
   18218          223 :           pc = &OMP_CLAUSE_CHAIN (c);
   18219          223 :           continue;
   18220              : 
   18221            0 :         case OMP_CLAUSE_SIZES:
   18222            0 :           pc = &OMP_CLAUSE_CHAIN (c);
   18223            0 :           continue;
   18224              : 
   18225          205 :         case OMP_CLAUSE_INBRANCH:
   18226          205 :         case OMP_CLAUSE_NOTINBRANCH:
   18227          205 :           if (branch_seen)
   18228              :             {
   18229            1 :               error_at (OMP_CLAUSE_LOCATION (c),
   18230              :                         "%<inbranch%> clause is incompatible with "
   18231              :                         "%<notinbranch%>");
   18232            1 :               remove = true;
   18233            1 :               break;
   18234              :             }
   18235          204 :           branch_seen = true;
   18236          204 :           pc = &OMP_CLAUSE_CHAIN (c);
   18237          204 :           continue;
   18238              : 
   18239          367 :         case OMP_CLAUSE_INCLUSIVE:
   18240          367 :         case OMP_CLAUSE_EXCLUSIVE:
   18241          367 :           need_complete = true;
   18242          367 :           need_implicitly_determined = true;
   18243          367 :           t = OMP_CLAUSE_DECL (c);
   18244          367 :           if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL)
   18245              :             {
   18246            0 :               error_at (OMP_CLAUSE_LOCATION (c),
   18247              :                         "%qE is not a variable in clause %qs", t,
   18248            0 :                         omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   18249            0 :               remove = true;
   18250              :             }
   18251              :           break;
   18252              : 
   18253          152 :         case OMP_CLAUSE_INIT:
   18254          152 :           init_seen = true;
   18255          152 :           if (!OMP_CLAUSE_INIT_TARGETSYNC (c))
   18256           71 :             init_no_targetsync_clause = c;
   18257              :           /* FALLTHRU */
   18258          242 :         case OMP_CLAUSE_DESTROY:
   18259          242 :         case OMP_CLAUSE_USE:
   18260          242 :           init_use_destroy_seen = true;
   18261          242 :           t = OMP_CLAUSE_DECL (c);
   18262          242 :           if (bitmap_bit_p (&generic_head, DECL_UID (t)))
   18263              :             {
   18264            3 :               error_at (OMP_CLAUSE_LOCATION (c),
   18265              :                         "%qD appears more than once in action clauses", t);
   18266            3 :               remove = true;
   18267            3 :               break;
   18268              :             }
   18269          239 :           bitmap_set_bit (&generic_head, DECL_UID (t));
   18270              :           /* FALLTHRU */
   18271          298 :         case OMP_CLAUSE_INTEROP:
   18272          298 :           if (/* ort == C_ORT_OMP_INTEROP [uncomment for depobj init]  */
   18273          298 :                    !c_omp_interop_t_p (TREE_TYPE (OMP_CLAUSE_DECL (c))))
   18274              :             {
   18275           40 :               error_at (OMP_CLAUSE_LOCATION (c),
   18276              :                         "%qD must be of %<omp_interop_t%>",
   18277           20 :                         OMP_CLAUSE_DECL (c));
   18278           20 :               remove = true;
   18279              :             }
   18280          278 :           else if ((OMP_CLAUSE_CODE (c) == OMP_CLAUSE_INIT
   18281          133 :                     || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DESTROY)
   18282          318 :                    && TREE_READONLY (OMP_CLAUSE_DECL (c)))
   18283              :             {
   18284           12 :               error_at (OMP_CLAUSE_LOCATION (c),
   18285            6 :                       "%qD shall not be const", OMP_CLAUSE_DECL (c));
   18286            6 :               remove = true;
   18287              :             }
   18288          298 :           pc = &OMP_CLAUSE_CHAIN (c);
   18289          298 :           break;
   18290            0 :         default:
   18291            0 :           gcc_unreachable ();
   18292        24952 :         }
   18293              : 
   18294        22921 :       if (!remove)
   18295              :         {
   18296        22367 :           t = OMP_CLAUSE_DECL (c);
   18297              : 
   18298        22367 :           if (need_complete)
   18299              :             {
   18300         3953 :               t = require_complete_type (OMP_CLAUSE_LOCATION (c), t);
   18301         3953 :               if (t == error_mark_node)
   18302            7 :                 remove = true;
   18303              :             }
   18304              : 
   18305        22367 :           if (need_implicitly_determined)
   18306              :             {
   18307         9552 :               const char *share_name = NULL;
   18308              : 
   18309         9552 :               if (VAR_P (t) && DECL_THREAD_LOCAL_P (t))
   18310              :                 share_name = "threadprivate";
   18311         9546 :               else switch (c_omp_predetermined_sharing (t))
   18312              :                 {
   18313              :                 case OMP_CLAUSE_DEFAULT_UNSPECIFIED:
   18314              :                   break;
   18315           20 :                 case OMP_CLAUSE_DEFAULT_SHARED:
   18316           20 :                   if ((OMP_CLAUSE_CODE (c) == OMP_CLAUSE_SHARED
   18317           12 :                        || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_FIRSTPRIVATE)
   18318           28 :                       && c_omp_predefined_variable (t))
   18319              :                     /* The __func__ variable and similar function-local
   18320              :                        predefined variables may be listed in a shared or
   18321              :                        firstprivate clause.  */
   18322              :                     break;
   18323              :                   share_name = "shared";
   18324              :                   break;
   18325              :                 case OMP_CLAUSE_DEFAULT_PRIVATE:
   18326              :                   share_name = "private";
   18327              :                   break;
   18328            0 :                 default:
   18329            0 :                   gcc_unreachable ();
   18330              :                 }
   18331              :               if (share_name)
   18332              :                 {
   18333           20 :                   error_at (OMP_CLAUSE_LOCATION (c),
   18334              :                             "%qE is predetermined %qs for %qs",
   18335              :                             t, share_name,
   18336           10 :                             omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   18337           10 :                   remove = true;
   18338              :                 }
   18339         9542 :               else if (TREE_READONLY (t)
   18340           23 :                        && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_SHARED
   18341         9555 :                        && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_FIRSTPRIVATE)
   18342              :                 {
   18343            4 :                   error_at (OMP_CLAUSE_LOCATION (c),
   18344              :                             "%<const%> qualified %qE may appear only in "
   18345              :                             "%<shared%> or %<firstprivate%> clauses", t);
   18346            4 :                   remove = true;
   18347              :                 }
   18348              :             }
   18349              :         }
   18350              : 
   18351        22367 :       if (remove)
   18352              :         {
   18353          575 :           if (grp_start_p)
   18354              :             {
   18355              :               /* If we found a clause to remove, we want to remove the whole
   18356              :                  expanded group, otherwise gimplify
   18357              :                  (omp_resolve_clause_dependencies) can get confused.  */
   18358          153 :               *grp_start_p = grp_sentinel;
   18359          153 :               pc = grp_start_p;
   18360          153 :               grp_start_p = NULL;
   18361              :             }
   18362              :           else
   18363          422 :             *pc = OMP_CLAUSE_CHAIN (c);
   18364              :         }
   18365              :       else
   18366        22346 :         pc = &OMP_CLAUSE_CHAIN (c);
   18367              :     }
   18368              : 
   18369        29545 :   if (grp_start_p
   18370        29545 :       && OMP_CLAUSE_HAS_ITERATORS (*grp_start_p))
   18371           52 :     for (tree gc = *grp_start_p; gc; gc = OMP_CLAUSE_CHAIN (gc))
   18372           32 :       OMP_CLAUSE_ITERATORS (gc) = OMP_CLAUSE_ITERATORS (*grp_start_p);
   18373              : 
   18374        29545 :   if (simdlen
   18375        29545 :       && safelen
   18376        29662 :       && tree_int_cst_lt (OMP_CLAUSE_SAFELEN_EXPR (safelen),
   18377          117 :                           OMP_CLAUSE_SIMDLEN_EXPR (simdlen)))
   18378              :     {
   18379            0 :       error_at (OMP_CLAUSE_LOCATION (simdlen),
   18380              :                 "%<simdlen%> clause value is bigger than "
   18381              :                 "%<safelen%> clause value");
   18382            0 :       OMP_CLAUSE_SIMDLEN_EXPR (simdlen)
   18383            0 :         = OMP_CLAUSE_SAFELEN_EXPR (safelen);
   18384              :     }
   18385              : 
   18386        29545 :   if (ordered_clause
   18387        29545 :       && schedule_clause
   18388        29545 :       && (OMP_CLAUSE_SCHEDULE_KIND (schedule_clause)
   18389              :           & OMP_CLAUSE_SCHEDULE_NONMONOTONIC))
   18390              :     {
   18391            7 :       error_at (OMP_CLAUSE_LOCATION (schedule_clause),
   18392              :                 "%<nonmonotonic%> schedule modifier specified together "
   18393              :                 "with %<ordered%> clause");
   18394           14 :       OMP_CLAUSE_SCHEDULE_KIND (schedule_clause)
   18395            7 :         = (enum omp_clause_schedule_kind)
   18396            7 :           (OMP_CLAUSE_SCHEDULE_KIND (schedule_clause)
   18397              :            & ~OMP_CLAUSE_SCHEDULE_NONMONOTONIC);
   18398              :     }
   18399              : 
   18400        29545 :   if (reduction_seen < 0 && ordered_clause)
   18401              :     {
   18402            2 :       error_at (OMP_CLAUSE_LOCATION (ordered_clause),
   18403              :                 "%qs clause specified together with %<inscan%> "
   18404              :                 "%<reduction%> clause", "ordered");
   18405            2 :       reduction_seen = -2;
   18406              :     }
   18407              : 
   18408        29545 :   if (reduction_seen < 0 && schedule_clause)
   18409              :     {
   18410            3 :       error_at (OMP_CLAUSE_LOCATION (schedule_clause),
   18411              :                 "%qs clause specified together with %<inscan%> "
   18412              :                 "%<reduction%> clause", "schedule");
   18413            3 :       reduction_seen = -2;
   18414              :     }
   18415              : 
   18416        29545 :   if (linear_variable_step_check
   18417        29545 :       || reduction_seen == -2
   18418              :       || allocate_seen
   18419        29533 :       || target_in_reduction_seen)
   18420         5190 :     for (pc = &clauses, c = clauses; c ; c = *pc)
   18421              :       {
   18422         4589 :         bool remove = false;
   18423         4589 :         if (allocate_seen)
   18424         4431 :           switch (OMP_CLAUSE_CODE (c))
   18425              :             {
   18426          430 :             case OMP_CLAUSE_REDUCTION:
   18427          430 :             case OMP_CLAUSE_IN_REDUCTION:
   18428          430 :             case OMP_CLAUSE_TASK_REDUCTION:
   18429          430 :               if (TREE_CODE (OMP_CLAUSE_DECL (c)) == MEM_REF)
   18430              :                 {
   18431           23 :                   t = TREE_OPERAND (OMP_CLAUSE_DECL (c), 0);
   18432           23 :                   if (TREE_CODE (t) == POINTER_PLUS_EXPR)
   18433            0 :                     t = TREE_OPERAND (t, 0);
   18434           23 :                   if (TREE_CODE (t) == ADDR_EXPR
   18435           10 :                       || INDIRECT_REF_P (t))
   18436           13 :                     t = TREE_OPERAND (t, 0);
   18437           23 :                   if (DECL_P (t))
   18438           23 :                     bitmap_clear_bit (&aligned_head, DECL_UID (t));
   18439              :                   break;
   18440              :                 }
   18441              :               /* FALLTHRU */
   18442         1318 :             case OMP_CLAUSE_PRIVATE:
   18443         1318 :             case OMP_CLAUSE_FIRSTPRIVATE:
   18444         1318 :             case OMP_CLAUSE_LASTPRIVATE:
   18445         1318 :             case OMP_CLAUSE_LINEAR:
   18446         1318 :               if (DECL_P (OMP_CLAUSE_DECL (c)))
   18447         2636 :                 bitmap_clear_bit (&aligned_head,
   18448         1318 :                                   DECL_UID (OMP_CLAUSE_DECL (c)));
   18449              :               break;
   18450              :             default:
   18451              :               break;
   18452              :             }
   18453         4589 :         if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_LINEAR
   18454           29 :             && OMP_CLAUSE_LINEAR_VARIABLE_STRIDE (c)
   18455         4596 :             && !bitmap_bit_p (&map_head,
   18456            7 :                               DECL_UID (OMP_CLAUSE_LINEAR_STEP (c))))
   18457              :           {
   18458            2 :             error_at (OMP_CLAUSE_LOCATION (c),
   18459              :                       "%<linear%> clause step is a parameter %qD not "
   18460              :                       "specified in %<uniform%> clause",
   18461            2 :                       OMP_CLAUSE_LINEAR_STEP (c));
   18462            2 :             remove = true;
   18463              :           }
   18464         4587 :         else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION
   18465         4587 :                  && reduction_seen == -2)
   18466            9 :           OMP_CLAUSE_REDUCTION_INSCAN (c) = 0;
   18467         4589 :         if (target_in_reduction_seen
   18468         4589 :             && OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP)
   18469              :           {
   18470          256 :             tree t = OMP_CLAUSE_DECL (c);
   18471          256 :             while (handled_component_p (t)
   18472              :                    || INDIRECT_REF_P (t)
   18473              :                    || TREE_CODE (t) == ADDR_EXPR
   18474              :                    || TREE_CODE (t) == MEM_REF
   18475          288 :                    || TREE_CODE (t) == NON_LVALUE_EXPR)
   18476           32 :               t = TREE_OPERAND (t, 0);
   18477          256 :             if (DECL_P (t)
   18478          256 :                 && bitmap_bit_p (&oacc_reduction_head, DECL_UID (t)))
   18479          138 :               OMP_CLAUSE_MAP_IN_REDUCTION (c) = 1;
   18480              :           }
   18481              : 
   18482         4589 :         if (remove)
   18483            2 :           *pc = OMP_CLAUSE_CHAIN (c);
   18484              :         else
   18485         4587 :           pc = &OMP_CLAUSE_CHAIN (c);
   18486              :       }
   18487              : 
   18488          601 :   if (allocate_seen)
   18489         5006 :     for (pc = &clauses, c = clauses; c ; c = *pc)
   18490              :       {
   18491         4431 :         bool remove = false;
   18492         4431 :         if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_ALLOCATE
   18493          720 :             && !OMP_CLAUSE_ALLOCATE_COMBINED (c)
   18494         5131 :             && bitmap_bit_p (&aligned_head, DECL_UID (OMP_CLAUSE_DECL (c))))
   18495              :           {
   18496            3 :             error_at (OMP_CLAUSE_LOCATION (c),
   18497              :                       "%qD specified in %<allocate%> clause but not in "
   18498            3 :                       "an explicit privatization clause", OMP_CLAUSE_DECL (c));
   18499            3 :             remove = true;
   18500              :           }
   18501         4431 :         if (remove)
   18502            3 :           *pc = OMP_CLAUSE_CHAIN (c);
   18503              :         else
   18504         4428 :           pc = &OMP_CLAUSE_CHAIN (c);
   18505              :       }
   18506              : 
   18507        29545 :   if (nogroup_seen && reduction_seen)
   18508              :     {
   18509            1 :       error_at (OMP_CLAUSE_LOCATION (*nogroup_seen),
   18510              :                 "%<nogroup%> clause must not be used together with "
   18511              :                 "%<reduction%> clause");
   18512            1 :       *nogroup_seen = OMP_CLAUSE_CHAIN (*nogroup_seen);
   18513              :     }
   18514              : 
   18515        29545 :   if (grainsize_seen && num_tasks_seen)
   18516              :     {
   18517            2 :       error_at (OMP_CLAUSE_LOCATION (*grainsize_seen),
   18518              :                 "%<grainsize%> clause must not be used together with "
   18519              :                 "%<num_tasks%> clause");
   18520            2 :       *grainsize_seen = OMP_CLAUSE_CHAIN (*grainsize_seen);
   18521              :     }
   18522              : 
   18523        29545 :   if (full_seen && partial_seen)
   18524              :     {
   18525            4 :       error_at (OMP_CLAUSE_LOCATION (*full_seen),
   18526              :                 "%<full%> clause must not be used together with "
   18527              :                 "%<partial%> clause");
   18528            4 :       *full_seen = OMP_CLAUSE_CHAIN (*full_seen);
   18529              :     }
   18530              : 
   18531        29545 :   if (detach_seen)
   18532              :     {
   18533           31 :       if (mergeable_seen)
   18534              :         {
   18535            2 :           error_at (OMP_CLAUSE_LOCATION (*detach_seen),
   18536              :                     "%<detach%> clause must not be used together with "
   18537              :                     "%<mergeable%> clause");
   18538            2 :           *detach_seen = OMP_CLAUSE_CHAIN (*detach_seen);
   18539              :         }
   18540              :       else
   18541              :         {
   18542           29 :           tree detach_decl = OMP_CLAUSE_DECL (*detach_seen);
   18543              : 
   18544           79 :           for (pc = &clauses, c = clauses; c ; c = *pc)
   18545              :             {
   18546           50 :               bool remove = false;
   18547           50 :               if ((OMP_CLAUSE_CODE (c) == OMP_CLAUSE_SHARED
   18548           48 :                    || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_PRIVATE
   18549           48 :                    || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_FIRSTPRIVATE
   18550           44 :                    || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_LASTPRIVATE)
   18551           54 :                   && OMP_CLAUSE_DECL (c) == detach_decl)
   18552              :                 {
   18553            2 :                   error_at (OMP_CLAUSE_LOCATION (c),
   18554              :                             "the event handle of a %<detach%> clause "
   18555              :                             "should not be in a data-sharing clause");
   18556            2 :                   remove = true;
   18557              :                 }
   18558           50 :               if (remove)
   18559            2 :                 *pc = OMP_CLAUSE_CHAIN (c);
   18560              :               else
   18561           48 :                 pc = &OMP_CLAUSE_CHAIN (c);
   18562              :             }
   18563              :         }
   18564              :     }
   18565              : 
   18566        29545 :   if (ort == C_ORT_OMP_INTEROP
   18567        29545 :       && depend_clause
   18568           21 :       && (!init_use_destroy_seen
   18569           20 :           || (init_seen && init_no_targetsync_clause)))
   18570              :     {
   18571            3 :       error_at (OMP_CLAUSE_LOCATION (depend_clause),
   18572              :                 "%<depend%> clause requires action clauses with "
   18573              :                 "%<targetsync%> interop-type");
   18574            3 :       if (init_no_targetsync_clause)
   18575            2 :         inform (OMP_CLAUSE_LOCATION (init_no_targetsync_clause),
   18576              :                 "%<init%> clause lacks the %<targetsync%> modifier");
   18577              :     }
   18578              : 
   18579        29545 :   bitmap_obstack_release (NULL);
   18580        29545 :   return clauses;
   18581              : }
   18582              : 
   18583              : /* Do processing necessary to make CLAUSES well-formed, where CLAUSES result
   18584              :    from implicit instantiation of user-defined mappers (in gimplify.cc).  */
   18585              : 
   18586              : tree
   18587           15 : c_omp_finish_mapper_clauses (tree clauses)
   18588              : {
   18589           15 :   return c_finish_omp_clauses (clauses, C_ORT_OMP);
   18590              : }
   18591              : 
   18592              : /* Return code to initialize DST with a copy constructor from SRC.
   18593              :    C doesn't have copy constructors nor assignment operators, only for
   18594              :    _Atomic vars we need to perform __atomic_load from src into a temporary
   18595              :    followed by __atomic_store of the temporary to dst.  */
   18596              : 
   18597              : tree
   18598        18735 : c_omp_clause_copy_ctor (tree clause, tree dst, tree src)
   18599              : {
   18600        18735 :   if (!really_atomic_lvalue (dst) && !really_atomic_lvalue (src))
   18601        18731 :     return build2 (MODIFY_EXPR, TREE_TYPE (dst), dst, src);
   18602              : 
   18603            4 :   location_t loc = OMP_CLAUSE_LOCATION (clause);
   18604            4 :   tree type = TREE_TYPE (dst);
   18605            4 :   tree nonatomic_type = build_qualified_type (type, TYPE_UNQUALIFIED);
   18606            4 :   tree tmp = create_tmp_var (nonatomic_type);
   18607            4 :   tree tmp_addr = build_fold_addr_expr (tmp);
   18608            4 :   TREE_ADDRESSABLE (tmp) = 1;
   18609            4 :   suppress_warning (tmp);
   18610            4 :   tree src_addr = build_fold_addr_expr (src);
   18611            4 :   tree dst_addr = build_fold_addr_expr (dst);
   18612            4 :   tree seq_cst = build_int_cst (integer_type_node, MEMMODEL_SEQ_CST);
   18613            4 :   vec<tree, va_gc> *params;
   18614              :   /* Expansion of a generic atomic load may require an addition
   18615              :      element, so allocate enough to prevent a resize.  */
   18616            4 :   vec_alloc (params, 4);
   18617              : 
   18618              :   /* Build __atomic_load (&src, &tmp, SEQ_CST);  */
   18619            4 :   tree fndecl = builtin_decl_explicit (BUILT_IN_ATOMIC_LOAD);
   18620            4 :   params->quick_push (src_addr);
   18621            4 :   params->quick_push (tmp_addr);
   18622            4 :   params->quick_push (seq_cst);
   18623            4 :   tree load = c_build_function_call_vec (loc, vNULL, fndecl, params, NULL);
   18624              : 
   18625            4 :   vec_alloc (params, 4);
   18626              : 
   18627              :   /* Build __atomic_store (&dst, &tmp, SEQ_CST);  */
   18628            4 :   fndecl = builtin_decl_explicit (BUILT_IN_ATOMIC_STORE);
   18629            4 :   params->quick_push (dst_addr);
   18630            4 :   params->quick_push (tmp_addr);
   18631            4 :   params->quick_push (seq_cst);
   18632            4 :   tree store = c_build_function_call_vec (loc, vNULL, fndecl, params, NULL);
   18633            4 :   return build2 (COMPOUND_EXPR, void_type_node, load, store);
   18634              : }
   18635              : 
   18636              : /* Create a transaction node.  */
   18637              : 
   18638              : tree
   18639          135 : c_finish_transaction (location_t loc, tree block, int flags)
   18640              : {
   18641          135 :   tree stmt = build_stmt (loc, TRANSACTION_EXPR, block);
   18642          135 :   if (flags & TM_STMT_ATTR_OUTER)
   18643           10 :     TRANSACTION_EXPR_OUTER (stmt) = 1;
   18644          135 :   if (flags & TM_STMT_ATTR_RELAXED)
   18645           31 :     TRANSACTION_EXPR_RELAXED (stmt) = 1;
   18646          135 :   return add_stmt (stmt);
   18647              : }
   18648              : 
   18649              : /* Make a variant type in the proper way for C/C++, propagating qualifiers
   18650              :    down to the element type of an array.  If ORIG_QUAL_TYPE is not
   18651              :    NULL, then it should be used as the qualified type
   18652              :    ORIG_QUAL_INDIRECT levels down in array type derivation (to
   18653              :    preserve information about the typedef name from which an array
   18654              :    type was derived).  */
   18655              : 
   18656              : tree
   18657     74694275 : c_build_qualified_type (tree type, int type_quals, tree orig_qual_type,
   18658              :                         size_t orig_qual_indirect)
   18659              : {
   18660     74694275 :   if (type == error_mark_node)
   18661              :     return type;
   18662              : 
   18663     74694123 :   if (TREE_CODE (type) == ARRAY_TYPE)
   18664              :     {
   18665      3147816 :       tree t;
   18666      3147816 :       tree element_type = c_build_qualified_type (TREE_TYPE (type),
   18667              :                                                   type_quals, orig_qual_type,
   18668              :                                                   orig_qual_indirect - 1);
   18669              : 
   18670              :       /* See if we already have an identically qualified type.  */
   18671      3147816 :       if (orig_qual_type && orig_qual_indirect == 0)
   18672              :         t = orig_qual_type;
   18673              :       else
   18674      4590640 :         for (t = TYPE_MAIN_VARIANT (type); t; t = TYPE_NEXT_VARIANT (t))
   18675              :           {
   18676      4450967 :             if (TYPE_QUALS (strip_array_types (t)) == type_quals
   18677      3029043 :                 && TYPE_NAME (t) == TYPE_NAME (type)
   18678      3008102 :                 && TYPE_CONTEXT (t) == TYPE_CONTEXT (type)
   18679      7459069 :                 && attribute_list_equal (TYPE_ATTRIBUTES (t),
   18680      3008102 :                                          TYPE_ATTRIBUTES (type)))
   18681              :               break;
   18682              :           }
   18683      3147775 :       if (!t)
   18684              :         {
   18685       139673 :           tree domain = TYPE_DOMAIN (type);
   18686              : 
   18687       139673 :           t = build_variant_type_copy (type);
   18688       139673 :           TREE_TYPE (t) = element_type;
   18689       139673 :           TYPE_ADDR_SPACE (t) = TYPE_ADDR_SPACE (element_type);
   18690              : 
   18691       139673 :           if (TYPE_STRUCTURAL_EQUALITY_P (element_type)
   18692       139673 :               || (domain && TYPE_STRUCTURAL_EQUALITY_P (domain)))
   18693          196 :             SET_TYPE_STRUCTURAL_EQUALITY (t);
   18694       139477 :           else if (TYPE_CANONICAL (element_type) != element_type
   18695       139477 :                    || (domain && TYPE_CANONICAL (domain) != domain))
   18696              :             {
   18697         2752 :               tree unqualified_canon
   18698         5278 :                 = c_build_array_type (TYPE_CANONICAL (element_type),
   18699         2526 :                                       domain ? TYPE_CANONICAL (domain)
   18700              :                                              : NULL_TREE);
   18701         2752 :               if (TYPE_REVERSE_STORAGE_ORDER (type))
   18702              :                 {
   18703            0 :                   unqualified_canon
   18704            0 :                     = build_distinct_type_copy (unqualified_canon);
   18705            0 :                   TYPE_REVERSE_STORAGE_ORDER (unqualified_canon) = 1;
   18706              :                 }
   18707         2752 :               TYPE_CANONICAL (t)
   18708         5504 :                 = c_build_qualified_type (unqualified_canon, type_quals);
   18709              :             }
   18710              :           else
   18711       136725 :             TYPE_CANONICAL (t) = t;
   18712              :         }
   18713      3147816 :       return t;
   18714              :     }
   18715              : 
   18716              :   /* A restrict-qualified pointer type must be a pointer to object or
   18717              :      incomplete type.  Note that the use of POINTER_TYPE_P also allows
   18718              :      REFERENCE_TYPEs, which is appropriate for C++.  */
   18719     71546307 :   if ((type_quals & TYPE_QUAL_RESTRICT)
   18720     71546307 :       && (!POINTER_TYPE_P (type)
   18721      3400712 :           || !C_TYPE_OBJECT_OR_INCOMPLETE_P (TREE_TYPE (type))))
   18722              :     {
   18723            3 :       error ("invalid use of %<restrict%>");
   18724            3 :       type_quals &= ~TYPE_QUAL_RESTRICT;
   18725              :     }
   18726              : 
   18727     71546307 :   tree var_type = (orig_qual_type && orig_qual_indirect == 0
   18728     71546307 :                    ? orig_qual_type
   18729     71546276 :                    : build_qualified_type (type, type_quals));
   18730              : 
   18731     71546307 :   gcc_checking_assert (C_TYPE_VARIABLE_SIZE (var_type)
   18732              :                        == C_TYPE_VARIABLE_SIZE (type));
   18733     71546307 :   gcc_checking_assert (c_type_variably_modified_p (var_type)
   18734              :                        == c_type_variably_modified_p (type));
   18735              : 
   18736              :   /* A variant type does not inherit the list of incomplete vars from the
   18737              :      type main variant.  */
   18738     71546307 :   if ((RECORD_OR_UNION_TYPE_P (var_type)
   18739     69626950 :        || TREE_CODE (var_type) == ENUMERAL_TYPE)
   18740     71651444 :       && TYPE_MAIN_VARIANT (var_type) != var_type)
   18741      1408681 :     C_TYPE_INCOMPLETE_VARS (var_type) = 0;
   18742              :   return var_type;
   18743              : }
   18744              : 
   18745              : /* Build a VA_ARG_EXPR for the C parser.  */
   18746              : 
   18747              : tree
   18748        19914 : c_build_va_arg (location_t loc1, tree expr, location_t loc2, tree type,
   18749              :                 tree type_expr)
   18750              : {
   18751        19914 :   if (error_operand_p (type))
   18752            2 :     return error_mark_node;
   18753              :   /* VA_ARG_EXPR cannot be used for a scalar va_list with reverse storage
   18754              :      order because it takes the address of the expression.  */
   18755        19912 :   else if (handled_component_p (expr)
   18756           31 :            && reverse_storage_order_for_component_p (expr))
   18757              :     {
   18758            0 :       error_at (loc1, "cannot use %<va_arg%> with reverse storage order");
   18759            0 :       return error_mark_node;
   18760              :     }
   18761        19912 :   else if (!COMPLETE_TYPE_P (type))
   18762              :     {
   18763           11 :       error_at (loc2, "second argument to %<va_arg%> is of incomplete "
   18764              :                 "type %qT", type);
   18765           11 :       return error_mark_node;
   18766              :     }
   18767        19901 :   else if (TREE_CODE (type) == FUNCTION_TYPE)
   18768              :     {
   18769            1 :       error_at (loc2, "second argument to %<va_arg%> is a function type %qT",
   18770              :                 type);
   18771            1 :       return error_mark_node;
   18772              :     }
   18773            6 :   else if (TREE_CODE (type) == ARRAY_TYPE && C_TYPE_VARIABLE_SIZE (type)
   18774        19903 :            && !flag_isoc99)
   18775              :     {
   18776            1 :       error_at (loc2, "second argument to %<va_arg%> is an array type %qT",
   18777              :                 type);
   18778            1 :       return error_mark_node;
   18779              :     }
   18780        19899 :   else if (warn_cxx_compat && TREE_CODE (type) == ENUMERAL_TYPE)
   18781            1 :     warning_at (loc2, OPT_Wc___compat,
   18782              :                 "C++ requires promoted type, not enum type, in %<va_arg%>");
   18783              : 
   18784        19899 :   if (flag_isoc99 && TREE_CODE (type) == ARRAY_TYPE)
   18785              :     {
   18786            3 :       warning_at (loc2, 0, "second argument to %<va_arg%> is an array type %qT",
   18787              :                   type);
   18788              :       /* We create a trap but evaluate side effects first.  */
   18789            3 :       tree trapfn = builtin_decl_explicit (BUILT_IN_TRAP);
   18790            3 :       trapfn = build_call_expr_loc (loc2, trapfn, 0);
   18791            3 :       tree e2 = build2 (COMPOUND_EXPR, void_type_node, expr, trapfn);
   18792              :       /* Return a compound literal of the right type.  */
   18793            3 :       tree e1 = build_compound_literal (loc2, type, NULL, true, 0, NULL);
   18794            3 :       expr = build2 (COMPOUND_EXPR, type, e2, e1);
   18795            3 :     }
   18796              :   else
   18797        19896 :     expr = build_va_arg (loc2, expr, type);
   18798              : 
   18799        19899 :   if (type_expr)
   18800           26 :     expr = build2 (COMPOUND_EXPR, TREE_TYPE (expr), type_expr, expr);
   18801              : 
   18802              :   return expr;
   18803              : }
   18804              : 
   18805              : /* Return truthvalue of whether T1 is the same tree structure as T2.
   18806              :    Return 1 if they are the same. Return false if they are different.  */
   18807              : 
   18808              : bool
   18809         1854 : c_tree_equal (tree t1, tree t2)
   18810              : {
   18811         1883 :   enum tree_code code1, code2;
   18812              : 
   18813         1883 :   if (t1 == t2)
   18814              :     return true;
   18815          661 :   if (!t1 || !t2)
   18816              :     return false;
   18817              : 
   18818          681 :   for (code1 = TREE_CODE (t1); code1 == NON_LVALUE_EXPR;
   18819           20 :        code1 = TREE_CODE (t1))
   18820           20 :     t1 = TREE_OPERAND (t1, 0);
   18821          682 :   for (code2 = TREE_CODE (t2); code2 == NON_LVALUE_EXPR;
   18822           21 :        code2 = TREE_CODE (t2))
   18823           21 :     t2 = TREE_OPERAND (t2, 0);
   18824              : 
   18825              :   /* They might have become equal now.  */
   18826          661 :   if (t1 == t2)
   18827              :     return true;
   18828              : 
   18829          640 :   if (code1 != code2)
   18830              :     return false;
   18831              : 
   18832          379 :   if (CONSTANT_CLASS_P (t1) && !comptypes (TREE_TYPE (t1), TREE_TYPE (t2)))
   18833              :     return false;
   18834              : 
   18835          379 :   switch (code1)
   18836              :     {
   18837            2 :     case INTEGER_CST:
   18838            2 :       return wi::to_wide (t1) == wi::to_wide (t2);
   18839              : 
   18840           10 :     case REAL_CST:
   18841           10 :       return real_equal (&TREE_REAL_CST (t1), &TREE_REAL_CST (t2));
   18842              : 
   18843            0 :     case STRING_CST:
   18844            0 :       return TREE_STRING_LENGTH (t1) == TREE_STRING_LENGTH (t2)
   18845            0 :         && !memcmp (TREE_STRING_POINTER (t1), TREE_STRING_POINTER (t2),
   18846            0 :                     TREE_STRING_LENGTH (t1));
   18847              : 
   18848            0 :     case FIXED_CST:
   18849            0 :       return FIXED_VALUES_IDENTICAL (TREE_FIXED_CST (t1),
   18850              :                                      TREE_FIXED_CST (t2));
   18851              : 
   18852            0 :     case COMPLEX_CST:
   18853            0 :       return c_tree_equal (TREE_REALPART (t1), TREE_REALPART (t2))
   18854            0 :              && c_tree_equal (TREE_IMAGPART (t1), TREE_IMAGPART (t2));
   18855              : 
   18856            0 :     case VECTOR_CST:
   18857            0 :       return operand_equal_p (t1, t2, OEP_ONLY_CONST);
   18858              : 
   18859            0 :     case CONSTRUCTOR:
   18860              :       /* We need to do this when determining whether or not two
   18861              :          non-type pointer to member function template arguments
   18862              :          are the same.  */
   18863            0 :       if (!comptypes (TREE_TYPE (t1), TREE_TYPE (t2))
   18864            0 :           || CONSTRUCTOR_NELTS (t1) != CONSTRUCTOR_NELTS (t2))
   18865              :         return false;
   18866              :       {
   18867              :         tree field, value;
   18868              :         unsigned int i;
   18869            0 :         FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (t1), i, field, value)
   18870              :           {
   18871            0 :             constructor_elt *elt2 = CONSTRUCTOR_ELT (t2, i);
   18872            0 :             if (!c_tree_equal (field, elt2->index)
   18873            0 :                 || !c_tree_equal (value, elt2->value))
   18874            0 :               return false;
   18875              :           }
   18876              :       }
   18877              :       return true;
   18878              : 
   18879            0 :     case TREE_LIST:
   18880            0 :       if (!c_tree_equal (TREE_PURPOSE (t1), TREE_PURPOSE (t2)))
   18881              :         return false;
   18882            0 :       if (!c_tree_equal (TREE_VALUE (t1), TREE_VALUE (t2)))
   18883              :         return false;
   18884            0 :       return c_tree_equal (TREE_CHAIN (t1), TREE_CHAIN (t2));
   18885              : 
   18886            0 :     case SAVE_EXPR:
   18887            0 :       return c_tree_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0));
   18888              : 
   18889           25 :     case CALL_EXPR:
   18890           25 :       {
   18891           25 :         tree arg1, arg2;
   18892           25 :         call_expr_arg_iterator iter1, iter2;
   18893           25 :         if (!c_tree_equal (CALL_EXPR_FN (t1), CALL_EXPR_FN (t2)))
   18894              :           return false;
   18895           50 :         for (arg1 = first_call_expr_arg (t1, &iter1),
   18896           25 :                arg2 = first_call_expr_arg (t2, &iter2);
   18897           25 :              arg1 && arg2;
   18898            0 :              arg1 = next_call_expr_arg (&iter1),
   18899            0 :                arg2 = next_call_expr_arg (&iter2))
   18900            0 :           if (!c_tree_equal (arg1, arg2))
   18901              :             return false;
   18902           25 :         if (arg1 || arg2)
   18903              :           return false;
   18904              :         return true;
   18905              :       }
   18906              : 
   18907            0 :     case TARGET_EXPR:
   18908            0 :       {
   18909            0 :         tree o1 = TREE_OPERAND (t1, 0);
   18910            0 :         tree o2 = TREE_OPERAND (t2, 0);
   18911              : 
   18912              :         /* Special case: if either target is an unallocated VAR_DECL,
   18913              :            it means that it's going to be unified with whatever the
   18914              :            TARGET_EXPR is really supposed to initialize, so treat it
   18915              :            as being equivalent to anything.  */
   18916            0 :         if (VAR_P (o1) && DECL_NAME (o1) == NULL_TREE
   18917            0 :             && !DECL_RTL_SET_P (o1))
   18918              :           /*Nop*/;
   18919            0 :         else if (VAR_P (o2) && DECL_NAME (o2) == NULL_TREE
   18920            0 :                  && !DECL_RTL_SET_P (o2))
   18921              :           /*Nop*/;
   18922            0 :         else if (!c_tree_equal (o1, o2))
   18923              :           return false;
   18924              : 
   18925            0 :         return c_tree_equal (TREE_OPERAND (t1, 1), TREE_OPERAND (t2, 1));
   18926              :       }
   18927              : 
   18928           29 :     case COMPONENT_REF:
   18929           29 :       if (TREE_OPERAND (t1, 1) != TREE_OPERAND (t2, 1))
   18930              :         return false;
   18931           29 :       return c_tree_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0));
   18932              : 
   18933              :     case PARM_DECL:
   18934              :     case VAR_DECL:
   18935              :     case CONST_DECL:
   18936              :     case FIELD_DECL:
   18937              :     case FUNCTION_DECL:
   18938              :     case IDENTIFIER_NODE:
   18939              :     case SSA_NAME:
   18940              :       return false;
   18941              : 
   18942            0 :     case TREE_VEC:
   18943            0 :       {
   18944            0 :         unsigned ix;
   18945            0 :         if (TREE_VEC_LENGTH (t1) != TREE_VEC_LENGTH (t2))
   18946              :           return false;
   18947            0 :         for (ix = TREE_VEC_LENGTH (t1); ix--;)
   18948            0 :           if (!c_tree_equal (TREE_VEC_ELT (t1, ix),
   18949            0 :                              TREE_VEC_ELT (t2, ix)))
   18950              :             return false;
   18951              :         return true;
   18952              :       }
   18953              : 
   18954           22 :     CASE_CONVERT:
   18955           22 :       if (!comptypes (TREE_TYPE (t1), TREE_TYPE (t2)))
   18956              :         return false;
   18957              :       break;
   18958              : 
   18959              :     default:
   18960              :       break;
   18961              :     }
   18962              : 
   18963          131 :   switch (TREE_CODE_CLASS (code1))
   18964              :     {
   18965          131 :     case tcc_unary:
   18966          131 :     case tcc_binary:
   18967          131 :     case tcc_comparison:
   18968          131 :     case tcc_expression:
   18969          131 :     case tcc_vl_exp:
   18970          131 :     case tcc_reference:
   18971          131 :     case tcc_statement:
   18972          131 :       {
   18973          131 :         int i, n = TREE_OPERAND_LENGTH (t1);
   18974              : 
   18975          131 :         switch (code1)
   18976              :           {
   18977            0 :           case PREINCREMENT_EXPR:
   18978            0 :           case PREDECREMENT_EXPR:
   18979            0 :           case POSTINCREMENT_EXPR:
   18980            0 :           case POSTDECREMENT_EXPR:
   18981            0 :             n = 1;
   18982            0 :             break;
   18983           16 :           case ARRAY_REF:
   18984           16 :             n = 2;
   18985           16 :             break;
   18986              :           default:
   18987              :             break;
   18988              :           }
   18989              : 
   18990          131 :         if (TREE_CODE_CLASS (code1) == tcc_vl_exp
   18991          131 :             && n != TREE_OPERAND_LENGTH (t2))
   18992              :           return false;
   18993              : 
   18994          305 :         for (i = 0; i < n; ++i)
   18995          186 :           if (!c_tree_equal (TREE_OPERAND (t1, i), TREE_OPERAND (t2, i)))
   18996              :             return false;
   18997              : 
   18998              :         return true;
   18999              :       }
   19000              : 
   19001            0 :     case tcc_type:
   19002            0 :       return comptypes (t1, t2);
   19003            0 :     default:
   19004            0 :       gcc_unreachable ();
   19005              :     }
   19006              : }
   19007              : 
   19008              : /* Returns true when the function declaration FNDECL is implicit,
   19009              :    introduced as a result of a call to an otherwise undeclared
   19010              :    function, and false otherwise.  */
   19011              : 
   19012              : bool
   19013         2013 : c_decl_implicit (const_tree fndecl)
   19014              : {
   19015         2013 :   return C_DECL_IMPLICIT (fndecl);
   19016              : }
        

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